mercury-rails 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/mercury/toolbar/primary/tools.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/user.png +0 -0
- data/app/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +1 -1
- data/app/assets/javascripts/mercury/lightview.js.coffee +11 -4
- data/app/assets/javascripts/mercury/locales/ar.locale.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/da.locale.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/de.locale.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/es.locale.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/example.local.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/fr.locale.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/hu.locale.js.coffee +209 -0
- data/app/assets/javascripts/mercury/locales/it.locale.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/ko.local.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/nl.locale.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/pt.locale.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/ru.locale.js.coffee +200 -0
- data/app/assets/javascripts/mercury/locales/sv.local.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +0 -4
- data/app/assets/javascripts/mercury/locales/zh.local.js.coffee +0 -4
- data/app/assets/javascripts/mercury/mercury-compiled.js +10720 -0
- data/app/assets/javascripts/mercury/mercury.js.coffee +1 -1
- data/app/assets/javascripts/mercury/modal.js.coffee +14 -7
- data/app/assets/javascripts/mercury/modals/htmleditor.js.coffee +1 -1
- data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +2 -0
- data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +10 -4
- data/app/assets/javascripts/mercury/page_editor.js.coffee +9 -9
- data/app/assets/javascripts/mercury/palette.js.coffee +1 -1
- data/app/assets/javascripts/mercury/panel.js.coffee +1 -0
- data/app/assets/javascripts/mercury/region.js.coffee +3 -3
- data/app/assets/javascripts/mercury/regions/{full.coffee → full.js.coffee} +2 -2
- data/app/assets/javascripts/mercury/regions/{markdown.coffee → markdown.js.coffee} +7 -1
- data/app/assets/javascripts/mercury/regions/snippets.js.coffee +1 -1
- data/app/assets/javascripts/mercury/select.js.coffee +1 -1
- data/app/assets/javascripts/mercury/snippet.js.coffee +40 -21
- data/app/assets/javascripts/mercury/toolbar.button.js.coffee +35 -20
- data/app/assets/javascripts/mercury/toolbar.expander.js.coffee +4 -3
- data/app/assets/javascripts/mercury/toolbar.js.coffee +6 -2
- data/app/assets/stylesheets/_mercury-bootstrap-overrides.scss +61 -0
- data/app/assets/stylesheets/_mercury-sass.scss +33 -0
- data/app/assets/stylesheets/mercury.css +1 -0
- data/app/assets/stylesheets/mercury/all_images.css.erb +4 -0
- data/app/assets/stylesheets/mercury/dialog.css +5 -2
- data/app/assets/stylesheets/mercury/mercury.css +0 -1
- data/app/assets/stylesheets/mercury/toolbar.css +3 -0
- data/app/assets/stylesheets/mercury/uploader.css +1 -1
- data/app/views/mercury/modals/media.html +10 -0
- data/app/views/mercury/panels/snippets.html +6 -1
- data/app/views/mercury/snippets/example/options.html.erb +1 -1
- data/app/views/mercury/snippets/no_options/preview.html.erb +1 -0
- data/features/loading/loading.feature +1 -1
- data/features/regions/full/basic_editing.feature +2 -2
- data/features/regions/full/inserting_media.feature +18 -0
- data/features/regions/full/inserting_snippets.feature +11 -0
- data/features/step_definitions/custom_web_steps.rb +22 -0
- data/features/step_definitions/mercury_steps.rb +1 -439
- data/features/support/selectors.rb +23 -0
- data/lib/generators/mercury/install/images/templates/ar_paperclip_image.rb +2 -0
- data/lib/mercury/cucumber/step_definitions.rb +13 -0
- data/lib/mercury/cucumber/step_definitions/mercury_steps.rb +408 -0
- data/{features → lib/mercury/cucumber}/support/mercury_contents.rb +1 -1
- data/{features → lib/mercury/cucumber}/support/mercury_selectors.rb +0 -20
- data/lib/mercury/rails.rb +1 -0
- data/lib/mercury/version.rb +1 -1
- data/spec/dummy/config/application.rb +4 -1
- data/spec/dummy/config/database.yml +10 -0
- data/spec/dummy/db/.gitkeep +0 -0
- data/spec/dummy/public/index.html +13 -2
- data/spec/javascripts/mercury/lightview_spec.js.coffee +33 -1
- data/spec/javascripts/mercury/modal_spec.js.coffee +35 -3
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +6 -2
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +10 -0
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +6 -5
- data/spec/javascripts/mercury/region_spec.js.coffee +4 -0
- data/spec/javascripts/mercury/snippet_spec.js.coffee +65 -21
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +22 -0
- data/spec/javascripts/templates/mercury/modals/insertmedia.html +10 -0
- metadata +26 -16
- data/spec/dummy/config/database.example.yml +0 -25
- data/spec/dummy/config/database.travisci.yml +0 -4
@@ -1,7 +1,7 @@
|
|
1
1
|
@Mercury.modal = (url, options = {}) ->
|
2
|
-
|
3
|
-
|
4
|
-
return
|
2
|
+
instance = new Mercury.Modal(url, options)
|
3
|
+
instance.show()
|
4
|
+
return instance
|
5
5
|
|
6
6
|
|
7
7
|
class @Mercury.Modal
|
@@ -13,6 +13,7 @@ class @Mercury.Modal
|
|
13
13
|
@url = url || @url
|
14
14
|
@options = options || @options
|
15
15
|
@options.minWidth ||= 400
|
16
|
+
@options.ujsHandling = true unless @options.ujsHandling == false
|
16
17
|
|
17
18
|
Mercury.trigger('focus:window')
|
18
19
|
@initializeModal()
|
@@ -54,9 +55,10 @@ class @Mercury.Modal
|
|
54
55
|
@titleElement.find('a').on 'click', =>
|
55
56
|
@hide()
|
56
57
|
|
57
|
-
@
|
58
|
-
|
59
|
-
|
58
|
+
if @options.ujsHandling
|
59
|
+
@element.on 'ajax:beforeSend', (event, xhr, options) =>
|
60
|
+
options.success = (content) =>
|
61
|
+
@loadContent(content)
|
60
62
|
|
61
63
|
jQuery(document).on 'keydown', (event) =>
|
62
64
|
@hide() if event.keyCode == 27 && @visible
|
@@ -187,6 +189,7 @@ class @Mercury.Modal
|
|
187
189
|
@initialize()
|
188
190
|
|
189
191
|
@element.localize(Mercury.locale()) if Mercury.config.localization.enabled
|
192
|
+
@element.find('.modal-close').on('click', @hide)
|
190
193
|
@resize()
|
191
194
|
|
192
195
|
|
@@ -196,12 +199,16 @@ class @Mercury.Modal
|
|
196
199
|
if @options.closeButton == false then closeButton.hide() else closeButton.show()
|
197
200
|
|
198
201
|
|
202
|
+
serializeForm: ->
|
203
|
+
return @element.find('form').serializeObject() || {}
|
204
|
+
|
205
|
+
|
199
206
|
reset: ->
|
200
207
|
@titleElement.find('span').html('')
|
201
208
|
@contentElement.html('')
|
202
209
|
|
203
210
|
|
204
|
-
hide:
|
211
|
+
hide: =>
|
205
212
|
return if @showing
|
206
213
|
@options = {}
|
207
214
|
|
@@ -7,6 +7,6 @@
|
|
7
7
|
# replace the contents on form submit
|
8
8
|
@element.find('form').on 'submit', (event) =>
|
9
9
|
event.preventDefault()
|
10
|
-
value = @element.find('textarea').val()
|
10
|
+
value = @element.find('textarea').val()
|
11
11
|
Mercury.trigger('action', {action: 'replaceHTML', value: value})
|
12
12
|
@hide()
|
@@ -27,6 +27,7 @@
|
|
27
27
|
if image = selection.is?('img')
|
28
28
|
@element.find('#media_image_url').val(image.attr('src'))
|
29
29
|
@element.find('#media_image_alignment').val(image.attr('align'))
|
30
|
+
@element.find('#media_image_float').val(if image.attr('style')? then image.css('float') else '')
|
30
31
|
@focus('#media_image_url')
|
31
32
|
|
32
33
|
# if we're editing an iframe (assume it's a video for now)
|
@@ -98,6 +99,7 @@
|
|
98
99
|
when 'image_url'
|
99
100
|
attrs = {src: @element.find('#media_image_url').val()}
|
100
101
|
attrs['align'] = alignment if alignment = @element.find('#media_image_alignment').val()
|
102
|
+
attrs['style'] = 'float: ' + float + ';' if float = @element.find('#media_image_float').val()
|
101
103
|
Mercury.trigger('action', {action: 'insertImage', value: attrs})
|
102
104
|
|
103
105
|
when 'youtube_url'
|
@@ -41,13 +41,19 @@
|
|
41
41
|
setTableAlignment: ->
|
42
42
|
@table.attr({align: @element.find('#table_alignment').val()})
|
43
43
|
|
44
|
-
|
45
44
|
setTableBorder: ->
|
46
|
-
|
47
|
-
|
45
|
+
border = parseInt(@element.find('#table_border').val(), 10)
|
46
|
+
if isNaN(border)
|
47
|
+
@table.removeAttr('border')
|
48
|
+
else
|
49
|
+
@table.attr({border: border})
|
48
50
|
|
49
51
|
setTableCellSpacing: ->
|
50
|
-
|
52
|
+
cellspacing = parseInt(@element.find('#table_spacing').val(), 10)
|
53
|
+
if isNaN(cellspacing)
|
54
|
+
@table.removeAttr('cellspacing')
|
55
|
+
else
|
56
|
+
@table.attr({cellspacing: cellspacing})
|
51
57
|
|
52
58
|
|
53
59
|
submitForm: ->
|
@@ -24,12 +24,12 @@ class @Mercury.PageEditor
|
|
24
24
|
@iframe = jQuery('<iframe>', {id: 'mercury_iframe', class: 'mercury-iframe', frameborder: '0', src: 'about:blank'})
|
25
25
|
@iframe.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
|
26
26
|
|
27
|
-
@toolbar = new Mercury.Toolbar(@options)
|
28
|
-
@statusbar = new Mercury.Statusbar(@options)
|
27
|
+
@toolbar = new Mercury.Toolbar(jQuery.extend(true, {}, @options, @options.toolbarOptions))
|
28
|
+
@statusbar = new Mercury.Statusbar(jQuery.extend(true, {}, @options, @options.statusbarOptions))
|
29
29
|
@resize()
|
30
30
|
|
31
|
-
@iframe.on 'load', => @initializeFrame()
|
32
31
|
@iframe.one 'load', => @bindEvents()
|
32
|
+
@iframe.on 'load', => @initializeFrame()
|
33
33
|
@loadIframeSrc(null)
|
34
34
|
|
35
35
|
|
@@ -93,7 +93,7 @@ class @Mercury.PageEditor
|
|
93
93
|
|
94
94
|
|
95
95
|
finalizeInterface: ->
|
96
|
-
@santizerElement = jQuery('<div>', {id: 'mercury_sanitizer', contenteditable: 'true', style: 'position:fixed;width:100px;height:100px;top:0;left:-100px;opacity:0;overflow:hidden'})
|
96
|
+
@santizerElement = jQuery('<div>', {id: 'mercury_sanitizer', contenteditable: 'true', style: 'position:fixed;width:100px;height:100px;min-width:0;top:0;left:-100px;opacity:0;overflow:hidden'})
|
97
97
|
@santizerElement.appendTo(@options.appendTo ? @document.find('body'))
|
98
98
|
|
99
99
|
@snippetToolbar.release() if @snippetToolbar
|
@@ -126,7 +126,7 @@ class @Mercury.PageEditor
|
|
126
126
|
Mercury.on 'action', (event, options) =>
|
127
127
|
action = Mercury.config.globalBehaviors[options.action] || @[options.action]
|
128
128
|
return unless typeof(action) == 'function'
|
129
|
-
|
129
|
+
event.preventDefault()
|
130
130
|
action.call(@, options)
|
131
131
|
|
132
132
|
jQuery(window).on 'resize', =>
|
@@ -161,7 +161,7 @@ class @Mercury.PageEditor
|
|
161
161
|
resize: ->
|
162
162
|
width = jQuery(window).width()
|
163
163
|
height = @statusbar.top()
|
164
|
-
toolbarHeight = @toolbar.height()
|
164
|
+
toolbarHeight = @toolbar.top() + @toolbar.height()
|
165
165
|
|
166
166
|
Mercury.displayRect = {top: toolbarHeight, left: 0, width: width, height: height - toolbarHeight, fullHeight: height}
|
167
167
|
|
@@ -178,7 +178,7 @@ class @Mercury.PageEditor
|
|
178
178
|
# remove the /editor segment of the url if it gets passed through
|
179
179
|
url = (url ? window.location.href).replace(Mercury.config.editorUrlRegEx ?= /([http|https]:\/\/.[^\/]*)\/editor\/?(.*)/i, "$1/$2")
|
180
180
|
url = url.replace(/[\?|\&]mercury_frame=true/gi, '')
|
181
|
-
url = url.replace(/\&_
|
181
|
+
url = url.replace(/\&_=\d+/gi, '')
|
182
182
|
if params
|
183
183
|
# add a param allowing the server to know that the request is coming from mercury
|
184
184
|
# and add a cache busting param so we don't get stale content
|
@@ -236,9 +236,9 @@ class @Mercury.PageEditor
|
|
236
236
|
type: method
|
237
237
|
dataType: @options.saveDataType
|
238
238
|
data: data
|
239
|
-
success: =>
|
239
|
+
success: (response) =>
|
240
240
|
Mercury.changes = false
|
241
|
-
Mercury.trigger('saved')
|
241
|
+
Mercury.trigger('saved', response)
|
242
242
|
callback() if typeof(callback) == 'function'
|
243
243
|
error: (response) =>
|
244
244
|
Mercury.trigger('save_failed', response)
|
@@ -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.position()
|
20
20
|
width = @element.width()
|
21
21
|
|
22
22
|
position.left = position.left - width + @button.width() if position.left + width > jQuery(window).width()
|
@@ -57,6 +57,7 @@ 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()
|
60
61
|
@makeDraggable()
|
61
62
|
|
62
63
|
@hide() unless @visible
|
@@ -28,7 +28,7 @@ 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 != @ || event.isDefaultPrevented()
|
32
32
|
@execCommand(options.action, options) if options.action
|
33
33
|
|
34
34
|
@element.on 'mousemove', (event) =>
|
@@ -76,7 +76,7 @@ class @Mercury.Region
|
|
76
76
|
@pushHistory() unless action == 'redo'
|
77
77
|
|
78
78
|
Mercury.log('execCommand', action, options.value)
|
79
|
-
Mercury.changes = true
|
79
|
+
Mercury.changes = true
|
80
80
|
|
81
81
|
|
82
82
|
pushHistory: ->
|
@@ -94,7 +94,7 @@ class @Mercury.Region
|
|
94
94
|
|
95
95
|
dataAttributes: ->
|
96
96
|
data = {}
|
97
|
-
data[attr] = @element.attr('data-' + attr) for attr in Mercury.config.regions.dataAttributes
|
97
|
+
data[attr] = (@container || @element).attr('data-' + attr) for attr in Mercury.config.regions.dataAttributes
|
98
98
|
return data
|
99
99
|
|
100
100
|
|
@@ -94,7 +94,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
94
94
|
return if @previewing
|
95
95
|
if snippetPlaceHolder = @element.find('img[data-snippet]').get(0)
|
96
96
|
@focus()
|
97
|
-
Mercury.Snippet.displayOptionsFor(jQuery(snippetPlaceHolder).data('snippet'))
|
97
|
+
Mercury.Snippet.displayOptionsFor(jQuery(snippetPlaceHolder).data('snippet'), {}, jQuery(snippetPlaceHolder).data('options'))
|
98
98
|
@document.execCommand('undo', false, null)
|
99
99
|
|
100
100
|
# custom paste handling: we have to do some hackery to get the pasted content since it's not exposed normally
|
@@ -425,7 +425,7 @@ class @Mercury.Regions.Full extends Mercury.Region
|
|
425
425
|
|
426
426
|
redo: -> @content(@history.redo())
|
427
427
|
|
428
|
-
horizontalRule: ->
|
428
|
+
horizontalRule: -> @execCommand('insertHTML', {value: '<hr/>'})
|
429
429
|
|
430
430
|
removeFormatting: (selection) -> selection.insertTextNode(selection.textContent())
|
431
431
|
|
@@ -34,6 +34,12 @@ class @Mercury.Regions.Markdown extends Mercury.Region
|
|
34
34
|
@resize()
|
35
35
|
|
36
36
|
|
37
|
+
dataAttributes: ->
|
38
|
+
data = {}
|
39
|
+
data[attr] = @container.attr('data-' + attr) for attr in Mercury.config.regions.dataAttributes
|
40
|
+
return data
|
41
|
+
|
42
|
+
|
37
43
|
bindEvents: ->
|
38
44
|
Mercury.on 'mode', (event, options) => @togglePreview() if options.mode == 'preview'
|
39
45
|
Mercury.on 'focus:frame', => @focus() if !@previewing && Mercury.region == @
|
@@ -65,7 +71,7 @@ class @Mercury.Regions.Markdown extends Mercury.Region
|
|
65
71
|
if Mercury.snippet
|
66
72
|
event.preventDefault()
|
67
73
|
@focus()
|
68
|
-
Mercury.Snippet.displayOptionsFor(Mercury.snippet)
|
74
|
+
Mercury.Snippet.displayOptionsFor(Mercury.snippet.name, {}, Mercury.snippet.hasOptions)
|
69
75
|
|
70
76
|
# handle any files that were dropped
|
71
77
|
if event.originalEvent.dataTransfer.files.length
|
@@ -46,7 +46,7 @@ class @Mercury.Regions.Snippets extends Mercury.Region
|
|
46
46
|
return if @previewing || ! Mercury.snippet
|
47
47
|
@focus()
|
48
48
|
event.preventDefault()
|
49
|
-
Mercury.Snippet.displayOptionsFor(Mercury.snippet)
|
49
|
+
Mercury.Snippet.displayOptionsFor(Mercury.snippet.name, {}, Mercury.snippet.hasOptions)
|
50
50
|
|
51
51
|
jQuery(@document).on 'keydown', (event) =>
|
52
52
|
return if @previewing || Mercury.region != @
|
@@ -20,7 +20,7 @@ class @Mercury.Select extends Mercury.Dialog
|
|
20
20
|
|
21
21
|
position: (keepVisible) ->
|
22
22
|
@element.css({top: 0, left: 0, display: 'block', visibility: 'hidden'})
|
23
|
-
position = @button.
|
23
|
+
position = @button.position()
|
24
24
|
elementWidth = @element.width()
|
25
25
|
elementHeight = @element.height()
|
26
26
|
documentHeight = jQuery(document).height()
|
@@ -2,27 +2,47 @@ class @Mercury.Snippet
|
|
2
2
|
|
3
3
|
@all: []
|
4
4
|
|
5
|
-
@displayOptionsFor: (name, options = {}) ->
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
@displayOptionsFor: (name, options = {}, displayOptions = true) ->
|
6
|
+
if displayOptions
|
7
|
+
Mercury.modal @optionsUrl(name), jQuery.extend({
|
8
|
+
title: 'Snippet Options'
|
9
|
+
handler: 'insertSnippet'
|
10
|
+
snippetName: name
|
11
|
+
loadType: Mercury.config.snippets.method
|
12
|
+
}, options)
|
13
|
+
else
|
14
|
+
snippet = Mercury.Snippet.create(name)
|
15
|
+
Mercury.trigger('action', {action: 'insertSnippet', value: snippet})
|
11
16
|
Mercury.snippet = null
|
12
17
|
|
13
18
|
|
14
|
-
@
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
else
|
20
|
-
identity = "snippet_#{@all.length}"
|
19
|
+
@optionsUrl: (name) ->
|
20
|
+
url = Mercury.config.snippets.optionsUrl
|
21
|
+
url = url() if typeof(url) == 'function'
|
22
|
+
return url.replace(':name', name)
|
23
|
+
|
21
24
|
|
22
|
-
|
25
|
+
@previewUrl: (name) ->
|
26
|
+
url = Mercury.config.snippets.previewUrl
|
27
|
+
url = url() if typeof(url) == 'function'
|
28
|
+
return url.replace(':name', name)
|
29
|
+
|
30
|
+
|
31
|
+
@create: (name, options) ->
|
32
|
+
instance = new Mercury.Snippet(name, @uniqueId(), options)
|
23
33
|
@all.push(instance)
|
24
34
|
return instance
|
25
35
|
|
36
|
+
@uniqueId: ->
|
37
|
+
[i, identity] = [0, "snippet_0"]
|
38
|
+
identities = (snippet.identity for snippet in @all)
|
39
|
+
|
40
|
+
while identities.indexOf(identity) isnt -1
|
41
|
+
i += 1
|
42
|
+
identity = "snippet_#{i}"
|
43
|
+
|
44
|
+
return identity
|
45
|
+
|
26
46
|
|
27
47
|
@find: (identity) ->
|
28
48
|
for snippet in @all
|
@@ -32,7 +52,7 @@ class @Mercury.Snippet
|
|
32
52
|
|
33
53
|
@load: (snippets) ->
|
34
54
|
for own identity, details of snippets
|
35
|
-
instance = new Mercury.Snippet(details.name, identity, details
|
55
|
+
instance = new Mercury.Snippet(details.name, identity, details)
|
36
56
|
@all.push(instance)
|
37
57
|
|
38
58
|
|
@@ -66,7 +86,7 @@ class @Mercury.Snippet
|
|
66
86
|
|
67
87
|
|
68
88
|
loadPreview: (element, callback = null) ->
|
69
|
-
jQuery.ajax
|
89
|
+
jQuery.ajax Snippet.previewUrl(@name), {
|
70
90
|
headers: Mercury.ajaxHeaders()
|
71
91
|
type: Mercury.config.snippets.method
|
72
92
|
data: @options
|
@@ -81,7 +101,7 @@ class @Mercury.Snippet
|
|
81
101
|
|
82
102
|
displayOptions: ->
|
83
103
|
Mercury.snippet = @
|
84
|
-
Mercury.modal
|
104
|
+
Mercury.modal Snippet.optionsUrl(@name), {
|
85
105
|
title: 'Snippet Options',
|
86
106
|
handler: 'insertSnippet',
|
87
107
|
loadType: Mercury.config.snippets.method,
|
@@ -107,7 +127,6 @@ class @Mercury.Snippet
|
|
107
127
|
|
108
128
|
|
109
129
|
serialize: ->
|
110
|
-
return {
|
111
|
-
|
112
|
-
|
113
|
-
}
|
130
|
+
return $.extend({name: @name}, @options )
|
131
|
+
|
132
|
+
|
@@ -89,32 +89,47 @@ class @Mercury.Toolbar.Button
|
|
89
89
|
|
90
90
|
@element.on 'click', (event) =>
|
91
91
|
if @element.closest('.disabled').length then return
|
92
|
+
@handleClick(event)
|
92
93
|
|
93
|
-
handled = false
|
94
|
-
for own type, mixed of @handled
|
95
|
-
switch type
|
96
|
-
when 'toggle'
|
97
|
-
@togglePressed() unless @handled.mode
|
98
94
|
|
99
|
-
|
100
|
-
|
101
|
-
|
95
|
+
handleClick: (event) ->
|
96
|
+
handled = false
|
97
|
+
for own type, mixed of @handled
|
98
|
+
switch type
|
99
|
+
when 'toggle'
|
100
|
+
@togglePressed() unless @handled.mode
|
101
|
+
|
102
|
+
when 'mode'
|
103
|
+
handled = true
|
104
|
+
Mercury.trigger('mode', {mode: mixed})
|
105
|
+
|
106
|
+
when 'modal'
|
107
|
+
handled = @handleModal(event)
|
108
|
+
|
109
|
+
when 'lightview'
|
110
|
+
handled = @handleLightview(event)
|
111
|
+
|
112
|
+
when 'palette', 'select', 'panel'
|
113
|
+
handled = @handleDialog(event, type)
|
114
|
+
|
115
|
+
Mercury.trigger('action', {action: @name}) unless handled
|
116
|
+
Mercury.trigger('focus:frame') if @options['regions'] && @options['regions'].length
|
117
|
+
|
118
|
+
|
119
|
+
handleModal: (event) ->
|
120
|
+
Mercury.modal(@handled.modal, {title: @summary || @title, handler: @name})
|
121
|
+
return true
|
102
122
|
|
103
|
-
when 'modal'
|
104
|
-
handled = true
|
105
|
-
Mercury.modal(@handled.modal, {title: @summary || @title, handler: @name})
|
106
123
|
|
107
|
-
|
108
|
-
|
109
|
-
|
124
|
+
handleLightview: (event) ->
|
125
|
+
Mercury.lightview(@handled.lightview, {title: @summary || @title, handler: @name, closeButton: true})
|
126
|
+
return true
|
110
127
|
|
111
|
-
when 'palette', 'select', 'panel'
|
112
|
-
event.stopPropagation()
|
113
|
-
handled = true
|
114
|
-
@handled[type].toggle()
|
115
128
|
|
116
|
-
|
117
|
-
|
129
|
+
handleDialog: (event, type) ->
|
130
|
+
event.stopPropagation()
|
131
|
+
@handled[type].toggle()
|
132
|
+
return true
|
118
133
|
|
119
134
|
|
120
135
|
defaultDialogOptions: ->
|