Projet

Général

Profil

Révision 503b3f7b

Ajouté par Assos Assos il y a environ 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/jquery_update/replace/ui/ui/jquery.ui.mouse.js
1 1
/*!
2
 * jQuery UI Mouse 1.8.11
2
 * jQuery UI Mouse 1.10.2
3
 * http://jqueryui.com
3 4
 *
4
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
 * Dual licensed under the MIT or GPL Version 2 licenses.
5
 * Copyright 2013 jQuery Foundation and other contributors
6
 * Released under the MIT license.
6 7
 * http://jquery.org/license
7 8
 *
8
 * http://docs.jquery.com/UI/Mouse
9
 * http://api.jqueryui.com/mouse/
9 10
 *
10 11
 * Depends:
11 12
 *	jquery.ui.widget.js
12 13
 */
13 14
(function( $, undefined ) {
14 15

  
16
var mouseHandled = false;
17
$( document ).mouseup( function() {
18
	mouseHandled = false;
19
});
20

  
15 21
$.widget("ui.mouse", {
22
	version: "1.10.2",
16 23
	options: {
17
		cancel: ':input,option',
24
		cancel: "input,textarea,button,select,option",
18 25
		distance: 1,
19 26
		delay: 0
20 27
	},
21 28
	_mouseInit: function() {
22
		var self = this;
29
		var that = this;
23 30

  
24 31
		this.element
25
			.bind('mousedown.'+this.widgetName, function(event) {
26
				return self._mouseDown(event);
32
			.bind("mousedown."+this.widgetName, function(event) {
33
				return that._mouseDown(event);
27 34
			})
28
			.bind('click.'+this.widgetName, function(event) {
29
				if (true === $.data(event.target, self.widgetName + '.preventClickEvent')) {
30
				    $.removeData(event.target, self.widgetName + '.preventClickEvent');
35
			.bind("click."+this.widgetName, function(event) {
36
				if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
37
					$.removeData(event.target, that.widgetName + ".preventClickEvent");
31 38
					event.stopImmediatePropagation();
32 39
					return false;
33 40
				}
......
39 46
	// TODO: make sure destroying one instance of mouse doesn't mess with
40 47
	// other instances of mouse
41 48
	_mouseDestroy: function() {
42
		this.element.unbind('.'+this.widgetName);
49
		this.element.unbind("."+this.widgetName);
50
		if ( this._mouseMoveDelegate ) {
51
			$(document)
52
				.unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
53
				.unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
54
		}
43 55
	},
44 56

  
45 57
	_mouseDown: function(event) {
46 58
		// don't let more than one widget handle mouseStart
47
		// TODO: figure out why we have to use originalEvent
48
		event.originalEvent = event.originalEvent || {};
49
		if (event.originalEvent.mouseHandled) { return; }
59
		if( mouseHandled ) { return; }
50 60

  
51 61
		// we may have missed mouseup (out of window)
52 62
		(this._mouseStarted && this._mouseUp(event));
53 63

  
54 64
		this._mouseDownEvent = event;
55 65

  
56
		var self = this,
57
			btnIsLeft = (event.which == 1),
58
			elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
66
		var that = this,
67
			btnIsLeft = (event.which === 1),
68
			// event.target.nodeName works around a bug in IE 8 with
69
			// disabled inputs (#7620)
70
			elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
59 71
		if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
60 72
			return true;
61 73
		}
......
63 75
		this.mouseDelayMet = !this.options.delay;
64 76
		if (!this.mouseDelayMet) {
65 77
			this._mouseDelayTimer = setTimeout(function() {
66
				self.mouseDelayMet = true;
78
				that.mouseDelayMet = true;
67 79
			}, this.options.delay);
68 80
		}
69 81

  
......
76 88
		}
77 89

  
78 90
		// Click event may never have fired (Gecko & Opera)
79
		if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
80
			$.removeData(event.target, this.widgetName + '.preventClickEvent');
91
		if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
92
			$.removeData(event.target, this.widgetName + ".preventClickEvent");
81 93
		}
82 94

  
83 95
		// these delegates are required to keep context
84 96
		this._mouseMoveDelegate = function(event) {
85
			return self._mouseMove(event);
97
			return that._mouseMove(event);
86 98
		};
87 99
		this._mouseUpDelegate = function(event) {
88
			return self._mouseUp(event);
100
			return that._mouseUp(event);
89 101
		};
90 102
		$(document)
91
			.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
92
			.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
103
			.bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
104
			.bind("mouseup."+this.widgetName, this._mouseUpDelegate);
93 105

  
94 106
		event.preventDefault();
95
		event.originalEvent.mouseHandled = true;
107

  
108
		mouseHandled = true;
96 109
		return true;
97 110
	},
98 111

  
99 112
	_mouseMove: function(event) {
100 113
		// IE mouseup check - mouseup happened when mouse was out of window
101
		if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
114
		if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
102 115
			return this._mouseUp(event);
103 116
		}
104 117

  
......
118 131

  
119 132
	_mouseUp: function(event) {
120 133
		$(document)
121
			.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
122
			.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
134
			.unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
135
			.unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
123 136

  
124 137
		if (this._mouseStarted) {
125 138
			this._mouseStarted = false;
126 139

  
127
			if (event.target == this._mouseDownEvent.target) {
128
			    $.data(event.target, this.widgetName + '.preventClickEvent', true);
140
			if (event.target === this._mouseDownEvent.target) {
141
				$.data(event.target, this.widgetName + ".preventClickEvent", true);
129 142
			}
130 143

  
131 144
			this._mouseStop(event);
......
142 155
		);
143 156
	},
144 157

  
145
	_mouseDelayMet: function(event) {
158
	_mouseDelayMet: function(/* event */) {
146 159
		return this.mouseDelayMet;
147 160
	},
148 161

  
149 162
	// These are placeholder methods, to be overriden by extending plugin
150
	_mouseStart: function(event) {},
151
	_mouseDrag: function(event) {},
152
	_mouseStop: function(event) {},
153
	_mouseCapture: function(event) { return true; }
163
	_mouseStart: function(/* event */) {},
164
	_mouseDrag: function(/* event */) {},
165
	_mouseStop: function(/* event */) {},
166
	_mouseCapture: function(/* event */) { return true; }
154 167
});
155 168

  
156 169
})(jQuery);

Formats disponibles : Unified diff