mercury-rails 0.2.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. data/app/controllers/{images_controller.rb → mercury/images_controller.rb} +3 -3
  2. data/app/controllers/mercury_controller.rb +13 -3
  3. data/app/models/{image.rb → mercury/image.rb} +3 -1
  4. data/app/views/layouts/mercury.html.erb +14 -6
  5. data/app/views/mercury/lightviews/about.html +7 -3
  6. data/app/views/mercury/modals/character.html +2 -2
  7. data/app/views/mercury/modals/htmleditor.html +2 -2
  8. data/app/views/mercury/modals/link.html +3 -3
  9. data/app/views/mercury/modals/media.html +3 -3
  10. data/app/views/mercury/modals/table.html +3 -3
  11. data/app/views/mercury/panels/snippets.html +1 -1
  12. data/app/views/mercury/selects/formatblock.html +9 -9
  13. data/app/views/mercury/snippets/example/options.html.erb +27 -16
  14. data/config/engine.rb +35 -0
  15. data/db/migrate/{20110526035601_create_images.rb → 20110526035601_create_mercury_images.rb} +2 -2
  16. data/features/loading/loading.feature +1 -1
  17. data/features/loading/navigating.feature +1 -1
  18. data/features/loading/user_interface.feature +2 -2
  19. data/features/regions/editable/basic_editing.feature +8 -8
  20. data/features/regions/editable/inserting_snippets.feature +4 -5
  21. data/features/regions/editable/inserting_tables.feature +9 -9
  22. data/features/step_definitions/mercury_steps.rb +20 -23
  23. data/features/step_definitions/web_steps.rb +5 -5
  24. data/features/support/mercury_selectors.rb +1 -0
  25. data/lib/generators/mercury/install/install_generator.rb +24 -3
  26. data/lib/generators/mercury/install/templates/mongoid_paperclip_image.rb +17 -0
  27. data/lib/mercury-rails.rb +0 -1
  28. data/lib/mercury/authentication.rb +8 -0
  29. data/spec/javascripts/mercury/dialog_spec.js.coffee +28 -21
  30. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +0 -2
  31. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +0 -2
  32. data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +0 -2
  33. data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +0 -2
  34. data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +0 -2
  35. data/spec/javascripts/mercury/history_buffer_spec.js.coffee +0 -2
  36. data/spec/javascripts/mercury/lightview_spec.js.coffee +42 -21
  37. data/spec/javascripts/mercury/mercury_spec.js.coffee +87 -7
  38. data/spec/javascripts/mercury/modal_spec.js.coffee +53 -23
  39. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +0 -2
  40. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +2 -3
  41. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +0 -2
  42. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +2 -2
  43. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +0 -2
  44. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +2 -4
  45. data/spec/javascripts/mercury/native_extensions_spec.js.coffee +20 -2
  46. data/spec/javascripts/mercury/page_editor_spec.js.coffee +130 -35
  47. data/spec/javascripts/mercury/palette_spec.js.coffee +4 -6
  48. data/spec/javascripts/mercury/panel_spec.js.coffee +44 -6
  49. data/spec/javascripts/mercury/region_spec.js.coffee +42 -8
  50. data/spec/javascripts/mercury/regions/editable_spec.js.coffee +0 -2
  51. data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +0 -2
  52. data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +3 -5
  53. data/spec/javascripts/mercury/select_spec.js.coffee +4 -6
  54. data/spec/javascripts/mercury/snippet_spec.js.coffee +3 -4
  55. data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +2 -4
  56. data/spec/javascripts/mercury/statusbar_spec.js.coffee +0 -2
  57. data/spec/javascripts/mercury/table_editor_spec.js.coffee +2 -4
  58. data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +0 -2
  59. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +34 -15
  60. data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +0 -2
  61. data/spec/javascripts/mercury/toolbar_spec.js.coffee +41 -26
  62. data/spec/javascripts/mercury/tooltip_spec.js.coffee +3 -5
  63. data/spec/javascripts/mercury/uploader_spec.js.coffee +8 -14
  64. data/spec/javascripts/spec_helper.js +1 -0
  65. data/spec/javascripts/templates/mercury/page_editor.html +1 -0
  66. data/spec/javascripts/templates/mercury/region.html +2 -2
  67. data/vendor/assets/images/mercury/missing-image.png +0 -0
  68. data/vendor/assets/javascripts/mercury.js +218 -112
  69. data/vendor/assets/javascripts/mercury/dependencies/{jquery-1.6.js → jquery-1.7.js} +2030 -1595
  70. data/vendor/assets/javascripts/mercury/dependencies/jquery.additions.js +55 -0
  71. data/vendor/assets/javascripts/mercury/dialog.js.coffee +7 -5
  72. data/vendor/assets/javascripts/mercury/dialogs/backcolor.js.coffee +1 -1
  73. data/vendor/assets/javascripts/mercury/dialogs/forecolor.js.coffee +1 -1
  74. data/vendor/assets/javascripts/mercury/dialogs/formatblock.js.coffee +1 -1
  75. data/vendor/assets/javascripts/mercury/dialogs/{objectspanel.js.coffee → snippetpanel.js.coffee} +2 -2
  76. data/vendor/assets/javascripts/mercury/dialogs/style.js.coffee +1 -1
  77. data/vendor/assets/javascripts/mercury/finalize.js.coffee +3 -0
  78. data/vendor/assets/javascripts/mercury/lightview.js.coffee +76 -30
  79. data/vendor/assets/javascripts/mercury/locales/da.locale.js.coffee +211 -0
  80. data/vendor/assets/javascripts/mercury/locales/de.locale.js.coffee +206 -0
  81. data/vendor/assets/javascripts/mercury/locales/es.locale.js.coffee +211 -0
  82. data/vendor/assets/javascripts/mercury/locales/example.local.js.coffee +211 -0
  83. data/vendor/assets/javascripts/mercury/locales/fr.locale.js.coffee +211 -0
  84. data/vendor/assets/javascripts/mercury/locales/it.locale.js.coffee +208 -0
  85. data/vendor/assets/javascripts/mercury/locales/ko.local.js.coffee +206 -0
  86. data/vendor/assets/javascripts/mercury/locales/nl.locale.js.coffee +206 -0
  87. data/vendor/assets/javascripts/mercury/locales/pt.locale.js.coffee +211 -0
  88. data/vendor/assets/javascripts/mercury/locales/sv.local.js.coffee +209 -0
  89. data/vendor/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +213 -0
  90. data/vendor/assets/javascripts/mercury/mercury.js.coffee +62 -17
  91. data/vendor/assets/javascripts/mercury/modal.js.coffee +34 -21
  92. data/vendor/assets/javascripts/mercury/modals/htmleditor.js.coffee +1 -2
  93. data/vendor/assets/javascripts/mercury/modals/insertcharacter.js.coffee +3 -3
  94. data/vendor/assets/javascripts/mercury/modals/insertlink.js.coffee +4 -4
  95. data/vendor/assets/javascripts/mercury/modals/insertmedia.js.coffee +10 -9
  96. data/vendor/assets/javascripts/mercury/modals/insertsnippet.js.coffee +1 -1
  97. data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +8 -9
  98. data/vendor/assets/javascripts/mercury/native_extensions.js.coffee +26 -8
  99. data/vendor/assets/javascripts/mercury/page_editor.js.coffee +68 -46
  100. data/vendor/assets/javascripts/mercury/palette.js.coffee +1 -1
  101. data/vendor/assets/javascripts/mercury/panel.js.coffee +25 -7
  102. data/vendor/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +1 -0
  103. data/vendor/assets/javascripts/mercury/region.js.coffee +21 -17
  104. data/vendor/assets/javascripts/mercury/regions/editable.js.coffee +47 -35
  105. data/vendor/assets/javascripts/mercury/regions/markupable.js.coffee +43 -36
  106. data/vendor/assets/javascripts/mercury/regions/snippetable.js.coffee +22 -24
  107. data/vendor/assets/javascripts/mercury/select.js.coffee +3 -2
  108. data/vendor/assets/javascripts/mercury/snippet.js.coffee +2 -1
  109. data/vendor/assets/javascripts/mercury/snippet_toolbar.js.coffee +10 -7
  110. data/vendor/assets/javascripts/mercury/statusbar.js.coffee +4 -4
  111. data/vendor/assets/javascripts/mercury/table_editor.js.coffee +1 -3
  112. data/vendor/assets/javascripts/mercury/toolbar.button.js.coffee +42 -20
  113. data/vendor/assets/javascripts/mercury/toolbar.button_group.js.coffee +3 -3
  114. data/vendor/assets/javascripts/mercury/toolbar.expander.js.coffee +2 -2
  115. data/vendor/assets/javascripts/mercury/toolbar.js.coffee +8 -6
  116. data/vendor/assets/javascripts/mercury/tooltip.js.coffee +13 -9
  117. data/vendor/assets/javascripts/mercury/uploader.js.coffee +22 -16
  118. data/vendor/assets/javascripts/mercury_loader.js +2 -0
  119. data/vendor/assets/javascripts/mercury_overrides.js +6 -0
  120. data/vendor/assets/stylesheets/mercury/all_images.css.erb +89 -0
  121. data/vendor/assets/stylesheets/mercury/dialog.css +13 -4
  122. data/vendor/assets/stylesheets/mercury/lightview.css +66 -15
  123. data/vendor/assets/stylesheets/mercury/mercury.css +12 -7
  124. data/vendor/assets/stylesheets/mercury/modal.css +9 -5
  125. data/vendor/assets/stylesheets/mercury/toolbar.css +3 -29
  126. metadata +266 -144
  127. data/POST_INSTALL +0 -15
  128. data/README.md +0 -299
  129. data/VERSION +0 -1
  130. data/annotated_source.template +0 -57
  131. data/config/routes.rb +0 -15
  132. data/mercury-rails.gemspec +0 -288
  133. data/spec/javascripts/responses/blank.html +0 -1
  134. data/vendor/assets/javascripts/mercury/lightviews/imageprocessor.js.coffee +0 -2
@@ -1,4 +1,7 @@
1
1
  class @Mercury.Regions.Snippetable extends Mercury.Region
2
+ @supported: document.getElementById
3
+ @supportedText: "IE 7+, Chrome 10+, Firefox 4+, Safari 5+, Opera 8+"
4
+
2
5
  type = 'snippetable'
3
6
 
4
7
  constructor: (@element, @window, @options = {}) ->
@@ -14,52 +17,48 @@ class @Mercury.Regions.Snippetable extends Mercury.Region
14
17
  bindEvents: ->
15
18
  super
16
19
 
17
- Mercury.bind 'unfocus:regions', (event) =>
20
+ Mercury.on 'unfocus:regions', (event) =>
18
21
  return if @previewing
19
22
  if Mercury.region == @
20
23
  @element.removeClass('focus')
21
24
  @element.sortable('destroy')
22
25
  Mercury.trigger('region:blurred', {region: @})
23
26
 
24
- Mercury.bind 'focus:window', (event) =>
27
+ Mercury.on 'focus:window', (event) =>
25
28
  return if @previewing
26
29
  if Mercury.region == @
27
30
  @element.removeClass('focus')
28
31
  @element.sortable('destroy')
29
32
  Mercury.trigger('region:blurred', {region: @})
30
33
 
31
- jQuery(@document).keydown (event) =>
32
- return if @previewing
33
- return unless Mercury.region == @
34
- Mercury.changes = true
35
- switch event.keyCode
36
- when 90 # undo / redo
37
- return unless event.metaKey
38
- event.preventDefault()
39
- if event.shiftKey
40
- @execCommand('redo')
41
- else
42
- @execCommand('undo')
43
-
44
- return
45
-
46
- @element.mouseup =>
34
+ @element.on 'mouseup', =>
47
35
  return if @previewing
48
36
  @focus()
49
37
  Mercury.trigger('region:focused', {region: @})
50
38
 
51
- @element.bind 'dragover', (event) =>
39
+ @element.on 'dragover', (event) =>
52
40
  return if @previewing
53
41
  event.preventDefault()
54
42
  event.originalEvent.dataTransfer.dropEffect = 'copy'
55
43
 
56
- @element.bind 'drop', (event) =>
57
- return if @previewing
58
- return unless Mercury.snippet
44
+ @element.on 'drop', (event) =>
45
+ return if @previewing || ! Mercury.snippet
59
46
  @focus()
60
47
  event.preventDefault()
61
48
  Mercury.Snippet.displayOptionsFor(Mercury.snippet)
62
49
 
50
+ jQuery(@document).on 'keydown', (event) =>
51
+ return if @previewing || Mercury.region != @
52
+ switch event.keyCode
53
+ when 90 # undo / redo
54
+ return unless event.metaKey
55
+ event.preventDefault()
56
+ if event.shiftKey then @execCommand('redo') else @execCommand('undo')
57
+
58
+ jQuery(@document).on 'keyup', =>
59
+ return if @previewing || Mercury.region != @
60
+ Mercury.changes = true
61
+
63
62
 
64
63
  focus: ->
65
64
  Mercury.region = @
@@ -78,7 +77,6 @@ class @Mercury.Regions.Snippetable extends Mercury.Region
78
77
 
79
78
  execCommand: (action, options = {}) ->
80
79
  super
81
-
82
80
  handler.call(@, options) if handler = Mercury.Regions.Snippetable.actions[action]
83
81
 
84
82
 
@@ -95,7 +93,7 @@ class @Mercury.Regions.Snippetable extends Mercury.Region
95
93
  Mercury.trigger('hide:toolbar', {type: 'snippet', immediately: true})
96
94
  return true
97
95
  stop: =>
98
- setTimeout((=> @pushHistory()), 100)
96
+ setTimeout(100, => @pushHistory())
99
97
  return true
100
98
  }
101
99
 
@@ -10,9 +10,10 @@ class @Mercury.Select extends Mercury.Dialog
10
10
 
11
11
 
12
12
  bindEvents: ->
13
- Mercury.bind 'hide:dialogs', (event, dialog) => @hide() unless dialog == @
13
+ Mercury.on 'hide:dialogs', (event, dialog) => @hide() unless dialog == @
14
14
 
15
- @element.mousedown (event) => event.preventDefault()
15
+ @element.on 'mousedown', (event) =>
16
+ event.preventDefault()
16
17
 
17
18
  super
18
19
 
@@ -52,6 +52,7 @@ class @Mercury.Snippet
52
52
 
53
53
  loadPreview: (element, callback = null) ->
54
54
  jQuery.ajax Mercury.config.snippets.previewUrl.replace(':name', @name), {
55
+ headers: Mercury.ajaxHeaders()
55
56
  type: Mercury.config.snippets.method
56
57
  data: @options
57
58
  success: (data) =>
@@ -59,7 +60,7 @@ class @Mercury.Snippet
59
60
  element.html(data)
60
61
  callback() if callback
61
62
  error: =>
62
- alert("Error loading the preview for the #{@name} snippet.")
63
+ Mercury.notify('Error loading the preview for the \"%s\" snippet.', @name)
63
64
  }
64
65
 
65
66
 
@@ -14,19 +14,23 @@ class @Mercury.SnippetToolbar extends Mercury.Toolbar
14
14
 
15
15
 
16
16
  bindEvents: ->
17
- Mercury.bind 'show:toolbar', (event, options) =>
17
+ Mercury.on 'show:toolbar', (event, options) =>
18
18
  return unless options.snippet
19
19
  options.snippet.mouseout => @hide()
20
20
  @show(options.snippet)
21
21
 
22
- Mercury.bind 'hide:toolbar', (event, options) =>
22
+ Mercury.on 'hide:toolbar', (event, options) =>
23
23
  return unless options.type && options.type == 'snippet'
24
24
  @hide(options.immediately)
25
25
 
26
- jQuery(@document).scroll => @position() if @visible
26
+ @element.mousemove =>
27
+ clearTimeout(@hideTimeout)
27
28
 
28
- @element.mousemove => clearTimeout(@hideTimeout)
29
- @element.mouseout => @hide()
29
+ @element.mouseout =>
30
+ @hide()
31
+
32
+ jQuery(@document).on 'scroll', =>
33
+ @position() if @visible
30
34
 
31
35
 
32
36
  show: (@snippet) ->
@@ -61,9 +65,8 @@ class @Mercury.SnippetToolbar extends Mercury.Toolbar
61
65
  @element.hide()
62
66
  @visible = false
63
67
  else
64
- @hideTimeout = setTimeout((=>
68
+ @hideTimeout = setTimeout 500, =>
65
69
  @element.stop().animate {opacity: 0}, 300, 'easeInOutSine', =>
66
70
  @element.hide()
67
71
  @visible = false
68
- ), 500)
69
72
 
@@ -16,11 +16,11 @@ class @Mercury.Statusbar
16
16
 
17
17
 
18
18
  bindEvents: ->
19
- Mercury.bind 'region:update', (event, options) =>
19
+ Mercury.on 'region:update', (event, options) =>
20
20
  @setPath(options.region.path()) if options.region && jQuery.type(options.region.path) == 'function'
21
21
 
22
- @aboutElement.click =>
23
- Mercury.lightview('/mercury/lightviews/about.html', {title: "About Mercury Editor v#{Mercury.version}"})
22
+ @aboutElement.on 'click', =>
23
+ Mercury.lightview('/mercury/lightviews/about.html', {title: "Mercury Editor v#{Mercury.version}"})
24
24
 
25
25
 
26
26
  height: ->
@@ -37,7 +37,7 @@ class @Mercury.Statusbar
37
37
  path = []
38
38
  path.push("<a>#{element.tagName.toLowerCase()}</a>") for element in elements
39
39
 
40
- @pathElement.html("<span><strong>Path: </strong>#{path.reverse().join(' &raquo; ')}</span>")
40
+ @pathElement.html("<span><strong>#{Mercury.I18n('Path:')} </strong>#{path.reverse().join(' &raquo; ')}</span>")
41
41
 
42
42
 
43
43
  show: ->
@@ -2,7 +2,7 @@
2
2
  Mercury.tableEditor.load(table, cell, cellContent)
3
3
  return Mercury.tableEditor
4
4
 
5
- jQuery.extend Mercury.tableEditor, {
5
+ jQuery.extend Mercury.tableEditor,
6
6
 
7
7
  load: (@table, @cell, @cellContent = '') ->
8
8
  @row = @cell.parent('tr')
@@ -263,5 +263,3 @@ jQuery.extend Mercury.tableEditor, {
263
263
  # Sets the rowspan of a cell, removing it if it's 1
264
264
  setRowspanFor: (cell, value) ->
265
265
  jQuery(cell).attr('rowspan', if value > 1 then value else null)
266
-
267
- }
@@ -1,6 +1,9 @@
1
1
  class @Mercury.Toolbar.Button
2
2
 
3
3
  constructor: (@name, @title, @summary = null, @types = {}, @options = {}) ->
4
+ @title = Mercury.I18n(@title) if @title
5
+ @summary = Mercury.I18n(@summary) if @summary
6
+
4
7
  @build()
5
8
  @bindEvents()
6
9
  return @element
@@ -10,8 +13,8 @@ class @Mercury.Toolbar.Button
10
13
  @element = jQuery('<div>', {title: @summary ? @title, class: "mercury-button mercury-#{@name}-button"}).html("<em>#{@title}</em>")
11
14
  @element.data('expander', "<div class=\"mercury-expander-button\" data-button=\"#{@name}\"><em></em><span>#{@title}</span></div>")
12
15
 
13
- @handled = []
14
- dialogOptions = {title: @summary || @title, preload: @types.preload, appendTo: @options.appendDialogsTo || 'body', for: @element}
16
+ @handled = {}
17
+
15
18
  for own type, mixed of @types
16
19
  switch type
17
20
  when 'preload' then true
@@ -32,30 +35,33 @@ class @Mercury.Toolbar.Button
32
35
  when 'palette'
33
36
  @element.addClass("mercury-button-palette")
34
37
  url = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
35
- @handled[type] = new Mercury.Palette(url, @name, dialogOptions)
38
+ @handled[type] = new Mercury.Palette(url, @name, @defaultDialogOptions())
36
39
 
37
40
  when 'select'
38
41
  @element.addClass("mercury-button-select").find('em').html(@title)
39
42
  url = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
40
- @handled[type] = new Mercury.Select(url, @name, dialogOptions)
43
+ @handled[type] = new Mercury.Select(url, @name, @defaultDialogOptions())
41
44
 
42
45
  when 'panel'
43
46
  @element.addClass('mercury-button-panel')
44
47
  url = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
45
48
  @handled['toggle'] = true
46
- @handled[type] = new Mercury.Panel(url, @name, dialogOptions)
49
+ @handled[type] = new Mercury.Panel(url, @name, @defaultDialogOptions())
47
50
 
48
51
  when 'modal'
49
52
  @handled[type] = if jQuery.isFunction(mixed) then mixed.apply(@, @name) else mixed
50
53
 
51
- else throw "Unknown button type #{type} used for the #{@name} button."
54
+ when 'lightview'
55
+ @handled[type] = if jQuery.isFunction(mixed) then mixed.apply(@, @name) else mixed
56
+
57
+ else throw Mercury.I18n('Unknown button type \"%s\" used for the \"%s\" button.', type, @name)
52
58
 
53
59
 
54
60
  bindEvents: ->
55
- Mercury.bind 'button', (event, options) =>
56
- @element.click() if options.action == @name
61
+ Mercury.on 'button', (event, options) => @element.click() if options.action == @name
62
+ Mercury.on 'mode', (event, options) => @togglePressed() if @handled.mode == options.mode && @handled.toggle
57
63
 
58
- Mercury.bind 'region:update', (event, options) =>
64
+ Mercury.on 'region:update', (event, options) =>
59
65
  if @handled.context && options.region && jQuery.type(options.region.currentElement) == 'function'
60
66
  element = options.region.currentElement()
61
67
  if element.length && @handled.context.call(@, element, options.region.element)
@@ -65,30 +71,30 @@ class @Mercury.Toolbar.Button
65
71
  else
66
72
  @element.removeClass('active')
67
73
 
68
- Mercury.bind 'region:focused', (event, options) =>
74
+ Mercury.on 'region:focused', (event, options) =>
69
75
  if @handled.regions && options.region && options.region.type
70
76
  if @handled.regions.indexOf(options.region.type) > -1
71
77
  @element.removeClass('disabled')
72
78
  else
73
79
  @element.addClass('disabled')
74
80
 
75
- Mercury.bind 'region:blurred', (event, options) =>
81
+ Mercury.on 'region:blurred', =>
76
82
  @element.addClass('disabled') if @handled.regions
77
83
 
78
- @element.mousedown (event) =>
84
+ @element.on 'mousedown', =>
79
85
  @element.addClass('active')
80
86
 
81
- @element.mouseup (event) =>
87
+ @element.on 'mouseup', =>
82
88
  @element.removeClass('active')
83
89
 
84
- @element.click (event) =>
90
+ @element.on 'click', (event) =>
85
91
  if @element.closest('.disabled').length then return
86
92
 
87
93
  handled = false
88
94
  for own type, mixed of @handled
89
95
  switch type
90
96
  when 'toggle'
91
- @togglePressed()
97
+ @togglePressed() unless @handled.mode
92
98
 
93
99
  when 'mode'
94
100
  handled = true
@@ -98,13 +104,27 @@ class @Mercury.Toolbar.Button
98
104
  handled = true
99
105
  Mercury.modal(@handled.modal, {title: @summary || @title, handler: @name})
100
106
 
107
+ when 'lightview'
108
+ handled = true
109
+ Mercury.lightview(@handled.lightview, {title: @summary || @title, handler: @name, closeButton: true})
110
+
101
111
  when 'palette', 'select', 'panel'
102
112
  event.stopPropagation()
103
113
  handled = true
104
114
  @handled[type].toggle()
105
115
 
106
116
  Mercury.trigger('action', {action: @name}) unless handled
107
- Mercury.trigger('focus:frame')
117
+ Mercury.trigger('focus:frame') if @options['regions'] && @options['regions'].length
118
+
119
+
120
+ defaultDialogOptions: ->
121
+ return {
122
+ title: @summary || @title
123
+ preload: @types.preload
124
+ appendTo: @options.appendDialogsTo || 'body'
125
+ closeButton: true
126
+ for: @element
127
+ }
108
128
 
109
129
 
110
130
  togglePressed: ->
@@ -125,11 +145,13 @@ class @Mercury.Toolbar.Button
125
145
 
126
146
  italic: (node) -> node.css('font-style') == 'italic'
127
147
 
128
- # todo: overline is a bit weird because <u> and <strike> override text-decoration, so we can't always tell
129
- # todo: maybe walk up the tree if it's not too expensive?
130
- overline: (node) -> node.css('text-decoration') == 'overline'
148
+ # overline is weird because <u> and <strike> override text-decoration -- we can't always tell without checking parents
149
+ overline: (node) ->
150
+ return true if node.css('text-decoration') == 'overline'
151
+ for parent in node.parentsUntil(@element)
152
+ return true if jQuery(parent).css('text-decoration') == 'overline'
153
+ return false
131
154
 
132
- # todo: this should never check for tags, because they could be styled differently
133
155
  strikethrough: (node, region) -> node.css('text-decoration') == 'line-through' || !!node.closest('strike', region).length
134
156
 
135
157
  underline: (node, region) -> node.css('text-decoration') == 'underline' || !!node.closest('u', region).length
@@ -14,7 +14,7 @@ class @Mercury.Toolbar.ButtonGroup
14
14
 
15
15
 
16
16
  bindEvents: ->
17
- Mercury.bind 'region:update', (event, options) =>
17
+ Mercury.on 'region:update', (event, options) =>
18
18
  context = Mercury.Toolbar.ButtonGroup.contexts[@name]
19
19
  if context
20
20
  if options.region && jQuery.type(options.region.currentElement) == 'function'
@@ -24,14 +24,14 @@ class @Mercury.Toolbar.ButtonGroup
24
24
  else
25
25
  @element.addClass('disabled')
26
26
 
27
- Mercury.bind 'region:focused', (event, options) =>
27
+ Mercury.on 'region:focused', (event, options) =>
28
28
  if @regions && options.region && options.region.type
29
29
  if @regions.indexOf(options.region.type) > -1
30
30
  @element.removeClass('disabled') unless @options._context
31
31
  else
32
32
  @element.addClass('disabled')
33
33
 
34
- Mercury.bind 'region:blurred', (event, options) =>
34
+ Mercury.on 'region:blurred', (event, options) =>
35
35
  @element.addClass('disabled') if @options.regions
36
36
 
37
37
 
@@ -15,8 +15,8 @@ class @Mercury.Toolbar.Expander extends Mercury.Palette
15
15
 
16
16
 
17
17
  bindEvents: ->
18
- Mercury.bind 'hide:dialogs', (event, dialog) => @hide() unless dialog == @
19
- Mercury.bind 'resize', => @windowResize()
18
+ Mercury.on 'hide:dialogs', (event, dialog) => @hide() unless dialog == @
19
+ Mercury.on 'resize', => @windowResize()
20
20
 
21
21
  super
22
22
 
@@ -26,7 +26,7 @@ class @Mercury.Toolbar
26
26
  expander = new Mercury.Toolbar.Expander(toolbarName, {appendTo: toolbar, for: container})
27
27
  expander.appendTo(@element)
28
28
 
29
- toolbar.addClass('disabled') unless toolbarName == 'primary'
29
+ toolbar.addClass('disabled') if Mercury.config.toolbars['primary'] && toolbarName != 'primary'
30
30
 
31
31
  @element.css({width: '100%'})
32
32
 
@@ -48,25 +48,27 @@ class @Mercury.Toolbar
48
48
  when 'string' # separator
49
49
  jQuery('<hr>', {class: "mercury-#{if options == '-' then 'line-separator' else 'separator'}"})
50
50
 
51
- else throw "Unknown button structure -- please provide an array, object, or string for #{name}."
51
+ else throw Mercury.I18n('Unknown button structure -- please provide an array, object, or string for "%s".', name)
52
52
 
53
53
 
54
54
  bindEvents: ->
55
- Mercury.bind 'region:focused', (event, options) =>
55
+ Mercury.on 'region:focused', (event, options) =>
56
56
  for toolbar in @element.find(".mercury-toolbar")
57
57
  toolbar = jQuery(toolbar)
58
58
  if regions = toolbar.data('regions')
59
59
  toolbar.removeClass('disabled') if regions.split(',').indexOf(options.region.type) > -1
60
60
 
61
- Mercury.bind 'region:blurred', (event, options) =>
61
+ Mercury.on 'region:blurred', (event, options) =>
62
62
  for toolbar in @element.find(".mercury-toolbar")
63
63
  toolbar = jQuery(toolbar)
64
64
  if regions = toolbar.data('regions')
65
65
  toolbar.addClass('disabled') if regions.split(',').indexOf(options.region.type) > -1
66
66
 
67
+ @element.on 'click', ->
68
+ Mercury.trigger('hide:dialogs')
67
69
 
68
- @element.click -> Mercury.trigger('hide:dialogs')
69
- @element.mousedown (event) -> event.preventDefault()
70
+ @element.on 'mousedown', (event) ->
71
+ event.preventDefault()
70
72
 
71
73
 
72
74
  height: ->
@@ -2,10 +2,10 @@
2
2
  Mercury.tooltip.show(forElement, content, options)
3
3
  return Mercury.tooltip
4
4
 
5
- jQuery.extend Mercury.tooltip, {
5
+ jQuery.extend Mercury.tooltip,
6
6
 
7
7
  show: (@forElement, @content, @options = {}) ->
8
- @document = jQuery(@forElement.get(0).ownerDocument)
8
+ @document = @forElement.get(0).ownerDocument
9
9
  @initialize()
10
10
  if @visible then @update() else @appear()
11
11
 
@@ -23,15 +23,20 @@ jQuery.extend Mercury.tooltip, {
23
23
 
24
24
 
25
25
  bindEvents: ->
26
- Mercury.bind 'resize', => @position() if @visible
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
31
- @element.mousedown (event) ->
26
+ Mercury.on 'resize', => @position() if @visible
27
+
28
+ @element.on 'mousedown', (event) ->
32
29
  event.preventDefault()
33
30
  event.stopPropagation()
34
31
 
32
+ for parent in @forElement.parentsUntil(jQuery('body', @document))
33
+ continue unless parent.scrollHeight > parent.clientHeight
34
+ jQuery(parent).on 'scroll', =>
35
+ @position() if @visible
36
+
37
+ jQuery(@document).on 'scroll', =>
38
+ @position() if @visible
39
+
35
40
 
36
41
  appear: ->
37
42
  @update()
@@ -67,4 +72,3 @@ jQuery.extend Mercury.tooltip, {
67
72
  @element.hide()
68
73
  @visible = false
69
74
 
70
- }