diff options
author | Scott González <scott.gonzalez@gmail.com> | 2013-04-22 12:33:35 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2013-04-22 12:33:35 -0400 |
commit | 7033544cdd9792f4b1be473eeea7bc37eed52469 (patch) | |
tree | 28e8ae526335b720df0fd28da543f3f6982b6c36 /ui/jquery.ui.sortable.js | |
parent | 71a332e8b83a1657521e04388f5592997e81bbcc (diff) | |
download | jquery-ui-7033544cdd9792f4b1be473eeea7bc37eed52469.tar.gz jquery-ui-7033544cdd9792f4b1be473eeea7bc37eed52469.zip |
Sortable: Don't create functions inside loops.
Diffstat (limited to 'ui/jquery.ui.sortable.js')
-rw-r--r-- | ui/jquery.ui.sortable.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 7b145159e..c7794f06a 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -15,8 +15,6 @@ */ (function( $, undefined ) { -/*jshint loopfunc: true */ - function isOverAxis( x, reference, size ) { return ( x > reference ) && ( x < ( reference + size ) ); } @@ -629,10 +627,11 @@ $.widget("ui.sortable", $.ui.mouse, { queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]); + function addItems() { + items.push( this ); + } for (i = queries.length - 1; i >= 0; i--){ - queries[i][0].each(function() { - items.push(this); - }); + queries[i][0].each( addItems ); } return $(items); @@ -1190,12 +1189,17 @@ $.widget("ui.sortable", $.ui.mouse, { //Post events to containers + function delayEvent( type, instance, container ) { + return function( event ) { + container._trigger( type, event, instance._uiHash( instance ) ); + }; + } for (i = this.containers.length - 1; i >= 0; i--){ - if(!noPropagation) { - delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i])); + if (!noPropagation) { + delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) ); } if(this.containers[i].containerCache.over) { - delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i])); + delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) ); this.containers[i].containerCache.over = 0; } } |