jquery-ui-middleman 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +2 -0
  5. data/Gemfile +3 -0
  6. data/History.md +115 -0
  7. data/License.txt +2 -0
  8. data/README.md +226 -0
  9. data/Rakefile +221 -0
  10. data/VERSIONS.md +27 -0
  11. data/app/assets/images/jquery-ui/animated-overlay.gif +0 -0
  12. data/app/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  13. data/app/assets/images/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  14. data/app/assets/images/jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  15. data/app/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  16. data/app/assets/images/jquery-ui/ui-bg_glass_75_dadada_1x400.png +0 -0
  17. data/app/assets/images/jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  18. data/app/assets/images/jquery-ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  19. data/app/assets/images/jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  20. data/app/assets/images/jquery-ui/ui-icons_222222_256x240.png +0 -0
  21. data/app/assets/images/jquery-ui/ui-icons_2e83ff_256x240.png +0 -0
  22. data/app/assets/images/jquery-ui/ui-icons_454545_256x240.png +0 -0
  23. data/app/assets/images/jquery-ui/ui-icons_888888_256x240.png +0 -0
  24. data/app/assets/images/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
  25. data/app/assets/javascripts/jquery.ui.accordion.js +575 -0
  26. data/app/assets/javascripts/jquery.ui.all.js +34 -0
  27. data/app/assets/javascripts/jquery.ui.autocomplete.js +615 -0
  28. data/app/assets/javascripts/jquery.ui.button.js +422 -0
  29. data/app/assets/javascripts/jquery.ui.core.js +320 -0
  30. data/app/assets/javascripts/jquery.ui.datepicker-af.js +23 -0
  31. data/app/assets/javascripts/jquery.ui.datepicker-ar-DZ.js +23 -0
  32. data/app/assets/javascripts/jquery.ui.datepicker-ar.js +23 -0
  33. data/app/assets/javascripts/jquery.ui.datepicker-az.js +23 -0
  34. data/app/assets/javascripts/jquery.ui.datepicker-be.js +23 -0
  35. data/app/assets/javascripts/jquery.ui.datepicker-bg.js +24 -0
  36. data/app/assets/javascripts/jquery.ui.datepicker-bs.js +23 -0
  37. data/app/assets/javascripts/jquery.ui.datepicker-ca.js +23 -0
  38. data/app/assets/javascripts/jquery.ui.datepicker-cs.js +23 -0
  39. data/app/assets/javascripts/jquery.ui.datepicker-cy-GB.js +23 -0
  40. data/app/assets/javascripts/jquery.ui.datepicker-da.js +23 -0
  41. data/app/assets/javascripts/jquery.ui.datepicker-de.js +23 -0
  42. data/app/assets/javascripts/jquery.ui.datepicker-el.js +23 -0
  43. data/app/assets/javascripts/jquery.ui.datepicker-en-AU.js +23 -0
  44. data/app/assets/javascripts/jquery.ui.datepicker-en-GB.js +23 -0
  45. data/app/assets/javascripts/jquery.ui.datepicker-en-NZ.js +23 -0
  46. data/app/assets/javascripts/jquery.ui.datepicker-eo.js +23 -0
  47. data/app/assets/javascripts/jquery.ui.datepicker-es.js +23 -0
  48. data/app/assets/javascripts/jquery.ui.datepicker-et.js +23 -0
  49. data/app/assets/javascripts/jquery.ui.datepicker-eu.js +23 -0
  50. data/app/assets/javascripts/jquery.ui.datepicker-fa.js +59 -0
  51. data/app/assets/javascripts/jquery.ui.datepicker-fi.js +23 -0
  52. data/app/assets/javascripts/jquery.ui.datepicker-fo.js +23 -0
  53. data/app/assets/javascripts/jquery.ui.datepicker-fr-CA.js +23 -0
  54. data/app/assets/javascripts/jquery.ui.datepicker-fr-CH.js +23 -0
  55. data/app/assets/javascripts/jquery.ui.datepicker-fr.js +25 -0
  56. data/app/assets/javascripts/jquery.ui.datepicker-gl.js +23 -0
  57. data/app/assets/javascripts/jquery.ui.datepicker-he.js +23 -0
  58. data/app/assets/javascripts/jquery.ui.datepicker-hi.js +23 -0
  59. data/app/assets/javascripts/jquery.ui.datepicker-hr.js +23 -0
  60. data/app/assets/javascripts/jquery.ui.datepicker-hu.js +23 -0
  61. data/app/assets/javascripts/jquery.ui.datepicker-hy.js +23 -0
  62. data/app/assets/javascripts/jquery.ui.datepicker-id.js +23 -0
  63. data/app/assets/javascripts/jquery.ui.datepicker-is.js +23 -0
  64. data/app/assets/javascripts/jquery.ui.datepicker-it.js +23 -0
  65. data/app/assets/javascripts/jquery.ui.datepicker-ja.js +23 -0
  66. data/app/assets/javascripts/jquery.ui.datepicker-ka.js +21 -0
  67. data/app/assets/javascripts/jquery.ui.datepicker-kk.js +23 -0
  68. data/app/assets/javascripts/jquery.ui.datepicker-km.js +23 -0
  69. data/app/assets/javascripts/jquery.ui.datepicker-ko.js +23 -0
  70. data/app/assets/javascripts/jquery.ui.datepicker-ky.js +24 -0
  71. data/app/assets/javascripts/jquery.ui.datepicker-lb.js +23 -0
  72. data/app/assets/javascripts/jquery.ui.datepicker-lt.js +23 -0
  73. data/app/assets/javascripts/jquery.ui.datepicker-lv.js +23 -0
  74. data/app/assets/javascripts/jquery.ui.datepicker-mk.js +23 -0
  75. data/app/assets/javascripts/jquery.ui.datepicker-ml.js +23 -0
  76. data/app/assets/javascripts/jquery.ui.datepicker-ms.js +23 -0
  77. data/app/assets/javascripts/jquery.ui.datepicker-nb.js +22 -0
  78. data/app/assets/javascripts/jquery.ui.datepicker-nl-BE.js +23 -0
  79. data/app/assets/javascripts/jquery.ui.datepicker-nl.js +23 -0
  80. data/app/assets/javascripts/jquery.ui.datepicker-nn.js +22 -0
  81. data/app/assets/javascripts/jquery.ui.datepicker-no.js +23 -0
  82. data/app/assets/javascripts/jquery.ui.datepicker-pl.js +23 -0
  83. data/app/assets/javascripts/jquery.ui.datepicker-pt-BR.js +23 -0
  84. data/app/assets/javascripts/jquery.ui.datepicker-pt.js +22 -0
  85. data/app/assets/javascripts/jquery.ui.datepicker-rm.js +21 -0
  86. data/app/assets/javascripts/jquery.ui.datepicker-ro.js +26 -0
  87. data/app/assets/javascripts/jquery.ui.datepicker-ru.js +23 -0
  88. data/app/assets/javascripts/jquery.ui.datepicker-sk.js +23 -0
  89. data/app/assets/javascripts/jquery.ui.datepicker-sl.js +24 -0
  90. data/app/assets/javascripts/jquery.ui.datepicker-sq.js +23 -0
  91. data/app/assets/javascripts/jquery.ui.datepicker-sr-SR.js +23 -0
  92. data/app/assets/javascripts/jquery.ui.datepicker-sr.js +23 -0
  93. data/app/assets/javascripts/jquery.ui.datepicker-sv.js +23 -0
  94. data/app/assets/javascripts/jquery.ui.datepicker-ta.js +23 -0
  95. data/app/assets/javascripts/jquery.ui.datepicker-th.js +23 -0
  96. data/app/assets/javascripts/jquery.ui.datepicker-tj.js +23 -0
  97. data/app/assets/javascripts/jquery.ui.datepicker-tr.js +23 -0
  98. data/app/assets/javascripts/jquery.ui.datepicker-uk.js +24 -0
  99. data/app/assets/javascripts/jquery.ui.datepicker-vi.js +23 -0
  100. data/app/assets/javascripts/jquery.ui.datepicker-zh-CN.js +23 -0
  101. data/app/assets/javascripts/jquery.ui.datepicker-zh-HK.js +23 -0
  102. data/app/assets/javascripts/jquery.ui.datepicker-zh-TW.js +23 -0
  103. data/app/assets/javascripts/jquery.ui.datepicker.js +2040 -0
  104. data/app/assets/javascripts/jquery.ui.dialog.js +815 -0
  105. data/app/assets/javascripts/jquery.ui.draggable.js +962 -0
  106. data/app/assets/javascripts/jquery.ui.droppable.js +377 -0
  107. data/app/assets/javascripts/jquery.ui.effect-blind.js +84 -0
  108. data/app/assets/javascripts/jquery.ui.effect-bounce.js +115 -0
  109. data/app/assets/javascripts/jquery.ui.effect-clip.js +69 -0
  110. data/app/assets/javascripts/jquery.ui.effect-drop.js +67 -0
  111. data/app/assets/javascripts/jquery.ui.effect-explode.js +99 -0
  112. data/app/assets/javascripts/jquery.ui.effect-fade.js +32 -0
  113. data/app/assets/javascripts/jquery.ui.effect-fold.js +78 -0
  114. data/app/assets/javascripts/jquery.ui.effect-highlight.js +52 -0
  115. data/app/assets/javascripts/jquery.ui.effect-pulsate.js +65 -0
  116. data/app/assets/javascripts/jquery.ui.effect-scale.js +320 -0
  117. data/app/assets/javascripts/jquery.ui.effect-shake.js +76 -0
  118. data/app/assets/javascripts/jquery.ui.effect-slide.js +66 -0
  119. data/app/assets/javascripts/jquery.ui.effect-transfer.js +49 -0
  120. data/app/assets/javascripts/jquery.ui.effect.all.js +14 -0
  121. data/app/assets/javascripts/jquery.ui.effect.js +1289 -0
  122. data/app/assets/javascripts/jquery.ui.menu.js +625 -0
  123. data/app/assets/javascripts/jquery.ui.mouse.js +172 -0
  124. data/app/assets/javascripts/jquery.ui.position.js +497 -0
  125. data/app/assets/javascripts/jquery.ui.progressbar.js +148 -0
  126. data/app/assets/javascripts/jquery.ui.resizable.js +972 -0
  127. data/app/assets/javascripts/jquery.ui.selectable.js +281 -0
  128. data/app/assets/javascripts/jquery.ui.slider.js +676 -0
  129. data/app/assets/javascripts/jquery.ui.sortable.js +1289 -0
  130. data/app/assets/javascripts/jquery.ui.spinner.js +497 -0
  131. data/app/assets/javascripts/jquery.ui.tabs.js +849 -0
  132. data/app/assets/javascripts/jquery.ui.tooltip.js +406 -0
  133. data/app/assets/javascripts/jquery.ui.widget.js +521 -0
  134. data/app/assets/stylesheets/jquery.ui.accordion.css.erb +42 -0
  135. data/app/assets/stylesheets/jquery.ui.all.css.erb +14 -0
  136. data/app/assets/stylesheets/jquery.ui.autocomplete.css.erb +21 -0
  137. data/app/assets/stylesheets/jquery.ui.base.css.erb +27 -0
  138. data/app/assets/stylesheets/jquery.ui.button.css.erb +118 -0
  139. data/app/assets/stylesheets/jquery.ui.core.css.erb +93 -0
  140. data/app/assets/stylesheets/jquery.ui.datepicker.css.erb +182 -0
  141. data/app/assets/stylesheets/jquery.ui.dialog.css.erb +75 -0
  142. data/app/assets/stylesheets/jquery.ui.menu.css.erb +83 -0
  143. data/app/assets/stylesheets/jquery.ui.progressbar.css.erb +32 -0
  144. data/app/assets/stylesheets/jquery.ui.resizable.css.erb +82 -0
  145. data/app/assets/stylesheets/jquery.ui.selectable.css.erb +19 -0
  146. data/app/assets/stylesheets/jquery.ui.slider.css.erb +77 -0
  147. data/app/assets/stylesheets/jquery.ui.spinner.css.erb +70 -0
  148. data/app/assets/stylesheets/jquery.ui.tabs.css.erb +56 -0
  149. data/app/assets/stylesheets/jquery.ui.theme.css.erb +409 -0
  150. data/app/assets/stylesheets/jquery.ui.tooltip.css.erb +23 -0
  151. data/lib/jquery-ui-middleman.rb +1 -0
  152. data/lib/jquery/ui/version.rb +6 -0
  153. metadata +209 -0
@@ -0,0 +1,1289 @@
1
+ //= require jquery.ui.core
2
+ //= require jquery.ui.widget
3
+ //= require jquery.ui.mouse
4
+
5
+ /*!
6
+ * jQuery UI Sortable 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/sortable/
14
+ *
15
+ * Depends:
16
+ * jquery.ui.core.js
17
+ * jquery.ui.mouse.js
18
+ * jquery.ui.widget.js
19
+ */
20
+ (function( $, undefined ) {
21
+
22
+ /*jshint loopfunc: true */
23
+
24
+ function isOverAxis( x, reference, size ) {
25
+ return ( x > reference ) && ( x < ( reference + size ) );
26
+ }
27
+
28
+ function isFloating(item) {
29
+ return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
30
+ }
31
+
32
+ $.widget("ui.sortable", $.ui.mouse, {
33
+ version: "1.10.3",
34
+ widgetEventPrefix: "sort",
35
+ ready: false,
36
+ options: {
37
+ appendTo: "parent",
38
+ axis: false,
39
+ connectWith: false,
40
+ containment: false,
41
+ cursor: "auto",
42
+ cursorAt: false,
43
+ dropOnEmpty: true,
44
+ forcePlaceholderSize: false,
45
+ forceHelperSize: false,
46
+ grid: false,
47
+ handle: false,
48
+ helper: "original",
49
+ items: "> *",
50
+ opacity: false,
51
+ placeholder: false,
52
+ revert: false,
53
+ scroll: true,
54
+ scrollSensitivity: 20,
55
+ scrollSpeed: 20,
56
+ scope: "default",
57
+ tolerance: "intersect",
58
+ zIndex: 1000,
59
+
60
+ // callbacks
61
+ activate: null,
62
+ beforeStop: null,
63
+ change: null,
64
+ deactivate: null,
65
+ out: null,
66
+ over: null,
67
+ receive: null,
68
+ remove: null,
69
+ sort: null,
70
+ start: null,
71
+ stop: null,
72
+ update: null
73
+ },
74
+ _create: function() {
75
+
76
+ var o = this.options;
77
+ this.containerCache = {};
78
+ this.element.addClass("ui-sortable");
79
+
80
+ //Get the items
81
+ this.refresh();
82
+
83
+ //Let's determine if the items are being displayed horizontally
84
+ this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
85
+
86
+ //Let's determine the parent's offset
87
+ this.offset = this.element.offset();
88
+
89
+ //Initialize mouse events for interaction
90
+ this._mouseInit();
91
+
92
+ //We're ready to go
93
+ this.ready = true;
94
+
95
+ },
96
+
97
+ _destroy: function() {
98
+ this.element
99
+ .removeClass("ui-sortable ui-sortable-disabled");
100
+ this._mouseDestroy();
101
+
102
+ for ( var i = this.items.length - 1; i >= 0; i-- ) {
103
+ this.items[i].item.removeData(this.widgetName + "-item");
104
+ }
105
+
106
+ return this;
107
+ },
108
+
109
+ _setOption: function(key, value){
110
+ if ( key === "disabled" ) {
111
+ this.options[ key ] = value;
112
+
113
+ this.widget().toggleClass( "ui-sortable-disabled", !!value );
114
+ } else {
115
+ // Don't call widget base _setOption for disable as it adds ui-state-disabled class
116
+ $.Widget.prototype._setOption.apply(this, arguments);
117
+ }
118
+ },
119
+
120
+ _mouseCapture: function(event, overrideHandle) {
121
+ var currentItem = null,
122
+ validHandle = false,
123
+ that = this;
124
+
125
+ if (this.reverting) {
126
+ return false;
127
+ }
128
+
129
+ if(this.options.disabled || this.options.type === "static") {
130
+ return false;
131
+ }
132
+
133
+ //We have to refresh the items data once first
134
+ this._refreshItems(event);
135
+
136
+ //Find out if the clicked node (or one of its parents) is a actual item in this.items
137
+ $(event.target).parents().each(function() {
138
+ if($.data(this, that.widgetName + "-item") === that) {
139
+ currentItem = $(this);
140
+ return false;
141
+ }
142
+ });
143
+ if($.data(event.target, that.widgetName + "-item") === that) {
144
+ currentItem = $(event.target);
145
+ }
146
+
147
+ if(!currentItem) {
148
+ return false;
149
+ }
150
+ if(this.options.handle && !overrideHandle) {
151
+ $(this.options.handle, currentItem).find("*").addBack().each(function() {
152
+ if(this === event.target) {
153
+ validHandle = true;
154
+ }
155
+ });
156
+ if(!validHandle) {
157
+ return false;
158
+ }
159
+ }
160
+
161
+ this.currentItem = currentItem;
162
+ this._removeCurrentsFromItems();
163
+ return true;
164
+
165
+ },
166
+
167
+ _mouseStart: function(event, overrideHandle, noActivation) {
168
+
169
+ var i, body,
170
+ o = this.options;
171
+
172
+ this.currentContainer = this;
173
+
174
+ //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
175
+ this.refreshPositions();
176
+
177
+ //Create and append the visible helper
178
+ this.helper = this._createHelper(event);
179
+
180
+ //Cache the helper size
181
+ this._cacheHelperProportions();
182
+
183
+ /*
184
+ * - Position generation -
185
+ * This block generates everything position related - it's the core of draggables.
186
+ */
187
+
188
+ //Cache the margins of the original element
189
+ this._cacheMargins();
190
+
191
+ //Get the next scrolling parent
192
+ this.scrollParent = this.helper.scrollParent();
193
+
194
+ //The element's absolute position on the page minus margins
195
+ this.offset = this.currentItem.offset();
196
+ this.offset = {
197
+ top: this.offset.top - this.margins.top,
198
+ left: this.offset.left - this.margins.left
199
+ };
200
+
201
+ $.extend(this.offset, {
202
+ click: { //Where the click happened, relative to the element
203
+ left: event.pageX - this.offset.left,
204
+ top: event.pageY - this.offset.top
205
+ },
206
+ parent: this._getParentOffset(),
207
+ relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
208
+ });
209
+
210
+ // Only after we got the offset, we can change the helper's position to absolute
211
+ // TODO: Still need to figure out a way to make relative sorting possible
212
+ this.helper.css("position", "absolute");
213
+ this.cssPosition = this.helper.css("position");
214
+
215
+ //Generate the original position
216
+ this.originalPosition = this._generatePosition(event);
217
+ this.originalPageX = event.pageX;
218
+ this.originalPageY = event.pageY;
219
+
220
+ //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
221
+ (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
222
+
223
+ //Cache the former DOM position
224
+ this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
225
+
226
+ //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
227
+ if(this.helper[0] !== this.currentItem[0]) {
228
+ this.currentItem.hide();
229
+ }
230
+
231
+ //Create the placeholder
232
+ this._createPlaceholder();
233
+
234
+ //Set a containment if given in the options
235
+ if(o.containment) {
236
+ this._setContainment();
237
+ }
238
+
239
+ if( o.cursor && o.cursor !== "auto" ) { // cursor option
240
+ body = this.document.find( "body" );
241
+
242
+ // support: IE
243
+ this.storedCursor = body.css( "cursor" );
244
+ body.css( "cursor", o.cursor );
245
+
246
+ this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
247
+ }
248
+
249
+ if(o.opacity) { // opacity option
250
+ if (this.helper.css("opacity")) {
251
+ this._storedOpacity = this.helper.css("opacity");
252
+ }
253
+ this.helper.css("opacity", o.opacity);
254
+ }
255
+
256
+ if(o.zIndex) { // zIndex option
257
+ if (this.helper.css("zIndex")) {
258
+ this._storedZIndex = this.helper.css("zIndex");
259
+ }
260
+ this.helper.css("zIndex", o.zIndex);
261
+ }
262
+
263
+ //Prepare scrolling
264
+ if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
265
+ this.overflowOffset = this.scrollParent.offset();
266
+ }
267
+
268
+ //Call callbacks
269
+ this._trigger("start", event, this._uiHash());
270
+
271
+ //Recache the helper size
272
+ if(!this._preserveHelperProportions) {
273
+ this._cacheHelperProportions();
274
+ }
275
+
276
+
277
+ //Post "activate" events to possible containers
278
+ if( !noActivation ) {
279
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
280
+ this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
281
+ }
282
+ }
283
+
284
+ //Prepare possible droppables
285
+ if($.ui.ddmanager) {
286
+ $.ui.ddmanager.current = this;
287
+ }
288
+
289
+ if ($.ui.ddmanager && !o.dropBehaviour) {
290
+ $.ui.ddmanager.prepareOffsets(this, event);
291
+ }
292
+
293
+ this.dragging = true;
294
+
295
+ this.helper.addClass("ui-sortable-helper");
296
+ this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
297
+ return true;
298
+
299
+ },
300
+
301
+ _mouseDrag: function(event) {
302
+ var i, item, itemElement, intersection,
303
+ o = this.options,
304
+ scrolled = false;
305
+
306
+ //Compute the helpers position
307
+ this.position = this._generatePosition(event);
308
+ this.positionAbs = this._convertPositionTo("absolute");
309
+
310
+ if (!this.lastPositionAbs) {
311
+ this.lastPositionAbs = this.positionAbs;
312
+ }
313
+
314
+ //Do scrolling
315
+ if(this.options.scroll) {
316
+ if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
317
+
318
+ if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
319
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
320
+ } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
321
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
322
+ }
323
+
324
+ if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
325
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
326
+ } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
327
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
328
+ }
329
+
330
+ } else {
331
+
332
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
333
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
334
+ } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
335
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
336
+ }
337
+
338
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
339
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
340
+ } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
341
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
342
+ }
343
+
344
+ }
345
+
346
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
347
+ $.ui.ddmanager.prepareOffsets(this, event);
348
+ }
349
+ }
350
+
351
+ //Regenerate the absolute position used for position checks
352
+ this.positionAbs = this._convertPositionTo("absolute");
353
+
354
+ //Set the helper position
355
+ if(!this.options.axis || this.options.axis !== "y") {
356
+ this.helper[0].style.left = this.position.left+"px";
357
+ }
358
+ if(!this.options.axis || this.options.axis !== "x") {
359
+ this.helper[0].style.top = this.position.top+"px";
360
+ }
361
+
362
+ //Rearrange
363
+ for (i = this.items.length - 1; i >= 0; i--) {
364
+
365
+ //Cache variables and intersection, continue if no intersection
366
+ item = this.items[i];
367
+ itemElement = item.item[0];
368
+ intersection = this._intersectsWithPointer(item);
369
+ if (!intersection) {
370
+ continue;
371
+ }
372
+
373
+ // Only put the placeholder inside the current Container, skip all
374
+ // items form other containers. This works because when moving
375
+ // an item from one container to another the
376
+ // currentContainer is switched before the placeholder is moved.
377
+ //
378
+ // Without this moving items in "sub-sortables" can cause the placeholder to jitter
379
+ // beetween the outer and inner container.
380
+ if (item.instance !== this.currentContainer) {
381
+ continue;
382
+ }
383
+
384
+ // cannot intersect with itself
385
+ // no useless actions that have been done before
386
+ // no action if the item moved is the parent of the item checked
387
+ if (itemElement !== this.currentItem[0] &&
388
+ this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
389
+ !$.contains(this.placeholder[0], itemElement) &&
390
+ (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
391
+ ) {
392
+
393
+ this.direction = intersection === 1 ? "down" : "up";
394
+
395
+ if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
396
+ this._rearrange(event, item);
397
+ } else {
398
+ break;
399
+ }
400
+
401
+ this._trigger("change", event, this._uiHash());
402
+ break;
403
+ }
404
+ }
405
+
406
+ //Post events to containers
407
+ this._contactContainers(event);
408
+
409
+ //Interconnect with droppables
410
+ if($.ui.ddmanager) {
411
+ $.ui.ddmanager.drag(this, event);
412
+ }
413
+
414
+ //Call callbacks
415
+ this._trigger("sort", event, this._uiHash());
416
+
417
+ this.lastPositionAbs = this.positionAbs;
418
+ return false;
419
+
420
+ },
421
+
422
+ _mouseStop: function(event, noPropagation) {
423
+
424
+ if(!event) {
425
+ return;
426
+ }
427
+
428
+ //If we are using droppables, inform the manager about the drop
429
+ if ($.ui.ddmanager && !this.options.dropBehaviour) {
430
+ $.ui.ddmanager.drop(this, event);
431
+ }
432
+
433
+ if(this.options.revert) {
434
+ var that = this,
435
+ cur = this.placeholder.offset(),
436
+ axis = this.options.axis,
437
+ animation = {};
438
+
439
+ if ( !axis || axis === "x" ) {
440
+ animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
441
+ }
442
+ if ( !axis || axis === "y" ) {
443
+ animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
444
+ }
445
+ this.reverting = true;
446
+ $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
447
+ that._clear(event);
448
+ });
449
+ } else {
450
+ this._clear(event, noPropagation);
451
+ }
452
+
453
+ return false;
454
+
455
+ },
456
+
457
+ cancel: function() {
458
+
459
+ if(this.dragging) {
460
+
461
+ this._mouseUp({ target: null });
462
+
463
+ if(this.options.helper === "original") {
464
+ this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
465
+ } else {
466
+ this.currentItem.show();
467
+ }
468
+
469
+ //Post deactivating events to containers
470
+ for (var i = this.containers.length - 1; i >= 0; i--){
471
+ this.containers[i]._trigger("deactivate", null, this._uiHash(this));
472
+ if(this.containers[i].containerCache.over) {
473
+ this.containers[i]._trigger("out", null, this._uiHash(this));
474
+ this.containers[i].containerCache.over = 0;
475
+ }
476
+ }
477
+
478
+ }
479
+
480
+ if (this.placeholder) {
481
+ //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
482
+ if(this.placeholder[0].parentNode) {
483
+ this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
484
+ }
485
+ if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
486
+ this.helper.remove();
487
+ }
488
+
489
+ $.extend(this, {
490
+ helper: null,
491
+ dragging: false,
492
+ reverting: false,
493
+ _noFinalSort: null
494
+ });
495
+
496
+ if(this.domPosition.prev) {
497
+ $(this.domPosition.prev).after(this.currentItem);
498
+ } else {
499
+ $(this.domPosition.parent).prepend(this.currentItem);
500
+ }
501
+ }
502
+
503
+ return this;
504
+
505
+ },
506
+
507
+ serialize: function(o) {
508
+
509
+ var items = this._getItemsAsjQuery(o && o.connected),
510
+ str = [];
511
+ o = o || {};
512
+
513
+ $(items).each(function() {
514
+ var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
515
+ if (res) {
516
+ str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
517
+ }
518
+ });
519
+
520
+ if(!str.length && o.key) {
521
+ str.push(o.key + "=");
522
+ }
523
+
524
+ return str.join("&");
525
+
526
+ },
527
+
528
+ toArray: function(o) {
529
+
530
+ var items = this._getItemsAsjQuery(o && o.connected),
531
+ ret = [];
532
+
533
+ o = o || {};
534
+
535
+ items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
536
+ return ret;
537
+
538
+ },
539
+
540
+ /* Be careful with the following core functions */
541
+ _intersectsWith: function(item) {
542
+
543
+ var x1 = this.positionAbs.left,
544
+ x2 = x1 + this.helperProportions.width,
545
+ y1 = this.positionAbs.top,
546
+ y2 = y1 + this.helperProportions.height,
547
+ l = item.left,
548
+ r = l + item.width,
549
+ t = item.top,
550
+ b = t + item.height,
551
+ dyClick = this.offset.click.top,
552
+ dxClick = this.offset.click.left,
553
+ isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
554
+ isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
555
+ isOverElement = isOverElementHeight && isOverElementWidth;
556
+
557
+ if ( this.options.tolerance === "pointer" ||
558
+ this.options.forcePointerForContainers ||
559
+ (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
560
+ ) {
561
+ return isOverElement;
562
+ } else {
563
+
564
+ return (l < x1 + (this.helperProportions.width / 2) && // Right Half
565
+ x2 - (this.helperProportions.width / 2) < r && // Left Half
566
+ t < y1 + (this.helperProportions.height / 2) && // Bottom Half
567
+ y2 - (this.helperProportions.height / 2) < b ); // Top Half
568
+
569
+ }
570
+ },
571
+
572
+ _intersectsWithPointer: function(item) {
573
+
574
+ var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
575
+ isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
576
+ isOverElement = isOverElementHeight && isOverElementWidth,
577
+ verticalDirection = this._getDragVerticalDirection(),
578
+ horizontalDirection = this._getDragHorizontalDirection();
579
+
580
+ if (!isOverElement) {
581
+ return false;
582
+ }
583
+
584
+ return this.floating ?
585
+ ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
586
+ : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
587
+
588
+ },
589
+
590
+ _intersectsWithSides: function(item) {
591
+
592
+ var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
593
+ isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
594
+ verticalDirection = this._getDragVerticalDirection(),
595
+ horizontalDirection = this._getDragHorizontalDirection();
596
+
597
+ if (this.floating && horizontalDirection) {
598
+ return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
599
+ } else {
600
+ return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
601
+ }
602
+
603
+ },
604
+
605
+ _getDragVerticalDirection: function() {
606
+ var delta = this.positionAbs.top - this.lastPositionAbs.top;
607
+ return delta !== 0 && (delta > 0 ? "down" : "up");
608
+ },
609
+
610
+ _getDragHorizontalDirection: function() {
611
+ var delta = this.positionAbs.left - this.lastPositionAbs.left;
612
+ return delta !== 0 && (delta > 0 ? "right" : "left");
613
+ },
614
+
615
+ refresh: function(event) {
616
+ this._refreshItems(event);
617
+ this.refreshPositions();
618
+ return this;
619
+ },
620
+
621
+ _connectWith: function() {
622
+ var options = this.options;
623
+ return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
624
+ },
625
+
626
+ _getItemsAsjQuery: function(connected) {
627
+
628
+ var i, j, cur, inst,
629
+ items = [],
630
+ queries = [],
631
+ connectWith = this._connectWith();
632
+
633
+ if(connectWith && connected) {
634
+ for (i = connectWith.length - 1; i >= 0; i--){
635
+ cur = $(connectWith[i]);
636
+ for ( j = cur.length - 1; j >= 0; j--){
637
+ inst = $.data(cur[j], this.widgetFullName);
638
+ if(inst && inst !== this && !inst.options.disabled) {
639
+ queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
640
+ }
641
+ }
642
+ }
643
+ }
644
+
645
+ queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
646
+
647
+ for (i = queries.length - 1; i >= 0; i--){
648
+ queries[i][0].each(function() {
649
+ items.push(this);
650
+ });
651
+ }
652
+
653
+ return $(items);
654
+
655
+ },
656
+
657
+ _removeCurrentsFromItems: function() {
658
+
659
+ var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
660
+
661
+ this.items = $.grep(this.items, function (item) {
662
+ for (var j=0; j < list.length; j++) {
663
+ if(list[j] === item.item[0]) {
664
+ return false;
665
+ }
666
+ }
667
+ return true;
668
+ });
669
+
670
+ },
671
+
672
+ _refreshItems: function(event) {
673
+
674
+ this.items = [];
675
+ this.containers = [this];
676
+
677
+ var i, j, cur, inst, targetData, _queries, item, queriesLength,
678
+ items = this.items,
679
+ queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
680
+ connectWith = this._connectWith();
681
+
682
+ if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
683
+ for (i = connectWith.length - 1; i >= 0; i--){
684
+ cur = $(connectWith[i]);
685
+ for (j = cur.length - 1; j >= 0; j--){
686
+ inst = $.data(cur[j], this.widgetFullName);
687
+ if(inst && inst !== this && !inst.options.disabled) {
688
+ queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
689
+ this.containers.push(inst);
690
+ }
691
+ }
692
+ }
693
+ }
694
+
695
+ for (i = queries.length - 1; i >= 0; i--) {
696
+ targetData = queries[i][1];
697
+ _queries = queries[i][0];
698
+
699
+ for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
700
+ item = $(_queries[j]);
701
+
702
+ item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
703
+
704
+ items.push({
705
+ item: item,
706
+ instance: targetData,
707
+ width: 0, height: 0,
708
+ left: 0, top: 0
709
+ });
710
+ }
711
+ }
712
+
713
+ },
714
+
715
+ refreshPositions: function(fast) {
716
+
717
+ //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
718
+ if(this.offsetParent && this.helper) {
719
+ this.offset.parent = this._getParentOffset();
720
+ }
721
+
722
+ var i, item, t, p;
723
+
724
+ for (i = this.items.length - 1; i >= 0; i--){
725
+ item = this.items[i];
726
+
727
+ //We ignore calculating positions of all connected containers when we're not over them
728
+ if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
729
+ continue;
730
+ }
731
+
732
+ t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
733
+
734
+ if (!fast) {
735
+ item.width = t.outerWidth();
736
+ item.height = t.outerHeight();
737
+ }
738
+
739
+ p = t.offset();
740
+ item.left = p.left;
741
+ item.top = p.top;
742
+ }
743
+
744
+ if(this.options.custom && this.options.custom.refreshContainers) {
745
+ this.options.custom.refreshContainers.call(this);
746
+ } else {
747
+ for (i = this.containers.length - 1; i >= 0; i--){
748
+ p = this.containers[i].element.offset();
749
+ this.containers[i].containerCache.left = p.left;
750
+ this.containers[i].containerCache.top = p.top;
751
+ this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
752
+ this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
753
+ }
754
+ }
755
+
756
+ return this;
757
+ },
758
+
759
+ _createPlaceholder: function(that) {
760
+ that = that || this;
761
+ var className,
762
+ o = that.options;
763
+
764
+ if(!o.placeholder || o.placeholder.constructor === String) {
765
+ className = o.placeholder;
766
+ o.placeholder = {
767
+ element: function() {
768
+
769
+ var nodeName = that.currentItem[0].nodeName.toLowerCase(),
770
+ element = $( "<" + nodeName + ">", that.document[0] )
771
+ .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
772
+ .removeClass("ui-sortable-helper");
773
+
774
+ if ( nodeName === "tr" ) {
775
+ that.currentItem.children().each(function() {
776
+ $( "<td>&#160;</td>", that.document[0] )
777
+ .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
778
+ .appendTo( element );
779
+ });
780
+ } else if ( nodeName === "img" ) {
781
+ element.attr( "src", that.currentItem.attr( "src" ) );
782
+ }
783
+
784
+ if ( !className ) {
785
+ element.css( "visibility", "hidden" );
786
+ }
787
+
788
+ return element;
789
+ },
790
+ update: function(container, p) {
791
+
792
+ // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
793
+ // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
794
+ if(className && !o.forcePlaceholderSize) {
795
+ return;
796
+ }
797
+
798
+ //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
799
+ if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
800
+ if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
801
+ }
802
+ };
803
+ }
804
+
805
+ //Create the placeholder
806
+ that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
807
+
808
+ //Append it after the actual current item
809
+ that.currentItem.after(that.placeholder);
810
+
811
+ //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
812
+ o.placeholder.update(that, that.placeholder);
813
+
814
+ },
815
+
816
+ _contactContainers: function(event) {
817
+ var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
818
+ innermostContainer = null,
819
+ innermostIndex = null;
820
+
821
+ // get innermost container that intersects with item
822
+ for (i = this.containers.length - 1; i >= 0; i--) {
823
+
824
+ // never consider a container that's located within the item itself
825
+ if($.contains(this.currentItem[0], this.containers[i].element[0])) {
826
+ continue;
827
+ }
828
+
829
+ if(this._intersectsWith(this.containers[i].containerCache)) {
830
+
831
+ // if we've already found a container and it's more "inner" than this, then continue
832
+ if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
833
+ continue;
834
+ }
835
+
836
+ innermostContainer = this.containers[i];
837
+ innermostIndex = i;
838
+
839
+ } else {
840
+ // container doesn't intersect. trigger "out" event if necessary
841
+ if(this.containers[i].containerCache.over) {
842
+ this.containers[i]._trigger("out", event, this._uiHash(this));
843
+ this.containers[i].containerCache.over = 0;
844
+ }
845
+ }
846
+
847
+ }
848
+
849
+ // if no intersecting containers found, return
850
+ if(!innermostContainer) {
851
+ return;
852
+ }
853
+
854
+ // move the item into the container if it's not there already
855
+ if(this.containers.length === 1) {
856
+ if (!this.containers[innermostIndex].containerCache.over) {
857
+ this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
858
+ this.containers[innermostIndex].containerCache.over = 1;
859
+ }
860
+ } else {
861
+
862
+ //When entering a new container, we will find the item with the least distance and append our item near it
863
+ dist = 10000;
864
+ itemWithLeastDistance = null;
865
+ floating = innermostContainer.floating || isFloating(this.currentItem);
866
+ posProperty = floating ? "left" : "top";
867
+ sizeProperty = floating ? "width" : "height";
868
+ base = this.positionAbs[posProperty] + this.offset.click[posProperty];
869
+ for (j = this.items.length - 1; j >= 0; j--) {
870
+ if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
871
+ continue;
872
+ }
873
+ if(this.items[j].item[0] === this.currentItem[0]) {
874
+ continue;
875
+ }
876
+ if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
877
+ continue;
878
+ }
879
+ cur = this.items[j].item.offset()[posProperty];
880
+ nearBottom = false;
881
+ if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
882
+ nearBottom = true;
883
+ cur += this.items[j][sizeProperty];
884
+ }
885
+
886
+ if(Math.abs(cur - base) < dist) {
887
+ dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
888
+ this.direction = nearBottom ? "up": "down";
889
+ }
890
+ }
891
+
892
+ //Check if dropOnEmpty is enabled
893
+ if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
894
+ return;
895
+ }
896
+
897
+ if(this.currentContainer === this.containers[innermostIndex]) {
898
+ return;
899
+ }
900
+
901
+ itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
902
+ this._trigger("change", event, this._uiHash());
903
+ this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
904
+ this.currentContainer = this.containers[innermostIndex];
905
+
906
+ //Update the placeholder
907
+ this.options.placeholder.update(this.currentContainer, this.placeholder);
908
+
909
+ this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
910
+ this.containers[innermostIndex].containerCache.over = 1;
911
+ }
912
+
913
+
914
+ },
915
+
916
+ _createHelper: function(event) {
917
+
918
+ var o = this.options,
919
+ helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
920
+
921
+ //Add the helper to the DOM if that didn't happen already
922
+ if(!helper.parents("body").length) {
923
+ $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
924
+ }
925
+
926
+ if(helper[0] === this.currentItem[0]) {
927
+ this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
928
+ }
929
+
930
+ if(!helper[0].style.width || o.forceHelperSize) {
931
+ helper.width(this.currentItem.width());
932
+ }
933
+ if(!helper[0].style.height || o.forceHelperSize) {
934
+ helper.height(this.currentItem.height());
935
+ }
936
+
937
+ return helper;
938
+
939
+ },
940
+
941
+ _adjustOffsetFromHelper: function(obj) {
942
+ if (typeof obj === "string") {
943
+ obj = obj.split(" ");
944
+ }
945
+ if ($.isArray(obj)) {
946
+ obj = {left: +obj[0], top: +obj[1] || 0};
947
+ }
948
+ if ("left" in obj) {
949
+ this.offset.click.left = obj.left + this.margins.left;
950
+ }
951
+ if ("right" in obj) {
952
+ this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
953
+ }
954
+ if ("top" in obj) {
955
+ this.offset.click.top = obj.top + this.margins.top;
956
+ }
957
+ if ("bottom" in obj) {
958
+ this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
959
+ }
960
+ },
961
+
962
+ _getParentOffset: function() {
963
+
964
+
965
+ //Get the offsetParent and cache its position
966
+ this.offsetParent = this.helper.offsetParent();
967
+ var po = this.offsetParent.offset();
968
+
969
+ // This is a special case where we need to modify a offset calculated on start, since the following happened:
970
+ // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
971
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
972
+ // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
973
+ if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
974
+ po.left += this.scrollParent.scrollLeft();
975
+ po.top += this.scrollParent.scrollTop();
976
+ }
977
+
978
+ // This needs to be actually done for all browsers, since pageX/pageY includes this information
979
+ // with an ugly IE fix
980
+ if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
981
+ po = { top: 0, left: 0 };
982
+ }
983
+
984
+ return {
985
+ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
986
+ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
987
+ };
988
+
989
+ },
990
+
991
+ _getRelativeOffset: function() {
992
+
993
+ if(this.cssPosition === "relative") {
994
+ var p = this.currentItem.position();
995
+ return {
996
+ top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
997
+ left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
998
+ };
999
+ } else {
1000
+ return { top: 0, left: 0 };
1001
+ }
1002
+
1003
+ },
1004
+
1005
+ _cacheMargins: function() {
1006
+ this.margins = {
1007
+ left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
1008
+ top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
1009
+ };
1010
+ },
1011
+
1012
+ _cacheHelperProportions: function() {
1013
+ this.helperProportions = {
1014
+ width: this.helper.outerWidth(),
1015
+ height: this.helper.outerHeight()
1016
+ };
1017
+ },
1018
+
1019
+ _setContainment: function() {
1020
+
1021
+ var ce, co, over,
1022
+ o = this.options;
1023
+ if(o.containment === "parent") {
1024
+ o.containment = this.helper[0].parentNode;
1025
+ }
1026
+ if(o.containment === "document" || o.containment === "window") {
1027
+ this.containment = [
1028
+ 0 - this.offset.relative.left - this.offset.parent.left,
1029
+ 0 - this.offset.relative.top - this.offset.parent.top,
1030
+ $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
1031
+ ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
1032
+ ];
1033
+ }
1034
+
1035
+ if(!(/^(document|window|parent)$/).test(o.containment)) {
1036
+ ce = $(o.containment)[0];
1037
+ co = $(o.containment).offset();
1038
+ over = ($(ce).css("overflow") !== "hidden");
1039
+
1040
+ this.containment = [
1041
+ co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
1042
+ co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
1043
+ co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
1044
+ co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
1045
+ ];
1046
+ }
1047
+
1048
+ },
1049
+
1050
+ _convertPositionTo: function(d, pos) {
1051
+
1052
+ if(!pos) {
1053
+ pos = this.position;
1054
+ }
1055
+ var mod = d === "absolute" ? 1 : -1,
1056
+ scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
1057
+ scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
1058
+
1059
+ return {
1060
+ top: (
1061
+ pos.top + // The absolute mouse position
1062
+ this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
1063
+ this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
1064
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
1065
+ ),
1066
+ left: (
1067
+ pos.left + // The absolute mouse position
1068
+ this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
1069
+ this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
1070
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
1071
+ )
1072
+ };
1073
+
1074
+ },
1075
+
1076
+ _generatePosition: function(event) {
1077
+
1078
+ var top, left,
1079
+ o = this.options,
1080
+ pageX = event.pageX,
1081
+ pageY = event.pageY,
1082
+ scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
1083
+
1084
+ // This is another very weird special case that only happens for relative elements:
1085
+ // 1. If the css position is relative
1086
+ // 2. and the scroll parent is the document or similar to the offset parent
1087
+ // we have to refresh the relative offset during the scroll so there are no jumps
1088
+ if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
1089
+ this.offset.relative = this._getRelativeOffset();
1090
+ }
1091
+
1092
+ /*
1093
+ * - Position constraining -
1094
+ * Constrain the position to a mix of grid, containment.
1095
+ */
1096
+
1097
+ if(this.originalPosition) { //If we are not dragging yet, we won't check for options
1098
+
1099
+ if(this.containment) {
1100
+ if(event.pageX - this.offset.click.left < this.containment[0]) {
1101
+ pageX = this.containment[0] + this.offset.click.left;
1102
+ }
1103
+ if(event.pageY - this.offset.click.top < this.containment[1]) {
1104
+ pageY = this.containment[1] + this.offset.click.top;
1105
+ }
1106
+ if(event.pageX - this.offset.click.left > this.containment[2]) {
1107
+ pageX = this.containment[2] + this.offset.click.left;
1108
+ }
1109
+ if(event.pageY - this.offset.click.top > this.containment[3]) {
1110
+ pageY = this.containment[3] + this.offset.click.top;
1111
+ }
1112
+ }
1113
+
1114
+ if(o.grid) {
1115
+ top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
1116
+ pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
1117
+
1118
+ left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
1119
+ pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
1120
+ }
1121
+
1122
+ }
1123
+
1124
+ return {
1125
+ top: (
1126
+ pageY - // The absolute mouse position
1127
+ this.offset.click.top - // Click offset (relative to the element)
1128
+ this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
1129
+ this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
1130
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
1131
+ ),
1132
+ left: (
1133
+ pageX - // The absolute mouse position
1134
+ this.offset.click.left - // Click offset (relative to the element)
1135
+ this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
1136
+ this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
1137
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
1138
+ )
1139
+ };
1140
+
1141
+ },
1142
+
1143
+ _rearrange: function(event, i, a, hardRefresh) {
1144
+
1145
+ a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
1146
+
1147
+ //Various things done here to improve the performance:
1148
+ // 1. we create a setTimeout, that calls refreshPositions
1149
+ // 2. on the instance, we have a counter variable, that get's higher after every append
1150
+ // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
1151
+ // 4. this lets only the last addition to the timeout stack through
1152
+ this.counter = this.counter ? ++this.counter : 1;
1153
+ var counter = this.counter;
1154
+
1155
+ this._delay(function() {
1156
+ if(counter === this.counter) {
1157
+ this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
1158
+ }
1159
+ });
1160
+
1161
+ },
1162
+
1163
+ _clear: function(event, noPropagation) {
1164
+
1165
+ this.reverting = false;
1166
+ // We delay all events that have to be triggered to after the point where the placeholder has been removed and
1167
+ // everything else normalized again
1168
+ var i,
1169
+ delayedTriggers = [];
1170
+
1171
+ // We first have to update the dom position of the actual currentItem
1172
+ // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
1173
+ if(!this._noFinalSort && this.currentItem.parent().length) {
1174
+ this.placeholder.before(this.currentItem);
1175
+ }
1176
+ this._noFinalSort = null;
1177
+
1178
+ if(this.helper[0] === this.currentItem[0]) {
1179
+ for(i in this._storedCSS) {
1180
+ if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
1181
+ this._storedCSS[i] = "";
1182
+ }
1183
+ }
1184
+ this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
1185
+ } else {
1186
+ this.currentItem.show();
1187
+ }
1188
+
1189
+ if(this.fromOutside && !noPropagation) {
1190
+ delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
1191
+ }
1192
+ if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
1193
+ delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
1194
+ }
1195
+
1196
+ // Check if the items Container has Changed and trigger appropriate
1197
+ // events.
1198
+ if (this !== this.currentContainer) {
1199
+ if(!noPropagation) {
1200
+ delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
1201
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
1202
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
1203
+ }
1204
+ }
1205
+
1206
+
1207
+ //Post events to containers
1208
+ for (i = this.containers.length - 1; i >= 0; i--){
1209
+ if(!noPropagation) {
1210
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
1211
+ }
1212
+ if(this.containers[i].containerCache.over) {
1213
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
1214
+ this.containers[i].containerCache.over = 0;
1215
+ }
1216
+ }
1217
+
1218
+ //Do what was originally in plugins
1219
+ if ( this.storedCursor ) {
1220
+ this.document.find( "body" ).css( "cursor", this.storedCursor );
1221
+ this.storedStylesheet.remove();
1222
+ }
1223
+ if(this._storedOpacity) {
1224
+ this.helper.css("opacity", this._storedOpacity);
1225
+ }
1226
+ if(this._storedZIndex) {
1227
+ this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
1228
+ }
1229
+
1230
+ this.dragging = false;
1231
+ if(this.cancelHelperRemoval) {
1232
+ if(!noPropagation) {
1233
+ this._trigger("beforeStop", event, this._uiHash());
1234
+ for (i=0; i < delayedTriggers.length; i++) {
1235
+ delayedTriggers[i].call(this, event);
1236
+ } //Trigger all delayed events
1237
+ this._trigger("stop", event, this._uiHash());
1238
+ }
1239
+
1240
+ this.fromOutside = false;
1241
+ return false;
1242
+ }
1243
+
1244
+ if(!noPropagation) {
1245
+ this._trigger("beforeStop", event, this._uiHash());
1246
+ }
1247
+
1248
+ //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
1249
+ this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
1250
+
1251
+ if(this.helper[0] !== this.currentItem[0]) {
1252
+ this.helper.remove();
1253
+ }
1254
+ this.helper = null;
1255
+
1256
+ if(!noPropagation) {
1257
+ for (i=0; i < delayedTriggers.length; i++) {
1258
+ delayedTriggers[i].call(this, event);
1259
+ } //Trigger all delayed events
1260
+ this._trigger("stop", event, this._uiHash());
1261
+ }
1262
+
1263
+ this.fromOutside = false;
1264
+ return true;
1265
+
1266
+ },
1267
+
1268
+ _trigger: function() {
1269
+ if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
1270
+ this.cancel();
1271
+ }
1272
+ },
1273
+
1274
+ _uiHash: function(_inst) {
1275
+ var inst = _inst || this;
1276
+ return {
1277
+ helper: inst.helper,
1278
+ placeholder: inst.placeholder || $([]),
1279
+ position: inst.position,
1280
+ originalPosition: inst.originalPosition,
1281
+ offset: inst.positionAbs,
1282
+ item: inst.currentItem,
1283
+ sender: _inst ? _inst.element : null
1284
+ };
1285
+ }
1286
+
1287
+ });
1288
+
1289
+ })(jQuery);