mercury-rails 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/README.rdoc +81 -50
  2. data/VERSION +1 -1
  3. data/app/assets/javascripts/mercury/dialog.js.coffee +4 -4
  4. data/app/assets/javascripts/mercury/dialogs/backcolor.js.coffee +3 -3
  5. data/app/assets/javascripts/mercury/dialogs/forecolor.js.coffee +3 -3
  6. data/app/assets/javascripts/mercury/dialogs/formatblock.js.coffee +1 -1
  7. data/app/assets/javascripts/mercury/dialogs/objectspanel.js.coffee +3 -3
  8. data/app/assets/javascripts/mercury/dialogs/style.js.coffee +1 -1
  9. data/app/assets/javascripts/mercury/history_buffer.js.coffee +2 -2
  10. data/app/assets/javascripts/mercury/mercury.js.coffee +47 -54
  11. data/app/assets/javascripts/mercury/modal.js.coffee +13 -13
  12. data/app/assets/javascripts/mercury/modals/htmleditor.js.coffee +2 -2
  13. data/app/assets/javascripts/mercury/modals/insertcharacter.js.coffee +2 -2
  14. data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +7 -7
  15. data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +5 -5
  16. data/app/assets/javascripts/mercury/modals/insertsnippet.js.coffee +2 -2
  17. data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +14 -15
  18. data/app/assets/javascripts/mercury/native_extensions.js.coffee +2 -1
  19. data/app/assets/javascripts/mercury/page_editor.js.coffee +27 -27
  20. data/app/assets/javascripts/mercury/palette.js.coffee +6 -6
  21. data/app/assets/javascripts/mercury/panel.js.coffee +4 -4
  22. data/app/assets/javascripts/mercury/region.js.coffee +9 -9
  23. data/app/assets/javascripts/mercury/regions/editable.js.coffee +71 -71
  24. data/app/assets/javascripts/mercury/regions/markupable.js.coffee +51 -42
  25. data/app/assets/javascripts/mercury/regions/snippetable.js.coffee +7 -8
  26. data/app/assets/javascripts/mercury/select.js.coffee +8 -8
  27. data/app/assets/javascripts/mercury/snippet.js.coffee +6 -6
  28. data/app/assets/javascripts/mercury/snippet_toolbar.js.coffee +7 -7
  29. data/app/assets/javascripts/mercury/statusbar.js.coffee +7 -3
  30. data/app/assets/javascripts/mercury/table_editor.js.coffee +24 -24
  31. data/app/assets/javascripts/mercury/toolbar.button.js.coffee +20 -21
  32. data/app/assets/javascripts/mercury/toolbar.button_group.js.coffee +2 -2
  33. data/app/assets/javascripts/mercury/toolbar.expander.js.coffee +9 -9
  34. data/app/assets/javascripts/mercury/toolbar.js.coffee +12 -13
  35. data/app/assets/javascripts/mercury/tooltip.js.coffee +7 -7
  36. data/app/assets/javascripts/mercury/uploader.js.coffee +12 -13
  37. data/app/assets/javascripts/mercury_loader.js +98 -0
  38. data/app/assets/stylesheets/mercury/modal.scss +5 -5
  39. data/app/assets/stylesheets/mercury/toolbar.scss +62 -64
  40. data/app/views/layouts/mercury.html.haml +0 -4
  41. data/app/views/mercury/modals/character.html.haml +1 -1
  42. data/app/views/mercury/modals/htmleditor.html.haml +1 -1
  43. data/app/views/mercury/modals/table.html.haml +10 -10
  44. data/config/routes.rb +2 -2
  45. data/mercury-rails.gemspec +17 -20
  46. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +3 -3
  47. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +3 -3
  48. data/spec/javascripts/mercury/dialogs/objectspanel_spec.js.coffee +3 -3
  49. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +4 -4
  50. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +2 -2
  51. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +10 -10
  52. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +7 -7
  53. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +4 -4
  54. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +17 -17
  55. data/spec/javascripts/mercury/page_editor_spec.js.coffee +5 -6
  56. data/spec/javascripts/mercury/region_spec.js.coffee +5 -5
  57. data/spec/javascripts/mercury/regions/editable_spec.js.coffee +398 -0
  58. data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +18 -14
  59. data/spec/javascripts/mercury/snippet_spec.js.coffee +1 -1
  60. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +16 -16
  61. data/spec/javascripts/templates/mercury/modals/inserttable.html +11 -11
  62. data/spec/javascripts/templates/mercury/regions/editable.html +3 -0
  63. data/spec/javascripts/templates/mercury/toolbar.button.html +8 -8
  64. data/vendor/assets/javascripts/{jquery-ui-1.8.13.sortable.custom.js → jquery-ui-1.8.13.custom.js} +250 -0
  65. data/vendor/assets/javascripts/jquery.additions.js +151 -0
  66. data/vendor/assets/javascripts/showdown.js +1254 -1276
  67. metadata +26 -29
  68. data/app/assets/javascripts/mercury/websocket.js.coffee +0 -34
  69. data/spec/javascripts/mercury/regions/_editable_.js.coffee +0 -0
  70. data/vendor/assets/javascripts/jquery-ui-1.8.13.custom.min.js +0 -249
  71. data/vendor/assets/javascripts/jquery.easing.js +0 -173
  72. data/vendor/assets/javascripts/jquery.json2.js +0 -178
  73. data/vendor/assets/javascripts/jquery.serialize_object.js +0 -16
  74. data/vendor/assets/javascripts/jquery.ujs.js +0 -289
@@ -1,6 +1,6 @@
1
1
  require '/assets/mercury/mercury.js'
2
2
 
3
- describe "Mercury.modalHandlers.inserttable", ->
3
+ describe "Mercury.modalHandlers.insertTable", ->
4
4
 
5
5
  template 'mercury/modals/inserttable.html'
6
6
 
@@ -13,7 +13,7 @@ describe "Mercury.modalHandlers.inserttable", ->
13
13
 
14
14
  beforeEach ->
15
15
  @tableEditorSpy = spyOn(Mercury, 'tableEditor').andCallFake(=>)
16
- Mercury.modalHandlers.inserttable.call(@modal)
16
+ Mercury.modalHandlers.insertTable.call(@modal)
17
17
 
18
18
  it "selects the first cell", ->
19
19
  expect($('#cell1').hasClass('selected')).toEqual(true)
@@ -27,7 +27,7 @@ describe "Mercury.modalHandlers.inserttable", ->
27
27
 
28
28
  beforeEach ->
29
29
  @tableEditorSpy = spyOn(Mercury, 'tableEditor').andCallFake(=>)
30
- Mercury.modalHandlers.inserttable.call(@modal)
30
+ Mercury.modalHandlers.insertTable.call(@modal)
31
31
 
32
32
  it "should unselect any selected cells", ->
33
33
  jasmine.simulate.click($('#cell2').get(0))
@@ -54,50 +54,50 @@ describe "Mercury.modalHandlers.inserttable", ->
54
54
  @decreaseColspanSpy = spyOn(Mercury.tableEditor, 'decreaseColspan').andCallFake(=>)
55
55
  @increaseRowspanSpy = spyOn(Mercury.tableEditor, 'increaseRowspan').andCallFake(=>)
56
56
  @decreaseRowspanSpy = spyOn(Mercury.tableEditor, 'decreaseRowspan').andCallFake(=>)
57
- Mercury.modalHandlers.inserttable.call(@modal)
57
+ Mercury.modalHandlers.insertTable.call(@modal)
58
58
 
59
59
  it "adds a row before the selected cell", ->
60
- jasmine.simulate.click($('input[name=insertrowbefore]').get(0))
60
+ jasmine.simulate.click($('input[name=insertRowBefore]').get(0))
61
61
  expect(@addRowSpy.callCount).toEqual(1)
62
62
  expect(@addRowSpy.argsForCall[0]).toEqual(['before'])
63
63
 
64
64
  it "adds a row after the selected cell", ->
65
- jasmine.simulate.click($('input[name=insertrowafter]').get(0))
65
+ jasmine.simulate.click($('input[name=insertRowAfter]').get(0))
66
66
  expect(@addRowSpy.callCount).toEqual(1)
67
67
  expect(@addRowSpy.argsForCall[0]).toEqual(['after'])
68
68
 
69
69
  it "deletes the row of the selected cell", ->
70
- jasmine.simulate.click($('input[name=deleterow]').get(0))
70
+ jasmine.simulate.click($('input[name=deleteRow]').get(0))
71
71
  expect(@removeRowSpy.callCount).toEqual(1)
72
72
 
73
73
  it "adds a column before the selected cell", ->
74
- jasmine.simulate.click($('input[name=insertcolumnbefore]').get(0))
74
+ jasmine.simulate.click($('input[name=insertColumnBefore]').get(0))
75
75
  expect(@addColumnSpy.callCount).toEqual(1)
76
76
  expect(@addColumnSpy.argsForCall[0]).toEqual(['before'])
77
77
 
78
78
  it "adds a column after the selected cell", ->
79
- jasmine.simulate.click($('input[name=insertcolumnafter]').get(0))
79
+ jasmine.simulate.click($('input[name=insertColumnAfter]').get(0))
80
80
  expect(@addColumnSpy.callCount).toEqual(1)
81
81
  expect(@addColumnSpy.argsForCall[0]).toEqual(['after'])
82
82
 
83
83
  it "deletes the column of the selected cell", ->
84
- jasmine.simulate.click($('input[name=deletecolumn]').get(0))
84
+ jasmine.simulate.click($('input[name=deleteColumn]').get(0))
85
85
  expect(@removeColumnSpy.callCount).toEqual(1)
86
86
 
87
87
  it "increases the colspan of the selected cell", ->
88
- jasmine.simulate.click($('input[name=increasecolspan]').get(0))
88
+ jasmine.simulate.click($('input[name=increaseColspan]').get(0))
89
89
  expect(@increaseColspanSpy.callCount).toEqual(1)
90
90
 
91
91
  it "decreases the colspan of the selected cell", ->
92
- jasmine.simulate.click($('input[name=decreasecolspan]').get(0))
92
+ jasmine.simulate.click($('input[name=decreaseColspan]').get(0))
93
93
  expect(@decreaseColspanSpy.callCount).toEqual(1)
94
94
 
95
95
  it "increases the rowspan of the selected cell", ->
96
- jasmine.simulate.click($('input[name=increaserowspan]').get(0))
96
+ jasmine.simulate.click($('input[name=increaseRowspan]').get(0))
97
97
  expect(@increaseRowspanSpy.callCount).toEqual(1)
98
98
 
99
99
  it "decreases the rowspan of the selected cell", ->
100
- jasmine.simulate.click($('input[name=decreaserowspan]').get(0))
100
+ jasmine.simulate.click($('input[name=decreaseRowspan]').get(0))
101
101
  expect(@decreaseRowspanSpy.callCount).toEqual(1)
102
102
 
103
103
 
@@ -109,7 +109,7 @@ describe "Mercury.modalHandlers.inserttable", ->
109
109
  describe "changing the border", ->
110
110
 
111
111
  beforeEach ->
112
- Mercury.modalHandlers.inserttable.call(@modal)
112
+ Mercury.modalHandlers.insertTable.call(@modal)
113
113
 
114
114
  it "changes the border of the table", ->
115
115
  $('#table_border').val('19')
@@ -125,7 +125,7 @@ describe "Mercury.modalHandlers.inserttable", ->
125
125
  describe "changing the cellspacing", ->
126
126
 
127
127
  beforeEach ->
128
- Mercury.modalHandlers.inserttable.call(@modal)
128
+ Mercury.modalHandlers.insertTable.call(@modal)
129
129
 
130
130
  it "changes the cellspacing of the table", ->
131
131
  $('#table_spacing').val('5')
@@ -141,7 +141,7 @@ describe "Mercury.modalHandlers.inserttable", ->
141
141
  describe "submitting", ->
142
142
 
143
143
  beforeEach ->
144
- Mercury.modalHandlers.inserttable.call(@modal)
144
+ Mercury.modalHandlers.insertTable.call(@modal)
145
145
 
146
146
  it "triggers an action", ->
147
147
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
@@ -66,7 +66,6 @@ describe "Mercury.PageEditor", ->
66
66
  it "builds an iframe", ->
67
67
  @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
68
68
  expect($('iframe.mercury-iframe').length).toEqual(1)
69
- expect($('iframe.mercury-iframe').attr('src')).toEqual('/foo')
70
69
 
71
70
  it "appends the elements to any node", ->
72
71
  @pageEditor = new Mercury.PageEditor('', {appendTo: $('#page_editor_container')})
@@ -284,19 +283,19 @@ describe "Mercury.PageEditor", ->
284
283
 
285
284
  beforeEach ->
286
285
  Mercury.Toolbar = -> {toolbar: true, height: -> 100}
287
- Mercury.Statusbar = -> {statusbar: true, height: -> 10}
286
+ Mercury.Statusbar = -> {statusbar: true, top: -> 500}
288
287
  Mercury.PageEditor.prototype.initializeFrame = ->
289
288
  @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
290
289
 
291
290
  it "sets the display rectangle to displayRect", ->
292
291
  @pageEditor.resize()
293
292
  expect(Mercury.displayRect.top).toEqual(100)
294
- expect(Mercury.displayRect.height).toEqual($(window).height() - 100 - 10)
293
+ expect(Mercury.displayRect.height).toEqual(500 - 100)
295
294
 
296
295
  it "resizes the iframe", ->
297
296
  @pageEditor.resize()
298
297
  expect($('.mercury-iframe').css('top')).toEqual('100px')
299
- expect($('.mercury-iframe').css('height')).toEqual("#{$(window).height() - 100 - 10}px")
298
+ expect($('.mercury-iframe').css('height')).toEqual("#{500 - 100}px")
300
299
 
301
300
  it "triggers a resize event", ->
302
301
  spy = spyOn(Mercury, 'trigger').andCallFake(=>)
@@ -310,8 +309,8 @@ describe "Mercury.PageEditor", ->
310
309
  Mercury.PageEditor.prototype.initializeFrame = ->
311
310
  @pageEditor = new Mercury.PageEditor('', {appendTo: $('#test')})
312
311
 
313
- it "takes the location and removes the /edit", ->
314
- expect(@pageEditor.iframeSrc('http://something/edit/path')).toEqual('http://something/path')
312
+ it "takes the location and removes the /editor", ->
313
+ expect(@pageEditor.iframeSrc('http://foo.com/editor/path')).toEqual('http://foo.com/path')
315
314
 
316
315
 
317
316
  describe "#hijackLinks", ->
@@ -154,17 +154,17 @@ describe "Mercury.Region", ->
154
154
  describe "getting html", ->
155
155
 
156
156
  it "returns the html of the element", ->
157
- html = @region.html()
158
- expect(html).toEqual('contents<div class="mercury-snippet" data-snippet="snippet_1" data-version="1">snippet</div>')
157
+ content = @region.content()
158
+ expect(content).toEqual('contents<div class="mercury-snippet" data-snippet="snippet_1" data-version="1">snippet</div>')
159
159
 
160
160
  it "replaces snippet content with an indentifier if asked", ->
161
- html = @region.html(null, true)
162
- expect(html).toEqual('contents<div class="mercury-snippet" data-snippet="snippet_1">[snippet_1]</div>')
161
+ content = @region.content(null, true)
162
+ expect(content).toEqual('contents<div class="mercury-snippet" data-snippet="snippet_1">[snippet_1]</div>')
163
163
 
164
164
  describe "setting html", ->
165
165
 
166
166
  it "sets the value of the html", ->
167
- @region.html('new html')
167
+ @region.content('new html')
168
168
  expect($('#region_with_snippet').html()).toEqual('new html')
169
169
 
170
170
 
@@ -0,0 +1,398 @@
1
+ require '/assets/mercury/mercury.js'
2
+
3
+ describe "Mercury.Regions.Editable", ->
4
+
5
+ template 'mercury/regions/editable.html'
6
+
7
+ beforeEach ->
8
+ @regionElement = $('#editable_region1')
9
+
10
+ describe "constructor", ->
11
+
12
+ beforeEach ->
13
+ @buildSpy = spyOn(Mercury.Regions.Editable.prototype, 'build').andCallFake(=>)
14
+ @bindEventsSpy = spyOn(Mercury.Regions.Editable.prototype, 'bindEvents').andCallFake(=>)
15
+
16
+ it "expects an element and window", ->
17
+ @region = new Mercury.Regions.Editable(@regionElement, window)
18
+ expect(@region.element.get(0)).toEqual($('#editable_region1').get(0))
19
+ expect(@region.window).toEqual(window)
20
+
21
+ it "accepts options", ->
22
+ @region = new Mercury.Regions.Editable(@regionElement, window, {foo: 'something'})
23
+ expect(@region.options).toEqual({foo: 'something'})
24
+
25
+ it "sets it's type", ->
26
+ @region = new Mercury.Regions.Editable(@regionElement, window)
27
+ expect(@region.type).toEqual('editable')
28
+
29
+ it "calls build", ->
30
+ @region = new Mercury.Regions.Editable(@regionElement, window)
31
+ expect(@buildSpy.callCount).toEqual(1)
32
+
33
+ it "calls bindEvents", ->
34
+ @region = new Mercury.Regions.Editable(@regionElement, window)
35
+ expect(@bindEventsSpy.callCount).toEqual(1)
36
+
37
+
38
+ describe "#build", ->
39
+
40
+ it "sets the content to &nbsp; if the content is blank [mozilla only]", ->
41
+
42
+ it "sets the current overflow to the element data", ->
43
+
44
+ it "resets the elements overflow to auto", ->
45
+
46
+ it "sets the container to have special handling if it's not a div [mozilla only]", ->
47
+
48
+ it "turns on contentEditable", ->
49
+
50
+ it "sets the version to 1 on any snippets within it", ->
51
+
52
+ it "enables and disables some basic contentEditable features (only once)", ->
53
+
54
+ it "sets mercuryEditing on the document", ->
55
+
56
+
57
+ describe "observed events", ->
58
+
59
+ describe "custom event: region:update", ->
60
+
61
+ it "sets a timeout and forces a selection", ->
62
+
63
+ it "sets up the table editor if we're in a table", ->
64
+
65
+ it "displays a tooltip if the selection is within an anchor", ->
66
+
67
+ it "hides the tooltip if the selection is not within an anchor", ->
68
+
69
+ it "does nothing if previewing", ->
70
+
71
+ it "does nothing if it's not the active region", ->
72
+
73
+ describe "custom event: possible:drop", ->
74
+
75
+ it "does nothing if previewing", ->
76
+
77
+ describe "when a snippet image is in the content", ->
78
+
79
+ it "calls focus", ->
80
+
81
+ it "calls displayOptionsFor for the snippet", ->
82
+
83
+ it "calls the native undo", ->
84
+
85
+ describe "dragenter", ->
86
+
87
+ it "does nothing if previewing", ->
88
+
89
+ it "it prevents the default action if shift is pressed", ->
90
+
91
+ describe "dragover", ->
92
+
93
+ it "does nothing if previewing", ->
94
+
95
+ it "it prevents the default action if shift is pressed", ->
96
+
97
+ describe "drop", ->
98
+
99
+ it "triggers the possible:drop event in a setTimeout", ->
100
+
101
+ it "does nothing if previewing", ->
102
+
103
+ describe "when a file is dropped", ->
104
+
105
+ it "prevents the default action", ->
106
+
107
+ it "calls focus", ->
108
+
109
+ it "loads the uploader", ->
110
+
111
+ describe "paste", ->
112
+
113
+ it "tells mercury that changes have been made", ->
114
+
115
+ # mozilla: doesn't seem to handle pasting in elements besides divs.
116
+ it "prevents the default if it's a special container", ->
117
+
118
+ it "calls handle paste with the pre-paste content in a setTimeout", ->
119
+
120
+ it "does nothing if previewing", ->
121
+
122
+ it "does nothing if it's not the active region", ->
123
+
124
+ describe "focus", ->
125
+
126
+ it "sets the active region", ->
127
+
128
+ it "forces a selection", ->
129
+
130
+ it "triggers a region:focused event", ->
131
+
132
+ it "does nothing if previewing", ->
133
+
134
+ describe "blur", ->
135
+
136
+ it "triggers a region:blurred event", ->
137
+
138
+ it "hides the tooltip", ->
139
+
140
+ it "does nothing if previewing", ->
141
+
142
+ describe "click", ->
143
+
144
+ it "sets anchor targets to top if previewing", ->
145
+
146
+ describe "dblclick", ->
147
+
148
+ it "does nothing if previewing", ->
149
+
150
+ describe "on an image", ->
151
+
152
+ it "selects the image element", ->
153
+
154
+ it "triggers the button event with the insertMedia action", ->
155
+
156
+ describe "mouseup", ->
157
+
158
+ it "calls pushHistory", ->
159
+
160
+ it "triggers the region:update event", ->
161
+
162
+ it "does nothing if previewing", ->
163
+
164
+ describe "keydown", ->
165
+
166
+ it "does nothing if previewing", ->
167
+
168
+ it "calls pushHistory", ->
169
+
170
+ it "calls execCommand with undo on meta+z", ->
171
+
172
+ it "calls execCommand with redo on shift+meta+z", ->
173
+
174
+ describe "pressing enter in a list", ->
175
+
176
+ it "prevents the default event", ->
177
+ it "calls execCommand with insertLineBreak", ->
178
+
179
+ describe "pressing enter when it's a special container (not a div)", ->
180
+
181
+ it "prevents the default event", ->
182
+ it "calls execCommand with insertHTML and <br/>", ->
183
+
184
+ describe "pressing tab", ->
185
+
186
+ it "calls execCommand with inserHTML and two spaces", ->
187
+
188
+ describe "pressing tab in a list", ->
189
+
190
+ it "calls execCommand with indent", ->
191
+
192
+ it "calls execCommand with outdent if shift is used", ->
193
+
194
+ it "doesn't call execCommand with inserHTML and two spaces", ->
195
+
196
+ describe "with common actions", ->
197
+
198
+ it "calls execCommand with bold on meta+b", ->
199
+
200
+ it "calls execCommand with italic on meta+i", ->
201
+
202
+ it "calls execCommand with underline on meta+u", ->
203
+
204
+ describe "keyup", ->
205
+
206
+ it "triggers the region:update event", ->
207
+
208
+ it "does nothing if previewing", ->
209
+
210
+
211
+ describe "#focus", ->
212
+
213
+ it "calls focus on the element", ->
214
+
215
+ it "sets a timeout that forces the selection", ->
216
+
217
+ it "triggers the region:update event", ->
218
+
219
+
220
+ describe "#content", ->
221
+
222
+ describe "when setting the content", ->
223
+
224
+ it "sanitizes the html (in case there's anything malformed)", ->
225
+
226
+ it "fills in any snippets with their stored content", ->
227
+
228
+ it "sets the html", ->
229
+
230
+ it "creates a selection if there's markers", ->
231
+
232
+ describe "when getting the content", ->
233
+
234
+ it "removes any meta tags", ->
235
+
236
+ it "places markers if asked", ->
237
+
238
+ it "sanitizes the html (in case there's anything malformed)", ->
239
+
240
+ it "replaces the snippet contents with an identifier if asked", ->
241
+
242
+ it "returns the content", ->
243
+
244
+
245
+ describe "#togglePreview", ->
246
+
247
+ describe "when not previewing", ->
248
+
249
+ it "replaces the content with whatever the content is", ->
250
+
251
+ it "turns contentEditable off", ->
252
+
253
+ it "sets the overflow back to what was stored on the element", ->
254
+
255
+ it "blurs the element", ->
256
+
257
+ describe "when previewing", ->
258
+
259
+ it "turns contentEditable on", ->
260
+
261
+ it "sets the overflow to auto", ->
262
+
263
+
264
+ describe "#execCommand", ->
265
+
266
+ describe "when a handler exists", ->
267
+
268
+ it "calls it if one is defined in Mercury.config.behaviors", ->
269
+
270
+ it "calls it if one is defined in actions", ->
271
+
272
+ describe "when a handler doesn't exist", ->
273
+
274
+ it "gets the html value of a jQuery element if one is passed in with the insertHTML action", ->
275
+
276
+ it "calls the native execCommand", ->
277
+
278
+ # mozilla has a weird bug when indenting.. if there's only one element in the region it will put the blockquote
279
+ # outside the region, so we have to remove it so it seems like nothing happened.
280
+ it "removes the previous sibling if it doesn't match what used to be there on indent [mozilla only]", ->
281
+
282
+
283
+ describe "#pushHistory", ->
284
+
285
+ it "clears the history timeout", ->
286
+
287
+ it "immediately pushes to the history buffer", ->
288
+
289
+ it "remembers the last key pressed if one was passed", ->
290
+
291
+ describe "when pressing enter, delete, or backspace", ->
292
+
293
+ it "immediately pushes to the history buffer", ->
294
+
295
+ it "only pushes once for each keyCode (eg. enter enter enter results in one push)", ->
296
+
297
+ describe "when pressing any other key", ->
298
+
299
+ it "waits for 2.5 seconds and then pushes to the history buffer", ->
300
+
301
+
302
+ describe "#selection", ->
303
+
304
+ it "returns a new instance of the selection helper class", ->
305
+
306
+
307
+ describe "#path", ->
308
+
309
+ it "returns an array of parents from the element with the selection to the region element", ->
310
+
311
+ it "returns an empty array if there's no selection", ->
312
+
313
+
314
+ describe "#currentElement", ->
315
+
316
+ it "returns the element that's closest to the node or element with the selection", ->
317
+
318
+ it "returns an empty array if there's no selection", ->
319
+
320
+
321
+ describe "#handlePaste", ->
322
+
323
+ it "removes any regions that might have been pasted", ->
324
+
325
+ describe "when it looks like MS word content", ->
326
+
327
+ it "calls the native undo to remove the pasted content", ->
328
+
329
+ it "inserts the cleaned content (which is the text version of what was pasted)", ->
330
+
331
+ describe "when undo throws an exception", ->
332
+
333
+ it "sets the content to what it was before the paste", ->
334
+
335
+ it "opens a modal (featuring clippy)", ->
336
+
337
+ describe "when it's configured to strip styles", ->
338
+
339
+ it "calls the native undo to remove the pasted content", ->
340
+
341
+ it "strips style attributes from the pasted content and inserts the cleaned html", ->
342
+
343
+
344
+ describe "Mercury.Regions.Editable.actions", ->
345
+
346
+ template 'mercury/regions/editable.html'
347
+
348
+ beforeEach ->
349
+ #@region = new Mercury.Regions.Editable($('#editable_region1'), window)
350
+ #@actions = Mercury.Regions.Editable.actions
351
+
352
+ # behaviors
353
+ describe "*horizontalRule", ->
354
+ describe "*htmlEditor", ->
355
+
356
+ # native actions
357
+ describe "-formatblock", ->
358
+ describe "-foreColor", ->
359
+ describe "-bold", ->
360
+ describe "-italic", ->
361
+ describe "-strikethrough", ->
362
+ describe "-underline", ->
363
+ describe "-subscript", ->
364
+ describe "-superscript", ->
365
+ describe "-justifyLeft", ->
366
+ describe "-justifyCenter", ->
367
+ describe "-justifyRight", ->
368
+ describe "-justifyFull", ->
369
+ describe "-insertUnorderedList", ->
370
+ describe "-insertOrderedList", ->
371
+ describe "-outdent", ->
372
+ describe "-indent", ->
373
+
374
+ # custom actions
375
+ describe ".style", ->
376
+ describe ".backColor", ->
377
+ describe ".removeFormatting", ->
378
+ describe ".overline", ->
379
+ describe ".insertRowBefore", ->
380
+ describe ".insertRowAfter", ->
381
+ describe ".deleteRow", ->
382
+ describe ".insertColumnBefore", ->
383
+ describe ".insertColumnAfter", ->
384
+ describe ".deleteColumn", ->
385
+ describe ".increaseColspan", ->
386
+ describe ".decreaseColspan", ->
387
+ describe ".increaseRowspan", ->
388
+ describe ".decreaseRowspan", ->
389
+ describe ".undo", ->
390
+ describe ".redo", ->
391
+ describe ".replaceHTML", ->
392
+ describe ".insertImage", ->
393
+ describe ".insertLink", ->
394
+ describe ".replaceLink", ->
395
+ describe ".insertSnippet", ->
396
+ describe ".editSnippet", ->
397
+ describe ".removeSnippet", ->
398
+