/* * Function to allow an input to act like a combobox with times in the dropdown list. */ (function( $ ) { $.widget( "ui.combobox", { _create: function() { var self = this; var amDesignator = this.options.amDesignator; var pmDesignator = this.options.pmDesignator; var timeSeparator = this.options.timeSeparator; var twentyFour = amDesignator.length==0 && pmDesignator.length==0; var data = new Array(); //Create the list of times for the dropdown list. if(twentyFour){ for (hours = 0; hours < 24; hours++){ displayHour = (hours<10)?'0'+hours:hours; data.push(displayHour + timeSeparator + '00'); data.push(displayHour + timeSeparator + '30'); } } else{ for(loop = 0; loop < 2; loop++){ designator = loop == 0 ? amDesignator : pmDesignator; for (hours = 0; hours < 12; hours++){ displayHour = hours==0?'12':hours; data.push(displayHour + timeSeparator + '00 ' + designator); data.push(displayHour + timeSeparator + '30 ' + designator); } } //Convert the parameter current value time passed in (24 hour) to region-specific time. var currentTime = this.element.val(); if(currentTime.length > 0){ var units = currentTime.split(':'); var designator = pmDesignator; var h = parseInt(units[0]); if(h < 12){ designator = amDesignator; } if(h==0){ h=12; } if(h > 12){ h = h - 12; } var newTime = h; for(unit=1; unit" ) .data( "item.autocomplete", item ) .append( "" + item.label + "" ) .appendTo( ul ); }; autocompleteInput.menu.element.addClass("sideBarScrollableMenu"); this.button = $( " " ) .insertAfter( input ) .addClass( "sideBarDateTimepickerTrigger ui-icon ui-icon-clock" ) .click(function() { // close if already visible if ( input.autocomplete( "widget" ).is( ":visible" ) ) { input.autocomplete( "close" ); return; } if(this.previousSibling.disabled){ return; } // pass empty string as value to search for, displaying all results input.autocomplete("option","disabled",false); input.autocomplete( "search", "" ); input.focus(); }); }, destroy: function() { this.button.remove(); this.element.show(); $.Widget.prototype.destroy.call( this ); } }); })( jQuery );