jquery-ui-rails 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jquery-ui-rails might be problematic. Click here for more details.

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