jqueryui-requirejs-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/LICENSE +22 -0
  2. data/README.md +3 -0
  3. data/Rakefile +27 -0
  4. data/app/assets/javascripts/jqueryui/accordion.js +575 -0
  5. data/app/assets/javascripts/jqueryui/autocomplete.js +613 -0
  6. data/app/assets/javascripts/jqueryui/button.js +422 -0
  7. data/app/assets/javascripts/jqueryui/core.js +323 -0
  8. data/app/assets/javascripts/jqueryui/datepicker-af.js +26 -0
  9. data/app/assets/javascripts/jqueryui/datepicker-ar-DZ.js +26 -0
  10. data/app/assets/javascripts/jqueryui/datepicker-ar.js +26 -0
  11. data/app/assets/javascripts/jqueryui/datepicker-az.js +26 -0
  12. data/app/assets/javascripts/jqueryui/datepicker-be.js +26 -0
  13. data/app/assets/javascripts/jqueryui/datepicker-bg.js +27 -0
  14. data/app/assets/javascripts/jqueryui/datepicker-bs.js +26 -0
  15. data/app/assets/javascripts/jqueryui/datepicker-ca.js +26 -0
  16. data/app/assets/javascripts/jqueryui/datepicker-cs.js +26 -0
  17. data/app/assets/javascripts/jqueryui/datepicker-cy-GB.js +26 -0
  18. data/app/assets/javascripts/jqueryui/datepicker-da.js +26 -0
  19. data/app/assets/javascripts/jqueryui/datepicker-de.js +26 -0
  20. data/app/assets/javascripts/jqueryui/datepicker-el.js +26 -0
  21. data/app/assets/javascripts/jqueryui/datepicker-en-AU.js +26 -0
  22. data/app/assets/javascripts/jqueryui/datepicker-en-GB.js +26 -0
  23. data/app/assets/javascripts/jqueryui/datepicker-en-NZ.js +26 -0
  24. data/app/assets/javascripts/jqueryui/datepicker-eo.js +26 -0
  25. data/app/assets/javascripts/jqueryui/datepicker-es.js +26 -0
  26. data/app/assets/javascripts/jqueryui/datepicker-et.js +26 -0
  27. data/app/assets/javascripts/jqueryui/datepicker-eu.js +26 -0
  28. data/app/assets/javascripts/jqueryui/datepicker-fa.js +62 -0
  29. data/app/assets/javascripts/jqueryui/datepicker-fi.js +26 -0
  30. data/app/assets/javascripts/jqueryui/datepicker-fo.js +26 -0
  31. data/app/assets/javascripts/jqueryui/datepicker-fr-CA.js +26 -0
  32. data/app/assets/javascripts/jqueryui/datepicker-fr-CH.js +26 -0
  33. data/app/assets/javascripts/jqueryui/datepicker-fr.js +28 -0
  34. data/app/assets/javascripts/jqueryui/datepicker-gl.js +26 -0
  35. data/app/assets/javascripts/jqueryui/datepicker-he.js +26 -0
  36. data/app/assets/javascripts/jqueryui/datepicker-hi.js +26 -0
  37. data/app/assets/javascripts/jqueryui/datepicker-hr.js +26 -0
  38. data/app/assets/javascripts/jqueryui/datepicker-hu.js +26 -0
  39. data/app/assets/javascripts/jqueryui/datepicker-hy.js +26 -0
  40. data/app/assets/javascripts/jqueryui/datepicker-id.js +26 -0
  41. data/app/assets/javascripts/jqueryui/datepicker-is.js +26 -0
  42. data/app/assets/javascripts/jqueryui/datepicker-it.js +26 -0
  43. data/app/assets/javascripts/jqueryui/datepicker-ja.js +26 -0
  44. data/app/assets/javascripts/jqueryui/datepicker-ka.js +24 -0
  45. data/app/assets/javascripts/jqueryui/datepicker-kk.js +26 -0
  46. data/app/assets/javascripts/jqueryui/datepicker-km.js +26 -0
  47. data/app/assets/javascripts/jqueryui/datepicker-ko.js +26 -0
  48. data/app/assets/javascripts/jqueryui/datepicker-ky.js +27 -0
  49. data/app/assets/javascripts/jqueryui/datepicker-lb.js +26 -0
  50. data/app/assets/javascripts/jqueryui/datepicker-lt.js +26 -0
  51. data/app/assets/javascripts/jqueryui/datepicker-lv.js +26 -0
  52. data/app/assets/javascripts/jqueryui/datepicker-mk.js +26 -0
  53. data/app/assets/javascripts/jqueryui/datepicker-ml.js +26 -0
  54. data/app/assets/javascripts/jqueryui/datepicker-ms.js +26 -0
  55. data/app/assets/javascripts/jqueryui/datepicker-nb.js +25 -0
  56. data/app/assets/javascripts/jqueryui/datepicker-nl-BE.js +26 -0
  57. data/app/assets/javascripts/jqueryui/datepicker-nl.js +26 -0
  58. data/app/assets/javascripts/jqueryui/datepicker-nn.js +25 -0
  59. data/app/assets/javascripts/jqueryui/datepicker-no.js +26 -0
  60. data/app/assets/javascripts/jqueryui/datepicker-pl.js +26 -0
  61. data/app/assets/javascripts/jqueryui/datepicker-pt-BR.js +26 -0
  62. data/app/assets/javascripts/jqueryui/datepicker-pt.js +25 -0
  63. data/app/assets/javascripts/jqueryui/datepicker-rm.js +24 -0
  64. data/app/assets/javascripts/jqueryui/datepicker-ro.js +29 -0
  65. data/app/assets/javascripts/jqueryui/datepicker-ru.js +26 -0
  66. data/app/assets/javascripts/jqueryui/datepicker-sk.js +26 -0
  67. data/app/assets/javascripts/jqueryui/datepicker-sl.js +27 -0
  68. data/app/assets/javascripts/jqueryui/datepicker-sq.js +26 -0
  69. data/app/assets/javascripts/jqueryui/datepicker-sr-SR.js +26 -0
  70. data/app/assets/javascripts/jqueryui/datepicker-sr.js +26 -0
  71. data/app/assets/javascripts/jqueryui/datepicker-sv.js +26 -0
  72. data/app/assets/javascripts/jqueryui/datepicker-ta.js +26 -0
  73. data/app/assets/javascripts/jqueryui/datepicker-th.js +26 -0
  74. data/app/assets/javascripts/jqueryui/datepicker-tj.js +26 -0
  75. data/app/assets/javascripts/jqueryui/datepicker-tr.js +26 -0
  76. data/app/assets/javascripts/jqueryui/datepicker-uk.js +27 -0
  77. data/app/assets/javascripts/jqueryui/datepicker-vi.js +26 -0
  78. data/app/assets/javascripts/jqueryui/datepicker-zh-CN.js +26 -0
  79. data/app/assets/javascripts/jqueryui/datepicker-zh-HK.js +26 -0
  80. data/app/assets/javascripts/jqueryui/datepicker-zh-TW.js +26 -0
  81. data/app/assets/javascripts/jqueryui/datepicker.js +2053 -0
  82. data/app/assets/javascripts/jqueryui/dialog.js +811 -0
  83. data/app/assets/javascripts/jqueryui/draggable.js +936 -0
  84. data/app/assets/javascripts/jqueryui/droppable.js +375 -0
  85. data/app/assets/javascripts/jqueryui/effect-blind.js +85 -0
  86. data/app/assets/javascripts/jqueryui/effect-bounce.js +116 -0
  87. data/app/assets/javascripts/jqueryui/effect-clip.js +70 -0
  88. data/app/assets/javascripts/jqueryui/effect-drop.js +68 -0
  89. data/app/assets/javascripts/jqueryui/effect-explode.js +100 -0
  90. data/app/assets/javascripts/jqueryui/effect-fade.js +33 -0
  91. data/app/assets/javascripts/jqueryui/effect-fold.js +79 -0
  92. data/app/assets/javascripts/jqueryui/effect-highlight.js +53 -0
  93. data/app/assets/javascripts/jqueryui/effect-pulsate.js +66 -0
  94. data/app/assets/javascripts/jqueryui/effect-scale.js +321 -0
  95. data/app/assets/javascripts/jqueryui/effect-shake.js +77 -0
  96. data/app/assets/javascripts/jqueryui/effect-slide.js +67 -0
  97. data/app/assets/javascripts/jqueryui/effect-transfer.js +50 -0
  98. data/app/assets/javascripts/jqueryui/effect.js +1292 -0
  99. data/app/assets/javascripts/jqueryui/menu.js +624 -0
  100. data/app/assets/javascripts/jqueryui/mouse.js +172 -0
  101. data/app/assets/javascripts/jqueryui/position.js +500 -0
  102. data/app/assets/javascripts/jqueryui/progressbar.js +148 -0
  103. data/app/assets/javascripts/jqueryui/resizable.js +971 -0
  104. data/app/assets/javascripts/jqueryui/selectable.js +280 -0
  105. data/app/assets/javascripts/jqueryui/slider.js +675 -0
  106. data/app/assets/javascripts/jqueryui/sortable.js +1285 -0
  107. data/app/assets/javascripts/jqueryui/spinner.js +496 -0
  108. data/app/assets/javascripts/jqueryui/tabs.js +849 -0
  109. data/app/assets/javascripts/jqueryui/tooltip.js +405 -0
  110. data/app/assets/javascripts/jqueryui/widget.js +524 -0
  111. data/lib/jqueryui-requirejs-rails.rb +4 -0
  112. data/lib/jqueryui-requirejs-rails/engine.rb +4 -0
  113. data/lib/jqueryui-requirejs-rails/version.rb +3 -0
  114. metadata +196 -0
@@ -0,0 +1,936 @@
1
+ define(['jquery','./core','./mouse','./widget'], function (jQuery) {
2
+ /*!
3
+ * jQuery UI Draggable 1.10.2
4
+ * http://jqueryui.com
5
+ *
6
+ * Copyright 2013 jQuery Foundation and other contributors
7
+ * Released under the MIT license.
8
+ * http://jquery.org/license
9
+ *
10
+ * http://api.jqueryui.com/draggable/
11
+ *
12
+ * Depends:
13
+ * jquery.ui.core.js
14
+ * jquery.ui.mouse.js
15
+ * jquery.ui.widget.js
16
+ */
17
+ (function( $, undefined ) {
18
+
19
+ $.widget("ui.draggable", $.ui.mouse, {
20
+ version: "1.10.2",
21
+ widgetEventPrefix: "drag",
22
+ options: {
23
+ addClasses: true,
24
+ appendTo: "parent",
25
+ axis: false,
26
+ connectToSortable: false,
27
+ containment: false,
28
+ cursor: "auto",
29
+ cursorAt: false,
30
+ grid: false,
31
+ handle: false,
32
+ helper: "original",
33
+ iframeFix: false,
34
+ opacity: false,
35
+ refreshPositions: false,
36
+ revert: false,
37
+ revertDuration: 500,
38
+ scope: "default",
39
+ scroll: true,
40
+ scrollSensitivity: 20,
41
+ scrollSpeed: 20,
42
+ snap: false,
43
+ snapMode: "both",
44
+ snapTolerance: 20,
45
+ stack: false,
46
+ zIndex: false,
47
+
48
+ // callbacks
49
+ drag: null,
50
+ start: null,
51
+ stop: null
52
+ },
53
+ _create: function() {
54
+
55
+ if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
56
+ this.element[0].style.position = "relative";
57
+ }
58
+ if (this.options.addClasses){
59
+ this.element.addClass("ui-draggable");
60
+ }
61
+ if (this.options.disabled){
62
+ this.element.addClass("ui-draggable-disabled");
63
+ }
64
+
65
+ this._mouseInit();
66
+
67
+ },
68
+
69
+ _destroy: function() {
70
+ this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
71
+ this._mouseDestroy();
72
+ },
73
+
74
+ _mouseCapture: function(event) {
75
+
76
+ var o = this.options;
77
+
78
+ // among others, prevent a drag on a resizable-handle
79
+ if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
80
+ return false;
81
+ }
82
+
83
+ //Quit if we're not on a valid handle
84
+ this.handle = this._getHandle(event);
85
+ if (!this.handle) {
86
+ return false;
87
+ }
88
+
89
+ $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
90
+ $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
91
+ .css({
92
+ width: this.offsetWidth+"px", height: this.offsetHeight+"px",
93
+ position: "absolute", opacity: "0.001", zIndex: 1000
94
+ })
95
+ .css($(this).offset())
96
+ .appendTo("body");
97
+ });
98
+
99
+ return true;
100
+
101
+ },
102
+
103
+ _mouseStart: function(event) {
104
+
105
+ var o = this.options;
106
+
107
+ //Create and append the visible helper
108
+ this.helper = this._createHelper(event);
109
+
110
+ this.helper.addClass("ui-draggable-dragging");
111
+
112
+ //Cache the helper size
113
+ this._cacheHelperProportions();
114
+
115
+ //If ddmanager is used for droppables, set the global draggable
116
+ if($.ui.ddmanager) {
117
+ $.ui.ddmanager.current = this;
118
+ }
119
+
120
+ /*
121
+ * - Position generation -
122
+ * This block generates everything position related - it's the core of draggables.
123
+ */
124
+
125
+ //Cache the margins of the original element
126
+ this._cacheMargins();
127
+
128
+ //Store the helper's css position
129
+ this.cssPosition = this.helper.css("position");
130
+ this.scrollParent = this.helper.scrollParent();
131
+
132
+ //The element's absolute position on the page minus margins
133
+ this.offset = this.positionAbs = this.element.offset();
134
+ this.offset = {
135
+ top: this.offset.top - this.margins.top,
136
+ left: this.offset.left - this.margins.left
137
+ };
138
+
139
+ $.extend(this.offset, {
140
+ click: { //Where the click happened, relative to the element
141
+ left: event.pageX - this.offset.left,
142
+ top: event.pageY - this.offset.top
143
+ },
144
+ parent: this._getParentOffset(),
145
+ relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
146
+ });
147
+
148
+ //Generate the original position
149
+ this.originalPosition = this.position = this._generatePosition(event);
150
+ this.originalPageX = event.pageX;
151
+ this.originalPageY = event.pageY;
152
+
153
+ //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
154
+ (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
155
+
156
+ //Set a containment if given in the options
157
+ if(o.containment) {
158
+ this._setContainment();
159
+ }
160
+
161
+ //Trigger event + callbacks
162
+ if(this._trigger("start", event) === false) {
163
+ this._clear();
164
+ return false;
165
+ }
166
+
167
+ //Recache the helper size
168
+ this._cacheHelperProportions();
169
+
170
+ //Prepare the droppable offsets
171
+ if ($.ui.ddmanager && !o.dropBehaviour) {
172
+ $.ui.ddmanager.prepareOffsets(this, event);
173
+ }
174
+
175
+
176
+ this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
177
+
178
+ //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
179
+ if ( $.ui.ddmanager ) {
180
+ $.ui.ddmanager.dragStart(this, event);
181
+ }
182
+
183
+ return true;
184
+ },
185
+
186
+ _mouseDrag: function(event, noPropagation) {
187
+
188
+ //Compute the helpers position
189
+ this.position = this._generatePosition(event);
190
+ this.positionAbs = this._convertPositionTo("absolute");
191
+
192
+ //Call plugins and callbacks and use the resulting position if something is returned
193
+ if (!noPropagation) {
194
+ var ui = this._uiHash();
195
+ if(this._trigger("drag", event, ui) === false) {
196
+ this._mouseUp({});
197
+ return false;
198
+ }
199
+ this.position = ui.position;
200
+ }
201
+
202
+ if(!this.options.axis || this.options.axis !== "y") {
203
+ this.helper[0].style.left = this.position.left+"px";
204
+ }
205
+ if(!this.options.axis || this.options.axis !== "x") {
206
+ this.helper[0].style.top = this.position.top+"px";
207
+ }
208
+ if($.ui.ddmanager) {
209
+ $.ui.ddmanager.drag(this, event);
210
+ }
211
+
212
+ return false;
213
+ },
214
+
215
+ _mouseStop: function(event) {
216
+
217
+ //If we are using droppables, inform the manager about the drop
218
+ var element,
219
+ that = this,
220
+ elementInDom = false,
221
+ dropped = false;
222
+ if ($.ui.ddmanager && !this.options.dropBehaviour) {
223
+ dropped = $.ui.ddmanager.drop(this, event);
224
+ }
225
+
226
+ //if a drop comes from outside (a sortable)
227
+ if(this.dropped) {
228
+ dropped = this.dropped;
229
+ this.dropped = false;
230
+ }
231
+
232
+ //if the original element is no longer in the DOM don't bother to continue (see #8269)
233
+ element = this.element[0];
234
+ while ( element && (element = element.parentNode) ) {
235
+ if (element === document ) {
236
+ elementInDom = true;
237
+ }
238
+ }
239
+ if ( !elementInDom && this.options.helper === "original" ) {
240
+ return false;
241
+ }
242
+
243
+ if((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
244
+ $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
245
+ if(that._trigger("stop", event) !== false) {
246
+ that._clear();
247
+ }
248
+ });
249
+ } else {
250
+ if(this._trigger("stop", event) !== false) {
251
+ this._clear();
252
+ }
253
+ }
254
+
255
+ return false;
256
+ },
257
+
258
+ _mouseUp: function(event) {
259
+ //Remove frame helpers
260
+ $("div.ui-draggable-iframeFix").each(function() {
261
+ this.parentNode.removeChild(this);
262
+ });
263
+
264
+ //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
265
+ if( $.ui.ddmanager ) {
266
+ $.ui.ddmanager.dragStop(this, event);
267
+ }
268
+
269
+ return $.ui.mouse.prototype._mouseUp.call(this, event);
270
+ },
271
+
272
+ cancel: function() {
273
+
274
+ if(this.helper.is(".ui-draggable-dragging")) {
275
+ this._mouseUp({});
276
+ } else {
277
+ this._clear();
278
+ }
279
+
280
+ return this;
281
+
282
+ },
283
+
284
+ _getHandle: function(event) {
285
+ return this.options.handle ?
286
+ !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
287
+ true;
288
+ },
289
+
290
+ _createHelper: function(event) {
291
+
292
+ var o = this.options,
293
+ helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
294
+
295
+ if(!helper.parents("body").length) {
296
+ helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
297
+ }
298
+
299
+ if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
300
+ helper.css("position", "absolute");
301
+ }
302
+
303
+ return helper;
304
+
305
+ },
306
+
307
+ _adjustOffsetFromHelper: function(obj) {
308
+ if (typeof obj === "string") {
309
+ obj = obj.split(" ");
310
+ }
311
+ if ($.isArray(obj)) {
312
+ obj = {left: +obj[0], top: +obj[1] || 0};
313
+ }
314
+ if ("left" in obj) {
315
+ this.offset.click.left = obj.left + this.margins.left;
316
+ }
317
+ if ("right" in obj) {
318
+ this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
319
+ }
320
+ if ("top" in obj) {
321
+ this.offset.click.top = obj.top + this.margins.top;
322
+ }
323
+ if ("bottom" in obj) {
324
+ this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
325
+ }
326
+ },
327
+
328
+ _getParentOffset: function() {
329
+
330
+ //Get the offsetParent and cache its position
331
+ this.offsetParent = this.helper.offsetParent();
332
+ var po = this.offsetParent.offset();
333
+
334
+ // This is a special case where we need to modify a offset calculated on start, since the following happened:
335
+ // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
336
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
337
+ // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
338
+ if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
339
+ po.left += this.scrollParent.scrollLeft();
340
+ po.top += this.scrollParent.scrollTop();
341
+ }
342
+
343
+ //This needs to be actually done for all browsers, since pageX/pageY includes this information
344
+ //Ugly IE fix
345
+ if((this.offsetParent[0] === document.body) ||
346
+ (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
347
+ po = { top: 0, left: 0 };
348
+ }
349
+
350
+ return {
351
+ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
352
+ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
353
+ };
354
+
355
+ },
356
+
357
+ _getRelativeOffset: function() {
358
+
359
+ if(this.cssPosition === "relative") {
360
+ var p = this.element.position();
361
+ return {
362
+ top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
363
+ left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
364
+ };
365
+ } else {
366
+ return { top: 0, left: 0 };
367
+ }
368
+
369
+ },
370
+
371
+ _cacheMargins: function() {
372
+ this.margins = {
373
+ left: (parseInt(this.element.css("marginLeft"),10) || 0),
374
+ top: (parseInt(this.element.css("marginTop"),10) || 0),
375
+ right: (parseInt(this.element.css("marginRight"),10) || 0),
376
+ bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
377
+ };
378
+ },
379
+
380
+ _cacheHelperProportions: function() {
381
+ this.helperProportions = {
382
+ width: this.helper.outerWidth(),
383
+ height: this.helper.outerHeight()
384
+ };
385
+ },
386
+
387
+ _setContainment: function() {
388
+
389
+ var over, c, ce,
390
+ o = this.options;
391
+
392
+ if(o.containment === "parent") {
393
+ o.containment = this.helper[0].parentNode;
394
+ }
395
+ if(o.containment === "document" || o.containment === "window") {
396
+ this.containment = [
397
+ o.containment === "document" ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
398
+ o.containment === "document" ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
399
+ (o.containment === "document" ? 0 : $(window).scrollLeft()) + $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
400
+ (o.containment === "document" ? 0 : $(window).scrollTop()) + ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
401
+ ];
402
+ }
403
+
404
+ if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor !== Array) {
405
+ c = $(o.containment);
406
+ ce = c[0];
407
+
408
+ if(!ce) {
409
+ return;
410
+ }
411
+
412
+ over = ($(ce).css("overflow") !== "hidden");
413
+
414
+ this.containment = [
415
+ (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
416
+ (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
417
+ (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderRightWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
418
+ (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderBottomWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom
419
+ ];
420
+ this.relative_container = c;
421
+
422
+ } else if(o.containment.constructor === Array) {
423
+ this.containment = o.containment;
424
+ }
425
+
426
+ },
427
+
428
+ _convertPositionTo: function(d, pos) {
429
+
430
+ if(!pos) {
431
+ pos = this.position;
432
+ }
433
+
434
+ var mod = d === "absolute" ? 1 : -1,
435
+ 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);
436
+
437
+ return {
438
+ top: (
439
+ pos.top + // The absolute mouse position
440
+ this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
441
+ this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
442
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
443
+ ),
444
+ left: (
445
+ pos.left + // The absolute mouse position
446
+ this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
447
+ this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
448
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
449
+ )
450
+ };
451
+
452
+ },
453
+
454
+ _generatePosition: function(event) {
455
+
456
+ var containment, co, top, left,
457
+ o = this.options,
458
+ scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
459
+ scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName),
460
+ pageX = event.pageX,
461
+ pageY = event.pageY;
462
+
463
+ /*
464
+ * - Position constraining -
465
+ * Constrain the position to a mix of grid, containment.
466
+ */
467
+
468
+ if(this.originalPosition) { //If we are not dragging yet, we won't check for options
469
+ if(this.containment) {
470
+ if (this.relative_container){
471
+ co = this.relative_container.offset();
472
+ containment = [ this.containment[0] + co.left,
473
+ this.containment[1] + co.top,
474
+ this.containment[2] + co.left,
475
+ this.containment[3] + co.top ];
476
+ }
477
+ else {
478
+ containment = this.containment;
479
+ }
480
+
481
+ if(event.pageX - this.offset.click.left < containment[0]) {
482
+ pageX = containment[0] + this.offset.click.left;
483
+ }
484
+ if(event.pageY - this.offset.click.top < containment[1]) {
485
+ pageY = containment[1] + this.offset.click.top;
486
+ }
487
+ if(event.pageX - this.offset.click.left > containment[2]) {
488
+ pageX = containment[2] + this.offset.click.left;
489
+ }
490
+ if(event.pageY - this.offset.click.top > containment[3]) {
491
+ pageY = containment[3] + this.offset.click.top;
492
+ }
493
+ }
494
+
495
+ if(o.grid) {
496
+ //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
497
+ top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
498
+ pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
499
+
500
+ left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
501
+ pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
502
+ }
503
+
504
+ }
505
+
506
+ return {
507
+ top: (
508
+ pageY - // The absolute mouse position
509
+ this.offset.click.top - // Click offset (relative to the element)
510
+ this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
511
+ this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
512
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
513
+ ),
514
+ left: (
515
+ pageX - // The absolute mouse position
516
+ this.offset.click.left - // Click offset (relative to the element)
517
+ this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
518
+ this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
519
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
520
+ )
521
+ };
522
+
523
+ },
524
+
525
+ _clear: function() {
526
+ this.helper.removeClass("ui-draggable-dragging");
527
+ if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
528
+ this.helper.remove();
529
+ }
530
+ this.helper = null;
531
+ this.cancelHelperRemoval = false;
532
+ },
533
+
534
+ // From now on bulk stuff - mainly helpers
535
+
536
+ _trigger: function(type, event, ui) {
537
+ ui = ui || this._uiHash();
538
+ $.ui.plugin.call(this, type, [event, ui]);
539
+ //The absolute position has to be recalculated after plugins
540
+ if(type === "drag") {
541
+ this.positionAbs = this._convertPositionTo("absolute");
542
+ }
543
+ return $.Widget.prototype._trigger.call(this, type, event, ui);
544
+ },
545
+
546
+ plugins: {},
547
+
548
+ _uiHash: function() {
549
+ return {
550
+ helper: this.helper,
551
+ position: this.position,
552
+ originalPosition: this.originalPosition,
553
+ offset: this.positionAbs
554
+ };
555
+ }
556
+
557
+ });
558
+
559
+ $.ui.plugin.add("draggable", "connectToSortable", {
560
+ start: function(event, ui) {
561
+
562
+ var inst = $(this).data("ui-draggable"), o = inst.options,
563
+ uiSortable = $.extend({}, ui, { item: inst.element });
564
+ inst.sortables = [];
565
+ $(o.connectToSortable).each(function() {
566
+ var sortable = $.data(this, "ui-sortable");
567
+ if (sortable && !sortable.options.disabled) {
568
+ inst.sortables.push({
569
+ instance: sortable,
570
+ shouldRevert: sortable.options.revert
571
+ });
572
+ sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
573
+ sortable._trigger("activate", event, uiSortable);
574
+ }
575
+ });
576
+
577
+ },
578
+ stop: function(event, ui) {
579
+
580
+ //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
581
+ var inst = $(this).data("ui-draggable"),
582
+ uiSortable = $.extend({}, ui, { item: inst.element });
583
+
584
+ $.each(inst.sortables, function() {
585
+ if(this.instance.isOver) {
586
+
587
+ this.instance.isOver = 0;
588
+
589
+ inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
590
+ this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
591
+
592
+ //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
593
+ if(this.shouldRevert) {
594
+ this.instance.options.revert = this.shouldRevert;
595
+ }
596
+
597
+ //Trigger the stop of the sortable
598
+ this.instance._mouseStop(event);
599
+
600
+ this.instance.options.helper = this.instance.options._helper;
601
+
602
+ //If the helper has been the original item, restore properties in the sortable
603
+ if(inst.options.helper === "original") {
604
+ this.instance.currentItem.css({ top: "auto", left: "auto" });
605
+ }
606
+
607
+ } else {
608
+ this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
609
+ this.instance._trigger("deactivate", event, uiSortable);
610
+ }
611
+
612
+ });
613
+
614
+ },
615
+ drag: function(event, ui) {
616
+
617
+ var inst = $(this).data("ui-draggable"), that = this;
618
+
619
+ $.each(inst.sortables, function() {
620
+
621
+ var innermostIntersecting = false,
622
+ thisSortable = this;
623
+
624
+ //Copy over some variables to allow calling the sortable's native _intersectsWith
625
+ this.instance.positionAbs = inst.positionAbs;
626
+ this.instance.helperProportions = inst.helperProportions;
627
+ this.instance.offset.click = inst.offset.click;
628
+
629
+ if(this.instance._intersectsWith(this.instance.containerCache)) {
630
+ innermostIntersecting = true;
631
+ $.each(inst.sortables, function () {
632
+ this.instance.positionAbs = inst.positionAbs;
633
+ this.instance.helperProportions = inst.helperProportions;
634
+ this.instance.offset.click = inst.offset.click;
635
+ if (this !== thisSortable &&
636
+ this.instance._intersectsWith(this.instance.containerCache) &&
637
+ $.contains(thisSortable.instance.element[0], this.instance.element[0])
638
+ ) {
639
+ innermostIntersecting = false;
640
+ }
641
+ return innermostIntersecting;
642
+ });
643
+ }
644
+
645
+
646
+ if(innermostIntersecting) {
647
+ //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
648
+ if(!this.instance.isOver) {
649
+
650
+ this.instance.isOver = 1;
651
+ //Now we fake the start of dragging for the sortable instance,
652
+ //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
653
+ //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
654
+ this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
655
+ this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
656
+ this.instance.options.helper = function() { return ui.helper[0]; };
657
+
658
+ event.target = this.instance.currentItem[0];
659
+ this.instance._mouseCapture(event, true);
660
+ this.instance._mouseStart(event, true, true);
661
+
662
+ //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
663
+ this.instance.offset.click.top = inst.offset.click.top;
664
+ this.instance.offset.click.left = inst.offset.click.left;
665
+ this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
666
+ this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
667
+
668
+ inst._trigger("toSortable", event);
669
+ inst.dropped = this.instance.element; //draggable revert needs that
670
+ //hack so receive/update callbacks work (mostly)
671
+ inst.currentItem = inst.element;
672
+ this.instance.fromOutside = inst;
673
+
674
+ }
675
+
676
+ //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
677
+ if(this.instance.currentItem) {
678
+ this.instance._mouseDrag(event);
679
+ }
680
+
681
+ } else {
682
+
683
+ //If it doesn't intersect with the sortable, and it intersected before,
684
+ //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
685
+ if(this.instance.isOver) {
686
+
687
+ this.instance.isOver = 0;
688
+ this.instance.cancelHelperRemoval = true;
689
+
690
+ //Prevent reverting on this forced stop
691
+ this.instance.options.revert = false;
692
+
693
+ // The out event needs to be triggered independently
694
+ this.instance._trigger("out", event, this.instance._uiHash(this.instance));
695
+
696
+ this.instance._mouseStop(event, true);
697
+ this.instance.options.helper = this.instance.options._helper;
698
+
699
+ //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
700
+ this.instance.currentItem.remove();
701
+ if(this.instance.placeholder) {
702
+ this.instance.placeholder.remove();
703
+ }
704
+
705
+ inst._trigger("fromSortable", event);
706
+ inst.dropped = false; //draggable revert needs that
707
+ }
708
+
709
+ }
710
+
711
+ });
712
+
713
+ }
714
+ });
715
+
716
+ $.ui.plugin.add("draggable", "cursor", {
717
+ start: function() {
718
+ var t = $("body"), o = $(this).data("ui-draggable").options;
719
+ if (t.css("cursor")) {
720
+ o._cursor = t.css("cursor");
721
+ }
722
+ t.css("cursor", o.cursor);
723
+ },
724
+ stop: function() {
725
+ var o = $(this).data("ui-draggable").options;
726
+ if (o._cursor) {
727
+ $("body").css("cursor", o._cursor);
728
+ }
729
+ }
730
+ });
731
+
732
+ $.ui.plugin.add("draggable", "opacity", {
733
+ start: function(event, ui) {
734
+ var t = $(ui.helper), o = $(this).data("ui-draggable").options;
735
+ if(t.css("opacity")) {
736
+ o._opacity = t.css("opacity");
737
+ }
738
+ t.css("opacity", o.opacity);
739
+ },
740
+ stop: function(event, ui) {
741
+ var o = $(this).data("ui-draggable").options;
742
+ if(o._opacity) {
743
+ $(ui.helper).css("opacity", o._opacity);
744
+ }
745
+ }
746
+ });
747
+
748
+ $.ui.plugin.add("draggable", "scroll", {
749
+ start: function() {
750
+ var i = $(this).data("ui-draggable");
751
+ if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
752
+ i.overflowOffset = i.scrollParent.offset();
753
+ }
754
+ },
755
+ drag: function( event ) {
756
+
757
+ var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
758
+
759
+ if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
760
+
761
+ if(!o.axis || o.axis !== "x") {
762
+ if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
763
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
764
+ } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
765
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
766
+ }
767
+ }
768
+
769
+ if(!o.axis || o.axis !== "y") {
770
+ if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
771
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
772
+ } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
773
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
774
+ }
775
+ }
776
+
777
+ } else {
778
+
779
+ if(!o.axis || o.axis !== "x") {
780
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
781
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
782
+ } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
783
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
784
+ }
785
+ }
786
+
787
+ if(!o.axis || o.axis !== "y") {
788
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
789
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
790
+ } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
791
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
792
+ }
793
+ }
794
+
795
+ }
796
+
797
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
798
+ $.ui.ddmanager.prepareOffsets(i, event);
799
+ }
800
+
801
+ }
802
+ });
803
+
804
+ $.ui.plugin.add("draggable", "snap", {
805
+ start: function() {
806
+
807
+ var i = $(this).data("ui-draggable"),
808
+ o = i.options;
809
+
810
+ i.snapElements = [];
811
+
812
+ $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
813
+ var $t = $(this),
814
+ $o = $t.offset();
815
+ if(this !== i.element[0]) {
816
+ i.snapElements.push({
817
+ item: this,
818
+ width: $t.outerWidth(), height: $t.outerHeight(),
819
+ top: $o.top, left: $o.left
820
+ });
821
+ }
822
+ });
823
+
824
+ },
825
+ drag: function(event, ui) {
826
+
827
+ var ts, bs, ls, rs, l, r, t, b, i, first,
828
+ inst = $(this).data("ui-draggable"),
829
+ o = inst.options,
830
+ d = o.snapTolerance,
831
+ x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
832
+ y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
833
+
834
+ for (i = inst.snapElements.length - 1; i >= 0; i--){
835
+
836
+ l = inst.snapElements[i].left;
837
+ r = l + inst.snapElements[i].width;
838
+ t = inst.snapElements[i].top;
839
+ b = t + inst.snapElements[i].height;
840
+
841
+ //Yes, I know, this is insane ;)
842
+ if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
843
+ if(inst.snapElements[i].snapping) {
844
+ (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
845
+ }
846
+ inst.snapElements[i].snapping = false;
847
+ continue;
848
+ }
849
+
850
+ if(o.snapMode !== "inner") {
851
+ ts = Math.abs(t - y2) <= d;
852
+ bs = Math.abs(b - y1) <= d;
853
+ ls = Math.abs(l - x2) <= d;
854
+ rs = Math.abs(r - x1) <= d;
855
+ if(ts) {
856
+ ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
857
+ }
858
+ if(bs) {
859
+ ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
860
+ }
861
+ if(ls) {
862
+ ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
863
+ }
864
+ if(rs) {
865
+ ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
866
+ }
867
+ }
868
+
869
+ first = (ts || bs || ls || rs);
870
+
871
+ if(o.snapMode !== "outer") {
872
+ ts = Math.abs(t - y1) <= d;
873
+ bs = Math.abs(b - y2) <= d;
874
+ ls = Math.abs(l - x1) <= d;
875
+ rs = Math.abs(r - x2) <= d;
876
+ if(ts) {
877
+ ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
878
+ }
879
+ if(bs) {
880
+ ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
881
+ }
882
+ if(ls) {
883
+ ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
884
+ }
885
+ if(rs) {
886
+ ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
887
+ }
888
+ }
889
+
890
+ if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
891
+ (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
892
+ }
893
+ inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
894
+
895
+ }
896
+
897
+ }
898
+ });
899
+
900
+ $.ui.plugin.add("draggable", "stack", {
901
+ start: function() {
902
+ var min,
903
+ o = this.data("ui-draggable").options,
904
+ group = $.makeArray($(o.stack)).sort(function(a,b) {
905
+ return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
906
+ });
907
+
908
+ if (!group.length) { return; }
909
+
910
+ min = parseInt($(group[0]).css("zIndex"), 10) || 0;
911
+ $(group).each(function(i) {
912
+ $(this).css("zIndex", min + i);
913
+ });
914
+ this.css("zIndex", (min + group.length));
915
+ }
916
+ });
917
+
918
+ $.ui.plugin.add("draggable", "zIndex", {
919
+ start: function(event, ui) {
920
+ var t = $(ui.helper), o = $(this).data("ui-draggable").options;
921
+ if(t.css("zIndex")) {
922
+ o._zIndex = t.css("zIndex");
923
+ }
924
+ t.css("zIndex", o.zIndex);
925
+ },
926
+ stop: function(event, ui) {
927
+ var o = $(this).data("ui-draggable").options;
928
+ if(o._zIndex) {
929
+ $(ui.helper).css("zIndex", o._zIndex);
930
+ }
931
+ }
932
+ });
933
+
934
+ })(jQuery);
935
+
936
+ });