]> source.dussan.org Git - jquery-ui.git/commitdiff
Mouse: Move mouse into widgets folder
authorAlexander Schmitz <arschmitz@gmail.com>
Wed, 15 Jul 2015 02:18:43 +0000 (22:18 -0400)
committerAlexander Schmitz <arschmitz@gmail.com>
Sat, 8 Aug 2015 04:29:38 +0000 (00:29 -0400)
Ref #13885

demos/bootstrap.js
ui/mouse.js [deleted file]
ui/resizable.js
ui/selectable.js
ui/slider.js
ui/sortable.js
ui/widgets/dialog.js
ui/widgets/draggable.js
ui/widgets/droppable.js
ui/widgets/mouse.js [new file with mode: 0644]

index 5a5d888894245dda982b2f57e6741ae12781011c..37f3321dbf0a8cd409c69d041c11b83868c3b304 100644 (file)
@@ -33,7 +33,9 @@ var widgets = [
        "draggable",
        "droppable",
        "menu",
+       "mouse",
        "progressbar"
+
 ];
 
 function getPath( module ) {
diff --git a/ui/mouse.js b/ui/mouse.js
deleted file mode 100644 (file)
index a48a799..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/*!
- * jQuery UI Mouse @VERSION
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Mouse
-//>>group: UI Core
-//>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
-//>>docs: http://api.jqueryui.com/mouse/
-
-(function( factory ) {
-       if ( typeof define === "function" && define.amd ) {
-
-               // AMD. Register as an anonymous module.
-               define([
-                       "jquery",
-                       "./ie",
-                       "./version",
-                       "./widget"
-               ], factory );
-       } else {
-
-               // Browser globals
-               factory( jQuery );
-       }
-}(function( $ ) {
-
-var mouseHandled = false;
-$( document ).on( "mouseup", function() {
-       mouseHandled = false;
-});
-
-return $.widget("ui.mouse", {
-       version: "@VERSION",
-       options: {
-               cancel: "input, textarea, button, select, option",
-               distance: 1,
-               delay: 0
-       },
-       _mouseInit: function() {
-               var that = this;
-
-               this.element
-                       .on("mousedown." + this.widgetName, function(event) {
-                               return that._mouseDown(event);
-                       })
-                       .on("click." + this.widgetName, function(event) {
-                               if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
-                                       $.removeData(event.target, that.widgetName + ".preventClickEvent");
-                                       event.stopImmediatePropagation();
-                                       return false;
-                               }
-                       });
-
-               this.started = false;
-       },
-
-       // TODO: make sure destroying one instance of mouse doesn't mess with
-       // other instances of mouse
-       _mouseDestroy: function() {
-               this.element.off("." + this.widgetName);
-               if ( this._mouseMoveDelegate ) {
-                       this.document
-                               .off("mousemove." + this.widgetName, this._mouseMoveDelegate)
-                               .off("mouseup." + this.widgetName, this._mouseUpDelegate);
-               }
-       },
-
-       _mouseDown: function(event) {
-               // don't let more than one widget handle mouseStart
-               if ( mouseHandled ) {
-                       return;
-               }
-
-               this._mouseMoved = false;
-
-               // we may have missed mouseup (out of window)
-               (this._mouseStarted && this._mouseUp(event));
-
-               this._mouseDownEvent = event;
-
-               var that = this,
-                       btnIsLeft = (event.which === 1),
-                       // event.target.nodeName works around a bug in IE 8 with
-                       // disabled inputs (#7620)
-                       elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
-               if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
-                       return true;
-               }
-
-               this.mouseDelayMet = !this.options.delay;
-               if (!this.mouseDelayMet) {
-                       this._mouseDelayTimer = setTimeout(function() {
-                               that.mouseDelayMet = true;
-                       }, this.options.delay);
-               }
-
-               if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
-                       this._mouseStarted = (this._mouseStart(event) !== false);
-                       if (!this._mouseStarted) {
-                               event.preventDefault();
-                               return true;
-                       }
-               }
-
-               // Click event may never have fired (Gecko & Opera)
-               if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
-                       $.removeData(event.target, this.widgetName + ".preventClickEvent");
-               }
-
-               // these delegates are required to keep context
-               this._mouseMoveDelegate = function(event) {
-                       return that._mouseMove(event);
-               };
-               this._mouseUpDelegate = function(event) {
-                       return that._mouseUp(event);
-               };
-
-               this.document
-                       .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
-                       .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
-
-               event.preventDefault();
-
-               mouseHandled = true;
-               return true;
-       },
-
-       _mouseMove: function(event) {
-               // Only check for mouseups outside the document if you've moved inside the document
-               // at least once. This prevents the firing of mouseup in the case of IE<9, which will
-               // fire a mousemove event if content is placed under the cursor. See #7778
-               // Support: IE <9
-               if ( this._mouseMoved ) {
-                       // IE mouseup check - mouseup happened when mouse was out of window
-                       if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
-                               return this._mouseUp(event);
-
-                       // Iframe mouseup check - mouseup occurred in another document
-                       } else if ( !event.which ) {
-                               return this._mouseUp( event );
-                       }
-               }
-
-               if ( event.which || event.button ) {
-                       this._mouseMoved = true;
-               }
-
-               if (this._mouseStarted) {
-                       this._mouseDrag(event);
-                       return event.preventDefault();
-               }
-
-               if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
-                       this._mouseStarted =
-                               (this._mouseStart(this._mouseDownEvent, event) !== false);
-                       (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
-               }
-
-               return !this._mouseStarted;
-       },
-
-       _mouseUp: function(event) {
-               this.document
-                       .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
-                       .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
-
-               if (this._mouseStarted) {
-                       this._mouseStarted = false;
-
-                       if (event.target === this._mouseDownEvent.target) {
-                               $.data(event.target, this.widgetName + ".preventClickEvent", true);
-                       }
-
-                       this._mouseStop(event);
-               }
-
-               mouseHandled = false;
-               return false;
-       },
-
-       _mouseDistanceMet: function(event) {
-               return (Math.max(
-                               Math.abs(this._mouseDownEvent.pageX - event.pageX),
-                               Math.abs(this._mouseDownEvent.pageY - event.pageY)
-                       ) >= this.options.distance
-               );
-       },
-
-       _mouseDelayMet: function(/* event */) {
-               return this.mouseDelayMet;
-       },
-
-       // These are placeholder methods, to be overriden by extending plugin
-       _mouseStart: function(/* event */) {},
-       _mouseDrag: function(/* event */) {},
-       _mouseStop: function(/* event */) {},
-       _mouseCapture: function(/* event */) { return true; }
-});
-
-}));
index ca36f2ca2d5a3299fde4cd5d54d8585eba620f51..8513efe81627629eb7d2e82c332a53d9b9e83607 100644 (file)
@@ -23,7 +23,7 @@
                define([
                        "jquery",
                        "./disable-selection",
-                       "./mouse",
+                       "./widgets/mouse",
                        "./plugin",
                        "./version",
                        "./widget"
index ec4895d15015c4ecbe548be86691e933931cc7ae..160fcf56dcd69d0ed26b3054fbefd80d5bf37d46 100644 (file)
@@ -21,7 +21,7 @@
                define([
                        "jquery",
                        "./version",
-                       "./mouse",
+                       "./widgets/mouse",
                        "./widget"
                ], factory );
        } else {
index ff883a1ebb39d9fadc8ec4708b8b129bb029ea86..3690fbc3c3f5400081c6d52b6086999256e73958 100644 (file)
@@ -23,7 +23,7 @@
                define([
                        "jquery",
                        "./keycode",
-                       "./mouse",
+                       "./widgets/mouse",
                        "./version",
                        "./widget"
                ], factory );
index cb89c30e6c624e36d046c05289ae39926fa1731b..ecf8bffb43276969542d693b87ff00deccf7cc8d 100644 (file)
@@ -24,7 +24,7 @@
                        "./data",
                        "./version",
                        "./ie",
-                       "./mouse",
+                       "./widgets/mouse",
                        "./scroll-parent",
                        "./widget"
                ], factory );
index 856ad9bb0f46f83e9dd0972a5c6f62abfe3d4d0e..88f8c93de0c069520ed5e6f4330f3f3ba424ea8a 100644 (file)
@@ -24,7 +24,7 @@
                        "jquery",
                        "./button",
                        "./draggable",
-                       "../mouse",
+                       "./mouse",
                        "../resizable",
                        "../focusable",
                        "../keycode",
index e26be73b1b5dbdae6c13a9681d28c2b11b6855ec..ab9d24667789fcc7e3a4cc0a9e492b701bfc426f 100644 (file)
@@ -20,7 +20,7 @@
                // AMD. Register as an anonymous module.
                define([
                        "jquery",
-                       "../mouse",
+                       "./mouse",
                        "../data",
                        "../plugin",
                        "../safe-active-element",
index 551828b6d10d1cef25ff638f22f2b40d5730fa7d..3a8bd71094fbc916fcafa12c2e376f389f880e05 100644 (file)
@@ -20,7 +20,7 @@
                define([
                        "jquery",
                        "./draggable",
-                       "../mouse",
+                       "./mouse",
                        "../version",
                        "../widget"
                ], factory );
diff --git a/ui/widgets/mouse.js b/ui/widgets/mouse.js
new file mode 100644 (file)
index 0000000..80242c0
--- /dev/null
@@ -0,0 +1,205 @@
+/*!
+ * jQuery UI Mouse @VERSION
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Mouse
+//>>group: UI Core
+//>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
+//>>docs: http://api.jqueryui.com/mouse/
+
+(function( factory ) {
+       if ( typeof define === "function" && define.amd ) {
+
+               // AMD. Register as an anonymous module.
+               define([
+                       "jquery",
+                       "../ie",
+                       "../version",
+                       "../widget"
+               ], factory );
+       } else {
+
+               // Browser globals
+               factory( jQuery );
+       }
+}(function( $ ) {
+
+var mouseHandled = false;
+$( document ).on( "mouseup", function() {
+       mouseHandled = false;
+});
+
+return $.widget("ui.mouse", {
+       version: "@VERSION",
+       options: {
+               cancel: "input, textarea, button, select, option",
+               distance: 1,
+               delay: 0
+       },
+       _mouseInit: function() {
+               var that = this;
+
+               this.element
+                       .on("mousedown." + this.widgetName, function(event) {
+                               return that._mouseDown(event);
+                       })
+                       .on("click." + this.widgetName, function(event) {
+                               if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
+                                       $.removeData(event.target, that.widgetName + ".preventClickEvent");
+                                       event.stopImmediatePropagation();
+                                       return false;
+                               }
+                       });
+
+               this.started = false;
+       },
+
+       // TODO: make sure destroying one instance of mouse doesn't mess with
+       // other instances of mouse
+       _mouseDestroy: function() {
+               this.element.off("." + this.widgetName);
+               if ( this._mouseMoveDelegate ) {
+                       this.document
+                               .off("mousemove." + this.widgetName, this._mouseMoveDelegate)
+                               .off("mouseup." + this.widgetName, this._mouseUpDelegate);
+               }
+       },
+
+       _mouseDown: function(event) {
+               // don't let more than one widget handle mouseStart
+               if ( mouseHandled ) {
+                       return;
+               }
+
+               this._mouseMoved = false;
+
+               // we may have missed mouseup (out of window)
+               (this._mouseStarted && this._mouseUp(event));
+
+               this._mouseDownEvent = event;
+
+               var that = this,
+                       btnIsLeft = (event.which === 1),
+                       // event.target.nodeName works around a bug in IE 8 with
+                       // disabled inputs (#7620)
+                       elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
+               if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+                       return true;
+               }
+
+               this.mouseDelayMet = !this.options.delay;
+               if (!this.mouseDelayMet) {
+                       this._mouseDelayTimer = setTimeout(function() {
+                               that.mouseDelayMet = true;
+                       }, this.options.delay);
+               }
+
+               if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+                       this._mouseStarted = (this._mouseStart(event) !== false);
+                       if (!this._mouseStarted) {
+                               event.preventDefault();
+                               return true;
+                       }
+               }
+
+               // Click event may never have fired (Gecko & Opera)
+               if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
+                       $.removeData(event.target, this.widgetName + ".preventClickEvent");
+               }
+
+               // these delegates are required to keep context
+               this._mouseMoveDelegate = function(event) {
+                       return that._mouseMove(event);
+               };
+               this._mouseUpDelegate = function(event) {
+                       return that._mouseUp(event);
+               };
+
+               this.document
+                       .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
+                       .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
+
+               event.preventDefault();
+
+               mouseHandled = true;
+               return true;
+       },
+
+       _mouseMove: function(event) {
+               // Only check for mouseups outside the document if you've moved inside the document
+               // at least once. This prevents the firing of mouseup in the case of IE<9, which will
+               // fire a mousemove event if content is placed under the cursor. See #7778
+               // Support: IE <9
+               if ( this._mouseMoved ) {
+                       // IE mouseup check - mouseup happened when mouse was out of window
+                       if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
+                               return this._mouseUp(event);
+
+                       // Iframe mouseup check - mouseup occurred in another document
+                       } else if ( !event.which ) {
+                               return this._mouseUp( event );
+                       }
+               }
+
+               if ( event.which || event.button ) {
+                       this._mouseMoved = true;
+               }
+
+               if (this._mouseStarted) {
+                       this._mouseDrag(event);
+                       return event.preventDefault();
+               }
+
+               if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+                       this._mouseStarted =
+                               (this._mouseStart(this._mouseDownEvent, event) !== false);
+                       (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+               }
+
+               return !this._mouseStarted;
+       },
+
+       _mouseUp: function(event) {
+               this.document
+                       .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
+                       .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
+
+               if (this._mouseStarted) {
+                       this._mouseStarted = false;
+
+                       if (event.target === this._mouseDownEvent.target) {
+                               $.data(event.target, this.widgetName + ".preventClickEvent", true);
+                       }
+
+                       this._mouseStop(event);
+               }
+
+               mouseHandled = false;
+               return false;
+       },
+
+       _mouseDistanceMet: function(event) {
+               return (Math.max(
+                               Math.abs(this._mouseDownEvent.pageX - event.pageX),
+                               Math.abs(this._mouseDownEvent.pageY - event.pageY)
+                       ) >= this.options.distance
+               );
+       },
+
+       _mouseDelayMet: function(/* event */) {
+               return this.mouseDelayMet;
+       },
+
+       // These are placeholder methods, to be overriden by extending plugin
+       _mouseStart: function(/* event */) {},
+       _mouseDrag: function(/* event */) {},
+       _mouseStop: function(/* event */) {},
+       _mouseCapture: function(/* event */) { return true; }
+});
+
+}));