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