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,281 @@
|
|
1
|
+
describe "Mercury.Dialog", ->
|
2
|
+
|
3
|
+
template 'mercury/dialog.html'
|
4
|
+
|
5
|
+
beforeEach ->
|
6
|
+
$.fx.off = true
|
7
|
+
Mercury.determinedLocale =
|
8
|
+
top: {'hello world!': 'bork! bork!'}
|
9
|
+
sub: {'foo': 'Bork!'}
|
10
|
+
|
11
|
+
afterEach ->
|
12
|
+
delete(@dialog)
|
13
|
+
Mercury.config.localization.enabled = false
|
14
|
+
|
15
|
+
|
16
|
+
describe "constructor", ->
|
17
|
+
|
18
|
+
beforeEach ->
|
19
|
+
@buildSpy = spyOn(Mercury.Dialog.prototype, 'build').andCallFake(=>)
|
20
|
+
@bindEventsSpy = spyOn(Mercury.Dialog.prototype, 'bindEvents').andCallFake(=>)
|
21
|
+
@preloadSpy = spyOn(Mercury.Dialog.prototype, 'preload').andCallFake(=>)
|
22
|
+
|
23
|
+
it "expects a url and name", ->
|
24
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo')
|
25
|
+
expect(@dialog.url).toEqual('/blank.html')
|
26
|
+
expect(@dialog.name).toEqual('foo')
|
27
|
+
|
28
|
+
it "accepts options", ->
|
29
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {for: 'something', foo: 'bar'})
|
30
|
+
expect(@dialog.options).toEqual({for: 'something', foo: 'bar'})
|
31
|
+
|
32
|
+
it "calls build", ->
|
33
|
+
@dialog = new Mercury.Dialog()
|
34
|
+
expect(@buildSpy.callCount).toEqual(1)
|
35
|
+
|
36
|
+
it "calls bindEvents", ->
|
37
|
+
@dialog = new Mercury.Dialog()
|
38
|
+
expect(@bindEventsSpy.callCount).toEqual(1)
|
39
|
+
|
40
|
+
it "preloads if configured", ->
|
41
|
+
@dialog = new Mercury.Dialog()
|
42
|
+
expect(@preloadSpy.callCount).toEqual(1)
|
43
|
+
|
44
|
+
|
45
|
+
describe "#build", ->
|
46
|
+
|
47
|
+
beforeEach ->
|
48
|
+
@bindEventsSpy = spyOn(Mercury.Dialog.prototype, 'bindEvents').andCallFake(=>)
|
49
|
+
@preloadSpy = spyOn(Mercury.Dialog.prototype, 'preload').andCallFake(=>)
|
50
|
+
|
51
|
+
it "builds an element", ->
|
52
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {appendTo: '#test'})
|
53
|
+
html = $('<div>').html(@dialog.element).html()
|
54
|
+
expect(html).toContain('class="mercury-dialog mercury-foo-dialog loading"')
|
55
|
+
expect(html).toContain('style="display:none"')
|
56
|
+
|
57
|
+
it "appends to any element", ->
|
58
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {appendTo: '#dialog_container'})
|
59
|
+
expect($('#dialog_container .mercury-dialog').length).toEqual(1)
|
60
|
+
|
61
|
+
|
62
|
+
describe "#bindEvents", ->
|
63
|
+
|
64
|
+
it "only observes mousedown to stop the event"
|
65
|
+
|
66
|
+
|
67
|
+
describe "#preload", ->
|
68
|
+
|
69
|
+
beforeEach ->
|
70
|
+
@loadSpy = spyOn(Mercury.Dialog.prototype, 'load').andCallFake(=>)
|
71
|
+
|
72
|
+
it "calls load if configured", ->
|
73
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {appendTo: '#test', preload: true})
|
74
|
+
expect(@loadSpy.callCount).toEqual(1)
|
75
|
+
|
76
|
+
it "doesn't call load if configured", ->
|
77
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {appendTo: '#test', preload: false})
|
78
|
+
expect(@loadSpy.callCount).toEqual(0)
|
79
|
+
|
80
|
+
|
81
|
+
describe "#toggle", ->
|
82
|
+
|
83
|
+
beforeEach ->
|
84
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {appendTo: '#test'})
|
85
|
+
|
86
|
+
it "shows or hides", ->
|
87
|
+
expect(@dialog.element.css('display')).toEqual('none')
|
88
|
+
@dialog.toggle()
|
89
|
+
expect(@dialog.element.css('display')).toEqual('block')
|
90
|
+
@dialog.toggle()
|
91
|
+
expect(@dialog.element.css('display')).toEqual('none')
|
92
|
+
|
93
|
+
|
94
|
+
describe "#resize", ->
|
95
|
+
|
96
|
+
beforeEach ->
|
97
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {appendTo: '#test'})
|
98
|
+
|
99
|
+
it "calls show", ->
|
100
|
+
spy = spyOn(Mercury.Dialog.prototype, 'show').andCallFake(=>)
|
101
|
+
@dialog.resize()
|
102
|
+
expect(spy.callCount).toEqual(1)
|
103
|
+
|
104
|
+
|
105
|
+
describe "#show", ->
|
106
|
+
|
107
|
+
beforeEach ->
|
108
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {appendTo: '#test'})
|
109
|
+
|
110
|
+
it "triggers a custom event to hide all other dialogs", ->
|
111
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
112
|
+
@dialog.show()
|
113
|
+
expect(spy.callCount).toEqual(1)
|
114
|
+
expect(spy.argsForCall[0]).toEqual(['hide:dialogs', @dialog])
|
115
|
+
|
116
|
+
describe "when already loaded", ->
|
117
|
+
|
118
|
+
beforeEach ->
|
119
|
+
@dialog.loaded = true
|
120
|
+
|
121
|
+
it "sets width and height on the element to auto", ->
|
122
|
+
@dialog.element.css({width: 100})
|
123
|
+
@dialog.show()
|
124
|
+
expect(@dialog.element.get(0).style.width).toEqual('auto')
|
125
|
+
expect(@dialog.element.get(0).style.height).toEqual('auto')
|
126
|
+
|
127
|
+
it "calls position", ->
|
128
|
+
spy = spyOn(Mercury.Dialog.prototype, 'position').andCallFake(=>)
|
129
|
+
@dialog.show()
|
130
|
+
expect(spy.callCount).toEqual(1)
|
131
|
+
expect(spy.argsForCall[0]).toEqual([true])
|
132
|
+
|
133
|
+
it "calls appear", ->
|
134
|
+
spy = spyOn(Mercury.Dialog.prototype, 'appear').andCallFake(=>)
|
135
|
+
@dialog.show()
|
136
|
+
expect(spy.callCount).toEqual(1)
|
137
|
+
|
138
|
+
describe "when not loaded", ->
|
139
|
+
|
140
|
+
it "calls position", ->
|
141
|
+
spy = spyOn(Mercury.Dialog.prototype, 'position').andCallFake(=>)
|
142
|
+
@dialog.show()
|
143
|
+
expect(spy.callCount).toEqual(1)
|
144
|
+
expect(spy.argsForCall[0]).toEqual([])
|
145
|
+
|
146
|
+
it "calls appear", ->
|
147
|
+
spy = spyOn(Mercury.Dialog.prototype, 'appear').andCallFake(=>)
|
148
|
+
@dialog.show()
|
149
|
+
expect(spy.callCount).toEqual(1)
|
150
|
+
|
151
|
+
|
152
|
+
describe "#position", ->
|
153
|
+
|
154
|
+
it "does nothing and is there as an interface method"
|
155
|
+
|
156
|
+
|
157
|
+
describe "#appear", ->
|
158
|
+
|
159
|
+
beforeEach ->
|
160
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {appendTo: '#test'})
|
161
|
+
|
162
|
+
it "animates the dialog in", ->
|
163
|
+
@dialog.appear()
|
164
|
+
expect(@dialog.element.css('display')).toEqual('block')
|
165
|
+
expect(parseFloat(@dialog.element.css('opacity')).toPrecision(2)).toEqual('0.95')
|
166
|
+
|
167
|
+
it "calls load if it's not already loaded", ->
|
168
|
+
|
169
|
+
|
170
|
+
describe "#hide", ->
|
171
|
+
|
172
|
+
beforeEach ->
|
173
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {appendTo: '#test'})
|
174
|
+
|
175
|
+
it "hides the dialog", ->
|
176
|
+
@dialog.element.css({display: 'block'})
|
177
|
+
@dialog.hide()
|
178
|
+
expect(@dialog.element.css('display')).toEqual('none')
|
179
|
+
expect(@dialog.visible).toEqual(false)
|
180
|
+
|
181
|
+
|
182
|
+
describe "#load", ->
|
183
|
+
|
184
|
+
beforeEach ->
|
185
|
+
@spyFunction = ->
|
186
|
+
Mercury.dialogHandlers.foo = ->
|
187
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
|
188
|
+
|
189
|
+
it "does nothing if there's no url", ->
|
190
|
+
spy = spyOn($, 'ajax').andCallFake(=>)
|
191
|
+
@dialog.url = false
|
192
|
+
@dialog.load()
|
193
|
+
expect(spy.callCount).toEqual(0)
|
194
|
+
|
195
|
+
describe "on a preloaded view", ->
|
196
|
+
|
197
|
+
beforeEach ->
|
198
|
+
Mercury.preloadedViews = {'/blank.html': 'this is the preloaded content'}
|
199
|
+
|
200
|
+
afterEach ->
|
201
|
+
Mercury.preloadedViews = {}
|
202
|
+
|
203
|
+
it "calls loadContent with the content in the preloaded view", ->
|
204
|
+
spy = spyOn(Mercury.Dialog.prototype, 'loadContent').andCallFake(=>)
|
205
|
+
@dialog.load()
|
206
|
+
expect(spy.callCount).toEqual(1)
|
207
|
+
expect(spy.argsForCall[0]).toEqual(['this is the preloaded content'])
|
208
|
+
|
209
|
+
describe "when not a preloaded view", ->
|
210
|
+
|
211
|
+
it "makes an ajax request", ->
|
212
|
+
spy = spyOn($, 'ajax').andCallFake(=>)
|
213
|
+
@dialog.load()
|
214
|
+
expect(spy.callCount).toEqual(1)
|
215
|
+
|
216
|
+
describe "on success", ->
|
217
|
+
|
218
|
+
beforeEach ->
|
219
|
+
@loadContentSpy = spyOn(Mercury.Dialog.prototype, 'loadContent').andCallFake(=>)
|
220
|
+
@ajaxSpy = spyOn($, 'ajax').andCallFake (url, options) =>
|
221
|
+
options.success('return value') if (options.success)
|
222
|
+
|
223
|
+
it "calls loadContent with data", ->
|
224
|
+
@dialog.load()
|
225
|
+
expect(@loadContentSpy.callCount).toEqual(1)
|
226
|
+
expect(@loadContentSpy.argsForCall[0]).toEqual(['return value'])
|
227
|
+
|
228
|
+
it "calls a dialog handler if there's one", ->
|
229
|
+
spy = spyOn(Mercury.dialogHandlers, 'foo').andCallFake(=>)
|
230
|
+
@dialog.load()
|
231
|
+
expect(spy.callCount).toEqual(1)
|
232
|
+
|
233
|
+
it "calls a callback if one was provided", ->
|
234
|
+
spy = spyOn(@, 'spyFunction').andCallFake(=>)
|
235
|
+
@dialog.load(@spyFunction)
|
236
|
+
expect(spy.callCount).toEqual(1)
|
237
|
+
|
238
|
+
describe "on failure", ->
|
239
|
+
|
240
|
+
beforeEach ->
|
241
|
+
@alertSpy = spyOn(window, 'alert').andCallFake(=>)
|
242
|
+
@ajaxSpy = spyOn($, 'ajax').andCallFake (url, options) =>
|
243
|
+
options.error() if (options.error)
|
244
|
+
|
245
|
+
it "hides", ->
|
246
|
+
spy = spyOn(Mercury.Dialog.prototype, 'hide').andCallFake(=>)
|
247
|
+
@dialog.load()
|
248
|
+
expect(spy.callCount).toEqual(1)
|
249
|
+
|
250
|
+
it "removes the pressed state for it's button", ->
|
251
|
+
$('#button').addClass('pressed')
|
252
|
+
@dialog.load()
|
253
|
+
expect($('#button').hasClass('pressed')).toEqual(false)
|
254
|
+
|
255
|
+
it "alerts the user", ->
|
256
|
+
@dialog.load()
|
257
|
+
expect(@alertSpy.callCount).toEqual(1)
|
258
|
+
expect(@alertSpy.argsForCall[0]).toEqual(['Mercury was unable to load /blank.html for the "foo" dialog.'])
|
259
|
+
|
260
|
+
|
261
|
+
describe "#loadContent", ->
|
262
|
+
|
263
|
+
beforeEach ->
|
264
|
+
@dialog = new Mercury.Dialog('/blank.html', 'foo', {appendTo: '#test'})
|
265
|
+
|
266
|
+
it "sets loaded to be true", ->
|
267
|
+
@dialog.loadContent()
|
268
|
+
expect(@dialog.loaded).toEqual(true)
|
269
|
+
|
270
|
+
it "removes the loading class from the element", ->
|
271
|
+
@dialog.loadContent()
|
272
|
+
expect(@dialog.element.hasClass('loading')).toEqual(false)
|
273
|
+
|
274
|
+
it "sets the element html to be the data passed to it", ->
|
275
|
+
@dialog.loadContent('<span>hello world!</span>')
|
276
|
+
expect(@dialog.element.html()).toEqual('<span>hello world!</span>')
|
277
|
+
|
278
|
+
it "translates the content if configured", ->
|
279
|
+
Mercury.config.localization.enabled = true
|
280
|
+
@dialog.loadContent('<span>hello world!</span>')
|
281
|
+
expect(@dialog.element.html()).toEqual('<span>bork! bork!</span>')
|
@@ -0,0 +1,37 @@
|
|
1
|
+
describe "Mercury.dialogHandlers.backColor", ->
|
2
|
+
|
3
|
+
template 'mercury/dialogs/backcolor.html'
|
4
|
+
|
5
|
+
beforeEach ->
|
6
|
+
@dialog = {element: $('#test'), button: $('#button')}
|
7
|
+
Mercury.dialogHandlers.backColor.call(@dialog)
|
8
|
+
|
9
|
+
describe "when a .picker or .last-picked element is clicked", ->
|
10
|
+
|
11
|
+
it "sets the last picked color to whatever was selected", ->
|
12
|
+
$('.last-picked').css({background: '#0000FF'})
|
13
|
+
jasmine.simulate.click($('#white').get(0))
|
14
|
+
expect($('.last-picked').css('backgroundColor')).toEqual('rgb(255, 255, 255)')
|
15
|
+
jasmine.simulate.click($('#red').get(0))
|
16
|
+
expect($('.last-picked').css('backgroundColor')).toEqual('rgb(255, 0, 0)')
|
17
|
+
|
18
|
+
it "sets the background color of the button", ->
|
19
|
+
$('#button').css({background: '#0000FF'})
|
20
|
+
jasmine.simulate.click($('#white').get(0))
|
21
|
+
expect($('#button').css('backgroundColor')).toEqual('rgb(255, 255, 255)')
|
22
|
+
jasmine.simulate.click($('#red').get(0))
|
23
|
+
expect($('#button').css('backgroundColor')).toEqual('rgb(255, 0, 0)')
|
24
|
+
|
25
|
+
it "triggers an action", ->
|
26
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
27
|
+
jasmine.simulate.click($('#white').get(0))
|
28
|
+
expect(spy.callCount).toEqual(1)
|
29
|
+
expect(spy.argsForCall[0]).toEqual(['action', {action: 'backColor', value: 'rgb(255, 255, 255)'}])
|
30
|
+
|
31
|
+
|
32
|
+
describe "when any other element is clicked", ->
|
33
|
+
|
34
|
+
it "does nothing", ->
|
35
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
36
|
+
jasmine.simulate.click($('#green').get(0))
|
37
|
+
expect(spy.callCount).toEqual(0)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
describe "Mercury.dialogHandlers.foreColor", ->
|
2
|
+
|
3
|
+
template 'mercury/dialogs/forecolor.html'
|
4
|
+
|
5
|
+
beforeEach ->
|
6
|
+
@dialog = {element: $('#test'), button: $('#button')}
|
7
|
+
Mercury.dialogHandlers.foreColor.call(@dialog)
|
8
|
+
|
9
|
+
describe "when a .picker or .last-picked element is clicked", ->
|
10
|
+
|
11
|
+
it "sets the last picked color to whatever was selected", ->
|
12
|
+
$('.last-picked').css({background: '#0000FF'})
|
13
|
+
jasmine.simulate.click($('#white').get(0))
|
14
|
+
expect($('.last-picked').css('backgroundColor')).toEqual('rgb(255, 255, 255)')
|
15
|
+
jasmine.simulate.click($('#red').get(0))
|
16
|
+
expect($('.last-picked').css('backgroundColor')).toEqual('rgb(255, 0, 0)')
|
17
|
+
|
18
|
+
it "sets the background color of the button", ->
|
19
|
+
$('#button').css({background: '#0000FF'})
|
20
|
+
jasmine.simulate.click($('#white').get(0))
|
21
|
+
expect($('#button').css('backgroundColor')).toEqual('rgb(255, 255, 255)')
|
22
|
+
jasmine.simulate.click($('#red').get(0))
|
23
|
+
expect($('#button').css('backgroundColor')).toEqual('rgb(255, 0, 0)')
|
24
|
+
|
25
|
+
it "triggers an action", ->
|
26
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
27
|
+
jasmine.simulate.click($('#white').get(0))
|
28
|
+
expect(spy.callCount).toEqual(1)
|
29
|
+
expect(spy.argsForCall[0]).toEqual(['action', {action: 'foreColor', value: 'rgb(255, 255, 255)'}])
|
30
|
+
|
31
|
+
|
32
|
+
describe "when any other element is clicked", ->
|
33
|
+
|
34
|
+
it "does nothing", ->
|
35
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
36
|
+
jasmine.simulate.click($('#green').get(0))
|
37
|
+
expect(spy.callCount).toEqual(0)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
describe "Mercury.dialogHandlers.formatblock", ->
|
2
|
+
|
3
|
+
template 'mercury/dialogs/formatblock.html'
|
4
|
+
|
5
|
+
beforeEach ->
|
6
|
+
@dialog = {element: $('#test')}
|
7
|
+
Mercury.dialogHandlers.formatblock.call(@dialog)
|
8
|
+
|
9
|
+
describe "when an element with a data-tag attribute is clicked", ->
|
10
|
+
|
11
|
+
it "triggers an action", ->
|
12
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
13
|
+
jasmine.simulate.click($('#h1').get(0))
|
14
|
+
expect(spy.callCount).toEqual(1)
|
15
|
+
expect(spy.argsForCall[0]).toEqual(['action', {action: 'formatblock', value: 'h1'}])
|
16
|
+
jasmine.simulate.click($('#div').get(0))
|
17
|
+
expect(spy.argsForCall[1]).toEqual(['action', {action: 'formatblock', value: 'pre'}])
|
18
|
+
|
19
|
+
|
20
|
+
describe "when any other element is clicked", ->
|
21
|
+
|
22
|
+
it "does nothing", ->
|
23
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
24
|
+
jasmine.simulate.click($('#em').get(0))
|
25
|
+
expect(spy.callCount).toEqual(0)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
describe "Mercury.dialogHandlers.snippetPanel", ->
|
2
|
+
|
3
|
+
template 'mercury/dialogs/snippetpanel.html'
|
4
|
+
|
5
|
+
beforeEach ->
|
6
|
+
@dialog = {element: $('#test'), button: $('#button')}
|
7
|
+
Mercury.dialogHandlers.snippetPanel.call(@dialog)
|
8
|
+
|
9
|
+
describe "filter", ->
|
10
|
+
|
11
|
+
it "filters on keypress", ->
|
12
|
+
$('#filter').val('foo')
|
13
|
+
jasmine.simulate.keyup($('#filter').get(0))
|
14
|
+
expect($('#first').css('display')).toNotEqual('none')
|
15
|
+
expect($('#second').css('display')).toEqual('none')
|
16
|
+
|
17
|
+
$('#filter').val('b')
|
18
|
+
jasmine.simulate.keyup($('#filter').get(0))
|
19
|
+
expect($('#first').css('display')).toNotEqual('none')
|
20
|
+
expect($('#second').css('display')).toNotEqual('none')
|
21
|
+
|
22
|
+
$('#filter').val('baz')
|
23
|
+
jasmine.simulate.keyup($('#filter').get(0))
|
24
|
+
expect($('#first').css('display')).toEqual('none')
|
25
|
+
expect($('#second').css('display')).toNotEqual('none')
|
26
|
+
|
27
|
+
|
28
|
+
describe "dragging an image with a data-snippet attribute", ->
|
29
|
+
|
30
|
+
it "sets the active snippet", ->
|
@@ -0,0 +1,25 @@
|
|
1
|
+
describe "Mercury.dialogHandlers.style", ->
|
2
|
+
|
3
|
+
template 'mercury/dialogs/style.html'
|
4
|
+
|
5
|
+
beforeEach ->
|
6
|
+
@dialog = {element: $('#test')}
|
7
|
+
Mercury.dialogHandlers.style.call(@dialog)
|
8
|
+
|
9
|
+
describe "when an element with a data-class attribute is clicked", ->
|
10
|
+
|
11
|
+
it "triggers an action", ->
|
12
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
13
|
+
jasmine.simulate.click($('#red').get(0))
|
14
|
+
expect(spy.callCount).toEqual(1)
|
15
|
+
expect(spy.argsForCall[0]).toEqual(['action', {action: 'style', value: 'red'}])
|
16
|
+
jasmine.simulate.click($('#bold').get(0))
|
17
|
+
expect(spy.argsForCall[1]).toEqual(['action', {action: 'style', value: 'bold'}])
|
18
|
+
|
19
|
+
|
20
|
+
describe "when any other element is clicked", ->
|
21
|
+
|
22
|
+
it "does nothing", ->
|
23
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
24
|
+
jasmine.simulate.click($('#blue').get(0))
|
25
|
+
expect(spy.callCount).toEqual(0)
|
@@ -0,0 +1,76 @@
|
|
1
|
+
describe "Mercury.HistoryBuffer", ->
|
2
|
+
|
3
|
+
beforeEach ->
|
4
|
+
@buffer = new Mercury.HistoryBuffer(5)
|
5
|
+
|
6
|
+
afterEach ->
|
7
|
+
@buffer = null
|
8
|
+
delete(@buffer)
|
9
|
+
|
10
|
+
describe "constructor", ->
|
11
|
+
|
12
|
+
it "accepts a max length", ->
|
13
|
+
expect(@buffer.maxLength).toEqual(5)
|
14
|
+
|
15
|
+
it "initializes an empty stack", ->
|
16
|
+
expect(@buffer.index).toEqual(0)
|
17
|
+
expect(@buffer.stack).toEqual([])
|
18
|
+
|
19
|
+
|
20
|
+
describe "#push", ->
|
21
|
+
|
22
|
+
it "won't duplicate items if the content is the same", ->
|
23
|
+
@buffer.push('1')
|
24
|
+
expect(@buffer.stack).toEqual(['1'])
|
25
|
+
|
26
|
+
@buffer.push('2<em class="mercury-marker"></em>')
|
27
|
+
expect(@buffer.stack).toEqual(['1', '2<em class="mercury-marker"></em>'])
|
28
|
+
|
29
|
+
it "pushes onto the stack where it should", ->
|
30
|
+
@buffer.push('1')
|
31
|
+
@buffer.push('2')
|
32
|
+
expect(@buffer.stack).toEqual(['1', '2'])
|
33
|
+
|
34
|
+
@buffer.index = 0
|
35
|
+
@buffer.push('3')
|
36
|
+
expect(@buffer.stack).toEqual(['1', '3'])
|
37
|
+
|
38
|
+
it "keeps the number of items within the max length by dropping the oldest items", ->
|
39
|
+
@buffer.push('1')
|
40
|
+
@buffer.push('2')
|
41
|
+
@buffer.push('3')
|
42
|
+
@buffer.push('4')
|
43
|
+
@buffer.push('5')
|
44
|
+
expect(@buffer.stack).toEqual(['1', '2', '3', '4', '5'])
|
45
|
+
@buffer.push('6')
|
46
|
+
expect(@buffer.stack).toEqual(['2', '3', '4', '5', '6'])
|
47
|
+
|
48
|
+
|
49
|
+
describe "#undo", ->
|
50
|
+
|
51
|
+
beforeEach ->
|
52
|
+
@buffer.push('1')
|
53
|
+
@buffer.push('2')
|
54
|
+
|
55
|
+
it "returns the correct item", ->
|
56
|
+
expect(@buffer.undo()).toEqual('1')
|
57
|
+
|
58
|
+
it "returns null if there are no more items to undo", ->
|
59
|
+
expect(@buffer.undo()).toEqual('1')
|
60
|
+
expect(@buffer.undo()).toEqual(null)
|
61
|
+
|
62
|
+
|
63
|
+
describe "#redo", ->
|
64
|
+
|
65
|
+
beforeEach ->
|
66
|
+
@buffer.push('1')
|
67
|
+
@buffer.push('2')
|
68
|
+
|
69
|
+
it "returns the correct item", ->
|
70
|
+
@buffer.undo()
|
71
|
+
expect(@buffer.redo()).toEqual('2')
|
72
|
+
|
73
|
+
it "returns null if there are no more items to redo", ->
|
74
|
+
@buffer.undo()
|
75
|
+
expect(@buffer.redo()).toEqual('2')
|
76
|
+
expect(@buffer.redo()).toEqual(null)
|