transit 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/Gemfile +19 -11
  2. data/app/assets/images/transit/icon24x24.png +0 -0
  3. data/app/assets/images/transit/icon24x24_files.png +0 -0
  4. data/app/assets/images/transit/jplayer.swf +0 -0
  5. data/app/assets/images/transit/uploadify.swf +0 -0
  6. data/app/assets/images/transit/video_player.swf +0 -0
  7. data/app/assets/javascripts/jqtools/expose.js +224 -0
  8. data/app/assets/javascripts/jqtools/flashembed.js +300 -0
  9. data/app/assets/javascripts/jqtools/overlay.js +294 -0
  10. data/app/assets/javascripts/jqtools/scrollable.js +3 -0
  11. data/app/assets/javascripts/jqtools/scrollable/autoscroll.js +81 -0
  12. data/app/assets/javascripts/jqtools/scrollable/base.js +335 -0
  13. data/app/assets/javascripts/jqtools/scrollable/navigator.js +139 -0
  14. data/app/assets/javascripts/jqtools/validator.js +590 -0
  15. data/app/assets/javascripts/jqueryui/accordion.js +611 -0
  16. data/app/assets/javascripts/jqueryui/autocomplete.js +612 -0
  17. data/app/assets/javascripts/jqueryui/button.js +388 -0
  18. data/app/assets/javascripts/jqueryui/core.js +312 -0
  19. data/app/assets/javascripts/jqueryui/datepicker.js +1791 -0
  20. data/app/assets/javascripts/jqueryui/dialog.js +878 -0
  21. data/app/assets/javascripts/jqueryui/draggable.js +815 -0
  22. data/app/assets/javascripts/jqueryui/droppable.js +285 -0
  23. data/app/assets/javascripts/jqueryui/effects/blind.js +49 -0
  24. data/app/assets/javascripts/jqueryui/effects/bounce.js +78 -0
  25. data/app/assets/javascripts/jqueryui/effects/clip.js +54 -0
  26. data/app/assets/javascripts/jqueryui/effects/core.js +746 -0
  27. data/app/assets/javascripts/jqueryui/effects/drop.js +50 -0
  28. data/app/assets/javascripts/jqueryui/effects/explode.js +79 -0
  29. data/app/assets/javascripts/jqueryui/effects/fade.js +32 -0
  30. data/app/assets/javascripts/jqueryui/effects/fold.js +56 -0
  31. data/app/assets/javascripts/jqueryui/effects/highlight.js +50 -0
  32. data/app/assets/javascripts/jqueryui/effects/pulsate.js +51 -0
  33. data/app/assets/javascripts/jqueryui/effects/scale.js +178 -0
  34. data/app/assets/javascripts/jqueryui/effects/shake.js +57 -0
  35. data/app/assets/javascripts/jqueryui/effects/slide.js +50 -0
  36. data/app/assets/javascripts/jqueryui/effects/transfer.js +45 -0
  37. data/app/assets/javascripts/jqueryui/mouse.js +160 -0
  38. data/app/assets/javascripts/jqueryui/position.js +252 -0
  39. data/app/assets/javascripts/jqueryui/progressbar.js +109 -0
  40. data/app/assets/javascripts/jqueryui/resizable.js +814 -0
  41. data/app/assets/javascripts/jqueryui/selectable.js +266 -0
  42. data/app/assets/javascripts/jqueryui/slider.js +666 -0
  43. data/app/assets/javascripts/jqueryui/sortable.js +1077 -0
  44. data/app/assets/javascripts/jqueryui/tabs.js +758 -0
  45. data/app/assets/javascripts/jqueryui/widget.js +262 -0
  46. data/app/assets/javascripts/libs/backbone.js +1152 -0
  47. data/app/assets/javascripts/libs/cookie.js +89 -0
  48. data/app/assets/javascripts/libs/fileinput.js +130 -0
  49. data/app/assets/javascripts/libs/jplayer.js +1768 -0
  50. data/app/assets/javascripts/libs/proper.js +541 -0
  51. data/app/assets/javascripts/libs/sanitize.js +282 -0
  52. data/app/assets/javascripts/libs/selecttolist.js +75 -0
  53. data/app/assets/javascripts/libs/underscore.js +807 -0
  54. data/app/assets/javascripts/libs/uploadify.js +677 -0
  55. data/app/assets/javascripts/libs/wymeditor.js +9538 -0
  56. data/app/assets/javascripts/transit.js +4 -0
  57. data/app/assets/javascripts/transit/admin.js +22 -0
  58. data/app/assets/javascripts/transit/admin/contexts.js +52 -0
  59. data/app/assets/javascripts/transit/admin/fields.js +36 -0
  60. data/app/assets/javascripts/transit/admin/upload.js +109 -0
  61. data/app/assets/javascripts/transit/config.js.erb +101 -0
  62. data/app/assets/javascripts/transit/contexts/audio.js +39 -0
  63. data/app/assets/javascripts/transit/contexts/video.js +79 -0
  64. data/app/assets/javascripts/transit/core.js +171 -0
  65. data/app/assets/javascripts/transit/frontend.js +3 -0
  66. data/app/assets/javascripts/transit/lib/base64.js +120 -0
  67. data/app/assets/javascripts/transit/lib/editor.js +177 -0
  68. data/app/assets/javascripts/transit/views/audio_player.jst +22 -0
  69. data/app/assets/javascripts/transit/views/editor_toolbar.jst +12 -0
  70. data/app/assets/javascripts/transit/views/file_upload.jst +5 -0
  71. data/app/assets/javascripts/transit/views/video_player.jst +20 -0
  72. data/app/assets/javascripts/transit/views/wym_box.jst +4 -0
  73. data/app/assets/javascripts/transit/views/wym_iframe.jst +3 -0
  74. data/app/assets/stylesheets/transit.css.scss.erb +42 -0
  75. data/app/assets/stylesheets/transit/forms.css.scss +66 -0
  76. data/app/assets/stylesheets/transit/media/audio.css.scss +65 -0
  77. data/app/assets/stylesheets/transit/media/video.css.scss +30 -0
  78. data/app/assets/stylesheets/transit/panel.css.scss +100 -0
  79. data/app/assets/stylesheets/transit/ui.css.scss +507 -0
  80. data/app/controllers/pages_controller.rb +3 -0
  81. data/app/controllers/posts_controller.rb +3 -0
  82. data/app/controllers/transit/assets_controller.rb +38 -0
  83. data/app/controllers/transit/contexts_controller.rb +12 -9
  84. data/app/controllers/transit/pages_controller.rb +26 -0
  85. data/app/controllers/transit/posts_controller.rb +31 -0
  86. data/app/controllers/transit/topics_controller.rb +5 -0
  87. data/app/controllers/transit_controller.rb +16 -0
  88. data/app/helpers/transit/admin_helper.rb +43 -0
  89. data/app/helpers/transit/form_helper.rb +17 -0
  90. data/app/helpers/transit/package_helper.rb +41 -0
  91. data/app/helpers/transit/pagination_helper.rb +58 -0
  92. data/app/helpers/transit_helper.rb +42 -0
  93. data/app/models/comment.rb +37 -0
  94. data/app/models/contexts/audio.rb +12 -0
  95. data/app/models/{text.rb → contexts/text.rb} +0 -0
  96. data/app/models/contexts/video.rb +24 -0
  97. data/app/models/topic.rb +19 -0
  98. data/app/models/transit/asset.rb +68 -0
  99. data/{lib → app/models}/transit/context.rb +29 -0
  100. data/app/views/contexts/_text.html.erb +1 -1
  101. data/app/views/posts/index.rss.builder +18 -0
  102. data/app/views/transit/assets/_file.html.erb +4 -0
  103. data/app/views/transit/assets/_image.html.erb +13 -0
  104. data/app/views/transit/assets/create.js.erb +8 -0
  105. data/app/views/transit/assets/destroy.js.erb +3 -0
  106. data/app/views/transit/assets/manage.html.erb +20 -0
  107. data/app/views/transit/contexts/_audio.html.erb +18 -0
  108. data/app/views/transit/contexts/_text.html.erb +6 -0
  109. data/app/views/transit/contexts/_video.html.erb +13 -0
  110. data/app/views/transit/contexts/destroy.js.erb +1 -0
  111. data/app/views/transit/contexts/index.html.erb +5 -0
  112. data/app/views/transit/contexts/new.js.erb +7 -0
  113. data/app/views/transit/contexts/show.html.erb +8 -0
  114. data/app/views/transit/index.html.erb +26 -0
  115. data/app/views/transit/index.js.erb +1 -0
  116. data/app/views/transit/interface/post_panel.html.erb +96 -0
  117. data/app/views/transit/pages/_table.html.erb +7 -0
  118. data/app/views/transit/pages/edit.html.erb +17 -0
  119. data/app/views/transit/pages/index.html.erb +17 -0
  120. data/app/views/transit/pages/update.js.erb +1 -0
  121. data/app/views/transit/posts/_form.html.erb +49 -0
  122. data/app/views/transit/posts/edit.html.erb +14 -0
  123. data/app/views/transit/posts/new.html.erb +21 -0
  124. data/app/views/transit/table.html.erb +13 -0
  125. data/app/views/transit/table.js.erb +8 -0
  126. data/app/views/transit/topics/manage.html.erb +28 -0
  127. data/config/locales/en.yml +22 -0
  128. data/config/routes.rb +3 -3
  129. data/lib/transit.rb +51 -17
  130. data/lib/transit/admin.rb +85 -0
  131. data/lib/transit/builders/form_builder.rb +319 -0
  132. data/lib/transit/builders/jst_builder.rb +38 -0
  133. data/lib/transit/builders/package_builder.rb +45 -0
  134. data/lib/transit/config.rb +20 -0
  135. data/lib/transit/controller/generator.rb +42 -0
  136. data/lib/transit/controller/responder.rb +34 -0
  137. data/lib/transit/core_ext.rb +18 -0
  138. data/lib/transit/errors/resource_not_found.rb +6 -0
  139. data/lib/transit/model/assets.rb +14 -0
  140. data/lib/transit/model/attachments.rb +55 -0
  141. data/lib/transit/model/auto_increment.rb +22 -0
  142. data/lib/transit/model/base.rb +56 -0
  143. data/lib/transit/model/comments.rb +19 -0
  144. data/lib/transit/model/hooks.rb +38 -0
  145. data/lib/transit/model/owners.rb +14 -0
  146. data/lib/transit/model/paginator.rb +92 -0
  147. data/lib/transit/model/topics.rb +14 -0
  148. data/lib/transit/package/page.rb +20 -12
  149. data/lib/transit/package/post.rb +87 -33
  150. data/lib/transit/package/post/validations.rb +14 -0
  151. data/lib/transit/rails/engine.rb +29 -13
  152. data/lib/transit/rails/railtie.rb +31 -0
  153. data/lib/transit/rails/routing.rb +11 -6
  154. data/lib/transit/services.rb +13 -0
  155. data/lib/transit/services/base.rb +14 -0
  156. data/lib/transit/services/facebook.rb +13 -0
  157. data/lib/transit/services/ted.rb +10 -0
  158. data/lib/transit/services/twitter.rb +13 -0
  159. data/lib/transit/services/vimeo.rb +10 -0
  160. data/lib/transit/services/you_tube.rb +12 -0
  161. data/lib/transit/version.rb +1 -1
  162. metadata +178 -31
  163. data/app/assets/stylesheets/includes/_compat.scss +0 -24
  164. data/app/assets/stylesheets/includes/_defaults.scss +0 -99
  165. data/app/assets/stylesheets/includes/_global.scss +0 -16
  166. data/app/assets/stylesheets/includes/_imports.scss +0 -27
  167. data/app/assets/stylesheets/includes/_mixins.scss +0 -38
  168. data/app/assets/stylesheets/includes/_setup.scss +0 -85
  169. data/app/assets/stylesheets/layout.css.scss +0 -29
  170. data/app/assets/stylesheets/transit.css +0 -3
  171. data/app/controllers/application_controller.rb +0 -5
  172. data/app/controllers/transit/index_controller.rb +0 -7
  173. data/app/controllers/transit/packages_controller.rb +0 -64
  174. data/app/controllers/transit/transit_controller.rb +0 -4
  175. data/app/helpers/routing_helpers.rb +0 -7
  176. data/app/models/audio.rb +0 -4
  177. data/app/models/package_asset.rb +0 -11
  178. data/app/models/video.rb +0 -8
  179. data/app/views/contexts/_audio.html.erb +0 -1
  180. data/app/views/contexts/_video.html.erb +0 -1
  181. data/app/views/layouts/transit.html.erb +0 -31
  182. data/app/views/transit/index/index.html.erb +0 -0
  183. data/lib/transit/helpers/controller_helpers.rb +0 -40
  184. data/lib/transit/helpers/model_helpers.rb +0 -26
  185. data/lib/transit/package.rb +0 -25
  186. data/lib/transit/package/base.rb +0 -49
@@ -0,0 +1,815 @@
1
+ /*
2
+ * jQuery UI Draggable 1.8.13
3
+ *
4
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ * http://jquery.org/license
7
+ *
8
+ * http://docs.jquery.com/UI/Draggables
9
+ *
10
+ * Depends:
11
+ * jquery.ui.core.js
12
+ * jquery.ui.mouse.js
13
+ * jquery.ui.widget.js
14
+ */
15
+ (function( $, undefined ) {
16
+
17
+ $.widget("ui.draggable", $.ui.mouse, {
18
+ widgetEventPrefix: "drag",
19
+ options: {
20
+ addClasses: true,
21
+ appendTo: "parent",
22
+ axis: false,
23
+ connectToSortable: false,
24
+ containment: false,
25
+ cursor: "auto",
26
+ cursorAt: false,
27
+ grid: false,
28
+ handle: false,
29
+ helper: "original",
30
+ iframeFix: false,
31
+ opacity: false,
32
+ refreshPositions: false,
33
+ revert: false,
34
+ revertDuration: 500,
35
+ scope: "default",
36
+ scroll: true,
37
+ scrollSensitivity: 20,
38
+ scrollSpeed: 20,
39
+ snap: false,
40
+ snapMode: "both",
41
+ snapTolerance: 20,
42
+ stack: false,
43
+ zIndex: false
44
+ },
45
+ _create: function() {
46
+
47
+ if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
48
+ this.element[0].style.position = 'relative';
49
+
50
+ (this.options.addClasses && this.element.addClass("ui-draggable"));
51
+ (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
52
+
53
+ this._mouseInit();
54
+
55
+ },
56
+
57
+ destroy: function() {
58
+ if(!this.element.data('draggable')) return;
59
+ this.element
60
+ .removeData("draggable")
61
+ .unbind(".draggable")
62
+ .removeClass("ui-draggable"
63
+ + " ui-draggable-dragging"
64
+ + " ui-draggable-disabled");
65
+ this._mouseDestroy();
66
+
67
+ return this;
68
+ },
69
+
70
+ _mouseCapture: function(event) {
71
+
72
+ var o = this.options;
73
+
74
+ // among others, prevent a drag on a resizable-handle
75
+ if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
76
+ return false;
77
+
78
+ //Quit if we're not on a valid handle
79
+ this.handle = this._getHandle(event);
80
+ if (!this.handle)
81
+ return false;
82
+
83
+ $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
84
+ $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
85
+ .css({
86
+ width: this.offsetWidth+"px", height: this.offsetHeight+"px",
87
+ position: "absolute", opacity: "0.001", zIndex: 1000
88
+ })
89
+ .css($(this).offset())
90
+ .appendTo("body");
91
+ });
92
+
93
+ return true;
94
+
95
+ },
96
+
97
+ _mouseStart: function(event) {
98
+
99
+ var o = this.options;
100
+
101
+ //Create and append the visible helper
102
+ this.helper = this._createHelper(event);
103
+
104
+ //Cache the helper size
105
+ this._cacheHelperProportions();
106
+
107
+ //If ddmanager is used for droppables, set the global draggable
108
+ if($.ui.ddmanager)
109
+ $.ui.ddmanager.current = this;
110
+
111
+ /*
112
+ * - Position generation -
113
+ * This block generates everything position related - it's the core of draggables.
114
+ */
115
+
116
+ //Cache the margins of the original element
117
+ this._cacheMargins();
118
+
119
+ //Store the helper's css position
120
+ this.cssPosition = this.helper.css("position");
121
+ this.scrollParent = this.helper.scrollParent();
122
+
123
+ //The element's absolute position on the page minus margins
124
+ this.offset = this.positionAbs = this.element.offset();
125
+ this.offset = {
126
+ top: this.offset.top - this.margins.top,
127
+ left: this.offset.left - this.margins.left
128
+ };
129
+
130
+ $.extend(this.offset, {
131
+ click: { //Where the click happened, relative to the element
132
+ left: event.pageX - this.offset.left,
133
+ top: event.pageY - this.offset.top
134
+ },
135
+ parent: this._getParentOffset(),
136
+ relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
137
+ });
138
+
139
+ //Generate the original position
140
+ this.originalPosition = this.position = this._generatePosition(event);
141
+ this.originalPageX = event.pageX;
142
+ this.originalPageY = event.pageY;
143
+
144
+ //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
145
+ (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
146
+
147
+ //Set a containment if given in the options
148
+ if(o.containment)
149
+ this._setContainment();
150
+
151
+ //Trigger event + callbacks
152
+ if(this._trigger("start", event) === false) {
153
+ this._clear();
154
+ return false;
155
+ }
156
+
157
+ //Recache the helper size
158
+ this._cacheHelperProportions();
159
+
160
+ //Prepare the droppable offsets
161
+ if ($.ui.ddmanager && !o.dropBehaviour)
162
+ $.ui.ddmanager.prepareOffsets(this, event);
163
+
164
+ this.helper.addClass("ui-draggable-dragging");
165
+ this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
166
+ return true;
167
+ },
168
+
169
+ _mouseDrag: function(event, noPropagation) {
170
+
171
+ //Compute the helpers position
172
+ this.position = this._generatePosition(event);
173
+ this.positionAbs = this._convertPositionTo("absolute");
174
+
175
+ //Call plugins and callbacks and use the resulting position if something is returned
176
+ if (!noPropagation) {
177
+ var ui = this._uiHash();
178
+ if(this._trigger('drag', event, ui) === false) {
179
+ this._mouseUp({});
180
+ return false;
181
+ }
182
+ this.position = ui.position;
183
+ }
184
+
185
+ if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
186
+ if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
187
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
188
+
189
+ return false;
190
+ },
191
+
192
+ _mouseStop: function(event) {
193
+
194
+ //If we are using droppables, inform the manager about the drop
195
+ var dropped = false;
196
+ if ($.ui.ddmanager && !this.options.dropBehaviour)
197
+ dropped = $.ui.ddmanager.drop(this, event);
198
+
199
+ //if a drop comes from outside (a sortable)
200
+ if(this.dropped) {
201
+ dropped = this.dropped;
202
+ this.dropped = false;
203
+ }
204
+
205
+ //if the original element is removed, don't bother to continue if helper is set to "original"
206
+ if((!this.element[0] || !this.element[0].parentNode) && this.options.helper == "original")
207
+ return false;
208
+
209
+ 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))) {
210
+ var self = this;
211
+ $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
212
+ if(self._trigger("stop", event) !== false) {
213
+ self._clear();
214
+ }
215
+ });
216
+ } else {
217
+ if(this._trigger("stop", event) !== false) {
218
+ this._clear();
219
+ }
220
+ }
221
+
222
+ return false;
223
+ },
224
+
225
+ _mouseUp: function(event) {
226
+ if (this.options.iframeFix === true) {
227
+ $("div.ui-draggable-iframeFix").each(function() {
228
+ this.parentNode.removeChild(this);
229
+ }); //Remove frame helpers
230
+ }
231
+
232
+ return $.ui.mouse.prototype._mouseUp.call(this, event);
233
+ },
234
+
235
+ cancel: function() {
236
+
237
+ if(this.helper.is(".ui-draggable-dragging")) {
238
+ this._mouseUp({});
239
+ } else {
240
+ this._clear();
241
+ }
242
+
243
+ return this;
244
+
245
+ },
246
+
247
+ _getHandle: function(event) {
248
+
249
+ var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
250
+ $(this.options.handle, this.element)
251
+ .find("*")
252
+ .andSelf()
253
+ .each(function() {
254
+ if(this == event.target) handle = true;
255
+ });
256
+
257
+ return handle;
258
+
259
+ },
260
+
261
+ _createHelper: function(event) {
262
+
263
+ var o = this.options;
264
+ var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
265
+
266
+ if(!helper.parents('body').length)
267
+ helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
268
+
269
+ if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
270
+ helper.css("position", "absolute");
271
+
272
+ return helper;
273
+
274
+ },
275
+
276
+ _adjustOffsetFromHelper: function(obj) {
277
+ if (typeof obj == 'string') {
278
+ obj = obj.split(' ');
279
+ }
280
+ if ($.isArray(obj)) {
281
+ obj = {left: +obj[0], top: +obj[1] || 0};
282
+ }
283
+ if ('left' in obj) {
284
+ this.offset.click.left = obj.left + this.margins.left;
285
+ }
286
+ if ('right' in obj) {
287
+ this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
288
+ }
289
+ if ('top' in obj) {
290
+ this.offset.click.top = obj.top + this.margins.top;
291
+ }
292
+ if ('bottom' in obj) {
293
+ this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
294
+ }
295
+ },
296
+
297
+ _getParentOffset: function() {
298
+
299
+ //Get the offsetParent and cache its position
300
+ this.offsetParent = this.helper.offsetParent();
301
+ var po = this.offsetParent.offset();
302
+
303
+ // This is a special case where we need to modify a offset calculated on start, since the following happened:
304
+ // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
305
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
306
+ // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
307
+ if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
308
+ po.left += this.scrollParent.scrollLeft();
309
+ po.top += this.scrollParent.scrollTop();
310
+ }
311
+
312
+ if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
313
+ || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
314
+ po = { top: 0, left: 0 };
315
+
316
+ return {
317
+ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
318
+ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
319
+ };
320
+
321
+ },
322
+
323
+ _getRelativeOffset: function() {
324
+
325
+ if(this.cssPosition == "relative") {
326
+ var p = this.element.position();
327
+ return {
328
+ top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
329
+ left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
330
+ };
331
+ } else {
332
+ return { top: 0, left: 0 };
333
+ }
334
+
335
+ },
336
+
337
+ _cacheMargins: function() {
338
+ this.margins = {
339
+ left: (parseInt(this.element.css("marginLeft"),10) || 0),
340
+ top: (parseInt(this.element.css("marginTop"),10) || 0),
341
+ right: (parseInt(this.element.css("marginRight"),10) || 0),
342
+ bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
343
+ };
344
+ },
345
+
346
+ _cacheHelperProportions: function() {
347
+ this.helperProportions = {
348
+ width: this.helper.outerWidth(),
349
+ height: this.helper.outerHeight()
350
+ };
351
+ },
352
+
353
+ _setContainment: function() {
354
+
355
+ var o = this.options;
356
+ if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
357
+ if(o.containment == 'document' || o.containment == 'window') this.containment = [
358
+ (o.containment == 'document' ? 0 : $(window).scrollLeft()) - this.offset.relative.left - this.offset.parent.left,
359
+ (o.containment == 'document' ? 0 : $(window).scrollTop()) - this.offset.relative.top - this.offset.parent.top,
360
+ (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
361
+ (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
362
+ ];
363
+
364
+ if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
365
+ var c = $(o.containment);
366
+ var ce = c[0]; if(!ce) return;
367
+ var co = c.offset();
368
+ var over = ($(ce).css("overflow") != 'hidden');
369
+
370
+ this.containment = [
371
+ (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
372
+ (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
373
+ (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 - this.margins.right,
374
+ (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 - this.margins.bottom
375
+ ];
376
+ this.relative_container = c;
377
+
378
+ } else if(o.containment.constructor == Array) {
379
+ this.containment = o.containment;
380
+ }
381
+
382
+ },
383
+
384
+ _convertPositionTo: function(d, pos) {
385
+
386
+ if(!pos) pos = this.position;
387
+ var mod = d == "absolute" ? 1 : -1;
388
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
389
+
390
+ return {
391
+ top: (
392
+ pos.top // The absolute mouse position
393
+ + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
394
+ + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
395
+ - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
396
+ ),
397
+ left: (
398
+ pos.left // The absolute mouse position
399
+ + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
400
+ + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
401
+ - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
402
+ )
403
+ };
404
+
405
+ },
406
+
407
+ _generatePosition: function(event) {
408
+
409
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
410
+ var pageX = event.pageX;
411
+ var pageY = event.pageY;
412
+
413
+ /*
414
+ * - Position constraining -
415
+ * Constrain the position to a mix of grid, containment.
416
+ */
417
+
418
+ if(this.originalPosition) { //If we are not dragging yet, we won't check for options
419
+ var containment;
420
+ if(this.containment) {
421
+ if (this.relative_container){
422
+ var co = this.relative_container.offset();
423
+ containment = [ this.containment[0] + co.left,
424
+ this.containment[1] + co.top,
425
+ this.containment[2] + co.left,
426
+ this.containment[3] + co.top ];
427
+ }
428
+ else {
429
+ containment = this.containment;
430
+ }
431
+
432
+ if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
433
+ if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
434
+ if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
435
+ if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
436
+ }
437
+
438
+ if(o.grid) {
439
+ var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
440
+ 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;
441
+
442
+ var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
443
+ 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;
444
+ }
445
+
446
+ }
447
+
448
+ return {
449
+ top: (
450
+ pageY // The absolute mouse position
451
+ - this.offset.click.top // Click offset (relative to the element)
452
+ - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
453
+ - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
454
+ + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
455
+ ),
456
+ left: (
457
+ pageX // The absolute mouse position
458
+ - this.offset.click.left // Click offset (relative to the element)
459
+ - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
460
+ - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
461
+ + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
462
+ )
463
+ };
464
+
465
+ },
466
+
467
+ _clear: function() {
468
+ this.helper.removeClass("ui-draggable-dragging");
469
+ if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
470
+ //if($.ui.ddmanager) $.ui.ddmanager.current = null;
471
+ this.helper = null;
472
+ this.cancelHelperRemoval = false;
473
+ },
474
+
475
+ // From now on bulk stuff - mainly helpers
476
+
477
+ _trigger: function(type, event, ui) {
478
+ ui = ui || this._uiHash();
479
+ $.ui.plugin.call(this, type, [event, ui]);
480
+ if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
481
+ return $.Widget.prototype._trigger.call(this, type, event, ui);
482
+ },
483
+
484
+ plugins: {},
485
+
486
+ _uiHash: function(event) {
487
+ return {
488
+ helper: this.helper,
489
+ position: this.position,
490
+ originalPosition: this.originalPosition,
491
+ offset: this.positionAbs
492
+ };
493
+ }
494
+
495
+ });
496
+
497
+ $.extend($.ui.draggable, {
498
+ version: "1.8.13"
499
+ });
500
+
501
+ $.ui.plugin.add("draggable", "connectToSortable", {
502
+ start: function(event, ui) {
503
+
504
+ var inst = $(this).data("draggable"), o = inst.options,
505
+ uiSortable = $.extend({}, ui, { item: inst.element });
506
+ inst.sortables = [];
507
+ $(o.connectToSortable).each(function() {
508
+ var sortable = $.data(this, 'sortable');
509
+ if (sortable && !sortable.options.disabled) {
510
+ inst.sortables.push({
511
+ instance: sortable,
512
+ shouldRevert: sortable.options.revert
513
+ });
514
+ 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).
515
+ sortable._trigger("activate", event, uiSortable);
516
+ }
517
+ });
518
+
519
+ },
520
+ stop: function(event, ui) {
521
+
522
+ //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
523
+ var inst = $(this).data("draggable"),
524
+ uiSortable = $.extend({}, ui, { item: inst.element });
525
+
526
+ $.each(inst.sortables, function() {
527
+ if(this.instance.isOver) {
528
+
529
+ this.instance.isOver = 0;
530
+
531
+ inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
532
+ this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
533
+
534
+ //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
535
+ if(this.shouldRevert) this.instance.options.revert = true;
536
+
537
+ //Trigger the stop of the sortable
538
+ this.instance._mouseStop(event);
539
+
540
+ this.instance.options.helper = this.instance.options._helper;
541
+
542
+ //If the helper has been the original item, restore properties in the sortable
543
+ if(inst.options.helper == 'original')
544
+ this.instance.currentItem.css({ top: 'auto', left: 'auto' });
545
+
546
+ } else {
547
+ this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
548
+ this.instance._trigger("deactivate", event, uiSortable);
549
+ }
550
+
551
+ });
552
+
553
+ },
554
+ drag: function(event, ui) {
555
+
556
+ var inst = $(this).data("draggable"), self = this;
557
+
558
+ var checkPos = function(o) {
559
+ var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
560
+ var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
561
+ var itemHeight = o.height, itemWidth = o.width;
562
+ var itemTop = o.top, itemLeft = o.left;
563
+
564
+ return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
565
+ };
566
+
567
+ $.each(inst.sortables, function(i) {
568
+
569
+ //Copy over some variables to allow calling the sortable's native _intersectsWith
570
+ this.instance.positionAbs = inst.positionAbs;
571
+ this.instance.helperProportions = inst.helperProportions;
572
+ this.instance.offset.click = inst.offset.click;
573
+
574
+ if(this.instance._intersectsWith(this.instance.containerCache)) {
575
+
576
+ //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
577
+ if(!this.instance.isOver) {
578
+
579
+ this.instance.isOver = 1;
580
+ //Now we fake the start of dragging for the sortable instance,
581
+ //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
582
+ //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)
583
+ this.instance.currentItem = $(self).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
584
+ this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
585
+ this.instance.options.helper = function() { return ui.helper[0]; };
586
+
587
+ event.target = this.instance.currentItem[0];
588
+ this.instance._mouseCapture(event, true);
589
+ this.instance._mouseStart(event, true, true);
590
+
591
+ //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
592
+ this.instance.offset.click.top = inst.offset.click.top;
593
+ this.instance.offset.click.left = inst.offset.click.left;
594
+ this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
595
+ this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
596
+
597
+ inst._trigger("toSortable", event);
598
+ inst.dropped = this.instance.element; //draggable revert needs that
599
+ //hack so receive/update callbacks work (mostly)
600
+ inst.currentItem = inst.element;
601
+ this.instance.fromOutside = inst;
602
+
603
+ }
604
+
605
+ //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
606
+ if(this.instance.currentItem) this.instance._mouseDrag(event);
607
+
608
+ } else {
609
+
610
+ //If it doesn't intersect with the sortable, and it intersected before,
611
+ //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
612
+ if(this.instance.isOver) {
613
+
614
+ this.instance.isOver = 0;
615
+ this.instance.cancelHelperRemoval = true;
616
+
617
+ //Prevent reverting on this forced stop
618
+ this.instance.options.revert = false;
619
+
620
+ // The out event needs to be triggered independently
621
+ this.instance._trigger('out', event, this.instance._uiHash(this.instance));
622
+
623
+ this.instance._mouseStop(event, true);
624
+ this.instance.options.helper = this.instance.options._helper;
625
+
626
+ //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
627
+ this.instance.currentItem.remove();
628
+ if(this.instance.placeholder) this.instance.placeholder.remove();
629
+
630
+ inst._trigger("fromSortable", event);
631
+ inst.dropped = false; //draggable revert needs that
632
+ }
633
+
634
+ };
635
+
636
+ });
637
+
638
+ }
639
+ });
640
+
641
+ $.ui.plugin.add("draggable", "cursor", {
642
+ start: function(event, ui) {
643
+ var t = $('body'), o = $(this).data('draggable').options;
644
+ if (t.css("cursor")) o._cursor = t.css("cursor");
645
+ t.css("cursor", o.cursor);
646
+ },
647
+ stop: function(event, ui) {
648
+ var o = $(this).data('draggable').options;
649
+ if (o._cursor) $('body').css("cursor", o._cursor);
650
+ }
651
+ });
652
+
653
+ $.ui.plugin.add("draggable", "opacity", {
654
+ start: function(event, ui) {
655
+ var t = $(ui.helper), o = $(this).data('draggable').options;
656
+ if(t.css("opacity")) o._opacity = t.css("opacity");
657
+ t.css('opacity', o.opacity);
658
+ },
659
+ stop: function(event, ui) {
660
+ var o = $(this).data('draggable').options;
661
+ if(o._opacity) $(ui.helper).css('opacity', o._opacity);
662
+ }
663
+ });
664
+
665
+ $.ui.plugin.add("draggable", "scroll", {
666
+ start: function(event, ui) {
667
+ var i = $(this).data("draggable");
668
+ if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
669
+ },
670
+ drag: function(event, ui) {
671
+
672
+ var i = $(this).data("draggable"), o = i.options, scrolled = false;
673
+
674
+ if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
675
+
676
+ if(!o.axis || o.axis != 'x') {
677
+ if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
678
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
679
+ else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
680
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
681
+ }
682
+
683
+ if(!o.axis || o.axis != 'y') {
684
+ if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
685
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
686
+ else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
687
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
688
+ }
689
+
690
+ } else {
691
+
692
+ if(!o.axis || o.axis != 'x') {
693
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
694
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
695
+ else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
696
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
697
+ }
698
+
699
+ if(!o.axis || o.axis != 'y') {
700
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
701
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
702
+ else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
703
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
704
+ }
705
+
706
+ }
707
+
708
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
709
+ $.ui.ddmanager.prepareOffsets(i, event);
710
+
711
+ }
712
+ });
713
+
714
+ $.ui.plugin.add("draggable", "snap", {
715
+ start: function(event, ui) {
716
+
717
+ var i = $(this).data("draggable"), o = i.options;
718
+ i.snapElements = [];
719
+
720
+ $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
721
+ var $t = $(this); var $o = $t.offset();
722
+ if(this != i.element[0]) i.snapElements.push({
723
+ item: this,
724
+ width: $t.outerWidth(), height: $t.outerHeight(),
725
+ top: $o.top, left: $o.left
726
+ });
727
+ });
728
+
729
+ },
730
+ drag: function(event, ui) {
731
+
732
+ var inst = $(this).data("draggable"), o = inst.options;
733
+ var d = o.snapTolerance;
734
+
735
+ var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
736
+ y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
737
+
738
+ for (var i = inst.snapElements.length - 1; i >= 0; i--){
739
+
740
+ var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
741
+ t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
742
+
743
+ //Yes, I know, this is insane ;)
744
+ 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))) {
745
+ 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 })));
746
+ inst.snapElements[i].snapping = false;
747
+ continue;
748
+ }
749
+
750
+ if(o.snapMode != 'inner') {
751
+ var ts = Math.abs(t - y2) <= d;
752
+ var bs = Math.abs(b - y1) <= d;
753
+ var ls = Math.abs(l - x2) <= d;
754
+ var rs = Math.abs(r - x1) <= d;
755
+ if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
756
+ if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
757
+ if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
758
+ if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
759
+ }
760
+
761
+ var first = (ts || bs || ls || rs);
762
+
763
+ if(o.snapMode != 'outer') {
764
+ var ts = Math.abs(t - y1) <= d;
765
+ var bs = Math.abs(b - y2) <= d;
766
+ var ls = Math.abs(l - x1) <= d;
767
+ var rs = Math.abs(r - x2) <= d;
768
+ if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
769
+ if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
770
+ if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
771
+ if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
772
+ }
773
+
774
+ if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
775
+ (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
776
+ inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
777
+
778
+ };
779
+
780
+ }
781
+ });
782
+
783
+ $.ui.plugin.add("draggable", "stack", {
784
+ start: function(event, ui) {
785
+
786
+ var o = $(this).data("draggable").options;
787
+
788
+ var group = $.makeArray($(o.stack)).sort(function(a,b) {
789
+ return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
790
+ });
791
+ if (!group.length) { return; }
792
+
793
+ var min = parseInt(group[0].style.zIndex) || 0;
794
+ $(group).each(function(i) {
795
+ this.style.zIndex = min + i;
796
+ });
797
+
798
+ this[0].style.zIndex = min + group.length;
799
+
800
+ }
801
+ });
802
+
803
+ $.ui.plugin.add("draggable", "zIndex", {
804
+ start: function(event, ui) {
805
+ var t = $(ui.helper), o = $(this).data("draggable").options;
806
+ if(t.css("zIndex")) o._zIndex = t.css("zIndex");
807
+ t.css('zIndex', o.zIndex);
808
+ },
809
+ stop: function(event, ui) {
810
+ var o = $(this).data("draggable").options;
811
+ if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
812
+ }
813
+ });
814
+
815
+ })(jQuery);