1/*-------------------------- 2 _______ ______ __ __ ___ __ __ __ _______ __ _______ __ __ .___________. _______. 3| ____| / __ \ | | | | / \ | | | | | | | ____|| | / _____|| | | | | | / | 4| |__ | | | | | | | | / ^ \ | | | |__| | | |__ | | | | __ | |__| | `---| |----` | (----` 5| __| | | | | | | | | / /_\ \ | | | __ | | __| | | | | |_ | | __ | | | \ \ 6| |____ | `--' '--.| `--' | / _____ \ | `----. | | | | | |____ | | | |__| | | | | | | | .----) | 7|_______| \_____\_____\\______/ /__/ \__\ |_______| |__| |__| |_______||__| \______| |__| |__| |__| |_______/ 8 9--------------------------------------------*/ 10 11$.fn.equalHeightsGrid = function () { 12 var currentTallest = 0, 13 currentRowStart = 0, 14 rowDivs = new Array(), 15 $el, 16 topPosition = 0; 17 18 $(this).height("auto").each(function () { 19 $el = $(this); 20 topPostion = $el.offset().top; 21 22 if (currentRowStart != topPostion) { 23 // we just came to a new row. Set all the heights on the completed row 24 for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) { 25 rowDivs[currentDiv].height(currentTallest); 26 } 27 28 // set the variables for the new row 29 rowDivs.length = 0; // empty the array 30 currentRowStart = topPostion; 31 currentTallest = $el.height(); 32 rowDivs.push($el); 33 } else { 34 // another div on the current row. Add it to the list and check if it's taller 35 rowDivs.push($el); 36 currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest); 37 } 38 39 // do the last row 40 for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) { 41 rowDivs[currentDiv].height(currentTallest); 42 } 43 }); 44}; 45 46var initCustomEqualizerzs = function () { 47 // static variables 48 49 // to use: add in a new array of elements that need equlizing in the order they need to be hit i.e. heading then text then the wrapper element 50 51 var equalizerArrays = []; 52 53 // functions 54 55 var addElementsWithDataAttrbutes = function () { 56 var $allContainersWithCustomAttribute = $('*[data-custom-equalizer]'); 57 58 if ($allContainersWithCustomAttribute.length) { 59 $.each($allContainersWithCustomAttribute, function (index, containerElement) { 60 var $childenToEqualize = $(containerElement).find('*[data-custom-equalizer-watch]'); 61 62 if ($childenToEqualize.length) { 63 var breakpointValue = null; 64 var breakpointText = $(containerElement).data('custom-equalizer-mq'); 65 66 switch (breakpointText) { 67 case "medium-up": { 68 breakpointValue = mediumBreakpoint; 69 break; 70 } 71 case "large-up": { 72 breakpointValue = largeBreakpoint; 73 break; 74 } 75 }; 76 77 // run a check to see if they need ordering 78 79 if ($childenToEqualize.first().data('custom-equalizer-order')) { 80 // sort elements into the correct order 81 82 $childenToEqualize.sort(function (a, b) { 83 return $(a).data('custom-equalizer-order') - $(b).data('custom-equalizer-order'); 84 }); 85 86 // group elements by order 87 88 var maxLevel = $childenToEqualize.last().data('custom-equalizer-order'), 89 elementArrays = []; 90 91 for (i = 1; i <= maxLevel; i++) { 92 var level = $childenToEqualize.filter(function () { return $(this).data('custom-equalizer-order') == i; }); 93 elementArrays.push(level); 94 } 95 96 var jsonItem = { 97 breakpointToEqualizeAfter: breakpointValue, 98 elements: elementArrays 99 }; 100 } else { 101 var jsonItem = { 102 breakpointToEqualizeAfter: breakpointValue, 103 elements: [$childenToEqualize] 104 }; 105 } 106 107 equalizerArrays.push(jsonItem); 108 } 109 }); 110 } 111 }; 112 113 var equalize = function () { 114 $.each(equalizerArrays, function (index, equalizerSettings) { 115 if (equalizerSettings.breakpointToEqualizeAfter == null) { 116 $.each(equalizerSettings.elements, function (index, element) { 117 $(element).equalHeightsGrid(); 118 }); 119 } else { 120 if ($(window).width() >= equalizerSettings.breakpointToEqualizeAfter) { 121 $.each(equalizerSettings.elements, function (index, element) { 122 $(element).equalHeightsGrid(); 123 }); 124 } else { 125 $.each(equalizerSettings.elements, function (index, element) { 126 $(element).height('auto'); 127 }); 128 } 129 } 130 }); 131 }; 132 133 // UI Bindings 134 135 addElementsWithDataAttrbutes(); 136 equalize(); 137 138 // return object 139 140 return {
141 resizeEvent: equalize 142 } 143};
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.