11 //>>group: Widgets |
11 //>>group: Widgets |
12 //>>description: Abstracts mouse-based interactions to assist in creating certain widgets. |
12 //>>description: Abstracts mouse-based interactions to assist in creating certain widgets. |
13 //>>docs: http://api.jqueryui.com/mouse/ |
13 //>>docs: http://api.jqueryui.com/mouse/ |
14 |
14 |
15 ( function( factory ) { |
15 ( function( factory ) { |
|
16 "use strict"; |
|
17 |
16 if ( typeof define === "function" && define.amd ) { |
18 if ( typeof define === "function" && define.amd ) { |
17 |
19 |
18 // AMD. Register as an anonymous module. |
20 // AMD. Register as an anonymous module. |
19 define( [ |
21 define( [ |
20 "jquery", |
22 "jquery", |
23 } else { |
25 } else { |
24 |
26 |
25 // Browser globals |
27 // Browser globals |
26 factory( jQuery ); |
28 factory( jQuery ); |
27 } |
29 } |
28 }( function( $ ) { |
30 } )( function( $ ) { |
|
31 "use strict"; |
29 |
32 |
30 var mouseHandled = false; |
33 var mouseHandled = false; |
31 $( document ).on( "mouseup", function() { |
34 $( document ).on( "mouseup", function() { |
32 mouseHandled = false; |
35 mouseHandled = false; |
33 } ); |
36 } ); |
34 |
37 |
35 return $.widget( "ui.mouse", { |
38 return $.widget( "ui.mouse", { |
36 version: "1.12.1", |
39 version: "1.13.1", |
37 options: { |
40 options: { |
38 cancel: "input, textarea, button, select, option", |
41 cancel: "input, textarea, button, select, option", |
39 distance: 1, |
42 distance: 1, |
40 delay: 0 |
43 delay: 0 |
41 }, |
44 }, |
76 } |
79 } |
77 |
80 |
78 this._mouseMoved = false; |
81 this._mouseMoved = false; |
79 |
82 |
80 // We may have missed mouseup (out of window) |
83 // We may have missed mouseup (out of window) |
81 ( this._mouseStarted && this._mouseUp( event ) ); |
84 if ( this._mouseStarted ) { |
|
85 this._mouseUp( event ); |
|
86 } |
82 |
87 |
83 this._mouseDownEvent = event; |
88 this._mouseDownEvent = event; |
84 |
89 |
85 var that = this, |
90 var that = this, |
86 btnIsLeft = ( event.which === 1 ), |
91 btnIsLeft = ( event.which === 1 ), |
139 // Support: IE <9 |
144 // Support: IE <9 |
140 if ( this._mouseMoved ) { |
145 if ( this._mouseMoved ) { |
141 |
146 |
142 // IE mouseup check - mouseup happened when mouse was out of window |
147 // IE mouseup check - mouseup happened when mouse was out of window |
143 if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && |
148 if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && |
144 !event.button ) { |
149 !event.button ) { |
145 return this._mouseUp( event ); |
150 return this._mouseUp( event ); |
146 |
151 |
147 // Iframe mouseup check - mouseup occurred in another document |
152 // Iframe mouseup check - mouseup occurred in another document |
148 } else if ( !event.which ) { |
153 } else if ( !event.which ) { |
149 |
154 |
150 // Support: Safari <=8 - 9 |
155 // Support: Safari <=8 - 9 |
151 // Safari sets which to 0 if you press any of the following keys |
156 // Safari sets which to 0 if you press any of the following keys |
152 // during a drag (#14461) |
157 // during a drag (#14461) |
153 if ( event.originalEvent.altKey || event.originalEvent.ctrlKey || |
158 if ( event.originalEvent.altKey || event.originalEvent.ctrlKey || |
154 event.originalEvent.metaKey || event.originalEvent.shiftKey ) { |
159 event.originalEvent.metaKey || event.originalEvent.shiftKey ) { |
155 this.ignoreMissingWhich = true; |
160 this.ignoreMissingWhich = true; |
156 } else if ( !this.ignoreMissingWhich ) { |
161 } else if ( !this.ignoreMissingWhich ) { |
157 return this._mouseUp( event ); |
162 return this._mouseUp( event ); |
158 } |
163 } |
159 } |
164 } |
169 } |
174 } |
170 |
175 |
171 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { |
176 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { |
172 this._mouseStarted = |
177 this._mouseStarted = |
173 ( this._mouseStart( this._mouseDownEvent, event ) !== false ); |
178 ( this._mouseStart( this._mouseDownEvent, event ) !== false ); |
174 ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) ); |
179 if ( this._mouseStarted ) { |
|
180 this._mouseDrag( event ); |
|
181 } else { |
|
182 this._mouseUp( event ); |
|
183 } |
175 } |
184 } |
176 |
185 |
177 return !this._mouseStarted; |
186 return !this._mouseStarted; |
178 }, |
187 }, |
179 |
188 |
216 |
225 |
217 // These are placeholder methods, to be overriden by extending plugin |
226 // These are placeholder methods, to be overriden by extending plugin |
218 _mouseStart: function( /* event */ ) {}, |
227 _mouseStart: function( /* event */ ) {}, |
219 _mouseDrag: function( /* event */ ) {}, |
228 _mouseDrag: function( /* event */ ) {}, |
220 _mouseStop: function( /* event */ ) {}, |
229 _mouseStop: function( /* event */ ) {}, |
221 _mouseCapture: function( /* event */ ) { return true; } |
230 _mouseCapture: function( /* event */ ) { |
|
231 return true; |
|
232 } |
222 } ); |
233 } ); |
223 |
234 |
224 } ) ); |
235 } ); |