h2ocube_rails_assets 0.0.19 → 0.0.20

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