mercury-rails 0.2.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/{images_controller.rb → mercury/images_controller.rb} +3 -3
- data/app/controllers/mercury_controller.rb +13 -3
- data/app/models/{image.rb → mercury/image.rb} +3 -1
- data/app/views/layouts/mercury.html.erb +14 -6
- data/app/views/mercury/lightviews/about.html +7 -3
- data/app/views/mercury/modals/character.html +2 -2
- data/app/views/mercury/modals/htmleditor.html +2 -2
- data/app/views/mercury/modals/link.html +3 -3
- data/app/views/mercury/modals/media.html +3 -3
- data/app/views/mercury/modals/table.html +3 -3
- data/app/views/mercury/panels/snippets.html +1 -1
- data/app/views/mercury/selects/formatblock.html +9 -9
- data/app/views/mercury/snippets/example/options.html.erb +27 -16
- data/config/engine.rb +35 -0
- data/db/migrate/{20110526035601_create_images.rb → 20110526035601_create_mercury_images.rb} +2 -2
- data/features/loading/loading.feature +1 -1
- data/features/loading/navigating.feature +1 -1
- data/features/loading/user_interface.feature +2 -2
- data/features/regions/editable/basic_editing.feature +8 -8
- data/features/regions/editable/inserting_snippets.feature +4 -5
- data/features/regions/editable/inserting_tables.feature +9 -9
- data/features/step_definitions/mercury_steps.rb +20 -23
- data/features/step_definitions/web_steps.rb +5 -5
- data/features/support/mercury_selectors.rb +1 -0
- data/lib/generators/mercury/install/install_generator.rb +24 -3
- data/lib/generators/mercury/install/templates/mongoid_paperclip_image.rb +17 -0
- data/lib/mercury-rails.rb +0 -1
- data/lib/mercury/authentication.rb +8 -0
- data/spec/javascripts/mercury/dialog_spec.js.coffee +28 -21
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/history_buffer_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/lightview_spec.js.coffee +42 -21
- data/spec/javascripts/mercury/mercury_spec.js.coffee +87 -7
- data/spec/javascripts/mercury/modal_spec.js.coffee +53 -23
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +2 -2
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +2 -4
- data/spec/javascripts/mercury/native_extensions_spec.js.coffee +20 -2
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +130 -35
- data/spec/javascripts/mercury/palette_spec.js.coffee +4 -6
- data/spec/javascripts/mercury/panel_spec.js.coffee +44 -6
- data/spec/javascripts/mercury/region_spec.js.coffee +42 -8
- data/spec/javascripts/mercury/regions/editable_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +3 -5
- data/spec/javascripts/mercury/select_spec.js.coffee +4 -6
- data/spec/javascripts/mercury/snippet_spec.js.coffee +3 -4
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +2 -4
- data/spec/javascripts/mercury/statusbar_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/table_editor_spec.js.coffee +2 -4
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +34 -15
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +0 -2
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +41 -26
- data/spec/javascripts/mercury/tooltip_spec.js.coffee +3 -5
- data/spec/javascripts/mercury/uploader_spec.js.coffee +8 -14
- data/spec/javascripts/spec_helper.js +1 -0
- data/spec/javascripts/templates/mercury/page_editor.html +1 -0
- data/spec/javascripts/templates/mercury/region.html +2 -2
- data/vendor/assets/images/mercury/missing-image.png +0 -0
- data/vendor/assets/javascripts/mercury.js +218 -112
- data/vendor/assets/javascripts/mercury/dependencies/{jquery-1.6.js → jquery-1.7.js} +2030 -1595
- data/vendor/assets/javascripts/mercury/dependencies/jquery.additions.js +55 -0
- data/vendor/assets/javascripts/mercury/dialog.js.coffee +7 -5
- data/vendor/assets/javascripts/mercury/dialogs/backcolor.js.coffee +1 -1
- data/vendor/assets/javascripts/mercury/dialogs/forecolor.js.coffee +1 -1
- data/vendor/assets/javascripts/mercury/dialogs/formatblock.js.coffee +1 -1
- data/vendor/assets/javascripts/mercury/dialogs/{objectspanel.js.coffee → snippetpanel.js.coffee} +2 -2
- data/vendor/assets/javascripts/mercury/dialogs/style.js.coffee +1 -1
- data/vendor/assets/javascripts/mercury/finalize.js.coffee +3 -0
- data/vendor/assets/javascripts/mercury/lightview.js.coffee +76 -30
- data/vendor/assets/javascripts/mercury/locales/da.locale.js.coffee +211 -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 +62 -17
- data/vendor/assets/javascripts/mercury/modal.js.coffee +34 -21
- data/vendor/assets/javascripts/mercury/modals/htmleditor.js.coffee +1 -2
- data/vendor/assets/javascripts/mercury/modals/insertcharacter.js.coffee +3 -3
- data/vendor/assets/javascripts/mercury/modals/insertlink.js.coffee +4 -4
- data/vendor/assets/javascripts/mercury/modals/insertmedia.js.coffee +10 -9
- data/vendor/assets/javascripts/mercury/modals/insertsnippet.js.coffee +1 -1
- data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +8 -9
- data/vendor/assets/javascripts/mercury/native_extensions.js.coffee +26 -8
- data/vendor/assets/javascripts/mercury/page_editor.js.coffee +68 -46
- data/vendor/assets/javascripts/mercury/palette.js.coffee +1 -1
- data/vendor/assets/javascripts/mercury/panel.js.coffee +25 -7
- data/vendor/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +1 -0
- data/vendor/assets/javascripts/mercury/region.js.coffee +21 -17
- data/vendor/assets/javascripts/mercury/regions/editable.js.coffee +47 -35
- data/vendor/assets/javascripts/mercury/regions/markupable.js.coffee +43 -36
- data/vendor/assets/javascripts/mercury/regions/snippetable.js.coffee +22 -24
- data/vendor/assets/javascripts/mercury/select.js.coffee +3 -2
- data/vendor/assets/javascripts/mercury/snippet.js.coffee +2 -1
- data/vendor/assets/javascripts/mercury/snippet_toolbar.js.coffee +10 -7
- data/vendor/assets/javascripts/mercury/statusbar.js.coffee +4 -4
- data/vendor/assets/javascripts/mercury/table_editor.js.coffee +1 -3
- data/vendor/assets/javascripts/mercury/toolbar.button.js.coffee +42 -20
- data/vendor/assets/javascripts/mercury/toolbar.button_group.js.coffee +3 -3
- data/vendor/assets/javascripts/mercury/toolbar.expander.js.coffee +2 -2
- data/vendor/assets/javascripts/mercury/toolbar.js.coffee +8 -6
- data/vendor/assets/javascripts/mercury/tooltip.js.coffee +13 -9
- data/vendor/assets/javascripts/mercury/uploader.js.coffee +22 -16
- data/vendor/assets/javascripts/mercury_loader.js +2 -0
- data/vendor/assets/javascripts/mercury_overrides.js +6 -0
- data/vendor/assets/stylesheets/mercury/all_images.css.erb +89 -0
- data/vendor/assets/stylesheets/mercury/dialog.css +13 -4
- data/vendor/assets/stylesheets/mercury/lightview.css +66 -15
- data/vendor/assets/stylesheets/mercury/mercury.css +12 -7
- data/vendor/assets/stylesheets/mercury/modal.css +9 -5
- data/vendor/assets/stylesheets/mercury/toolbar.css +3 -29
- metadata +266 -144
- data/POST_INSTALL +0 -15
- data/README.md +0 -299
- data/VERSION +0 -1
- data/annotated_source.template +0 -57
- data/config/routes.rb +0 -15
- data/mercury-rails.gemspec +0 -288
- data/spec/javascripts/responses/blank.html +0 -1
- data/vendor/assets/javascripts/mercury/lightviews/imageprocessor.js.coffee +0 -2
@@ -1,5 +1,3 @@
|
|
1
|
-
require '/assets/mercury.js'
|
2
|
-
|
3
1
|
describe "Mercury.Palette", ->
|
4
2
|
|
5
3
|
template 'mercury/palette.html'
|
@@ -14,20 +12,20 @@ describe "Mercury.Palette", ->
|
|
14
12
|
describe "#build", ->
|
15
13
|
|
16
14
|
it "builds an element", ->
|
17
|
-
@palette = new Mercury.Palette('/
|
15
|
+
@palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
|
18
16
|
html = $('<div>').html(@palette.element).html()
|
19
17
|
expect(html).toContain('class="mercury-palette mercury-foo-palette loading"')
|
20
18
|
expect(html).toContain('style="display:none"')
|
21
19
|
|
22
20
|
it "appends to any element", ->
|
23
|
-
@palette = new Mercury.Palette('/
|
21
|
+
@palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: '#palette_container', for: $('#button')})
|
24
22
|
expect($('#palette_container .mercury-palette').length).toEqual(1)
|
25
23
|
|
26
24
|
|
27
25
|
describe "observed events", ->
|
28
26
|
|
29
27
|
beforeEach ->
|
30
|
-
@palette = new Mercury.Palette('/
|
28
|
+
@palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
|
31
29
|
|
32
30
|
it "hides", ->
|
33
31
|
@palette.element.css({display: 'block'})
|
@@ -43,7 +41,7 @@ describe "Mercury.Palette", ->
|
|
43
41
|
describe "#position", ->
|
44
42
|
|
45
43
|
beforeEach ->
|
46
|
-
@palette = new Mercury.Palette('/
|
44
|
+
@palette = new Mercury.Palette('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
|
47
45
|
|
48
46
|
it "positions based on it's button", ->
|
49
47
|
@palette.element.css({display: 'block'})
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require '/assets/mercury.js'
|
2
|
-
|
3
1
|
describe "Mercury.Panel", ->
|
4
2
|
|
5
3
|
template 'mercury/panel.html'
|
@@ -7,9 +5,12 @@ describe "Mercury.Panel", ->
|
|
7
5
|
beforeEach ->
|
8
6
|
Mercury.displayRect = {top: 20, left: 20, width: 200, height: 200}
|
9
7
|
$.fx.off = true
|
8
|
+
Mercury.determinedLocale =
|
9
|
+
top: {'hello world!': 'bork! bork!'}
|
10
|
+
sub: {'foo': 'Bork!'}
|
10
11
|
|
11
12
|
afterEach ->
|
12
|
-
|
13
|
+
Mercury.config.localization.enabled = false
|
13
14
|
delete(@panel)
|
14
15
|
$(window).unbind('mercury:resize')
|
15
16
|
$(window).unbind('mercury:hide:panels')
|
@@ -22,16 +23,23 @@ describe "Mercury.Panel", ->
|
|
22
23
|
expect(html).toContain('class="mercury-panel loading"')
|
23
24
|
expect(html).toContain('style="display:none;"')
|
24
25
|
expect(html).toContain('<h1>foo panel</h1><div class="mercury-panel-pane"></div>')
|
26
|
+
expect(html).not.toContain('class="mercury-panel-close"')
|
25
27
|
|
26
28
|
it "appends to any element", ->
|
27
29
|
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#panel_container', title: 'foo panel'})
|
28
30
|
expect($('#panel_container .mercury-panel').length).toEqual(1)
|
29
31
|
|
32
|
+
it "creates a close button if it should", ->
|
33
|
+
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel', closeButton: true})
|
34
|
+
html = $('<div>').html(@panel.element).html()
|
35
|
+
expect(html).toContain('class="mercury-panel-close"')
|
36
|
+
expect(@panel.element.find('.mercury-panel-close').css('opacity')).toEqual('0')
|
37
|
+
|
30
38
|
|
31
39
|
describe "observed events", ->
|
32
40
|
|
33
41
|
beforeEach ->
|
34
|
-
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel', for: $('#button')})
|
42
|
+
@panel = new Mercury.Panel('/evergreen/resources/panel.html', 'foo', {appendTo: '#test', title: 'foo panel', for: $('#button'), closeButton: true})
|
35
43
|
|
36
44
|
describe "custom event: resize", ->
|
37
45
|
|
@@ -52,6 +60,27 @@ describe "Mercury.Panel", ->
|
|
52
60
|
Mercury.trigger('hide:panels', @panel)
|
53
61
|
expect(@panel.element.css('display')).toEqual('block')
|
54
62
|
|
63
|
+
describe "ajax:beforeSend", ->
|
64
|
+
|
65
|
+
it "sets a success that will load the contents of the response", ->
|
66
|
+
options = {}
|
67
|
+
loadContentSpy = spyOn(Mercury.Panel.prototype, 'loadContent').andCallFake(=>)
|
68
|
+
resizeSpy = spyOn(Mercury.Panel.prototype, 'resize').andCallFake(=>)
|
69
|
+
@panel.element.trigger('ajax:beforeSend', [null, options])
|
70
|
+
expect(options.success).toBeDefined()
|
71
|
+
options.success('new content')
|
72
|
+
expect(loadContentSpy.callCount).toEqual(1)
|
73
|
+
expect(loadContentSpy.argsForCall[0]).toEqual(['new content'])
|
74
|
+
expect(resizeSpy.callCount).toEqual(1)
|
75
|
+
|
76
|
+
describe "clicking on the close button", ->
|
77
|
+
|
78
|
+
it "calls hide:panels", ->
|
79
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
80
|
+
jasmine.simulate.click(@panel.element.find('.mercury-panel-close').get(0))
|
81
|
+
expect(spy.callCount).toEqual(1)
|
82
|
+
expect(spy.argsForCall[0]).toEqual(['hide:panels'])
|
83
|
+
|
55
84
|
|
56
85
|
describe "#show", ->
|
57
86
|
|
@@ -128,12 +157,21 @@ describe "Mercury.Panel", ->
|
|
128
157
|
expect(@panel.element.hasClass('loading')).toEqual(false)
|
129
158
|
|
130
159
|
it "sets the element html to be the data passed to it", ->
|
131
|
-
@panel.loadContent('hello world
|
160
|
+
@panel.loadContent('<span>hello world!</span>')
|
161
|
+
html = @panel.element.html()
|
162
|
+
expect(html).toContain('<h1>foo panel</h1>')
|
163
|
+
expect(html).toContain('class="mercury-panel-pane"')
|
164
|
+
expect(html).toContain('style="visibility: hidden;')
|
165
|
+
expect(html).toContain('hello world!')
|
166
|
+
|
167
|
+
it "sets the element html to be the data passed to it", ->
|
168
|
+
Mercury.config.localization.enabled = true
|
169
|
+
@panel.loadContent('<span>hello world!</span>')
|
132
170
|
html = @panel.element.html()
|
133
171
|
expect(html).toContain('<h1>foo panel</h1>')
|
134
172
|
expect(html).toContain('class="mercury-panel-pane"')
|
135
173
|
expect(html).toContain('style="visibility: hidden;')
|
136
|
-
expect(html).toContain('
|
174
|
+
expect(html).toContain('bork! bork!')
|
137
175
|
|
138
176
|
|
139
177
|
describe "#makesDraggable", ->
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require '/assets/mercury.js'
|
2
|
-
|
3
1
|
describe "Mercury.Region", ->
|
4
2
|
|
5
3
|
template 'mercury/region.html'
|
6
4
|
|
7
5
|
beforeEach ->
|
8
|
-
Mercury.config.
|
6
|
+
Mercury.config.regions.className = 'custom-region-class'
|
7
|
+
Mercury.config.regions.dataAttributes = []
|
9
8
|
|
10
9
|
afterEach ->
|
11
10
|
@region = null
|
@@ -34,6 +33,11 @@ describe "Mercury.Region", ->
|
|
34
33
|
expect(@region.name).toEqual('region')
|
35
34
|
expect(@region.history).toBeDefined()
|
36
35
|
|
36
|
+
it "sets name based on configuration", ->
|
37
|
+
Mercury.config.regions.identifier = 'data-scope'
|
38
|
+
@region = new Mercury.Region($('#region'), window, {foo: 'bar'})
|
39
|
+
expect(@region.name).toEqual('scope')
|
40
|
+
|
37
41
|
it "calls build", ->
|
38
42
|
@region = new Mercury.Region($('#region'), window, {foo: 'bar'})
|
39
43
|
expect(@buildSpy.callCount).toEqual(1)
|
@@ -46,6 +50,10 @@ describe "Mercury.Region", ->
|
|
46
50
|
@region = new Mercury.Region($('#region'), window, {foo: 'bar'})
|
47
51
|
expect(@pushHistorySpy.callCount).toEqual(1)
|
48
52
|
|
53
|
+
it "sets the instance of the region into data for the element", ->
|
54
|
+
@region = new Mercury.Region($('#region'), window, {foo: 'bar'})
|
55
|
+
expect(@region.element.data('region')).toEqual(@region)
|
56
|
+
|
49
57
|
|
50
58
|
describe "#build", ->
|
51
59
|
|
@@ -252,13 +260,39 @@ describe "Mercury.Region", ->
|
|
252
260
|
it "does nothing and is there as an interface", ->
|
253
261
|
|
254
262
|
|
263
|
+
describe "#dataAttributes", ->
|
264
|
+
|
265
|
+
beforeEach ->
|
266
|
+
Mercury.config.regions.dataAttributes = ['scope', 'version']
|
267
|
+
@region = new Mercury.Region($('#region'), window)
|
268
|
+
|
269
|
+
it "returns an object of data attributes based on configuration", ->
|
270
|
+
@region.element.attr('data-version', 2)
|
271
|
+
expect(@region.dataAttributes()).toEqual({scope: 'scope', version: '2'})
|
272
|
+
|
273
|
+
|
255
274
|
describe "#serialize", ->
|
256
275
|
|
257
276
|
beforeEach ->
|
258
277
|
@region = new Mercury.Region($('#region'), window)
|
259
278
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
279
|
+
describe "without data attributes configured", ->
|
280
|
+
|
281
|
+
it "returns an object with it's type, value, and snippets", ->
|
282
|
+
serialized = @region.serialize()
|
283
|
+
expect(serialized.type).toEqual('region')
|
284
|
+
expect(serialized.value).toEqual('contents')
|
285
|
+
expect(serialized.snippets).toEqual({})
|
286
|
+
expect(serialized.data).toEqual({})
|
287
|
+
|
288
|
+
describe "with data attributes configured", ->
|
289
|
+
|
290
|
+
beforeEach ->
|
291
|
+
Mercury.config.regions.dataAttributes = ['scope', 'version']
|
292
|
+
|
293
|
+
it "returns an object with it's type, value, data and snippets", ->
|
294
|
+
serialized = @region.serialize()
|
295
|
+
expect(serialized.type).toEqual('region')
|
296
|
+
expect(serialized.value).toEqual('contents')
|
297
|
+
expect(serialized.snippets).toEqual({})
|
298
|
+
expect(serialized.data).toEqual({scope: 'scope', version: '1'})
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require '/assets/mercury.js'
|
2
|
-
|
3
1
|
describe "Mercury.Regions.Snippetable", ->
|
4
2
|
|
5
3
|
template 'mercury/regions/snippetable.html'
|
@@ -166,13 +164,13 @@ describe "Mercury.Regions.Snippetable", ->
|
|
166
164
|
|
167
165
|
describe "dragover", ->
|
168
166
|
|
169
|
-
#
|
167
|
+
# untestable
|
170
168
|
it "prevents the default event", ->
|
171
169
|
it "does nothing if previewing", ->
|
172
170
|
|
173
171
|
describe "drop", ->
|
174
172
|
|
175
|
-
#
|
173
|
+
# untestable
|
176
174
|
it "calls focus", ->
|
177
175
|
it "prevents the default event", ->
|
178
176
|
it "displays the options for the snippet that was dropped", ->
|
@@ -264,7 +262,7 @@ describe "Mercury.Regions.Snippetable", ->
|
|
264
262
|
|
265
263
|
it "pushes to the history after dragging", ->
|
266
264
|
spy = spyOn(Mercury.Regions.Snippetable.prototype, 'pushHistory').andCallFake(=>)
|
267
|
-
spyOn(window, 'setTimeout').andCallFake((callback)=> callback())
|
265
|
+
spyOn(window, 'setTimeout').andCallFake((timeout, callback)=> callback())
|
268
266
|
@sortableSpy.andCallFake((arg) => if arg == 'destroy' then return @region.element else arg.stop())
|
269
267
|
@region.makeSortable()
|
270
268
|
expect(spy.callCount).toEqual(1)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require '/assets/mercury.js'
|
2
|
-
|
3
1
|
describe "Mercury.Select", ->
|
4
2
|
|
5
3
|
template 'mercury/select.html'
|
@@ -14,20 +12,20 @@ describe "Mercury.Select", ->
|
|
14
12
|
describe "#build", ->
|
15
13
|
|
16
14
|
it "builds an element", ->
|
17
|
-
@select = new Mercury.Select('/
|
15
|
+
@select = new Mercury.Select('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
|
18
16
|
html = $('<div>').html(@select.element).html()
|
19
17
|
expect(html).toContain('class="mercury-select mercury-foo-select loading"')
|
20
18
|
expect(html).toContain('style="display:none"')
|
21
19
|
|
22
20
|
it "appends to any element", ->
|
23
|
-
@select = new Mercury.Select('/
|
21
|
+
@select = new Mercury.Select('/blank.html', 'foo', {appendTo: '#select_container', for: $('#button')})
|
24
22
|
expect($('#select_container .mercury-select').length).toEqual(1)
|
25
23
|
|
26
24
|
|
27
25
|
describe "observed events", ->
|
28
26
|
|
29
27
|
beforeEach ->
|
30
|
-
@select = new Mercury.Select('/
|
28
|
+
@select = new Mercury.Select('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
|
31
29
|
|
32
30
|
it "hides", ->
|
33
31
|
@select.element.css({display: 'block'})
|
@@ -43,7 +41,7 @@ describe "Mercury.Select", ->
|
|
43
41
|
describe "#position", ->
|
44
42
|
|
45
43
|
beforeEach ->
|
46
|
-
@select = new Mercury.Select('/
|
44
|
+
@select = new Mercury.Select('/blank.html', 'foo', {appendTo: '#test', for: $('#button')})
|
47
45
|
|
48
46
|
it "positions based on it's button", ->
|
49
47
|
@select.element.css({display: 'block'})
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require '/assets/mercury.js'
|
2
|
-
|
3
1
|
describe "Mercury.Snippet", ->
|
4
2
|
|
5
3
|
template 'mercury/snippet.html'
|
@@ -44,7 +42,6 @@ describe "Mercury.Snippet", ->
|
|
44
42
|
|
45
43
|
it "sets the default content to the identity", ->
|
46
44
|
ret = @snippet.getHTML($(document))
|
47
|
-
html = $('<div>').html(ret).html()
|
48
45
|
expect(ret.html()).toEqual('[identity]')
|
49
46
|
|
50
47
|
it "calls loadPreview", ->
|
@@ -74,11 +71,13 @@ describe "Mercury.Snippet", ->
|
|
74
71
|
|
75
72
|
it "makes an ajax request", ->
|
76
73
|
@ajaxSpy.andCallFake(=>)
|
74
|
+
spyOn(Mercury, 'ajaxHeaders').andCallFake(=> {'X-CSRFToken': 'f00'})
|
77
75
|
@snippet.loadPreview()
|
78
76
|
expect(@ajaxSpy.callCount).toEqual(1)
|
79
77
|
expect(@ajaxSpy.argsForCall[0][0]).toEqual("/mercury/snippets/foo/preview.html")
|
80
78
|
expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual({foo: 'bar'})
|
81
79
|
expect(@ajaxSpy.argsForCall[0][1]['type']).toEqual('POST')
|
80
|
+
expect(@ajaxSpy.argsForCall[0][1]['headers']).toEqual({'X-CSRFToken': 'f00'})
|
82
81
|
|
83
82
|
describe "ajax success", ->
|
84
83
|
|
@@ -108,7 +107,7 @@ describe "Mercury.Snippet", ->
|
|
108
107
|
spy = spyOn(window, 'alert').andCallFake(=>)
|
109
108
|
@snippet.loadPreview($('#snippet'))
|
110
109
|
expect(spy.callCount).toEqual(1)
|
111
|
-
expect(spy.argsForCall[0]).toEqual(['Error loading the preview for the foo snippet.'])
|
110
|
+
expect(spy.argsForCall[0]).toEqual(['Error loading the preview for the "foo" snippet.'])
|
112
111
|
|
113
112
|
|
114
113
|
describe "#displayOptions", ->
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require '/assets/mercury.js'
|
2
|
-
|
3
1
|
describe "Mercury.SnippetToolbar", ->
|
4
2
|
|
5
3
|
template 'mercury/snippet_toolbar.html'
|
@@ -176,11 +174,11 @@ describe "Mercury.SnippetToolbar", ->
|
|
176
174
|
expect(@setTimeoutSpy.callCount).toEqual(1)
|
177
175
|
|
178
176
|
it "hides the element", ->
|
179
|
-
@setTimeoutSpy.andCallFake((callback) => callback())
|
177
|
+
@setTimeoutSpy.andCallFake((timeout, callback) => callback())
|
180
178
|
@snippetToolbar.hide()
|
181
179
|
expect(@snippetToolbar.element.css('display')).toEqual('none')
|
182
180
|
|
183
181
|
it "sets visible", ->
|
184
|
-
@setTimeoutSpy.andCallFake((callback) => callback())
|
182
|
+
@setTimeoutSpy.andCallFake((timeout, callback) => callback())
|
185
183
|
@snippetToolbar.hide()
|
186
184
|
expect(@snippetToolbar.visible).toEqual(false)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require '/assets/mercury.js'
|
2
|
-
|
3
1
|
describe "Mercury.tableEditor", ->
|
4
2
|
|
5
3
|
template 'mercury/table_editor.html'
|
@@ -30,8 +28,8 @@ describe "Mercury.tableEditor", ->
|
|
30
28
|
expect(Mercury.tableEditor.cell).toEqual(@cell)
|
31
29
|
|
32
30
|
it "accepts content that will be placed inside cells", ->
|
33
|
-
Mercury.tableEditor(@table, @cell, '
|
34
|
-
expect(Mercury.tableEditor.cellContent).toEqual('
|
31
|
+
Mercury.tableEditor(@table, @cell, '<br/>')
|
32
|
+
expect(Mercury.tableEditor.cellContent).toEqual('<br/>')
|
35
33
|
|
36
34
|
it "sets row based on where the cell is", ->
|
37
35
|
Mercury.tableEditor(@table, @cell)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require '/assets/mercury.js'
|
2
|
-
|
3
1
|
describe "Mercury.Toolbar.Button", ->
|
4
2
|
|
5
3
|
template 'mercury/toolbar.button.html'
|
@@ -12,6 +10,7 @@ describe "Mercury.Toolbar.Button", ->
|
|
12
10
|
element: $('<div class="mercury-region">')
|
13
11
|
currentElement: -> $('<div>')
|
14
12
|
}
|
13
|
+
Mercury.preloadedViews['/nothing'] = 'nothing'
|
15
14
|
|
16
15
|
afterEach ->
|
17
16
|
@button = null
|
@@ -68,7 +67,7 @@ describe "Mercury.Toolbar.Button", ->
|
|
68
67
|
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
69
68
|
|
70
69
|
jasmine.simulate.click(@button.get(0))
|
71
|
-
expect(spy.callCount).toEqual(
|
70
|
+
expect(spy.callCount).toEqual(1)
|
72
71
|
expect(spy.argsForCall[0]).toEqual(['mode', {mode: 'foo'}])
|
73
72
|
|
74
73
|
it "builds buttons that understand context", ->
|
@@ -79,7 +78,7 @@ describe "Mercury.Toolbar.Button", ->
|
|
79
78
|
expect(@button.hasClass('active')).toEqual(true)
|
80
79
|
|
81
80
|
it "builds panel buttons (and assigns toggle)", ->
|
82
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {panel: '/
|
81
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {panel: '/blank.html'}, {appendDialogsTo: $('#test')})
|
83
82
|
expect($('#test .mercury-panel').length).toEqual(1)
|
84
83
|
|
85
84
|
jasmine.simulate.click(@button.get(0))
|
@@ -89,21 +88,25 @@ describe "Mercury.Toolbar.Button", ->
|
|
89
88
|
expect(@button.hasClass('pressed')).toEqual(false)
|
90
89
|
|
91
90
|
it "builds palette buttons", ->
|
92
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {palette: '/
|
91
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {palette: '/blank.html'}, {appendDialogsTo: $('#test')})
|
93
92
|
expect($('#test .mercury-palette').length).toEqual(1)
|
94
93
|
|
95
94
|
it "builds select buttons", ->
|
96
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {select: '/
|
95
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {select: '/blank.html'}, {appendDialogsTo: $('#test')})
|
97
96
|
expect($('#test .mercury-select').length).toEqual(1)
|
98
97
|
|
99
98
|
it "builds modal buttons", ->
|
100
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {modal: '/
|
99
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {modal: '/blank.html'}, {appendDialogsTo: $('#test')})
|
101
100
|
# nothing unique about this in building -- the modal is built/fired on click
|
102
101
|
|
102
|
+
it "builds lightview buttons", ->
|
103
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {lightview: '/blank.html'}, {appendDialogsTo: $('#test')})
|
104
|
+
# nothing unique about this in building -- the lightview is built/fired on click
|
105
|
+
|
103
106
|
it "throws an error when an unknown type is encountered", ->
|
104
107
|
expect(=>
|
105
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {foo: '/
|
106
|
-
).toThrow('Unknown button type foo used for the foo button.')
|
108
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {foo: '/blank.html'})
|
109
|
+
).toThrow('Unknown button type "foo" used for the "foo" button.')
|
107
110
|
|
108
111
|
|
109
112
|
describe "observed events", ->
|
@@ -117,6 +120,15 @@ describe "Mercury.Toolbar.Button", ->
|
|
117
120
|
Mercury.trigger('button', {action: 'foo'})
|
118
121
|
expect(spy.callCount).toEqual(1)
|
119
122
|
|
123
|
+
describe "custom event: mode", ->
|
124
|
+
|
125
|
+
it "toggles a button when that mode is triggered and the button is toggleable", ->
|
126
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {mode: 'preview', toggle: true})
|
127
|
+
spy = spyOn(Mercury.Toolbar.Button.prototype, 'togglePressed').andCallFake(=>)
|
128
|
+
|
129
|
+
Mercury.trigger('mode', {mode: 'preview'})
|
130
|
+
expect(spy.callCount).toEqual(1)
|
131
|
+
|
120
132
|
describe "custom event: region:update", ->
|
121
133
|
|
122
134
|
it "calls contexts if one is available and set", ->
|
@@ -191,7 +203,7 @@ describe "Mercury.Toolbar.Button", ->
|
|
191
203
|
|
192
204
|
it "triggers a focus:frame event", ->
|
193
205
|
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
194
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary')
|
206
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {}, {regions: ['editable']})
|
195
207
|
|
196
208
|
jasmine.simulate.click(@button.get(0))
|
197
209
|
expect(spy.argsForCall[1]).toEqual(['focus:frame'])
|
@@ -214,14 +226,21 @@ describe "Mercury.Toolbar.Button", ->
|
|
214
226
|
|
215
227
|
it "opens a modal window", ->
|
216
228
|
spy = spyOn(Mercury, 'modal').andCallFake(=>)
|
217
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {modal: '/
|
229
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {modal: '/blank.html'})
|
230
|
+
|
231
|
+
jasmine.simulate.click(@button.get(0))
|
232
|
+
expect(spy.argsForCall[0]).toEqual(['/blank.html', {title: 'summary', handler: 'foo'}])
|
233
|
+
|
234
|
+
it "opens a lightview window", ->
|
235
|
+
spy = spyOn(Mercury, 'lightview').andCallFake(=>)
|
236
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {lightview: '/blank.html'})
|
218
237
|
|
219
238
|
jasmine.simulate.click(@button.get(0))
|
220
|
-
expect(spy.argsForCall[0]).toEqual(['/
|
239
|
+
expect(spy.argsForCall[0]).toEqual(['/blank.html', {title: 'summary', handler: 'foo', closeButton: true}])
|
221
240
|
|
222
241
|
it "shows and hides palettes", ->
|
223
242
|
spy = spyOn(Mercury.Palette.prototype, 'toggle').andCallFake(=>)
|
224
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {palette: '/
|
243
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {palette: '/blank.html'})
|
225
244
|
|
226
245
|
jasmine.simulate.click(@button.get(0))
|
227
246
|
expect(spy.callCount).toEqual(1)
|
@@ -231,7 +250,7 @@ describe "Mercury.Toolbar.Button", ->
|
|
231
250
|
|
232
251
|
it "shows and hides selects", ->
|
233
252
|
spy = spyOn(Mercury.Select.prototype, 'toggle').andCallFake(=>)
|
234
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {select: '/
|
253
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {select: '/blank.html'})
|
235
254
|
|
236
255
|
jasmine.simulate.click(@button.get(0))
|
237
256
|
expect(spy.callCount).toEqual(1)
|
@@ -241,7 +260,7 @@ describe "Mercury.Toolbar.Button", ->
|
|
241
260
|
|
242
261
|
it "shows and hides panels, and toggles the button pressed state", ->
|
243
262
|
spy = spyOn(Mercury.Panel.prototype, 'toggle').andCallFake(=>)
|
244
|
-
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {panel: '/
|
263
|
+
@button = new Mercury.Toolbar.Button('foo', 'title', 'summary', {panel: '/blank.html'})
|
245
264
|
|
246
265
|
jasmine.simulate.click(@button.get(0))
|
247
266
|
expect(spy.callCount).toEqual(1)
|