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