aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/javascripts/dragdrop.js
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-07-01 07:25:44 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-07-01 07:25:44 +0000
commitcadcd9e7144394ecc9df01961191d20e5e219a37 (patch)
tree6014e509c117efbb6cb20e806388e73f7d34f8c6 /actionpack/lib/action_view/helpers/javascripts/dragdrop.js
parent24a8cb1e5600d95a51323982e4d7508eb22c8b1f (diff)
downloadrails-cadcd9e7144394ecc9df01961191d20e5e219a37.tar.gz
rails-cadcd9e7144394ecc9df01961191d20e5e219a37.tar.bz2
rails-cadcd9e7144394ecc9df01961191d20e5e219a37.zip
Fix IE 30-sec timeout bug, make auto_complete_for even more delicious #1572 [Thomas Fuchs]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1579 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.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/helpers/javascripts/dragdrop.js b/actionpack/lib/action_view/helpers/javascripts/dragdrop.js
index 6086b44ee0..78f82bcd23 100644
--- a/actionpack/lib/action_view/helpers/javascripts/dragdrop.js
+++ b/actionpack/lib/action_view/helpers/javascripts/dragdrop.js
@@ -221,9 +221,9 @@ Draggables = {
addObserver: function(observer) {
this.observers.push(observer);
},
- notify: function(eventName) { // 'onStart', 'onEnd'
+ notify: function(eventName, draggable) { // 'onStart', 'onEnd'
for(var i = 0; i < this.observers.length; i++)
- this.observers[i][eventName]();
+ this.observers[i][eventName](draggable);
}
}
@@ -243,7 +243,8 @@ Draggable.prototype = {
endeffect: function(element) {
new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0});
},
- zindex: 1000
+ zindex: 1000,
+ revert: false
}.extend(arguments[1] || {});
this.element = $(element);
@@ -278,8 +279,8 @@ Draggable.prototype = {
this.active = true;
var style = this.element.style;
- this.originalY = this.element.offsetTop - this.currentTop(); - this.originalTop;
- this.originalX = this.element.offsetLeft - this.currentLeft(); - this.originalLeft;
+ this.originalY = this.element.offsetTop - this.currentTop() - this.originalTop;
+ this.originalX = this.element.offsetLeft - this.currentLeft() - this.originalLeft;
this.offsetY = event.clientY - this.originalY - this.originalTop;
this.offsetX = event.clientX - this.originalX - this.originalLeft;
@@ -292,9 +293,12 @@ Draggable.prototype = {
this.dragging = false;
Droppables.fire(event, this.element);
- Draggables.notify('onEnd');
+ Draggables.notify('onEnd', this);
- if(this.options.revert && this.options.reverteffect) {
+ var revert = this.options.revert;
+ if(revert && typeof revert == 'function') revert = revert(this.element);
+
+ if(revert && this.options.reverteffect) {
this.options.reverteffect(this.element,
this.currentTop()-this.originalTop,
this.currentLeft()-this.originalLeft);
@@ -330,7 +334,7 @@ Draggable.prototype = {
this.dragging = true;
if(style.position=="") style.position = "relative";
style.zIndex = this.options.zindex;
- Draggables.notify('onStart');
+ Draggables.notify('onStart', this);
if(this.options.starteffect) this.options.starteffect(this.element);
}