kiteditor 1.0.12 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/{lib/generators/mercury/install/images/templates → app/controllers/mercury}/images_controller.rb +0 -0
- data/{lib/generators/mercury/install/images/templates/ar_paperclip_image.rb → app/models/mercury/image.rb} +0 -7
- data/app/views/layouts/mercury.html.erb +20 -10
- data/app/views/mercury/modals/character.html +1 -1
- data/app/views/mercury/modals/htmleditor.html +7 -3
- data/app/views/mercury/modals/link.html +51 -37
- data/app/views/mercury/modals/media.html +0 -102
- data/app/views/mercury/modals/table.html +73 -79
- data/app/views/mercury/panels/snippets.html +1 -6
- data/app/views/mercury/snippets/example/options.html.erb +27 -23
- data/{lib/generators/mercury/install/images/templates/ar_paperclip_image_migration.rb → db/migrate/20110526035601_create_mercury_images.rb} +0 -0
- data/features/loading/loading.feature +2 -5
- data/features/loading/user_interface.feature +7 -9
- data/features/regions/{full → editable}/advanced_editing.feature +0 -0
- data/features/regions/editable/basic_editing.feature +195 -0
- data/features/regions/{full → editable}/inserting_links.feature +19 -20
- data/features/regions/{full → editable}/inserting_media.feature +18 -36
- data/features/regions/{full → editable}/inserting_snippets.feature +18 -28
- data/features/regions/{full → editable}/inserting_special_characters.feature +2 -2
- data/features/regions/editable/inserting_tables.feature +109 -0
- data/features/regions/{full → editable}/pasting.feature +0 -0
- data/features/regions/{full → editable}/uploading_images.feature +0 -0
- data/features/regions/{markdown → markupable}/advanced_editing.feature +0 -0
- data/features/regions/{markdown → markupable}/basic_editing.feature +0 -0
- data/features/regions/{markdown → markupable}/inserting_links.feature +0 -0
- data/features/regions/{markdown → markupable}/inserting_media.feature +0 -0
- data/features/regions/{markdown → markupable}/inserting_snippets.feature +0 -0
- data/features/regions/{markdown → markupable}/inserting_special_characters.feature +0 -0
- data/features/regions/{markdown → markupable}/inserting_tables.feature +0 -0
- data/features/regions/{image → markupable}/uploading_images.feature +0 -0
- data/features/regions/{snippets → snippetable}/advanced_editing.feature +0 -0
- data/features/regions/{snippets → snippetable}/basic_editing.feature +0 -0
- data/features/regions/{snippets → snippetable}/inserting_snippets.feature +0 -0
- data/features/saving/saving.feature +8 -8
- data/features/step_definitions/mercury_steps.rb +438 -1
- data/features/support/env.rb +1 -11
- data/{lib/mercury/cucumber → features}/support/mercury_contents.rb +3 -3
- data/{lib/mercury/cucumber → features}/support/mercury_selectors.rb +20 -0
- data/features/support/selectors.rb +0 -23
- data/lib/generators/mercury/install/install_generator.rb +23 -12
- data/lib/generators/mercury/install/{images/templates → templates}/mongoid_paperclip_image.rb +0 -0
- data/lib/mercury/authentication.rb +0 -1
- data/lib/mercury-rails.rb +2 -1
- data/spec/javascripts/mercury/{dialog_spec.coffee → dialog_spec.js.coffee} +12 -11
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +3 -2
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +4 -3
- data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +3 -2
- data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +3 -2
- data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +3 -2
- data/spec/javascripts/mercury/lightview_spec.js.coffee +142 -180
- data/spec/javascripts/mercury/mercury_spec.js.coffee +13 -19
- data/spec/javascripts/mercury/modal_spec.js.coffee +148 -192
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +5 -4
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +3 -2
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +34 -107
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +26 -106
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +3 -2
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +40 -50
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +80 -124
- data/spec/javascripts/mercury/palette_spec.js.coffee +5 -4
- data/spec/javascripts/mercury/panel_spec.js.coffee +12 -9
- data/spec/javascripts/mercury/region_spec.js.coffee +17 -22
- data/spec/javascripts/mercury/regions/{full_spec.js.coffee → editable_spec.js.coffee} +28 -26
- data/spec/javascripts/mercury/regions/{markdown_spec.js.coffee → markupable_spec.js.coffee} +34 -32
- data/spec/javascripts/mercury/regions/{snippets_spec.js.coffee → snippetable_spec.js.coffee} +55 -54
- data/spec/javascripts/mercury/select_spec.js.coffee +5 -4
- data/spec/javascripts/mercury/snippet_spec.js.coffee +16 -92
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +16 -31
- data/spec/javascripts/mercury/statusbar_spec.js.coffee +10 -9
- data/spec/javascripts/mercury/table_editor_spec.js.coffee +2 -1
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +9 -7
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +26 -55
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +13 -13
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +14 -43
- data/spec/javascripts/mercury/tooltip_spec.js.coffee +2 -1
- data/spec/javascripts/mercury/uploader_spec.js.coffee +33 -47
- data/spec/javascripts/{support/event_simulation.js → spec_helper.js} +2 -0
- data/spec/javascripts/{fixtures → templates}/mercury/dialog.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/dialogs/backcolor.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/dialogs/forecolor.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/dialogs/formatblock.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/dialogs/snippetpanel.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/dialogs/style.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/lightview.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/modal.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/modals/htmleditor.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/modals/insertcharacter.html +0 -0
- data/spec/javascripts/templates/mercury/modals/insertlink.html +30 -0
- data/spec/javascripts/templates/mercury/modals/insertmedia.html +35 -0
- data/spec/javascripts/{fixtures → templates}/mercury/modals/insertsnippet.html +0 -0
- data/spec/javascripts/templates/mercury/modals/inserttable.html +27 -0
- data/spec/javascripts/{fixtures → templates}/mercury/page_editor.html +4 -4
- data/spec/javascripts/{fixtures → templates}/mercury/palette.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/panel.html +0 -0
- data/spec/javascripts/templates/mercury/region.html +2 -0
- data/spec/javascripts/templates/mercury/regions/editable.html +3 -0
- data/spec/javascripts/templates/mercury/regions/snippetable.html +4 -0
- data/spec/javascripts/{fixtures → templates}/mercury/select.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/snippet.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/snippet_toolbar.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/statusbar.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/table_editor.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/toolbar.button.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/toolbar.button_group.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/toolbar.expander.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/toolbar.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/tooltip.html +0 -0
- data/spec/javascripts/{fixtures → templates}/mercury/uploader.html +0 -0
- data/{app → vendor}/assets/images/mercury/button.png +0 -0
- data/{app → vendor}/assets/images/mercury/close.png +0 -0
- data/{app → vendor}/assets/images/mercury/loading-dark.gif +0 -0
- data/{app → vendor}/assets/images/mercury/loading-light.gif +0 -0
- data/{app → vendor}/assets/images/mercury/missing-image.png +0 -0
- data/{app → vendor}/assets/images/mercury/search-icon.png +0 -0
- data/{app → vendor}/assets/images/mercury/temp-logo.png +0 -0
- data/{app/assets/javascripts → vendor/assets/javascripts/mercury/dependencies}/jquery-1.7.js +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dependencies/jquery.additions.js +13 -103
- data/{app → vendor}/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dependencies/liquidmetal.js +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dependencies/showdown.js +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dialog.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +1 -1
- data/{app → vendor}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +1 -1
- data/{app → vendor}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/finalize.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/lightview.js.coffee +17 -38
- data/{features/regions/markdown/uploading_images.feature → vendor/assets/javascripts/mercury/locales/da.locale.js.coffee} +0 -0
- data/{app → vendor}/assets/javascripts/mercury/locales/de.locale.js.coffee +10 -4
- data/{app → vendor}/assets/javascripts/mercury/locales/es.locale.js.coffee +9 -3
- data/{app → vendor}/assets/javascripts/mercury/locales/example.local.js.coffee +5 -3
- data/{app → vendor}/assets/javascripts/mercury/locales/fr.locale.js.coffee +9 -3
- data/{app → vendor}/assets/javascripts/mercury/locales/it.locale.js.coffee +9 -3
- data/{app → vendor}/assets/javascripts/mercury/locales/ko.local.js.coffee +10 -4
- data/{app → vendor}/assets/javascripts/mercury/locales/nl.locale.js.coffee +9 -3
- data/{app → vendor}/assets/javascripts/mercury/locales/pt.locale.js.coffee +9 -3
- data/{app → vendor}/assets/javascripts/mercury/locales/sv.local.js.coffee +9 -3
- data/{app → vendor}/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +9 -3
- data/{app → vendor}/assets/javascripts/mercury/mercury.js.coffee +1 -10
- data/{app → vendor}/assets/javascripts/mercury/modal.js.coffee +40 -62
- data/{app → vendor}/assets/javascripts/mercury/modals/htmleditor.js.coffee +2 -3
- data/{app → vendor}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +0 -1
- data/{app → vendor}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +0 -2
- data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +54 -0
- data/{app → vendor}/assets/javascripts/mercury/native_extensions.js.coffee +6 -0
- data/{app → vendor}/assets/javascripts/mercury/page_editor.js.coffee +50 -84
- data/{app → vendor}/assets/javascripts/mercury/palette.js.coffee +1 -1
- data/{app → vendor}/assets/javascripts/mercury/panel.js.coffee +2 -3
- data/{app → vendor}/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +2 -2
- data/{app → vendor}/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +0 -0
- data/{app → vendor}/assets/javascripts/mercury/region.js.coffee +17 -18
- data/{app/assets/javascripts/mercury/regions/full.js.coffee → vendor/assets/javascripts/mercury/regions/editable.js.coffee} +31 -41
- data/{app/assets/javascripts/mercury/regions/markdown.js.coffee → vendor/assets/javascripts/mercury/regions/markupable.js.coffee} +24 -29
- data/{app → vendor}/assets/javascripts/mercury/regions/simple.js.coffee +54 -11
- data/{app/assets/javascripts/mercury/regions/snippets.js.coffee → vendor/assets/javascripts/mercury/regions/snippetable.js.coffee} +9 -10
- data/{app → vendor}/assets/javascripts/mercury/select.js.coffee +1 -1
- data/{app → vendor}/assets/javascripts/mercury/snippet_toolbar.js.coffee +6 -19
- data/{app → vendor}/assets/javascripts/mercury/statusbar.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/support/history.js +0 -0
- data/{app → vendor}/assets/javascripts/mercury/table_editor.js.coffee +0 -16
- data/{app → vendor}/assets/javascripts/mercury/toolbar.button.js.coffee +30 -45
- data/{app → vendor}/assets/javascripts/mercury/toolbar.button_group.js.coffee +2 -2
- data/{app → vendor}/assets/javascripts/mercury/toolbar.expander.js.coffee +4 -4
- data/{app → vendor}/assets/javascripts/mercury/toolbar.js.coffee +6 -10
- data/{app → vendor}/assets/javascripts/mercury/tooltip.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/uploader.js.coffee +19 -37
- data/{app → vendor}/assets/javascripts/mercury.js +87 -60
- data/vendor/assets/javascripts/mercury_loader.js +193 -0
- data/vendor/assets/javascripts/mercury_overrides.js +6 -0
- data/{app → vendor}/assets/stylesheets/mercury/all_images.css.erb +2 -6
- data/{app → vendor}/assets/stylesheets/mercury/dialog.css +8 -21
- data/{app → vendor}/assets/stylesheets/mercury/lightview.css +56 -6
- data/vendor/assets/stylesheets/mercury/mercury.css +151 -0
- data/{app → vendor}/assets/stylesheets/mercury/modal.css +32 -15
- data/{app → vendor}/assets/stylesheets/mercury/statusbar.css +0 -0
- data/{app → vendor}/assets/stylesheets/mercury/toolbar.css +1 -4
- data/{app → vendor}/assets/stylesheets/mercury/tooltip.css +0 -0
- data/{app → vendor}/assets/stylesheets/mercury/uploader.css +4 -4
- data/{app → vendor}/assets/stylesheets/mercury.css +5 -1
- data/vendor/assets/stylesheets/mercury_overrides.css +17 -0
- metadata +197 -367
- data/POST_INSTALL +0 -21
- data/app/assets/images/mercury/default-snippet.png +0 -0
- data/app/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/action.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/tools.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/user.png +0 -0
- data/app/assets/images/mercury/toolbar/snippets/buttons.png +0 -0
- data/app/assets/javascripts/mercury/locales/ar.locale.js.coffee +0 -201
- data/app/assets/javascripts/mercury/locales/da.locale.js.coffee +0 -208
- data/app/assets/javascripts/mercury/locales/hu.locale.js.coffee +0 -209
- data/app/assets/javascripts/mercury/locales/pl.locale.js.coffee +0 -213
- data/app/assets/javascripts/mercury/locales/ru.locale.js.coffee +0 -200
- data/app/assets/javascripts/mercury/locales/uk.locale.js.coffee +0 -200
- data/app/assets/javascripts/mercury/locales/zh.local.js.coffee +0 -203
- data/app/assets/javascripts/mercury/mercury-compiled.js +0 -10720
- data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +0 -152
- data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +0 -132
- data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +0 -68
- data/app/assets/javascripts/mercury/regions/image.js.coffee +0 -93
- data/app/assets/javascripts/mercury/snippet.js.coffee +0 -136
- data/app/assets/stylesheets/_mercury-bootstrap-overrides.scss +0 -61
- data/app/assets/stylesheets/_mercury-sass.scss +0 -33
- data/app/assets/stylesheets/mercury/bootstrap-ish.css +0 -1367
- data/app/assets/stylesheets/mercury/bootstrap-overrides.css +0 -61
- data/app/assets/stylesheets/mercury/mercury.css +0 -43
- data/app/helpers/mercury_helper.rb +0 -7
- data/app/views/layouts/mercury.html.haml +0 -19
- data/app/views/layouts/mercury.html.slim +0 -19
- data/app/views/mercury/snippets/no_options/preview.html.erb +0 -1
- data/config/routes.rb +0 -9
- data/features/generators/authentication.feature +0 -10
- data/features/generators/images.feature +0 -41
- data/features/generators/install.feature +0 -21
- data/features/regions/full/basic_editing.feature +0 -198
- data/features/regions/full/inserting_tables.feature +0 -109
- data/features/regions/simple/basic_editing.feature +0 -5
- data/features/step_definitions/custom_web_steps.rb +0 -22
- data/features/step_definitions/generator_steps.rb +0 -23
- data/features/support/aruba.rb +0 -28
- data/lib/generators/mercury/install/authentication/authentication_generator.rb +0 -17
- data/lib/generators/mercury/install/images/images_generator.rb +0 -47
- data/lib/mercury/cucumber/step_definitions/mercury_steps.rb +0 -408
- data/lib/mercury/cucumber/step_definitions.rb +0 -13
- data/lib/mercury/engine.rb +0 -19
- data/lib/mercury/rails.rb +0 -5
- data/lib/mercury/version.rb +0 -3
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/javascripts/application.js +0 -0
- data/spec/dummy/app/assets/javascripts/prototype.js +0 -6082
- data/spec/dummy/app/assets/stylesheets/application.css.scss +0 -110
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/app/views/layouts/mercury.html.erb +0 -28
- data/spec/dummy/config/application.rb +0 -58
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/database.yml +0 -10
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -67
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/teabag.rb +0 -9
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -5
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/.gitkeep +0 -0
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/blank.html +0 -1
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/images/bunny.gif +0 -0
- data/spec/dummy/public/images/bunny2.jpg +0 -0
- data/spec/dummy/public/index.html +0 -279
- data/spec/dummy/script/rails +0 -6
- data/spec/javascripts/fixtures/mercury/modals/insertlink.html +0 -67
- data/spec/javascripts/fixtures/mercury/modals/insertmedia.html +0 -87
- data/spec/javascripts/fixtures/mercury/modals/inserttable.html +0 -73
- data/spec/javascripts/fixtures/mercury/region.html +0 -6
- data/spec/javascripts/fixtures/mercury/regions/full.html +0 -1
- data/spec/javascripts/fixtures/mercury/regions/image.html +0 -1
- data/spec/javascripts/fixtures/mercury/regions/markdown.html +0 -1
- data/spec/javascripts/fixtures/mercury/regions/simple.html +0 -1
- data/spec/javascripts/fixtures/mercury/regions/snippets.html +0 -4
- data/spec/javascripts/mercury/regions/image_spec.js.coffee +0 -33
- data/spec/javascripts/mercury/regions/simple_spec.js.coffee +0 -32
- data/spec/javascripts/spec_helper.coffee +0 -4
- data/spec/teabag_env.rb +0 -32
@@ -25,6 +25,7 @@ jQuery.extend Mercury.uploader,
|
|
25
25
|
|
26
26
|
supported: ->
|
27
27
|
xhr = new XMLHttpRequest
|
28
|
+
fileReader = window.FileReader
|
28
29
|
|
29
30
|
if window.Uint8Array && window.ArrayBuffer && !XMLHttpRequest.prototype.sendAsBinary
|
30
31
|
XMLHttpRequest::sendAsBinary = (datastr) ->
|
@@ -32,13 +33,8 @@ jQuery.extend Mercury.uploader,
|
|
32
33
|
ui8a[index] = (datastr.charCodeAt(index) & 0xff) for data, index in datastr
|
33
34
|
@send(ui8a.buffer)
|
34
35
|
|
35
|
-
return !!(xhr.upload && xhr.sendAsBinary &&
|
36
|
+
return !!(xhr.upload && xhr.sendAsBinary && fileReader)
|
36
37
|
|
37
|
-
fileReaderSupported: ->
|
38
|
-
!!(window.FileReader)
|
39
|
-
|
40
|
-
formDataSupported: ->
|
41
|
-
!!(window.FormData)
|
42
38
|
|
43
39
|
build: ->
|
44
40
|
@element = jQuery('<div>', {class: 'mercury-uploader', style: 'display:none'})
|
@@ -90,11 +86,8 @@ jQuery.extend Mercury.uploader,
|
|
90
86
|
|
91
87
|
|
92
88
|
loadImage: ->
|
93
|
-
|
94
|
-
@
|
95
|
-
@element.find('.mercury-uploader-preview b').html(jQuery('<img>', {src: result}))
|
96
|
-
@upload()
|
97
|
-
else
|
89
|
+
@file.readAsDataURL (result) =>
|
90
|
+
@element.find('.mercury-uploader-preview b').html(jQuery('<img>', {src: result}))
|
98
91
|
@upload()
|
99
92
|
|
100
93
|
|
@@ -128,28 +121,16 @@ jQuery.extend Mercury.uploader,
|
|
128
121
|
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
129
122
|
xhr.setRequestHeader(Mercury.config.csrfHeader, Mercury.csrfToken)
|
130
123
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
@file.readAsBinaryString (result) =>
|
135
|
-
|
136
|
-
multipart = new Mercury.uploader.MultiPartPost(Mercury.config.uploading.inputName, @file, result)
|
124
|
+
@file.readAsBinaryString (result) =>
|
125
|
+
# build the multipart post string
|
126
|
+
multipart = new Mercury.uploader.MultiPartPost(Mercury.config.uploading.inputName, @file, result)
|
137
127
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
# set the content type and send
|
142
|
-
xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + multipart.boundary)
|
143
|
-
xhr.sendAsBinary(multipart.body)
|
144
|
-
|
145
|
-
# FormData based. Safari 5.1.2.
|
146
|
-
#
|
147
|
-
else
|
148
|
-
formData = new FormData()
|
149
|
-
formData.append(Mercury.config.uploading.inputName, @file.file, @file.file.name)
|
150
|
-
|
151
|
-
xhr.send(formData)
|
128
|
+
# update the content size so we can calculate
|
129
|
+
@file.updateSize(multipart.delta)
|
152
130
|
|
131
|
+
# set the content type and send
|
132
|
+
xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + multipart.boundary)
|
133
|
+
xhr.sendAsBinary(multipart.body)
|
153
134
|
|
154
135
|
|
155
136
|
updateStatus: (message, loaded) ->
|
@@ -161,7 +142,7 @@ jQuery.extend Mercury.uploader,
|
|
161
142
|
|
162
143
|
|
163
144
|
hide: (delay = 0) ->
|
164
|
-
setTimeout =>
|
145
|
+
setTimeout delay * 1000, =>
|
165
146
|
@element.animate {opacity: 0}, 200, 'easeInOutSine', =>
|
166
147
|
@overlay.animate {opacity: 0}, 200, 'easeInOutSine', =>
|
167
148
|
@overlay.hide()
|
@@ -169,7 +150,6 @@ jQuery.extend Mercury.uploader,
|
|
169
150
|
@reset()
|
170
151
|
@visible = false
|
171
152
|
Mercury.trigger('focus:frame')
|
172
|
-
, delay * 1000
|
173
153
|
|
174
154
|
|
175
155
|
reset: ->
|
@@ -200,10 +180,12 @@ jQuery.extend Mercury.uploader,
|
|
200
180
|
class Mercury.uploader.File
|
201
181
|
|
202
182
|
constructor: (@file) ->
|
203
|
-
@
|
204
|
-
@
|
205
|
-
@
|
206
|
-
@
|
183
|
+
@size = @file.size
|
184
|
+
@fullSize = @file.size
|
185
|
+
@readableSize = @file.size.toBytes()
|
186
|
+
@name = @file.fileName
|
187
|
+
@name ||= @file.name
|
188
|
+
@type = @file.type
|
207
189
|
|
208
190
|
# add any errors if we need to
|
209
191
|
errors = []
|
@@ -2,14 +2,40 @@
|
|
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
|
-
*
|
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
|
+
*
|
6
25
|
*= require_self
|
7
26
|
*
|
27
|
+
* Minimum jQuery requirements are 1.7
|
28
|
+
*= require mercury/dependencies/jquery-1.7
|
29
|
+
*
|
8
30
|
* You can include the Rails jQuery ujs script here to get some nicer behaviors in modals, panels and lightviews when
|
9
31
|
* using :remote => true within the contents rendered in them.
|
10
32
|
* require jquery_ujs
|
11
33
|
*
|
12
|
-
*
|
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.
|
13
39
|
* require mercury/support/history
|
14
40
|
*
|
15
41
|
* Require Mercury Editor itself.
|
@@ -17,14 +43,10 @@
|
|
17
43
|
*
|
18
44
|
* Require any localizations you wish to support
|
19
45
|
* Example: es.locale, or fr.locale -- regional dialects are in each language file so never en_US for instance.
|
20
|
-
* Make sure you enable the localization feature in the configuration.
|
21
46
|
* require mercury/locales/swedish_chef.locale
|
22
47
|
*
|
23
48
|
* Add all requires for plugins that extend or change the behavior of Mercury Editor.
|
24
49
|
* require mercury/plugins/save_as_xml/plugin.js
|
25
|
-
*
|
26
|
-
* Require any files you want to use that either extend, or change the default Mercury behavior.
|
27
|
-
* require mercury_overrides
|
28
50
|
*/
|
29
51
|
window.Mercury = {
|
30
52
|
|
@@ -36,16 +58,16 @@ window.Mercury = {
|
|
36
58
|
// behaviors. Any top level object put here will create a new toolbar. Buttons are simply nested inside the
|
37
59
|
// toolbars, along with button groups.
|
38
60
|
//
|
39
|
-
// Some toolbars are custom (the
|
40
|
-
// build the toolbar yourself with it's own behavior.
|
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.
|
41
63
|
//
|
42
64
|
// Buttons can be grouped, and a button group is simply a way to wrap buttons for styling -- they can also handle
|
43
|
-
// enabling or disabling all the buttons within it by using a context. The table button group is a good example
|
44
|
-
// this.
|
65
|
+
// enabling or disabling all the buttons within it by using a context. The table button group is a good example
|
66
|
+
// of this.
|
45
67
|
//
|
46
|
-
// It's important to note that each of the button names (keys), in each toolbar object must be unique, regardless
|
47
|
-
// if it's in a button group, or nested, etc. This is because styling is applied to them by name, and because
|
48
|
-
// name is used in the event that's fired when you click on them.
|
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.
|
49
71
|
//
|
50
72
|
// Button format: `[label, description, {type: action, type: action, etc}]`
|
51
73
|
//
|
@@ -75,8 +97,8 @@ window.Mercury = {
|
|
75
97
|
// 1. a string, denoting the name of the mode
|
76
98
|
// note: it's assumed that when a specific mode is turned on, all other modes will be turned off, which happens
|
77
99
|
// automatically, thus putting the editor into a specific "state"
|
78
|
-
// - regions: allows buttons to be enabled/disabled based on what region type has focus, expects:
|
79
|
-
// 1. an array of region types (eg. ['
|
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'])
|
80
102
|
// - preload: allows some dialog views to be loaded when the button is created instead of on first open, expects:
|
81
103
|
// 1. a boolean true / false
|
82
104
|
// note: this is only used by panels, selects, and palettes
|
@@ -100,10 +122,10 @@ window.Mercury = {
|
|
100
122
|
redo: ['Redo', 'Redo your last action'],
|
101
123
|
sep: ' '
|
102
124
|
},
|
103
|
-
insertLink: ['Link', 'Insert Link', { modal: '/mercury/modals/link.html', regions: ['
|
104
|
-
insertMedia: ['Media', 'Insert Media (images and videos)', { modal: '/mercury/modals/media.html', regions: ['
|
105
|
-
insertTable: ['Table', 'Insert Table', { modal: '/mercury/modals/table.html', regions: ['
|
106
|
-
insertCharacter: ['Character', 'Special Characters', { modal: '/mercury/modals/character.html', regions: ['
|
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'] }],
|
107
129
|
snippetPanel: ['Snippet', 'Snippet Panel', { panel: '/mercury/panels/snippets.html' }],
|
108
130
|
sep2: ' ',
|
109
131
|
historyPanel: ['History', 'Page Version History', { panel: '/mercury/panels/history.html' }],
|
@@ -112,7 +134,7 @@ window.Mercury = {
|
|
112
134
|
},
|
113
135
|
|
114
136
|
editable: {
|
115
|
-
_regions: ['
|
137
|
+
_regions: ['editable', 'markupable'],
|
116
138
|
predefined: {
|
117
139
|
style: ['Style', null, { select: '/mercury/selects/style.html', preload: true }],
|
118
140
|
sep1: ' ',
|
@@ -120,17 +142,17 @@ window.Mercury = {
|
|
120
142
|
sep2: '-'
|
121
143
|
},
|
122
144
|
colors: {
|
123
|
-
backColor: ['Background Color', null, { palette: '/mercury/palettes/backcolor.html', context: true, preload: true, regions: ['
|
145
|
+
backColor: ['Background Color', null, { palette: '/mercury/palettes/backcolor.html', context: true, preload: true, regions: ['editable'] }],
|
124
146
|
sep1: ' ',
|
125
|
-
foreColor: ['Text Color', null, { palette: '/mercury/palettes/forecolor.html', context: true, preload: true, regions: ['
|
147
|
+
foreColor: ['Text Color', null, { palette: '/mercury/palettes/forecolor.html', context: true, preload: true, regions: ['editable'] }],
|
126
148
|
sep2: '-'
|
127
149
|
},
|
128
150
|
decoration: {
|
129
151
|
bold: ['Bold', null, { context: true }],
|
130
152
|
italic: ['Italicize', null, { context: true }],
|
131
|
-
overline: ['Overline', null, { context: true, regions: ['
|
132
|
-
strikethrough: ['Strikethrough', null, { context: true, regions: ['
|
133
|
-
underline: ['Underline', null, { context: true, regions: ['
|
153
|
+
overline: ['Overline', null, { context: true, regions: ['editable'] }],
|
154
|
+
strikethrough: ['Strikethrough', null, { context: true, regions: ['editable'] }],
|
155
|
+
underline: ['Underline', null, { context: true, regions: ['editable'] }],
|
134
156
|
sep: '-'
|
135
157
|
},
|
136
158
|
script: {
|
@@ -139,10 +161,10 @@ window.Mercury = {
|
|
139
161
|
sep: '-'
|
140
162
|
},
|
141
163
|
justify: {
|
142
|
-
justifyLeft: ['Align Left', null, { context: true, regions: ['
|
143
|
-
justifyCenter: ['Center', null, { context: true, regions: ['
|
144
|
-
justifyRight: ['Align Right', null, { context: true, regions: ['
|
145
|
-
justifyFull: ['Justify Full', null, { context: true, regions: ['
|
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'] }],
|
146
168
|
sep: '-'
|
147
169
|
},
|
148
170
|
list: {
|
@@ -157,12 +179,12 @@ window.Mercury = {
|
|
157
179
|
},
|
158
180
|
table: {
|
159
181
|
_context: true,
|
160
|
-
insertRowBefore: ['Insert Table Row', 'Insert a table row before the cursor', { regions: ['
|
161
|
-
insertRowAfter: ['Insert Table Row', 'Insert a table row after the cursor', { regions: ['
|
162
|
-
deleteRow: ['Delete Table Row', 'Delete this table row', { regions: ['
|
163
|
-
insertColumnBefore: ['Insert Table Column', 'Insert a table column before the cursor', { regions: ['
|
164
|
-
insertColumnAfter: ['Insert Table Column', 'Insert a table column after the cursor', { regions: ['
|
165
|
-
deleteColumn: ['Delete Table Column', 'Delete this table column', { regions: ['
|
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'] }],
|
166
188
|
sep1: ' ',
|
167
189
|
increaseColspan: ['Increase Cell Columns', 'Increase the cells colspan'],
|
168
190
|
decreaseColspan: ['Decrease Cell Columns', 'Decrease the cells colspan and add a new cell'],
|
@@ -175,15 +197,15 @@ window.Mercury = {
|
|
175
197
|
sep1: '-'
|
176
198
|
},
|
177
199
|
formatting: {
|
178
|
-
removeFormatting: ['Remove Formatting', 'Remove formatting for the selection', { regions: ['
|
200
|
+
removeFormatting: ['Remove Formatting', 'Remove formatting for the selection', { regions: ['editable'] }],
|
179
201
|
sep2: ' '
|
180
202
|
},
|
181
203
|
editors: {
|
182
|
-
htmlEditor: ['Edit HTML', 'Edit the HTML content', { regions: ['
|
204
|
+
htmlEditor: ['Edit HTML', 'Edit the HTML content', { regions: ['editable'] }]
|
183
205
|
}
|
184
206
|
},
|
185
207
|
|
186
|
-
|
208
|
+
snippetable: {
|
187
209
|
_custom: true,
|
188
210
|
actions: {
|
189
211
|
editSnippet: ['Edit Snippet Settings'],
|
@@ -198,27 +220,28 @@ window.Mercury = {
|
|
198
220
|
//
|
199
221
|
// You can customize some aspects of how regions are found, identified, and saved.
|
200
222
|
//
|
201
|
-
//
|
202
|
-
//
|
203
|
-
//
|
204
|
-
//
|
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)
|
205
228
|
//
|
206
229
|
// identifier: This is used as a unique identifier for any given region (and thus should be unique to the page).
|
207
230
|
// By default this is the id attribute but can be changed to a data attribute should you want to use something
|
208
231
|
// custom instead.
|
209
232
|
//
|
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
|
+
//
|
210
236
|
// dataAttributes: The dataAttributes is an array of data attributes that will be serialized and returned to the
|
211
237
|
// server upon saving. These attributes, when applied to a Mercury region element, will be automatically serialized
|
212
238
|
// and submitted with the AJAX request sent when a page is saved. These are expected to be HTML5 data attributes,
|
213
239
|
// and 'data-' will automatically be prepended to each item in this directive. (ex. ['scope', 'version'])
|
214
|
-
//
|
215
|
-
// determineType: This function is called after checking the data-type attribute for the correct field type. Use
|
216
|
-
// it if you want to dynamically set the type based on inspection of the region.
|
217
240
|
regions: {
|
218
|
-
|
241
|
+
className: 'mercury-region',
|
219
242
|
identifier: 'id',
|
220
|
-
dataAttributes: []
|
221
243
|
// determineType: function(region){},
|
244
|
+
dataAttributes: []
|
222
245
|
},
|
223
246
|
|
224
247
|
|
@@ -306,7 +329,7 @@ window.Mercury = {
|
|
306
329
|
// If you want to add behaviors to specific region types, you can mix them into the actions property of any region
|
307
330
|
// type.
|
308
331
|
//
|
309
|
-
// Mercury.Regions.
|
332
|
+
// Mercury.Regions.Editable.actions.htmlEditor = function() {}
|
310
333
|
//
|
311
334
|
// You can see how the behavior matches up directly with the button names. It's also important to note that the
|
312
335
|
// callback functions are executed within the scope of the given region, so you have access to all it's methods.
|
@@ -347,14 +370,12 @@ window.Mercury = {
|
|
347
370
|
csrfSelector: 'meta[name="csrf-token"]',
|
348
371
|
csrfHeader: 'X-CSRF-Token',
|
349
372
|
|
350
|
-
|
351
373
|
// ## Editor URLs
|
352
374
|
//
|
353
375
|
// When loading a given page, you may want to tweak this regex. It's to allow the url to differ from the page
|
354
376
|
// you're editing, and the url at which you access it.
|
355
377
|
editorUrlRegEx: /([http|https]:\/\/.[^\/]*)\/editor\/?(.*)/i,
|
356
378
|
|
357
|
-
|
358
379
|
// ## Hijacking Links & Forms
|
359
380
|
//
|
360
381
|
// Mercury will hijack links and forms that don't have a target set, or the target is set to _self and will set it
|
@@ -427,16 +448,15 @@ window.Mercury = {
|
|
427
448
|
// Mercury tries to stay as much out of your code as possible, but because regions appear within your document we
|
428
449
|
// need to include a few styles to indicate regions, as well as the different states of them (eg. focused). These
|
429
450
|
// 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.
|
430
453
|
injectedStyles: '' +
|
431
|
-
'
|
432
|
-
'
|
433
|
-
'
|
434
|
-
'
|
435
|
-
'
|
436
|
-
'
|
437
|
-
'[data-mercury] td { border: 1px dotted red; min-width: 6px; }' +
|
438
|
-
'[data-mercury] .mercury-textarea { border: 0; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; resize: none; }' +
|
439
|
-
'[data-mercury] .mercury-textarea:focus { outline: none; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; }'
|
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; }'
|
440
460
|
},
|
441
461
|
|
442
462
|
// ## Silent Mode
|
@@ -447,6 +467,13 @@ window.Mercury = {
|
|
447
467
|
// ## Debug Mode
|
448
468
|
//
|
449
469
|
// Turning debug mode on will log events and other various things (using console.debug if available).
|
450
|
-
debug: false
|
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
478
|
|
452
479
|
};
|
@@ -0,0 +1,193 @@
|
|
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
|
+
*/
|
26
|
+
|
27
|
+
// ## Default Packages
|
28
|
+
//
|
29
|
+
// Some default packages are provided for you. If you want to define your own, feel free to do so before including this
|
30
|
+
// script. These, or your own packages can be specified to the loader in query params (read below for details).
|
31
|
+
if (!window.mercuryPackages) window.mercuryPackages = {
|
32
|
+
development: {javascripts: 'mercury.js', stylesheets: 'mercury.css'},
|
33
|
+
bundled: {javascripts: 'javascripts/mercury.min.js,javascripts/mercury_dialogs.js', stylesheets: 'stylesheets/mercury.bundle.css'}
|
34
|
+
};
|
35
|
+
|
36
|
+
|
37
|
+
// ## Mercury Loader
|
38
|
+
(function() {
|
39
|
+
// Useragent detection, which we use to determine if the client is supported. We do this method instead of checking
|
40
|
+
// features because many of the features are supported in IE, but aren't implemented to the W3C spec.
|
41
|
+
var browser = {
|
42
|
+
webkit: /(webkit)[ \/]([\w.]+)/,
|
43
|
+
opera: /(opera)(?:.*version)?[ \/]([\w.]+)/,
|
44
|
+
msie: /(msie) ([\w.]+)/,
|
45
|
+
mozilla: /(mozilla)(?:.*? rv:([\w.]+))?/
|
46
|
+
};
|
47
|
+
|
48
|
+
var ua = navigator.userAgent.toLowerCase();
|
49
|
+
var match = browser.webkit.exec(ua) || browser.opera.exec(ua) || browser.msie.exec(ua) || ua.indexOf("compatible") < 0 && browser.mozilla.exec(ua) || [];
|
50
|
+
browser = {version: match[2] || "0" };
|
51
|
+
browser[match[1] || ""] = true;
|
52
|
+
|
53
|
+
// If the browser isn't supported, we don't try to do anything more. We do direct userAgent detection here because IE
|
54
|
+
// thinks it's supported but isn't -- in part because it has it's own implementation of the contentEditable spec.
|
55
|
+
if (document.getElementsByTagName && document.getElementById && document.designMode && !browser.konqueror && !browser.msie) {
|
56
|
+
// supported
|
57
|
+
} else {
|
58
|
+
return;
|
59
|
+
}
|
60
|
+
|
61
|
+
// Default options, which can be overridden by specifying them in query params to the loader script.
|
62
|
+
// You can provide any additional options to the loader, and they will be passed to the PageEditor instance when it's
|
63
|
+
// created, so for instance you could put `visible=false`, and the editor be hidden after it's created.
|
64
|
+
var options = {
|
65
|
+
// A path or url from which the javascripts and css should be loaded.
|
66
|
+
src: '/assets',
|
67
|
+
// A value defined in the packages above. Development is used by default. If you want to provide your own package
|
68
|
+
// you can just define one before including this script.
|
69
|
+
pack: 'development'
|
70
|
+
};
|
71
|
+
|
72
|
+
// Hide the document during loading so there isn't a flicker while mercury is being loaded.
|
73
|
+
var head = document.getElementsByTagName("head")[0];
|
74
|
+
if (window == top) {
|
75
|
+
var style = document.createElement('style');
|
76
|
+
var rules = document.createTextNode('body{visibility:hidden;display:none}');
|
77
|
+
style.type = 'text/css';
|
78
|
+
if (style.styleSheet) style.styleSheet.cssText = rules.nodeValue;
|
79
|
+
else style.appendChild(rules);
|
80
|
+
head.appendChild(style);
|
81
|
+
}
|
82
|
+
|
83
|
+
// Because Mercury loads the document it's going to edit into an iframe we do some tweaks to the current document to
|
84
|
+
// make that feel more seamless.
|
85
|
+
function loadMercury() {
|
86
|
+
if (document.mercuryLoaded) return;
|
87
|
+
if (timer) window.clearTimeout(timer);
|
88
|
+
document.mercuryLoaded = true;
|
89
|
+
|
90
|
+
// If the current window is the top window, it means that Mercury hasn't been loaded yet. So we load it.
|
91
|
+
if (window == top) {
|
92
|
+
var i;
|
93
|
+
|
94
|
+
// Find the loader script and determine what options were provided so the defaults can be overridden. To provide
|
95
|
+
// options just pass them in as query params (eg. `mercury_loader.js?src=/asset_path&pack=bundled`)
|
96
|
+
var scripts = document.getElementsByTagName('script');
|
97
|
+
for (i = 0; i <= scripts.length - 1; i += 1) {
|
98
|
+
var match = scripts[i].src.match(/mercury_loader\.js\??(.*)?$/);
|
99
|
+
if (!match || !match[1]) continue;
|
100
|
+
|
101
|
+
match[1].replace(/([^&=]*)=([^&=]*)/g, function (m, attr, value) {
|
102
|
+
if (['true', 'false'].indexOf(value) >= 0) value = JSON.parse(value);
|
103
|
+
options[attr] = value;
|
104
|
+
});
|
105
|
+
}
|
106
|
+
|
107
|
+
var pack = window.mercuryPackages[options.pack];
|
108
|
+
setTimeout(function() {
|
109
|
+
// Once we're ready to load Mercury we clear the document contents, and add in the css and javascript tags.
|
110
|
+
// Once the script has loaded we display the body again, and instantiate a new instance of Mercury.PageEditor.
|
111
|
+
document.body.innerHTML = '<div style="height:0;overflow:hidden;">Mercury</div>';
|
112
|
+
for (i = 0; i <= document.styleSheets.length - 1; i += 1) {
|
113
|
+
document.styleSheets[i].disabled = true;
|
114
|
+
}
|
115
|
+
|
116
|
+
// Load all the stylesheets.
|
117
|
+
var stylesheets = pack.stylesheets.split(',');
|
118
|
+
for (i = 0; i <= stylesheets.length - 1; i += 1) {
|
119
|
+
var link = document.createElement('link');
|
120
|
+
link.href = options.src + '/' + stylesheets[i];
|
121
|
+
link.media = 'screen';
|
122
|
+
link.rel = 'stylesheet';
|
123
|
+
link.type = 'text/css';
|
124
|
+
head.appendChild(link);
|
125
|
+
}
|
126
|
+
|
127
|
+
// Load all the javascripts.
|
128
|
+
var javascripts = pack.javascripts.split(',');
|
129
|
+
var loaded = 0;
|
130
|
+
function loadScript(src) {
|
131
|
+
var script = document.createElement('script');
|
132
|
+
script.src = options.src + '/' + src;
|
133
|
+
script.type = 'text/javascript';
|
134
|
+
script.charset = 'utf-8';
|
135
|
+
head.appendChild(script);
|
136
|
+
script.onload = function() {
|
137
|
+
loaded += 1;
|
138
|
+
if (loaded >= javascripts.length) {
|
139
|
+
document.body.style.visibility = 'visible';
|
140
|
+
document.body.style.display = 'block';
|
141
|
+
// Instantiate the PageEditor, passing in the options that were provided to the loader.
|
142
|
+
new Mercury.PageEditor(null, options);
|
143
|
+
// If there's a mercuryLoaded function available, call it. You can provide one before the loading script
|
144
|
+
// and it will be called after everything is loaded, but before everything is initialized. You can bind
|
145
|
+
// to the mercury:ready event or use Mercury.bind('ready', function() {}).
|
146
|
+
if (typeof(window.mercuryLoaded) == 'function') {
|
147
|
+
window.mercuryLoaded();
|
148
|
+
}
|
149
|
+
} else {
|
150
|
+
loadScript(javascripts[loaded]);
|
151
|
+
}
|
152
|
+
};
|
153
|
+
}
|
154
|
+
loadScript(javascripts[loaded]);
|
155
|
+
}, 1);
|
156
|
+
} else if (top.Mercury) {
|
157
|
+
// Since this file will be included in the iframe as well, we use it to tell Mercury that the document is ready to
|
158
|
+
// be worked on. By firing this event we're able to build the regions and get everything ready without having to
|
159
|
+
// wait for assets and slow javascripts to load or complete.
|
160
|
+
window.Mercury = top.Mercury;
|
161
|
+
Mercury.trigger('initialize:frame');
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
// This is a common technique for determining if the document has loaded yet, and is based on the methods used in
|
166
|
+
// Prototype.js. The following portions just call loadMercury once it's appropriate to do so.
|
167
|
+
//
|
168
|
+
// Support for the DOMContentLoaded event is based on work by Dan Webb, Matthias Miller, Dean Edwards, John Resig,
|
169
|
+
// and Diego Perini.
|
170
|
+
var timer;
|
171
|
+
function checkReadyState() {
|
172
|
+
if (document.readyState === 'complete') {
|
173
|
+
document.stopObserving('readystatechange', checkReadyState);
|
174
|
+
loadMercury();
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
function pollDoScroll() {
|
179
|
+
try { document.documentElement.doScroll('left'); }
|
180
|
+
catch(e) {
|
181
|
+
timer = pollDoScroll.defer();
|
182
|
+
return;
|
183
|
+
}
|
184
|
+
loadMercury();
|
185
|
+
}
|
186
|
+
|
187
|
+
if (document.addEventListener) {
|
188
|
+
document.addEventListener('DOMContentLoaded', loadMercury, false);
|
189
|
+
} else {
|
190
|
+
document.observe('readystatechange', checkReadyState);
|
191
|
+
if (window == top) { timer = pollDoScroll.defer(); }
|
192
|
+
}
|
193
|
+
})();
|
@@ -0,0 +1,6 @@
|
|
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
|
+
*/
|
@@ -74,10 +74,6 @@ form fieldset.buttons .commit input {
|
|
74
74
|
.mercury-expander-button[data-button=historyPanel] em { background-image: url(<%= asset_path 'mercury/toolbar/primary/historypanel.png' %>) }
|
75
75
|
.mercury-primary-toolbar .mercury-notesPanel-button em,
|
76
76
|
.mercury-expander-button[data-button=notesPanel] em { background-image: url(<%= asset_path 'mercury/toolbar/primary/notespanel.png' %>) }
|
77
|
-
.mercury-primary-toolbar .mercury-userPanel-button em,
|
78
|
-
.mercury-expander-button[data-button=userPanel] em { background-image: url(<%= asset_path 'mercury/toolbar/primary/user.png' %>) }
|
79
|
-
.mercury-primary-toolbar .mercury-toolsPanel-button em,
|
80
|
-
.mercury-expander-button[data-button=toolsPanel] em { background-image: url(<%= asset_path 'mercury/toolbar/primary/tools.png' %>) }
|
81
77
|
.mercury-editable-toolbar .mercury-button {
|
82
78
|
background-image: url(<%= asset_path 'mercury/toolbar/editable/buttons.png' %>);
|
83
79
|
}
|
@@ -86,8 +82,8 @@ form fieldset.buttons .commit input {
|
|
86
82
|
}
|
87
83
|
|
88
84
|
.mercury-snippet-toolbar .mercury-button {
|
89
|
-
background-image: url(<%= asset_path 'mercury/toolbar/
|
85
|
+
background-image: url(<%= asset_path 'mercury/toolbar/snippetable/buttons.png' %>);
|
90
86
|
}
|
91
87
|
.mercury-snippet-toolbar .mercury-button em {
|
92
|
-
background-image: url(<%= asset_path 'mercury/toolbar/
|
88
|
+
background-image: url(<%= asset_path 'mercury/toolbar/snippetable/buttons.png' %>);
|
93
89
|
}
|