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
File without changes
|
@@ -3,7 +3,11 @@ class @Mercury.Snippet
|
|
3
3
|
@all: []
|
4
4
|
|
5
5
|
@displayOptionsFor: (name) ->
|
6
|
-
Mercury.modal(
|
6
|
+
Mercury.modal Mercury.config.snippets.optionsUrl.replace(':name', name), {
|
7
|
+
title: 'Snippet Options'
|
8
|
+
handler: 'insertSnippet'
|
9
|
+
snippetName: name
|
10
|
+
}
|
7
11
|
Mercury.snippet = null
|
8
12
|
|
9
13
|
|
@@ -47,8 +51,8 @@ class @Mercury.Snippet
|
|
47
51
|
|
48
52
|
|
49
53
|
loadPreview: (element, callback = null) ->
|
50
|
-
jQuery.ajax
|
51
|
-
type:
|
54
|
+
jQuery.ajax Mercury.config.snippets.previewUrl.replace(':name', @name), {
|
55
|
+
type: Mercury.config.snippets.method
|
52
56
|
data: @options
|
53
57
|
success: (data) =>
|
54
58
|
@data = data
|
@@ -61,10 +65,10 @@ class @Mercury.Snippet
|
|
61
65
|
|
62
66
|
displayOptions: ->
|
63
67
|
Mercury.snippet = @
|
64
|
-
Mercury.modal
|
68
|
+
Mercury.modal Mercury.config.snippets.optionsUrl.replace(':name', @name), {
|
65
69
|
title: 'Snippet Options',
|
66
70
|
handler: 'insertSnippet',
|
67
|
-
loadType:
|
71
|
+
loadType: Mercury.config.snippets.method,
|
68
72
|
loadData: @options
|
69
73
|
}
|
70
74
|
|
File without changes
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class @Mercury.Statusbar
|
2
|
+
|
3
|
+
constructor: (@options = {}) ->
|
4
|
+
@visible = @options.visible
|
5
|
+
@build()
|
6
|
+
@bindEvents()
|
7
|
+
|
8
|
+
|
9
|
+
build: ->
|
10
|
+
@element = jQuery('<div>', {class: 'mercury-statusbar'})
|
11
|
+
@aboutElement = jQuery('<a>', {class: "mercury-statusbar-about"}).appendTo(@element).html("Mercury Editor v#{Mercury.version}")
|
12
|
+
@pathElement = jQuery('<div>', {class: 'mercury-statusbar-path'}).appendTo(@element)
|
13
|
+
|
14
|
+
@element.css({visibility: 'hidden'}) unless @visible
|
15
|
+
@element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
|
16
|
+
|
17
|
+
|
18
|
+
bindEvents: ->
|
19
|
+
Mercury.bind 'region:update', (event, options) =>
|
20
|
+
@setPath(options.region.path()) if options.region && jQuery.type(options.region.path) == 'function'
|
21
|
+
|
22
|
+
@aboutElement.click =>
|
23
|
+
Mercury.lightview('/mercury/lightviews/about.html', {title: "About Mercury Editor v#{Mercury.version}"})
|
24
|
+
|
25
|
+
|
26
|
+
height: ->
|
27
|
+
@element.outerHeight()
|
28
|
+
|
29
|
+
|
30
|
+
top: ->
|
31
|
+
top = @element.offset().top
|
32
|
+
currentTop = if parseInt(@element.css('bottom')) < 0 then top - @element.outerHeight() else top
|
33
|
+
if @visible then currentTop else top + @element.outerHeight()
|
34
|
+
|
35
|
+
|
36
|
+
setPath: (elements) ->
|
37
|
+
path = []
|
38
|
+
path.push("<a>#{element.tagName.toLowerCase()}</a>") for element in elements
|
39
|
+
|
40
|
+
@pathElement.html("<span><strong>Path: </strong>#{path.reverse().join(' » ')}</span>")
|
41
|
+
|
42
|
+
|
43
|
+
show: ->
|
44
|
+
@visible = true
|
45
|
+
@element.css({opacity: 0, visibility: 'visible'})
|
46
|
+
@element.animate({opacity: 1}, 200, 'easeInOutSine')
|
47
|
+
|
48
|
+
|
49
|
+
hide: ->
|
50
|
+
@visible = false
|
51
|
+
@element.css({visibility: 'hidden'})
|
@@ -1,10 +1,10 @@
|
|
1
|
-
@Mercury.tableEditor = (table, cell) ->
|
2
|
-
Mercury.tableEditor.load(table, cell)
|
1
|
+
@Mercury.tableEditor = (table, cell, cellContent) ->
|
2
|
+
Mercury.tableEditor.load(table, cell, cellContent)
|
3
3
|
return Mercury.tableEditor
|
4
4
|
|
5
5
|
jQuery.extend Mercury.tableEditor, {
|
6
6
|
|
7
|
-
load: (@table, @cell) ->
|
7
|
+
load: (@table, @cell, @cellContent = '') ->
|
8
8
|
@row = @cell.parent('tr')
|
9
9
|
@columnCount = @getColumnCount()
|
10
10
|
@rowCount = @getRowCount()
|
@@ -17,7 +17,7 @@ jQuery.extend Mercury.tableEditor, {
|
|
17
17
|
rowSpan = 1
|
18
18
|
matchOptions = if position == 'after' then {right: sig.right} else {left: sig.left}
|
19
19
|
if matching = @findCellByOptionsFor(row, matchOptions)
|
20
|
-
newCell = jQuery("<#{matching.cell.get(0).tagName}>").
|
20
|
+
newCell = jQuery("<#{matching.cell.get(0).tagName}>").html(@cellContent)
|
21
21
|
@setRowspanFor(newCell, matching.height)
|
22
22
|
if position == 'before' then matching.cell.before(newCell) else matching.cell.after(newCell)
|
23
23
|
i += matching.height - 1
|
@@ -51,7 +51,7 @@ jQuery.extend Mercury.tableEditor, {
|
|
51
51
|
cellCount = 0
|
52
52
|
for cell in @row.find('th, td')
|
53
53
|
colspan = @colspanFor(cell)
|
54
|
-
newCell = jQuery("<#{cell.tagName}>").
|
54
|
+
newCell = jQuery("<#{cell.tagName}>").html(@cellContent)
|
55
55
|
@setColspanFor(newCell, colspan)
|
56
56
|
cellCount += colspan
|
57
57
|
if (rowspan = @rowspanFor(cell)) > 1 && position == 'after'
|
@@ -70,7 +70,8 @@ jQuery.extend Mercury.tableEditor, {
|
|
70
70
|
@setRowspanFor(cell, rowspan + 1)
|
71
71
|
else if rowspan - 1 >= rowCount && position == 'after'
|
72
72
|
if rowspan - 1 == rowCount
|
73
|
-
newCell = jQuery("<#{cell.tagName}>"
|
73
|
+
newCell = jQuery("<#{cell.tagName}>").html(@cellContent)
|
74
|
+
@setColspanFor(newCell, @colspanFor(cell))
|
74
75
|
newRow.append(newCell)
|
75
76
|
else
|
76
77
|
@setRowspanFor(cell, rowspan + 1)
|
@@ -129,7 +130,7 @@ jQuery.extend Mercury.tableEditor, {
|
|
129
130
|
decreaseColspan: ->
|
130
131
|
return if @colspanFor(@cell) == 1
|
131
132
|
@setColspanFor(@cell, @colspanFor(@cell) - 1)
|
132
|
-
newCell = jQuery("<#{@cell.get(0).tagName}>").
|
133
|
+
newCell = jQuery("<#{@cell.get(0).tagName}>").html(@cellContent)
|
133
134
|
@setRowspanFor(newCell, @rowspanFor(@cell))
|
134
135
|
@cell.after(newCell)
|
135
136
|
|
@@ -146,7 +147,7 @@ jQuery.extend Mercury.tableEditor, {
|
|
146
147
|
return if sig.height == 1
|
147
148
|
nextRow = @row.nextAll('tr')[sig.height - 2]
|
148
149
|
if match = @findCellByOptionsFor(nextRow, {left: sig.left, forceAdjacent: true})
|
149
|
-
newCell = jQuery("<#{@cell.get(0).tagName}>").
|
150
|
+
newCell = jQuery("<#{@cell.get(0).tagName}>").html(@cellContent)
|
150
151
|
@setColspanFor(newCell, @colspanFor(@cell))
|
151
152
|
@setRowspanFor(@cell, sig.height - 1)
|
152
153
|
if match.direction == 'before' then match.cell.before(newCell) else match.cell.after(newCell)
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,12 +1,14 @@
|
|
1
1
|
class @Mercury.Toolbar
|
2
2
|
|
3
3
|
constructor: (@options = {}) ->
|
4
|
+
@visible = @options.visible
|
4
5
|
@build()
|
5
6
|
@bindEvents()
|
6
7
|
|
7
8
|
|
8
9
|
build: ->
|
9
10
|
@element = jQuery('<div>', {class: 'mercury-toolbar-container', style: 'width:10000px'})
|
11
|
+
@element.css({display: 'none'}) unless @visible
|
10
12
|
@element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
|
11
13
|
|
12
14
|
for own toolbarName, buttons of Mercury.config.toolbars
|
@@ -68,4 +70,15 @@ class @Mercury.Toolbar
|
|
68
70
|
|
69
71
|
|
70
72
|
height: ->
|
71
|
-
@element.outerHeight()
|
73
|
+
if @visible then @element.outerHeight() else 0
|
74
|
+
|
75
|
+
|
76
|
+
show: ->
|
77
|
+
@visible = true
|
78
|
+
@element.css({top: -@element.outerHeight(), display: 'block'})
|
79
|
+
@element.animate({top: 0}, 200, 'easeInOutSine')
|
80
|
+
|
81
|
+
|
82
|
+
hide: ->
|
83
|
+
@visible = false
|
84
|
+
@element.hide()
|
@@ -25,6 +25,9 @@ jQuery.extend Mercury.tooltip, {
|
|
25
25
|
bindEvents: ->
|
26
26
|
Mercury.bind 'resize', => @position() if @visible
|
27
27
|
@document.scroll => @position() if @visible
|
28
|
+
for parent in @forElement.parentsUntil(jQuery('body', @document))
|
29
|
+
if parent.scrollHeight > parent.clientHeight
|
30
|
+
jQuery(parent).scroll => @position() if @visible
|
28
31
|
@element.mousedown (event) ->
|
29
32
|
event.preventDefault()
|
30
33
|
event.stopPropagation()
|
@@ -1,5 +1,5 @@
|
|
1
1
|
@Mercury.uploader = (file, options) ->
|
2
|
-
Mercury.uploader.show(file, options)
|
2
|
+
Mercury.uploader.show(file, options) if Mercury.config.uploading.enabled
|
3
3
|
return Mercury.uploader
|
4
4
|
|
5
5
|
jQuery.extend Mercury.uploader, {
|
@@ -65,15 +65,12 @@ jQuery.extend Mercury.uploader, {
|
|
65
65
|
|
66
66
|
|
67
67
|
position: ->
|
68
|
-
viewportWidth = jQuery(window).width()
|
69
|
-
viewportHeight = jQuery(window).height()
|
70
|
-
|
71
68
|
width = @element.outerWidth()
|
72
69
|
height = @element.outerHeight()
|
73
70
|
|
74
71
|
@element.css {
|
75
|
-
top: (
|
76
|
-
left: (
|
72
|
+
top: (Mercury.displayRect.height - height) / 2
|
73
|
+
left: (Mercury.displayRect.width - width) / 2
|
77
74
|
}
|
78
75
|
|
79
76
|
|
@@ -93,16 +90,28 @@ jQuery.extend Mercury.uploader, {
|
|
93
90
|
jQuery.each ['onloadstart', 'onprogress', 'onload', 'onabort', 'onerror'], (index, eventName) =>
|
94
91
|
xhr.upload[eventName] = (event) => @uploaderEvents[eventName].call(@, event)
|
95
92
|
xhr.onload = (event) =>
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
@
|
93
|
+
console.debug(event)
|
94
|
+
if (event.currentTarget.status >= 400)
|
95
|
+
@updateStatus('Error: Unable to upload the file')
|
96
|
+
alert("#{event.currentTarget.status}: Unable to process response")
|
97
|
+
@hide()
|
98
|
+
else
|
99
|
+
try
|
100
|
+
response =
|
101
|
+
if Mercury.config.uploading.handler
|
102
|
+
Mercury.config.uploading.handler(event.target.responseText)
|
103
|
+
else
|
104
|
+
jQuery.parseJSON(event.target.responseText)
|
105
|
+
Mercury.trigger('action', {action: 'insertImage', value: {src: response.image.url}})
|
106
|
+
catch error
|
107
|
+
@updateStatus('Error: Unable to upload the file')
|
108
|
+
alert("Unable to process response: #{error}")
|
109
|
+
@hide()
|
101
110
|
|
102
111
|
xhr.open('post', Mercury.config.uploading.url, true)
|
103
112
|
xhr.setRequestHeader('Accept', 'application/json, text/javascript, text/html, application/xml, text/xml, */*')
|
104
113
|
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
105
|
-
xhr.setRequestHeader(
|
114
|
+
xhr.setRequestHeader(Mercury.config.csrfHeader, Mercury.csrfToken)
|
106
115
|
|
107
116
|
@file.readAsBinaryString (result) =>
|
108
117
|
# build the multipart post string
|
@@ -158,7 +167,7 @@ jQuery.extend Mercury.uploader, {
|
|
158
167
|
|
159
168
|
onerror: ->
|
160
169
|
@updateStatus('Error: Unable to upload the file')
|
161
|
-
@hide(
|
170
|
+
@hide(3)
|
162
171
|
}
|
163
172
|
|
164
173
|
|
File without changes
|
File without changes
|
data/vendor/assets/javascripts/{jquery.additions.js → mercury_dependencies/jquery.additions.js}
RENAMED
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,191 @@
|
|
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
|
+
options[attr] = value;
|
103
|
+
});
|
104
|
+
}
|
105
|
+
|
106
|
+
var pack = window.mercuryPackages[options.pack];
|
107
|
+
setTimeout(function() {
|
108
|
+
// Once we're ready to load Mercury we clear the document contents, and add in the css and javascript tags.
|
109
|
+
// Once the script has loaded we display the body again, and instantiate a new instance of Mercury.PageEditor.
|
110
|
+
document.body.innerHTML = ' ';
|
111
|
+
for (i = 0; i <= document.styleSheets.length - 1; i += 1) {
|
112
|
+
document.styleSheets[i].disabled = true
|
113
|
+
}
|
114
|
+
|
115
|
+
// Load all the stylesheets.
|
116
|
+
var stylesheets = pack.stylesheets.split(',');
|
117
|
+
for (i = 0; i <= stylesheets.length - 1; i += 1) {
|
118
|
+
var link = document.createElement('link');
|
119
|
+
link.href = options.src + '/' + stylesheets[i];
|
120
|
+
link.media = 'screen';
|
121
|
+
link.rel = 'stylesheet';
|
122
|
+
link.type = 'text/css';
|
123
|
+
head.appendChild(link);
|
124
|
+
}
|
125
|
+
|
126
|
+
// Load all the javascripts.
|
127
|
+
var javascripts = pack.javascripts.split(',');
|
128
|
+
var loaded = 0;
|
129
|
+
function loadScript(src) {
|
130
|
+
var script = document.createElement('script');
|
131
|
+
script.src = options.src + '/' + src;
|
132
|
+
script.type = 'text/javascript';
|
133
|
+
head.appendChild(script);
|
134
|
+
script.onload = function() {
|
135
|
+
loaded += 1;
|
136
|
+
if (loaded >= javascripts.length) {
|
137
|
+
document.body.style.visibility = 'visible';
|
138
|
+
document.body.style.display = 'block';
|
139
|
+
// Instantiate the PageEditor, passing in the options that were provided to the loader.
|
140
|
+
new Mercury.PageEditor(null, {visible: true});
|
141
|
+
// If there's a mercuryLoaded function available, call it. You can provide one before the loading script
|
142
|
+
// and it will be called after everything is loaded, but before everything is initialized. You can bind
|
143
|
+
// to the mercury:ready event or use Mercury.bind('ready', function() {}).
|
144
|
+
if (typeof(window.mercuryLoaded) == 'function') {
|
145
|
+
window.mercuryLoaded();
|
146
|
+
}
|
147
|
+
} else {
|
148
|
+
loadScript(javascripts[loaded]);
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
loadScript(javascripts[loaded]);
|
153
|
+
}, 1);
|
154
|
+
} else if (top.Mercury) {
|
155
|
+
// Since this file will be included in the iframe as well, we use it to tell Mercury that the document is ready to
|
156
|
+
// be worked on. By firing this event we're able to build the regions and get everything ready without having to
|
157
|
+
// wait for assets and slow javascripts to load or complete.
|
158
|
+
window.Mercury = top.Mercury;
|
159
|
+
Mercury.trigger('initialize:frame');
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
// This is a common technique for determining if the document has loaded yet, and is based on the methods used in
|
164
|
+
// Prototype.js. The following portions just call loadMercury once it's appropriate to do so.
|
165
|
+
//
|
166
|
+
// Support for the DOMContentLoaded event is based on work by Dan Webb, Matthias Miller, Dean Edwards, John Resig,
|
167
|
+
// and Diego Perini.
|
168
|
+
var timer;
|
169
|
+
function checkReadyState() {
|
170
|
+
if (document.readyState === 'complete') {
|
171
|
+
document.stopObserving('readystatechange', checkReadyState);
|
172
|
+
loadMercury();
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
function pollDoScroll() {
|
177
|
+
try { document.documentElement.doScroll('left'); }
|
178
|
+
catch(e) {
|
179
|
+
timer = pollDoScroll.defer();
|
180
|
+
return;
|
181
|
+
}
|
182
|
+
loadMercury();
|
183
|
+
}
|
184
|
+
|
185
|
+
if (document.addEventListener) {
|
186
|
+
document.addEventListener('DOMContentLoaded', loadMercury, false);
|
187
|
+
} else {
|
188
|
+
document.observe('readystatechange', checkReadyState);
|
189
|
+
if (window == top) { timer = pollDoScroll.defer(); }
|
190
|
+
}
|
191
|
+
})();
|