alchemy_cms 3.4.2 → 3.5.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +9 -3
  3. data/.teatro.yml +1 -0
  4. data/.travis.yml +14 -17
  5. data/CHANGELOG.md +44 -6
  6. data/Gemfile +7 -4
  7. data/README.md +60 -10
  8. data/Rakefile +1 -1
  9. data/alchemy_cms.gemspec +5 -8
  10. data/app/assets/javascripts/alchemy/admin.js +2 -0
  11. data/app/assets/javascripts/alchemy/alchemy.dialog.js.coffee +1 -0
  12. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +1 -0
  13. data/app/assets/javascripts/alchemy/alchemy.hotkeys.js.coffee +1 -1
  14. data/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee +9 -7
  15. data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +1 -0
  16. data/app/assets/javascripts/alchemy/alchemy.preview_window.js.coffee +11 -7
  17. data/app/assets/javascripts/alchemy/alchemy.sitemap.js.coffee +1 -1
  18. data/app/assets/javascripts/alchemy/alchemy.tinymce.js.coffee +8 -3
  19. data/app/assets/javascripts/alchemy/alchemy.tooltips.coffee +10 -0
  20. data/app/assets/javascripts/alchemy/alchemy.uploader.js.coffee +104 -73
  21. data/app/assets/stylesheets/alchemy/_defaults.scss +1 -4
  22. data/app/assets/stylesheets/alchemy/_extends.scss +13 -35
  23. data/app/assets/stylesheets/alchemy/_mixins.scss +82 -18
  24. data/app/assets/stylesheets/alchemy/_variables.scss +21 -8
  25. data/app/assets/stylesheets/alchemy/admin.scss +4 -0
  26. data/app/assets/stylesheets/alchemy/archive.scss +8 -12
  27. data/app/assets/stylesheets/alchemy/attachments.scss +39 -0
  28. data/app/assets/stylesheets/alchemy/base.scss +26 -15
  29. data/app/assets/stylesheets/alchemy/buttons.scss +59 -31
  30. data/app/assets/stylesheets/alchemy/dashboard.scss +3 -3
  31. data/app/assets/stylesheets/alchemy/dialogs.scss +10 -8
  32. data/app/assets/stylesheets/alchemy/elements.scss +65 -41
  33. data/app/assets/stylesheets/alchemy/errors.scss +7 -0
  34. data/app/assets/stylesheets/alchemy/flash.scss +1 -1
  35. data/app/assets/stylesheets/alchemy/form_fields.scss +0 -37
  36. data/app/assets/stylesheets/alchemy/forms.scss +18 -27
  37. data/app/assets/stylesheets/alchemy/frame.scss +104 -204
  38. data/app/assets/stylesheets/alchemy/hints.scss +62 -0
  39. data/app/assets/stylesheets/alchemy/icon-font.scss +2 -1
  40. data/app/assets/stylesheets/alchemy/icons.scss +9 -4
  41. data/app/assets/stylesheets/alchemy/image_library.scss +6 -6
  42. data/app/assets/stylesheets/alchemy/jquery-ui.scss +6 -4
  43. data/app/assets/stylesheets/alchemy/lists.scss +0 -1
  44. data/app/assets/stylesheets/alchemy/menubar.scss +3 -4
  45. data/app/assets/stylesheets/alchemy/modules.scss +0 -6
  46. data/app/assets/stylesheets/alchemy/navigation.scss +242 -0
  47. data/app/assets/stylesheets/alchemy/pagination.scss +3 -3
  48. data/app/assets/stylesheets/alchemy/print.scss +1 -0
  49. data/app/assets/stylesheets/alchemy/resource_info.scss +45 -0
  50. data/app/assets/stylesheets/alchemy/search.scss +72 -1
  51. data/app/assets/stylesheets/alchemy/selects.scss +38 -44
  52. data/app/assets/stylesheets/alchemy/sitemap.scss +89 -79
  53. data/app/assets/stylesheets/alchemy/tables.scss +6 -10
  54. data/app/assets/stylesheets/alchemy/toolbar.scss +7 -36
  55. data/app/assets/stylesheets/alchemy/upload.scss +12 -3
  56. data/app/assets/stylesheets/tinymce/skins/alchemy/content.min.css.scss +6 -3
  57. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce-small.svg +58 -170
  58. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce-small.ttf +0 -0
  59. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce-small.woff +0 -0
  60. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce.svg +124 -148
  61. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce.ttf +0 -0
  62. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce.woff +0 -0
  63. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +426 -144
  64. data/app/controllers/alchemy/admin/attachments_controller.rb +24 -16
  65. data/app/controllers/alchemy/admin/clipboard_controller.rb +1 -1
  66. data/app/controllers/alchemy/admin/essence_files_controller.rb +1 -1
  67. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +9 -8
  68. data/app/controllers/alchemy/admin/layoutpages_controller.rb +1 -0
  69. data/app/controllers/alchemy/admin/pages_controller.rb +2 -2
  70. data/app/controllers/alchemy/admin/resources_controller.rb +2 -2
  71. data/app/controllers/alchemy/admin/tags_controller.rb +1 -1
  72. data/app/controllers/alchemy/api/pages_controller.rb +16 -0
  73. data/app/controllers/alchemy/messages_controller.rb +1 -1
  74. data/app/controllers/concerns/alchemy/admin/uploader_responses.rb +2 -2
  75. data/app/helpers/alchemy/admin/attachments_helper.rb +11 -0
  76. data/app/helpers/alchemy/admin/base_helper.rb +37 -4
  77. data/app/helpers/alchemy/admin/contents_helper.rb +11 -4
  78. data/app/helpers/alchemy/admin/elements_helper.rb +0 -19
  79. data/app/helpers/alchemy/admin/essences_helper.rb +7 -30
  80. data/app/helpers/alchemy/admin/navigation_helper.rb +13 -51
  81. data/app/helpers/alchemy/admin/pages_helper.rb +21 -16
  82. data/app/helpers/alchemy/admin/pictures_helper.rb +9 -0
  83. data/app/helpers/alchemy/deprecated_pages_helper.rb +54 -0
  84. data/app/helpers/alchemy/essences_helper.rb +1 -1
  85. data/app/helpers/alchemy/pages_helper.rb +8 -109
  86. data/app/helpers/alchemy/url_helper.rb +8 -13
  87. data/app/models/alchemy/attachment.rb +7 -4
  88. data/app/models/alchemy/cell.rb +2 -2
  89. data/app/models/alchemy/content.rb +2 -2
  90. data/app/models/alchemy/content/factory.rb +12 -9
  91. data/app/models/alchemy/element.rb +6 -3
  92. data/app/models/alchemy/essence_file.rb +1 -1
  93. data/app/models/alchemy/essence_picture.rb +37 -47
  94. data/app/models/alchemy/essence_picture_view.rb +8 -1
  95. data/app/models/alchemy/folded_page.rb +3 -2
  96. data/app/models/alchemy/legacy_page_url.rb +3 -3
  97. data/app/models/alchemy/page.rb +50 -5
  98. data/app/models/alchemy/page/fixed_attributes.rb +63 -0
  99. data/app/models/alchemy/page/page_elements.rb +10 -7
  100. data/app/models/alchemy/page/page_natures.rb +19 -0
  101. data/app/models/alchemy/picture.rb +1 -0
  102. data/app/models/alchemy/picture/transformations.rb +1 -1
  103. data/app/models/alchemy/picture/url.rb +82 -0
  104. data/app/serializers/alchemy/page_tree_serializer.rb +29 -8
  105. data/app/views/alchemy/_edit_mode.html.erb +2 -0
  106. data/app/views/alchemy/_menubar.html.erb +1 -1
  107. data/app/views/alchemy/_preview_mode_code.html.erb +6 -0
  108. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +1 -1
  109. data/app/views/alchemy/admin/attachments/_attachment.html.erb +25 -5
  110. data/app/views/alchemy/admin/attachments/_replace_button.html.erb +26 -0
  111. data/app/views/alchemy/admin/attachments/index.html.erb +1 -1
  112. data/app/views/alchemy/admin/attachments/show.html.erb +52 -0
  113. data/app/views/alchemy/admin/elements/_element_header.html.erb +6 -3
  114. data/app/views/alchemy/admin/elements/create.js.erb +0 -2
  115. data/app/views/alchemy/admin/elements/trash.js.erb +0 -1
  116. data/app/views/alchemy/admin/elements/update.js.erb +0 -2
  117. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +1 -4
  118. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +1 -1
  119. data/app/views/alchemy/admin/languages/index.html.erb +1 -0
  120. data/app/views/alchemy/admin/layoutpages/_layoutpage.html.erb +26 -27
  121. data/app/views/alchemy/admin/layoutpages/edit.html.erb +1 -1
  122. data/app/views/alchemy/admin/pages/_form.html.erb +13 -40
  123. data/app/views/alchemy/admin/pages/_locked_page.html.erb +1 -1
  124. data/app/views/alchemy/admin/pages/_page.html.erb +119 -61
  125. data/app/views/alchemy/admin/pages/_page_for_links.html.erb +4 -2
  126. data/app/views/alchemy/admin/pages/_page_infos.html.erb +12 -12
  127. data/app/views/alchemy/admin/pages/_page_status.html.erb +1 -1
  128. data/app/views/alchemy/admin/pages/_publication_fields.html.erb +35 -0
  129. data/app/views/alchemy/admin/pages/edit.html.erb +13 -2
  130. data/app/views/alchemy/admin/pages/index.html.erb +3 -8
  131. data/app/views/alchemy/admin/pages/info.html.erb +15 -2
  132. data/app/views/alchemy/admin/pages/sort.js.erb +1 -1
  133. data/app/views/alchemy/admin/pages/update.js.erb +1 -14
  134. data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +12 -8
  135. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +4 -4
  136. data/app/views/alchemy/admin/partials/_search_form.html.erb +1 -1
  137. data/app/views/alchemy/admin/partials/_sub_navigation.html.erb +9 -6
  138. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +1 -1
  139. data/app/views/alchemy/admin/pictures/_picture.html.erb +1 -6
  140. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -6
  141. data/app/views/alchemy/admin/pictures/index.html.erb +1 -1
  142. data/app/views/alchemy/admin/pictures/show.html.erb +1 -6
  143. data/app/views/alchemy/admin/uploader/_button.html.erb +4 -4
  144. data/app/views/alchemy/base/500.html.erb +15 -1
  145. data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +13 -15
  146. data/app/views/alchemy/essences/_essence_boolean_view.html.erb +1 -3
  147. data/app/views/alchemy/essences/_essence_date_editor.html.erb +0 -2
  148. data/app/views/alchemy/essences/_essence_date_view.html.erb +0 -2
  149. data/app/views/alchemy/essences/_essence_file_editor.html.erb +2 -7
  150. data/app/views/alchemy/essences/_essence_file_view.html.erb +1 -3
  151. data/app/views/alchemy/essences/_essence_html_editor.html.erb +0 -2
  152. data/app/views/alchemy/essences/_essence_html_view.html.erb +1 -3
  153. data/app/views/alchemy/essences/_essence_link_editor.html.erb +0 -2
  154. data/app/views/alchemy/essences/_essence_link_view.html.erb +0 -2
  155. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +47 -49
  156. data/app/views/alchemy/essences/_essence_picture_view.html.erb +1 -3
  157. data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +0 -2
  158. data/app/views/alchemy/essences/_essence_richtext_view.html.erb +1 -3
  159. data/app/views/alchemy/essences/_essence_select_editor.html.erb +27 -29
  160. data/app/views/alchemy/essences/_essence_select_view.html.erb +1 -3
  161. data/app/views/alchemy/essences/_essence_text_editor.html.erb +17 -19
  162. data/app/views/alchemy/essences/_essence_text_view.html.erb +0 -2
  163. data/app/views/alchemy/pages/_meta_data.html.erb +9 -0
  164. data/app/views/layouts/alchemy/admin.html.erb +9 -11
  165. data/bin/alchemy +1 -2
  166. data/config/alchemy/config.yml +1 -1
  167. data/config/alchemy/modules.yml +0 -16
  168. data/config/initializers/dragonfly.rb +0 -18
  169. data/config/initializers/mini_profiler.rb +6 -0
  170. data/config/locales/alchemy.de.yml +9 -1
  171. data/config/locales/alchemy.en.yml +7 -1
  172. data/config/locales/alchemy.es.yml +6 -0
  173. data/config/locales/alchemy.fr.yml +2 -0
  174. data/config/locales/alchemy.it.yml +3 -1
  175. data/config/locales/alchemy.nl.yml +2 -0
  176. data/config/locales/alchemy.ru.yml +2 -0
  177. data/config/routes.rb +3 -8
  178. data/db/migrate/20160912223112_add_index_to_alchemy_pages_rgt.rb +9 -0
  179. data/db/migrate/20160927205604_add_foreign_key_indices_and_null_constraints.rb +20 -0
  180. data/db/migrate/20160928080104_add_foreign_keys.rb +27 -0
  181. data/lib/alchemy/admin/locale.rb +4 -3
  182. data/lib/alchemy/engine.rb +2 -4
  183. data/lib/alchemy/errors.rb +9 -2
  184. data/lib/alchemy/forms/builder.rb +8 -0
  185. data/lib/alchemy/modules.rb +20 -19
  186. data/lib/alchemy/permissions.rb +15 -4
  187. data/lib/alchemy/resources_helper.rb +4 -2
  188. data/lib/alchemy/sass_support.rb +9 -0
  189. data/lib/alchemy/seeder.rb +89 -1
  190. data/lib/alchemy/test_support/essence_shared_examples.rb +2 -0
  191. data/lib/alchemy/test_support/factories/attachment_factory.rb +1 -1
  192. data/lib/alchemy/test_support/factories/content_factory.rb +1 -0
  193. data/lib/alchemy/test_support/factories/element_factory.rb +1 -0
  194. data/lib/alchemy/test_support/factories/picture_factory.rb +1 -1
  195. data/lib/alchemy/test_support/fixtures/image.png +0 -0
  196. data/lib/alchemy/tinymce.rb +2 -6
  197. data/lib/alchemy/upgrader.rb +4 -55
  198. data/lib/alchemy/upgrader/tasks/install_dragonfly_config.rb +14 -0
  199. data/lib/alchemy/upgrader/three_point_five.rb +32 -0
  200. data/lib/alchemy/upgrader/three_point_four.rb +2 -8
  201. data/lib/alchemy/upgrader/three_point_one.rb +30 -30
  202. data/lib/alchemy/upgrader/three_point_three.rb +31 -31
  203. data/lib/alchemy/upgrader/three_point_two.rb +25 -25
  204. data/lib/alchemy/upgrader/three_point_zero.rb +59 -59
  205. data/lib/alchemy/version.rb +1 -1
  206. data/lib/rails/generators/alchemy/elements/templates/view.html.erb +1 -1
  207. data/lib/rails/generators/alchemy/elements/templates/view.html.haml +1 -1
  208. data/lib/rails/generators/alchemy/elements/templates/view.html.slim +1 -1
  209. data/lib/rails/generators/alchemy/essence/templates/editor.html.erb +1 -3
  210. data/lib/rails/generators/alchemy/install/files/_article_view.html.erb +1 -1
  211. data/lib/rails/generators/alchemy/install/files/application.html.erb +3 -4
  212. data/lib/rails/generators/alchemy/install/install_generator.rb +4 -0
  213. data/lib/rails/generators/alchemy/install/templates/dragonfly.rb.tt +35 -0
  214. data/lib/rails/generators/alchemy/module/module_generator.rb +1 -1
  215. data/lib/tasks/alchemy/db.rake +6 -0
  216. data/lib/tasks/alchemy/tidy.rake +85 -0
  217. data/lib/tasks/alchemy/upgrade.rake +165 -16
  218. data/vendor/assets/javascripts/clipboard.min.js +7 -0
  219. data/vendor/assets/javascripts/fileupload/jquery.fileupload-process.js +4 -4
  220. data/vendor/assets/javascripts/fileupload/jquery.fileupload-validate.js +2 -2
  221. data/vendor/assets/javascripts/fileupload/jquery.fileupload.js +29 -14
  222. data/vendor/assets/javascripts/fileupload/jquery.iframe-transport.js +2 -2
  223. data/vendor/assets/javascripts/tinymce/langs/es.js +2 -2
  224. data/vendor/assets/javascripts/tinymce/langs/fr.js +1 -1
  225. data/vendor/assets/javascripts/tinymce/langs/it.js +1 -1
  226. data/vendor/assets/javascripts/tinymce/langs/nl.js +3 -3
  227. data/vendor/assets/javascripts/tinymce/tinymce.min.js +15 -12
  228. metadata +44 -88
  229. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/readme.md +0 -1
  230. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce-small.eot +0 -0
  231. data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce.eot +0 -0
  232. data/app/assets/stylesheets/tinymce/skins/alchemy/img/wline.gif +0 -0
  233. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.ie7.min.css +0 -1
  234. data/app/controllers/alchemy/pictures_controller.rb +0 -97
  235. data/app/views/alchemy/admin/elements/_refresh_editor.js.erb +0 -8
  236. data/vendor/assets/javascripts/tinymce/plugins/anchor/plugin.min.js +0 -1
  237. data/vendor/assets/javascripts/tinymce/plugins/autoresize/plugin.min.js +0 -1
  238. data/vendor/assets/javascripts/tinymce/plugins/charmap/plugin.min.js +0 -1
  239. data/vendor/assets/javascripts/tinymce/plugins/code/plugin.min.js +0 -1
  240. data/vendor/assets/javascripts/tinymce/plugins/directionality/plugin.min.js +0 -1
  241. data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.min.js +0 -1
  242. data/vendor/assets/javascripts/tinymce/plugins/hr/plugin.min.js +0 -1
  243. data/vendor/assets/javascripts/tinymce/plugins/link/plugin.min.js +0 -1
  244. data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.min.js +0 -1
  245. data/vendor/assets/javascripts/tinymce/plugins/tabfocus/plugin.min.js +0 -1
  246. data/vendor/assets/javascripts/tinymce/plugins/table/plugin.min.js +0 -1
  247. data/vendor/assets/javascripts/tinymce/themes/modern/theme.min.js +0 -1
@@ -157,6 +157,7 @@ class window.Alchemy.LinkDialog extends Alchemy.Dialog
157
157
 
158
158
  # Handles actions for internal link tab.
159
159
  selectInternalLinkTab: ->
160
+ return unless @$link
160
161
  url = @$link.attr('href').split('#')
161
162
  urlname = url[0]
162
163
  anchor = url[1]
@@ -1,6 +1,8 @@
1
1
  window.Alchemy = {} if typeof(window.Alchemy) is 'undefined'
2
2
 
3
3
  Alchemy.PreviewWindow =
4
+ MIN_WIDTH: 240
5
+ HEIGHT: 75 # Top menu height
4
6
 
5
7
  init: (url) ->
6
8
  $iframe = $("<iframe name=\"alchemy_preview_window\" src=\"#{url}\" id=\"alchemy_preview_window\" frameborder=\"0\"/>")
@@ -14,13 +16,9 @@ Alchemy.PreviewWindow =
14
16
  @resize()
15
17
 
16
18
  resize: ->
17
- $window = $(window)
18
- if Alchemy.ElementsWindow.hidden
19
- width = $window.width() - 64
20
- else
21
- width = $window.width() - 466
22
- height = $window.height() - 73
23
- width = 240 if width < 240
19
+ width = @_calculateWidth()
20
+ height = $(window).height() - @HEIGHT
21
+ width = @MIN_WIDTH if width < @MIN_WIDTH
24
22
  @currentWidth = width
25
23
  @currentWindow.css
26
24
  width: width
@@ -54,5 +52,11 @@ Alchemy.PreviewWindow =
54
52
  $reload.click =>
55
53
  @refresh()
56
54
 
55
+ _calculateWidth: ->
56
+ width = $(window).width() - $('#left_menu').width()
57
+ unless Alchemy.ElementsWindow.hidden
58
+ width -= $('#alchemy_elements_window').width()
59
+ return width
60
+
57
61
  Alchemy.reloadPreview = ->
58
62
  Alchemy.PreviewWindow.refresh()
@@ -7,7 +7,7 @@ Alchemy.Sitemap =
7
7
 
8
8
  # Storing some objects.
9
9
  init: (options) ->
10
- @search_field = $("#search_field")
10
+ @search_field = $(".search_input_field")
11
11
  @filter_field_clear = $('.js_filter_field_clear')
12
12
  @display = $('#page_filter_result')
13
13
  @sitemap_wrapper = $('#sitemap-wrapper p.loading')
@@ -45,7 +45,11 @@ $.extend Alchemy.Tinymce,
45
45
  # - Editor id that should be initialized.
46
46
  #
47
47
  initEditor: (id) ->
48
- textarea = $("#tinymce_#{id}")
48
+ editor_id = "tinymce_#{id}"
49
+ textarea = $("##{editor_id}")
50
+ editor = tinymce.get(editor_id)
51
+ # remove editor instance, if already initialized
52
+ editor.remove() if editor
49
53
  if textarea.length == 0
50
54
  Alchemy.log_error "Could not initialize TinyMCE for textarea#tinymce_#{id}!"
51
55
  return
@@ -63,7 +67,7 @@ $.extend Alchemy.Tinymce,
63
67
  $this = $("##{inst.id}")
64
68
  parent = $this.closest('.element-editor')
65
69
  parent.find('.spinner').remove()
66
- inst.on 'change', (e) ->
70
+ inst.on 'dirty', (e) ->
67
71
  Alchemy.setElementDirty(parent)
68
72
 
69
73
  # Removes the TinyMCE editor from given dom ids.
@@ -77,6 +81,7 @@ $.extend Alchemy.Tinymce,
77
81
  # Remove all tinymce instances for given selector
78
82
  removeFrom: (selector) ->
79
83
  $(selector).each ->
80
- tinymce.get(this.id).remove()
84
+ elem = tinymce.get(this.id)
85
+ elem.remove() if elem
81
86
  return
82
87
  return
@@ -0,0 +1,10 @@
1
+ window.Alchemy = {} if typeof(window.Alchemy) is 'undefined'
2
+
3
+ Alchemy.Tooltips = (scope) ->
4
+ $('[data-alchemy-tooltip]', scope).each ->
5
+ $el = $(this)
6
+ text = $el.data('alchemy-tooltip')
7
+ $el.wrap('<span class="with-hint"/>')
8
+ $el.after('<span class="hint-bubble">'+text+'</span>')
9
+ return
10
+ return
@@ -10,6 +10,9 @@ window.Alchemy = {} if typeof(window.Alchemy) is 'undefined'
10
10
  Alchemy.Uploader = (settings) ->
11
11
  totalFilesCount = 0
12
12
  completedUploads = 0
13
+ $filesContainer = $('.upload-progress-container')
14
+ selector = settings.selector || '.fileupload'
15
+ $fields = $(selector)
13
16
  $dropZone = $(settings.dropzone)
14
17
 
15
18
  # Normalize file types regex
@@ -22,79 +25,107 @@ Alchemy.Uploader = (settings) ->
22
25
  $dropZone.on 'dragleave', ->
23
26
  $dropZone.removeClass('dragover')
24
27
 
25
- # Init jquery.fileupload
26
- $(".fileupload").fileupload
27
- dropZone: $dropZone
28
- dataType: 'json'
29
- filesContainer: $('.upload-progress-container')
30
- acceptFileTypes: new RegExp("(.|/)(#{file_types})", "i")
31
- maxNumberOfFiles: Alchemy.uploader_defaults.file_upload_limit
32
- maxFileSize: Alchemy.uploader_defaults.file_size_limit * 1000000
33
- getNumberOfFiles: ->
34
- @filesContainer
35
- .children()
36
- .not('.progress-bar-in-progress').length - 1
37
- dragover: ->
38
- $dropZone.addClass('dragover')
39
- add: (e, data) ->
40
- $this = $(this)
41
- data.context = new Alchemy.FileProgress(data.files[0])
42
- totalFilesCount = data.originalFiles.length
43
- $('.total-files-count').text(totalFilesCount)
44
- $dropZone.removeClass('dragover').addClass('upload-in-progress')
45
- $('.overall-upload').addClass('visible')
46
- # trigger validations
47
- data.process -> $this.fileupload('process', data)
48
- if data.files.error
49
- data.context.setError()
50
- data.context.setStatus(data.files[0].error)
51
- data.context.$fileProgressCancel.click (e) ->
52
- e.preventDefault()
53
- data.context.setCancelled()
54
- data.context.setStatus('cancelled')
55
- false
56
- false
57
- else
58
- xhr = data.submit()
59
- data.context.$fileProgressCancel.click (e) ->
60
- e.preventDefault()
61
- xhr.abort()
62
- data.context.setCancelled()
63
- data.context.setStatus('cancelled')
64
- false
65
- xhr
66
- progress: (e, data) ->
67
- progress = parseInt(data.loaded / data.total * 100, 10)
68
- data.context.setProgress(progress)
69
- progressall: (e, data) ->
70
- progress = parseInt(data.loaded / data.total * 100, 10)
71
- bar = $('.overall-upload .progress')
72
- bar.css width: "#{progress}%"
73
- $('.progress-status').text("#{progress}%")
74
- done: (e, data) ->
75
- completedUploads += 1
76
- $('.uploaded-files-count').text(completedUploads)
77
- data.context.setComplete()
78
- data.context.setStatus('complete')
79
- response_data = data.xhr().response
80
- if completedUploads == totalFilesCount
81
- completedUploads = 0
82
- totalFilesCount = 0
83
- $('.overall-upload').removeClass('visible')
84
- settings.complete()
85
- fail: (e, data) ->
28
+ getNumberOfFiles = ->
29
+ $filesContainer
30
+ .children()
31
+ .not('.progress-bar-in-progress').length - 1
32
+
33
+ dragover = ->
34
+ $dropZone.addClass('dragover')
35
+ return
36
+
37
+ add = (e, data) ->
38
+ $this = $(this)
39
+ data.context = new Alchemy.FileProgress(data.files[0])
40
+ totalFilesCount = data.originalFiles.length
41
+ $('.total-files-count').text(totalFilesCount)
42
+ $dropZone.removeClass('dragover').addClass('upload-in-progress')
43
+ $('.overall-upload').addClass('visible')
44
+ # trigger validations
45
+ data.process -> $this.fileupload('process', data)
46
+ if data.files.error
86
47
  data.context.setError()
87
- response_data = data.xhr().response
88
- if response_data
89
- response = JSON.parse(response_data)
90
- error = response.files[0].error
91
- data.context.setStatus(error || data.textStatus)
92
- always: (e, data) ->
93
- xhr = data.xhr()
94
- response_data = xhr.response
95
- if response_data
96
- response = JSON.parse(response_data)
97
- if response.growl_message
98
- Alchemy.growl(response.growl_message, if xhr.status == 422 then 'alert' else 'notice')
48
+ data.context.setStatus(data.files[0].error)
49
+ data.context.$fileProgressCancel.click (e) ->
50
+ data.context.setCancelled()
51
+ data.context.setStatus('cancelled')
52
+ return false
53
+ return false
54
+ else
55
+ xhr = data.submit()
56
+ data.context.$fileProgressCancel.click (e) ->
57
+ xhr.abort()
58
+ data.context.setCancelled()
59
+ data.context.setStatus('cancelled')
60
+ return false
61
+ return xhr
62
+
63
+ progress = (e, data) ->
64
+ progress = parseInt(data.loaded / data.total * 100, 10)
65
+ data.context.setProgress(progress)
66
+ return
67
+
68
+ progressall = (e, data) ->
69
+ progress = parseInt(data.loaded / data.total * 100, 10)
70
+ bar = $('.overall-upload .progress')
71
+ bar.css width: "#{progress}%"
72
+ $('.progress-status').text("#{progress}%")
73
+ return
74
+
75
+ done = (e, data) ->
76
+ completedUploads += 1
77
+ $('.uploaded-files-count').text(completedUploads)
78
+ data.context.setComplete()
79
+ data.context.setStatus('complete')
80
+ response_data = data.xhr().response
81
+ if completedUploads == totalFilesCount
82
+ completedUploads = 0
83
+ totalFilesCount = 0
84
+ $('.overall-upload').removeClass('visible')
85
+ settings.complete()
86
+ return
87
+
88
+ fail = (e, data) ->
89
+ data.context.setError()
90
+ response_data = data.xhr().response
91
+ if response_data
92
+ response = JSON.parse(response_data)
93
+ error = response.files[0].error
94
+ data.context.setStatus(error || data.textStatus)
95
+ return
96
+
97
+ always = (e, data) ->
98
+ xhr = data.xhr()
99
+ response_data = xhr.response
100
+ if response_data
101
+ response = JSON.parse(response_data)
102
+ if response.growl_message
103
+ Alchemy.growl(response.growl_message, if xhr.status == 422 then 'alert' else 'notice')
104
+ return
105
+
106
+ $fields.each ->
107
+ $field = $(this)
108
+ $form = $field.parents('form')
109
+ url = $form.attr('action')
110
+ http_method = $form.find('[name="_method"]').val()
111
+ # Init jquery.fileupload
112
+ $field.fileupload
113
+ url: url
114
+ type: if http_method then http_method.toUpperCase() else 'POST'
115
+ dropZone: $dropZone
116
+ dataType: 'json'
117
+ filesContainer: $filesContainer
118
+ acceptFileTypes: new RegExp("(.|/)(#{file_types})", "i")
119
+ maxNumberOfFiles: Alchemy.uploader_defaults.file_upload_limit
120
+ maxFileSize: Alchemy.uploader_defaults.file_size_limit * 1000000
121
+ getNumberOfFiles: getNumberOfFiles
122
+ dragover: dragover
123
+ add: add
124
+ progress: progress
125
+ progressall: progressall
126
+ done: done
127
+ fail: fail
128
+ always: always
129
+ return
99
130
 
100
131
  return
@@ -1,7 +1,4 @@
1
- @import "compass/css3";
2
- @import "compass/css3/user-interface";
3
- @import "compass/utilities/general/clearfix";
4
- @import "sassy-buttons";
1
+ @import "bourbon";
5
2
  @import "alchemy/variables";
6
3
  @import "alchemy/mixins";
7
4
  @import "alchemy/extends";
@@ -1,5 +1,5 @@
1
1
  %rounded-border {
2
- @include border-radius($default-border-radius);
2
+ border-radius: $default-border-radius;
3
3
  }
4
4
 
5
5
  %text-overflow {
@@ -11,33 +11,6 @@
11
11
  -moz-text-overflow: ellipsis;
12
12
  }
13
13
 
14
- %tooltip {
15
- display: none;
16
- background: $light_yellow;
17
- @extend %rounded-border;
18
- @include box-shadow(0 4px 24px $dark-gray);
19
- position: absolute;
20
- right: -25px;
21
- top: 26px;
22
- z-index: 100;
23
- padding: 8px;
24
- line-height: 1.5em;
25
- min-width: 180px;
26
- font-size: 12px;
27
-
28
- &:before {
29
- content: '';
30
- position: absolute;
31
- top: -8px;
32
- right: 24px;
33
- width: 0px;
34
- height: 0px;
35
- border-style: solid;
36
- border-width: 0 8px 8px 8px;
37
- border-color: transparent transparent $light_yellow transparent;
38
- }
39
- }
40
-
41
14
  %thumbnail-background {
42
15
  display: table-cell;
43
16
  background-color: $dark-gray;
@@ -51,7 +24,7 @@
51
24
  border-color: $error_border_color;
52
25
  color: $error_text_color;
53
26
  background-color: lighten($error_background_color, 8%);
54
- @include box-shadow(inset 1px 1px 4px rgba($error_border_color, 0.5));
27
+ box-shadow: inset 1px 1px 4px rgba($error_border_color, 0.5);
55
28
  }
56
29
 
57
30
  %blue-focus-style {
@@ -59,10 +32,9 @@
59
32
  }
60
33
 
61
34
  %default-input-style {
62
- @include box-sizing(border-box);
63
- $border-inset-color: lighten($default-border-color, 20%);
35
+ box-sizing: border-box;
64
36
  @extend %rounded-border;
65
- @include box-shadow(inset 0px 1px 1px $medium-gray);
37
+ box-shadow: inset 0px 1px 1px $medium-gray;
66
38
  font: $default-font-style;
67
39
  padding: 1px 2*$default-padding;
68
40
  margin: $default-form-field-margin;
@@ -74,7 +46,7 @@
74
46
  width: 100%;
75
47
  font-size: 12px;
76
48
  line-height: 12px;
77
- height: 29px;
49
+ height: $default-form-field-height;
78
50
  @include transition(
79
51
  box-shadow 0.25s ease-in-out,
80
52
  background-color 0.25s ease-in-out,
@@ -84,10 +56,16 @@
84
56
  &:focus {
85
57
  @extend %blue-focus-style;
86
58
  }
59
+
60
+ &[disabled], .disabled {
61
+ color: #888;
62
+ background-color: rgba(#fff, 0.5);
63
+ cursor: not-allowed;
64
+ }
87
65
  }
88
66
 
89
67
  %gradiated-toolbar {
90
- background: $medium-gray;
68
+ background: $toolbar-bg-color;
91
69
  padding: 8px 4px;
92
- height: 29px;
70
+ height: $default-form-field-height;
93
71
  }
@@ -1,6 +1,6 @@
1
1
  @mixin default-focus-style {
2
2
  border-color: $blue;
3
- @include box-shadow(0 0 1px 2px $blue);
3
+ box-shadow: 0 0 1px 1px $blue;
4
4
  outline: none;
5
5
 
6
6
  &::-moz-focus-inner {
@@ -9,10 +9,58 @@
9
9
  }
10
10
  }
11
11
 
12
- @mixin button-defaults {
13
- @include sassy-button('simple', $sb-border-radius, $sb-font-size, $sb-base-color, $sb-second-color, $sb-text-color, $sb-text-style, $sb-pseudo-states, $sb-ie-support);
14
- border-color: $button-border-color;
15
- margin: $default-form-field-margin;
12
+ @mixin button-defaults(
13
+ $first-color: $button-gradient-first-color,
14
+ $second-color: $button-gradient-second-color,
15
+ $border-radius: $default-border-radius,
16
+ $padding: $button-padding,
17
+ $margin: $button-margin) {
18
+ display: inline-block;
19
+ font-size: 12px;
20
+ padding: $padding;
21
+ cursor: pointer;
22
+ border-radius: $border-radius;
23
+ background-color: $button-bg-color;
24
+ background-image: linear-gradient($first-color, $second-color);
25
+ box-shadow: white 0 1px 0 inset;
26
+ border: 1px solid $button-border-color;
27
+ color: $text-color;
28
+ text-shadow: $button-text-shadow;
29
+ margin: $margin;
30
+ @include appearance(none);
31
+
32
+ &:hover {
33
+ text-decoration: none;
34
+ background-color: $button-hover-bg-color;
35
+ background-image: linear-gradient(
36
+ darken($first-color, 5%),
37
+ darken($second-color, 5%)
38
+ );
39
+ border-color: $button-hover-border-color;
40
+ }
41
+
42
+ &:active, &:active:focus {
43
+ box-shadow: #c4c4c4 0 1px 2px inset;
44
+ border-color: $button-border-color;
45
+ }
46
+
47
+ &:focus {
48
+ @include default-focus-style;
49
+ }
50
+
51
+ &.disabled, &[disabled],
52
+ &.disabled:active, &[disabled]:active,
53
+ &.disabled:hover, &[disabled]:hover {
54
+ opacity: 0.6;
55
+ background: $second-color;
56
+ cursor: not-allowed;
57
+ box-shadow: none;
58
+ }
59
+
60
+ &::-moz-focus-inner {
61
+ padding: 0 !important;
62
+ margin: -1px !important;
63
+ }
16
64
  }
17
65
 
18
66
  @mixin default-label-style {
@@ -54,7 +102,7 @@
54
102
  margin: $default-form-field-margin;
55
103
  padding: $default-padding 2*$default-padding;
56
104
  line-height: 21px;
57
- min-height: 29px;
105
+ min-height: $default-form-field-height;
58
106
  background: white;
59
107
  @extend %rounded-border;
60
108
  @extend .border-box-sizing;
@@ -123,17 +171,33 @@
123
171
  }
124
172
 
125
173
  @mixin linked-button($border-radius: $default-border-radius) {
126
- @include sassy-button(
127
- 'matte',
128
- $border-radius,
129
- $sb-font-size,
130
- $linked-button-color,
131
- $sb-second-color,
132
- $sb-text-color,
133
- $sb-text-style,
134
- $sb-pseudo-states,
135
- $sb-ie-support
174
+ @include button-defaults(
175
+ $first-color: $linked-color,
176
+ $second-color: darken($linked-color, 10%),
177
+ $border-radius: $border-radius,
178
+ $padding: 3px,
179
+ $margin: 0
136
180
  );
137
- padding: 3px;
138
- border-color: $default-border-color;
181
+ }
182
+
183
+ @mixin zoom-in {
184
+ cursor: pointer;
185
+ cursor: image-url('alchemy/lupe.cur');
186
+ cursor: -webkit-zoom-in;
187
+ cursor: -moz-zoom-in;
188
+ cursor: zoom-in;
189
+ }
190
+
191
+ @mixin truncate($max-width, $display: inline-block) {
192
+ display: $display;
193
+ max-width: $max-width;
194
+ overflow: hidden;
195
+ text-overflow: ellipsis;
196
+ }
197
+
198
+ @mixin hint-hover-style {
199
+ visibility: visible;
200
+ top: 26px;
201
+ opacity: 1;
202
+ transition-delay: .2s;
139
203
  }