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