kiteditor 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/POST_INSTALL +21 -0
- data/{vendor → app}/assets/images/mercury/button.png +0 -0
- data/{vendor → app}/assets/images/mercury/close.png +0 -0
- data/app/assets/images/mercury/default-snippet.png +0 -0
- data/{vendor → app}/assets/images/mercury/loading-dark.gif +0 -0
- data/{vendor → app}/assets/images/mercury/loading-light.gif +0 -0
- data/{vendor → app}/assets/images/mercury/missing-image.png +0 -0
- data/{vendor → app}/assets/images/mercury/search-icon.png +0 -0
- data/{vendor → app}/assets/images/mercury/temp-logo.png +0 -0
- data/app/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/action.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/tools.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/user.png +0 -0
- data/app/assets/images/mercury/toolbar/snippets/buttons.png +0 -0
- data/{vendor/assets/javascripts/mercury/dependencies → app/assets/javascripts}/jquery-1.7.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury.js +60 -87
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.additions.js +103 -13
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/liquidmetal.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/showdown.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialog.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +1 -1
- data/{vendor → app}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +1 -1
- data/{vendor → app}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/finalize.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/lightview.js.coffee +38 -17
- data/app/assets/javascripts/mercury/locales/ar.locale.js.coffee +201 -0
- data/app/assets/javascripts/mercury/locales/da.locale.js.coffee +208 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/de.locale.js.coffee +4 -10
- data/{vendor → app}/assets/javascripts/mercury/locales/es.locale.js.coffee +3 -9
- data/{vendor → app}/assets/javascripts/mercury/locales/example.local.js.coffee +3 -5
- data/{vendor → app}/assets/javascripts/mercury/locales/fr.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/hu.locale.js.coffee +209 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/it.locale.js.coffee +3 -9
- data/{vendor → app}/assets/javascripts/mercury/locales/ko.local.js.coffee +4 -10
- data/{vendor → app}/assets/javascripts/mercury/locales/nl.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/pl.locale.js.coffee +213 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/pt.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/ru.locale.js.coffee +200 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/sv.local.js.coffee +3 -9
- data/{vendor → app}/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/uk.locale.js.coffee +200 -0
- data/app/assets/javascripts/mercury/locales/zh.local.js.coffee +203 -0
- data/app/assets/javascripts/mercury/mercury-compiled.js +10720 -0
- data/{vendor → app}/assets/javascripts/mercury/mercury.js.coffee +10 -1
- data/{vendor → app}/assets/javascripts/mercury/modal.js.coffee +62 -40
- data/{vendor → app}/assets/javascripts/mercury/modals/htmleditor.js.coffee +1 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +1 -0
- data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +152 -0
- data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +132 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +2 -0
- data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +68 -0
- data/{vendor → app}/assets/javascripts/mercury/native_extensions.js.coffee +0 -6
- data/{vendor → app}/assets/javascripts/mercury/page_editor.js.coffee +84 -50
- data/{vendor → app}/assets/javascripts/mercury/palette.js.coffee +1 -1
- data/{vendor → app}/assets/javascripts/mercury/panel.js.coffee +3 -2
- data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +2 -2
- data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/region.js.coffee +18 -17
- data/{vendor/assets/javascripts/mercury/regions/editable.js.coffee → app/assets/javascripts/mercury/regions/full.js.coffee} +41 -31
- data/app/assets/javascripts/mercury/regions/image.js.coffee +93 -0
- data/{vendor/assets/javascripts/mercury/regions/markupable.js.coffee → app/assets/javascripts/mercury/regions/markdown.js.coffee} +29 -24
- data/{vendor → app}/assets/javascripts/mercury/regions/simple.js.coffee +11 -54
- data/{vendor/assets/javascripts/mercury/regions/snippetable.js.coffee → app/assets/javascripts/mercury/regions/snippets.js.coffee} +10 -9
- data/{vendor → app}/assets/javascripts/mercury/select.js.coffee +1 -1
- data/app/assets/javascripts/mercury/snippet.js.coffee +136 -0
- data/{vendor → app}/assets/javascripts/mercury/snippet_toolbar.js.coffee +19 -6
- data/{vendor → app}/assets/javascripts/mercury/statusbar.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/support/history.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/table_editor.js.coffee +16 -0
- data/{vendor → app}/assets/javascripts/mercury/toolbar.button.js.coffee +45 -30
- data/{vendor → app}/assets/javascripts/mercury/toolbar.button_group.js.coffee +2 -2
- data/{vendor → app}/assets/javascripts/mercury/toolbar.expander.js.coffee +4 -4
- data/{vendor → app}/assets/javascripts/mercury/toolbar.js.coffee +10 -6
- data/{vendor → app}/assets/javascripts/mercury/tooltip.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/uploader.js.coffee +37 -19
- data/app/assets/stylesheets/_mercury-bootstrap-overrides.scss +61 -0
- data/app/assets/stylesheets/_mercury-sass.scss +33 -0
- data/{vendor → app}/assets/stylesheets/mercury.css +1 -5
- data/{vendor → app}/assets/stylesheets/mercury/all_images.css.erb +6 -2
- data/app/assets/stylesheets/mercury/bootstrap-ish.css +1367 -0
- data/app/assets/stylesheets/mercury/bootstrap-overrides.css +61 -0
- data/{vendor → app}/assets/stylesheets/mercury/dialog.css +21 -8
- data/{vendor → app}/assets/stylesheets/mercury/lightview.css +6 -56
- data/app/assets/stylesheets/mercury/mercury.css +43 -0
- data/{vendor → app}/assets/stylesheets/mercury/modal.css +15 -32
- data/{vendor → app}/assets/stylesheets/mercury/statusbar.css +0 -0
- data/{vendor → app}/assets/stylesheets/mercury/toolbar.css +4 -1
- data/{vendor → app}/assets/stylesheets/mercury/tooltip.css +0 -0
- data/{vendor → app}/assets/stylesheets/mercury/uploader.css +4 -4
- data/app/helpers/mercury_helper.rb +7 -0
- data/app/views/layouts/mercury.html.erb +10 -20
- data/app/views/layouts/mercury.html.haml +19 -0
- data/app/views/layouts/mercury.html.slim +19 -0
- data/app/views/mercury/modals/character.html +1 -1
- data/app/views/mercury/modals/htmleditor.html +3 -7
- data/app/views/mercury/modals/link.html +37 -51
- data/app/views/mercury/modals/media.html +102 -0
- data/app/views/mercury/modals/table.html +79 -73
- data/app/views/mercury/panels/snippets.html +6 -1
- data/app/views/mercury/snippets/example/options.html.erb +23 -27
- data/app/views/mercury/snippets/no_options/preview.html.erb +1 -0
- data/config/routes.rb +9 -0
- data/features/generators/authentication.feature +10 -0
- data/features/generators/images.feature +41 -0
- data/features/generators/install.feature +21 -0
- data/features/loading/loading.feature +5 -2
- data/features/loading/user_interface.feature +9 -7
- data/features/regions/{editable → full}/advanced_editing.feature +0 -0
- data/features/regions/full/basic_editing.feature +198 -0
- data/features/regions/{editable → full}/inserting_links.feature +20 -19
- data/features/regions/{editable → full}/inserting_media.feature +36 -18
- data/features/regions/{editable → full}/inserting_snippets.feature +28 -18
- data/features/regions/{editable → full}/inserting_special_characters.feature +2 -2
- data/features/regions/full/inserting_tables.feature +109 -0
- data/features/regions/{editable → full}/pasting.feature +0 -0
- data/features/regions/{editable → full}/uploading_images.feature +0 -0
- data/features/regions/{markupable → image}/uploading_images.feature +0 -0
- data/features/regions/{markupable → markdown}/advanced_editing.feature +0 -0
- data/features/regions/{markupable → markdown}/basic_editing.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_links.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_media.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_snippets.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_special_characters.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_tables.feature +0 -0
- data/features/regions/{snippetable/advanced_editing.feature → markdown/uploading_images.feature} +0 -0
- data/features/regions/simple/basic_editing.feature +5 -0
- data/features/regions/{snippetable/basic_editing.feature → snippets/advanced_editing.feature} +0 -0
- data/features/regions/{snippetable/inserting_snippets.feature → snippets/basic_editing.feature} +0 -0
- data/{vendor/assets/javascripts/mercury/locales/da.locale.js.coffee → features/regions/snippets/inserting_snippets.feature} +0 -0
- data/features/saving/saving.feature +8 -8
- data/features/step_definitions/custom_web_steps.rb +22 -0
- data/features/step_definitions/generator_steps.rb +23 -0
- data/features/step_definitions/mercury_steps.rb +1 -438
- data/features/support/aruba.rb +28 -0
- data/features/support/env.rb +11 -1
- data/features/support/selectors.rb +23 -0
- data/lib/generators/mercury/install/authentication/authentication_generator.rb +17 -0
- data/lib/generators/mercury/install/images/images_generator.rb +47 -0
- data/{app/models/mercury/image.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image.rb} +7 -0
- data/{db/migrate/20110526035601_create_mercury_images.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image_migration.rb} +0 -0
- data/{app/controllers/mercury → lib/generators/mercury/install/images/templates}/images_controller.rb +0 -0
- data/lib/generators/mercury/install/{templates → images/templates}/mongoid_paperclip_image.rb +0 -0
- data/lib/generators/mercury/install/install_generator.rb +12 -23
- data/lib/mercury-rails.rb +1 -2
- data/lib/mercury/authentication.rb +1 -0
- data/lib/mercury/cucumber/step_definitions.rb +13 -0
- data/lib/mercury/cucumber/step_definitions/mercury_steps.rb +408 -0
- data/{features → lib/mercury/cucumber}/support/mercury_contents.rb +3 -3
- data/{features → lib/mercury/cucumber}/support/mercury_selectors.rb +0 -20
- data/lib/mercury/engine.rb +19 -0
- data/lib/mercury/rails.rb +5 -0
- data/lib/mercury/version.rb +3 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -0
- data/spec/dummy/app/assets/javascripts/prototype.js +6082 -0
- data/spec/dummy/app/assets/stylesheets/application.css.scss +110 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/mercury.html.erb +28 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +58 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/teabag.rb +9 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/db/.gitkeep +0 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/blank.html +1 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/images/bunny.gif +0 -0
- data/spec/dummy/public/images/bunny2.jpg +0 -0
- data/spec/dummy/public/index.html +279 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialog.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/backcolor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/forecolor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/formatblock.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/snippetpanel.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/style.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/lightview.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modal.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modals/htmleditor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modals/insertcharacter.html +0 -0
- data/spec/javascripts/fixtures/mercury/modals/insertlink.html +67 -0
- data/spec/javascripts/fixtures/mercury/modals/insertmedia.html +87 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modals/insertsnippet.html +0 -0
- data/spec/javascripts/fixtures/mercury/modals/inserttable.html +73 -0
- data/spec/javascripts/{templates → fixtures}/mercury/page_editor.html +4 -4
- data/spec/javascripts/{templates → fixtures}/mercury/palette.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/panel.html +0 -0
- data/spec/javascripts/fixtures/mercury/region.html +6 -0
- data/spec/javascripts/fixtures/mercury/regions/full.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/image.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/markdown.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/simple.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/snippets.html +4 -0
- data/spec/javascripts/{templates → fixtures}/mercury/select.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/snippet.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/snippet_toolbar.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/statusbar.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/table_editor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.button.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.button_group.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.expander.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/tooltip.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/uploader.html +0 -0
- data/spec/javascripts/mercury/{dialog_spec.js.coffee → dialog_spec.coffee} +11 -12
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +3 -4
- data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/lightview_spec.js.coffee +180 -142
- data/spec/javascripts/mercury/mercury_spec.js.coffee +19 -13
- data/spec/javascripts/mercury/modal_spec.js.coffee +192 -148
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +4 -5
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +107 -34
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +106 -26
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +50 -40
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +124 -80
- data/spec/javascripts/mercury/palette_spec.js.coffee +4 -5
- data/spec/javascripts/mercury/panel_spec.js.coffee +9 -12
- data/spec/javascripts/mercury/region_spec.js.coffee +22 -17
- data/spec/javascripts/mercury/regions/{editable_spec.js.coffee → full_spec.js.coffee} +26 -28
- data/spec/javascripts/mercury/regions/image_spec.js.coffee +33 -0
- data/spec/javascripts/mercury/regions/{markupable_spec.js.coffee → markdown_spec.js.coffee} +32 -34
- data/spec/javascripts/mercury/regions/simple_spec.js.coffee +32 -0
- data/spec/javascripts/mercury/regions/{snippetable_spec.js.coffee → snippets_spec.js.coffee} +54 -55
- data/spec/javascripts/mercury/select_spec.js.coffee +4 -5
- data/spec/javascripts/mercury/snippet_spec.js.coffee +92 -16
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +31 -16
- data/spec/javascripts/mercury/statusbar_spec.js.coffee +9 -10
- data/spec/javascripts/mercury/table_editor_spec.js.coffee +1 -2
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +7 -9
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +55 -26
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +13 -13
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +43 -14
- data/spec/javascripts/mercury/tooltip_spec.js.coffee +1 -2
- data/spec/javascripts/mercury/uploader_spec.js.coffee +47 -33
- data/spec/javascripts/spec_helper.coffee +4 -0
- data/spec/javascripts/{spec_helper.js → support/event_simulation.js} +0 -2
- data/spec/teabag_env.rb +32 -0
- metadata +366 -196
- data/features/regions/editable/basic_editing.feature +0 -195
- data/features/regions/editable/inserting_tables.feature +0 -109
- data/spec/javascripts/templates/mercury/modals/insertlink.html +0 -30
- data/spec/javascripts/templates/mercury/modals/insertmedia.html +0 -35
- data/spec/javascripts/templates/mercury/modals/inserttable.html +0 -27
- data/spec/javascripts/templates/mercury/region.html +0 -2
- data/spec/javascripts/templates/mercury/regions/editable.html +0 -3
- data/spec/javascripts/templates/mercury/regions/snippetable.html +0 -4
- data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +0 -54
- data/vendor/assets/javascripts/mercury_loader.js +0 -193
- data/vendor/assets/javascripts/mercury_overrides.js +0 -6
- data/vendor/assets/stylesheets/mercury/mercury.css +0 -151
- data/vendor/assets/stylesheets/mercury_overrides.css +0 -17
@@ -2,6 +2,7 @@ describe "Mercury", ->
|
|
2
2
|
|
3
3
|
afterEach: ->
|
4
4
|
Mercury.config.localization.enabled = false
|
5
|
+
window.console ||= {}
|
5
6
|
|
6
7
|
describe "supported:", ->
|
7
8
|
|
@@ -50,7 +51,8 @@ describe "Mercury", ->
|
|
50
51
|
describe ".warn", ->
|
51
52
|
|
52
53
|
beforeEach ->
|
53
|
-
window.console
|
54
|
+
window.console.warn ||= -> ''
|
55
|
+
window.console.trace ||= -> ''
|
54
56
|
@warnSpy = spyOn(window.console, 'warn').andCallFake(=>)
|
55
57
|
@notifySpy = spyOn(Mercury, 'notify').andCallFake(=>)
|
56
58
|
|
@@ -59,15 +61,18 @@ describe "Mercury", ->
|
|
59
61
|
expect(@warnSpy.callCount).toEqual(1)
|
60
62
|
|
61
63
|
it "calls Mercury.notify if there's no console", ->
|
62
|
-
window.console
|
63
|
-
|
64
|
-
|
64
|
+
# original = window.console.debug
|
65
|
+
# window.console.debug = null
|
66
|
+
# Mercury.warn('message', 2)
|
67
|
+
# expect(@notifySpy.callCount).toEqual(1)
|
68
|
+
# window.console.debug = original
|
69
|
+
|
65
70
|
|
66
71
|
|
67
72
|
describe ".log", ->
|
68
73
|
|
69
74
|
beforeEach ->
|
70
|
-
window.console
|
75
|
+
window.console.debug ||= ->
|
71
76
|
@debugSpy = spyOn(window.console, 'debug').andCallFake(=>)
|
72
77
|
Mercury.debug = true
|
73
78
|
|
@@ -80,10 +85,11 @@ describe "Mercury", ->
|
|
80
85
|
Mercury.log(1, 2)
|
81
86
|
expect(@debugSpy.callCount).toEqual(0)
|
82
87
|
|
83
|
-
it "does nothing if there's no console"
|
84
|
-
window.console
|
85
|
-
|
86
|
-
|
88
|
+
it "does nothing if there's no console"
|
89
|
+
# original = window.console.debug
|
90
|
+
# window.console = null
|
91
|
+
# Mercury.log(1, 2)
|
92
|
+
# expect(@debugSpy.callCount).toEqual(0)
|
87
93
|
|
88
94
|
|
89
95
|
describe ".locale", ->
|
@@ -95,10 +101,10 @@ describe "Mercury", ->
|
|
95
101
|
}
|
96
102
|
|
97
103
|
it "memoizes array for what the browsers language is set to (breaks with a different language set)", ->
|
98
|
-
Mercury.config.localization.enabled = true
|
99
|
-
expect(Mercury.determinedLocale).toEqual(undefined)
|
100
|
-
expect(Mercury.locale()).toEqual({top: @translationSource, sub: @translationSource['_US_']})
|
101
|
-
expect(Mercury.determinedLocale).toEqual({top: @translationSource, sub: @translationSource['_US_']})
|
104
|
+
# Mercury.config.localization.enabled = true
|
105
|
+
# expect(Mercury.determinedLocale).toEqual(undefined)
|
106
|
+
# expect(Mercury.locale()).toEqual({top: @translationSource, sub: @translationSource['_US_']})
|
107
|
+
# expect(Mercury.determinedLocale).toEqual({top: @translationSource, sub: @translationSource['_US_']})
|
102
108
|
|
103
109
|
|
104
110
|
describe ".I18n", ->
|
@@ -1,8 +1,7 @@
|
|
1
1
|
describe "Mercury.modal", ->
|
2
2
|
|
3
|
-
template 'mercury/modal.html'
|
4
|
-
|
5
3
|
beforeEach ->
|
4
|
+
fixture.load('mercury/modal.html')
|
6
5
|
$.fx.off = true
|
7
6
|
Mercury.displayRect = {fullHeight: 200}
|
8
7
|
Mercury.determinedLocale =
|
@@ -11,127 +10,148 @@ describe "Mercury.modal", ->
|
|
11
10
|
|
12
11
|
afterEach ->
|
13
12
|
Mercury.config.localization.enabled = false
|
14
|
-
Mercury.modal.
|
15
|
-
Mercury.modal.visible = false
|
13
|
+
Mercury.modal.instance = false
|
16
14
|
$(window).unbind('mercury:refresh')
|
17
15
|
$(window).unbind('mercury:resize')
|
18
16
|
$(document).unbind('keydown')
|
19
17
|
|
20
|
-
describe "
|
18
|
+
describe "builder method", ->
|
21
19
|
|
22
20
|
beforeEach ->
|
23
|
-
@showSpy = spyOn(Mercury.
|
21
|
+
@showSpy = spyOn(Mercury.Modal.prototype, 'show').andCallFake(=>)
|
24
22
|
|
25
23
|
it "calls show", ->
|
26
24
|
Mercury.modal('/foo')
|
27
25
|
expect(@showSpy.callCount).toEqual(1)
|
28
26
|
|
29
|
-
it "returns
|
27
|
+
it "returns an instance", ->
|
30
28
|
ret = Mercury.modal('/foo')
|
31
|
-
expect(ret).toEqual(Mercury.
|
29
|
+
expect(ret.constructor).toEqual(Mercury.Modal)
|
30
|
+
expect(ret.show).toEqual(Mercury.Modal.prototype.show)
|
32
31
|
|
33
32
|
|
34
33
|
describe "#show", ->
|
35
34
|
|
36
35
|
beforeEach ->
|
37
|
-
@initializeSpy = spyOn(Mercury.
|
38
|
-
@updateSpy = spyOn(Mercury.
|
39
|
-
@appearSpy = spyOn(Mercury.
|
36
|
+
@initializeSpy = spyOn(Mercury.Modal.prototype, 'initializeModal').andCallFake(=>)
|
37
|
+
@updateSpy = spyOn(Mercury.Modal.prototype, 'update').andCallFake(=>)
|
38
|
+
@appearSpy = spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
|
39
|
+
|
40
|
+
it "sets options.ujsHandling to true unless set to false", ->
|
41
|
+
instance = new Mercury.Modal()
|
42
|
+
instance.show()
|
43
|
+
expect(instance.options.ujsHandling).toEqual(true)
|
44
|
+
instance = new Mercury.Modal('', {ujsHandling: false})
|
45
|
+
instance.show()
|
46
|
+
expect(instance.options.ujsHandling).toEqual(false)
|
40
47
|
|
41
48
|
it "triggers the focus:window event", ->
|
42
49
|
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
43
|
-
Mercury.
|
50
|
+
new Mercury.Modal().show()
|
44
51
|
expect(spy.callCount).toEqual(1)
|
45
52
|
expect(spy.argsForCall[0]).toEqual(['focus:window'])
|
46
53
|
|
47
54
|
it "calls initialize", ->
|
48
|
-
Mercury.
|
55
|
+
new Mercury.Modal().show()
|
49
56
|
expect(@initializeSpy.callCount).toEqual(1)
|
50
57
|
|
51
58
|
describe "if already visible", ->
|
52
59
|
|
53
60
|
it "calls update", ->
|
54
|
-
|
55
|
-
|
61
|
+
modal = new Mercury.Modal()
|
62
|
+
modal.visible = true
|
63
|
+
modal.show()
|
56
64
|
expect(@updateSpy.callCount).toEqual(1)
|
57
65
|
|
58
66
|
describe "if not visible", ->
|
59
67
|
|
60
68
|
it "calls appear", ->
|
61
|
-
Mercury.
|
69
|
+
modal = new Mercury.Modal()
|
70
|
+
modal.visible = false
|
71
|
+
modal.show()
|
62
72
|
expect(@appearSpy.callCount).toEqual(1)
|
63
73
|
|
64
74
|
|
65
|
-
describe "#
|
75
|
+
describe "#initializeModal", ->
|
66
76
|
|
67
77
|
beforeEach ->
|
68
|
-
@buildSpy = spyOn(Mercury.
|
69
|
-
@bindEventsSpy = spyOn(Mercury.
|
78
|
+
@buildSpy = spyOn(Mercury.Modal.prototype, 'build').andCallFake(=>)
|
79
|
+
@bindEventsSpy = spyOn(Mercury.Modal.prototype, 'bindEvents').andCallFake(=>)
|
80
|
+
@modal = new Mercury.Modal()
|
70
81
|
|
71
82
|
it "calls build", ->
|
72
|
-
|
83
|
+
@modal.initializeModal()
|
73
84
|
expect(@buildSpy.callCount).toEqual(1)
|
74
85
|
|
75
86
|
it "calls bindEvents", ->
|
76
|
-
|
87
|
+
@modal.initializeModal()
|
77
88
|
expect(@bindEventsSpy.callCount).toEqual(1)
|
78
89
|
|
79
90
|
it "does nothing if already initialized", ->
|
80
|
-
|
81
|
-
|
91
|
+
@modal.initialized = true
|
92
|
+
@modal.initializeModal()
|
82
93
|
expect(@buildSpy.callCount).toEqual(0)
|
83
94
|
|
84
95
|
it "sets initialized to true", ->
|
85
|
-
|
86
|
-
expect(
|
96
|
+
@modal.initializeModal()
|
97
|
+
expect(@modal.initialized).toEqual(true)
|
87
98
|
|
88
99
|
|
89
100
|
describe "#build", ->
|
90
101
|
|
91
102
|
beforeEach ->
|
92
|
-
|
103
|
+
@modal = new Mercury.Modal('', {appendTo: fixture.el})
|
93
104
|
|
94
105
|
it "builds an element", ->
|
95
|
-
|
96
|
-
expect($('
|
106
|
+
@modal.build()
|
107
|
+
expect($('.mercury-modal', fixture.el).length).toEqual(1)
|
97
108
|
|
98
109
|
it "builds an overlay element", ->
|
99
|
-
|
100
|
-
expect($('
|
110
|
+
@modal.build()
|
111
|
+
expect($('.mercury-modal-overlay', fixture.el).length).toEqual(1)
|
101
112
|
|
102
113
|
it "creates a titleElement", ->
|
103
|
-
|
104
|
-
expect($('
|
105
|
-
expect($('
|
106
|
-
expect(
|
114
|
+
@modal.build()
|
115
|
+
expect($('.mercury-modal-title', fixture.el).length).toEqual(1)
|
116
|
+
expect($('.mercury-modal-title', fixture.el).html()).toMatch(/<span><\/span><a>.+<\/a>/)
|
117
|
+
expect(@modal.titleElement).toBeDefined()
|
107
118
|
|
108
119
|
it "creates a contentContainerElement", ->
|
109
|
-
|
110
|
-
expect($('
|
111
|
-
expect(
|
120
|
+
@modal.build()
|
121
|
+
expect($('.mercury-modal-content-container', fixture.el).length).toEqual(1)
|
122
|
+
expect(@modal.contentContainerElement).toBeDefined()
|
112
123
|
|
113
124
|
it "creates a contentElement", ->
|
114
|
-
|
115
|
-
expect($('
|
116
|
-
expect(
|
125
|
+
@modal.build()
|
126
|
+
expect($('.mercury-modal-content-container .mercury-modal-content', fixture.el).length).toEqual(1)
|
127
|
+
expect(@modal.contentElement).toBeDefined()
|
117
128
|
|
118
129
|
it "appends to any element", ->
|
119
|
-
|
120
|
-
|
130
|
+
@modal.options = {appendTo: $('#modal_container')}
|
131
|
+
@modal.build()
|
121
132
|
expect($('#modal_container .mercury-modal').length).toEqual(1)
|
122
133
|
expect($('#modal_container .mercury-modal-overlay').length).toEqual(1)
|
134
|
+
|
135
|
+
it "reuses the .mercury-modal and .mercury-modal-overlay elements", ->
|
136
|
+
@modal2 = new Mercury.Modal('', {appendTo: fixture.el})
|
137
|
+
@modal.build()
|
138
|
+
@modal2.build()
|
139
|
+
expect($('.mercury-modal').length).toEqual(1)
|
140
|
+
expect($('.mercury-modal-overlay').length).toEqual(1)
|
141
|
+
expect(@modal2.element.get(0)).toEqual($('.mercury-modal').get(0))
|
142
|
+
expect(@modal2.overlay.get(0)).toEqual($('.mercury-modal-overlay').get(0))
|
123
143
|
|
124
144
|
|
125
145
|
describe "observed events", ->
|
126
146
|
|
127
147
|
beforeEach ->
|
128
|
-
spyOn(Mercury.
|
129
|
-
Mercury.modal('/foo', {appendTo:
|
148
|
+
spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
|
149
|
+
@modal = Mercury.modal('/foo', {appendTo: fixture.el})
|
130
150
|
|
131
151
|
describe "custom event: refresh", ->
|
132
152
|
|
133
153
|
it "calls resize telling it stay visible", ->
|
134
|
-
spy = spyOn(
|
154
|
+
spy = spyOn(@modal, 'resize').andCallFake(=>)
|
135
155
|
Mercury.trigger('refresh')
|
136
156
|
expect(spy.callCount).toEqual(1)
|
137
157
|
expect(spy.argsForCall[0]).toEqual([true])
|
@@ -139,39 +159,39 @@ describe "Mercury.modal", ->
|
|
139
159
|
describe "custom event: resize", ->
|
140
160
|
|
141
161
|
it "calls position", ->
|
142
|
-
spy = spyOn(
|
162
|
+
spy = spyOn(@modal, 'position').andCallFake(=>)
|
143
163
|
Mercury.trigger('resize')
|
144
164
|
expect(spy.callCount).toEqual(1)
|
145
165
|
|
146
166
|
describe "clicking on the overlay (options.allowHideUsingOverlay = true)", ->
|
147
167
|
|
148
168
|
it "calls hide", ->
|
149
|
-
|
150
|
-
spy = spyOn(
|
169
|
+
@modal.options.allowHideUsingOverlay = true
|
170
|
+
spy = spyOn(@modal, 'hide').andCallFake(=>)
|
151
171
|
jasmine.simulate.click($('.mercury-modal-overlay').get(0))
|
152
172
|
expect(spy.callCount).toEqual(1)
|
153
173
|
|
154
174
|
describe "clicking on the overlay (options.allowHideUsingOverlay = false)", ->
|
155
175
|
|
156
176
|
it "doesn't call hide", ->
|
157
|
-
spy = spyOn(
|
177
|
+
spy = spyOn(@modal, 'hide').andCallFake(=>)
|
158
178
|
jasmine.simulate.click($('.mercury-modal-overlay').get(0))
|
159
179
|
expect(spy.callCount).toEqual(0)
|
160
180
|
|
161
181
|
describe "clicking on the close button", ->
|
162
182
|
|
163
183
|
it "calls hide", ->
|
164
|
-
spy = spyOn(
|
184
|
+
spy = spyOn(@modal, 'hide').andCallFake(=>)
|
165
185
|
jasmine.simulate.click($('.mercury-modal-title a').get(0))
|
166
186
|
expect(spy.callCount).toEqual(1)
|
167
187
|
|
168
188
|
describe "pressing esc on document", ->
|
169
189
|
|
170
190
|
beforeEach ->
|
171
|
-
|
172
|
-
|
191
|
+
@modal.visible = true
|
192
|
+
|
173
193
|
it "calls hide", ->
|
174
|
-
spy = spyOn(
|
194
|
+
spy = spyOn(@modal, 'hide').andCallFake(=>)
|
175
195
|
jasmine.simulate.keydown(document, {keyCode: 27})
|
176
196
|
expect(spy.callCount).toEqual(1)
|
177
197
|
|
@@ -179,8 +199,8 @@ describe "Mercury.modal", ->
|
|
179
199
|
|
180
200
|
it "sets a success that will load the contents of the response", ->
|
181
201
|
options = {}
|
182
|
-
spy = spyOn(
|
183
|
-
|
202
|
+
spy = spyOn(@modal, 'loadContent').andCallFake(=>)
|
203
|
+
@modal.element.trigger('ajax:beforeSend', [null, options])
|
184
204
|
expect(options.success).toBeDefined()
|
185
205
|
options.success('new content')
|
186
206
|
expect(spy.callCount).toEqual(1)
|
@@ -190,81 +210,83 @@ describe "Mercury.modal", ->
|
|
190
210
|
describe "#appear", ->
|
191
211
|
|
192
212
|
beforeEach ->
|
193
|
-
Mercury.
|
194
|
-
|
195
|
-
|
196
|
-
@
|
197
|
-
|
213
|
+
@modal = new Mercury.Modal('/blank.html', {appendTo: fixture.el})
|
214
|
+
@modal.visible = true
|
215
|
+
spyOn(@modal, 'update').andCallFake(=>)
|
216
|
+
@loadSpy = spyOn(@modal, 'load').andCallFake(=>)
|
217
|
+
@positionSpy = spyOn(@modal, 'position').andCallFake(=>)
|
218
|
+
@modal.show()
|
198
219
|
|
199
220
|
it "calls position", ->
|
200
|
-
|
221
|
+
@modal.appear()
|
201
222
|
expect(@positionSpy.callCount).toEqual(1)
|
202
223
|
|
203
224
|
it "shows the overlay", ->
|
204
225
|
expect($('.mercury-modal-overlay').css('display')).toEqual('none')
|
205
|
-
|
226
|
+
@modal.appear()
|
206
227
|
expect($('.mercury-modal-overlay').css('display')).toEqual('block')
|
207
228
|
|
208
229
|
it "animates the overlay to full opacity", ->
|
209
230
|
expect($('.mercury-modal-overlay').css('opacity')).toEqual('0')
|
210
|
-
|
231
|
+
@modal.appear()
|
211
232
|
expect($('.mercury-modal-overlay').css('opacity')).toEqual('1')
|
212
233
|
|
213
234
|
it "calls setTitle", ->
|
214
|
-
spy = spyOn(
|
215
|
-
|
235
|
+
spy = spyOn(@modal, 'setTitle').andCallFake(=>)
|
236
|
+
@modal.appear()
|
216
237
|
expect(spy.callCount).toEqual(1)
|
217
238
|
|
218
239
|
it "shows the element", ->
|
219
240
|
expect($('.mercury-modal').css('display')).toEqual('none')
|
220
|
-
|
241
|
+
@modal.appear()
|
221
242
|
expect($('.mercury-modal').css('display')).toEqual('block')
|
222
243
|
|
223
244
|
it "animates the element down", ->
|
224
245
|
expect($('.mercury-modal').css('top')).toEqual('-100px')
|
225
|
-
|
246
|
+
@modal.appear()
|
226
247
|
expect($('.mercury-modal').css('top')).toEqual('0px')
|
227
248
|
|
228
249
|
it "sets visible to true", ->
|
229
|
-
|
230
|
-
|
231
|
-
expect(
|
250
|
+
@modal.visible = false
|
251
|
+
@modal.appear()
|
252
|
+
expect(@modal.visible).toEqual(true)
|
232
253
|
|
233
254
|
it "calls load", ->
|
234
|
-
|
255
|
+
@modal.appear()
|
235
256
|
expect(@loadSpy.callCount).toEqual(1)
|
236
257
|
|
237
258
|
|
238
259
|
describe "#resize", ->
|
239
260
|
|
240
261
|
beforeEach ->
|
241
|
-
|
242
|
-
|
243
|
-
|
262
|
+
@modal = new Mercury.Modal('/blank.html', {appendTo: fixture.el})
|
263
|
+
spyOn(@modal, 'appear').andCallFake(=>)
|
264
|
+
@modal.show()
|
265
|
+
@modal.contentPane = $()
|
244
266
|
|
245
267
|
it "will keep the content element visible if asked to do so", ->
|
246
268
|
$('.mercury-modal-content').css('visibility', 'visible')
|
247
|
-
|
269
|
+
@modal.resize(true)
|
248
270
|
expect($('.mercury-modal-content').css('visibility')).toEqual('visible')
|
249
271
|
|
250
272
|
it "resizes the element and adjusts it's position", ->
|
251
273
|
Mercury.displayRect.width = 1000
|
252
274
|
$('.mercury-modal').css({display: 'block', visibility: 'visible', top: 0})
|
253
|
-
|
275
|
+
@modal.resize()
|
254
276
|
expect($('.mercury-modal').width()).toEqual(400)
|
255
277
|
expect($('.mercury-modal').offset()).toEqual({top: 0, left: 300})
|
256
278
|
expect($('.mercury-modal').height()).toBeGreaterThan(20)
|
257
279
|
|
258
280
|
it "respects minWidth provided in options", ->
|
259
|
-
|
260
|
-
|
281
|
+
@modal.options.minWidth = 500
|
282
|
+
@modal.resize()
|
261
283
|
expect($('.mercury-modal').width()).toEqual(500)
|
262
284
|
|
263
285
|
|
264
286
|
describe "#position", ->
|
265
287
|
|
266
288
|
beforeEach ->
|
267
|
-
spyOn(Mercury.
|
289
|
+
spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
|
268
290
|
|
269
291
|
# todo: test this
|
270
292
|
it "positions the element", ->
|
@@ -273,10 +295,11 @@ describe "Mercury.modal", ->
|
|
273
295
|
describe "#update", ->
|
274
296
|
|
275
297
|
beforeEach ->
|
276
|
-
@
|
277
|
-
@
|
278
|
-
@
|
279
|
-
|
298
|
+
@modal = new Mercury.Modal()
|
299
|
+
@resetSpy = spyOn(@modal, 'reset').andCallFake(=>)
|
300
|
+
@resizeSpy = spyOn(@modal, 'resize').andCallFake(=>)
|
301
|
+
@loadSpy = spyOn(@modal, 'load').andCallFake(=>)
|
302
|
+
@modal.update()
|
280
303
|
|
281
304
|
it "calls reset", ->
|
282
305
|
expect(@resetSpy.callCount).toEqual(1)
|
@@ -291,37 +314,37 @@ describe "Mercury.modal", ->
|
|
291
314
|
describe "#load", ->
|
292
315
|
|
293
316
|
beforeEach ->
|
294
|
-
spyOn(Mercury.
|
317
|
+
spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
|
295
318
|
@ajaxSpy = spyOn($, 'ajax')
|
296
|
-
Mercury.modal('/blank.html', {appendTo:
|
319
|
+
@modal = Mercury.modal('/blank.html', {appendTo: fixture.el})
|
297
320
|
|
298
321
|
it "does nothing if there's no url", ->
|
299
|
-
|
322
|
+
@modal.url = null
|
300
323
|
$('.mercury-modal').removeClass('loading')
|
301
|
-
|
324
|
+
@modal.load()
|
302
325
|
expect($('.mercury-modal').hasClass('loading')).toEqual(false)
|
303
326
|
|
304
327
|
it "sets the loading class on the element", ->
|
305
|
-
|
328
|
+
@modal.load()
|
306
329
|
expect($('.mercury-modal').hasClass('loading')).toEqual(true)
|
307
330
|
|
308
331
|
it "calls setTitle", ->
|
309
|
-
spy = spyOn(
|
310
|
-
|
332
|
+
spy = spyOn(@modal, 'setTitle').andCallFake(=>)
|
333
|
+
@modal.load()
|
311
334
|
expect(spy.callCount).toEqual(1)
|
312
335
|
|
313
336
|
describe "on a preloaded view", ->
|
314
337
|
|
315
338
|
beforeEach ->
|
316
|
-
@setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((
|
339
|
+
@setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((callback, timeout) => callback())
|
317
340
|
Mercury.preloadedViews = {'/blank.html': 'this is the preloaded content'}
|
318
341
|
|
319
342
|
afterEach ->
|
320
343
|
Mercury.preloadedViews = {}
|
321
344
|
|
322
345
|
it "calls loadContent with the content in the preloaded view", ->
|
323
|
-
spy = spyOn(
|
324
|
-
|
346
|
+
spy = spyOn(@modal, 'loadContent').andCallFake(=>)
|
347
|
+
@modal.load()
|
325
348
|
expect(@setTimeoutSpy.callCount).toEqual(1)
|
326
349
|
expect(spy.callCount).toEqual(1)
|
327
350
|
|
@@ -330,7 +353,7 @@ describe "Mercury.modal", ->
|
|
330
353
|
it "makes an ajax request", ->
|
331
354
|
@ajaxSpy.andCallFake(=>)
|
332
355
|
spyOn(Mercury, 'ajaxHeaders').andCallFake(=> {'X-CSRFToken': 'f00'})
|
333
|
-
|
356
|
+
@modal.load()
|
334
357
|
expect(@ajaxSpy.callCount).toEqual(1)
|
335
358
|
expect(@ajaxSpy.argsForCall[0][1]['headers']).toEqual({'X-CSRFToken': 'f00'})
|
336
359
|
|
@@ -340,8 +363,8 @@ describe "Mercury.modal", ->
|
|
340
363
|
@ajaxSpy.andCallFake((url, options) => options.success('return value'))
|
341
364
|
|
342
365
|
it "calls loadContent and passes the returned data", ->
|
343
|
-
spy = spyOn(
|
344
|
-
|
366
|
+
spy = spyOn(@modal, 'loadContent').andCallFake(=>)
|
367
|
+
@modal.load()
|
345
368
|
expect(spy.callCount).toEqual(1)
|
346
369
|
expect(spy.argsForCall[0]).toEqual(['return value'])
|
347
370
|
|
@@ -352,14 +375,14 @@ describe "Mercury.modal", ->
|
|
352
375
|
|
353
376
|
it "calls hide", ->
|
354
377
|
spyOn(window, 'alert').andCallFake(=>)
|
355
|
-
spy = spyOn(
|
356
|
-
|
378
|
+
spy = spyOn(@modal, 'hide').andCallFake(=>)
|
379
|
+
@modal.load()
|
357
380
|
expect(spy.callCount).toEqual(1)
|
358
381
|
|
359
382
|
it "alerts an error message", ->
|
360
|
-
spyOn(
|
383
|
+
spyOn(@modal, 'hide').andCallFake(=>)
|
361
384
|
spy = spyOn(window, 'alert').andCallFake(=>)
|
362
|
-
|
385
|
+
@modal.load()
|
363
386
|
expect(spy.callCount).toEqual(1)
|
364
387
|
expect(spy.argsForCall[0]).toEqual(['Mercury was unable to load /blank.html for the modal.'])
|
365
388
|
|
@@ -367,98 +390,121 @@ describe "Mercury.modal", ->
|
|
367
390
|
describe "#loadContent", ->
|
368
391
|
|
369
392
|
beforeEach ->
|
370
|
-
spyOn(Mercury.
|
371
|
-
@resizeSpy = spyOn(Mercury.
|
372
|
-
Mercury.modal('/blank.html', {appendTo:
|
393
|
+
spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
|
394
|
+
@resizeSpy = spyOn(Mercury.Modal.prototype, 'resize').andCallFake(=>)
|
395
|
+
@modal = Mercury.modal('/blank.html', {appendTo: fixture.el, title: 'title'})
|
373
396
|
|
374
397
|
it "accepts options and sets them to the instance options", ->
|
375
|
-
|
376
|
-
expect(
|
398
|
+
@modal.loadContent('content', {title: 'title'})
|
399
|
+
expect(@modal.options).toEqual({title: 'title'})
|
377
400
|
|
378
401
|
it "calls initialize", ->
|
379
|
-
spy = spyOn(
|
380
|
-
|
402
|
+
spy = spyOn(@modal, 'initializeModal').andCallFake(=>)
|
403
|
+
@modal.loadContent('content')
|
381
404
|
expect(spy.callCount).toEqual(1)
|
382
405
|
|
383
406
|
it "calls setTitle", ->
|
384
|
-
spy = spyOn(
|
385
|
-
|
407
|
+
spy = spyOn(@modal, 'setTitle').andCallFake(=>)
|
408
|
+
@modal.loadContent('content')
|
386
409
|
expect(spy.callCount).toEqual(1)
|
387
410
|
|
388
411
|
it "sets loaded to true", ->
|
389
|
-
|
390
|
-
|
391
|
-
expect(
|
412
|
+
@modal.loaded = false
|
413
|
+
@modal.loadContent('content')
|
414
|
+
expect(@modal.loaded).toEqual(true)
|
392
415
|
|
393
416
|
it "removes the loading class", ->
|
394
417
|
$('.mercury-modal').addClass('loading')
|
395
|
-
|
418
|
+
@modal.loadContent('content')
|
396
419
|
expect($('.mercury-modal').hasClass('loading')).toEqual(false)
|
397
420
|
|
398
421
|
it "sets the content elements html to whatever was passed", ->
|
399
|
-
|
422
|
+
@modal.loadContent('<span>content</span>')
|
400
423
|
expect($('.mercury-modal-content').html()).toEqual('<span>content</span>')
|
401
424
|
|
402
425
|
it "hides the contentElement", ->
|
403
426
|
$('.mercury-modal-content').css('display', 'block')
|
404
|
-
|
427
|
+
@modal.loadContent('content')
|
405
428
|
expect($('.mercury-modal-content').css('display')).toEqual('none')
|
406
429
|
expect($('.mercury-modal-content').css('visibility')).toEqual('hidden')
|
407
430
|
|
408
431
|
it "finds the content panes and control elements in case they were added with the content", ->
|
409
|
-
|
410
|
-
expect(
|
411
|
-
expect(
|
432
|
+
@modal.loadContent('<div class="mercury-display-pane-container"></div><div class="mercury-display-controls"></div>')
|
433
|
+
expect(@modal.contentPane.get(0)).toEqual($('.mercury-display-pane-container', fixture.el).get(0))
|
434
|
+
expect(@modal.contentControl.get(0)).toEqual($('.mercury-display-controls', fixture.el).get(0))
|
412
435
|
|
413
436
|
it "calls an afterLoad callback (if provided in options)", ->
|
414
437
|
callCount = 0
|
415
|
-
|
438
|
+
@modal.loadContent('content', {afterLoad: => callCount += 1})
|
416
439
|
expect(callCount).toEqual(1)
|
417
440
|
|
418
441
|
it "calls a handler method if one is set in modalHandlers", ->
|
419
442
|
callCount = 0
|
420
443
|
Mercury.modalHandlers['foo'] = => callCount += 1
|
421
|
-
|
444
|
+
@modal.loadContent('content', {handler: 'foo'})
|
422
445
|
expect(callCount).toEqual(1)
|
423
446
|
|
424
447
|
it "translates the content if configured", ->
|
425
448
|
Mercury.config.localization.enabled = true
|
426
|
-
|
449
|
+
@modal.loadContent('<span>foo</span>')
|
427
450
|
expect($('.mercury-modal-content').html()).toEqual('<span>Bork!</span>')
|
428
451
|
|
452
|
+
it "makes any element with the modal-close class close the modal", ->
|
453
|
+
spy = spyOn(@modal, 'hide').andCallFake(=>)
|
454
|
+
@modal.loadContent('<span class="modal-close">foo</span>')
|
455
|
+
jasmine.simulate.click(@modal.contentElement.find('.modal-close').get(0))
|
456
|
+
expect(spy.callCount).toEqual(1)
|
457
|
+
|
429
458
|
it "calls resize", ->
|
430
|
-
|
459
|
+
@modal.loadContent('content')
|
431
460
|
expect(@resizeSpy.callCount).toEqual(1)
|
432
461
|
|
433
462
|
|
434
463
|
describe "#setTitle", ->
|
435
464
|
|
436
465
|
beforeEach ->
|
437
|
-
spyOn(Mercury.
|
438
|
-
Mercury.modal('/blank.html', {appendTo:
|
466
|
+
spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
|
467
|
+
@modal = Mercury.modal('/blank.html', {appendTo: fixture.el, title: 'title'})
|
439
468
|
|
440
469
|
it "sets the the title contents to what was provided in the options", ->
|
441
|
-
|
442
|
-
|
470
|
+
@modal.options = {title: 'new title'}
|
471
|
+
@modal.setTitle()
|
443
472
|
expect($('.mercury-modal-title span').html()).toEqual('new title')
|
444
473
|
expect($('.mercury-modal-title a').css('display')).toEqual('inline')
|
445
474
|
|
446
475
|
it "hides the close button if the options.closeButton is false", ->
|
447
|
-
|
448
|
-
|
476
|
+
@modal.options = {title: 'new title', closeButton: false}
|
477
|
+
@modal.setTitle()
|
449
478
|
expect($('.mercury-modal-title a').css('display')).toEqual('none')
|
450
479
|
|
451
480
|
|
481
|
+
describe "#serializeForm", ->
|
482
|
+
|
483
|
+
beforeEach ->
|
484
|
+
spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
|
485
|
+
@modal = Mercury.modal('/blank.html', {appendTo: fixture.el, title: 'title'})
|
486
|
+
|
487
|
+
describe "without a form", ->
|
488
|
+
|
489
|
+
it "returns an empty object", ->
|
490
|
+
expect(@modal.serializeForm()).toEqual({})
|
491
|
+
|
492
|
+
describe "with a form", ->
|
493
|
+
|
494
|
+
it "returns an object of the serialized form", ->
|
495
|
+
@modal.loadContent('<form><input name="options[foo]" value="bar"/></form>')
|
496
|
+
expect(@modal.serializeForm()).toEqual({options: {foo: 'bar'}})
|
497
|
+
|
452
498
|
|
453
499
|
describe "#reset", ->
|
454
500
|
|
455
501
|
beforeEach ->
|
456
|
-
spyOn(Mercury.
|
457
|
-
Mercury.modal('/blank.html', {appendTo:
|
502
|
+
spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
|
503
|
+
@modal = Mercury.modal('/blank.html', {appendTo: fixture.el, title: 'title'})
|
458
504
|
|
459
505
|
it "clears the title and content elements", ->
|
460
506
|
$('.mercury-modal-content').html('content')
|
461
|
-
|
507
|
+
@modal.reset()
|
462
508
|
expect($('.mercury-modal-content').html()).toEqual('')
|
463
509
|
expect($('.mercury-modal-title span').html()).toEqual('')
|
464
510
|
|
@@ -466,39 +512,37 @@ describe "Mercury.modal", ->
|
|
466
512
|
describe "#hide", ->
|
467
513
|
|
468
514
|
beforeEach ->
|
469
|
-
spyOn(Mercury.
|
470
|
-
Mercury.modal('/blank.html', {appendTo:
|
515
|
+
spyOn(Mercury.Modal.prototype, 'appear').andCallFake(=>)
|
516
|
+
@modal = Mercury.modal('/blank.html', {appendTo: fixture.el})
|
471
517
|
|
472
518
|
it "triggers the focus:frame event", ->
|
473
519
|
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
474
|
-
|
520
|
+
@modal.hide()
|
475
521
|
expect(spy.callCount).toEqual(1)
|
476
522
|
expect(spy.argsForCall[0]).toEqual(['focus:frame'])
|
477
523
|
|
478
524
|
it "hides the element", ->
|
479
|
-
|
480
|
-
|
525
|
+
@modal.element.css('display:block')
|
526
|
+
@modal.hide()
|
481
527
|
expect($('.mercury-modal').css('display')).toEqual('none')
|
482
528
|
|
483
529
|
it "hides the overlay element", ->
|
484
|
-
|
485
|
-
|
530
|
+
@modal.overlay.css('display:block')
|
531
|
+
@modal.hide()
|
486
532
|
expect($('.mercury-modal-overlay').css('display')).toEqual('none')
|
487
533
|
|
488
534
|
it "calls reset", ->
|
489
|
-
spy = spyOn(
|
490
|
-
|
535
|
+
spy = spyOn(@modal, 'reset').andCallFake(=>)
|
536
|
+
@modal.hide()
|
491
537
|
expect(spy.callCount).toEqual(1)
|
492
538
|
|
493
539
|
it "sets visible to false", ->
|
494
|
-
|
495
|
-
|
496
|
-
expect(
|
540
|
+
@modal.visible = true
|
541
|
+
@modal.hide()
|
542
|
+
expect(@modal.visible).toEqual(false)
|
497
543
|
|
498
544
|
it "does nothing if the modal is still in the process of showing", ->
|
499
|
-
spy = spyOn(
|
500
|
-
|
501
|
-
|
545
|
+
spy = spyOn(@modal, 'reset').andCallFake(=>)
|
546
|
+
@modal.showing = true
|
547
|
+
@modal.hide()
|
502
548
|
expect(spy.callCount).toEqual(0)
|
503
|
-
|
504
|
-
|