// JavaScript Document var is_mobile = (('ontouchstart' in document.documentElement) || (parseInt(navigator.msMaxTouchPoints) > 0)); jQuery(document).ready(function(){ /* setupFormField("#SearchForm_SearchFor", "Search"); jQuery('#SearchForm_SearchForm').submit(function(){ if( !validateFormField("#SearchForm_SearchFor", "Search", "Please specify your search terms") ) return false; return true; }); */ fixHeights({selector:'.internal #page_right', method:'parent'}); fixHeights({selector:'.sameheight', method:'match'}); // alert(is_mobile); if (!is_mobile) { skrollr.init({ forceHeight: 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"); }); }); // 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(name, value) { jQuery(name).val(value); jQuery(name).blur(function(){ if( jQuery(name).val() == "" ) { jQuery(name).val(value); } }); jQuery(name).focus(function(){ if( jQuery(name).val() == value ) { jQuery(name).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; }