PageSourceSearch

https://www.pitajucene.com/wp-includes/js/jquery/ui/mouse.js?ver=1.14.2

js pitajucene.com collected 2026-09-24 10:18:27 UTC 5,625 bytes, 223 lines download raw bytes

vendor: 5,625 bytes, lines 1-223
1/*!
2 * jQuery UI Mouse 1.14.2
3 * https://jqueryui.com
4 *
5 * Copyright OpenJS Foundation and other contributors
6 * Released under the MIT license.
7 * https://jquery.org/license
8 */
9
10//>>label: Mouse
11//>>group: Widgets
12//>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
13//>>docs: https://api.jqueryui.com/mouse/
14
15( function( factory ) {
16	"use strict";
17
18	if ( typeof define === "function" && define.amd ) {
19
20		// AMD. Register as an anonymous module.
21		define( [
22			"jquery",
23			"../version",
24			"../widget"
25		], factory );
26	} else {
27
28		// Browser globals
29		factory( jQuery );
30	}
31} )( function( $ ) {
32"use strict";
33
34var mouseHandled = false;
35$( document ).on( "mouseup", function() {
36	mouseHandled = false;
37} );
38
39return $.widget( "ui.mouse", {
40	version: "1.14.2",
41	options: {
42		cancel: "input, textarea, button, select, option",
43		distance: 1,
44		delay: 0
45	},
46	_mouseInit: function() {
47		var that = this;
48
49		this.element
50			.on( "mousedown." + this.widgetName, function( event ) {
51				return that._mouseDown( event );
52			} )
53			.on( "click." + this.widgetName, function( event ) {
54				if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
55					$.removeData( event.target, that.widgetName + ".preventClickEvent" );
56					event.stopImmediatePropagation();
57					return false;
58				}
59			} );
60
61		this.started = false;
62	},
63
64	// TODO: make sure destroying one instance of mouse doesn't mess with
65	// other instances of mouse
66	_mouseDestroy: function() {
67		this.element.off( "." + this.widgetName );
68		if ( this._mouseMoveDelegate ) {
69			this.document
70				.off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
71				.off( "mouseup." + this.widgetName, this._mouseUpDelegate );
72		}
73	},
74
75	_mouseDown: function( event ) {
76
77		// don't let more than one widget handle mouseStart
78		if ( mouseHandled ) {
79			return;
80		}
81
82		this._mouseMoved = false;
83
84		// We may have missed mouseup (out of window)
85		if ( this._mouseStarted ) {
86			this._mouseUp( event );
87		}
88
89		this._mouseDownEvent = event;
90
91		var that = this,
92			btnIsLeft = event.which === 1,
93			elIsCancel = typeof this.options.cancel === "string" ?
94				$( event.target ).closest( this.options.cancel ).length :
95				false;
96		if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
97			return true;
98		}
99
100		this.mouseDelayMet = !this.options.delay;
101		if ( !this.mouseDelayMet ) {
102			this._mouseDelayTimer = setTimeout( function() {
103				that.mouseDelayMet = true;
104			}, this.options.delay );
105		}
106
107		if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
108			this._mouseStarted = ( this._mouseStart( event ) !== false );
109			if ( !this._mouseStarted ) {
110				event.preventDefault();
111				return true;
112			}
113		}
114
115		// Click event may never have fired (Gecko & Opera)
116		if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
117			$.removeData( event.target, this.widgetName + ".preventClickEvent" );
118		}
119
120		// These delegates are required to keep context
121		this._mouseMoveDelegate = function( event ) {
122			return that._mouseMove( event );
123		};
124		this._mouseUpDelegate = function( event ) {
125			return that._mouseUp( event );
126		};
127
128		this.document
129			.on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
130			.on( "mouseup." + this.widgetName, this._mouseUpDelegate );
131
132		event.preventDefault();
133
134		mouseHandled = true;
135		return true;
136	},
137
138	_mouseMove: function( event ) {
139
140		// Only check for mouseups outside the document if you've moved inside the document
141		// at least once.
142		if ( this._mouseMoved && !event.which ) {
143
144			// Support: Safari <=8 - 9
145			// Safari sets which to 0 if you press any of the following keys
146			// during a drag (#14461)
147			if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
148					event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
149				this.ignoreMissingWhich = true;
150			} else if ( !this.ignoreMissingWhich ) {
151				return this._mouseUp( event );
152			}
153		}
154
155		if ( event.which || event.button ) {
156			this._mouseMoved = true;
157		}
158
159		if ( this._mouseStarted ) {
160			this._mouseDrag( event );
161			return event.preventDefault();
162		}
163
164		if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
165			this._mouseStarted =
166				( this._mouseStart( this._mouseDownEvent, event ) !== false );
167			if ( this._mouseStarted ) {
168				this._mouseDrag( event );
169			} else {
170				this._mouseUp( event );
171			}
172		}
173
174		return !this._mouseStarted;
175	},
176
177	_mouseUp: function( event ) {
178		this.document
179			.off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
180			.off( "mouseup." + this.widgetName, this._mouseUpDelegate );
181
182		if ( this._mouseStarted ) {
183			this._mouseStarted = false;
184
185			if ( event.target === this._mouseDownEvent.target ) {
186				$.data( event.target, this.widgetName + ".preventClickEvent", true );
187			}
188
189			this._mouseStop( event );
190		}
191
192		if ( this._mouseDelayTimer ) {
193			clearTimeout( this._mouseDelayTimer );
194			delete this._mouseDelayTimer;
195		}
196
197		this.ignoreMissingWhich = false;
198		mouseHandled = false;
199		event.preventDefault();
200	},
201
202	_mouseDistanceMet: function( event ) {
203		return ( Math.max(
204				Math.abs( this._mouseDownEvent.pageX - event.pageX ),
205				Math.abs( this._mouseDownEvent.pageY - event.pageY )
206			) >= this.options.distance
207		);
208	},
209
210	_mouseDelayMet: function( /* event */ ) {
211		return this.mouseDelayMet;
212	},
213
214	// These are placeholder methods, to be overriden by extending plugin
215	_mouseStart: function( /* event */ ) {},
216	_mouseDrag: function( /* event */ ) {},
217	_mouseStop: function( /* event */ ) {},
218	_mouseCapture: function( /* event */ ) {
219		return true;
220	}
221} );
222
223} );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.