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,6 @@
|
|
1
1
|
describe "Mercury.Snippet", ->
|
2
2
|
|
3
|
-
|
4
|
-
fixture.load('mercury/snippet.html')
|
3
|
+
template 'mercury/snippet.html'
|
5
4
|
|
6
5
|
afterEach ->
|
7
6
|
Mercury.Snippet.all = []
|
@@ -36,7 +35,7 @@ describe "Mercury.Snippet", ->
|
|
36
35
|
it "builds an element (in whatever context is provided", ->
|
37
36
|
ret = @snippet.getHTML($(document))
|
38
37
|
html = $('<div>').html(ret).html()
|
39
|
-
expect(html).toContain('class="
|
38
|
+
expect(html).toContain('class="mercury-snippet"')
|
40
39
|
expect(html).toContain('contenteditable="false"')
|
41
40
|
expect(html).toContain('data-snippet="identity"')
|
42
41
|
expect(html).toContain('data-version="1"')
|
@@ -54,19 +53,6 @@ describe "Mercury.Snippet", ->
|
|
54
53
|
@snippet.getHTML($(document), callback)
|
55
54
|
expect(@loadPreviewSpy.argsForCall[0][1]).toEqual(callback)
|
56
55
|
|
57
|
-
it "wraps the snippet in the specified wrapperTag", ->
|
58
|
-
@snippet.wrapperTag = 'li'
|
59
|
-
ret = @snippet.getHTML($(document))
|
60
|
-
container = $('<div>')
|
61
|
-
container.html(ret)
|
62
|
-
expect($(container.children()[0]).is('li')).toEqual(true)
|
63
|
-
|
64
|
-
it "adds the specified wrapperClass to the wrapperTag", ->
|
65
|
-
@snippet.wrapperClass = 'something'
|
66
|
-
ret = @snippet.getHTML($(document))
|
67
|
-
container = $('<div>')
|
68
|
-
container.html(ret)
|
69
|
-
expect($(container.children()[0]).hasClass('something')).toEqual(true)
|
70
56
|
|
71
57
|
describe "#getText", ->
|
72
58
|
|
@@ -156,11 +142,6 @@ describe "Mercury.Snippet", ->
|
|
156
142
|
@snippet.setOptions({foo: 'baz'})
|
157
143
|
expect(@snippet.history.stack.length).toEqual(2)
|
158
144
|
|
159
|
-
it "can set the wrapperTag attribute from options", ->
|
160
|
-
expect(@snippet.wrapperTag).toEqual('div')
|
161
|
-
@snippet.setOptions({wrapperTag: 'li'})
|
162
|
-
expect(@snippet.wrapperTag).toEqual('li')
|
163
|
-
|
164
145
|
|
165
146
|
describe "#setVersion", ->
|
166
147
|
|
@@ -170,11 +151,11 @@ describe "Mercury.Snippet", ->
|
|
170
151
|
|
171
152
|
it "sets the version", ->
|
172
153
|
@snippet.setVersion(5)
|
173
|
-
expect(@snippet.version).toEqual(
|
154
|
+
expect(@snippet.version).toEqual(4)
|
174
155
|
|
175
156
|
it "accepts a version (can be a string)", ->
|
176
157
|
@snippet.setVersion('2')
|
177
|
-
expect(@snippet.version).toEqual(
|
158
|
+
expect(@snippet.version).toEqual(1)
|
178
159
|
|
179
160
|
it "pulls the version out of the history buffer", ->
|
180
161
|
@snippet.setVersion(3)
|
@@ -196,7 +177,7 @@ describe "Mercury.Snippet", ->
|
|
196
177
|
|
197
178
|
it "returns an object with name and options", ->
|
198
179
|
ret = @snippet.serialize()
|
199
|
-
expect(ret).toEqual({name: 'foo', foo: 'bar'})
|
180
|
+
expect(ret).toEqual({name: 'foo', options: {foo: 'bar'}})
|
200
181
|
|
201
182
|
|
202
183
|
|
@@ -209,45 +190,16 @@ describe "Mercury.Snippet class methods", ->
|
|
209
190
|
|
210
191
|
beforeEach ->
|
211
192
|
@modalSpy = spyOn(Mercury, 'modal').andCallFake(=>)
|
212
|
-
@triggerSpy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
213
|
-
|
214
|
-
describe "with options", ->
|
215
|
-
|
216
|
-
it "opens a modal with the name in the url", ->
|
217
|
-
Mercury.Snippet.displayOptionsFor('foo')
|
218
|
-
expect(@modalSpy.callCount).toEqual(1)
|
219
|
-
expect(@modalSpy.argsForCall[0]).toEqual(["/mercury/snippets/foo/options.html", {title: 'Snippet Options', handler: 'insertSnippet', snippetName: 'foo', loadType : 'POST'}])
|
220
|
-
|
221
|
-
it "sets the snippet back to nothing", ->
|
222
|
-
Mercury.snippet = 'foo'
|
223
|
-
Mercury.Snippet.displayOptionsFor('foo')
|
224
|
-
expect(Mercury.snippet).toEqual(null)
|
225
|
-
|
226
|
-
it "can pass options to the modal", ->
|
227
|
-
Mercury.Snippet.displayOptionsFor('foo', {option1: 'option1'})
|
228
|
-
expect(@modalSpy.callCount).toEqual(1)
|
229
|
-
expect(@modalSpy.argsForCall[0]).toEqual(["/mercury/snippets/foo/options.html", {title: 'Snippet Options', handler: 'insertSnippet', snippetName: 'foo', loadType: 'POST', option1: 'option1'}])
|
230
193
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
describe "without options", ->
|
236
|
-
|
237
|
-
it "triggers an event to insert the snippet", ->
|
238
|
-
Mercury.Snippet.displayOptionsFor('foo', {}, false)
|
239
|
-
expect(@triggerSpy.callCount).toEqual(1)
|
240
|
-
expect(@triggerSpy.argsForCall[0][0]).toEqual('action')
|
241
|
-
expect(@triggerSpy.argsForCall[0][1]['action']).toEqual('insertSnippet')
|
242
|
-
|
243
|
-
it "doesn't open a modal", ->
|
244
|
-
Mercury.Snippet.displayOptionsFor('foo', {}, false)
|
245
|
-
expect(@modalSpy.callCount).toEqual(0)
|
194
|
+
it "opens a modal with the name in the url", ->
|
195
|
+
Mercury.Snippet.displayOptionsFor('foo')
|
196
|
+
expect(@modalSpy.callCount).toEqual(1)
|
197
|
+
expect(@modalSpy.argsForCall[0]).toEqual(["/mercury/snippets/foo/options.html", {title: 'Snippet Options', handler: 'insertSnippet', snippetName: 'foo'}])
|
246
198
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
199
|
+
it "sets the snippet back to nothing", ->
|
200
|
+
Mercury.snippet = 'foo'
|
201
|
+
Mercury.Snippet.displayOptionsFor('foo')
|
202
|
+
expect(Mercury.snippet).toEqual(null)
|
251
203
|
|
252
204
|
|
253
205
|
describe ".create", ->
|
@@ -267,30 +219,6 @@ describe "Mercury.Snippet class methods", ->
|
|
267
219
|
Mercury.Snippet.create('foo', {foo: 'bar'})
|
268
220
|
expect(Mercury.Snippet.all.length).toEqual(1)
|
269
221
|
|
270
|
-
describe "when a snippet exist with an identical identity", ->
|
271
|
-
it "generates a unique identity", ->
|
272
|
-
Mercury.Snippet.load
|
273
|
-
snippet_0: {name: 'foo0', options: {foo: 'bar'}}
|
274
|
-
snippet_1: {name: 'foo1', options: {foo: 'bar'}}
|
275
|
-
snippet_3: {name: 'bar3', options: {baz: 'pizza'}}
|
276
|
-
|
277
|
-
ret = Mercury.Snippet.create('noobie', {noobie: 'one'})
|
278
|
-
expect(ret.identity).toEqual('snippet_2')
|
279
|
-
|
280
|
-
it "generates a unique identity with an un-ordered snippet list", ->
|
281
|
-
Mercury.Snippet.load
|
282
|
-
snippet_0: {name: 'foo0', options: {foo: 'bar'}}
|
283
|
-
snippet_1: {name: 'foo1', options: {foo: 'bar'}}
|
284
|
-
snippet_2: {name: 'foo2', options: {foo: 'bar'}}
|
285
|
-
snippet_12: {name: 'bar12', options: {baz: 'pizza'}}
|
286
|
-
snippet_6: {name: 'bar6', options: {baz: 'pizza'}}
|
287
|
-
snippet_7: {name: 'bar7', options: {baz: 'pizza'}}
|
288
|
-
snippet_3: {name: 'foo3', options: {foo: 'bar'}}
|
289
|
-
snippet_4: {name: 'foo4', options: {foo: 'bar'}}
|
290
|
-
snippet_5: {name: 'foo5', options: {foo: 'bar'}}
|
291
|
-
|
292
|
-
ret = Mercury.Snippet.create('noobie', {noobie: 'one'})
|
293
|
-
expect(ret.identity).toEqual('snippet_8')
|
294
222
|
|
295
223
|
describe ".find", ->
|
296
224
|
|
@@ -308,14 +236,10 @@ describe "Mercury.Snippet class methods", ->
|
|
308
236
|
|
309
237
|
beforeEach ->
|
310
238
|
@snippets = {
|
311
|
-
snippet_1: {name: 'foo',
|
312
|
-
snippet_2: {name: 'bar',
|
239
|
+
snippet_1: {name: 'foo', options: {foo: 'bar'}}
|
240
|
+
snippet_2: {name: 'bar', options: {baz: 'pizza'}}
|
313
241
|
}
|
314
|
-
Mercury.Snippet.load(@snippets)
|
315
242
|
|
316
243
|
it "creates a new instance for each item in the collection", ->
|
244
|
+
Mercury.Snippet.load(@snippets)
|
317
245
|
expect(Mercury.Snippet.all.length).toEqual(2)
|
318
|
-
|
319
|
-
it 'sets the options', ->
|
320
|
-
expect(Mercury.Snippet.find('snippet_1').options.something.foo).toEqual('bar')
|
321
|
-
|
@@ -1,7 +1,8 @@
|
|
1
1
|
describe "Mercury.SnippetToolbar", ->
|
2
2
|
|
3
|
+
template 'mercury/snippet_toolbar.html'
|
4
|
+
|
3
5
|
beforeEach ->
|
4
|
-
fixture.load('mercury/snippet_toolbar.html')
|
5
6
|
$.fx.off = true
|
6
7
|
|
7
8
|
afterEach ->
|
@@ -28,7 +29,7 @@ describe "Mercury.SnippetToolbar", ->
|
|
28
29
|
describe "#build", ->
|
29
30
|
|
30
31
|
it "builds an element", ->
|
31
|
-
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo:
|
32
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test'})
|
32
33
|
html = $('<div>').html(@snippetToolbar.element).html()
|
33
34
|
expect(html).toContain('class="mercury-toolbar mercury-snippet-toolbar"')
|
34
35
|
expect(html).toContain('style="display:none"')
|
@@ -41,7 +42,7 @@ describe "Mercury.SnippetToolbar", ->
|
|
41
42
|
describe "observed events", ->
|
42
43
|
|
43
44
|
beforeEach ->
|
44
|
-
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo:
|
45
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test'})
|
45
46
|
|
46
47
|
describe "custom event: show:toolbar", ->
|
47
48
|
|
@@ -71,34 +72,21 @@ describe "Mercury.SnippetToolbar", ->
|
|
71
72
|
|
72
73
|
it "clears the hide timeout", ->
|
73
74
|
spy = spyOn(window, 'clearTimeout').andCallFake(=>)
|
74
|
-
jasmine.simulate.mousemove($('.mercury-snippet-toolbar'
|
75
|
+
jasmine.simulate.mousemove($('#test .mercury-snippet-toolbar').get(0))
|
75
76
|
expect(spy.callCount).toEqual(1)
|
76
77
|
|
77
78
|
describe "mouseout", ->
|
78
79
|
|
79
80
|
it "calls hide", ->
|
80
81
|
spy = spyOn(Mercury.SnippetToolbar.prototype, 'hide').andCallFake(=>)
|
81
|
-
jasmine.simulate.mouseout($('.mercury-snippet-toolbar'
|
82
|
+
jasmine.simulate.mouseout($('#test .mercury-snippet-toolbar').get(0))
|
82
83
|
expect(spy.callCount).toEqual(1)
|
83
84
|
|
84
|
-
describe "releasing events", ->
|
85
|
-
|
86
|
-
it 'makes the following events releasable', ->
|
87
|
-
events = (eventName for [target, eventName, handler] in @snippetToolbar._boundEvents)
|
88
|
-
expect(events).toEqual(['show:toolbar', 'hide:toolbar', 'scroll'])
|
89
|
-
|
90
|
-
it 'calls off to unbind the events on release', ->
|
91
|
-
targets = (target for [target, eventName, handler] in @snippetToolbar._boundEvents)
|
92
|
-
# we bind to Mercury twice so pop the first one off for spying
|
93
|
-
targets.shift()
|
94
|
-
spys = (spyOn(target, 'off') for target in targets)
|
95
|
-
@snippetToolbar.release()
|
96
|
-
expect(spy).toHaveBeenCalled() for spy in spys
|
97
85
|
|
98
86
|
describe "#show", ->
|
99
87
|
|
100
88
|
beforeEach ->
|
101
|
-
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo:
|
89
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test'})
|
102
90
|
@positionSpy = spyOn(Mercury.SnippetToolbar.prototype, 'position').andCallFake(=>)
|
103
91
|
@appearSpy = spyOn(Mercury.SnippetToolbar.prototype, 'appear').andCallFake(=>)
|
104
92
|
|
@@ -119,22 +107,22 @@ describe "Mercury.SnippetToolbar", ->
|
|
119
107
|
|
120
108
|
beforeEach ->
|
121
109
|
Mercury.displayRect = {top: 20}
|
122
|
-
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo:
|
110
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test', visible: true})
|
123
111
|
@snippetToolbar.snippet = $('#snippet')
|
124
112
|
|
125
113
|
it "positions itself based on the snippet", ->
|
126
114
|
@snippetToolbar.element.show()
|
127
115
|
@snippetToolbar.position()
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
116
|
+
if $.browser.webkit
|
117
|
+
expect(@snippetToolbar.element.offset()).toEqual({top: 18, left : 200})
|
118
|
+
else
|
119
|
+
expect(@snippetToolbar.element.offset()).toEqual({top: 14, left : 200})
|
132
120
|
|
133
121
|
|
134
122
|
describe "#appear", ->
|
135
123
|
|
136
124
|
beforeEach ->
|
137
|
-
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo:
|
125
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test'})
|
138
126
|
|
139
127
|
it "clears the hide timeout", ->
|
140
128
|
spy = spyOn(window, 'clearTimeout').andCallFake(=>)
|
@@ -153,9 +141,7 @@ describe "Mercury.SnippetToolbar", ->
|
|
153
141
|
describe "#hide", ->
|
154
142
|
|
155
143
|
beforeEach ->
|
156
|
-
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo:
|
157
|
-
|
158
|
-
afterEach -> @snippetToolbar.release()
|
144
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test'})
|
159
145
|
|
160
146
|
it "it clears the hide timeout", ->
|
161
147
|
spy = spyOn(window, 'clearTimeout').andCallFake(=>)
|
@@ -188,12 +174,11 @@ describe "Mercury.SnippetToolbar", ->
|
|
188
174
|
expect(@setTimeoutSpy.callCount).toEqual(1)
|
189
175
|
|
190
176
|
it "hides the element", ->
|
191
|
-
@setTimeoutSpy.andCallFake((
|
177
|
+
@setTimeoutSpy.andCallFake((timeout, callback) => callback())
|
192
178
|
@snippetToolbar.hide()
|
193
179
|
expect(@snippetToolbar.element.css('display')).toEqual('none')
|
194
180
|
|
195
181
|
it "sets visible", ->
|
196
|
-
@setTimeoutSpy.andCallFake((
|
182
|
+
@setTimeoutSpy.andCallFake((timeout, callback) => callback())
|
197
183
|
@snippetToolbar.hide()
|
198
184
|
expect(@snippetToolbar.visible).toEqual(false)
|
199
|
-
|
@@ -1,7 +1,8 @@
|
|
1
1
|
describe "Mercury.Statusbar", ->
|
2
2
|
|
3
|
+
template 'mercury/statusbar.html'
|
4
|
+
|
3
5
|
beforeEach ->
|
4
|
-
fixture.load('mercury/statusbar.html')
|
5
6
|
$.fx.off = true
|
6
7
|
@region = {
|
7
8
|
path: -> [{tagName: 'A'}, {tagName: 'B'}, {tagName: 'C'}]
|
@@ -16,7 +17,7 @@ describe "Mercury.Statusbar", ->
|
|
16
17
|
beforeEach ->
|
17
18
|
@buildSpy = spyOn(Mercury.Statusbar.prototype, 'build')
|
18
19
|
@bindEventsSpy = spyOn(Mercury.Statusbar.prototype, 'bindEvents')
|
19
|
-
@statusbar = new Mercury.Statusbar({appendTo:
|
20
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', foo: 'bar', visible: false})
|
20
21
|
|
21
22
|
it "accepts options", ->
|
22
23
|
expect(@statusbar.options.foo).toEqual('bar')
|
@@ -54,7 +55,7 @@ describe "Mercury.Statusbar", ->
|
|
54
55
|
describe "observed events ", ->
|
55
56
|
|
56
57
|
beforeEach ->
|
57
|
-
@statusbar = new Mercury.Statusbar({appendTo:
|
58
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test'})
|
58
59
|
|
59
60
|
describe "custom event: region:update", ->
|
60
61
|
|
@@ -75,7 +76,7 @@ describe "Mercury.Statusbar", ->
|
|
75
76
|
|
76
77
|
beforeEach ->
|
77
78
|
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
78
|
-
@statusbar = new Mercury.Statusbar({appendTo:
|
79
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: true})
|
79
80
|
|
80
81
|
it "knows it's own height", ->
|
81
82
|
expect(@statusbar.height()).toEqual(20) # styled with css in the template
|
@@ -87,7 +88,7 @@ describe "Mercury.Statusbar", ->
|
|
87
88
|
|
88
89
|
beforeEach ->
|
89
90
|
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
90
|
-
@statusbar = new Mercury.Statusbar({appendTo:
|
91
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: true})
|
91
92
|
|
92
93
|
it "returns the offset top of the element", ->
|
93
94
|
expect(@statusbar.top()).toEqual($('.mercury-statusbar').offset().top)
|
@@ -96,7 +97,7 @@ describe "Mercury.Statusbar", ->
|
|
96
97
|
|
97
98
|
beforeEach ->
|
98
99
|
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
99
|
-
@statusbar = new Mercury.Statusbar({appendTo:
|
100
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: false})
|
100
101
|
|
101
102
|
it "returns the offset top of the element + it's outer height", ->
|
102
103
|
expect(@statusbar.top()).toEqual($('.mercury-statusbar').offset().top + $('.mercury-statusbar').outerHeight())
|
@@ -105,7 +106,7 @@ describe "Mercury.Statusbar", ->
|
|
105
106
|
describe "#setPath", ->
|
106
107
|
|
107
108
|
beforeEach ->
|
108
|
-
@statusbar = new Mercury.Statusbar({appendTo:
|
109
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test'})
|
109
110
|
|
110
111
|
it "builds a path and displays it", ->
|
111
112
|
@statusbar.setPath(@region.path())
|
@@ -115,7 +116,7 @@ describe "Mercury.Statusbar", ->
|
|
115
116
|
describe "#show", ->
|
116
117
|
|
117
118
|
beforeEach ->
|
118
|
-
@statusbar = new Mercury.Statusbar({appendTo:
|
119
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: false})
|
119
120
|
|
120
121
|
it "sets visible to true", ->
|
121
122
|
@statusbar.visible = false
|
@@ -136,7 +137,7 @@ describe "Mercury.Statusbar", ->
|
|
136
137
|
describe "#hide", ->
|
137
138
|
|
138
139
|
beforeEach ->
|
139
|
-
@statusbar = new Mercury.Statusbar({appendTo:
|
140
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: true})
|
140
141
|
|
141
142
|
it "sets visible to false", ->
|
142
143
|
@statusbar.visible = true
|
@@ -1,10 +1,11 @@
|
|
1
1
|
describe "Mercury.Toolbar.ButtonGroup", ->
|
2
2
|
|
3
|
+
template 'mercury/toolbar.button_group.html'
|
4
|
+
|
3
5
|
beforeEach ->
|
4
|
-
fixture.load('mercury/toolbar.button_group.html')
|
5
6
|
Mercury.Toolbar.ButtonGroup.contexts.foo = -> false
|
6
7
|
@region = {
|
7
|
-
element: $('<div>')
|
8
|
+
element: $('<div class="mercury-region">')
|
8
9
|
currentElement: -> $('<div>')
|
9
10
|
}
|
10
11
|
|
@@ -49,8 +50,8 @@ describe "Mercury.Toolbar.ButtonGroup", ->
|
|
49
50
|
|
50
51
|
beforeEach ->
|
51
52
|
@region = {
|
52
|
-
type:
|
53
|
-
element: $('<div>')
|
53
|
+
type: 'editable'
|
54
|
+
element: $('<div class="mercury-region">')
|
54
55
|
}
|
55
56
|
|
56
57
|
it "disables if the region type isn't supported", ->
|
@@ -60,7 +61,7 @@ describe "Mercury.Toolbar.ButtonGroup", ->
|
|
60
61
|
expect(@buttonGroup.hasClass('disabled')).toEqual(true)
|
61
62
|
|
62
63
|
it "enables if the region type is supported", ->
|
63
|
-
@buttonGroup = new Mercury.Toolbar.ButtonGroup('foo', {_regions: ['
|
64
|
+
@buttonGroup = new Mercury.Toolbar.ButtonGroup('foo', {_regions: ['editable']})
|
64
65
|
@buttonGroup.addClass('disabled')
|
65
66
|
Mercury.trigger('region:focused', {region: @region})
|
66
67
|
expect(@buttonGroup.hasClass('disabled')).toEqual(false)
|
@@ -68,7 +69,7 @@ describe "Mercury.Toolbar.ButtonGroup", ->
|
|
68
69
|
describe "custom event: region:blurred", ->
|
69
70
|
|
70
71
|
it "disables if it's a button group for specific region types", ->
|
71
|
-
@buttonGroup = new Mercury.Toolbar.ButtonGroup('foo', {_regions: ['
|
72
|
+
@buttonGroup = new Mercury.Toolbar.ButtonGroup('foo', {_regions: ['editable']})
|
72
73
|
@buttonGroup.removeClass('disabled')
|
73
74
|
Mercury.trigger('region:blurred', {region: @region})
|
74
75
|
|
@@ -76,8 +77,9 @@ describe "Mercury.Toolbar.ButtonGroup", ->
|
|
76
77
|
|
77
78
|
describe "Mercury.Toolbar.ButtonGroup.contexts", ->
|
78
79
|
|
80
|
+
template 'mercury/toolbar.button_group.html'
|
81
|
+
|
79
82
|
beforeEach ->
|
80
|
-
fixture.load('mercury/toolbar.button_group.html')
|
81
83
|
@contexts = Mercury.Toolbar.ButtonGroup.contexts
|
82
84
|
@region = $('#context_container')
|
83
85
|
|
@@ -1,12 +1,13 @@
|
|
1
1
|
describe "Mercury.Toolbar.Button", ->
|
2
2
|
|
3
|
+
template 'mercury/toolbar.button.html'
|
4
|
+
|
3
5
|
beforeEach ->
|
4
|
-
|
5
|
-
Mercury.displayRect = {top: 0, left: 0, width: 500, height: 200}
|
6
|
+
Mercury.displayRect = {0, 0, 500, 200}
|
6
7
|
Mercury.Toolbar.Button.contexts.foo = -> true
|
7
8
|
@region = {
|
8
|
-
type:
|
9
|
-
element: $('<div>')
|
9
|
+
type: 'editable'
|
10
|
+
element: $('<div class="mercury-region">')
|
10
11
|
currentElement: -> $('<div>')
|
11
12
|
}
|
12
13
|
Mercury.preloadedViews['/nothing'] = 'nothing'
|
@@ -27,7 +28,7 @@ describe "Mercury.Toolbar.Button", ->
|
|
27
28
|
expect(html).toContain('<em>title</em>')
|
28
29
|
|
29
30
|
it "accepts summary, types and options", ->
|
30
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {palette: '/nothing'}, {appendDialogsTo:
|
31
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {palette: '/nothing'}, {appendDialogsTo: $('#test')})
|
31
32
|
html = $('<div>').html(@button).html()
|
32
33
|
expect(html).toContain('title="summary"')
|
33
34
|
expect(html).toContain('class="mercury-button mercury-foo-button mercury-button-palette"')
|
@@ -70,15 +71,15 @@ describe "Mercury.Toolbar.Button", ->
|
|
70
71
|
expect(spy.argsForCall[0]).toEqual(['mode', {mode: 'foo'}])
|
71
72
|
|
72
73
|
it "builds buttons that understand context", ->
|
73
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {context: true}
|
74
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {context: true})
|
74
75
|
|
75
76
|
expect(@button.hasClass('active')).toEqual(false)
|
76
77
|
Mercury.trigger('region:update', {region: @region})
|
77
78
|
expect(@button.hasClass('active')).toEqual(true)
|
78
79
|
|
79
80
|
it "builds panel buttons (and assigns toggle)", ->
|
80
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {panel: '/blank.html'}, {appendDialogsTo:
|
81
|
-
expect($('.mercury-panel'
|
81
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {panel: '/blank.html'}, {appendDialogsTo: $('#test')})
|
82
|
+
expect($('#test .mercury-panel').length).toEqual(1)
|
82
83
|
|
83
84
|
jasmine.simulate.click(@button.get(0))
|
84
85
|
expect(@button.hasClass('pressed')).toEqual(true)
|
@@ -86,36 +87,20 @@ describe "Mercury.Toolbar.Button", ->
|
|
86
87
|
jasmine.simulate.click(@button.get(0))
|
87
88
|
expect(@button.hasClass('pressed')).toEqual(false)
|
88
89
|
|
89
|
-
it "builds a panel button with a custom panel object", ->
|
90
|
-
namespace = {}
|
91
|
-
namespace.customPanel = ->
|
92
|
-
namespace.customPanel::toggle = ->
|
93
|
-
'toggled'
|
94
|
-
handler = (name)->
|
95
|
-
new namespace.customPanel()
|
96
|
-
|
97
|
-
constructorSpy = spyOn(namespace, 'customPanel').andCallThrough()
|
98
|
-
panelSpy = spyOn(Mercury, 'Panel')
|
99
|
-
|
100
|
-
@button = new Mercury.Toolbar.Button('customFoo', 'title', 'summary', {panel: handler}, {appendDialogsTo: fixture.el})
|
101
|
-
expect(constructorSpy).toHaveBeenCalled()
|
102
|
-
expect(panelSpy).wasNotCalled()
|
103
|
-
|
104
|
-
|
105
90
|
it "builds palette buttons", ->
|
106
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {palette: '/blank.html'}, {appendDialogsTo:
|
107
|
-
expect($('.mercury-palette'
|
91
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {palette: '/blank.html'}, {appendDialogsTo: $('#test')})
|
92
|
+
expect($('#test .mercury-palette').length).toEqual(1)
|
108
93
|
|
109
94
|
it "builds select buttons", ->
|
110
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {select: '/blank.html'}, {appendDialogsTo:
|
111
|
-
expect($('.mercury-select'
|
95
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {select: '/blank.html'}, {appendDialogsTo: $('#test')})
|
96
|
+
expect($('#test .mercury-select').length).toEqual(1)
|
112
97
|
|
113
98
|
it "builds modal buttons", ->
|
114
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {modal: '/blank.html'}, {appendDialogsTo:
|
99
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {modal: '/blank.html'}, {appendDialogsTo: $('#test')})
|
115
100
|
# nothing unique about this in building -- the modal is built/fired on click
|
116
101
|
|
117
102
|
it "builds lightview buttons", ->
|
118
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {lightview: '/blank.html'}, {appendDialogsTo:
|
103
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {lightview: '/blank.html'}, {appendDialogsTo: $('#test')})
|
119
104
|
# nothing unique about this in building -- the lightview is built/fired on click
|
120
105
|
|
121
106
|
it "throws an error when an unknown type is encountered", ->
|
@@ -128,13 +113,12 @@ describe "Mercury.Toolbar.Button", ->
|
|
128
113
|
|
129
114
|
describe "custom event: button", ->
|
130
115
|
|
131
|
-
it "calls click on the button itself"
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
# expect(spy.callCount).toEqual(1)
|
116
|
+
it "calls click on the button itself", ->
|
117
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {context: true})
|
118
|
+
spy = spyOn(@button, 'click').andCallFake(=>)
|
119
|
+
|
120
|
+
Mercury.trigger('button', {action: 'foo'})
|
121
|
+
expect(spy.callCount).toEqual(1)
|
138
122
|
|
139
123
|
describe "custom event: mode", ->
|
140
124
|
|
@@ -166,7 +150,7 @@ describe "Mercury.Toolbar.Button", ->
|
|
166
150
|
expect(@button.hasClass('disabled')).toEqual(true)
|
167
151
|
|
168
152
|
it "enables if the region type is supported", ->
|
169
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {context: true, regions: ['
|
153
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {context: true, regions: ['editable']})
|
170
154
|
@button.addClass('disabled')
|
171
155
|
Mercury.trigger('region:focused', {region: @region})
|
172
156
|
expect(@button.hasClass('disabled')).toEqual(false)
|
@@ -174,7 +158,7 @@ describe "Mercury.Toolbar.Button", ->
|
|
174
158
|
describe "custom event: region:blurred", ->
|
175
159
|
|
176
160
|
it "disables if it's a button for specific region types", ->
|
177
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {context: true, regions: ['
|
161
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {context: true, regions: ['editable']})
|
178
162
|
@button.addClass('disabled')
|
179
163
|
Mercury.trigger('region:blurred', {region: @region})
|
180
164
|
expect(@button.hasClass('disabled')).toEqual(true)
|
@@ -219,7 +203,7 @@ describe "Mercury.Toolbar.Button", ->
|
|
219
203
|
|
220
204
|
it "triggers a focus:frame event", ->
|
221
205
|
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
222
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {}, {regions: ['
|
206
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {}, {regions: ['editable']})
|
223
207
|
|
224
208
|
jasmine.simulate.click(@button.get(0))
|
225
209
|
expect(spy.argsForCall[1]).toEqual(['focus:frame'])
|
@@ -284,25 +268,12 @@ describe "Mercury.Toolbar.Button", ->
|
|
284
268
|
jasmine.simulate.click(@button.get(0))
|
285
269
|
expect(spy.callCount).toEqual(2)
|
286
270
|
|
287
|
-
it "shows and hides the custom panel", ->
|
288
|
-
namespace = {}
|
289
|
-
namespace.customPanel = ->
|
290
|
-
namespace.customPanel::toggle = ->
|
291
|
-
'toggled'
|
292
|
-
handler = (name)->
|
293
|
-
new namespace.customPanel()
|
294
|
-
|
295
|
-
toggleSpy = spyOn(namespace.customPanel.prototype, 'toggle')
|
296
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {panel: handler}, {appendDialogsTo: fixture.el})
|
297
|
-
|
298
|
-
jasmine.simulate.click(@button.get(0))
|
299
|
-
expect(toggleSpy).toHaveBeenCalled()
|
300
|
-
|
301
271
|
|
302
272
|
describe "Mercury.Toolbar.Button.contexts", ->
|
303
273
|
|
274
|
+
template 'mercury/toolbar.button.html'
|
275
|
+
|
304
276
|
beforeEach ->
|
305
|
-
fixture.load('mercury/toolbar.button.html')
|
306
277
|
@contexts = Mercury.Toolbar.Button.contexts
|
307
278
|
@region = $('#context_container')
|
308
279
|
@element = $('#context_button')
|