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