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