mercury-rails 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +5 -0
- data/{README.rdoc → README.md} +150 -60
- data/VERSION +1 -1
- data/annotated_source.template +57 -0
- data/app/controllers/mercury_controller.rb +8 -4
- data/app/models/image.rb +2 -2
- data/app/views/layouts/mercury.html.erb +14 -0
- data/app/views/mercury/lightviews/about.html +7 -0
- data/app/views/mercury/lightviews/imageprocessor.html +3 -0
- data/app/views/mercury/modals/character.html +255 -0
- data/app/views/mercury/modals/htmleditor.html +13 -0
- data/app/views/mercury/modals/link.html +75 -0
- data/app/views/mercury/modals/media.html +82 -0
- data/app/views/mercury/modals/sanitizer.html +9 -0
- data/app/views/mercury/modals/table.html +84 -0
- data/app/views/mercury/palettes/backcolor.html +73 -0
- data/app/views/mercury/palettes/forecolor.html +73 -0
- data/app/views/mercury/panels/history.html +3 -0
- data/app/views/mercury/panels/notes.html +3 -0
- data/app/views/mercury/panels/snippets.html +12 -0
- data/app/views/mercury/selects/formatblock.html +11 -0
- data/app/views/mercury/selects/style.html +5 -0
- data/app/views/mercury/snippets/example.html.erb +1 -0
- data/app/views/mercury/snippets/example_options.html.erb +23 -0
- data/config/routes.rb +1 -1
- data/features/editing/basic.feature +1 -1
- data/features/support/paths.rb +1 -0
- data/lib/generators/mercury/install/install_generator.rb +14 -0
- data/mercury-rails.gemspec +115 -106
- data/spec/javascripts/mercury/dialog_spec.js.coffee +54 -38
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/dialogs/{objectspanel_spec.js.coffee → snippetpanel_spec.js.coffee} +4 -4
- data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/history_buffer_spec.js.coffee +0 -1
- data/spec/javascripts/mercury/lightview_spec.js.coffee +448 -0
- data/spec/javascripts/mercury/mercury_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/modal_spec.js.coffee +474 -0
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +8 -2
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/native_extensions_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +160 -20
- data/spec/javascripts/mercury/palette_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/panel_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/region_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/regions/editable_spec.js.coffee +191 -6
- data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +369 -0
- data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/select_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/snippet_spec.js.coffee +3 -3
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +2 -2
- data/spec/javascripts/mercury/statusbar_spec.js.coffee +91 -17
- data/spec/javascripts/mercury/table_editor_spec.js.coffee +5 -1
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +70 -15
- data/spec/javascripts/mercury/tooltip_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/uploader_spec.js.coffee +9 -1
- data/spec/javascripts/templates/mercury/dialogs/{objectspanel.html → snippetpanel.html} +0 -0
- data/spec/javascripts/templates/mercury/lightview.html +13 -0
- data/spec/javascripts/templates/mercury/modal.html +13 -0
- data/spec/javascripts/templates/mercury/page_editor.html +11 -1
- data/spec/javascripts/templates/mercury/statusbar.html +1 -0
- data/spec/javascripts/templates/mercury/toolbar.html +1 -0
- data/{app → vendor}/assets/images/mercury/button.png +0 -0
- data/{app → vendor}/assets/images/mercury/clippy.png +0 -0
- data/{app → vendor}/assets/images/mercury/default-snippet.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/search-icon.png +0 -0
- data/vendor/assets/images/mercury/temp-logo.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/{app/assets/images/mercury/toolbar/primary/objectspanel.png → vendor/assets/images/mercury/toolbar/primary/snippetpanel.png} +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/{app → vendor}/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
- data/vendor/assets/javascripts/mercury.js +302 -0
- data/vendor/assets/javascripts/mercury/dialog.js.coffee +157 -0
- data/{app → vendor}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/dialogs/objectspanel.js.coffee +1 -1
- data/{app → vendor}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
- data/vendor/assets/javascripts/mercury/lightview.js.coffee +156 -0
- data/vendor/assets/javascripts/mercury/lightviews/imageprocessor.js.coffee +2 -0
- data/vendor/assets/javascripts/mercury/mercury.js.coffee +63 -0
- data/{app → vendor}/assets/javascripts/mercury/modal.js.coffee +25 -17
- data/{app → vendor}/assets/javascripts/mercury/modals/htmleditor.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/modals/insertlink.js.coffee +3 -0
- data/{app → vendor}/assets/javascripts/mercury/modals/insertmedia.js.coffee +10 -2
- data/{app → vendor}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/modals/inserttable.js.coffee +2 -2
- data/{app → vendor}/assets/javascripts/mercury/native_extensions.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/page_editor.js.coffee +44 -13
- data/{app → vendor}/assets/javascripts/mercury/palette.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/panel.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/region.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/regions/editable.js.coffee +58 -12
- data/{app → vendor}/assets/javascripts/mercury/regions/markupable.js.coffee +26 -24
- data/{app → vendor}/assets/javascripts/mercury/regions/snippetable.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/select.js.coffee +3 -0
- data/{app → vendor}/assets/javascripts/mercury/snippet.js.coffee +9 -5
- data/{app → vendor}/assets/javascripts/mercury/snippet_toolbar.js.coffee +0 -0
- data/vendor/assets/javascripts/mercury/statusbar.js.coffee +51 -0
- data/{app → vendor}/assets/javascripts/mercury/table_editor.js.coffee +9 -8
- data/{app → vendor}/assets/javascripts/mercury/toolbar.button.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/toolbar.button_group.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/toolbar.expander.js.coffee +0 -0
- data/{app → vendor}/assets/javascripts/mercury/toolbar.js.coffee +14 -1
- data/{app → vendor}/assets/javascripts/mercury/tooltip.js.coffee +3 -0
- data/{app → vendor}/assets/javascripts/mercury/uploader.js.coffee +22 -13
- data/vendor/assets/javascripts/{jquery-1.6.js → mercury_dependencies/jquery-1.6.js} +0 -0
- data/vendor/assets/javascripts/{jquery-ui-1.8.13.custom.js → mercury_dependencies/jquery-ui-1.8.13.custom.js} +0 -0
- data/vendor/assets/javascripts/{jquery.additions.js → mercury_dependencies/jquery.additions.js} +0 -0
- data/vendor/assets/javascripts/{liquidmetal.js → mercury_dependencies/liquidmetal.js} +0 -0
- data/vendor/assets/javascripts/{showdown.js → mercury_dependencies/showdown.js} +0 -0
- data/vendor/assets/javascripts/mercury_loader.js +191 -0
- data/{app → vendor}/assets/stylesheets/mercury.css +3 -6
- data/vendor/assets/stylesheets/mercury/dialog.css +199 -0
- data/vendor/assets/stylesheets/mercury/lightview.css +92 -0
- data/vendor/assets/stylesheets/mercury/mercury.css +134 -0
- data/vendor/assets/stylesheets/mercury/modal.css +191 -0
- data/{app/assets/stylesheets/mercury/statusbar.scss → vendor/assets/stylesheets/mercury/statusbar.css} +9 -1
- data/vendor/assets/stylesheets/mercury/toolbar.css +329 -0
- data/{app/assets/stylesheets/mercury/tooltip.scss → vendor/assets/stylesheets/mercury/tooltip.css} +7 -7
- data/vendor/assets/stylesheets/mercury/uploader.css +111 -0
- metadata +230 -225
- data/app/assets/images/mercury/toolbar/markupable/buttons.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/todospanel.png +0 -0
- data/app/assets/javascripts/mercury.js +0 -30
- data/app/assets/javascripts/mercury/dialog.js.coffee +0 -75
- data/app/assets/javascripts/mercury/mercury.js.coffee +0 -286
- data/app/assets/javascripts/mercury/statusbar.js.coffee +0 -29
- data/app/assets/javascripts/mercury_loader.js +0 -98
- data/app/assets/stylesheets/mercury/dialog.scss +0 -179
- data/app/assets/stylesheets/mercury/mercury.scss +0 -127
- data/app/assets/stylesheets/mercury/modal.scss +0 -194
- data/app/assets/stylesheets/mercury/toolbar.scss +0 -415
- data/app/assets/stylesheets/mercury/uploader.scss +0 -109
- data/app/views/layouts/mercury.html.haml +0 -8
- data/app/views/mercury/modals/character.html.haml +0 -252
- data/app/views/mercury/modals/htmleditor.html.haml +0 -8
- data/app/views/mercury/modals/link.html.haml +0 -31
- data/app/views/mercury/modals/media.html.haml +0 -33
- data/app/views/mercury/modals/sanitizer.html.haml +0 -4
- data/app/views/mercury/modals/table.html.haml +0 -49
- data/app/views/mercury/palettes/backcolor.html.haml +0 -79
- data/app/views/mercury/palettes/forecolor.html.haml +0 -79
- data/app/views/mercury/panels/history.html.haml +0 -0
- data/app/views/mercury/panels/notes.html.haml +0 -0
- data/app/views/mercury/panels/snippets.html.haml +0 -10
- data/app/views/mercury/selects/formatblock.html.haml +0 -10
- data/app/views/mercury/selects/style.html.haml +0 -4
- data/app/views/mercury/snippets/example.html.haml +0 -2
- data/app/views/mercury/snippets/example_options.html.haml +0 -16
- data/log/.gitkeep +0 -0
- data/spec/javascripts/mercury/regions/_markupable_.js.coffee +0 -0
Binary file
|
Binary file
|
@@ -1,30 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* Mercury Editor is a Coffeescript and jQuery based WYSIWYG editor. Mercury Editor utilizes the HTML5 ContentEditable
|
3
|
-
* spec to allow editing sections of a given page (instead of using iframes) and provides an editing experience that's as
|
4
|
-
* realistic as possible. By not using iframes for editable regions it allows CSS to behave naturally.
|
5
|
-
*
|
6
|
-
* Mercury Editor was written for the future, and doesn't attempt to support legacy implementations of document editing.
|
7
|
-
*
|
8
|
-
* Currently supported browsers are
|
9
|
-
* - Firefox 4+
|
10
|
-
* - Chrome 10+
|
11
|
-
* - Safari 5+
|
12
|
-
*
|
13
|
-
* Copyright (c) 2011 Jeremy Jackson
|
14
|
-
*
|
15
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
16
|
-
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
17
|
-
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
18
|
-
* persons to whom the Software is furnished to do so, subject to the following conditions:
|
19
|
-
*
|
20
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
21
|
-
* Software.
|
22
|
-
*
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
24
|
-
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
25
|
-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
26
|
-
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
|
-
*
|
28
|
-
*= require_self
|
29
|
-
*= require mercury/mercury
|
30
|
-
*/
|
@@ -1,75 +0,0 @@
|
|
1
|
-
class @Mercury.Dialog
|
2
|
-
|
3
|
-
constructor: (@url, @name, @options = {}) ->
|
4
|
-
@button = @options.for
|
5
|
-
|
6
|
-
@build()
|
7
|
-
@bindEvents()
|
8
|
-
@preload()
|
9
|
-
|
10
|
-
|
11
|
-
build: ->
|
12
|
-
@element = jQuery('<div>', {class: "mercury-dialog mercury-#{@name}-dialog loading", style: 'display:none'})
|
13
|
-
@element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
|
14
|
-
|
15
|
-
|
16
|
-
bindEvents: ->
|
17
|
-
@element.mousedown (event) -> event.stopPropagation()
|
18
|
-
|
19
|
-
|
20
|
-
preload: ->
|
21
|
-
@load() if @options.preload
|
22
|
-
|
23
|
-
|
24
|
-
toggle: (element) ->
|
25
|
-
if @visible then @hide() else @show()
|
26
|
-
|
27
|
-
|
28
|
-
resize: ->
|
29
|
-
@show()
|
30
|
-
|
31
|
-
|
32
|
-
show: ->
|
33
|
-
Mercury.trigger('hide:dialogs', @)
|
34
|
-
@visible = true
|
35
|
-
if @loaded
|
36
|
-
@element.css({width: 'auto', height: 'auto'})
|
37
|
-
@position(@visible)
|
38
|
-
@appear()
|
39
|
-
else
|
40
|
-
@position()
|
41
|
-
@appear()
|
42
|
-
|
43
|
-
|
44
|
-
position: (keepVisible) ->
|
45
|
-
|
46
|
-
|
47
|
-
appear: ->
|
48
|
-
@element.css({display: 'block', opacity: 0})
|
49
|
-
@element.animate {opacity: 0.95}, 200, 'easeInOutSine', =>
|
50
|
-
@load(=> @resize()) unless @loaded
|
51
|
-
|
52
|
-
|
53
|
-
hide: ->
|
54
|
-
@element.hide()
|
55
|
-
@visible = false
|
56
|
-
|
57
|
-
|
58
|
-
load: (callback) ->
|
59
|
-
return unless @url
|
60
|
-
jQuery.ajax @url, {
|
61
|
-
success: (data) =>
|
62
|
-
@loadContent(data)
|
63
|
-
Mercury.dialogHandlers[@name].call(@) if Mercury.dialogHandlers[@name]
|
64
|
-
callback() if callback
|
65
|
-
error: =>
|
66
|
-
@hide()
|
67
|
-
@button.removeClass('pressed') if @button
|
68
|
-
alert("Mercury was unable to load #{@url} for the #{@name} dialog.")
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
loadContent: (data) ->
|
73
|
-
@loaded = true
|
74
|
-
@element.removeClass('loading')
|
75
|
-
@element.html(data)
|
@@ -1,286 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#= require jquery-1.6
|
3
|
-
#= require jquery-ui-1.8.13.custom
|
4
|
-
#= require jquery.additions
|
5
|
-
#= require liquidmetal
|
6
|
-
#= require showdown
|
7
|
-
#
|
8
|
-
#= require_self
|
9
|
-
#= require ./native_extensions
|
10
|
-
#= require ./page_editor
|
11
|
-
#= require ./history_buffer
|
12
|
-
#= require ./table_editor
|
13
|
-
#= require ./dialog
|
14
|
-
#= require ./palette
|
15
|
-
#= require ./select
|
16
|
-
#= require ./panel
|
17
|
-
#= require ./modal
|
18
|
-
#= require ./statusbar
|
19
|
-
#= require ./toolbar
|
20
|
-
#= require ./toolbar.button
|
21
|
-
#= require ./toolbar.button_group
|
22
|
-
#= require ./toolbar.expander
|
23
|
-
#= require ./tooltip
|
24
|
-
#= require ./snippet
|
25
|
-
#= require ./snippet_toolbar
|
26
|
-
#= require ./region
|
27
|
-
#= require ./uploader
|
28
|
-
#= require_tree ./regions
|
29
|
-
#= require_tree ./dialogs
|
30
|
-
#= require_tree ./modals
|
31
|
-
#
|
32
|
-
|
33
|
-
@Mercury =
|
34
|
-
|
35
|
-
version: '0.1.1'
|
36
|
-
|
37
|
-
|
38
|
-
# No IE support yet because it doesn't follow the W3C standards for HTML5 contentEditable (aka designMode).
|
39
|
-
supported: document.getElementById && document.designMode && !jQuery.browser.konqueror && !jQuery.browser.msie
|
40
|
-
|
41
|
-
|
42
|
-
# Silent mode disables things like asking about unsaved changes before leaving the page.
|
43
|
-
silent: false
|
44
|
-
|
45
|
-
|
46
|
-
# Turning debug mode on will log events and other various things (using console.log if available).
|
47
|
-
debug: false
|
48
|
-
|
49
|
-
|
50
|
-
# Configuration
|
51
|
-
config: {
|
52
|
-
|
53
|
-
# Pasting (in Chrome/Safari)
|
54
|
-
#
|
55
|
-
# When copying content using webkit, it embeds all the user defined styles (from the css files) into the html style
|
56
|
-
# attributes directly. When pasting this content into HTML5 contentEditable elements it leaves these intact. This
|
57
|
-
# can be a desired feature, or an annoyance, so you can enable it or disable it here. Keep in mind this will only
|
58
|
-
# change the behavior in webkit, as gecko doesn't do this.
|
59
|
-
#
|
60
|
-
cleanStylesOnPaste: true
|
61
|
-
|
62
|
-
|
63
|
-
# Image Uploading (in supported regions)
|
64
|
-
#
|
65
|
-
# If you drag images (while pressing shift) from your desktop into regions that support it, it will be uploaded to
|
66
|
-
# the server and inserted into the region. This configuration allows you to specify if you want to disable/enable
|
67
|
-
# this feature, the accepted mime-types, file size restrictions, and other things related to uploading.
|
68
|
-
#
|
69
|
-
uploading:
|
70
|
-
enabled: true
|
71
|
-
allowedMimeTypes: ['image/jpeg', 'image/gif', 'image/png']
|
72
|
-
maxFileSize: 1235242880 # bytes (5 Mb by default)
|
73
|
-
inputName: 'image[image]'
|
74
|
-
url: '/images'
|
75
|
-
|
76
|
-
|
77
|
-
# Toolbars
|
78
|
-
#
|
79
|
-
# This is where you can customize the toolbars by adding or removing buttons, or changing them and their behaviors.
|
80
|
-
# Any top level object put here will create a new toolbar. Buttons are simply nested inside the toolbars, along
|
81
|
-
# with button groups.
|
82
|
-
#
|
83
|
-
# Buttons can be grouped. A button group is simply a way to wrap buttons for styling, and can also handle enabling
|
84
|
-
# or disabling all the buttons within it by using a context. The table button group is a good example of this.
|
85
|
-
#
|
86
|
-
# The primary toolbar is always visible, but any other toolbar should have a name based on what type of region it's
|
87
|
-
# for. The toolbar will be enabled/disabled base on what region currently has focus. Some toolbars are custom (the
|
88
|
-
# snippetable toolbar for instance), and to denote that use _custom: true. You can then build the toolbar yourself
|
89
|
-
# with it's own behavior.
|
90
|
-
#
|
91
|
-
# It's important to note that each of the button names (keys), in each toolbar object must be unique, regardless of
|
92
|
-
# if it's in a button group, or nested, etc. This is because styling is applied to them by name.
|
93
|
-
#
|
94
|
-
# Button format: [label, description, {type: action, type: action, etc}] The available button types are:
|
95
|
-
#
|
96
|
-
# toggle: toggles on or off when clicked, otherwise behaves like a button
|
97
|
-
# modal: opens a modal window, expects the action to be one of:
|
98
|
-
# a string url
|
99
|
-
# a function that returns a string url
|
100
|
-
# panel: opens a panel dialog, expects the action to be one of:
|
101
|
-
# a string url
|
102
|
-
# a function that returns a string url
|
103
|
-
# palette: opens a palette window, expects the action to be one of:
|
104
|
-
# a string url
|
105
|
-
# a function that returns a string url
|
106
|
-
# select: opens a pulldown style window, expects the action to be one of:
|
107
|
-
# a string url
|
108
|
-
# a function that returns a string url
|
109
|
-
# context: calls a callback function, expects the action to be:
|
110
|
-
# a function that returns a boolean to highlight the button
|
111
|
-
# note: if a function isn't provided, the key will be passed to the contextHandler, in which case a
|
112
|
-
# default context will be used (for more info read the Contexts section below)
|
113
|
-
# mode: toggle a given mode in the editor, expects the action to be:
|
114
|
-
# a string, denoting the name of the mode
|
115
|
-
# note: it's assumed that when a specific mode is turned on, all other modes will be turned off, which
|
116
|
-
# happens automatically, thus putting the editor into a specific "state"
|
117
|
-
# regions: allows buttons to be enabled/disabled based on what region type has focus, expects the action to be:
|
118
|
-
# an array of region types (eg. ['editable', 'markupable']
|
119
|
-
# preload: allows some dialog views to be loaded whtn the button is created instead of on first open, expects:
|
120
|
-
# a boolean
|
121
|
-
# note: only used for panels, selects, and palettes
|
122
|
-
#
|
123
|
-
# Separators are any "button" that's not an array, and are expected to be a string. You can use two different
|
124
|
-
# separator styles: line ('-'), and spacer (' ').
|
125
|
-
#
|
126
|
-
toolbars:
|
127
|
-
primary:
|
128
|
-
save: ['Save', 'Save this page']
|
129
|
-
preview: ['Preview', 'Preview this page', {toggle: true, mode: true}]
|
130
|
-
sep1: ' '
|
131
|
-
undoredo:
|
132
|
-
undo: ['Undo', 'Undo your last action']
|
133
|
-
redo: ['Redo', 'Redo your last action']
|
134
|
-
sep: ' '
|
135
|
-
insertLink: ['Link', 'Insert Link', {modal: '/mercury/modals/link', regions: ['editable', 'markupable']}]
|
136
|
-
insertMedia: ['Media', 'Insert Media (images and videos)', {modal: '/mercury/modals/media', regions: ['editable', 'markupable']}]
|
137
|
-
insertTable: ['Table', 'Insert Table', {modal: '/mercury/modals/table', regions: ['editable', 'markupable']}]
|
138
|
-
insertCharacter: ['Character', 'Special Characters', {modal: '/mercury/modals/character', regions: ['editable', 'markupable']}]
|
139
|
-
objectsPanel: ['Snippet', 'Snippet Panel', {panel: '/mercury/panels/snippets'}]
|
140
|
-
sep2: ' '
|
141
|
-
historyPanel: ['History', 'Page Version History', {panel: '/mercury/panels/history'}]
|
142
|
-
sep3: ' '
|
143
|
-
notesPanel: ['Notes', 'Page Notes', {panel: '/mercury/panels/notes'}]
|
144
|
-
|
145
|
-
editable:
|
146
|
-
_regions: ['editable', 'markupable']
|
147
|
-
predefined:
|
148
|
-
style: ['Style', null, {select: '/mercury/selects/style', preload: true}]
|
149
|
-
sep1: ' '
|
150
|
-
formatblock: ['Block Format', null, {select: '/mercury/selects/formatblock', preload: true}]
|
151
|
-
sep2: '-'
|
152
|
-
colors:
|
153
|
-
_regions: ['editable']
|
154
|
-
backColor: ['Background Color', null, {palette: '/mercury/palettes/backcolor', context: true, preload: true}]
|
155
|
-
sep1: ' '
|
156
|
-
foreColor: ['Text Color', null, {palette: '/mercury/palettes/forecolor', context: true, preload: true}]
|
157
|
-
sep2: '-'
|
158
|
-
decoration:
|
159
|
-
bold: ['Bold', null, {context: true}]
|
160
|
-
italic: ['Italicize', null, {context: true}]
|
161
|
-
overline: ['Overline', null, {context: true, regions: ['editable']}]
|
162
|
-
strikethrough: ['Strikethrough', null, {context: true, regions: ['editable']}]
|
163
|
-
underline: ['Underline', null, {context: true, regions: ['editable']}]
|
164
|
-
sep: '-'
|
165
|
-
script:
|
166
|
-
subscript: ['Subscript', null, {context: true}]
|
167
|
-
superscript: ['Superscript', null, {context: true}]
|
168
|
-
sep: '-'
|
169
|
-
justify:
|
170
|
-
_regions: ['editable']
|
171
|
-
justifyLeft: ['Align Left', null, {context: true}]
|
172
|
-
justifyCenter: ['Center', null, {context: true}]
|
173
|
-
justifyRight: ['Align Right', null, {context: true}]
|
174
|
-
justifyFull: ['Justify Full', null, {context: true}]
|
175
|
-
sep: '-'
|
176
|
-
list:
|
177
|
-
insertUnorderedList: ['Unordered List', null, {context: true}]
|
178
|
-
insertOrderedList: ['Numbered List', null, {context: true}]
|
179
|
-
sep: '-'
|
180
|
-
indent:
|
181
|
-
outdent: ['Decrease Indentation', null]
|
182
|
-
indent: ['Increase Indentation', null]
|
183
|
-
sep: '-'
|
184
|
-
table:
|
185
|
-
_context: true
|
186
|
-
_regions: ['editable']
|
187
|
-
insertRowBefore: ['Insert Table Row', 'Insert a table row before the cursor']
|
188
|
-
insertRowAfter: ['Insert Table Row', 'Insert a table row after the cursor']
|
189
|
-
deleteRow: ['Delete Table Row', 'Delete this table row']
|
190
|
-
insertColumnBefore: ['Insert Table Column', 'Insert a table column before the cursor']
|
191
|
-
insertColumnAfter: ['Insert Table Column', 'Insert a table column after the cursor']
|
192
|
-
deleteColumn: ['Delete Table Column', 'Delete this table column']
|
193
|
-
sep1: ' '
|
194
|
-
increaseColspan: ['Increase Cell Columns', 'Increase the cells colspan']
|
195
|
-
decreaseColspan: ['Decrease Cell Columns', 'Decrease the cells colspan and add a new cell']
|
196
|
-
increaseRowspan: ['Increase Cell Rows', 'Increase the cells rowspan']
|
197
|
-
decreaseRowspan: ['Decrease Cell Rows', 'Decrease the cells rowspan and add a new cell']
|
198
|
-
sep2: '-'
|
199
|
-
rules:
|
200
|
-
horizontalRule: ['Horizontal Rule', 'Insert a horizontal rule']
|
201
|
-
sep1: '-'
|
202
|
-
formatting:
|
203
|
-
_regions: ['editable']
|
204
|
-
removeFormatting: ['Remove Formatting', 'Remove formatting for the selection']
|
205
|
-
sep2: ' '
|
206
|
-
editors:
|
207
|
-
_regions: ['editable']
|
208
|
-
htmlEditor: ['Edit HTML', 'Edit the HTML content'] # example behavior below
|
209
|
-
|
210
|
-
snippetable:
|
211
|
-
_custom: true
|
212
|
-
actions:
|
213
|
-
editSnippet: ['Edit Snippet Settings', null]
|
214
|
-
sep1: ' '
|
215
|
-
removeSnippet: ['Remove Snippet', null]
|
216
|
-
|
217
|
-
|
218
|
-
# Behaviors
|
219
|
-
#
|
220
|
-
# Behaviors are used to change the default behaviors of a given region type when a given button is clicked. For
|
221
|
-
# example, you may prefer to add HR tags using an HR wrapped within a div with a classname (for styling). You can
|
222
|
-
# add your own complex behaviors here.
|
223
|
-
#
|
224
|
-
# You can see how the behavior matches up directly with the button name. It's also important to note that the
|
225
|
-
# callback functions are executed within the scope of the given region, so you have access to all it's methods.
|
226
|
-
# todo: figure out how this impacts different regions.. should they go away, or should they get moved into regions?
|
227
|
-
behaviors:
|
228
|
-
horizontalRule: (selection) -> selection.replace('<hr/>')
|
229
|
-
|
230
|
-
htmlEditor: ->
|
231
|
-
Mercury.modal '/mercury/modals/htmleditor', {
|
232
|
-
title: 'HTML Editor'
|
233
|
-
fullHeight: true
|
234
|
-
handler: 'htmlEditor'
|
235
|
-
}
|
236
|
-
|
237
|
-
|
238
|
-
# Contexts
|
239
|
-
#
|
240
|
-
# Contexts are used callback functions used for highlighting and disabling/enabling buttons and buttongroups. When
|
241
|
-
# the cursor enters an element within an html region for instance we want to disable or highlight buttons based on
|
242
|
-
# the properties of the given node. You can see some examples of contexts in:
|
243
|
-
#
|
244
|
-
# Mercury.Toolbar.Button.contexts
|
245
|
-
# and
|
246
|
-
# Mercury.Toolbar.ButtonGroup.contexts
|
247
|
-
#
|
248
|
-
|
249
|
-
|
250
|
-
# Styles
|
251
|
-
#
|
252
|
-
# Mercury tries to stay as much out of your code as possible, but because regions appear within your document we
|
253
|
-
# need to include a few styles to indicate regions, as well as the different states of them (eg. focused). These
|
254
|
-
# styles are injected into your document, and as simple as they might be, you may want to change them. You can do
|
255
|
-
# so here.
|
256
|
-
#
|
257
|
-
injectedStyles: '''
|
258
|
-
.mercury-region, .mercury-textarea { min-height: 10px; outline: 1px dotted #09F }
|
259
|
-
.mercury-textarea { box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; resize: vertical; }
|
260
|
-
.mercury-region:focus, .mercury-region.focus, .mercury-textarea.focus { outline: none; -webkit-box-shadow: 0 0 10px #09F, 0 0 1px #045; box-shadow: 0 0 10px #09F, 0 0 1px #045 }
|
261
|
-
.mercury-region:after { content: '.'; display: block; visibility: hidden; clear: both; height: 0; overflow: hidden; }
|
262
|
-
.mercury-region table, .mercury-region td { border: 1px dotted red; }
|
263
|
-
'''
|
264
|
-
}
|
265
|
-
|
266
|
-
|
267
|
-
# Custom event and logging methods
|
268
|
-
bind: (eventName, callback) ->
|
269
|
-
jQuery(document).bind("mercury:#{eventName}", callback)
|
270
|
-
|
271
|
-
|
272
|
-
trigger: (eventName, options) ->
|
273
|
-
Mercury.log(eventName, options)
|
274
|
-
jQuery(document).trigger("mercury:#{eventName}", options)
|
275
|
-
|
276
|
-
|
277
|
-
log: ->
|
278
|
-
if Mercury.debug && console
|
279
|
-
return if arguments[0] == 'hide:toolbar' || arguments[0] == 'show:toolbar'
|
280
|
-
try console.debug(arguments) catch e
|
281
|
-
|
282
|
-
|
283
|
-
# Mercury object namespaces
|
284
|
-
Regions: {}
|
285
|
-
modalHandlers: {}
|
286
|
-
dialogHandlers: {}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class @Mercury.Statusbar
|
2
|
-
|
3
|
-
constructor: (@options = {}) ->
|
4
|
-
@build()
|
5
|
-
@bindEvents()
|
6
|
-
|
7
|
-
|
8
|
-
build: ->
|
9
|
-
@element = jQuery('<div>', {class: 'mercury-statusbar'}).appendTo(jQuery(@options.appendTo).get(0) ? 'body')
|
10
|
-
|
11
|
-
|
12
|
-
bindEvents: ->
|
13
|
-
Mercury.bind 'region:update', (event, options) =>
|
14
|
-
@setPath(options.region.path()) if options.region && jQuery.type(options.region.path) == 'function'
|
15
|
-
|
16
|
-
|
17
|
-
height: ->
|
18
|
-
return @element.outerHeight()
|
19
|
-
|
20
|
-
|
21
|
-
top: ->
|
22
|
-
return @element.offset().top
|
23
|
-
|
24
|
-
|
25
|
-
setPath: (elements) ->
|
26
|
-
path = []
|
27
|
-
path.push("<a>#{element.tagName.toLowerCase()}</a>") for element in elements
|
28
|
-
|
29
|
-
@element.html("<span><strong>Path: </strong></span>#{path.reverse().join(' » ')}")
|
@@ -1,98 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* Mercury Editor is a Coffeescript and jQuery based WYSIWYG editor. Mercury Editor utilizes the HTML5 ContentEditable
|
3
|
-
* spec to allow editing sections of a given page (instead of using iframes) and provides an editing experience that's as
|
4
|
-
* realistic as possible. By not using iframes for editable regions it allows CSS to behave naturally.
|
5
|
-
*
|
6
|
-
* Mercury Editor was written for the future, and doesn't attempt to support legacy implementations of document editing.
|
7
|
-
*
|
8
|
-
* Currently supported browsers are
|
9
|
-
* - Firefox 4+
|
10
|
-
* - Chrome 10+
|
11
|
-
* - Safari 5+
|
12
|
-
*
|
13
|
-
* Copyright (c) 2011 Jeremy Jackson
|
14
|
-
*
|
15
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
16
|
-
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
17
|
-
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
18
|
-
* persons to whom the Software is furnished to do so, subject to the following conditions:
|
19
|
-
*
|
20
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
21
|
-
* Software.
|
22
|
-
*
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
24
|
-
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
25
|
-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
26
|
-
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
|
-
*
|
28
|
-
*= require_self
|
29
|
-
*/
|
30
|
-
(function() {
|
31
|
-
if (!document.getElementsByTagName) return;
|
32
|
-
|
33
|
-
var head = document.getElementsByTagName("head")[0];
|
34
|
-
if (window == top) {
|
35
|
-
var style = document.createElement('style');
|
36
|
-
style.innerText = 'body{visibility:hidden;display:none}';
|
37
|
-
head.appendChild(style);
|
38
|
-
}
|
39
|
-
|
40
|
-
var timer;
|
41
|
-
function fireContentLoadedEvent() {
|
42
|
-
if (document.mercuryLoaded) return;
|
43
|
-
if (timer) window.clearTimeout(timer);
|
44
|
-
document.mercuryLoaded = true;
|
45
|
-
|
46
|
-
if (window == top) {
|
47
|
-
setTimeout(function() {
|
48
|
-
document.body.innerHTML = ' ';
|
49
|
-
for (var i = 0; i <= document.styleSheets.length - 1; i += 1) {
|
50
|
-
document.styleSheets[i].disabled = true
|
51
|
-
}
|
52
|
-
|
53
|
-
var link = document.createElement('link');
|
54
|
-
link.href = '/assets/mercury.css';
|
55
|
-
link.media = 'screen';
|
56
|
-
link.rel = 'stylesheet';
|
57
|
-
link.type = 'text/css';
|
58
|
-
head.appendChild(link);
|
59
|
-
|
60
|
-
var script = document.createElement('script');
|
61
|
-
script.src = '/assets/mercury.js';
|
62
|
-
script.type = 'text/javascript';
|
63
|
-
head.appendChild(script);
|
64
|
-
script.onload = function() {
|
65
|
-
document.body.style.visibility = 'visible';
|
66
|
-
document.body.style.display = 'block';
|
67
|
-
new Mercury.PageEditor()
|
68
|
-
}
|
69
|
-
}, 1);
|
70
|
-
} else if (top.Mercury) {
|
71
|
-
window.Mercury = top.Mercury;
|
72
|
-
Mercury.trigger('initialize:frame');
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
function checkReadyState() {
|
77
|
-
if (document.readyState === 'complete') {
|
78
|
-
document.stopObserving('readystatechange', checkReadyState);
|
79
|
-
fireContentLoadedEvent();
|
80
|
-
}
|
81
|
-
}
|
82
|
-
|
83
|
-
function pollDoScroll() {
|
84
|
-
try { document.documentElement.doScroll('left'); }
|
85
|
-
catch(e) {
|
86
|
-
timer = pollDoScroll.defer();
|
87
|
-
return;
|
88
|
-
}
|
89
|
-
fireContentLoadedEvent();
|
90
|
-
}
|
91
|
-
|
92
|
-
if (document.addEventListener) {
|
93
|
-
document.addEventListener('DOMContentLoaded', fireContentLoadedEvent, false);
|
94
|
-
} else {
|
95
|
-
document.observe('readystatechange', checkReadyState);
|
96
|
-
if (window == top) { timer = pollDoScroll.defer(); }
|
97
|
-
}
|
98
|
-
})();
|