alchemy_cms 2.0.7 → 2.1.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) hide show
  1. data/.gitignore +1 -4
  2. data/.travis.yml +1 -1
  3. data/Gemfile +7 -2
  4. data/README.md +6 -6
  5. data/Rakefile +26 -18
  6. data/alchemy_cms.gemspec +14 -14
  7. data/{assets/stylesheets → app/assets/images/alchemy}/Jcrop.gif +0 -0
  8. data/{assets/images → app/assets/images/alchemy}/ajax_loader.gif +0 -0
  9. data/{assets/images → app/assets/images/alchemy}/alchemy-logo.png +0 -0
  10. data/{assets/images → app/assets/images/alchemy}/flags.png +0 -0
  11. data/{assets/images → app/assets/images/alchemy}/gui/navi-tab.png +0 -0
  12. data/{assets/images → app/assets/images/alchemy}/gui/shading_90.png +0 -0
  13. data/{assets/images → app/assets/images/alchemy}/gui/toggle.png +0 -0
  14. data/{assets/images → app/assets/images/alchemy}/icons.png +0 -0
  15. data/{assets/images → app/assets/images/alchemy}/image_loader.gif +0 -0
  16. data/{assets/images → app/assets/images/alchemy}/jquery-sb/select_arrow.gif +0 -0
  17. data/{assets/images → app/assets/images/alchemy}/jquery-sb/select_arrow_bg.gif +0 -0
  18. data/{assets/images → app/assets/images/alchemy}/jquery-sb/select_arrow_bg_hover.gif +0 -0
  19. data/{assets/images → app/assets/images/alchemy}/placeholder.png +0 -0
  20. data/{assets/images/gui → app/assets/images/alchemy}/shading.png +0 -0
  21. data/{assets/images → app/assets/images/alchemy}/swfupload/browse_button.png +0 -0
  22. data/{assets/stylesheets/default/img → app/assets/images/alchemy}/tabs.gif +0 -0
  23. data/{assets/images/jquery-ui → app/assets/images/alchemy}/ui-icons_666666_256x240.png +0 -0
  24. data/app/assets/javascripts/alchemy/alchemy.base.js +212 -0
  25. data/app/assets/javascripts/alchemy/alchemy.buttons.js +36 -0
  26. data/app/assets/javascripts/alchemy/alchemy.dirty.js +91 -0
  27. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +114 -0
  28. data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.element_editor_selector.js +0 -0
  29. data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.growler.js +0 -0
  30. data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.image_cropper.js +0 -0
  31. data/app/assets/javascripts/alchemy/alchemy.js +26 -0
  32. data/app/assets/javascripts/alchemy/alchemy.js_extensions.js +17 -0
  33. data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.link_overlay.js +1 -1
  34. data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.page_sorter.js +0 -0
  35. data/{assets/javascripts → app/assets/javascripts/alchemy}/alchemy.preview.js +0 -0
  36. data/app/assets/javascripts/alchemy/alchemy.windows.js +438 -0
  37. data/app/assets/stylesheets/alchemy/_defaults.scss +160 -0
  38. data/app/assets/stylesheets/alchemy/alchemy.css +9 -0
  39. data/{assets/stylesheets/alchemy.css → app/assets/stylesheets/alchemy/base.css.scss} +216 -353
  40. data/{assets/stylesheets/elements.css → app/assets/stylesheets/alchemy/elements.css.scss} +41 -70
  41. data/{assets/stylesheets/flags.css → app/assets/stylesheets/alchemy/flags.css.scss} +1 -1
  42. data/{assets/stylesheets/jquery-ui-1.8.7.alchemy.css → app/assets/stylesheets/alchemy/jquery-ui.alchemy.css} +15 -15
  43. data/{assets/stylesheets/jquery.Jcrop.css → app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss} +3 -3
  44. data/{assets/stylesheets/jquery.sb.css → app/assets/stylesheets/alchemy/jquery.sb.css.scss} +19 -29
  45. data/{assets/stylesheets → app/assets/stylesheets/alchemy}/print.css +6 -1
  46. data/{assets/stylesheets → app/assets/stylesheets/alchemy}/standard_set.css +0 -0
  47. data/{assets/stylesheets/alchemy_tinymce_content.css → app/assets/stylesheets/alchemy/tinymce_content.css} +0 -0
  48. data/{assets/stylesheets/alchemy_tinymce_dialog.css → app/assets/stylesheets/alchemy/tinymce_dialog.css} +2 -2
  49. data/app/controllers/admin/attachments_controller.rb +2 -8
  50. data/app/controllers/admin/clipboard_controller.rb +2 -2
  51. data/app/controllers/admin/contents_controller.rb +4 -16
  52. data/app/controllers/admin/elements_controller.rb +2 -2
  53. data/app/controllers/admin/essence_audios_controller.rb +0 -3
  54. data/app/controllers/admin/essence_files_controller.rb +0 -11
  55. data/app/controllers/admin/essence_flashes_controller.rb +0 -3
  56. data/app/controllers/admin/essence_pictures_controller.rb +2 -7
  57. data/app/controllers/admin/essence_videos_controller.rb +0 -3
  58. data/app/controllers/admin/languages_controller.rb +4 -10
  59. data/app/controllers/admin/pages_controller.rb +6 -4
  60. data/app/controllers/admin/pictures_controller.rb +13 -18
  61. data/app/controllers/admin/trash_controller.rb +0 -5
  62. data/app/controllers/admin/users_controller.rb +2 -3
  63. data/app/controllers/alchemy_controller.rb +18 -30
  64. data/app/controllers/pages_controller.rb +21 -24
  65. data/app/helpers/admin/elements_helper.rb +5 -0
  66. data/app/helpers/admin/pages_helper.rb +36 -1
  67. data/app/helpers/alchemy_helper.rb +39 -17
  68. data/app/models/attachment.rb +2 -2
  69. data/app/models/essence_file.rb +1 -1
  70. data/app/models/page.rb +1 -1
  71. data/app/sweepers/pages_sweeper.rb +10 -0
  72. data/app/views/admin/attachments/destroy.js.erb +4 -0
  73. data/app/views/admin/clipboard/insert.js.erb +12 -19
  74. data/app/views/admin/contents/create.js.erb +1 -1
  75. data/app/views/admin/contents/destroy.js.erb +7 -0
  76. data/app/views/admin/contents/order.js.erb +6 -0
  77. data/app/views/admin/elements/_element.html.erb +4 -2
  78. data/app/views/admin/elements/create.js.erb +19 -26
  79. data/app/views/admin/elements/fold.js.erb +1 -1
  80. data/app/views/admin/elements/index.html.erb +1 -1
  81. data/app/views/admin/essence_files/assign.js.erb +8 -0
  82. data/app/views/admin/essence_pictures/save_link.js.erb +3 -0
  83. data/app/views/admin/index.html.erb +37 -27
  84. data/app/views/admin/languages/destroy.js.erb +1 -0
  85. data/app/views/admin/pages/_page.html.erb +1 -1
  86. data/app/views/admin/pages/_sitemap.html.erb +1 -1
  87. data/app/views/admin/pages/edit.html.erb +2 -2
  88. data/app/views/admin/pages/update.js.erb +1 -1
  89. data/app/views/admin/partials/_upload_form.html.erb +11 -11
  90. data/app/views/admin/pictures/archive_overlay.js.erb +1 -0
  91. data/app/views/admin/pictures/flush.js.erb +2 -0
  92. data/app/views/admin/pictures/update.js.erb +1 -0
  93. data/app/views/admin/trash/clear.js.erb +3 -0
  94. data/app/views/alchemy/error_notice.js.erb +1 -0
  95. data/app/views/alchemy/permission_denied.js.erb +2 -0
  96. data/app/views/alchemy/redirect.js.erb +1 -0
  97. data/app/views/alchemy/remote_errors.js.erb +3 -0
  98. data/app/views/alchemy/update.js.erb +5 -0
  99. data/app/views/essences/_essence_file_editor.html.erb +0 -1
  100. data/app/views/essences/_essence_file_view.html.erb +1 -5
  101. data/app/views/essences/_essence_picture_tools.html.erb +1 -1
  102. data/app/views/layouts/alchemy.html.erb +22 -9
  103. data/app/views/pages/show.rss.builder +1 -1
  104. data/config/alchemy/elements.yml +0 -5
  105. data/config/alchemy/page_layouts.yml +1 -1
  106. data/config/asset_packages.yml +17 -19
  107. data/config/authorization_rules.rb +1 -0
  108. data/config/locales/de.yml +0 -1
  109. data/config/routes.rb +1 -1
  110. data/lib/alchemy/tinymce.rb +51 -0
  111. data/lib/alchemy/version.rb +3 -3
  112. data/lib/alchemy_cms.rb +4 -2
  113. data/script/rails +6 -0
  114. data/spec/controllers/admin/clipboard_controller_spec.rb +15 -13
  115. data/spec/controllers/admin/contents_controller_spec.rb +4 -4
  116. data/spec/controllers/admin/trash_controller_spec.rb +6 -9
  117. data/spec/controllers/pages_controller_spec.rb +9 -8
  118. data/spec/dummy/Rakefile +1 -1
  119. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  120. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  121. data/spec/dummy/app/mailers/.gitkeep +0 -0
  122. data/spec/dummy/app/models/.gitkeep +0 -0
  123. data/spec/dummy/app/views/layouts/application.html.erb +3 -3
  124. data/spec/dummy/config/application.rb +12 -6
  125. data/spec/dummy/config/database.yml +3 -0
  126. data/spec/dummy/config/environments/development.rb +7 -3
  127. data/spec/dummy/config/environments/production.rb +23 -12
  128. data/spec/dummy/config/environments/test.rb +5 -1
  129. data/spec/dummy/config/initializers/secret_token.rb +1 -1
  130. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  131. data/spec/dummy/config/locales/en.yml +1 -1
  132. data/spec/dummy/config/routes.rb +1 -1
  133. data/spec/dummy/lib/assets/.gitkeep +0 -0
  134. data/spec/factories.rb +8 -8
  135. data/spec/helpers/admin/elements_helper_spec.rb +2 -2
  136. data/spec/helpers/contents_helper_spec.rb +1 -1
  137. data/spec/helpers/elements_helper_spec.rb +6 -6
  138. data/spec/helpers/essences_helper_spec.rb +1 -1
  139. data/spec/helpers/pages_helper_spec.rb +37 -37
  140. data/spec/integration/pages_controller_spec.rb +29 -26
  141. data/spec/integration/security_spec.rb +2 -1
  142. data/spec/models/content_spec.rb +1 -1
  143. data/spec/models/element_spec.rb +11 -11
  144. data/spec/models/language_spec.rb +5 -5
  145. data/spec/models/page_spec.rb +54 -54
  146. data/spec/models/user_spec.rb +2 -1
  147. data/spec/routing_spec.rb +1 -1
  148. data/{assets/javascripts/jquery.js → vendor/assets/javascripts/jquery-1.6.2.min.js} +0 -0
  149. data/{assets/javascripts/jquery-ui.js → vendor/assets/javascripts/jquery-ui-custom-1.8.16.min.js} +0 -0
  150. data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.Jcrop.min.js +0 -0
  151. data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.dialogextend.min.js +7 -7
  152. data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.in-place-edit.js +0 -0
  153. data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.sb.min.js +0 -0
  154. data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.scrollTo-1.4.2-min.js +10 -10
  155. data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.ui.nestedSortable.js +0 -0
  156. data/{assets/javascripts → vendor/assets/javascripts/jquery_plugins}/jquery.ui.tabspaging.js +0 -0
  157. data/{assets → vendor/assets}/javascripts/swfupload/fileprogress.js +202 -202
  158. data/{assets → vendor/assets}/javascripts/swfupload/handlers.js +171 -171
  159. data/{assets → vendor/assets}/javascripts/swfupload/queue.js +97 -97
  160. data/{assets → vendor/assets}/javascripts/swfupload/swfupload.js +980 -980
  161. data/{assets → vendor/assets}/javascripts/swfupload/swfupload.swf +0 -0
  162. data/{assets → vendor/assets}/javascripts/tiny_mce/jquery.tinymce.js +0 -0
  163. data/{assets → vendor/assets}/javascripts/tiny_mce/langs/de.js +0 -0
  164. data/{assets → vendor/assets}/javascripts/tiny_mce/langs/en.js +0 -0
  165. data/{assets → vendor/assets}/javascripts/tiny_mce/license.txt +504 -504
  166. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/alchemy_link/editor_plugin.js +0 -0
  167. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/alchemy_link/langs/de.js +0 -0
  168. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/alchemy_link/langs/en.js +0 -0
  169. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/autoresize/editor_plugin.js +0 -0
  170. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/fullscreen/editor_plugin.js +0 -0
  171. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/fullscreen/fullscreen.htm +110 -110
  172. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/inlinepopups/editor_plugin.js +0 -0
  173. data/{assets/javascripts/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css → vendor/assets/javascripts/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.erb} +8 -8
  174. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/inlinepopups/template.htm +387 -387
  175. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/editor_plugin.js +0 -0
  176. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/js/pastetext.js +36 -36
  177. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/js/pasteword.js +51 -51
  178. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/langs/de_dlg.js +0 -0
  179. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/langs/en_dlg.js +0 -0
  180. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/pastetext.htm +26 -26
  181. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/paste/pasteword.htm +21 -21
  182. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/cell.htm +180 -180
  183. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/css/cell.css +16 -16
  184. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/css/row.css +25 -25
  185. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/css/table.css +13 -13
  186. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/editor_plugin.js +0 -0
  187. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/js/cell.js +319 -319
  188. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/js/merge_cells.js +27 -27
  189. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/js/row.js +237 -237
  190. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/js/table.js +450 -450
  191. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/langs/de_dlg.js +0 -0
  192. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/langs/en_dlg.js +0 -0
  193. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/merge_cells.htm +32 -32
  194. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/row.htm +158 -158
  195. data/{assets → vendor/assets}/javascripts/tiny_mce/plugins/table/table.htm +188 -188
  196. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/about.htm +52 -52
  197. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/anchor.htm +26 -26
  198. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/charmap.htm +51 -51
  199. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/color_picker.htm +74 -74
  200. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/editor_template.js +0 -0
  201. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/image.htm +80 -80
  202. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/colorpicker.jpg +0 -0
  203. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/flash.gif +0 -0
  204. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/icons.gif +0 -0
  205. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/iframe.gif +0 -0
  206. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/pagebreak.gif +0 -0
  207. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/quicktime.gif +0 -0
  208. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/realmedia.gif +0 -0
  209. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/shockwave.gif +0 -0
  210. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/trans.gif +0 -0
  211. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/video.gif +0 -0
  212. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/img/windowsmedia.gif +0 -0
  213. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/about.js +73 -73
  214. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/anchor.js +43 -43
  215. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/charmap.js +355 -355
  216. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/color_picker.js +329 -329
  217. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/image.js +251 -251
  218. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/link.js +153 -153
  219. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/js/source_editor.js +56 -56
  220. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/langs/de.js +0 -0
  221. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/langs/de_dlg.js +0 -0
  222. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/langs/en.js +0 -0
  223. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/langs/en_dlg.js +0 -0
  224. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/link.htm +57 -57
  225. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/shortcuts.htm +47 -47
  226. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/content.css +50 -50
  227. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/dialog.css +117 -117
  228. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/buttons.png +0 -0
  229. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/items.gif +0 -0
  230. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif +0 -0
  231. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/menu_check.gif +0 -0
  232. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/progress.gif +0 -0
  233. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/img/tabs.gif +0 -0
  234. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/default/ui.css +214 -214
  235. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/content.css +48 -48
  236. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/dialog.css +117 -117
  237. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png +0 -0
  238. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_black.png +0 -0
  239. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_silver.png +0 -0
  240. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui.css +217 -217
  241. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_black.css +7 -7
  242. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css +5 -5
  243. data/{assets → vendor/assets}/javascripts/tiny_mce/themes/advanced/source_editor.htm +25 -25
  244. data/{assets → vendor/assets}/javascripts/tiny_mce/tiny_mce.js +0 -0
  245. data/{assets → vendor/assets}/javascripts/tiny_mce/tiny_mce_popup.js +0 -0
  246. data/{assets → vendor/assets}/javascripts/tiny_mce/utils/editable_selects.js +70 -70
  247. data/{assets → vendor/assets}/javascripts/tiny_mce/utils/form_utils.js +210 -210
  248. data/{assets → vendor/assets}/javascripts/tiny_mce/utils/mctabs.js +161 -161
  249. data/{assets → vendor/assets}/javascripts/tiny_mce/utils/validate.js +252 -252
  250. metadata +338 -369
  251. data/app/views/elements/_download_editor.html.erb +0 -1
  252. data/app/views/elements/_download_view.html.erb +0 -3
  253. data/assets/javascripts/alchemy.js +0 -903
  254. data/assets/javascripts/jquery.rails.js +0 -315
  255. data/assets/stylesheets/ie6.css +0 -18
  256. data/config/initializers/tinymce_hammer.rb +0 -31
@@ -1 +0,0 @@
1
- <%= render_essence_editor_by_name(element, 'file') %>
@@ -1,3 +0,0 @@
1
- <div class="download" <%= element_preview_code(element) -%>>
2
- <%= render_essence_view_by_name(element, 'file') %>
3
- </div>
@@ -1,903 +0,0 @@
1
- if (typeof(Alchemy) === 'undefined') {
2
- var Alchemy = {};
3
- }
4
-
5
- (function ($) {
6
-
7
- // Setting jQueryUIs global animation duration
8
- $.fx.speeds._default = 400;
9
-
10
- // The Alchemy JavaScript Object contains all Functions
11
- $.extend(Alchemy, {
12
-
13
- inPlaceEditor : function (options) {
14
- var defaults = {
15
- save_label: 'save',
16
- cancel_label: 'cancel'
17
- };
18
- var settings = jQuery.extend({}, defaults, options);
19
- var cancel_handler = function(element) {
20
- jQuery(element).css({overflow: 'hidden'});
21
- return true;
22
- };
23
- var submit_handler = function(element, id, value) {
24
- $(element).css({overflow: 'hidden'});
25
- id = parseInt(id.replace(/^image_picture_/, ''));
26
- $.ajax({url:'/admin/pictures/'+id, type: 'PUT', data: {name: value}});
27
- return false;
28
- };
29
-
30
- $('#alchemy .rename').click(function () {
31
- $(this).css({overflow: 'visible'});
32
- });
33
-
34
- $('#alchemy .rename').inPlaceEdit({
35
- submit : submit_handler,
36
- cancel : cancel_handler,
37
- html : ' \
38
- <div class="inplace-edit"> \
39
- <input type="text" value="" class="thin_border field" /> \
40
- <div class="buttons"> \
41
- <input type="button" value="'+settings.save_label+'" class="save-button button" /> \
42
- <input type="button" value="'+settings.cancel_label+'" class="cancel-button button" /> \
43
- </div> \
44
- </div>'
45
- });
46
-
47
- },
48
-
49
- getOverlaySpinner : function (options) {
50
- var defaults = {
51
- x: '47%',
52
- y: '33%'
53
- };
54
- var settings = $.extend({}, defaults, options);
55
- var $spinner = $('<img src="/images/alchemy/ajax_loader.gif" />');
56
- var left = (settings.x - 32) / 2;
57
- var top = ((settings.y - 32) / 2) - 16;
58
- top = top < 0 ? 0 : top;
59
- $spinner.css({
60
- marginLeft: left + 'px',
61
- marginTop: top + 'px'
62
- });
63
- return $spinner;
64
- },
65
-
66
- AjaxErrorHandler : function($dialog, status, textStatus, errorThrown) {
67
- var $div = $('<div class="with_padding" />');
68
- var $errorDiv = $('<div id="errorExplanation" />');
69
- $dialog.html($div);
70
- $div.append($errorDiv);
71
- if (status === 0) {
72
- $errorDiv.append('<h2>The server does not respond!</h2>');
73
- $errorDiv.append('<p>Please start server and try again.</p>');
74
- } else {
75
- $errorDiv.append('<h2>'+errorThrown+' ('+status+')</h2>');
76
- $errorDiv.append('<p>Please check log and try again.</p>');
77
- }
78
- },
79
-
80
- openPreviewWindow : function (url, title) {
81
- var $iframe = $('#alchemyPreviewWindow');
82
- if ($iframe.length === 0) {
83
- $iframe = $('<iframe src="'+url+'" id="alchemyPreviewWindow"></iframe>');
84
- $iframe.load(function() {
85
- $('#preview_load_info').hide();
86
- });
87
- $iframe.css({'background-color': '#ffffff'});
88
- Alchemy.PreviewWindow = $iframe.dialog({
89
- modal: false,
90
- title: title,
91
- width: $(window).width() - 504,
92
- height: $(window).height() - 90,
93
- minWidth: 600,
94
- minHeight: 300,
95
- show: "fade",
96
- hide: "fade",
97
- position: [70, 84],
98
- autoResize: true,
99
- closeOnEscape: false,
100
- create: function() {
101
- var $spinner = $('<img src="/images/alchemy/ajax_loader.gif" alt="" id="preview_load_info" />');
102
- $('#ui-dialog-title-alchemyPreviewWindow').after($spinner);
103
- var $reload = $('<a href="#" class="ui-dialog-titlebar-refresh ui-corner-all" role="button"></a>');
104
- $reload.append('<span class="ui-icon ui-icon-refresh">reload</span>');
105
- $('#ui-dialog-title-alchemyPreviewWindow').after($reload);
106
- $reload.click(Alchemy.reloadPreview);
107
- },
108
- close: function(event, ui) {
109
- Alchemy.PreviewWindowButton.enable();
110
- },
111
- open: function (event, ui) {
112
- $(this).css({width: '100%'});
113
- Alchemy.PreviewWindowButton.disable();
114
- Alchemy.previewWindowFrameWidth = $('#alchemyPreviewWindow').width();
115
- }
116
- }).dialogExtend({
117
- "maximize" : true,
118
- "dblclick" : "maximize",
119
- "events" : {
120
- beforeMaximize: function(evt, dlg) {
121
- Alchemy.previewWindowPosition = $('#alchemyPreviewWindow').dialog('widget').offset();
122
- Alchemy.previewWindowFrameWidth = $('#alchemyPreviewWindow').width();
123
- },
124
- maximize : function(evt, dlg) {
125
- $('#alchemyPreviewWindow').css({width: "100%"});
126
- },
127
- restore : function(evt, dlg) {
128
- $('#alchemyPreviewWindow').dialog('widget').css(Alchemy.previewWindowPosition);
129
- $('#alchemyPreviewWindow').css({width: Alchemy.previewWindowFrameWidth});
130
- }
131
- }
132
- });
133
- } else {
134
- $('#alchemyPreviewWindow').dialog('open');
135
- }
136
- Alchemy.PreviewWindow.refresh = function () {
137
- var $iframe = $('#alchemyPreviewWindow');
138
- $('#preview_load_info').show();
139
- $iframe.load(function() {
140
- $('#preview_load_info').hide();
141
- });
142
- $iframe.attr('src', $iframe.attr('src'));
143
- return true;
144
- };
145
- },
146
-
147
- PreviewWindowExists : function() {
148
- if (Alchemy.PreviewWindow) {
149
- return true;
150
- } else {
151
- return false;
152
- }
153
- },
154
-
155
- reloadPreview : function() {
156
- Alchemy.PreviewWindow.refresh();
157
- },
158
-
159
- ElementsWindowButton : {
160
- enable: function() {
161
- $('div#show_element_window').removeClass('disabled');
162
- },
163
- disable: function() {
164
- $('div#show_element_window').addClass('disabled');
165
- },
166
- toggle: function() {
167
- $('div#show_element_window').toggleClass('disabled');
168
- }
169
- },
170
-
171
- PreviewWindowButton : {
172
- enable: function() {
173
- $('div#show_preview_window').removeClass('disabled');
174
- },
175
- disable: function() {
176
- $('div#show_preview_window').addClass('disabled');
177
- },
178
- toggle: function() {
179
- $('div#show_preview_window').toggleClass('disabled');
180
- }
181
- },
182
-
183
- openElementsWindow : function (path, options) {
184
- var $dialog = $('<div style="display: none" id="alchemyElementWindow"></div>');
185
- var closeCallback = function() {
186
- $dialog.dialog("destroy");
187
- $('#alchemyElementWindow').remove();
188
- Alchemy.ElementsWindowButton.enable();
189
- };
190
- $dialog.html(Alchemy.getOverlaySpinner({x: 420, y: 300}));
191
- Alchemy.ElementsWindow = $dialog.dialog({
192
- modal: false,
193
- minWidth: 422,
194
- minHeight: 300,
195
- height: $(window).height() - 90,
196
- title: options.texts.title,
197
- show: "fade",
198
- hide: "fade",
199
- position: [$(window).width() - 428, 84],
200
- closeOnEscape: false,
201
- create: function() {
202
- $dialog.before(Alchemy.createElementWindowToolbar(options.toolbarButtons));
203
- },
204
- open: function(event, ui) {
205
- Alchemy.ElementsWindowButton.disable();
206
- $.ajax({
207
- url: path,
208
- success: function(data, textStatus, XMLHttpRequest) {
209
- $dialog.html(data);
210
- Alchemy.ButtonObserver('#alchemyElementWindow .button');
211
- },
212
- error: function(XMLHttpRequest, textStatus, errorThrown) {
213
- Alchemy.AjaxErrorHandler($dialog, XMLHttpRequest.status, textStatus, errorThrown);
214
- }
215
- });
216
- },
217
- beforeClose : function() {
218
- if (Alchemy.isPageDirty()) {
219
- Alchemy.openConfirmWindow({
220
- title: options.texts.dirtyTitle,
221
- message: options.texts.dirtyMessage,
222
- okLabel: options.texts.okLabel,
223
- cancelLabel: options.texts.cancelLabel,
224
- okCallback: closeCallback
225
- });
226
- return false;
227
- } else {
228
- return true;
229
- }
230
- },
231
- close: closeCallback
232
- });
233
- },
234
-
235
- createElementWindowToolbar : function(buttons) {
236
- var $toolbar = $('<div id="overlay_toolbar"></div>'), btn;
237
- for (i = 0; i < buttons.length; i++) {
238
- btn = buttons[i];
239
- $toolbar.append(
240
- Alchemy.createToolbarButton({
241
- buttonTitle: btn.title,
242
- buttonLabel: btn.label,
243
- iconClass: btn.iconClass,
244
- onClick: btn.onClick,
245
- buttonId: btn.buttonId
246
- })
247
- );
248
- }
249
- return $toolbar;
250
- },
251
-
252
- createToolbarButton : function(options) {
253
- var $btn = $('<div class="button_with_label"></div>'), $lnk;
254
- if (options.buttonId) $btn.attr({'id': options.buttonId});
255
- $lnk = $('<a title="'+options.buttonTitle+'" class="icon_button"></a>');
256
- $lnk.click(options.onClick);
257
- $lnk.append('<span class="icon '+options.iconClass+'"></span>');
258
- $btn.append($lnk);
259
- $btn.append('<br><label>'+options.buttonLabel+'</label>');
260
- return $btn;
261
- },
262
-
263
- openConfirmWindow : function (options) {
264
- var $confirmation = $('<div style="display:none" id="alchemyConfirmation"></div>');
265
- $confirmation.appendTo('body');
266
- $confirmation.html('<p>'+options.message+'</p>');
267
- Alchemy.ConfirmationWindow = $confirmation.dialog({
268
- resizable: false,
269
- minHeight: 100,
270
- minWidth: 300,
271
- modal: true,
272
- title: options.title,
273
- show: "fade",
274
- hide: "fade",
275
- buttons: [
276
- {
277
- text: options.cancelLabel,
278
- click: function() {
279
- $(this).dialog("close");
280
- }
281
- },
282
- {
283
- text: options.okLabel,
284
- click: function() {
285
- $(this).dialog("close");
286
- options.okCallback();
287
- }
288
- }
289
- ],
290
- open: function () {
291
- Alchemy.ButtonObserver('#alchemyConfirmation .button');
292
- },
293
- close: function() {
294
- $('#alchemyConfirmation').remove();
295
- }
296
- });
297
- },
298
-
299
- confirmToDeleteWindow : function (url, title, message, okLabel, cancelLabel) {
300
- var $confirmation = $('<div style="display:none" id="alchemyConfirmation"></div>');
301
- $confirmation.appendTo('body');
302
- $confirmation.html('<p>'+message+'</p>');
303
- Alchemy.ConfirmationWindow = $confirmation.dialog({
304
- resizable: false,
305
- minHeight: 100,
306
- minWidth: 300,
307
- modal: true,
308
- title: title,
309
- show: "fade",
310
- hide: "fade",
311
- buttons: [
312
- {
313
- text: cancelLabel,
314
- click: function() {
315
- $(this).dialog("close");
316
- }
317
- },
318
- {
319
- text: okLabel,
320
- click: function() {
321
- $(this).dialog("close");
322
- $.ajax({
323
- url: url,
324
- type: 'DELETE'
325
- });
326
- }
327
- }
328
- ],
329
- open: function () {
330
- Alchemy.ButtonObserver('#alchemyConfirmation .button');
331
- },
332
- close: function() {
333
- $('#alchemyConfirmation').remove();
334
- }
335
- });
336
- },
337
-
338
- openWindow : function (action_url, title, size_x, size_y, resizable, modal, overflow) {
339
- overflow == undefined ? overflow = false: overflow = overflow;
340
- if (size_x === 'fullscreen') {
341
- size_x = $(window).width() - 50;
342
- size_y = $(window).height() - 50;
343
- }
344
- var $dialog = $('<div style="display:none" id="alchemyOverlay"></div>');
345
- $dialog.appendTo('body');
346
- $dialog.html(Alchemy.getOverlaySpinner({x: size_x, y: size_y}));
347
-
348
- Alchemy.CurrentWindow = $dialog.dialog({
349
- modal: modal,
350
- minWidth: size_x,
351
- minHeight: size_y > 68 ? size_y : 68,
352
- title: title,
353
- resizable: resizable,
354
- show: "fade",
355
- hide: "fade",
356
- open: function (event, ui) {
357
- $.ajax({
358
- url: action_url,
359
- success: function(data, textStatus, XMLHttpRequest) {
360
- $dialog.html(data);
361
- $dialog.css({overflow: overflow ? 'visible' : 'auto'});
362
- $dialog.dialog('widget').css({overflow: overflow ? 'visible' : 'hidden'});
363
- Alchemy.SelectBox('#alchemyOverlay select');
364
- Alchemy.ButtonObserver('#alchemyOverlay .button');
365
- },
366
- error: function(XMLHttpRequest, textStatus, errorThrown) {
367
- Alchemy.AjaxErrorHandler($dialog, XMLHttpRequest.status, textStatus, errorThrown);
368
- }
369
- });
370
- },
371
- beforeClose: function() {
372
- $(".sb.open").triggerAll("close");
373
- },
374
- close: function () {
375
- $dialog.remove();
376
- }
377
- });
378
- },
379
-
380
- closeCurrentWindow : function() {
381
- if (Alchemy.CurrentWindow) {
382
- Alchemy.CurrentWindow.dialog('close');
383
- Alchemy.CurrentWindow = null;
384
- } else {
385
- $('#alchemyOverlay').dialog('close');
386
- }
387
- return true;
388
- },
389
-
390
- zoomImage : function(url, title, width, height) {
391
- var window_height = height;
392
- var window_width = width;
393
- var $doc_width = $(window).width();
394
- var $doc_height = $(window).height();
395
- if (width > $doc_width) {
396
- window_width = $doc_width - 50;
397
- }
398
- if (height > $doc_height) {
399
- window_height = $doc_height - 50;
400
- }
401
- var $dialog = $('<div style="display:none" id="alchemyOverlay"></div>');
402
- $dialog.appendTo('body');
403
- $dialog.html(Alchemy.getOverlaySpinner({x: width, y: height}));
404
- $dialog.dialog({
405
- modal: false,
406
- minWidth: window_width < 320 ? 320 : window_width,
407
- minHeight: window_height < 240 ? 240 : window_height,
408
- title: title,
409
- show: "fade",
410
- hide: "fade",
411
- open: function (event, ui) {
412
- $.ajax({
413
- url: url,
414
- success: function(data, textStatus, XMLHttpRequest) {
415
- $dialog.html(data);
416
- },
417
- error: function(XMLHttpRequest, textStatus, errorThrown) {
418
- Alchemy.AjaxErrorHandler($dialog, XMLHttpRequest.status, textStatus, errorThrown);
419
- }
420
- });
421
- },
422
- close: function () {
423
- $dialog.remove();
424
- }
425
- });
426
- return false;
427
- },
428
-
429
- openLicencseWindow : function() {
430
- var height = $(window).height() - 150;
431
- var $iframe = $('<iframe src="https://raw.github.com/magiclabs/alchemy_cms/master/LICENSE"></iframe>');
432
- $iframe.dialog({
433
- bgiframe: true,
434
- title: 'Alchemy CMS License',
435
- width: 650,
436
- height: height,
437
- autoResize: true,
438
- close: function(event, ui) { $(this).dialog('destroy'); },
439
- open: function (event, ui) { $(this).css({width: '100%'}); }
440
- });
441
- },
442
-
443
- pleaseWaitOverlay : function(show) {
444
- if (typeof(show) == 'undefined') {
445
- show = true;
446
- }
447
- var $overlay = $('#overlay');
448
- $overlay.css("visibility", show ? 'visible': 'hidden');
449
- },
450
-
451
- toggleElement : function (id, url, token, text) {
452
- var toggle = function() {
453
- $('#element_'+id+'_folder').hide();
454
- $('#element_'+id+'_folder_spinner').show();
455
- $.post(url, {
456
- authenticity_token: encodeURIComponent(token)
457
- }, function(request) {
458
- $('#element_'+id+'_folder').show();
459
- $('#element_'+id+'_folder_spinner').hide();
460
- });
461
- }
462
- if (Alchemy.isPageDirty()) {
463
- Alchemy.openConfirmWindow({
464
- title: text.title,
465
- message: text.message,
466
- okLabel: text.okLabel,
467
- cancelLabel: text.cancelLabel,
468
- okCallback: toggle
469
- });
470
- return false;
471
- } else {
472
- toggle();
473
- }
474
- },
475
-
476
- ListFilter : function(selector) {
477
- var text = $('#search_field').val().toLowerCase();
478
- var $boxes = $(selector);
479
- $boxes.map(function() {
480
- $this = $(this);
481
- $this.css({
482
- display: $this.attr('name').toLowerCase().indexOf(text) != -1 ? '' : 'none'
483
- });
484
- });
485
- },
486
-
487
- fadeImage : function(image, spinner_selector) {
488
- try {
489
- $(spinner_selector).hide();
490
- $(image).fadeIn(600);
491
- } catch(e) {
492
- Alchemy.debug(e);
493
- };
494
- },
495
-
496
- saveElement : function(form) {
497
- var $rtf_contents = $(form).find('div.content_rtf_editor');
498
- if ($rtf_contents.size() > 0) {
499
- $rtf_contents.each(function() {
500
- var id = $(this).children('textarea.tinymce').attr('id');
501
- tinymce.get(id).save();
502
- });
503
- }
504
- },
505
-
506
- setElementSaved : function(selector) {
507
- var $element = $(selector);
508
- Alchemy.setElementClean(selector);
509
- Alchemy.enableButton(selector + ' button.button');
510
- },
511
-
512
- resizeFrame : function() {
513
- var options = {
514
- top: 90,
515
- left: 65,
516
- right: 0
517
- };
518
- var $mainFrame = $('#main_content');
519
- var $topFrame = $('#top_menu');
520
- var view_height = $(window).height();
521
- var view_width = $(window).width();
522
- var mainFrameHeight = view_height - options.top;
523
- var topFrameHeight = options.top;
524
- var width = view_width - options.left - options.right;
525
- if ($mainFrame.length > 0) {
526
- $mainFrame.css({
527
- width: width,
528
- height: mainFrameHeight
529
- });
530
- }
531
- if ($topFrame.length > 0) {
532
- $topFrame.css({
533
- width: width,
534
- height: topFrameHeight
535
- });
536
- }
537
- },
538
-
539
- SortableElements : function(page_id, form_token) {
540
- $('#element_area .sortable_cell').sortable({
541
- items: 'div.element_editor',
542
- handle: '.element_handle',
543
- axis: 'y',
544
- placeholder: 'droppable_element_placeholder',
545
- forcePlaceholderSize: true,
546
- dropOnEmpty: true,
547
- opacity: 0.5,
548
- cursor: 'move',
549
- tolerance: 'pointer',
550
- update: function(event, ui) {
551
- var ids = $.map($(event.target).children(), function(child) {
552
- return $(child).attr('data-element-id');
553
- });
554
- var params_string = '';
555
- var cell_id = $(event.target).attr('data-cell-id');
556
- // Is the trash window open?
557
- if ($('#alchemyTrashWindow').length > 0) {
558
- // updating the trash icon
559
- if ($('#trash_items div.element_editor').not('.dragged').length === 0) {
560
- $('#element_trash_button .icon').removeClass('full');
561
- $('#trash_empty_notice').show();
562
- }
563
- }
564
- $(event.target).css("cursor", "progress");
565
- params_string = "page_id=" + page_id + "&authenticity_token=" + encodeURIComponent(form_token) + "&" + $.param({element_ids: ids});
566
- if (cell_id) {
567
- params_string += "&cell_id=" + cell_id;
568
- }
569
- $.ajax({
570
- url: '/admin/elements/order',
571
- type: 'POST',
572
- data: params_string,
573
- complete: function () {
574
- $(event.target).css("cursor", "auto");
575
- Alchemy.refreshTrashWindow(page_id);
576
- }
577
- });
578
- },
579
- start: function(event, ui) {
580
- var $textareas = ui.item.find('textarea.tinymce');
581
- $textareas.each(function() {
582
- tinymce.get(this.id).remove();
583
- });
584
- },
585
- stop: function(event, ui) {
586
- var $textareas = ui.item.find('textarea.tinymce');
587
- $textareas.each(function() {
588
- TinymceHammer.addEditor(this.id);
589
- });
590
- }
591
- });
592
- },
593
-
594
- openTrashWindow : function (page_id, title) {
595
- var size_x = 380, size_y = 270;
596
- if (size_x === 'fullscreen') {
597
- size_x = $(window).width() - 50;
598
- size_y = $(window).height() - 50;
599
- }
600
- var $dialog = $('<div style="display:none" id="alchemyTrashWindow"></div>');
601
- $dialog.appendTo('body');
602
- $dialog.html(Alchemy.getOverlaySpinner({x: size_x, y: size_y}));
603
-
604
- Alchemy.trashWindow = $dialog.dialog({
605
- modal: false,
606
- width: 380,
607
- minHeight: 450,
608
- maxHeight: $(window).height() - 50,
609
- title: title,
610
- resizable: false,
611
- show: "fade",
612
- hide: "fade",
613
- open: function (event, ui) {
614
- $.ajax({
615
- url: '/admin/trash?page_id=' + page_id,
616
- success: function(data, textStatus, XMLHttpRequest) {
617
- $dialog.html(data);
618
- // Need this for DragnDrop elements into elements window.
619
- // Badly this is screwing up maxHeight option
620
- $dialog.css({overflow: 'visible'}).dialog('widget').css({overflow: 'visible'});
621
- },
622
- error: function(XMLHttpRequest, textStatus, errorThrown) {
623
- Alchemy.AjaxErrorHandler($dialog, XMLHttpRequest.status, textStatus, errorThrown);
624
- }
625
- });
626
- },
627
- close: function () {
628
- $dialog.remove();
629
- }
630
- });
631
- },
632
-
633
- refreshTrashWindow: function(page_id) {
634
- if ($('#alchemyTrashWindow').length > 0) {
635
- $('#alchemyTrashWindow').html(Alchemy.getOverlaySpinner({x: 380, y: 270}));
636
- $.get('/admin/trash?page_id='+page_id, function(html) {
637
- $('#alchemyTrashWindow').html(html);
638
- });
639
- }
640
- },
641
-
642
- SortableContents : function(selector, token) {
643
- $(selector).sortable({
644
- items: 'div.dragable_picture',
645
- handle: 'div.picture_handle',
646
- placeholder: 'droppable_content_placeholder',
647
- opacity: 0.5,
648
- cursor: 'move',
649
- tolerance: 'pointer',
650
- containment: 'parent',
651
- update: function(event, ui) {
652
- var ids = $.map($(event.target).children('div.dragable_picture'), function (child) {
653
- return child.id.replace(/essence_picture_/, '');
654
- });
655
- $(event.originalTarget).css("cursor", "progress");
656
- $.ajax({
657
- url: '/admin/contents/order',
658
- type: 'POST',
659
- data: "authenticity_token=" + encodeURIComponent(token) + "&" + $.param({content_ids: ids}),
660
- complete: function () {
661
- $(event.originalTarget).css("cursor", "move");
662
- }
663
- });
664
- }
665
- });
666
- },
667
-
668
- Tooltips : function() {
669
- var xOffset = 10;
670
- var yOffset = 20;
671
- $(".tooltip").hover(function(e) {
672
- this.original_title = this.title;
673
- if (this.original_title == '') {
674
- this.tooltip_content = $(this).next('.tooltip_content').html();
675
- } else {
676
- this.tooltip_content = this.original_title;
677
- }
678
- if (this.tooltip_content != null) {
679
- this.title = "";
680
- $("body").append("<div id='tooltip'>"+ this.tooltip_content +"</div>");
681
- $("#tooltip")
682
- .css("top",(e.pageY - xOffset) + "px")
683
- .css("left",(e.pageX + yOffset) + "px")
684
- .fadeIn(400);
685
- }
686
- },
687
- function() {
688
- this.title = this.original_title;
689
- $("#tooltip").remove();
690
- });
691
- $(".tooltip").mousemove(function(e) {
692
- $("#tooltip")
693
- .css("top",(e.pageY - xOffset) + "px")
694
- .css("left",(e.pageX + yOffset) + "px");
695
- });
696
- },
697
-
698
- SelectBox : function(selector) {
699
- $(selector).sb({animDuration: 0, fixedWidth: true});
700
- },
701
-
702
- Buttons : function(options) {
703
- $("button, input:submit, a.button").button(options);
704
- },
705
-
706
- ElementDirtyObserver : function(selector) {
707
- var $elements = $(selector);
708
- $elements.find('textarea.tinymce').map(function() {
709
- var $this = $(this);
710
- var ed = tinymce.get(this.id);
711
- ed.onChange.add(function(ed, l) {
712
- Alchemy.setElementDirty($this.parents('.element_editor'));
713
- });
714
- });
715
- $elements.find('input[type="text"]').bind('change', function() {
716
- $(this).addClass('dirty');
717
- Alchemy.setElementDirty($(this).parents('.element_editor'));
718
- });
719
- $elements.find('.element_foot input[type="checkbox"]').bind('click', function() {
720
- $(this).addClass('dirty');
721
- Alchemy.setElementDirty($(this).parents('.element_editor'));
722
- });
723
- $elements.find('select').bind('change', function() {
724
- $(this).addClass('dirty');
725
- Alchemy.setElementDirty($(this).parents('.element_editor'));
726
- });
727
- },
728
-
729
- setElementDirty : function(element) {
730
- var $element = $(element);
731
- $element.addClass('dirty');
732
- $element.find('.element_head .icon').addClass('element_dirty');
733
- },
734
-
735
- setElementClean : function(element) {
736
- var $element = $(element);
737
- $element.removeClass('dirty');
738
- $element.find('.element_foot input[type="checkbox"]').removeClass('dirty');
739
- $element.find('input[type="text"]').removeClass('dirty');
740
- $element.find('select').removeClass('dirty');
741
- $element.find('.element_head .icon').removeClass('element_dirty');
742
- },
743
-
744
- isPageDirty : function() {
745
- return $('#element_area').find('.element_editor.dirty').size() > 0;
746
- },
747
-
748
- checkPageDirtyness : function(element, text) {
749
- var okcallback;
750
- if ($(element).is('form')) {
751
- okcallback = function() {
752
- var $form = $('<form action="'+element.action+'" method="POST" style="display: none"></form>');
753
- $form.append($(element).find('input'));
754
- $form.appendTo('body');
755
- Alchemy.pleaseWaitOverlay();
756
- $form.submit();
757
- }
758
- } else if ($(element).is('a')) {
759
- okcallback = function() {
760
- Alchemy.pleaseWaitOverlay();
761
- document.location = element.pathname;
762
- }
763
- }
764
- if (Alchemy.isPageDirty()) {
765
- Alchemy.openConfirmWindow({
766
- title: text.title,
767
- message: text.message,
768
- okLabel: text.okLabel,
769
- cancelLabel: text.cancelLabel,
770
- okCallback: okcallback
771
- });
772
- return false;
773
- } else {
774
- return true;
775
- }
776
- },
777
-
778
- PageLeaveObserver : function(texts) {
779
- $('#main_navi a').click(function(event) {
780
- if (!Alchemy.checkPageDirtyness(event.currentTarget, texts)) {
781
- event.preventDefault();
782
- }
783
- });
784
- },
785
-
786
- handleEssenceCheckbox: function (checkbox) {
787
- var $checkbox = $(checkbox);
788
- if (checkbox.checked) {
789
- $('#' + checkbox.id + '_hidden').remove();
790
- } else {
791
- $checkbox.after('<input type="hidden" value="0" name="'+checkbox.name+'" id="'+checkbox.id+'_hidden">');
792
- }
793
- },
794
-
795
- DraggableTrashItems: function (items_n_cells) {
796
- $("#trash_items div.draggable").each(function () {
797
- var cell_classes = '';
798
- var cell_names = items_n_cells[this.id];
799
- $.each(cell_names, function (i) {
800
- cell_classes += '.' + this + '_cell' + ', ';
801
- });
802
- $(this).draggable({
803
- helper: 'clone',
804
- iframeFix: 'iframe#alchemyPreviewWindow',
805
- connectToSortable: cell_classes,
806
- start: function(event, ui) {
807
- $(this).hide().addClass('dragged');
808
- ui.helper.css({width: '300px'});
809
- },
810
- stop: function() {
811
- $(this).show().removeClass('dragged');
812
- }
813
- });
814
- });
815
- },
816
-
817
- selectOrCreateCellTab: function (cell_name, label) {
818
- if ($('#cell_'+cell_name).size() === 0) {
819
- $('#cells').tabs('add', '#cell_'+cell_name, label);
820
- $('#cell_'+cell_name).addClass('sortable_cell');
821
- }
822
- $('#cells').tabs('select', 'cell_'+cell_name);
823
- },
824
-
825
- ButtonObserver: function (selector) {
826
- $(selector).click(function(event) {
827
- Alchemy.disableButton(this);
828
- });
829
- },
830
-
831
- disableButton: function (button) {
832
- var $button = $(button), $clone = $button.clone(), width = $button.outerWidth(), text = $button.text();
833
- $button.hide();
834
- $button.parent().append($clone);
835
- $clone.attr({disabled: true, href: 'javascript:void(0)'})
836
- .addClass('disabled cloned-button')
837
- .css({width: width})
838
- .html('<img src="/images/alchemy/ajax_loader.gif">')
839
- .show();
840
- return true;
841
- },
842
-
843
- enableButton: function (button) {
844
- var $button = $(button);
845
- $button.show();
846
- $button.parent().find('.cloned-button').remove();
847
- return true;
848
- },
849
-
850
- debug : function(e) {
851
- if (window['console']) {
852
- console.debug(e);
853
- console.trace();
854
- }
855
- }
856
-
857
- });
858
-
859
- })(jQuery);
860
-
861
- (function($) {
862
-
863
- // Call all Alchemy "onload" scripts
864
- $(document).ready(function () {
865
- Alchemy.resizeFrame();
866
- Alchemy.Tooltips();
867
- if (typeof(jQuery().sb) === 'function') {
868
- Alchemy.SelectBox('body#alchemy select');
869
- }
870
- if (jQuery('#flash_notices').length > 0) {
871
- Alchemy.Growler.fade();
872
- }
873
- $('#alchemy a.icon_button.please_wait_overlay').click(function() {
874
- Alchemy.pleaseWaitOverlay();
875
- });
876
- });
877
-
878
- // Alchemy window resize listener
879
- $(window).resize(function() {
880
- Alchemy.resizeFrame();
881
- });
882
-
883
- })(jQuery);
884
-
885
- // Javascript extensions
886
-
887
- String.prototype.beginsWith = function(t, i) {
888
- if (i==false) {
889
- return (t == this.substring(0, t.length));
890
- }
891
- else {
892
- return (t.toLowerCase() == this.substring(0, t.length).toLowerCase());
893
- }
894
- };
895
-
896
- String.prototype.endsWith = function(t, i) {
897
- if (i==false) {
898
- return (t == this.substring(this.length - t.length));
899
- }
900
- else {
901
- return (t.toLowerCase() == this.substring(this.length - t.length).toLowerCase());
902
- }
903
- };