// DOCUMENT READY FUNCTION: uses noConflict to work with other libraries (function($) { jQuery.fn.autogrow = function() { return this.each(function() { var textarea = this; jQuery.fn.autogrow.resize(textarea); jQuery(textarea).focus(function() { textarea.interval = setInterval(function() { jQuery.fn.autogrow.resize(textarea); }, 500); }).blur(function() { clearInterval(textarea.interval); }); }); }; jQuery.fn.autogrow.resize = function(textarea) { var lineHeight = parseInt(jQuery(textarea).css('line-height'), 10); var lines = textarea.value.split('\n'); var columns = textarea.cols; var lineCount = 0; jQuery.each(lines, function() { lineCount += Math.ceil(this.length / columns) || 1; }); var height = lineHeight * (lineCount + 1); jQuery(textarea).css('height', height); }; })(jQuery); this.synchMsgForms = function(){ function synchFields(a,b){ jQuery(a).bind("input propertychange",function(){jQuery(b).val(jQuery(this).val())}); jQuery(b).bind("input propertychange",function(){jQuery(a).val(jQuery(this).val())}); } synchFields("#WLOmsgName","#WLOleadName"); synchFields("#WLOmsgPhone","#WLOleadPhone"); synchFields("#WLOmsgEmail","#WLOleadEmail"); synchFields("#WLOmsgSubject","#WLOleadSubject"); synchFields("#WLOmsgBody","#WLOleadBody"); synchFields("#WLOmsgCallback","#WLOleadCallback"); jQuery("#WLOmsgPrint").bind("input change",function(){jQuery("#WLOleadPrint").find(":checkbox").prop("checked", jQuery(this).find(":checkbox").prop('checked'));}); jQuery("#WLOleadPrint").bind("input change",function(){jQuery("#WLOmsgPrint").find(":checkbox").prop("checked", jQuery(this).find(":checkbox").prop('checked'));}); jQuery("#WLOmsgTransferred").bind("input change",function(){jQuery("#WLOleadTransferred").find(":checkbox").prop("checked", jQuery(this).find(":checkbox").prop('checked'));}); jQuery("#WLOleadTransferred").bind("input change",function(){jQuery("#WLOmsgTransferred").find(":checkbox").prop("checked", jQuery(this).find(":checkbox").prop('checked'));}); jQuery("#WLOmsgRecip").bind("select change",function(){jQuery("#WLOleadRecip").val(jQuery(this).val());}); jQuery("#WLOleadRecip").bind("select change",function(){jQuery("#WLOmsgRecip").val(jQuery(this).val());}); } function clearForm(form) { jQuery(':input', form).each(function() { var type = this.type; var tag = this.tagName.toLowerCase(); // normalize case var value = jQuery(this).val(); if (type == 'text' || type == 'password' || tag == 'textarea') { this.value = ""; } else if (type == 'checkbox' || type == 'radio') { if (value=="phone") {this.checked = true;}else{this.checked = false;} //checkboxes and radios must be false, but keep value } else if (tag == 'select') { this.selectedIndex = 0; //set index to 0 so it will land on the "---SELECT---" prompt option } }); }; jQuery(document).ready(function($) { clearForm('#WLOmsg');clearForm('#WLOlead'); //jQuery('.cf7-db-table').colResizable({liveDrag:true}); synchMsgForms(); $( "#WLOmsgPhone, #WLOleadPhone" ).bind( "blur", function(){jQuery("#test").html(select);}) $( "#WLOmsgPhone, #WLOleadPhone" ).bind( "keydown", function(){ if(window.getSelection){var select = window.getSelection();}else if (document.selection){select=document.selection;} if(select!=""){ jQuery(this).val().empty(); jQuery(this).val().removeAllRanges(); document.selection.empty(); } var input = jQuery(this).val(); var select = jQuery("#test").html(); str = input.split(''); for (var i = 0; i < str.length; i++) { if((i==3||i==7)&&str[i]!="-"){str[i+1]=str[i];str[i]="-";str[i+1]=str[i+1].replace(/[^0-9]/, '');if(str[i+1]!=str[i+1].match(/[0-9]/)){str.length=i+1;}} if((i>=0&&i<=2)||(i>=4&&i<=6)||(i>=8&&i<=11)){str[i]=str[i].replace(/[^0-9]/, '');if(str[i]!=str[i].match(/[0-9]/)){str[i]="";}} if(i==12&&str[i]!=" "){str.length=13;str[13]=str[i];str[i]=" ";} } jQuery(this).val(str.join("")); }); $( "#WLOmsgPhone, #WLOleadPhone" ).bind( "keyup", function(){ var input = jQuery(this).val(); str = input.split(''); for (var i = 0; i < str.length; i++) { if(i<12){ if(str[i]!=str[i].match(/[0-9|\-]/)){str[i]="";} } if(i==12&&str[i]!=" "){str.length=13;str[13]=str[i];str[i]=" ";} } jQuery(this).val(str.join("")); }); jQuery('.datepicker').datepicker(); jQuery('#intake-form').tabs(); jQuery("#intake-form" ).removeClass( "unhide-on-load" ); jQuery(".wpcf7-textarea" ).autogrow(); jQuery('#fscf_field4_3').maxlength({ events: [], // Array of events to be triggerd maxCharacters: 2055, // Characters limit status: true, // True to show status indicator bewlow the element statusClass: "status", // The class on the status div statusText: "character left", // The status text notificationClass: "notification", // Will be added when maxlength is reached showAlert: false, // True to show a regular alert message alertText: "You have typed too many characters.", // Text in alert message slider: false // True Use counter slider }); jQuery(".form-submit").bind("click",function(){jQuery("input[name='to-print[]']").each( function(){ if(jQuery(this).attr('checked')){ window.print(); } }); }); });//<--- end of the document ready function. don't delete