hancock_cms 2.0.0.2 → 2.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +4 -0
  3. data/app/assets/images/{devices → hancock/devise}/login-bg.jpg +0 -0
  4. data/app/assets/images/{rails-admin → hancock/rails_admin}/hancock_logo.svg +0 -0
  5. data/app/assets/javascripts/hancock/cms.coffee +1 -1
  6. data/app/assets/javascripts/hancock/rails_admin/cms.ui.coffee +11 -37
  7. data/app/assets/javascripts/hancock/rails_admin/en_ru_switcher.coffee +90 -0
  8. data/app/assets/javascripts/hancock/rails_admin/enum_with_custom.coffee +42 -0
  9. data/app/assets/javascripts/hancock/rails_admin/form_controls_fixed.coffee +44 -0
  10. data/app/assets/javascripts/hancock/rails_admin/leftside_hider.coffee +106 -0
  11. data/app/assets/javascripts/hancock/rails_admin/multiselect.coffee +8 -0
  12. data/app/assets/javascripts/hancock/rails_admin/navigation_dropdown.coffee +25 -0
  13. data/app/assets/javascripts/hancock/rails_admin/navigation_filter.coffee +108 -0
  14. data/app/assets/javascripts/hancock/rails_admin/navigation_scroll.coffee +12 -0
  15. data/app/assets/javascripts/hancock/rails_admin/plugins.coffee.erb +16 -0
  16. data/app/assets/javascripts/jquery.placeholder.js +3 -2
  17. data/app/assets/javascripts/rails_admin/custom/ui.coffee +1 -0
  18. data/app/assets/stylesheets/hancock/cms/devise.sass +4 -1
  19. data/app/assets/stylesheets/hancock/rails_admin/cms.theming.sass +354 -147
  20. data/app/assets/stylesheets/hancock/rails_admin/fieldsets.sass +198 -0
  21. data/app/assets/stylesheets/hancock/rails_admin/plugins.sass.erb +6 -0
  22. data/app/assets/stylesheets/rails_admin/custom/theming.sass +1 -1
  23. data/app/controllers/concerns/hancock/decorators/home.rb +1 -1
  24. data/app/controllers/concerns/hancock/errors.rb +5 -7
  25. data/app/controllers/hancock/registrations_controller.rb +2 -7
  26. data/app/controllers/hancock/sessions_controller.rb +3 -7
  27. data/app/helpers/hancock/powered_helper.rb +3 -3
  28. data/app/helpers/hancock/settings_helper.rb +44 -0
  29. data/app/helpers/rails_admin/application/hancock_helper.rb +19 -0
  30. data/app/helpers/rails_admin/hancock/form_builder.rb +44 -0
  31. data/app/helpers/rails_admin/main/hancock_helper.rb +51 -0
  32. data/app/models/concerns/hancock/boolean_field.rb +7 -2
  33. data/app/models/concerns/hancock/decorators/embedded_element.rb +1 -9
  34. data/app/models/concerns/hancock/enableable.rb +1 -0
  35. data/app/models/concerns/hancock/hash_field.rb +9 -8
  36. data/app/models/concerns/hancock/html_field.rb +6 -3
  37. data/app/models/concerns/hancock/insertion_field.rb +115 -0
  38. data/app/models/concerns/hancock/mappable.rb +1 -0
  39. data/app/models/concerns/hancock/master_collection.rb +31 -0
  40. data/app/models/concerns/hancock/model_localizeable.rb +4 -1
  41. data/app/models/concerns/hancock/rails_admin_patch.rb +22 -3
  42. data/app/models/concerns/hancock/sort_field.rb +26 -3
  43. data/app/models/concerns/hancock/sortable.rb +3 -0
  44. data/app/models/concerns/hancock/user_defined.rb +53 -0
  45. data/app/views/blocks/_footer.html.slim +1 -1
  46. data/app/views/devise/passwords/edit.html.slim +0 -2
  47. data/app/views/devise/passwords/new.html.slim +0 -2
  48. data/app/views/devise/registrations/edit.html.slim +0 -2
  49. data/app/views/devise/registrations/new.html.slim +0 -2
  50. data/app/views/devise/sessions/new.html.slim +0 -2
  51. data/app/views/hancock/home/index.html.slim +4 -1
  52. data/app/views/layouts/application.html.slim +1 -11
  53. data/app/views/layouts/hancock/_assets.html.slim +15 -0
  54. data/app/views/layouts/hancock/devise/confirmations.html.slim +7 -4
  55. data/app/views/layouts/hancock/devise/passwords.html.slim +7 -4
  56. data/app/views/layouts/hancock/devise/registrations.html.slim +7 -4
  57. data/app/views/layouts/hancock/devise/sessions.html.slim +7 -4
  58. data/app/views/layouts/hancock/devise/unlocks.html.slim +7 -4
  59. data/app/views/layouts/rails_admin/_footer.html.slim +2 -2
  60. data/app/views/layouts/rails_admin/_footer_navigation.html.slim +20 -4
  61. data/app/views/layouts/rails_admin/_navigation.html.slim +13 -47
  62. data/app/views/layouts/rails_admin/_secondary_navigation.html.slim +5 -12
  63. data/app/views/layouts/rails_admin/_sidebar_navigation.html.slim +2 -0
  64. data/app/views/layouts/rails_admin/_sidebar_navigation_filter.html.slim +3 -0
  65. data/app/views/layouts/rails_admin/application.html.haml +3 -38
  66. data/app/views/rails_admin/main/_enum_for_settings_kinds.html.slim +24 -0
  67. data/app/views/rails_admin/main/_form_hancock_enum.html.slim +18 -0
  68. data/app/views/rails_admin/main/_form_hancock_enum_with_custom.slim +20 -0
  69. data/app/views/rails_admin/main/_hancock_html.html.slim +2 -2
  70. data/app/views/rails_admin/main/_hancock_html_ml.html.slim +31 -34
  71. data/app/views/rails_admin/main/edit.html.haml +18 -0
  72. data/app/views/rails_admin/main/new.html.haml +17 -0
  73. data/app/views/shared/_admin_link.html.slim +4 -2
  74. data/config/initializers/nested_set_patch.rb +76 -73
  75. data/config/initializers/rails_admin_mongoid_patch.rb +27 -0
  76. data/config/initializers/sprockets_patch.rb +159 -0
  77. data/config/locales/en.hancock.yml +1 -0
  78. data/config/locales/ru.devise.yml +22 -18
  79. data/config/locales/ru.hancock.yml +5 -5
  80. data/config/locales/ru.rails_admin.yml +3 -0
  81. data/hancock_cms.gemspec +7 -2
  82. data/lib/filename_to_slug.rb +0 -20
  83. data/lib/generators/hancock/cms/ability_generator.rb +1 -0
  84. data/lib/generators/hancock/cms/admin_generator.rb +1 -0
  85. data/lib/generators/hancock/cms/application_generator.rb +1 -0
  86. data/lib/generators/hancock/cms/assets_generator.rb +1 -0
  87. data/lib/generators/hancock/cms/layout_generator.rb +1 -0
  88. data/lib/generators/hancock/cms/model_generator.rb +1 -0
  89. data/lib/generators/hancock/cms/models/templates/embedded_element.erb +2 -2
  90. data/lib/generators/hancock/cms/rack_generator.rb +1 -0
  91. data/lib/generators/hancock/cms/raven_generator.rb +13 -0
  92. data/lib/generators/hancock/cms/robots_generator.rb +1 -0
  93. data/lib/generators/hancock/cms/scripts_generator.rb +1 -0
  94. data/lib/generators/hancock/cms/setup_generator.rb +146 -33
  95. data/lib/generators/hancock/cms/templates/Gemfile.erb +4 -5
  96. data/lib/generators/hancock/cms/templates/ability.erb +1 -1
  97. data/lib/generators/hancock/cms/templates/admin.erb +12 -4
  98. data/lib/generators/hancock/cms/templates/hancock_cms.erb +6 -3
  99. data/lib/generators/hancock/cms/templates/model.erb +5 -6
  100. data/lib/generators/hancock/cms/templates/raven.erb +13 -0
  101. data/lib/generators/hancock/cms/templates/robots.txt.erb +6 -2
  102. data/lib/generators/hancock/cms/templates/scripts/db_dump.sh.erb +1 -1
  103. data/lib/generators/hancock/cms/unicorn_god_generator.rb +1 -0
  104. data/lib/generators/hancock/cms/utils.rb +2 -0
  105. data/lib/hancock/admin.rb +153 -21
  106. data/lib/hancock/admin/embedded_element.rb +7 -2
  107. data/lib/hancock/configuration.rb +49 -4
  108. data/lib/hancock/controller.rb +1 -1
  109. data/lib/hancock/engine.rb +32 -36
  110. data/lib/hancock/model.rb +10 -0
  111. data/lib/hancock/models/embedded_element.rb +2 -0
  112. data/lib/hancock/models/mongoid/embedded_element.rb +17 -0
  113. data/lib/hancock/plugin_configuration.rb +1 -1
  114. data/lib/hancock/rails_admin_ext/config.rb +21 -4
  115. data/lib/hancock/rails_admin_ext/hancock_array.rb +19 -0
  116. data/lib/hancock/rails_admin_ext/hancock_enum.rb +33 -0
  117. data/lib/hancock/rails_admin_ext/hancock_enum_with_custom.rb +34 -0
  118. data/lib/hancock/rails_admin_ext/hancock_hash.rb +8 -1
  119. data/lib/hancock/rails_admin_ext/hancock_html.rb +17 -2
  120. data/lib/hancock/rails_admin_ext/hancock_multiselect.rb +1 -5
  121. data/lib/hancock/rails_admin_ext/hancock_slugs.rb +2 -6
  122. data/lib/hancock/rails_admin_ext/patches/field_patch.rb +2 -1
  123. data/lib/hancock/rails_admin_ext/patches/fieldset_patch.rb +14 -0
  124. data/lib/hancock/rails_admin_ext/patches/group_patch.rb +9 -0
  125. data/lib/hancock/rails_admin_ext/patches/hancock_cms_group.rb +2 -0
  126. data/lib/hancock/rails_admin_ext/patches/has_fields.rb +27 -0
  127. data/lib/hancock/rails_admin_ext/patches/navigation_patch.rb +25 -0
  128. data/lib/hancock/rails_admin_settings_patch.rb +219 -0
  129. data/lib/hancock/version.rb +1 -1
  130. data/lib/hancock_cms.rb +12 -9
  131. data/lib/manual_slug/active_record.rb +8 -8
  132. data/lib/manual_slug/mongoid.rb +6 -1
  133. data/lib/rails_admin/custom_show_in_app.rb +21 -32
  134. data/template.rb +19 -20
  135. metadata +104 -12
  136. data/app/controllers/concerns/hancock/no_cache.rb +0 -12
  137. data/app/models/concerns/hancock/cacheable.rb +0 -51
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '0596d7c61478cd10684f4d1c9c9b5361de0f3de5'
4
- data.tar.gz: 4f4c14ff3ddf539e96ea445df5d0510986c7d4a8
3
+ metadata.gz: 4912054bea60590ecbd372be1f315ef3230246f4
4
+ data.tar.gz: 4d32710a18c75fbce14b1eb1ae6be18b09fa82e6
5
5
  SHA512:
6
- metadata.gz: 0747b77095baeadfe3bcd8c0dbc427234a2eb569586264bad110e5cc1d1e09fc971df94a63ddd0bbef331727fd0d065e4781a47d389943e9311dc45be81fcf1d
7
- data.tar.gz: ef3f1fbd6012aecc0eecae628dc76365d60653e6b94525e670c4dafc6253bae1506bc3858633f05bab3ab7ead7046ef79d7b9504ab744a3e0c54e5d43d3ee7d3
6
+ metadata.gz: 38d71b778e00c74795b10862124398f9b2d6c84caf7f3918896b9497ed58a822d32e7e46e820df24cf2db648a8e7d67e61ac6293b9c0df4955766491b4a15912
7
+ data.tar.gz: 639647f5db3c1bc0b480a1e8935bcdbb1dc2f95d9e1b8c9322b2aed2b84c90acfe09b35bd859530e698447a26e7471fb48b2ce964d67b032b66ab19e880d35f7
data/.gitattributes ADDED
@@ -0,0 +1,4 @@
1
+ .ruby-gemset merge=ours
2
+ .ruby-version merge=ours
3
+ .README.md merge=ours
4
+ release.sh merge=ours
@@ -1,4 +1,4 @@
1
- #= require jquery
1
+ #= require jquery2
2
2
  #= require jquery_ujs
3
3
 
4
4
  # require turbolinks
@@ -1,43 +1,17 @@
1
- #= require jquery.mCustomScrollbar.concat.min
1
+ #= require_self
2
2
 
3
- window.hancock_cms ||= {}
4
- window.hancock_cms.multiselect_dblclick = (selector)->
5
- $(document).delegate selector + ' .ra-multiselect-left select option', 'dblclick', (e)->
6
- $(e.currentTarget).closest('.ra-multiselect').find('.ra-multiselect-center .ra-multiselect-item-add').click()
7
-
8
- $(document).delegate selector + ' .ra-multiselect-right select option', 'dblclick', (e)->
9
- $(e.currentTarget).closest('.ra-multiselect').find('.ra-multiselect-center .ra-multiselect-item-remove').click()
10
-
11
- window.hancock_cms.multiselect_dblclick("select.hancock_multiselect + .ra-multiselect")
3
+ #= require jquery.sticky-kit.js
12
4
 
5
+ #= require ./form_controls_fixed
6
+ #= require ./leftside_hider
13
7
 
14
- $(document).delegate '.toolbar .nav .dropdown-header', 'click', (e)->
15
- e.preventDefault()
16
- _target = $(e.currentTarget).toggleClass('opened')
17
- li = _target.next()
18
- loop
19
- li.toggleClass('visible')
20
- li = li.next()
21
- break if li.length == 0 or li.hasClass('dropdown-header')
8
+ #= require ./navigation_dropdown
9
+ #= require ./navigation_scroll
10
+ #= require ./navigation_filter
22
11
 
23
- $(document).on 'pjax:complete ready', ()->
24
- active_nav_element = $(".toolbar .nav .active")
25
- if active_nav_element.length > 0
26
- _parent = active_nav_element.prevAll(".dropdown-header:first")
27
- if _parent.length > 0 and !_parent.hasClass('opened')
28
- _parent.click()
12
+ #= require ./multiselect
13
+ #= require ./enum_with_custom
29
14
 
30
- mscroll = () ->
31
- $('.toolbar').mCustomScrollbar(
32
- scrollInertia: 60
33
- mouseWheelPixels: 60
34
- theme: 'minimal'
35
- mouseWheel:
36
- scrollAmount: 0
37
- )
15
+ #= require ./plugins
38
16
 
39
- $(window).on 'load', ->
40
- mscroll()
41
-
42
- $(document).bind "page:load", ->
43
- mscroll()
17
+ window.hancock_cms ||= {}
@@ -0,0 +1,90 @@
1
+ window.hancock_cms ||= {}
2
+ window.hancock_cms.en_ru_keytable = {
3
+ "q": "й", "Q": "Й",
4
+ "w": "ц", "W": "Ц",
5
+ "e": "у", "E": "У",
6
+ "r": "к", "R": "К",
7
+ "t": "е", "T": "Е",
8
+ "y": "н", "Y": "Н",
9
+ "u": "г", "U": "Г",
10
+ "i": "ш", "I": "Ш",
11
+ "o": "щ", "O": "Щ",
12
+ "p": "з", "P": "З",
13
+ "[": "х", "{": "Х",
14
+ "]": "ъ", "}": "Ъ",
15
+
16
+ "a": "ф", "A": "Ф",
17
+ "s": "ы", "S": "Ы",
18
+ "d": "в", "D": "В",
19
+ "f": "а", "F": "А",
20
+ "g": "п", "G": "П",
21
+ "h": "р", "H": "Р",
22
+ "j": "о", "J": "О",
23
+ "k": "л", "K": "Л",
24
+ "l": "д", "L": "Д",
25
+ ";": "ж", ":": "Ж",
26
+ "'": "э", '"': "Э",
27
+
28
+ "z": "я", "Z": "Я",
29
+ "x": "ч", "X": "Ч",
30
+ "c": "с", "C": "С",
31
+ "v": "м", "V": "М",
32
+ "b": "и", "B": "И",
33
+ "n": "т", "N": "Т",
34
+ "m": "ь", "M": "Ь",
35
+ ",": "б", "<": "Б",
36
+ ".": "ю", ">": "Ю",
37
+ # "/": ".", "?": ","
38
+ }
39
+ window.hancock_cms.ru_en_keytable = {
40
+ "й": "q", "Й": "Q",
41
+ "ц": "w", "Ц": "W",
42
+ "у": "e", "У": "E",
43
+ "к": "r", "К": "R",
44
+ "е": "t", "Е": "T",
45
+ "н": "y", "Н": "Y",
46
+ "г": "u", "Г": "U",
47
+ "ш": "i", "Ш": "I",
48
+ "щ": "o", "Щ": "O",
49
+ "з": "p", "З": "P",
50
+ # "х": "[", "Х": "{",
51
+ # "ъ": "]", "Ъ": "}",
52
+
53
+ "ф": "a", "Ф": "A",
54
+ "ы": "s", "Ы": "S",
55
+ "в": "d", "В": "D",
56
+ "а": "f", "А": "F",
57
+ "п": "g", "П": "G",
58
+ "р": "h", "Р": "H",
59
+ "о": "j", "О": "J",
60
+ "л": "k", "Л": "K",
61
+ "д": "l", "Д": "L",
62
+ # "ж": ";", "Ж": ":",
63
+ # "э": "'", "Э": '"',
64
+
65
+ "я": "z", "Я": "Z",
66
+ "ч": "x", "Ч": "X",
67
+ "с": "c", "С": "C",
68
+ "м": "v", "М": "V",
69
+ "и": "b", "И": "B",
70
+ "т": "n", "Т": "N",
71
+ "ь": "m", "Ь": "M",
72
+ # "б": ",", "Б": "<",
73
+ # "ю": ".", "Ю": ">",
74
+ # ".": "/", ",": "?"
75
+ }
76
+
77
+ window.hancock_cms.ru_en_change_string = (str)->
78
+ new_str = ""
79
+
80
+ for letter in str
81
+ letter_change = hancock_cms.ru_en_keytable[letter]
82
+ new_str += letter_change || letter
83
+
84
+ if new_str == str
85
+ new_str = ""
86
+ for letter in str
87
+ letter_change = hancock_cms.en_ru_keytable[letter]
88
+ new_str += letter_change || letter
89
+
90
+ new_str
@@ -0,0 +1,42 @@
1
+ window.hancock_cms.set_enum_with_custom = () ->
2
+ $('.hancock_enum_with_custom_type .ra-filtering-select-input, .hancock_array_type .ra-filtering-select-input').autocomplete(
3
+ search: (e, ui)->
4
+ if e.currentTarget
5
+ $(e.currentTarget).closest(".controls").find("select.hancock_enum option:first").val(e.currentTarget.value).text(e.currentTarget.value)
6
+ _src = $(e.currentTarget).closest(".controls").find("select.hancock_enum option").map( ->
7
+ { label: $(this).text(), value: $(this).text() }
8
+ ).toArray();
9
+ $(e.currentTarget).closest(".controls").find("select").data('raFilteringSelect').options.source = _src
10
+ )
11
+ $('.hancock_enum_with_custom_type .ra-multiselect-search, .hancock_array_type .ra-multiselect-search').on('keydown', (e)->
12
+ return true if e.ctrlKey
13
+ if e.which == 13
14
+ e.preventDefault()
15
+ me = $(e.currentTarget)
16
+ new_item_text = me.val().trim()
17
+ return false if new_item_text.length == 0
18
+ parent_block = me.closest(".ra-multiselect")
19
+ left_collection = parent_block.find(".ra-multiselect-left .ra-multiselect-collection")
20
+ found_item = null
21
+ left_collection.find("option").each ->
22
+ found_item = $(this) if this.value == new_item_text
23
+ return !found_item
24
+ unless found_item
25
+ if parent_block.siblings("[data-filteringmultiselect][data-unique=true]").length > 0
26
+ right_collection = parent_block.find(".ra-multiselect-right .ra-multiselect-selection")
27
+ right_collection.find("option").each ->
28
+ found_item = $(this) if this.value == new_item_text
29
+ return !found_item
30
+ return false if found_item
31
+ left_collection.append(found_item = $('<option></option>').attr('value', new_item_text).attr('title', new_item_text).text(new_item_text))
32
+ found_item.prop('selected', true).trigger('dblclick')
33
+
34
+ return false
35
+ ).each ->
36
+ onclick = '$(this).siblings(".ra-multiselect-search").trigger($.Event("keydown", {which: 13}));return false;'
37
+ # onclick = '$(this).siblings(".ra-multiselect-search").keydown({which: 13});return false;'
38
+ $(this).after("<a class='hancock_enum_with_custom_type_add_button' href='#' onclick='" + onclick + "' title='Добавить'>+</a>")
39
+
40
+
41
+ $(document).on 'rails_admin.dom_ready', ->
42
+ window.hancock_cms.set_enum_with_custom()
@@ -0,0 +1,44 @@
1
+ $(document).on "click", "#form_controls_fixed a", (e)->
2
+ e.preventDefault()
3
+ $(e.currentTarget).data('target').click()
4
+ return false
5
+
6
+ $(document).on 'rails_admin.dom_ready', ->
7
+ return if $("#form_controls_fixed").length > 0
8
+ $('form .form-actions').each ->
9
+ me = $(this)
10
+ form = me.closest("form")
11
+ buttons = me.find("button")
12
+ form.append("<div id='form_controls_fixed'></div>")
13
+ form_controls_fixed = form.find("#form_controls_fixed")
14
+ buttons.each ->
15
+ clone_link = $("<a href='#' class='clone" + $(this).attr( 'name' ) + "' title='" + $(this).text() + "'></a>")
16
+ clone_link.data('target', $(this))
17
+ form_controls_fixed.append(clone_link)
18
+ ## load CKEDITOR env for user ckeditor assets loading anythere
19
+ $(document).on 'rails_admin.dom_ready', ->
20
+ # return if $("#form_controls_fixed").length > 0
21
+ # $editors = $('[data-richtext=ckeditor]').not('.ckeditored')
22
+ # if $editors.length
23
+ # if not window.CKEDITOR
24
+ # options = $editors.first().data('options')
25
+ # window.CKEDITOR_BASEPATH = options['base_location']
26
+ # $.getScript options['jspath'], (script, textStatus, jqXHR) ->
27
+ if window.CKEDITOR
28
+ window.CKEDITOR.dtd.$removeEmpty[tag] = false for tag of window.CKEDITOR.dtd.$removeEmpty
29
+
30
+ $(document).on "keydown", 'form', (e)->
31
+ if e.ctrlKey and e.keyCode == 13
32
+ form = $(e.currentTarget)
33
+ # maybe try this conditions
34
+ # # form.prop('id').startsWith("edit_")
35
+ # # form.prop('id').startsWith("edit_")
36
+ # button = form.find("[type='submit'][name='_add_edit']")
37
+ # button = form.find("[type='submit'][name='_add_another']") if button.length == 0
38
+ # button = form.find("[type='submit'][name='_save']") if button.length == 0
39
+ button = form.find("[type='submit'][name='_save']")
40
+ if button.length > 0
41
+ button.click()
42
+ else
43
+ form.submit()
44
+ return false
@@ -0,0 +1,106 @@
1
+ $(document).on "rails_admin.dom_ready", ->
2
+ _offsettop = $(window).height() / 2 - 63
3
+ $('.scroll_fieldset_block').each ->
4
+ me = $(this)
5
+ me.stick_in_parent(
6
+ offset_top: _offsettop
7
+ )
8
+
9
+ $(document).on "mouseenter", "fieldset", (e)->
10
+ $(e.currentTarget).addClass("hover")
11
+
12
+ $(document).on "mouseleave", "fieldset", (e)->
13
+ $(e.currentTarget).removeClass("hover")
14
+
15
+
16
+ $(document).on "click", "fieldset .leftside_hider", (e)->
17
+ e.preventDefault()
18
+ fieldset = $(e.currentTarget).closest('fieldset')
19
+ fieldset.find('legend:visible').click()
20
+ return false
21
+
22
+
23
+ $(document).on "click", "fieldset .leftside_hider .scroll_fieldset_top", (e)->
24
+ e.preventDefault()
25
+ fieldset = $(e.currentTarget).closest('fieldset')
26
+ start_position = window.scrollY
27
+ finish_position = fieldset.offset().top - 60
28
+ return false if start_position < finish_position
29
+ speed = 1.7 # px/msec
30
+ duration = Math.abs((finish_position - start_position) / speed)
31
+ $("html, body").animate({scrollTop: finish_position}, duration);
32
+ return false
33
+
34
+
35
+ $(document).on "click", "fieldset .leftside_hider .scroll_fieldset_bottom", (e)->
36
+ e.preventDefault()
37
+ fieldset = $(e.currentTarget).closest('fieldset')
38
+ start_position = window.scrollY
39
+ finish_position = fieldset.next().offset().top - $(window).height() + 35 # 35px - offset-bottom
40
+ return false if start_position > finish_position
41
+ speed = 1.7 # px/msec
42
+ duration = 300 #Math.abs((finish_position - start_position) / speed)
43
+ $("html, body").animate({scrollTop: finish_position}, duration);
44
+ return false
45
+
46
+
47
+ $(document).on "click", "fieldset .leftside_hider .select_fieldset", (e)->
48
+ e.preventDefault()
49
+ me = $(e.currentTarget)
50
+ fieldset = me.closest('fieldset')
51
+ fieldsets = fieldset.siblings('fieldset').andSelf()
52
+ fieldset_links = []
53
+ fieldsets.each ->
54
+ f = $(this)
55
+ l = $(this).find("legend:first")
56
+ if f[0] == fieldset[0]
57
+ fieldset_link = $("<span></span>").attr("title", l.text()).text(l.text())
58
+ else
59
+ fieldset_link = $("<a></a>").attr("title", l.text()).attr("href", '#').text(l.text()).data('target', f)
60
+
61
+ fieldset_links.push(fieldset_link)
62
+ me.html("").append(fieldset_links).addClass('links-list')
63
+ # css(width: "auto", display: 'inline-flex')
64
+ # me.html("").append(fieldset_links).css(width: fieldset_links.length * 60 + "px")
65
+ return false
66
+
67
+
68
+ $(document).delegate ".scroll_fieldset_block", "mouseleave", (e)->
69
+ me = $(e.currentTarget).find('.select_fieldset')
70
+ me.html("<i class='fa fa-indent'></i>").removeClass('links-list')
71
+ return false
72
+
73
+ $(document).on "click", ".form-horizontal legend", (e)->
74
+ fieldset = $(this).closest("fieldset")
75
+ if $(this).has('i.icon-chevron-down').length
76
+ fieldset.addClass('opened')
77
+ fieldset.find('.scroll_fieldset_block').css(position: '', top: '').trigger("sticky_kit:recalc")
78
+ else
79
+ if $(this).has('i.icon-chevron-right').length
80
+ fieldset.removeClass('opened')
81
+
82
+
83
+ $(document).on "click", "fieldset .leftside_hider .select_fieldset a", (e)->
84
+ e.preventDefault()
85
+ e.stopImmediatePropagation()
86
+ hide_previous = false #true
87
+ me = $(e.currentTarget)
88
+ fieldset = $(me.closest('fieldset'))
89
+ fieldsets = fieldset.siblings('fieldset').andSelf()
90
+ target = $(me.data('target'))
91
+ me.closest('select_fieldset').html("SF").css(width: "")
92
+ target_position = $(fieldsets[0]).offset().top
93
+ for i in [0..fieldsets.length]
94
+ fs = $(fieldsets[i])
95
+ if fs[0] == target[0]
96
+ break
97
+ if hide_previous and fieldset[0] == fs[0]
98
+ target_position += 30
99
+ else
100
+ target_position += fs.height()
101
+ target_position -= 60
102
+
103
+ fieldset.find("legend:visible").click() if fieldset.hasClass('opened') if hide_previous
104
+ target.find("legend:visible").click() unless target.hasClass('opened')
105
+ $("html, body").animate({scrollTop: target_position}, 300);
106
+ return false
@@ -0,0 +1,8 @@
1
+ window.hancock_cms.multiselect_dblclick = (selector)->
2
+ $(document).on 'dblclick', selector + ' .ra-multiselect-left select option', (e)->
3
+ $(e.currentTarget).closest('.ra-multiselect').find('.ra-multiselect-center .ra-multiselect-item-add').click()
4
+
5
+ $(document).on 'dblclick', selector + ' .ra-multiselect-right select option', (e)->
6
+ $(e.currentTarget).closest('.ra-multiselect').find('.ra-multiselect-center .ra-multiselect-item-remove').click()
7
+
8
+ window.hancock_cms.multiselect_dblclick("select.hancock_multiselect + .ra-multiselect, select.hancock_enum + .ra-multiselect")
@@ -0,0 +1,25 @@
1
+ $(document).on 'click', '.toolbar .nav .dropdown-header', (e)->
2
+ e.preventDefault()
3
+ _target = $(e.currentTarget).toggleClass('opened')
4
+ li = _target.next()
5
+ loop
6
+ li.toggleClass('visible')
7
+ if _target.hasClass('forced-closed')
8
+ li.addClass('forced-closed')
9
+ else
10
+ li.removeClass('forced-closed')
11
+ if _target.hasClass('forced-opened')
12
+ li.addClass('forced-opened')
13
+ else
14
+ li.removeClass('forced-opened')
15
+
16
+ li = li.next()
17
+ break if li.length == 0 or li.hasClass('dropdown-header')
18
+
19
+
20
+ $(document).on 'rails_admin.dom_ready', ->
21
+ active_nav_element = $(".toolbar .nav .active")
22
+ if active_nav_element.length > 0
23
+ _parent = active_nav_element.prevAll(".dropdown-header:first")
24
+ if _parent.length > 0 and !_parent.hasClass('opened')
25
+ _parent.click()
@@ -0,0 +1,108 @@
1
+ #= require ./en_ru_switcher
2
+
3
+ $(document).on 'click', '.clear_navigation_filter_field', (e)->
4
+ e.preventDefault()
5
+ $("#navigation_filter").val("").trigger("keyup")
6
+ return false
7
+
8
+ $(document).on 'keydown', '#navigation_filter', (e)->
9
+ _code = e.which || e.keyCode
10
+ if _code == 13 or _code == 39 or _code == 37
11
+ _navig = $(e.currentTarget).parent().siblings('.toolbar').find('.nav')
12
+ return true if _navig.find("li:visible").length == 0 and _code != 13
13
+ if (_selected = _navig.find("li.current_selected")).length == 1
14
+ if _selected.find("a").length > 0
15
+ _selected.find('a').click()
16
+ else
17
+ if _selected.hasClass('opened')
18
+ _selected.addClass('forced-closed').removeClass('forced-opened').click()
19
+ else
20
+ return true if _code == 37
21
+ _selected.removeClass('forced-closed').addClass('forced-opened').click()
22
+ else
23
+ return true if _code == 37
24
+ if (_selected = _navig.find('li.visible[data-model]')).length == 1
25
+ _selected.find('a').click()
26
+ else
27
+ return true if _code == 39
28
+
29
+
30
+ e.preventDefault()
31
+ return false
32
+ else
33
+ if _code == 38 or _code == 40
34
+ e.preventDefault()
35
+ if $('#navigation_filter').val().length == 0
36
+ _possible_li_selector = "li.dropdown-header, li.visible"
37
+ else
38
+ _possible_li_selector = "li.opened, li.opened-filtered, li.visible"
39
+ _navig = $(e.currentTarget).parent().siblings('.toolbar')
40
+ _visibled = _navig.find(".nav").find(_possible_li_selector)
41
+ _current = _visibled.filter(".current_selected")
42
+ _navig.find(".nav li").removeClass("current_selected")
43
+ if _code == 38 # up
44
+ if _current.length == 0
45
+ _current = _visibled.last()
46
+ else
47
+ _current = _current.prevAll(_possible_li_selector).first()
48
+ _current = _visibled.last() if _current.length == 0
49
+ else
50
+ if _current.length == 0
51
+ # # if we want select first child of single visible .dropdown-header
52
+ # if _visibled.filter(".dropdown-header").length == 1
53
+ # _current = _visibled.filter(".dropdown-header").nextAll(".visible").first()
54
+ # else
55
+ # _current = _visibled.first()
56
+ # _current ||= _visibled.first()
57
+ _current = _visibled.first()
58
+ else
59
+ _current = _current.nextAll(_possible_li_selector).first()
60
+ _current = _visibled.first() if _current.length == 0
61
+ _current.addClass("current_selected")
62
+ return false
63
+
64
+ else
65
+ $(e.currentTarget).parent().siblings('.toolbar').find(".nav li").removeClass('forced-closed').removeClass('forced-opened')
66
+ return true
67
+
68
+
69
+
70
+
71
+ $(document).on 'keyup', '#navigation_filter', (e)->
72
+ filter = e.currentTarget.value
73
+ navigation_block = $(e.currentTarget).parent().siblings('.toolbar').find('.nav')
74
+ nav_first_lvl = navigation_block.find("li.dropdown-header:not(.forced-closed, .forced-opened)").removeClass('hidden').removeClass('opened').removeClass('opened-filtered')
75
+ nav_sec_lvl = navigation_block.find("li[data-model]:not(.forced-closed, .forced-opened)").removeClass('hidden').removeClass('visible')
76
+ select_menu_items = (filter, nav_first_lvl, nav_sec_lvl)->
77
+ if filter.length > 0
78
+ filter = new RegExp(filter, "i")
79
+
80
+ nav_first_lvl.each ->
81
+ me = $(this)
82
+ if !filter.test(me.html())
83
+ me.addClass("hidden")
84
+ else
85
+ me.addClass("opened").addClass("opened-filtered")
86
+
87
+ nav_sec_lvl.each ->
88
+ me = $(this)
89
+ return me.addClass("visible") if me.prevAll(".dropdown-header").first().hasClass('opened-filtered')
90
+ if !filter.test(me.find('a').text()) and !filter.test(me.data('model')) and !filter.test(me.data('name-synonyms') || "")
91
+ me.addClass("hidden")
92
+ else
93
+ me.addClass('visible').prevAll(".dropdown-header").first().removeClass('hidden').addClass('opened')
94
+
95
+ select_menu_items(filter, nav_first_lvl, nav_sec_lvl)
96
+ if navigation_block.find("li:visible").length == 0
97
+ nav_first_lvl.removeClass('hidden').removeClass('opened')
98
+ nav_sec_lvl.removeClass('hidden').removeClass('visible')
99
+ select_menu_items(window.hancock_cms.ru_en_change_string(filter), nav_first_lvl, nav_sec_lvl)
100
+
101
+ window.hancock_cms.navigation_mscroll()
102
+
103
+
104
+
105
+ $(document).on "rails_admin.dom_ready", ->
106
+ _search_field = $('form #filters_box ~ .input-group [type="search"][name="query"]:not(:focus)')
107
+ _val = _search_field.val()
108
+ _search_field.focus().val("").val(_val)