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