]> source.dussan.org Git - jquery-ui.git/commitdiff
reverted back to minimal drag. The other may have depended on some things that got...
authorRichard Worth <rdworth@gmail.com>
Thu, 5 Jun 2008 13:05:28 +0000 (13:05 +0000)
committerRichard Worth <rdworth@gmail.com>
Thu, 5 Jun 2008 13:05:28 +0000 (13:05 +0000)
ui/tests/jquery.simulate.js

index e3803a3cb908ac2e3b6beef8b8d7a8042a40af97..d2c49ea891fc33455f6d3dee31c989e8b4b26de0 100644 (file)
@@ -33,10 +33,9 @@ $.simulate = function(el, type, options) {
 \r
 $.extend($.simulate.prototype, {\r
        simulateEvent: function(el, type, options) {\r
-               // creates a individual option for each simulation inside this instance\r
-               options = $.extend({}, this.options, options);\r
                var evt = this.createEvent(type, options);\r
-               return this.dispatchEvent(el, type, evt, options);\r
+               this.dispatchEvent(el, type, evt, options);\r
+               return evt;\r
        },\r
        createEvent: function(type, options) {\r
                if (/^mouse(over|out|down|up|move)|(dbl)?click$/.test(type)) {\r
@@ -102,14 +101,12 @@ $.extend($.simulate.prototype, {
                return evt;\r
        },\r
        \r
-       dispatchEvent: function(el, type, evt, options) {\r
+       dispatchEvent: function(el, type, evt) {\r
                if (el.dispatchEvent) {\r
                        el.dispatchEvent(evt);\r
                } else if (el.fireEvent) {\r
                        el.fireEvent('on' + type, evt);\r
                }\r
-               // trigget complete for all events - not drag.\r
-               this.triggerComplete(evt, options);\r
                return evt;\r
        },\r
        \r
@@ -117,54 +114,15 @@ $.extend($.simulate.prototype, {
                var self = this, center = this.findCenter(this.target), \r
                        options = this.options, x = center.x, y = center.y, \r
                        dx = options.dx || 0, dy = options.dy || 0, target = this.target;\r
-\r
-               var coord = { clientX: x, clientX: y, complete: null }, evt;\r
-               this.simulateEvent(target, "mouseover", coord);\r
+               var coord = { clientX: x, clientY: y };\r
+               this.simulateEvent(target, "mouseover");\r
                this.simulateEvent(target, "mousedown", coord);\r
-               \r
-               var drag = function(x, y) {\r
-                       evt = self.simulateEvent(target, "mousemove", $.extend(coord, { x: x, y: y }));\r
-                       // triggering drag callback\r
-                       (self.options.drag && self.options.drag($.event.fix(evt)));\r
-               };\r
-               \r
-               if (/^sync$/.test(options.speed)) {\r
-                       // trigger synchronous simulation\r
-                       this.triggerSync(center, dx, dy, drag);\r
-               }\r
-               else {\r
-                       // trigger asynchronous simulation - animated\r
-                       this.triggerAsync(center, dx, dy, drag);\r
-               }\r
-               \r
+               coord = { clientX: x + dx, clientY: y + dy };\r
+               this.simulateEvent(document, "mousemove", coord);\r
+               this.simulateEvent(document, "mousemove", coord);\r
                this.simulateEvent(target, "mouseup", coord);\r
-               this.simulateEvent(target, "mouseout", coord);\r
-               this.triggerComplete(evt, options);\r
+               this.simulateEvent(target, "mouseout");\r
        },\r
-       \r
-       triggerComplete: function(evt, options) {\r
-               evt = $.event.fix(evt);\r
-               (options.complete && options.complete(evt)); return evt;\r
-       },\r
-       \r
-       triggerSync: function(center, dx, dy, fn) {\r
-               var x = center.x, y = center.y, mdx = Math.abs(dx) || 0, mdy = Math.abs(dy) || 0;\r
-               var range = Math.max(mdx, mdy), sigx = dx/mdx || 1, sigy = dy/mdy || 1;\r
-               \r
-               for (var dt = 1; dt <= range; dt++) {\r
-                       if (dt <= mdx) x = center.x + sigx*dt;\r
-                       if (dt <= mdy) y = center.y + sigy*dt;\r
-                       (fn && fn(x, y));\r
-               }\r
-       },\r
-       \r
-       triggerAsync: function(center, dx, dy, fn) {\r
-               /*TODO*/\r
-               // this method just have to call: (fn && fn(x, y));\r
-               // return the x, y of the mousemove.\r
-               // idea: $.animate({ step: function() { var x,y; (fn && fn(x, y)); } });\r
-       },\r
-       \r
        findCenter: function(el) {\r
                var el = $(this.target), o = el.offset();\r
                return {\r