1// height equalizer 2// v1.0 3 4(function ($) { 5 6 // custom select class 7 8 function equalizer(item, options) { 9 10 // options 11 12 var defaults = { 13 target: null 14 }; 15 16 this.options = $.extend(true, defaults, options); 17 18 this.item = $(item); 19 this.init(); 20 } 21 22 equalizer.prototype = { 23 24 // init 25 26 init: function () { 27 28 var plugin_instance = this; 29 var plugin_settings = plugin_instance.options; 30 31 // 32 // ELEMENTS 33 // 34 35 plugin_instance._equalize(); 36 37 $(window).resize(function() { 38 //console.log('resizing the window'); 39 plugin_instance._equalize(); 40 }); 41 }, 42 43 _equalize: function(fn_options) { 44 45 var plugin_instance = this; 46 var plugin_item = this.item; 47 var plugin_settings = plugin_instance.options; 48 49 plugin_item.find(plugin_settings.target).css('height', 'auto'); 50 51 var equalize_height = plugin_item.find(plugin_settings.target).first().outerHeight(); 52 53 plugin_item.find(plugin_settings.target).each(function() { 54 55 var current_height = $(this).outerHeight(); 56 57 if (current_height >= equalize_height) { 58 equalize_height = current_height; 59 } 60 61 }); 62 63 //console.log('equalize to ' + equalize_height); 64 65 plugin_item.find(plugin_settings.target).css('height', equalize_height + 'px'); 66 67 } 68 69 } 70 71 // jQuery plugin interface 72 73 $.fn.equalizer = function (opt) { 74 var args = Array.prototype.slice.call(arguments, 1); 75 76 return this.each(function () { 77 78 var item = $(this); 79 var instance = item.data('equalizer'); 80 81 if (!instance) { 82 83 // create plugin instance if not created 84 item.data('equalizer', new equalizer(this, opt)); 85 86 } else { 87 88 // otherwise check arguments for method call 89 if (typeof opt === 'string') { 90 instance[opt].apply(instance, args); 91 } 92 93 } 94 }); 95 } 96 97}(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.