This commit is contained in:
2024-12-20 06:04:35 +03:00
parent 0f779b7ebf
commit d630370039
267 changed files with 34950 additions and 11 deletions
+42
View File
@@ -0,0 +1,42 @@
# equalize.js
The jQuery plugin for equalizing the height or width of elements. [See it in action »](http://tsvensen.github.com/equalize.js).
## How to Use
Call the plugin on the parent of the elements to equalize their height.
Equalize will accept any of the <a target="_blank" href="http://api.jquery.com/category/dimensions/">jQuery Dimension</a> methods: height, outerHeight, innerHeight, width, outerWidth, innerWidth.
<pre>$('#height-example').equalize();</pre>
## Advanced Usage
Equalize will now accept a settings object to get the "minimum max dimension". By setting reset to true the height/width will be removed before determining the max.
<pre>$('.parent').equalize({reset: true}); // default to height
$('.parent').equalize({equalize: 'width', reset: true});</pre>
This advanced usage is for dynamic instances where equalize is ran after elements are added or removed to maintain minimum max height or width.
Equalize the .parent's child element. See @larsbo's <a href="http://jsfiddle.net/4QTNP/3/">example</a>.
<pre>$('.parent').equalize({children: 'p'}); // equalize height of paragraphs within .parent</pre>
## Examples
<pre>$('.parent').equalize('height'); // default, same as above
$('.parent').equalize('outerHeight');
$('.parent').equalize('innerHeight');
$('.parent').equalize('width');
$('.parent').equalize('outerWidth');
$('.parent').equalize('innerWidth');</pre>
# Legal
Author & copyright (c) 2012: [Tim Svensen](http://timsvensen.com)
Dual MIT & GPLv2 license
+38
View File
@@ -0,0 +1,38 @@
{
"name": "equalize",
"version": "1.0.1",
"description": "jQuery plugin for equalizing the height or width of your elements",
"homepage": "http://tsvensen.github.io/equalize.js/",
"keywords": [
"ui",
"equalize",
"equal",
"height",
"width",
"layout"
],
"author": {
"name": "Tim Svensen",
"url": "http://timsvensen.com"
},
"licenses": [{
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
}, {
"type": "GPLv2",
"url": "http://opensource.org/licenses/GPL-2.0"
}],
"main": [
"js/equalize.js",
"js/equalize.min.js"
],
"dependencies": {
"jquery": ">=1.4.x"
},
"ignore": [
"**/.*",
"index.html",
"css",
"js/libs/*"
]
}
@@ -0,0 +1,35 @@
{
"name": "equalize.js",
"title": "equalize",
"description": "The jQuery plugin for equalizing the height or width of your elements",
"keywords": [
"ui",
"equalize",
"equal",
"height",
"width",
"layout"
],
"version": "1.0.1",
"author": {
"name": "Tim Svensen",
"url": "http://timsvensen.com"
},
"licenses": [{
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
}, {
"type": "GPLv2",
"url": "http://opensource.org/licenses/GPL-2.0"
}],
"homepage": "https://github.com/tsvensen/equalize.js",
"demo": "http://tsvensen.github.com/equalize.js/",
"dependencies": {
"jquery": ">=1.4.x"
}
}
+68
View File
@@ -0,0 +1,68 @@
/**
* equalize.js
* Author & copyright (c) 2012: Tim Svensen
* Dual MIT & GPL license
*
* Page: http://tsvensen.github.com/equalize.js
* Repo: https://github.com/tsvensen/equalize.js/
*
* The jQuery plugin for equalizing the height or width of elements.
*
* Equalize will accept any of the jQuery Dimension methods:
* height, outerHeight, innerHeight,
* width, outerWidth, innerWidth.
*
* EXAMPLE
* $('.parent').equalize(); // defaults to 'height'
* $('.parent').equalize('width'); // equalize the widths
*
* ADVANCED EXAMPLES
* Get the minimum max dimension by removing the existing height/width
* $('.parent').equalize({reset: true}); // equalize height by default, remove existing height, then determin max
* $('.parent').equalize({equalize: 'width', reset: true}); // equalize width, remove existing width, then determin max
*
* Equalize internal child elements
* From @larsbo : http://jsfiddle.net/4QTNP/3/
* $('.parent').equalize({children: 'p'}); // equalize height of paragraphs within .parent
*/
;(function($) {
$.fn.equalize = function(options) {
var $containers = this, // this is the jQuery object
children = false,
reset = false,
equalize,
type;
// when options are an object
if ($.isPlainObject(options)) {
equalize = options.equalize || 'height';
children = options.children || false;
reset = options.reset || false;
} else { // otherwise, a string was passed in or default to height
equalize = options || 'height';
}
if (!$.isFunction($.fn[equalize])) { return false; }
// determine if the height or width is being equalized
type = (equalize.indexOf('eight') > 0) ? 'height' : 'width';
return $containers.each(function() {
// when children exist, equalize the passed in child elements, otherwise equalize the children
var $children = (children) ? $(this).find(children) : $(this).children(),
max = 0; // reset for each container
$children.each(function() {
var $element = $(this),
value;
if (reset) { $element.css(type, ''); } // remove existing height/width dimension
value = $element[equalize](); // call height(), outerHeight(), etc.
if (value > max) { max = value; } // update max
});
$children.css(type, max +'px'); // add CSS to children
});
};
}(jQuery));
+9
View File
@@ -0,0 +1,9 @@
/*!
* equalize.js
* Author & copyright (c) 2012: Tim Svensen
* Dual MIT & GPL license
*
* Page: http://tsvensen.github.com/equalize.js
* Repo: https://github.com/tsvensen/equalize.js/
*/
!function(i){i.fn.equalize=function(e){var n,t,h=!1,c=!1;return i.isPlainObject(e)?(n=e.equalize||"height",h=e.children||!1,c=e.reset||!1):n=e||"height",i.isFunction(i.fn[n])?(t=0<n.indexOf("eight")?"height":"width",this.each(function(){var e=h?i(this).find(h):i(this).children(),s=0;e.each(function(){var e=i(this);c&&e.css(t,""),e=e[n](),e>s&&(s=e)}),e.css(t,s+"px")})):!1}}(jQuery);