kiteditor 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/LICENSE +25 -0
  2. data/app/controllers/mercury/images_controller.rb +5 -0
  3. data/app/controllers/mercury_controller.rb +34 -0
  4. data/app/models/mercury/image.rb +17 -0
  5. data/app/views/layouts/mercury.html.erb +33 -0
  6. data/app/views/layouts/popup.html.haml +9 -0
  7. data/app/views/mercury/images/_list.html.haml +22 -0
  8. data/app/views/mercury/images/index.html.haml +4 -0
  9. data/app/views/mercury/images/index.js.erb +2 -0
  10. data/app/views/mercury/lightviews/about.html +11 -0
  11. data/app/views/mercury/modals/character.html +255 -0
  12. data/app/views/mercury/modals/htmleditor.html +13 -0
  13. data/app/views/mercury/modals/link.html +94 -0
  14. data/app/views/mercury/modals/media.html +1 -0
  15. data/app/views/mercury/modals/table.html +84 -0
  16. data/app/views/mercury/palettes/backcolor.html +73 -0
  17. data/app/views/mercury/palettes/forecolor.html +73 -0
  18. data/app/views/mercury/panels/history.html +3 -0
  19. data/app/views/mercury/panels/notes.html +3 -0
  20. data/app/views/mercury/panels/snippets.html +12 -0
  21. data/app/views/mercury/selects/formatblock.html +11 -0
  22. data/app/views/mercury/selects/style.html +5 -0
  23. data/app/views/mercury/snippets/example/options.html.erb +34 -0
  24. data/app/views/mercury/snippets/example/preview.html.erb +1 -0
  25. data/config/engine.rb +44 -0
  26. data/db/migrate/20110526035601_create_mercury_images.rb +11 -0
  27. data/features/loading/loading.feature +22 -0
  28. data/features/loading/navigating.feature +77 -0
  29. data/features/loading/user_interface.feature +67 -0
  30. data/features/regions/editable/advanced_editing.feature +0 -0
  31. data/features/regions/editable/basic_editing.feature +195 -0
  32. data/features/regions/editable/inserting_links.feature +98 -0
  33. data/features/regions/editable/inserting_media.feature +110 -0
  34. data/features/regions/editable/inserting_snippets.feature +102 -0
  35. data/features/regions/editable/inserting_special_characters.feature +24 -0
  36. data/features/regions/editable/inserting_tables.feature +109 -0
  37. data/features/regions/editable/pasting.feature +0 -0
  38. data/features/regions/editable/uploading_images.feature +0 -0
  39. data/features/regions/markupable/advanced_editing.feature +0 -0
  40. data/features/regions/markupable/basic_editing.feature +0 -0
  41. data/features/regions/markupable/inserting_links.feature +0 -0
  42. data/features/regions/markupable/inserting_media.feature +0 -0
  43. data/features/regions/markupable/inserting_snippets.feature +0 -0
  44. data/features/regions/markupable/inserting_special_characters.feature +0 -0
  45. data/features/regions/markupable/inserting_tables.feature +0 -0
  46. data/features/regions/markupable/uploading_images.feature +0 -0
  47. data/features/regions/snippetable/advanced_editing.feature +0 -0
  48. data/features/regions/snippetable/basic_editing.feature +0 -0
  49. data/features/regions/snippetable/inserting_snippets.feature +0 -0
  50. data/features/saving/saving.feature +33 -0
  51. data/features/step_definitions/debug_steps.rb +14 -0
  52. data/features/step_definitions/mercury_steps.rb +438 -0
  53. data/features/step_definitions/web_steps.rb +211 -0
  54. data/features/support/env.rb +46 -0
  55. data/features/support/mercury_contents.rb +25 -0
  56. data/features/support/mercury_selectors.rb +148 -0
  57. data/features/support/paths.rb +38 -0
  58. data/features/support/selectors.rb +44 -0
  59. data/lib/generators/mercury/install/install_generator.rb +49 -0
  60. data/lib/generators/mercury/install/templates/mongoid_paperclip_image.rb +17 -0
  61. data/lib/mercury/authentication.rb +8 -0
  62. data/lib/mercury-rails.rb +3 -0
  63. data/spec/javascripts/mercury/dialog_spec.js.coffee +281 -0
  64. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +37 -0
  65. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +37 -0
  66. data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +25 -0
  67. data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +30 -0
  68. data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +25 -0
  69. data/spec/javascripts/mercury/history_buffer_spec.js.coffee +76 -0
  70. data/spec/javascripts/mercury/lightview_spec.js.coffee +497 -0
  71. data/spec/javascripts/mercury/mercury_spec.js.coffee +132 -0
  72. data/spec/javascripts/mercury/modal_spec.js.coffee +504 -0
  73. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +30 -0
  74. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +29 -0
  75. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +220 -0
  76. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +167 -0
  77. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +52 -0
  78. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +160 -0
  79. data/spec/javascripts/mercury/native_extensions_spec.js.coffee +60 -0
  80. data/spec/javascripts/mercury/page_editor_spec.js.coffee +750 -0
  81. data/spec/javascripts/mercury/palette_spec.js.coffee +49 -0
  82. data/spec/javascripts/mercury/panel_spec.js.coffee +185 -0
  83. data/spec/javascripts/mercury/region_spec.js.coffee +298 -0
  84. data/spec/javascripts/mercury/regions/editable_spec.js.coffee +561 -0
  85. data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +367 -0
  86. data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +370 -0
  87. data/spec/javascripts/mercury/select_spec.js.coffee +49 -0
  88. data/spec/javascripts/mercury/snippet_spec.js.coffee +245 -0
  89. data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +184 -0
  90. data/spec/javascripts/mercury/statusbar_spec.js.coffee +150 -0
  91. data/spec/javascripts/mercury/table_editor_spec.js.coffee +194 -0
  92. data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +90 -0
  93. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +360 -0
  94. data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +118 -0
  95. data/spec/javascripts/mercury/toolbar_spec.js.coffee +222 -0
  96. data/spec/javascripts/mercury/tooltip_spec.js.coffee +186 -0
  97. data/spec/javascripts/mercury/uploader_spec.js.coffee +514 -0
  98. data/spec/javascripts/spec_helper.js +513 -0
  99. data/spec/javascripts/templates/mercury/dialog.html +2 -0
  100. data/spec/javascripts/templates/mercury/dialogs/backcolor.html +5 -0
  101. data/spec/javascripts/templates/mercury/dialogs/forecolor.html +5 -0
  102. data/spec/javascripts/templates/mercury/dialogs/formatblock.html +3 -0
  103. data/spec/javascripts/templates/mercury/dialogs/snippetpanel.html +16 -0
  104. data/spec/javascripts/templates/mercury/dialogs/style.html +3 -0
  105. data/spec/javascripts/templates/mercury/lightview.html +13 -0
  106. data/spec/javascripts/templates/mercury/modal.html +13 -0
  107. data/spec/javascripts/templates/mercury/modals/htmleditor.html +5 -0
  108. data/spec/javascripts/templates/mercury/modals/insertcharacter.html +5 -0
  109. data/spec/javascripts/templates/mercury/modals/insertlink.html +30 -0
  110. data/spec/javascripts/templates/mercury/modals/insertmedia.html +35 -0
  111. data/spec/javascripts/templates/mercury/modals/insertsnippet.html +6 -0
  112. data/spec/javascripts/templates/mercury/modals/inserttable.html +27 -0
  113. data/spec/javascripts/templates/mercury/page_editor.html +35 -0
  114. data/spec/javascripts/templates/mercury/palette.html +16 -0
  115. data/spec/javascripts/templates/mercury/panel.html +16 -0
  116. data/spec/javascripts/templates/mercury/region.html +2 -0
  117. data/spec/javascripts/templates/mercury/regions/editable.html +3 -0
  118. data/spec/javascripts/templates/mercury/regions/snippetable.html +4 -0
  119. data/spec/javascripts/templates/mercury/select.html +16 -0
  120. data/spec/javascripts/templates/mercury/snippet.html +1 -0
  121. data/spec/javascripts/templates/mercury/snippet_toolbar.html +16 -0
  122. data/spec/javascripts/templates/mercury/statusbar.html +8 -0
  123. data/spec/javascripts/templates/mercury/table_editor.html +65 -0
  124. data/spec/javascripts/templates/mercury/toolbar.button.html +64 -0
  125. data/spec/javascripts/templates/mercury/toolbar.button_group.html +9 -0
  126. data/spec/javascripts/templates/mercury/toolbar.expander.html +18 -0
  127. data/spec/javascripts/templates/mercury/toolbar.html +11 -0
  128. data/spec/javascripts/templates/mercury/tooltip.html +12 -0
  129. data/spec/javascripts/templates/mercury/uploader.html +11 -0
  130. data/vendor/assets/images/mercury/button.png +0 -0
  131. data/vendor/assets/images/mercury/close.png +0 -0
  132. data/vendor/assets/images/mercury/default-snippet.png +0 -0
  133. data/vendor/assets/images/mercury/loading-dark.gif +0 -0
  134. data/vendor/assets/images/mercury/loading-light.gif +0 -0
  135. data/vendor/assets/images/mercury/missing-image.png +0 -0
  136. data/vendor/assets/images/mercury/search-icon.png +0 -0
  137. data/vendor/assets/images/mercury/temp-logo.png +0 -0
  138. data/vendor/assets/images/mercury/toolbar/editable/buttons.png +0 -0
  139. data/vendor/assets/images/mercury/toolbar/primary/_expander.png +0 -0
  140. data/vendor/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
  141. data/vendor/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
  142. data/vendor/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
  143. data/vendor/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
  144. data/vendor/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
  145. data/vendor/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
  146. data/vendor/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
  147. data/vendor/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
  148. data/vendor/assets/images/mercury/toolbar/primary/preview.png +0 -0
  149. data/vendor/assets/images/mercury/toolbar/primary/redo.png +0 -0
  150. data/vendor/assets/images/mercury/toolbar/primary/save.png +0 -0
  151. data/vendor/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
  152. data/vendor/assets/images/mercury/toolbar/primary/undo.png +0 -0
  153. data/vendor/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
  154. data/vendor/assets/javascripts/mercury/dependencies/jquery-1.7.js +9300 -0
  155. data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +1328 -0
  156. data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.18.custom.min.js +356 -0
  157. data/vendor/assets/javascripts/mercury/dependencies/jquery-ui.1.8.13.custom.min.js +356 -0
  158. data/vendor/assets/javascripts/mercury/dependencies/jquery.additions.js +206 -0
  159. data/vendor/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +527 -0
  160. data/vendor/assets/javascripts/mercury/dependencies/liquidmetal.js +88 -0
  161. data/vendor/assets/javascripts/mercury/dependencies/showdown.js +1340 -0
  162. data/vendor/assets/javascripts/mercury/dialog.js.coffee +159 -0
  163. data/vendor/assets/javascripts/mercury/dialogs/backcolor.js.coffee +6 -0
  164. data/vendor/assets/javascripts/mercury/dialogs/forecolor.js.coffee +6 -0
  165. data/vendor/assets/javascripts/mercury/dialogs/formatblock.js.coffee +4 -0
  166. data/vendor/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +10 -0
  167. data/vendor/assets/javascripts/mercury/dialogs/style.js.coffee +4 -0
  168. data/vendor/assets/javascripts/mercury/finalize.js.coffee +3 -0
  169. data/vendor/assets/javascripts/mercury/history_buffer.js.coffee +30 -0
  170. data/vendor/assets/javascripts/mercury/lightview.js.coffee +205 -0
  171. data/vendor/assets/javascripts/mercury/locales/da.locale.js.coffee +0 -0
  172. data/vendor/assets/javascripts/mercury/locales/de.locale.js.coffee +206 -0
  173. data/vendor/assets/javascripts/mercury/locales/es.locale.js.coffee +211 -0
  174. data/vendor/assets/javascripts/mercury/locales/example.local.js.coffee +211 -0
  175. data/vendor/assets/javascripts/mercury/locales/fr.locale.js.coffee +211 -0
  176. data/vendor/assets/javascripts/mercury/locales/it.locale.js.coffee +208 -0
  177. data/vendor/assets/javascripts/mercury/locales/ko.local.js.coffee +206 -0
  178. data/vendor/assets/javascripts/mercury/locales/nl.locale.js.coffee +206 -0
  179. data/vendor/assets/javascripts/mercury/locales/pt.locale.js.coffee +211 -0
  180. data/vendor/assets/javascripts/mercury/locales/sv.local.js.coffee +209 -0
  181. data/vendor/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +213 -0
  182. data/vendor/assets/javascripts/mercury/mercury.js.coffee +109 -0
  183. data/vendor/assets/javascripts/mercury/modal.js.coffee +204 -0
  184. data/vendor/assets/javascripts/mercury/modals/htmleditor.js.coffee +11 -0
  185. data/vendor/assets/javascripts/mercury/modals/insertcharacter.js.coffee +4 -0
  186. data/vendor/assets/javascripts/mercury/modals/insertlink.js.coffee +95 -0
  187. data/vendor/assets/javascripts/mercury/modals/insertmedia.js.coffee +107 -0
  188. data/vendor/assets/javascripts/mercury/modals/insertsnippet.js.coffee +12 -0
  189. data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +54 -0
  190. data/vendor/assets/javascripts/mercury/native_extensions.js.coffee +55 -0
  191. data/vendor/assets/javascripts/mercury/page_editor.js.coffee +241 -0
  192. data/vendor/assets/javascripts/mercury/palette.js.coffee +29 -0
  193. data/vendor/assets/javascripts/mercury/panel.js.coffee +115 -0
  194. data/vendor/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +28 -0
  195. data/vendor/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +9 -0
  196. data/vendor/assets/javascripts/mercury/region.js.coffee +107 -0
  197. data/vendor/assets/javascripts/mercury/regions/editable.js.coffee +600 -0
  198. data/vendor/assets/javascripts/mercury/regions/markupable.js.coffee +398 -0
  199. data/vendor/assets/javascripts/mercury/regions/simple.js.coffee +339 -0
  200. data/vendor/assets/javascripts/mercury/regions/snippetable.js.coffee +124 -0
  201. data/vendor/assets/javascripts/mercury/select.js.coffee +44 -0
  202. data/vendor/assets/javascripts/mercury/snippet.js.coffee +104 -0
  203. data/vendor/assets/javascripts/mercury/snippet_toolbar.js.coffee +72 -0
  204. data/vendor/assets/javascripts/mercury/statusbar.js.coffee +51 -0
  205. data/vendor/assets/javascripts/mercury/support/history.js +1 -0
  206. data/vendor/assets/javascripts/mercury/table_editor.js.coffee +265 -0
  207. data/vendor/assets/javascripts/mercury/toolbar.button.js.coffee +173 -0
  208. data/vendor/assets/javascripts/mercury/toolbar.button_group.js.coffee +42 -0
  209. data/vendor/assets/javascripts/mercury/toolbar.expander.js.coffee +56 -0
  210. data/vendor/assets/javascripts/mercury/toolbar.js.coffee +86 -0
  211. data/vendor/assets/javascripts/mercury/tooltip.js.coffee +74 -0
  212. data/vendor/assets/javascripts/mercury/uploader.js.coffee +227 -0
  213. data/vendor/assets/javascripts/mercury.js +479 -0
  214. data/vendor/assets/javascripts/mercury_loader.js +193 -0
  215. data/vendor/assets/javascripts/mercury_overrides.js +6 -0
  216. data/vendor/assets/javascripts/popup.js +8 -0
  217. data/vendor/assets/stylesheets/mercury/all_images.css.erb +89 -0
  218. data/vendor/assets/stylesheets/mercury/dialog.css +208 -0
  219. data/vendor/assets/stylesheets/mercury/lightview.css +151 -0
  220. data/vendor/assets/stylesheets/mercury/mercury.css +151 -0
  221. data/vendor/assets/stylesheets/mercury/modal.css +183 -0
  222. data/vendor/assets/stylesheets/mercury/statusbar.css +32 -0
  223. data/vendor/assets/stylesheets/mercury/toolbar.css +304 -0
  224. data/vendor/assets/stylesheets/mercury/tooltip.css +26 -0
  225. data/vendor/assets/stylesheets/mercury/uploader.css +111 -0
  226. data/vendor/assets/stylesheets/mercury.css +28 -0
  227. data/vendor/assets/stylesheets/mercury_overrides.css +17 -0
  228. data/vendor/assets/stylesheets/popup.css.erb +37 -0
  229. metadata +634 -0
@@ -0,0 +1,561 @@
1
+ describe "Mercury.Regions.Editable", ->
2
+
3
+ template 'mercury/regions/editable.html'
4
+
5
+ beforeEach ->
6
+ @regionElement = $('#editable_region1')
7
+
8
+ describe "constructor", ->
9
+
10
+ beforeEach ->
11
+ @buildSpy = spyOn(Mercury.Regions.Editable.prototype, 'build').andCallFake(=>)
12
+ @bindEventsSpy = spyOn(Mercury.Regions.Editable.prototype, 'bindEvents').andCallFake(=>)
13
+
14
+ it "expects an element and window", ->
15
+ @region = new Mercury.Regions.Editable(@regionElement, window)
16
+ expect(@region.element.get(0)).toEqual($('#editable_region1').get(0))
17
+ expect(@region.window).toEqual(window)
18
+
19
+ it "accepts options", ->
20
+ @region = new Mercury.Regions.Editable(@regionElement, window, {foo: 'something'})
21
+ expect(@region.options).toEqual({foo: 'something'})
22
+
23
+ it "sets it's type", ->
24
+ @region = new Mercury.Regions.Editable(@regionElement, window)
25
+ expect(@region.type).toEqual('editable')
26
+
27
+ it "calls build", ->
28
+ @region = new Mercury.Regions.Editable(@regionElement, window)
29
+ expect(@buildSpy.callCount).toEqual(1)
30
+
31
+ it "calls bindEvents", ->
32
+ @region = new Mercury.Regions.Editable(@regionElement, window)
33
+ expect(@bindEventsSpy.callCount).toEqual(1)
34
+
35
+
36
+ describe "#build", ->
37
+
38
+ it "sets the content to   if the content is blank [mozilla only]", ->
39
+
40
+ it "sets the current overflow to the element data", ->
41
+
42
+ it "resets the elements overflow to auto", ->
43
+
44
+ it "sets the container to have special handling if it's not a div [mozilla only]", ->
45
+
46
+ it "turns on contentEditable", ->
47
+
48
+ it "sets the version to 1 on any snippets within it", ->
49
+
50
+ it "enables and disables some basic contentEditable features (only once)", ->
51
+
52
+ it "sets mercuryEditing on the document", ->
53
+
54
+
55
+ describe "observed events", ->
56
+
57
+ describe "custom event: region:update", ->
58
+
59
+ it "sets a timeout and forces a selection", ->
60
+
61
+ it "sets up the table editor if we're in a table", ->
62
+
63
+ it "displays a tooltip if the selection is within an anchor", ->
64
+
65
+ it "hides the tooltip if the selection is not within an anchor", ->
66
+
67
+ it "does nothing if previewing", ->
68
+
69
+ it "does nothing if it's not the active region", ->
70
+
71
+ describe "custom event: possible:drop", ->
72
+
73
+ it "does nothing if previewing", ->
74
+
75
+ describe "when a snippet image is in the content", ->
76
+
77
+ it "calls focus", ->
78
+
79
+ it "calls displayOptionsFor for the snippet", ->
80
+
81
+ it "calls the native undo", ->
82
+
83
+ describe "dragenter", ->
84
+
85
+ it "does nothing if previewing", ->
86
+
87
+ it "prevents the default action if shift is pressed", ->
88
+
89
+ describe "dragover", ->
90
+
91
+ it "does nothing if previewing", ->
92
+
93
+ it "prevents the default action if shift is pressed", ->
94
+
95
+ describe "drop", ->
96
+
97
+ it "triggers the possible:drop event in a setTimeout", ->
98
+
99
+ it "does nothing if previewing", ->
100
+
101
+ describe "when a file is dropped", ->
102
+
103
+ it "prevents the default action", ->
104
+
105
+ it "calls focus", ->
106
+
107
+ it "loads the uploader", ->
108
+
109
+ describe "paste", ->
110
+
111
+ it "tells mercury that changes have been made", ->
112
+
113
+ # mozilla: doesn't seem to handle pasting in elements besides divs.
114
+ it "prevents the default if it's a special container", ->
115
+
116
+ it "calls handle paste with the pre-paste content in a setTimeout", ->
117
+
118
+ it "does nothing if previewing", ->
119
+
120
+ it "does nothing if it's not the active region", ->
121
+
122
+ describe "focus", ->
123
+
124
+ it "sets the active region", ->
125
+
126
+ it "forces a selection", ->
127
+
128
+ it "triggers a region:focused event", ->
129
+
130
+ it "does nothing if previewing", ->
131
+
132
+ describe "blur", ->
133
+
134
+ it "triggers a region:blurred event", ->
135
+
136
+ it "hides the tooltip", ->
137
+
138
+ it "does nothing if previewing", ->
139
+
140
+ describe "click", ->
141
+
142
+ it "sets anchor targets to top if previewing", ->
143
+
144
+ describe "dblclick", ->
145
+
146
+ it "does nothing if previewing", ->
147
+
148
+ describe "on an image", ->
149
+
150
+ it "selects the image element", ->
151
+
152
+ it "triggers the button event with the insertMedia action", ->
153
+
154
+ describe "mouseup", ->
155
+
156
+ it "calls pushHistory", ->
157
+
158
+ it "triggers the region:update event", ->
159
+
160
+ it "does nothing if previewing", ->
161
+
162
+ describe "keydown", ->
163
+
164
+ it "does nothing if previewing", ->
165
+
166
+ it "tells mercury that changes have been made", ->
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
+ describe "if this isn't the active region", ->
214
+
215
+ it "calls focus on the element", ->
216
+
217
+ it "collapses the selection", ->
218
+
219
+ it "sets a timeout that forces the selection", ->
220
+
221
+ it "triggers the region:update event", ->
222
+
223
+
224
+ describe "#content", ->
225
+
226
+ describe "when setting the content", ->
227
+
228
+ it "sanitizes the html (in case there's anything malformed)", ->
229
+
230
+ it "fills in any snippets with their stored content", ->
231
+
232
+ it "sets the html", ->
233
+
234
+ it "creates a selection if there's markers", ->
235
+
236
+ describe "when getting the content", ->
237
+
238
+ it "removes any meta tags", ->
239
+
240
+ it "places markers if asked", ->
241
+
242
+ it "sanitizes the html (in case there's anything malformed)", ->
243
+
244
+ it "replaces the snippet contents with an identifier if asked", ->
245
+
246
+ it "returns the content", ->
247
+
248
+
249
+ describe "#togglePreview", ->
250
+
251
+ describe "when not previewing", ->
252
+
253
+ it "replaces the content with whatever the content is", ->
254
+
255
+ it "turns contentEditable off", ->
256
+
257
+ it "sets the overflow back to what was stored on the element", ->
258
+
259
+ it "blurs the element", ->
260
+
261
+ describe "when previewing", ->
262
+
263
+ it "turns contentEditable on", ->
264
+
265
+ it "sets the overflow to auto", ->
266
+
267
+
268
+ describe "#execCommand", ->
269
+
270
+ describe "when a handler exists", ->
271
+
272
+ it "calls it if one is defined in Mercury.config.behaviors", ->
273
+
274
+ it "calls it if one is defined in actions", ->
275
+
276
+ describe "when a handler doesn't exist", ->
277
+
278
+ it "gets the html value of a jQuery element if one is passed in with the insertHTML action", ->
279
+
280
+ it "calls the native execCommand", ->
281
+
282
+ # mozilla has a weird bug when indenting.. if there's only one element in the region it will put the blockquote
283
+ # outside the region, so we have to remove it so it seems like nothing happened.
284
+ it "removes the previous sibling if it doesn't match what used to be there on indent [mozilla only]", ->
285
+
286
+
287
+ describe "#pushHistory", ->
288
+
289
+ it "clears the history timeout", ->
290
+
291
+ it "immediately pushes to the history buffer", ->
292
+
293
+ it "remembers the last key pressed if one was passed", ->
294
+
295
+ describe "when pressing enter, delete, or backspace", ->
296
+
297
+ it "immediately pushes to the history buffer", ->
298
+
299
+ it "only pushes once for each keyCode (eg. enter enter enter results in one push)", ->
300
+
301
+ describe "when pressing any other key", ->
302
+
303
+ it "waits for 2.5 seconds and then pushes to the history buffer", ->
304
+
305
+
306
+ describe "#selection", ->
307
+
308
+ it "returns a new instance of the selection helper class", ->
309
+
310
+
311
+ describe "#path", ->
312
+
313
+ it "returns an array of parents from the element with the selection to the region element", ->
314
+
315
+ it "returns an empty array if there's no selection", ->
316
+
317
+
318
+ describe "#currentElement", ->
319
+
320
+ it "returns the element that's closest to the node or element with the selection", ->
321
+
322
+ it "returns an empty array if there's no selection", ->
323
+
324
+
325
+ describe "#handlePaste", ->
326
+
327
+
328
+
329
+ describe "Mercury.Regions.Editable.actions", ->
330
+
331
+ template 'mercury/regions/editable.html'
332
+
333
+ beforeEach ->
334
+ #@region = new Mercury.Regions.Editable($('#editable_region1'), window)
335
+ #@actions = Mercury.Regions.Editable.actions
336
+
337
+ #
338
+ # behaviors
339
+ #
340
+
341
+ describe "*horizontalRule", ->
342
+
343
+ it "replaces the selection with an hr tag", ->
344
+
345
+
346
+ describe "*htmlEditor", ->
347
+
348
+ it "opens a modal", ->
349
+
350
+ #
351
+ # native actions
352
+ #
353
+
354
+ describe "-formatblock", ->
355
+
356
+ it "wraps the line of the selection in a given tag", ->
357
+
358
+
359
+ describe "-foreColor", ->
360
+
361
+ it "wraps the selection in a span styled with the color", ->
362
+
363
+
364
+ describe "-bold", ->
365
+
366
+ it "wraps the selection in a strong or s tag", ->
367
+
368
+
369
+ describe "-italic", ->
370
+
371
+ it "wraps the selection in an em or i tag", ->
372
+
373
+
374
+ describe "-strikethrough", ->
375
+
376
+ it "wraps the selection in a strike tag", ->
377
+
378
+
379
+ describe "-underline", ->
380
+
381
+ it "wraps the selection in a u tag", ->
382
+
383
+
384
+ describe "-subscript", ->
385
+
386
+ it "wraps the selection in a sub tag", ->
387
+
388
+
389
+ describe "-superscript", ->
390
+
391
+ it "wraps the selection in a sup tag", ->
392
+
393
+
394
+ describe "-justifyLeft", ->
395
+
396
+ it "justifies the text to the left", ->
397
+
398
+
399
+ describe "-justifyCenter", ->
400
+
401
+ it "justifies the test to be in the center", ->
402
+
403
+
404
+ describe "-justifyRight", ->
405
+
406
+ it "justifies the text to the right", ->
407
+
408
+
409
+ describe "-justifyFull", ->
410
+
411
+ it "styles the text to be fully justified", ->
412
+
413
+
414
+ describe "-insertUnorderedList", ->
415
+
416
+ it "wraps the line of the selection in an unordered list", ->
417
+
418
+
419
+ describe "-insertOrderedList", ->
420
+
421
+ it "wraps the line of the selection in an ordered list", ->
422
+
423
+
424
+ describe "-outdent", ->
425
+
426
+ it "unwraps the line of the selection in a blockquote tag", ->
427
+
428
+
429
+ describe "-indent", ->
430
+
431
+ it "wraps the line of the selection in a blockquote tag", ->
432
+
433
+ #
434
+ # custom actions
435
+ #
436
+
437
+ describe ".undo", ->
438
+
439
+ it "calls undo on the history buffer", ->
440
+
441
+ it "sets the contents", ->
442
+
443
+
444
+ describe ".redo", ->
445
+
446
+ it "calls redo on the history buffer", ->
447
+
448
+ it "sets the contents", ->
449
+
450
+
451
+ describe ".style", ->
452
+
453
+ it "wraps the selection in a span tag with a given class", ->
454
+
455
+
456
+ describe ".backColor", ->
457
+
458
+ it "wraps the selection in a span styled with the background color", ->
459
+
460
+
461
+ describe ".removeFormatting", ->
462
+
463
+ it "replaces the selection with the text content of the selection", ->
464
+
465
+
466
+ describe ".overline", ->
467
+
468
+ it "wraps the selection in a span styled with an overline", ->
469
+
470
+
471
+ describe ".insertRowBefore", ->
472
+
473
+ it "calls addRow on the table editor", ->
474
+
475
+
476
+ describe ".insertRowAfter", ->
477
+
478
+ it "calls addRow on the table editor", ->
479
+
480
+
481
+ describe ".deleteRow", ->
482
+
483
+ it "calls removeRow on the table editor", ->
484
+
485
+
486
+ describe ".insertColumnBefore", ->
487
+
488
+ it "calls addColumn on the table editor", ->
489
+
490
+
491
+ describe ".insertColumnAfter", ->
492
+
493
+ it "calls addColumn on the table editor", ->
494
+
495
+
496
+ describe ".deleteColumn", ->
497
+
498
+ it "calls removeColumn on the table editor", ->
499
+
500
+
501
+ describe ".increaseColspan", ->
502
+
503
+ it "calls increaseColspan on the table editor", ->
504
+
505
+
506
+ describe ".decreaseColspan", ->
507
+
508
+ it "calls decreaseColspan on the table editor", ->
509
+
510
+
511
+ describe ".increaseRowspan", ->
512
+
513
+ it "calls increaseRowspan on the table editor", ->
514
+
515
+
516
+ describe ".decreaseRowspan", ->
517
+
518
+ it "calls decreaseRowspan on the table editor", ->
519
+
520
+
521
+ describe ".replaceHTML", ->
522
+
523
+ it "sets the content", ->
524
+
525
+
526
+ describe ".insertImage", ->
527
+
528
+ it "replaces the selection with an image tag", ->
529
+
530
+
531
+ describe ".insertLink", ->
532
+
533
+ it "inserts a link node", ->
534
+
535
+
536
+ describe ".replaceLink", ->
537
+
538
+ it "selects the anchor tag that we're going to replace", ->
539
+
540
+ it "replaces the selection with an anchor tag", ->
541
+
542
+
543
+ describe ".insertSnippet", ->
544
+
545
+ it "selects any snippets that have the same identity", ->
546
+
547
+ it "replaces the selection with the content returned from the snippets getHTML", ->
548
+
549
+
550
+ describe ".editSnippet", ->
551
+
552
+ it "does nothing if there's no snippet being hovered over", ->
553
+
554
+ it "calls displayOntions for the snippet", ->
555
+
556
+
557
+ describe ".removeSnippet", ->
558
+
559
+ it "calls remove on the snippet element", ->
560
+
561
+ it "fires a hide:toolbar event", ->