1/** 2 * Gestionnaire des éléments "autoheight" 3 * 4 * Pour que des éléments aie la même hauteur, il faut ajouter la classe 'autoheight-row' au conteneur, 5 * puis la classe 'autoheight' au enfants devant être de la même hauteur. 6 * 7 */ 8(function ($) { 9 $.TCAutoHeight = function (el, options) { 10 var base = this; 11 var publicFunction = this; 12 13 // Access to jQuery and DOM versions of element 14 base.$el = $(el); 15 var plugin = base.$el; 16 17 base.el = el; 18 19 // Référence à l'objet DOM: utile pour pouvoir appeler une méthode publique du plugin 20 plugin.data("TCAutoHeight", base); 21 22 /** 23 * Calcul de la hauteur à appliquer à tous les enfants du plugin, en fonction de l'enfant le plus haut 24 */ 25 var _autoHeight = function () { 26 var maxHeight = 0; 27 28 var $childs = plugin.find(base.options.childSelector); 29 30 $childs.removeAttr('style'); 31 $childs.each(function () { 32 var $element = $(this); 33 if ($element.outerHeight() > maxHeight) { 34 maxHeight = $element.outerHeight(); 35 } 36 }); 37 38 $childs.css('height', maxHeight + 'px'); 39 }; 40 41 /** 42 * Appel explicite depuis l'extérieur 43 */ 44 publicFunction.autoHeight = function () { 45 _autoHeight(); 46 }; 47 48 publicFunction.init = function () { 49 base.options = $.extend({}, $.TCAutoHeight.defaultOptions, options); 50 _autoHeight(); 51 52 }; 53 54 // Attend que toutes les images de l'élément soient chargées pour initialiser le calcul 55 plugin.imagesLoaded( function() { 56 // Initialisation 57 base.init(); 58 }); 59 }; 60 61 $.TCAutoHeight.defaultOptions = { 62 childSelector: '.autoheight' 63 }; 64 65 $.fn.TCAutoHeight = function (options) { 66 return this.each(function () { 67 (new $.TCAutoHeight(this, options)); 68 }); 69 }; 70 71 $.fn.getTCAutoHeight = function () { 72 this.data("TCAutoHeight"); 73 }; 74 75})(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.