kiteditor 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. data/LICENSE +25 -0
  2. data/app/controllers/mercury/images_controller.rb +5 -0
  3. data/app/controllers/mercury_controller.rb +34 -0
  4. data/app/models/mercury/image.rb +17 -0
  5. data/app/views/layouts/mercury.html.erb +33 -0
  6. data/app/views/layouts/popup.html.haml +9 -0
  7. data/app/views/mercury/images/_list.html.haml +22 -0
  8. data/app/views/mercury/images/index.html.haml +4 -0
  9. data/app/views/mercury/images/index.js.erb +2 -0
  10. data/app/views/mercury/lightviews/about.html +11 -0
  11. data/app/views/mercury/modals/character.html +255 -0
  12. data/app/views/mercury/modals/htmleditor.html +13 -0
  13. data/app/views/mercury/modals/link.html +94 -0
  14. data/app/views/mercury/modals/media.html +1 -0
  15. data/app/views/mercury/modals/table.html +84 -0
  16. data/app/views/mercury/palettes/backcolor.html +73 -0
  17. data/app/views/mercury/palettes/forecolor.html +73 -0
  18. data/app/views/mercury/panels/history.html +3 -0
  19. data/app/views/mercury/panels/notes.html +3 -0
  20. data/app/views/mercury/panels/snippets.html +12 -0
  21. data/app/views/mercury/selects/formatblock.html +11 -0
  22. data/app/views/mercury/selects/style.html +5 -0
  23. data/app/views/mercury/snippets/example/options.html.erb +34 -0
  24. data/app/views/mercury/snippets/example/preview.html.erb +1 -0
  25. data/config/engine.rb +44 -0
  26. data/db/migrate/20110526035601_create_mercury_images.rb +11 -0
  27. data/features/loading/loading.feature +22 -0
  28. data/features/loading/navigating.feature +77 -0
  29. data/features/loading/user_interface.feature +67 -0
  30. data/features/regions/editable/advanced_editing.feature +0 -0
  31. data/features/regions/editable/basic_editing.feature +195 -0
  32. data/features/regions/editable/inserting_links.feature +98 -0
  33. data/features/regions/editable/inserting_media.feature +110 -0
  34. data/features/regions/editable/inserting_snippets.feature +102 -0
  35. data/features/regions/editable/inserting_special_characters.feature +24 -0
  36. data/features/regions/editable/inserting_tables.feature +109 -0
  37. data/features/regions/editable/pasting.feature +0 -0
  38. data/features/regions/editable/uploading_images.feature +0 -0
  39. data/features/regions/markupable/advanced_editing.feature +0 -0
  40. data/features/regions/markupable/basic_editing.feature +0 -0
  41. data/features/regions/markupable/inserting_links.feature +0 -0
  42. data/features/regions/markupable/inserting_media.feature +0 -0
  43. data/features/regions/markupable/inserting_snippets.feature +0 -0
  44. data/features/regions/markupable/inserting_special_characters.feature +0 -0
  45. data/features/regions/markupable/inserting_tables.feature +0 -0
  46. data/features/regions/markupable/uploading_images.feature +0 -0
  47. data/features/regions/snippetable/advanced_editing.feature +0 -0
  48. data/features/regions/snippetable/basic_editing.feature +0 -0
  49. data/features/regions/snippetable/inserting_snippets.feature +0 -0
  50. data/features/saving/saving.feature +33 -0
  51. data/features/step_definitions/debug_steps.rb +14 -0
  52. data/features/step_definitions/mercury_steps.rb +438 -0
  53. data/features/step_definitions/web_steps.rb +211 -0
  54. data/features/support/env.rb +46 -0
  55. data/features/support/mercury_contents.rb +25 -0
  56. data/features/support/mercury_selectors.rb +148 -0
  57. data/features/support/paths.rb +38 -0
  58. data/features/support/selectors.rb +44 -0
  59. data/lib/generators/mercury/install/install_generator.rb +49 -0
  60. data/lib/generators/mercury/install/templates/mongoid_paperclip_image.rb +17 -0
  61. data/lib/mercury/authentication.rb +8 -0
  62. data/lib/mercury-rails.rb +3 -0
  63. data/spec/javascripts/mercury/dialog_spec.js.coffee +281 -0
  64. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +37 -0
  65. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +37 -0
  66. data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +25 -0
  67. data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +30 -0
  68. data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +25 -0
  69. data/spec/javascripts/mercury/history_buffer_spec.js.coffee +76 -0
  70. data/spec/javascripts/mercury/lightview_spec.js.coffee +497 -0
  71. data/spec/javascripts/mercury/mercury_spec.js.coffee +132 -0
  72. data/spec/javascripts/mercury/modal_spec.js.coffee +504 -0
  73. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +30 -0
  74. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +29 -0
  75. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +220 -0
  76. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +167 -0
  77. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +52 -0
  78. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +160 -0
  79. data/spec/javascripts/mercury/native_extensions_spec.js.coffee +60 -0
  80. data/spec/javascripts/mercury/page_editor_spec.js.coffee +750 -0
  81. data/spec/javascripts/mercury/palette_spec.js.coffee +49 -0
  82. data/spec/javascripts/mercury/panel_spec.js.coffee +185 -0
  83. data/spec/javascripts/mercury/region_spec.js.coffee +298 -0
  84. data/spec/javascripts/mercury/regions/editable_spec.js.coffee +561 -0
  85. data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +367 -0
  86. data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +370 -0
  87. data/spec/javascripts/mercury/select_spec.js.coffee +49 -0
  88. data/spec/javascripts/mercury/snippet_spec.js.coffee +245 -0
  89. data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +184 -0
  90. data/spec/javascripts/mercury/statusbar_spec.js.coffee +150 -0
  91. data/spec/javascripts/mercury/table_editor_spec.js.coffee +194 -0
  92. data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +90 -0
  93. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +360 -0
  94. data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +118 -0
  95. data/spec/javascripts/mercury/toolbar_spec.js.coffee +222 -0
  96. data/spec/javascripts/mercury/tooltip_spec.js.coffee +186 -0
  97. data/spec/javascripts/mercury/uploader_spec.js.coffee +514 -0
  98. data/spec/javascripts/spec_helper.js +513 -0
  99. data/spec/javascripts/templates/mercury/dialog.html +2 -0
  100. data/spec/javascripts/templates/mercury/dialogs/backcolor.html +5 -0
  101. data/spec/javascripts/templates/mercury/dialogs/forecolor.html +5 -0
  102. data/spec/javascripts/templates/mercury/dialogs/formatblock.html +3 -0
  103. data/spec/javascripts/templates/mercury/dialogs/snippetpanel.html +16 -0
  104. data/spec/javascripts/templates/mercury/dialogs/style.html +3 -0
  105. data/spec/javascripts/templates/mercury/lightview.html +13 -0
  106. data/spec/javascripts/templates/mercury/modal.html +13 -0
  107. data/spec/javascripts/templates/mercury/modals/htmleditor.html +5 -0
  108. data/spec/javascripts/templates/mercury/modals/insertcharacter.html +5 -0
  109. data/spec/javascripts/templates/mercury/modals/insertlink.html +30 -0
  110. data/spec/javascripts/templates/mercury/modals/insertmedia.html +35 -0
  111. data/spec/javascripts/templates/mercury/modals/insertsnippet.html +6 -0
  112. data/spec/javascripts/templates/mercury/modals/inserttable.html +27 -0
  113. data/spec/javascripts/templates/mercury/page_editor.html +35 -0
  114. data/spec/javascripts/templates/mercury/palette.html +16 -0
  115. data/spec/javascripts/templates/mercury/panel.html +16 -0
  116. data/spec/javascripts/templates/mercury/region.html +2 -0
  117. data/spec/javascripts/templates/mercury/regions/editable.html +3 -0
  118. data/spec/javascripts/templates/mercury/regions/snippetable.html +4 -0
  119. data/spec/javascripts/templates/mercury/select.html +16 -0
  120. data/spec/javascripts/templates/mercury/snippet.html +1 -0
  121. data/spec/javascripts/templates/mercury/snippet_toolbar.html +16 -0
  122. data/spec/javascripts/templates/mercury/statusbar.html +8 -0
  123. data/spec/javascripts/templates/mercury/table_editor.html +65 -0
  124. data/spec/javascripts/templates/mercury/toolbar.button.html +64 -0
  125. data/spec/javascripts/templates/mercury/toolbar.button_group.html +9 -0
  126. data/spec/javascripts/templates/mercury/toolbar.expander.html +18 -0
  127. data/spec/javascripts/templates/mercury/toolbar.html +11 -0
  128. data/spec/javascripts/templates/mercury/tooltip.html +12 -0
  129. data/spec/javascripts/templates/mercury/uploader.html +11 -0
  130. data/vendor/assets/images/mercury/button.png +0 -0
  131. data/vendor/assets/images/mercury/close.png +0 -0
  132. data/vendor/assets/images/mercury/default-snippet.png +0 -0
  133. data/vendor/assets/images/mercury/loading-dark.gif +0 -0
  134. data/vendor/assets/images/mercury/loading-light.gif +0 -0
  135. data/vendor/assets/images/mercury/missing-image.png +0 -0
  136. data/vendor/assets/images/mercury/search-icon.png +0 -0
  137. data/vendor/assets/images/mercury/temp-logo.png +0 -0
  138. data/vendor/assets/images/mercury/toolbar/editable/buttons.png +0 -0
  139. data/vendor/assets/images/mercury/toolbar/primary/_expander.png +0 -0
  140. data/vendor/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
  141. data/vendor/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
  142. data/vendor/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
  143. data/vendor/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
  144. data/vendor/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
  145. data/vendor/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
  146. data/vendor/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
  147. data/vendor/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
  148. data/vendor/assets/images/mercury/toolbar/primary/preview.png +0 -0
  149. data/vendor/assets/images/mercury/toolbar/primary/redo.png +0 -0
  150. data/vendor/assets/images/mercury/toolbar/primary/save.png +0 -0
  151. data/vendor/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
  152. data/vendor/assets/images/mercury/toolbar/primary/undo.png +0 -0
  153. data/vendor/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
  154. data/vendor/assets/javascripts/mercury/dependencies/jquery-1.7.js +9300 -0
  155. data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +1328 -0
  156. data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.18.custom.min.js +356 -0
  157. data/vendor/assets/javascripts/mercury/dependencies/jquery-ui.1.8.13.custom.min.js +356 -0
  158. data/vendor/assets/javascripts/mercury/dependencies/jquery.additions.js +206 -0
  159. data/vendor/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +527 -0
  160. data/vendor/assets/javascripts/mercury/dependencies/liquidmetal.js +88 -0
  161. data/vendor/assets/javascripts/mercury/dependencies/showdown.js +1340 -0
  162. data/vendor/assets/javascripts/mercury/dialog.js.coffee +159 -0
  163. data/vendor/assets/javascripts/mercury/dialogs/backcolor.js.coffee +6 -0
  164. data/vendor/assets/javascripts/mercury/dialogs/forecolor.js.coffee +6 -0
  165. data/vendor/assets/javascripts/mercury/dialogs/formatblock.js.coffee +4 -0
  166. data/vendor/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +10 -0
  167. data/vendor/assets/javascripts/mercury/dialogs/style.js.coffee +4 -0
  168. data/vendor/assets/javascripts/mercury/finalize.js.coffee +3 -0
  169. data/vendor/assets/javascripts/mercury/history_buffer.js.coffee +30 -0
  170. data/vendor/assets/javascripts/mercury/lightview.js.coffee +205 -0
  171. data/vendor/assets/javascripts/mercury/locales/da.locale.js.coffee +0 -0
  172. data/vendor/assets/javascripts/mercury/locales/de.locale.js.coffee +206 -0
  173. data/vendor/assets/javascripts/mercury/locales/es.locale.js.coffee +211 -0
  174. data/vendor/assets/javascripts/mercury/locales/example.local.js.coffee +211 -0
  175. data/vendor/assets/javascripts/mercury/locales/fr.locale.js.coffee +211 -0
  176. data/vendor/assets/javascripts/mercury/locales/it.locale.js.coffee +208 -0
  177. data/vendor/assets/javascripts/mercury/locales/ko.local.js.coffee +206 -0
  178. data/vendor/assets/javascripts/mercury/locales/nl.locale.js.coffee +206 -0
  179. data/vendor/assets/javascripts/mercury/locales/pt.locale.js.coffee +211 -0
  180. data/vendor/assets/javascripts/mercury/locales/sv.local.js.coffee +209 -0
  181. data/vendor/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +213 -0
  182. data/vendor/assets/javascripts/mercury/mercury.js.coffee +109 -0
  183. data/vendor/assets/javascripts/mercury/modal.js.coffee +204 -0
  184. data/vendor/assets/javascripts/mercury/modals/htmleditor.js.coffee +11 -0
  185. data/vendor/assets/javascripts/mercury/modals/insertcharacter.js.coffee +4 -0
  186. data/vendor/assets/javascripts/mercury/modals/insertlink.js.coffee +95 -0
  187. data/vendor/assets/javascripts/mercury/modals/insertmedia.js.coffee +107 -0
  188. data/vendor/assets/javascripts/mercury/modals/insertsnippet.js.coffee +12 -0
  189. data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +54 -0
  190. data/vendor/assets/javascripts/mercury/native_extensions.js.coffee +55 -0
  191. data/vendor/assets/javascripts/mercury/page_editor.js.coffee +241 -0
  192. data/vendor/assets/javascripts/mercury/palette.js.coffee +29 -0
  193. data/vendor/assets/javascripts/mercury/panel.js.coffee +115 -0
  194. data/vendor/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +28 -0
  195. data/vendor/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +9 -0
  196. data/vendor/assets/javascripts/mercury/region.js.coffee +107 -0
  197. data/vendor/assets/javascripts/mercury/regions/editable.js.coffee +600 -0
  198. data/vendor/assets/javascripts/mercury/regions/markupable.js.coffee +398 -0
  199. data/vendor/assets/javascripts/mercury/regions/simple.js.coffee +339 -0
  200. data/vendor/assets/javascripts/mercury/regions/snippetable.js.coffee +124 -0
  201. data/vendor/assets/javascripts/mercury/select.js.coffee +44 -0
  202. data/vendor/assets/javascripts/mercury/snippet.js.coffee +104 -0
  203. data/vendor/assets/javascripts/mercury/snippet_toolbar.js.coffee +72 -0
  204. data/vendor/assets/javascripts/mercury/statusbar.js.coffee +51 -0
  205. data/vendor/assets/javascripts/mercury/support/history.js +1 -0
  206. data/vendor/assets/javascripts/mercury/table_editor.js.coffee +265 -0
  207. data/vendor/assets/javascripts/mercury/toolbar.button.js.coffee +173 -0
  208. data/vendor/assets/javascripts/mercury/toolbar.button_group.js.coffee +42 -0
  209. data/vendor/assets/javascripts/mercury/toolbar.expander.js.coffee +56 -0
  210. data/vendor/assets/javascripts/mercury/toolbar.js.coffee +86 -0
  211. data/vendor/assets/javascripts/mercury/tooltip.js.coffee +74 -0
  212. data/vendor/assets/javascripts/mercury/uploader.js.coffee +227 -0
  213. data/vendor/assets/javascripts/mercury.js +479 -0
  214. data/vendor/assets/javascripts/mercury_loader.js +193 -0
  215. data/vendor/assets/javascripts/mercury_overrides.js +6 -0
  216. data/vendor/assets/javascripts/popup.js +8 -0
  217. data/vendor/assets/stylesheets/mercury/all_images.css.erb +89 -0
  218. data/vendor/assets/stylesheets/mercury/dialog.css +208 -0
  219. data/vendor/assets/stylesheets/mercury/lightview.css +151 -0
  220. data/vendor/assets/stylesheets/mercury/mercury.css +151 -0
  221. data/vendor/assets/stylesheets/mercury/modal.css +183 -0
  222. data/vendor/assets/stylesheets/mercury/statusbar.css +32 -0
  223. data/vendor/assets/stylesheets/mercury/toolbar.css +304 -0
  224. data/vendor/assets/stylesheets/mercury/tooltip.css +26 -0
  225. data/vendor/assets/stylesheets/mercury/uploader.css +111 -0
  226. data/vendor/assets/stylesheets/mercury.css +28 -0
  227. data/vendor/assets/stylesheets/mercury_overrides.css +17 -0
  228. data/vendor/assets/stylesheets/popup.css.erb +37 -0
  229. metadata +634 -0
@@ -0,0 +1,479 @@
1
+ /*!
2
+ * Mercury Editor is a CoffeeScript and jQuery based WYSIWYG editor. Documentation and other useful information can be
3
+ * found at https://github.com/jejacks0n/mercury
4
+ *
5
+ * Supported browsers:
6
+ * - Firefox 4+
7
+ * - Chrome 10+
8
+ * - Safari 5+
9
+ *
10
+ * Copyright (c) 2011 Jeremy Jackson
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
14
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
15
+ * persons to whom the Software is furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
18
+ * Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
21
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ *
25
+ *= require_self
26
+ *
27
+ * Minimum jQuery requirements are 1.7
28
+ *= require mercury/dependencies/jquery-1.7
29
+ *
30
+ * You can include the Rails jQuery ujs script here to get some nicer behaviors in modals, panels and lightviews when
31
+ * using :remote => true within the contents rendered in them.
32
+ * require jquery_ujs
33
+ *
34
+ * If you want to override Mercury functionality, you can do so in a custom file that binds to the mercury:loaded event,
35
+ * or do so at the end of the current file (mercury.js). There's an example that will help you get started.
36
+ * require mercury_overrides
37
+ *
38
+ * Add all requires for the support libraries that integrate nicely with Mercury Editor.
39
+ * require mercury/support/history
40
+ *
41
+ * Require Mercury Editor itself.
42
+ *= require mercury/mercury
43
+ *
44
+ * Require any localizations you wish to support
45
+ * Example: es.locale, or fr.locale -- regional dialects are in each language file so never en_US for instance.
46
+ * require mercury/locales/swedish_chef.locale
47
+ *
48
+ * Add all requires for plugins that extend or change the behavior of Mercury Editor.
49
+ * require mercury/plugins/save_as_xml/plugin.js
50
+ */
51
+ window.Mercury = {
52
+
53
+ // # Mercury Configuration
54
+ config: {
55
+ // ## Toolbars
56
+ //
57
+ // This is where you can customize the toolbars by adding or removing buttons, or changing them and their
58
+ // behaviors. Any top level object put here will create a new toolbar. Buttons are simply nested inside the
59
+ // toolbars, along with button groups.
60
+ //
61
+ // Some toolbars are custom (the snippetable toolbar for instance), and to denote that use _custom: true. You can
62
+ // then build the toolbar yourself with it's own behavior.
63
+ //
64
+ // Buttons can be grouped, and a button group is simply a way to wrap buttons for styling -- they can also handle
65
+ // enabling or disabling all the buttons within it by using a context. The table button group is a good example
66
+ // of this.
67
+ //
68
+ // It's important to note that each of the button names (keys), in each toolbar object must be unique, regardless
69
+ // of if it's in a button group, or nested, etc. This is because styling is applied to them by name, and because
70
+ // their name is used in the event that's fired when you click on them.
71
+ //
72
+ // Button format: `[label, description, {type: action, type: action, etc}]`
73
+ //
74
+ // ### The available button types are:
75
+ //
76
+ // - toggle: toggles on or off when clicked, otherwise behaves like a button
77
+ // - modal: opens a modal window, expects the action to be one of:
78
+ // 1. a string url
79
+ // 2. a function that returns a string url
80
+ // - lightview: opens a lightview window (like modal, but different UI), expects the action to be one of:
81
+ // 1. a string url
82
+ // 2. a function that returns a string url
83
+ // - panel: opens a panel dialog, expects the action to be one of:
84
+ // 1. a string url
85
+ // 2. a function that returns a string url
86
+ // - palette: opens a palette window, expects the action to be one of:
87
+ // 1. a string url
88
+ // 2. a function that returns a string url
89
+ // - select: opens a pulldown style window, expects the action to be one of:
90
+ // 1. a string url
91
+ // 2. a function that returns a string url
92
+ // - context: calls a callback function, expects the action to be:
93
+ // 1. a function that returns a boolean to highlight the button
94
+ // note: if a function isn't provided, the key will be passed to the contextHandler, in which case a default
95
+ // context will be used (for more info read the Contexts section below)
96
+ // - mode: toggle a given mode in the editor, expects the action to be:
97
+ // 1. a string, denoting the name of the mode
98
+ // note: it's assumed that when a specific mode is turned on, all other modes will be turned off, which happens
99
+ // automatically, thus putting the editor into a specific "state"
100
+ // - regions: allows buttons to be enabled/disabled based on what region type has focus, expects the action to be:
101
+ // 1. an array of region types (eg. ['editable', 'markupable'])
102
+ // - preload: allows some dialog views to be loaded when the button is created instead of on first open, expects:
103
+ // 1. a boolean true / false
104
+ // note: this is only used by panels, selects, and palettes
105
+ //
106
+ // Separators are any "button" that's not an array, and are expected to be a string. You can use two different
107
+ // separator styles: line ('-'), and spacer (' ').
108
+ //
109
+ // ### Adding Contexts
110
+ //
111
+ // Contexts are used callback functions used for highlighting and disabling/enabling buttons and buttongroups. When
112
+ // the cursor enters an element within an html region for instance we want to disable or highlight buttons based on
113
+ // the properties of the given node. You can see examples of contexts in, and add your own to:
114
+ // `Mercury.Toolbar.Button.contexts` and `Mercury.Toolbar.ButtonGroup.contexts`
115
+ toolbars: {
116
+ primary: {
117
+ save: ['Save', 'Save this page'],
118
+ preview: ['Preview', 'Preview this page', { toggle: true, mode: true }],
119
+ sep1: ' ',
120
+ undoredo: {
121
+ undo: ['Undo', 'Undo your last action'],
122
+ redo: ['Redo', 'Redo your last action'],
123
+ sep: ' '
124
+ },
125
+ insertLink: ['Link', 'Insert Link', { modal: '/mercury/modals/link.html', regions: ['editable', 'markupable'] }],
126
+ insertMedia: ['Media', 'Insert Media (images and videos)', { modal: '/mercury/modals/media.html', regions: ['editable', 'markupable'] }],
127
+ insertTable: ['Table', 'Insert Table', { modal: '/mercury/modals/table.html', regions: ['editable', 'markupable'] }],
128
+ insertCharacter: ['Character', 'Special Characters', { modal: '/mercury/modals/character.html', regions: ['editable', 'markupable'] }],
129
+ snippetPanel: ['Snippet', 'Snippet Panel', { panel: '/mercury/panels/snippets.html' }],
130
+ sep2: ' ',
131
+ historyPanel: ['History', 'Page Version History', { panel: '/mercury/panels/history.html' }],
132
+ sep3: ' ',
133
+ notesPanel: ['Notes', 'Page Notes', { panel: '/mercury/panels/notes.html' }]
134
+ },
135
+
136
+ editable: {
137
+ _regions: ['editable', 'markupable'],
138
+ predefined: {
139
+ style: ['Style', null, { select: '/mercury/selects/style.html', preload: true }],
140
+ sep1: ' ',
141
+ formatblock: ['Block Format', null, { select: '/mercury/selects/formatblock.html', preload: true }],
142
+ sep2: '-'
143
+ },
144
+ colors: {
145
+ backColor: ['Background Color', null, { palette: '/mercury/palettes/backcolor.html', context: true, preload: true, regions: ['editable'] }],
146
+ sep1: ' ',
147
+ foreColor: ['Text Color', null, { palette: '/mercury/palettes/forecolor.html', context: true, preload: true, regions: ['editable'] }],
148
+ sep2: '-'
149
+ },
150
+ decoration: {
151
+ bold: ['Bold', null, { context: true }],
152
+ italic: ['Italicize', null, { context: true }],
153
+ overline: ['Overline', null, { context: true, regions: ['editable'] }],
154
+ strikethrough: ['Strikethrough', null, { context: true, regions: ['editable'] }],
155
+ underline: ['Underline', null, { context: true, regions: ['editable'] }],
156
+ sep: '-'
157
+ },
158
+ script: {
159
+ subscript: ['Subscript', null, { context: true }],
160
+ superscript: ['Superscript', null, { context: true }],
161
+ sep: '-'
162
+ },
163
+ justify: {
164
+ justifyLeft: ['Align Left', null, { context: true, regions: ['editable'] }],
165
+ justifyCenter: ['Center', null, { context: true, regions: ['editable'] }],
166
+ justifyRight: ['Align Right', null, { context: true, regions: ['editable'] }],
167
+ justifyFull: ['Justify Full', null, { context: true, regions: ['editable'] }],
168
+ sep: '-'
169
+ },
170
+ list: {
171
+ insertUnorderedList: ['Unordered List', null, { context: true }],
172
+ insertOrderedList: ['Numbered List', null, { context: true }],
173
+ sep: '-'
174
+ },
175
+ indent: {
176
+ outdent: ['Decrease Indentation'],
177
+ indent: ['Increase Indentation'],
178
+ sep: '-'
179
+ },
180
+ table: {
181
+ _context: true,
182
+ insertRowBefore: ['Insert Table Row', 'Insert a table row before the cursor', { regions: ['editable'] }],
183
+ insertRowAfter: ['Insert Table Row', 'Insert a table row after the cursor', { regions: ['editable'] }],
184
+ deleteRow: ['Delete Table Row', 'Delete this table row', { regions: ['editable'] }],
185
+ insertColumnBefore: ['Insert Table Column', 'Insert a table column before the cursor', { regions: ['editable'] }],
186
+ insertColumnAfter: ['Insert Table Column', 'Insert a table column after the cursor', { regions: ['editable'] }],
187
+ deleteColumn: ['Delete Table Column', 'Delete this table column', { regions: ['editable'] }],
188
+ sep1: ' ',
189
+ increaseColspan: ['Increase Cell Columns', 'Increase the cells colspan'],
190
+ decreaseColspan: ['Decrease Cell Columns', 'Decrease the cells colspan and add a new cell'],
191
+ increaseRowspan: ['Increase Cell Rows', 'Increase the cells rowspan'],
192
+ decreaseRowspan: ['Decrease Cell Rows', 'Decrease the cells rowspan and add a new cell'],
193
+ sep2: '-'
194
+ },
195
+ rules: {
196
+ horizontalRule: ['Horizontal Rule', 'Insert a horizontal rule'],
197
+ sep1: '-'
198
+ },
199
+ formatting: {
200
+ removeFormatting: ['Remove Formatting', 'Remove formatting for the selection', { regions: ['editable'] }],
201
+ sep2: ' '
202
+ },
203
+ editors: {
204
+ htmlEditor: ['Edit HTML', 'Edit the HTML content', { regions: ['editable'] }]
205
+ }
206
+ },
207
+
208
+ snippetable: {
209
+ _custom: true,
210
+ actions: {
211
+ editSnippet: ['Edit Snippet Settings'],
212
+ sep1: ' ',
213
+ removeSnippet: ['Remove Snippet']
214
+ }
215
+ }
216
+ },
217
+
218
+
219
+ // ## Region Options
220
+ //
221
+ // You can customize some aspects of how regions are found, identified, and saved.
222
+ //
223
+ // className: Mercury identifies editable regions by a className. This classname has to be added in your HTML in
224
+ // advance, and is the only real code/naming exposed in the implementation of Mercury. To allow this to be as
225
+ // configurable as possible, you can set the name of the class. When switching to preview mode, this configuration
226
+ // is also used to generate a class to indicate that Mercury is in preview mode by appending it with '-preview' (so
227
+ // by default it would be mercury-region-preview)
228
+ //
229
+ // identifier: This is used as a unique identifier for any given region (and thus should be unique to the page).
230
+ // By default this is the id attribute but can be changed to a data attribute should you want to use something
231
+ // custom instead.
232
+ //
233
+ // determineType: This function is called after checking the data-type attribute for the correct field type. Use
234
+ // it if you want to programatically set the type based on inspection of the region.
235
+ //
236
+ // dataAttributes: The dataAttributes is an array of data attributes that will be serialized and returned to the
237
+ // server upon saving. These attributes, when applied to a Mercury region element, will be automatically serialized
238
+ // and submitted with the AJAX request sent when a page is saved. These are expected to be HTML5 data attributes,
239
+ // and 'data-' will automatically be prepended to each item in this directive. (ex. ['scope', 'version'])
240
+ regions: {
241
+ className: 'mercury-region',
242
+ identifier: 'id',
243
+ // determineType: function(region){},
244
+ dataAttributes: []
245
+ },
246
+
247
+
248
+ // ## Snippet Options / Preview
249
+ //
250
+ // When a user drags a snippet onto the page they'll be prompted to enter options for the given snippet. The server
251
+ // is expected to respond with a form. Once the user submits this form, an Ajax request is sent to the server with
252
+ // the options provided; this preview request is expected to respond with the rendered markup for the snippet.
253
+ //
254
+ // method: The HTTP method used when submitting both the options and the preview. We use POST by default because a
255
+ // snippet options form may contain large text inputs and we don't want that to be truncated when sent to the
256
+ // server.
257
+ //
258
+ // optionsUrl: The url that the options form will be loaded from.
259
+ //
260
+ // previewUrl: The url that the options will be submitted to, and will return the rendered snippet markup.
261
+ //
262
+ // **Note:** `:name` will be replaced with the snippet name in the urls (eg. /mercury/snippets/example/options.html)
263
+ snippets: {
264
+ method: 'POST',
265
+ optionsUrl: '/mercury/snippets/:name/options.html',
266
+ previewUrl: '/mercury/snippets/:name/preview.html'
267
+ },
268
+
269
+
270
+ // ## Image Uploading
271
+ //
272
+ // If you drag images from your desktop into regions that support it, it will be uploaded to the server and inserted
273
+ // into the region. You can disable or enable this feature, the accepted mime-types, file size restrictions, and
274
+ // other things related to uploading.
275
+ //
276
+ // **Note:** Image uploading is only supported in some region types, and some browsers.
277
+ //
278
+ // enabled: You can set this to true, or false if you want to disable the feature entirely.
279
+ //
280
+ // allowedMimeTypes: You can restrict the types of files that can be uploaded by providing a list of allowed mime
281
+ // types.
282
+ //
283
+ // maxFileSize: You can restrict large files by setting the maxFileSize (in bytes).
284
+ //
285
+ // inputName: When uploading, a form is generated and submitted to the server via Ajax. If your server would prefer
286
+ // a different name for how the image comes through, you can change the inputName.
287
+ //
288
+ // url: The url that the image upload will be submitted to.
289
+ //
290
+ // handler: You can use false to let Mercury handle it for you, or you can provide a handler function that can
291
+ // modify the response from the server. This can be useful if your server doesn't respond the way Mercury expects.
292
+ // The handler function should take the response from the server and return an object that matches:
293
+ // `{image: {url: '[your provided url]'}`
294
+ uploading: {
295
+ enabled: true,
296
+ allowedMimeTypes: ['image/jpeg', 'image/gif', 'image/png'],
297
+ maxFileSize: 1235242880,
298
+ inputName: 'image[image]',
299
+ url: '/mercury/images',
300
+ handler: false
301
+ },
302
+
303
+
304
+ // ## Localization / I18n
305
+ //
306
+ // Include the .locale files you want to support when loading Mercury. The files are always named by the language,
307
+ // and not the regional dialect (eg. en.locale.js) because the regional dialects are nested within the primary
308
+ // locale files.
309
+ //
310
+ // The client locale will be used first, and if no proper locale file is found for their language then the fallback
311
+ // preferredLocale configuration will be used. If one isn't provided, and the client locale isn't included, the
312
+ // strings will remain untranslated.
313
+ //
314
+ // enabled: Set to false to disable, true to enable.
315
+ //
316
+ // preferredLocale: If a client doesn't support the locales you've included, this is used as a fallback.
317
+ localization: {
318
+ enabled: false,
319
+ preferredLocale: 'swedish_chef-BORK'
320
+ },
321
+
322
+
323
+ // ## Behaviors
324
+ //
325
+ // Behaviors are used to change the default behaviors of a given region type when a given button is clicked. For
326
+ // example, you may prefer to add HR tags using an HR wrapped within a div with a classname (for styling). You
327
+ // can add your own complex behaviors here and they'll be shared across all regions.
328
+ //
329
+ // If you want to add behaviors to specific region types, you can mix them into the actions property of any region
330
+ // type.
331
+ //
332
+ // Mercury.Regions.Editable.actions.htmlEditor = function() {}
333
+ //
334
+ // You can see how the behavior matches up directly with the button names. It's also important to note that the
335
+ // callback functions are executed within the scope of the given region, so you have access to all it's methods.
336
+ behaviors: {
337
+ //foreColor: function(selection, options) { selection.wrap('<span style="color:' + options.value.toHex() + '">', true) },
338
+ htmlEditor: function() { Mercury.modal('/mercury/modals/htmleditor.html', { title: 'HTML Editor', fullHeight: true, handler: 'htmlEditor' }); }
339
+ },
340
+
341
+
342
+ // ## Global Behaviors
343
+ //
344
+ // Global behaviors are much like behaviors, but are more "global". Things like save, exit, etc. can be included
345
+ // here. They'll only be called once, and execute within the scope of whatever editor is instantiated (eg.
346
+ // PageEditor).
347
+ //
348
+ // An example of changing how saving works:
349
+ //
350
+ // save: function() {
351
+ // var data = top.JSON.stringify(this.serialize(), null, ' ');
352
+ // var content = '<textarea style="width:500px;height:200px" wrap="off">' + data + '</textarea>';
353
+ // Mercury.modal(null, {title: 'Saving', closeButton: true, content: content})
354
+ // }
355
+ //
356
+ // This is a nice way to add functionality, when the behaviors aren't region specific. These can be triggered by a
357
+ // button, or manually with `Mercury.trigger('action', {action: 'barrelRoll'})`
358
+ globalBehaviors: {
359
+ exit: function() { window.location.href = this.iframeSrc() },
360
+ barrelRoll: function() { $('body').css({webkitTransform: 'rotate(360deg)'}) }
361
+ },
362
+
363
+
364
+ // ## Ajax and CSRF Headers
365
+ //
366
+ // Some server frameworks require that you provide a specific header for Ajax requests. The values for these CSRF
367
+ // tokens are typically stored in the rendered DOM. By default, Mercury will look for the Rails specific meta tag,
368
+ // and provide the X-CSRF-Token header on Ajax requests, but you can modify this configuration if the system you're
369
+ // using doesn't follow the same standard.
370
+ csrfSelector: 'meta[name="csrf-token"]',
371
+ csrfHeader: 'X-CSRF-Token',
372
+
373
+ // ## Editor URLs
374
+ //
375
+ // When loading a given page, you may want to tweak this regex. It's to allow the url to differ from the page
376
+ // you're editing, and the url at which you access it.
377
+ editorUrlRegEx: /([http|https]:\/\/.[^\/]*)\/editor\/?(.*)/i,
378
+
379
+ // ## Hijacking Links & Forms
380
+ //
381
+ // Mercury will hijack links and forms that don't have a target set, or the target is set to _self and will set it
382
+ // to _parent. This is because the target must be set properly for Mercury to not get in the way of some
383
+ // functionality, like proper page loads on form submissions etc. Mercury doesn't do this to links or forms that
384
+ // are within editable regions because it doesn't want to impact the html that's saved. With that being explained,
385
+ // you can add classes to links or forms that you don't want this behavior added to. Let's say you have links that
386
+ // open a lightbox style window, and you don't want the targets of these to be set to _parent. You can add classes
387
+ // to this array, and they will be ignored when the hijacking is applied.
388
+ nonHijackableClasses: [],
389
+
390
+
391
+ // ## Pasting & Sanitizing
392
+ //
393
+ // When pasting content into Mercury it may sometimes contain HTML tags and attributes. This markup is used to
394
+ // style the content and makes the pasted content look (and behave) the same as the original content. This can be a
395
+ // desired feature or an annoyance, so you can enable various sanitizing methods to clean the content when it's
396
+ // pasted.
397
+ //
398
+ // sanitize: Can be any of the following:
399
+ // - false: no sanitizing is done, the content is pasted the exact same as it was copied by the user
400
+ // - 'whitelist': content is cleaned using the settings specified in the tag white list (described below)
401
+ // - 'text': all html is stripped before pasting, leaving only the raw text
402
+ //
403
+ // whitelist: The white list allows you to specify tags and attributes that are allowed when pasting content. Each
404
+ // item in this object should contain the allowed tag, and an array of attributes that are allowed on that tag. If
405
+ // the allowed attributes array is empty, all attributes will be removed. If a tag is not present in this list, it
406
+ // will be removed, but without removing any of the text or tags inside it.
407
+ //
408
+ // **Note:** Content is *always* sanitized if looks like it's from MS Word or similar editors regardless of this
409
+ // configuration.
410
+ pasting: {
411
+ sanitize: 'whitelist',
412
+ whitelist: {
413
+ h1: [],
414
+ h2: [],
415
+ h3: [],
416
+ h4: [],
417
+ h5: [],
418
+ h6: [],
419
+ table: [],
420
+ thead: [],
421
+ tbody: [],
422
+ tfoot: [],
423
+ tr: [],
424
+ th: ['colspan', 'rowspan'],
425
+ td: ['colspan', 'rowspan'],
426
+ div: ['class'],
427
+ span: ['class'],
428
+ ul: [],
429
+ ol: [],
430
+ li: [],
431
+ b: [],
432
+ strong: [],
433
+ i: [],
434
+ em: [],
435
+ u: [],
436
+ strike: [],
437
+ br: [],
438
+ p: [],
439
+ hr: [],
440
+ a: ['href', 'target', 'title', 'name'],
441
+ img: ['src', 'title', 'alt']
442
+ }
443
+ },
444
+
445
+
446
+ // ## Injected Styles
447
+ //
448
+ // Mercury tries to stay as much out of your code as possible, but because regions appear within your document we
449
+ // need to include a few styles to indicate regions, as well as the different states of them (eg. focused). These
450
+ // styles are injected into your document, and as simple as they might be, you may want to change them.
451
+ //
452
+ // {{regionClass}} will be automatically replaced with whatever you have set in the regions.class config directive.
453
+ injectedStyles: '' +
454
+ '.{{regionClass}} { min-height: 10px; outline: 1px dotted #09F } ' +
455
+ '.{{regionClass}}:focus, .{{regionClass}}.focus { outline: none; -webkit-box-shadow: 0 0 10px #09F, 0 0 1px #045; box-shadow: 0 0 10px #09F, 0 0 1px #045 }' +
456
+ '.{{regionClass}}:after { content: "."; display: block; visibility: hidden; clear: both; height: 0; overflow: hidden; }' +
457
+ '.{{regionClass}} table, .{{regionClass}} td, .{{regionClass}} th { border: 1px dotted red; min-width: 6px; }' +
458
+ '.mercury-textarea { border: 0; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; resize: none; }' +
459
+ '.mercury-textarea:focus { outline: none; }'
460
+ },
461
+
462
+ // ## Silent Mode
463
+ //
464
+ // Turning silent mode on will disable asking about unsaved changes before leaving the page.
465
+ silent: false,
466
+
467
+ // ## Debug Mode
468
+ //
469
+ // Turning debug mode on will log events and other various things (using console.debug if available).
470
+ debug: false,
471
+
472
+ // The onload method is provided as a callback in case you want to override default Mercury Editor behavior. It will
473
+ // be called directly after the Mercury scripts have loaded, but before anything has been initialized. It's a good
474
+ // place to add or change functionality.
475
+ onload: function() {
476
+ //Mercury.PageEditor.prototype.iframeSrc = function(url) { return '/testing'; }
477
+ },
478
+
479
+ };