1jQuery(function($){ 2 3 /** 4 * Keep all instances of .widget the same height within any instance of .equal-height-widgets whilst widow width exceeds relevant breakpoint 5 */ 6 function convertStringCamelcaseToHyphenated(stringToConvert){ 7 if(typeof stringToConvert == "string"){ 8 var i = stringToConvert.length; 9 var convertedString = []; 10 while (i--) { 11 if( stringToConvert[i] == stringToConvert[i].toUpperCase()){ 12 var character = stringToConvert[i]; 13 var characterLowered = character.toLowerCase(); 14 var convertedCharacter = '-'+characterLowered; 15 convertedString.push(convertedCharacter); 16 } else { 17 convertedString.push(stringToConvert[i]); 18 } 19 } 20 convertedString = convertedString.reverse().join(''); 21 return convertedString; 22 } else { 23 return false; 24 } 25 } 26 27 function giveBreakwidthsCssClass (){ 28 $.each(phpVars.breakpoints, function(key, value){ 29 phpVars.breakpoints[key] = {}; 30 phpVars.breakpoints[key].cssClass = 'breakpoint-'+convertStringCamelcaseToHyphenated(key); 31 phpVars.breakpoints[key].pixelValue = value; 32 }); 33 } 34 35 function getBreakpointsLessThanWindowWidth(){ 36 var windowWidth = widthWithScroll; 37 var breakpointsLessThanWindowWidth = []; 38 $.each(phpVars.breakpoints, function(key, value){ 39 if (parseInt($(this)[0].pixelValue) < windowWidth){ 40 breakpointsLessThanWindowWidth.push($(this)); 41 } 42 }); 43 return breakpointsLessThanWindowWidth; 44 } 45 46 function equalizeWidgetHeights(){ 47 var breakpointsLessThanWindowWidth = getBreakpointsLessThanWindowWidth(); 48 breakpointClassesToEqualize = []; 49 $.each(breakpointsLessThanWindowWidth, function(key, value){ 50 breakpointClassesToEqualize.push('.'+$(this)[0].cssClass); 51 }); 52 53 var $elementsThatEqualize = $('.equal-height-widgets'); 54 $elementsThatEqualize.each(function(){ 55 var $elementThatEqualizes = $(this); 56 $elementThatEqualizes.find('.widget').css("height", ''); 57 $.each(breakpointClassesToEqualize, function(key, value){ 58 if($elementThatEqualizes.find(value).length > 0){ 59 var heights = []; 60 $elementThatEqualizes.find(value).find('.widget').each(function(){ 61 heights.push($(this).outerHeight()); 62 }).css("height", parseInt(Math.max.apply(null, heights))+'px'); 63 } 64 }); 65 }); 66 } 67 68//----MAIN----- 69 $(document).ready(function(){ 70 giveBreakwidthsCssClass(); 71 }); 72 73 $(window).load(function() { 74 equalizeWidgetHeights(); 75 }); 76 $( window ).resize(function() { 77 equalizeWidgetHeights(); 78 }); 79});
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.