1jQuery(document).ready(gformInitDatepicker); 2 3function gformInitDatepicker() { 4 jQuery('.datepicker').each(function () { 5 var $element = jQuery(this); 6 gformInitSingleDatepicker( $element) ; 7 }); 8} 9 10function gformInitSingleDatepicker( $element ) { 11 var inputId = $element.attr( 'id' ) ? $element.attr( 'id' ) : '', 12 optionsObj = { 13 yearRange: '-100:+20', 14 showOn: 'focus', 15 dateFormat: 'mm/dd/yy', 16 changeMonth: true, 17 changeYear: true, 18 suppressDatePicker: false, 19 onClose: function () { 20 $element.focus(); 21 var self = this; 22 this.suppressDatePicker = true; 23 setTimeout( function() { 24 self.suppressDatePicker = false; 25 }, 200 ); 26 }, 27 beforeShow: function( input, inst ) { 28 return ! this.suppressDatePicker; 29 } 30 }; 31 32 if ($element.hasClass('dmy')) { 33 optionsObj.dateFormat = 'dd/mm/yy'; 34 } else if ($element.hasClass('dmy_dash')) { 35 optionsObj.dateFormat = 'dd-mm-yy'; 36 } else if ($element.hasClass('dmy_dot')) { 37 optionsObj.dateFormat = 'dd.mm.yy'; 38 } else if ($element.hasClass('ymd_slash')) { 39 optionsObj.dateFormat = 'yy/mm/dd'; 40 } else if ($element.hasClass('ymd_dash')) { 41 optionsObj.dateFormat = 'yy-mm-dd'; 42 } else if ($element.hasClass('ymd_dot')) { 43 optionsObj.dateFormat = 'yy.mm.dd'; 44 } 45 46 if ($element.hasClass('datepicker_with_icon')) { 47 optionsObj.showOn = 'both'; 48 optionsObj.buttonImage = $element.parent().siblings("[id^='gforms_calendar_icon_input']").val(); 49 optionsObj.buttonImageOnly = true; 50 optionsObj.buttonText = ''; 51 } 52 53 inputId = inputId.split('_'); 54 55 // allow the user to override the datepicker options object 56 optionsObj = gform.applyFilters('gform_datepicker_options_pre_init', optionsObj, inputId[1], inputId[2]); 57 58 $element.datepicker(optionsObj); 59 60 // We give the input focus after selecting a date which differs from default Datepicker behavior; this prevents 61 // users from clicking on the input again to open the datepicker. Let's add a manual click event to handle this. 62 if( $element.is( ':input' ) ) { 63 $element.click( function() { 64 $element.datepicker( 'show' ); 65 } ); 66 } 67 68}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.