diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-07-11 05:17:22 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-07-11 05:17:22 +0000 |
commit | 16669774903dd7bfaaf1bf8f0c72e49ebaeffeeb (patch) | |
tree | 1e2b6e66d19e261efeceeb6937c605785527ee57 /actionpack/lib/action_view/helpers/javascripts/dragdrop.js | |
parent | 1911f8eee928915f1020753a4a3ba34c81131a66 (diff) | |
download | rails-16669774903dd7bfaaf1bf8f0c72e49ebaeffeeb.tar.gz rails-16669774903dd7bfaaf1bf8f0c72e49ebaeffeeb.tar.bz2 rails-16669774903dd7bfaaf1bf8f0c72e49ebaeffeeb.zip |
Script.aculo.us: latest rev, new autocompleter features, memory leaks fixed #1695 [Thomas Fuchs]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1810 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/javascripts/dragdrop.js')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascripts/dragdrop.js | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/actionpack/lib/action_view/helpers/javascripts/dragdrop.js b/actionpack/lib/action_view/helpers/javascripts/dragdrop.js index 2bf84f1cb1..c0fd1d1e53 100644 --- a/actionpack/lib/action_view/helpers/javascripts/dragdrop.js +++ b/actionpack/lib/action_view/helpers/javascripts/dragdrop.js @@ -120,10 +120,10 @@ var Droppables = { add: function(element) { var element = $(element); - var options = { + var options = Object.extend({ greedy: true, hoverclass: null - }.extend(arguments[1] || {}); + }, arguments[1] || {}); // cache containers if(options.containment) { @@ -220,9 +220,9 @@ Draggables = { addObserver: function(observer) { this.observers.push(observer); }, - removeObserver: function(observer) { + removeObserver: function(element) { // element instead of obsever fixes mem leaks for(var i = 0; i < this.observers.length; i++) - if(this.observers[i] = observer) + if(this.observers[i].element && (this.observers[i].element == element)) this.observers.splice(i,1); }, notify: function(eventName, draggable) { // 'onStart', 'onEnd' @@ -236,7 +236,7 @@ Draggables = { Draggable = Class.create(); Draggable.prototype = { initialize: function(element) { - var options = { + var options = Object.extend({ handle: false, starteffect: function(element) { new Effect.Opacity(element, {duration:0.2, from:1.0, to:0.7}); @@ -249,7 +249,7 @@ Draggable.prototype = { }, zindex: 1000, revert: false - }.extend(arguments[1] || {}); + }, arguments[1] || {}); this.element = $(element); this.handle = options.handle ? $(options.handle) : this.element; @@ -411,7 +411,7 @@ Sortable = { for(var i=0;i<this.sortables.length;i++) { if(this.sortables[i].element == element) { var s = this.sortables[i]; - Draggables.removeObserver(s.observer); + Draggables.removeObserver(s.element); for(var j=0;j<s.droppables.length;j++) Droppables.remove(s.droppables[j]); for(var j=0;j<s.draggables.length;j++) @@ -422,7 +422,7 @@ Sortable = { }, create: function(element) { var element = $(element); - var options = { + var options = Object.extend({ element: element, tag: 'li', // assumes li children, override with tag: 'tagname' overlap: 'vertical', // one of 'vertical', 'horizontal' @@ -433,7 +433,7 @@ Sortable = { hoverclass: null, onChange: function() {}, onUpdate: function() {} - }.extend(arguments[1] || {}); + }, arguments[1] || {}); // clear any old sortable with same element this.destroy(element); @@ -499,7 +499,7 @@ Sortable = { var handle = options.handle ? Element.Class.childrenWith(elements[i], options.handle)[0] : elements[i]; - options.draggables.push(new Draggable(elements[i], options_for_draggable.extend({ handle: handle }))); + options.draggables.push(new Draggable(elements[i], Object.extend(options_for_draggable, { handle: handle }))); Droppables.add(elements[i], options_for_droppable); options.droppables.push(elements[i]); @@ -510,18 +510,17 @@ Sortable = { this.sortables.push(options); // for onupdate - options.observer = new SortableObserver(element, options.onUpdate); - Draggables.addObserver(options.observer); + Draggables.addObserver(new SortableObserver(element, options.onUpdate)); }, serialize: function(element) { var element = $(element); var sortableOptions = this.options(element); - var options = { + var options = Object.extend({ tag: sortableOptions.tag, only: sortableOptions.only, name: element.id - }.extend(arguments[1] || {}); + }, arguments[1] || {}); var items = $(element).childNodes; var queryComponents = new Array(); |