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
@@ -2,6 +2,7 @@ describe "Mercury", ->
2
2
 
3
3
  afterEach: ->
4
4
  Mercury.config.localization.enabled = false
5
+ window.console ||= {}
5
6
 
6
7
  describe "supported:", ->
7
8
 
@@ -50,7 +51,8 @@ describe "Mercury", ->
50
51
  describe ".warn", ->
51
52
 
52
53
  beforeEach ->
53
- window.console = {warn: (-> ''), trace: (-> '')}
54
+ window.console.warn ||= -> ''
55
+ window.console.trace ||= -> ''
54
56
  @warnSpy = spyOn(window.console, 'warn').andCallFake(=>)
55
57
  @notifySpy = spyOn(Mercury, 'notify').andCallFake(=>)
56
58
 
@@ -59,15 +61,18 @@ describe "Mercury", ->
59
61
  expect(@warnSpy.callCount).toEqual(1)
60
62
 
61
63
  it "calls Mercury.notify if there's no console", ->
62
- window.console = null
63
- Mercury.warn('message', 2)
64
- expect(@notifySpy.callCount).toEqual(1)
64
+ # original = window.console.debug
65
+ # window.console.debug = null
66
+ # Mercury.warn('message', 2)
67
+ # expect(@notifySpy.callCount).toEqual(1)
68
+ # window.console.debug = original
69
+
65
70
 
66
71
 
67
72
  describe ".log", ->
68
73
 
69
74
  beforeEach ->
70
- window.console = {debug: -> ''}
75
+ window.console.debug ||= ->
71
76
  @debugSpy = spyOn(window.console, 'debug').andCallFake(=>)
72
77
  Mercury.debug = true
73
78
 
@@ -80,10 +85,11 @@ describe "Mercury", ->
80
85
  Mercury.log(1, 2)
81
86
  expect(@debugSpy.callCount).toEqual(0)
82
87
 
83
- it "does nothing if there's no console", ->
84
- window.console = null
85
- Mercury.log(1, 2)
86
- expect(@debugSpy.callCount).toEqual(0)
88
+ it "does nothing if there's no console"
89
+ # original = window.console.debug
90
+ # window.console = null
91
+ # Mercury.log(1, 2)
92
+ # expect(@debugSpy.callCount).toEqual(0)
87
93
 
88
94
 
89
95
  describe ".locale", ->
@@ -95,10 +101,10 @@ describe "Mercury", ->
95
101
  }
96
102
 
97
103
  it "memoizes array for what the browsers language is set to (breaks with a different language set)", ->
98
- Mercury.config.localization.enabled = true
99
- expect(Mercury.determinedLocale).toEqual(undefined)
100
- expect(Mercury.locale()).toEqual({top: @translationSource, sub: @translationSource['_US_']})
101
- expect(Mercury.determinedLocale).toEqual({top: @translationSource, sub: @translationSource['_US_']})
104
+ # Mercury.config.localization.enabled = true
105
+ # expect(Mercury.determinedLocale).toEqual(undefined)
106
+ # expect(Mercury.locale()).toEqual({top: @translationSource, sub: @translationSource['_US_']})
107
+ # expect(Mercury.determinedLocale).toEqual({top: @translationSource, sub: @translationSource['_US_']})
102
108
 
103
109
 
104
110
  describe ".I18n", ->
@@ -1,8 +1,7 @@
1
1
  describe "Mercury.modal", ->
2
2
 
3
- template 'mercury/modal.html'
4
-
5
3
  beforeEach ->
4
+ fixture.load('mercury/modal.html')
6
5
  $.fx.off = true
7
6
  Mercury.displayRect = {fullHeight: 200}
8
7
  Mercury.determinedLocale =
@@ -11,127 +10,148 @@ describe "Mercury.modal", ->
11
10
 
12
11
  afterEach ->
13
12
  Mercury.config.localization.enabled = false
14
- Mercury.modal.initialized = false
15
- Mercury.modal.visible = false
13
+ Mercury.modal.instance = false
16
14
  $(window).unbind('mercury:refresh')
17
15
  $(window).unbind('mercury:resize')
18
16
  $(document).unbind('keydown')
19
17
 
20
- describe "singleton method", ->
18
+ describe "builder method", ->
21
19
 
22
20
  beforeEach ->
23
- @showSpy = spyOn(Mercury.modal, 'show').andCallFake(=>)
21
+ @showSpy = spyOn(Mercury.Modal.prototype, 'show').andCallFake(=>)
24
22
 
25
23
  it "calls show", ->
26
24
  Mercury.modal('/foo')
27
25
  expect(@showSpy.callCount).toEqual(1)
28
26
 
29
- it "returns the function object", ->
27
+ it "returns an instance", ->
30
28
  ret = Mercury.modal('/foo')
31
- expect(ret).toEqual(Mercury.modal)
29
+ expect(ret.constructor).toEqual(Mercury.Modal)
30
+ expect(ret.show).toEqual(Mercury.Modal.prototype.show)
32
31
 
33
32
 
34
33
  describe "#show", ->
35
34
 
36
35
  beforeEach ->
37
- @initializeSpy = spyOn(Mercury.modal, 'initialize').andCallFake(=>)
38
- @updateSpy = spyOn(Mercury.modal, 'update').andCallFake(=>)
39
- @appearSpy = spyOn(Mercury.modal, 'appear').andCallFake(=>)
36
+ @initializeSpy = spyOn(Mercury.Modal.prototype, 'initializeModal').andCallFake(=>)
37
+ @updateSpy = spyOn(Mercury.Modal.prototype, 'update').andCallFake(=>)
38
+ @appearSpy = spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
39
+
40
+ it "sets options.ujsHandling to true unless set to false", ->
41
+ instance = new Mercury.Modal()
42
+ instance.show()
43
+ expect(instance.options.ujsHandling).toEqual(true)
44
+ instance = new Mercury.Modal('', {ujsHandling: false})
45
+ instance.show()
46
+ expect(instance.options.ujsHandling).toEqual(false)
40
47
 
41
48
  it "triggers the focus:window event", ->
42
49
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
43
- Mercury.modal.show()
50
+ new Mercury.Modal().show()
44
51
  expect(spy.callCount).toEqual(1)
45
52
  expect(spy.argsForCall[0]).toEqual(['focus:window'])
46
53
 
47
54
  it "calls initialize", ->
48
- Mercury.modal.show()
55
+ new Mercury.Modal().show()
49
56
  expect(@initializeSpy.callCount).toEqual(1)
50
57
 
51
58
  describe "if already visible", ->
52
59
 
53
60
  it "calls update", ->
54
- Mercury.modal.visible = true
55
- Mercury.modal.show()
61
+ modal = new Mercury.Modal()
62
+ modal.visible = true
63
+ modal.show()
56
64
  expect(@updateSpy.callCount).toEqual(1)
57
65
 
58
66
  describe "if not visible", ->
59
67
 
60
68
  it "calls appear", ->
61
- Mercury.modal.show()
69
+ modal = new Mercury.Modal()
70
+ modal.visible = false
71
+ modal.show()
62
72
  expect(@appearSpy.callCount).toEqual(1)
63
73
 
64
74
 
65
- describe "#initialize", ->
75
+ describe "#initializeModal", ->
66
76
 
67
77
  beforeEach ->
68
- @buildSpy = spyOn(Mercury.modal, 'build').andCallFake(=>)
69
- @bindEventsSpy = spyOn(Mercury.modal, 'bindEvents').andCallFake(=>)
78
+ @buildSpy = spyOn(Mercury.Modal.prototype, 'build').andCallFake(=>)
79
+ @bindEventsSpy = spyOn(Mercury.Modal.prototype, 'bindEvents').andCallFake(=>)
80
+ @modal = new Mercury.Modal()
70
81
 
71
82
  it "calls build", ->
72
- Mercury.modal.initialize()
83
+ @modal.initializeModal()
73
84
  expect(@buildSpy.callCount).toEqual(1)
74
85
 
75
86
  it "calls bindEvents", ->
76
- Mercury.modal.initialize()
87
+ @modal.initializeModal()
77
88
  expect(@bindEventsSpy.callCount).toEqual(1)
78
89
 
79
90
  it "does nothing if already initialized", ->
80
- Mercury.modal.initialized = true
81
- Mercury.modal.initialize()
91
+ @modal.initialized = true
92
+ @modal.initializeModal()
82
93
  expect(@buildSpy.callCount).toEqual(0)
83
94
 
84
95
  it "sets initialized to true", ->
85
- Mercury.modal.initialize()
86
- expect(Mercury.modal.initialized).toEqual(true)
96
+ @modal.initializeModal()
97
+ expect(@modal.initialized).toEqual(true)
87
98
 
88
99
 
89
100
  describe "#build", ->
90
101
 
91
102
  beforeEach ->
92
- Mercury.modal.options = {appendTo: $('#test')}
103
+ @modal = new Mercury.Modal('', {appendTo: fixture.el})
93
104
 
94
105
  it "builds an element", ->
95
- Mercury.modal.build()
96
- expect($('#test .mercury-modal').length).toEqual(1)
106
+ @modal.build()
107
+ expect($('.mercury-modal', fixture.el).length).toEqual(1)
97
108
 
98
109
  it "builds an overlay element", ->
99
- Mercury.modal.build()
100
- expect($('#test .mercury-modal-overlay').length).toEqual(1)
110
+ @modal.build()
111
+ expect($('.mercury-modal-overlay', fixture.el).length).toEqual(1)
101
112
 
102
113
  it "creates a titleElement", ->
103
- Mercury.modal.build()
104
- expect($('#test .mercury-modal-title').length).toEqual(1)
105
- expect($('#test .mercury-modal-title').html()).toMatch(/<span><\/span><a>.+<\/a>/)
106
- expect(Mercury.modal.titleElement).toBeDefined()
114
+ @modal.build()
115
+ expect($('.mercury-modal-title', fixture.el).length).toEqual(1)
116
+ expect($('.mercury-modal-title', fixture.el).html()).toMatch(/<span><\/span><a>.+<\/a>/)
117
+ expect(@modal.titleElement).toBeDefined()
107
118
 
108
119
  it "creates a contentContainerElement", ->
109
- Mercury.modal.build()
110
- expect($('#test .mercury-modal-content-container').length).toEqual(1)
111
- expect(Mercury.modal.contentContainerElement).toBeDefined()
120
+ @modal.build()
121
+ expect($('.mercury-modal-content-container', fixture.el).length).toEqual(1)
122
+ expect(@modal.contentContainerElement).toBeDefined()
112
123
 
113
124
  it "creates a contentElement", ->
114
- Mercury.modal.build()
115
- expect($('#test .mercury-modal-content-container .mercury-modal-content').length).toEqual(1)
116
- expect(Mercury.modal.contentElement).toBeDefined()
125
+ @modal.build()
126
+ expect($('.mercury-modal-content-container .mercury-modal-content', fixture.el).length).toEqual(1)
127
+ expect(@modal.contentElement).toBeDefined()
117
128
 
118
129
  it "appends to any element", ->
119
- Mercury.modal.options = {appendTo: $('#modal_container')}
120
- Mercury.modal.build()
130
+ @modal.options = {appendTo: $('#modal_container')}
131
+ @modal.build()
121
132
  expect($('#modal_container .mercury-modal').length).toEqual(1)
122
133
  expect($('#modal_container .mercury-modal-overlay').length).toEqual(1)
134
+
135
+ it "reuses the .mercury-modal and .mercury-modal-overlay elements", ->
136
+ @modal2 = new Mercury.Modal('', {appendTo: fixture.el})
137
+ @modal.build()
138
+ @modal2.build()
139
+ expect($('.mercury-modal').length).toEqual(1)
140
+ expect($('.mercury-modal-overlay').length).toEqual(1)
141
+ expect(@modal2.element.get(0)).toEqual($('.mercury-modal').get(0))
142
+ expect(@modal2.overlay.get(0)).toEqual($('.mercury-modal-overlay').get(0))
123
143
 
124
144
 
125
145
  describe "observed events", ->
126
146
 
127
147
  beforeEach ->
128
- spyOn(Mercury.modal, 'appear').andCallFake(=>)
129
- Mercury.modal('/foo', {appendTo: $('#test')})
148
+ spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
149
+ @modal = Mercury.modal('/foo', {appendTo: fixture.el})
130
150
 
131
151
  describe "custom event: refresh", ->
132
152
 
133
153
  it "calls resize telling it stay visible", ->
134
- spy = spyOn(Mercury.modal, 'resize').andCallFake(=>)
154
+ spy = spyOn(@modal, 'resize').andCallFake(=>)
135
155
  Mercury.trigger('refresh')
136
156
  expect(spy.callCount).toEqual(1)
137
157
  expect(spy.argsForCall[0]).toEqual([true])
@@ -139,39 +159,39 @@ describe "Mercury.modal", ->
139
159
  describe "custom event: resize", ->
140
160
 
141
161
  it "calls position", ->
142
- spy = spyOn(Mercury.modal, 'position').andCallFake(=>)
162
+ spy = spyOn(@modal, 'position').andCallFake(=>)
143
163
  Mercury.trigger('resize')
144
164
  expect(spy.callCount).toEqual(1)
145
165
 
146
166
  describe "clicking on the overlay (options.allowHideUsingOverlay = true)", ->
147
167
 
148
168
  it "calls hide", ->
149
- Mercury.modal.options.allowHideUsingOverlay = true
150
- spy = spyOn(Mercury.modal, 'hide').andCallFake(=>)
169
+ @modal.options.allowHideUsingOverlay = true
170
+ spy = spyOn(@modal, 'hide').andCallFake(=>)
151
171
  jasmine.simulate.click($('.mercury-modal-overlay').get(0))
152
172
  expect(spy.callCount).toEqual(1)
153
173
 
154
174
  describe "clicking on the overlay (options.allowHideUsingOverlay = false)", ->
155
175
 
156
176
  it "doesn't call hide", ->
157
- spy = spyOn(Mercury.modal, 'hide').andCallFake(=>)
177
+ spy = spyOn(@modal, 'hide').andCallFake(=>)
158
178
  jasmine.simulate.click($('.mercury-modal-overlay').get(0))
159
179
  expect(spy.callCount).toEqual(0)
160
180
 
161
181
  describe "clicking on the close button", ->
162
182
 
163
183
  it "calls hide", ->
164
- spy = spyOn(Mercury.modal, 'hide').andCallFake(=>)
184
+ spy = spyOn(@modal, 'hide').andCallFake(=>)
165
185
  jasmine.simulate.click($('.mercury-modal-title a').get(0))
166
186
  expect(spy.callCount).toEqual(1)
167
187
 
168
188
  describe "pressing esc on document", ->
169
189
 
170
190
  beforeEach ->
171
- Mercury.modal.visible = true
172
-
191
+ @modal.visible = true
192
+
173
193
  it "calls hide", ->
174
- spy = spyOn(Mercury.modal, 'hide').andCallFake(=>)
194
+ spy = spyOn(@modal, 'hide').andCallFake(=>)
175
195
  jasmine.simulate.keydown(document, {keyCode: 27})
176
196
  expect(spy.callCount).toEqual(1)
177
197
 
@@ -179,8 +199,8 @@ describe "Mercury.modal", ->
179
199
 
180
200
  it "sets a success that will load the contents of the response", ->
181
201
  options = {}
182
- spy = spyOn(Mercury.modal, 'loadContent').andCallFake(=>)
183
- Mercury.modal.element.trigger('ajax:beforeSend', [null, options])
202
+ spy = spyOn(@modal, 'loadContent').andCallFake(=>)
203
+ @modal.element.trigger('ajax:beforeSend', [null, options])
184
204
  expect(options.success).toBeDefined()
185
205
  options.success('new content')
186
206
  expect(spy.callCount).toEqual(1)
@@ -190,81 +210,83 @@ describe "Mercury.modal", ->
190
210
  describe "#appear", ->
191
211
 
192
212
  beforeEach ->
193
- Mercury.modal.visible = true
194
- spyOn(Mercury.modal, 'update').andCallFake(=>)
195
- @loadSpy = spyOn(Mercury.modal, 'load').andCallFake(=>)
196
- @positionSpy = spyOn(Mercury.modal, 'position').andCallFake(=>)
197
- Mercury.modal('/blank.html', {appendTo: $('#test')})
213
+ @modal = new Mercury.Modal('/blank.html', {appendTo: fixture.el})
214
+ @modal.visible = true
215
+ spyOn(@modal, 'update').andCallFake(=>)
216
+ @loadSpy = spyOn(@modal, 'load').andCallFake(=>)
217
+ @positionSpy = spyOn(@modal, 'position').andCallFake(=>)
218
+ @modal.show()
198
219
 
199
220
  it "calls position", ->
200
- Mercury.modal.appear()
221
+ @modal.appear()
201
222
  expect(@positionSpy.callCount).toEqual(1)
202
223
 
203
224
  it "shows the overlay", ->
204
225
  expect($('.mercury-modal-overlay').css('display')).toEqual('none')
205
- Mercury.modal.appear()
226
+ @modal.appear()
206
227
  expect($('.mercury-modal-overlay').css('display')).toEqual('block')
207
228
 
208
229
  it "animates the overlay to full opacity", ->
209
230
  expect($('.mercury-modal-overlay').css('opacity')).toEqual('0')
210
- Mercury.modal.appear()
231
+ @modal.appear()
211
232
  expect($('.mercury-modal-overlay').css('opacity')).toEqual('1')
212
233
 
213
234
  it "calls setTitle", ->
214
- spy = spyOn(Mercury.modal, 'setTitle').andCallFake(=>)
215
- Mercury.modal.appear()
235
+ spy = spyOn(@modal, 'setTitle').andCallFake(=>)
236
+ @modal.appear()
216
237
  expect(spy.callCount).toEqual(1)
217
238
 
218
239
  it "shows the element", ->
219
240
  expect($('.mercury-modal').css('display')).toEqual('none')
220
- Mercury.modal.appear()
241
+ @modal.appear()
221
242
  expect($('.mercury-modal').css('display')).toEqual('block')
222
243
 
223
244
  it "animates the element down", ->
224
245
  expect($('.mercury-modal').css('top')).toEqual('-100px')
225
- Mercury.modal.appear()
246
+ @modal.appear()
226
247
  expect($('.mercury-modal').css('top')).toEqual('0px')
227
248
 
228
249
  it "sets visible to true", ->
229
- Mercury.modal.visible = false
230
- Mercury.modal.appear()
231
- expect(Mercury.modal.visible).toEqual(true)
250
+ @modal.visible = false
251
+ @modal.appear()
252
+ expect(@modal.visible).toEqual(true)
232
253
 
233
254
  it "calls load", ->
234
- Mercury.modal.appear()
255
+ @modal.appear()
235
256
  expect(@loadSpy.callCount).toEqual(1)
236
257
 
237
258
 
238
259
  describe "#resize", ->
239
260
 
240
261
  beforeEach ->
241
- spyOn(Mercury.modal, 'appear').andCallFake(=>)
242
- Mercury.modal('/blank.html', {appendTo: $('#test')})
243
- Mercury.modal.contentPane = $()
262
+ @modal = new Mercury.Modal('/blank.html', {appendTo: fixture.el})
263
+ spyOn(@modal, 'appear').andCallFake(=>)
264
+ @modal.show()
265
+ @modal.contentPane = $()
244
266
 
245
267
  it "will keep the content element visible if asked to do so", ->
246
268
  $('.mercury-modal-content').css('visibility', 'visible')
247
- Mercury.modal.resize(true)
269
+ @modal.resize(true)
248
270
  expect($('.mercury-modal-content').css('visibility')).toEqual('visible')
249
271
 
250
272
  it "resizes the element and adjusts it's position", ->
251
273
  Mercury.displayRect.width = 1000
252
274
  $('.mercury-modal').css({display: 'block', visibility: 'visible', top: 0})
253
- Mercury.modal.resize()
275
+ @modal.resize()
254
276
  expect($('.mercury-modal').width()).toEqual(400)
255
277
  expect($('.mercury-modal').offset()).toEqual({top: 0, left: 300})
256
278
  expect($('.mercury-modal').height()).toBeGreaterThan(20)
257
279
 
258
280
  it "respects minWidth provided in options", ->
259
- Mercury.modal.minWidth = 500
260
- Mercury.modal.resize()
281
+ @modal.options.minWidth = 500
282
+ @modal.resize()
261
283
  expect($('.mercury-modal').width()).toEqual(500)
262
284
 
263
285
 
264
286
  describe "#position", ->
265
287
 
266
288
  beforeEach ->
267
- spyOn(Mercury.modal, 'appear').andCallFake(=>)
289
+ spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
268
290
 
269
291
  # todo: test this
270
292
  it "positions the element", ->
@@ -273,10 +295,11 @@ describe "Mercury.modal", ->
273
295
  describe "#update", ->
274
296
 
275
297
  beforeEach ->
276
- @resetSpy = spyOn(Mercury.modal, 'reset').andCallFake(=>)
277
- @resizeSpy = spyOn(Mercury.modal, 'resize').andCallFake(=>)
278
- @loadSpy = spyOn(Mercury.modal, 'load').andCallFake(=>)
279
- Mercury.modal.update()
298
+ @modal = new Mercury.Modal()
299
+ @resetSpy = spyOn(@modal, 'reset').andCallFake(=>)
300
+ @resizeSpy = spyOn(@modal, 'resize').andCallFake(=>)
301
+ @loadSpy = spyOn(@modal, 'load').andCallFake(=>)
302
+ @modal.update()
280
303
 
281
304
  it "calls reset", ->
282
305
  expect(@resetSpy.callCount).toEqual(1)
@@ -291,37 +314,37 @@ describe "Mercury.modal", ->
291
314
  describe "#load", ->
292
315
 
293
316
  beforeEach ->
294
- spyOn(Mercury.modal, 'appear').andCallFake(=>)
317
+ spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
295
318
  @ajaxSpy = spyOn($, 'ajax')
296
- Mercury.modal('/blank.html', {appendTo: $('#test')})
319
+ @modal = Mercury.modal('/blank.html', {appendTo: fixture.el})
297
320
 
298
321
  it "does nothing if there's no url", ->
299
- Mercury.modal.url = null
322
+ @modal.url = null
300
323
  $('.mercury-modal').removeClass('loading')
301
- Mercury.modal.load()
324
+ @modal.load()
302
325
  expect($('.mercury-modal').hasClass('loading')).toEqual(false)
303
326
 
304
327
  it "sets the loading class on the element", ->
305
- Mercury.modal.load()
328
+ @modal.load()
306
329
  expect($('.mercury-modal').hasClass('loading')).toEqual(true)
307
330
 
308
331
  it "calls setTitle", ->
309
- spy = spyOn(Mercury.modal, 'setTitle').andCallFake(=>)
310
- Mercury.modal.load()
332
+ spy = spyOn(@modal, 'setTitle').andCallFake(=>)
333
+ @modal.load()
311
334
  expect(spy.callCount).toEqual(1)
312
335
 
313
336
  describe "on a preloaded view", ->
314
337
 
315
338
  beforeEach ->
316
- @setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((timeout, callback) => callback())
339
+ @setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((callback, timeout) => callback())
317
340
  Mercury.preloadedViews = {'/blank.html': 'this is the preloaded content'}
318
341
 
319
342
  afterEach ->
320
343
  Mercury.preloadedViews = {}
321
344
 
322
345
  it "calls loadContent with the content in the preloaded view", ->
323
- spy = spyOn(Mercury.modal, 'loadContent').andCallFake(=>)
324
- Mercury.modal.load()
346
+ spy = spyOn(@modal, 'loadContent').andCallFake(=>)
347
+ @modal.load()
325
348
  expect(@setTimeoutSpy.callCount).toEqual(1)
326
349
  expect(spy.callCount).toEqual(1)
327
350
 
@@ -330,7 +353,7 @@ describe "Mercury.modal", ->
330
353
  it "makes an ajax request", ->
331
354
  @ajaxSpy.andCallFake(=>)
332
355
  spyOn(Mercury, 'ajaxHeaders').andCallFake(=> {'X-CSRFToken': 'f00'})
333
- Mercury.modal.load()
356
+ @modal.load()
334
357
  expect(@ajaxSpy.callCount).toEqual(1)
335
358
  expect(@ajaxSpy.argsForCall[0][1]['headers']).toEqual({'X-CSRFToken': 'f00'})
336
359
 
@@ -340,8 +363,8 @@ describe "Mercury.modal", ->
340
363
  @ajaxSpy.andCallFake((url, options) => options.success('return value'))
341
364
 
342
365
  it "calls loadContent and passes the returned data", ->
343
- spy = spyOn(Mercury.modal, 'loadContent').andCallFake(=>)
344
- Mercury.modal.load()
366
+ spy = spyOn(@modal, 'loadContent').andCallFake(=>)
367
+ @modal.load()
345
368
  expect(spy.callCount).toEqual(1)
346
369
  expect(spy.argsForCall[0]).toEqual(['return value'])
347
370
 
@@ -352,14 +375,14 @@ describe "Mercury.modal", ->
352
375
 
353
376
  it "calls hide", ->
354
377
  spyOn(window, 'alert').andCallFake(=>)
355
- spy = spyOn(Mercury.modal, 'hide').andCallFake(=>)
356
- Mercury.modal.load()
378
+ spy = spyOn(@modal, 'hide').andCallFake(=>)
379
+ @modal.load()
357
380
  expect(spy.callCount).toEqual(1)
358
381
 
359
382
  it "alerts an error message", ->
360
- spyOn(Mercury.modal, 'hide').andCallFake(=>)
383
+ spyOn(@modal, 'hide').andCallFake(=>)
361
384
  spy = spyOn(window, 'alert').andCallFake(=>)
362
- Mercury.modal.load()
385
+ @modal.load()
363
386
  expect(spy.callCount).toEqual(1)
364
387
  expect(spy.argsForCall[0]).toEqual(['Mercury was unable to load /blank.html for the modal.'])
365
388
 
@@ -367,98 +390,121 @@ describe "Mercury.modal", ->
367
390
  describe "#loadContent", ->
368
391
 
369
392
  beforeEach ->
370
- spyOn(Mercury.modal, 'appear').andCallFake(=>)
371
- @resizeSpy = spyOn(Mercury.modal, 'resize').andCallFake(=>)
372
- Mercury.modal('/blank.html', {appendTo: $('#test'), title: 'title'})
393
+ spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
394
+ @resizeSpy = spyOn(Mercury.Modal.prototype, 'resize').andCallFake(=>)
395
+ @modal = Mercury.modal('/blank.html', {appendTo: fixture.el, title: 'title'})
373
396
 
374
397
  it "accepts options and sets them to the instance options", ->
375
- Mercury.modal.loadContent('content', {title: 'title'})
376
- expect(Mercury.modal.options).toEqual({title: 'title'})
398
+ @modal.loadContent('content', {title: 'title'})
399
+ expect(@modal.options).toEqual({title: 'title'})
377
400
 
378
401
  it "calls initialize", ->
379
- spy = spyOn(Mercury.modal, 'initialize').andCallFake(=>)
380
- Mercury.modal.loadContent('content')
402
+ spy = spyOn(@modal, 'initializeModal').andCallFake(=>)
403
+ @modal.loadContent('content')
381
404
  expect(spy.callCount).toEqual(1)
382
405
 
383
406
  it "calls setTitle", ->
384
- spy = spyOn(Mercury.modal, 'setTitle').andCallFake(=>)
385
- Mercury.modal.loadContent('content')
407
+ spy = spyOn(@modal, 'setTitle').andCallFake(=>)
408
+ @modal.loadContent('content')
386
409
  expect(spy.callCount).toEqual(1)
387
410
 
388
411
  it "sets loaded to true", ->
389
- Mercury.modal.loaded = false
390
- Mercury.modal.loadContent('content')
391
- expect(Mercury.modal.loaded).toEqual(true)
412
+ @modal.loaded = false
413
+ @modal.loadContent('content')
414
+ expect(@modal.loaded).toEqual(true)
392
415
 
393
416
  it "removes the loading class", ->
394
417
  $('.mercury-modal').addClass('loading')
395
- Mercury.modal.loadContent('content')
418
+ @modal.loadContent('content')
396
419
  expect($('.mercury-modal').hasClass('loading')).toEqual(false)
397
420
 
398
421
  it "sets the content elements html to whatever was passed", ->
399
- Mercury.modal.loadContent('<span>content</span>')
422
+ @modal.loadContent('<span>content</span>')
400
423
  expect($('.mercury-modal-content').html()).toEqual('<span>content</span>')
401
424
 
402
425
  it "hides the contentElement", ->
403
426
  $('.mercury-modal-content').css('display', 'block')
404
- Mercury.modal.loadContent('content')
427
+ @modal.loadContent('content')
405
428
  expect($('.mercury-modal-content').css('display')).toEqual('none')
406
429
  expect($('.mercury-modal-content').css('visibility')).toEqual('hidden')
407
430
 
408
431
  it "finds the content panes and control elements in case they were added with the content", ->
409
- Mercury.modal.loadContent('<div class="mercury-display-pane-container"></div><div class="mercury-display-controls"></div>')
410
- expect(Mercury.modal.contentPane.get(0)).toEqual($('#test .mercury-display-pane-container').get(0))
411
- expect(Mercury.modal.contentControl.get(0)).toEqual($('#test .mercury-display-controls').get(0))
432
+ @modal.loadContent('<div class="mercury-display-pane-container"></div><div class="mercury-display-controls"></div>')
433
+ expect(@modal.contentPane.get(0)).toEqual($('.mercury-display-pane-container', fixture.el).get(0))
434
+ expect(@modal.contentControl.get(0)).toEqual($('.mercury-display-controls', fixture.el).get(0))
412
435
 
413
436
  it "calls an afterLoad callback (if provided in options)", ->
414
437
  callCount = 0
415
- Mercury.modal.loadContent('content', {afterLoad: => callCount += 1})
438
+ @modal.loadContent('content', {afterLoad: => callCount += 1})
416
439
  expect(callCount).toEqual(1)
417
440
 
418
441
  it "calls a handler method if one is set in modalHandlers", ->
419
442
  callCount = 0
420
443
  Mercury.modalHandlers['foo'] = => callCount += 1
421
- Mercury.modal.loadContent('content', {handler: 'foo'})
444
+ @modal.loadContent('content', {handler: 'foo'})
422
445
  expect(callCount).toEqual(1)
423
446
 
424
447
  it "translates the content if configured", ->
425
448
  Mercury.config.localization.enabled = true
426
- Mercury.modal.loadContent('<span>foo</span>')
449
+ @modal.loadContent('<span>foo</span>')
427
450
  expect($('.mercury-modal-content').html()).toEqual('<span>Bork!</span>')
428
451
 
452
+ it "makes any element with the modal-close class close the modal", ->
453
+ spy = spyOn(@modal, 'hide').andCallFake(=>)
454
+ @modal.loadContent('<span class="modal-close">foo</span>')
455
+ jasmine.simulate.click(@modal.contentElement.find('.modal-close').get(0))
456
+ expect(spy.callCount).toEqual(1)
457
+
429
458
  it "calls resize", ->
430
- Mercury.modal.loadContent('content')
459
+ @modal.loadContent('content')
431
460
  expect(@resizeSpy.callCount).toEqual(1)
432
461
 
433
462
 
434
463
  describe "#setTitle", ->
435
464
 
436
465
  beforeEach ->
437
- spyOn(Mercury.modal, 'appear').andCallFake(=>)
438
- Mercury.modal('/blank.html', {appendTo: $('#test'), title: 'title'})
466
+ spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
467
+ @modal = Mercury.modal('/blank.html', {appendTo: fixture.el, title: 'title'})
439
468
 
440
469
  it "sets the the title contents to what was provided in the options", ->
441
- Mercury.modal.options = {title: 'new title'}
442
- Mercury.modal.setTitle()
470
+ @modal.options = {title: 'new title'}
471
+ @modal.setTitle()
443
472
  expect($('.mercury-modal-title span').html()).toEqual('new title')
444
473
  expect($('.mercury-modal-title a').css('display')).toEqual('inline')
445
474
 
446
475
  it "hides the close button if the options.closeButton is false", ->
447
- Mercury.modal.options = {title: 'new title', closeButton: false}
448
- Mercury.modal.setTitle()
476
+ @modal.options = {title: 'new title', closeButton: false}
477
+ @modal.setTitle()
449
478
  expect($('.mercury-modal-title a').css('display')).toEqual('none')
450
479
 
451
480
 
481
+ describe "#serializeForm", ->
482
+
483
+ beforeEach ->
484
+ spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
485
+ @modal = Mercury.modal('/blank.html', {appendTo: fixture.el, title: 'title'})
486
+
487
+ describe "without a form", ->
488
+
489
+ it "returns an empty object", ->
490
+ expect(@modal.serializeForm()).toEqual({})
491
+
492
+ describe "with a form", ->
493
+
494
+ it "returns an object of the serialized form", ->
495
+ @modal.loadContent('<form><input name="options[foo]" value="bar"/></form>')
496
+ expect(@modal.serializeForm()).toEqual({options: {foo: 'bar'}})
497
+
452
498
 
453
499
  describe "#reset", ->
454
500
 
455
501
  beforeEach ->
456
- spyOn(Mercury.modal, 'appear').andCallFake(=>)
457
- Mercury.modal('/blank.html', {appendTo: $('#test'), title: 'title'})
502
+ spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
503
+ @modal = Mercury.modal('/blank.html', {appendTo: fixture.el, title: 'title'})
458
504
 
459
505
  it "clears the title and content elements", ->
460
506
  $('.mercury-modal-content').html('content')
461
- Mercury.modal.reset()
507
+ @modal.reset()
462
508
  expect($('.mercury-modal-content').html()).toEqual('')
463
509
  expect($('.mercury-modal-title span').html()).toEqual('')
464
510
 
@@ -466,39 +512,37 @@ describe "Mercury.modal", ->
466
512
  describe "#hide", ->
467
513
 
468
514
  beforeEach ->
469
- spyOn(Mercury.modal, 'appear').andCallFake(=>)
470
- Mercury.modal('/blank.html', {appendTo: $('#test')})
515
+ spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
516
+ @modal = Mercury.modal('/blank.html', {appendTo: fixture.el})
471
517
 
472
518
  it "triggers the focus:frame event", ->
473
519
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
474
- Mercury.modal.hide()
520
+ @modal.hide()
475
521
  expect(spy.callCount).toEqual(1)
476
522
  expect(spy.argsForCall[0]).toEqual(['focus:frame'])
477
523
 
478
524
  it "hides the element", ->
479
- Mercury.modal.element.css('display:block')
480
- Mercury.modal.hide()
525
+ @modal.element.css('display:block')
526
+ @modal.hide()
481
527
  expect($('.mercury-modal').css('display')).toEqual('none')
482
528
 
483
529
  it "hides the overlay element", ->
484
- Mercury.modal.overlay.css('display:block')
485
- Mercury.modal.hide()
530
+ @modal.overlay.css('display:block')
531
+ @modal.hide()
486
532
  expect($('.mercury-modal-overlay').css('display')).toEqual('none')
487
533
 
488
534
  it "calls reset", ->
489
- spy = spyOn(Mercury.modal, 'reset').andCallFake(=>)
490
- Mercury.modal.hide()
535
+ spy = spyOn(@modal, 'reset').andCallFake(=>)
536
+ @modal.hide()
491
537
  expect(spy.callCount).toEqual(1)
492
538
 
493
539
  it "sets visible to false", ->
494
- Mercury.modal.visible = true
495
- Mercury.modal.hide()
496
- expect(Mercury.modal.visible).toEqual(false)
540
+ @modal.visible = true
541
+ @modal.hide()
542
+ expect(@modal.visible).toEqual(false)
497
543
 
498
544
  it "does nothing if the modal is still in the process of showing", ->
499
- spy = spyOn(Mercury.modal, 'reset').andCallFake(=>)
500
- Mercury.modal.showing = true
501
- Mercury.modal.hide()
545
+ spy = spyOn(@modal, 'reset').andCallFake(=>)
546
+ @modal.showing = true
547
+ @modal.hide()
502
548
  expect(spy.callCount).toEqual(0)
503
-
504
-