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,8 +1,9 @@
|
|
1
1
|
describe "Mercury.PageEditor", ->
|
2
2
|
|
3
|
+
template 'mercury/page_editor.html'
|
4
|
+
|
3
5
|
beforeEach ->
|
4
|
-
|
5
|
-
Mercury.config.regions.attribute = 'custom-region-attribute'
|
6
|
+
Mercury.config.regions.className = 'custom-region-class'
|
6
7
|
|
7
8
|
afterEach ->
|
8
9
|
@pageEditor = null
|
@@ -35,9 +36,9 @@ describe "Mercury.PageEditor", ->
|
|
35
36
|
expect(window.mercuryInstance).toEqual(@pageEditor)
|
36
37
|
|
37
38
|
it "accepts a saveUrl, and options", ->
|
38
|
-
@pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar'
|
39
|
+
@pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar'})
|
39
40
|
expect(@pageEditor.saveUrl).toEqual('/foo/1')
|
40
|
-
expect(@pageEditor.options).toEqual({foo: 'bar',
|
41
|
+
expect(@pageEditor.options).toEqual({foo: 'bar', visible: true})
|
41
42
|
|
42
43
|
it "sets the visible option to true unless it's set", ->
|
43
44
|
@pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar', visible: false})
|
@@ -59,27 +60,24 @@ describe "Mercury.PageEditor", ->
|
|
59
60
|
|
60
61
|
it "gets the csrf token if there's one available", ->
|
61
62
|
new Mercury.PageEditor()
|
62
|
-
expect(Mercury.csrfToken).
|
63
|
+
expect(Mercury.csrfToken).toEqual('K6JhyfOVKJX8X2ZkiJXSf491fc1fF+k79wzrChHQa0g=')
|
63
64
|
|
64
65
|
|
65
66
|
describe "#initializeInterface", ->
|
66
67
|
|
67
68
|
beforeEach ->
|
68
69
|
@resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
|
69
|
-
|
70
|
-
|
70
|
+
Mercury.Toolbar = -> {toolbar: true}
|
71
|
+
Mercury.Statusbar = -> {statusbar: true}
|
71
72
|
@iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo')
|
72
73
|
|
73
74
|
it "builds a focusable element (so we can get focus off the iframe)", ->
|
74
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
75
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
75
76
|
expect($('input.mercury-focusable[type=text]').length).toEqual(1)
|
76
77
|
|
77
|
-
it "builds an iframe
|
78
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
79
|
-
|
80
|
-
expect(iframe.length).toEqual(1)
|
81
|
-
expect(iframe.attr('name')).toEqual 'mercury_iframe'
|
82
|
-
expect(iframe.attr('id')).toEqual 'mercury_iframe'
|
78
|
+
it "builds an iframe", ->
|
79
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
80
|
+
expect($('iframe.mercury-iframe').length).toEqual(1)
|
83
81
|
|
84
82
|
it "appends the elements to any node", ->
|
85
83
|
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#page_editor_container')})
|
@@ -87,36 +85,26 @@ describe "Mercury.PageEditor", ->
|
|
87
85
|
expect($('#page_editor_container iframe.mercury-iframe').length).toEqual(1)
|
88
86
|
|
89
87
|
it "instantiates the toolbar", ->
|
90
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
88
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
91
89
|
expect(@pageEditor.toolbar).toEqual({toolbar: true})
|
92
90
|
|
93
91
|
it "instantiates the statusbar", ->
|
94
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
92
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
95
93
|
expect(@pageEditor.statusbar).toEqual({statusbar: true})
|
96
94
|
|
97
95
|
it "calls resize", ->
|
98
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
96
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
99
97
|
expect(@resizeSpy.callCount).toEqual(1)
|
100
98
|
|
101
|
-
it "binds to iframe load event", ->
|
102
|
-
initializeFrameSpy = spyOn(Mercury.PageEditor.prototype, 'initializeFrame')
|
103
|
-
bindEventsSpy = spyOn(Mercury.PageEditor.prototype, 'bindEvents')
|
104
|
-
|
105
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
|
106
|
-
@pageEditor.iframe.trigger('load')
|
107
|
-
|
108
|
-
expect(initializeFrameSpy.callCount).toEqual(1)
|
109
|
-
expect(bindEventsSpy.callCount).toEqual(1)
|
110
99
|
|
111
|
-
|
112
|
-
xdescribe "#initializeFrame", ->
|
100
|
+
describe "#initializeFrame", ->
|
113
101
|
|
114
102
|
beforeEach ->
|
115
103
|
@resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
|
116
104
|
@bindEventsSpy = spyOn(Mercury.PageEditor.prototype, 'bindEvents').andCallFake(=>)
|
117
105
|
@initializeRegionsSpy = spyOn(Mercury.PageEditor.prototype, 'initializeRegions').andCallFake(=>)
|
118
106
|
@finalizeInterfaceSpy = spyOn(Mercury.PageEditor.prototype, 'finalizeInterface')
|
119
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
107
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
120
108
|
|
121
109
|
it "does nothing if the iframe is already loaded", ->
|
122
110
|
@finalizeInterfaceSpy.andCallFake(=>)
|
@@ -151,6 +139,11 @@ describe "Mercury.PageEditor", ->
|
|
151
139
|
@pageEditor.initializeFrame()
|
152
140
|
expect(@pageEditor.iframe.get(0).contentWindow.History).toEqual(window.History)
|
153
141
|
|
142
|
+
it "calls bindEvents", ->
|
143
|
+
@finalizeInterfaceSpy.andCallFake(=>)
|
144
|
+
@pageEditor.initializeFrame()
|
145
|
+
expect(@bindEventsSpy.callCount).toEqual(1)
|
146
|
+
|
154
147
|
it "calls resize", ->
|
155
148
|
@finalizeInterfaceSpy.andCallFake(=>)
|
156
149
|
@pageEditor.initializeFrame()
|
@@ -174,13 +167,11 @@ describe "Mercury.PageEditor", ->
|
|
174
167
|
expect(spy.argsForCall[0]).toEqual(['ready'])
|
175
168
|
|
176
169
|
it "fires the ready event (jQuery.trigger)", ->
|
177
|
-
|
178
|
-
@pageEditor.iframe.get(0).contentWindow.jQuery = -> mock
|
179
|
-
spy = spyOn(mock, 'trigger').andCallFake(=>)
|
170
|
+
spy = spyOn(jQuery.fn, 'trigger').andCallFake(=>)
|
180
171
|
@finalizeInterfaceSpy.andCallFake(=>)
|
181
172
|
@pageEditor.initializeFrame()
|
182
|
-
expect(spy.callCount).toEqual(
|
183
|
-
expect(spy.argsForCall[0]).toEqual(['mercury:ready'])
|
173
|
+
expect(spy.callCount).toEqual(2)
|
174
|
+
expect(spy.argsForCall[0]).toEqual(['mercury:ready', undefined])
|
184
175
|
|
185
176
|
it "fires the ready event (Event.fire)", ->
|
186
177
|
@finalizeInterfaceSpy.andCallFake(=>)
|
@@ -213,12 +204,12 @@ describe "Mercury.PageEditor", ->
|
|
213
204
|
expect(spy.argsForCall[0]).toEqual(['Mercury.PageEditor failed to load: unknown error\n\nPlease try refreshing.'])
|
214
205
|
|
215
206
|
|
216
|
-
|
207
|
+
describe "#initializeRegions", ->
|
217
208
|
|
218
209
|
beforeEach ->
|
219
210
|
@resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
|
220
211
|
Mercury.PageEditor.prototype.initializeFrame = ->
|
221
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
212
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
222
213
|
@pageEditor.document = $(document)
|
223
214
|
|
224
215
|
it "it calls buildRegion for all the regions found in a document", ->
|
@@ -247,7 +238,7 @@ describe "Mercury.PageEditor", ->
|
|
247
238
|
expect(firstFocusCalled).toEqual(false)
|
248
239
|
|
249
240
|
|
250
|
-
|
241
|
+
describe "#buildRegion", ->
|
251
242
|
# it "throws an error if it's not supported", ->
|
252
243
|
# Mercury.supported = false
|
253
244
|
# expect(=>
|
@@ -259,9 +250,9 @@ describe "Mercury.PageEditor", ->
|
|
259
250
|
beforeEach ->
|
260
251
|
@resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
|
261
252
|
Mercury.PageEditor.prototype.initializeFrame = ->
|
262
|
-
Mercury.Regions.
|
263
|
-
Mercury.Regions.
|
264
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
253
|
+
Mercury.Regions.Editable = -> {region: true}
|
254
|
+
Mercury.Regions.Editable.supported = true
|
255
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
265
256
|
|
266
257
|
it "instantiates the region and pushes it into the regions array", ->
|
267
258
|
@pageEditor.buildRegion($('#region2'))
|
@@ -274,7 +265,7 @@ describe "Mercury.PageEditor", ->
|
|
274
265
|
|
275
266
|
it "throws an exception when the data-type isn't known", ->
|
276
267
|
expect(=> @pageEditor.buildRegion($('#region4'))).toThrow('Region type is malformed, no data-type provided, or "Unknown" is unknown for the "region4" region.')
|
277
|
-
$('#region4').attr('
|
268
|
+
$('#region4').attr('data-type', 'foo')
|
278
269
|
expect(=> @pageEditor.buildRegion($('#region4'))).toThrow('Region type is malformed, no data-type provided, or "Foo" is unknown for the "region4" region.')
|
279
270
|
|
280
271
|
it "doesn't re-instantiate the region if the element's already initialized", ->
|
@@ -285,27 +276,27 @@ describe "Mercury.PageEditor", ->
|
|
285
276
|
|
286
277
|
it "calls togglePreview on the region if in preview mode", ->
|
287
278
|
callCount = 0
|
288
|
-
Mercury.Regions.
|
289
|
-
Mercury.Regions.
|
279
|
+
Mercury.Regions.Editable = -> {region: true, togglePreview: -> callCount += 1 }
|
280
|
+
Mercury.Regions.Editable.supported = true
|
290
281
|
@pageEditor.previewing = true
|
291
282
|
@pageEditor.buildRegion($('#region2'))
|
292
283
|
expect(callCount).toEqual(1)
|
293
284
|
|
294
285
|
it "doesn't call togglePreview if not in preview mode", ->
|
295
286
|
callCount = 0
|
296
|
-
Mercury.Regions.
|
297
|
-
Mercury.Regions.
|
287
|
+
Mercury.Regions.Editable = -> {region: true, togglePreview: -> callCount += 1 }
|
288
|
+
Mercury.Regions.Editable.supported = true
|
298
289
|
@pageEditor.buildRegion($('#region2'))
|
299
290
|
expect(callCount).toEqual(0)
|
300
291
|
|
301
292
|
|
302
|
-
|
293
|
+
describe "#finalizeInterface", ->
|
303
294
|
|
304
295
|
beforeEach ->
|
305
296
|
@resizeSpy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
|
306
297
|
Mercury.PageEditor.prototype.initializeFrame = ->
|
307
298
|
Mercury.SnippetToolbar = -> {snippetToolbar: true}
|
308
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
299
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
309
300
|
@highjackLinksAndFormsSpy = spyOn(Mercury.PageEditor.prototype, 'hijackLinksAndForms').andCallFake(=>)
|
310
301
|
|
311
302
|
it "injects an sanitizing element used for sanitizing content", ->
|
@@ -322,25 +313,24 @@ describe "Mercury.PageEditor", ->
|
|
322
313
|
|
323
314
|
it "fires a mode event to put things into preview mode if it's not visible yet", ->
|
324
315
|
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
325
|
-
@pageEditor.visible = false
|
316
|
+
@pageEditor.options.visible = false
|
326
317
|
@pageEditor.finalizeInterface()
|
327
318
|
expect(spy.callCount).toEqual(1)
|
328
319
|
|
329
320
|
|
330
|
-
|
321
|
+
describe "observed events", ->
|
331
322
|
|
332
323
|
beforeEach ->
|
333
324
|
@initializeInterfaceSpy = spyOn(Mercury.PageEditor.prototype, 'initializeInterface').andCallFake(=>)
|
334
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
325
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
335
326
|
@pageEditor.document = $(document)
|
336
327
|
@pageEditor.bindEvents()
|
337
|
-
@pageEditor.bindDocumentEvents()
|
338
328
|
|
339
329
|
describe "custom event: initialize:frame", ->
|
340
330
|
|
341
331
|
it "calls initializeFrame", ->
|
342
332
|
@initializeFrameSpy = spyOn(Mercury.PageEditor.prototype, 'initializeFrame').andCallFake(=>)
|
343
|
-
@setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((
|
333
|
+
@setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((timeout, callback) -> callback())
|
344
334
|
Mercury.trigger('initialize:frame')
|
345
335
|
expect(@initializeFrameSpy.callCount).toEqual(1)
|
346
336
|
expect(@setTimeoutSpy.callCount).toEqual(1)
|
@@ -358,7 +348,7 @@ describe "Mercury.PageEditor", ->
|
|
358
348
|
it "calls focus on a focusable element", ->
|
359
349
|
callCount = 0
|
360
350
|
@pageEditor.focusableElement = {focus: -> callCount += 1}
|
361
|
-
@setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((
|
351
|
+
@setTimeoutSpy = spyOn(window, 'setTimeout').andCallFake((timeout, callback) -> callback())
|
362
352
|
Mercury.trigger('focus:window')
|
363
353
|
expect(callCount).toEqual(1)
|
364
354
|
|
@@ -430,7 +420,7 @@ describe "Mercury.PageEditor", ->
|
|
430
420
|
#expect(spy.callCount).toEqual(1)
|
431
421
|
|
432
422
|
|
433
|
-
|
423
|
+
describe "#toggleInterface", ->
|
434
424
|
|
435
425
|
beforeEach ->
|
436
426
|
spec = @
|
@@ -441,7 +431,6 @@ describe "Mercury.PageEditor", ->
|
|
441
431
|
Mercury.Toolbar = -> {
|
442
432
|
toolbar: true,
|
443
433
|
height: (-> 100),
|
444
|
-
top: (-> 0),
|
445
434
|
show: (=> spec.toolbarShowCallCount += 1),
|
446
435
|
hide: (=> spec.toolbarHideCallCount += 1)
|
447
436
|
}
|
@@ -452,7 +441,7 @@ describe "Mercury.PageEditor", ->
|
|
452
441
|
hide: (=> spec.statusbarHideCallCount += 1)
|
453
442
|
}
|
454
443
|
Mercury.PageEditor.prototype.initializeFrame = ->
|
455
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
444
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
456
445
|
|
457
446
|
it "calls resize", ->
|
458
447
|
spy = spyOn(Mercury.PageEditor.prototype, 'resize').andCallFake(=>)
|
@@ -471,12 +460,13 @@ describe "Mercury.PageEditor", ->
|
|
471
460
|
beforeEach ->
|
472
461
|
@pageEditor.visible = true
|
473
462
|
|
474
|
-
it "triggers an preview mode event if
|
475
|
-
@pageEditor.previewing =
|
463
|
+
it "triggers an extra preview mode event if currently previewing", ->
|
464
|
+
@pageEditor.previewing = true
|
476
465
|
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
477
466
|
@pageEditor.toggleInterface()
|
478
|
-
expect(spy.callCount).toEqual(
|
467
|
+
expect(spy.callCount).toEqual(3)
|
479
468
|
expect(spy.argsForCall[0]).toEqual(['mode', {mode: 'preview'}])
|
469
|
+
expect(spy.argsForCall[1]).toEqual(['mode', {mode: 'preview'}])
|
480
470
|
|
481
471
|
it "sets visible to false", ->
|
482
472
|
@pageEditor.toggleInterface()
|
@@ -508,22 +498,22 @@ describe "Mercury.PageEditor", ->
|
|
508
498
|
expect(@statusbarShowCallCount).toEqual(1)
|
509
499
|
|
510
500
|
|
511
|
-
|
501
|
+
describe "#resize", ->
|
512
502
|
|
513
503
|
beforeEach ->
|
514
|
-
Mercury.Toolbar = -> {toolbar: true, height:
|
504
|
+
Mercury.Toolbar = -> {toolbar: true, height: -> 100}
|
515
505
|
Mercury.Statusbar = -> {statusbar: true, top: -> 500}
|
516
506
|
Mercury.PageEditor.prototype.initializeFrame = ->
|
517
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
507
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
518
508
|
|
519
509
|
it "sets the display rectangle to displayRect", ->
|
520
510
|
@pageEditor.resize()
|
521
|
-
expect(Mercury.displayRect.top).toEqual(100
|
522
|
-
expect(Mercury.displayRect.height).toEqual(500 -
|
511
|
+
expect(Mercury.displayRect.top).toEqual(100)
|
512
|
+
expect(Mercury.displayRect.height).toEqual(500 - 100)
|
523
513
|
|
524
514
|
it "resizes the iframe", ->
|
525
515
|
@pageEditor.resize()
|
526
|
-
expect($('.mercury-iframe').css('height')).toEqual("#{500 -
|
516
|
+
expect($('.mercury-iframe').css('height')).toEqual("#{500 - 100}px")
|
527
517
|
|
528
518
|
it "triggers a resize event", ->
|
529
519
|
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
@@ -531,12 +521,11 @@ describe "Mercury.PageEditor", ->
|
|
531
521
|
expect(spy.callCount).toEqual(1)
|
532
522
|
|
533
523
|
|
534
|
-
|
524
|
+
describe "#iframeSrc", ->
|
535
525
|
|
536
526
|
beforeEach ->
|
537
527
|
Mercury.PageEditor.prototype.initializeFrame = ->
|
538
|
-
|
539
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
|
528
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
540
529
|
|
541
530
|
it "takes the location and removes the /editor", ->
|
542
531
|
expect(@pageEditor.iframeSrc('http://foo.com/editor/path')).toEqual('http://foo.com/path')
|
@@ -548,43 +537,17 @@ describe "Mercury.PageEditor", ->
|
|
548
537
|
Mercury.config.editorUrlRegEx = original
|
549
538
|
|
550
539
|
it "adds query params", ->
|
551
|
-
expect(@pageEditor.iframeSrc('http://foo.com/editor/path', true)).toEqual('http://foo.com/path?mercury_frame=true
|
552
|
-
expect(@pageEditor.iframeSrc('http://foo.com/editor/path?something=true', true)).toEqual('http://foo.com/path?something=true&mercury_frame=true
|
553
|
-
|
554
|
-
|
555
|
-
xdescribe "#loadIframeSrc", ->
|
540
|
+
expect(@pageEditor.iframeSrc('http://foo.com/editor/path', true)).toEqual('http://foo.com/path?mercury_frame=true')
|
541
|
+
expect(@pageEditor.iframeSrc('http://foo.com/editor/path?something=true', true)).toEqual('http://foo.com/path?something=true&mercury_frame=true')
|
556
542
|
|
557
|
-
beforeEach ->
|
558
|
-
Mercury.PageEditor.prototype.initializeFrame = ->
|
559
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo: fixture.el})
|
560
|
-
|
561
|
-
it 'unbinds events to @document', ->
|
562
|
-
@pageEditor.document = {off: ->}
|
563
|
-
documentSpy = spyOn(@pageEditor.document, 'off')
|
564
|
-
@pageEditor.loadIframeSrc()
|
565
|
-
expect(documentSpy).toHaveBeenCalled()
|
566
|
-
|
567
|
-
it 'resets the iframe loaded data attribute', ->
|
568
|
-
@pageEditor.iframe.data('loaded', true)
|
569
|
-
@pageEditor.loadIframeSrc()
|
570
|
-
expect(@pageEditor.iframe.data('loaded')).toEqual(false)
|
571
|
-
|
572
|
-
it 'sets the iframe source', ->
|
573
|
-
iframe = {contentWindow: {document: {location: {}}}}
|
574
|
-
spyOn(Date.prototype, 'getTime').andReturn(1234)
|
575
|
-
@pageEditor.iframe = {data: (->), get: -> iframe}
|
576
|
-
@pageEditor.loadIframeSrc('boo')
|
577
|
-
expect(iframe.contentWindow.document.location.href).toEqual('boo?mercury_frame=true&_=1234')
|
578
543
|
|
579
|
-
|
580
|
-
|
581
|
-
xdescribe "#hijackLinksAndForms", ->
|
544
|
+
describe "#hijackLinksAndForms", ->
|
582
545
|
|
583
546
|
beforeEach ->
|
584
547
|
Mercury.config.nonHijackableClasses = ['lightview']
|
585
548
|
|
586
549
|
Mercury.PageEditor.prototype.initializeFrame = ->
|
587
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
550
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
588
551
|
@pageEditor.document = $(document)
|
589
552
|
|
590
553
|
afterEach ->
|
@@ -623,11 +586,11 @@ describe "Mercury.PageEditor", ->
|
|
623
586
|
expect($('#form6').attr('target')).toEqual('foo')
|
624
587
|
|
625
588
|
|
626
|
-
|
589
|
+
describe "#beforeUnload", ->
|
627
590
|
|
628
591
|
beforeEach ->
|
629
592
|
Mercury.PageEditor.prototype.initializeInterface = ->
|
630
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
593
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
631
594
|
Mercury.silent = false
|
632
595
|
Mercury.changes = true
|
633
596
|
|
@@ -642,11 +605,11 @@ describe "Mercury.PageEditor", ->
|
|
642
605
|
expect(@pageEditor.beforeUnload()).toEqual(null)
|
643
606
|
|
644
607
|
|
645
|
-
|
608
|
+
describe "#getRegionByName", ->
|
646
609
|
|
647
610
|
beforeEach ->
|
648
611
|
Mercury.PageEditor.prototype.initializeInterface = ->
|
649
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
612
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
650
613
|
@iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
|
651
614
|
@ajaxSpy = spyOn($, 'ajax')
|
652
615
|
|
@@ -660,12 +623,12 @@ describe "Mercury.PageEditor", ->
|
|
660
623
|
expect(@pageEditor.getRegionByName('foo')).toEqual(null)
|
661
624
|
|
662
625
|
|
663
|
-
|
626
|
+
describe "#save", ->
|
664
627
|
|
665
628
|
describe "POST", ->
|
666
629
|
beforeEach ->
|
667
630
|
Mercury.PageEditor.prototype.initializeInterface = ->
|
668
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
631
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test'), saveDataType: 'text'})
|
669
632
|
@iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
|
670
633
|
@ajaxSpy = spyOn($, 'ajax')
|
671
634
|
|
@@ -687,12 +650,12 @@ describe "Mercury.PageEditor", ->
|
|
687
650
|
expect(@ajaxSpy.argsForCall[0][0]).toEqual('/foo/bar')
|
688
651
|
|
689
652
|
@pageEditor.saveUrl = null
|
690
|
-
Mercury.
|
653
|
+
Mercury.saveURL = '/foo/bit'
|
691
654
|
@pageEditor.save()
|
692
655
|
expect(@ajaxSpy.argsForCall[1][0]).toEqual('/foo/bit')
|
693
656
|
|
694
657
|
@pageEditor.saveUrl = null
|
695
|
-
Mercury.
|
658
|
+
Mercury.saveURL = null
|
696
659
|
@pageEditor.save()
|
697
660
|
expect(@ajaxSpy.argsForCall[2][0]).toEqual('/foo/baz')
|
698
661
|
|
@@ -701,7 +664,7 @@ describe "Mercury.PageEditor", ->
|
|
701
664
|
Mercury.config.saveStyle = 'json'
|
702
665
|
spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
|
703
666
|
@pageEditor.save()
|
704
|
-
expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual(
|
667
|
+
expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual({content: '{"region1":"region1"}' })
|
705
668
|
|
706
669
|
it "can serialize as form values", ->
|
707
670
|
@ajaxSpy.andCallFake(=>)
|
@@ -743,32 +706,25 @@ describe "Mercury.PageEditor", ->
|
|
743
706
|
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
744
707
|
@pageEditor.save()
|
745
708
|
expect(spy.callCount).toEqual(1)
|
746
|
-
expect(spy.argsForCall[0]).toEqual(['saved'
|
709
|
+
expect(spy.argsForCall[0]).toEqual(['saved'])
|
747
710
|
|
748
711
|
describe "on failed ajax request", ->
|
749
712
|
|
750
713
|
beforeEach ->
|
751
|
-
@ajaxSpy.andCallFake((url, options) => options.error(
|
752
|
-
|
753
|
-
it "alerts and triggers save_failed with the url", ->
|
754
|
-
alert_spy = spyOn(window, 'alert').andCallFake(=>)
|
755
|
-
trigger_spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
714
|
+
@ajaxSpy.andCallFake((url, options) => options.error() )
|
756
715
|
|
716
|
+
it "alerts with the url", ->
|
717
|
+
spy = spyOn(window, 'alert').andCallFake(=>)
|
757
718
|
@pageEditor.saveUrl = '/foo/bar'
|
758
719
|
@pageEditor.save()
|
759
|
-
|
760
|
-
expect(
|
761
|
-
expect(alert_spy.argsForCall[0]).toEqual(['Mercury was unable to save to the url: /foo/bar'])
|
762
|
-
|
763
|
-
expect(trigger_spy.callCount).toEqual(1)
|
764
|
-
expect(trigger_spy.argsForCall[0][0]).toEqual('save_failed')
|
765
|
-
expect(trigger_spy.argsForCall[0][1]).toBeDefined()
|
720
|
+
expect(spy.callCount).toEqual(1)
|
721
|
+
expect(spy.argsForCall[0]).toEqual(['Mercury was unable to save to the url: /foo/bar'])
|
766
722
|
|
767
723
|
describe "PUT", ->
|
768
724
|
|
769
725
|
beforeEach ->
|
770
726
|
Mercury.PageEditor.prototype.initializeInterface = ->
|
771
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
727
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test'), saveMethod: 'PUT'})
|
772
728
|
@iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
|
773
729
|
@ajaxSpy = spyOn($, 'ajax')
|
774
730
|
|
@@ -776,14 +732,14 @@ describe "Mercury.PageEditor", ->
|
|
776
732
|
@ajaxSpy.andCallFake(=>)
|
777
733
|
spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
|
778
734
|
@pageEditor.save()
|
779
|
-
expect(
|
735
|
+
expect(@ajaxSpy.argsForCall[0][1]['data']['_method']).toEqual('PUT')
|
780
736
|
|
781
737
|
|
782
|
-
|
738
|
+
describe "#serialize", ->
|
783
739
|
|
784
740
|
beforeEach ->
|
785
741
|
Mercury.PageEditor.prototype.initializeInterface = ->
|
786
|
-
@pageEditor = new Mercury.PageEditor('', {appendTo:
|
742
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
787
743
|
@pageEditor.regions = [
|
788
744
|
{name: 'region1', serialize: -> 'region1'},
|
789
745
|
{name: 'region2', serialize: -> 'region2'}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
describe "Mercury.Palette", ->
|
2
2
|
|
3
|
+
template 'mercury/palette.html'
|
4
|
+
|
3
5
|
beforeEach ->
|
4
|
-
fixture.load('mercury/palette.html')
|
5
6
|
$.fx.off = true
|
6
7
|
|
7
8
|
afterEach ->
|
@@ -11,7 +12,7 @@ describe "Mercury.Palette", ->
|
|
11
12
|
describe "#build", ->
|
12
13
|
|
13
14
|
it "builds an element", ->
|
14
|
-
@palette = new Mercury.Palette('/blank.html', 'foo', {appendTo:
|
15
|
+
@palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
|
15
16
|
html = $('<div>').html(@palette.element).html()
|
16
17
|
expect(html).toContain('class="mercury-palette mercury-foo-palette loading"')
|
17
18
|
expect(html).toContain('style="display:none"')
|
@@ -24,7 +25,7 @@ describe "Mercury.Palette", ->
|
|
24
25
|
describe "observed events", ->
|
25
26
|
|
26
27
|
beforeEach ->
|
27
|
-
@palette = new Mercury.Palette('/blank.html', 'foo', {appendTo:
|
28
|
+
@palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
|
28
29
|
|
29
30
|
it "hides", ->
|
30
31
|
@palette.element.css({display: 'block'})
|
@@ -40,7 +41,7 @@ describe "Mercury.Palette", ->
|
|
40
41
|
describe "#position", ->
|
41
42
|
|
42
43
|
beforeEach ->
|
43
|
-
@palette = new Mercury.Palette('/blank.html', 'foo', {appendTo:
|
44
|
+
@palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
|
44
45
|
|
45
46
|
it "positions based on it's button", ->
|
46
47
|
@palette.element.css({display: 'block'})
|
@@ -1,7 +1,8 @@
|
|
1
1
|
describe "Mercury.Panel", ->
|
2
2
|
|
3
|
+
template 'mercury/panel.html'
|
4
|
+
|
3
5
|
beforeEach ->
|
4
|
-
fixture.load('mercury/panel.html')
|
5
6
|
Mercury.displayRect = {top: 20, left: 20, width: 200, height: 200}
|
6
7
|
$.fx.off = true
|
7
8
|
Mercury.determinedLocale =
|
@@ -17,11 +18,11 @@ describe "Mercury.Panel", ->
|
|
17
18
|
describe "#build", ->
|
18
19
|
|
19
20
|
it "builds an element", ->
|
20
|
-
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo:
|
21
|
+
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel'})
|
21
22
|
html = $('<div>').html(@panel.element).html()
|
22
23
|
expect(html).toContain('class="mercury-panel loading"')
|
23
24
|
expect(html).toContain('style="display:none;"')
|
24
|
-
expect(html).toContain('<h1
|
25
|
+
expect(html).toContain('<h1>foo panel</h1><div class="mercury-panel-pane"></div>')
|
25
26
|
expect(html).not.toContain('class="mercury-panel-close"')
|
26
27
|
|
27
28
|
it "appends to any element", ->
|
@@ -29,7 +30,7 @@ describe "Mercury.Panel", ->
|
|
29
30
|
expect($('#panel_container .mercury-panel').length).toEqual(1)
|
30
31
|
|
31
32
|
it "creates a close button if it should", ->
|
32
|
-
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo:
|
33
|
+
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel', closeButton: true})
|
33
34
|
html = $('<div>').html(@panel.element).html()
|
34
35
|
expect(html).toContain('class="mercury-panel-close"')
|
35
36
|
expect(@panel.element.find('.mercury-panel-close').css('opacity')).toEqual('0')
|
@@ -38,7 +39,7 @@ describe "Mercury.Panel", ->
|
|
38
39
|
describe "observed events", ->
|
39
40
|
|
40
41
|
beforeEach ->
|
41
|
-
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo:
|
42
|
+
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel', for: $('#button'), closeButton: true})
|
42
43
|
|
43
44
|
describe "custom event: resize", ->
|
44
45
|
|
@@ -84,7 +85,7 @@ describe "Mercury.Panel", ->
|
|
84
85
|
describe "#show", ->
|
85
86
|
|
86
87
|
beforeEach ->
|
87
|
-
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo:
|
88
|
+
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel'})
|
88
89
|
|
89
90
|
it "hides other panels and dialogs", ->
|
90
91
|
spyOn(Mercury.Panel.prototype, 'position')
|
@@ -145,7 +146,7 @@ describe "Mercury.Panel", ->
|
|
145
146
|
describe "#loadContent", ->
|
146
147
|
|
147
148
|
beforeEach ->
|
148
|
-
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo:
|
149
|
+
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel'})
|
149
150
|
|
150
151
|
it "sets loaded to be true", ->
|
151
152
|
@panel.loadContent()
|
@@ -158,14 +159,16 @@ describe "Mercury.Panel", ->
|
|
158
159
|
it "sets the element html to be the data passed to it", ->
|
159
160
|
@panel.loadContent('<span>hello world!</span>')
|
160
161
|
html = @panel.element.html()
|
162
|
+
expect(html).toContain('<h1>foo panel</h1>')
|
161
163
|
expect(html).toContain('class="mercury-panel-pane"')
|
162
164
|
expect(html).toContain('style="visibility: hidden;')
|
163
165
|
expect(html).toContain('hello world!')
|
164
166
|
|
165
|
-
it "sets the element html to be the data passed to it
|
167
|
+
it "sets the element html to be the data passed to it", ->
|
166
168
|
Mercury.config.localization.enabled = true
|
167
169
|
@panel.loadContent('<span>hello world!</span>')
|
168
170
|
html = @panel.element.html()
|
171
|
+
expect(html).toContain('<h1>foo panel</h1>')
|
169
172
|
expect(html).toContain('class="mercury-panel-pane"')
|
170
173
|
expect(html).toContain('style="visibility: hidden;')
|
171
174
|
expect(html).toContain('bork! bork!')
|
@@ -174,7 +177,7 @@ describe "Mercury.Panel", ->
|
|
174
177
|
describe "#makesDraggable", ->
|
175
178
|
|
176
179
|
beforeEach ->
|
177
|
-
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo:
|
180
|
+
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel'})
|
178
181
|
|
179
182
|
it "makes the element draggable", ->
|
180
183
|
spy = spyOn($.fn, 'draggable').andCallFake(=>)
|