aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorAlexander Schmitz <arschmitz@gmail.com>2015-08-24 08:59:04 -0400
committerAlexander Schmitz <arschmitz@gmail.com>2015-09-11 08:29:08 -0400
commita3a847f23a3ab7323df495fa81ad69e0b93196c4 (patch)
treecf8c0cd46129e6386f21ecf042e52fbf9156bfaf /ui
parent12be35562af60ea25a6578005cf8b914345f26e3 (diff)
downloadjquery-ui-a3a847f23a3ab7323df495fa81ad69e0b93196c4.tar.gz
jquery-ui-a3a847f23a3ab7323df495fa81ad69e0b93196c4.zip
Mouse: Style updates
Ref #14246
Diffstat (limited to 'ui')
-rw-r--r--ui/widgets/mouse.js116
1 files changed, 60 insertions, 56 deletions
diff --git a/ui/widgets/mouse.js b/ui/widgets/mouse.js
index b06f219b4..3f07e1101 100644
--- a/ui/widgets/mouse.js
+++ b/ui/widgets/mouse.js
@@ -12,11 +12,11 @@
//>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
//>>docs: http://api.jqueryui.com/mouse/
-(function( factory ) {
+( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
- define([
+ define( [
"jquery",
"../ie",
"../version",
@@ -27,14 +27,14 @@
// Browser globals
factory( jQuery );
}
-}(function( $ ) {
+}( function( $ ) {
var mouseHandled = false;
$( document ).on( "mouseup", function() {
mouseHandled = false;
-});
+} );
-return $.widget("ui.mouse", {
+return $.widget( "ui.mouse", {
version: "@VERSION",
options: {
cancel: "input, textarea, button, select, option",
@@ -45,16 +45,16 @@ return $.widget("ui.mouse", {
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");
+ .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;
},
@@ -62,15 +62,16 @@ return $.widget("ui.mouse", {
// TODO: make sure destroying one instance of mouse doesn't mess with
// other instances of mouse
_mouseDestroy: function() {
- this.element.off("." + this.widgetName);
+ this.element.off( "." + this.widgetName );
if ( this._mouseMoveDelegate ) {
this.document
- .off("mousemove." + this.widgetName, this._mouseMoveDelegate)
- .off("mouseup." + this.widgetName, this._mouseUpDelegate);
+ .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
+ .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
}
},
- _mouseDown: function(event) {
+ _mouseDown: function( event ) {
+
// don't let more than one widget handle mouseStart
if ( mouseHandled ) {
return;
@@ -79,45 +80,46 @@ return $.widget("ui.mouse", {
this._mouseMoved = false;
// We may have missed mouseup (out of window)
- (this._mouseStarted && this._mouseUp(event));
+ ( this._mouseStarted && this._mouseUp( event ) );
this._mouseDownEvent = event;
var that = this,
- btnIsLeft = (event.which === 1),
+ 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)) {
+ 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() {
+ if ( !this.mouseDelayMet ) {
+ this._mouseDelayTimer = setTimeout( function() {
that.mouseDelayMet = true;
- }, this.options.delay);
+ }, this.options.delay );
}
- if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
- this._mouseStarted = (this._mouseStart(event) !== false);
- if (!this._mouseStarted) {
+ 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");
+ 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._mouseMoveDelegate = function( event ) {
+ return that._mouseMove( event );
};
- this._mouseUpDelegate = function(event) {
- return that._mouseUp(event);
+ this._mouseUpDelegate = function( event ) {
+ return that._mouseUp( event );
};
this.document
@@ -130,15 +132,17 @@ return $.widget("ui.mouse", {
return true;
},
- _mouseMove: function(event) {
+ _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);
+ 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 ) {
@@ -150,33 +154,33 @@ return $.widget("ui.mouse", {
this._mouseMoved = true;
}
- if (this._mouseStarted) {
- this._mouseDrag(event);
+ if ( this._mouseStarted ) {
+ this._mouseDrag( event );
return event.preventDefault();
}
- if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
this._mouseStarted =
- (this._mouseStart(this._mouseDownEvent, event) !== false);
- (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+ ( this._mouseStart( this._mouseDownEvent, event ) !== false );
+ ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
}
return !this._mouseStarted;
},
- _mouseUp: function(event) {
+ _mouseUp: function( event ) {
this.document
.off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
.off( "mouseup." + this.widgetName, this._mouseUpDelegate );
- if (this._mouseStarted) {
+ if ( this._mouseStarted ) {
this._mouseStarted = false;
- if (event.target === this._mouseDownEvent.target) {
- $.data(event.target, this.widgetName + ".preventClickEvent", true);
+ if ( event.target === this._mouseDownEvent.target ) {
+ $.data( event.target, this.widgetName + ".preventClickEvent", true );
}
- this._mouseStop(event);
+ this._mouseStop( event );
}
if (this._mouseDelayTimer) {
@@ -188,23 +192,23 @@ return $.widget("ui.mouse", {
return false;
},
- _mouseDistanceMet: function(event) {
- return (Math.max(
- Math.abs(this._mouseDownEvent.pageX - event.pageX),
- Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ _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 */) {
+ _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; }
-});
+ _mouseStart: function( /* event */ ) {},
+ _mouseDrag: function( /* event */ ) {},
+ _mouseStop: function( /* event */ ) {},
+ _mouseCapture: function( /* event */ ) { return true; }
+} );
-}));
+} ) );