1;(function ( $ ) { 2 3 var method = { 4 5 // СÑиÑаем кол-во ÑлеменÑов в ÑÑÑоке 6 countElementInRow: function ( wrap, element ) { 7 return Math.floor(wrap.width() / wrap.find(element).eq(0).outerWidth(true)); 8 9 }, 10 11 // ÐолÑÑаем макÑималÑнÑÑ Ð²ÑÑоÑÑ ÑлеменÑов 12 getMaxHeight: function ( element ) { 13 14 var height = 0; 15 16 // ÐбнÑление вÑÑоÑÑ ÑлеменÑов, Ð´Ð»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑеалÑнÑÑ Ð·Ð½Ð°Ñений 17 element.css({ 18 'height': 'auto', 19 'min-height': 0 20 }); 21 22 element.each(function() { 23 24 if ( $(this).height() > height ) { 25 height = $(this).height(); 26 }; 27 28 }); 29 30 return height; 31 }, 32 33 // ÐадаÑм вÑÑоÑÑ ÑлеменÑам 34 setHeight: function ( element, height ) { 35 36 element.css('min-height', height); 37 38 return { 39 element: element, 40 height: height 41 } 42 43 } 44 45 }; 46 47 $.fn.equalHeight = function ( options ) { 48 49 var settings = $.extend({ 50 // ÐоÑеÑние ÑлеменÑÑ 51 child: [], 52 // ÐÑполнение поÑле полной загÑÑзки ÑÑÑаниÑÑ 53 windowLoad: false, 54 55 //CALLBACKS 56 // ÐÑполнение ÑÑнкÑии до пÑиÑÐ²Ð¾ÐµÐ½Ð¸Ñ Ð²ÑÑоÑÑ ÑлеменÑам в ÑÑÑоке 57 onRowBefore: function () {}, 58 // ÐÑполнение ÑÑнкÑии поÑле пÑиÑÐ²Ð¾ÐµÐ½Ð¸Ñ Ð²ÑÑоÑÑ ÑлеменÑам в ÑÑÑоке 59 onRowAfter: function () {}, 60 // ÐÑполнение ÑÑнкÑии до ÑобÑÑÐ¸Ñ resize 61 onResizeBefore: function () {}, 62 // ÐÑполнение ÑÑнкÑии поÑле ÑобÑÑÐ¸Ñ resize 63 onResizeAfter: function () {}, 64 // ÐÑполнение поÑле вÑÐ¿Ð¾Ð»Ð½ÐµÐ½Ð¸Ñ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð°. 65 onLoad: function () {} 66 67 68 }, options); 69 70 var element = this; 71 var wrap = $(element).parent(); 72 var pluginLoader = false; 73 74 75 if ( !element.length ) { 76 return false; 77 }; 78 79 function init () { 80 81 // ÐÑÐ¾Ñ Ð¾Ð´Ð¸Ð¼ÑÑ Ð¿Ð¾ ÐºÐ°Ð¶Ð´Ð¾Ð¼Ñ ÑодиÑÐµÐ»Ñ ÑлеменÑов 82 wrap.each(function() { 83 84 var setup = { 85 thisWrap : $(this), 86 thisElement : $(this).find(element), 87 rowCount : 1 88 89 }; 90 91 // Ðол-во ÑлеменÑов в ÑÑÑоке 92 setup.amountInRow = method.countElementInRow(setup.thisWrap, element) || 0; 93 94 // Ðол-во ÑÑÑок 95 setup.rowCount = Math.ceil(setup.thisElement.length/setup.amountInRow); 96 97 // ÐÑли кол-во ÑÑÑок болÑÑе 1 98 if ( setup.rowCount > 1 ) { 99 100 var el = []; 101 102 setup.thisElement.each(function( index ) { 103 104 // ÐобавлÑем каждÑй ÑÐ»ÐµÐ¼ÐµÐ½Ñ ÑÑÑоки в маÑÑив 105 el.push(this); 106 107 // ÐÑли Ð½Ð°Ñ Ð¾Ð´Ð¸Ð¼ÑÑ Ð½Ð° поÑледнем ÑлеменÑе в ÑÑÑоке 108 // или еÑли ÑÑо поÑледний ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ð² набоÑе 109 if ( (index+1)%setup.amountInRow == 0 || !setup.thisElement[index+1] ) { 110 111 var $el = $(el) 112 113 settings.onRowBefore( $el ); 114 115 // СнаÑала задаÑм вÑÑоÑÑ Ð²Ð»Ð¾Ð¶ÐµÐ½Ð½Ñм ÑлеменÑам 116 for ( var i = 0; i < settings.child.length; i++ ) { 117 method.setHeight( 118 $el.find(settings.child[i]), 119 method.getMaxHeight( $el.find(settings.child[i]) ) 120 ); 121 } 122 123 // ÐадаÑм вÑÑоÑÑ ÑÐ°Ð¼Ð¾Ð¼Ñ ÑлеменÑÑ 124 method.setHeight( 125 $el, 126 method.getMaxHeight( $el ) 127 ); 128 129 settings.onRowAfter( $el ); 130 131 // ÐÑиÑаем маÑÑив Ñ ÑлеменÑами пÑи пеÑÐµÑ Ð¾Ð´Ðµ на новÑÑ ÑÑÑÐ¾ÐºÑ 132 el = []; 133 134 }; 135 136 }); 137 138 }; 139 140 // ÐÑли кол-во ÑÑÑок Ñавно единиÑе 141 if ( setup.rowCount == 1 ) { 142 143 settings.onRowBefore( setup.thisElement ); 144 145 // СнаÑала задаÑм вÑÑоÑÑ Ð²Ð»Ð¾Ð¶ÐµÐ½Ð½Ñм ÑлеменÑам 146 for ( var i = 0; i < settings.child.length; i++ ) { 147 method.setHeight( 148 setup.thisWrap.find(settings.child[i]), 149 method.getMaxHeight( setup.thisWrap.find(settings.child[i]) ) 150 ); 151 } 152 153 // ÐадаÑм вÑÑоÑÑ ÑÐ°Ð¼Ð¾Ð¼Ñ ÑлеменÑÑ 154 method.setHeight( 155 setup.thisElement, 156 method.getMaxHeight( setup.thisWrap.find(setup.thisElement)) 157 ); 158 159 settings.onRowAfter( setup.thisElement ); 160 161 }; 162 163 164 }); 165 166 167 if ( !pluginLoader ) { 168 169 settings.onLoad( element ); 170 pluginLoader = true; 171 172 }; 173 174 }; 175 176 if ( settings.windowLoad ) { 177 178 $(window).on('load', init); 179 180 } else { 181 182 init(); 183 184 }; 185 186 $(window).on('resize', function() { 187 188 settings.onResizeBefore( element ); 189 init(); 190 settings.onResizeAfter( element ); 191 192 }); 193 194 195 return element; 196 197 }; 198 199})( 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.