// JavaScript Document jQuery(document).ready(function(){ setupFormFields(".clearclick"); setupFormField("#IQTemplateForm_SubmitForm_FirstName", "First Name"); setupFormField("#IQTemplateForm_SubmitForm_LastName", "Last Name"); setupFormField("#IQTemplateForm_SubmitForm_Email", "Email"); fixHeights({selector:'.internal #page_right', method:'parent'}); fixHeights({selector:'.sameheight', method:'match'}); jQuery("a[href^=tel]").click(function(e){ if (jQuery(window).width() > 500){ e.preventDefault(); return false; } }); }); jQuery(window).load(function(){ fixHeights({selector:'.internal #page_right', method:'parent'}); fixHeights({selector:'.sameheight', method:'match'}); jQuery('.centered_ul').each(function(e){ var full_width = 0; jQuery(this).children().each(function(){full_width += jQuery(this).outerWidth(true);}); jQuery(this).css('margin-left','auto').css('margin-right','auto').css('width',full_width+"px"); }); }); function setupFormFields(selector) { jQuery(selector).each(function(){ var my_val = jQuery(this).val(); setupFormField(this, my_val); }); } // For info on how to use this function, check the wiki: http://iqwebwork.com/wiki/index.php?title=SilverStripe_Tips_%26_Tricks#Using_fixHeights.28.29_to_make_your_content_and_sidebar_the_same_height function fixHeights(params) { if(params){ var selector = params.selector; var method = params.method; switch(method) { case "parent": jQuery(selector).each(function(){ var my_padding = jQuery(this).innerHeight() - jQuery(this).height(); jQuery(this).css('min-height',(jQuery(this).parent().height())-my_padding+'px'); }); break; case "match": var max_height = []; jQuery(selector).css("height", "auto"); jQuery(selector).each(function(){ if (!max_height[jQuery(this).attr("rel")]) max_height[jQuery(this).attr("rel")] = 0; var my_height = jQuery(this).outerHeight(false); if (jQuery(this).attr("lang")) my_height += parseInt(jQuery(this).attr("lang")); max_height[jQuery(this).attr("rel")] = Math.max(max_height[jQuery(this).attr("rel")], my_height); }); jQuery(selector).each(function(){ jQuery(this).height(max_height[jQuery(this).attr("rel")] - (parseInt(jQuery(this).css("padding-top"), 10) + parseInt(jQuery(this).css("padding-bottom"), 10) + parseInt(jQuery(this).css("border-top-width"), 10) + parseInt(jQuery(this).css("border-bottom-width"), 10))); }); break; default: false; } } } function setupFormField(field, value) { jQuery(field).val(value); jQuery(field).blur(function(){ if( jQuery(this).val() == "" ) { jQuery(this).val(value); } }); jQuery(field).focus(function(){ if( jQuery(this).val() == value ) { jQuery(this).val(""); } }); } function setupImageField(name, className) { jQuery(name).addClass(className); jQuery(name).blur(function(){ if( jQuery(name).val() == "" ) { jQuery(name).addClass(className); } }); jQuery(name).focus(function(){ jQuery(name).removeClass(className); }); } function validateFormField(name, default_value, message) { if (jQuery(name).val() == "" || jQuery(name).val() == default_value) { alert(message); jQuery(name).focus(); return false; } return true; } function jScroll(anchor_name){ var aTag = jQuery("a[name='"+anchor_name+"']"); jQuery('html,body').animate({scrollTop: aTag.offset().top},'slow'); } function ajaxLoad(url, resultFunc) { jQuery.ajax({ url: url, global: false, dataType: "html", async: false, cache: false, success: function(data) { resultFunc(data); } }); return; }