diff options
author | Oliver Sartun <sartun@dievision.de> | 2015-11-13 15:43:30 +0100 |
---|---|---|
committer | Oliver Sartun <sartun@dievision.de> | 2015-11-13 15:43:30 +0100 |
commit | 8afc576a5086408d74be1f4f8ced76cdc378ae72 (patch) | |
tree | ac38737f4101d47b74aac293bc17364c5eaf6fb9 | |
parent | 8b273eeeae01bb4134a750b40f65487487e46c13 (diff) | |
download | jQuery.equalHeights-8afc576a5086408d74be1f4f8ced76cdc378ae72.zip jQuery.equalHeights-8afc576a5086408d74be1f4f8ced76cdc378ae72.tar.gz jQuery.equalHeights-8afc576a5086408d74be1f4f8ced76cdc378ae72.tar.bz2 |
Create unwatch option + improving data-options
+ When `equalHeights` is called with {unwatch: true}, the elements are stopped being watched
+ All data-attributes are now passed in as options, so that new options don't need to be specified separately any more
-rw-r--r-- | jquery.equalheights.js | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/jquery.equalheights.js b/jquery.equalheights.js index 3e23d2d..304f7a4 100644 --- a/jquery.equalheights.js +++ b/jquery.equalheights.js @@ -6,7 +6,7 @@ * Uses the same license as jQuery, see: * http://docs.jquery.com/License * - * @version 1.5.1 + * @version 1.5.2 */ (function($) { @@ -31,11 +31,20 @@ $this.each(equalHeightsFn); - if (options.watch) { + if (options.watch || option.equalWatch) { watched.push(this) } - if (options.wait) { + if (options.unwatch || options.equalUnwatch) { + for (var i = 0, l = watched.length, res = []; i < l; i++) { + if (watched[i].length && !$this.is(watched[i])) { + res.push(watched[i]); + } + } + watched = res; + } + + if (options.wait || options.equalWait) { var loop = setInterval(function() { if(maxHeight > 0) { clearInterval(loop); @@ -52,10 +61,9 @@ $(document).on('ready', function() { $('[data-equal]').each(function(){ var $this = $(this), - wait = $this.data('equal-wait'), - watch = $this.data('equal-watch'), - target = $this.data('equal'); - $this.find(target).equalHeights({'wait': wait, 'watch': watch}); + options = $this.data(), + target = options.equal; + $this.find(target).equalHeights(options); }); }); |