mercury-rails 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/app/assets/images/mercury/toolbar/{snippetable → snippets}/buttons.png +0 -0
  2. data/app/assets/javascripts/mercury.js +58 -84
  3. data/app/assets/javascripts/mercury/lightview.js.coffee +1 -1
  4. data/app/assets/javascripts/mercury/mercury.js.coffee +1 -1
  5. data/app/assets/javascripts/mercury/modal.js.coffee +1 -1
  6. data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +13 -9
  7. data/app/assets/javascripts/mercury/native_extensions.js.coffee +0 -6
  8. data/app/assets/javascripts/mercury/page_editor.js.coffee +19 -19
  9. data/app/assets/javascripts/mercury/region.js.coffee +11 -10
  10. data/app/assets/javascripts/mercury/regions/{editable.js.coffee → full.coffee} +18 -18
  11. data/app/assets/javascripts/mercury/regions/image.js.coffee +13 -34
  12. data/app/assets/javascripts/mercury/regions/{markupable.js.coffee → markdown.coffee} +21 -22
  13. data/app/assets/javascripts/mercury/regions/simple.js.coffee +10 -39
  14. data/app/assets/javascripts/mercury/regions/{snippetable.js.coffee → snippets.js.coffee} +8 -7
  15. data/app/assets/javascripts/mercury/snippet.js.coffee +1 -1
  16. data/app/assets/javascripts/mercury/snippet_toolbar.js.coffee +3 -2
  17. data/app/assets/javascripts/mercury/toolbar.button.js.coffee +2 -2
  18. data/app/assets/javascripts/mercury/toolbar.button_group.js.coffee +2 -2
  19. data/app/assets/javascripts/mercury/toolbar.js.coffee +2 -2
  20. data/app/assets/javascripts/mercury/uploader.js.coffee +2 -1
  21. data/app/assets/stylesheets/mercury/all_images.css.erb +2 -2
  22. data/app/assets/stylesheets/mercury/dialog.css +2 -2
  23. data/app/assets/stylesheets/mercury/lightview.css +14 -14
  24. data/app/assets/stylesheets/mercury/modal.css +1 -1
  25. data/app/assets/stylesheets/mercury/toolbar.css +1 -1
  26. data/features/generators/install.feature +1 -1
  27. data/features/loading/loading.feature +2 -2
  28. data/features/regions/{editable → full}/advanced_editing.feature +0 -0
  29. data/features/regions/full/basic_editing.feature +196 -0
  30. data/features/regions/{editable → full}/inserting_links.feature +12 -12
  31. data/features/regions/{editable → full}/inserting_media.feature +15 -15
  32. data/features/regions/{editable → full}/inserting_snippets.feature +15 -15
  33. data/features/regions/{editable → full}/inserting_special_characters.feature +2 -2
  34. data/features/regions/full/inserting_tables.feature +109 -0
  35. data/features/regions/{editable → full}/pasting.feature +0 -0
  36. data/features/regions/{editable → full}/uploading_images.feature +0 -0
  37. data/features/regions/{markupable → markdown}/advanced_editing.feature +0 -0
  38. data/features/regions/{markupable → markdown}/basic_editing.feature +0 -0
  39. data/features/regions/{markupable → markdown}/inserting_links.feature +0 -0
  40. data/features/regions/{markupable → markdown}/inserting_media.feature +0 -0
  41. data/features/regions/{markupable → markdown}/inserting_snippets.feature +0 -0
  42. data/features/regions/{markupable → markdown}/inserting_special_characters.feature +0 -0
  43. data/features/regions/{markupable → markdown}/inserting_tables.feature +0 -0
  44. data/features/regions/{markupable → markdown}/uploading_images.feature +0 -0
  45. data/features/regions/{snippetable → snippets}/advanced_editing.feature +0 -0
  46. data/features/regions/{snippetable → snippets}/basic_editing.feature +0 -0
  47. data/features/regions/{snippetable → snippets}/inserting_snippets.feature +0 -0
  48. data/features/saving/saving.feature +8 -8
  49. data/features/step_definitions/mercury_steps.rb +13 -13
  50. data/features/support/mercury_selectors.rb +3 -3
  51. data/lib/generators/mercury/install/images/images_generator.rb +3 -0
  52. data/lib/generators/mercury/install/install_generator.rb +5 -5
  53. data/lib/mercury/version.rb +1 -1
  54. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  55. data/spec/dummy/{public → app/assets/javascripts}/prototype.js +0 -0
  56. data/spec/dummy/app/assets/stylesheets/application.css.scss +110 -0
  57. data/spec/dummy/public/frame.html +1 -1
  58. data/spec/dummy/public/index.html +92 -216
  59. data/spec/javascripts/mercury/lightview_spec.js.coffee +1 -1
  60. data/spec/javascripts/mercury/modal_spec.js.coffee +1 -1
  61. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +41 -2
  62. data/spec/javascripts/mercury/page_editor_spec.js.coffee +19 -18
  63. data/spec/javascripts/mercury/region_spec.js.coffee +12 -14
  64. data/spec/javascripts/mercury/regions/{editable_spec.js.coffee → full_spec.js.coffee} +16 -16
  65. data/spec/javascripts/mercury/regions/image_spec.js.coffee +3 -3
  66. data/spec/javascripts/mercury/regions/{markupable_spec.js.coffee → markdown_spec.js.coffee} +18 -18
  67. data/spec/javascripts/mercury/regions/simple_spec.js.coffee +3 -3
  68. data/spec/javascripts/mercury/regions/{snippetable_spec.js.coffee → snippets_spec.js.coffee} +53 -53
  69. data/spec/javascripts/mercury/snippet_spec.js.coffee +1 -1
  70. data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +2 -2
  71. data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +5 -5
  72. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +6 -6
  73. data/spec/javascripts/mercury/toolbar_spec.js.coffee +4 -4
  74. data/spec/javascripts/mercury/uploader_spec.js.coffee +5 -5
  75. data/spec/javascripts/templates/mercury/page_editor.html +4 -4
  76. data/spec/javascripts/templates/mercury/region.html +1 -1
  77. data/spec/javascripts/templates/mercury/regions/full.html +1 -0
  78. data/spec/javascripts/templates/mercury/regions/image.html +1 -1
  79. data/spec/javascripts/templates/mercury/regions/markdown.html +1 -0
  80. data/spec/javascripts/templates/mercury/regions/simple.html +1 -3
  81. data/spec/javascripts/templates/mercury/regions/snippets.html +4 -0
  82. metadata +65 -75
  83. data/app/assets/javascripts/mercury_loader.js +0 -193
  84. data/app/assets/javascripts/mercury_overrides.js +0 -6
  85. data/app/assets/stylesheets/mercury_overrides.css +0 -17
  86. data/features/regions/editable/basic_editing.feature +0 -196
  87. data/features/regions/editable/inserting_tables.feature +0 -109
  88. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  89. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  90. data/spec/dummy/public/404.html +0 -26
  91. data/spec/dummy/public/422.html +0 -26
  92. data/spec/dummy/public/canvastest.html +0 -103
  93. data/spec/javascripts/templates/mercury/regions/editable.html +0 -3
  94. data/spec/javascripts/templates/mercury/regions/snippetable.html +0 -4
@@ -1,6 +0,0 @@
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
- * This file is intended to provide a standard way to override or add JS that comes default with Mercury Editor.
6
- */
@@ -1,17 +0,0 @@
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
- * This file is intended to provide a standard way to override the CSS that comes default with Mercury Editor, and
6
- * includes an example button style, should you ever need to add new ones yourself. Read the toolbar configuration in
7
- * mercury.js for more on how to add your own buttons to the toolbar.
8
- */
9
-
10
- /* Disable text sizing in webkit (ipad/iphone etc -- should apply to mercury only) */
11
- html { -webkit-text-size-adjust: none; }
12
-
13
- /* Button example */
14
- .mercury-primary-toolbar .mercury-inspector-button em,
15
- .mercury-expander-button[data-button="inspector"] em {
16
- background-image: url(/assets/mercury/toolbar/primary/inspectorpanel.png);
17
- }
@@ -1,196 +0,0 @@
1
- @javascript
2
- Feature:
3
- As a content editor type person
4
- In order to manage content
5
- I should be able to manipulate it in various ways (eg. bold, add italics, set headers, colors, etc.)
6
-
7
- Background:
8
- Given I am on an editable page
9
- And the editor won't prompt when leaving the page
10
-
11
- # Scenario: A user can expect all this!
12
-
13
-
14
- Scenario: A user can set and unset bold content
15
- Given the content of the editable region is simple content
16
- And I make a selection
17
-
18
- When I click on the bold editor button
19
- Then the contents of the editable region should be "this is <b><span>simple</span></b> <b>content</b>"
20
-
21
- When I click on the bold editor button
22
- Then the contents of the editable region should be "this is <span>simple</span> <b>content</b>"
23
-
24
-
25
- Scenario: A user can italicize content
26
- Given the content of the editable region is simple content
27
- And I make a selection
28
-
29
- When I click on the italicize editor button
30
- Then the contents of the editable region should be "this is <i><span>simple</span></i> <b>content</b>"
31
-
32
- When I click on the italicize editor button
33
- Then the contents of the editable region should be "this is <span>simple</span> <b>content</b>"
34
-
35
-
36
- Scenario: A user can overline content
37
- Given the content of the editable region is simple content
38
- And I make a selection
39
-
40
- When I click on the overline editor button
41
- Then the contents of the editable region should be "this is <span style='text-decoration:overline'><span>simple</span></span> <b>content</b>"
42
- # doesn't remove overlines
43
-
44
-
45
- Scenario: A user can strikeout content
46
- Given the content of the editable region is simple content
47
- And I make a selection
48
-
49
- When I click on the strikethrough editor button
50
- Then the contents of the editable region should be "this is <strike><span>simple</span></strike> <b>content</b>"
51
-
52
- When I click on the strikethrough editor button
53
- Then the contents of the editable region should be "this is <span>simple</span> <b>content</b>"
54
-
55
- Scenario: A user can underline content
56
- Given the content of the editable region is simple content
57
- And I make a selection
58
-
59
- When I click on the underline editor button
60
- Then the contents of the editable region should be "this is <u><span>simple</span></u> <b>content</b>"
61
-
62
- When I click on the underline editor button
63
- Then the contents of the editable region should be "this is <span>simple</span> <b>content</b>"
64
-
65
-
66
- Scenario: A user can make content superscript
67
- Given the content of the editable region is simple content
68
- And I make a selection
69
-
70
- When I click on the superscript editor button
71
- Then the contents of the editable region should be "this is <sup><span>simple</span></sup> <b>content</b>"
72
-
73
- When I click on the superscript editor button
74
- Then the contents of the editable region should be "this is <span>simple</span> <b>content</b>"
75
-
76
-
77
- Scenario: A user can make content subscript
78
- Given the content of the editable region is simple content
79
- And I make a selection
80
-
81
- When I click on the subscript editor button
82
- Then the contents of the editable region should be "this is <sub><span>simple</span></sub> <b>content</b>"
83
-
84
- When I click on the subscript editor button
85
- Then the contents of the editable region should be "this is <span>simple</span> <b>content</b>"
86
-
87
-
88
- Scenario: A user can justify content to the left, center, right, or fully justified
89
- # firefox: this isn't possible on the first line due to a bug in gecko, so we have special content for it
90
- Given the content of the editable region has justifiable content
91
- And I make a selection
92
-
93
- When I click on the justify left editor button
94
- Then the contents of the editable region should be "<div>first line</div><br><div align='left'>this is <span>justifiable</span><b>content</b></div>"
95
-
96
- When I click on the justify center editor button
97
- Then the contents of the editable region should be "<div>first line</div><br><div align='center'>this is <span>justifiable</span><b>content</b></div>"
98
-
99
- When I click on the justify right editor button
100
- Then the contents of the editable region should be "<div>first line</div><br><div align='right'>this is <span>justifiable</span><b>content</b></div>"
101
-
102
- When I click on the full justification editor button
103
- Then the contents of the editable region should be "<div>first line</div><br><div align='justify'>this is <span>justifiable</span><b>content</b></div>"
104
-
105
-
106
- Scenario: A user can make an unordered list
107
- Given the content of the editable region is simple content
108
- And I make a selection
109
-
110
- When I click on the insert unordered list editor button
111
- Then the contents of the editable region should be "<ul><li>this is <span>simple</span> <b>content</b></li></ul>"
112
-
113
- # todo: we should test enter and tab, and shift+tab in advanced editing
114
-
115
- Scenario: A user can make an ordered list
116
- Given the content of the editable region is simple content
117
- And I make a selection
118
-
119
- When I click on the insert ordered list editor button
120
- Then the contents of the editable region should be "<ol><li>this is <span>simple</span> <b>content</b></li></ol>"
121
-
122
- # todo: we should test enter and tab, and shift+tab in advanced editing
123
-
124
-
125
- Scenario: A user can indent and outdent content
126
- # firefox: this isn't possible on the first line due to a bug in gecko, so we have special content for it
127
- Given the content of the editable region has justifiable content
128
- And I make a selection
129
-
130
- When I click on the indent editor button
131
- Then the contents of the editable region should be "<div>first line</div><br><blockquote>this is <span>justifiable</span><b>content</b></blockquote>"
132
-
133
- When I click on the indent editor button
134
- Then the contents of the editable region should be "<div>first line</div><br><blockquote><blockquote>this is <span>justifiable</span><b>content</b></blockquote></blockquote>"
135
-
136
- When I click on the outdent editor button
137
- Then the contents of the editable region should be "<div>first line</div><br><blockquote>this is <span>justifiable</span><b>content</b></blockquote>"
138
-
139
- When I click on the outdent editor button
140
- Then the contents of the editable region should be "<div>first line</div><br>this is <span>justifiable</span><b>content</b>"
141
-
142
-
143
- Scenario: A user can insert horizontal rules
144
- Given the content of the editable region is simple content
145
- And I make a selection
146
-
147
- When I click on the insert hr editor button
148
- Then the contents of the editable region should be "this is&nbsp;<hr size='2' width='100%'> <b>content</b>"
149
-
150
- When I click on the insert hr editor button
151
- Then the contents of the editable region should be "this is&nbsp;<hr size='2' width='100%'><hr size='2' width='100%'> <b>content</b>"
152
-
153
-
154
- Scenario: A user can clean/remove formatting on their selection
155
- Given the content of the editable region has wrapped content
156
- And I make a selection
157
-
158
- When I click on the remove formatting editor button
159
- Then the contents of the editable region should be "this is wrapped content"
160
-
161
-
162
- Scenario: A user can wrap content within predefined styles
163
- Given the content of the editable region is simple content
164
- And I make a selection
165
-
166
- When I click on the style editor dropdown
167
- And select the red style from the dropdown
168
- Then the contents of the editable region should be "this is <span class='red'><span>simple</span></span> <b>content</b>"
169
-
170
-
171
- Scenario: A user can wrap content in formatted block tags
172
- Given the content of the editable region is simple content
173
- And I make a selection
174
-
175
- When I click on the block format editor dropdown
176
- And select the heading 2 block from the dropdown
177
- Then the contents of the editable region should be "<h2>this is <span>simple</span> <b>content</b></h2>"
178
-
179
-
180
- Scenario: A user can set the background color of a selection
181
- Given the content of the editable region is simple content
182
- And I make a selection
183
-
184
- When I click on the background color editor palette
185
- And click on the color red
186
- Then the contents of the editable region should be "this is <span style='background-color:#FF0000'><span>simple</span></span> <b>content</b>"
187
-
188
-
189
- Scenario: A user can set the foreground color
190
- Given the content of the editable region is simple content
191
- And I make a selection
192
-
193
- When I click on the foreground color editor palette
194
- And click on the color red
195
- Then the contents of the editable region should be "this is <font color='rgb(255, 0, 0)'><span>simple</span></font> <b>content</b>"
196
-
@@ -1,109 +0,0 @@
1
- @javascript
2
- Feature:
3
- As a content editor type person
4
- In order to manage content
5
- I should be able to insert and edit complex tables
6
-
7
- Background:
8
- Given I am on an editable page
9
- And the editor won't prompt when leaving the page
10
-
11
- Scenario: A user can expect all this!
12
-
13
-
14
- # Scenario: A user can insert a table
15
- Given the content of the editable region is simple content
16
- And I make a selection
17
-
18
- When I click on the "Insert Table" button
19
- Then the modal window should be visible
20
- And I should see "Insert Table" within the modal title
21
-
22
- When I click on the third cell in the first row
23
- And I add a column before it
24
- Then the table column count should be 4
25
- And the selected cell should be the forth cell in the first row
26
-
27
- When I add a column after
28
- Then the table column count should be 5
29
- And the selected cell should be the forth cell in the first row
30
-
31
- When I add a row after
32
- Then the table row count should be 3
33
- And the selected cell should be the forth cell in the first row
34
-
35
- When I add a row before
36
- Then the table row count should be 4
37
- And the selected cell should be the forth cell in the second row
38
-
39
- When I delete the column
40
- Then the table column count should be 4
41
- And a selected cell should not be visible
42
-
43
- When I click on the second cell in the second row
44
- And delete the row
45
- Then the table row count should be 3
46
- And a selected cell should not be visible
47
-
48
- When I click on the second cell in the second row
49
- And increase the colspan
50
- And click on the first cell in the first row
51
- And increase the rowspan
52
- And select "Right" from "Alignment"
53
- And fill in "Border" with "2"
54
- And fill in "Spacing" with "2"
55
- And press "Insert Table"
56
- Then the contents of the editable region should be "this is&nbsp;<table align='right' border='2' cellspacing='2'><tbody><tr><td rowspan='2'><br></td><td><br></td><td><br></td><td><br></td></tr><tr><td colspan='2'><br></td><td><br></td></tr><tr><td><br></td><td><br></td><td><br></td><td><br></td></tr></tbody></table> <b>content</b>"
57
- And the modal window should not be visible
58
-
59
-
60
- # Scenario: A user can edit a table after inserting one (in an editable region)
61
- Given the content of the editable region has a table
62
- And I make a selection
63
-
64
- When I click on the add row before editor button
65
- Then the table row count should be 3
66
- And the contents of the editable region should be "this is a <table><tbody><tr><td><br></td><td><br></td></tr><tr><td><span>1</span></td><td><span>2</span></td></tr><tr><td><span>3</span></td><td><span>4</span></td></tr></tbody></table> <b>content</b>"
67
-
68
- When I click on the add row after editor button
69
- Then the table row count should be 4
70
- And the contents of the editable region should be "this is a <table><tbody><tr><td><br></td><td><br></td></tr><tr><td><span>1</span></td><td><span>2</span></td></tr><tr><td><br></td><td><br></td></tr><tr><td><span>3</span></td><td><span>4</span></td></tr></tbody></table> <b>content</b>"
71
-
72
- When I click on the add column before editor button
73
- Then the column count should be 3
74
- And the contents of the editable region should be "this is a <table><tbody><tr><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><span>1</span></td><td><span>2</span></td></tr><tr><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><span>3</span></td><td><span>4</span></td></tr></tbody></table> <b>content</b>"
75
-
76
- When I click on the add column after editor button
77
- Then the column count should be 4
78
- And the contents of the editable region should be "this is a <table><tbody><tr><td><br></td><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><span>1</span></td><td><br></td><td><span>2</span></td></tr><tr><td><br></td><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><span>3</span></td><td><br></td><td><span>4</span></td></tr></tbody></table> <b>content</b>"
79
-
80
- When I click on the delete row editor button
81
- Then the table row count should be 3
82
- And the contents of the editable region should be "this is a <table><tbody><tr><td><br></td><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><span>3</span></td><td><br></td><td><span>4</span></td></tr></tbody></table> <b>content</b>"
83
-
84
- When I make a selection
85
- And click on the delete column editor button
86
- Then the table column count should be 3
87
- And the contents of the editable region should be "this is a <table><tbody><tr><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><br></td><td><span>4</span></td></tr></tbody></table> <b>content</b>"
88
-
89
-
90
- # Scenario: A user can adjust the colspans of a table (in an editable region)
91
- Given the content of the editable region has a table
92
- And I make a selection
93
-
94
- When I click on the increase colspan editor button
95
- Then the contents of the editable region should be "this is a <table><tbody><tr><td colspan='2'><span>1</span></td></tr><tr><td><span>3</span></td><td><span>4</span></td></tr></tbody></table> <b>content</b>"
96
-
97
- When I click on the decrease colspan editor button
98
- Then the contents of the editable region should be "this is a <table><tbody><tr><td><span>1</span></td><td><br></td></tr><tr><td><span>3</span></td><td><span>4</span></td></tr></tbody></table> <b>content</b>"
99
-
100
-
101
- # Scenario: A user can adjust the rowspans of a table (in an editable region)
102
- Given the content of the editable region has a table
103
- And I make a selection
104
-
105
- When I click on the increase rowspan editor button
106
- Then the contents of the editable region should be "this is a <table><tbody><tr><td rowspan='2'><span>1</span></td><td><span>2</span></td></tr><tr><td><span>4</span></td></tr></tbody></table> <b>content</b>"
107
-
108
- When I click on the decrease rowspan editor button
109
- Then the contents of the editable region should be "this is a <table><tbody><tr><td><span>1</span></td><td><span>2</span></td></tr><tr><td><br></td><td><span>4</span></td></tr></tbody></table> <b>content</b>"
@@ -1,13 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
- *= require_self
12
- *= require_tree .
13
- */
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,103 +0,0 @@
1
- <html>
2
- <head>
3
- <script src="/assets/mercury.js" type="text/javascript"></script>
4
- <style>
5
- #dropper {
6
- border: 1px solid #999;
7
- padding: 20px;
8
- }
9
-
10
- </style>
11
- </head>
12
-
13
- <body>
14
- <div id="dropper">drop here</div>
15
- <canvas id="canvas" width="100" height="100"></canvas>
16
- <input id="png" type="button" value="png"/>
17
- <input id="jpeg" type="button" value="jpeg"/>
18
-
19
- <script>
20
- // webkit needs the sendAsBinary method.
21
- if (window.Uint8Array && window.ArrayBuffer && !XMLHttpRequest.prototype.sendAsBinary) {
22
- XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
23
- var data, index, ui8a, _len;
24
- ui8a = new Uint8Array(datastr.length);
25
- for (index = 0, _len = datastr.length; index < _len; index++) {
26
- data = datastr[index];
27
- ui8a[index] = datastr.charCodeAt(index) & 0xff;
28
- }
29
- return this.send(ui8a.buffer);
30
- };
31
- }
32
-
33
- // get the canvas element
34
- var canvas = $('canvas').get(0);
35
- var context = canvas.getContext('2d');
36
-
37
- var image = new Image();
38
- image.onload = function() {
39
- context.drawImage(image, 0, 15, 130, 110);
40
- // draw a cicle
41
- context.strokeStyle = '#000000';
42
- context.fillStyle = '#0099FF';
43
- context.beginPath();
44
- context.arc(50, 50, 25, 0, Math.PI * 2, true);
45
- context.closePath();
46
- context.stroke();
47
- context.fill();
48
- };
49
- image.src = '/assets/mercury/default-snippet.png';
50
-
51
- var dropper = $('#dropper');
52
-
53
- dropper.bind('dragenter', function(event) {
54
- event.preventDefault();
55
- event.originalEvent.dataTransfer.dropEffect = 'copy';
56
- });
57
-
58
- dropper.bind('dragover', function(event) {
59
- event.preventDefault();
60
- event.originalEvent.dataTransfer.dropEffect = 'copy';
61
- });
62
-
63
- dropper.bind('drop', function(event) {
64
- event.preventDefault();
65
-
66
- if (!event.originalEvent.dataTransfer.files.length) return;
67
-
68
- var reader = new FileReader();
69
- reader.readAsDataURL(event.originalEvent.dataTransfer.files[0]);
70
- reader.onload = function() {
71
- var image = new Image();
72
- image.src = reader.result;
73
- context.drawImage(image, 0, 15, 130, 110);
74
- };
75
-
76
- });
77
-
78
-
79
- // get the binary contents of the canvas and submit them back to the server using a multipart form
80
- $('input').click(function() {
81
- var xhr = new XMLHttpRequest;
82
- xhr.onload = function(event) {
83
- try {
84
- console.debug(jQuery.parseJSON(event.target.responseText));
85
- } catch (e) { alert('Unable to process response') }
86
- };
87
-
88
- var type = $(this).val();
89
- var binary = atob(document.getElementById('canvas').toDataURL("image/" + type).replace('data:image/' + type + ';base64,', ''));
90
- var multipart = new Mercury.uploader.MultiPartPost('image[image]', {name: 'test.' + type, size: 100, type: 'image/' + type}, binary);
91
-
92
- xhr.open('post', Mercury.config.uploading.url, true);
93
- xhr.setRequestHeader('Accept', 'application/json, text/javascript, text/html, application/xml, text/xml, */*');
94
- xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
95
- xhr.setRequestHeader('X-CSRF-Token', Mercury.csrfToken);
96
- xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + multipart.boundary);
97
- xhr.sendAsBinary(multipart.body);
98
- });
99
-
100
- </script>
101
-
102
- </body>
103
- </html>