jquery-ui-rails 3.0.1 → 4.0.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.

Potentially problematic release.


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

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