mercury-rails 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +81 -50
- data/VERSION +1 -1
- data/app/assets/javascripts/mercury/dialog.js.coffee +4 -4
- data/app/assets/javascripts/mercury/dialogs/backcolor.js.coffee +3 -3
- data/app/assets/javascripts/mercury/dialogs/forecolor.js.coffee +3 -3
- data/app/assets/javascripts/mercury/dialogs/formatblock.js.coffee +1 -1
- data/app/assets/javascripts/mercury/dialogs/objectspanel.js.coffee +3 -3
- data/app/assets/javascripts/mercury/dialogs/style.js.coffee +1 -1
- data/app/assets/javascripts/mercury/history_buffer.js.coffee +2 -2
- data/app/assets/javascripts/mercury/mercury.js.coffee +47 -54
- data/app/assets/javascripts/mercury/modal.js.coffee +13 -13
- data/app/assets/javascripts/mercury/modals/htmleditor.js.coffee +2 -2
- data/app/assets/javascripts/mercury/modals/insertcharacter.js.coffee +2 -2
- data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +7 -7
- data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +5 -5
- data/app/assets/javascripts/mercury/modals/insertsnippet.js.coffee +2 -2
- data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +14 -15
- data/app/assets/javascripts/mercury/native_extensions.js.coffee +2 -1
- data/app/assets/javascripts/mercury/page_editor.js.coffee +27 -27
- data/app/assets/javascripts/mercury/palette.js.coffee +6 -6
- data/app/assets/javascripts/mercury/panel.js.coffee +4 -4
- data/app/assets/javascripts/mercury/region.js.coffee +9 -9
- data/app/assets/javascripts/mercury/regions/editable.js.coffee +71 -71
- data/app/assets/javascripts/mercury/regions/markupable.js.coffee +51 -42
- data/app/assets/javascripts/mercury/regions/snippetable.js.coffee +7 -8
- data/app/assets/javascripts/mercury/select.js.coffee +8 -8
- data/app/assets/javascripts/mercury/snippet.js.coffee +6 -6
- data/app/assets/javascripts/mercury/snippet_toolbar.js.coffee +7 -7
- data/app/assets/javascripts/mercury/statusbar.js.coffee +7 -3
- data/app/assets/javascripts/mercury/table_editor.js.coffee +24 -24
- data/app/assets/javascripts/mercury/toolbar.button.js.coffee +20 -21
- data/app/assets/javascripts/mercury/toolbar.button_group.js.coffee +2 -2
- data/app/assets/javascripts/mercury/toolbar.expander.js.coffee +9 -9
- data/app/assets/javascripts/mercury/toolbar.js.coffee +12 -13
- data/app/assets/javascripts/mercury/tooltip.js.coffee +7 -7
- data/app/assets/javascripts/mercury/uploader.js.coffee +12 -13
- data/app/assets/javascripts/mercury_loader.js +98 -0
- data/app/assets/stylesheets/mercury/modal.scss +5 -5
- data/app/assets/stylesheets/mercury/toolbar.scss +62 -64
- data/app/views/layouts/mercury.html.haml +0 -4
- data/app/views/mercury/modals/character.html.haml +1 -1
- data/app/views/mercury/modals/htmleditor.html.haml +1 -1
- data/app/views/mercury/modals/table.html.haml +10 -10
- data/config/routes.rb +2 -2
- data/mercury-rails.gemspec +17 -20
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +3 -3
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +3 -3
- data/spec/javascripts/mercury/dialogs/objectspanel_spec.js.coffee +3 -3
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +4 -4
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +2 -2
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +10 -10
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +7 -7
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +4 -4
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +17 -17
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +5 -6
- data/spec/javascripts/mercury/region_spec.js.coffee +5 -5
- data/spec/javascripts/mercury/regions/editable_spec.js.coffee +398 -0
- data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +18 -14
- data/spec/javascripts/mercury/snippet_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +16 -16
- data/spec/javascripts/templates/mercury/modals/inserttable.html +11 -11
- data/spec/javascripts/templates/mercury/regions/editable.html +3 -0
- data/spec/javascripts/templates/mercury/toolbar.button.html +8 -8
- data/vendor/assets/javascripts/{jquery-ui-1.8.13.sortable.custom.js → jquery-ui-1.8.13.custom.js} +250 -0
- data/vendor/assets/javascripts/jquery.additions.js +151 -0
- data/vendor/assets/javascripts/showdown.js +1254 -1276
- metadata +26 -29
- data/app/assets/javascripts/mercury/websocket.js.coffee +0 -34
- data/spec/javascripts/mercury/regions/_editable_.js.coffee +0 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.13.custom.min.js +0 -249
- data/vendor/assets/javascripts/jquery.easing.js +0 -173
- data/vendor/assets/javascripts/jquery.json2.js +0 -178
- data/vendor/assets/javascripts/jquery.serialize_object.js +0 -16
- data/vendor/assets/javascripts/jquery.ujs.js +0 -289
@@ -2,7 +2,7 @@
|
|
2
2
|
Mercury.modal.show(url, options)
|
3
3
|
return Mercury.modal
|
4
4
|
|
5
|
-
|
5
|
+
jQuery.extend Mercury.modal, {
|
6
6
|
|
7
7
|
minWidth: 400
|
8
8
|
|
@@ -20,18 +20,18 @@ $.extend Mercury.modal, {
|
|
20
20
|
|
21
21
|
|
22
22
|
build: ->
|
23
|
-
@element =
|
23
|
+
@element = jQuery('<div>', {class: 'mercury-modal loading'})
|
24
24
|
@element.html('<h1 class="mercury-modal-title"><span></span><a>×</a></h1>')
|
25
25
|
@element.append('<div class="mercury-modal-content-container"><div class="mercury-modal-content"></div></div>')
|
26
26
|
|
27
|
-
@overlay =
|
27
|
+
@overlay = jQuery('<div>', {class: 'mercury-modal-overlay'})
|
28
28
|
|
29
29
|
@titleElement = @element.find('.mercury-modal-title')
|
30
30
|
@contentContainerElement = @element.find('.mercury-modal-content-container')
|
31
31
|
@contentElement = @element.find('.mercury-modal-content')
|
32
32
|
|
33
|
-
@element.appendTo(
|
34
|
-
@overlay.appendTo(
|
33
|
+
@element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
|
34
|
+
@overlay.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
|
35
35
|
|
36
36
|
@titleElement.find('span').html(@options.title)
|
37
37
|
|
@@ -62,7 +62,7 @@ $.extend Mercury.modal, {
|
|
62
62
|
# TODO: resizing is a bit shitty when the modal has panes and is scrollable
|
63
63
|
visibility = if keepVisible then 'visible' else 'hidden'
|
64
64
|
|
65
|
-
viewportHeight =
|
65
|
+
viewportHeight = jQuery(window).height()
|
66
66
|
titleHeight = @titleElement.outerHeight()
|
67
67
|
|
68
68
|
width = @contentElement.outerWidth()
|
@@ -75,7 +75,7 @@ $.extend Mercury.modal, {
|
|
75
75
|
width = @minWidth if width < @minWidth
|
76
76
|
height = viewportHeight - 20 if height > viewportHeight - 20 || @options.fullHeight
|
77
77
|
|
78
|
-
@element.stop().animate {left: (
|
78
|
+
@element.stop().animate {left: (jQuery(window).width() - width) / 2, width: width, height: height}, 200, 'easeInOutSine', =>
|
79
79
|
@contentElement.css({visibility: 'visible', display: 'block'})
|
80
80
|
if @contentPane.length
|
81
81
|
@contentElement.css({height: height - titleHeight, overflow: 'visible'})
|
@@ -87,8 +87,8 @@ $.extend Mercury.modal, {
|
|
87
87
|
|
88
88
|
|
89
89
|
position: ->
|
90
|
-
viewportWidth =
|
91
|
-
viewportHeight =
|
90
|
+
viewportWidth = jQuery(window).width()
|
91
|
+
viewportHeight = jQuery(window).height()
|
92
92
|
|
93
93
|
@contentPane.css({height: 'auto'}) if @contentPane
|
94
94
|
@contentElement.css({height: 'auto'})
|
@@ -111,9 +111,9 @@ $.extend Mercury.modal, {
|
|
111
111
|
|
112
112
|
@element.css {
|
113
113
|
left: (viewportWidth - width) / 2
|
114
|
-
width: width
|
115
|
-
height: height
|
116
|
-
display: if @visible then 'block' else 'none'
|
114
|
+
width: width
|
115
|
+
height: height
|
116
|
+
display: if @visible then 'block' else 'none'
|
117
117
|
visibility: 'visible'
|
118
118
|
}
|
119
119
|
|
@@ -127,7 +127,7 @@ $.extend Mercury.modal, {
|
|
127
127
|
load: ->
|
128
128
|
@element.addClass('loading')
|
129
129
|
@setTitle()
|
130
|
-
|
130
|
+
jQuery.ajax @url, {
|
131
131
|
type: @options.loadType || 'get'
|
132
132
|
data: @options.loadData
|
133
133
|
success: (data) => @loadContent(data)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
@Mercury.modalHandlers.
|
1
|
+
@Mercury.modalHandlers.htmlEditor = ->
|
2
2
|
# fill the text area with the content
|
3
|
-
@element.find('textarea').val(Mercury.region.
|
3
|
+
@element.find('textarea').val(Mercury.region.content(null, true, false))
|
4
4
|
|
5
5
|
# replace the contents on form submit
|
6
6
|
@element.find('form').submit (event) =>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
@Mercury.modalHandlers.
|
1
|
+
@Mercury.modalHandlers.insertCharacter = ->
|
2
2
|
@element.find('.character').click ->
|
3
|
-
Mercury.trigger('action', {action: 'insertHTML', value: "&#{
|
3
|
+
Mercury.trigger('action', {action: 'insertHTML', value: "&#{jQuery(@).attr('data-entity')};"})
|
4
4
|
Mercury.modal.hide()
|
@@ -1,10 +1,10 @@
|
|
1
|
-
@Mercury.modalHandlers.
|
1
|
+
@Mercury.modalHandlers.insertLink = ->
|
2
2
|
# make the inputs work with the radio buttons
|
3
3
|
@element.find('label input').click (event) ->
|
4
|
-
|
4
|
+
jQuery(@).closest('label').next('.selectable').focus()
|
5
5
|
|
6
6
|
@element.find('.selectable').focus ->
|
7
|
-
|
7
|
+
jQuery(@).prev('label').find('input[type=radio]').prop("checked", true)
|
8
8
|
|
9
9
|
# show/hide the link target options on target change
|
10
10
|
@element.find('#link_target').change =>
|
@@ -14,8 +14,8 @@
|
|
14
14
|
|
15
15
|
# fill the existing bookmark select
|
16
16
|
bookmarkSelect = @element.find('#link_existing_bookmark')
|
17
|
-
for link in
|
18
|
-
bookmarkSelect.append(
|
17
|
+
for link in jQuery('a[name]', window.mercuryInstance.document)
|
18
|
+
bookmarkSelect.append(jQuery('<option>', {value: jQuery(link).attr('name')}).text(jQuery(link).text()))
|
19
19
|
|
20
20
|
# get the selection and initialize its information into the form
|
21
21
|
if Mercury.region && Mercury.region.selection
|
@@ -76,7 +76,7 @@
|
|
76
76
|
menubar: 'no',
|
77
77
|
toolbar: 'no'
|
78
78
|
}
|
79
|
-
attrs['href'] = "javascript:void(window.open('#{attrs['href']}', 'popup_window', '#{
|
79
|
+
attrs['href'] = "javascript:void(window.open('#{attrs['href']}', 'popup_window', '#{jQuery.param(args).replace(/&/g, ',')}'))"
|
80
80
|
else attrs['target'] = target if target
|
81
81
|
|
82
82
|
value = {tagName: 'a', attrs: attrs, content: content}
|
@@ -86,4 +86,4 @@
|
|
86
86
|
else
|
87
87
|
Mercury.trigger('action', {action: 'insertLink', value: value})
|
88
88
|
|
89
|
-
@hide()
|
89
|
+
@hide()
|
@@ -1,10 +1,10 @@
|
|
1
|
-
@Mercury.modalHandlers.
|
1
|
+
@Mercury.modalHandlers.insertMedia = ->
|
2
2
|
# make the inputs work with the radio buttons, and options
|
3
3
|
@element.find('label input').click (event) ->
|
4
|
-
|
4
|
+
jQuery(@).closest('label').next('.selectable').focus()
|
5
5
|
|
6
6
|
@element.find('.selectable').focus (event) =>
|
7
|
-
element =
|
7
|
+
element = jQuery(event.target)
|
8
8
|
element.prev('label').find('input[type=radio]').prop("checked", true)
|
9
9
|
|
10
10
|
@element.find(".media-options").hide()
|
@@ -50,7 +50,7 @@
|
|
50
50
|
|
51
51
|
when 'youtube_url'
|
52
52
|
code = @element.find('#media_youtube_url').val().replace('http://youtu.be/', '')
|
53
|
-
value =
|
53
|
+
value = jQuery('<iframe>', {
|
54
54
|
width: @element.find('#media_youtube_width').val() || 560,
|
55
55
|
height: @element.find('#media_youtube_height').val() || 349,
|
56
56
|
src: "http://www.youtube.com/embed/#{code}?wmode=transparent",
|
@@ -61,7 +61,7 @@
|
|
61
61
|
|
62
62
|
when 'vimeo_url'
|
63
63
|
code = @element.find('#media_vimeo_url').val().replace('http://vimeo.com/', '')
|
64
|
-
value =
|
64
|
+
value = jQuery('<iframe>', {
|
65
65
|
width: @element.find('#media_vimeo_width').val() || 400,
|
66
66
|
height: @element.find('#media_vimeo_height').val() || 225,
|
67
67
|
src: "http://player.vimeo.com/video/#{code}?title=1&byline=1&portrait=0&color=ffffff",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
@Mercury.modalHandlers.
|
1
|
+
@Mercury.modalHandlers.insertSnippet = ->
|
2
2
|
@element.find('form').submit (event) =>
|
3
3
|
event.preventDefault()
|
4
4
|
serializedForm = @element.find('form').serializeObject()
|
@@ -8,5 +8,5 @@
|
|
8
8
|
Mercury.snippet = null
|
9
9
|
else
|
10
10
|
snippet = Mercury.Snippet.create(@options.snippetName, serializedForm)
|
11
|
-
Mercury.trigger('action', {action: '
|
11
|
+
Mercury.trigger('action', {action: 'insertSnippet', value: snippet})
|
12
12
|
@hide()
|
@@ -1,9 +1,9 @@
|
|
1
|
-
@Mercury.modalHandlers.
|
1
|
+
@Mercury.modalHandlers.insertTable = ->
|
2
2
|
table = @element.find('#table_display table')
|
3
3
|
|
4
4
|
# make td's selectable
|
5
5
|
table.click (event) =>
|
6
|
-
cell =
|
6
|
+
cell = jQuery(event.target)
|
7
7
|
table = cell.closest('table')
|
8
8
|
table.find('.selected').removeClass('selected')
|
9
9
|
cell.addClass('selected')
|
@@ -16,19 +16,18 @@
|
|
16
16
|
|
17
17
|
# make the buttons work
|
18
18
|
@element.find('input.action').click (event) =>
|
19
|
-
action =
|
19
|
+
action = jQuery(event.target).attr('name')
|
20
20
|
switch action
|
21
|
-
|
22
|
-
when '
|
23
|
-
when '
|
24
|
-
when '
|
25
|
-
when '
|
26
|
-
when '
|
27
|
-
when '
|
28
|
-
when '
|
29
|
-
when '
|
30
|
-
when '
|
31
|
-
when 'decreaserowspan' then Mercury.tableEditor.decreaseRowspan()
|
21
|
+
when 'insertRowBefore' then Mercury.tableEditor.addRow('before')
|
22
|
+
when 'insertRowAfter' then Mercury.tableEditor.addRow('after')
|
23
|
+
when 'deleteRow' then Mercury.tableEditor.removeRow()
|
24
|
+
when 'insertColumnBefore' then Mercury.tableEditor.addColumn('before')
|
25
|
+
when 'insertColumnAfter' then Mercury.tableEditor.addColumn('after')
|
26
|
+
when 'deleteColumn' then Mercury.tableEditor.removeColumn()
|
27
|
+
when 'increaseColspan' then Mercury.tableEditor.increaseColspan()
|
28
|
+
when 'decreaseColspan' then Mercury.tableEditor.decreaseColspan()
|
29
|
+
when 'increaseRowspan' then Mercury.tableEditor.increaseRowspan()
|
30
|
+
when 'decreaseRowspan' then Mercury.tableEditor.decreaseRowspan()
|
32
31
|
|
33
32
|
# set the alignment
|
34
33
|
@element.find('#table_alignment').change =>
|
@@ -48,7 +47,7 @@
|
|
48
47
|
table.find('.selected').removeClass('selected')
|
49
48
|
table.find('td, th').html(' ')
|
50
49
|
|
51
|
-
html =
|
50
|
+
html = jQuery('<div>').html(table).html()
|
52
51
|
value = html.replace(/^\s+|\n/gm, '').replace(/(<\/.*?>|<table.*?>|<tbody>|<tr>)/g, '$1\n')
|
53
52
|
|
54
53
|
Mercury.trigger('action', {action: 'insertHTML', value: value})
|
@@ -12,6 +12,7 @@ String::toHex = ->
|
|
12
12
|
String::singleDiff = (that) ->
|
13
13
|
diff = ''
|
14
14
|
for char, index in that
|
15
|
+
break if char == 'each'
|
15
16
|
if char != @[index]
|
16
17
|
re = new RegExp(@substr(index).regExpEscape().replace(/^\s+|^( )+/g, '') + '$', 'm')
|
17
18
|
diff = that.substr(index).replace(re, '')
|
@@ -26,7 +27,7 @@ String::regExpEscape = ->
|
|
26
27
|
|
27
28
|
|
28
29
|
String::sanitizeHTML = ->
|
29
|
-
element =
|
30
|
+
element = jQuery('<div>').html(@.toString())
|
30
31
|
element.find('style').remove()
|
31
32
|
content = element.text()
|
32
33
|
content = content.replace(/\n+/g, '<br/>').replace(/.*<!--.*-->/g, '').replace(/^(<br\/>)+|(<br\/>\s*)+$/g, '')
|
@@ -10,15 +10,16 @@ class @Mercury.PageEditor
|
|
10
10
|
window.mercuryInstance = @
|
11
11
|
@regions = []
|
12
12
|
@initializeInterface()
|
13
|
-
Mercury.csrfToken = token if token =
|
13
|
+
Mercury.csrfToken = token if token = jQuery('meta[name="csrf-token"]').attr('content')
|
14
14
|
|
15
15
|
|
16
16
|
initializeInterface: ->
|
17
|
-
@focusableElement =
|
18
|
-
@iframe =
|
17
|
+
@focusableElement = jQuery('<input>', {type: 'text', style: 'position:absolute;opacity:0'}).appendTo(@options.appendTo ? 'body')
|
18
|
+
@iframe = jQuery('<iframe>', {class: 'mercury-iframe', seamless: 'true', frameborder: '0', src: 'about:blank', style: 'position:absolute;top:0;width:100%;visibility:hidden'})
|
19
|
+
@iframe.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
|
20
|
+
|
19
21
|
@iframe.load => @initializeFrame()
|
20
|
-
@iframe.
|
21
|
-
@iframe.appendTo($(@options.appendTo).get(0) ? 'body')
|
22
|
+
@iframe.get(0).contentWindow.document.location.href = @iframeSrc()
|
22
23
|
|
23
24
|
@toolbar = new Mercury.Toolbar(@options)
|
24
25
|
@statusbar = new Mercury.Statusbar(@options)
|
@@ -28,14 +29,14 @@ class @Mercury.PageEditor
|
|
28
29
|
try
|
29
30
|
return if @iframe.data('loaded')
|
30
31
|
@iframe.data('loaded', true)
|
31
|
-
@document =
|
32
|
-
|
32
|
+
@document = jQuery(@iframe.get(0).contentWindow.document)
|
33
|
+
jQuery("<style mercury-styles=\"true\">").html(Mercury.config.injectedStyles).appendTo(@document.find('head'))
|
33
34
|
|
34
35
|
# jquery: make jQuery evaluate scripts within the context of the iframe window -- note that this means that we
|
35
36
|
# can't use eval in mercury (eg. script tags in ajax responses) because it will eval in the wrong context (you can
|
36
37
|
# use top.Mercury though, if you keep it in mind)
|
37
38
|
iframeWindow = @iframe.get(0).contentWindow
|
38
|
-
|
39
|
+
jQuery.globalEval = (data) -> (iframeWindow.execScript || (data) -> iframeWindow["eval"].call(iframeWindow, data))(data) if (data && /\S/.test(data))
|
39
40
|
|
40
41
|
@bindEvents()
|
41
42
|
@initializeRegions()
|
@@ -47,7 +48,7 @@ class @Mercury.PageEditor
|
|
47
48
|
|
48
49
|
|
49
50
|
initializeRegions: ->
|
50
|
-
@buildRegion(
|
51
|
+
@buildRegion(jQuery(region)) for region in jQuery('.mercury-region', @document)
|
51
52
|
for region in @regions
|
52
53
|
if region.focus
|
53
54
|
region.focus()
|
@@ -71,51 +72,50 @@ class @Mercury.PageEditor
|
|
71
72
|
|
72
73
|
|
73
74
|
bindEvents: ->
|
74
|
-
Mercury.bind 'initialize:frame', => setTimeout(@initializeFrame,
|
75
|
+
Mercury.bind 'initialize:frame', => setTimeout(@initializeFrame, 1000)
|
75
76
|
Mercury.bind 'focus:frame', => @iframe.focus()
|
76
77
|
Mercury.bind 'focus:window', => setTimeout((=> @focusableElement.focus()), 10)
|
77
78
|
|
78
79
|
Mercury.bind 'action', (event, options) =>
|
79
|
-
|
80
|
+
@save() if options.action == 'save'
|
80
81
|
|
81
82
|
@document.mousedown (event) ->
|
82
83
|
Mercury.trigger('hide:dialogs')
|
83
|
-
Mercury.trigger('unfocus:regions') unless
|
84
|
+
Mercury.trigger('unfocus:regions') unless jQuery(event.target).closest('.mercury-region').get(0) == Mercury.region.element.get(0)
|
84
85
|
|
85
|
-
|
86
|
+
jQuery(window).resize => @resize()
|
86
87
|
window.onbeforeunload = @beforeUnload
|
87
88
|
|
88
89
|
|
89
90
|
resize: ->
|
90
|
-
width =
|
91
|
-
height =
|
91
|
+
width = jQuery(window).width()
|
92
|
+
height = @statusbar.top()
|
92
93
|
toolbarHeight = @toolbar.height()
|
93
|
-
statusbarHeight = @statusbar.height()
|
94
94
|
|
95
|
-
Mercury.displayRect = {top: toolbarHeight, left: 0, width: width, height: height -
|
95
|
+
Mercury.displayRect = {top: toolbarHeight, left: 0, width: width, height: height - toolbarHeight}
|
96
96
|
|
97
97
|
@iframe.css {
|
98
|
-
top: toolbarHeight
|
99
|
-
|
100
|
-
height: height -
|
98
|
+
top: toolbarHeight
|
99
|
+
left: 0
|
100
|
+
height: height - toolbarHeight
|
101
101
|
}
|
102
102
|
|
103
103
|
Mercury.trigger('resize')
|
104
104
|
|
105
105
|
|
106
106
|
iframeSrc: (url = null) ->
|
107
|
-
(url ? window.location.href).replace(/([http|https]:\/\/.[^\/]*)\/
|
107
|
+
(url ? window.location.href).replace(/([http|https]:\/\/.[^\/]*)\/editor\/?(.*)/i, "$1/$2")
|
108
108
|
|
109
109
|
|
110
110
|
hijackLinks: ->
|
111
|
-
for link in
|
111
|
+
for link in jQuery('a', @document)
|
112
112
|
ignored = false
|
113
113
|
for classname in @options.ignoredLinks || []
|
114
|
-
if
|
114
|
+
if jQuery(link).hasClass(classname)
|
115
115
|
ignored = true
|
116
116
|
continue
|
117
|
-
if !ignored && (link.target == '' || link.target == '_self') &&
|
118
|
-
|
117
|
+
if !ignored && (link.target == '' || link.target == '_self') && !jQuery(link).closest('.mercury-region').length
|
118
|
+
jQuery(link).attr('target', '_top')
|
119
119
|
|
120
120
|
|
121
121
|
beforeUnload: ->
|
@@ -128,8 +128,8 @@ class @Mercury.PageEditor
|
|
128
128
|
url = @saveUrl ? @iframeSrc()
|
129
129
|
data = @serialize()
|
130
130
|
Mercury.log('saving', data)
|
131
|
-
data =
|
132
|
-
|
131
|
+
data = jQuery.toJSON(data) unless @options.saveStyle == 'form'
|
132
|
+
jQuery.ajax url, {
|
133
133
|
type: 'POST'
|
134
134
|
data: {content: data}
|
135
135
|
success: =>
|
@@ -5,8 +5,8 @@ class @Mercury.Palette extends Mercury.Dialog
|
|
5
5
|
|
6
6
|
|
7
7
|
build: ->
|
8
|
-
@element =
|
9
|
-
@element.appendTo(
|
8
|
+
@element = jQuery('<div>', {class: "mercury-palette mercury-#{@name}-palette loading", style: 'display:none'})
|
9
|
+
@element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
|
10
10
|
|
11
11
|
|
12
12
|
bindEvents: ->
|
@@ -19,11 +19,11 @@ class @Mercury.Palette extends Mercury.Dialog
|
|
19
19
|
position = @button.offset()
|
20
20
|
width = @element.width()
|
21
21
|
|
22
|
-
position.left = position.left - width + @button.width() if position.left + width >
|
22
|
+
position.left = position.left - width + @button.width() if position.left + width > jQuery(window).width()
|
23
23
|
|
24
24
|
@element.css {
|
25
|
-
top: position.top + @button.height()
|
26
|
-
left: position.left
|
27
|
-
display: if keepVisible then 'block' else 'none'
|
25
|
+
top: position.top + @button.height()
|
26
|
+
left: position.left
|
27
|
+
display: if keepVisible then 'block' else 'none'
|
28
28
|
visibility: 'visible'
|
29
29
|
}
|
@@ -5,11 +5,11 @@ class @Mercury.Panel extends Mercury.Dialog
|
|
5
5
|
|
6
6
|
|
7
7
|
build: ->
|
8
|
-
@element =
|
9
|
-
@titleElement =
|
10
|
-
@paneElement =
|
8
|
+
@element = jQuery('<div>', {class: 'mercury-panel loading', style: 'display:none;'})
|
9
|
+
@titleElement = jQuery("<h1>#{@options.title}</h1>").appendTo(@element)
|
10
|
+
@paneElement = jQuery('<div>', {class: 'mercury-panel-pane'}).appendTo(@element)
|
11
11
|
|
12
|
-
@element.appendTo(
|
12
|
+
@element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
|
13
13
|
|
14
14
|
|
15
15
|
bindEvents: ->
|
@@ -36,7 +36,7 @@ class @Mercury.Region
|
|
36
36
|
@element.mousemove (event) =>
|
37
37
|
return if @previewing
|
38
38
|
return unless Mercury.region == @
|
39
|
-
snippet =
|
39
|
+
snippet = jQuery(event.target).closest('.mercury-snippet')
|
40
40
|
if snippet.length
|
41
41
|
@snippet = snippet
|
42
42
|
Mercury.trigger('show:toolbar', {type: 'snippet', snippet: @snippet})
|
@@ -46,17 +46,17 @@ class @Mercury.Region
|
|
46
46
|
Mercury.trigger('hide:toolbar', {type: 'snippet', immediately: false})
|
47
47
|
|
48
48
|
|
49
|
-
|
49
|
+
content: (value = null, filterSnippets = false) ->
|
50
50
|
if value != null
|
51
51
|
@element.html(value)
|
52
52
|
else
|
53
53
|
# sanitize the html before we return it
|
54
|
-
container =
|
54
|
+
container = jQuery('<div>').appendTo(@document.createDocumentFragment())
|
55
55
|
container.html(@element.html().replace(/^\s+|\s+$/g, ''))
|
56
56
|
|
57
57
|
# replace snippet contents to be an identifier
|
58
58
|
if filterSnippets then for snippet, index in container.find('.mercury-snippet')
|
59
|
-
snippet =
|
59
|
+
snippet = jQuery(snippet)
|
60
60
|
snippet.attr({contenteditable: null, 'data-version': null})
|
61
61
|
snippet.html("[#{snippet.data('snippet')}]")
|
62
62
|
|
@@ -83,21 +83,21 @@ class @Mercury.Region
|
|
83
83
|
|
84
84
|
|
85
85
|
pushHistory: ->
|
86
|
-
@history.push(@
|
86
|
+
@history.push(@content())
|
87
87
|
|
88
88
|
|
89
89
|
snippets: ->
|
90
90
|
snippets = {}
|
91
91
|
for element in @element.find('[data-snippet]')
|
92
|
-
snippet = Mercury.Snippet.find(
|
93
|
-
snippet.setVersion(
|
92
|
+
snippet = Mercury.Snippet.find(jQuery(element).data('snippet'))
|
93
|
+
snippet.setVersion(jQuery(element).data('version'))
|
94
94
|
snippets[snippet.identity] = snippet.serialize()
|
95
95
|
return snippets
|
96
96
|
|
97
97
|
|
98
98
|
serialize: ->
|
99
99
|
return {
|
100
|
-
type: @type
|
101
|
-
value: @
|
100
|
+
type: @type
|
101
|
+
value: @content(null, true)
|
102
102
|
snippets: @snippets()
|
103
103
|
}
|