mercury-rails 0.2.0 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/POST_INSTALL +15 -0
- data/README.md +27 -6
- data/VERSION +1 -1
- data/app/controllers/mercury_controller.rb +4 -4
- data/app/views/layouts/mercury.html.erb +14 -3
- data/app/views/mercury/panels/snippets.html +1 -1
- data/app/views/mercury/snippets/{example_options.html.erb → example/options.html.erb} +0 -0
- data/app/views/mercury/snippets/{example.html.erb → example/preview.html.erb} +0 -0
- data/config/routes.rb +2 -2
- 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 +103 -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 +2 -2
- data/features/step_definitions/mercury_steps.rb +441 -0
- data/features/support/env.rb +3 -3
- data/features/support/mercury_contents.rb +25 -0
- data/features/support/mercury_selectors.rb +147 -0
- data/features/support/paths.rb +20 -18
- data/features/support/selectors.rb +5 -3
- data/lib/generators/mercury/install/install_generator.rb +14 -0
- data/mercury-rails.gemspec +50 -20
- data/spec/javascripts/mercury/lightview_spec.js.coffee +55 -27
- data/spec/javascripts/mercury/mercury_spec.js.coffee +3 -3
- data/spec/javascripts/mercury/modal_spec.js.coffee +2 -2
- data/spec/javascripts/mercury/native_extensions_spec.js.coffee +0 -24
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +148 -67
- data/spec/javascripts/mercury/panel_spec.js.coffee +2 -2
- data/spec/javascripts/mercury/region_spec.js.coffee +10 -7
- data/spec/javascripts/mercury/regions/editable_spec.js.coffee +0 -20
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +2 -2
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +1 -1
- data/spec/javascripts/templates/mercury/page_editor.html +3 -3
- data/vendor/assets/images/mercury/close.png +0 -0
- data/vendor/assets/javascripts/mercury.js +140 -73
- data/vendor/assets/javascripts/{mercury_dependencies → mercury/dependencies}/jquery-1.6.js +0 -0
- data/vendor/assets/javascripts/{mercury_dependencies → mercury/dependencies}/jquery-ui-1.8.13.custom.js +0 -0
- data/vendor/assets/javascripts/{mercury_dependencies → mercury/dependencies}/jquery.additions.js +0 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +527 -0
- data/vendor/assets/javascripts/{mercury_dependencies → mercury/dependencies}/liquidmetal.js +0 -0
- data/vendor/assets/javascripts/{mercury_dependencies → mercury/dependencies}/showdown.js +0 -0
- data/vendor/assets/javascripts/mercury/lightview.js.coffee +5 -2
- data/vendor/assets/javascripts/mercury/mercury.js.coffee +9 -8
- data/vendor/assets/javascripts/mercury/modals/htmleditor.js.coffee +3 -1
- data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +2 -2
- data/vendor/assets/javascripts/mercury/native_extensions.js.coffee +6 -17
- data/vendor/assets/javascripts/mercury/page_editor.js.coffee +29 -8
- data/vendor/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +27 -0
- data/vendor/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +9 -0
- data/vendor/assets/javascripts/mercury/region.js.coffee +2 -2
- data/vendor/assets/javascripts/mercury/regions/editable.js.coffee +89 -93
- data/vendor/assets/javascripts/mercury/regions/markupable.js.coffee +1 -1
- data/vendor/assets/javascripts/mercury/support/history.js +1 -0
- data/vendor/assets/javascripts/mercury/uploader.js.coffee +0 -1
- data/vendor/assets/javascripts/mercury_loader.js +4 -4
- data/vendor/assets/stylesheets/mercury/lightview.css +8 -0
- data/vendor/assets/stylesheets/mercury/mercury.css +12 -0
- data/vendor/assets/stylesheets/mercury/modal.css +0 -12
- data/vendor/assets/stylesheets/mercury/toolbar.css +1 -0
- data/vendor/assets/stylesheets/mercury_overrides.css +17 -0
- metadata +73 -45
- data/app/views/mercury/lightviews/imageprocessor.html +0 -3
- data/app/views/mercury/modals/sanitizer.html +0 -9
- data/features/editing/basic.feature +0 -11
- data/vendor/assets/images/mercury/clippy.png +0 -0
@@ -12,16 +12,16 @@ describe "Mercury", ->
|
|
12
12
|
|
13
13
|
describe "#bind", ->
|
14
14
|
|
15
|
-
it "binds an event prefixed with 'mercury:' to
|
15
|
+
it "binds an event prefixed with 'mercury:' to the top window", ->
|
16
16
|
callCount = 0
|
17
17
|
Mercury.bind('test', -> callCount += 1)
|
18
|
-
$(
|
18
|
+
$(top).trigger("mercury:test")
|
19
19
|
expect(callCount).toEqual(1)
|
20
20
|
|
21
21
|
|
22
22
|
describe "#trigger", ->
|
23
23
|
|
24
|
-
it "triggers an event prefixed with 'mercury:' on
|
24
|
+
it "triggers an event prefixed with 'mercury:' on the top window", ->
|
25
25
|
argsForCall = []
|
26
26
|
callCount = 0
|
27
27
|
Mercury.bind('test', -> argsForCall[callCount] = arguments; callCount += 1)
|
@@ -11,8 +11,8 @@ describe "Mercury.modal", ->
|
|
11
11
|
afterEach ->
|
12
12
|
Mercury.modal.initialized = false
|
13
13
|
Mercury.modal.visible = false
|
14
|
-
$(
|
15
|
-
$(
|
14
|
+
$(window).unbind('mercury:refresh')
|
15
|
+
$(window).unbind('mercury:resize')
|
16
16
|
$(document).unbind('keydown')
|
17
17
|
|
18
18
|
describe "singleton method", ->
|
@@ -15,30 +15,6 @@ describe "String", ->
|
|
15
15
|
expect('rgb(255, 255, 0)'.toHex()).toEqual('#FFFF00')
|
16
16
|
|
17
17
|
|
18
|
-
describe "#singleDiff", ->
|
19
|
-
|
20
|
-
it "takes a string to compare against, and returns the first diff it comes to", ->
|
21
|
-
expect('abcdefg'.singleDiff('ab[diff]cdefg')).toEqual('[diff]')
|
22
|
-
expect('abcd/e\\f.g'.singleDiff('ab[diff]cd/e\\f.g')).toEqual('[diff]')
|
23
|
-
|
24
|
-
|
25
|
-
describe "#regExpEscape", ->
|
26
|
-
|
27
|
-
it "escapes characters used in regular expressions", ->
|
28
|
-
expect('/.*+?|()[]{}\\'.regExpEscape()).toEqual('\\/\\.\\*\\+\\?\\|\\(\\)\\[\\]\\{\\}\\\\')
|
29
|
-
|
30
|
-
describe "#sanitizeHTML", ->
|
31
|
-
|
32
|
-
it "removes style tags", ->
|
33
|
-
expect('123<style></style>456'.sanitizeHTML()).toEqual('123456')
|
34
|
-
|
35
|
-
it "removes comment tags", ->
|
36
|
-
expect('123<!--this is a comment-->456'.sanitizeHTML()).toEqual('123456')
|
37
|
-
|
38
|
-
it "replaces new lines with br tags", ->
|
39
|
-
expect('123\n456'.sanitizeHTML()).toEqual('123<br/>456')
|
40
|
-
|
41
|
-
|
42
18
|
describe "Number", ->
|
43
19
|
|
44
20
|
describe "#toHex", ->
|
@@ -4,17 +4,20 @@ describe "Mercury.PageEditor", ->
|
|
4
4
|
|
5
5
|
template 'mercury/page_editor.html'
|
6
6
|
|
7
|
+
beforeEach ->
|
8
|
+
Mercury.config.regionClass = 'custom-region-class'
|
9
|
+
|
7
10
|
afterEach ->
|
8
11
|
@pageEditor = null
|
9
12
|
delete(@pageEditor)
|
10
13
|
window.mercuryInstance = null
|
11
|
-
$(
|
12
|
-
$(
|
13
|
-
$(
|
14
|
-
$(
|
15
|
-
$(
|
16
|
-
$(document).unbind('mousedown')
|
14
|
+
$(window).unbind('mercury:initialize:frame')
|
15
|
+
$(window).unbind('mercury:focus:frame')
|
16
|
+
$(window).unbind('mercury:focus:window')
|
17
|
+
$(window).unbind('mercury:toggle:interface')
|
18
|
+
$(window).unbind('mercury:action')
|
17
19
|
$(window).unbind('resize')
|
20
|
+
$(document).unbind('mousedown')
|
18
21
|
|
19
22
|
describe "constructor", ->
|
20
23
|
|
@@ -76,7 +79,7 @@ describe "Mercury.PageEditor", ->
|
|
76
79
|
|
77
80
|
it "builds a focusable element (so we can get focus off the iframe)", ->
|
78
81
|
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
79
|
-
expect($('input[type=text]').length).toEqual(1)
|
82
|
+
expect($('input.mercury-focusable[type=text]').length).toEqual(1)
|
80
83
|
|
81
84
|
it "builds an iframe", ->
|
82
85
|
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
@@ -130,7 +133,13 @@ describe "Mercury.PageEditor", ->
|
|
130
133
|
it "injects mercury namespace into the iframe", ->
|
131
134
|
@finalizeInterfaceSpy.andCallFake(=>)
|
132
135
|
@pageEditor.initializeFrame()
|
133
|
-
expect(@pageEditor.iframe.get(0).contentWindow.Mercury).toEqual(Mercury)
|
136
|
+
expect(@pageEditor.iframe.get(0).contentWindow.Mercury).toEqual(window.Mercury)
|
137
|
+
|
138
|
+
it "provides the iframe with History (history.js)", ->
|
139
|
+
@finalizeInterfaceSpy.andCallFake(=>)
|
140
|
+
window.History = {Adapter: 'foo'}
|
141
|
+
@pageEditor.initializeFrame()
|
142
|
+
expect(@pageEditor.iframe.get(0).contentWindow.History).toEqual(window.History)
|
134
143
|
|
135
144
|
it "calls bindEvents", ->
|
136
145
|
@finalizeInterfaceSpy.andCallFake(=>)
|
@@ -152,13 +161,37 @@ describe "Mercury.PageEditor", ->
|
|
152
161
|
@pageEditor.initializeFrame()
|
153
162
|
expect(@finalizeInterfaceSpy.callCount).toEqual(1)
|
154
163
|
|
155
|
-
it "fires the ready event", ->
|
164
|
+
it "fires the ready event (Mercury.trigger)", ->
|
156
165
|
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
157
166
|
@finalizeInterfaceSpy.andCallFake(=>)
|
158
167
|
@pageEditor.initializeFrame()
|
159
168
|
expect(spy.callCount).toEqual(1)
|
160
169
|
expect(spy.argsForCall[0]).toEqual(['ready'])
|
161
170
|
|
171
|
+
it "fires the ready event (jQuery.trigger)", ->
|
172
|
+
spy = spyOn(jQuery.fn, 'trigger').andCallFake(=>)
|
173
|
+
@finalizeInterfaceSpy.andCallFake(=>)
|
174
|
+
@pageEditor.initializeFrame()
|
175
|
+
expect(spy.callCount).toEqual(2)
|
176
|
+
expect(spy.argsForCall[0]).toEqual(['mercury:ready', undefined])
|
177
|
+
|
178
|
+
it "fires the ready event (Event.fire)", ->
|
179
|
+
@finalizeInterfaceSpy.andCallFake(=>)
|
180
|
+
iframeWindow = @pageEditor.iframe.get(0).contentWindow
|
181
|
+
iframeWindow.Event = {fire: ->}
|
182
|
+
spy = spyOn(iframeWindow.Event, 'fire').andCallFake(=>)
|
183
|
+
@pageEditor.initializeFrame()
|
184
|
+
expect(spy.callCount).toEqual(1)
|
185
|
+
expect(spy.argsForCall[0][1]).toEqual('mercury:ready')
|
186
|
+
|
187
|
+
it "calls onMercuryReady in the iframe", ->
|
188
|
+
@finalizeInterfaceSpy.andCallFake(=>)
|
189
|
+
iframeWindow = @pageEditor.iframe.get(0).contentWindow
|
190
|
+
iframeWindow.onMercuryReady = ->
|
191
|
+
spy = spyOn(iframeWindow, 'onMercuryReady').andCallFake(=>)
|
192
|
+
@pageEditor.initializeFrame()
|
193
|
+
expect(spy.callCount).toEqual(1)
|
194
|
+
|
162
195
|
it "shows the iframe", ->
|
163
196
|
@pageEditor.iframe.css({visibility: 'visible'})
|
164
197
|
@finalizeInterfaceSpy.andCallFake(=>)
|
@@ -228,7 +261,11 @@ describe "Mercury.PageEditor", ->
|
|
228
261
|
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
|
229
262
|
@highjackLinksAndFormsSpy = spyOn(Mercury.PageEditor.prototype, 'hijackLinksAndForms').andCallFake(=>)
|
230
263
|
|
231
|
-
it "
|
264
|
+
it "injects an sanitizing element used for sanitizing content", ->
|
265
|
+
@pageEditor.finalizeInterface()
|
266
|
+
expect($('#mercury_sanitizer[contenteditable]').length).toEqual(1)
|
267
|
+
|
268
|
+
it "builds a snippetToolbar", ->
|
232
269
|
@pageEditor.finalizeInterface()
|
233
270
|
expect(@pageEditor.snippetToolbar).toEqual({snippetToolbar: true})
|
234
271
|
|
@@ -403,7 +440,6 @@ describe "Mercury.PageEditor", ->
|
|
403
440
|
|
404
441
|
it "resizes the iframe", ->
|
405
442
|
@pageEditor.resize()
|
406
|
-
expect($('.mercury-iframe').css('top')).toEqual('100px')
|
407
443
|
expect($('.mercury-iframe').css('height')).toEqual("#{500 - 100}px")
|
408
444
|
|
409
445
|
it "triggers a resize event", ->
|
@@ -486,7 +522,7 @@ describe "Mercury.PageEditor", ->
|
|
486
522
|
expect(@pageEditor.beforeUnload()).toEqual(null)
|
487
523
|
|
488
524
|
|
489
|
-
describe "#
|
525
|
+
describe "#getRegionByName", ->
|
490
526
|
|
491
527
|
beforeEach ->
|
492
528
|
Mercury.PageEditor.prototype.initializeInterface = ->
|
@@ -494,69 +530,114 @@ describe "Mercury.PageEditor", ->
|
|
494
530
|
@iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
|
495
531
|
@ajaxSpy = spyOn($, 'ajax')
|
496
532
|
|
497
|
-
it "
|
498
|
-
@
|
499
|
-
@pageEditor.
|
500
|
-
expect(@
|
501
|
-
|
502
|
-
it "uses the save url passed in via options, the configured save url, or the iframe src", ->
|
503
|
-
@ajaxSpy.andCallFake(=>)
|
504
|
-
@pageEditor.saveUrl = '/foo/bar'
|
505
|
-
@pageEditor.save()
|
506
|
-
expect(@ajaxSpy.argsForCall[0][0]).toEqual('/foo/bar')
|
507
|
-
|
508
|
-
@pageEditor.saveUrl = null
|
509
|
-
Mercury.saveURL = '/foo/bit'
|
510
|
-
@pageEditor.save()
|
511
|
-
expect(@ajaxSpy.argsForCall[1][0]).toEqual('/foo/bit')
|
512
|
-
|
513
|
-
@pageEditor.saveUrl = null
|
514
|
-
Mercury.saveURL = null
|
515
|
-
@pageEditor.save()
|
516
|
-
expect(@ajaxSpy.argsForCall[2][0]).toEqual('/foo/baz')
|
517
|
-
|
518
|
-
it "serializes the data in json", ->
|
519
|
-
@ajaxSpy.andCallFake(=>)
|
520
|
-
Mercury.config.saveStyle = 'json'
|
521
|
-
spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
|
522
|
-
@pageEditor.save()
|
523
|
-
expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual({content: '{"region1":"region1"}' })
|
524
|
-
|
525
|
-
it "can serialize as form values", ->
|
526
|
-
@ajaxSpy.andCallFake(=>)
|
527
|
-
@pageEditor.options.saveStyle = 'form'
|
528
|
-
spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
|
529
|
-
@pageEditor.save()
|
530
|
-
expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual({content: {region1: 'region1'}})
|
531
|
-
|
532
|
-
it "sets headers by calling #saveHeaders", ->
|
533
|
-
@ajaxSpy.andCallFake(=>)
|
534
|
-
spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
|
535
|
-
spy = spyOn(Mercury.PageEditor.prototype, 'saveHeaders').andCallFake(=> {'X-CSRFToken': 'f00'})
|
536
|
-
@pageEditor.save()
|
537
|
-
expect(@ajaxSpy.argsForCall[0][1]['headers']).toEqual({'X-CSRFToken': 'f00'})
|
538
|
-
|
539
|
-
describe "on successful ajax request", ->
|
533
|
+
it "returns the region if a match is found", ->
|
534
|
+
@pageEditor.regions = [{name: 'foo'}, {name: 'bar'}, {name: 'baz'}]
|
535
|
+
expect(@pageEditor.getRegionByName('foo')).toEqual(@pageEditor.regions[0])
|
536
|
+
expect(@pageEditor.getRegionByName('baz')).toEqual(@pageEditor.regions[2])
|
540
537
|
|
541
|
-
|
542
|
-
|
538
|
+
it "returns null if no match was found", ->
|
539
|
+
@pageEditor.regions = [{name: 'bar'}]
|
540
|
+
expect(@pageEditor.getRegionByName('foo')).toEqual(null)
|
543
541
|
|
544
|
-
it "sets changes back to false", ->
|
545
|
-
Mercury.changes = true
|
546
|
-
@pageEditor.save()
|
547
|
-
expect(Mercury.changes).toEqual(false)
|
548
542
|
|
549
|
-
|
543
|
+
describe "#save", ->
|
550
544
|
|
545
|
+
describe "POST", ->
|
551
546
|
beforeEach ->
|
552
|
-
|
547
|
+
Mercury.PageEditor.prototype.initializeInterface = ->
|
548
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test'), saveDataType: 'text'})
|
549
|
+
@iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
|
550
|
+
@ajaxSpy = spyOn($, 'ajax')
|
551
|
+
|
552
|
+
it "doesn't set the _method in the request data", ->
|
553
|
+
@ajaxSpy.andCallFake(=>)
|
554
|
+
spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
|
555
|
+
@pageEditor.save()
|
556
|
+
expect(@ajaxSpy.argsForCall[0][1]['data']['_method']).toEqual(undefined)
|
553
557
|
|
554
|
-
it "
|
555
|
-
|
558
|
+
it "makes an ajax request", ->
|
559
|
+
@ajaxSpy.andCallFake(=>)
|
560
|
+
@pageEditor.save()
|
561
|
+
expect(@ajaxSpy.callCount).toEqual(1)
|
562
|
+
|
563
|
+
it "uses the save url passed in via options, the configured save url, or the iframe src", ->
|
564
|
+
@ajaxSpy.andCallFake(=>)
|
556
565
|
@pageEditor.saveUrl = '/foo/bar'
|
557
566
|
@pageEditor.save()
|
558
|
-
expect(
|
559
|
-
|
567
|
+
expect(@ajaxSpy.argsForCall[0][0]).toEqual('/foo/bar')
|
568
|
+
|
569
|
+
@pageEditor.saveUrl = null
|
570
|
+
Mercury.saveURL = '/foo/bit'
|
571
|
+
@pageEditor.save()
|
572
|
+
expect(@ajaxSpy.argsForCall[1][0]).toEqual('/foo/bit')
|
573
|
+
|
574
|
+
@pageEditor.saveUrl = null
|
575
|
+
Mercury.saveURL = null
|
576
|
+
@pageEditor.save()
|
577
|
+
expect(@ajaxSpy.argsForCall[2][0]).toEqual('/foo/baz')
|
578
|
+
|
579
|
+
it "serializes the data in json", ->
|
580
|
+
@ajaxSpy.andCallFake(=>)
|
581
|
+
Mercury.config.saveStyle = 'json'
|
582
|
+
spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
|
583
|
+
@pageEditor.save()
|
584
|
+
expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual({content: '{"region1":"region1"}' })
|
585
|
+
|
586
|
+
it "can serialize as form values", ->
|
587
|
+
@ajaxSpy.andCallFake(=>)
|
588
|
+
@pageEditor.options.saveStyle = 'form'
|
589
|
+
spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
|
590
|
+
@pageEditor.save()
|
591
|
+
expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual({content: {region1: 'region1'}})
|
592
|
+
|
593
|
+
it "sets headers by calling #saveHeaders", ->
|
594
|
+
@ajaxSpy.andCallFake(=>)
|
595
|
+
spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
|
596
|
+
spy = spyOn(Mercury.PageEditor.prototype, 'saveHeaders').andCallFake(=> {'X-CSRFToken': 'f00'})
|
597
|
+
@pageEditor.save()
|
598
|
+
expect(@ajaxSpy.argsForCall[0][1]['headers']).toEqual({'X-CSRFToken': 'f00'})
|
599
|
+
|
600
|
+
it "sets the data type from options", ->
|
601
|
+
@ajaxSpy.andCallFake(=>)
|
602
|
+
spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
|
603
|
+
@pageEditor.save()
|
604
|
+
expect(@ajaxSpy.argsForCall[0][1]['dataType']).toEqual('text')
|
605
|
+
|
606
|
+
describe "on successful ajax request", ->
|
607
|
+
|
608
|
+
beforeEach ->
|
609
|
+
@ajaxSpy.andCallFake((url, options) => options.success('data') )
|
610
|
+
|
611
|
+
it "sets changes back to false", ->
|
612
|
+
Mercury.changes = true
|
613
|
+
@pageEditor.save()
|
614
|
+
expect(Mercury.changes).toEqual(false)
|
615
|
+
|
616
|
+
describe "on failed ajax request", ->
|
617
|
+
|
618
|
+
beforeEach ->
|
619
|
+
@ajaxSpy.andCallFake((url, options) => options.error() )
|
620
|
+
|
621
|
+
it "alerts with the url", ->
|
622
|
+
spy = spyOn(window, 'alert').andCallFake(=>)
|
623
|
+
@pageEditor.saveUrl = '/foo/bar'
|
624
|
+
@pageEditor.save()
|
625
|
+
expect(spy.callCount).toEqual(1)
|
626
|
+
expect(spy.argsForCall[0]).toEqual(['Mercury was unable to save to the url: /foo/bar'])
|
627
|
+
|
628
|
+
describe "PUT", ->
|
629
|
+
|
630
|
+
beforeEach ->
|
631
|
+
Mercury.PageEditor.prototype.initializeInterface = ->
|
632
|
+
@pageEditor = new Mercury.PageEditor('', {appendTo: $('#test'), saveMethod: 'PUT'})
|
633
|
+
@iframeSrcSpy = spyOn(Mercury.PageEditor.prototype, 'iframeSrc').andCallFake(=> '/foo/baz')
|
634
|
+
@ajaxSpy = spyOn($, 'ajax')
|
635
|
+
|
636
|
+
it "sets the _method in the request", ->
|
637
|
+
@ajaxSpy.andCallFake(=>)
|
638
|
+
spyOn(Mercury.PageEditor.prototype, 'serialize').andCallFake(=> {region1: 'region1'})
|
639
|
+
@pageEditor.save()
|
640
|
+
expect(@ajaxSpy.argsForCall[0][1]['data']['_method']).toEqual('PUT')
|
560
641
|
|
561
642
|
|
562
643
|
describe "#serialize", ->
|
@@ -11,8 +11,8 @@ describe "Mercury.Panel", ->
|
|
11
11
|
afterEach ->
|
12
12
|
@panel = null
|
13
13
|
delete(@panel)
|
14
|
-
$(
|
15
|
-
$(
|
14
|
+
$(window).unbind('mercury:resize')
|
15
|
+
$(window).unbind('mercury:hide:panels')
|
16
16
|
|
17
17
|
describe "#build", ->
|
18
18
|
|
@@ -4,12 +4,15 @@ describe "Mercury.Region", ->
|
|
4
4
|
|
5
5
|
template 'mercury/region.html'
|
6
6
|
|
7
|
+
beforeEach ->
|
8
|
+
Mercury.config.regionClass = 'custom-region-class'
|
9
|
+
|
7
10
|
afterEach ->
|
8
11
|
@region = null
|
9
12
|
delete(@region)
|
10
|
-
$(
|
11
|
-
$(
|
12
|
-
$(
|
13
|
+
$(window).unbind('mercury:mode')
|
14
|
+
$(window).unbind('mercury:focus:frame')
|
15
|
+
$(window).unbind('mercury:action')
|
13
16
|
|
14
17
|
describe "constructor", ->
|
15
18
|
|
@@ -185,8 +188,8 @@ describe "Mercury.Region", ->
|
|
185
188
|
expect(@region.previewing).toEqual(true)
|
186
189
|
|
187
190
|
it "swaps classes on the element", ->
|
188
|
-
expect(@region.element.hasClass('
|
189
|
-
expect(@region.element.hasClass('
|
191
|
+
expect(@region.element.hasClass('custom-region-class')).toEqual(false)
|
192
|
+
expect(@region.element.hasClass('custom-region-class-preview')).toEqual(true)
|
190
193
|
|
191
194
|
it "triggers a blur event", ->
|
192
195
|
expect(@triggerSpy.callCount).toEqual(1)
|
@@ -202,8 +205,8 @@ describe "Mercury.Region", ->
|
|
202
205
|
expect(@region.previewing).toEqual(false)
|
203
206
|
|
204
207
|
it "swaps classes on the element", ->
|
205
|
-
expect(@region.element.hasClass('
|
206
|
-
expect(@region.element.hasClass('
|
208
|
+
expect(@region.element.hasClass('custom-region-class-preview')).toEqual(false)
|
209
|
+
expect(@region.element.hasClass('custom-region-class')).toEqual(true)
|
207
210
|
|
208
211
|
it "calls focus if it's the active region", ->
|
209
212
|
expect(@focusSpy.callCount).toEqual(1)
|
@@ -326,26 +326,6 @@ describe "Mercury.Regions.Editable", ->
|
|
326
326
|
|
327
327
|
describe "#handlePaste", ->
|
328
328
|
|
329
|
-
it "removes any regions that might have been pasted", ->
|
330
|
-
|
331
|
-
describe "when it looks like MS word content", ->
|
332
|
-
|
333
|
-
it "calls the native undo to remove the pasted content", ->
|
334
|
-
|
335
|
-
it "inserts the cleaned content (which is the text version of what was pasted)", ->
|
336
|
-
|
337
|
-
describe "when undo throws an exception", ->
|
338
|
-
|
339
|
-
it "sets the content to what it was before the paste", ->
|
340
|
-
|
341
|
-
it "opens a modal (featuring clippy)", ->
|
342
|
-
|
343
|
-
describe "when it's configured to strip styles", ->
|
344
|
-
|
345
|
-
it "calls the native undo to remove the pasted content", ->
|
346
|
-
|
347
|
-
it "strips style attributes from the pasted content and inserts the cleaned html", ->
|
348
|
-
|
349
329
|
|
350
330
|
|
351
331
|
describe "Mercury.Regions.Editable.actions", ->
|
@@ -10,8 +10,8 @@ describe "Mercury.SnippetToolbar", ->
|
|
10
10
|
afterEach ->
|
11
11
|
@snippetToolbar = null
|
12
12
|
delete(@snippetToolbar)
|
13
|
-
$(
|
14
|
-
$(
|
13
|
+
$(window).unbind('mercury:hide:toolbar')
|
14
|
+
$(window).unbind('mercury:show:toolbar')
|
15
15
|
|
16
16
|
describe "constructor", ->
|
17
17
|
|