stuff_to_do_plugin 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. data/COPYRIGHT.txt +18 -0
  2. data/CREDITS.txt +6 -0
  3. data/GPL.txt +339 -0
  4. data/README.rdoc +61 -0
  5. data/Rakefile +38 -0
  6. data/VERSION +1 -0
  7. data/app/controllers/stuff_to_do_controller.rb +161 -0
  8. data/app/helpers/stuff_to_do_helper.rb +88 -0
  9. data/app/models/stuff_to_do.rb +208 -0
  10. data/app/models/stuff_to_do_filter.rb +32 -0
  11. data/app/models/stuff_to_do_mailer.rb +16 -0
  12. data/app/views/settings/_stuff_to_do_settings.html.erb +27 -0
  13. data/app/views/stuff_to_do/_issue.html.erb +16 -0
  14. data/app/views/stuff_to_do/_item.html.erb +5 -0
  15. data/app/views/stuff_to_do/_left_panes.html.erb +51 -0
  16. data/app/views/stuff_to_do/_panes.html.erb +11 -0
  17. data/app/views/stuff_to_do/_project.html.erb +6 -0
  18. data/app/views/stuff_to_do/_right_panes.html.erb +25 -0
  19. data/app/views/stuff_to_do/_time_grid.html.erb +113 -0
  20. data/app/views/stuff_to_do/_time_grid_form.html.erb +32 -0
  21. data/app/views/stuff_to_do/index.html.erb +44 -0
  22. data/app/views/stuff_to_do_mailer/recommended_below_threshold.erb +3 -0
  23. data/app/views/stuff_to_do_mailer/recommended_below_threshold.text.html.rhtml +1 -0
  24. data/assets/images/b.png +0 -0
  25. data/assets/images/bl.png +0 -0
  26. data/assets/images/br.png +0 -0
  27. data/assets/images/closelabel.gif +0 -0
  28. data/assets/images/loading.gif +0 -0
  29. data/assets/images/tl.png +0 -0
  30. data/assets/images/tr.png +0 -0
  31. data/assets/javascripts/facebox.js +319 -0
  32. data/assets/javascripts/jquery-1.2.6.min.js +32 -0
  33. data/assets/javascripts/jquery-ui.js +2839 -0
  34. data/assets/javascripts/jquery.contextMenu.js +212 -0
  35. data/assets/javascripts/semantic.cache +15 -0
  36. data/assets/javascripts/stuff-to-do.js +270 -0
  37. data/assets/javascripts/ui/build.xml +24 -0
  38. data/assets/javascripts/ui/effects.blind.js +49 -0
  39. data/assets/javascripts/ui/effects.bounce.js +78 -0
  40. data/assets/javascripts/ui/effects.clip.js +54 -0
  41. data/assets/javascripts/ui/effects.core.js +510 -0
  42. data/assets/javascripts/ui/effects.drop.js +50 -0
  43. data/assets/javascripts/ui/effects.explode.js +79 -0
  44. data/assets/javascripts/ui/effects.fold.js +55 -0
  45. data/assets/javascripts/ui/effects.highlight.js +48 -0
  46. data/assets/javascripts/ui/effects.pulsate.js +55 -0
  47. data/assets/javascripts/ui/effects.scale.js +180 -0
  48. data/assets/javascripts/ui/effects.shake.js +57 -0
  49. data/assets/javascripts/ui/effects.slide.js +50 -0
  50. data/assets/javascripts/ui/effects.transfer.js +59 -0
  51. data/assets/javascripts/ui/i18n/ui.datepicker-ar.js +26 -0
  52. data/assets/javascripts/ui/i18n/ui.datepicker-bg.js +25 -0
  53. data/assets/javascripts/ui/i18n/ui.datepicker-ca.js +25 -0
  54. data/assets/javascripts/ui/i18n/ui.datepicker-cs.js +25 -0
  55. data/assets/javascripts/ui/i18n/ui.datepicker-da.js +25 -0
  56. data/assets/javascripts/ui/i18n/ui.datepicker-de.js +25 -0
  57. data/assets/javascripts/ui/i18n/ui.datepicker-eo.js +25 -0
  58. data/assets/javascripts/ui/i18n/ui.datepicker-es.js +25 -0
  59. data/assets/javascripts/ui/i18n/ui.datepicker-fa.js +25 -0
  60. data/assets/javascripts/ui/i18n/ui.datepicker-fi.js +25 -0
  61. data/assets/javascripts/ui/i18n/ui.datepicker-fr.js +25 -0
  62. data/assets/javascripts/ui/i18n/ui.datepicker-he.js +25 -0
  63. data/assets/javascripts/ui/i18n/ui.datepicker-hr.js +25 -0
  64. data/assets/javascripts/ui/i18n/ui.datepicker-hu.js +25 -0
  65. data/assets/javascripts/ui/i18n/ui.datepicker-hy.js +25 -0
  66. data/assets/javascripts/ui/i18n/ui.datepicker-id.js +25 -0
  67. data/assets/javascripts/ui/i18n/ui.datepicker-is.js +25 -0
  68. data/assets/javascripts/ui/i18n/ui.datepicker-it.js +25 -0
  69. data/assets/javascripts/ui/i18n/ui.datepicker-ja.js +26 -0
  70. data/assets/javascripts/ui/i18n/ui.datepicker-ko.js +25 -0
  71. data/assets/javascripts/ui/i18n/ui.datepicker-lt.js +25 -0
  72. data/assets/javascripts/ui/i18n/ui.datepicker-lv.js +25 -0
  73. data/assets/javascripts/ui/i18n/ui.datepicker-nl.js +25 -0
  74. data/assets/javascripts/ui/i18n/ui.datepicker-no.js +25 -0
  75. data/assets/javascripts/ui/i18n/ui.datepicker-pl.js +25 -0
  76. data/assets/javascripts/ui/i18n/ui.datepicker-pt-BR.js +25 -0
  77. data/assets/javascripts/ui/i18n/ui.datepicker-ro.js +25 -0
  78. data/assets/javascripts/ui/i18n/ui.datepicker-ru.js +25 -0
  79. data/assets/javascripts/ui/i18n/ui.datepicker-sk.js +25 -0
  80. data/assets/javascripts/ui/i18n/ui.datepicker-sl.js +26 -0
  81. data/assets/javascripts/ui/i18n/ui.datepicker-sq.js +25 -0
  82. data/assets/javascripts/ui/i18n/ui.datepicker-sv.js +25 -0
  83. data/assets/javascripts/ui/i18n/ui.datepicker-th.js +25 -0
  84. data/assets/javascripts/ui/i18n/ui.datepicker-tr.js +25 -0
  85. data/assets/javascripts/ui/i18n/ui.datepicker-uk.js +25 -0
  86. data/assets/javascripts/ui/i18n/ui.datepicker-zh-CN.js +25 -0
  87. data/assets/javascripts/ui/i18n/ui.datepicker-zh-TW.js +25 -0
  88. data/assets/javascripts/ui/svn.log +11 -0
  89. data/assets/javascripts/ui/ui.accordion.js +400 -0
  90. data/assets/javascripts/ui/ui.core.js +533 -0
  91. data/assets/javascripts/ui/ui.datepicker.js +1754 -0
  92. data/assets/javascripts/ui/ui.dialog.js +630 -0
  93. data/assets/javascripts/ui/ui.draggable.js +696 -0
  94. data/assets/javascripts/ui/ui.droppable.js +314 -0
  95. data/assets/javascripts/ui/ui.progressbar.js +114 -0
  96. data/assets/javascripts/ui/ui.resizable.js +805 -0
  97. data/assets/javascripts/ui/ui.selectable.js +266 -0
  98. data/assets/javascripts/ui/ui.slider.js +552 -0
  99. data/assets/javascripts/ui/ui.sortable.js +1012 -0
  100. data/assets/javascripts/ui/ui.tabs.js +572 -0
  101. data/assets/stylesheets/stuff_to_do.css +216 -0
  102. data/config/locales/bg.yml +18 -0
  103. data/config/locales/ca-fr.yml +18 -0
  104. data/config/locales/cs.yml +16 -0
  105. data/config/locales/da.yml +16 -0
  106. data/config/locales/de.yml +18 -0
  107. data/config/locales/en.yml +24 -0
  108. data/config/locales/es.yml +19 -0
  109. data/config/locales/fr.yml +17 -0
  110. data/config/locales/hu.yml +16 -0
  111. data/config/locales/it.yml +16 -0
  112. data/config/locales/ja.yml +18 -0
  113. data/config/locales/ko.yml +18 -0
  114. data/config/locales/lt.yml +18 -0
  115. data/config/locales/nl.yml +20 -0
  116. data/config/locales/pt-BR.yml +18 -0
  117. data/config/locales/ru.yml +19 -0
  118. data/config/locales/sv.yml +19 -0
  119. data/config/locales/tr.yml +18 -0
  120. data/config/routes.rb +3 -0
  121. data/init.rb +54 -0
  122. data/lang/bg.yml +17 -0
  123. data/lang/ca-fr.yml +17 -0
  124. data/lang/cs.yml +15 -0
  125. data/lang/da.yml +15 -0
  126. data/lang/de.yml +17 -0
  127. data/lang/en.yml +21 -0
  128. data/lang/es.yml +18 -0
  129. data/lang/fr.yml +16 -0
  130. data/lang/hu.yml +15 -0
  131. data/lang/it.yml +15 -0
  132. data/lang/ja.yml +17 -0
  133. data/lang/ko.yml +17 -0
  134. data/lang/lt.yml +17 -0
  135. data/lang/pt-br.yml +17 -0
  136. data/lang/ru.yml +15 -0
  137. data/lang/sv.yml +18 -0
  138. data/lang/tr.yml +17 -0
  139. data/lib/redmine_stuff_to_do/stuff_to_do_compatibility.rb +15 -0
  140. data/lib/stuff_to_do_array_patch.rb +8 -0
  141. data/lib/stuff_to_do_issue_patch.rb +57 -0
  142. data/lib/stuff_to_do_project_patch.rb +31 -0
  143. data/lib/stuff_to_do_user_patch.rb +10 -0
  144. data/rails/init.rb +1 -0
  145. data/spec/controllers/stuff_to_do_controller_add_to_time_grid_spec.rb +58 -0
  146. data/spec/controllers/stuff_to_do_controller_index_spec.rb +155 -0
  147. data/spec/controllers/stuff_to_do_controller_remove_from_time_grid_spec.rb +56 -0
  148. data/spec/controllers/stuff_to_do_controller_reorder_spec.rb +179 -0
  149. data/spec/controllers/stuff_to_do_controller_save_time_entries_spec.rb +56 -0
  150. data/spec/controllers/stuff_to_do_private_methods_spec.rb +82 -0
  151. data/spec/lib/stuff_to_do_issue_patch_spec.rb +60 -0
  152. data/spec/lib/stuff_to_do_project_patch_spec.rb +50 -0
  153. data/spec/lib/stuff_to_do_user_patch_spec.rb +8 -0
  154. data/spec/models/stuff_to_do_filter_spec.rb +3 -0
  155. data/spec/models/stuff_to_do_mailer_spec.rb +42 -0
  156. data/spec/models/stuff_to_do_spec.rb +426 -0
  157. data/spec/sanity_spec.rb +7 -0
  158. data/spec/spec_helper.rb +130 -0
  159. metadata +211 -0
@@ -0,0 +1,696 @@
1
+ /*
2
+ * jQuery UI Draggable @VERSION
3
+ *
4
+ * Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.com/about)
5
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
6
+ * and GPL (GPL-LICENSE.txt) licenses.
7
+ *
8
+ * http://docs.jquery.com/UI/Draggables
9
+ *
10
+ * Depends:
11
+ * ui.core.js
12
+ */
13
+ (function($) {
14
+
15
+ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
16
+
17
+ _init: function() {
18
+
19
+ if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
20
+ this.element[0].style.position = 'relative';
21
+
22
+ (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-draggable"));
23
+ (this.options.disabled && this.element.addClass('ui-draggable-disabled'));
24
+
25
+ this._mouseInit();
26
+
27
+ },
28
+
29
+ destroy: function() {
30
+ if(!this.element.data('draggable')) return;
31
+ this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled');
32
+ this._mouseDestroy();
33
+ },
34
+
35
+ _mouseCapture: function(event) {
36
+
37
+ var o = this.options;
38
+
39
+ if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
40
+ return false;
41
+
42
+ //Quit if we're not on a valid handle
43
+ this.handle = this._getHandle(event);
44
+ if (!this.handle)
45
+ return false;
46
+
47
+ return true;
48
+
49
+ },
50
+
51
+ _mouseStart: function(event) {
52
+
53
+ var o = this.options;
54
+
55
+ //Create and append the visible helper
56
+ this.helper = this._createHelper(event);
57
+
58
+ //Cache the helper size
59
+ this._cacheHelperProportions();
60
+
61
+ //If ddmanager is used for droppables, set the global draggable
62
+ if($.ui.ddmanager)
63
+ $.ui.ddmanager.current = this;
64
+
65
+ /*
66
+ * - Position generation -
67
+ * This block generates everything position related - it's the core of draggables.
68
+ */
69
+
70
+ //Cache the margins of the original element
71
+ this._cacheMargins();
72
+
73
+ //Store the helper's css position
74
+ this.cssPosition = this.helper.css("position");
75
+ this.scrollParent = this.helper.scrollParent();
76
+
77
+ //The element's absolute position on the page minus margins
78
+ this.offset = this.element.offset();
79
+ this.offset = {
80
+ top: this.offset.top - this.margins.top,
81
+ left: this.offset.left - this.margins.left
82
+ };
83
+
84
+ $.extend(this.offset, {
85
+ click: { //Where the click happened, relative to the element
86
+ left: event.pageX - this.offset.left,
87
+ top: event.pageY - this.offset.top
88
+ },
89
+ parent: this._getParentOffset(),
90
+ relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
91
+ });
92
+
93
+ //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
94
+ if(o.cursorAt)
95
+ this._adjustOffsetFromHelper(o.cursorAt);
96
+
97
+ //Generate the original position
98
+ this.originalPosition = this._generatePosition(event);
99
+
100
+ //Set a containment if given in the options
101
+ if(o.containment)
102
+ this._setContainment();
103
+
104
+ //Call plugins and callbacks
105
+ this._propagate("start", event);
106
+
107
+ //Recache the helper size
108
+ this._cacheHelperProportions();
109
+
110
+ //Prepare the droppable offsets
111
+ if ($.ui.ddmanager && !o.dropBehaviour)
112
+ $.ui.ddmanager.prepareOffsets(this, event);
113
+
114
+ this.helper.addClass("ui-draggable-dragging");
115
+ this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
116
+ return true;
117
+ },
118
+
119
+ _mouseDrag: function(event, noPropagation) {
120
+
121
+ //Compute the helpers position
122
+ this.position = this._generatePosition(event);
123
+ this.positionAbs = this._convertPositionTo("absolute");
124
+
125
+ //Call plugins and callbacks and use the resulting position if something is returned
126
+ if(!noPropagation) this.position = this._propagate("drag", event) || this.position;
127
+
128
+ if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
129
+ if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
130
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
131
+
132
+ return false;
133
+ },
134
+
135
+ _mouseStop: function(event) {
136
+
137
+ //If we are using droppables, inform the manager about the drop
138
+ var dropped = false;
139
+ if ($.ui.ddmanager && !this.options.dropBehaviour)
140
+ var dropped = $.ui.ddmanager.drop(this, event);
141
+
142
+ 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))) {
143
+ var self = this;
144
+ $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
145
+ self._propagate("stop", event);
146
+ self._clear();
147
+ });
148
+ } else {
149
+ this._propagate("stop", event);
150
+ this._clear();
151
+ }
152
+
153
+ return false;
154
+ },
155
+
156
+ _getHandle: function(event) {
157
+
158
+ var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
159
+ $(this.options.handle, this.element)
160
+ .find("*")
161
+ .andSelf()
162
+ .each(function() {
163
+ if(this == event.target) handle = true;
164
+ });
165
+
166
+ return handle;
167
+
168
+ },
169
+
170
+ _createHelper: function(event) {
171
+
172
+ var o = this.options;
173
+ var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element);
174
+
175
+ if(!helper.parents('body').length)
176
+ helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
177
+
178
+ if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
179
+ helper.css("position", "absolute");
180
+
181
+ return helper;
182
+
183
+ },
184
+
185
+ _adjustOffsetFromHelper: function(obj) {
186
+ if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left;
187
+ if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
188
+ if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top;
189
+ if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
190
+ },
191
+
192
+ _getParentOffset: function() {
193
+
194
+ this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); //Get the offsetParent and cache its position
195
+
196
+ if((this.offsetParent[0] == document.body && $.browser.mozilla) //Ugly FF3 fix
197
+ || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
198
+ po = { top: 0, left: 0 };
199
+
200
+ return {
201
+ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
202
+ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
203
+ };
204
+
205
+ },
206
+
207
+ _getRelativeOffset: function() {
208
+
209
+ if(this.cssPosition == "relative") {
210
+ var p = this.element.position();
211
+ return {
212
+ top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
213
+ left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
214
+ };
215
+ } else {
216
+ return { top: 0, left: 0 };
217
+ }
218
+
219
+ },
220
+
221
+ _cacheMargins: function() {
222
+ this.margins = {
223
+ left: (parseInt(this.element.css("marginLeft"),10) || 0),
224
+ top: (parseInt(this.element.css("marginTop"),10) || 0)
225
+ };
226
+ },
227
+
228
+ _cacheHelperProportions: function() {
229
+ this.helperProportions = {
230
+ width: this.helper.outerWidth(),
231
+ height: this.helper.outerHeight()
232
+ };
233
+ },
234
+
235
+ _setContainment: function() {
236
+
237
+ var o = this.options;
238
+ if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
239
+ if(o.containment == 'document' || o.containment == 'window') this.containment = [
240
+ 0 - this.offset.relative.left - this.offset.parent.left,
241
+ 0 - this.offset.relative.top - this.offset.parent.top,
242
+ $(o.containment == 'document' ? document : window).width() - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),
243
+ ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)
244
+ ];
245
+
246
+ if(!(/^(document|window|parent)$/).test(o.containment)) {
247
+ var ce = $(o.containment)[0];
248
+ var co = $(o.containment).offset();
249
+ var over = ($(ce).css("overflow") != 'hidden');
250
+
251
+ this.containment = [
252
+ co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left,
253
+ co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top,
254
+ co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),
255
+ co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)
256
+ ];
257
+ }
258
+
259
+ },
260
+
261
+ _convertPositionTo: function(d, pos) {
262
+
263
+ if(!pos) pos = this.position;
264
+ var mod = d == "absolute" ? 1 : -1;
265
+ var scroll = this[(this.cssPosition == 'absolute' ? 'offset' : 'scroll')+'Parent'], scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
266
+
267
+ return {
268
+ top: (
269
+ pos.top // the calculated relative position
270
+ + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
271
+ + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
272
+ + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod
273
+ + this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods)
274
+ ),
275
+ left: (
276
+ pos.left // the calculated relative position
277
+ + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
278
+ + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
279
+ + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : ( scrollIsRootNode ? 0 : scroll.scrollLeft() ) ) * mod
280
+ + this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods)
281
+ )
282
+ };
283
+ },
284
+
285
+ _generatePosition: function(event) {
286
+
287
+ var o = this.options, scroll = this[(this.cssPosition == 'absolute' ? 'offset' : 'scroll')+'Parent'], scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
288
+
289
+ var position = {
290
+ top: (
291
+ event.pageY // The absolute mouse position
292
+ - this.offset.click.top // Click offset (relative to the element)
293
+ - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
294
+ - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
295
+ + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )
296
+ ),
297
+ left: (
298
+ event.pageX // The absolute mouse position
299
+ - this.offset.click.left // Click offset (relative to the element)
300
+ - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
301
+ - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
302
+ + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )
303
+ )
304
+ };
305
+
306
+ if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options
307
+
308
+ /*
309
+ * - Position constraining -
310
+ * Constrain the position to a mix of grid, containment.
311
+ */
312
+ if(this.containment) {
313
+ if(position.left < this.containment[0]) position.left = this.containment[0];
314
+ if(position.top < this.containment[1]) position.top = this.containment[1];
315
+ if(position.left > this.containment[2]) position.left = this.containment[2];
316
+ if(position.top > this.containment[3]) position.top = this.containment[3];
317
+ }
318
+
319
+ if(o.grid) {
320
+ var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];
321
+ position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
322
+
323
+ var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];
324
+ position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
325
+ }
326
+
327
+ return position;
328
+ },
329
+
330
+ _clear: function() {
331
+ this.helper.removeClass("ui-draggable-dragging");
332
+ if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
333
+ //if($.ui.ddmanager) $.ui.ddmanager.current = null;
334
+ this.helper = null;
335
+ this.cancelHelperRemoval = false;
336
+ },
337
+
338
+ // From now on bulk stuff - mainly helpers
339
+
340
+ _propagate: function(n, event) {
341
+ $.ui.plugin.call(this, n, [event, this._uiHash()]);
342
+ if(n == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
343
+ return this.element.triggerHandler(n == "drag" ? n : "drag"+n, [event, this._uiHash()], this.options[n]);
344
+ },
345
+
346
+ plugins: {},
347
+
348
+ _uiHash: function(event) {
349
+ return {
350
+ helper: this.helper,
351
+ position: this.position,
352
+ absolutePosition: this.positionAbs,
353
+ options: this.options
354
+ };
355
+ }
356
+
357
+ }));
358
+
359
+ $.extend($.ui.draggable, {
360
+ version: "@VERSION",
361
+ defaults: {
362
+ appendTo: "parent",
363
+ axis: false,
364
+ cancel: ":input",
365
+ connectToSortable: false,
366
+ containment: false,
367
+ cssNamespace: "ui",
368
+ cursor: "default",
369
+ cursorAt: null,
370
+ delay: 0,
371
+ distance: 1,
372
+ grid: false,
373
+ handle: false,
374
+ helper: "original",
375
+ iframeFix: false,
376
+ opacity: 1,
377
+ refreshPositions: false,
378
+ revert: false,
379
+ revertDuration: 500,
380
+ scope: "default",
381
+ scroll: false,
382
+ scrollSensitivity: 20,
383
+ scrollSpeed: 20,
384
+ snap: false,
385
+ snapMode: "both",
386
+ snapTolerance: 20,
387
+ stack: false,
388
+ zIndex: null
389
+ }
390
+ });
391
+
392
+ $.ui.plugin.add("draggable", "connectToSortable", {
393
+ start: function(event, ui) {
394
+
395
+ var inst = $(this).data("draggable");
396
+ inst.sortables = [];
397
+ $(ui.options.connectToSortable).each(function() {
398
+ // 'this' points to a string, and should therefore resolved as query, but instead, if the string is assigned to a variable, it loops through the strings properties,
399
+ // so we have to append '' to make it anonymous again
400
+ $(this+'').each(function() {
401
+ if($.data(this, 'sortable')) {
402
+ var sortable = $.data(this, 'sortable');
403
+ inst.sortables.push({
404
+ instance: sortable,
405
+ shouldRevert: sortable.options.revert
406
+ });
407
+ sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache
408
+ sortable._propagate("activate", event, inst);
409
+ }
410
+ });
411
+ });
412
+
413
+ },
414
+ stop: function(event, ui) {
415
+
416
+ //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
417
+ var inst = $(this).data("draggable");
418
+
419
+ $.each(inst.sortables, function() {
420
+ if(this.instance.isOver) {
421
+ this.instance.isOver = 0;
422
+ inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
423
+ this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
424
+ if(this.shouldRevert) this.instance.options.revert = true; //revert here
425
+ this.instance._mouseStop(event);
426
+
427
+ //Also propagate receive event, since the sortable is actually receiving a element
428
+ this.instance.element.triggerHandler("sortreceive", [event, $.extend(this.instance._ui(), { sender: inst.element })], this.instance.options["receive"]);
429
+
430
+ this.instance.options.helper = this.instance.options._helper;
431
+ } else {
432
+ this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
433
+ this.instance._propagate("deactivate", event, inst);
434
+ }
435
+
436
+ });
437
+
438
+ },
439
+ drag: function(event, ui) {
440
+
441
+ var inst = $(this).data("draggable"), self = this;
442
+
443
+ var checkPos = function(o) {
444
+ var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
445
+ var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
446
+ var itemHeight = o.height, itemWidth = o.width;
447
+ var itemTop = o.top, itemLeft = o.left;
448
+
449
+ return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
450
+ };
451
+
452
+ $.each(inst.sortables, function(i) {
453
+
454
+ if(checkPos.call(inst, this.instance.containerCache)) {
455
+
456
+ //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
457
+ if(!this.instance.isOver) {
458
+ this.instance.isOver = 1;
459
+ //Now we fake the start of dragging for the sortable instance,
460
+ //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
461
+ //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)
462
+ this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
463
+ this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
464
+ this.instance.options.helper = function() { return ui.helper[0]; };
465
+
466
+ event.target = this.instance.currentItem[0];
467
+ this.instance._mouseCapture(event, true);
468
+ this.instance._mouseStart(event, true, true);
469
+
470
+ //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
471
+ this.instance.offset.click.top = inst.offset.click.top;
472
+ this.instance.offset.click.left = inst.offset.click.left;
473
+ this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
474
+ this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
475
+
476
+ inst._propagate("toSortable", event);
477
+
478
+ }
479
+
480
+ //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
481
+ if(this.instance.currentItem) this.instance._mouseDrag(event);
482
+
483
+ } else {
484
+
485
+ //If it doesn't intersect with the sortable, and it intersected before,
486
+ //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
487
+ if(this.instance.isOver) {
488
+ this.instance.isOver = 0;
489
+ this.instance.cancelHelperRemoval = true;
490
+ this.instance.options.revert = false; //No revert here
491
+ this.instance._mouseStop(event, true);
492
+ this.instance.options.helper = this.instance.options._helper;
493
+
494
+ //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
495
+ this.instance.currentItem.remove();
496
+ if(this.instance.placeholder) this.instance.placeholder.remove();
497
+
498
+ inst._propagate("fromSortable", event);
499
+ }
500
+
501
+ };
502
+
503
+ });
504
+
505
+ }
506
+ });
507
+
508
+ $.ui.plugin.add("draggable", "cursor", {
509
+ start: function(event, ui) {
510
+ var t = $('body');
511
+ if (t.css("cursor")) ui.options._cursor = t.css("cursor");
512
+ t.css("cursor", ui.options.cursor);
513
+ },
514
+ stop: function(event, ui) {
515
+ if (ui.options._cursor) $('body').css("cursor", ui.options._cursor);
516
+ }
517
+ });
518
+
519
+ $.ui.plugin.add("draggable", "iframeFix", {
520
+ start: function(event, ui) {
521
+ $(ui.options.iframeFix === true ? "iframe" : ui.options.iframeFix).each(function() {
522
+ $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
523
+ .css({
524
+ width: this.offsetWidth+"px", height: this.offsetHeight+"px",
525
+ position: "absolute", opacity: "0.001", zIndex: 1000
526
+ })
527
+ .css($(this).offset())
528
+ .appendTo("body");
529
+ });
530
+ },
531
+ stop: function(event, ui) {
532
+ $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers
533
+ }
534
+ });
535
+
536
+ $.ui.plugin.add("draggable", "opacity", {
537
+ start: function(event, ui) {
538
+ var t = $(ui.helper);
539
+ if(t.css("opacity")) ui.options._opacity = t.css("opacity");
540
+ t.css('opacity', ui.options.opacity);
541
+ },
542
+ stop: function(event, ui) {
543
+ if(ui.options._opacity) $(ui.helper).css('opacity', ui.options._opacity);
544
+ }
545
+ });
546
+
547
+ $.ui.plugin.add("draggable", "scroll", {
548
+ start: function(event, ui) {
549
+ var o = ui.options;
550
+ var i = $(this).data("draggable");
551
+
552
+ if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
553
+
554
+ },
555
+ drag: function(event, ui) {
556
+
557
+ var o = ui.options, scrolled = false;
558
+ var i = $(this).data("draggable");
559
+
560
+ if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
561
+
562
+ if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
563
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
564
+ else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
565
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
566
+
567
+ if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
568
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
569
+ else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
570
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
571
+
572
+ } else {
573
+
574
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
575
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
576
+ else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
577
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
578
+
579
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
580
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
581
+ else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
582
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
583
+
584
+ }
585
+
586
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
587
+ $.ui.ddmanager.prepareOffsets(i, event);
588
+
589
+
590
+
591
+ //This is a special case where we need to modify a offset calculated on start, since the following happened:
592
+ // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
593
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
594
+ // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
595
+ if(scrolled !== false && i.cssPosition == 'absolute' && i.scrollParent[0] != document && $.ui.contains(i.scrollParent[0], i.offsetParent[0])) {
596
+ i.offset.parent = i._getParentOffset();
597
+ }
598
+
599
+ }
600
+ });
601
+
602
+ $.ui.plugin.add("draggable", "snap", {
603
+ start: function(event, ui) {
604
+
605
+ var inst = $(this).data("draggable");
606
+ inst.snapElements = [];
607
+
608
+ $(ui.options.snap.constructor != String ? ( ui.options.snap.items || ':data(draggable)' ) : ui.options.snap).each(function() {
609
+ var $t = $(this); var $o = $t.offset();
610
+ if(this != inst.element[0]) inst.snapElements.push({
611
+ item: this,
612
+ width: $t.outerWidth(), height: $t.outerHeight(),
613
+ top: $o.top, left: $o.left
614
+ });
615
+ });
616
+
617
+ },
618
+ drag: function(event, ui) {
619
+
620
+ var inst = $(this).data("draggable");
621
+ var d = ui.options.snapTolerance;
622
+
623
+ var x1 = ui.absolutePosition.left, x2 = x1 + inst.helperProportions.width,
624
+ y1 = ui.absolutePosition.top, y2 = y1 + inst.helperProportions.height;
625
+
626
+ for (var i = inst.snapElements.length - 1; i >= 0; i--){
627
+
628
+ var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
629
+ t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
630
+
631
+ //Yes, I know, this is insane ;)
632
+ 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))) {
633
+ if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
634
+ inst.snapElements[i].snapping = false;
635
+ continue;
636
+ }
637
+
638
+ if(ui.options.snapMode != 'inner') {
639
+ var ts = Math.abs(t - y2) <= d;
640
+ var bs = Math.abs(b - y1) <= d;
641
+ var ls = Math.abs(l - x2) <= d;
642
+ var rs = Math.abs(r - x1) <= d;
643
+ if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
644
+ if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
645
+ if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
646
+ if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
647
+ }
648
+
649
+ var first = (ts || bs || ls || rs);
650
+
651
+ if(ui.options.snapMode != 'outer') {
652
+ var ts = Math.abs(t - y1) <= d;
653
+ var bs = Math.abs(b - y2) <= d;
654
+ var ls = Math.abs(l - x1) <= d;
655
+ var rs = Math.abs(r - x2) <= d;
656
+ if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
657
+ if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
658
+ if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
659
+ if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
660
+ }
661
+
662
+ if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
663
+ (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
664
+ inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
665
+
666
+ };
667
+
668
+ }
669
+ });
670
+
671
+ $.ui.plugin.add("draggable", "stack", {
672
+ start: function(event, ui) {
673
+ var group = $.makeArray($(ui.options.stack.group)).sort(function(a,b) {
674
+ return (parseInt($(a).css("zIndex"),10) || ui.options.stack.min) - (parseInt($(b).css("zIndex"),10) || ui.options.stack.min);
675
+ });
676
+
677
+ $(group).each(function(i) {
678
+ this.style.zIndex = ui.options.stack.min + i;
679
+ });
680
+
681
+ this[0].style.zIndex = ui.options.stack.min + group.length;
682
+ }
683
+ });
684
+
685
+ $.ui.plugin.add("draggable", "zIndex", {
686
+ start: function(event, ui) {
687
+ var t = $(ui.helper);
688
+ if(t.css("zIndex")) ui.options._zIndex = t.css("zIndex");
689
+ t.css('zIndex', ui.options.zIndex);
690
+ },
691
+ stop: function(event, ui) {
692
+ if(ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex);
693
+ }
694
+ });
695
+
696
+ })(jQuery);