1/*! jQuery.equalHeightResponsive | v.1.6 | 24.04.2015 | http://git.io/OwM7Ow */ 2/** 3 * Ðлагин : jQuery.equalHeightResponsive 4 * ÐеÑÑÐ¸Ñ : 1.6 (24.04.2015) 5 * РепозиÑоÑий: http://git.io/OwM7Ow 6 * ÐвÑÐ¾Ñ : ÐаÑÐÑÑиР7 * Twitter : @pafnuty_name 8 * ÐазнаÑение : ÐвÑомаÑиÑеÑкое вÑÑавнивание вÑÑоÑÑ Ð±Ð»Ð¾ÐºÐ¾Ð² (в каждом ÑÑÐ´Ñ ÑÐ²Ð¾Ñ Ð²ÑÑоÑа) Ð´Ð»Ñ Ð°Ð´Ð°Ð¿ÑивнÑÑ ÑайÑов. Ðлагин ÑÑабаÑÑÐ²Ð°ÐµÑ Ð¿Ñи ÑобÑÑиÑÑ window: 9 * load 10 * resize 11 * equal-refresh 12 * 13 * Ðлагин оÑнован на коде из поÑÑа: http://css-tricks.com/equal-height-blocks-in-rows/ 14 * 15 * 16 * ÐÑполÑзование: 17 * HTML: 18 * <div class="container"> 19 * <div class="element"></div> 20 * <div class="element"></div> 21 * <div class="element"></div> 22 * <div class="element"></div> 23 * </div> 24 * 25 * jQuery(document).ready(function($) { 26 * $('.element').equalHeightResponsive(); 27 * }); 28 * 29 * ÐÐ»Ñ Ð¿Ð¾Ð²ÑоÑной иниÑиализаÑии делаем Ñак: 30 * $('.element').equalHeightResponsive('refresh'); 31 * или 32 * $('.element').trigger('equal-refresh.equalHeightResponsive'); 33 * или 34 * $('.element').trigger('equal-refresh'); 35 * 36 * Так же возможно ÑÑÑанавливаÑÑ Ð¾Ð±ÑабаÑÑваемÑм блокам ÑвойÑÑво line-height, Ñавное вÑÑоÑе. 37 * ÐÑедÑÑмоÑÑена возможноÑÑÑ Ð²Ð»Ð¸ÑÑÑ Ð½Ð° line-height (иногда нÑжно на ÐµÑ ÑменÑÑиÑÑ/ÑвелиÑиÑÑ.) 38 * ÐÐ»Ñ ÑÑого нÑжно "акÑивиÑоваÑÑ" опÑÐ¸Ñ setLineHeight, Ð²Ð¾Ñ Ñак: 39 * $('.element').equalHeightResponsive({ 40 * setLineHeight : true, 41 * lineHeightOffset: 0 42 * }); 43 * 44 * 45 */ 46 47 48;(function ($, window, document, undefined) { 49 'use strict'; 50 var maxHeight = 0, 51 currentRowStart = 0, 52 rowEls = [], 53 topPostion = 0, 54 $el, 55 currentEl, 56 defaults = { 57 setLineHeight: false, 58 lineHeightOffset: -4 59 }, 60 methods = { 61 init: function (options) { 62 63 var props = $.extend({}, defaults, options), 64 _this = this, 65 $window = $(window), 66 winWidth = $window.width(), // IE8 loop resize fix 67 winHeight = $window.height(), // IE8 loop resize fix 68 _run = function (e) { 69 var winNewWidth = $window.width(), // IE8 loop resize fix 70 winNewHeight = $window.height(); // IE8 loop resize fix 71 // IE8 loop resize fix 72 if ((winWidth != winNewWidth || winHeight != winNewHeight) || e.type == 'load' || e.type == 'equal-refresh') { 73 methods.run(_this, props); 74 } 75 // IE8 loop resize fix 76 winWidth = winNewWidth; 77 winHeight = winNewHeight; 78 }; 79 80 $window.on('load.equalHeightResponsive resize.equalHeightResponsive equal-refresh.equalHeightResponsive', _this, _run); 81 82 // Bitrix composite fix 83 if (window.frameCacheVars !== undefined) { 84 methods.run(_this, props); 85 } 86 87 return this; 88 89 }, 90 run: function (elements, options) { 91 92 $.each(elements, function () { 93 $el = $(this); 94 $($el).height('auto'); 95 topPostion = $el.offset().top; 96 if ($el.is(':visible')) { 97 if (currentRowStart != topPostion) { 98 for (currentEl = 0; currentEl < rowEls.length; currentEl++) { 99 rowEls[currentEl].height(maxHeight); 100 } 101 rowEls.length = 0; 102 currentRowStart = topPostion; 103 maxHeight = $el.height(); 104 rowEls.push($el); 105 } 106 else { 107 rowEls.push($el); 108 maxHeight = (maxHeight < $el.height()) ? ($el.height()) : (maxHeight); 109 } 110 for (currentEl = 0; currentEl < rowEls.length; currentEl++) { 111 rowEls[currentEl].height(maxHeight); 112 if (options.setLineHeight) { 113 rowEls[currentEl].css({ 114 'line-height': maxHeight + options.lineHeightOffset + 'px' 115 });
116 } 117 } 118 } 119 }); 120 121 return this; 122 }, 123 refresh: function () { 124 $(window).trigger('equal-refresh.equalHeightResponsive'); 125 return this; 126 } 127 }; 128 129 $.fn.equalHeightResponsive = function (method) { 130 131 if (methods[method]) { 132 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 133 } 134 else if (typeof method === 'object' || !method) { 135 return methods.init.apply(this, arguments); 136 } 137 else { 138 $.error('ÐеÑод Ñ Ð¸Ð¼ÐµÐ½ÐµÐ¼ ' + method + ' не ÑÑÑеÑÑвÑÐµÑ Ð´Ð»Ñ jQuery.equalHeightResponsive'); 139 } 140 141 }; 142 143})(jQuery, window, document);
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.