spiderfw 0.6.27 → 0.6.28

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