kiteditor 1.0.11 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (289) hide show
  1. data/POST_INSTALL +21 -0
  2. data/{vendor → app}/assets/images/mercury/button.png +0 -0
  3. data/{vendor → app}/assets/images/mercury/close.png +0 -0
  4. data/app/assets/images/mercury/default-snippet.png +0 -0
  5. data/{vendor → app}/assets/images/mercury/loading-dark.gif +0 -0
  6. data/{vendor → app}/assets/images/mercury/loading-light.gif +0 -0
  7. data/{vendor → app}/assets/images/mercury/missing-image.png +0 -0
  8. data/{vendor → app}/assets/images/mercury/search-icon.png +0 -0
  9. data/{vendor → app}/assets/images/mercury/temp-logo.png +0 -0
  10. data/app/assets/images/mercury/toolbar/editable/buttons.png +0 -0
  11. data/app/assets/images/mercury/toolbar/primary/_expander.png +0 -0
  12. data/app/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
  13. data/app/assets/images/mercury/toolbar/primary/action.png +0 -0
  14. data/app/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
  15. data/app/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
  16. data/app/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
  17. data/app/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
  18. data/app/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
  19. data/app/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
  20. data/app/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
  21. data/app/assets/images/mercury/toolbar/primary/preview.png +0 -0
  22. data/app/assets/images/mercury/toolbar/primary/redo.png +0 -0
  23. data/app/assets/images/mercury/toolbar/primary/save.png +0 -0
  24. data/app/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
  25. data/app/assets/images/mercury/toolbar/primary/tools.png +0 -0
  26. data/app/assets/images/mercury/toolbar/primary/undo.png +0 -0
  27. data/app/assets/images/mercury/toolbar/primary/user.png +0 -0
  28. data/app/assets/images/mercury/toolbar/snippets/buttons.png +0 -0
  29. data/{vendor/assets/javascripts/mercury/dependencies → app/assets/javascripts}/jquery-1.7.js +0 -0
  30. data/{vendor → app}/assets/javascripts/mercury.js +60 -87
  31. data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +0 -0
  32. data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.additions.js +103 -13
  33. data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +0 -0
  34. data/{vendor → app}/assets/javascripts/mercury/dependencies/liquidmetal.js +0 -0
  35. data/{vendor → app}/assets/javascripts/mercury/dependencies/showdown.js +0 -0
  36. data/{vendor → app}/assets/javascripts/mercury/dialog.js.coffee +0 -0
  37. data/{vendor → app}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
  38. data/{vendor → app}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +1 -1
  39. data/{vendor → app}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
  40. data/{vendor → app}/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +1 -1
  41. data/{vendor → app}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
  42. data/{vendor → app}/assets/javascripts/mercury/finalize.js.coffee +0 -0
  43. data/{vendor → app}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
  44. data/{vendor → app}/assets/javascripts/mercury/lightview.js.coffee +38 -17
  45. data/app/assets/javascripts/mercury/locales/ar.locale.js.coffee +201 -0
  46. data/app/assets/javascripts/mercury/locales/da.locale.js.coffee +208 -0
  47. data/{vendor → app}/assets/javascripts/mercury/locales/de.locale.js.coffee +4 -10
  48. data/{vendor → app}/assets/javascripts/mercury/locales/es.locale.js.coffee +3 -9
  49. data/{vendor → app}/assets/javascripts/mercury/locales/example.local.js.coffee +3 -5
  50. data/{vendor → app}/assets/javascripts/mercury/locales/fr.locale.js.coffee +3 -9
  51. data/app/assets/javascripts/mercury/locales/hu.locale.js.coffee +209 -0
  52. data/{vendor → app}/assets/javascripts/mercury/locales/it.locale.js.coffee +3 -9
  53. data/{vendor → app}/assets/javascripts/mercury/locales/ko.local.js.coffee +4 -10
  54. data/{vendor → app}/assets/javascripts/mercury/locales/nl.locale.js.coffee +3 -9
  55. data/app/assets/javascripts/mercury/locales/pl.locale.js.coffee +213 -0
  56. data/{vendor → app}/assets/javascripts/mercury/locales/pt.locale.js.coffee +3 -9
  57. data/app/assets/javascripts/mercury/locales/ru.locale.js.coffee +200 -0
  58. data/{vendor → app}/assets/javascripts/mercury/locales/sv.local.js.coffee +3 -9
  59. data/{vendor → app}/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +3 -9
  60. data/app/assets/javascripts/mercury/locales/uk.locale.js.coffee +200 -0
  61. data/app/assets/javascripts/mercury/locales/zh.local.js.coffee +203 -0
  62. data/app/assets/javascripts/mercury/mercury-compiled.js +10720 -0
  63. data/{vendor → app}/assets/javascripts/mercury/mercury.js.coffee +10 -1
  64. data/{vendor → app}/assets/javascripts/mercury/modal.js.coffee +62 -40
  65. data/{vendor → app}/assets/javascripts/mercury/modals/htmleditor.js.coffee +1 -0
  66. data/{vendor → app}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +1 -0
  67. data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +152 -0
  68. data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +132 -0
  69. data/{vendor → app}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +2 -0
  70. data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +68 -0
  71. data/{vendor → app}/assets/javascripts/mercury/native_extensions.js.coffee +0 -6
  72. data/{vendor → app}/assets/javascripts/mercury/page_editor.js.coffee +84 -50
  73. data/{vendor → app}/assets/javascripts/mercury/palette.js.coffee +1 -1
  74. data/{vendor → app}/assets/javascripts/mercury/panel.js.coffee +3 -2
  75. data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +2 -2
  76. data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +0 -0
  77. data/{vendor → app}/assets/javascripts/mercury/region.js.coffee +18 -17
  78. data/{vendor/assets/javascripts/mercury/regions/editable.js.coffee → app/assets/javascripts/mercury/regions/full.js.coffee} +41 -31
  79. data/app/assets/javascripts/mercury/regions/image.js.coffee +93 -0
  80. data/{vendor/assets/javascripts/mercury/regions/markupable.js.coffee → app/assets/javascripts/mercury/regions/markdown.js.coffee} +29 -24
  81. data/{vendor → app}/assets/javascripts/mercury/regions/simple.js.coffee +11 -54
  82. data/{vendor/assets/javascripts/mercury/regions/snippetable.js.coffee → app/assets/javascripts/mercury/regions/snippets.js.coffee} +10 -9
  83. data/{vendor → app}/assets/javascripts/mercury/select.js.coffee +1 -1
  84. data/app/assets/javascripts/mercury/snippet.js.coffee +136 -0
  85. data/{vendor → app}/assets/javascripts/mercury/snippet_toolbar.js.coffee +19 -6
  86. data/{vendor → app}/assets/javascripts/mercury/statusbar.js.coffee +0 -0
  87. data/{vendor → app}/assets/javascripts/mercury/support/history.js +0 -0
  88. data/{vendor → app}/assets/javascripts/mercury/table_editor.js.coffee +16 -0
  89. data/{vendor → app}/assets/javascripts/mercury/toolbar.button.js.coffee +45 -30
  90. data/{vendor → app}/assets/javascripts/mercury/toolbar.button_group.js.coffee +2 -2
  91. data/{vendor → app}/assets/javascripts/mercury/toolbar.expander.js.coffee +4 -4
  92. data/{vendor → app}/assets/javascripts/mercury/toolbar.js.coffee +10 -6
  93. data/{vendor → app}/assets/javascripts/mercury/tooltip.js.coffee +0 -0
  94. data/{vendor → app}/assets/javascripts/mercury/uploader.js.coffee +37 -19
  95. data/app/assets/stylesheets/_mercury-bootstrap-overrides.scss +61 -0
  96. data/app/assets/stylesheets/_mercury-sass.scss +33 -0
  97. data/{vendor → app}/assets/stylesheets/mercury.css +1 -5
  98. data/{vendor → app}/assets/stylesheets/mercury/all_images.css.erb +6 -2
  99. data/app/assets/stylesheets/mercury/bootstrap-ish.css +1367 -0
  100. data/app/assets/stylesheets/mercury/bootstrap-overrides.css +61 -0
  101. data/{vendor → app}/assets/stylesheets/mercury/dialog.css +21 -8
  102. data/{vendor → app}/assets/stylesheets/mercury/lightview.css +6 -56
  103. data/app/assets/stylesheets/mercury/mercury.css +43 -0
  104. data/{vendor → app}/assets/stylesheets/mercury/modal.css +15 -32
  105. data/{vendor → app}/assets/stylesheets/mercury/statusbar.css +0 -0
  106. data/{vendor → app}/assets/stylesheets/mercury/toolbar.css +4 -1
  107. data/{vendor → app}/assets/stylesheets/mercury/tooltip.css +0 -0
  108. data/{vendor → app}/assets/stylesheets/mercury/uploader.css +4 -4
  109. data/app/helpers/mercury_helper.rb +7 -0
  110. data/app/views/layouts/mercury.html.erb +10 -20
  111. data/app/views/layouts/mercury.html.haml +19 -0
  112. data/app/views/layouts/mercury.html.slim +19 -0
  113. data/app/views/mercury/modals/character.html +1 -1
  114. data/app/views/mercury/modals/htmleditor.html +3 -7
  115. data/app/views/mercury/modals/link.html +37 -51
  116. data/app/views/mercury/modals/media.html +102 -0
  117. data/app/views/mercury/modals/table.html +79 -73
  118. data/app/views/mercury/panels/snippets.html +6 -1
  119. data/app/views/mercury/snippets/example/options.html.erb +23 -27
  120. data/app/views/mercury/snippets/no_options/preview.html.erb +1 -0
  121. data/config/routes.rb +9 -0
  122. data/features/generators/authentication.feature +10 -0
  123. data/features/generators/images.feature +41 -0
  124. data/features/generators/install.feature +21 -0
  125. data/features/loading/loading.feature +5 -2
  126. data/features/loading/user_interface.feature +9 -7
  127. data/features/regions/{editable → full}/advanced_editing.feature +0 -0
  128. data/features/regions/full/basic_editing.feature +198 -0
  129. data/features/regions/{editable → full}/inserting_links.feature +20 -19
  130. data/features/regions/{editable → full}/inserting_media.feature +36 -18
  131. data/features/regions/{editable → full}/inserting_snippets.feature +28 -18
  132. data/features/regions/{editable → full}/inserting_special_characters.feature +2 -2
  133. data/features/regions/full/inserting_tables.feature +109 -0
  134. data/features/regions/{editable → full}/pasting.feature +0 -0
  135. data/features/regions/{editable → full}/uploading_images.feature +0 -0
  136. data/features/regions/{markupable → image}/uploading_images.feature +0 -0
  137. data/features/regions/{markupable → markdown}/advanced_editing.feature +0 -0
  138. data/features/regions/{markupable → markdown}/basic_editing.feature +0 -0
  139. data/features/regions/{markupable → markdown}/inserting_links.feature +0 -0
  140. data/features/regions/{markupable → markdown}/inserting_media.feature +0 -0
  141. data/features/regions/{markupable → markdown}/inserting_snippets.feature +0 -0
  142. data/features/regions/{markupable → markdown}/inserting_special_characters.feature +0 -0
  143. data/features/regions/{markupable → markdown}/inserting_tables.feature +0 -0
  144. data/features/regions/{snippetable/advanced_editing.feature → markdown/uploading_images.feature} +0 -0
  145. data/features/regions/simple/basic_editing.feature +5 -0
  146. data/features/regions/{snippetable/basic_editing.feature → snippets/advanced_editing.feature} +0 -0
  147. data/features/regions/{snippetable/inserting_snippets.feature → snippets/basic_editing.feature} +0 -0
  148. data/{vendor/assets/javascripts/mercury/locales/da.locale.js.coffee → features/regions/snippets/inserting_snippets.feature} +0 -0
  149. data/features/saving/saving.feature +8 -8
  150. data/features/step_definitions/custom_web_steps.rb +22 -0
  151. data/features/step_definitions/generator_steps.rb +23 -0
  152. data/features/step_definitions/mercury_steps.rb +1 -438
  153. data/features/support/aruba.rb +28 -0
  154. data/features/support/env.rb +11 -1
  155. data/features/support/selectors.rb +23 -0
  156. data/lib/generators/mercury/install/authentication/authentication_generator.rb +17 -0
  157. data/lib/generators/mercury/install/images/images_generator.rb +47 -0
  158. data/{app/models/mercury/image.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image.rb} +7 -0
  159. data/{db/migrate/20110526035601_create_mercury_images.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image_migration.rb} +0 -0
  160. data/{app/controllers/mercury → lib/generators/mercury/install/images/templates}/images_controller.rb +0 -0
  161. data/lib/generators/mercury/install/{templates → images/templates}/mongoid_paperclip_image.rb +0 -0
  162. data/lib/generators/mercury/install/install_generator.rb +12 -23
  163. data/lib/mercury-rails.rb +1 -2
  164. data/lib/mercury/authentication.rb +1 -0
  165. data/lib/mercury/cucumber/step_definitions.rb +13 -0
  166. data/lib/mercury/cucumber/step_definitions/mercury_steps.rb +408 -0
  167. data/{features → lib/mercury/cucumber}/support/mercury_contents.rb +3 -3
  168. data/{features → lib/mercury/cucumber}/support/mercury_selectors.rb +0 -20
  169. data/lib/mercury/engine.rb +19 -0
  170. data/lib/mercury/rails.rb +5 -0
  171. data/lib/mercury/version.rb +3 -0
  172. data/spec/dummy/Rakefile +7 -0
  173. data/spec/dummy/app/assets/javascripts/application.js +0 -0
  174. data/spec/dummy/app/assets/javascripts/prototype.js +6082 -0
  175. data/spec/dummy/app/assets/stylesheets/application.css.scss +110 -0
  176. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  177. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  178. data/spec/dummy/app/views/layouts/mercury.html.erb +28 -0
  179. data/spec/dummy/config.ru +4 -0
  180. data/spec/dummy/config/application.rb +58 -0
  181. data/spec/dummy/config/boot.rb +10 -0
  182. data/spec/dummy/config/database.yml +10 -0
  183. data/spec/dummy/config/environment.rb +5 -0
  184. data/spec/dummy/config/environments/development.rb +37 -0
  185. data/spec/dummy/config/environments/production.rb +67 -0
  186. data/spec/dummy/config/environments/test.rb +37 -0
  187. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  188. data/spec/dummy/config/initializers/inflections.rb +15 -0
  189. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  190. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  191. data/spec/dummy/config/initializers/session_store.rb +8 -0
  192. data/spec/dummy/config/initializers/teabag.rb +9 -0
  193. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  194. data/spec/dummy/config/locales/en.yml +5 -0
  195. data/spec/dummy/config/routes.rb +5 -0
  196. data/spec/dummy/db/.gitkeep +0 -0
  197. data/spec/dummy/public/500.html +25 -0
  198. data/spec/dummy/public/blank.html +1 -0
  199. data/spec/dummy/public/favicon.ico +0 -0
  200. data/spec/dummy/public/images/bunny.gif +0 -0
  201. data/spec/dummy/public/images/bunny2.jpg +0 -0
  202. data/spec/dummy/public/index.html +279 -0
  203. data/spec/dummy/script/rails +6 -0
  204. data/spec/javascripts/{templates → fixtures}/mercury/dialog.html +0 -0
  205. data/spec/javascripts/{templates → fixtures}/mercury/dialogs/backcolor.html +0 -0
  206. data/spec/javascripts/{templates → fixtures}/mercury/dialogs/forecolor.html +0 -0
  207. data/spec/javascripts/{templates → fixtures}/mercury/dialogs/formatblock.html +0 -0
  208. data/spec/javascripts/{templates → fixtures}/mercury/dialogs/snippetpanel.html +0 -0
  209. data/spec/javascripts/{templates → fixtures}/mercury/dialogs/style.html +0 -0
  210. data/spec/javascripts/{templates → fixtures}/mercury/lightview.html +0 -0
  211. data/spec/javascripts/{templates → fixtures}/mercury/modal.html +0 -0
  212. data/spec/javascripts/{templates → fixtures}/mercury/modals/htmleditor.html +0 -0
  213. data/spec/javascripts/{templates → fixtures}/mercury/modals/insertcharacter.html +0 -0
  214. data/spec/javascripts/fixtures/mercury/modals/insertlink.html +67 -0
  215. data/spec/javascripts/fixtures/mercury/modals/insertmedia.html +87 -0
  216. data/spec/javascripts/{templates → fixtures}/mercury/modals/insertsnippet.html +0 -0
  217. data/spec/javascripts/fixtures/mercury/modals/inserttable.html +73 -0
  218. data/spec/javascripts/{templates → fixtures}/mercury/page_editor.html +4 -4
  219. data/spec/javascripts/{templates → fixtures}/mercury/palette.html +0 -0
  220. data/spec/javascripts/{templates → fixtures}/mercury/panel.html +0 -0
  221. data/spec/javascripts/fixtures/mercury/region.html +6 -0
  222. data/spec/javascripts/fixtures/mercury/regions/full.html +1 -0
  223. data/spec/javascripts/fixtures/mercury/regions/image.html +1 -0
  224. data/spec/javascripts/fixtures/mercury/regions/markdown.html +1 -0
  225. data/spec/javascripts/fixtures/mercury/regions/simple.html +1 -0
  226. data/spec/javascripts/fixtures/mercury/regions/snippets.html +4 -0
  227. data/spec/javascripts/{templates → fixtures}/mercury/select.html +0 -0
  228. data/spec/javascripts/{templates → fixtures}/mercury/snippet.html +0 -0
  229. data/spec/javascripts/{templates → fixtures}/mercury/snippet_toolbar.html +0 -0
  230. data/spec/javascripts/{templates → fixtures}/mercury/statusbar.html +0 -0
  231. data/spec/javascripts/{templates → fixtures}/mercury/table_editor.html +0 -0
  232. data/spec/javascripts/{templates → fixtures}/mercury/toolbar.button.html +0 -0
  233. data/spec/javascripts/{templates → fixtures}/mercury/toolbar.button_group.html +0 -0
  234. data/spec/javascripts/{templates → fixtures}/mercury/toolbar.expander.html +0 -0
  235. data/spec/javascripts/{templates → fixtures}/mercury/toolbar.html +0 -0
  236. data/spec/javascripts/{templates → fixtures}/mercury/tooltip.html +0 -0
  237. data/spec/javascripts/{templates → fixtures}/mercury/uploader.html +0 -0
  238. data/spec/javascripts/mercury/{dialog_spec.js.coffee → dialog_spec.coffee} +11 -12
  239. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +2 -3
  240. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +3 -4
  241. data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +2 -3
  242. data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +2 -3
  243. data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +2 -3
  244. data/spec/javascripts/mercury/lightview_spec.js.coffee +180 -142
  245. data/spec/javascripts/mercury/mercury_spec.js.coffee +19 -13
  246. data/spec/javascripts/mercury/modal_spec.js.coffee +192 -148
  247. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +4 -5
  248. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +2 -3
  249. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +107 -34
  250. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +106 -26
  251. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +2 -3
  252. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +50 -40
  253. data/spec/javascripts/mercury/page_editor_spec.js.coffee +124 -80
  254. data/spec/javascripts/mercury/palette_spec.js.coffee +4 -5
  255. data/spec/javascripts/mercury/panel_spec.js.coffee +9 -12
  256. data/spec/javascripts/mercury/region_spec.js.coffee +22 -17
  257. data/spec/javascripts/mercury/regions/{editable_spec.js.coffee → full_spec.js.coffee} +26 -28
  258. data/spec/javascripts/mercury/regions/image_spec.js.coffee +33 -0
  259. data/spec/javascripts/mercury/regions/{markupable_spec.js.coffee → markdown_spec.js.coffee} +32 -34
  260. data/spec/javascripts/mercury/regions/simple_spec.js.coffee +32 -0
  261. data/spec/javascripts/mercury/regions/{snippetable_spec.js.coffee → snippets_spec.js.coffee} +54 -55
  262. data/spec/javascripts/mercury/select_spec.js.coffee +4 -5
  263. data/spec/javascripts/mercury/snippet_spec.js.coffee +92 -16
  264. data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +31 -16
  265. data/spec/javascripts/mercury/statusbar_spec.js.coffee +9 -10
  266. data/spec/javascripts/mercury/table_editor_spec.js.coffee +1 -2
  267. data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +7 -9
  268. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +55 -26
  269. data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +13 -13
  270. data/spec/javascripts/mercury/toolbar_spec.js.coffee +43 -14
  271. data/spec/javascripts/mercury/tooltip_spec.js.coffee +1 -2
  272. data/spec/javascripts/mercury/uploader_spec.js.coffee +47 -33
  273. data/spec/javascripts/spec_helper.coffee +4 -0
  274. data/spec/javascripts/{spec_helper.js → support/event_simulation.js} +0 -2
  275. data/spec/teabag_env.rb +32 -0
  276. metadata +366 -196
  277. data/features/regions/editable/basic_editing.feature +0 -195
  278. data/features/regions/editable/inserting_tables.feature +0 -109
  279. data/spec/javascripts/templates/mercury/modals/insertlink.html +0 -30
  280. data/spec/javascripts/templates/mercury/modals/insertmedia.html +0 -35
  281. data/spec/javascripts/templates/mercury/modals/inserttable.html +0 -27
  282. data/spec/javascripts/templates/mercury/region.html +0 -2
  283. data/spec/javascripts/templates/mercury/regions/editable.html +0 -3
  284. data/spec/javascripts/templates/mercury/regions/snippetable.html +0 -4
  285. data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +0 -54
  286. data/vendor/assets/javascripts/mercury_loader.js +0 -193
  287. data/vendor/assets/javascripts/mercury_overrides.js +0 -6
  288. data/vendor/assets/stylesheets/mercury/mercury.css +0 -151
  289. data/vendor/assets/stylesheets/mercury_overrides.css +0 -17
@@ -1,4 +1,5 @@
1
1
  @Mercury.modalHandlers.insertSnippet = ->
2
+
2
3
  @element.find('form').on 'submit', (event) =>
3
4
  event.preventDefault()
4
5
  serializedForm = @element.find('form').serializeObject()
@@ -10,3 +11,4 @@
10
11
  snippet = Mercury.Snippet.create(@options.snippetName, serializedForm)
11
12
  Mercury.trigger('action', {action: 'insertSnippet', value: snippet})
12
13
  @hide()
14
+
@@ -0,0 +1,68 @@
1
+ @Mercury.modalHandlers.insertTable = {
2
+
3
+ initialize: ->
4
+ @table = @element.find('#table_display table')
5
+
6
+ @table.on 'click', (event) => @onCellClick($(event.target))
7
+
8
+ @element.find('#table_alignment').on 'change', => @setTableAlignment()
9
+ @element.find('#table_border').on 'keyup', => @setTableBorder()
10
+ @element.find('#table_spacing').on 'keyup', => @setTableCellSpacing()
11
+ @element.find('[data-action]').on 'click', (event) =>
12
+ event.preventDefault()
13
+ @onActionClick(jQuery(event.target).data('action'))
14
+
15
+ @selectFirstCell()
16
+
17
+ @element.find('form').on 'submit', (event) =>
18
+ event.preventDefault()
19
+ @submitForm()
20
+ @hide()
21
+
22
+
23
+ selectFirstCell: ->
24
+ firstCell = @table.find('td, th').first()
25
+ firstCell.addClass('selected')
26
+ Mercury.tableEditor(@table, firstCell, ' ')
27
+
28
+
29
+ onCellClick: (@cell) ->
30
+ @table = @cell.closest('table')
31
+ @table.find('.selected').removeAttr('class')
32
+ @cell.addClass('selected')
33
+ Mercury.tableEditor(@table, @cell, ' ')
34
+
35
+
36
+ onActionClick: (action) ->
37
+ return unless action
38
+ Mercury.tableEditor[action]()
39
+
40
+
41
+ setTableAlignment: ->
42
+ @table.attr({align: @element.find('#table_alignment').val()})
43
+
44
+ setTableBorder: ->
45
+ border = parseInt(@element.find('#table_border').val(), 10)
46
+ if isNaN(border)
47
+ @table.removeAttr('border')
48
+ else
49
+ @table.attr({border: border})
50
+
51
+ setTableCellSpacing: ->
52
+ cellspacing = parseInt(@element.find('#table_spacing').val(), 10)
53
+ if isNaN(cellspacing)
54
+ @table.removeAttr('cellspacing')
55
+ else
56
+ @table.attr({cellspacing: cellspacing})
57
+
58
+
59
+ submitForm: ->
60
+ @table.find('.selected').removeAttr('class')
61
+ @table.find('td, th').html('<br/>')
62
+
63
+ html = jQuery('<div>').html(@table).html()
64
+ value = html.replace(/^\s+|\n/gm, '').replace(/(<\/.*?>|<table.*?>|<tbody>|<tr>)/g, '$1\n')
65
+
66
+ Mercury.trigger('action', {action: 'insertTable', value: value})
67
+
68
+ }
@@ -47,9 +47,3 @@ Number::toBytes = ->
47
47
  bytes /= 1024
48
48
  i += 1
49
49
  return if i then "#{bytes.toFixed(2)}#{['', ' kb', ' Mb', ' Gb', ' Tb', ' Pb', ' Eb'][i]}" else "#{bytes} bytes"
50
-
51
-
52
- # make setTimeout not suck for coffeescript
53
- window.originalSetTimeout = window.setTimeout
54
- window.setTimeout = (arg1, arg2) ->
55
- if typeof(arg1) == 'number' then window.originalSetTimeout(arg2, arg1) else window.originalSetTimeout(arg1, arg2)
@@ -3,13 +3,14 @@ class @Mercury.PageEditor
3
3
  # options
4
4
  # saveStyle: 'form', or 'json' (defaults to json)
5
5
  # saveDataType: 'xml', 'json', 'jsonp', 'script', 'text', 'html' (defaults to json)
6
- # saveMethod: 'POST', or 'PUT', create or update actions on save (defaults to POST)
6
+ # saveMethod: 'POST', or 'PUT', create or update actions on save (defaults to PUT)
7
7
  # visible: boolean, if the interface should start visible or not (defaults to true)
8
8
  constructor: (@saveUrl = null, @options = {}) ->
9
9
  throw Mercury.I18n('Mercury.PageEditor can only be instantiated once.') if window.mercuryInstance
10
10
 
11
- @options.visible = true unless (@options.visible == false || @options.visible == 'no')
11
+ @options.visible = true unless (@options.visible == false || @options.visible == 'false')
12
12
  @visible = @options.visible
13
+ @options.saveDataType = 'json' unless (@options.saveDataType == false || @options.saveDataType)
13
14
 
14
15
  window.mercuryInstance = @
15
16
  @regions = []
@@ -20,25 +21,28 @@ class @Mercury.PageEditor
20
21
  initializeInterface: ->
21
22
  @focusableElement = jQuery('<input>', {class: 'mercury-focusable', type: 'text'}).appendTo(@options.appendTo ? 'body')
22
23
 
23
- @iframe = jQuery('<iframe>', {id: 'mercury_iframe', class: 'mercury-iframe', seamless: 'true', frameborder: '0', src: 'about:blank'})
24
+ @iframe = jQuery('<iframe>', {id: 'mercury_iframe', name: 'mercury_iframe', class: 'mercury-iframe', frameborder: '0', src: 'about:blank'})
24
25
  @iframe.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
25
26
 
26
- @toolbar = new Mercury.Toolbar(@options)
27
- @statusbar = new Mercury.Statusbar(@options)
27
+ @toolbar = new Mercury.Toolbar(jQuery.extend(true, {}, @options, @options.toolbarOptions))
28
+ @statusbar = new Mercury.Statusbar(jQuery.extend(true, {}, @options, @options.statusbarOptions))
28
29
  @resize()
29
30
 
31
+ @iframe.one 'load', => @bindEvents()
30
32
  @iframe.on 'load', => @initializeFrame()
31
- @iframe.get(0).contentWindow.document.location.href = @iframeSrc(null, true)
33
+ @loadIframeSrc(null)
32
34
 
33
35
 
34
36
  initializeFrame: ->
35
37
  try
36
38
  return if @iframe.data('loaded')
37
39
  @iframe.data('loaded', true)
38
- Mercury.notify("Opera isn't a fully supported browser, your results may not be optimal.") if jQuery.browser.opera
40
+
41
+ # set document reference of iframe
39
42
  @document = jQuery(@iframe.get(0).contentWindow.document)
40
- stylesToInject = Mercury.config.injectedStyles.replace(/{{regionClass}}/g, Mercury.config.regions.className)
41
- jQuery("<style mercury-styles=\"true\">").html(stylesToInject).appendTo(@document.find('head'))
43
+
44
+ # inject styles for document to be able to highlight regions and other tools
45
+ jQuery("<style mercury-styles=\"true\">").html(Mercury.config.injectedStyles).appendTo(@document.find('head'))
42
46
 
43
47
  # jquery: make jQuery evaluate scripts within the context of the iframe window
44
48
  iframeWindow = @iframe.get(0).contentWindow
@@ -47,12 +51,15 @@ class @Mercury.PageEditor
47
51
  iframeWindow.Mercury = Mercury
48
52
  iframeWindow.History = History if window.History && History.Adapter
49
53
 
50
- @bindEvents()
54
+ # (re) initialize the editor against the new document
55
+ @bindDocumentEvents()
51
56
  @resize()
52
57
  @initializeRegions()
53
58
  @finalizeInterface()
59
+
60
+ # trigger ready events
54
61
  Mercury.trigger('ready')
55
- jQuery(iframeWindow).trigger('mercury:ready')
62
+ iframeWindow.jQuery(iframeWindow).trigger('mercury:ready') if iframeWindow.jQuery
56
63
  iframeWindow.Event.fire(iframeWindow, 'mercury:ready') if iframeWindow.Event && iframeWindow.Event.fire
57
64
  iframeWindow.onMercuryReady() if iframeWindow.onMercuryReady
58
65
 
@@ -63,8 +70,8 @@ class @Mercury.PageEditor
63
70
 
64
71
  initializeRegions: ->
65
72
  @regions = []
66
- @buildRegion(jQuery(region)) for region in jQuery(".#{Mercury.config.regions.className}", @document)
67
- return unless @options.visible
73
+ @buildRegion(jQuery(region)) for region in jQuery("[#{Mercury.config.regions.attribute}]", @document)
74
+ return unless @visible
68
75
  for region in @regions
69
76
  if region.focus
70
77
  region.focus()
@@ -75,11 +82,7 @@ class @Mercury.PageEditor
75
82
  if region.data('region')
76
83
  region = region.data('region')
77
84
  else
78
- type = (
79
- region.data('type') ||
80
- ( jQuery.type(Mercury.config.regions.determineType) == 'function' && Mercury.config.regions.determineType(region) ) ||
81
- 'unknown'
82
- ).titleize()
85
+ type = (region.attr(Mercury.config.regions.attribute) || Mercury.config.regions.determineType?(region) || 'unknown').titleize()
83
86
  throw Mercury.I18n('Region type is malformed, no data-type provided, or "%s" is unknown for the "%s" region.', type, region.attr('id') || 'unknown') if type == 'Unknown' || !Mercury.Regions[type]
84
87
  if !Mercury.Regions[type].supported
85
88
  Mercury.notify('Mercury.Regions.%s is unsupported in this client. Supported browsers are %s.', type, Mercury.Regions[type].supportedText)
@@ -90,43 +93,46 @@ class @Mercury.PageEditor
90
93
 
91
94
 
92
95
  finalizeInterface: ->
93
- @santizerElement = jQuery('<div>', {id: 'mercury_sanitizer', contenteditable: 'true', style: 'position:fixed;width:100px;height:100px;top:0;left:-100px;opacity:0;overflow:hidden'})
96
+ @santizerElement = jQuery('<div>', {id: 'mercury_sanitizer', contenteditable: 'true', style: 'position:fixed;width:100px;height:100px;min-width:0;top:0;left:-100px;opacity:0;overflow:hidden'})
94
97
  @santizerElement.appendTo(@options.appendTo ? @document.find('body'))
95
98
 
99
+ @snippetToolbar.release() if @snippetToolbar
96
100
  @snippetToolbar = new Mercury.SnippetToolbar(@document)
97
101
 
98
102
  @hijackLinksAndForms()
99
- Mercury.trigger('mode', {mode: 'preview'}) unless @options.visible
103
+ Mercury.trigger('mode', {mode: 'preview'}) unless @visible
104
+
105
+
106
+ bindDocumentEvents: ->
107
+ @document.on 'mousedown', (event) ->
108
+ Mercury.trigger('hide:dialogs')
109
+ if Mercury.region
110
+ Mercury.trigger('unfocus:regions') unless jQuery(event.target).closest("[#{Mercury.config.regions.attribute}]").get(0) == Mercury.region.element.get(0)
111
+
112
+ jQuery(@document).bind 'keydown', (event) =>
113
+ return unless event.ctrlKey || event.metaKey
114
+ if (event.keyCode == 83) # meta+S
115
+ Mercury.trigger('action', {action: 'save'})
116
+ event.preventDefault()
100
117
 
101
118
 
102
119
  bindEvents: ->
103
120
  Mercury.on 'autosave', => @autosave()
104
- Mercury.on 'initialize:frame', => setTimeout(100, @initializeFrame)
121
+ Mercury.on 'initialize:frame', => setTimeout(@initializeFrame, 100)
105
122
  Mercury.on 'focus:frame', => @iframe.focus()
106
- Mercury.on 'focus:window', => setTimeout(10, => @focusableElement.focus())
123
+ Mercury.on 'focus:window', => setTimeout((=> @focusableElement.focus()), 10)
107
124
  Mercury.on 'toggle:interface', => @toggleInterface()
108
125
  Mercury.on 'reinitialize', => @initializeRegions()
109
126
  Mercury.on 'mode', (event, options) => @previewing = !@previewing if options.mode == 'preview'
110
127
  Mercury.on 'action', (event, options) =>
111
128
  action = Mercury.config.globalBehaviors[options.action] || @[options.action]
112
129
  return unless typeof(action) == 'function'
113
- options.already_handled = true
130
+ event.preventDefault()
114
131
  action.call(@, options)
115
132
 
116
- @document.on 'mousedown', (event) ->
117
- Mercury.trigger('hide:dialogs')
118
- if Mercury.region
119
- Mercury.trigger('unfocus:regions') unless jQuery(event.target).closest(".#{Mercury.config.regions.className}").get(0) == Mercury.region.element.get(0)
120
-
121
133
  jQuery(window).on 'resize', =>
122
134
  @resize()
123
135
 
124
- jQuery(@document).bind 'keydown', (event) =>
125
- return unless event.ctrlKey || event.metaKey
126
- if (event.keyCode == 83) # meta+S
127
- Mercury.trigger('action', {action: 'save'})
128
- event.preventDefault()
129
-
130
136
  jQuery(window).bind 'keydown', (event) =>
131
137
  return unless event.ctrlKey || event.metaKey
132
138
  if (event.keyCode == 83) # meta+S
@@ -138,22 +144,25 @@ class @Mercury.PageEditor
138
144
 
139
145
  toggleInterface: ->
140
146
  if @visible
141
- Mercury.trigger('mode', {mode: 'preview'}) if @previewing
142
147
  @visible = false
143
148
  @toolbar.hide()
144
149
  @statusbar.hide()
150
+ Mercury.trigger('mode', {mode: 'preview'}) unless @previewing
151
+ @previewing = true
152
+ @resize()
145
153
  else
146
154
  @visible = true
155
+ @iframe.animate({top: @toolbar.height(true)}, 200, 'easeInOutSine', => @resize())
147
156
  @toolbar.show()
148
157
  @statusbar.show()
149
- Mercury.trigger('mode', {mode: 'preview'})
150
- @resize()
158
+ Mercury.trigger('mode', {mode: 'preview'})
159
+ @previewing = false
151
160
 
152
161
 
153
162
  resize: ->
154
163
  width = jQuery(window).width()
155
164
  height = @statusbar.top()
156
- toolbarHeight = @toolbar.height()
165
+ toolbarHeight = @toolbar.top() + @toolbar.height()
157
166
 
158
167
  Mercury.displayRect = {top: toolbarHeight, left: 0, width: width, height: height - toolbarHeight, fullHeight: height}
159
168
 
@@ -167,14 +176,25 @@ class @Mercury.PageEditor
167
176
 
168
177
 
169
178
  iframeSrc: (url = null, params = false) ->
179
+ # remove the /editor segment of the url if it gets passed through
170
180
  url = (url ? window.location.href).replace(Mercury.config.editorUrlRegEx ?= /([http|https]:\/\/.[^\/]*)\/editor\/?(.*)/i, "$1/$2")
171
- url = url.replace(/[\?|\&]mercury_frame=true/gi, '')
181
+ url = url.replace(/[\?|\&]mercury_frame=true/gi, '').replace(/\&_=\d+/gi, '').replace(/#$/, '')
172
182
  if params
173
- return "#{url}#{if url.indexOf('?') > -1 then '&' else '?'}mercury_frame=true"
183
+ # add a param allowing the server to know that the request is coming from mercury
184
+ # and add a cache busting param so we don't get stale content
185
+ return "#{url}#{if url.indexOf('?') > -1 then '&' else '?'}mercury_frame=true&_=#{new Date().getTime()}"
174
186
  else
175
187
  return url
176
188
 
177
189
 
190
+ loadIframeSrc: (url)->
191
+ # clear any existing events if we are loading a new iframe to replace the existing one
192
+ @document.off() if @document
193
+
194
+ @iframe.data('loaded', false)
195
+ @iframe.get(0).contentWindow.document.location.href = @iframeSrc(url, true)
196
+
197
+
178
198
  hijackLinksAndForms: ->
179
199
  for element in jQuery('a, form', @document)
180
200
  ignored = false
@@ -182,7 +202,7 @@ class @Mercury.PageEditor
182
202
  if jQuery(element).hasClass(classname)
183
203
  ignored = true
184
204
  continue
185
- if !ignored && (element.target == '' || element.target == '_self') && !jQuery(element).closest(".#{Mercury.config.regions.className}").length
205
+ if !ignored && (element.target == '' || element.target == '_self') && !jQuery(element).closest("[#{Mercury.config.regions.attribute}]").length
186
206
  jQuery(element).attr('target', '_parent')
187
207
 
188
208
 
@@ -214,22 +234,35 @@ class @Mercury.PageEditor
214
234
  }
215
235
 
216
236
  save: (callback) ->
217
- url = @saveUrl ? Mercury.saveURL ? @iframeSrc()
237
+ url = @saveUrl ? Mercury.saveUrl ? @iframeSrc()
218
238
  data = @serialize()
239
+ data = {content: data}
240
+
241
+ if @options.saveMethod == 'POST'
242
+ method = 'POST'
243
+ else
244
+ method = 'PUT'
245
+ data['_method'] = method
246
+
219
247
  Mercury.log('saving', data)
220
- data = jQuery.toJSON(data) unless @options.saveStyle == 'form'
221
- method = 'PUT' if @options.saveMethod == 'PUT'
222
- jQuery.ajax url, {
248
+
249
+ options = {
223
250
  headers: Mercury.ajaxHeaders()
224
- type: method || 'POST'
225
- data: {content: data, _method: method}
226
- success: =>
251
+ type: method
252
+ dataType: @options.saveDataType
253
+ data: data
254
+ success: (response) =>
227
255
  Mercury.changes = false
228
- Mercury.trigger('saved')
256
+ Mercury.trigger('saved', response)
229
257
  callback() if typeof(callback) == 'function'
230
- error: =>
258
+ error: (response) =>
259
+ Mercury.trigger('save_failed', response)
231
260
  Mercury.notify('Mercury was unable to save to the url: %s', url)
232
261
  }
262
+ if @options.saveStyle != 'form'
263
+ options['data'] = jQuery.toJSON(data)
264
+ options['contentType'] = 'application/json'
265
+ jQuery.ajax url, options
233
266
 
234
267
 
235
268
  serialize: ->
@@ -238,3 +271,4 @@ class @Mercury.PageEditor
238
271
  Mercury.log("region", region)
239
272
  serialized[region.name] = region.serialize()
240
273
  return serialized
274
+
@@ -16,7 +16,7 @@ class @Mercury.Palette extends Mercury.Dialog
16
16
 
17
17
  position: (keepVisible) ->
18
18
  @element.css({top: 0, left: 0, display: 'block', visibility: 'hidden'})
19
- position = @button.offset()
19
+ position = @button.position()
20
20
  width = @element.width()
21
21
 
22
22
  position.left = position.left - width + @button.width() if position.left + width > jQuery(window).width()
@@ -6,7 +6,7 @@ class @Mercury.Panel extends Mercury.Dialog
6
6
 
7
7
  build: ->
8
8
  @element = jQuery('<div>', {class: 'mercury-panel loading', style: 'display:none;'})
9
- @titleElement = jQuery("<h1>#{Mercury.I18n(@options.title)}</h1>").appendTo(@element)
9
+ @titleElement = jQuery("<h1><span>#{Mercury.I18n(@options.title)}</span></h1>").appendTo(@element)
10
10
  @paneElement = jQuery('<div>', {class: 'mercury-panel-pane'}).appendTo(@element)
11
11
 
12
12
  if @options.closeButton
@@ -57,6 +57,7 @@ class @Mercury.Panel extends Mercury.Dialog
57
57
  @titleElement.find('.mercury-panel-close').animate({opacity: 1}, 100)
58
58
 
59
59
  @paneElement.css({display: 'block', width: postWidth})
60
+ jQuery(@paneElement.find('.focusable').get(0)).focus()
60
61
  @makeDraggable()
61
62
 
62
63
  @hide() unless @visible
@@ -100,7 +101,7 @@ class @Mercury.Panel extends Mercury.Dialog
100
101
  makeDraggable: ->
101
102
  elementWidth = @element.width()
102
103
  @element.draggable {
103
- handle: 'h1',
104
+ handle: 'h1 span',
104
105
  axis: 'x',
105
106
  opacity: 0.70
106
107
  scroll: false,
@@ -1,7 +1,7 @@
1
1
  class Mercury.PageEditor extends Mercury.PageEditor
2
2
 
3
3
  save: ->
4
- url = @saveUrl ? Mercury.saveURL ? @iframeSrc()
4
+ url = @saveUrl ? Mercury.saveUrl ? @iframeSrc()
5
5
  data = @serializeAsXml()
6
6
  console.log('saving', data)
7
7
  return
@@ -25,4 +25,4 @@ class Mercury.PageEditor extends Mercury.PageEditor
25
25
  for snippetName, snippetProperties of regionProperties['snippets']
26
26
  snippetNodes.push("<#{snippetName} name=\"#{snippetProperties['name']}\"><![CDATA[#{jQuery.toJSON(snippetProperties['options'])}]]></#{snippetName}>")
27
27
  regionNodes.push("<region name=\"#{regionName}\" type=\"#{regionProperties['type']}\"><value>\n<![CDATA[#{regionProperties['value']}]]>\n</value><snippets>#{snippetNodes.join('')}</snippets></region>")
28
- return "<regions>#{regionNodes.join('')}</regions>"
28
+ return "<regions>#{regionNodes.join('')}</regions>"
@@ -1,10 +1,7 @@
1
1
  class @Mercury.Region
2
- type = 'region'
3
2
 
4
3
  constructor: (@element, @window, @options = {}) ->
5
- @type = 'region' unless @type
6
- Mercury.log("building #{@type}", @element, @options)
7
-
4
+ Mercury.log("building #{@type()}", @element, @options)
8
5
  @document = @window.document
9
6
  @name = @element.attr(Mercury.config.regions.identifier)
10
7
  @history = new Mercury.HistoryBuffer()
@@ -14,6 +11,9 @@ class @Mercury.Region
14
11
  @element.data('region', @)
15
12
 
16
13
 
14
+ type: -> 'unknown'
15
+
16
+
17
17
  build: ->
18
18
 
19
19
 
@@ -28,15 +28,15 @@ class @Mercury.Region
28
28
  @focus()
29
29
 
30
30
  Mercury.on 'action', (event, options) =>
31
- return if @previewing || Mercury.region != @
31
+ return if @previewing || Mercury.region != @ || event.isDefaultPrevented()
32
32
  @execCommand(options.action, options) if options.action
33
33
 
34
34
  @element.on 'mousemove', (event) =>
35
35
  return if @previewing || Mercury.region != @
36
- snippet = jQuery(event.target).closest('.mercury-snippet')
36
+ snippet = jQuery(event.target).closest('[data-snippet]')
37
37
  if snippet.length
38
38
  @snippet = snippet
39
- Mercury.trigger('show:toolbar', {type: 'snippet', snippet: @snippet})
39
+ Mercury.trigger('show:toolbar', {type: 'snippet', snippet: @snippet}) if @snippet.data('snippet')
40
40
 
41
41
  @element.on 'mouseout', =>
42
42
  return if @previewing
@@ -48,11 +48,13 @@ class @Mercury.Region
48
48
  @element.html(value)
49
49
  else
50
50
  # sanitize the html before we return it
51
- container = jQuery('<div>').appendTo(@document.createDocumentFragment())
52
- container.html(@element.html().replace(/^\s+|\s+$/g, ''))
51
+ # create the element without jQuery since $el.html() executes <script> tags
52
+ container = document.createElement('div')
53
+ container.innerHTML = @element.html().replace(/^\s+|\s+$/g, '')
54
+ container = $(container)
53
55
 
54
56
  # replace snippet contents to be an identifier
55
- if filterSnippets then for snippet in container.find('.mercury-snippet')
57
+ if filterSnippets then for snippet in container.find('[data-snippet]')
56
58
  snippet = jQuery(snippet)
57
59
  snippet.attr({contenteditable: null, 'data-version': null})
58
60
  snippet.html("[#{snippet.data('snippet')}]")
@@ -63,11 +65,11 @@ class @Mercury.Region
63
65
  togglePreview: ->
64
66
  if @previewing
65
67
  @previewing = false
66
- @element.addClass(Mercury.config.regions.className).removeClass("#{Mercury.config.regions.className}-preview")
68
+ @element.attr(Mercury.config.regions.attribute, @type())
67
69
  @focus() if Mercury.region == @
68
70
  else
69
71
  @previewing = true
70
- @element.addClass("#{Mercury.config.regions.className}-preview").removeClass(Mercury.config.regions.className)
72
+ @element.removeAttr(Mercury.config.regions.attribute)
71
73
  Mercury.trigger('region:blurred', {region: @})
72
74
 
73
75
 
@@ -76,7 +78,7 @@ class @Mercury.Region
76
78
  @pushHistory() unless action == 'redo'
77
79
 
78
80
  Mercury.log('execCommand', action, options.value)
79
- Mercury.changes = true unless options.already_handled
81
+ Mercury.changes = true
80
82
 
81
83
 
82
84
  pushHistory: ->
@@ -87,20 +89,19 @@ class @Mercury.Region
87
89
  snippets = {}
88
90
  for element in @element.find('[data-snippet]')
89
91
  snippet = Mercury.Snippet.find(jQuery(element).data('snippet'))
90
- snippet.setVersion(jQuery(element).data('version'))
92
+ continue unless snippet
91
93
  snippets[snippet.identity] = snippet.serialize()
92
94
  return snippets
93
95
 
94
96
 
95
97
  dataAttributes: ->
96
98
  data = {}
97
- o = if @type=='simple' then jQuery(this.container[0]) else @element
98
- data[attr] = o.attr('data-' + attr) for attr in Mercury.config.regions.dataAttributes
99
+ data[attr] = (@container || @element).attr('data-' + attr) for attr in Mercury.config.regions.dataAttributes
99
100
  return data
100
101
 
101
102
  serialize: ->
102
103
  return {
103
- type: @type
104
+ type: @type()
104
105
  data: @dataAttributes()
105
106
  value: @content(null, true)
106
107
  snippets: @snippets()