1/** 2 * equalize.js 3 * Author & copyright (c) 2012: Tim Svensen 4 * Dual MIT & GPL license 5 * 6 * Page: http://tsvensen.github.com/equalize.js 7 * Repo: https://github.com/tsvensen/equalize.js/ 8 * 9 * The jQuery plugin for equalizing the height or width of elements. 10 * 11 * Equalize will accept any of the jQuery Dimension methods: 12 * height, outerHeight, innerHeight, 13 * width, outerWidth, innerWidth. 14 * 15 * EXAMPLE 16 * $('.parent').equalize(); // defaults to 'height' 17 * $('.parent').equalize('width'); // equalize the widths 18 * 19 * ADVANCED EXAMPLES 20 * Get the minimum max dimension by removing the existing height/width 21 * $('.parent').equalize({reset: true}); // equalize height by default, remove existing height, then determin max 22 * $('.parent').equalize({equalize: 'width', reset: true}); // equalize width, remove existing width, then determin max 23 * 24 * Equalize internal child elements 25 * From @larsbo : http://jsfiddle.net/4QTNP/3/ 26 * $('.parent').equalize({children: 'p'}); // equalize height of paragraphs within .parent 27 */ 28;(function($) { 29 30 $.fn.equalize = function(options) { 31 var $containers = this, // this is the jQuery object 32 children = false, 33 reset = false, 34 equalize, 35 type; 36 37 // when options are an object 38 if ($.isPlainObject(options)) { 39 equalize = options.equalize || 'height'; 40 children = options.children || false; 41 reset = options.reset || false; 42 } else { // otherwise, a string was passed in or default to height 43 equalize = options || 'height'; 44 } 45 46 if (!$.isFunction($.fn[equalize])) { return false; } 47 48 // determine if the height or width is being equalized 49 type = (equalize.indexOf('eight') > 0) ? 'height' : 'width'; 50 51 return $containers.each(function() { 52 // when children exist, equalize the passed in child elements, otherwise equalize the children 53 var $children = (children) ? $(this).find(children) : $(this).children(), 54 max = 0; // reset for each container 55 56 $children.each(function() { 57 var $element = $(this), 58 value; 59 if (reset) { $element.css(type, ''); } // remove existing height/width dimension 60 value = $element[equalize](); // call height(), outerHeight(), etc. 61 if (value > max) { max = value; } // update max 62 }); 63 64 $children.css(type, max +'px'); // add CSS to children 65 }); 66 }; 67 68}(jQuery));
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.