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