kiteditor 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +25 -0
- data/app/controllers/mercury/images_controller.rb +5 -0
- data/app/controllers/mercury_controller.rb +34 -0
- data/app/models/mercury/image.rb +17 -0
- data/app/views/layouts/mercury.html.erb +33 -0
- data/app/views/layouts/popup.html.haml +9 -0
- data/app/views/mercury/images/_list.html.haml +22 -0
- data/app/views/mercury/images/index.html.haml +4 -0
- data/app/views/mercury/images/index.js.erb +2 -0
- data/app/views/mercury/lightviews/about.html +11 -0
- data/app/views/mercury/modals/character.html +255 -0
- data/app/views/mercury/modals/htmleditor.html +13 -0
- data/app/views/mercury/modals/link.html +94 -0
- data/app/views/mercury/modals/media.html +1 -0
- data/app/views/mercury/modals/table.html +84 -0
- data/app/views/mercury/palettes/backcolor.html +73 -0
- data/app/views/mercury/palettes/forecolor.html +73 -0
- data/app/views/mercury/panels/history.html +3 -0
- data/app/views/mercury/panels/notes.html +3 -0
- data/app/views/mercury/panels/snippets.html +12 -0
- data/app/views/mercury/selects/formatblock.html +11 -0
- data/app/views/mercury/selects/style.html +5 -0
- data/app/views/mercury/snippets/example/options.html.erb +34 -0
- data/app/views/mercury/snippets/example/preview.html.erb +1 -0
- data/config/engine.rb +44 -0
- data/db/migrate/20110526035601_create_mercury_images.rb +11 -0
- data/features/loading/loading.feature +22 -0
- data/features/loading/navigating.feature +77 -0
- data/features/loading/user_interface.feature +67 -0
- data/features/regions/editable/advanced_editing.feature +0 -0
- data/features/regions/editable/basic_editing.feature +195 -0
- data/features/regions/editable/inserting_links.feature +98 -0
- data/features/regions/editable/inserting_media.feature +110 -0
- data/features/regions/editable/inserting_snippets.feature +102 -0
- data/features/regions/editable/inserting_special_characters.feature +24 -0
- data/features/regions/editable/inserting_tables.feature +109 -0
- data/features/regions/editable/pasting.feature +0 -0
- data/features/regions/editable/uploading_images.feature +0 -0
- data/features/regions/markupable/advanced_editing.feature +0 -0
- data/features/regions/markupable/basic_editing.feature +0 -0
- data/features/regions/markupable/inserting_links.feature +0 -0
- data/features/regions/markupable/inserting_media.feature +0 -0
- data/features/regions/markupable/inserting_snippets.feature +0 -0
- data/features/regions/markupable/inserting_special_characters.feature +0 -0
- data/features/regions/markupable/inserting_tables.feature +0 -0
- data/features/regions/markupable/uploading_images.feature +0 -0
- data/features/regions/snippetable/advanced_editing.feature +0 -0
- data/features/regions/snippetable/basic_editing.feature +0 -0
- data/features/regions/snippetable/inserting_snippets.feature +0 -0
- data/features/saving/saving.feature +33 -0
- data/features/step_definitions/debug_steps.rb +14 -0
- data/features/step_definitions/mercury_steps.rb +438 -0
- data/features/step_definitions/web_steps.rb +211 -0
- data/features/support/env.rb +46 -0
- data/features/support/mercury_contents.rb +25 -0
- data/features/support/mercury_selectors.rb +148 -0
- data/features/support/paths.rb +38 -0
- data/features/support/selectors.rb +44 -0
- data/lib/generators/mercury/install/install_generator.rb +49 -0
- data/lib/generators/mercury/install/templates/mongoid_paperclip_image.rb +17 -0
- data/lib/mercury/authentication.rb +8 -0
- data/lib/mercury-rails.rb +3 -0
- data/spec/javascripts/mercury/dialog_spec.js.coffee +281 -0
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +37 -0
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +37 -0
- data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +25 -0
- data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +30 -0
- data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +25 -0
- data/spec/javascripts/mercury/history_buffer_spec.js.coffee +76 -0
- data/spec/javascripts/mercury/lightview_spec.js.coffee +497 -0
- data/spec/javascripts/mercury/mercury_spec.js.coffee +132 -0
- data/spec/javascripts/mercury/modal_spec.js.coffee +504 -0
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +30 -0
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +29 -0
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +220 -0
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +167 -0
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +52 -0
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +160 -0
- data/spec/javascripts/mercury/native_extensions_spec.js.coffee +60 -0
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +750 -0
- data/spec/javascripts/mercury/palette_spec.js.coffee +49 -0
- data/spec/javascripts/mercury/panel_spec.js.coffee +185 -0
- data/spec/javascripts/mercury/region_spec.js.coffee +298 -0
- data/spec/javascripts/mercury/regions/editable_spec.js.coffee +561 -0
- data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +367 -0
- data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +370 -0
- data/spec/javascripts/mercury/select_spec.js.coffee +49 -0
- data/spec/javascripts/mercury/snippet_spec.js.coffee +245 -0
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +184 -0
- data/spec/javascripts/mercury/statusbar_spec.js.coffee +150 -0
- data/spec/javascripts/mercury/table_editor_spec.js.coffee +194 -0
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +90 -0
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +360 -0
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +118 -0
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +222 -0
- data/spec/javascripts/mercury/tooltip_spec.js.coffee +186 -0
- data/spec/javascripts/mercury/uploader_spec.js.coffee +514 -0
- data/spec/javascripts/spec_helper.js +513 -0
- data/spec/javascripts/templates/mercury/dialog.html +2 -0
- data/spec/javascripts/templates/mercury/dialogs/backcolor.html +5 -0
- data/spec/javascripts/templates/mercury/dialogs/forecolor.html +5 -0
- data/spec/javascripts/templates/mercury/dialogs/formatblock.html +3 -0
- data/spec/javascripts/templates/mercury/dialogs/snippetpanel.html +16 -0
- data/spec/javascripts/templates/mercury/dialogs/style.html +3 -0
- data/spec/javascripts/templates/mercury/lightview.html +13 -0
- data/spec/javascripts/templates/mercury/modal.html +13 -0
- data/spec/javascripts/templates/mercury/modals/htmleditor.html +5 -0
- data/spec/javascripts/templates/mercury/modals/insertcharacter.html +5 -0
- data/spec/javascripts/templates/mercury/modals/insertlink.html +30 -0
- data/spec/javascripts/templates/mercury/modals/insertmedia.html +35 -0
- data/spec/javascripts/templates/mercury/modals/insertsnippet.html +6 -0
- data/spec/javascripts/templates/mercury/modals/inserttable.html +27 -0
- data/spec/javascripts/templates/mercury/page_editor.html +35 -0
- data/spec/javascripts/templates/mercury/palette.html +16 -0
- data/spec/javascripts/templates/mercury/panel.html +16 -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/templates/mercury/select.html +16 -0
- data/spec/javascripts/templates/mercury/snippet.html +1 -0
- data/spec/javascripts/templates/mercury/snippet_toolbar.html +16 -0
- data/spec/javascripts/templates/mercury/statusbar.html +8 -0
- data/spec/javascripts/templates/mercury/table_editor.html +65 -0
- data/spec/javascripts/templates/mercury/toolbar.button.html +64 -0
- data/spec/javascripts/templates/mercury/toolbar.button_group.html +9 -0
- data/spec/javascripts/templates/mercury/toolbar.expander.html +18 -0
- data/spec/javascripts/templates/mercury/toolbar.html +11 -0
- data/spec/javascripts/templates/mercury/tooltip.html +12 -0
- data/spec/javascripts/templates/mercury/uploader.html +11 -0
- data/vendor/assets/images/mercury/button.png +0 -0
- data/vendor/assets/images/mercury/close.png +0 -0
- data/vendor/assets/images/mercury/default-snippet.png +0 -0
- data/vendor/assets/images/mercury/loading-dark.gif +0 -0
- data/vendor/assets/images/mercury/loading-light.gif +0 -0
- data/vendor/assets/images/mercury/missing-image.png +0 -0
- data/vendor/assets/images/mercury/search-icon.png +0 -0
- data/vendor/assets/images/mercury/temp-logo.png +0 -0
- data/vendor/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/vendor/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-1.7.js +9300 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +1328 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.18.custom.min.js +356 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-ui.1.8.13.custom.min.js +356 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery.additions.js +206 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +527 -0
- data/vendor/assets/javascripts/mercury/dependencies/liquidmetal.js +88 -0
- data/vendor/assets/javascripts/mercury/dependencies/showdown.js +1340 -0
- data/vendor/assets/javascripts/mercury/dialog.js.coffee +159 -0
- data/vendor/assets/javascripts/mercury/dialogs/backcolor.js.coffee +6 -0
- data/vendor/assets/javascripts/mercury/dialogs/forecolor.js.coffee +6 -0
- data/vendor/assets/javascripts/mercury/dialogs/formatblock.js.coffee +4 -0
- data/vendor/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +10 -0
- data/vendor/assets/javascripts/mercury/dialogs/style.js.coffee +4 -0
- data/vendor/assets/javascripts/mercury/finalize.js.coffee +3 -0
- data/vendor/assets/javascripts/mercury/history_buffer.js.coffee +30 -0
- data/vendor/assets/javascripts/mercury/lightview.js.coffee +205 -0
- data/vendor/assets/javascripts/mercury/locales/da.locale.js.coffee +0 -0
- data/vendor/assets/javascripts/mercury/locales/de.locale.js.coffee +206 -0
- data/vendor/assets/javascripts/mercury/locales/es.locale.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/example.local.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/fr.locale.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/it.locale.js.coffee +208 -0
- data/vendor/assets/javascripts/mercury/locales/ko.local.js.coffee +206 -0
- data/vendor/assets/javascripts/mercury/locales/nl.locale.js.coffee +206 -0
- data/vendor/assets/javascripts/mercury/locales/pt.locale.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/sv.local.js.coffee +209 -0
- data/vendor/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +213 -0
- data/vendor/assets/javascripts/mercury/mercury.js.coffee +109 -0
- data/vendor/assets/javascripts/mercury/modal.js.coffee +204 -0
- data/vendor/assets/javascripts/mercury/modals/htmleditor.js.coffee +11 -0
- data/vendor/assets/javascripts/mercury/modals/insertcharacter.js.coffee +4 -0
- data/vendor/assets/javascripts/mercury/modals/insertlink.js.coffee +95 -0
- data/vendor/assets/javascripts/mercury/modals/insertmedia.js.coffee +107 -0
- data/vendor/assets/javascripts/mercury/modals/insertsnippet.js.coffee +12 -0
- data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +54 -0
- data/vendor/assets/javascripts/mercury/native_extensions.js.coffee +55 -0
- data/vendor/assets/javascripts/mercury/page_editor.js.coffee +241 -0
- data/vendor/assets/javascripts/mercury/palette.js.coffee +29 -0
- data/vendor/assets/javascripts/mercury/panel.js.coffee +115 -0
- data/vendor/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +28 -0
- data/vendor/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +9 -0
- data/vendor/assets/javascripts/mercury/region.js.coffee +107 -0
- data/vendor/assets/javascripts/mercury/regions/editable.js.coffee +600 -0
- data/vendor/assets/javascripts/mercury/regions/markupable.js.coffee +398 -0
- data/vendor/assets/javascripts/mercury/regions/simple.js.coffee +339 -0
- data/vendor/assets/javascripts/mercury/regions/snippetable.js.coffee +124 -0
- data/vendor/assets/javascripts/mercury/select.js.coffee +44 -0
- data/vendor/assets/javascripts/mercury/snippet.js.coffee +104 -0
- data/vendor/assets/javascripts/mercury/snippet_toolbar.js.coffee +72 -0
- data/vendor/assets/javascripts/mercury/statusbar.js.coffee +51 -0
- data/vendor/assets/javascripts/mercury/support/history.js +1 -0
- data/vendor/assets/javascripts/mercury/table_editor.js.coffee +265 -0
- data/vendor/assets/javascripts/mercury/toolbar.button.js.coffee +173 -0
- data/vendor/assets/javascripts/mercury/toolbar.button_group.js.coffee +42 -0
- data/vendor/assets/javascripts/mercury/toolbar.expander.js.coffee +56 -0
- data/vendor/assets/javascripts/mercury/toolbar.js.coffee +86 -0
- data/vendor/assets/javascripts/mercury/tooltip.js.coffee +74 -0
- data/vendor/assets/javascripts/mercury/uploader.js.coffee +227 -0
- data/vendor/assets/javascripts/mercury.js +479 -0
- data/vendor/assets/javascripts/mercury_loader.js +193 -0
- data/vendor/assets/javascripts/mercury_overrides.js +6 -0
- data/vendor/assets/javascripts/popup.js +8 -0
- data/vendor/assets/stylesheets/mercury/all_images.css.erb +89 -0
- data/vendor/assets/stylesheets/mercury/dialog.css +208 -0
- data/vendor/assets/stylesheets/mercury/lightview.css +151 -0
- data/vendor/assets/stylesheets/mercury/mercury.css +151 -0
- data/vendor/assets/stylesheets/mercury/modal.css +183 -0
- data/vendor/assets/stylesheets/mercury/statusbar.css +32 -0
- data/vendor/assets/stylesheets/mercury/toolbar.css +304 -0
- data/vendor/assets/stylesheets/mercury/tooltip.css +26 -0
- data/vendor/assets/stylesheets/mercury/uploader.css +111 -0
- data/vendor/assets/stylesheets/mercury.css +28 -0
- data/vendor/assets/stylesheets/mercury_overrides.css +17 -0
- data/vendor/assets/stylesheets/popup.css.erb +37 -0
- metadata +634 -0
@@ -0,0 +1,184 @@
|
|
1
|
+
describe "Mercury.SnippetToolbar", ->
|
2
|
+
|
3
|
+
template 'mercury/snippet_toolbar.html'
|
4
|
+
|
5
|
+
beforeEach ->
|
6
|
+
$.fx.off = true
|
7
|
+
|
8
|
+
afterEach ->
|
9
|
+
@snippetToolbar = null
|
10
|
+
delete(@snippetToolbar)
|
11
|
+
$(window).unbind('mercury:hide:toolbar')
|
12
|
+
$(window).unbind('mercury:show:toolbar')
|
13
|
+
|
14
|
+
describe "constructor", ->
|
15
|
+
|
16
|
+
beforeEach ->
|
17
|
+
spyOn(Mercury.SnippetToolbar.prototype, 'build').andCallFake(=>)
|
18
|
+
spyOn(Mercury.SnippetToolbar.prototype, 'bindEvents').andCallFake(=>)
|
19
|
+
|
20
|
+
it "expects document", ->
|
21
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'))
|
22
|
+
expect(@snippetToolbar.document).toEqual($('document'))
|
23
|
+
|
24
|
+
it "accepts options", ->
|
25
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'))
|
26
|
+
expect(@snippetToolbar.document).toEqual($('document'))
|
27
|
+
|
28
|
+
|
29
|
+
describe "#build", ->
|
30
|
+
|
31
|
+
it "builds an element", ->
|
32
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test'})
|
33
|
+
html = $('<div>').html(@snippetToolbar.element).html()
|
34
|
+
expect(html).toContain('class="mercury-toolbar mercury-snippet-toolbar"')
|
35
|
+
expect(html).toContain('style="display:none"')
|
36
|
+
|
37
|
+
it "appends to any element", ->
|
38
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#snippet_toolbar_container'})
|
39
|
+
expect($('#snippet_toolbar_container .mercury-toolbar').length).toEqual(1)
|
40
|
+
|
41
|
+
|
42
|
+
describe "observed events", ->
|
43
|
+
|
44
|
+
beforeEach ->
|
45
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test'})
|
46
|
+
|
47
|
+
describe "custom event: show:toolbar", ->
|
48
|
+
|
49
|
+
it "does nothing if there's no snippet", ->
|
50
|
+
spy = spyOn(Mercury.SnippetToolbar.prototype, 'show').andCallFake(=>)
|
51
|
+
Mercury.trigger('show:toolbar', {snippet: null})
|
52
|
+
expect(spy.callCount).toEqual(0)
|
53
|
+
|
54
|
+
it "calls show", ->
|
55
|
+
spy = spyOn(Mercury.SnippetToolbar.prototype, 'show').andCallFake(=>)
|
56
|
+
Mercury.trigger('show:toolbar', {snippet: $('#snippet')})
|
57
|
+
expect(spy.callCount).toEqual(1)
|
58
|
+
|
59
|
+
describe "custom event: hide:toolbar", ->
|
60
|
+
|
61
|
+
it "does nothing if it's not for the snippet toolbar", ->
|
62
|
+
spy = spyOn(Mercury.SnippetToolbar.prototype, 'hide').andCallFake(=>)
|
63
|
+
Mercury.trigger('hide:toolbar', {type: 'foo'})
|
64
|
+
expect(spy.callCount).toEqual(0)
|
65
|
+
|
66
|
+
it "calls hide", ->
|
67
|
+
spy = spyOn(Mercury.SnippetToolbar.prototype, 'hide').andCallFake(=>)
|
68
|
+
Mercury.trigger('hide:toolbar', {type: 'snippet'})
|
69
|
+
expect(spy.callCount).toEqual(1)
|
70
|
+
|
71
|
+
describe "mousemove", ->
|
72
|
+
|
73
|
+
it "clears the hide timeout", ->
|
74
|
+
spy = spyOn(window, 'clearTimeout').andCallFake(=>)
|
75
|
+
jasmine.simulate.mousemove($('#test .mercury-snippet-toolbar').get(0))
|
76
|
+
expect(spy.callCount).toEqual(1)
|
77
|
+
|
78
|
+
describe "mouseout", ->
|
79
|
+
|
80
|
+
it "calls hide", ->
|
81
|
+
spy = spyOn(Mercury.SnippetToolbar.prototype, 'hide').andCallFake(=>)
|
82
|
+
jasmine.simulate.mouseout($('#test .mercury-snippet-toolbar').get(0))
|
83
|
+
expect(spy.callCount).toEqual(1)
|
84
|
+
|
85
|
+
|
86
|
+
describe "#show", ->
|
87
|
+
|
88
|
+
beforeEach ->
|
89
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test'})
|
90
|
+
@positionSpy = spyOn(Mercury.SnippetToolbar.prototype, 'position').andCallFake(=>)
|
91
|
+
@appearSpy = spyOn(Mercury.SnippetToolbar.prototype, 'appear').andCallFake(=>)
|
92
|
+
|
93
|
+
it "expects a snippet", ->
|
94
|
+
@snippetToolbar.show({snippet: 'foo'})
|
95
|
+
expect(@snippetToolbar.snippet).toEqual({snippet: 'foo'})
|
96
|
+
|
97
|
+
it "calls position", ->
|
98
|
+
@snippetToolbar.show()
|
99
|
+
expect(@positionSpy.callCount).toEqual(1)
|
100
|
+
|
101
|
+
it "calls appear", ->
|
102
|
+
@snippetToolbar.show()
|
103
|
+
expect(@appearSpy.callCount).toEqual(1)
|
104
|
+
|
105
|
+
|
106
|
+
describe "#position", ->
|
107
|
+
|
108
|
+
beforeEach ->
|
109
|
+
Mercury.displayRect = {top: 20}
|
110
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test', visible: true})
|
111
|
+
@snippetToolbar.snippet = $('#snippet')
|
112
|
+
|
113
|
+
it "positions itself based on the snippet", ->
|
114
|
+
@snippetToolbar.element.show()
|
115
|
+
@snippetToolbar.position()
|
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})
|
120
|
+
|
121
|
+
|
122
|
+
describe "#appear", ->
|
123
|
+
|
124
|
+
beforeEach ->
|
125
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test'})
|
126
|
+
|
127
|
+
it "clears the hide timeout", ->
|
128
|
+
spy = spyOn(window, 'clearTimeout').andCallFake(=>)
|
129
|
+
@snippetToolbar.appear()
|
130
|
+
expect(spy.callCount).toEqual(1)
|
131
|
+
|
132
|
+
it "sets visible", ->
|
133
|
+
@snippetToolbar.appear()
|
134
|
+
expect(@snippetToolbar.visible).toEqual(true)
|
135
|
+
|
136
|
+
it "shows the element", ->
|
137
|
+
@snippetToolbar.appear()
|
138
|
+
expect(@snippetToolbar.element.css('display')).toEqual('block')
|
139
|
+
|
140
|
+
|
141
|
+
describe "#hide", ->
|
142
|
+
|
143
|
+
beforeEach ->
|
144
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test'})
|
145
|
+
|
146
|
+
it "it clears the hide timeout", ->
|
147
|
+
spy = spyOn(window, 'clearTimeout').andCallFake(=>)
|
148
|
+
@snippetToolbar.hide()
|
149
|
+
expect(spy.callCount).toEqual(1)
|
150
|
+
|
151
|
+
describe "immediately", ->
|
152
|
+
|
153
|
+
beforeEach ->
|
154
|
+
@snippetToolbar.element.show()
|
155
|
+
|
156
|
+
it "hides the element", ->
|
157
|
+
@snippetToolbar.hide(true)
|
158
|
+
expect(@snippetToolbar.element.css('display')).toEqual('none')
|
159
|
+
|
160
|
+
it "sets visible", ->
|
161
|
+
@snippetToolbar.visible = true
|
162
|
+
@snippetToolbar.hide(true)
|
163
|
+
expect(@snippetToolbar.visible).toEqual(false)
|
164
|
+
|
165
|
+
describe "not immediately", ->
|
166
|
+
|
167
|
+
beforeEach ->
|
168
|
+
@snippetToolbar.element.show()
|
169
|
+
@setTimeoutSpy = spyOn(window, 'setTimeout')
|
170
|
+
|
171
|
+
it "sets a timeout", ->
|
172
|
+
@setTimeoutSpy.andCallFake(=>)
|
173
|
+
@snippetToolbar.hide()
|
174
|
+
expect(@setTimeoutSpy.callCount).toEqual(1)
|
175
|
+
|
176
|
+
it "hides the element", ->
|
177
|
+
@setTimeoutSpy.andCallFake((timeout, callback) => callback())
|
178
|
+
@snippetToolbar.hide()
|
179
|
+
expect(@snippetToolbar.element.css('display')).toEqual('none')
|
180
|
+
|
181
|
+
it "sets visible", ->
|
182
|
+
@setTimeoutSpy.andCallFake((timeout, callback) => callback())
|
183
|
+
@snippetToolbar.hide()
|
184
|
+
expect(@snippetToolbar.visible).toEqual(false)
|
@@ -0,0 +1,150 @@
|
|
1
|
+
describe "Mercury.Statusbar", ->
|
2
|
+
|
3
|
+
template 'mercury/statusbar.html'
|
4
|
+
|
5
|
+
beforeEach ->
|
6
|
+
$.fx.off = true
|
7
|
+
@region = {
|
8
|
+
path: -> [{tagName: 'A'}, {tagName: 'B'}, {tagName: 'C'}]
|
9
|
+
}
|
10
|
+
|
11
|
+
afterEach ->
|
12
|
+
@statusbar = null
|
13
|
+
delete(@statusbar)
|
14
|
+
|
15
|
+
describe "constructor", ->
|
16
|
+
|
17
|
+
beforeEach ->
|
18
|
+
@buildSpy = spyOn(Mercury.Statusbar.prototype, 'build')
|
19
|
+
@bindEventsSpy = spyOn(Mercury.Statusbar.prototype, 'bindEvents')
|
20
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', foo: 'bar', visible: false})
|
21
|
+
|
22
|
+
it "accepts options", ->
|
23
|
+
expect(@statusbar.options.foo).toEqual('bar')
|
24
|
+
|
25
|
+
it "sets visible based on options", ->
|
26
|
+
expect(@statusbar.visible).toEqual(false)
|
27
|
+
|
28
|
+
it "calls build", ->
|
29
|
+
expect(@buildSpy.callCount).toEqual(1)
|
30
|
+
|
31
|
+
it "calls bindEvents", ->
|
32
|
+
expect(@bindEventsSpy.callCount).toEqual(1)
|
33
|
+
|
34
|
+
|
35
|
+
describe "#build", ->
|
36
|
+
|
37
|
+
beforeEach ->
|
38
|
+
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
39
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#statusbar_container', visible: false})
|
40
|
+
|
41
|
+
it "builds an element", ->
|
42
|
+
expect($('.mercury-statusbar').length).toEqual(1)
|
43
|
+
|
44
|
+
it "builds an about element", ->
|
45
|
+
expect($('.mercury-statusbar-about').length).toEqual(1)
|
46
|
+
expect(@statusbar.aboutElement).toBeDefined()
|
47
|
+
|
48
|
+
it "hides the element if it's not supposed to be visible", ->
|
49
|
+
expect($('.mercury-statusbar').css('visibility')).toEqual('hidden')
|
50
|
+
|
51
|
+
it "can append to any element", ->
|
52
|
+
expect($('#statusbar_container .mercury-statusbar').length).toEqual(1)
|
53
|
+
|
54
|
+
|
55
|
+
describe "observed events ", ->
|
56
|
+
|
57
|
+
beforeEach ->
|
58
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test'})
|
59
|
+
|
60
|
+
describe "custom event: region:update", ->
|
61
|
+
|
62
|
+
it "calls setPath if a region was provided", ->
|
63
|
+
spy = spyOn(Mercury.Statusbar.prototype, 'setPath').andCallFake(=>)
|
64
|
+
Mercury.trigger('region:update', {region: @region})
|
65
|
+
expect(spy.callCount).toEqual(1)
|
66
|
+
|
67
|
+
describe "clicking on the about element", ->
|
68
|
+
|
69
|
+
it "opens a lightview", ->
|
70
|
+
spy = spyOn(Mercury, 'lightview').andCallFake(=>)
|
71
|
+
jasmine.simulate.click($('.mercury-statusbar-about').get(0))
|
72
|
+
expect(spy.callCount).toEqual(1)
|
73
|
+
|
74
|
+
|
75
|
+
describe "#height", ->
|
76
|
+
|
77
|
+
beforeEach ->
|
78
|
+
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
79
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: true})
|
80
|
+
|
81
|
+
it "knows it's own height", ->
|
82
|
+
expect(@statusbar.height()).toEqual(20) # styled with css in the template
|
83
|
+
|
84
|
+
|
85
|
+
describe "#top", ->
|
86
|
+
|
87
|
+
describe "when visible", ->
|
88
|
+
|
89
|
+
beforeEach ->
|
90
|
+
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
91
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: true})
|
92
|
+
|
93
|
+
it "returns the offset top of the element", ->
|
94
|
+
expect(@statusbar.top()).toEqual($('.mercury-statusbar').offset().top)
|
95
|
+
|
96
|
+
describe "when not visible", ->
|
97
|
+
|
98
|
+
beforeEach ->
|
99
|
+
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
100
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: false})
|
101
|
+
|
102
|
+
it "returns the offset top of the element + it's outer height", ->
|
103
|
+
expect(@statusbar.top()).toEqual($('.mercury-statusbar').offset().top + $('.mercury-statusbar').outerHeight())
|
104
|
+
|
105
|
+
|
106
|
+
describe "#setPath", ->
|
107
|
+
|
108
|
+
beforeEach ->
|
109
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test'})
|
110
|
+
|
111
|
+
it "builds a path and displays it", ->
|
112
|
+
@statusbar.setPath(@region.path())
|
113
|
+
expect($('.mercury-statusbar').html()).toMatch(/<span><strong>Path: <\/strong><a>c<\/a> .+ <a>b<\/a> .+ <a>a<\/a><\/span>/)
|
114
|
+
|
115
|
+
|
116
|
+
describe "#show", ->
|
117
|
+
|
118
|
+
beforeEach ->
|
119
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: false})
|
120
|
+
|
121
|
+
it "sets visible to true", ->
|
122
|
+
@statusbar.visible = false
|
123
|
+
@statusbar.show()
|
124
|
+
expect(@statusbar.visible).toEqual(true)
|
125
|
+
|
126
|
+
it "displays the element", ->
|
127
|
+
$('.mercury-statusbar').css({visibility: 'hidden'})
|
128
|
+
@statusbar.show()
|
129
|
+
expect($('.mercury-statusbar').css('visibility')).toEqual('visible')
|
130
|
+
|
131
|
+
it "sets the opacity of the element", ->
|
132
|
+
$('.mercury-statusbar').css({opacity: 0})
|
133
|
+
@statusbar.show()
|
134
|
+
expect($('.mercury-statusbar').css('opacity')).toEqual('1')
|
135
|
+
|
136
|
+
|
137
|
+
describe "#hide", ->
|
138
|
+
|
139
|
+
beforeEach ->
|
140
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: true})
|
141
|
+
|
142
|
+
it "sets visible to false", ->
|
143
|
+
@statusbar.visible = true
|
144
|
+
@statusbar.hide()
|
145
|
+
expect(@statusbar.visible).toEqual(false)
|
146
|
+
|
147
|
+
it "hides the element", ->
|
148
|
+
$('.mercury-statusbar').css({visibility: 'visible'})
|
149
|
+
@statusbar.hide()
|
150
|
+
expect($('.mercury-statusbar').css('visibility')).toEqual('hidden')
|
@@ -0,0 +1,194 @@
|
|
1
|
+
describe "Mercury.tableEditor", ->
|
2
|
+
|
3
|
+
template 'mercury/table_editor.html'
|
4
|
+
|
5
|
+
beforeEach ->
|
6
|
+
@table = $('#table1')
|
7
|
+
@cell = @table.find('th, td').first()
|
8
|
+
|
9
|
+
describe "singleton method", ->
|
10
|
+
|
11
|
+
beforeEach ->
|
12
|
+
@loadSpy = spyOn(Mercury.tableEditor, 'load').andCallFake(=>)
|
13
|
+
|
14
|
+
it "calls load", ->
|
15
|
+
Mercury.tableEditor(@table, @cell)
|
16
|
+
expect(@loadSpy.callCount).toEqual(1)
|
17
|
+
|
18
|
+
it "returns the function object", ->
|
19
|
+
ret = Mercury.tableEditor(@table, @cell)
|
20
|
+
expect(ret).toEqual(Mercury.tableEditor)
|
21
|
+
|
22
|
+
|
23
|
+
describe "#load", ->
|
24
|
+
|
25
|
+
it "expects a table and a table cell", ->
|
26
|
+
Mercury.tableEditor(@table, @cell)
|
27
|
+
expect(Mercury.tableEditor.table).toEqual(@table)
|
28
|
+
expect(Mercury.tableEditor.cell).toEqual(@cell)
|
29
|
+
|
30
|
+
it "accepts content that will be placed inside cells", ->
|
31
|
+
Mercury.tableEditor(@table, @cell, '<br/>')
|
32
|
+
expect(Mercury.tableEditor.cellContent).toEqual('<br/>')
|
33
|
+
|
34
|
+
it "sets row based on where the cell is", ->
|
35
|
+
Mercury.tableEditor(@table, @cell)
|
36
|
+
expect(Mercury.tableEditor.row.get(0)).toEqual(@table.find('tr').get(0))
|
37
|
+
|
38
|
+
it "gets the column count", ->
|
39
|
+
Mercury.tableEditor(@table, @cell)
|
40
|
+
expect(Mercury.tableEditor.columnCount).toEqual(6)
|
41
|
+
|
42
|
+
it "gets the row count", ->
|
43
|
+
Mercury.tableEditor(@table, @cell)
|
44
|
+
expect(Mercury.tableEditor.rowCount).toEqual(8)
|
45
|
+
|
46
|
+
|
47
|
+
describe "#getColumnCount", ->
|
48
|
+
|
49
|
+
it "gets the column count from the alpha row", ->
|
50
|
+
Mercury.tableEditor(@table, @cell)
|
51
|
+
expect(Mercury.tableEditor.columnCount).toEqual(6)
|
52
|
+
|
53
|
+
|
54
|
+
describe "#getRowCount", ->
|
55
|
+
|
56
|
+
it "gets the row count", ->
|
57
|
+
Mercury.tableEditor(@table, @cell)
|
58
|
+
expect(Mercury.tableEditor.rowCount).toEqual(8)
|
59
|
+
|
60
|
+
|
61
|
+
describe "#cellIndexFor", ->
|
62
|
+
|
63
|
+
it "gives the right index for different cells", ->
|
64
|
+
cell = @table.find('#row1 td:nth-child(1n)').get(0)
|
65
|
+
expect(Mercury.tableEditor.cellIndexFor(cell)).toEqual(0)
|
66
|
+
|
67
|
+
cell = @table.find('#row2 th:nth-child(2n)').get(0)
|
68
|
+
expect(Mercury.tableEditor.cellIndexFor(cell)).toEqual(1)
|
69
|
+
|
70
|
+
cell = @table.find('#row2 th:nth-child(6n)').get(0)
|
71
|
+
expect(Mercury.tableEditor.cellIndexFor(cell)).toEqual(5)
|
72
|
+
|
73
|
+
cell = @table.find('#row3 td:nth-child(4n)').get(0)
|
74
|
+
expect(Mercury.tableEditor.cellIndexFor(cell)).toEqual(5)
|
75
|
+
|
76
|
+
cell = @table.find('#row7 td:nth-child(2n)').get(0)
|
77
|
+
expect(Mercury.tableEditor.cellIndexFor(cell)).toEqual(2)
|
78
|
+
|
79
|
+
|
80
|
+
describe "#cellSignatureFor", ->
|
81
|
+
|
82
|
+
it "returns an object with cell information", ->
|
83
|
+
cell = @table.find('#row2 th:nth-child(3n)').get(0)
|
84
|
+
sig = Mercury.tableEditor.cellSignatureFor(cell)
|
85
|
+
expect(sig.width).toEqual(1)
|
86
|
+
expect(sig.height).toEqual(2)
|
87
|
+
expect(sig.right).toEqual(3)
|
88
|
+
|
89
|
+
cell = @table.find('#row2 th:nth-child(5n)').get(0)
|
90
|
+
sig = Mercury.tableEditor.cellSignatureFor(cell)
|
91
|
+
expect(sig.width).toEqual(1)
|
92
|
+
expect(sig.height).toEqual(4)
|
93
|
+
expect(sig.right).toEqual(5)
|
94
|
+
|
95
|
+
cell = @table.find('#row7 td:nth-child(1n)').get(0)
|
96
|
+
sig = Mercury.tableEditor.cellSignatureFor(cell)
|
97
|
+
expect(sig.width).toEqual(2)
|
98
|
+
expect(sig.height).toEqual(1)
|
99
|
+
expect(sig.right).toEqual(2)
|
100
|
+
|
101
|
+
describe "#findCellByOptionsFor", ->
|
102
|
+
|
103
|
+
it "finds a matching cell in a specific row, based on right", ->
|
104
|
+
row = @table.find('#row2').get(0)
|
105
|
+
sig = Mercury.tableEditor.findCellByOptionsFor(row, { right: 5 })
|
106
|
+
expect(sig.cell.get(0)).toEqual(@table.find('#row2 th:nth-child(5n)').get(0))
|
107
|
+
|
108
|
+
it "finds a cell based on left", ->
|
109
|
+
row = @table.find('#row5').get(0)
|
110
|
+
sig = Mercury.tableEditor.findCellByOptionsFor(row, { left: 5 })
|
111
|
+
expect(sig.cell.get(0)).toEqual(@table.find('#row5 th:nth-child(5n)').get(0))
|
112
|
+
|
113
|
+
it "finds a cell based on left and width", ->
|
114
|
+
row = @table.find('#row7').get(0)
|
115
|
+
sig = Mercury.tableEditor.findCellByOptionsFor(row, { left: 2, width: 4 })
|
116
|
+
expect(sig.cell.get(0)).toEqual(@table.find('#row7 td:nth-child(2n)').get(0))
|
117
|
+
|
118
|
+
describe "when a cell isn't there", ->
|
119
|
+
|
120
|
+
beforeEach ->
|
121
|
+
@row = @table.find('#row3').get(0)
|
122
|
+
|
123
|
+
it "returns null", ->
|
124
|
+
sig = Mercury.tableEditor.findCellByOptionsFor(@row, { left: 2 })
|
125
|
+
expect(sig).toEqual(null)
|
126
|
+
|
127
|
+
it "can force to an adjacent cell", ->
|
128
|
+
sig = Mercury.tableEditor.findCellByOptionsFor(@row, { left: 2, forceAdjacent: true })
|
129
|
+
expect(sig.cell.get(0)).toEqual(@table.find('#row3 td:nth-child(2n)').get(0))
|
130
|
+
expect(sig.direction).toEqual('after')
|
131
|
+
|
132
|
+
|
133
|
+
describe "#findCellByIntersectionFor", ->
|
134
|
+
|
135
|
+
it "finds cells that intersect vertically, based on the signature of another cell", ->
|
136
|
+
sig = Mercury.tableEditor.cellSignatureFor(@table.find('#row6 td:nth-child(3n)'))
|
137
|
+
intersectingSig = Mercury.tableEditor.findCellByIntersectionFor(@table.find('#row7'), sig)
|
138
|
+
expect(intersectingSig.cell.get(0)).toEqual(@table.find('#row7 td:nth-child(2n)').get(0))
|
139
|
+
|
140
|
+
|
141
|
+
describe "#columnsFor", ->
|
142
|
+
|
143
|
+
it "returns the total number of cells and colspans for a given collection of cells", ->
|
144
|
+
expect(Mercury.tableEditor.columnsFor(@table.find('#row7 td'))).toEqual(6)
|
145
|
+
|
146
|
+
|
147
|
+
describe "#colspanFor", ->
|
148
|
+
|
149
|
+
it "returns the colspan of a given cell", ->
|
150
|
+
cell = @table.find('#row7 td:nth-child(2n)')
|
151
|
+
expect(Mercury.tableEditor.colspanFor(cell)).toEqual(4)
|
152
|
+
|
153
|
+
it "defaults to 1", ->
|
154
|
+
cell = @table.find('#row6 td:first-child')
|
155
|
+
expect(Mercury.tableEditor.colspanFor(cell)).toEqual(1)
|
156
|
+
|
157
|
+
|
158
|
+
describe "#rowspanFor", ->
|
159
|
+
|
160
|
+
it "returns the rowspan of a given cell", ->
|
161
|
+
cell = @table.find('#row2 th:nth-child(5n)')
|
162
|
+
expect(Mercury.tableEditor.rowspanFor(cell)).toEqual(4)
|
163
|
+
|
164
|
+
it "defaults to 1", ->
|
165
|
+
cell = @table.find('#row6 td:first-child')
|
166
|
+
expect(Mercury.tableEditor.rowspanFor(cell)).toEqual(1)
|
167
|
+
|
168
|
+
|
169
|
+
describe "setColspanFor", ->
|
170
|
+
|
171
|
+
beforeEach ->
|
172
|
+
@cell = @table.find('#row2 th:first-child')
|
173
|
+
|
174
|
+
it "sets the colspan for a cell", ->
|
175
|
+
Mercury.tableEditor.setColspanFor(@cell, 20)
|
176
|
+
expect(@cell.attr('colspan')).toEqual('20')
|
177
|
+
|
178
|
+
it "removes the attribute if it's 1", ->
|
179
|
+
Mercury.tableEditor.setColspanFor(@cell, 1)
|
180
|
+
expect(@cell.attr('colspan')).toEqual(undefined)
|
181
|
+
|
182
|
+
|
183
|
+
describe "setRowspanFor", ->
|
184
|
+
|
185
|
+
beforeEach ->
|
186
|
+
@cell = @table.find('#row2 th:first-child')
|
187
|
+
|
188
|
+
it "sets the rowspan for a cell", ->
|
189
|
+
Mercury.tableEditor.setRowspanFor(@cell, 20)
|
190
|
+
expect(@cell.attr('rowspan')).toEqual('20')
|
191
|
+
|
192
|
+
it "removes the attribute if it's 1", ->
|
193
|
+
Mercury.tableEditor.setRowspanFor(@cell, 1)
|
194
|
+
expect(@cell.attr('rowspan')).toEqual(undefined)
|
@@ -0,0 +1,90 @@
|
|
1
|
+
describe "Mercury.Toolbar.ButtonGroup", ->
|
2
|
+
|
3
|
+
template 'mercury/toolbar.button_group.html'
|
4
|
+
|
5
|
+
beforeEach ->
|
6
|
+
Mercury.Toolbar.ButtonGroup.contexts.foo = -> false
|
7
|
+
@region = {
|
8
|
+
element: $('<div class="mercury-region">')
|
9
|
+
currentElement: -> $('<div>')
|
10
|
+
}
|
11
|
+
|
12
|
+
afterEach ->
|
13
|
+
@buttonGroup = null
|
14
|
+
delete(@buttonGroup)
|
15
|
+
$(window).unbind('mercury:region:update')
|
16
|
+
|
17
|
+
describe "constructor", ->
|
18
|
+
|
19
|
+
beforeEach ->
|
20
|
+
@buildSpy = spyOn(Mercury.Toolbar.ButtonGroup.prototype, 'build').andCallThrough()
|
21
|
+
@bindEventsSpy = spyOn(Mercury.Toolbar.ButtonGroup.prototype, 'bindEvents').andCallThrough()
|
22
|
+
@buttonGroup = new Mercury.Toolbar.ButtonGroup('foo', {_context: true})
|
23
|
+
|
24
|
+
it "returns an element", ->
|
25
|
+
html = $('<div>').html(@buttonGroup).html()
|
26
|
+
expect(html).toEqual('<div class="mercury-button-group mercury-foo-group disabled"></div>')
|
27
|
+
|
28
|
+
it "calls build", ->
|
29
|
+
expect(@buildSpy.callCount).toEqual(1)
|
30
|
+
|
31
|
+
it "calls bindEvents", ->
|
32
|
+
expect(@bindEventsSpy.callCount).toEqual(1)
|
33
|
+
|
34
|
+
|
35
|
+
describe "observed events", ->
|
36
|
+
|
37
|
+
describe "custom event: region:update", ->
|
38
|
+
|
39
|
+
it "sets disabled/enabled state based on it's context", ->
|
40
|
+
@buttonGroup = new Mercury.Toolbar.ButtonGroup('foo', {_context: true})
|
41
|
+
contextSpy = spyOn(Mercury.Toolbar.ButtonGroup.contexts, 'foo').andCallFake(-> true)
|
42
|
+
|
43
|
+
expect(@buttonGroup.hasClass('disabled')).toEqual(true)
|
44
|
+
|
45
|
+
Mercury.trigger('region:update', {region: @region})
|
46
|
+
expect(contextSpy.callCount).toEqual(1)
|
47
|
+
expect(@buttonGroup.hasClass('disabled')).toEqual(false)
|
48
|
+
|
49
|
+
describe "custom event: region:focused", ->
|
50
|
+
|
51
|
+
beforeEach ->
|
52
|
+
@region = {
|
53
|
+
type: 'editable'
|
54
|
+
element: $('<div class="mercury-region">')
|
55
|
+
}
|
56
|
+
|
57
|
+
it "disables if the region type isn't supported", ->
|
58
|
+
@buttonGroup = new Mercury.Toolbar.ButtonGroup('foo', {_regions: ['foo']})
|
59
|
+
@buttonGroup.removeClass('disabled')
|
60
|
+
Mercury.trigger('region:focused', {region: @region})
|
61
|
+
expect(@buttonGroup.hasClass('disabled')).toEqual(true)
|
62
|
+
|
63
|
+
it "enables if the region type is supported", ->
|
64
|
+
@buttonGroup = new Mercury.Toolbar.ButtonGroup('foo', {_regions: ['editable']})
|
65
|
+
@buttonGroup.addClass('disabled')
|
66
|
+
Mercury.trigger('region:focused', {region: @region})
|
67
|
+
expect(@buttonGroup.hasClass('disabled')).toEqual(false)
|
68
|
+
|
69
|
+
describe "custom event: region:blurred", ->
|
70
|
+
|
71
|
+
it "disables if it's a button group for specific region types", ->
|
72
|
+
@buttonGroup = new Mercury.Toolbar.ButtonGroup('foo', {_regions: ['editable']})
|
73
|
+
@buttonGroup.removeClass('disabled')
|
74
|
+
Mercury.trigger('region:blurred', {region: @region})
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
describe "Mercury.Toolbar.ButtonGroup.contexts", ->
|
79
|
+
|
80
|
+
template 'mercury/toolbar.button_group.html'
|
81
|
+
|
82
|
+
beforeEach ->
|
83
|
+
@contexts = Mercury.Toolbar.ButtonGroup.contexts
|
84
|
+
@region = $('#context_container')
|
85
|
+
|
86
|
+
describe "table", ->
|
87
|
+
|
88
|
+
it "looks up for a table tag", ->
|
89
|
+
expect(@contexts.table($('#context_td'), @region)).toEqual(true)
|
90
|
+
expect(@contexts.table($('#context_em'), @region)).toEqual(false)
|