mercury-rails 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -2,26 +2,6 @@
2
2
  * Mercury Editor is a CoffeeScript and jQuery based WYSIWYG editor. Documentation and other useful information can be
3
3
  * found at https://github.com/jejacks0n/mercury
4
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
5
  *= require_self
26
6
  *
27
7
  * Minimum jQuery requirements are 1.7
@@ -31,11 +11,7 @@
31
11
  * using :remote => true within the contents rendered in them.
32
12
  * require jquery_ujs
33
13
  *
34
- * If you want to override Mercury functionality, you can do so in a custom file that binds to the mercury:loaded event,
35
- * or do so at the end of the current file (mercury.js). There's an example that will help you get started.
36
- * require mercury_overrides
37
- *
38
- * Add all requires for the support libraries that integrate nicely with Mercury Editor.
14
+ * Add any requires for the support libraries that integrate nicely with Mercury Editor.
39
15
  * require mercury/support/history
40
16
  *
41
17
  * Require Mercury Editor itself.
@@ -47,6 +23,9 @@
47
23
  *
48
24
  * Add all requires for plugins that extend or change the behavior of Mercury Editor.
49
25
  * require mercury/plugins/save_as_xml/plugin.js
26
+ *
27
+ * Require any files you want to use that either extend, or change the default Mercury behavior.
28
+ * require mercury_overrides
50
29
  */
51
30
  window.Mercury = {
52
31
 
@@ -58,16 +37,16 @@ window.Mercury = {
58
37
  // behaviors. Any top level object put here will create a new toolbar. Buttons are simply nested inside the
59
38
  // toolbars, along with button groups.
60
39
  //
61
- // Some toolbars are custom (the snippetable toolbar for instance), and to denote that use _custom: true. You can
62
- // then build the toolbar yourself with it's own behavior.
40
+ // Some toolbars are custom (the snippets toolbar for instance), and to denote that use _custom: true. You can then
41
+ // build the toolbar yourself with it's own behavior.
63
42
  //
64
43
  // Buttons can be grouped, and a button group is simply a way to wrap buttons for styling -- they can also handle
65
- // enabling or disabling all the buttons within it by using a context. The table button group is a good example
66
- // of this.
44
+ // enabling or disabling all the buttons within it by using a context. The table button group is a good example of
45
+ // this.
67
46
  //
68
- // It's important to note that each of the button names (keys), in each toolbar object must be unique, regardless
69
- // of if it's in a button group, or nested, etc. This is because styling is applied to them by name, and because
70
- // their name is used in the event that's fired when you click on them.
47
+ // It's important to note that each of the button names (keys), in each toolbar object must be unique, regardless of
48
+ // if it's in a button group, or nested, etc. This is because styling is applied to them by name, and because their
49
+ // name is used in the event that's fired when you click on them.
71
50
  //
72
51
  // Button format: `[label, description, {type: action, type: action, etc}]`
73
52
  //
@@ -97,8 +76,8 @@ window.Mercury = {
97
76
  // 1. a string, denoting the name of the mode
98
77
  // note: it's assumed that when a specific mode is turned on, all other modes will be turned off, which happens
99
78
  // automatically, thus putting the editor into a specific "state"
100
- // - regions: allows buttons to be enabled/disabled based on what region type has focus, expects the action to be:
101
- // 1. an array of region types (eg. ['editable', 'markupable'])
79
+ // - regions: allows buttons to be enabled/disabled based on what region type has focus, expects:
80
+ // 1. an array of region types (eg. ['full', 'markdown'])
102
81
  // - preload: allows some dialog views to be loaded when the button is created instead of on first open, expects:
103
82
  // 1. a boolean true / false
104
83
  // note: this is only used by panels, selects, and palettes
@@ -122,10 +101,10 @@ window.Mercury = {
122
101
  redo: ['Redo', 'Redo your last action'],
123
102
  sep: ' '
124
103
  },
125
- insertLink: ['Link', 'Insert Link', { modal: '/mercury/modals/link.html', regions: ['editable', 'markupable'] }],
126
- insertMedia: ['Media', 'Insert Media (images and videos)', { modal: '/mercury/modals/media.html', regions: ['editable', 'markupable'] }],
127
- insertTable: ['Table', 'Insert Table', { modal: '/mercury/modals/table.html', regions: ['editable', 'markupable'] }],
128
- insertCharacter: ['Character', 'Special Characters', { modal: '/mercury/modals/character.html', regions: ['editable', 'markupable'] }],
104
+ insertLink: ['Link', 'Insert Link', { modal: '/mercury/modals/link.html', regions: ['full', 'markdown'] }],
105
+ insertMedia: ['Media', 'Insert Media (images and videos)', { modal: '/mercury/modals/media.html', regions: ['full', 'markdown'] }],
106
+ insertTable: ['Table', 'Insert Table', { modal: '/mercury/modals/table.html', regions: ['full', 'markdown'] }],
107
+ insertCharacter: ['Character', 'Special Characters', { modal: '/mercury/modals/character.html', regions: ['full', 'markdown'] }],
129
108
  snippetPanel: ['Snippet', 'Snippet Panel', { panel: '/mercury/panels/snippets.html' }],
130
109
  sep2: ' ',
131
110
  historyPanel: ['History', 'Page Version History', { panel: '/mercury/panels/history.html' }],
@@ -134,7 +113,7 @@ window.Mercury = {
134
113
  },
135
114
 
136
115
  editable: {
137
- _regions: ['editable', 'markupable'],
116
+ _regions: ['full', 'markdown'],
138
117
  predefined: {
139
118
  style: ['Style', null, { select: '/mercury/selects/style.html', preload: true }],
140
119
  sep1: ' ',
@@ -142,17 +121,17 @@ window.Mercury = {
142
121
  sep2: '-'
143
122
  },
144
123
  colors: {
145
- backColor: ['Background Color', null, { palette: '/mercury/palettes/backcolor.html', context: true, preload: true, regions: ['editable'] }],
124
+ backColor: ['Background Color', null, { palette: '/mercury/palettes/backcolor.html', context: true, preload: true, regions: ['full'] }],
146
125
  sep1: ' ',
147
- foreColor: ['Text Color', null, { palette: '/mercury/palettes/forecolor.html', context: true, preload: true, regions: ['editable'] }],
126
+ foreColor: ['Text Color', null, { palette: '/mercury/palettes/forecolor.html', context: true, preload: true, regions: ['full'] }],
148
127
  sep2: '-'
149
128
  },
150
129
  decoration: {
151
130
  bold: ['Bold', null, { context: true }],
152
131
  italic: ['Italicize', null, { context: true }],
153
- overline: ['Overline', null, { context: true, regions: ['editable'] }],
154
- strikethrough: ['Strikethrough', null, { context: true, regions: ['editable'] }],
155
- underline: ['Underline', null, { context: true, regions: ['editable'] }],
132
+ overline: ['Overline', null, { context: true, regions: ['full'] }],
133
+ strikethrough: ['Strikethrough', null, { context: true, regions: ['full'] }],
134
+ underline: ['Underline', null, { context: true, regions: ['full'] }],
156
135
  sep: '-'
157
136
  },
158
137
  script: {
@@ -161,10 +140,10 @@ window.Mercury = {
161
140
  sep: '-'
162
141
  },
163
142
  justify: {
164
- justifyLeft: ['Align Left', null, { context: true, regions: ['editable'] }],
165
- justifyCenter: ['Center', null, { context: true, regions: ['editable'] }],
166
- justifyRight: ['Align Right', null, { context: true, regions: ['editable'] }],
167
- justifyFull: ['Justify Full', null, { context: true, regions: ['editable'] }],
143
+ justifyLeft: ['Align Left', null, { context: true, regions: ['full'] }],
144
+ justifyCenter: ['Center', null, { context: true, regions: ['full'] }],
145
+ justifyRight: ['Align Right', null, { context: true, regions: ['full'] }],
146
+ justifyFull: ['Justify Full', null, { context: true, regions: ['full'] }],
168
147
  sep: '-'
169
148
  },
170
149
  list: {
@@ -179,12 +158,12 @@ window.Mercury = {
179
158
  },
180
159
  table: {
181
160
  _context: true,
182
- insertRowBefore: ['Insert Table Row', 'Insert a table row before the cursor', { regions: ['editable'] }],
183
- insertRowAfter: ['Insert Table Row', 'Insert a table row after the cursor', { regions: ['editable'] }],
184
- deleteRow: ['Delete Table Row', 'Delete this table row', { regions: ['editable'] }],
185
- insertColumnBefore: ['Insert Table Column', 'Insert a table column before the cursor', { regions: ['editable'] }],
186
- insertColumnAfter: ['Insert Table Column', 'Insert a table column after the cursor', { regions: ['editable'] }],
187
- deleteColumn: ['Delete Table Column', 'Delete this table column', { regions: ['editable'] }],
161
+ insertRowBefore: ['Insert Table Row', 'Insert a table row before the cursor', { regions: ['full'] }],
162
+ insertRowAfter: ['Insert Table Row', 'Insert a table row after the cursor', { regions: ['full'] }],
163
+ deleteRow: ['Delete Table Row', 'Delete this table row', { regions: ['full'] }],
164
+ insertColumnBefore: ['Insert Table Column', 'Insert a table column before the cursor', { regions: ['full'] }],
165
+ insertColumnAfter: ['Insert Table Column', 'Insert a table column after the cursor', { regions: ['full'] }],
166
+ deleteColumn: ['Delete Table Column', 'Delete this table column', { regions: ['full'] }],
188
167
  sep1: ' ',
189
168
  increaseColspan: ['Increase Cell Columns', 'Increase the cells colspan'],
190
169
  decreaseColspan: ['Decrease Cell Columns', 'Decrease the cells colspan and add a new cell'],
@@ -197,15 +176,15 @@ window.Mercury = {
197
176
  sep1: '-'
198
177
  },
199
178
  formatting: {
200
- removeFormatting: ['Remove Formatting', 'Remove formatting for the selection', { regions: ['editable'] }],
179
+ removeFormatting: ['Remove Formatting', 'Remove formatting for the selection', { regions: ['full'] }],
201
180
  sep2: ' '
202
181
  },
203
182
  editors: {
204
- htmlEditor: ['Edit HTML', 'Edit the HTML content', { regions: ['editable'] }]
183
+ htmlEditor: ['Edit HTML', 'Edit the HTML content', { regions: ['full'] }]
205
184
  }
206
185
  },
207
186
 
208
- snippetable: {
187
+ snippets: {
209
188
  _custom: true,
210
189
  actions: {
211
190
  editSnippet: ['Edit Snippet Settings'],
@@ -220,28 +199,27 @@ window.Mercury = {
220
199
  //
221
200
  // You can customize some aspects of how regions are found, identified, and saved.
222
201
  //
223
- // className: Mercury identifies editable regions by a className. This classname has to be added in your HTML in
224
- // advance, and is the only real code/naming exposed in the implementation of Mercury. To allow this to be as
225
- // configurable as possible, you can set the name of the class. When switching to preview mode, this configuration
226
- // is also used to generate a class to indicate that Mercury is in preview mode by appending it with '-preview' (so
227
- // by default it would be mercury-region-preview)
202
+ // attribute: Mercury identifies editable regions by a data-mercury attribute. This attribute has to be added in
203
+ // your HTML in advance, and is the only real code/naming exposed in the implementation of Mercury. To allow this
204
+ // to be as configurable as possible, you can set the name of this attribute. If you change this, you should adjust
205
+ // the injected styles as well.
228
206
  //
229
207
  // identifier: This is used as a unique identifier for any given region (and thus should be unique to the page).
230
208
  // By default this is the id attribute but can be changed to a data attribute should you want to use something
231
209
  // custom instead.
232
210
  //
233
- // determineType: This function is called after checking the data-type attribute for the correct field type. Use
234
- // it if you want to programatically set the type based on inspection of the region.
235
- //
236
211
  // dataAttributes: The dataAttributes is an array of data attributes that will be serialized and returned to the
237
212
  // server upon saving. These attributes, when applied to a Mercury region element, will be automatically serialized
238
213
  // and submitted with the AJAX request sent when a page is saved. These are expected to be HTML5 data attributes,
239
214
  // and 'data-' will automatically be prepended to each item in this directive. (ex. ['scope', 'version'])
215
+ //
216
+ // determineType: This function is called after checking the data-type attribute for the correct field type. Use
217
+ // it if you want to dynamically set the type based on inspection of the region.
240
218
  regions: {
241
- className: 'mercury-region',
219
+ attribute: 'data-mercury',
242
220
  identifier: 'id',
243
- // determineType: function(region){},
244
221
  dataAttributes: []
222
+ // determineType: function(region){},
245
223
  },
246
224
 
247
225
 
@@ -329,7 +307,7 @@ window.Mercury = {
329
307
  // If you want to add behaviors to specific region types, you can mix them into the actions property of any region
330
308
  // type.
331
309
  //
332
- // Mercury.Regions.Editable.actions.htmlEditor = function() {}
310
+ // Mercury.Regions.Full.actions.htmlEditor = function() {}
333
311
  //
334
312
  // You can see how the behavior matches up directly with the button names. It's also important to note that the
335
313
  // callback functions are executed within the scope of the given region, so you have access to all it's methods.
@@ -370,12 +348,14 @@ window.Mercury = {
370
348
  csrfSelector: 'meta[name="csrf-token"]',
371
349
  csrfHeader: 'X-CSRF-Token',
372
350
 
351
+
373
352
  // ## Editor URLs
374
353
  //
375
354
  // When loading a given page, you may want to tweak this regex. It's to allow the url to differ from the page
376
355
  // you're editing, and the url at which you access it.
377
356
  editorUrlRegEx: /([http|https]:\/\/.[^\/]*)\/editor\/?(.*)/i,
378
357
 
358
+
379
359
  // ## Hijacking Links & Forms
380
360
  //
381
361
  // Mercury will hijack links and forms that don't have a target set, or the target is set to _self and will set it
@@ -448,15 +428,16 @@ window.Mercury = {
448
428
  // Mercury tries to stay as much out of your code as possible, but because regions appear within your document we
449
429
  // need to include a few styles to indicate regions, as well as the different states of them (eg. focused). These
450
430
  // styles are injected into your document, and as simple as they might be, you may want to change them.
451
- //
452
- // {{regionClass}} will be automatically replaced with whatever you have set in the regions.class config directive.
453
431
  injectedStyles: '' +
454
- '.{{regionClass}} { min-height: 10px; outline: 1px dotted #09F } ' +
455
- '.{{regionClass}}:focus, .{{regionClass}}.focus { outline: none; -webkit-box-shadow: 0 0 10px #09F, 0 0 1px #045; box-shadow: 0 0 10px #09F, 0 0 1px #045 }' +
456
- '.{{regionClass}}:after { content: "."; display: block; visibility: hidden; clear: both; height: 0; overflow: hidden; }' +
457
- '.{{regionClass}} table, .{{regionClass}} td, .{{regionClass}} th { border: 1px dotted red; min-width: 6px; }' +
458
- '.mercury-textarea { border: 0; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; resize: none; }' +
459
- '.mercury-textarea:focus { outline: none; }'
432
+ '[data-mercury] { min-height: 10px; outline: 1px dotted #09F } ' +
433
+ '[data-mercury]:focus { outline: none; -webkit-box-shadow: 0 0 10px #09F, 0 0 1px #045; box-shadow: 0 0 10px #09F, 0 0 1px #045 }' +
434
+ '[data-mercury].focus { outline: none; -webkit-box-shadow: 0 0 10px #09F, 0 0 1px #045; box-shadow: 0 0 10px #09F, 0 0 1px #045 }' +
435
+ '[data-mercury]:after { content: "."; display: block; visibility: hidden; clear: both; height: 0; overflow: hidden; }' +
436
+ '[data-mercury] table { border: 1px dotted red; min-width: 6px; }' +
437
+ '[data-mercury] th { border: 1px dotted red; min-width: 6px; }' +
438
+ '[data-mercury] td { border: 1px dotted red; min-width: 6px; }' +
439
+ '[data-mercury] .mercury-textarea { border: 0; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; resize: none; }' +
440
+ '[data-mercury] .mercury-textarea:focus { outline: none; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; }'
460
441
  },
461
442
 
462
443
  // ## Silent Mode
@@ -467,13 +448,6 @@ window.Mercury = {
467
448
  // ## Debug Mode
468
449
  //
469
450
  // Turning debug mode on will log events and other various things (using console.debug if available).
470
- debug: false,
471
-
472
- // The onload method is provided as a callback in case you want to override default Mercury Editor behavior. It will
473
- // be called directly after the Mercury scripts have loaded, but before anything has been initialized. It's a good
474
- // place to add or change functionality.
475
- onload: function() {
476
- //Mercury.PageEditor.prototype.iframeSrc = function(url) { return '/testing'; }
477
- },
451
+ debug: false
478
452
 
479
453
  };
@@ -146,7 +146,7 @@ jQuery.extend Mercury.lightview,
146
146
  return unless @url
147
147
  @element.addClass('loading')
148
148
  if Mercury.preloadedViews[@url]
149
- setTimeout(10, => @loadContent(Mercury.preloadedViews[@url]))
149
+ setTimeout((=> @loadContent(Mercury.preloadedViews[@url])), 10)
150
150
  else
151
151
  jQuery.ajax @url, {
152
152
  headers: Mercury.ajaxHeaders()
@@ -34,7 +34,7 @@
34
34
  #
35
35
  @Mercury ||= {}
36
36
  jQuery.extend @Mercury,
37
- version: '0.5.0'
37
+ version: '0.6.0'
38
38
 
39
39
  # Mercury object namespaces
40
40
  Regions: Mercury.Regions || {}
@@ -137,7 +137,7 @@ jQuery.extend Mercury.modal,
137
137
  return unless @url
138
138
  @element.addClass('loading')
139
139
  if Mercury.preloadedViews[@url]
140
- setTimeout(10, => @loadContent(Mercury.preloadedViews[@url]))
140
+ setTimeout((=> @loadContent(Mercury.preloadedViews[@url])), 10)
141
141
  else
142
142
  jQuery.ajax @url, {
143
143
  headers: Mercury.ajaxHeaders()
@@ -19,7 +19,7 @@
19
19
  if selection.is && image = selection.is('img')
20
20
  @element.find('#media_image_url').val(image.attr('src'))
21
21
  @element.find('#media_image_alignment').val(image.attr('align'))
22
- setTimeout 300, => @element.find('#media_image_url').focus()
22
+ setTimeout((=> @element.find('#media_image_url').focus()), 300)
23
23
 
24
24
  # if we're editing an iframe (assume it's a video for now)
25
25
  if selection.is && iframe = selection.is('iframe')
@@ -29,13 +29,13 @@
29
29
  @element.find('#media_youtube_url').val("http://youtu.be/#{src.match(/\/embed\/(\w+)/)[1]}")
30
30
  @element.find('#media_youtube_width').val(iframe.width())
31
31
  @element.find('#media_youtube_height').val(iframe.height())
32
- setTimeout 300, => @element.find('#media_youtube_url').focus()
32
+ setTimeout((=> @element.find('#media_youtube_url').focus()), 300)
33
33
  else if src.indexOf('http://player.vimeo.com') > -1
34
34
  # it's a vimeo video
35
35
  @element.find('#media_vimeo_url').val("http://vimeo.com/#{src.match(/\/video\/(\w+)/)[1]}")
36
36
  @element.find('#media_vimeo_width').val(iframe.width())
37
37
  @element.find('#media_vimeo_height').val(iframe.height())
38
- setTimeout 300, => @element.find('#media_vimeo_url').focus()
38
+ setTimeout((=> @element.find('#media_vimeo_url').focus()), 300)
39
39
 
40
40
 
41
41
  # build the image or youtube embed on form submission
@@ -51,14 +51,16 @@
51
51
 
52
52
  when 'youtube_url'
53
53
  url = @element.find('#media_youtube_url').val()
54
- unless /^http:\/\/youtu.be\//.test(url)
54
+ unless /^https?:\/\/youtu.be\//.test(url)
55
55
  Mercury.notify('Error: The provided youtube share url was invalid.')
56
56
  return
57
- code = url.replace('http://youtu.be/', '')
57
+ code = url.replace(/https?:\/\/youtu.be\//, '')
58
+ protocol = 'http'
59
+ protocol = 'https' if /^https:/.test(url)
58
60
  value = jQuery('<iframe>', {
59
61
  width: @element.find('#media_youtube_width').val() || 560,
60
62
  height: @element.find('#media_youtube_height').val() || 349,
61
- src: "http://www.youtube.com/embed/#{code}?wmode=transparent",
63
+ src: "#{protocol}://www.youtube.com/embed/#{code}?wmode=transparent",
62
64
  frameborder: 0,
63
65
  allowfullscreen: 'true'
64
66
  })
@@ -66,14 +68,16 @@
66
68
 
67
69
  when 'vimeo_url'
68
70
  url = @element.find('#media_vimeo_url').val()
69
- unless /^http:\/\/vimeo.com\//.test(url)
71
+ unless /^https?:\/\/vimeo.com\//.test(url)
70
72
  Mercury.notify('Error: The provided vimeo url was invalid.')
71
73
  return
72
- code = url.replace('http://vimeo.com/', '')
74
+ code = url.replace(/^https?:\/\/vimeo.com\//, '')
75
+ protocol = 'http'
76
+ protocol = 'https' if /^https:/.test(url)
73
77
  value = jQuery('<iframe>', {
74
78
  width: @element.find('#media_vimeo_width').val() || 400,
75
79
  height: @element.find('#media_vimeo_height').val() || 225,
76
- src: "http://player.vimeo.com/video/#{code}?title=1&byline=1&portrait=0&color=ffffff",
80
+ src: "#{protocol}://player.vimeo.com/video/#{code}?title=1&byline=1&portrait=0&color=ffffff",
77
81
  frameborder: 0
78
82
  })
79
83
  Mercury.trigger('action', {action: 'insertHTML', value: value})
@@ -47,9 +47,3 @@ Number::toBytes = ->
47
47
  bytes /= 1024
48
48
  i += 1
49
49
  return if i then "#{bytes.toFixed(2)}#{['', ' kb', ' Mb', ' Gb', ' Tb', ' Pb', ' Eb'][i]}" else "#{bytes} bytes"
50
-
51
-
52
- # make setTimeout not suck for coffeescript
53
- window.originalSetTimeout = window.setTimeout
54
- window.setTimeout = (arg1, arg2) ->
55
- if typeof(arg1) == 'number' then window.originalSetTimeout(arg2, arg1) else window.originalSetTimeout(arg1, arg2)
@@ -8,9 +8,9 @@ class @Mercury.PageEditor
8
8
  constructor: (@saveUrl = null, @options = {}) ->
9
9
  throw Mercury.I18n('Mercury.PageEditor can only be instantiated once.') if window.mercuryInstance
10
10
 
11
- @options.visible = true unless (@options.visible == false || @options.visible == 'no')
12
- @options.saveDataType = 'json' unless (@options.saveDataType == false || @options.saveDataType)
11
+ @options.visible = true unless (@options.visible == false || @options.visible == 'false')
13
12
  @visible = @options.visible
13
+ @options.saveDataType = 'json' unless (@options.saveDataType == false || @options.saveDataType)
14
14
 
15
15
  window.mercuryInstance = @
16
16
  @regions = []
@@ -32,6 +32,7 @@ class @Mercury.PageEditor
32
32
  @iframe.one 'load', => @bindEvents()
33
33
  @loadIframeSrc(null)
34
34
 
35
+
35
36
  initializeFrame: ->
36
37
  try
37
38
  return if @iframe.data('loaded')
@@ -42,8 +43,7 @@ class @Mercury.PageEditor
42
43
  @document = jQuery(@iframe.get(0).contentWindow.document)
43
44
 
44
45
  # inject styles for document to be able to highlight regions and other tools
45
- stylesToInject = Mercury.config.injectedStyles.replace(/{{regionClass}}/g, Mercury.config.regions.className)
46
- jQuery("<style mercury-styles=\"true\">").html(stylesToInject).appendTo(@document.find('head'))
46
+ jQuery("<style mercury-styles=\"true\">").html(Mercury.config.injectedStyles).appendTo(@document.find('head'))
47
47
 
48
48
  # jquery: make jQuery evaluate scripts within the context of the iframe window
49
49
  iframeWindow = @iframe.get(0).contentWindow
@@ -60,7 +60,7 @@ class @Mercury.PageEditor
60
60
 
61
61
  # trigger ready events
62
62
  Mercury.trigger('ready')
63
- jQuery(iframeWindow).trigger('mercury:ready')
63
+ iframeWindow.jQuery(iframeWindow).trigger('mercury:ready') if iframeWindow.jQuery
64
64
  iframeWindow.Event.fire(iframeWindow, 'mercury:ready') if iframeWindow.Event && iframeWindow.Event.fire
65
65
  iframeWindow.onMercuryReady() if iframeWindow.onMercuryReady
66
66
 
@@ -71,8 +71,8 @@ class @Mercury.PageEditor
71
71
 
72
72
  initializeRegions: ->
73
73
  @regions = []
74
- @buildRegion(jQuery(region)) for region in jQuery(".#{Mercury.config.regions.className}", @document)
75
- return unless @options.visible
74
+ @buildRegion(jQuery(region)) for region in jQuery("[#{Mercury.config.regions.attribute}]", @document)
75
+ return unless @visible
76
76
  for region in @regions
77
77
  if region.focus
78
78
  region.focus()
@@ -83,11 +83,7 @@ class @Mercury.PageEditor
83
83
  if region.data('region')
84
84
  region = region.data('region')
85
85
  else
86
- type = (
87
- region.data('type') ||
88
- ( jQuery.type(Mercury.config.regions.determineType) == 'function' && Mercury.config.regions.determineType(region) ) ||
89
- 'unknown'
90
- ).titleize()
86
+ type = (region.attr(Mercury.config.regions.attribute) || Mercury.config.regions.determineType?(region) || 'unknown').titleize()
91
87
  throw Mercury.I18n('Region type is malformed, no data-type provided, or "%s" is unknown for the "%s" region.', type, region.attr('id') || 'unknown') if type == 'Unknown' || !Mercury.Regions[type]
92
88
  if !Mercury.Regions[type].supported
93
89
  Mercury.notify('Mercury.Regions.%s is unsupported in this client. Supported browsers are %s.', type, Mercury.Regions[type].supportedText)
@@ -105,14 +101,14 @@ class @Mercury.PageEditor
105
101
  @snippetToolbar = new Mercury.SnippetToolbar(@document)
106
102
 
107
103
  @hijackLinksAndForms()
108
- Mercury.trigger('mode', {mode: 'preview'}) unless @options.visible
104
+ Mercury.trigger('mode', {mode: 'preview'}) unless @visible
109
105
 
110
106
 
111
107
  bindDocumentEvents: ->
112
108
  @document.on 'mousedown', (event) ->
113
109
  Mercury.trigger('hide:dialogs')
114
110
  if Mercury.region
115
- Mercury.trigger('unfocus:regions') unless jQuery(event.target).closest(".#{Mercury.config.regions.className}").get(0) == Mercury.region.element.get(0)
111
+ Mercury.trigger('unfocus:regions') unless jQuery(event.target).closest("[#{Mercury.config.regions.attribute}]").get(0) == Mercury.region.element.get(0)
116
112
 
117
113
  jQuery(@document).bind 'keydown', (event) =>
118
114
  return unless event.ctrlKey || event.metaKey
@@ -122,9 +118,9 @@ class @Mercury.PageEditor
122
118
 
123
119
 
124
120
  bindEvents: ->
125
- Mercury.on 'initialize:frame', => setTimeout(100, @initializeFrame)
121
+ Mercury.on 'initialize:frame', => setTimeout(@initializeFrame, 100)
126
122
  Mercury.on 'focus:frame', => @iframe.focus()
127
- Mercury.on 'focus:window', => setTimeout(10, => @focusableElement.focus())
123
+ Mercury.on 'focus:window', => setTimeout((=> @focusableElement.focus()), 10)
128
124
  Mercury.on 'toggle:interface', => @toggleInterface()
129
125
  Mercury.on 'reinitialize', => @initializeRegions()
130
126
  Mercury.on 'mode', (event, options) => @previewing = !@previewing if options.mode == 'preview'
@@ -148,15 +144,17 @@ class @Mercury.PageEditor
148
144
 
149
145
  toggleInterface: ->
150
146
  if @visible
151
- Mercury.trigger('mode', {mode: 'preview'}) if @previewing
152
147
  @visible = false
153
148
  @toolbar.hide()
154
149
  @statusbar.hide()
150
+ Mercury.trigger('mode', {mode: 'preview'}) unless @previewing
151
+ @previewing = true
155
152
  else
156
153
  @visible = true
157
154
  @toolbar.show()
158
155
  @statusbar.show()
159
- Mercury.trigger('mode', {mode: 'preview'})
156
+ Mercury.trigger('mode', {mode: 'preview'})
157
+ @previewing = false
160
158
  @resize()
161
159
 
162
160
 
@@ -188,6 +186,7 @@ class @Mercury.PageEditor
188
186
  else
189
187
  return url
190
188
 
189
+
191
190
  loadIframeSrc: (url)->
192
191
  # clear any existing events if we are loading a new iframe to replace the existing one
193
192
  @document.off() if @document
@@ -195,6 +194,7 @@ class @Mercury.PageEditor
195
194
  @iframe.data('loaded', false)
196
195
  @iframe.get(0).contentWindow.document.location.href = @iframeSrc(url, true)
197
196
 
197
+
198
198
  hijackLinksAndForms: ->
199
199
  for element in jQuery('a, form', @document)
200
200
  ignored = false
@@ -202,7 +202,7 @@ class @Mercury.PageEditor
202
202
  if jQuery(element).hasClass(classname)
203
203
  ignored = true
204
204
  continue
205
- if !ignored && (element.target == '' || element.target == '_self') && !jQuery(element).closest(".#{Mercury.config.regions.className}").length
205
+ if !ignored && (element.target == '' || element.target == '_self') && !jQuery(element).closest("[#{Mercury.config.regions.attribute}]").length
206
206
  jQuery(element).attr('target', '_parent')
207
207
 
208
208