1/** 2 * syncHeight - jQuery plugin to automagically Sync the heights of columns 3 * Made to seemlessly work with the CCS-Framework YAML (yaml.de) 4 * @requires jQuery v1.0.3 or newer 5 * 6 * http://blog.ginader.de/dev/syncheight/ 7 * 8 * Copyright (c) 2007-2013 9 * Dirk Ginader (ginader.de) 10 * Dirk Jesse (yaml.de) 11 * Dual licensed under the MIT and GPL licenses: 12 * http://www.opensource.org/licenses/mit-license.php 13 * http://www.gnu.org/licenses/gpl.html 14 * 15 * Version: 1.5 16 * 17 * Changelog 18 * * v1.5 fixes issue with box-sizing: border-box 19 * * v1.4: new Method unSyncHeight() that removes previously added syncs i.e. for responsive layouts 20 * * v1.3: compatibility fix for jQuery 1.9.x (removed $.browser) 21 * 22 * Usage sync: 23 $(window).load(function(){ 24 $('p').syncHeight(); 25 }); 26 * Usage unsync: 27 $(window).resize(function(){ 28 if($(window).width() < 500){ 29 $('p').unSyncHeight(); 30 } 31 }); 32 */ 33 34(function($) { 35 var getHeightProperty = function() { 36 var browser_id = 0; 37 var property = [ 38 // To avoid content overflow in synchronised boxes on font scaling, we 39 // use 'min-height' property for modern browsers ... 40 ['min-height','0px'], 41 // and 'height' property for Internet Explorer. 42 ['height','1%'] 43 ]; 44 45 var bMatch = /(msie) ([\w.]+)/.exec(navigator.userAgent.toLowerCase()) || [], 46 browser = bMatch[1] || "", 47 browserVersion = bMatch[2] || "0"; 48 49 // check for IE6 ... 50 if(browser === 'msie' && browserVersion < 7){ 51 browser_id = 1; 52 } 53 54 return { 55 'name': property[browser_id][0], 56 'autoheightVal': property[browser_id][1] 57 }; 58 }; 59 60 $.getSyncedHeight = function(selector) { 61 var max = 0; 62 var heightProperty = getHeightProperty(); 63 // get maximum element height ... 64 $(selector).each(function() { 65 // fallback to auto height before height check ... 66 $(this).css(heightProperty.name, heightProperty.autoheightVal); 67 var val = parseInt($(this).css('height'),10); 68 if(val > max){ 69 max = val; 70 } 71 }); 72 return max; 73 }; 74 75 $.fn.syncHeight = function(config) { 76 var defaults = { 77 updateOnResize: false, // re-sync element heights after a browser resize event (useful in flexible layouts) 78 height: false 79 }; 80 81 var options = $.extend(defaults, config); 82 var e = this; 83 var max = 0; 84 var heightPropertyName = getHeightProperty().name; 85 86 87 if(options.parent==true){ 88 89 $(this).each(function() { 90 $(this).css(heightPropertyName, 0+'px'); 91 }); 92 93 $(this).each(function() { 94 $(this).css(heightPropertyName, $(this).parent().innerHeight()+'px'); 95 }); 96 }else{ 97 98 if(typeof(options.height) === "number") { 99 max = options.height; 100 } else { 101 max = $.getSyncedHeight(this); 102 } 103 104 105 // set synchronized element height ... 106 $(this).each(function() { 107 $(this).css(heightPropertyName, max+'px'); 108 }); 109 } 110 111 112 // optional sync refresh on resize event ... 113 if (options.updateOnResize === true) { 114 $(window).bind('resize.syncHeight', function(){ 115 options["updateOnResize"]=false; 116 $(e).syncHeight(options); 117 }); 118 } 119 return this; 120 }; 121 122 $.fn.unSyncHeight = function() { 123 // unbind optional resize event ... 124 $(window).unbind('resize.syncHeight'); 125 126 var heightPropertyName = getHeightProperty().name; 127 $(this).each(function() { 128 $(this).css(heightPropertyName, ''); 129 }); 130 }; 131})(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.