refinerycms-core 2.0.10 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/refinery/admin.js.erb +126 -234
  3. data/app/assets/javascripts/refinery/ajaxy_pagination.js.coffee +1 -1
  4. data/app/assets/javascripts/refinery/boot_wym.js.erb +4 -8
  5. data/app/assets/javascripts/refinery/core.js +1 -1
  6. data/app/assets/javascripts/refinery/interface.js.coffee.erb +3 -16
  7. data/app/assets/javascripts/refinery/modal_dialogs.js.erb +0 -3
  8. data/app/assets/javascripts/refinery/nestedsortables.js +312 -312
  9. data/app/assets/javascripts/refinery/refinery.js.erb +14 -15
  10. data/app/assets/javascripts/refinery/site_bar.js +3 -9
  11. data/app/assets/javascripts/refinery/sortable_list.js +145 -0
  12. data/app/assets/javascripts/refinery/sortable_menu.js.coffee +3 -4
  13. data/app/assets/javascripts/refinery/submit_continue.js.coffee.erb +1 -2
  14. data/app/assets/javascripts/refinery/tree.js +3 -3
  15. data/app/assets/javascripts/refinery/wymeditor.js +6 -6
  16. data/{public → app/assets/javascripts}/wymeditor/GPL-license.txt +0 -0
  17. data/{public → app/assets/javascripts}/wymeditor/MIT-license.txt +0 -0
  18. data/{public → app/assets/javascripts}/wymeditor/README +0 -0
  19. data/app/assets/javascripts/wymeditor/browsers/mozilla.js.erb +10 -11
  20. data/app/assets/javascripts/wymeditor/browsers/webkit.js.erb +17 -18
  21. data/app/assets/javascripts/wymeditor/classes.js.erb +3 -5
  22. data/app/assets/javascripts/wymeditor/functions.js.erb +5 -1
  23. data/app/assets/javascripts/wymeditor/prototypes.js.erb +0 -3
  24. data/app/assets/javascripts/wymeditor/setup.js.erb +5 -5
  25. data/app/assets/javascripts/wymeditor/skins/refinery/skin.js +1 -4
  26. data/app/assets/javascripts/wymeditor/validators.js.erb +3 -2
  27. data/app/assets/stylesheets/{formatting.css.scss → refinery/formatting.css.scss} +0 -0
  28. data/app/assets/stylesheets/refinery/layout.css.scss +41 -11
  29. data/app/assets/stylesheets/{theme.css.scss → refinery/theme.css.scss} +0 -0
  30. data/app/controllers/refinery/sitemap_controller.rb +1 -5
  31. data/app/helpers/refinery/admin_helper.rb +6 -0
  32. data/app/helpers/refinery/image_helper.rb +2 -1
  33. data/app/helpers/refinery/menu_helper.rb +0 -49
  34. data/app/helpers/refinery/meta_helper.rb +7 -3
  35. data/app/helpers/refinery/site_bar_helper.rb +3 -15
  36. data/app/models/refinery/core/base_model.rb +2 -0
  37. data/{lib → app/presenters}/refinery/base_presenter.rb +1 -2
  38. data/app/views/layouts/application.html.erb +8 -7
  39. data/app/views/refinery/_content_page.html.erb +1 -1
  40. data/app/views/refinery/_google_analytics.html.erb +12 -5
  41. data/app/views/refinery/_head.html.erb +11 -15
  42. data/app/views/refinery/_header.html.erb +1 -4
  43. data/app/views/refinery/_javascripts.html.erb +14 -8
  44. data/app/views/refinery/_site_bar.html.erb +4 -4
  45. data/app/views/refinery/admin/_form_advanced_options_menu.html.erb +12 -0
  46. data/app/views/refinery/admin/_javascripts.html.erb +13 -1
  47. data/app/views/refinery/admin/_locale_picker.html.erb +11 -0
  48. data/app/views/refinery/admin/_make_sortable.html.erb +8 -5
  49. data/app/views/refinery/admin/_search.html.erb +1 -7
  50. data/app/views/refinery/admin/_search_header.html.erb +1 -0
  51. data/app/views/refinery/admin/_wysiwyg.html.erb +16 -0
  52. data/config/initializers/will_paginate_monkeypatch.rb +1 -1
  53. data/config/locales/bg.yml +5 -1
  54. data/config/locales/cs.yml +5 -1
  55. data/config/locales/da.yml +5 -1
  56. data/config/locales/de.yml +7 -3
  57. data/config/locales/el.yml +5 -1
  58. data/config/locales/en.yml +7 -1
  59. data/config/locales/es.yml +5 -1
  60. data/config/locales/fi.yml +5 -1
  61. data/config/locales/fr.yml +5 -1
  62. data/config/locales/hu.yml +82 -0
  63. data/config/locales/it.yml +38 -34
  64. data/config/locales/ja.yml +5 -1
  65. data/config/locales/ko.yml +5 -1
  66. data/config/locales/lt.yml +5 -1
  67. data/config/locales/lv.yml +5 -1
  68. data/config/locales/nb.yml +5 -1
  69. data/config/locales/nl.yml +36 -29
  70. data/config/locales/pl.yml +8 -1
  71. data/config/locales/pt-BR.yml +7 -3
  72. data/config/locales/pt.yml +82 -0
  73. data/config/locales/rs.yml +5 -1
  74. data/config/locales/ru.yml +5 -1
  75. data/config/locales/sk.yml +10 -3
  76. data/config/locales/sl.yml +5 -1
  77. data/config/locales/sv.yml +5 -1
  78. data/config/locales/tr.yml +82 -0
  79. data/config/locales/uk.yml +77 -0
  80. data/config/locales/vi.yml +5 -1
  81. data/config/locales/zh-CN.yml +5 -1
  82. data/config/locales/zh-TW.yml +5 -1
  83. data/config/routes.rb +3 -3
  84. data/lib/generators/refinery/cms/cms_generator.rb +29 -0
  85. data/lib/generators/refinery/cms/templates/.gitignore +1 -0
  86. data/lib/generators/refinery/cms/templates/app/views/sitemap/index.xml.builder +13 -13
  87. data/lib/generators/refinery/core/templates/config/initializers/refinery/core.rb.erb +8 -12
  88. data/lib/generators/refinery/dummy/templates/rails/database.yml +3 -3
  89. data/lib/generators/refinery/engine/engine_generator.rb +8 -12
  90. data/lib/generators/refinery/engine/templates/Gemfile +5 -39
  91. data/lib/generators/refinery/engine/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb +4 -4
  92. data/lib/generators/refinery/engine/templates/app/models/refinery/namespace/singular_name.rb.erb +2 -3
  93. data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_actions.html.erb +1 -1
  94. data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_form.html.erb +31 -33
  95. data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_records.html.erb +1 -3
  96. data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_singular_name.html.erb +2 -2
  97. data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/index.html.erb +1 -1
  98. data/lib/generators/refinery/engine/templates/config/locales/cs.yml +28 -0
  99. data/lib/generators/refinery/engine/templates/config/locales/it.yml +28 -0
  100. data/lib/generators/refinery/engine/templates/config/locales/nl.yml +6 -6
  101. data/lib/generators/refinery/engine/templates/config/locales/tr.yml +28 -0
  102. data/lib/generators/refinery/engine/templates/config/routes.rb.erb +2 -2
  103. data/lib/generators/refinery/engine/templates/db/seeds.rb.erb +1 -1
  104. data/lib/generators/refinery/engine/templates/lib/generators/refinery/extension_plural_name_generator.rb.erb +1 -1
  105. data/lib/generators/refinery/engine/templates/lib/refinery/plural_name/engine.rb.erb +1 -1
  106. data/lib/generators/refinery/engine/templates/spec/{requests → features}/refinery/namespace/admin/plural_name_spec.rb.erb +1 -1
  107. data/lib/generators/refinery/engine/templates/spec/spec_helper.rb +25 -49
  108. data/lib/generators/refinery/form/form_generator.rb +1 -13
  109. data/lib/generators/refinery/form/templates/app/models/refinery/namespace/singular_name.rb.erb +0 -4
  110. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/_records.html.erb +2 -2
  111. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/spam.html.erb +7 -6
  112. data/lib/generators/refinery/form/templates/config/locales/nl.yml +29 -29
  113. data/lib/generators/refinery/form/templates/config/locales/tr.yml +78 -0
  114. data/lib/generators/refinery/form/templates/config/routes.rb.erb +1 -1
  115. data/lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb +2 -6
  116. data/lib/generators/refinery/form/templates/db/seeds.rb.erb +1 -1
  117. data/lib/generators/refinery/form/templates/lib/refinery/plural_name/engine.rb.erb +1 -1
  118. data/lib/generators/refinery/form/templates/refinerycms-plural_name.gemspec +2 -5
  119. data/lib/refinery.rb +191 -0
  120. data/lib/refinery/admin/base_controller.rb +27 -16
  121. data/lib/refinery/application_controller.rb +15 -47
  122. data/lib/refinery/cli.rb +48 -27
  123. data/lib/refinery/core.rb +7 -183
  124. data/lib/refinery/core/configuration.rb +17 -9
  125. data/lib/refinery/core/engine.rb +11 -47
  126. data/lib/refinery/crud.rb +81 -66
  127. data/lib/refinery/engine.rb +52 -55
  128. data/lib/refinery/ext/action_view/helpers/form_builder.rb +2 -0
  129. data/lib/refinery/extension_generation.rb +208 -110
  130. data/lib/refinery/menu.rb +16 -7
  131. data/lib/refinery/menu_item.rb +56 -54
  132. data/lib/refinery/plugin.rb +11 -3
  133. data/lib/refinery/plugins.rb +14 -1
  134. data/lib/refinery/version.rb +3 -3
  135. data/refinerycms-core.gemspec +11 -10
  136. data/spec/controllers/refinery/admin/dummy_controller_spec.rb +57 -0
  137. data/spec/controllers/refinery/admin/refinery_core_controller_spec.rb +3 -4
  138. data/spec/controllers/refinery/sitemap_controller_spec.rb +1 -14
  139. data/spec/{requests → features}/refinery/admin/custom_assets_spec.rb +1 -1
  140. data/spec/{requests → features}/refinery/admin/dialogs_spec.rb +1 -1
  141. data/spec/features/refinery/admin/xhr_paging_spec.rb +55 -0
  142. data/spec/features/refinery/application_layout_spec.rb +19 -0
  143. data/spec/features/refinery/core_spec.rb +14 -0
  144. data/spec/{requests → features}/refinery/site_bar_spec.rb +1 -1
  145. data/spec/helpers/refinery/meta_helper_spec.rb +25 -0
  146. data/spec/lib/generators/refinery/cms/cms_generator_spec.rb +61 -0
  147. data/spec/lib/generators/refinery/engine/engine_generator_multiple_resources_spec.rb +28 -1
  148. data/spec/lib/generators/refinery/engine/engine_generator_sanity_check_spec.rb +7 -7
  149. data/spec/lib/generators/refinery/engine/engine_generator_spec.rb +69 -8
  150. data/spec/lib/generators/refinery/engine/engine_generator_with_i18n_spec.rb +0 -2
  151. data/spec/lib/generators/refinery/form/form_generator_spec.rb +9 -1
  152. data/spec/lib/refinery/application_controller_spec.rb +48 -63
  153. data/spec/lib/refinery/cli_spec.rb +136 -0
  154. data/spec/lib/refinery/core/configuration_spec.rb +17 -0
  155. data/spec/lib/refinery/core_spec.rb +19 -13
  156. data/spec/lib/refinery/crud_spec.rb +0 -4
  157. data/spec/lib/refinery/menu_spec.rb +16 -26
  158. data/spec/support/refinery.rb +6 -1
  159. data/{app → vendor}/assets/javascripts/jquery/GPL-LICENSE.txt +0 -0
  160. data/{app → vendor}/assets/javascripts/jquery/MIT-LICENSE.txt +0 -0
  161. data/vendor/assets/javascripts/jquery/jquery.browser.js +49 -0
  162. data/{app → vendor}/assets/javascripts/jquery/jquery.html5-placeholder-shim.js +0 -0
  163. data/{app → vendor}/assets/javascripts/jquery/jquery.jcarousel.js +0 -0
  164. data/{app → vendor}/assets/javascripts/jquery/jquery.textTruncate.js +0 -0
  165. data/{app → vendor}/assets/javascripts/jquery/jquery.timers.js +0 -0
  166. data/{app → vendor}/assets/javascripts/modernizr-min.js +0 -0
  167. metadata +231 -78
  168. data/app/assets/images/refinery/resolve_digital_footer_logo.png +0 -0
  169. data/app/assets/javascripts/dd_belatedpng.js +0 -13
  170. data/app/assets/javascripts/jquery/jquery.corner.js +0 -345
  171. data/app/assets/stylesheets/application.css.scss +0 -55
  172. data/app/assets/stylesheets/home.css.scss +0 -3
  173. data/app/views/refinery/_ie6check.html.erb +0 -63
  174. data/app/views/refinery/_menu.html.erb +0 -20
  175. data/app/views/refinery/_menu_branch.html.erb +0 -19
  176. data/lib/generators/refinery/engine/templates/Guardfile +0 -27
  177. data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_locale_picker.html.erb +0 -11
  178. data/lib/refinery/catch_all_routes.rb +0 -3
  179. data/lib/tasks/yard.rake +0 -30
  180. data/spec/requests/refinery/admin/controller_restriction_spec.rb +0 -27
  181. data/spec/requests/refinery/search_spec.rb +0 -71
@@ -1,7 +1,7 @@
1
1
  @init_ajaxy_pagination = ->
2
2
  if typeof (window.history.pushState) == "function" and $(".pagination_container").length > 0
3
3
  pagination_pages = $(".pagination_container .pagination a")
4
- pagination_pages.live "click", (e) ->
4
+ pagination_pages.on "click", (e) ->
5
5
  navigate_to = @href.replace(/(\&(amp\;)?)?from_page\=\d+/, "")
6
6
  navigate_to += "&from_page=" + $(".current").text()
7
7
  navigate_to = navigate_to.replace("?&", "?").replace(/\s+/, "")
@@ -1,9 +1,5 @@
1
1
  onOpenDialog = function(dialog) {
2
- (dialog = $('.ui-dialog')).find('.ui-dialog-titlebar').corner('1px top');
3
- if(!$.browser.msie){
4
- dialog.corner('6px');
5
- }
6
- if (dialog.height() < $(window).height()) {
2
+ if ($('.ui-dialog').height() < $(window).height()) {
7
3
  if(iframed()) {
8
4
  $(parent.document.body).addClass('hide-overflow');
9
5
  } else {
@@ -224,7 +220,7 @@ var wymeditor_boot_options = $.extend({
224
220
  );
225
221
  }
226
222
  }
227
- , lang: '<%= ::Refinery::i18n_enabled? ? ::Refinery::I18n.current_locale : 'en' %>'
223
+ , lang: refinery.current_admin_locale
228
224
  }, custom_wymeditor_boot_options);
229
225
 
230
226
  WYMeditor.editor.prototype.loadIframe = function(iframe) {
@@ -252,8 +248,8 @@ WYMeditor.editor.prototype.loadIframe = function(iframe) {
252
248
 
253
249
  var doc_head = doc.head || $(doc).find('head').get(0);
254
250
  $("<link href='<%= asset_path 'wymeditor/skins/refinery/wymiframe.css' %>' media='all' rel='stylesheet' />").appendTo(doc_head);
255
- $("<link href='<%= asset_path 'formatting.css' %>' media='all' rel='stylesheet' />").appendTo(doc_head);
256
- $("<link href='<%= asset_path 'theme.css' %>' media='all' rel='stylesheet' />").appendTo(doc_head);
251
+ $("<link href='<%= asset_path 'refinery/formatting.css' %>' media='all' rel='stylesheet' />").appendTo(doc_head);
252
+ $("<link href='<%= asset_path 'refinery/theme.css' %>' media='all' rel='stylesheet' />").appendTo(doc_head);
257
253
  }
258
254
  if ((id_of_editor = wym._element.parent().attr('id')) != null) {
259
255
  $(doc.body).addClass(id_of_editor);
@@ -10,7 +10,7 @@ init_flash_messages = function(){
10
10
  'opacity': 0
11
11
  , 'visibility':'visible'
12
12
  }).animate({'opacity': '1'}, 550);
13
- $('#flash_close').live('click', function(e) {
13
+ $('#flash_close').on('click', function(e) {
14
14
  try {
15
15
  $('#flash').animate({
16
16
  'opacity': 0,
@@ -1,16 +1,6 @@
1
1
  @init_interface = ->
2
2
  $("body#dialog_container.dialog").addClass "iframed" if parent and parent.document.location.href != document.location.href
3
3
  $("input:submit:not(.button)").addClass "button"
4
- unless $.browser.msie
5
- $("#page_container, .wym_box").corner "5px bottom"
6
- $(".wym_box").corner "5px tr"
7
- $(".field > .wym_box").corner "5px tl"
8
- $(".wym_iframe iframe").corner "2px"
9
- $(".form-actions:not(\".form-actions-dialog\")").corner "5px"
10
- $("#recent_activity li a, #recent_inquiries li a").each (i, a) ->
11
- $(this).textTruncate
12
- width: $(this).width()
13
- tooltip: false
14
4
 
15
5
  $("textarea.wymeditor").each ->
16
6
  textarea = $(this)
@@ -39,10 +29,6 @@
39
29
  listTag: $menu.get(0).tagName.toLowerCase()
40
30
  itemTag: $menu.children(":first").get(0).tagName.toLowerCase()
41
31
 
42
- if $menu.outerWidth() < $("#page_container").outerWidth()
43
- $("#page_container:not('.login #page_container')").corner "5px tr"
44
- else
45
- $("#page_container:not('.login #page_container')").uncorner()
46
32
  $("#current_locale li a").click (e) ->
47
33
  $("#current_locale li a span").each (span) ->
48
34
  $(this).css "display", (if $(this).css("display") == "none" then "" else "none")
@@ -55,7 +41,8 @@
55
41
  e.preventDefault()
56
42
 
57
43
  $("#existing_image img").load ->
58
- $("form.edit_image .form-actions").css "margin-top": ($("#existing_image").height() - $("form.edit_image").height() + 8)
44
+ margin_top = ($("#existing_image").height() - $("form.edit_image").height() + 8)
45
+ $("form.edit_image .form-actions").css "margin-top": margin_top if margin_top > 0
59
46
 
60
47
  $(".form-actions .form-actions-left input:submit#submit_button").click (e) ->
61
48
  $("<img src='<%= asset_path 'refinery/ajax-loader.gif' %>' width='16' height='16' class='save-loader' />").appendTo $(this).parent()
@@ -66,5 +53,5 @@
66
53
  titlebar_close_button.trigger('click')
67
54
  e.preventDefault()
68
55
 
69
- $("a.suppress").live "click", (e) ->
56
+ $("a.suppress").on "click", (e) ->
70
57
  e.preventDefault()
@@ -14,7 +14,6 @@ init_modal_dialogs = function(){
14
14
  + 'app_dialog=true&dialog=true';
15
15
 
16
16
  iframe = $("<iframe id='dialog_iframe' frameborder='0' marginheight='0' marginwidth='0' border='0'></iframe>");
17
- if(!$.browser.msie) { iframe.corner('8px'); }
18
17
  iframe.dialog({
19
18
  title: $anchor.data('dialog-title')
20
19
  , modal: true
@@ -58,8 +57,6 @@ init_sortable_menu = function(){
58
57
  $menu.find('#menu_reorder_done').click(function(e){
59
58
  trigger_reordering(e, false);
60
59
  });
61
-
62
- $menu.find('> a').corner('top 5px');
63
60
  };
64
61
 
65
62
  trigger_reordering = function(e, enable) {
@@ -4,7 +4,7 @@
4
4
  * http://mjsarfatti.com/sandbox/nestedSortable
5
5
  *
6
6
  * Depends:
7
- * jquery.ui.sortable.js 1.8+
7
+ * jquery.ui.sortable.js 1.8+
8
8
  *
9
9
  * License CC BY-SA 3.0
10
10
  * Copyright 2010-2011, Manuele J Sarfatti
@@ -12,345 +12,345 @@
12
12
 
13
13
  (function($) {
14
14
 
15
- $.widget("ui.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
15
+ $.widget("ui.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
16
16
 
17
- options: {
18
- tabSize: 20,
19
- disableNesting: 'ui-nestedSortable-no-nesting',
20
- errorClass: 'ui-nestedSortable-error',
21
- listType: 'ol',
22
- maxLevels: 0,
23
- noJumpFix: 0
24
- },
25
-
26
- _create: function(){
27
- if (this.noJumpFix == false)
28
- this.element.height(this.element.height());
29
- this.element.data('sortable', this.element.data('nestedSortable'));
30
- return $.ui.sortable.prototype._create.apply(this, arguments);
31
- },
32
-
33
-
34
-
35
- _mouseDrag: function(event) {
36
-
37
- //Compute the helpers position
38
- this.position = this._generatePosition(event);
39
- this.positionAbs = this._convertPositionTo("absolute");
40
-
41
- if (!this.lastPositionAbs) {
42
- this.lastPositionAbs = this.positionAbs;
43
- }
44
-
45
- //Do scrolling
46
- if(this.options.scroll) {
47
- var o = this.options, scrolled = false;
48
- if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
49
-
50
- if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
51
- this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
52
- else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
53
- this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
54
-
55
- if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
56
- this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
57
- else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
58
- this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
59
-
60
- } else {
61
-
62
- if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
63
- scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
64
- else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
65
- scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
66
-
67
- if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
68
- scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
69
- else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
70
- scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
71
-
72
- }
73
-
74
- if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
75
- $.ui.ddmanager.prepareOffsets(this, event);
76
- }
77
-
78
- //Regenerate the absolute position used for position checks
79
- this.positionAbs = this._convertPositionTo("absolute");
80
-
81
- //Set the helper position
82
- if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
83
- if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
84
-
85
- //Rearrange
86
- for (var i = this.items.length - 1; i >= 0; i--) {
87
-
88
- //Cache variables and intersection, continue if no intersection
89
- var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
90
- if (!intersection) continue;
91
-
92
- if(itemElement != this.currentItem[0] //cannot intersect with itself
93
- && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
94
- && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
95
- && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
96
- //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
97
- ) {
98
-
99
- this.direction = intersection == 1 ? "down" : "up";
100
-
101
- if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
102
- this._rearrange(event, item);
103
- } else {
104
- break;
105
- }
106
-
107
- // Clear emtpy ul's/ol's
108
- this._clearEmpty(itemElement);
109
-
110
- this._trigger("change", event, this._uiHash());
111
- break;
112
- }
113
- }
114
-
115
- var parentItem = (this.placeholder[0].parentNode.parentNode && $(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length) ? $(this.placeholder[0].parentNode.parentNode) : null;
116
- var level = this._getLevel(this.placeholder);
117
- var childLevels = this._getChildLevels(this.helper);
118
- var previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null;
119
- if (previousItem != null) {
120
- while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0]) {
121
- if (previousItem[0].previousSibling) {
122
- previousItem = $(previousItem[0].previousSibling);
123
- } else {
124
- previousItem = null;
125
- break;
126
- }
127
- }
128
- }
129
-
130
- newList = document.createElement(o.listType);
131
-
132
- this.beyondMaxLevels = 0;
133
-
134
- // If the item is moved to the left, send it to its parent level
135
- if (parentItem != null && this.positionAbs.left < parentItem.offset().left) {
136
- parentItem.after(this.placeholder[0]);
137
- this._clearEmpty(parentItem[0]);
138
- this._trigger("change", event, this._uiHash());
139
- }
140
- // If the item is below another one and is moved to the right, make it a children of it
141
- else if (previousItem != null && this.positionAbs.left > previousItem.offset().left + o.tabSize) {
142
- this._isAllowed(previousItem, level+childLevels+1);
143
- if (!previousItem.children(o.listType).length) {
144
- previousItem[0].appendChild(newList);
145
- }
146
- previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
147
- this._trigger("change", event, this._uiHash());
148
- }
149
- else {
150
- this._isAllowed(parentItem, level+childLevels);
151
- }
152
-
153
- //Post events to containers
154
- this._contactContainers(event);
155
-
156
- //Interconnect with droppables
157
- if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
158
-
159
- //Call callbacks
160
- this._trigger('sort', event, this._uiHash());
161
-
162
- this.lastPositionAbs = this.positionAbs;
163
- return false;
164
-
165
- },
166
-
167
- _mouseStop: function(event, noPropagation) {
168
-
169
- // If the item is in a position not allowed, send it back
170
- if (this.beyondMaxLevels) {
171
- var parent = this.placeholder.parent().closest(this.options.items);
172
-
173
- for (var i = this.beyondMaxLevels - 1; i > 0; i--) {
174
- parent = parent.parent().closest(this.options.items);
175
- }
176
-
177
- this.placeholder.removeClass(this.options.errorClass);
178
- parent.after(this.placeholder);
179
- this._trigger("change", event, this._uiHash());
180
- }
181
-
182
- $.ui.sortable.prototype._mouseStop.apply(this, arguments);
183
-
184
- },
185
-
186
- serialize: function(o) {
187
-
188
- var items = this._getItemsAsjQuery(o && o.connected);
189
- var str = []; o = o || {};
190
-
191
- $(items).each(function() {
192
- var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
193
- var pid = ($(o.item || this).parent(o.listType).parent('li').attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
194
- if(res) str.push((o.key || res[1]+'['+(o.key && o.expression ? res[1] : res[2])+']')+'='+(pid ? (o.key && o.expression ? pid[1] : pid[2]) : 'root'));
195
- });
196
-
197
- if(!str.length && o.key) {
198
- str.push(o.key + '=');
199
- }
200
-
201
- return str.join('&');
202
-
203
- },
204
-
205
- toHierarchy: function(o) {
206
-
207
- o = o || {};
208
- var sDepth = o.startDepthCount || 0;
209
- var ret = [];
210
-
211
- $(this.element).children('li').each(function() {
212
- var level = _recursiveItems($(this));
213
- ret.push(level);
214
- });
215
-
216
- return ret;
217
-
218
- function _recursiveItems(li) {
219
- var id = ($(li).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
220
- if (id != null) {
221
- var item = {"id" : id[2]};
222
- if ($(li).children(o.listType).children('li').length > 0) {
223
- item.children = [];
224
- $(li).children(o.listType).children('li').each(function () {
225
- var level = _recursiveItems($(this));
226
- item.children.push(level);
227
- });
228
- }
229
- return item;
230
- }
231
- }
17
+ options: {
18
+ tabSize: 20,
19
+ disableNesting: 'ui-nestedSortable-no-nesting',
20
+ errorClass: 'ui-nestedSortable-error',
21
+ listType: 'ol',
22
+ maxLevels: 0,
23
+ noJumpFix: 0
24
+ },
25
+
26
+ _create: function(){
27
+ if (this.noJumpFix == false)
28
+ this.element.height(this.element.height());
29
+ this.element.data('sortable', this.element.data('nestedSortable'));
30
+ return $.ui.sortable.prototype._create.apply(this, arguments);
31
+ },
32
+
33
+
34
+
35
+ _mouseDrag: function(event) {
36
+
37
+ //Compute the helpers position
38
+ this.position = this._generatePosition(event);
39
+ this.positionAbs = this._convertPositionTo("absolute");
40
+
41
+ if (!this.lastPositionAbs) {
42
+ this.lastPositionAbs = this.positionAbs;
43
+ }
44
+
45
+ //Do scrolling
46
+ if(this.options.scroll) {
47
+ var o = this.options, scrolled = false;
48
+ if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
49
+
50
+ if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
51
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
52
+ else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
53
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
54
+
55
+ if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
56
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
57
+ else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
58
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
59
+
60
+ } else {
61
+
62
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
63
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
64
+ else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
65
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
66
+
67
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
68
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
69
+ else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
70
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
71
+
72
+ }
73
+
74
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
75
+ $.ui.ddmanager.prepareOffsets(this, event);
76
+ }
77
+
78
+ //Regenerate the absolute position used for position checks
79
+ this.positionAbs = this._convertPositionTo("absolute");
80
+
81
+ //Set the helper position
82
+ if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
83
+ if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
84
+
85
+ //Rearrange
86
+ for (var i = this.items.length - 1; i >= 0; i--) {
87
+
88
+ //Cache variables and intersection, continue if no intersection
89
+ var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
90
+ if (!intersection) continue;
91
+
92
+ if(itemElement != this.currentItem[0] //cannot intersect with itself
93
+ && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
94
+ && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
95
+ && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
96
+ //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
97
+ ) {
98
+
99
+ this.direction = intersection == 1 ? "down" : "up";
100
+
101
+ if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
102
+ this._rearrange(event, item);
103
+ } else {
104
+ break;
105
+ }
106
+
107
+ // Clear emtpy ul's/ol's
108
+ this._clearEmpty(itemElement);
109
+
110
+ this._trigger("change", event, this._uiHash());
111
+ break;
112
+ }
113
+ }
114
+
115
+ var parentItem = (this.placeholder[0].parentNode.parentNode && $(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length) ? $(this.placeholder[0].parentNode.parentNode) : null;
116
+ var level = this._getLevel(this.placeholder);
117
+ var childLevels = this._getChildLevels(this.helper);
118
+ var previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null;
119
+ if (previousItem != null) {
120
+ while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0]) {
121
+ if (previousItem[0].previousSibling) {
122
+ previousItem = $(previousItem[0].previousSibling);
123
+ } else {
124
+ previousItem = null;
125
+ break;
126
+ }
127
+ }
128
+ }
129
+
130
+ newList = document.createElement(o.listType);
131
+
132
+ this.beyondMaxLevels = 0;
133
+
134
+ // If the item is moved to the left, send it to its parent level
135
+ if (parentItem != null && this.positionAbs.left < parentItem.offset().left) {
136
+ parentItem.after(this.placeholder[0]);
137
+ this._clearEmpty(parentItem[0]);
138
+ this._trigger("change", event, this._uiHash());
139
+ }
140
+ // If the item is below another one and is moved to the right, make it a children of it
141
+ else if (previousItem != null && this.positionAbs.left > previousItem.offset().left + o.tabSize) {
142
+ this._isAllowed(previousItem, level+childLevels+1);
143
+ if (!previousItem.children(o.listType).length) {
144
+ previousItem[0].appendChild(newList);
145
+ }
146
+ previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
147
+ this._trigger("change", event, this._uiHash());
148
+ }
149
+ else {
150
+ this._isAllowed(parentItem, level+childLevels);
151
+ }
152
+
153
+ //Post events to containers
154
+ this._contactContainers(event);
155
+
156
+ //Interconnect with droppables
157
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
158
+
159
+ //Call callbacks
160
+ this._trigger('sort', event, this._uiHash());
161
+
162
+ this.lastPositionAbs = this.positionAbs;
163
+ return false;
164
+
165
+ },
166
+
167
+ _mouseStop: function(event, noPropagation) {
168
+
169
+ // If the item is in a position not allowed, send it back
170
+ if (this.beyondMaxLevels) {
171
+ var parent = this.placeholder.parent().closest(this.options.items);
172
+
173
+ for (var i = this.beyondMaxLevels - 1; i > 0; i--) {
174
+ parent = parent.parent().closest(this.options.items);
175
+ }
176
+
177
+ this.placeholder.removeClass(this.options.errorClass);
178
+ parent.after(this.placeholder);
179
+ this._trigger("change", event, this._uiHash());
180
+ }
181
+
182
+ $.ui.sortable.prototype._mouseStop.apply(this, arguments);
183
+
184
+ },
185
+
186
+ serialize: function(o) {
187
+
188
+ var items = this._getItemsAsjQuery(o && o.connected);
189
+ var str = []; o = o || {};
190
+
191
+ $(items).each(function() {
192
+ var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
193
+ var pid = ($(o.item || this).parent(o.listType).parent('li').attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
194
+ if(res) str.push((o.key || res[1]+'['+(o.key && o.expression ? res[1] : res[2])+']')+'='+(pid ? (o.key && o.expression ? pid[1] : pid[2]) : 'root'));
195
+ });
196
+
197
+ if(!str.length && o.key) {
198
+ str.push(o.key + '=');
199
+ }
200
+
201
+ return str.join('&');
202
+
203
+ },
204
+
205
+ toHierarchy: function(o) {
206
+
207
+ o = o || {};
208
+ var sDepth = o.startDepthCount || 0;
209
+ var ret = [];
210
+
211
+ $(this.element).children('li').each(function() {
212
+ var level = _recursiveItems($(this));
213
+ ret.push(level);
214
+ });
215
+
216
+ return ret;
217
+
218
+ function _recursiveItems(li) {
219
+ var id = ($(li).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
220
+ if (id != null) {
221
+ var item = {"id" : id[2]};
222
+ if ($(li).children(o.listType).children('li').length > 0) {
223
+ item.children = [];
224
+ $(li).children(o.listType).children('li').each(function () {
225
+ var level = _recursiveItems($(this));
226
+ item.children.push(level);
227
+ });
228
+ }
229
+ return item;
230
+ }
231
+ }
232
232
  },
233
233
 
234
- toArray: function(o) {
234
+ toArray: function(o) {
235
235
 
236
- o = o || {};
237
- var sDepth = o.startDepthCount || 0;
238
- var ret = [];
239
- var left = 2;
236
+ o = o || {};
237
+ var sDepth = o.startDepthCount || 0;
238
+ var ret = [];
239
+ var left = 2;
240
240
 
241
- ret.push({"item_id": 'root', "parent_id": 'none', "depth": sDepth, "left": '1', "right": ($('li', this.element).length + 1) * 2});
241
+ ret.push({"item_id": 'root', "parent_id": 'none', "depth": sDepth, "left": '1', "right": ($('li', this.element).length + 1) * 2});
242
242
 
243
- $(this.element).children('li').each(function () {
244
- left = _recursiveArray(this, sDepth + 1, left);
245
- });
243
+ $(this.element).children('li').each(function () {
244
+ left = _recursiveArray(this, sDepth + 1, left);
245
+ });
246
246
 
247
- function _sortByLeft(a,b) {
248
- return a['left'] - b['left'];
249
- }
250
- ret = ret.sort(_sortByLeft);
247
+ function _sortByLeft(a,b) {
248
+ return a['left'] - b['left'];
249
+ }
250
+ ret = ret.sort(_sortByLeft);
251
251
 
252
- return ret;
252
+ return ret;
253
253
 
254
- function _recursiveArray(item, depth, left) {
254
+ function _recursiveArray(item, depth, left) {
255
255
 
256
- right = left + 1;
256
+ right = left + 1;
257
257
 
258
- if ($(item).children(o.listType).children('li').length > 0) {
259
- depth ++;
260
- $(item).children(o.listType).children('li').each(function () {
261
- right = _recursiveArray($(this), depth, right);
262
- });
263
- depth --;
264
- }
258
+ if ($(item).children(o.listType).children('li').length > 0) {
259
+ depth ++;
260
+ $(item).children(o.listType).children('li').each(function () {
261
+ right = _recursiveArray($(this), depth, right);
262
+ });
263
+ depth --;
264
+ }
265
265
 
266
- id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
266
+ id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
267
267
 
268
- if (depth === sDepth + 1) pid = 'root';
269
- else {
270
- parentItem = ($(item).parent(o.listType).parent('li').attr('id')).match(o.expression || (/(.+)[-=_](.+)/));
271
- pid = parentItem[2];
272
- }
268
+ if (depth === sDepth + 1) pid = 'root';
269
+ else {
270
+ parentItem = ($(item).parent(o.listType).parent('li').attr('id')).match(o.expression || (/(.+)[-=_](.+)/));
271
+ pid = parentItem[2];
272
+ }
273
273
 
274
- if (id != null) {
275
- ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right});
276
- }
274
+ if (id != null) {
275
+ ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right});
276
+ }
277
277
 
278
- return left = right + 1;
279
- }
278
+ return left = right + 1;
279
+ }
280
280
 
281
- },
281
+ },
282
282
 
283
- _clear: function(event, noPropagation) {
283
+ _clear: function(event, noPropagation) {
284
284
 
285
- $.ui.sortable.prototype._clear.apply(this, arguments);
285
+ $.ui.sortable.prototype._clear.apply(this, arguments);
286
286
 
287
- // Clean last empty ul/ol
288
- for (var i = this.items.length - 1; i >= 0; i--) {
289
- var item = this.items[i].item[0];
290
- this._clearEmpty(item);
291
- }
292
- return true;
287
+ // Clean last empty ul/ol
288
+ for (var i = this.items.length - 1; i >= 0; i--) {
289
+ var item = this.items[i].item[0];
290
+ this._clearEmpty(item);
291
+ }
292
+ return true;
293
293
 
294
- },
294
+ },
295
295
 
296
- _clearEmpty: function(item) {
296
+ _clearEmpty: function(item) {
297
297
 
298
- if (item.children[1] && item.children[1].children.length == 0) {
299
- item.removeChild(item.children[1]);
300
- }
298
+ if (item.children[1] && item.children[1].children.length == 0) {
299
+ item.removeChild(item.children[1]);
300
+ }
301
301
 
302
- },
302
+ },
303
303
 
304
- _getLevel: function(item) {
304
+ _getLevel: function(item) {
305
305
 
306
- var level = 1;
306
+ var level = 1;
307
307
 
308
- if (this.options.listType) {
309
- var list = item.closest(this.options.listType);
310
- while (!list.is('.ui-sortable')/* && level < this.options.maxLevels*/) {
311
- level++;
312
- list = list.parent().closest(this.options.listType);
313
- }
314
- }
308
+ if (this.options.listType) {
309
+ var list = item.closest(this.options.listType);
310
+ while (!list.is('.ui-sortable')/* && level < this.options.maxLevels*/) {
311
+ level++;
312
+ list = list.parent().closest(this.options.listType);
313
+ }
314
+ }
315
315
 
316
- return level;
317
- },
316
+ return level;
317
+ },
318
318
 
319
- _getChildLevels: function(parent, depth) {
320
- var self = this,
321
- o = this.options,
322
- result = 0;
323
- depth = depth || 0;
319
+ _getChildLevels: function(parent, depth) {
320
+ var self = this,
321
+ o = this.options,
322
+ result = 0;
323
+ depth = depth || 0;
324
324
 
325
- $(parent).children(o.listType).children(o.items).each(function (index, child) {
326
- result = Math.max(self._getChildLevels(child, depth + 1), result);
327
- });
325
+ $(parent).children(o.listType).children(o.items).each(function (index, child) {
326
+ result = Math.max(self._getChildLevels(child, depth + 1), result);
327
+ });
328
328
 
329
- return depth ? result + 1 : result;
330
- },
329
+ return depth ? result + 1 : result;
330
+ },
331
331
 
332
- _isAllowed: function(parentItem, levels) {
333
- var o = this.options
334
- // Are we trying to nest under a no-nest or are we nesting too deep?
335
- if (parentItem == null || !(parentItem.hasClass(o.disableNesting))) {
336
- if (o.maxLevels < levels && o.maxLevels != 0) {
337
- this.placeholder.addClass(o.errorClass);
338
- this.beyondMaxLevels = levels - o.maxLevels;
339
- } else {
340
- this.placeholder.removeClass(o.errorClass);
341
- this.beyondMaxLevels = 0;
342
- }
343
- } else {
344
- this.placeholder.addClass(o.errorClass);
345
- if (o.maxLevels < levels && o.maxLevels != 0) {
346
- this.beyondMaxLevels = levels - o.maxLevels;
347
- } else {
348
- this.beyondMaxLevels = 1;
349
- }
350
- }
351
- }
352
-
353
- }));
354
-
355
- $.ui.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.ui.nestedSortable.prototype.options);
356
- })(jQuery);
332
+ _isAllowed: function(parentItem, levels) {
333
+ var o = this.options
334
+ // Are we trying to nest under a no-nest or are we nesting too deep?
335
+ if (parentItem == null || !(parentItem.hasClass(o.disableNesting))) {
336
+ if (o.maxLevels < levels && o.maxLevels != 0) {
337
+ this.placeholder.addClass(o.errorClass);
338
+ this.beyondMaxLevels = levels - o.maxLevels;
339
+ } else {
340
+ this.placeholder.removeClass(o.errorClass);
341
+ this.beyondMaxLevels = 0;
342
+ }
343
+ } else {
344
+ this.placeholder.addClass(o.errorClass);
345
+ if (o.maxLevels < levels && o.maxLevels != 0) {
346
+ this.beyondMaxLevels = levels - o.maxLevels;
347
+ } else {
348
+ this.beyondMaxLevels = 1;
349
+ }
350
+ }
351
+ }
352
+
353
+ }));
354
+
355
+ $.ui.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.ui.nestedSortable.prototype.options);
356
+ })(jQuery);