Révision 503b3f7b
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/jquery_update/replace/ui/ui/jquery.ui.draggable.js | ||
---|---|---|
1 |
/* |
|
2 |
* jQuery UI Draggable 1.8.11 |
|
1 |
/*! |
|
2 |
* jQuery UI Draggable 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/Draggables
|
|
9 |
* http://api.jqueryui.com/draggable/
|
|
9 | 10 |
* |
10 | 11 |
* Depends: |
11 | 12 |
* jquery.ui.core.js |
... | ... | |
15 | 16 |
(function( $, undefined ) { |
16 | 17 |
|
17 | 18 |
$.widget("ui.draggable", $.ui.mouse, { |
19 |
version: "1.10.2", |
|
18 | 20 |
widgetEventPrefix: "drag", |
19 | 21 |
options: { |
20 | 22 |
addClasses: true, |
... | ... | |
40 | 42 |
snapMode: "both", |
41 | 43 |
snapTolerance: 20, |
42 | 44 |
stack: false, |
43 |
zIndex: false |
|
45 |
zIndex: false, |
|
46 |
|
|
47 |
// callbacks |
|
48 |
drag: null, |
|
49 |
start: null, |
|
50 |
stop: null |
|
44 | 51 |
}, |
45 | 52 |
_create: function() { |
46 | 53 |
|
47 |
if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) |
|
48 |
this.element[0].style.position = 'relative'; |
|
49 |
|
|
50 |
(this.options.addClasses && this.element.addClass("ui-draggable")); |
|
51 |
(this.options.disabled && this.element.addClass("ui-draggable-disabled")); |
|
54 |
if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) { |
|
55 |
this.element[0].style.position = "relative"; |
|
56 |
} |
|
57 |
if (this.options.addClasses){ |
|
58 |
this.element.addClass("ui-draggable"); |
|
59 |
} |
|
60 |
if (this.options.disabled){ |
|
61 |
this.element.addClass("ui-draggable-disabled"); |
|
62 |
} |
|
52 | 63 |
|
53 | 64 |
this._mouseInit(); |
54 | 65 |
|
55 | 66 |
}, |
56 | 67 |
|
57 |
destroy: function() { |
|
58 |
if(!this.element.data('draggable')) return; |
|
59 |
this.element |
|
60 |
.removeData("draggable") |
|
61 |
.unbind(".draggable") |
|
62 |
.removeClass("ui-draggable" |
|
63 |
+ " ui-draggable-dragging" |
|
64 |
+ " ui-draggable-disabled"); |
|
68 |
_destroy: function() { |
|
69 |
this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" ); |
|
65 | 70 |
this._mouseDestroy(); |
66 |
|
|
67 |
return this; |
|
68 | 71 |
}, |
69 | 72 |
|
70 | 73 |
_mouseCapture: function(event) { |
... | ... | |
72 | 75 |
var o = this.options; |
73 | 76 |
|
74 | 77 |
// among others, prevent a drag on a resizable-handle |
75 |
if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
|
|
78 |
if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
|
|
76 | 79 |
return false; |
80 |
} |
|
77 | 81 |
|
78 | 82 |
//Quit if we're not on a valid handle |
79 | 83 |
this.handle = this._getHandle(event); |
80 |
if (!this.handle) |
|
84 |
if (!this.handle) {
|
|
81 | 85 |
return false; |
86 |
} |
|
87 |
|
|
88 |
$(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { |
|
89 |
$("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>") |
|
90 |
.css({ |
|
91 |
width: this.offsetWidth+"px", height: this.offsetHeight+"px", |
|
92 |
position: "absolute", opacity: "0.001", zIndex: 1000 |
|
93 |
}) |
|
94 |
.css($(this).offset()) |
|
95 |
.appendTo("body"); |
|
96 |
}); |
|
82 | 97 |
|
83 | 98 |
return true; |
84 | 99 |
|
... | ... | |
91 | 106 |
//Create and append the visible helper |
92 | 107 |
this.helper = this._createHelper(event); |
93 | 108 |
|
109 |
this.helper.addClass("ui-draggable-dragging"); |
|
110 |
|
|
94 | 111 |
//Cache the helper size |
95 | 112 |
this._cacheHelperProportions(); |
96 | 113 |
|
97 | 114 |
//If ddmanager is used for droppables, set the global draggable |
98 |
if($.ui.ddmanager) |
|
115 |
if($.ui.ddmanager) {
|
|
99 | 116 |
$.ui.ddmanager.current = this; |
117 |
} |
|
100 | 118 |
|
101 | 119 |
/* |
102 | 120 |
* - Position generation - |
... | ... | |
131 | 149 |
this.originalPageX = event.pageX; |
132 | 150 |
this.originalPageY = event.pageY; |
133 | 151 |
|
134 |
//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
|
|
152 |
//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
|
|
135 | 153 |
(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); |
136 | 154 |
|
137 | 155 |
//Set a containment if given in the options |
138 |
if(o.containment) |
|
156 |
if(o.containment) {
|
|
139 | 157 |
this._setContainment(); |
158 |
} |
|
140 | 159 |
|
141 | 160 |
//Trigger event + callbacks |
142 | 161 |
if(this._trigger("start", event) === false) { |
... | ... | |
148 | 167 |
this._cacheHelperProportions(); |
149 | 168 |
|
150 | 169 |
//Prepare the droppable offsets |
151 |
if ($.ui.ddmanager && !o.dropBehaviour) |
|
170 |
if ($.ui.ddmanager && !o.dropBehaviour) {
|
|
152 | 171 |
$.ui.ddmanager.prepareOffsets(this, event); |
172 |
} |
|
173 |
|
|
153 | 174 |
|
154 |
this.helper.addClass("ui-draggable-dragging"); |
|
155 | 175 |
this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
176 |
|
|
177 |
//If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003) |
|
178 |
if ( $.ui.ddmanager ) { |
|
179 |
$.ui.ddmanager.dragStart(this, event); |
|
180 |
} |
|
181 |
|
|
156 | 182 |
return true; |
157 | 183 |
}, |
158 | 184 |
|
... | ... | |
165 | 191 |
//Call plugins and callbacks and use the resulting position if something is returned |
166 | 192 |
if (!noPropagation) { |
167 | 193 |
var ui = this._uiHash(); |
168 |
if(this._trigger('drag', event, ui) === false) {
|
|
194 |
if(this._trigger("drag", event, ui) === false) {
|
|
169 | 195 |
this._mouseUp({}); |
170 | 196 |
return false; |
171 | 197 |
} |
172 | 198 |
this.position = ui.position; |
173 | 199 |
} |
174 | 200 |
|
175 |
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; |
|
176 |
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; |
|
177 |
if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); |
|
201 |
if(!this.options.axis || this.options.axis !== "y") { |
|
202 |
this.helper[0].style.left = this.position.left+"px"; |
|
203 |
} |
|
204 |
if(!this.options.axis || this.options.axis !== "x") { |
|
205 |
this.helper[0].style.top = this.position.top+"px"; |
|
206 |
} |
|
207 |
if($.ui.ddmanager) { |
|
208 |
$.ui.ddmanager.drag(this, event); |
|
209 |
} |
|
178 | 210 |
|
179 | 211 |
return false; |
180 | 212 |
}, |
... | ... | |
182 | 214 |
_mouseStop: function(event) { |
183 | 215 |
|
184 | 216 |
//If we are using droppables, inform the manager about the drop |
185 |
var dropped = false; |
|
186 |
if ($.ui.ddmanager && !this.options.dropBehaviour) |
|
217 |
var element, |
|
218 |
that = this, |
|
219 |
elementInDom = false, |
|
220 |
dropped = false; |
|
221 |
if ($.ui.ddmanager && !this.options.dropBehaviour) { |
|
187 | 222 |
dropped = $.ui.ddmanager.drop(this, event); |
223 |
} |
|
188 | 224 |
|
189 | 225 |
//if a drop comes from outside (a sortable) |
190 | 226 |
if(this.dropped) { |
191 | 227 |
dropped = this.dropped; |
192 | 228 |
this.dropped = false; |
193 | 229 |
} |
194 |
|
|
195 |
//if the original element is removed, don't bother to continue if helper is set to "original" |
|
196 |
if((!this.element[0] || !this.element[0].parentNode) && this.options.helper == "original") |
|
230 |
|
|
231 |
//if the original element is no longer in the DOM don't bother to continue (see #8269) |
|
232 |
element = this.element[0]; |
|
233 |
while ( element && (element = element.parentNode) ) { |
|
234 |
if (element === document ) { |
|
235 |
elementInDom = true; |
|
236 |
} |
|
237 |
} |
|
238 |
if ( !elementInDom && this.options.helper === "original" ) { |
|
197 | 239 |
return false; |
240 |
} |
|
198 | 241 |
|
199 |
if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { |
|
200 |
var self = this; |
|
242 |
if((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { |
|
201 | 243 |
$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { |
202 |
if(self._trigger("stop", event) !== false) {
|
|
203 |
self._clear();
|
|
244 |
if(that._trigger("stop", event) !== false) {
|
|
245 |
that._clear();
|
|
204 | 246 |
} |
205 | 247 |
}); |
206 | 248 |
} else { |
... | ... | |
211 | 253 |
|
212 | 254 |
return false; |
213 | 255 |
}, |
214 |
|
|
256 |
|
|
257 |
_mouseUp: function(event) { |
|
258 |
//Remove frame helpers |
|
259 |
$("div.ui-draggable-iframeFix").each(function() { |
|
260 |
this.parentNode.removeChild(this); |
|
261 |
}); |
|
262 |
|
|
263 |
//If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) |
|
264 |
if( $.ui.ddmanager ) { |
|
265 |
$.ui.ddmanager.dragStop(this, event); |
|
266 |
} |
|
267 |
|
|
268 |
return $.ui.mouse.prototype._mouseUp.call(this, event); |
|
269 |
}, |
|
270 |
|
|
215 | 271 |
cancel: function() { |
216 |
|
|
272 |
|
|
217 | 273 |
if(this.helper.is(".ui-draggable-dragging")) { |
218 | 274 |
this._mouseUp({}); |
219 | 275 |
} else { |
220 | 276 |
this._clear(); |
221 | 277 |
} |
222 |
|
|
278 |
|
|
223 | 279 |
return this; |
224 |
|
|
280 |
|
|
225 | 281 |
}, |
226 | 282 |
|
227 | 283 |
_getHandle: function(event) { |
228 |
|
|
229 |
var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; |
|
230 |
$(this.options.handle, this.element) |
|
231 |
.find("*") |
|
232 |
.andSelf() |
|
233 |
.each(function() { |
|
234 |
if(this == event.target) handle = true; |
|
235 |
}); |
|
236 |
|
|
237 |
return handle; |
|
238 |
|
|
284 |
return this.options.handle ? |
|
285 |
!!$( event.target ).closest( this.element.find( this.options.handle ) ).length : |
|
286 |
true; |
|
239 | 287 |
}, |
240 | 288 |
|
241 | 289 |
_createHelper: function(event) { |
242 | 290 |
|
243 |
var o = this.options;
|
|
244 |
var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element);
|
|
291 |
var o = this.options,
|
|
292 |
helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
|
|
245 | 293 |
|
246 |
if(!helper.parents('body').length) |
|
247 |
helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo)); |
|
294 |
if(!helper.parents("body").length) { |
|
295 |
helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo)); |
|
296 |
} |
|
248 | 297 |
|
249 |
if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
|
|
298 |
if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
|
|
250 | 299 |
helper.css("position", "absolute"); |
300 |
} |
|
251 | 301 |
|
252 | 302 |
return helper; |
253 | 303 |
|
254 | 304 |
}, |
255 | 305 |
|
256 | 306 |
_adjustOffsetFromHelper: function(obj) { |
257 |
if (typeof obj == 'string') {
|
|
258 |
obj = obj.split(' ');
|
|
307 |
if (typeof obj === "string") {
|
|
308 |
obj = obj.split(" ");
|
|
259 | 309 |
} |
260 | 310 |
if ($.isArray(obj)) { |
261 | 311 |
obj = {left: +obj[0], top: +obj[1] || 0}; |
262 | 312 |
} |
263 |
if ('left' in obj) {
|
|
313 |
if ("left" in obj) {
|
|
264 | 314 |
this.offset.click.left = obj.left + this.margins.left; |
265 | 315 |
} |
266 |
if ('right' in obj) {
|
|
316 |
if ("right" in obj) {
|
|
267 | 317 |
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; |
268 | 318 |
} |
269 |
if ('top' in obj) {
|
|
319 |
if ("top" in obj) {
|
|
270 | 320 |
this.offset.click.top = obj.top + this.margins.top; |
271 | 321 |
} |
272 |
if ('bottom' in obj) {
|
|
322 |
if ("bottom" in obj) {
|
|
273 | 323 |
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; |
274 | 324 |
} |
275 | 325 |
}, |
... | ... | |
284 | 334 |
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent |
285 | 335 |
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that |
286 | 336 |
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag |
287 |
if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
|
|
337 |
if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
|
|
288 | 338 |
po.left += this.scrollParent.scrollLeft(); |
289 | 339 |
po.top += this.scrollParent.scrollTop(); |
290 | 340 |
} |
291 | 341 |
|
292 |
if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information |
|
293 |
|| (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix |
|
342 |
//This needs to be actually done for all browsers, since pageX/pageY includes this information |
|
343 |
//Ugly IE fix |
|
344 |
if((this.offsetParent[0] === document.body) || |
|
345 |
(this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) { |
|
294 | 346 |
po = { top: 0, left: 0 }; |
347 |
} |
|
295 | 348 |
|
296 | 349 |
return { |
297 | 350 |
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), |
... | ... | |
302 | 355 |
|
303 | 356 |
_getRelativeOffset: function() { |
304 | 357 |
|
305 |
if(this.cssPosition == "relative") { |
|
358 |
if(this.cssPosition === "relative") {
|
|
306 | 359 |
var p = this.element.position(); |
307 | 360 |
return { |
308 | 361 |
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), |
... | ... | |
332 | 385 |
|
333 | 386 |
_setContainment: function() { |
334 | 387 |
|
335 |
var o = this.options; |
|
336 |
if(o.containment == 'parent') o.containment = this.helper[0].parentNode; |
|
337 |
if(o.containment == 'document' || o.containment == 'window') this.containment = [ |
|
338 |
(o.containment == 'document' ? 0 : $(window).scrollLeft()) - this.offset.relative.left - this.offset.parent.left, |
|
339 |
(o.containment == 'document' ? 0 : $(window).scrollTop()) - this.offset.relative.top - this.offset.parent.top, |
|
340 |
(o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, |
|
341 |
(o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top |
|
342 |
]; |
|
343 |
|
|
344 |
if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) { |
|
345 |
var ce = $(o.containment)[0]; if(!ce) return; |
|
346 |
var co = $(o.containment).offset(); |
|
347 |
var over = ($(ce).css("overflow") != 'hidden'); |
|
388 |
var over, c, ce, |
|
389 |
o = this.options; |
|
348 | 390 |
|
391 |
if(o.containment === "parent") { |
|
392 |
o.containment = this.helper[0].parentNode; |
|
393 |
} |
|
394 |
if(o.containment === "document" || o.containment === "window") { |
|
349 | 395 |
this.containment = [ |
350 |
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
|
|
351 |
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
|
|
352 |
co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
|
|
353 |
co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom
|
|
396 |
o.containment === "document" ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
|
|
397 |
o.containment === "document" ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
|
|
398 |
(o.containment === "document" ? 0 : $(window).scrollLeft()) + $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
|
|
399 |
(o.containment === "document" ? 0 : $(window).scrollTop()) + ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
|
|
354 | 400 |
]; |
355 |
} else if(o.containment.constructor == Array) { |
|
401 |
} |
|
402 |
|
|
403 |
if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor !== Array) { |
|
404 |
c = $(o.containment); |
|
405 |
ce = c[0]; |
|
406 |
|
|
407 |
if(!ce) { |
|
408 |
return; |
|
409 |
} |
|
410 |
|
|
411 |
over = ($(ce).css("overflow") !== "hidden"); |
|
412 |
|
|
413 |
this.containment = [ |
|
414 |
(parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0), |
|
415 |
(parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0), |
|
416 |
(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderRightWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right, |
|
417 |
(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderBottomWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom |
|
418 |
]; |
|
419 |
this.relative_container = c; |
|
420 |
|
|
421 |
} else if(o.containment.constructor === Array) { |
|
356 | 422 |
this.containment = o.containment; |
357 | 423 |
} |
358 | 424 |
|
... | ... | |
360 | 426 |
|
361 | 427 |
_convertPositionTo: function(d, pos) { |
362 | 428 |
|
363 |
if(!pos) pos = this.position; |
|
364 |
var mod = d == "absolute" ? 1 : -1; |
|
365 |
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
429 |
if(!pos) { |
|
430 |
pos = this.position; |
|
431 |
} |
|
432 |
|
|
433 |
var mod = d === "absolute" ? 1 : -1, |
|
434 |
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
366 | 435 |
|
367 | 436 |
return { |
368 | 437 |
top: ( |
369 |
pos.top // The absolute mouse position |
|
370 |
+ this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
|
|
371 |
+ this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
|
|
372 |
- ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
|
|
438 |
pos.top + // The absolute mouse position
|
|
439 |
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
|
440 |
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
|
|
441 |
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
|
|
373 | 442 |
), |
374 | 443 |
left: ( |
375 |
pos.left // The absolute mouse position |
|
376 |
+ this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
|
|
377 |
+ this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
|
|
378 |
- ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
|
|
444 |
pos.left + // The absolute mouse position
|
|
445 |
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
|
446 |
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
|
|
447 |
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
|
|
379 | 448 |
) |
380 | 449 |
}; |
381 | 450 |
|
... | ... | |
383 | 452 |
|
384 | 453 |
_generatePosition: function(event) { |
385 | 454 |
|
386 |
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
387 |
var pageX = event.pageX; |
|
388 |
var pageY = event.pageY; |
|
455 |
var containment, co, top, left, |
|
456 |
o = this.options, |
|
457 |
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, |
|
458 |
scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName), |
|
459 |
pageX = event.pageX, |
|
460 |
pageY = event.pageY; |
|
389 | 461 |
|
390 | 462 |
/* |
391 | 463 |
* - Position constraining - |
... | ... | |
393 | 465 |
*/ |
394 | 466 |
|
395 | 467 |
if(this.originalPosition) { //If we are not dragging yet, we won't check for options |
396 |
|
|
397 | 468 |
if(this.containment) { |
398 |
if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left; |
|
399 |
if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top; |
|
400 |
if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left; |
|
401 |
if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top; |
|
469 |
if (this.relative_container){ |
|
470 |
co = this.relative_container.offset(); |
|
471 |
containment = [ this.containment[0] + co.left, |
|
472 |
this.containment[1] + co.top, |
|
473 |
this.containment[2] + co.left, |
|
474 |
this.containment[3] + co.top ]; |
|
475 |
} |
|
476 |
else { |
|
477 |
containment = this.containment; |
|
478 |
} |
|
479 |
|
|
480 |
if(event.pageX - this.offset.click.left < containment[0]) { |
|
481 |
pageX = containment[0] + this.offset.click.left; |
|
482 |
} |
|
483 |
if(event.pageY - this.offset.click.top < containment[1]) { |
|
484 |
pageY = containment[1] + this.offset.click.top; |
|
485 |
} |
|
486 |
if(event.pageX - this.offset.click.left > containment[2]) { |
|
487 |
pageX = containment[2] + this.offset.click.left; |
|
488 |
} |
|
489 |
if(event.pageY - this.offset.click.top > containment[3]) { |
|
490 |
pageY = containment[3] + this.offset.click.top; |
|
491 |
} |
|
402 | 492 |
} |
403 | 493 |
|
404 | 494 |
if(o.grid) { |
405 |
var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; |
|
406 |
pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; |
|
495 |
//Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950) |
|
496 |
top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY; |
|
497 |
pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; |
|
407 | 498 |
|
408 |
var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
|
|
409 |
pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
|
|
499 |
left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
|
|
500 |
pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
|
|
410 | 501 |
} |
411 | 502 |
|
412 | 503 |
} |
413 | 504 |
|
414 | 505 |
return { |
415 | 506 |
top: ( |
416 |
pageY // The absolute mouse position |
|
417 |
- this.offset.click.top // Click offset (relative to the element)
|
|
418 |
- this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
|
|
419 |
- this.offset.parent.top // The offsetParent's offset without borders (offset + border)
|
|
420 |
+ ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
|
|
507 |
pageY - // The absolute mouse position
|
|
508 |
this.offset.click.top - // Click offset (relative to the element)
|
|
509 |
this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
|
|
510 |
this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
|
|
511 |
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
|
|
421 | 512 |
), |
422 | 513 |
left: ( |
423 |
pageX // The absolute mouse position |
|
424 |
- this.offset.click.left // Click offset (relative to the element)
|
|
425 |
- this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
|
|
426 |
- this.offset.parent.left // The offsetParent's offset without borders (offset + border)
|
|
427 |
+ ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
|
|
514 |
pageX - // The absolute mouse position
|
|
515 |
this.offset.click.left - // Click offset (relative to the element)
|
|
516 |
this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
|
|
517 |
this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
|
|
518 |
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
|
|
428 | 519 |
) |
429 | 520 |
}; |
430 | 521 |
|
... | ... | |
432 | 523 |
|
433 | 524 |
_clear: function() { |
434 | 525 |
this.helper.removeClass("ui-draggable-dragging"); |
435 |
if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove(); |
|
436 |
//if($.ui.ddmanager) $.ui.ddmanager.current = null; |
|
526 |
if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) { |
|
527 |
this.helper.remove(); |
|
528 |
} |
|
437 | 529 |
this.helper = null; |
438 | 530 |
this.cancelHelperRemoval = false; |
439 | 531 |
}, |
... | ... | |
443 | 535 |
_trigger: function(type, event, ui) { |
444 | 536 |
ui = ui || this._uiHash(); |
445 | 537 |
$.ui.plugin.call(this, type, [event, ui]); |
446 |
if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins |
|
538 |
//The absolute position has to be recalculated after plugins |
|
539 |
if(type === "drag") { |
|
540 |
this.positionAbs = this._convertPositionTo("absolute"); |
|
541 |
} |
|
447 | 542 |
return $.Widget.prototype._trigger.call(this, type, event, ui); |
448 | 543 |
}, |
449 | 544 |
|
450 | 545 |
plugins: {}, |
451 | 546 |
|
452 |
_uiHash: function(event) {
|
|
547 |
_uiHash: function() { |
|
453 | 548 |
return { |
454 | 549 |
helper: this.helper, |
455 | 550 |
position: this.position, |
... | ... | |
460 | 555 |
|
461 | 556 |
}); |
462 | 557 |
|
463 |
$.extend($.ui.draggable, { |
|
464 |
version: "1.8.11" |
|
465 |
}); |
|
466 |
|
|
467 | 558 |
$.ui.plugin.add("draggable", "connectToSortable", { |
468 | 559 |
start: function(event, ui) { |
469 | 560 |
|
470 |
var inst = $(this).data("draggable"), o = inst.options, |
|
561 |
var inst = $(this).data("ui-draggable"), o = inst.options,
|
|
471 | 562 |
uiSortable = $.extend({}, ui, { item: inst.element }); |
472 | 563 |
inst.sortables = []; |
473 | 564 |
$(o.connectToSortable).each(function() { |
474 |
var sortable = $.data(this, 'sortable');
|
|
565 |
var sortable = $.data(this, "ui-sortable");
|
|
475 | 566 |
if (sortable && !sortable.options.disabled) { |
476 | 567 |
inst.sortables.push({ |
477 | 568 |
instance: sortable, |
... | ... | |
486 | 577 |
stop: function(event, ui) { |
487 | 578 |
|
488 | 579 |
//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper |
489 |
var inst = $(this).data("draggable"), |
|
580 |
var inst = $(this).data("ui-draggable"),
|
|
490 | 581 |
uiSortable = $.extend({}, ui, { item: inst.element }); |
491 | 582 |
|
492 | 583 |
$.each(inst.sortables, function() { |
... | ... | |
497 | 588 |
inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance |
498 | 589 |
this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work) |
499 | 590 |
|
500 |
//The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid' |
|
501 |
if(this.shouldRevert) this.instance.options.revert = true; |
|
591 |
//The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid" |
|
592 |
if(this.shouldRevert) { |
|
593 |
this.instance.options.revert = this.shouldRevert; |
|
594 |
} |
|
502 | 595 |
|
503 | 596 |
//Trigger the stop of the sortable |
504 | 597 |
this.instance._mouseStop(event); |
... | ... | |
506 | 599 |
this.instance.options.helper = this.instance.options._helper; |
507 | 600 |
|
508 | 601 |
//If the helper has been the original item, restore properties in the sortable |
509 |
if(inst.options.helper == 'original') |
|
510 |
this.instance.currentItem.css({ top: 'auto', left: 'auto' }); |
|
602 |
if(inst.options.helper === "original") { |
|
603 |
this.instance.currentItem.css({ top: "auto", left: "auto" }); |
|
604 |
} |
|
511 | 605 |
|
512 | 606 |
} else { |
513 | 607 |
this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance |
... | ... | |
519 | 613 |
}, |
520 | 614 |
drag: function(event, ui) { |
521 | 615 |
|
522 |
var inst = $(this).data("draggable"), self = this;
|
|
616 |
var inst = $(this).data("ui-draggable"), that = this;
|
|
523 | 617 |
|
524 |
var checkPos = function(o) { |
|
525 |
var dyClick = this.offset.click.top, dxClick = this.offset.click.left; |
|
526 |
var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left; |
|
527 |
var itemHeight = o.height, itemWidth = o.width; |
|
528 |
var itemTop = o.top, itemLeft = o.left; |
|
618 |
$.each(inst.sortables, function() { |
|
529 | 619 |
|
530 |
return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
|
|
531 |
};
|
|
620 |
var innermostIntersecting = false,
|
|
621 |
thisSortable = this;
|
|
532 | 622 |
|
533 |
$.each(inst.sortables, function(i) { |
|
534 |
|
|
535 | 623 |
//Copy over some variables to allow calling the sortable's native _intersectsWith |
536 | 624 |
this.instance.positionAbs = inst.positionAbs; |
537 | 625 |
this.instance.helperProportions = inst.helperProportions; |
538 | 626 |
this.instance.offset.click = inst.offset.click; |
539 |
|
|
627 |
|
|
540 | 628 |
if(this.instance._intersectsWith(this.instance.containerCache)) { |
629 |
innermostIntersecting = true; |
|
630 |
$.each(inst.sortables, function () { |
|
631 |
this.instance.positionAbs = inst.positionAbs; |
|
632 |
this.instance.helperProportions = inst.helperProportions; |
|
633 |
this.instance.offset.click = inst.offset.click; |
|
634 |
if (this !== thisSortable && |
|
635 |
this.instance._intersectsWith(this.instance.containerCache) && |
|
636 |
$.contains(thisSortable.instance.element[0], this.instance.element[0]) |
|
637 |
) { |
|
638 |
innermostIntersecting = false; |
|
639 |
} |
|
640 |
return innermostIntersecting; |
|
641 |
}); |
|
642 |
} |
|
643 |
|
|
541 | 644 |
|
645 |
if(innermostIntersecting) { |
|
542 | 646 |
//If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once |
543 | 647 |
if(!this.instance.isOver) { |
544 | 648 |
|
... | ... | |
546 | 650 |
//Now we fake the start of dragging for the sortable instance, |
547 | 651 |
//by cloning the list group item, appending it to the sortable and using it as inst.currentItem |
548 | 652 |
//We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one) |
549 |
this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
|
|
653 |
this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
|
|
550 | 654 |
this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it |
551 | 655 |
this.instance.options.helper = function() { return ui.helper[0]; }; |
552 | 656 |
|
... | ... | |
569 | 673 |
} |
570 | 674 |
|
571 | 675 |
//Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable |
572 |
if(this.instance.currentItem) this.instance._mouseDrag(event); |
|
676 |
if(this.instance.currentItem) { |
|
677 |
this.instance._mouseDrag(event); |
|
678 |
} |
|
573 | 679 |
|
574 | 680 |
} else { |
575 | 681 |
|
... | ... | |
579 | 685 |
|
580 | 686 |
this.instance.isOver = 0; |
581 | 687 |
this.instance.cancelHelperRemoval = true; |
582 |
|
|
688 |
|
|
583 | 689 |
//Prevent reverting on this forced stop |
584 | 690 |
this.instance.options.revert = false; |
585 |
|
|
691 |
|
|
586 | 692 |
// The out event needs to be triggered independently |
587 |
this.instance._trigger('out', event, this.instance._uiHash(this.instance));
|
|
588 |
|
|
693 |
this.instance._trigger("out", event, this.instance._uiHash(this.instance));
|
|
694 |
|
|
589 | 695 |
this.instance._mouseStop(event, true); |
590 | 696 |
this.instance.options.helper = this.instance.options._helper; |
591 | 697 |
|
592 | 698 |
//Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size |
593 | 699 |
this.instance.currentItem.remove(); |
594 |
if(this.instance.placeholder) this.instance.placeholder.remove(); |
|
700 |
if(this.instance.placeholder) { |
|
701 |
this.instance.placeholder.remove(); |
|
702 |
} |
|
595 | 703 |
|
596 | 704 |
inst._trigger("fromSortable", event); |
597 | 705 |
inst.dropped = false; //draggable revert needs that |
598 | 706 |
} |
599 | 707 |
|
600 |
};
|
|
708 |
} |
|
601 | 709 |
|
602 | 710 |
}); |
603 | 711 |
|
... | ... | |
605 | 713 |
}); |
606 | 714 |
|
607 | 715 |
$.ui.plugin.add("draggable", "cursor", { |
608 |
start: function(event, ui) { |
|
609 |
var t = $('body'), o = $(this).data('draggable').options; |
|
610 |
if (t.css("cursor")) o._cursor = t.css("cursor"); |
|
716 |
start: function() { |
|
717 |
var t = $("body"), o = $(this).data("ui-draggable").options; |
|
718 |
if (t.css("cursor")) { |
|
719 |
o._cursor = t.css("cursor"); |
|
720 |
} |
|
611 | 721 |
t.css("cursor", o.cursor); |
612 | 722 |
}, |
613 |
stop: function(event, ui) { |
|
614 |
var o = $(this).data('draggable').options; |
|
615 |
if (o._cursor) $('body').css("cursor", o._cursor); |
|
616 |
} |
|
617 |
}); |
|
618 |
|
|
619 |
$.ui.plugin.add("draggable", "iframeFix", { |
|
620 |
start: function(event, ui) { |
|
621 |
var o = $(this).data('draggable').options; |
|
622 |
$(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { |
|
623 |
$('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>') |
|
624 |
.css({ |
|
625 |
width: this.offsetWidth+"px", height: this.offsetHeight+"px", |
|
626 |
position: "absolute", opacity: "0.001", zIndex: 1000 |
|
627 |
}) |
|
628 |
.css($(this).offset()) |
|
629 |
.appendTo("body"); |
|
630 |
}); |
|
631 |
}, |
|
632 |
stop: function(event, ui) { |
|
633 |
$("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers |
|
723 |
stop: function() { |
|
724 |
var o = $(this).data("ui-draggable").options; |
|
725 |
if (o._cursor) { |
|
726 |
$("body").css("cursor", o._cursor); |
|
727 |
} |
|
634 | 728 |
} |
635 | 729 |
}); |
636 | 730 |
|
637 | 731 |
$.ui.plugin.add("draggable", "opacity", { |
638 | 732 |
start: function(event, ui) { |
639 |
var t = $(ui.helper), o = $(this).data('draggable').options; |
|
640 |
if(t.css("opacity")) o._opacity = t.css("opacity"); |
|
641 |
t.css('opacity', o.opacity); |
|
733 |
var t = $(ui.helper), o = $(this).data("ui-draggable").options; |
|
734 |
if(t.css("opacity")) { |
|
735 |
o._opacity = t.css("opacity"); |
|
736 |
} |
|
737 |
t.css("opacity", o.opacity); |
|
642 | 738 |
}, |
643 | 739 |
stop: function(event, ui) { |
644 |
var o = $(this).data('draggable').options; |
|
645 |
if(o._opacity) $(ui.helper).css('opacity', o._opacity); |
|
740 |
var o = $(this).data("ui-draggable").options; |
|
741 |
if(o._opacity) { |
|
742 |
$(ui.helper).css("opacity", o._opacity); |
|
743 |
} |
|
646 | 744 |
} |
647 | 745 |
}); |
648 | 746 |
|
649 | 747 |
$.ui.plugin.add("draggable", "scroll", { |
650 |
start: function(event, ui) { |
|
651 |
var i = $(this).data("draggable"); |
|
652 |
if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset(); |
|
748 |
start: function() { |
|
749 |
var i = $(this).data("ui-draggable"); |
|
750 |
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") { |
|
751 |
i.overflowOffset = i.scrollParent.offset(); |
|
752 |
} |
|
653 | 753 |
}, |
654 |
drag: function(event, ui) {
|
|
754 |
drag: function( event ) {
|
|
655 | 755 |
|
656 |
var i = $(this).data("draggable"), o = i.options, scrolled = false; |
|
756 |
var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
|
|
657 | 757 |
|
658 |
if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
|
|
758 |
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
|
|
659 | 759 |
|
660 |
if(!o.axis || o.axis != 'x') {
|
|
661 |
if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) |
|
760 |
if(!o.axis || o.axis !== "x") {
|
|
761 |
if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
|
|
662 | 762 |
i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed; |
663 |
else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
|
|
763 |
} else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
|
|
664 | 764 |
i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed; |
765 |
} |
|
665 | 766 |
} |
666 | 767 |
|
667 |
if(!o.axis || o.axis != 'y') {
|
|
668 |
if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) |
|
768 |
if(!o.axis || o.axis !== "y") {
|
|
769 |
if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
|
|
669 | 770 |
i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed; |
670 |
else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
|
|
771 |
} else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
|
|
671 | 772 |
i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed; |
773 |
} |
|
672 | 774 |
} |
673 | 775 |
|
674 | 776 |
} else { |
675 | 777 |
|
676 |
if(!o.axis || o.axis != 'x') {
|
|
677 |
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) |
|
778 |
if(!o.axis || o.axis !== "x") {
|
|
779 |
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
|
|
678 | 780 |
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); |
679 |
else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
|
|
781 |
} else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
|
|
680 | 782 |
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); |
783 |
} |
|
681 | 784 |
} |
682 | 785 |
|
683 |
if(!o.axis || o.axis != 'y') {
|
|
684 |
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) |
|
786 |
if(!o.axis || o.axis !== "y") {
|
|
787 |
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
|
|
685 | 788 |
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); |
686 |
else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
|
|
789 |
} else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
|
|
687 | 790 |
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); |
791 |
} |
|
688 | 792 |
} |
689 | 793 |
|
690 | 794 |
} |
691 | 795 |
|
692 |
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) |
|
796 |
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
|
|
693 | 797 |
$.ui.ddmanager.prepareOffsets(i, event); |
798 |
} |
|
694 | 799 |
|
695 | 800 |
} |
696 | 801 |
}); |
697 | 802 |
|
698 | 803 |
$.ui.plugin.add("draggable", "snap", { |
699 |
start: function(event, ui) { |
|
804 |
start: function() { |
|
805 |
|
|
806 |
var i = $(this).data("ui-draggable"), |
|
807 |
o = i.options; |
|
700 | 808 |
|
701 |
var i = $(this).data("draggable"), o = i.options; |
|
702 | 809 |
i.snapElements = []; |
703 | 810 |
|
704 |
$(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() { |
|
705 |
var $t = $(this); var $o = $t.offset(); |
|
706 |
if(this != i.element[0]) i.snapElements.push({ |
|
707 |
item: this, |
|
708 |
width: $t.outerWidth(), height: $t.outerHeight(), |
|
709 |
top: $o.top, left: $o.left |
|
710 |
}); |
|
811 |
$(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() { |
|
812 |
var $t = $(this), |
|
813 |
$o = $t.offset(); |
|
814 |
if(this !== i.element[0]) { |
|
815 |
i.snapElements.push({ |
|
816 |
item: this, |
|
817 |
width: $t.outerWidth(), height: $t.outerHeight(), |
|
818 |
top: $o.top, left: $o.left |
|
819 |
}); |
|
820 |
} |
|
711 | 821 |
}); |
712 | 822 |
|
713 | 823 |
}, |
714 | 824 |
drag: function(event, ui) { |
715 | 825 |
|
716 |
var inst = $(this).data("draggable"), o = inst.options; |
|
717 |
var d = o.snapTolerance; |
|
718 |
|
|
719 |
var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, |
|
826 |
var ts, bs, ls, rs, l, r, t, b, i, first, |
|
827 |
inst = $(this).data("ui-draggable"), |
|
828 |
o = inst.options, |
|
829 |
d = o.snapTolerance, |
|
830 |
x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, |
|
720 | 831 |
y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; |
721 | 832 |
|
722 |
for (var i = inst.snapElements.length - 1; i >= 0; i--){
|
|
833 |
for (i = inst.snapElements.length - 1; i >= 0; i--){ |
|
723 | 834 |
|
724 |
var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, |
|
725 |
t = inst.snapElements[i].top, b = t + inst.snapElements[i].height; |
|
835 |
l = inst.snapElements[i].left; |
|
836 |
r = l + inst.snapElements[i].width; |
|
837 |
t = inst.snapElements[i].top; |
|
838 |
b = t + inst.snapElements[i].height; |
|
726 | 839 |
|
727 | 840 |
//Yes, I know, this is insane ;) |
728 | 841 |
if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) { |
729 |
if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
|
842 |
if(inst.snapElements[i].snapping) { |
|
843 |
(inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
|
844 |
} |
|
730 | 845 |
inst.snapElements[i].snapping = false; |
731 | 846 |
continue; |
732 | 847 |
} |
733 | 848 |
|
734 |
if(o.snapMode != 'inner') { |
|
735 |
var ts = Math.abs(t - y2) <= d; |
|
736 |
var bs = Math.abs(b - y1) <= d; |
|
737 |
var ls = Math.abs(l - x2) <= d; |
|
738 |
var rs = Math.abs(r - x1) <= d; |
|
739 |
if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
|
740 |
if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top; |
|
741 |
if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left; |
|
742 |
if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left; |
|
849 |
if(o.snapMode !== "inner") { |
|
850 |
ts = Math.abs(t - y2) <= d; |
|
851 |
bs = Math.abs(b - y1) <= d; |
|
852 |
ls = Math.abs(l - x2) <= d; |
|
853 |
rs = Math.abs(r - x1) <= d; |
|
854 |
if(ts) { |
|
855 |
ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
|
856 |
} |
|
857 |
if(bs) { |
|
858 |
ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top; |
|
859 |
} |
|
860 |
if(ls) { |
|
861 |
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left; |
|
862 |
} |
|
863 |
if(rs) { |
|
864 |
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left; |
|
865 |
} |
|
743 | 866 |
} |
744 | 867 |
|
745 |
var first = (ts || bs || ls || rs); |
|
746 |
|
|
747 |
if(o.snapMode != 'outer') { |
|
748 |
var ts = Math.abs(t - y1) <= d; |
|
749 |
var bs = Math.abs(b - y2) <= d; |
|
750 |
var ls = Math.abs(l - x1) <= d; |
|
751 |
var rs = Math.abs(r - x2) <= d; |
|
752 |
if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top; |
|
753 |
if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
|
754 |
if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left; |
|
755 |
if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left; |
|
868 |
first = (ts || bs || ls || rs); |
|
869 |
|
|
870 |
if(o.snapMode !== "outer") { |
|
871 |
ts = Math.abs(t - y1) <= d; |
|
872 |
bs = Math.abs(b - y2) <= d; |
|
873 |
ls = Math.abs(l - x1) <= d; |
|
874 |
rs = Math.abs(r - x2) <= d; |
|
875 |
if(ts) { |
|
876 |
ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top; |
|
877 |
} |
|
878 |
if(bs) { |
|
879 |
ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
|
880 |
} |
|
881 |
if(ls) { |
|
882 |
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left; |
|
883 |
} |
|
884 |
if(rs) { |
|
885 |
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left; |
|
886 |
} |
|
756 | 887 |
} |
757 | 888 |
|
758 |
if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) |
|
889 |
if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
|
|
759 | 890 |
(inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
891 |
} |
|
760 | 892 |
inst.snapElements[i].snapping = (ts || bs || ls || rs || first); |
761 | 893 |
|
762 |
};
|
|
894 |
} |
|
763 | 895 |
|
764 | 896 |
} |
765 | 897 |
}); |
766 | 898 |
|
767 | 899 |
$.ui.plugin.add("draggable", "stack", { |
768 |
start: function(event, ui) { |
|
769 |
|
|
770 |
var o = $(this).data("draggable").options; |
|
900 |
start: function() { |
|
901 |
var min, |
|
902 |
o = this.data("ui-draggable").options, |
|
903 |
group = $.makeArray($(o.stack)).sort(function(a,b) { |
|
904 |
return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0); |
|
905 |
}); |
|
771 | 906 |
|
772 |
var group = $.makeArray($(o.stack)).sort(function(a,b) { |
|
773 |
return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0); |
|
774 |
}); |
|
775 | 907 |
if (!group.length) { return; } |
776 |
|
|
777 |
var min = parseInt(group[0].style.zIndex) || 0;
|
|
908 |
|
|
909 |
min = parseInt($(group[0]).css("zIndex"), 10) || 0;
|
|
778 | 910 |
$(group).each(function(i) { |
779 |
this.style.zIndex = min + i;
|
|
911 |
$(this).css("zIndex", min + i);
|
|
780 | 912 |
}); |
781 |
|
|
782 |
this[0].style.zIndex = min + group.length; |
|
783 |
|
|
913 |
this.css("zIndex", (min + group.length)); |
|
784 | 914 |
} |
785 | 915 |
}); |
786 | 916 |
|
787 | 917 |
$.ui.plugin.add("draggable", "zIndex", { |
788 | 918 |
start: function(event, ui) { |
789 |
var t = $(ui.helper), o = $(this).data("draggable").options; |
|
790 |
if(t.css("zIndex")) o._zIndex = t.css("zIndex"); |
|
791 |
t.css('zIndex', o.zIndex); |
|
919 |
var t = $(ui.helper), o = $(this).data("ui-draggable").options; |
|
920 |
if(t.css("zIndex")) { |
|
921 |
o._zIndex = t.css("zIndex"); |
|
922 |
} |
|
923 |
t.css("zIndex", o.zIndex); |
|
792 | 924 |
}, |
793 | 925 |
stop: function(event, ui) { |
794 |
var o = $(this).data("draggable").options; |
|
795 |
if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex); |
|
926 |
var o = $(this).data("ui-draggable").options; |
|
927 |
if(o._zIndex) { |
|
928 |
$(ui.helper).css("zIndex", o._zIndex); |
|
929 |
} |
|
796 | 930 |
} |
797 | 931 |
}); |
798 | 932 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules