adva-core 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (284) hide show
  1. data/lib/bundler/repository.rb +118 -0
  2. metadata +68 -317
  3. data/app/controllers/admin/base_controller.rb +0 -21
  4. data/app/controllers/admin/pages_controller.rb +0 -7
  5. data/app/controllers/admin/sections_controller.rb +0 -39
  6. data/app/controllers/admin/sites_controller.rb +0 -21
  7. data/app/controllers/articles_controller.rb +0 -3
  8. data/app/controllers/base_controller.rb +0 -22
  9. data/app/controllers/installations_controller.rb +0 -28
  10. data/app/controllers/pages_controller.rb +0 -2
  11. data/app/controllers/sections_controller.rb +0 -3
  12. data/app/helpers/form_helper.rb +0 -13
  13. data/app/helpers/sections_helper.rb +0 -7
  14. data/app/helpers/url_helper.rb +0 -18
  15. data/app/models/account.rb +0 -3
  16. data/app/models/article.rb +0 -2
  17. data/app/models/content.rb +0 -4
  18. data/app/models/page.rb +0 -17
  19. data/app/models/section.rb +0 -59
  20. data/app/models/site.rb +0 -26
  21. data/app/views/admin/contents/_menu.html.rb +0 -17
  22. data/app/views/admin/pages/_menu.html.rb +0 -10
  23. data/app/views/admin/pages/new.html.rb +0 -19
  24. data/app/views/admin/pages/show.html.rb +0 -25
  25. data/app/views/admin/sections/_menu.html.rb +0 -45
  26. data/app/views/admin/sections/_section.html.rb +0 -7
  27. data/app/views/admin/sections/_select_type.html.rb +0 -16
  28. data/app/views/admin/sections/index.html.rb +0 -28
  29. data/app/views/admin/sites/_menu.html.rb +0 -2
  30. data/app/views/admin/sites/edit.html.rb +0 -22
  31. data/app/views/admin/sites/index.html.rb +0 -12
  32. data/app/views/admin/sites/new.html.rb +0 -39
  33. data/app/views/admin/sites/show.html.rb +0 -7
  34. data/app/views/installations/new.html.rb +0 -39
  35. data/app/views/installations/show.html.rb +0 -9
  36. data/app/views/layouts/_flash.html.rb +0 -9
  37. data/app/views/layouts/admin.rb +0 -38
  38. data/app/views/layouts/admin/_header.rb +0 -48
  39. data/app/views/layouts/admin/_tabs.html.rb +0 -18
  40. data/app/views/layouts/admin/_top.rb +0 -58
  41. data/app/views/layouts/base.rb +0 -58
  42. data/app/views/layouts/default.rb +0 -45
  43. data/app/views/layouts/default/_menu.rb +0 -19
  44. data/app/views/layouts/simple.rb +0 -16
  45. data/app/views/pages/show.html.rb +0 -7
  46. data/config/initializers/simple_form.rb +0 -53
  47. data/config/locales/en.yml +0 -129
  48. data/config/redirects.rb +0 -8
  49. data/config/routes.rb +0 -21
  50. data/lib/adva-core.rb +0 -1
  51. data/lib/adva.rb +0 -37
  52. data/lib/adva/active_record/has_options.rb +0 -55
  53. data/lib/adva/cli.rb +0 -16
  54. data/lib/adva/controller.rb +0 -7
  55. data/lib/adva/controller/abstract_actions.rb +0 -87
  56. data/lib/adva/controller/internal_redirect.rb +0 -26
  57. data/lib/adva/controller/references.rb +0 -28
  58. data/lib/adva/core.rb +0 -85
  59. data/lib/adva/engine.rb +0 -64
  60. data/lib/adva/engine/sliced_models.rb +0 -35
  61. data/lib/adva/generators.rb +0 -8
  62. data/lib/adva/generators/app.rb +0 -121
  63. data/lib/adva/generators/engine.rb +0 -58
  64. data/lib/adva/generators/gemfile.rb +0 -50
  65. data/lib/adva/generators/install.rb +0 -31
  66. data/lib/adva/generators/templates/app/app_template.rb +0 -3
  67. data/lib/adva/generators/templates/engine/Gemfile.erb +0 -3
  68. data/lib/adva/generators/templates/engine/all.rb +0 -1
  69. data/lib/adva/generators/templates/engine/en.yml.erb +0 -2
  70. data/lib/adva/generators/templates/engine/engine.rb.erb +0 -11
  71. data/lib/adva/generators/templates/engine/gemspec.erb +0 -21
  72. data/lib/adva/generators/templates/engine/migration.rb.erb +0 -11
  73. data/lib/adva/generators/templates/engine/redirects.rb.erb +0 -3
  74. data/lib/adva/generators/templates/engine/routes.rb.erb +0 -3
  75. data/lib/adva/generators/templates/engine/test_helper.rb.erb +0 -3
  76. data/lib/adva/i18n.rb +0 -73
  77. data/lib/adva/rack.rb +0 -5
  78. data/lib/adva/rack/static.rb +0 -50
  79. data/lib/adva/registry.rb +0 -62
  80. data/lib/adva/responder.rb +0 -21
  81. data/lib/adva/responder/redirect.rb +0 -31
  82. data/lib/adva/routing_filters/section_path.rb +0 -72
  83. data/lib/adva/routing_filters/section_root.rb +0 -65
  84. data/lib/adva/tasks/core.rake +0 -9
  85. data/lib/adva/tasks/core.rb +0 -160
  86. data/lib/adva/testing.rb +0 -57
  87. data/lib/adva/testing/engine.rb +0 -37
  88. data/lib/adva/view.rb +0 -7
  89. data/lib/adva/view/form.rb +0 -44
  90. data/lib/adva/view/form/tabs.rb +0 -46
  91. data/lib/adva/view/helper/i18n.rb +0 -26
  92. data/lib/adva/view/menu.rb +0 -73
  93. data/lib/adva/view/menu/admin.rb +0 -100
  94. data/lib/adva/view/menu/items.rb +0 -26
  95. data/lib/adva/view/tabs.rb +0 -28
  96. data/lib/adva_core/version.rb +0 -3
  97. data/lib/core_ext/rails/action_view/has_many_through_collection_helpers.rb +0 -27
  98. data/lib/core_ext/rails/active_record/skip_callbacks.rb +0 -51
  99. data/lib/core_ext/ruby/array/flatten_once.rb +0 -9
  100. data/lib/core_ext/ruby/kernel/silence_stream.rb +0 -17
  101. data/lib/core_ext/ruby/module/include_anonymous.rb +0 -36
  102. data/lib/core_ext/ruby/module/option_reader.rb +0 -9
  103. data/lib/patches/arel/table_initialization_fixes.rb +0 -68
  104. data/lib/patches/inherited_resources.rb +0 -34
  105. data/lib/patches/rails/arel_table_options_fix.rb +0 -13
  106. data/lib/patches/rails/asset_expansion_multiple_registrations.rb +0 -21
  107. data/lib/patches/rails/recognize_path_env.rb +0 -43
  108. data/lib/patches/rails/route_set_to_param.rb +0 -25
  109. data/lib/patches/rails/sti_associations.rb +0 -17
  110. data/lib/patches/rails/template_resolver_caching.rb +0 -9
  111. data/lib/patches/rails/url_for.rb +0 -60
  112. data/lib/patches/responders/flash_responder.rb +0 -17
  113. data/lib/patches/simple_form.rb +0 -37
  114. data/lib/patches/thor/core_ext/hash.rb +0 -7
  115. data/lib/patches/thor/group/symbolized_options.rb +0 -8
  116. data/lib/patches/webrat/links-data-method.rb +0 -19
  117. data/lib/patches/webrat/logger.rb +0 -19
  118. data/lib/patches/webrat/upload_file.rb +0 -28
  119. data/lib/testing/assertions.rb +0 -19
  120. data/lib/testing/factories.rb +0 -30
  121. data/lib/testing/helpers/global_helpers.rb +0 -9
  122. data/lib/testing/paths.rb +0 -54
  123. data/lib/testing/step_definitions/common_steps.rb +0 -279
  124. data/lib/testing/step_definitions/menu_steps.rb +0 -11
  125. data/lib/testing/step_definitions/routes_steps.rb +0 -18
  126. data/lib/testing/step_definitions/transforms.rb +0 -50
  127. data/lib/testing/step_definitions/webrat_steps.rb +0 -291
  128. data/lib/testing/step_definitions/within_steps.rb +0 -17
  129. data/lib/webrat/integrations/rails.rb +0 -33
  130. data/public/images/adva-core/admin/header_bg.png +0 -0
  131. data/public/images/adva-core/admin/menu_checkmark.png +0 -0
  132. data/public/images/adva-core/admin/section_menu_bg.png +0 -0
  133. data/public/images/adva-core/admin/tab_action_active.png +0 -0
  134. data/public/images/adva-core/admin/tab_main_active.png +0 -0
  135. data/public/images/adva-core/admin/tab_sidebar_active.png +0 -0
  136. data/public/images/adva-core/admin/tab_top_active.png +0 -0
  137. data/public/images/adva-core/asset_selected.png +0 -0
  138. data/public/images/adva-core/avatar.gif +0 -0
  139. data/public/images/adva-core/feed.mini.png +0 -0
  140. data/public/images/adva-core/filter-bg.png +0 -0
  141. data/public/images/adva-core/grid.png +0 -0
  142. data/public/images/adva-core/icons/accept.png +0 -0
  143. data/public/images/adva-core/icons/add.png +0 -0
  144. data/public/images/adva-core/icons/arrow_cross.png +0 -0
  145. data/public/images/adva-core/icons/arrow_cross_2.png +0 -0
  146. data/public/images/adva-core/icons/arrow_cross_3.png +0 -0
  147. data/public/images/adva-core/icons/arrow_up_down.png +0 -0
  148. data/public/images/adva-core/icons/assets/audio.png +0 -0
  149. data/public/images/adva-core/icons/assets/doc.png +0 -0
  150. data/public/images/adva-core/icons/assets/pdf.png +0 -0
  151. data/public/images/adva-core/icons/assets/video.png +0 -0
  152. data/public/images/adva-core/icons/attach.png +0 -0
  153. data/public/images/adva-core/icons/bin.png +0 -0
  154. data/public/images/adva-core/icons/bin_closed.png +0 -0
  155. data/public/images/adva-core/icons/bin_empty.png +0 -0
  156. data/public/images/adva-core/icons/bullet_black.png +0 -0
  157. data/public/images/adva-core/icons/bullet_delete.png +0 -0
  158. data/public/images/adva-core/icons/bullet_error.png +0 -0
  159. data/public/images/adva-core/icons/bullet_go.png +0 -0
  160. data/public/images/adva-core/icons/bullet_red.png +0 -0
  161. data/public/images/adva-core/icons/bullet_white.png +0 -0
  162. data/public/images/adva-core/icons/bullet_yellow.png +0 -0
  163. data/public/images/adva-core/icons/cancel.png +0 -0
  164. data/public/images/adva-core/icons/comment.gif +0 -0
  165. data/public/images/adva-core/icons/comment.png +0 -0
  166. data/public/images/adva-core/icons/comment_add.png +0 -0
  167. data/public/images/adva-core/icons/comment_blue.gif +0 -0
  168. data/public/images/adva-core/icons/comment_delete.png +0 -0
  169. data/public/images/adva-core/icons/comment_edit.png +0 -0
  170. data/public/images/adva-core/icons/comment_yellow.gif +0 -0
  171. data/public/images/adva-core/icons/cross.png +0 -0
  172. data/public/images/adva-core/icons/delete.png +0 -0
  173. data/public/images/adva-core/icons/eye.png +0 -0
  174. data/public/images/adva-core/icons/favorites.png +0 -0
  175. data/public/images/adva-core/icons/help.png +0 -0
  176. data/public/images/adva-core/icons/hourglass.png +0 -0
  177. data/public/images/adva-core/icons/icon_attachment.gif +0 -0
  178. data/public/images/adva-core/icons/icon_padlock.gif +0 -0
  179. data/public/images/adva-core/icons/link.png +0 -0
  180. data/public/images/adva-core/icons/lock.png +0 -0
  181. data/public/images/adva-core/icons/magnifier.png +0 -0
  182. data/public/images/adva-core/icons/minus.gif +0 -0
  183. data/public/images/adva-core/icons/page_add.png +0 -0
  184. data/public/images/adva-core/icons/page_delete.png +0 -0
  185. data/public/images/adva-core/icons/page_edit.png +0 -0
  186. data/public/images/adva-core/icons/page_favorites.png +0 -0
  187. data/public/images/adva-core/icons/page_go.png +0 -0
  188. data/public/images/adva-core/icons/page_green.png +0 -0
  189. data/public/images/adva-core/icons/page_red.png +0 -0
  190. data/public/images/adva-core/icons/page_white_add.png +0 -0
  191. data/public/images/adva-core/icons/page_white_delete.png +0 -0
  192. data/public/images/adva-core/icons/page_white_edit.png +0 -0
  193. data/public/images/adva-core/icons/page_white_go.png +0 -0
  194. data/public/images/adva-core/icons/page_white_link.png +0 -0
  195. data/public/images/adva-core/icons/page_white_magnify.png +0 -0
  196. data/public/images/adva-core/icons/pencil.png +0 -0
  197. data/public/images/adva-core/icons/star.png +0 -0
  198. data/public/images/adva-core/icons/stop.png +0 -0
  199. data/public/images/adva-core/icons/tag_green.png +0 -0
  200. data/public/images/adva-core/icons/tick.png +0 -0
  201. data/public/images/adva-core/icons/zoom.png +0 -0
  202. data/public/images/adva-core/indicator.gif +0 -0
  203. data/public/images/adva-core/lines.png +0 -0
  204. data/public/images/adva-core/preview.png +0 -0
  205. data/public/images/adva-core/theme_selected.png +0 -0
  206. data/public/javascripts/adva-core/admin.js +0 -22
  207. data/public/javascripts/adva-core/jquery/jquery-1.4.2.min.js +0 -154
  208. data/public/javascripts/adva-core/jquery/jquery.table_tree.js +0 -296
  209. data/public/javascripts/adva-core/jquery/jquery.tablednd_0_5.js +0 -386
  210. data/public/javascripts/adva-core/rails.js +0 -127
  211. data/public/javascripts/backup/admin/jquery.admin.js +0 -77
  212. data/public/javascripts/backup/admin/jquery.article.js +0 -22
  213. data/public/javascripts/backup/admin/jquery.cached_pages.js +0 -14
  214. data/public/javascripts/backup/admin/jquery.table_tree.backup.js +0 -279
  215. data/public/javascripts/backup/admin/jquery.table_tree.js +0 -10
  216. data/public/javascripts/backup/application.js +0 -38
  217. data/public/javascripts/backup/application.prototype.js +0 -135
  218. data/public/javascripts/backup/builder.js +0 -136
  219. data/public/javascripts/backup/controls.js +0 -965
  220. data/public/javascripts/backup/cookie.js +0 -49
  221. data/public/javascripts/backup/dragdrop.js +0 -975
  222. data/public/javascripts/backup/effects.js +0 -1130
  223. data/public/javascripts/backup/flash.js +0 -49
  224. data/public/javascripts/backup/jquery.dates.js +0 -49
  225. data/public/javascripts/backup/jquery.flash.js +0 -40
  226. data/public/javascripts/backup/jquery.roles.js +0 -23
  227. data/public/javascripts/backup/jquery/jquery-lowpro.js +0 -224
  228. data/public/javascripts/backup/jquery/jquery-ui.js +0 -273
  229. data/public/javascripts/backup/jquery/jquery.js +0 -19
  230. data/public/javascripts/backup/jquery/jquery.qtip.min.js +0 -15
  231. data/public/javascripts/backup/json.js +0 -139
  232. data/public/javascripts/backup/lowpro.js +0 -320
  233. data/public/javascripts/backup/parseuri.js +0 -39
  234. data/public/javascripts/backup/prototype.js +0 -4320
  235. data/public/javascripts/backup/roles.js +0 -16
  236. data/public/javascripts/backup/scriptaculous.js +0 -60
  237. data/public/javascripts/backup/slider.js +0 -275
  238. data/public/javascripts/backup/sound.js +0 -55
  239. data/public/javascripts/backup/unittest.js +0 -568
  240. data/public/stylesheets/adva-core/admin/forms.css +0 -172
  241. data/public/stylesheets/adva-core/admin/layout.css +0 -38
  242. data/public/stylesheets/adva-core/admin/lists.css +0 -54
  243. data/public/stylesheets/adva-core/admin/navigation.css +0 -234
  244. data/public/stylesheets/adva-core/admin/sidebar.css +0 -87
  245. data/public/stylesheets/adva-core/admin/styles.css +0 -136
  246. data/public/stylesheets/adva-core/common/forms.css +0 -174
  247. data/public/stylesheets/adva-core/common/layout.css +0 -93
  248. data/public/stylesheets/adva-core/common/reset.css +0 -42
  249. data/public/stylesheets/adva-core/common/styles.css +0 -41
  250. data/public/stylesheets/adva-core/default/layout.css +0 -0
  251. data/public/stylesheets/adva-core/default/styles.css +0 -30
  252. data/public/stylesheets/adva-core/simple/layout.css +0 -11
  253. data/public/stylesheets/backup/alternate/common.css +0 -76
  254. data/public/stylesheets/backup/alternate/forms.css +0 -121
  255. data/public/stylesheets/backup/alternate/header.css +0 -125
  256. data/public/stylesheets/backup/alternate/layout.css +0 -103
  257. data/public/stylesheets/backup/alternate/lists.css +0 -153
  258. data/public/stylesheets/backup/alternate/sidebar.css +0 -65
  259. data/public/stylesheets/backup/alternate/top.css +0 -123
  260. data/public/stylesheets/backup/content.css +0 -11
  261. data/public/stylesheets/backup/helptip.css +0 -35
  262. data/public/stylesheets/backup/jquery/alternate/jquery.tooltip.css +0 -13
  263. data/public/stylesheets/backup/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  264. data/public/stylesheets/backup/jquery/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  265. data/public/stylesheets/backup/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  266. data/public/stylesheets/backup/jquery/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  267. data/public/stylesheets/backup/jquery/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  268. data/public/stylesheets/backup/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  269. data/public/stylesheets/backup/jquery/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  270. data/public/stylesheets/backup/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  271. data/public/stylesheets/backup/jquery/images/ui-icons_222222_256x240.png +0 -0
  272. data/public/stylesheets/backup/jquery/images/ui-icons_2e83ff_256x240.png +0 -0
  273. data/public/stylesheets/backup/jquery/images/ui-icons_454545_256x240.png +0 -0
  274. data/public/stylesheets/backup/jquery/images/ui-icons_888888_256x240.png +0 -0
  275. data/public/stylesheets/backup/jquery/images/ui-icons_cd0a0a_256x240.png +0 -0
  276. data/public/stylesheets/backup/jquery/jquery-ui.css +0 -406
  277. data/public/stylesheets/backup/jquery/jquery.tooltip.css +0 -10
  278. data/public/stylesheets/backup/layout.css +0 -22
  279. data/public/stylesheets/backup/lists.css +0 -17
  280. data/public/stylesheets/backup/menu.css +0 -129
  281. data/public/stylesheets/backup/projection.css +0 -118
  282. data/public/stylesheets/backup/screen/top.css +0 -8
  283. data/public/stylesheets/backup/themes.css +0 -49
  284. data/public/stylesheets/backup/users.css +0 -40
@@ -1,386 +0,0 @@
1
- /**
2
- * TableDnD plug-in for JQuery, allows you to drag and drop table rows
3
- * You can set up various options to control how the system will work
4
- * Copyright (c) Denis Howlett <denish@isocra.com>
5
- * Licensed like jQuery, see http://docs.jquery.com/License.
6
- *
7
- * Configuration options:
8
- *
9
- * onDragStyle
10
- * This is the style that is assigned to the row during drag. There are limitations to the styles that can be
11
- * associated with a row (such as you can't assign a border--well you can, but it won't be
12
- * displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as
13
- * a map (as used in the jQuery css(...) function).
14
- * onDropStyle
15
- * This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations
16
- * to what you can do. Also this replaces the original style, so again consider using onDragClass which
17
- * is simply added and then removed on drop.
18
- * onDragClass
19
- * This class is added for the duration of the drag and then removed when the row is dropped. It is more
20
- * flexible than using onDragStyle since it can be inherited by the row cells and other content. The default
21
- * is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your
22
- * stylesheet.
23
- * onDrop
24
- * Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
25
- * and the row that was dropped. You can work out the new order of the rows by using
26
- * table.rows.
27
- * onDragStart
28
- * Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
29
- * table and the row which the user has started to drag.
30
- * onAllowDrop
31
- * Pass a function that will be called as a row is over another row. If the function returns true, allow
32
- * dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
33
- * the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
34
- * scrollAmount
35
- * This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the
36
- * window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2,
37
- * FF3 beta
38
- * dragHandle
39
- * This is the name of a class that you assign to one or more cells in each row that is draggable. If you
40
- * specify this class, then you are responsible for setting cursor: move in the CSS and only these cells
41
- * will have the drag behaviour. If you do not specify a dragHandle, then you get the old behaviour where
42
- * the whole row is draggable.
43
- *
44
- * Other ways to control behaviour:
45
- *
46
- * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
47
- * that you don't want to be draggable.
48
- *
49
- * Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form
50
- * <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have
51
- * an ID as must all the rows.
52
- *
53
- * Other methods:
54
- *
55
- * $("...").tableDnDUpdate()
56
- * Will update all the matching tables, that is it will reapply the mousedown method to the rows (or handle cells).
57
- * This is useful if you have updated the table rows using Ajax and you want to make the table draggable again.
58
- * The table maintains the original configuration (so you don't have to specify it again).
59
- *
60
- * $("...").tableDnDSerialize()
61
- * Will serialize and return the serialized string as above, but for each of the matching tables--so it can be
62
- * called from anywhere and isn't dependent on the currentTable being set up correctly before calling
63
- *
64
- * Known problems:
65
- * - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
66
- *
67
- * Version 0.2: 2008-02-20 First public version
68
- * Version 0.3: 2008-02-07 Added onDragStart option
69
- * Made the scroll amount configurable (default is 5 as before)
70
- * Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes
71
- * Added onAllowDrop to control dropping
72
- * Fixed a bug which meant that you couldn't set the scroll amount in both directions
73
- * Added serialize method
74
- * Version 0.5: 2008-05-16 Changed so that if you specify a dragHandle class it doesn't make the whole row
75
- * draggable
76
- * Improved the serialize method to use a default (and settable) regular expression.
77
- * Added tableDnDupate() and tableDnDSerialize() to be called when you are outside the table
78
- */
79
- jQuery.tableDnD = {
80
- /** Keep hold of the current table being dragged */
81
- currentTable : null,
82
- /** Keep hold of the current drag object if any */
83
- dragObject: null,
84
- /** The current mouse offset */
85
- mouseOffset: null,
86
- /** Remember the old value of Y so that we don't do too much processing */
87
- oldY: 0,
88
-
89
- /** Actually build the structure */
90
- build: function(options) {
91
- // Set up the defaults if any
92
-
93
- this.each(function() {
94
- // This is bound to each matching table, set up the defaults and override with user options
95
- this.tableDnDConfig = $.extend({
96
- onDragStyle: null,
97
- onDropStyle: null,
98
- // Add in the default class for whileDragging
99
- onDragClass: "tDnD_whileDrag",
100
- onDrop: null,
101
- onDrag: null, // ADDED
102
- onDragStart: null,
103
- scrollAmount: 5,
104
- serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
105
- serializeParamName: null, // If you want to specify another parameter name instead of the table ID
106
- dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable
107
- }, options || {});
108
- // Now make the rows draggable
109
- jQuery.tableDnD.makeDraggable(this);
110
- });
111
-
112
- // Now we need to capture the mouse up and mouse move event
113
- // We can use bind so that we don't interfere with other event handlers
114
- jQuery(document)
115
- .bind('mousemove', jQuery.tableDnD.mousemove)
116
- .bind('mouseup', jQuery.tableDnD.mouseup);
117
-
118
- // Don't break the chain
119
- return this;
120
- },
121
-
122
- /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
123
- makeDraggable: function(table) {
124
- var config = table.tableDnDConfig;
125
- if (table.tableDnDConfig.dragHandle) {
126
- // We only need to add the event to the specified cells
127
- var cells = $("td."+table.tableDnDConfig.dragHandle, table);
128
- cells.each(function() {
129
- // The cell is bound to "this"
130
- jQuery(this).mousedown(function(ev) {
131
- jQuery.tableDnD.dragObject = this.parentNode;
132
- jQuery.tableDnD.currentTable = table;
133
- jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
134
- if (config.onDragStart) {
135
- // Call the onDrop method if there is one
136
- config.onDragStart(table, this);
137
- }
138
- return false;
139
- });
140
- })
141
- } else {
142
- // For backwards compatibility, we add the event to the whole row
143
- var rows = jQuery("tr", table); // get all the rows as a wrapped set
144
- rows.each(function() {
145
- // Iterate through each row, the row is bound to "this"
146
- var row = $(this);
147
- if (! row.hasClass("nodrag")) {
148
- row.mousedown(function(ev) {
149
- if (ev.target.tagName == "TD") {
150
- jQuery.tableDnD.dragObject = this;
151
- jQuery.tableDnD.currentTable = table;
152
- jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
153
- if (config.onDragStart) {
154
- // Call the onDrop method if there is one
155
- config.onDragStart(table, this);
156
- }
157
- return false;
158
- }
159
- }).css("cursor", "move"); // Store the tableDnD object
160
- }
161
- });
162
- }
163
- },
164
-
165
- updateTables: function() {
166
- this.each(function() {
167
- // this is now bound to each matching table
168
- if (this.tableDnDConfig) {
169
- jQuery.tableDnD.makeDraggable(this);
170
- }
171
- })
172
- },
173
-
174
- /** Get the mouse coordinates from the event (allowing for browser differences) */
175
- mouseCoords: function(ev){
176
- if(ev.pageX || ev.pageY){
177
- return {x:ev.pageX, y:ev.pageY};
178
- }
179
- return {
180
- x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
181
- y:ev.clientY + document.body.scrollTop - document.body.clientTop
182
- };
183
- },
184
-
185
- /** Given a target element and a mouse event, get the mouse offset from that element.
186
- To do this we need the element's position and the mouse position */
187
- getMouseOffset: function(target, ev) {
188
- ev = ev || window.event;
189
-
190
- var docPos = this.getPosition(target);
191
- var mousePos = this.mouseCoords(ev);
192
- return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
193
- },
194
-
195
- /** Get the position of an element by going up the DOM tree and adding up all the offsets */
196
- getPosition: function(e){
197
- var left = 0;
198
- var top = 0;
199
- /** Safari fix -- thanks to Luis Chato for this! */
200
- if (e.offsetHeight == 0) {
201
- /** Safari 2 doesn't correctly grab the offsetTop of a table row
202
- this is detailed here:
203
- http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
204
- the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
205
- note that firefox will return a text node as a first child, so designing a more thorough
206
- solution may need to take that into account, for now this seems to work in firefox, safari, ie */
207
- e = e.firstChild; // a table cell
208
- }
209
-
210
- while (e.offsetParent){
211
- left += e.offsetLeft;
212
- top += e.offsetTop;
213
- e = e.offsetParent;
214
- }
215
-
216
- left += e.offsetLeft;
217
- top += e.offsetTop;
218
-
219
- return {x:left, y:top};
220
- },
221
-
222
- mousemove: function(ev) {
223
- if (jQuery.tableDnD.dragObject == null) {
224
- return;
225
- }
226
-
227
- var dragObj = jQuery(jQuery.tableDnD.dragObject);
228
- var config = jQuery.tableDnD.currentTable.tableDnDConfig;
229
- var mousePos = jQuery.tableDnD.mouseCoords(ev);
230
- var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
231
- //auto scroll the window
232
- var yOffset = window.pageYOffset;
233
- if (document.all) {
234
- // Windows version
235
- //yOffset=document.body.scrollTop;
236
- if (typeof document.compatMode != 'undefined' &&
237
- document.compatMode != 'BackCompat') {
238
- yOffset = document.documentElement.scrollTop;
239
- }
240
- else if (typeof document.body != 'undefined') {
241
- yOffset=document.body.scrollTop;
242
- }
243
-
244
- }
245
-
246
- if (mousePos.y-yOffset < config.scrollAmount) {
247
- window.scrollBy(0, -config.scrollAmount);
248
- } else {
249
- var windowHeight = window.innerHeight ? window.innerHeight
250
- : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
251
- if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
252
- window.scrollBy(0, config.scrollAmount);
253
- }
254
- }
255
-
256
-
257
- if (y != jQuery.tableDnD.oldY) {
258
- // work out if we're going up or down...
259
- var movingDown = y > jQuery.tableDnD.oldY;
260
- // update the old value
261
- jQuery.tableDnD.oldY = y;
262
- // update the style to show we're dragging
263
- if (config.onDragClass) {
264
- dragObj.addClass(config.onDragClass);
265
- } else {
266
- dragObj.css(config.onDragStyle);
267
- }
268
- // If we're over a row then move the dragged row to there so that the user sees the
269
- // effect dynamically
270
- var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y, movingDown);
271
- if (currentRow) {
272
- // TODO worry about what happens when there are multiple TBODIES
273
- if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
274
- jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
275
- } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
276
- jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
277
- }
278
- if (config.onDrag) {
279
- config.onDrag(jQuery.tableDnD.currentTable, jQuery.tableDnD.dragObject);
280
- }
281
- }
282
- }
283
-
284
- return false;
285
- },
286
-
287
- /** We're only worried about the y position really, because we can only move rows up and down */
288
- findDropTargetRow: function(draggedRow, y, movingDown) {
289
- var rows = jQuery.tableDnD.currentTable.rows;
290
- for (var i=0; i<rows.length; i++) {
291
- var row = rows[i];
292
- var rowY = this.getPosition(row).y;
293
- var rowHeight = parseInt(row.offsetHeight)/2;
294
- if (row.offsetHeight == 0) {
295
- rowY = this.getPosition(row.firstChild).y;
296
- rowHeight = parseInt(row.firstChild.offsetHeight)/2;
297
- }
298
- // Because we always have to insert before, we need to offset the height a bit
299
- if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
300
- // that's the row we're over
301
- // If it's the same as the current row, ignore it
302
- if (row == draggedRow.get(0)) {return null;}
303
- var config = jQuery.tableDnD.currentTable.tableDnDConfig;
304
- if (config.onAllowDrop) {
305
- if (config.onAllowDrop(draggedRow, row, movingDown)) {
306
- return row;
307
- } else {
308
- return null;
309
- }
310
- } else {
311
- // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
312
- var nodrop = $(row).hasClass("nodrop");
313
- if (! nodrop) {
314
- return row;
315
- } else {
316
- return null;
317
- }
318
- }
319
- return row;
320
- }
321
- }
322
- return null;
323
- },
324
-
325
- mouseup: function(e) {
326
- if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
327
- var droppedRow = jQuery.tableDnD.dragObject;
328
- var config = jQuery.tableDnD.currentTable.tableDnDConfig;
329
- // If we have a dragObject, then we need to release it,
330
- // The row will already have been moved to the right place so we just reset stuff
331
- if (config.onDragClass) {
332
- jQuery(droppedRow).removeClass(config.onDragClass);
333
- } else {
334
- jQuery(droppedRow).css(config.onDropStyle);
335
- }
336
- jQuery.tableDnD.dragObject = null;
337
- if (config.onDrop) {
338
- // Call the onDrop method if there is one
339
- config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
340
- }
341
- jQuery.tableDnD.currentTable = null; // let go of the table too
342
- }
343
- },
344
-
345
- serialize: function() {
346
- if (jQuery.tableDnD.currentTable) {
347
- return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable);
348
- } else {
349
- return "Error: No Table id set, you need to set an id on your table and every row";
350
- }
351
- },
352
-
353
- serializeTable: function(table) {
354
- var result = "";
355
- var tableId = table.id;
356
- var rows = table.rows;
357
- for (var i=0; i<rows.length; i++) {
358
- if (result.length > 0) result += "&";
359
- var rowId = rows[i].id;
360
- if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) {
361
- rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0];
362
- }
363
-
364
- result += tableId + '[]=' + rows[i].id;
365
- }
366
- return result;
367
- },
368
-
369
- serializeTables: function() {
370
- var result = "";
371
- this.each(function() {
372
- // this is now bound to each matching table
373
- result += jQuery.tableDnD.serializeTable(this);
374
- });
375
- return result;
376
- }
377
-
378
- }
379
-
380
- jQuery.fn.extend(
381
- {
382
- tableDnD : jQuery.tableDnD.build,
383
- tableDnDUpdate : jQuery.tableDnD.updateTables,
384
- tableDnDSerialize: jQuery.tableDnD.serializeTables
385
- }
386
- );
@@ -1,127 +0,0 @@
1
- jQuery(function ($) {
2
- var csrf_token = $('meta[name=csrf-token]').attr('content'),
3
- csrf_param = $('meta[name=csrf-param]').attr('content');
4
-
5
- $.fn.extend({
6
- /**
7
- * Triggers a custom event on an element and returns the event result
8
- * this is used to get around not being able to ensure callbacks are placed
9
- * at the end of the chain.
10
- *
11
- * TODO: deprecate with jQuery 1.4.2 release, in favor of subscribing to our
12
- * own events and placing ourselves at the end of the chain.
13
- */
14
- triggerAndReturn: function (name, data) {
15
- var event = new $.Event(name);
16
- this.trigger(event, data);
17
-
18
- return event.result !== false;
19
- },
20
-
21
- /**
22
- * Handles execution of remote calls firing overridable events along the way
23
- */
24
- callRemote: function () {
25
- var el = this,
26
- method = el.attr('method') || el.attr('data-method') || 'GET',
27
- url = el.attr('action') || el.attr('href'),
28
- dataType = el.attr('data-type') || 'script';
29
-
30
- if (url === undefined) {
31
- throw "No URL specified for remote call (action or href must be present).";
32
- } else {
33
- if (el.triggerAndReturn('ajax:before')) {
34
- var data = el.is('form') ? el.serializeArray() : [];
35
- $.ajax({
36
- url: url,
37
- data: data,
38
- dataType: dataType,
39
- type: method.toUpperCase(),
40
- beforeSend: function (xhr) {
41
- el.trigger('ajax:loading', xhr);
42
- },
43
- success: function (data, status, xhr) {
44
- el.trigger('ajax:success', [data, status, xhr]);
45
- },
46
- complete: function (xhr) {
47
- el.trigger('ajax:complete', xhr);
48
- },
49
- error: function (xhr, status, error) {
50
- el.trigger('ajax:failure', [xhr, status, error]);
51
- }
52
- });
53
- }
54
-
55
- el.trigger('ajax:after');
56
- }
57
- }
58
- });
59
-
60
- /**
61
- * confirmation handler
62
- */
63
- $('a[data-confirm],input[data-confirm]').live('click', function () {
64
- var el = $(this);
65
- if (el.triggerAndReturn('confirm')) {
66
- if (!confirm(el.attr('data-confirm'))) {
67
- return false;
68
- }
69
- }
70
- });
71
-
72
-
73
- /**
74
- * remote handlers
75
- */
76
- $('form[data-remote]').live('submit', function (e) {
77
- $(this).callRemote();
78
- e.preventDefault();
79
- });
80
-
81
- $('a[data-remote],input[data-remote]').live('click', function (e) {
82
- $(this).callRemote();
83
- e.preventDefault();
84
- });
85
-
86
- $('a[data-method]:not([data-remote])').live('click', function (e){
87
- var link = $(this),
88
- href = link.attr('href'),
89
- method = link.attr('data-method'),
90
- form = $('<form method="post" action="'+href+'"></form>'),
91
- metadata_input = '<input name="_method" value="'+method+'" type="hidden" />';
92
-
93
- if (csrf_param != null && csrf_token != null) {
94
- metadata_input += '<input name="'+csrf_param+'" value="'+csrf_token+'" type="hidden" />';
95
- }
96
-
97
- form.hide()
98
- .append(metadata_input)
99
- .appendTo('body');
100
-
101
- e.preventDefault();
102
- form.submit();
103
- });
104
-
105
- /**
106
- * disable-with handlers
107
- */
108
- var disable_with_input_selector = 'input[data-disable-with]';
109
- var disable_with_form_selector = 'form[data-remote]:has(' + disable_with_input_selector + ')';
110
-
111
- $(disable_with_form_selector).live('ajax:before', function () {
112
- $(this).find(disable_with_input_selector).each(function () {
113
- var input = $(this);
114
- input.data('enable-with', input.val())
115
- .attr('value', input.attr('data-disable-with'))
116
- .attr('disabled', 'disabled');
117
- });
118
- });
119
-
120
- $(disable_with_form_selector).live('ajax:complete', function () {
121
- $(this).find(disable_with_input_selector).each(function () {
122
- var input = $(this);
123
- input.removeAttr('disabled')
124
- .val(input.data('enable-with'));
125
- });
126
- });
127
- });