mercury-rails 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +5 -0
- data/{README.rdoc → README.md} +150 -60
- data/VERSION +1 -1
- data/annotated_source.template +57 -0
- data/app/controllers/mercury_controller.rb +8 -4
- data/app/models/image.rb +2 -2
- data/app/views/layouts/mercury.html.erb +14 -0
- data/app/views/mercury/lightviews/about.html +7 -0
- data/app/views/mercury/lightviews/imageprocessor.html +3 -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 +75 -0
- data/app/views/mercury/modals/media.html +82 -0
- data/app/views/mercury/modals/sanitizer.html +9 -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.html.erb +1 -0
- data/app/views/mercury/snippets/example_options.html.erb +23 -0
- data/config/routes.rb +1 -1
- data/features/editing/basic.feature +1 -1
- data/features/support/paths.rb +1 -0
- data/lib/generators/mercury/install/install_generator.rb +14 -0
- data/mercury-rails.gemspec +115 -106
- data/spec/javascripts/mercury/dialog_spec.js.coffee +54 -38
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/dialogs/{objectspanel_spec.js.coffee → snippetpanel_spec.js.coffee} +4 -4
- data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/history_buffer_spec.js.coffee +0 -1
- data/spec/javascripts/mercury/lightview_spec.js.coffee +448 -0
- data/spec/javascripts/mercury/mercury_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/modal_spec.js.coffee +474 -0
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +8 -2
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/native_extensions_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +160 -20
- data/spec/javascripts/mercury/palette_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/panel_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/region_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/regions/editable_spec.js.coffee +191 -6
- data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +369 -0
- data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/select_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/snippet_spec.js.coffee +3 -3
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +2 -2
- data/spec/javascripts/mercury/statusbar_spec.js.coffee +91 -17
- data/spec/javascripts/mercury/table_editor_spec.js.coffee +5 -1
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +70 -15
- data/spec/javascripts/mercury/tooltip_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/uploader_spec.js.coffee +9 -1
- data/spec/javascripts/templates/mercury/dialogs/{objectspanel.html → snippetpanel.html} +0 -0
- data/spec/javascripts/templates/mercury/lightview.html +13 -0
- data/spec/javascripts/templates/mercury/modal.html +13 -0
- data/spec/javascripts/templates/mercury/page_editor.html +11 -1
- data/spec/javascripts/templates/mercury/statusbar.html +1 -0
- data/spec/javascripts/templates/mercury/toolbar.html +1 -0
- data/{app → vendor}/assets/images/mercury/button.png +0 -0
- data/{app → vendor}/assets/images/mercury/clippy.png +0 -0
- data/{app → vendor}/assets/images/mercury/default-snippet.png +0 -0
- data/{app → vendor}/assets/images/mercury/loading-dark.gif +0 -0
- data/{app → vendor}/assets/images/mercury/loading-light.gif +0 -0
- data/{app → vendor}/assets/images/mercury/search-icon.png +0 -0
- data/vendor/assets/images/mercury/temp-logo.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/{app/assets/images/mercury/toolbar/primary/objectspanel.png → vendor/assets/images/mercury/toolbar/primary/snippetpanel.png} +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
- data/vendor/assets/javascripts/mercury.js +302 -0
- data/vendor/assets/javascripts/mercury/dialog.js.coffee +157 -0
- data/{app → vendor}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dialogs/objectspanel.js.coffee +1 -1
- data/{app → vendor}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
- data/vendor/assets/javascripts/mercury/lightview.js.coffee +156 -0
- data/vendor/assets/javascripts/mercury/lightviews/imageprocessor.js.coffee +2 -0
- data/vendor/assets/javascripts/mercury/mercury.js.coffee +63 -0
- data/{app → vendor}/assets/javascripts/mercury/modal.js.coffee +25 -17
- data/{app → vendor}/assets/javascripts/mercury/modals/htmleditor.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/modals/insertlink.js.coffee +3 -0
- data/{app → vendor}/assets/javascripts/mercury/modals/insertmedia.js.coffee +10 -2
- data/{app → vendor}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/modals/inserttable.js.coffee +2 -2
- data/{app → vendor}/assets/javascripts/mercury/native_extensions.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/page_editor.js.coffee +44 -13
- data/{app → vendor}/assets/javascripts/mercury/palette.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/panel.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/region.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/regions/editable.js.coffee +58 -12
- data/{app → vendor}/assets/javascripts/mercury/regions/markupable.js.coffee +26 -24
- data/{app → vendor}/assets/javascripts/mercury/regions/snippetable.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/select.js.coffee +3 -0
- data/{app → vendor}/assets/javascripts/mercury/snippet.js.coffee +9 -5
- data/{app → vendor}/assets/javascripts/mercury/snippet_toolbar.js.coffee +0 -0
- data/vendor/assets/javascripts/mercury/statusbar.js.coffee +51 -0
- data/{app → vendor}/assets/javascripts/mercury/table_editor.js.coffee +9 -8
- data/{app → vendor}/assets/javascripts/mercury/toolbar.button.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/toolbar.button_group.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/toolbar.expander.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/toolbar.js.coffee +14 -1
- data/{app → vendor}/assets/javascripts/mercury/tooltip.js.coffee +3 -0
- data/{app → vendor}/assets/javascripts/mercury/uploader.js.coffee +22 -13
- data/vendor/assets/javascripts/{jquery-1.6.js → mercury_dependencies/jquery-1.6.js} +0 -0
- data/vendor/assets/javascripts/{jquery-ui-1.8.13.custom.js → mercury_dependencies/jquery-ui-1.8.13.custom.js} +0 -0
- data/vendor/assets/javascripts/{jquery.additions.js → mercury_dependencies/jquery.additions.js} +0 -0
- data/vendor/assets/javascripts/{liquidmetal.js → mercury_dependencies/liquidmetal.js} +0 -0
- data/vendor/assets/javascripts/{showdown.js → mercury_dependencies/showdown.js} +0 -0
- data/vendor/assets/javascripts/mercury_loader.js +191 -0
- data/{app → vendor}/assets/stylesheets/mercury.css +3 -6
- data/vendor/assets/stylesheets/mercury/dialog.css +199 -0
- data/vendor/assets/stylesheets/mercury/lightview.css +92 -0
- data/vendor/assets/stylesheets/mercury/mercury.css +134 -0
- data/vendor/assets/stylesheets/mercury/modal.css +191 -0
- data/{app/assets/stylesheets/mercury/statusbar.scss → vendor/assets/stylesheets/mercury/statusbar.css} +9 -1
- data/vendor/assets/stylesheets/mercury/toolbar.css +329 -0
- data/{app/assets/stylesheets/mercury/tooltip.scss → vendor/assets/stylesheets/mercury/tooltip.css} +7 -7
- data/vendor/assets/stylesheets/mercury/uploader.css +111 -0
- metadata +230 -225
- data/app/assets/images/mercury/toolbar/markupable/buttons.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/todospanel.png +0 -0
- data/app/assets/javascripts/mercury.js +0 -30
- data/app/assets/javascripts/mercury/dialog.js.coffee +0 -75
- data/app/assets/javascripts/mercury/mercury.js.coffee +0 -286
- data/app/assets/javascripts/mercury/statusbar.js.coffee +0 -29
- data/app/assets/javascripts/mercury_loader.js +0 -98
- data/app/assets/stylesheets/mercury/dialog.scss +0 -179
- data/app/assets/stylesheets/mercury/mercury.scss +0 -127
- data/app/assets/stylesheets/mercury/modal.scss +0 -194
- data/app/assets/stylesheets/mercury/toolbar.scss +0 -415
- data/app/assets/stylesheets/mercury/uploader.scss +0 -109
- data/app/views/layouts/mercury.html.haml +0 -8
- data/app/views/mercury/modals/character.html.haml +0 -252
- data/app/views/mercury/modals/htmleditor.html.haml +0 -8
- data/app/views/mercury/modals/link.html.haml +0 -31
- data/app/views/mercury/modals/media.html.haml +0 -33
- data/app/views/mercury/modals/sanitizer.html.haml +0 -4
- data/app/views/mercury/modals/table.html.haml +0 -49
- data/app/views/mercury/palettes/backcolor.html.haml +0 -79
- data/app/views/mercury/palettes/forecolor.html.haml +0 -79
- data/app/views/mercury/panels/history.html.haml +0 -0
- data/app/views/mercury/panels/notes.html.haml +0 -0
- data/app/views/mercury/panels/snippets.html.haml +0 -10
- data/app/views/mercury/selects/formatblock.html.haml +0 -10
- data/app/views/mercury/selects/style.html.haml +0 -4
- data/app/views/mercury/snippets/example.html.haml +0 -2
- data/app/views/mercury/snippets/example_options.html.haml +0 -16
- data/log/.gitkeep +0 -0
- data/spec/javascripts/mercury/regions/_markupable_.js.coffee +0 -0
@@ -0,0 +1,369 @@
|
|
1
|
+
require '/assets/mercury.js'
|
2
|
+
|
3
|
+
describe "Mercury.Regions.Markupable", ->
|
4
|
+
|
5
|
+
template 'mercury/regions/markupable.html'
|
6
|
+
|
7
|
+
beforeEach ->
|
8
|
+
@regionElement = $('#markupable_region1')
|
9
|
+
|
10
|
+
describe "constructor", ->
|
11
|
+
|
12
|
+
beforeEach ->
|
13
|
+
@buildSpy = spyOn(Mercury.Regions.Markupable.prototype, 'build').andCallFake(=>)
|
14
|
+
@bindEventsSpy = spyOn(Mercury.Regions.Markupable.prototype, 'bindEvents').andCallFake(=>)
|
15
|
+
spyOn(Mercury.Regions.Markupable.prototype, 'pushHistory').andCallFake(=>)
|
16
|
+
|
17
|
+
it "expects an element and window", ->
|
18
|
+
@region = new Mercury.Regions.Markupable(@regionElement, window)
|
19
|
+
expect(@region.element.get(0)).toEqual($('#markupable_region1').get(0))
|
20
|
+
expect(@region.window).toEqual(window)
|
21
|
+
|
22
|
+
it "accepts options", ->
|
23
|
+
@region = new Mercury.Regions.Markupable(@regionElement, window, {foo: 'something'})
|
24
|
+
expect(@region.options).toEqual({foo: 'something'})
|
25
|
+
|
26
|
+
it "sets it's type", ->
|
27
|
+
@region = new Mercury.Regions.Markupable(@regionElement, window)
|
28
|
+
expect(@region.type).toEqual('markupable')
|
29
|
+
|
30
|
+
it "creates a markdown converter using Showdown", ->
|
31
|
+
spy = spyOn(Showdown, 'converter').andCallFake(=>)
|
32
|
+
@region = new Mercury.Regions.Markupable(@regionElement, window)
|
33
|
+
expect(spy.callCount).toEqual(1)
|
34
|
+
expect(@region.converter).toBeDefined()
|
35
|
+
|
36
|
+
it "calls build", ->
|
37
|
+
@region = new Mercury.Regions.Markupable(@regionElement, window)
|
38
|
+
expect(@buildSpy.callCount).toEqual(1)
|
39
|
+
|
40
|
+
it "calls bindEvents", ->
|
41
|
+
@region = new Mercury.Regions.Markupable(@regionElement, window)
|
42
|
+
expect(@bindEventsSpy.callCount).toEqual(1)
|
43
|
+
|
44
|
+
|
45
|
+
describe "#build", ->
|
46
|
+
|
47
|
+
it "creates a textarea", ->
|
48
|
+
|
49
|
+
it "fills the textarea with the contents of the element", ->
|
50
|
+
|
51
|
+
it "sets some styles on the textarea", ->
|
52
|
+
|
53
|
+
it "appends the textarea to the element", ->
|
54
|
+
|
55
|
+
it "creates a preview element", ->
|
56
|
+
|
57
|
+
it "appends the preview element to the element", ->
|
58
|
+
|
59
|
+
it "element is reassigned to the textarea", ->
|
60
|
+
|
61
|
+
it "calls resize", ->
|
62
|
+
|
63
|
+
|
64
|
+
describe "#focus", ->
|
65
|
+
|
66
|
+
it "calls focus on the element", ->
|
67
|
+
|
68
|
+
|
69
|
+
describe "observed events", ->
|
70
|
+
|
71
|
+
describe "custom event: mode", ->
|
72
|
+
|
73
|
+
it "calls togglePreview if the mode is preview", ->
|
74
|
+
|
75
|
+
describe "custom event: focus:frame", ->
|
76
|
+
|
77
|
+
it "calls focus", ->
|
78
|
+
|
79
|
+
it "does nothing if previewing", ->
|
80
|
+
|
81
|
+
it "does nothing if it's not the active region", ->
|
82
|
+
|
83
|
+
describe "custom event: action", ->
|
84
|
+
|
85
|
+
it "calls execCommand", ->
|
86
|
+
|
87
|
+
it "does nothing if previewing", ->
|
88
|
+
|
89
|
+
it "does nothing if it's not the active region", ->
|
90
|
+
|
91
|
+
describe "custom event: unfocus:regions", ->
|
92
|
+
|
93
|
+
it "blurs the element", ->
|
94
|
+
|
95
|
+
it "removes the focus class from the element", ->
|
96
|
+
|
97
|
+
it "triggers the region:blurred event", ->
|
98
|
+
|
99
|
+
it "does nothing if previewing", ->
|
100
|
+
|
101
|
+
it "does nothing if it's not the active region", ->
|
102
|
+
|
103
|
+
describe "dragenter", ->
|
104
|
+
|
105
|
+
it "prevents the default action", ->
|
106
|
+
|
107
|
+
it "does nothing if previewing", ->
|
108
|
+
|
109
|
+
describe "dragover", ->
|
110
|
+
|
111
|
+
it "prevents the default action", ->
|
112
|
+
|
113
|
+
it "does nothing if previewing", ->
|
114
|
+
|
115
|
+
describe "drop", ->
|
116
|
+
|
117
|
+
it "does nothing if previewing", ->
|
118
|
+
|
119
|
+
describe "when there's an active snippet", ->
|
120
|
+
|
121
|
+
it "calls focus", ->
|
122
|
+
|
123
|
+
it "calls displayOptionsFor for the snippet", ->
|
124
|
+
|
125
|
+
it "calls the native undo", ->
|
126
|
+
|
127
|
+
describe "when a file is dropped", ->
|
128
|
+
|
129
|
+
it "calls focus", ->
|
130
|
+
|
131
|
+
it "loads the uploader", ->
|
132
|
+
|
133
|
+
describe "focus", ->
|
134
|
+
|
135
|
+
it "does nothing if previewing", ->
|
136
|
+
|
137
|
+
it "sets the active region to itself", ->
|
138
|
+
|
139
|
+
it "adds the focus class to the element", ->
|
140
|
+
|
141
|
+
it "triggers the region:focused event", ->
|
142
|
+
|
143
|
+
describe "keydown", ->
|
144
|
+
|
145
|
+
it "does nothing if previewing", ->
|
146
|
+
|
147
|
+
it "tells mercury that changes have been made", ->
|
148
|
+
|
149
|
+
it "calls pushHistory", ->
|
150
|
+
|
151
|
+
it "calls execCommand with undo on meta+z", ->
|
152
|
+
|
153
|
+
it "calls execCommand with redo on shift+meta+z", ->
|
154
|
+
|
155
|
+
describe "pressing enter in a list", ->
|
156
|
+
|
157
|
+
it "prevents the default event", ->
|
158
|
+
|
159
|
+
it "adds a new line with the next number or just dash for unordered lists", ->
|
160
|
+
|
161
|
+
describe "pressing tab", ->
|
162
|
+
|
163
|
+
it "calls execCommand with inserHTML and two spaces", ->
|
164
|
+
|
165
|
+
describe "with common actions", ->
|
166
|
+
|
167
|
+
it "calls execCommand with bold on meta+b", ->
|
168
|
+
|
169
|
+
it "calls execCommand with italic on meta+i", ->
|
170
|
+
|
171
|
+
it "calls execCommand with underline on meta+u", ->
|
172
|
+
|
173
|
+
describe "keyup", ->
|
174
|
+
|
175
|
+
it "triggers the region:update event", ->
|
176
|
+
|
177
|
+
it "does nothing if previewing", ->
|
178
|
+
|
179
|
+
describe "mouseup", ->
|
180
|
+
|
181
|
+
it "calls focus", ->
|
182
|
+
|
183
|
+
it "triggers the region:update event", ->
|
184
|
+
|
185
|
+
it "does nothing if previewing", ->
|
186
|
+
|
187
|
+
describe "click on the preview element", ->
|
188
|
+
|
189
|
+
it "sets anchor targets to top if previewing", ->
|
190
|
+
|
191
|
+
|
192
|
+
describe "#content", ->
|
193
|
+
|
194
|
+
describe "when setting the content using a string", ->
|
195
|
+
|
196
|
+
it "sets the value of the element", ->
|
197
|
+
|
198
|
+
describe "when setting the content using an object (with a selection)", ->
|
199
|
+
|
200
|
+
it "sets the value of the element", ->
|
201
|
+
|
202
|
+
it "selects using the selection start/end from the object", ->
|
203
|
+
|
204
|
+
describe "when getting the content", ->
|
205
|
+
|
206
|
+
it "returns the element value", ->
|
207
|
+
|
208
|
+
|
209
|
+
describe "#togglePreview", ->
|
210
|
+
|
211
|
+
describe "when not previewing", ->
|
212
|
+
|
213
|
+
it "sets the value of the preview element to the html from the markdown converter", ->
|
214
|
+
|
215
|
+
it "shows the preview element", ->
|
216
|
+
|
217
|
+
it "hides the element", ->
|
218
|
+
|
219
|
+
describe "when previewing", ->
|
220
|
+
|
221
|
+
it "hides the preview element", ->
|
222
|
+
|
223
|
+
it "shows the element", ->
|
224
|
+
|
225
|
+
|
226
|
+
describe "#execCommand", ->
|
227
|
+
|
228
|
+
it "calls resize", ->
|
229
|
+
|
230
|
+
describe "when a handler exists", ->
|
231
|
+
|
232
|
+
it "calls it if one is defined in actions", ->
|
233
|
+
|
234
|
+
|
235
|
+
describe "#htmlAndSelection", ->
|
236
|
+
|
237
|
+
it "returns an object with the content and the selection start/end", ->
|
238
|
+
|
239
|
+
|
240
|
+
describe "#pushHistory", ->
|
241
|
+
|
242
|
+
it "clears the history timeout", ->
|
243
|
+
|
244
|
+
it "immediately pushes to the history buffer", ->
|
245
|
+
|
246
|
+
it "remembers the last key pressed if one was passed", ->
|
247
|
+
|
248
|
+
describe "when pressing enter, delete, or backspace", ->
|
249
|
+
|
250
|
+
it "immediately pushes to the history buffer", ->
|
251
|
+
|
252
|
+
it "only pushes once for each keyCode (eg. enter enter enter results in one push)", ->
|
253
|
+
|
254
|
+
describe "when pressing any other key", ->
|
255
|
+
|
256
|
+
it "waits for 2.5 seconds and then pushes to the history buffer", ->
|
257
|
+
|
258
|
+
|
259
|
+
describe "#selection", ->
|
260
|
+
|
261
|
+
it "returns a new instance of the selection helper class", ->
|
262
|
+
|
263
|
+
|
264
|
+
describe "#resize", ->
|
265
|
+
|
266
|
+
|
267
|
+
describe "#snippets", ->
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
describe "Mercury.Regions.Markupable.actions", ->
|
272
|
+
|
273
|
+
template 'mercury/regions/markupable.html'
|
274
|
+
|
275
|
+
beforeEach ->
|
276
|
+
#@region = new Mercury.Regions.Markupable($('#markupable_region1'), window)
|
277
|
+
#@actions = Mercury.Regions.Markupable.actions
|
278
|
+
|
279
|
+
describe ".undo", ->
|
280
|
+
|
281
|
+
it "calls undo on the history buffer", ->
|
282
|
+
|
283
|
+
it "sets the contents", ->
|
284
|
+
|
285
|
+
|
286
|
+
describe ".redo", ->
|
287
|
+
|
288
|
+
it "calls redo on the history buffer", ->
|
289
|
+
|
290
|
+
it "sets the contents", ->
|
291
|
+
|
292
|
+
|
293
|
+
describe ".insertHTML", ->
|
294
|
+
|
295
|
+
it "gets the html value if it's a jQuery object", ->
|
296
|
+
|
297
|
+
it "replaces the selection with the content", ->
|
298
|
+
|
299
|
+
|
300
|
+
describe ".insertImage", ->
|
301
|
+
|
302
|
+
it "replaces the selection with the image markup", ->
|
303
|
+
|
304
|
+
|
305
|
+
describe ".insertLink", ->
|
306
|
+
|
307
|
+
it "replaces the selection with the link markup", ->
|
308
|
+
|
309
|
+
|
310
|
+
describe ".insertUnorderedList", ->
|
311
|
+
|
312
|
+
it "replaces the selection with the unordered list markup", ->
|
313
|
+
|
314
|
+
|
315
|
+
describe ".insertOrderedList", ->
|
316
|
+
|
317
|
+
it "replaces the selection with the ordered list markup", ->
|
318
|
+
|
319
|
+
|
320
|
+
describe ".style", ->
|
321
|
+
|
322
|
+
it "wraps the selection in a span tag with a given class", ->
|
323
|
+
|
324
|
+
|
325
|
+
describe ".formatblock", ->
|
326
|
+
|
327
|
+
it "unwraps the line of the selection of any block format markup", ->
|
328
|
+
|
329
|
+
it "wraps the line of the selection with the given block format markup", ->
|
330
|
+
|
331
|
+
|
332
|
+
describe ".bold", ->
|
333
|
+
|
334
|
+
it "wraps the selection in the bold markup (**)", ->
|
335
|
+
|
336
|
+
|
337
|
+
describe ".italic", ->
|
338
|
+
|
339
|
+
it "wraps the selection in the italics markup (_)", ->
|
340
|
+
|
341
|
+
|
342
|
+
describe ".subscript", ->
|
343
|
+
|
344
|
+
it "wraps the selection in a sub tag", ->
|
345
|
+
|
346
|
+
|
347
|
+
describe ".superscript", ->
|
348
|
+
|
349
|
+
it "wraps the selection in a sup tag", ->
|
350
|
+
|
351
|
+
|
352
|
+
describe ".indent", ->
|
353
|
+
|
354
|
+
it "adds a > to the front of the line", ->
|
355
|
+
|
356
|
+
|
357
|
+
describe ".outdent", ->
|
358
|
+
|
359
|
+
it "removes a > from the front of the line", ->
|
360
|
+
|
361
|
+
|
362
|
+
describe ".horizontalRule", ->
|
363
|
+
|
364
|
+
it "replaces the selection with the hr markup (- - -)", ->
|
365
|
+
|
366
|
+
|
367
|
+
describe ".insertSnippet", ->
|
368
|
+
|
369
|
+
it "replaces the selection with the content returned from the snippets getText", ->
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '/assets/mercury
|
1
|
+
require '/assets/mercury.js'
|
2
2
|
|
3
3
|
describe "Mercury.Snippet", ->
|
4
4
|
|
@@ -76,7 +76,7 @@ describe "Mercury.Snippet", ->
|
|
76
76
|
@ajaxSpy.andCallFake(=>)
|
77
77
|
@snippet.loadPreview()
|
78
78
|
expect(@ajaxSpy.callCount).toEqual(1)
|
79
|
-
expect(@ajaxSpy.argsForCall[0][0]).toEqual("/mercury/snippets/foo/preview")
|
79
|
+
expect(@ajaxSpy.argsForCall[0][0]).toEqual("/mercury/snippets/foo/preview.html")
|
80
80
|
expect(@ajaxSpy.argsForCall[0][1]['data']).toEqual({foo: 'bar'})
|
81
81
|
expect(@ajaxSpy.argsForCall[0][1]['type']).toEqual('POST')
|
82
82
|
|
@@ -195,7 +195,7 @@ describe "Mercury.Snippet class methods", ->
|
|
195
195
|
it "opens a modal with the name in the url", ->
|
196
196
|
Mercury.Snippet.displayOptionsFor('foo')
|
197
197
|
expect(@modalSpy.callCount).toEqual(1)
|
198
|
-
expect(@modalSpy.argsForCall[0]).toEqual(["/mercury/snippets/foo/options", {title: 'Snippet Options', handler: 'insertSnippet', snippetName: 'foo'}])
|
198
|
+
expect(@modalSpy.argsForCall[0]).toEqual(["/mercury/snippets/foo/options.html", {title: 'Snippet Options', handler: 'insertSnippet', snippetName: 'foo'}])
|
199
199
|
|
200
200
|
it "sets the snippet back to nothing", ->
|
201
201
|
Mercury.snippet = 'foo'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '/assets/mercury
|
1
|
+
require '/assets/mercury.js'
|
2
2
|
|
3
3
|
describe "Mercury.SnippetToolbar", ->
|
4
4
|
|
@@ -109,7 +109,7 @@ describe "Mercury.SnippetToolbar", ->
|
|
109
109
|
|
110
110
|
beforeEach ->
|
111
111
|
Mercury.displayRect = {top: 20}
|
112
|
-
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test'})
|
112
|
+
@snippetToolbar = new Mercury.SnippetToolbar($('document'), {appendTo: '#test', visible: true})
|
113
113
|
@snippetToolbar.snippet = $('#snippet')
|
114
114
|
|
115
115
|
it "positions itself based on the snippet", ->
|
@@ -1,10 +1,11 @@
|
|
1
|
-
require '/assets/mercury
|
1
|
+
require '/assets/mercury.js'
|
2
2
|
|
3
3
|
describe "Mercury.Statusbar", ->
|
4
4
|
|
5
5
|
template 'mercury/statusbar.html'
|
6
6
|
|
7
7
|
beforeEach ->
|
8
|
+
$.fx.off = true
|
8
9
|
@region = {
|
9
10
|
path: -> [{tagName: 'A'}, {tagName: 'B'}, {tagName: 'C'}]
|
10
11
|
}
|
@@ -18,11 +19,14 @@ describe "Mercury.Statusbar", ->
|
|
18
19
|
beforeEach ->
|
19
20
|
@buildSpy = spyOn(Mercury.Statusbar.prototype, 'build')
|
20
21
|
@bindEventsSpy = spyOn(Mercury.Statusbar.prototype, 'bindEvents')
|
21
|
-
@statusbar = new Mercury.Statusbar({appendTo: '#test', foo: 'bar'})
|
22
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', foo: 'bar', visible: false})
|
22
23
|
|
23
24
|
it "accepts options", ->
|
24
25
|
expect(@statusbar.options.foo).toEqual('bar')
|
25
26
|
|
27
|
+
it "sets visible based on options", ->
|
28
|
+
expect(@statusbar.visible).toEqual(false)
|
29
|
+
|
26
30
|
it "calls build", ->
|
27
31
|
expect(@buildSpy.callCount).toEqual(1)
|
28
32
|
|
@@ -30,24 +34,21 @@ describe "Mercury.Statusbar", ->
|
|
30
34
|
expect(@bindEventsSpy.callCount).toEqual(1)
|
31
35
|
|
32
36
|
|
33
|
-
describe "#height", ->
|
34
|
-
|
35
|
-
beforeEach ->
|
36
|
-
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
37
|
-
@statusbar = new Mercury.Statusbar({appendTo: '#test'})
|
38
|
-
|
39
|
-
it "knows it's own height", ->
|
40
|
-
expect(@statusbar.height()).toEqual(20) # styled with css in the template
|
41
|
-
|
42
|
-
|
43
37
|
describe "#build", ->
|
44
38
|
|
45
39
|
beforeEach ->
|
46
40
|
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
47
|
-
@statusbar = new Mercury.Statusbar({appendTo: '#statusbar_container'})
|
41
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#statusbar_container', visible: false})
|
48
42
|
|
49
43
|
it "builds an element", ->
|
50
|
-
expect($('
|
44
|
+
expect($('.mercury-statusbar').length).toEqual(1)
|
45
|
+
|
46
|
+
it "builds an about element", ->
|
47
|
+
expect($('.mercury-statusbar-about').length).toEqual(1)
|
48
|
+
expect(@statusbar.aboutElement).toBeDefined()
|
49
|
+
|
50
|
+
it "hides the element if it's not supposed to be visible", ->
|
51
|
+
expect($('.mercury-statusbar').css('visibility')).toEqual('hidden')
|
51
52
|
|
52
53
|
it "can append to any element", ->
|
53
54
|
expect($('#statusbar_container .mercury-statusbar').length).toEqual(1)
|
@@ -56,17 +57,53 @@ describe "Mercury.Statusbar", ->
|
|
56
57
|
describe "observed events ", ->
|
57
58
|
|
58
59
|
beforeEach ->
|
59
|
-
spyOn(Mercury.Statusbar.prototype, 'build').andCallFake(=>)
|
60
60
|
@statusbar = new Mercury.Statusbar({appendTo: '#test'})
|
61
61
|
|
62
62
|
describe "custom event: region:update", ->
|
63
63
|
|
64
64
|
it "calls setPath if a region was provided", ->
|
65
65
|
spy = spyOn(Mercury.Statusbar.prototype, 'setPath').andCallFake(=>)
|
66
|
-
|
67
66
|
Mercury.trigger('region:update', {region: @region})
|
68
67
|
expect(spy.callCount).toEqual(1)
|
69
68
|
|
69
|
+
describe "clicking on the about element", ->
|
70
|
+
|
71
|
+
it "opens a lightview", ->
|
72
|
+
spy = spyOn(Mercury, 'lightview').andCallFake(=>)
|
73
|
+
jasmine.simulate.click($('.mercury-statusbar-about').get(0))
|
74
|
+
expect(spy.callCount).toEqual(1)
|
75
|
+
|
76
|
+
|
77
|
+
describe "#height", ->
|
78
|
+
|
79
|
+
beforeEach ->
|
80
|
+
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
81
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: true})
|
82
|
+
|
83
|
+
it "knows it's own height", ->
|
84
|
+
expect(@statusbar.height()).toEqual(20) # styled with css in the template
|
85
|
+
|
86
|
+
|
87
|
+
describe "#top", ->
|
88
|
+
|
89
|
+
describe "when visible", ->
|
90
|
+
|
91
|
+
beforeEach ->
|
92
|
+
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
93
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: true})
|
94
|
+
|
95
|
+
it "returns the offset top of the element", ->
|
96
|
+
expect(@statusbar.top()).toEqual($('.mercury-statusbar').offset().top)
|
97
|
+
|
98
|
+
describe "when not visible", ->
|
99
|
+
|
100
|
+
beforeEach ->
|
101
|
+
spyOn(Mercury.Statusbar.prototype, 'bindEvents').andCallFake(=>)
|
102
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: false})
|
103
|
+
|
104
|
+
it "returns the offset top of the element + it's outer height", ->
|
105
|
+
expect(@statusbar.top()).toEqual($('.mercury-statusbar').offset().top + $('.mercury-statusbar').outerHeight())
|
106
|
+
|
70
107
|
|
71
108
|
describe "#setPath", ->
|
72
109
|
|
@@ -75,4 +112,41 @@ describe "Mercury.Statusbar", ->
|
|
75
112
|
|
76
113
|
it "builds a path and displays it", ->
|
77
114
|
@statusbar.setPath(@region.path())
|
78
|
-
expect($('.mercury-statusbar').html()).
|
115
|
+
expect($('.mercury-statusbar').html()).toMatch(/<span><strong>Path: <\/strong><a>c<\/a> .+ <a>b<\/a> .+ <a>a<\/a><\/span>/)
|
116
|
+
|
117
|
+
|
118
|
+
describe "#show", ->
|
119
|
+
|
120
|
+
beforeEach ->
|
121
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: false})
|
122
|
+
|
123
|
+
it "sets visible to true", ->
|
124
|
+
@statusbar.visible = false
|
125
|
+
@statusbar.show()
|
126
|
+
expect(@statusbar.visible).toEqual(true)
|
127
|
+
|
128
|
+
it "displays the element", ->
|
129
|
+
$('.mercury-statusbar').css({visibility: 'hidden'})
|
130
|
+
@statusbar.show()
|
131
|
+
expect($('.mercury-statusbar').css('visibility')).toEqual('visible')
|
132
|
+
|
133
|
+
it "sets the opacity of the element", ->
|
134
|
+
$('.mercury-statusbar').css({opacity: 0})
|
135
|
+
@statusbar.show()
|
136
|
+
expect($('.mercury-statusbar').css('opacity')).toEqual('1')
|
137
|
+
|
138
|
+
|
139
|
+
describe "#hide", ->
|
140
|
+
|
141
|
+
beforeEach ->
|
142
|
+
@statusbar = new Mercury.Statusbar({appendTo: '#test', visible: true})
|
143
|
+
|
144
|
+
it "sets visible to false", ->
|
145
|
+
@statusbar.visible = true
|
146
|
+
@statusbar.hide()
|
147
|
+
expect(@statusbar.visible).toEqual(false)
|
148
|
+
|
149
|
+
it "hides the element", ->
|
150
|
+
$('.mercury-statusbar').css({visibility: 'visible'})
|
151
|
+
@statusbar.hide()
|
152
|
+
expect($('.mercury-statusbar').css('visibility')).toEqual('hidden')
|