kiteditor 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (289) hide show
  1. data/{lib/generators/mercury/install/images/templates → app/controllers/mercury}/images_controller.rb +0 -0
  2. data/{lib/generators/mercury/install/images/templates/ar_paperclip_image.rb → app/models/mercury/image.rb} +0 -7
  3. data/app/views/layouts/mercury.html.erb +20 -10
  4. data/app/views/mercury/modals/character.html +1 -1
  5. data/app/views/mercury/modals/htmleditor.html +7 -3
  6. data/app/views/mercury/modals/link.html +51 -37
  7. data/app/views/mercury/modals/media.html +0 -102
  8. data/app/views/mercury/modals/table.html +73 -79
  9. data/app/views/mercury/panels/snippets.html +1 -6
  10. data/app/views/mercury/snippets/example/options.html.erb +27 -23
  11. data/{lib/generators/mercury/install/images/templates/ar_paperclip_image_migration.rb → db/migrate/20110526035601_create_mercury_images.rb} +0 -0
  12. data/features/loading/loading.feature +2 -5
  13. data/features/loading/user_interface.feature +7 -9
  14. data/features/regions/{full → editable}/advanced_editing.feature +0 -0
  15. data/features/regions/editable/basic_editing.feature +195 -0
  16. data/features/regions/{full → editable}/inserting_links.feature +19 -20
  17. data/features/regions/{full → editable}/inserting_media.feature +18 -36
  18. data/features/regions/{full → editable}/inserting_snippets.feature +18 -28
  19. data/features/regions/{full → editable}/inserting_special_characters.feature +2 -2
  20. data/features/regions/editable/inserting_tables.feature +109 -0
  21. data/features/regions/{full → editable}/pasting.feature +0 -0
  22. data/features/regions/{full → editable}/uploading_images.feature +0 -0
  23. data/features/regions/{markdown → markupable}/advanced_editing.feature +0 -0
  24. data/features/regions/{markdown → markupable}/basic_editing.feature +0 -0
  25. data/features/regions/{markdown → markupable}/inserting_links.feature +0 -0
  26. data/features/regions/{markdown → markupable}/inserting_media.feature +0 -0
  27. data/features/regions/{markdown → markupable}/inserting_snippets.feature +0 -0
  28. data/features/regions/{markdown → markupable}/inserting_special_characters.feature +0 -0
  29. data/features/regions/{markdown → markupable}/inserting_tables.feature +0 -0
  30. data/features/regions/{image → markupable}/uploading_images.feature +0 -0
  31. data/features/regions/{snippets → snippetable}/advanced_editing.feature +0 -0
  32. data/features/regions/{snippets → snippetable}/basic_editing.feature +0 -0
  33. data/features/regions/{snippets → snippetable}/inserting_snippets.feature +0 -0
  34. data/features/saving/saving.feature +8 -8
  35. data/features/step_definitions/mercury_steps.rb +438 -1
  36. data/features/support/env.rb +1 -11
  37. data/{lib/mercury/cucumber → features}/support/mercury_contents.rb +3 -3
  38. data/{lib/mercury/cucumber → features}/support/mercury_selectors.rb +20 -0
  39. data/features/support/selectors.rb +0 -23
  40. data/lib/generators/mercury/install/install_generator.rb +23 -12
  41. data/lib/generators/mercury/install/{images/templates → templates}/mongoid_paperclip_image.rb +0 -0
  42. data/lib/mercury/authentication.rb +0 -1
  43. data/lib/mercury-rails.rb +2 -1
  44. data/spec/javascripts/mercury/{dialog_spec.coffee → dialog_spec.js.coffee} +12 -11
  45. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +3 -2
  46. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +4 -3
  47. data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +3 -2
  48. data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +3 -2
  49. data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +3 -2
  50. data/spec/javascripts/mercury/lightview_spec.js.coffee +142 -180
  51. data/spec/javascripts/mercury/mercury_spec.js.coffee +13 -19
  52. data/spec/javascripts/mercury/modal_spec.js.coffee +148 -192
  53. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +5 -4
  54. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +3 -2
  55. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +34 -107
  56. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +26 -106
  57. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +3 -2
  58. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +40 -50
  59. data/spec/javascripts/mercury/page_editor_spec.js.coffee +80 -124
  60. data/spec/javascripts/mercury/palette_spec.js.coffee +5 -4
  61. data/spec/javascripts/mercury/panel_spec.js.coffee +12 -9
  62. data/spec/javascripts/mercury/region_spec.js.coffee +17 -22
  63. data/spec/javascripts/mercury/regions/{full_spec.js.coffee → editable_spec.js.coffee} +28 -26
  64. data/spec/javascripts/mercury/regions/{markdown_spec.js.coffee → markupable_spec.js.coffee} +34 -32
  65. data/spec/javascripts/mercury/regions/{snippets_spec.js.coffee → snippetable_spec.js.coffee} +55 -54
  66. data/spec/javascripts/mercury/select_spec.js.coffee +5 -4
  67. data/spec/javascripts/mercury/snippet_spec.js.coffee +16 -92
  68. data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +16 -31
  69. data/spec/javascripts/mercury/statusbar_spec.js.coffee +10 -9
  70. data/spec/javascripts/mercury/table_editor_spec.js.coffee +2 -1
  71. data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +9 -7
  72. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +26 -55
  73. data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +13 -13
  74. data/spec/javascripts/mercury/toolbar_spec.js.coffee +14 -43
  75. data/spec/javascripts/mercury/tooltip_spec.js.coffee +2 -1
  76. data/spec/javascripts/mercury/uploader_spec.js.coffee +33 -47
  77. data/spec/javascripts/{support/event_simulation.js → spec_helper.js} +2 -0
  78. data/spec/javascripts/{fixtures → templates}/mercury/dialog.html +0 -0
  79. data/spec/javascripts/{fixtures → templates}/mercury/dialogs/backcolor.html +0 -0
  80. data/spec/javascripts/{fixtures → templates}/mercury/dialogs/forecolor.html +0 -0
  81. data/spec/javascripts/{fixtures → templates}/mercury/dialogs/formatblock.html +0 -0
  82. data/spec/javascripts/{fixtures → templates}/mercury/dialogs/snippetpanel.html +0 -0
  83. data/spec/javascripts/{fixtures → templates}/mercury/dialogs/style.html +0 -0
  84. data/spec/javascripts/{fixtures → templates}/mercury/lightview.html +0 -0
  85. data/spec/javascripts/{fixtures → templates}/mercury/modal.html +0 -0
  86. data/spec/javascripts/{fixtures → templates}/mercury/modals/htmleditor.html +0 -0
  87. data/spec/javascripts/{fixtures → templates}/mercury/modals/insertcharacter.html +0 -0
  88. data/spec/javascripts/templates/mercury/modals/insertlink.html +30 -0
  89. data/spec/javascripts/templates/mercury/modals/insertmedia.html +35 -0
  90. data/spec/javascripts/{fixtures → templates}/mercury/modals/insertsnippet.html +0 -0
  91. data/spec/javascripts/templates/mercury/modals/inserttable.html +27 -0
  92. data/spec/javascripts/{fixtures → templates}/mercury/page_editor.html +4 -4
  93. data/spec/javascripts/{fixtures → templates}/mercury/palette.html +0 -0
  94. data/spec/javascripts/{fixtures → templates}/mercury/panel.html +0 -0
  95. data/spec/javascripts/templates/mercury/region.html +2 -0
  96. data/spec/javascripts/templates/mercury/regions/editable.html +3 -0
  97. data/spec/javascripts/templates/mercury/regions/snippetable.html +4 -0
  98. data/spec/javascripts/{fixtures → templates}/mercury/select.html +0 -0
  99. data/spec/javascripts/{fixtures → templates}/mercury/snippet.html +0 -0
  100. data/spec/javascripts/{fixtures → templates}/mercury/snippet_toolbar.html +0 -0
  101. data/spec/javascripts/{fixtures → templates}/mercury/statusbar.html +0 -0
  102. data/spec/javascripts/{fixtures → templates}/mercury/table_editor.html +0 -0
  103. data/spec/javascripts/{fixtures → templates}/mercury/toolbar.button.html +0 -0
  104. data/spec/javascripts/{fixtures → templates}/mercury/toolbar.button_group.html +0 -0
  105. data/spec/javascripts/{fixtures → templates}/mercury/toolbar.expander.html +0 -0
  106. data/spec/javascripts/{fixtures → templates}/mercury/toolbar.html +0 -0
  107. data/spec/javascripts/{fixtures → templates}/mercury/tooltip.html +0 -0
  108. data/spec/javascripts/{fixtures → templates}/mercury/uploader.html +0 -0
  109. data/{app → vendor}/assets/images/mercury/button.png +0 -0
  110. data/{app → vendor}/assets/images/mercury/close.png +0 -0
  111. data/{app → vendor}/assets/images/mercury/loading-dark.gif +0 -0
  112. data/{app → vendor}/assets/images/mercury/loading-light.gif +0 -0
  113. data/{app → vendor}/assets/images/mercury/missing-image.png +0 -0
  114. data/{app → vendor}/assets/images/mercury/search-icon.png +0 -0
  115. data/{app → vendor}/assets/images/mercury/temp-logo.png +0 -0
  116. data/{app/assets/javascripts → vendor/assets/javascripts/mercury/dependencies}/jquery-1.7.js +0 -0
  117. data/{app → vendor}/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +0 -0
  118. data/{app → vendor}/assets/javascripts/mercury/dependencies/jquery.additions.js +13 -103
  119. data/{app → vendor}/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +0 -0
  120. data/{app → vendor}/assets/javascripts/mercury/dependencies/liquidmetal.js +0 -0
  121. data/{app → vendor}/assets/javascripts/mercury/dependencies/showdown.js +0 -0
  122. data/{app → vendor}/assets/javascripts/mercury/dialog.js.coffee +0 -0
  123. data/{app → vendor}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
  124. data/{app → vendor}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +1 -1
  125. data/{app → vendor}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
  126. data/{app → vendor}/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +1 -1
  127. data/{app → vendor}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
  128. data/{app → vendor}/assets/javascripts/mercury/finalize.js.coffee +0 -0
  129. data/{app → vendor}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
  130. data/{app → vendor}/assets/javascripts/mercury/lightview.js.coffee +17 -38
  131. data/{features/regions/markdown/uploading_images.feature → vendor/assets/javascripts/mercury/locales/da.locale.js.coffee} +0 -0
  132. data/{app → vendor}/assets/javascripts/mercury/locales/de.locale.js.coffee +10 -4
  133. data/{app → vendor}/assets/javascripts/mercury/locales/es.locale.js.coffee +9 -3
  134. data/{app → vendor}/assets/javascripts/mercury/locales/example.local.js.coffee +5 -3
  135. data/{app → vendor}/assets/javascripts/mercury/locales/fr.locale.js.coffee +9 -3
  136. data/{app → vendor}/assets/javascripts/mercury/locales/it.locale.js.coffee +9 -3
  137. data/{app → vendor}/assets/javascripts/mercury/locales/ko.local.js.coffee +10 -4
  138. data/{app → vendor}/assets/javascripts/mercury/locales/nl.locale.js.coffee +9 -3
  139. data/{app → vendor}/assets/javascripts/mercury/locales/pt.locale.js.coffee +9 -3
  140. data/{app → vendor}/assets/javascripts/mercury/locales/sv.local.js.coffee +9 -3
  141. data/{app → vendor}/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +9 -3
  142. data/{app → vendor}/assets/javascripts/mercury/mercury.js.coffee +1 -10
  143. data/{app → vendor}/assets/javascripts/mercury/modal.js.coffee +40 -62
  144. data/{app → vendor}/assets/javascripts/mercury/modals/htmleditor.js.coffee +2 -3
  145. data/{app → vendor}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +0 -1
  146. data/{app → vendor}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +0 -2
  147. data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +54 -0
  148. data/{app → vendor}/assets/javascripts/mercury/native_extensions.js.coffee +6 -0
  149. data/{app → vendor}/assets/javascripts/mercury/page_editor.js.coffee +50 -84
  150. data/{app → vendor}/assets/javascripts/mercury/palette.js.coffee +1 -1
  151. data/{app → vendor}/assets/javascripts/mercury/panel.js.coffee +2 -3
  152. data/{app → vendor}/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +2 -2
  153. data/{app → vendor}/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +0 -0
  154. data/{app → vendor}/assets/javascripts/mercury/region.js.coffee +17 -18
  155. data/{app/assets/javascripts/mercury/regions/full.js.coffee → vendor/assets/javascripts/mercury/regions/editable.js.coffee} +31 -41
  156. data/{app/assets/javascripts/mercury/regions/markdown.js.coffee → vendor/assets/javascripts/mercury/regions/markupable.js.coffee} +24 -29
  157. data/{app → vendor}/assets/javascripts/mercury/regions/simple.js.coffee +54 -11
  158. data/{app/assets/javascripts/mercury/regions/snippets.js.coffee → vendor/assets/javascripts/mercury/regions/snippetable.js.coffee} +9 -10
  159. data/{app → vendor}/assets/javascripts/mercury/select.js.coffee +1 -1
  160. data/{app → vendor}/assets/javascripts/mercury/snippet_toolbar.js.coffee +6 -19
  161. data/{app → vendor}/assets/javascripts/mercury/statusbar.js.coffee +0 -0
  162. data/{app → vendor}/assets/javascripts/mercury/support/history.js +0 -0
  163. data/{app → vendor}/assets/javascripts/mercury/table_editor.js.coffee +0 -16
  164. data/{app → vendor}/assets/javascripts/mercury/toolbar.button.js.coffee +30 -45
  165. data/{app → vendor}/assets/javascripts/mercury/toolbar.button_group.js.coffee +2 -2
  166. data/{app → vendor}/assets/javascripts/mercury/toolbar.expander.js.coffee +4 -4
  167. data/{app → vendor}/assets/javascripts/mercury/toolbar.js.coffee +6 -10
  168. data/{app → vendor}/assets/javascripts/mercury/tooltip.js.coffee +0 -0
  169. data/{app → vendor}/assets/javascripts/mercury/uploader.js.coffee +19 -37
  170. data/{app → vendor}/assets/javascripts/mercury.js +87 -60
  171. data/vendor/assets/javascripts/mercury_loader.js +193 -0
  172. data/vendor/assets/javascripts/mercury_overrides.js +6 -0
  173. data/{app → vendor}/assets/stylesheets/mercury/all_images.css.erb +2 -6
  174. data/{app → vendor}/assets/stylesheets/mercury/dialog.css +8 -21
  175. data/{app → vendor}/assets/stylesheets/mercury/lightview.css +56 -6
  176. data/vendor/assets/stylesheets/mercury/mercury.css +151 -0
  177. data/{app → vendor}/assets/stylesheets/mercury/modal.css +32 -15
  178. data/{app → vendor}/assets/stylesheets/mercury/statusbar.css +0 -0
  179. data/{app → vendor}/assets/stylesheets/mercury/toolbar.css +1 -4
  180. data/{app → vendor}/assets/stylesheets/mercury/tooltip.css +0 -0
  181. data/{app → vendor}/assets/stylesheets/mercury/uploader.css +4 -4
  182. data/{app → vendor}/assets/stylesheets/mercury.css +5 -1
  183. data/vendor/assets/stylesheets/mercury_overrides.css +17 -0
  184. metadata +197 -367
  185. data/POST_INSTALL +0 -21
  186. data/app/assets/images/mercury/default-snippet.png +0 -0
  187. data/app/assets/images/mercury/toolbar/editable/buttons.png +0 -0
  188. data/app/assets/images/mercury/toolbar/primary/_expander.png +0 -0
  189. data/app/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
  190. data/app/assets/images/mercury/toolbar/primary/action.png +0 -0
  191. data/app/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
  192. data/app/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
  193. data/app/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
  194. data/app/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
  195. data/app/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
  196. data/app/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
  197. data/app/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
  198. data/app/assets/images/mercury/toolbar/primary/preview.png +0 -0
  199. data/app/assets/images/mercury/toolbar/primary/redo.png +0 -0
  200. data/app/assets/images/mercury/toolbar/primary/save.png +0 -0
  201. data/app/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
  202. data/app/assets/images/mercury/toolbar/primary/tools.png +0 -0
  203. data/app/assets/images/mercury/toolbar/primary/undo.png +0 -0
  204. data/app/assets/images/mercury/toolbar/primary/user.png +0 -0
  205. data/app/assets/images/mercury/toolbar/snippets/buttons.png +0 -0
  206. data/app/assets/javascripts/mercury/locales/ar.locale.js.coffee +0 -201
  207. data/app/assets/javascripts/mercury/locales/da.locale.js.coffee +0 -208
  208. data/app/assets/javascripts/mercury/locales/hu.locale.js.coffee +0 -209
  209. data/app/assets/javascripts/mercury/locales/pl.locale.js.coffee +0 -213
  210. data/app/assets/javascripts/mercury/locales/ru.locale.js.coffee +0 -200
  211. data/app/assets/javascripts/mercury/locales/uk.locale.js.coffee +0 -200
  212. data/app/assets/javascripts/mercury/locales/zh.local.js.coffee +0 -203
  213. data/app/assets/javascripts/mercury/mercury-compiled.js +0 -10720
  214. data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +0 -152
  215. data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +0 -132
  216. data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +0 -68
  217. data/app/assets/javascripts/mercury/regions/image.js.coffee +0 -93
  218. data/app/assets/javascripts/mercury/snippet.js.coffee +0 -136
  219. data/app/assets/stylesheets/_mercury-bootstrap-overrides.scss +0 -61
  220. data/app/assets/stylesheets/_mercury-sass.scss +0 -33
  221. data/app/assets/stylesheets/mercury/bootstrap-ish.css +0 -1367
  222. data/app/assets/stylesheets/mercury/bootstrap-overrides.css +0 -61
  223. data/app/assets/stylesheets/mercury/mercury.css +0 -43
  224. data/app/helpers/mercury_helper.rb +0 -7
  225. data/app/views/layouts/mercury.html.haml +0 -19
  226. data/app/views/layouts/mercury.html.slim +0 -19
  227. data/app/views/mercury/snippets/no_options/preview.html.erb +0 -1
  228. data/config/routes.rb +0 -9
  229. data/features/generators/authentication.feature +0 -10
  230. data/features/generators/images.feature +0 -41
  231. data/features/generators/install.feature +0 -21
  232. data/features/regions/full/basic_editing.feature +0 -198
  233. data/features/regions/full/inserting_tables.feature +0 -109
  234. data/features/regions/simple/basic_editing.feature +0 -5
  235. data/features/step_definitions/custom_web_steps.rb +0 -22
  236. data/features/step_definitions/generator_steps.rb +0 -23
  237. data/features/support/aruba.rb +0 -28
  238. data/lib/generators/mercury/install/authentication/authentication_generator.rb +0 -17
  239. data/lib/generators/mercury/install/images/images_generator.rb +0 -47
  240. data/lib/mercury/cucumber/step_definitions/mercury_steps.rb +0 -408
  241. data/lib/mercury/cucumber/step_definitions.rb +0 -13
  242. data/lib/mercury/engine.rb +0 -19
  243. data/lib/mercury/rails.rb +0 -5
  244. data/lib/mercury/version.rb +0 -3
  245. data/spec/dummy/Rakefile +0 -7
  246. data/spec/dummy/app/assets/javascripts/application.js +0 -0
  247. data/spec/dummy/app/assets/javascripts/prototype.js +0 -6082
  248. data/spec/dummy/app/assets/stylesheets/application.css.scss +0 -110
  249. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  250. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  251. data/spec/dummy/app/views/layouts/mercury.html.erb +0 -28
  252. data/spec/dummy/config/application.rb +0 -58
  253. data/spec/dummy/config/boot.rb +0 -10
  254. data/spec/dummy/config/database.yml +0 -10
  255. data/spec/dummy/config/environment.rb +0 -5
  256. data/spec/dummy/config/environments/development.rb +0 -37
  257. data/spec/dummy/config/environments/production.rb +0 -67
  258. data/spec/dummy/config/environments/test.rb +0 -37
  259. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  260. data/spec/dummy/config/initializers/inflections.rb +0 -15
  261. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  262. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  263. data/spec/dummy/config/initializers/session_store.rb +0 -8
  264. data/spec/dummy/config/initializers/teabag.rb +0 -9
  265. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  266. data/spec/dummy/config/locales/en.yml +0 -5
  267. data/spec/dummy/config/routes.rb +0 -5
  268. data/spec/dummy/config.ru +0 -4
  269. data/spec/dummy/db/.gitkeep +0 -0
  270. data/spec/dummy/public/500.html +0 -25
  271. data/spec/dummy/public/blank.html +0 -1
  272. data/spec/dummy/public/favicon.ico +0 -0
  273. data/spec/dummy/public/images/bunny.gif +0 -0
  274. data/spec/dummy/public/images/bunny2.jpg +0 -0
  275. data/spec/dummy/public/index.html +0 -279
  276. data/spec/dummy/script/rails +0 -6
  277. data/spec/javascripts/fixtures/mercury/modals/insertlink.html +0 -67
  278. data/spec/javascripts/fixtures/mercury/modals/insertmedia.html +0 -87
  279. data/spec/javascripts/fixtures/mercury/modals/inserttable.html +0 -73
  280. data/spec/javascripts/fixtures/mercury/region.html +0 -6
  281. data/spec/javascripts/fixtures/mercury/regions/full.html +0 -1
  282. data/spec/javascripts/fixtures/mercury/regions/image.html +0 -1
  283. data/spec/javascripts/fixtures/mercury/regions/markdown.html +0 -1
  284. data/spec/javascripts/fixtures/mercury/regions/simple.html +0 -1
  285. data/spec/javascripts/fixtures/mercury/regions/snippets.html +0 -4
  286. data/spec/javascripts/mercury/regions/image_spec.js.coffee +0 -33
  287. data/spec/javascripts/mercury/regions/simple_spec.js.coffee +0 -32
  288. data/spec/javascripts/spec_helper.coffee +0 -4
  289. data/spec/teabag_env.rb +0 -32
@@ -1,8 +1,9 @@
1
1
  describe "Mercury.PageEditor", ->
2
2
 
3
+ template 'mercury/page_editor.html'
4
+
3
5
  beforeEach ->
4
- fixture.load('mercury/page_editor.html')
5
- Mercury.config.regions.attribute = 'custom-region-attribute'
6
+ Mercury.config.regions.className = 'custom-region-class'
6
7
 
7
8
  afterEach ->
8
9
  @pageEditor = null
@@ -35,9 +36,9 @@ describe "Mercury.PageEditor", ->
35
36
  expect(window.mercuryInstance).toEqual(@pageEditor)
36
37
 
37
38
  it "accepts a saveUrl, and options", ->
38
- @pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar', saveDataType: 'text'})
39
+ @pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar'})
39
40
  expect(@pageEditor.saveUrl).toEqual('/foo/1')
40
- expect(@pageEditor.options).toEqual({foo: 'bar', saveDataType: 'text', visible: true})
41
+ expect(@pageEditor.options).toEqual({foo: 'bar', visible: true})
41
42
 
42
43
  it "sets the visible option to true unless it's set", ->
43
44
  @pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar', visible: false})
@@ -59,27 +60,24 @@ describe "Mercury.PageEditor", ->
59
60
 
60
61
  it "gets the csrf token if there's one available", ->
61
62
  new Mercury.PageEditor()
62
- expect(Mercury.csrfToken).toBeDefined()
63
+ expect(Mercury.csrfToken).toEqual('K6JhyfOVKJX8X2ZkiJXSf491fc1fF+k79wzrChHQa0g=')
63
64
 
64
65
 
65
66
  describe "#initializeInterface", ->
66
67
 
67
68
  beforeEach ->
68
69
  @resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
69
- spyOn(Mercury, "Toolbar").andReturn({toolbar: true})
70
- spyOn(Mercury, "Statusbar").andReturn({statusbar: true})
70
+ Mercury.Toolbar = -> {toolbar: true}
71
+ Mercury.Statusbar = -> {statusbar: true}
71
72
  @iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo')
72
73
 
73
74
  it "builds a focusable element (so we can get focus off the iframe)", ->
74
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
75
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
75
76
  expect($('input.mercury-focusable[type=text]').length).toEqual(1)
76
77
 
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'
78
+ it "builds an iframe", ->
79
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
80
+ expect($('iframe.mercury-iframe').length).toEqual(1)
83
81
 
84
82
  it "appends the elements to any node", ->
85
83
  @pageEditor = new Mercury.PageEditor('', {appendTo: $('#page_editor_container')})
@@ -87,36 +85,26 @@ describe "Mercury.PageEditor", ->
87
85
  expect($('#page_editor_container iframe.mercury-iframe').length).toEqual(1)
88
86
 
89
87
  it "instantiates the toolbar", ->
90
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
88
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
91
89
  expect(@pageEditor.toolbar).toEqual({toolbar: true})
92
90
 
93
91
  it "instantiates the statusbar", ->
94
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
92
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
95
93
  expect(@pageEditor.statusbar).toEqual({statusbar: true})
96
94
 
97
95
  it "calls resize", ->
98
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
96
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
99
97
  expect(@resizeSpy.callCount).toEqual(1)
100
98
 
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)
110
99
 
111
-
112
- xdescribe "#initializeFrame", ->
100
+ describe "#initializeFrame", ->
113
101
 
114
102
  beforeEach ->
115
103
  @resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
116
104
  @bindEventsSpy = spyOn(Mercury.PageEditor.prototype, 'bindEvents').andCallFake(=>)
117
105
  @initializeRegionsSpy = spyOn(Mercury.PageEditor.prototype, 'initializeRegions').andCallFake(=>)
118
106
  @finalizeInterfaceSpy = spyOn(Mercury.PageEditor.prototype, 'finalizeInterface')
119
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
107
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
120
108
 
121
109
  it "does nothing if the iframe is already loaded", ->
122
110
  @finalizeInterfaceSpy.andCallFake(=>)
@@ -151,6 +139,11 @@ describe "Mercury.PageEditor", ->
151
139
  @pageEditor.initializeFrame()
152
140
  expect(@pageEditor.iframe.get(0).contentWindow.History).toEqual(window.History)
153
141
 
142
+ it "calls bindEvents", ->
143
+ @finalizeInterfaceSpy.andCallFake(=>)
144
+ @pageEditor.initializeFrame()
145
+ expect(@bindEventsSpy.callCount).toEqual(1)
146
+
154
147
  it "calls resize", ->
155
148
  @finalizeInterfaceSpy.andCallFake(=>)
156
149
  @pageEditor.initializeFrame()
@@ -174,13 +167,11 @@ describe "Mercury.PageEditor", ->
174
167
  expect(spy.argsForCall[0]).toEqual(['ready'])
175
168
 
176
169
  it "fires the ready event (jQuery.trigger)", ->
177
- mock = {trigger: ->}
178
- @pageEditor.iframe.get(0).contentWindow.jQuery = -> mock
179
- spy = spyOn(mock, 'trigger').andCallFake(=>)
170
+ spy = spyOn(jQuery.fn, 'trigger').andCallFake(=>)
180
171
  @finalizeInterfaceSpy.andCallFake(=>)
181
172
  @pageEditor.initializeFrame()
182
- expect(spy.callCount).toEqual(1)
183
- expect(spy.argsForCall[0]).toEqual(['mercury:ready'])
173
+ expect(spy.callCount).toEqual(2)
174
+ expect(spy.argsForCall[0]).toEqual(['mercury:ready', undefined])
184
175
 
185
176
  it "fires the ready event (Event.fire)", ->
186
177
  @finalizeInterfaceSpy.andCallFake(=>)
@@ -213,12 +204,12 @@ describe "Mercury.PageEditor", ->
213
204
  expect(spy.argsForCall[0]).toEqual(['Mercury.PageEditor failed to load: unknown error\n\nPlease try refreshing.'])
214
205
 
215
206
 
216
- xdescribe "#initializeRegions", ->
207
+ describe "#initializeRegions", ->
217
208
 
218
209
  beforeEach ->
219
210
  @resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
220
211
  Mercury.PageEditor.prototype.initializeFrame = ->
221
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
212
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
222
213
  @pageEditor.document = $(document)
223
214
 
224
215
  it "it calls buildRegion for all the regions found in a document", ->
@@ -247,7 +238,7 @@ describe "Mercury.PageEditor", ->
247
238
  expect(firstFocusCalled).toEqual(false)
248
239
 
249
240
 
250
- xdescribe "#buildRegion", ->
241
+ describe "#buildRegion", ->
251
242
  # it "throws an error if it's not supported", ->
252
243
  # Mercury.supported = false
253
244
  # expect(=>
@@ -259,9 +250,9 @@ describe "Mercury.PageEditor", ->
259
250
  beforeEach ->
260
251
  @resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
261
252
  Mercury.PageEditor.prototype.initializeFrame = ->
262
- Mercury.Regions.Full = -> {region: true}
263
- Mercury.Regions.Full.supported = true
264
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
253
+ Mercury.Regions.Editable = -> {region: true}
254
+ Mercury.Regions.Editable.supported = true
255
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
265
256
 
266
257
  it "instantiates the region and pushes it into the regions array", ->
267
258
  @pageEditor.buildRegion($('#region2'))
@@ -274,7 +265,7 @@ describe "Mercury.PageEditor", ->
274
265
 
275
266
  it "throws an exception when the data-type isn't known", ->
276
267
  expect(=> @pageEditor.buildRegion($('#region4'))).toThrow('Region type is malformed, no data-type provided, or "Unknown" is unknown for the "region4" region.')
277
- $('#region4').attr('custom-region-attribute', 'foo')
268
+ $('#region4').attr('data-type', 'foo')
278
269
  expect(=> @pageEditor.buildRegion($('#region4'))).toThrow('Region type is malformed, no data-type provided, or "Foo" is unknown for the "region4" region.')
279
270
 
280
271
  it "doesn't re-instantiate the region if the element's already initialized", ->
@@ -285,27 +276,27 @@ describe "Mercury.PageEditor", ->
285
276
 
286
277
  it "calls togglePreview on the region if in preview mode", ->
287
278
  callCount = 0
288
- Mercury.Regions.Full = -> {region: true, togglePreview: -> callCount += 1 }
289
- Mercury.Regions.Full.supported = true
279
+ Mercury.Regions.Editable = -> {region: true, togglePreview: -> callCount += 1 }
280
+ Mercury.Regions.Editable.supported = true
290
281
  @pageEditor.previewing = true
291
282
  @pageEditor.buildRegion($('#region2'))
292
283
  expect(callCount).toEqual(1)
293
284
 
294
285
  it "doesn't call togglePreview if not in preview mode", ->
295
286
  callCount = 0
296
- Mercury.Regions.Full = -> {region: true, togglePreview: -> callCount += 1 }
297
- Mercury.Regions.Full.supported = true
287
+ Mercury.Regions.Editable = -> {region: true, togglePreview: -> callCount += 1 }
288
+ Mercury.Regions.Editable.supported = true
298
289
  @pageEditor.buildRegion($('#region2'))
299
290
  expect(callCount).toEqual(0)
300
291
 
301
292
 
302
- xdescribe "#finalizeInterface", ->
293
+ describe "#finalizeInterface", ->
303
294
 
304
295
  beforeEach ->
305
296
  @resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
306
297
  Mercury.PageEditor.prototype.initializeFrame = ->
307
298
  Mercury.SnippetToolbar = -> {snippetToolbar: true}
308
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
299
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
309
300
  @highjackLinksAndFormsSpy = spyOn(Mercury.PageEditor.prototype, 'hijackLinksAndForms').andCallFake(=>)
310
301
 
311
302
  it "injects an sanitizing element used for sanitizing content", ->
@@ -322,25 +313,24 @@ describe "Mercury.PageEditor", ->
322
313
 
323
314
  it "fires a mode event to put things into preview mode if it's not visible yet", ->
324
315
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
325
- @pageEditor.visible = false
316
+ @pageEditor.options.visible = false
326
317
  @pageEditor.finalizeInterface()
327
318
  expect(spy.callCount).toEqual(1)
328
319
 
329
320
 
330
- xdescribe "observed events", ->
321
+ describe "observed events", ->
331
322
 
332
323
  beforeEach ->
333
324
  @initializeInterfaceSpy = spyOn(Mercury.PageEditor.prototype, 'initializeInterface').andCallFake(=>)
334
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
325
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
335
326
  @pageEditor.document = $(document)
336
327
  @pageEditor.bindEvents()
337
- @pageEditor.bindDocumentEvents()
338
328
 
339
329
  describe "custom event: initialize:frame", ->
340
330
 
341
331
  it "calls initializeFrame", ->
342
332
  @initializeFrameSpy = spyOn(Mercury.PageEditor.prototype, 'initializeFrame').andCallFake(=>)
343
- @setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((callback, timeout) -> callback())
333
+ @setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((timeout, callback) -> callback())
344
334
  Mercury.trigger('initialize:frame')
345
335
  expect(@initializeFrameSpy.callCount).toEqual(1)
346
336
  expect(@setTimeoutSpy.callCount).toEqual(1)
@@ -358,7 +348,7 @@ describe "Mercury.PageEditor", ->
358
348
  it "calls focus on a focusable element", ->
359
349
  callCount = 0
360
350
  @pageEditor.focusableElement = {focus: -> callCount += 1}
361
- @setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((callback, timeout) -> callback())
351
+ @setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((timeout, callback) -> callback())
362
352
  Mercury.trigger('focus:window')
363
353
  expect(callCount).toEqual(1)
364
354
 
@@ -430,7 +420,7 @@ describe "Mercury.PageEditor", ->
430
420
  #expect(spy.callCount).toEqual(1)
431
421
 
432
422
 
433
- xdescribe "#toggleInterface", ->
423
+ describe "#toggleInterface", ->
434
424
 
435
425
  beforeEach ->
436
426
  spec = @
@@ -441,7 +431,6 @@ describe "Mercury.PageEditor", ->
441
431
  Mercury.Toolbar = -> {
442
432
  toolbar: true,
443
433
  height: (-> 100),
444
- top: (-> 0),
445
434
  show: (=> spec.toolbarShowCallCount += 1),
446
435
  hide: (=> spec.toolbarHideCallCount += 1)
447
436
  }
@@ -452,7 +441,7 @@ describe "Mercury.PageEditor", ->
452
441
  hide: (=> spec.statusbarHideCallCount += 1)
453
442
  }
454
443
  Mercury.PageEditor.prototype.initializeFrame = ->
455
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
444
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
456
445
 
457
446
  it "calls resize", ->
458
447
  spy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
@@ -471,12 +460,13 @@ describe "Mercury.PageEditor", ->
471
460
  beforeEach ->
472
461
  @pageEditor.visible = true
473
462
 
474
- it "triggers an preview mode event if not currently previewing", ->
475
- @pageEditor.previewing = false
463
+ it "triggers an extra preview mode event if currently previewing", ->
464
+ @pageEditor.previewing = true
476
465
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
477
466
  @pageEditor.toggleInterface()
478
- expect(spy.callCount).toEqual(2)
467
+ expect(spy.callCount).toEqual(3)
479
468
  expect(spy.argsForCall[0]).toEqual(['mode', {mode: 'preview'}])
469
+ expect(spy.argsForCall[1]).toEqual(['mode', {mode: 'preview'}])
480
470
 
481
471
  it "sets visible to false", ->
482
472
  @pageEditor.toggleInterface()
@@ -508,22 +498,22 @@ describe "Mercury.PageEditor", ->
508
498
  expect(@statusbarShowCallCount).toEqual(1)
509
499
 
510
500
 
511
- xdescribe "#resize", ->
501
+ describe "#resize", ->
512
502
 
513
503
  beforeEach ->
514
- Mercury.Toolbar = -> {toolbar: true, height: (-> 100), top: (-> 50)}
504
+ Mercury.Toolbar = -> {toolbar: true, height: -> 100}
515
505
  Mercury.Statusbar = -> {statusbar: true, top: -> 500}
516
506
  Mercury.PageEditor.prototype.initializeFrame = ->
517
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
507
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
518
508
 
519
509
  it "sets the display rectangle to displayRect", ->
520
510
  @pageEditor.resize()
521
- expect(Mercury.displayRect.top).toEqual(100+50)
522
- expect(Mercury.displayRect.height).toEqual(500 - (100+50))
511
+ expect(Mercury.displayRect.top).toEqual(100)
512
+ expect(Mercury.displayRect.height).toEqual(500 - 100)
523
513
 
524
514
  it "resizes the iframe", ->
525
515
  @pageEditor.resize()
526
- expect($('.mercury-iframe').css('height')).toEqual("#{500 - (100+50)}px")
516
+ expect($('.mercury-iframe').css('height')).toEqual("#{500 - 100}px")
527
517
 
528
518
  it "triggers a resize event", ->
529
519
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
@@ -531,12 +521,11 @@ describe "Mercury.PageEditor", ->
531
521
  expect(spy.callCount).toEqual(1)
532
522
 
533
523
 
534
- xdescribe "#iframeSrc", ->
524
+ describe "#iframeSrc", ->
535
525
 
536
526
  beforeEach ->
537
527
  Mercury.PageEditor.prototype.initializeFrame = ->
538
- spyOn(Date.prototype, 'getTime').andReturn(1234)
539
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
528
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
540
529
 
541
530
  it "takes the location and removes the /editor", ->
542
531
  expect(@pageEditor.iframeSrc('http://foo.com/editor/path')).toEqual('http://foo.com/path')
@@ -548,43 +537,17 @@ describe "Mercury.PageEditor", ->
548
537
  Mercury.config.editorUrlRegEx = original
549
538
 
550
539
  it "adds query params", ->
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", ->
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')
556
542
 
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')
578
543
 
579
-
580
-
581
- xdescribe "#hijackLinksAndForms", ->
544
+ describe "#hijackLinksAndForms", ->
582
545
 
583
546
  beforeEach ->
584
547
  Mercury.config.nonHijackableClasses = ['lightview']
585
548
 
586
549
  Mercury.PageEditor.prototype.initializeFrame = ->
587
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
550
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
588
551
  @pageEditor.document = $(document)
589
552
 
590
553
  afterEach ->
@@ -623,11 +586,11 @@ describe "Mercury.PageEditor", ->
623
586
  expect($('#form6').attr('target')).toEqual('foo')
624
587
 
625
588
 
626
- xdescribe "#beforeUnload", ->
589
+ describe "#beforeUnload", ->
627
590
 
628
591
  beforeEach ->
629
592
  Mercury.PageEditor.prototype.initializeInterface = ->
630
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
593
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
631
594
  Mercury.silent = false
632
595
  Mercury.changes = true
633
596
 
@@ -642,11 +605,11 @@ describe "Mercury.PageEditor", ->
642
605
  expect(@pageEditor.beforeUnload()).toEqual(null)
643
606
 
644
607
 
645
- xdescribe "#getRegionByName", ->
608
+ describe "#getRegionByName", ->
646
609
 
647
610
  beforeEach ->
648
611
  Mercury.PageEditor.prototype.initializeInterface = ->
649
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
612
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
650
613
  @iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
651
614
  @ajaxSpy = spyOn($, 'ajax')
652
615
 
@@ -660,12 +623,12 @@ describe "Mercury.PageEditor", ->
660
623
  expect(@pageEditor.getRegionByName('foo')).toEqual(null)
661
624
 
662
625
 
663
- xdescribe "#save", ->
626
+ describe "#save", ->
664
627
 
665
628
  describe "POST", ->
666
629
  beforeEach ->
667
630
  Mercury.PageEditor.prototype.initializeInterface = ->
668
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el, saveDataType: 'text', saveMethod: 'POST'})
631
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test'), saveDataType: 'text'})
669
632
  @iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
670
633
  @ajaxSpy = spyOn($, 'ajax')
671
634
 
@@ -687,12 +650,12 @@ describe "Mercury.PageEditor", ->
687
650
  expect(@ajaxSpy.argsForCall[0][0]).toEqual('/foo/bar')
688
651
 
689
652
  @pageEditor.saveUrl = null
690
- Mercury.saveUrl = '/foo/bit'
653
+ Mercury.saveURL = '/foo/bit'
691
654
  @pageEditor.save()
692
655
  expect(@ajaxSpy.argsForCall[1][0]).toEqual('/foo/bit')
693
656
 
694
657
  @pageEditor.saveUrl = null
695
- Mercury.saveUrl = null
658
+ Mercury.saveURL = null
696
659
  @pageEditor.save()
697
660
  expect(@ajaxSpy.argsForCall[2][0]).toEqual('/foo/baz')
698
661
 
@@ -701,7 +664,7 @@ describe "Mercury.PageEditor", ->
701
664
  Mercury.config.saveStyle = 'json'
702
665
  spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
703
666
  @pageEditor.save()
704
- expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual('{"content":{"region1":"region1"}}')
667
+ expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual({content: '{"region1":"region1"}' })
705
668
 
706
669
  it "can serialize as form values", ->
707
670
  @ajaxSpy.andCallFake(=>)
@@ -743,32 +706,25 @@ describe "Mercury.PageEditor", ->
743
706
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
744
707
  @pageEditor.save()
745
708
  expect(spy.callCount).toEqual(1)
746
- expect(spy.argsForCall[0]).toEqual(['saved', 'data'])
709
+ expect(spy.argsForCall[0]).toEqual(['saved'])
747
710
 
748
711
  describe "on failed ajax request", ->
749
712
 
750
713
  beforeEach ->
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(=>)
714
+ @ajaxSpy.andCallFake((url, options) => options.error() )
756
715
 
716
+ it "alerts with the url", ->
717
+ spy = spyOn(window, 'alert').andCallFake(=>)
757
718
  @pageEditor.saveUrl = '/foo/bar'
758
719
  @pageEditor.save()
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()
720
+ expect(spy.callCount).toEqual(1)
721
+ expect(spy.argsForCall[0]).toEqual(['Mercury was unable to save to the url: /foo/bar'])
766
722
 
767
723
  describe "PUT", ->
768
724
 
769
725
  beforeEach ->
770
726
  Mercury.PageEditor.prototype.initializeInterface = ->
771
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el, saveMethod: 'FOO'})
727
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test'), saveMethod: 'PUT'})
772
728
  @iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
773
729
  @ajaxSpy = spyOn($, 'ajax')
774
730
 
@@ -776,14 +732,14 @@ describe "Mercury.PageEditor", ->
776
732
  @ajaxSpy.andCallFake(=>)
777
733
  spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
778
734
  @pageEditor.save()
779
- expect(test=@ajaxSpy.argsForCall[0][1]['data']).toContain('"_method":"PUT"')
735
+ expect(@ajaxSpy.argsForCall[0][1]['data']['_method']).toEqual('PUT')
780
736
 
781
737
 
782
- xdescribe "#serialize", ->
738
+ describe "#serialize", ->
783
739
 
784
740
  beforeEach ->
785
741
  Mercury.PageEditor.prototype.initializeInterface = ->
786
- @pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
742
+ @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
787
743
  @pageEditor.regions = [
788
744
  {name: 'region1', serialize: -> 'region1'},
789
745
  {name: 'region2', serialize: -> 'region2'}
@@ -1,7 +1,8 @@
1
1
  describe "Mercury.Palette", ->
2
2
 
3
+ template 'mercury/palette.html'
4
+
3
5
  beforeEach ->
4
- fixture.load('mercury/palette.html')
5
6
  $.fx.off = true
6
7
 
7
8
  afterEach ->
@@ -11,7 +12,7 @@ describe "Mercury.Palette", ->
11
12
  describe "#build", ->
12
13
 
13
14
  it "builds an element", ->
14
- @palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: fixture.el, for: $('#button')})
15
+ @palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
15
16
  html = $('<div>').html(@palette.element).html()
16
17
  expect(html).toContain('class="mercury-palette mercury-foo-palette loading"')
17
18
  expect(html).toContain('style="display:none"')
@@ -24,7 +25,7 @@ describe "Mercury.Palette", ->
24
25
  describe "observed events", ->
25
26
 
26
27
  beforeEach ->
27
- @palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: fixture.el, for: $('#button')})
28
+ @palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
28
29
 
29
30
  it "hides", ->
30
31
  @palette.element.css({display: 'block'})
@@ -40,7 +41,7 @@ describe "Mercury.Palette", ->
40
41
  describe "#position", ->
41
42
 
42
43
  beforeEach ->
43
- @palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: fixture.el, for: $('#button')})
44
+ @palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
44
45
 
45
46
  it "positions based on it's button", ->
46
47
  @palette.element.css({display: 'block'})
@@ -1,7 +1,8 @@
1
1
  describe "Mercury.Panel", ->
2
2
 
3
+ template 'mercury/panel.html'
4
+
3
5
  beforeEach ->
4
- fixture.load('mercury/panel.html')
5
6
  Mercury.displayRect = {top: 20, left: 20, width: 200, height: 200}
6
7
  $.fx.off = true
7
8
  Mercury.determinedLocale =
@@ -17,11 +18,11 @@ describe "Mercury.Panel", ->
17
18
  describe "#build", ->
18
19
 
19
20
  it "builds an element", ->
20
- @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: fixture.el, title: 'foo panel'})
21
+ @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel'})
21
22
  html = $('<div>').html(@panel.element).html()
22
23
  expect(html).toContain('class="mercury-panel loading"')
23
24
  expect(html).toContain('style="display:none;"')
24
- expect(html).toContain('<h1><span>foo panel</span></h1><div class="mercury-panel-pane"></div>')
25
+ expect(html).toContain('<h1>foo panel</h1><div class="mercury-panel-pane"></div>')
25
26
  expect(html).not.toContain('class="mercury-panel-close"')
26
27
 
27
28
  it "appends to any element", ->
@@ -29,7 +30,7 @@ describe "Mercury.Panel", ->
29
30
  expect($('#panel_container .mercury-panel').length).toEqual(1)
30
31
 
31
32
  it "creates a close button if it should", ->
32
- @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: fixture.el, title: 'foo panel', closeButton: true})
33
+ @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel', closeButton: true})
33
34
  html = $('<div>').html(@panel.element).html()
34
35
  expect(html).toContain('class="mercury-panel-close"')
35
36
  expect(@panel.element.find('.mercury-panel-close').css('opacity')).toEqual('0')
@@ -38,7 +39,7 @@ describe "Mercury.Panel", ->
38
39
  describe "observed events", ->
39
40
 
40
41
  beforeEach ->
41
- @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: fixture.el, title: 'foo panel', for: $('#button'), closeButton: true})
42
+ @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel', for: $('#button'), closeButton: true})
42
43
 
43
44
  describe "custom event: resize", ->
44
45
 
@@ -84,7 +85,7 @@ describe "Mercury.Panel", ->
84
85
  describe "#show", ->
85
86
 
86
87
  beforeEach ->
87
- @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: fixture.el, title: 'foo panel'})
88
+ @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel'})
88
89
 
89
90
  it "hides other panels and dialogs", ->
90
91
  spyOn(Mercury.Panel.prototype, 'position')
@@ -145,7 +146,7 @@ describe "Mercury.Panel", ->
145
146
  describe "#loadContent", ->
146
147
 
147
148
  beforeEach ->
148
- @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: fixture.el, title: 'foo panel'})
149
+ @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel'})
149
150
 
150
151
  it "sets loaded to be true", ->
151
152
  @panel.loadContent()
@@ -158,14 +159,16 @@ describe "Mercury.Panel", ->
158
159
  it "sets the element html to be the data passed to it", ->
159
160
  @panel.loadContent('<span>hello world!</span>')
160
161
  html = @panel.element.html()
162
+ expect(html).toContain('<h1>foo panel</h1>')
161
163
  expect(html).toContain('class="mercury-panel-pane"')
162
164
  expect(html).toContain('style="visibility: hidden;')
163
165
  expect(html).toContain('hello world!')
164
166
 
165
- it "sets the element html to be the data passed to it -- translated", ->
167
+ it "sets the element html to be the data passed to it", ->
166
168
  Mercury.config.localization.enabled = true
167
169
  @panel.loadContent('<span>hello world!</span>')
168
170
  html = @panel.element.html()
171
+ expect(html).toContain('<h1>foo panel</h1>')
169
172
  expect(html).toContain('class="mercury-panel-pane"')
170
173
  expect(html).toContain('style="visibility: hidden;')
171
174
  expect(html).toContain('bork! bork!')
@@ -174,7 +177,7 @@ describe "Mercury.Panel", ->
174
177
  describe "#makesDraggable", ->
175
178
 
176
179
  beforeEach ->
177
- @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: fixture.el, title: 'foo panel'})
180
+ @panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel'})
178
181
 
179
182
  it "makes the element draggable", ->
180
183
  spy = spyOn($.fn, 'draggable').andCallFake(=>)