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.
Files changed (176) hide show
  1. data/LICENSE +5 -0
  2. data/{README.rdoc → README.md} +150 -60
  3. data/VERSION +1 -1
  4. data/annotated_source.template +57 -0
  5. data/app/controllers/mercury_controller.rb +8 -4
  6. data/app/models/image.rb +2 -2
  7. data/app/views/layouts/mercury.html.erb +14 -0
  8. data/app/views/mercury/lightviews/about.html +7 -0
  9. data/app/views/mercury/lightviews/imageprocessor.html +3 -0
  10. data/app/views/mercury/modals/character.html +255 -0
  11. data/app/views/mercury/modals/htmleditor.html +13 -0
  12. data/app/views/mercury/modals/link.html +75 -0
  13. data/app/views/mercury/modals/media.html +82 -0
  14. data/app/views/mercury/modals/sanitizer.html +9 -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.html.erb +1 -0
  24. data/app/views/mercury/snippets/example_options.html.erb +23 -0
  25. data/config/routes.rb +1 -1
  26. data/features/editing/basic.feature +1 -1
  27. data/features/support/paths.rb +1 -0
  28. data/lib/generators/mercury/install/install_generator.rb +14 -0
  29. data/mercury-rails.gemspec +115 -106
  30. data/spec/javascripts/mercury/dialog_spec.js.coffee +54 -38
  31. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +1 -1
  32. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +1 -1
  33. data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +1 -1
  34. data/spec/javascripts/mercury/dialogs/{objectspanel_spec.js.coffee → snippetpanel_spec.js.coffee} +4 -4
  35. data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +1 -1
  36. data/spec/javascripts/mercury/history_buffer_spec.js.coffee +0 -1
  37. data/spec/javascripts/mercury/lightview_spec.js.coffee +448 -0
  38. data/spec/javascripts/mercury/mercury_spec.js.coffee +1 -1
  39. data/spec/javascripts/mercury/modal_spec.js.coffee +474 -0
  40. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +1 -1
  41. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +1 -1
  42. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +8 -2
  43. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +1 -1
  44. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +1 -1
  45. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +1 -1
  46. data/spec/javascripts/mercury/native_extensions_spec.js.coffee +1 -1
  47. data/spec/javascripts/mercury/page_editor_spec.js.coffee +160 -20
  48. data/spec/javascripts/mercury/palette_spec.js.coffee +1 -1
  49. data/spec/javascripts/mercury/panel_spec.js.coffee +1 -1
  50. data/spec/javascripts/mercury/region_spec.js.coffee +1 -1
  51. data/spec/javascripts/mercury/regions/editable_spec.js.coffee +191 -6
  52. data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +369 -0
  53. data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +1 -1
  54. data/spec/javascripts/mercury/select_spec.js.coffee +1 -1
  55. data/spec/javascripts/mercury/snippet_spec.js.coffee +3 -3
  56. data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +2 -2
  57. data/spec/javascripts/mercury/statusbar_spec.js.coffee +91 -17
  58. data/spec/javascripts/mercury/table_editor_spec.js.coffee +5 -1
  59. data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +1 -1
  60. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +1 -1
  61. data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +1 -1
  62. data/spec/javascripts/mercury/toolbar_spec.js.coffee +70 -15
  63. data/spec/javascripts/mercury/tooltip_spec.js.coffee +1 -1
  64. data/spec/javascripts/mercury/uploader_spec.js.coffee +9 -1
  65. data/spec/javascripts/templates/mercury/dialogs/{objectspanel.html → snippetpanel.html} +0 -0
  66. data/spec/javascripts/templates/mercury/lightview.html +13 -0
  67. data/spec/javascripts/templates/mercury/modal.html +13 -0
  68. data/spec/javascripts/templates/mercury/page_editor.html +11 -1
  69. data/spec/javascripts/templates/mercury/statusbar.html +1 -0
  70. data/spec/javascripts/templates/mercury/toolbar.html +1 -0
  71. data/{app → vendor}/assets/images/mercury/button.png +0 -0
  72. data/{app → vendor}/assets/images/mercury/clippy.png +0 -0
  73. data/{app → vendor}/assets/images/mercury/default-snippet.png +0 -0
  74. data/{app → vendor}/assets/images/mercury/loading-dark.gif +0 -0
  75. data/{app → vendor}/assets/images/mercury/loading-light.gif +0 -0
  76. data/{app → vendor}/assets/images/mercury/search-icon.png +0 -0
  77. data/vendor/assets/images/mercury/temp-logo.png +0 -0
  78. data/{app → vendor}/assets/images/mercury/toolbar/editable/buttons.png +0 -0
  79. data/{app → vendor}/assets/images/mercury/toolbar/primary/_expander.png +0 -0
  80. data/{app → vendor}/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
  81. data/{app → vendor}/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
  82. data/{app → vendor}/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
  83. data/{app → vendor}/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
  84. data/{app → vendor}/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
  85. data/{app → vendor}/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
  86. data/{app → vendor}/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
  87. data/{app → vendor}/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
  88. data/{app → vendor}/assets/images/mercury/toolbar/primary/preview.png +0 -0
  89. data/{app → vendor}/assets/images/mercury/toolbar/primary/redo.png +0 -0
  90. data/{app → vendor}/assets/images/mercury/toolbar/primary/save.png +0 -0
  91. data/{app/assets/images/mercury/toolbar/primary/objectspanel.png → vendor/assets/images/mercury/toolbar/primary/snippetpanel.png} +0 -0
  92. data/{app → vendor}/assets/images/mercury/toolbar/primary/undo.png +0 -0
  93. data/{app → vendor}/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
  94. data/vendor/assets/javascripts/mercury.js +302 -0
  95. data/vendor/assets/javascripts/mercury/dialog.js.coffee +157 -0
  96. data/{app → vendor}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
  97. data/{app → vendor}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +0 -0
  98. data/{app → vendor}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
  99. data/{app → vendor}/assets/javascripts/mercury/dialogs/objectspanel.js.coffee +1 -1
  100. data/{app → vendor}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
  101. data/{app → vendor}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
  102. data/vendor/assets/javascripts/mercury/lightview.js.coffee +156 -0
  103. data/vendor/assets/javascripts/mercury/lightviews/imageprocessor.js.coffee +2 -0
  104. data/vendor/assets/javascripts/mercury/mercury.js.coffee +63 -0
  105. data/{app → vendor}/assets/javascripts/mercury/modal.js.coffee +25 -17
  106. data/{app → vendor}/assets/javascripts/mercury/modals/htmleditor.js.coffee +0 -0
  107. data/{app → vendor}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +0 -0
  108. data/{app → vendor}/assets/javascripts/mercury/modals/insertlink.js.coffee +3 -0
  109. data/{app → vendor}/assets/javascripts/mercury/modals/insertmedia.js.coffee +10 -2
  110. data/{app → vendor}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +0 -0
  111. data/{app → vendor}/assets/javascripts/mercury/modals/inserttable.js.coffee +2 -2
  112. data/{app → vendor}/assets/javascripts/mercury/native_extensions.js.coffee +0 -0
  113. data/{app → vendor}/assets/javascripts/mercury/page_editor.js.coffee +44 -13
  114. data/{app → vendor}/assets/javascripts/mercury/palette.js.coffee +0 -0
  115. data/{app → vendor}/assets/javascripts/mercury/panel.js.coffee +0 -0
  116. data/{app → vendor}/assets/javascripts/mercury/region.js.coffee +0 -0
  117. data/{app → vendor}/assets/javascripts/mercury/regions/editable.js.coffee +58 -12
  118. data/{app → vendor}/assets/javascripts/mercury/regions/markupable.js.coffee +26 -24
  119. data/{app → vendor}/assets/javascripts/mercury/regions/snippetable.js.coffee +0 -0
  120. data/{app → vendor}/assets/javascripts/mercury/select.js.coffee +3 -0
  121. data/{app → vendor}/assets/javascripts/mercury/snippet.js.coffee +9 -5
  122. data/{app → vendor}/assets/javascripts/mercury/snippet_toolbar.js.coffee +0 -0
  123. data/vendor/assets/javascripts/mercury/statusbar.js.coffee +51 -0
  124. data/{app → vendor}/assets/javascripts/mercury/table_editor.js.coffee +9 -8
  125. data/{app → vendor}/assets/javascripts/mercury/toolbar.button.js.coffee +0 -0
  126. data/{app → vendor}/assets/javascripts/mercury/toolbar.button_group.js.coffee +0 -0
  127. data/{app → vendor}/assets/javascripts/mercury/toolbar.expander.js.coffee +0 -0
  128. data/{app → vendor}/assets/javascripts/mercury/toolbar.js.coffee +14 -1
  129. data/{app → vendor}/assets/javascripts/mercury/tooltip.js.coffee +3 -0
  130. data/{app → vendor}/assets/javascripts/mercury/uploader.js.coffee +22 -13
  131. data/vendor/assets/javascripts/{jquery-1.6.js → mercury_dependencies/jquery-1.6.js} +0 -0
  132. data/vendor/assets/javascripts/{jquery-ui-1.8.13.custom.js → mercury_dependencies/jquery-ui-1.8.13.custom.js} +0 -0
  133. data/vendor/assets/javascripts/{jquery.additions.js → mercury_dependencies/jquery.additions.js} +0 -0
  134. data/vendor/assets/javascripts/{liquidmetal.js → mercury_dependencies/liquidmetal.js} +0 -0
  135. data/vendor/assets/javascripts/{showdown.js → mercury_dependencies/showdown.js} +0 -0
  136. data/vendor/assets/javascripts/mercury_loader.js +191 -0
  137. data/{app → vendor}/assets/stylesheets/mercury.css +3 -6
  138. data/vendor/assets/stylesheets/mercury/dialog.css +199 -0
  139. data/vendor/assets/stylesheets/mercury/lightview.css +92 -0
  140. data/vendor/assets/stylesheets/mercury/mercury.css +134 -0
  141. data/vendor/assets/stylesheets/mercury/modal.css +191 -0
  142. data/{app/assets/stylesheets/mercury/statusbar.scss → vendor/assets/stylesheets/mercury/statusbar.css} +9 -1
  143. data/vendor/assets/stylesheets/mercury/toolbar.css +329 -0
  144. data/{app/assets/stylesheets/mercury/tooltip.scss → vendor/assets/stylesheets/mercury/tooltip.css} +7 -7
  145. data/vendor/assets/stylesheets/mercury/uploader.css +111 -0
  146. metadata +230 -225
  147. data/app/assets/images/mercury/toolbar/markupable/buttons.png +0 -0
  148. data/app/assets/images/mercury/toolbar/primary/todospanel.png +0 -0
  149. data/app/assets/javascripts/mercury.js +0 -30
  150. data/app/assets/javascripts/mercury/dialog.js.coffee +0 -75
  151. data/app/assets/javascripts/mercury/mercury.js.coffee +0 -286
  152. data/app/assets/javascripts/mercury/statusbar.js.coffee +0 -29
  153. data/app/assets/javascripts/mercury_loader.js +0 -98
  154. data/app/assets/stylesheets/mercury/dialog.scss +0 -179
  155. data/app/assets/stylesheets/mercury/mercury.scss +0 -127
  156. data/app/assets/stylesheets/mercury/modal.scss +0 -194
  157. data/app/assets/stylesheets/mercury/toolbar.scss +0 -415
  158. data/app/assets/stylesheets/mercury/uploader.scss +0 -109
  159. data/app/views/layouts/mercury.html.haml +0 -8
  160. data/app/views/mercury/modals/character.html.haml +0 -252
  161. data/app/views/mercury/modals/htmleditor.html.haml +0 -8
  162. data/app/views/mercury/modals/link.html.haml +0 -31
  163. data/app/views/mercury/modals/media.html.haml +0 -33
  164. data/app/views/mercury/modals/sanitizer.html.haml +0 -4
  165. data/app/views/mercury/modals/table.html.haml +0 -49
  166. data/app/views/mercury/palettes/backcolor.html.haml +0 -79
  167. data/app/views/mercury/palettes/forecolor.html.haml +0 -79
  168. data/app/views/mercury/panels/history.html.haml +0 -0
  169. data/app/views/mercury/panels/notes.html.haml +0 -0
  170. data/app/views/mercury/panels/snippets.html.haml +0 -10
  171. data/app/views/mercury/selects/formatblock.html.haml +0 -10
  172. data/app/views/mercury/selects/style.html.haml +0 -4
  173. data/app/views/mercury/snippets/example.html.haml +0 -2
  174. data/app/views/mercury/snippets/example_options.html.haml +0 -16
  175. data/log/.gitkeep +0 -0
  176. data/spec/javascripts/mercury/regions/_markupable_.js.coffee +0 -0
@@ -1,4 +1,4 @@
1
- require '/assets/mercury/mercury.js'
1
+ require '/assets/mercury.js'
2
2
 
3
3
  describe "Mercury.tableEditor", ->
4
4
 
@@ -29,6 +29,10 @@ describe "Mercury.tableEditor", ->
29
29
  expect(Mercury.tableEditor.table).toEqual(@table)
30
30
  expect(Mercury.tableEditor.cell).toEqual(@cell)
31
31
 
32
+ it "accepts content that will be placed inside cells", ->
33
+ Mercury.tableEditor(@table, @cell, ' ')
34
+ expect(Mercury.tableEditor.cellContent).toEqual(' ')
35
+
32
36
  it "sets row based on where the cell is", ->
33
37
  Mercury.tableEditor(@table, @cell)
34
38
  expect(Mercury.tableEditor.row.get(0)).toEqual(@table.find('tr').get(0))
@@ -1,4 +1,4 @@
1
- require '/assets/mercury/mercury.js'
1
+ require '/assets/mercury.js'
2
2
 
3
3
  describe "Mercury.Toolbar.ButtonGroup", ->
4
4
 
@@ -1,4 +1,4 @@
1
- require '/assets/mercury/mercury.js'
1
+ require '/assets/mercury.js'
2
2
 
3
3
  describe "Mercury.Toolbar.Button", ->
4
4
 
@@ -1,4 +1,4 @@
1
- require '/assets/mercury/mercury.js'
1
+ require '/assets/mercury.js'
2
2
 
3
3
  describe "Mercury.Toolbar.Expander", ->
4
4
 
@@ -1,10 +1,11 @@
1
- require '/assets/mercury/mercury.js'
1
+ require '/assets/mercury.js'
2
2
 
3
3
  describe "Mercury.Toolbar", ->
4
4
 
5
5
  template 'mercury/toolbar.html'
6
6
 
7
7
  beforeEach ->
8
+ $.fx.off = true
8
9
  ajaxSpy = spyOn($, 'ajax').andCallFake (url, options) =>
9
10
  options.success('data') if options.success
10
11
 
@@ -29,26 +30,18 @@ describe "Mercury.Toolbar", ->
29
30
  expect(@bindEventsSpy.callCount).toEqual(1)
30
31
 
31
32
 
32
- describe "#height", ->
33
-
34
- beforeEach ->
35
- spyOn(Mercury.Toolbar.prototype, 'buildButton').andCallFake(=> $('<div>'))
36
- spyOn(Mercury.Toolbar.prototype, 'bindEvents').andCallFake(=>)
37
- @toolbar = new Mercury.Toolbar({appendTo: '#test'})
38
-
39
- it "knows it's own height", ->
40
- expect(@toolbar.height()).toEqual(200) # styled with css in the template
41
-
42
-
43
33
  describe "#build", ->
44
34
 
45
35
  beforeEach ->
46
36
  @buildButtonSpy = spyOn(Mercury.Toolbar.prototype, 'buildButton').andCallFake(=> $('<div>'))
47
- @toolbar = new Mercury.Toolbar({appendTo: '#toolbar_container'})
37
+ @toolbar = new Mercury.Toolbar({appendTo: '#toolbar_container', visible: false})
48
38
 
49
39
  it "builds an element", ->
50
40
  expect($('.mercury-toolbar-container').length).toEqual(1)
51
41
 
42
+ it "hides the element if options.visible is false", ->
43
+ expect($('.mercury-toolbar-container').css('display')).toEqual('none')
44
+
52
45
  it "can append to any element", ->
53
46
  expect($('#toolbar_container .mercury-toolbar-container').length).toEqual(1)
54
47
 
@@ -132,7 +125,6 @@ describe "Mercury.Toolbar", ->
132
125
  Mercury.trigger('region:focused', {region: {type: 'markupable'}})
133
126
  expect($('.mercury.editable-toolbar').hasClass('disabled')).toEqual(false)
134
127
 
135
-
136
128
  describe "custom event: region:blurred", ->
137
129
 
138
130
  it "disables toolbars for the region type", ->
@@ -140,7 +132,6 @@ describe "Mercury.Toolbar", ->
140
132
  Mercury.trigger('region:blurred', {region: {type: 'editable'}})
141
133
  expect($('.mercury-editable-toolbar').hasClass('disabled')).toEqual(true)
142
134
 
143
-
144
135
  describe "click", ->
145
136
 
146
137
  it "triggers hide:dialogs", ->
@@ -150,3 +141,67 @@ describe "Mercury.Toolbar", ->
150
141
 
151
142
  expect(spy.callCount).toEqual(1)
152
143
  expect(spy.argsForCall[0]).toEqual(['hide:dialogs'])
144
+
145
+
146
+ describe "#height", ->
147
+
148
+ beforeEach ->
149
+ spyOn(Mercury.Toolbar.prototype, 'buildButton').andCallFake(=> $('<div>'))
150
+ spyOn(Mercury.Toolbar.prototype, 'bindEvents').andCallFake(=>)
151
+
152
+ describe "when visible", ->
153
+
154
+ beforeEach ->
155
+ @toolbar = new Mercury.Toolbar({appendTo: '#test', visible: true})
156
+
157
+ it "returns the element outerheight", ->
158
+ expect(@toolbar.height()).toEqual($('.mercury-toolbar-container').outerHeight())
159
+
160
+ describe "when not visible", ->
161
+
162
+ beforeEach ->
163
+ @toolbar = new Mercury.Toolbar({appendTo: '#test', visible: false})
164
+
165
+ it "returns 0", ->
166
+ expect(@toolbar.height()).toEqual(0)
167
+
168
+
169
+ describe "#show", ->
170
+
171
+ beforeEach ->
172
+ spyOn(Mercury.Toolbar.prototype, 'buildButton').andCallFake(=> $('<div>'))
173
+ spyOn(Mercury.Toolbar.prototype, 'bindEvents').andCallFake(=>)
174
+ @toolbar = new Mercury.Toolbar({appendTo: '#test', visible: false})
175
+
176
+ it "sets visible to true", ->
177
+ @toolbar.visible = false
178
+ @toolbar.show()
179
+ expect(@toolbar.visible).toEqual(true)
180
+
181
+ it "displays the element", ->
182
+ $('.mercury-toolbar-container').css({display: 'none'})
183
+ @toolbar.show()
184
+ expect($('.mercury-toolbar-container').css('display')).toEqual('block')
185
+
186
+ it "sets the top of the element", ->
187
+ $('.mercury-toolbar-container').css({top: '-20px'})
188
+ @toolbar.show()
189
+ expect($('.mercury-toolbar-container').css('top')).toEqual('0px')
190
+
191
+
192
+ describe "#hide", ->
193
+
194
+ beforeEach ->
195
+ spyOn(Mercury.Toolbar.prototype, 'buildButton').andCallFake(=> $('<div>'))
196
+ spyOn(Mercury.Toolbar.prototype, 'bindEvents').andCallFake(=>)
197
+ @toolbar = new Mercury.Toolbar({appendTo: '#test', visible: true})
198
+
199
+ it "sets visible to false", ->
200
+ @toolbar.visible = true
201
+ @toolbar.hide()
202
+ expect(@toolbar.visible).toEqual(false)
203
+
204
+ it "hides the element", ->
205
+ $('.mercury-toolbar-container').css({display: 'block'})
206
+ @toolbar.hide()
207
+ expect($('.mercury-toolbar-container').css('display')).toEqual('none')
@@ -1,4 +1,4 @@
1
- require '/assets/mercury/mercury.js'
1
+ require '/assets/mercury.js'
2
2
 
3
3
  describe "Mercury.tooltip", ->
4
4
 
@@ -1,10 +1,11 @@
1
- require '/assets/mercury/mercury.js'
1
+ require '/assets/mercury.js'
2
2
 
3
3
  describe "Mercury.uploader", ->
4
4
 
5
5
  template 'mercury/uploader.html'
6
6
 
7
7
  beforeEach ->
8
+ Mercury.config.uploading.enabled = true
8
9
  $.fx.off = true
9
10
  @mockFile = {
10
11
  size: 1024
@@ -28,6 +29,11 @@ describe "Mercury.uploader", ->
28
29
  ret = Mercury.uploader(@mockFile)
29
30
  expect(ret).toEqual(Mercury.uploader)
30
31
 
32
+ it "doesn't call show if disabled in configuration", ->
33
+ Mercury.config.uploading.enabled = false
34
+ Mercury.uploader(@mockFile)
35
+ expect(@showSpy.callCount).toEqual(0)
36
+
31
37
 
32
38
  describe "#show", ->
33
39
 
@@ -234,6 +240,7 @@ describe "Mercury.uploader", ->
234
240
 
235
241
  describe "#upload", ->
236
242
 
243
+ # todo: test this
237
244
  it "", ->
238
245
 
239
246
 
@@ -372,6 +379,7 @@ describe "Mercury.uploader", ->
372
379
  it "calls hide", ->
373
380
  @events.onerror.call(Mercury.uploader)
374
381
  expect(@hideSpy.callCount).toEqual(1)
382
+ expect(@hideSpy.argsForCall[0]).toEqual([3])
375
383
 
376
384
 
377
385
 
@@ -0,0 +1,13 @@
1
+ <style>
2
+ .mercury-lightview, .mercury-lightview-overlay {
3
+ display: none;
4
+ }
5
+ .mercury-lightview {
6
+ position: absolute;
7
+ opacity: 0;
8
+ }
9
+ .mercury-lightview-overlay {
10
+ opacity: 0;
11
+ }
12
+ </style>
13
+ <div id="lightview_container"></div>
@@ -0,0 +1,13 @@
1
+ <style>
2
+ .mercury-modal, .mercury-modal-overlay {
3
+ display: none;
4
+ }
5
+ .mercury-modal {
6
+ position: absolute;
7
+ top: -100px;
8
+ }
9
+ .mercury-modal-overlay {
10
+ opacity: 0;
11
+ }
12
+ </style>
13
+ <div id="modal_container"></div>
@@ -14,6 +14,10 @@
14
14
  <a id="anchor2r" href="#" target="_blank">2</a>
15
15
  <a id="anchor3r" href="#" target="_self">3</a>
16
16
  <a id="anchor4r" href="#">4</a>
17
+ <form id="form1r" action="" target="_top"></form>
18
+ <form id="form2r" action="" target="_blank"></form>
19
+ <form id="form3r" action="" target="_self"></form>
20
+ <form id="form4r" action=""></form>
17
21
  </div>
18
22
 
19
23
  <a id="anchor1" href="#" target="_top">1</a>
@@ -21,4 +25,10 @@
21
25
  <a id="anchor3" href="#" target="_self">3</a>
22
26
  <a id="anchor4" href="#">4</a>
23
27
  <a id="anchor5" href="#" class="lightview" target="_self">5</a>
24
-
28
+ <a id="anchor6" href="#" target="foo">5</a>
29
+ <form id="form1" action="" target="_top"></form>
30
+ <form id="form2" action="" target="_blank"></form>
31
+ <form id="form3" action="" target="_self"></form>
32
+ <form id="form4" action=""></form>
33
+ <form id="form5" action="" class="lightview" target="_self"></form>
34
+ <form id="form6" action="" target="foo"></form>
@@ -1,5 +1,6 @@
1
1
  <style>
2
2
  .mercury-statusbar {
3
+ border-top: 3px;
3
4
  height: 20px;
4
5
  }
5
6
  </style>
@@ -1,5 +1,6 @@
1
1
  <style>
2
2
  .mercury-toolbar-container {
3
+ position: absolute;
3
4
  height: 200px;
4
5
  }
5
6
  .mercury-primary-toolbar {
File without changes
File without changes
@@ -0,0 +1,302 @@
1
+ /*!
2
+ * Mercury Editor is a CoffeeScript and jQuery based WYSIWYG editor. Documentation and other useful information can be
3
+ * found at https://github.com/jejacks0n/mercury
4
+ *
5
+ * Supported browsers:
6
+ * - Firefox 4+
7
+ * - Chrome 10+
8
+ * - Safari 5+
9
+ *
10
+ * Copyright (c) 2011 Jeremy Jackson
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
14
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
15
+ * persons to whom the Software is furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
18
+ * Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
21
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ *
25
+ *= require_self
26
+ *= require mercury/mercury
27
+ */
28
+ window.MercurySetup = {
29
+
30
+ // # Mercury Configuration
31
+ config: {
32
+ // ## Hijacking Links & Forms
33
+ //
34
+ // Mercury will hijack links and forms that don't have a target set, or the target is set to _self and will set it
35
+ // to _top. This is because the target must be set properly for Mercury to not get in the way of some
36
+ // functionality, like proper page loads on form submissions etc. Mercury doesn't do this to links or forms that
37
+ // are within editable regions because it doesn't want to impact the html that's saved. With that being explained,
38
+ // you can add classes to links or forms that you don't want this behavior added to. Let's say you have links that
39
+ // open a lightbox style window, and you don't want the targets of these to be set to _top. You can add classes to
40
+ // this array, and they will be ignored when the hijacking is applied.
41
+ nonHijackableClasses: [],
42
+
43
+
44
+ // ## Ajax and CSRF Headers
45
+ //
46
+ // Some server frameworks require that you provide a specific header for Ajax requests. The values for these CSRF
47
+ // tokens are typically stored in the rendered DOM. By default, Mercury will look for the Rails specific meta tag,
48
+ // and provide the X-CSRF-Token header on Ajax requests, but you can modify this configuration if the system you're
49
+ // using doesn't follow the same standard.
50
+ csrfSelector: 'meta[name="csrf-token"]',
51
+ csrfHeader: 'X-CSRF-Token',
52
+
53
+
54
+ // ## Pasting (in Chrome/Safari)
55
+ //
56
+ // When copying content using webkit, it embeds all the user defined styles (from the css files) into the html
57
+ // style attributes directly. When pasting this content into HTML5 contentEditable elements it leaves these
58
+ // intact. This can be a desired feature, or an annoyance, so you can enable it or disable it here. Keep in mind
59
+ // this will only change the behavior in webkit, as mozilla doesn't do this.
60
+ cleanStylesOnPaste: true,
61
+
62
+
63
+ // ## Snippet Options and Preview
64
+ //
65
+ // When a user drags a snippet onto the page they'll be prompted to enter options for the given snippet. The server
66
+ // is expected to respond with a form. Once the user submits this form, an Ajax request is sent to the server with
67
+ // the options provided; this preview request is expected to respond with the rendered markup for the snippet.
68
+ //
69
+ // Name will be replaced with the snippet name (eg. example)
70
+ snippets: {
71
+ method: 'POST',
72
+ optionsUrl: '/mercury/snippets/:name/options.html',
73
+ previewUrl: '/mercury/snippets/:name/preview.html'
74
+ },
75
+
76
+
77
+ // ## Image Uploading
78
+ //
79
+ // If you drag images (while pressing shift) from your desktop into regions that support it, it will be uploaded
80
+ // to the server and inserted into the region. This configuration allows you to specify if you want to
81
+ // disable/enable this feature, the accepted mime-types, file size restrictions, and other things related to
82
+ // uploading. You can optionally provide a handler function that takes the response from the server and returns an
83
+ // object: {image: {url: '[your provided url]'}
84
+ //
85
+ // **Note:** Image uploading is only supported in some region types.
86
+ uploading: {
87
+ enabled: true,
88
+ allowedMimeTypes: ['image/jpeg', 'image/gif', 'image/png'],
89
+ maxFileSize: 1235242880,
90
+ inputName: 'image[image]',
91
+ url: '/images',
92
+ handler: false
93
+ },
94
+
95
+
96
+ // ## Toolbars
97
+ //
98
+ // This is where you can customize the toolbars by adding or removing buttons, or changing them and their
99
+ // behaviors. Any top level object put here will create a new toolbar. Buttons are simply nested inside the
100
+ // toolbars, along with button groups.
101
+ //
102
+ // Some toolbars are custom (the snippetable toolbar for instance), and to denote that use _custom: true. You can
103
+ // then build the toolbar yourself with it's own behavior.
104
+ //
105
+ // Buttons can be grouped, and a button group is simply a way to wrap buttons for styling -- they can also handle
106
+ // enabling or disabling all the buttons within it by using a context. The table button group is a good example
107
+ // of this.
108
+ //
109
+ // It's important to note that each of the button names (keys), in each toolbar object must be unique, regardless
110
+ // of if it's in a button group, or nested, etc. This is because styling is applied to them by name, and because
111
+ // their name is used in the event that's fired when you click on them.
112
+ //
113
+ // Button format: `[label, description, {type: action, type: action, etc}]`
114
+ //
115
+ // ### The available button types are:
116
+ //
117
+ // - toggle: toggles on or off when clicked, otherwise behaves like a button
118
+ // - modal: opens a modal window, expects the action to be one of:
119
+ // 1. a string url
120
+ // 2. a function that returns a string url
121
+ // - panel: opens a panel dialog, expects the action to be one of:
122
+ // 1. a string url
123
+ // 2. a function that returns a string url
124
+ // - palette: opens a palette window, expects the action to be one of:
125
+ // 1. a string url
126
+ // 2. a function that returns a string url
127
+ // - select: opens a pulldown style window, expects the action to be one of:
128
+ // 1. a string url
129
+ // 2. a function that returns a string url
130
+ // - context: calls a callback function, expects the action to be:
131
+ // 1. a function that returns a boolean to highlight the button
132
+ // note: if a function isn't provided, the key will be passed to the contextHandler, in which case a default
133
+ // context will be used (for more info read the Contexts section below)
134
+ // - mode: toggle a given mode in the editor, expects the action to be:
135
+ // 1. a string, denoting the name of the mode
136
+ // note: it's assumed that when a specific mode is turned on, all other modes will be turned off, which happens
137
+ // automatically, thus putting the editor into a specific "state"
138
+ // - regions: allows buttons to be enabled/disabled based on what region type has focus, expects the action to be:
139
+ // 1. an array of region types (eg. ['editable', 'markupable'])
140
+ // - preload: allows some dialog views to be loaded when the button is created instead of on first open, expects:
141
+ // 1. a boolean true / false
142
+ // note: this is only used by panels, selects, and palettes
143
+ //
144
+ // Separators are any "button" that's not an array, and are expected to be a string. You can use two different
145
+ // separator styles: line ('-'), and spacer (' ').
146
+ toolbars: {
147
+ primary: {
148
+ save: ['Save', 'Save this page'],
149
+ preview: ['Preview', 'Preview this page', { toggle: true, mode: true }],
150
+ sep1: ' ',
151
+ undoredo: {
152
+ undo: ['Undo', 'Undo your last action'],
153
+ redo: ['Redo', 'Redo your last action'],
154
+ sep: ' '
155
+ },
156
+ insertLink: ['Link', 'Insert Link', { modal: '/mercury/modals/link.html', regions: ['editable', 'markupable'] }],
157
+ insertMedia: ['Media', 'Insert Media (images and videos)', { modal: '/mercury/modals/media.html', regions: ['editable', 'markupable'] }],
158
+ insertTable: ['Table', 'Insert Table', { modal: '/mercury/modals/table.html', regions: ['editable', 'markupable'] }],
159
+ insertCharacter: ['Character', 'Special Characters', { modal: '/mercury/modals/character.html', regions: ['editable', 'markupable'] }],
160
+ snippetPanel: ['Snippet', 'Snippet Panel', { panel: '/mercury/panels/snippets.html' }],
161
+ sep2: ' ',
162
+ historyPanel: ['History', 'Page Version History', { panel: '/mercury/panels/history.html' }],
163
+ sep3: ' ',
164
+ notesPanel: ['Notes', 'Page Notes', { panel: '/mercury/panels/notes.html' }]
165
+ },
166
+
167
+ editable: {
168
+ _regions: ['editable', 'markupable'],
169
+ predefined: {
170
+ style: ['Style', null, { select: '/mercury/selects/style.html', preload: true }],
171
+ sep1: ' ',
172
+ formatblock: ['Block Format', null, { select: '/mercury/selects/formatblock.html', preload: true }],
173
+ sep2: '-'
174
+ },
175
+ colors: {
176
+ backColor: ['Background Color', null, { palette: '/mercury/palettes/backcolor.html', context: true, preload: true, regions: ['editable'] }],
177
+ sep1: ' ',
178
+ foreColor: ['Text Color', null, { palette: '/mercury/palettes/forecolor.html', context: true, preload: true, regions: ['editable'] }],
179
+ sep2: '-'
180
+ },
181
+ decoration: {
182
+ bold: ['Bold', null, { context: true }],
183
+ italic: ['Italicize', null, { context: true }],
184
+ overline: ['Overline', null, { context: true, regions: ['editable'] }],
185
+ strikethrough: ['Strikethrough', null, { context: true, regions: ['editable'] }],
186
+ underline: ['Underline', null, { context: true, regions: ['editable'] }],
187
+ sep: '-'
188
+ },
189
+ script: {
190
+ subscript: ['Subscript', null, { context: true }],
191
+ superscript: ['Superscript', null, { context: true }],
192
+ sep: '-'
193
+ },
194
+ justify: {
195
+ justifyLeft: ['Align Left', null, { context: true, regions: ['editable'] }],
196
+ justifyCenter: ['Center', null, { context: true, regions: ['editable'] }],
197
+ justifyRight: ['Align Right', null, { context: true, regions: ['editable'] }],
198
+ justifyFull: ['Justify Full', null, { context: true, regions: ['editable'] }],
199
+ sep: '-'
200
+ },
201
+ list: {
202
+ insertUnorderedList: ['Unordered List', null, { context: true }],
203
+ insertOrderedList: ['Numbered List', null, { context: true }],
204
+ sep: '-'
205
+ },
206
+ indent: {
207
+ outdent: ['Decrease Indentation', null],
208
+ indent: ['Increase Indentation', null],
209
+ sep: '-'
210
+ },
211
+ table: {
212
+ _context: true,
213
+ insertRowBefore: ['Insert Table Row', 'Insert a table row before the cursor', { regions: ['editable'] }],
214
+ insertRowAfter: ['Insert Table Row', 'Insert a table row after the cursor', { regions: ['editable'] }],
215
+ deleteRow: ['Delete Table Row', 'Delete this table row', { regions: ['editable'] }],
216
+ insertColumnBefore: ['Insert Table Column', 'Insert a table column before the cursor', { regions: ['editable'] }],
217
+ insertColumnAfter: ['Insert Table Column', 'Insert a table column after the cursor', { regions: ['editable'] }],
218
+ deleteColumn: ['Delete Table Column', 'Delete this table column', { regions: ['editable'] }],
219
+ sep1: ' ',
220
+ increaseColspan: ['Increase Cell Columns', 'Increase the cells colspan'],
221
+ decreaseColspan: ['Decrease Cell Columns', 'Decrease the cells colspan and add a new cell'],
222
+ increaseRowspan: ['Increase Cell Rows', 'Increase the cells rowspan'],
223
+ decreaseRowspan: ['Decrease Cell Rows', 'Decrease the cells rowspan and add a new cell'],
224
+ sep2: '-'
225
+ },
226
+ rules: {
227
+ horizontalRule: ['Horizontal Rule', 'Insert a horizontal rule'],
228
+ sep1: '-'
229
+ },
230
+ formatting: {
231
+ removeFormatting: ['Remove Formatting', 'Remove formatting for the selection', { regions: ['editable'] }],
232
+ sep2: ' '
233
+ },
234
+ editors: {
235
+ htmlEditor: ['Edit HTML', 'Edit the HTML content', { regions: ['editable'] }]
236
+ }
237
+ },
238
+
239
+ snippetable: {
240
+ _custom: true,
241
+ actions: {
242
+ editSnippet: ['Edit Snippet Settings', null],
243
+ sep1: ' ',
244
+ removeSnippet: ['Remove Snippet', null]
245
+ }
246
+ }
247
+ },
248
+
249
+
250
+ // ## Behaviors
251
+ //
252
+ // Behaviors are used to change the default behaviors of a given region type when a given button is clicked. For
253
+ // example, you may prefer to add HR tags using an HR wrapped within a div with a classname (for styling). You
254
+ // can add your own complex behaviors here.
255
+ //
256
+ // You can see how the behavior matches up directly with the button name. It's also important to note that the
257
+ // callback functions are executed within the scope of the given region, so you have access to all it's methods.
258
+ behaviors: {
259
+ horizontalRule: function(selection) { selection.replace('<hr/>') },
260
+ htmlEditor: function() { Mercury.modal('/mercury/modals/htmleditor.html', { title: 'HTML Editor', fullHeight: true, handler: 'htmlEditor' }) }
261
+ },
262
+
263
+
264
+ // ## Contexts
265
+ //
266
+ // Contexts are used callback functions used for highlighting and disabling/enabling buttons and buttongroups.
267
+ // When the cursor enters an element within an html region for instance we want to disable or highlight buttons
268
+ // based on the properties of the given node. You can see some examples of contexts in:
269
+ //
270
+ // Mercury.Toolbar.Button.contexts
271
+ // and
272
+ // Mercury.Toolbar.ButtonGroup.contexts
273
+
274
+
275
+ // ## Styles
276
+ //
277
+ // Mercury tries to stay as much out of your code as possible, but because regions appear within your document we
278
+ // need to include a few styles to indicate regions, as well as the different states of them (eg. focused). These
279
+ // styles are injected into your document, and as simple as they might be, you may want to change them. You can do
280
+ // so here.
281
+ injectedStyles: '' +
282
+ '.mercury-region, .mercury-textarea { min-height: 10px; outline: 1px dotted #09F }' +
283
+ '.mercury-textarea { box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; resize: vertical; }' +
284
+ '.mercury-region:focus, .mercury-region.focus, .mercury-textarea.focus { outline: none; -webkit-box-shadow: 0 0 10px #09F, 0 0 1px #045; box-shadow: 0 0 10px #09F, 0 0 1px #045 }' +
285
+ '.mercury-region:after { content: "."; display: block; visibility: hidden; clear: both; height: 0; overflow: hidden; }' +
286
+ '.mercury-region table, .mercury-region td, .mercury-region th { border: 1px dotted red; }'
287
+ },
288
+
289
+ // ## Silent Mode
290
+ //
291
+ // Turning silent mode on will disable asking about unsaved changes before leaving the page.
292
+ silent: false,
293
+
294
+ // ## Debug Mode
295
+ //
296
+ // Turning debug mode on will log events and other various things (using console.debug if available).
297
+ debug: false
298
+
299
+ };
300
+
301
+ if (!window.Mercury) window.Mercury = window.MercurySetup;
302
+ else if (typeof(jQuery) !== 'undefined') jQuery.extend(window.Mercury, window.MercurySetup);