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,14 +1,13 @@
1
1
  describe "Mercury.modalHandlers.insertSnippet", ->
2
2
 
3
- template 'mercury/modals/insertsnippet.html'
4
-
5
3
  beforeEach ->
4
+ fixture.load('mercury/modals/insertsnippet.html')
6
5
  Mercury.Snippet.all = []
7
6
  Mercury.Snippet.load({
8
7
  'snippet_0': {name: 'foo', options: {'first_name': "Jeremy", 'last_name': "Jackson"}},
9
8
  })
10
9
  @modal =
11
- element: $('#test')
10
+ element: $(fixture.el)
12
11
  hide: ->
13
12
  options: {snippetName: 'test'}
14
13
  Mercury.modalHandlers.insertSnippet.call(@modal)
@@ -1,31 +1,31 @@
1
1
  describe "Mercury.modalHandlers.insertTable", ->
2
2
 
3
- template 'mercury/modals/inserttable.html'
4
-
5
3
  beforeEach ->
4
+ fixture.load('mercury/modals/inserttable.html')
6
5
  @modal =
7
- element: $('#test')
6
+ element: $(fixture.el)
8
7
  hide: ->
8
+ @insertTable = $.extend(@modal, Mercury.modalHandlers.insertTable)
9
9
 
10
10
  describe "initializing", ->
11
11
 
12
12
  beforeEach ->
13
13
  @tableEditorSpy = spyOn(Mercury, 'tableEditor').andCallFake(=>)
14
- Mercury.modalHandlers.insertTable.call(@modal)
14
+ @insertTable.initialize()
15
15
 
16
16
  it "selects the first cell", ->
17
17
  expect($('#cell1').hasClass('selected')).toEqual(true)
18
18
 
19
19
  it "sets the table editor up", ->
20
20
  expect(@tableEditorSpy.callCount).toEqual(1)
21
- expect(@tableEditorSpy.argsForCall[0][0].get(0)).toEqual($('#table').get(0))
21
+ expect(@tableEditorSpy.argsForCall[0][0].get(0)).toEqual($('table').get(0))
22
22
  expect(@tableEditorSpy.argsForCall[0][1].get(0)).toEqual($('#cell1').get(0))
23
23
 
24
24
  describe "clicking on the cells", ->
25
25
 
26
26
  beforeEach ->
27
27
  @tableEditorSpy = spyOn(Mercury, 'tableEditor').andCallFake(=>)
28
- Mercury.modalHandlers.insertTable.call(@modal)
28
+ @insertTable.initialize()
29
29
 
30
30
  it "should unselect any selected cells", ->
31
31
  jasmine.simulate.click($('#cell2').get(0))
@@ -44,58 +44,56 @@ describe "Mercury.modalHandlers.insertTable", ->
44
44
  describe "clicking on the action buttons", ->
45
45
 
46
46
  beforeEach ->
47
- @addRowSpy = spyOn(Mercury.tableEditor, 'addRow').andCallFake(=>)
48
- @removeRowSpy = spyOn(Mercury.tableEditor, 'removeRow').andCallFake(=>)
49
- @addColumnSpy = spyOn(Mercury.tableEditor, 'addColumn').andCallFake(=>)
50
- @removeColumnSpy = spyOn(Mercury.tableEditor, 'removeColumn').andCallFake(=>)
47
+ @addRowBeforeSpy = spyOn(Mercury.tableEditor, 'addRowBefore').andCallFake(=>)
48
+ @addRowSpy = spyOn(Mercury.tableEditor, 'addRow').andCallFake(=>)
49
+ @removeRowSpy = spyOn(Mercury.tableEditor, 'removeRow').andCallFake(=>)
50
+ @addColumnBeforeSpy = spyOn(Mercury.tableEditor, 'addColumnBefore').andCallFake(=>)
51
+ @addColumnSpy = spyOn(Mercury.tableEditor, 'addColumn').andCallFake(=>)
52
+ @removeColumnSpy = spyOn(Mercury.tableEditor, 'removeColumn').andCallFake(=>)
51
53
  @increaseColspanSpy = spyOn(Mercury.tableEditor, 'increaseColspan').andCallFake(=>)
52
54
  @decreaseColspanSpy = spyOn(Mercury.tableEditor, 'decreaseColspan').andCallFake(=>)
53
55
  @increaseRowspanSpy = spyOn(Mercury.tableEditor, 'increaseRowspan').andCallFake(=>)
54
56
  @decreaseRowspanSpy = spyOn(Mercury.tableEditor, 'decreaseRowspan').andCallFake(=>)
55
- Mercury.modalHandlers.insertTable.call(@modal)
57
+ @insertTable.initialize()
56
58
 
57
59
  it "adds a row before the selected cell", ->
58
- jasmine.simulate.click($('input[name=insertRowBefore]').get(0))
59
- expect(@addRowSpy.callCount).toEqual(1)
60
- expect(@addRowSpy.argsForCall[0]).toEqual(['before'])
60
+ jasmine.simulate.click($('[data-action=addRowBefore]').get(0))
61
+ expect(@addRowBeforeSpy.callCount).toEqual(1)
61
62
 
62
63
  it "adds a row after the selected cell", ->
63
- jasmine.simulate.click($('input[name=insertRowAfter]').get(0))
64
+ jasmine.simulate.click($('[data-action=addRow]').get(0))
64
65
  expect(@addRowSpy.callCount).toEqual(1)
65
- expect(@addRowSpy.argsForCall[0]).toEqual(['after'])
66
66
 
67
67
  it "deletes the row of the selected cell", ->
68
- jasmine.simulate.click($('input[name=deleteRow]').get(0))
68
+ jasmine.simulate.click($('[data-action=removeRow]').get(0))
69
69
  expect(@removeRowSpy.callCount).toEqual(1)
70
70
 
71
71
  it "adds a column before the selected cell", ->
72
- jasmine.simulate.click($('input[name=insertColumnBefore]').get(0))
73
- expect(@addColumnSpy.callCount).toEqual(1)
74
- expect(@addColumnSpy.argsForCall[0]).toEqual(['before'])
72
+ jasmine.simulate.click($('[data-action=addColumnBefore]').get(0))
73
+ expect(@addColumnBeforeSpy.callCount).toEqual(1)
75
74
 
76
75
  it "adds a column after the selected cell", ->
77
- jasmine.simulate.click($('input[name=insertColumnAfter]').get(0))
76
+ jasmine.simulate.click($('[data-action=addColumn]').get(0))
78
77
  expect(@addColumnSpy.callCount).toEqual(1)
79
- expect(@addColumnSpy.argsForCall[0]).toEqual(['after'])
80
78
 
81
79
  it "deletes the column of the selected cell", ->
82
- jasmine.simulate.click($('input[name=deleteColumn]').get(0))
80
+ jasmine.simulate.click($('[data-action=removeColumn]').get(0))
83
81
  expect(@removeColumnSpy.callCount).toEqual(1)
84
82
 
85
83
  it "increases the colspan of the selected cell", ->
86
- jasmine.simulate.click($('input[name=increaseColspan]').get(0))
84
+ jasmine.simulate.click($('[data-action=increaseColspan]').get(0))
87
85
  expect(@increaseColspanSpy.callCount).toEqual(1)
88
86
 
89
87
  it "decreases the colspan of the selected cell", ->
90
- jasmine.simulate.click($('input[name=decreaseColspan]').get(0))
88
+ jasmine.simulate.click($('[data-action=decreaseColspan]').get(0))
91
89
  expect(@decreaseColspanSpy.callCount).toEqual(1)
92
90
 
93
91
  it "increases the rowspan of the selected cell", ->
94
- jasmine.simulate.click($('input[name=increaseRowspan]').get(0))
92
+ jasmine.simulate.click($('[data-action=increaseRowspan]').get(0))
95
93
  expect(@increaseRowspanSpy.callCount).toEqual(1)
96
94
 
97
95
  it "decreases the rowspan of the selected cell", ->
98
- jasmine.simulate.click($('input[name=decreaseRowspan]').get(0))
96
+ jasmine.simulate.click($('[data-action=decreaseRowspan]').get(0))
99
97
  expect(@decreaseRowspanSpy.callCount).toEqual(1)
100
98
 
101
99
 
@@ -107,43 +105,57 @@ describe "Mercury.modalHandlers.insertTable", ->
107
105
  describe "changing the border", ->
108
106
 
109
107
  beforeEach ->
110
- Mercury.modalHandlers.insertTable.call(@modal)
108
+ @insertTable.initialize()
111
109
 
112
110
  it "changes the border of the table", ->
113
111
  $('#table_border').val('19')
114
112
  jasmine.simulate.keyup($('#table_border').get(0))
115
- expect($('#table').attr('border')).toEqual('19')
113
+ expect($('table').attr('border')).toEqual('19')
116
114
 
117
115
  it "handles non-numeric values", ->
118
- $('#table_border').val('2x')
116
+ $('#table_border').attr(value: '2x')
117
+ # chrome already does this -- so only test in those browsers that will return 12x
118
+ $('#table_border').attr(value: '2') unless $('#table_border').val() == '2x'
119
+ jasmine.simulate.keyup($('#table_border').get(0))
120
+ expect($('table').attr('border')).toEqual('2')
121
+
122
+ it "removes the property if empty value specified", ->
123
+ $('#table_border').val('')
119
124
  jasmine.simulate.keyup($('#table_border').get(0))
120
- expect($('#table').attr('border')).toEqual('2')
125
+ expect($('table').attr('border')).toEqual(undefined)
121
126
 
122
127
 
123
128
  describe "changing the cellspacing", ->
124
129
 
125
130
  beforeEach ->
126
- Mercury.modalHandlers.insertTable.call(@modal)
131
+ @insertTable.initialize()
127
132
 
128
133
  it "changes the cellspacing of the table", ->
129
134
  $('#table_spacing').val('5')
130
135
  jasmine.simulate.keyup($('#table_spacing').get(0))
131
- expect($('#table').attr('cellspacing')).toEqual('5')
136
+ expect($('table').attr('cellspacing')).toEqual('5')
132
137
 
133
138
  it "handles non-numeric values", ->
134
- $('#table_spacing').val('12x')
139
+ $('#table_spacing').attr(value: '12x')
140
+ # chrome already does this -- so only test in those browsers that will return 12x
141
+ $('#table_spacing').attr(value: '12') unless $('#table_spacing').val() == '12x'
135
142
  jasmine.simulate.keyup($('#table_spacing').get(0))
136
- expect($('#table').attr('cellspacing')).toEqual('12')
143
+ expect($('table').attr('cellspacing')).toEqual('12')
144
+
145
+ it "removes the property if empty value specified", ->
146
+ $('#table_spacing').val('')
147
+ jasmine.simulate.keyup($('#table_spacing').get(0))
148
+ expect($('table').attr('cellspacing')).toEqual(undefined)
137
149
 
138
150
 
139
151
  describe "submitting", ->
140
152
 
141
153
  beforeEach ->
142
- Mercury.modalHandlers.insertTable.call(@modal)
154
+ @insertTable.initialize()
143
155
 
144
156
  it "triggers an action", ->
145
157
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
146
- jasmine.simulate.click($('#submit').get(0))
158
+ jasmine.simulate.click($('input[type=submit]').get(0))
147
159
  expect(spy.callCount).toEqual(1)
148
160
  expect(spy.argsForCall[0][0]).toEqual('action')
149
161
  expect(spy.argsForCall[0][1]['action']).toEqual('insertTable')
@@ -154,7 +166,5 @@ describe "Mercury.modalHandlers.insertTable", ->
154
166
 
155
167
  it "hides the modal", ->
156
168
  spy = spyOn(@modal, 'hide').andCallFake(=>)
157
- jasmine.simulate.click($('#submit').get(0))
169
+ jasmine.simulate.click($('input[type=submit]').get(0))
158
170
  expect(spy.callCount).toEqual(1)
159
-
160
-
@@ -1,9 +1,8 @@
1
1
  describe "Mercury.PageEditor", ->
2
2
 
3
- template 'mercury/page_editor.html'
4
-
5
3
  beforeEach ->
6
- Mercury.config.regions.className = 'custom-region-class'
4
+ fixture.load('mercury/page_editor.html')
5
+ Mercury.config.regions.attribute = 'custom-region-attribute'
7
6
 
8
7
  afterEach ->
9
8
  @pageEditor = null
@@ -36,9 +35,9 @@ describe "Mercury.PageEditor", ->
36
35
  expect(window.mercuryInstance).toEqual(@pageEditor)
37
36
 
38
37
  it "accepts a saveUrl, and options", ->
39
- @pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar'})
38
+ @pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar', saveDataType: 'text'})
40
39
  expect(@pageEditor.saveUrl).toEqual('/foo/1')
41
- expect(@pageEditor.options).toEqual({foo: 'bar', visible: true})
40
+ expect(@pageEditor.options).toEqual({foo: 'bar', saveDataType: 'text', visible: true})
42
41
 
43
42
  it "sets the visible option to true unless it's set", ->
44
43
  @pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar', visible: false})
@@ -60,24 +59,27 @@ describe "Mercury.PageEditor", ->
60
59
 
61
60
  it "gets the csrf token if there's one available", ->
62
61
  new Mercury.PageEditor()
63
- expect(Mercury.csrfToken).toEqual('K6JhyfOVKJX8X2ZkiJXSf491fc1fF+k79wzrChHQa0g=')
62
+ expect(Mercury.csrfToken).toBeDefined()
64
63
 
65
64
 
66
65
  describe "#initializeInterface", ->
67
66
 
68
67
  beforeEach ->
69
68
  @resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
70
- Mercury.Toolbar = -> {toolbar: true}
71
- Mercury.Statusbar = -> {statusbar: true}
69
+ spyOn(Mercury, "Toolbar").andReturn({toolbar: true})
70
+ spyOn(Mercury, "Statusbar").andReturn({statusbar: true})
72
71
  @iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo')
73
72
 
74
73
  it "builds a focusable element (so we can get focus off the iframe)", ->
75
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
74
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
76
75
  expect($('input.mercury-focusable[type=text]').length).toEqual(1)
77
76
 
78
- it "builds an iframe", ->
79
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
80
- expect($('iframe.mercury-iframe').length).toEqual(1)
77
+ it "builds an iframe, setting id, class and name", ->
78
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
79
+ iframe = $('iframe.mercury-iframe')
80
+ expect(iframe.length).toEqual(1)
81
+ expect(iframe.attr('name')).toEqual 'mercury_iframe'
82
+ expect(iframe.attr('id')).toEqual 'mercury_iframe'
81
83
 
82
84
  it "appends the elements to any node", ->
83
85
  @pageEditor = new Mercury.PageEditor('', {appendTo: $('#page_editor_container')})
@@ -85,26 +87,36 @@ describe "Mercury.PageEditor", ->
85
87
  expect($('#page_editor_container iframe.mercury-iframe').length).toEqual(1)
86
88
 
87
89
  it "instantiates the toolbar", ->
88
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
90
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
89
91
  expect(@pageEditor.toolbar).toEqual({toolbar: true})
90
92
 
91
93
  it "instantiates the statusbar", ->
92
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
94
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
93
95
  expect(@pageEditor.statusbar).toEqual({statusbar: true})
94
96
 
95
97
  it "calls resize", ->
96
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
98
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
97
99
  expect(@resizeSpy.callCount).toEqual(1)
98
100
 
101
+ it "binds to iframe load event", ->
102
+ initializeFrameSpy = spyOn(Mercury.PageEditor.prototype, 'initializeFrame')
103
+ bindEventsSpy = spyOn(Mercury.PageEditor.prototype, 'bindEvents')
104
+
105
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
106
+ @pageEditor.iframe.trigger('load')
107
+
108
+ expect(initializeFrameSpy.callCount).toEqual(1)
109
+ expect(bindEventsSpy.callCount).toEqual(1)
99
110
 
100
- describe "#initializeFrame", ->
111
+
112
+ xdescribe "#initializeFrame", ->
101
113
 
102
114
  beforeEach ->
103
115
  @resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
104
116
  @bindEventsSpy = spyOn(Mercury.PageEditor.prototype, 'bindEvents').andCallFake(=>)
105
117
  @initializeRegionsSpy = spyOn(Mercury.PageEditor.prototype, 'initializeRegions').andCallFake(=>)
106
118
  @finalizeInterfaceSpy = spyOn(Mercury.PageEditor.prototype, 'finalizeInterface')
107
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
119
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
108
120
 
109
121
  it "does nothing if the iframe is already loaded", ->
110
122
  @finalizeInterfaceSpy.andCallFake(=>)
@@ -139,11 +151,6 @@ describe "Mercury.PageEditor", ->
139
151
  @pageEditor.initializeFrame()
140
152
  expect(@pageEditor.iframe.get(0).contentWindow.History).toEqual(window.History)
141
153
 
142
- it "calls bindEvents", ->
143
- @finalizeInterfaceSpy.andCallFake(=>)
144
- @pageEditor.initializeFrame()
145
- expect(@bindEventsSpy.callCount).toEqual(1)
146
-
147
154
  it "calls resize", ->
148
155
  @finalizeInterfaceSpy.andCallFake(=>)
149
156
  @pageEditor.initializeFrame()
@@ -167,11 +174,13 @@ describe "Mercury.PageEditor", ->
167
174
  expect(spy.argsForCall[0]).toEqual(['ready'])
168
175
 
169
176
  it "fires the ready event (jQuery.trigger)", ->
170
- spy = spyOn(jQuery.fn, 'trigger').andCallFake(=>)
177
+ mock = {trigger: ->}
178
+ @pageEditor.iframe.get(0).contentWindow.jQuery = -> mock
179
+ spy = spyOn(mock, 'trigger').andCallFake(=>)
171
180
  @finalizeInterfaceSpy.andCallFake(=>)
172
181
  @pageEditor.initializeFrame()
173
- expect(spy.callCount).toEqual(2)
174
- expect(spy.argsForCall[0]).toEqual(['mercury:ready', undefined])
182
+ expect(spy.callCount).toEqual(1)
183
+ expect(spy.argsForCall[0]).toEqual(['mercury:ready'])
175
184
 
176
185
  it "fires the ready event (Event.fire)", ->
177
186
  @finalizeInterfaceSpy.andCallFake(=>)
@@ -204,12 +213,12 @@ describe "Mercury.PageEditor", ->
204
213
  expect(spy.argsForCall[0]).toEqual(['Mercury.PageEditor failed to load: unknown error\n\nPlease try refreshing.'])
205
214
 
206
215
 
207
- describe "#initializeRegions", ->
216
+ xdescribe "#initializeRegions", ->
208
217
 
209
218
  beforeEach ->
210
219
  @resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
211
220
  Mercury.PageEditor.prototype.initializeFrame = ->
212
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
221
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
213
222
  @pageEditor.document = $(document)
214
223
 
215
224
  it "it calls buildRegion for all the regions found in a document", ->
@@ -238,7 +247,7 @@ describe "Mercury.PageEditor", ->
238
247
  expect(firstFocusCalled).toEqual(false)
239
248
 
240
249
 
241
- describe "#buildRegion", ->
250
+ xdescribe "#buildRegion", ->
242
251
  # it "throws an error if it's not supported", ->
243
252
  # Mercury.supported = false
244
253
  # expect(=>
@@ -250,9 +259,9 @@ describe "Mercury.PageEditor", ->
250
259
  beforeEach ->
251
260
  @resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
252
261
  Mercury.PageEditor.prototype.initializeFrame = ->
253
- Mercury.Regions.Editable = -> {region: true}
254
- Mercury.Regions.Editable.supported = true
255
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
262
+ Mercury.Regions.Full = -> {region: true}
263
+ Mercury.Regions.Full.supported = true
264
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
256
265
 
257
266
  it "instantiates the region and pushes it into the regions array", ->
258
267
  @pageEditor.buildRegion($('#region2'))
@@ -265,7 +274,7 @@ describe "Mercury.PageEditor", ->
265
274
 
266
275
  it "throws an exception when the data-type isn't known", ->
267
276
  expect(=> @pageEditor.buildRegion($('#region4'))).toThrow('Region type is malformed, no data-type provided, or "Unknown" is unknown for the "region4" region.')
268
- $('#region4').attr('data-type', 'foo')
277
+ $('#region4').attr('custom-region-attribute', 'foo')
269
278
  expect(=> @pageEditor.buildRegion($('#region4'))).toThrow('Region type is malformed, no data-type provided, or "Foo" is unknown for the "region4" region.')
270
279
 
271
280
  it "doesn't re-instantiate the region if the element's already initialized", ->
@@ -276,27 +285,27 @@ describe "Mercury.PageEditor", ->
276
285
 
277
286
  it "calls togglePreview on the region if in preview mode", ->
278
287
  callCount = 0
279
- Mercury.Regions.Editable = -> {region: true, togglePreview: -> callCount += 1 }
280
- Mercury.Regions.Editable.supported = true
288
+ Mercury.Regions.Full = -> {region: true, togglePreview: -> callCount += 1 }
289
+ Mercury.Regions.Full.supported = true
281
290
  @pageEditor.previewing = true
282
291
  @pageEditor.buildRegion($('#region2'))
283
292
  expect(callCount).toEqual(1)
284
293
 
285
294
  it "doesn't call togglePreview if not in preview mode", ->
286
295
  callCount = 0
287
- Mercury.Regions.Editable = -> {region: true, togglePreview: -> callCount += 1 }
288
- Mercury.Regions.Editable.supported = true
296
+ Mercury.Regions.Full = -> {region: true, togglePreview: -> callCount += 1 }
297
+ Mercury.Regions.Full.supported = true
289
298
  @pageEditor.buildRegion($('#region2'))
290
299
  expect(callCount).toEqual(0)
291
300
 
292
301
 
293
- describe "#finalizeInterface", ->
302
+ xdescribe "#finalizeInterface", ->
294
303
 
295
304
  beforeEach ->
296
305
  @resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
297
306
  Mercury.PageEditor.prototype.initializeFrame = ->
298
307
  Mercury.SnippetToolbar = -> {snippetToolbar: true}
299
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
308
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
300
309
  @highjackLinksAndFormsSpy = spyOn(Mercury.PageEditor.prototype, 'hijackLinksAndForms').andCallFake(=>)
301
310
 
302
311
  it "injects an sanitizing element used for sanitizing content", ->
@@ -313,24 +322,25 @@ describe "Mercury.PageEditor", ->
313
322
 
314
323
  it "fires a mode event to put things into preview mode if it's not visible yet", ->
315
324
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
316
- @pageEditor.options.visible = false
325
+ @pageEditor.visible = false
317
326
  @pageEditor.finalizeInterface()
318
327
  expect(spy.callCount).toEqual(1)
319
328
 
320
329
 
321
- describe "observed events", ->
330
+ xdescribe "observed events", ->
322
331
 
323
332
  beforeEach ->
324
333
  @initializeInterfaceSpy = spyOn(Mercury.PageEditor.prototype, 'initializeInterface').andCallFake(=>)
325
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
334
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
326
335
  @pageEditor.document = $(document)
327
336
  @pageEditor.bindEvents()
337
+ @pageEditor.bindDocumentEvents()
328
338
 
329
339
  describe "custom event: initialize:frame", ->
330
340
 
331
341
  it "calls initializeFrame", ->
332
342
  @initializeFrameSpy = spyOn(Mercury.PageEditor.prototype, 'initializeFrame').andCallFake(=>)
333
- @setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((timeout, callback) -> callback())
343
+ @setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((callback, timeout) -> callback())
334
344
  Mercury.trigger('initialize:frame')
335
345
  expect(@initializeFrameSpy.callCount).toEqual(1)
336
346
  expect(@setTimeoutSpy.callCount).toEqual(1)
@@ -348,7 +358,7 @@ describe "Mercury.PageEditor", ->
348
358
  it "calls focus on a focusable element", ->
349
359
  callCount = 0
350
360
  @pageEditor.focusableElement = {focus: -> callCount += 1}
351
- @setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((timeout, callback) -> callback())
361
+ @setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((callback, timeout) -> callback())
352
362
  Mercury.trigger('focus:window')
353
363
  expect(callCount).toEqual(1)
354
364
 
@@ -420,7 +430,7 @@ describe "Mercury.PageEditor", ->
420
430
  #expect(spy.callCount).toEqual(1)
421
431
 
422
432
 
423
- describe "#toggleInterface", ->
433
+ xdescribe "#toggleInterface", ->
424
434
 
425
435
  beforeEach ->
426
436
  spec = @
@@ -431,6 +441,7 @@ describe "Mercury.PageEditor", ->
431
441
  Mercury.Toolbar = -> {
432
442
  toolbar: true,
433
443
  height: (-> 100),
444
+ top: (-> 0),
434
445
  show: (=> spec.toolbarShowCallCount += 1),
435
446
  hide: (=> spec.toolbarHideCallCount += 1)
436
447
  }
@@ -441,7 +452,7 @@ describe "Mercury.PageEditor", ->
441
452
  hide: (=> spec.statusbarHideCallCount += 1)
442
453
  }
443
454
  Mercury.PageEditor.prototype.initializeFrame = ->
444
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
455
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
445
456
 
446
457
  it "calls resize", ->
447
458
  spy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
@@ -460,13 +471,12 @@ describe "Mercury.PageEditor", ->
460
471
  beforeEach ->
461
472
  @pageEditor.visible = true
462
473
 
463
- it "triggers an extra preview mode event if currently previewing", ->
464
- @pageEditor.previewing = true
474
+ it "triggers an preview mode event if not currently previewing", ->
475
+ @pageEditor.previewing = false
465
476
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
466
477
  @pageEditor.toggleInterface()
467
- expect(spy.callCount).toEqual(3)
478
+ expect(spy.callCount).toEqual(2)
468
479
  expect(spy.argsForCall[0]).toEqual(['mode', {mode: 'preview'}])
469
- expect(spy.argsForCall[1]).toEqual(['mode', {mode: 'preview'}])
470
480
 
471
481
  it "sets visible to false", ->
472
482
  @pageEditor.toggleInterface()
@@ -498,22 +508,22 @@ describe "Mercury.PageEditor", ->
498
508
  expect(@statusbarShowCallCount).toEqual(1)
499
509
 
500
510
 
501
- describe "#resize", ->
511
+ xdescribe "#resize", ->
502
512
 
503
513
  beforeEach ->
504
- Mercury.Toolbar = -> {toolbar: true, height: -> 100}
514
+ Mercury.Toolbar = -> {toolbar: true, height: (-> 100), top: (-> 50)}
505
515
  Mercury.Statusbar = -> {statusbar: true, top: -> 500}
506
516
  Mercury.PageEditor.prototype.initializeFrame = ->
507
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
517
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
508
518
 
509
519
  it "sets the display rectangle to displayRect", ->
510
520
  @pageEditor.resize()
511
- expect(Mercury.displayRect.top).toEqual(100)
512
- expect(Mercury.displayRect.height).toEqual(500 - 100)
521
+ expect(Mercury.displayRect.top).toEqual(100+50)
522
+ expect(Mercury.displayRect.height).toEqual(500 - (100+50))
513
523
 
514
524
  it "resizes the iframe", ->
515
525
  @pageEditor.resize()
516
- expect($('.mercury-iframe').css('height')).toEqual("#{500 - 100}px")
526
+ expect($('.mercury-iframe').css('height')).toEqual("#{500 - (100+50)}px")
517
527
 
518
528
  it "triggers a resize event", ->
519
529
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
@@ -521,11 +531,12 @@ describe "Mercury.PageEditor", ->
521
531
  expect(spy.callCount).toEqual(1)
522
532
 
523
533
 
524
- describe "#iframeSrc", ->
534
+ xdescribe "#iframeSrc", ->
525
535
 
526
536
  beforeEach ->
527
537
  Mercury.PageEditor.prototype.initializeFrame = ->
528
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
538
+ spyOn(Date.prototype, 'getTime').andReturn(1234)
539
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
529
540
 
530
541
  it "takes the location and removes the /editor", ->
531
542
  expect(@pageEditor.iframeSrc('http://foo.com/editor/path')).toEqual('http://foo.com/path')
@@ -537,17 +548,43 @@ describe "Mercury.PageEditor", ->
537
548
  Mercury.config.editorUrlRegEx = original
538
549
 
539
550
  it "adds query params", ->
540
- expect(@pageEditor.iframeSrc('http://foo.com/editor/path', true)).toEqual('http://foo.com/path?mercury_frame=true')
541
- expect(@pageEditor.iframeSrc('http://foo.com/editor/path?something=true', true)).toEqual('http://foo.com/path?something=true&mercury_frame=true')
551
+ expect(@pageEditor.iframeSrc('http://foo.com/editor/path', true)).toEqual('http://foo.com/path?mercury_frame=true&_=1234')
552
+ expect(@pageEditor.iframeSrc('http://foo.com/editor/path?something=true', true)).toEqual('http://foo.com/path?something=true&mercury_frame=true&_=1234')
553
+
554
+
555
+ xdescribe "#loadIframeSrc", ->
542
556
 
557
+ beforeEach ->
558
+ Mercury.PageEditor.prototype.initializeFrame = ->
559
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
560
+
561
+ it 'unbinds events to @document', ->
562
+ @pageEditor.document = {off: ->}
563
+ documentSpy = spyOn(@pageEditor.document, 'off')
564
+ @pageEditor.loadIframeSrc()
565
+ expect(documentSpy).toHaveBeenCalled()
566
+
567
+ it 'resets the iframe loaded data attribute', ->
568
+ @pageEditor.iframe.data('loaded', true)
569
+ @pageEditor.loadIframeSrc()
570
+ expect(@pageEditor.iframe.data('loaded')).toEqual(false)
571
+
572
+ it 'sets the iframe source', ->
573
+ iframe = {contentWindow: {document: {location: {}}}}
574
+ spyOn(Date.prototype, 'getTime').andReturn(1234)
575
+ @pageEditor.iframe = {data: (->), get: -> iframe}
576
+ @pageEditor.loadIframeSrc('boo')
577
+ expect(iframe.contentWindow.document.location.href).toEqual('boo?mercury_frame=true&_=1234')
543
578
 
544
- describe "#hijackLinksAndForms", ->
579
+
580
+
581
+ xdescribe "#hijackLinksAndForms", ->
545
582
 
546
583
  beforeEach ->
547
584
  Mercury.config.nonHijackableClasses = ['lightview']
548
585
 
549
586
  Mercury.PageEditor.prototype.initializeFrame = ->
550
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
587
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
551
588
  @pageEditor.document = $(document)
552
589
 
553
590
  afterEach ->
@@ -586,11 +623,11 @@ describe "Mercury.PageEditor", ->
586
623
  expect($('#form6').attr('target')).toEqual('foo')
587
624
 
588
625
 
589
- describe "#beforeUnload", ->
626
+ xdescribe "#beforeUnload", ->
590
627
 
591
628
  beforeEach ->
592
629
  Mercury.PageEditor.prototype.initializeInterface = ->
593
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
630
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
594
631
  Mercury.silent = false
595
632
  Mercury.changes = true
596
633
 
@@ -605,11 +642,11 @@ describe "Mercury.PageEditor", ->
605
642
  expect(@pageEditor.beforeUnload()).toEqual(null)
606
643
 
607
644
 
608
- describe "#getRegionByName", ->
645
+ xdescribe "#getRegionByName", ->
609
646
 
610
647
  beforeEach ->
611
648
  Mercury.PageEditor.prototype.initializeInterface = ->
612
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
649
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
613
650
  @iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
614
651
  @ajaxSpy = spyOn($, 'ajax')
615
652
 
@@ -623,12 +660,12 @@ describe "Mercury.PageEditor", ->
623
660
  expect(@pageEditor.getRegionByName('foo')).toEqual(null)
624
661
 
625
662
 
626
- describe "#save", ->
663
+ xdescribe "#save", ->
627
664
 
628
665
  describe "POST", ->
629
666
  beforeEach ->
630
667
  Mercury.PageEditor.prototype.initializeInterface = ->
631
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test'), saveDataType: 'text'})
668
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el, saveDataType: 'text', saveMethod: 'POST'})
632
669
  @iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
633
670
  @ajaxSpy = spyOn($, 'ajax')
634
671
 
@@ -650,12 +687,12 @@ describe "Mercury.PageEditor", ->
650
687
  expect(@ajaxSpy.argsForCall[0][0]).toEqual('/foo/bar')
651
688
 
652
689
  @pageEditor.saveUrl = null
653
- Mercury.saveURL = '/foo/bit'
690
+ Mercury.saveUrl = '/foo/bit'
654
691
  @pageEditor.save()
655
692
  expect(@ajaxSpy.argsForCall[1][0]).toEqual('/foo/bit')
656
693
 
657
694
  @pageEditor.saveUrl = null
658
- Mercury.saveURL = null
695
+ Mercury.saveUrl = null
659
696
  @pageEditor.save()
660
697
  expect(@ajaxSpy.argsForCall[2][0]).toEqual('/foo/baz')
661
698
 
@@ -664,7 +701,7 @@ describe "Mercury.PageEditor", ->
664
701
  Mercury.config.saveStyle = 'json'
665
702
  spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
666
703
  @pageEditor.save()
667
- expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual({content: '{"region1":"region1"}' })
704
+ expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual('{"content":{"region1":"region1"}}')
668
705
 
669
706
  it "can serialize as form values", ->
670
707
  @ajaxSpy.andCallFake(=>)
@@ -706,25 +743,32 @@ describe "Mercury.PageEditor", ->
706
743
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
707
744
  @pageEditor.save()
708
745
  expect(spy.callCount).toEqual(1)
709
- expect(spy.argsForCall[0]).toEqual(['saved'])
746
+ expect(spy.argsForCall[0]).toEqual(['saved', 'data'])
710
747
 
711
748
  describe "on failed ajax request", ->
712
749
 
713
750
  beforeEach ->
714
- @ajaxSpy.andCallFake((url, options) => options.error() )
751
+ @ajaxSpy.andCallFake((url, options) => options.error({'response': 'object'}) )
752
+
753
+ it "alerts and triggers save_failed with the url", ->
754
+ alert_spy = spyOn(window, 'alert').andCallFake(=>)
755
+ trigger_spy = spyOn(Mercury, 'trigger').andCallFake(=>)
715
756
 
716
- it "alerts with the url", ->
717
- spy = spyOn(window, 'alert').andCallFake(=>)
718
757
  @pageEditor.saveUrl = '/foo/bar'
719
758
  @pageEditor.save()
720
- expect(spy.callCount).toEqual(1)
721
- expect(spy.argsForCall[0]).toEqual(['Mercury was unable to save to the url: /foo/bar'])
759
+
760
+ expect(alert_spy.callCount).toEqual(1)
761
+ expect(alert_spy.argsForCall[0]).toEqual(['Mercury was unable to save to the url: /foo/bar'])
762
+
763
+ expect(trigger_spy.callCount).toEqual(1)
764
+ expect(trigger_spy.argsForCall[0][0]).toEqual('save_failed')
765
+ expect(trigger_spy.argsForCall[0][1]).toBeDefined()
722
766
 
723
767
  describe "PUT", ->
724
768
 
725
769
  beforeEach ->
726
770
  Mercury.PageEditor.prototype.initializeInterface = ->
727
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test'), saveMethod: 'PUT'})
771
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el, saveMethod: 'FOO'})
728
772
  @iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
729
773
  @ajaxSpy = spyOn($, 'ajax')
730
774
 
@@ -732,14 +776,14 @@ describe "Mercury.PageEditor", ->
732
776
  @ajaxSpy.andCallFake(=>)
733
777
  spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
734
778
  @pageEditor.save()
735
- expect(@ajaxSpy.argsForCall[0][1]['data']['_method']).toEqual('PUT')
779
+ expect(test=@ajaxSpy.argsForCall[0][1]['data']).toContain('"_method":"PUT"')
736
780
 
737
781
 
738
- describe "#serialize", ->
782
+ xdescribe "#serialize", ->
739
783
 
740
784
  beforeEach ->
741
785
  Mercury.PageEditor.prototype.initializeInterface = ->
742
- @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
786
+ @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
743
787
  @pageEditor.regions = [
744
788
  {name: 'region1', serialize: -> 'region1'},
745
789
  {name: 'region2', serialize: -> 'region2'}