1jQuery(document).ready( function() { 2 3 /* 4 * WPCF7 4.9 uses wpcf7 instead of _wpcf7 so both have to be checked. 5 * 6 * I didn't use is_plugin_active() because it fails when the plugin folder is renamed. 7 * Checking for the wpcf7 variable is reliable in more cases. 8 * Please support new variables whenever WPCF7 is updated. 9 * 10 * Don't remove the check since doing so may produce broken date fields; 11 * you'd rather skip this enhancement than end up with broken forms. 12 */ 13 var asisWpcf7 = {}; 14 if ( typeof _wpcf7 == "object" ) { 15 asisWpcf7 = _wpcf7; 16 } 17 else if ( typeof wpcf7 == "object" ) { 18 asisWpcf7 = wpcf7; 19 } 20 21 if ( !asisWpcf7.jqueryUi ) { 22 return; 23 } 24 25 /*Loop thru date fields */ 26 jQuery("input.wpcf7-date[type='date']").each( function(i,v) { 27 28 /* Destroy jQuery datepicker instance so we can re-initialize it */ 29 if( jQuery(v).hasClass("hasDatepicker") ) { 30 jQuery(v).datepicker("destroy"); 31 } 32 33 /* 34 * Convert date field to text field: 35 * - to normalize behavior and appearance. 36 * - to support the placeholder attribute 37 */ 38 jQuery(v).attr("type","text"); 39 40 /* 41 * Update placeholder 42 */ 43 if ( typeof jQuery(v).attr("placeholder") == "undefined" ) { 44 jQuery(v).attr("placeholder","yy-mm-dd"); 45 } 46 else { 47 jQuery(v).attr("placeholder", jQuery(v).attr("placeholder")); 48 } 49 50 /* Disable normal behavior */ 51 jQuery(v).on("keydown keyup",function(e) { 52 e.preventDefault(); 53 }); 54 55 /* Initialize datepicker */ 56 jQuery(v).datepicker( { 57 dateFormat: 'yy-mm-dd', 58 minDate: new Date( jQuery(v).attr("min") ), 59 maxDate: new Date( jQuery(v).attr("max") ) 60 } ); 61 62 63 /* Since we now use a text field, remove invalid attributes */ 64 jQuery(v).removeAttr("min max"); 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.