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
@@ -3,14 +3,13 @@ class @Mercury.PageEditor
|
|
3
3
|
# options
|
4
4
|
# saveStyle: 'form', or 'json' (defaults to json)
|
5
5
|
# saveDataType: 'xml', 'json', 'jsonp', 'script', 'text', 'html' (defaults to json)
|
6
|
-
# saveMethod: 'POST', or 'PUT', create or update actions on save (defaults to
|
6
|
+
# saveMethod: 'POST', or 'PUT', create or update actions on save (defaults to POST)
|
7
7
|
# visible: boolean, if the interface should start visible or not (defaults to true)
|
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 == '
|
11
|
+
@options.visible = true unless (@options.visible == false || @options.visible == 'no')
|
12
12
|
@visible = @options.visible
|
13
|
-
@options.saveDataType = 'json' unless (@options.saveDataType == false || @options.saveDataType)
|
14
13
|
|
15
14
|
window.mercuryInstance = @
|
16
15
|
@regions = []
|
@@ -21,28 +20,25 @@ class @Mercury.PageEditor
|
|
21
20
|
initializeInterface: ->
|
22
21
|
@focusableElement = jQuery('<input>', {class: 'mercury-focusable', type: 'text'}).appendTo(@options.appendTo ? 'body')
|
23
22
|
|
24
|
-
@iframe = jQuery('<iframe>', {id: 'mercury_iframe',
|
23
|
+
@iframe = jQuery('<iframe>', {id: 'mercury_iframe', class: 'mercury-iframe', seamless: 'true', frameborder: '0', src: 'about:blank'})
|
25
24
|
@iframe.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
|
26
25
|
|
27
|
-
@toolbar = new Mercury.Toolbar(
|
28
|
-
@statusbar = new Mercury.Statusbar(
|
26
|
+
@toolbar = new Mercury.Toolbar(@options)
|
27
|
+
@statusbar = new Mercury.Statusbar(@options)
|
29
28
|
@resize()
|
30
29
|
|
31
|
-
@iframe.one 'load', => @bindEvents()
|
32
30
|
@iframe.on 'load', => @initializeFrame()
|
33
|
-
@
|
31
|
+
@iframe.get(0).contentWindow.document.location.href = @iframeSrc(null, true)
|
34
32
|
|
35
33
|
|
36
34
|
initializeFrame: ->
|
37
35
|
try
|
38
36
|
return if @iframe.data('loaded')
|
39
37
|
@iframe.data('loaded', true)
|
40
|
-
|
41
|
-
# set document reference of iframe
|
38
|
+
Mercury.notify("Opera isn't a fully supported browser, your results may not be optimal.") if jQuery.browser.opera
|
42
39
|
@document = jQuery(@iframe.get(0).contentWindow.document)
|
43
|
-
|
44
|
-
|
45
|
-
jQuery("<style mercury-styles=\"true\">").html(Mercury.config.injectedStyles).appendTo(@document.find('head'))
|
40
|
+
stylesToInject = Mercury.config.injectedStyles.replace(/{{regionClass}}/g, Mercury.config.regions.className)
|
41
|
+
jQuery("<style mercury-styles=\"true\">").html(stylesToInject).appendTo(@document.find('head'))
|
46
42
|
|
47
43
|
# jquery: make jQuery evaluate scripts within the context of the iframe window
|
48
44
|
iframeWindow = @iframe.get(0).contentWindow
|
@@ -51,15 +47,12 @@ class @Mercury.PageEditor
|
|
51
47
|
iframeWindow.Mercury = Mercury
|
52
48
|
iframeWindow.History = History if window.History && History.Adapter
|
53
49
|
|
54
|
-
|
55
|
-
@bindDocumentEvents()
|
50
|
+
@bindEvents()
|
56
51
|
@resize()
|
57
52
|
@initializeRegions()
|
58
53
|
@finalizeInterface()
|
59
|
-
|
60
|
-
# trigger ready events
|
61
54
|
Mercury.trigger('ready')
|
62
|
-
|
55
|
+
jQuery(iframeWindow).trigger('mercury:ready')
|
63
56
|
iframeWindow.Event.fire(iframeWindow, 'mercury:ready') if iframeWindow.Event && iframeWindow.Event.fire
|
64
57
|
iframeWindow.onMercuryReady() if iframeWindow.onMercuryReady
|
65
58
|
|
@@ -70,8 +63,8 @@ class @Mercury.PageEditor
|
|
70
63
|
|
71
64
|
initializeRegions: ->
|
72
65
|
@regions = []
|
73
|
-
@buildRegion(jQuery(region)) for region in jQuery("
|
74
|
-
return unless @visible
|
66
|
+
@buildRegion(jQuery(region)) for region in jQuery(".#{Mercury.config.regions.className}", @document)
|
67
|
+
return unless @options.visible
|
75
68
|
for region in @regions
|
76
69
|
if region.focus
|
77
70
|
region.focus()
|
@@ -82,7 +75,11 @@ class @Mercury.PageEditor
|
|
82
75
|
if region.data('region')
|
83
76
|
region = region.data('region')
|
84
77
|
else
|
85
|
-
type = (
|
78
|
+
type = (
|
79
|
+
region.data('type') ||
|
80
|
+
( jQuery.type(Mercury.config.regions.determineType) == 'function' && Mercury.config.regions.determineType(region) ) ||
|
81
|
+
'unknown'
|
82
|
+
).titleize()
|
86
83
|
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]
|
87
84
|
if !Mercury.Regions[type].supported
|
88
85
|
Mercury.notify('Mercury.Regions.%s is unsupported in this client. Supported browsers are %s.', type, Mercury.Regions[type].supportedText)
|
@@ -93,46 +90,43 @@ class @Mercury.PageEditor
|
|
93
90
|
|
94
91
|
|
95
92
|
finalizeInterface: ->
|
96
|
-
@santizerElement = jQuery('<div>', {id: 'mercury_sanitizer', contenteditable: 'true', style: 'position:fixed;width:100px;height:100px;
|
93
|
+
@santizerElement = jQuery('<div>', {id: 'mercury_sanitizer', contenteditable: 'true', style: 'position:fixed;width:100px;height:100px;top:0;left:-100px;opacity:0;overflow:hidden'})
|
97
94
|
@santizerElement.appendTo(@options.appendTo ? @document.find('body'))
|
98
95
|
|
99
|
-
@snippetToolbar.release() if @snippetToolbar
|
100
96
|
@snippetToolbar = new Mercury.SnippetToolbar(@document)
|
101
97
|
|
102
98
|
@hijackLinksAndForms()
|
103
|
-
Mercury.trigger('mode', {mode: 'preview'}) unless @visible
|
104
|
-
|
105
|
-
|
106
|
-
bindDocumentEvents: ->
|
107
|
-
@document.on 'mousedown', (event) ->
|
108
|
-
Mercury.trigger('hide:dialogs')
|
109
|
-
if Mercury.region
|
110
|
-
Mercury.trigger('unfocus:regions') unless jQuery(event.target).closest("[#{Mercury.config.regions.attribute}]").get(0) == Mercury.region.element.get(0)
|
111
|
-
|
112
|
-
jQuery(@document).bind 'keydown', (event) =>
|
113
|
-
return unless event.ctrlKey || event.metaKey
|
114
|
-
if (event.keyCode == 83) # meta+S
|
115
|
-
Mercury.trigger('action', {action: 'save'})
|
116
|
-
event.preventDefault()
|
99
|
+
Mercury.trigger('mode', {mode: 'preview'}) unless @options.visible
|
117
100
|
|
118
101
|
|
119
102
|
bindEvents: ->
|
120
103
|
Mercury.on 'autosave', => @autosave()
|
121
|
-
Mercury.on 'initialize:frame', => setTimeout(@initializeFrame
|
104
|
+
Mercury.on 'initialize:frame', => setTimeout(100, @initializeFrame)
|
122
105
|
Mercury.on 'focus:frame', => @iframe.focus()
|
123
|
-
Mercury.on 'focus:window', => setTimeout(
|
106
|
+
Mercury.on 'focus:window', => setTimeout(10, => @focusableElement.focus())
|
124
107
|
Mercury.on 'toggle:interface', => @toggleInterface()
|
125
108
|
Mercury.on 'reinitialize', => @initializeRegions()
|
126
109
|
Mercury.on 'mode', (event, options) => @previewing = !@previewing if options.mode == 'preview'
|
127
110
|
Mercury.on 'action', (event, options) =>
|
128
111
|
action = Mercury.config.globalBehaviors[options.action] || @[options.action]
|
129
112
|
return unless typeof(action) == 'function'
|
130
|
-
|
113
|
+
options.already_handled = true
|
131
114
|
action.call(@, options)
|
132
115
|
|
116
|
+
@document.on 'mousedown', (event) ->
|
117
|
+
Mercury.trigger('hide:dialogs')
|
118
|
+
if Mercury.region
|
119
|
+
Mercury.trigger('unfocus:regions') unless jQuery(event.target).closest(".#{Mercury.config.regions.className}").get(0) == Mercury.region.element.get(0)
|
120
|
+
|
133
121
|
jQuery(window).on 'resize', =>
|
134
122
|
@resize()
|
135
123
|
|
124
|
+
jQuery(@document).bind 'keydown', (event) =>
|
125
|
+
return unless event.ctrlKey || event.metaKey
|
126
|
+
if (event.keyCode == 83) # meta+S
|
127
|
+
Mercury.trigger('action', {action: 'save'})
|
128
|
+
event.preventDefault()
|
129
|
+
|
136
130
|
jQuery(window).bind 'keydown', (event) =>
|
137
131
|
return unless event.ctrlKey || event.metaKey
|
138
132
|
if (event.keyCode == 83) # meta+S
|
@@ -144,25 +138,22 @@ class @Mercury.PageEditor
|
|
144
138
|
|
145
139
|
toggleInterface: ->
|
146
140
|
if @visible
|
141
|
+
Mercury.trigger('mode', {mode: 'preview'}) if @previewing
|
147
142
|
@visible = false
|
148
143
|
@toolbar.hide()
|
149
144
|
@statusbar.hide()
|
150
|
-
Mercury.trigger('mode', {mode: 'preview'}) unless @previewing
|
151
|
-
@previewing = true
|
152
|
-
@resize()
|
153
145
|
else
|
154
146
|
@visible = true
|
155
|
-
@iframe.animate({top: @toolbar.height(true)}, 200, 'easeInOutSine', => @resize())
|
156
147
|
@toolbar.show()
|
157
148
|
@statusbar.show()
|
158
|
-
|
159
|
-
|
149
|
+
Mercury.trigger('mode', {mode: 'preview'})
|
150
|
+
@resize()
|
160
151
|
|
161
152
|
|
162
153
|
resize: ->
|
163
154
|
width = jQuery(window).width()
|
164
155
|
height = @statusbar.top()
|
165
|
-
toolbarHeight = @toolbar.
|
156
|
+
toolbarHeight = @toolbar.height()
|
166
157
|
|
167
158
|
Mercury.displayRect = {top: toolbarHeight, left: 0, width: width, height: height - toolbarHeight, fullHeight: height}
|
168
159
|
|
@@ -176,25 +167,14 @@ class @Mercury.PageEditor
|
|
176
167
|
|
177
168
|
|
178
169
|
iframeSrc: (url = null, params = false) ->
|
179
|
-
# remove the /editor segment of the url if it gets passed through
|
180
170
|
url = (url ? window.location.href).replace(Mercury.config.editorUrlRegEx ?= /([http|https]:\/\/.[^\/]*)\/editor\/?(.*)/i, "$1/$2")
|
181
|
-
url = url.replace(/[\?|\&]mercury_frame=true/gi, '')
|
171
|
+
url = url.replace(/[\?|\&]mercury_frame=true/gi, '')
|
182
172
|
if params
|
183
|
-
#
|
184
|
-
# and add a cache busting param so we don't get stale content
|
185
|
-
return "#{url}#{if url.indexOf('?') > -1 then '&' else '?'}mercury_frame=true&_=#{new Date().getTime()}"
|
173
|
+
return "#{url}#{if url.indexOf('?') > -1 then '&' else '?'}mercury_frame=true"
|
186
174
|
else
|
187
175
|
return url
|
188
176
|
|
189
177
|
|
190
|
-
loadIframeSrc: (url)->
|
191
|
-
# clear any existing events if we are loading a new iframe to replace the existing one
|
192
|
-
@document.off() if @document
|
193
|
-
|
194
|
-
@iframe.data('loaded', false)
|
195
|
-
@iframe.get(0).contentWindow.document.location.href = @iframeSrc(url, true)
|
196
|
-
|
197
|
-
|
198
178
|
hijackLinksAndForms: ->
|
199
179
|
for element in jQuery('a, form', @document)
|
200
180
|
ignored = false
|
@@ -202,7 +182,7 @@ class @Mercury.PageEditor
|
|
202
182
|
if jQuery(element).hasClass(classname)
|
203
183
|
ignored = true
|
204
184
|
continue
|
205
|
-
if !ignored && (element.target == '' || element.target == '_self') && !jQuery(element).closest("
|
185
|
+
if !ignored && (element.target == '' || element.target == '_self') && !jQuery(element).closest(".#{Mercury.config.regions.className}").length
|
206
186
|
jQuery(element).attr('target', '_parent')
|
207
187
|
|
208
188
|
|
@@ -234,35 +214,22 @@ class @Mercury.PageEditor
|
|
234
214
|
}
|
235
215
|
|
236
216
|
save: (callback) ->
|
237
|
-
url = @saveUrl ? Mercury.
|
217
|
+
url = @saveUrl ? Mercury.saveURL ? @iframeSrc()
|
238
218
|
data = @serialize()
|
239
|
-
data = {content: data}
|
240
|
-
|
241
|
-
if @options.saveMethod == 'POST'
|
242
|
-
method = 'POST'
|
243
|
-
else
|
244
|
-
method = 'PUT'
|
245
|
-
data['_method'] = method
|
246
|
-
|
247
219
|
Mercury.log('saving', data)
|
248
|
-
|
249
|
-
|
220
|
+
data = jQuery.toJSON(data) unless @options.saveStyle == 'form'
|
221
|
+
method = 'PUT' if @options.saveMethod == 'PUT'
|
222
|
+
jQuery.ajax url, {
|
250
223
|
headers: Mercury.ajaxHeaders()
|
251
|
-
type: method
|
252
|
-
|
253
|
-
|
254
|
-
success: (response) =>
|
224
|
+
type: method || 'POST'
|
225
|
+
data: {content: data, _method: method}
|
226
|
+
success: =>
|
255
227
|
Mercury.changes = false
|
256
|
-
Mercury.trigger('saved'
|
228
|
+
Mercury.trigger('saved')
|
257
229
|
callback() if typeof(callback) == 'function'
|
258
|
-
error:
|
259
|
-
Mercury.trigger('save_failed', response)
|
230
|
+
error: =>
|
260
231
|
Mercury.notify('Mercury was unable to save to the url: %s', url)
|
261
232
|
}
|
262
|
-
if @options.saveStyle != 'form'
|
263
|
-
options['data'] = jQuery.toJSON(data)
|
264
|
-
options['contentType'] = 'application/json'
|
265
|
-
jQuery.ajax url, options
|
266
233
|
|
267
234
|
|
268
235
|
serialize: ->
|
@@ -271,4 +238,3 @@ class @Mercury.PageEditor
|
|
271
238
|
Mercury.log("region", region)
|
272
239
|
serialized[region.name] = region.serialize()
|
273
240
|
return serialized
|
274
|
-
|
@@ -16,7 +16,7 @@ class @Mercury.Palette extends Mercury.Dialog
|
|
16
16
|
|
17
17
|
position: (keepVisible) ->
|
18
18
|
@element.css({top: 0, left: 0, display: 'block', visibility: 'hidden'})
|
19
|
-
position = @button.
|
19
|
+
position = @button.offset()
|
20
20
|
width = @element.width()
|
21
21
|
|
22
22
|
position.left = position.left - width + @button.width() if position.left + width > jQuery(window).width()
|
@@ -6,7 +6,7 @@ class @Mercury.Panel extends Mercury.Dialog
|
|
6
6
|
|
7
7
|
build: ->
|
8
8
|
@element = jQuery('<div>', {class: 'mercury-panel loading', style: 'display:none;'})
|
9
|
-
@titleElement = jQuery("<h1
|
9
|
+
@titleElement = jQuery("<h1>#{Mercury.I18n(@options.title)}</h1>").appendTo(@element)
|
10
10
|
@paneElement = jQuery('<div>', {class: 'mercury-panel-pane'}).appendTo(@element)
|
11
11
|
|
12
12
|
if @options.closeButton
|
@@ -57,7 +57,6 @@ class @Mercury.Panel extends Mercury.Dialog
|
|
57
57
|
@titleElement.find('.mercury-panel-close').animate({opacity: 1}, 100)
|
58
58
|
|
59
59
|
@paneElement.css({display: 'block', width: postWidth})
|
60
|
-
jQuery(@paneElement.find('.focusable').get(0)).focus()
|
61
60
|
@makeDraggable()
|
62
61
|
|
63
62
|
@hide() unless @visible
|
@@ -101,7 +100,7 @@ class @Mercury.Panel extends Mercury.Dialog
|
|
101
100
|
makeDraggable: ->
|
102
101
|
elementWidth = @element.width()
|
103
102
|
@element.draggable {
|
104
|
-
handle: 'h1
|
103
|
+
handle: 'h1',
|
105
104
|
axis: 'x',
|
106
105
|
opacity: 0.70
|
107
106
|
scroll: false,
|
data/{app → vendor}/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Mercury.PageEditor extends Mercury.PageEditor
|
2
2
|
|
3
3
|
save: ->
|
4
|
-
url = @saveUrl ? Mercury.
|
4
|
+
url = @saveUrl ? Mercury.saveURL ? @iframeSrc()
|
5
5
|
data = @serializeAsXml()
|
6
6
|
console.log('saving', data)
|
7
7
|
return
|
@@ -25,4 +25,4 @@ class Mercury.PageEditor extends Mercury.PageEditor
|
|
25
25
|
for snippetName, snippetProperties of regionProperties['snippets']
|
26
26
|
snippetNodes.push("<#{snippetName} name=\"#{snippetProperties['name']}\"><![CDATA[#{jQuery.toJSON(snippetProperties['options'])}]]></#{snippetName}>")
|
27
27
|
regionNodes.push("<region name=\"#{regionName}\" type=\"#{regionProperties['type']}\"><value>\n<![CDATA[#{regionProperties['value']}]]>\n</value><snippets>#{snippetNodes.join('')}</snippets></region>")
|
28
|
-
return "<regions>#{regionNodes.join('')}</regions>"
|
28
|
+
return "<regions>#{regionNodes.join('')}</regions>"
|
File without changes
|
@@ -1,7 +1,10 @@
|
|
1
1
|
class @Mercury.Region
|
2
|
+
type = 'region'
|
2
3
|
|
3
4
|
constructor: (@element, @window, @options = {}) ->
|
4
|
-
|
5
|
+
@type = 'region' unless @type
|
6
|
+
Mercury.log("building #{@type}", @element, @options)
|
7
|
+
|
5
8
|
@document = @window.document
|
6
9
|
@name = @element.attr(Mercury.config.regions.identifier)
|
7
10
|
@history = new Mercury.HistoryBuffer()
|
@@ -11,9 +14,6 @@ class @Mercury.Region
|
|
11
14
|
@element.data('region', @)
|
12
15
|
|
13
16
|
|
14
|
-
type: -> 'unknown'
|
15
|
-
|
16
|
-
|
17
17
|
build: ->
|
18
18
|
|
19
19
|
|
@@ -28,15 +28,15 @@ class @Mercury.Region
|
|
28
28
|
@focus()
|
29
29
|
|
30
30
|
Mercury.on 'action', (event, options) =>
|
31
|
-
return if @previewing || Mercury.region != @
|
31
|
+
return if @previewing || Mercury.region != @
|
32
32
|
@execCommand(options.action, options) if options.action
|
33
33
|
|
34
34
|
@element.on 'mousemove', (event) =>
|
35
35
|
return if @previewing || Mercury.region != @
|
36
|
-
snippet = jQuery(event.target).closest('
|
36
|
+
snippet = jQuery(event.target).closest('.mercury-snippet')
|
37
37
|
if snippet.length
|
38
38
|
@snippet = snippet
|
39
|
-
Mercury.trigger('show:toolbar', {type: 'snippet', snippet: @snippet})
|
39
|
+
Mercury.trigger('show:toolbar', {type: 'snippet', snippet: @snippet})
|
40
40
|
|
41
41
|
@element.on 'mouseout', =>
|
42
42
|
return if @previewing
|
@@ -48,13 +48,11 @@ class @Mercury.Region
|
|
48
48
|
@element.html(value)
|
49
49
|
else
|
50
50
|
# sanitize the html before we return it
|
51
|
-
|
52
|
-
container
|
53
|
-
container.innerHTML = @element.html().replace(/^\s+|\s+$/g, '')
|
54
|
-
container = $(container)
|
51
|
+
container = jQuery('<div>').appendTo(@document.createDocumentFragment())
|
52
|
+
container.html(@element.html().replace(/^\s+|\s+$/g, ''))
|
55
53
|
|
56
54
|
# replace snippet contents to be an identifier
|
57
|
-
if filterSnippets then for snippet in container.find('
|
55
|
+
if filterSnippets then for snippet in container.find('.mercury-snippet')
|
58
56
|
snippet = jQuery(snippet)
|
59
57
|
snippet.attr({contenteditable: null, 'data-version': null})
|
60
58
|
snippet.html("[#{snippet.data('snippet')}]")
|
@@ -65,11 +63,11 @@ class @Mercury.Region
|
|
65
63
|
togglePreview: ->
|
66
64
|
if @previewing
|
67
65
|
@previewing = false
|
68
|
-
@element.
|
66
|
+
@element.addClass(Mercury.config.regions.className).removeClass("#{Mercury.config.regions.className}-preview")
|
69
67
|
@focus() if Mercury.region == @
|
70
68
|
else
|
71
69
|
@previewing = true
|
72
|
-
@element.
|
70
|
+
@element.addClass("#{Mercury.config.regions.className}-preview").removeClass(Mercury.config.regions.className)
|
73
71
|
Mercury.trigger('region:blurred', {region: @})
|
74
72
|
|
75
73
|
|
@@ -78,7 +76,7 @@ class @Mercury.Region
|
|
78
76
|
@pushHistory() unless action == 'redo'
|
79
77
|
|
80
78
|
Mercury.log('execCommand', action, options.value)
|
81
|
-
Mercury.changes = true
|
79
|
+
Mercury.changes = true unless options.already_handled
|
82
80
|
|
83
81
|
|
84
82
|
pushHistory: ->
|
@@ -89,19 +87,20 @@ class @Mercury.Region
|
|
89
87
|
snippets = {}
|
90
88
|
for element in @element.find('[data-snippet]')
|
91
89
|
snippet = Mercury.Snippet.find(jQuery(element).data('snippet'))
|
92
|
-
|
90
|
+
snippet.setVersion(jQuery(element).data('version'))
|
93
91
|
snippets[snippet.identity] = snippet.serialize()
|
94
92
|
return snippets
|
95
93
|
|
96
94
|
|
97
95
|
dataAttributes: ->
|
98
96
|
data = {}
|
99
|
-
|
97
|
+
o = if @type=='simple' then jQuery(this.container[0]) else @element
|
98
|
+
data[attr] = o.attr('data-' + attr) for attr in Mercury.config.regions.dataAttributes
|
100
99
|
return data
|
101
100
|
|
102
101
|
serialize: ->
|
103
102
|
return {
|
104
|
-
type: @type
|
103
|
+
type: @type
|
105
104
|
data: @dataAttributes()
|
106
105
|
value: @content(null, true)
|
107
106
|
snippets: @snippets()
|
@@ -1,11 +1,12 @@
|
|
1
|
-
class @Mercury.Regions.
|
2
|
-
# No IE
|
3
|
-
@supported: document.designMode && !jQuery.browser.konqueror &&
|
4
|
-
@supportedText: "Chrome 10+, Firefox 4+, Safari 5
|
5
|
-
|
6
|
-
type
|
1
|
+
class @Mercury.Regions.Editable extends Mercury.Region
|
2
|
+
# No IE support yet because it doesn't follow the W3C standards for HTML5 contentEditable (aka designMode).
|
3
|
+
@supported: document.designMode && !jQuery.browser.konqueror && !jQuery.browser.msie
|
4
|
+
@supportedText: "Chrome 10+, Firefox 4+, Safari 5+"
|
5
|
+
|
6
|
+
type = 'editable'
|
7
7
|
|
8
8
|
constructor: (@element, @window, @options = {}) ->
|
9
|
+
@type = 'editable'
|
9
10
|
super
|
10
11
|
|
11
12
|
|
@@ -25,7 +26,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
25
26
|
@element.get(0).contentEditable = true
|
26
27
|
|
27
28
|
# make all snippets not editable, and set their versions to 1
|
28
|
-
for element in @element.find('
|
29
|
+
for element in @element.find('.mercury-snippet')
|
29
30
|
element.contentEditable = false
|
30
31
|
jQuery(element).attr('data-version', '1')
|
31
32
|
|
@@ -46,7 +47,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
46
47
|
|
47
48
|
Mercury.on 'region:update', =>
|
48
49
|
return if @previewing || Mercury.region != @
|
49
|
-
setTimeout(
|
50
|
+
setTimeout(1, => @selection().forceSelection(@element.get(0)))
|
50
51
|
currentElement = @currentElement()
|
51
52
|
if currentElement.length
|
52
53
|
# setup the table editor if we're inside a table
|
@@ -68,17 +69,16 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
68
69
|
return if @previewing
|
69
70
|
event.preventDefault() unless Mercury.snippet
|
70
71
|
event.originalEvent.dataTransfer.dropEffect = 'copy'
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
# @dropTimeout = setTimeout((=> @element.trigger('possible:drop')), 10)
|
72
|
+
if jQuery.browser.webkit
|
73
|
+
clearTimeout(@dropTimeout)
|
74
|
+
@dropTimeout = setTimeout(10, => @element.trigger('possible:drop'))
|
75
75
|
|
76
76
|
@element.on 'drop', (event) =>
|
77
77
|
return if @previewing
|
78
78
|
|
79
79
|
# handle dropping snippets
|
80
80
|
clearTimeout(@dropTimeout)
|
81
|
-
@dropTimeout = setTimeout(
|
81
|
+
@dropTimeout = setTimeout(1, => @element.trigger('possible:drop'))
|
82
82
|
|
83
83
|
# handle any files that were dropped
|
84
84
|
return unless event.originalEvent.dataTransfer.files.length
|
@@ -93,9 +93,9 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
93
93
|
# read: http://www.quirksmode.org/blog/archives/2009/09/the_html5_drag.html
|
94
94
|
@element.on 'possible:drop', =>
|
95
95
|
return if @previewing
|
96
|
-
if
|
96
|
+
if snippet = @element.find('img[data-snippet]').get(0)
|
97
97
|
@focus()
|
98
|
-
Mercury.Snippet.displayOptionsFor(
|
98
|
+
Mercury.Snippet.displayOptionsFor(jQuery(snippet).data('snippet'))
|
99
99
|
@document.execCommand('undo', false, null)
|
100
100
|
|
101
101
|
# custom paste handling: we have to do some hackery to get the pasted content since it's not exposed normally
|
@@ -115,7 +115,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
115
115
|
@element.on 'focus', =>
|
116
116
|
return if @previewing
|
117
117
|
Mercury.region = @
|
118
|
-
setTimeout(
|
118
|
+
setTimeout(1, => @selection().forceSelection(@element.get(0)))
|
119
119
|
Mercury.trigger('region:focused', {region: @})
|
120
120
|
|
121
121
|
@element.on 'blur', =>
|
@@ -194,13 +194,13 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
194
194
|
|
195
195
|
focus: ->
|
196
196
|
if Mercury.region != @
|
197
|
-
setTimeout(
|
197
|
+
setTimeout(10, => @element.focus())
|
198
198
|
try
|
199
199
|
@selection().selection.collapseToStart()
|
200
200
|
catch e
|
201
201
|
# intentially do nothing
|
202
202
|
else
|
203
|
-
setTimeout(
|
203
|
+
setTimeout(10, => @element.focus())
|
204
204
|
|
205
205
|
Mercury.trigger('region:focused', {region: @})
|
206
206
|
Mercury.trigger('region:update', {region: @})
|
@@ -217,9 +217,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
217
217
|
element.contentEditable = false
|
218
218
|
element = jQuery(element)
|
219
219
|
if snippet = Mercury.Snippet.find(element.data('snippet'))
|
220
|
-
|
221
|
-
snippet.setVersion(element.data('version'))
|
222
|
-
else
|
220
|
+
unless element.data('version')
|
223
221
|
try
|
224
222
|
version = parseInt(element.html().match(/\/(\d+)\]/)[1])
|
225
223
|
if version
|
@@ -279,7 +277,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
279
277
|
super
|
280
278
|
|
281
279
|
# use a custom handler if there's one, otherwise use execCommand
|
282
|
-
if handler = Mercury.config.behaviors[action] || Mercury.Regions.
|
280
|
+
if handler = Mercury.config.behaviors[action] || Mercury.Regions.Editable.actions[action]
|
283
281
|
handler.call(@, @selection(), options)
|
284
282
|
else
|
285
283
|
sibling = @element.get(0).previousSibling if action == 'indent'
|
@@ -310,7 +308,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
310
308
|
@history.push(@content(null, false, true))
|
311
309
|
else if keyCode
|
312
310
|
# set a timeout for pushing to the history
|
313
|
-
@historyTimeout = setTimeout(
|
311
|
+
@historyTimeout = setTimeout(waitTime * 1000, => @history.push(@content(null, false, true)))
|
314
312
|
else
|
315
313
|
# push to the history immediately
|
316
314
|
@history.push(@content(null, false, true))
|
@@ -319,7 +317,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
319
317
|
|
320
318
|
|
321
319
|
selection: ->
|
322
|
-
return new Mercury.Regions.
|
320
|
+
return new Mercury.Regions.Editable.Selection(@window.getSelection(), @document)
|
323
321
|
|
324
322
|
|
325
323
|
path: ->
|
@@ -351,7 +349,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
351
349
|
sanitizer = jQuery('#mercury_sanitizer', @document).focus()
|
352
350
|
|
353
351
|
# set 1ms timeout to allow paste event to complete
|
354
|
-
setTimeout =>
|
352
|
+
setTimeout 1, =>
|
355
353
|
# sanitize the content
|
356
354
|
content = @sanitize(sanitizer)
|
357
355
|
|
@@ -362,13 +360,11 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
362
360
|
# paste sanitized content
|
363
361
|
@element.focus()
|
364
362
|
@execCommand('insertHTML', {value: content})
|
365
|
-
, 1
|
366
363
|
|
367
364
|
|
368
365
|
sanitize: (sanitizer) ->
|
369
366
|
# always remove nested regions
|
370
|
-
sanitizer.find("
|
371
|
-
sanitizer.find('[src*="webkit-fake-url://"]').remove()
|
367
|
+
sanitizer.find(".#{Mercury.config.regions.className}").remove()
|
372
368
|
|
373
369
|
if Mercury.config.pasting.sanitize
|
374
370
|
switch Mercury.config.pasting.sanitize
|
@@ -426,7 +422,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
426
422
|
|
427
423
|
redo: -> @content(@history.redo())
|
428
424
|
|
429
|
-
horizontalRule: ->
|
425
|
+
horizontalRule: -> this.execCommand('insertHorizontalRule')
|
430
426
|
|
431
427
|
removeFormatting: (selection) -> selection.insertTextNode(selection.textContent())
|
432
428
|
|
@@ -470,7 +466,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
470
466
|
|
471
467
|
|
472
468
|
# Helper class for managing selection and getting information from it
|
473
|
-
class Mercury.Regions.
|
469
|
+
class Mercury.Regions.Editable.Selection
|
474
470
|
|
475
471
|
constructor: (@selection, @context) ->
|
476
472
|
return unless @selection.rangeCount >= 1
|
@@ -494,13 +490,7 @@ class Mercury.Regions.Full.Selection
|
|
494
490
|
|
495
491
|
|
496
492
|
textContent: ->
|
497
|
-
return @
|
498
|
-
|
499
|
-
|
500
|
-
htmlContent: ->
|
501
|
-
content = @content()
|
502
|
-
return jQuery('<div>').html(content).html()
|
503
|
-
return null
|
493
|
+
return @range.cloneContents().textContent
|
504
494
|
|
505
495
|
|
506
496
|
content: ->
|
@@ -518,15 +508,15 @@ class Mercury.Regions.Full.Selection
|
|
518
508
|
range = @context.createRange()
|
519
509
|
|
520
510
|
if @range
|
521
|
-
if @commonAncestor(true).closest('
|
522
|
-
lastChild = @context.createTextNode(
|
511
|
+
if @commonAncestor(true).closest('.mercury-snippet').length
|
512
|
+
lastChild = @context.createTextNode('\x00')
|
523
513
|
element.appendChild(lastChild)
|
524
514
|
else
|
525
515
|
if element.lastChild && element.lastChild.nodeType == 3 && element.lastChild.textContent.replace(/^[\s+|\n+]|[\s+|\n+]$/, '') == ''
|
526
516
|
lastChild = element.lastChild
|
527
|
-
element.lastChild.textContent =
|
517
|
+
element.lastChild.textContent = '\x00'
|
528
518
|
else
|
529
|
-
lastChild = @context.createTextNode(
|
519
|
+
lastChild = @context.createTextNode('\x00')
|
530
520
|
element.appendChild(lastChild)
|
531
521
|
|
532
522
|
if lastChild
|