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.
Files changed (74) hide show
  1. data/README.rdoc +81 -50
  2. data/VERSION +1 -1
  3. data/app/assets/javascripts/mercury/dialog.js.coffee +4 -4
  4. data/app/assets/javascripts/mercury/dialogs/backcolor.js.coffee +3 -3
  5. data/app/assets/javascripts/mercury/dialogs/forecolor.js.coffee +3 -3
  6. data/app/assets/javascripts/mercury/dialogs/formatblock.js.coffee +1 -1
  7. data/app/assets/javascripts/mercury/dialogs/objectspanel.js.coffee +3 -3
  8. data/app/assets/javascripts/mercury/dialogs/style.js.coffee +1 -1
  9. data/app/assets/javascripts/mercury/history_buffer.js.coffee +2 -2
  10. data/app/assets/javascripts/mercury/mercury.js.coffee +47 -54
  11. data/app/assets/javascripts/mercury/modal.js.coffee +13 -13
  12. data/app/assets/javascripts/mercury/modals/htmleditor.js.coffee +2 -2
  13. data/app/assets/javascripts/mercury/modals/insertcharacter.js.coffee +2 -2
  14. data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +7 -7
  15. data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +5 -5
  16. data/app/assets/javascripts/mercury/modals/insertsnippet.js.coffee +2 -2
  17. data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +14 -15
  18. data/app/assets/javascripts/mercury/native_extensions.js.coffee +2 -1
  19. data/app/assets/javascripts/mercury/page_editor.js.coffee +27 -27
  20. data/app/assets/javascripts/mercury/palette.js.coffee +6 -6
  21. data/app/assets/javascripts/mercury/panel.js.coffee +4 -4
  22. data/app/assets/javascripts/mercury/region.js.coffee +9 -9
  23. data/app/assets/javascripts/mercury/regions/editable.js.coffee +71 -71
  24. data/app/assets/javascripts/mercury/regions/markupable.js.coffee +51 -42
  25. data/app/assets/javascripts/mercury/regions/snippetable.js.coffee +7 -8
  26. data/app/assets/javascripts/mercury/select.js.coffee +8 -8
  27. data/app/assets/javascripts/mercury/snippet.js.coffee +6 -6
  28. data/app/assets/javascripts/mercury/snippet_toolbar.js.coffee +7 -7
  29. data/app/assets/javascripts/mercury/statusbar.js.coffee +7 -3
  30. data/app/assets/javascripts/mercury/table_editor.js.coffee +24 -24
  31. data/app/assets/javascripts/mercury/toolbar.button.js.coffee +20 -21
  32. data/app/assets/javascripts/mercury/toolbar.button_group.js.coffee +2 -2
  33. data/app/assets/javascripts/mercury/toolbar.expander.js.coffee +9 -9
  34. data/app/assets/javascripts/mercury/toolbar.js.coffee +12 -13
  35. data/app/assets/javascripts/mercury/tooltip.js.coffee +7 -7
  36. data/app/assets/javascripts/mercury/uploader.js.coffee +12 -13
  37. data/app/assets/javascripts/mercury_loader.js +98 -0
  38. data/app/assets/stylesheets/mercury/modal.scss +5 -5
  39. data/app/assets/stylesheets/mercury/toolbar.scss +62 -64
  40. data/app/views/layouts/mercury.html.haml +0 -4
  41. data/app/views/mercury/modals/character.html.haml +1 -1
  42. data/app/views/mercury/modals/htmleditor.html.haml +1 -1
  43. data/app/views/mercury/modals/table.html.haml +10 -10
  44. data/config/routes.rb +2 -2
  45. data/mercury-rails.gemspec +17 -20
  46. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +3 -3
  47. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +3 -3
  48. data/spec/javascripts/mercury/dialogs/objectspanel_spec.js.coffee +3 -3
  49. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +4 -4
  50. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +2 -2
  51. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +10 -10
  52. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +7 -7
  53. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +4 -4
  54. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +17 -17
  55. data/spec/javascripts/mercury/page_editor_spec.js.coffee +5 -6
  56. data/spec/javascripts/mercury/region_spec.js.coffee +5 -5
  57. data/spec/javascripts/mercury/regions/editable_spec.js.coffee +398 -0
  58. data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +18 -14
  59. data/spec/javascripts/mercury/snippet_spec.js.coffee +1 -1
  60. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +16 -16
  61. data/spec/javascripts/templates/mercury/modals/inserttable.html +11 -11
  62. data/spec/javascripts/templates/mercury/regions/editable.html +3 -0
  63. data/spec/javascripts/templates/mercury/toolbar.button.html +8 -8
  64. data/vendor/assets/javascripts/{jquery-ui-1.8.13.sortable.custom.js → jquery-ui-1.8.13.custom.js} +250 -0
  65. data/vendor/assets/javascripts/jquery.additions.js +151 -0
  66. data/vendor/assets/javascripts/showdown.js +1254 -1276
  67. metadata +26 -29
  68. data/app/assets/javascripts/mercury/websocket.js.coffee +0 -34
  69. data/spec/javascripts/mercury/regions/_editable_.js.coffee +0 -0
  70. data/vendor/assets/javascripts/jquery-ui-1.8.13.custom.min.js +0 -249
  71. data/vendor/assets/javascripts/jquery.easing.js +0 -173
  72. data/vendor/assets/javascripts/jquery.json2.js +0 -178
  73. data/vendor/assets/javascripts/jquery.serialize_object.js +0 -16
  74. data/vendor/assets/javascripts/jquery.ujs.js +0 -289
@@ -28,12 +28,11 @@ class @Mercury.Regions.Snippetable extends Mercury.Region
28
28
  @element.sortable('destroy')
29
29
  Mercury.trigger('region:blurred', {region: @})
30
30
 
31
- $(@document).keydown (event) =>
31
+ jQuery(@document).keydown (event) =>
32
32
  return if @previewing
33
33
  return unless Mercury.region == @
34
34
  Mercury.changes = true
35
35
  switch event.keyCode
36
-
37
36
  when 90 # undo / redo
38
37
  return unless event.metaKey
39
38
  event.preventDefault()
@@ -89,7 +88,7 @@ class @Mercury.Regions.Snippetable extends Mercury.Region
89
88
  scroll: false, #scrolling is buggy
90
89
  containment: 'parent',
91
90
  items: '.mercury-snippet',
92
- opacity: .4,
91
+ opacity: 0.4,
93
92
  revert: 100,
94
93
  tolerance: 'pointer',
95
94
  beforeStop: =>
@@ -104,23 +103,23 @@ class @Mercury.Regions.Snippetable extends Mercury.Region
104
103
  # Actions
105
104
  @actions: {
106
105
 
107
- undo: -> @html(@history.undo())
106
+ undo: -> @content(@history.undo())
108
107
 
109
- redo: -> @html(@history.redo())
108
+ redo: -> @content(@history.redo())
110
109
 
111
- insertsnippet: (options) ->
110
+ insertSnippet: (options) ->
112
111
  snippet = options.value
113
112
  if (existing = @element.find("[data-snippet=#{snippet.identity}]")).length
114
113
  existing.replaceWith(snippet.getHTML(@document, => @pushHistory()))
115
114
  else
116
115
  @element.append(snippet.getHTML(@document, => @pushHistory()))
117
116
 
118
- editsnippet: ->
117
+ editSnippet: ->
119
118
  return unless @snippet
120
119
  snippet = Mercury.Snippet.find(@snippet.data('snippet'))
121
120
  snippet.displayOptions()
122
121
 
123
- removesnippet: ->
122
+ removeSnippet: ->
124
123
  @snippet.remove() if @snippet
125
124
  Mercury.trigger('hide:toolbar', {type: 'snippet', immediately: true})
126
125
 
@@ -5,8 +5,8 @@ class @Mercury.Select extends Mercury.Dialog
5
5
 
6
6
 
7
7
  build: ->
8
- @element = $('<div>', {class: "mercury-select mercury-#{@name}-select loading", style: 'display:none'})
9
- @element.appendTo($(@options.appendTo).get(0) ? 'body')
8
+ @element = jQuery('<div>', {class: "mercury-select mercury-#{@name}-select loading", style: 'display:none'})
9
+ @element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
10
10
 
11
11
 
12
12
  bindEvents: ->
@@ -19,7 +19,7 @@ class @Mercury.Select extends Mercury.Dialog
19
19
  position = @button.offset()
20
20
  elementWidth = @element.width()
21
21
  elementHeight = @element.height()
22
- documentHeight = $(document).height()
22
+ documentHeight = jQuery(document).height()
23
23
 
24
24
  top = position.top + (@button.height() / 2) - (elementHeight / 2)
25
25
  top = position.top - 100 if top < position.top - 100
@@ -29,12 +29,12 @@ class @Mercury.Select extends Mercury.Dialog
29
29
  height = documentHeight - top - 20 if top + elementHeight >= documentHeight - 20
30
30
 
31
31
  left = position.left
32
- left = left - elementWidth + @button.width() if left + elementWidth > $(window).width()
32
+ left = left - elementWidth + @button.width() if left + elementWidth > jQuery(window).width()
33
33
 
34
34
  @element.css {
35
- top: top,
36
- left: left,
37
- height: height,
38
- display: if keepVisible then 'block' else 'none',
35
+ top: top
36
+ left: left
37
+ height: height
38
+ display: if keepVisible then 'block' else 'none'
39
39
  visibility: 'visible'
40
40
  }
@@ -3,7 +3,7 @@ class @Mercury.Snippet
3
3
  @all: []
4
4
 
5
5
  @displayOptionsFor: (name) ->
6
- Mercury.modal("/mercury/snippets/#{name}/options", {title: 'Snippet Options', handler: 'insertsnippet', snippetName: name})
6
+ Mercury.modal("/mercury/snippets/#{name}/options", {title: 'Snippet Options', handler: 'insertSnippet', snippetName: name})
7
7
  Mercury.snippet = null
8
8
 
9
9
 
@@ -21,7 +21,7 @@ class @Mercury.Snippet
21
21
 
22
22
 
23
23
  @load: (snippets) ->
24
- for identity, details of snippets
24
+ for own identity, details of snippets
25
25
  instance = new Mercury.Snippet(details.name, identity, details.options)
26
26
  @all.push(instance)
27
27
 
@@ -34,7 +34,7 @@ class @Mercury.Snippet
34
34
 
35
35
 
36
36
  getHTML: (context, callback = null) ->
37
- element = $('<div class="mercury-snippet" contenteditable="false">', context)
37
+ element = jQuery('<div class="mercury-snippet" contenteditable="false">', context)
38
38
  element.attr({'data-snippet': @identity})
39
39
  element.attr({'data-version': @version})
40
40
  element.html("[#{@identity}]")
@@ -47,7 +47,7 @@ class @Mercury.Snippet
47
47
 
48
48
 
49
49
  loadPreview: (element, callback = null) ->
50
- $.ajax "/mercury/snippets/#{@name}/preview", {
50
+ jQuery.ajax "/mercury/snippets/#{@name}/preview", {
51
51
  type: 'POST'
52
52
  data: @options
53
53
  success: (data) =>
@@ -63,7 +63,7 @@ class @Mercury.Snippet
63
63
  Mercury.snippet = @
64
64
  Mercury.modal "/mercury/snippets/#{@name}/options", {
65
65
  title: 'Snippet Options',
66
- handler: 'insertsnippet',
66
+ handler: 'insertSnippet',
67
67
  loadType: 'post',
68
68
  loadData: @options
69
69
  }
@@ -87,6 +87,6 @@ class @Mercury.Snippet
87
87
 
88
88
  serialize: ->
89
89
  return {
90
- name: @name,
90
+ name: @name
91
91
  options: @options
92
92
  }
@@ -5,10 +5,10 @@ class @Mercury.SnippetToolbar extends Mercury.Toolbar
5
5
 
6
6
 
7
7
  build: ->
8
- @element = $('<div>', {class: 'mercury-toolbar mercury-snippet-toolbar', style: 'display:none'})
9
- @element.appendTo($(@options.appendTo).get(0) ? 'body')
8
+ @element = jQuery('<div>', {class: 'mercury-toolbar mercury-snippet-toolbar', style: 'display:none'})
9
+ @element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')
10
10
 
11
- for buttonName, options of Mercury.config.toolbars.snippetable
11
+ for own buttonName, options of Mercury.config.toolbars.snippetable
12
12
  button = @buildButton(buttonName, options)
13
13
  button.appendTo(@element) if button
14
14
 
@@ -23,7 +23,7 @@ class @Mercury.SnippetToolbar extends Mercury.Toolbar
23
23
  return unless options.type && options.type == 'snippet'
24
24
  @hide(options.immediately)
25
25
 
26
- $(@document).scroll => @position() if @visible
26
+ jQuery(@document).scroll => @position() if @visible
27
27
 
28
28
  @element.mousemove => clearTimeout(@hideTimeout)
29
29
  @element.mouseout => @hide()
@@ -38,11 +38,11 @@ class @Mercury.SnippetToolbar extends Mercury.Toolbar
38
38
  position: ->
39
39
  offset = @snippet.offset()
40
40
 
41
- top = offset.top + Mercury.displayRect.top - $(@document).scrollTop() - @height() + 10
42
- left = offset.left - $(@document).scrollLeft()
41
+ top = offset.top + Mercury.displayRect.top - jQuery(@document).scrollTop() - @height() + 10
42
+ left = offset.left - jQuery(@document).scrollLeft()
43
43
 
44
44
  @element.css {
45
- top: top,
45
+ top: top
46
46
  left: left
47
47
  }
48
48
 
@@ -6,16 +6,20 @@ class @Mercury.Statusbar
6
6
 
7
7
 
8
8
  build: ->
9
- @element = $('<div>', {class: 'mercury-statusbar'}).appendTo($(@options.appendTo).get(0) ? 'body')
9
+ @element = jQuery('<div>', {class: 'mercury-statusbar'}).appendTo(jQuery(@options.appendTo).get(0) ? 'body')
10
10
 
11
11
 
12
12
  bindEvents: ->
13
13
  Mercury.bind 'region:update', (event, options) =>
14
- @setPath(options.region.path()) if options.region && $.type(options.region.path) == 'function'
14
+ @setPath(options.region.path()) if options.region && jQuery.type(options.region.path) == 'function'
15
15
 
16
16
 
17
17
  height: ->
18
- @element.outerHeight()
18
+ return @element.outerHeight()
19
+
20
+
21
+ top: ->
22
+ return @element.offset().top
19
23
 
20
24
 
21
25
  setPath: (elements) ->
@@ -2,7 +2,7 @@
2
2
  Mercury.tableEditor.load(table, cell)
3
3
  return Mercury.tableEditor
4
4
 
5
- $.extend Mercury.tableEditor, {
5
+ jQuery.extend Mercury.tableEditor, {
6
6
 
7
7
  load: (@table, @cell) ->
8
8
  @row = @cell.parent('tr')
@@ -17,7 +17,7 @@ $.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 = $("<#{matching.cell.get(0).tagName}>").text('\00')
20
+ newCell = jQuery("<#{matching.cell.get(0).tagName}>").text('')
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
@@ -38,20 +38,20 @@ $.extend Mercury.tableEditor, {
38
38
  else if intersecting = @findCellByIntersectionFor(row, sig)
39
39
  adjusting.push(intersecting.cell)
40
40
 
41
- $(cell).remove() for cell in removing
41
+ jQuery(cell).remove() for cell in removing
42
42
  @setColspanFor(cell, @colspanFor(cell) - 1) for cell in adjusting
43
43
 
44
44
 
45
45
  addRow: (position = 'after') ->
46
- newRow = $('<tr>')
46
+ newRow = jQuery('<tr>')
47
47
 
48
48
  if (rowspan = @rowspanFor(@cell)) > 1 && position == 'after'
49
- @row = $(@row.nextAll('tr')[rowspan - 2])
49
+ @row = jQuery(@row.nextAll('tr')[rowspan - 2])
50
50
 
51
51
  cellCount = 0
52
52
  for cell in @row.find('th, td')
53
53
  colspan = @colspanFor(cell)
54
- newCell = $("<#{cell.tagName}>").text('\00')
54
+ newCell = jQuery("<#{cell.tagName}>").text('')
55
55
  @setColspanFor(newCell, colspan)
56
56
  cellCount += colspan
57
57
  if (rowspan = @rowspanFor(cell)) > 1 && position == 'after'
@@ -64,14 +64,14 @@ $.extend Mercury.tableEditor, {
64
64
  rowCount = 0
65
65
  for previousRow in @row.prevAll('tr')
66
66
  rowCount += 1
67
- for cell in $(previousRow).find('td[rowspan], th[rowspan]')
67
+ for cell in jQuery(previousRow).find('td[rowspan], th[rowspan]')
68
68
  rowspan = @rowspanFor(cell)
69
69
  if rowspan - 1 >= rowCount && position == 'before'
70
70
  @setRowspanFor(cell, rowspan + 1)
71
71
  else if rowspan - 1 >= rowCount && position == 'after'
72
72
  if rowspan - 1 == rowCount
73
- newCell = $("<#{cell.tagName}>", {colspan: @colspanFor(cell)})
74
- newRow.append(newCell);
73
+ newCell = jQuery("<#{cell.tagName}>", {colspan: @colspanFor(cell)})
74
+ newRow.append(newCell)
75
75
  else
76
76
  @setRowspanFor(cell, rowspan + 1)
77
77
 
@@ -93,7 +93,7 @@ $.extend Mercury.tableEditor, {
93
93
 
94
94
  # remove any emtpy rows below
95
95
  if minRowspan > 1
96
- $(@row.nextAll('tr')[i]).remove() for i in [0..minRowspan - 2]
96
+ jQuery(@row.nextAll('tr')[i]).remove() for i in [0..minRowspan - 2]
97
97
 
98
98
  # find and move down any cells that have a larger rowspan
99
99
  for cell in @row.find('td[rowspan], th[rowspan]')
@@ -101,14 +101,14 @@ $.extend Mercury.tableEditor, {
101
101
  continue if sig.height == minRowspan
102
102
  if match = @findCellByOptionsFor(@row.nextAll('tr')[minRowspan - 1], {left: sig.left, forceAdjacent: true})
103
103
  @setRowspanFor(cell, @rowspanFor(cell) - @rowspanFor(@cell))
104
- if match.direction == 'before' then match.cell.before($(cell).clone()) else match.cell.after($(cell).clone())
104
+ if match.direction == 'before' then match.cell.before(jQuery(cell).clone()) else match.cell.after(jQuery(cell).clone())
105
105
 
106
106
  if @columnsFor(@row.find('td, th')) < @columnCount
107
107
  # move up rows looking for cells with rowspans that might intersect
108
108
  rowsAbove = 0
109
109
  for aboveRow in @row.prevAll('tr')
110
110
  rowsAbove += 1
111
- for cell in $(aboveRow).find('td[rowspan], th[rowspan]')
111
+ for cell in jQuery(aboveRow).find('td[rowspan], th[rowspan]')
112
112
  # if the cell intersects with the row we're trying to calculate on, and it's index is less than where we've
113
113
  # gotten so far, add it
114
114
  rowspan = @rowspanFor(cell)
@@ -129,7 +129,7 @@ $.extend Mercury.tableEditor, {
129
129
  decreaseColspan: ->
130
130
  return if @colspanFor(@cell) == 1
131
131
  @setColspanFor(@cell, @colspanFor(@cell) - 1)
132
- newCell = $("<#{@cell.get(0).tagName}>").text('\00')
132
+ newCell = jQuery("<#{@cell.get(0).tagName}>").text('')
133
133
  @setRowspanFor(newCell, @rowspanFor(@cell))
134
134
  @cell.after(newCell)
135
135
 
@@ -146,7 +146,7 @@ $.extend Mercury.tableEditor, {
146
146
  return if sig.height == 1
147
147
  nextRow = @row.nextAll('tr')[sig.height - 2]
148
148
  if match = @findCellByOptionsFor(nextRow, {left: sig.left, forceAdjacent: true})
149
- newCell = $("<#{@cell.get(0).tagName}>").text('\00')
149
+ newCell = jQuery("<#{@cell.get(0).tagName}>").text('')
150
150
  @setColspanFor(newCell, @colspanFor(@cell))
151
151
  @setRowspanFor(@cell, sig.height - 1)
152
152
  if match.direction == 'before' then match.cell.before(newCell) else match.cell.after(newCell)
@@ -164,7 +164,7 @@ $.extend Mercury.tableEditor, {
164
164
 
165
165
  # Gets the index for a given cell, taking into account that rows above it can have cells that have rowspans.
166
166
  cellIndexFor: (cell) ->
167
- cell = $(cell)
167
+ cell = jQuery(cell)
168
168
 
169
169
  # get the row for the cell and calculate all the columns in it
170
170
  row = cell.parent('tr')
@@ -177,7 +177,7 @@ $.extend Mercury.tableEditor, {
177
177
  rowsAbove = 0
178
178
  for aboveRow in row.prevAll('tr')
179
179
  rowsAbove += 1
180
- for aboveCell in $(aboveRow).find('td[rowspan], th[rowspan]')
180
+ for aboveCell in jQuery(aboveRow).find('td[rowspan], th[rowspan]')
181
181
  # if the cell intersects with the row we're trying to calculate on, and it's index is less than where we've
182
182
  # gotten so far, add it
183
183
  if @rowspanFor(aboveCell) > rowsAbove && @cellIndexFor(aboveCell) <= index
@@ -187,7 +187,7 @@ $.extend Mercury.tableEditor, {
187
187
 
188
188
  # Creates a signature for a given cell, which is made up if it's size, and itself.
189
189
  cellSignatureFor: (cell) ->
190
- sig = {cell: $(cell)}
190
+ sig = {cell: jQuery(cell)}
191
191
  sig.left = @cellIndexFor(cell)
192
192
  sig.width = @colspanFor(cell)
193
193
  sig.height = @rowspanFor(cell)
@@ -200,7 +200,7 @@ $.extend Mercury.tableEditor, {
200
200
  # left, [width], [forceAdjacent]
201
201
  # eg. findCellByOptionsFor(@row, {left: 1, width: 2, forceAdjacent: true})
202
202
  findCellByOptionsFor: (row, options) ->
203
- for cell in $(row).find('td, th')
203
+ for cell in jQuery(row).find('td, th')
204
204
  sig = @cellSignatureFor(cell)
205
205
  if typeof(options.right) != 'undefined'
206
206
  return sig if sig.right == options.right
@@ -212,7 +212,7 @@ $.extend Mercury.tableEditor, {
212
212
  return sig if sig.left == options.left
213
213
  else if options.forceAdjacent
214
214
  if sig.left > options.left
215
- prev = $(cell).prev('td, th')
215
+ prev = jQuery(cell).prev('td, th')
216
216
  if prev.length
217
217
  sig = @cellSignatureFor(prev)
218
218
  sig.direction = 'after'
@@ -228,7 +228,7 @@ $.extend Mercury.tableEditor, {
228
228
 
229
229
  # Finds a cell that intersects with the current signature
230
230
  findCellByIntersectionFor: (row, signature) ->
231
- for cell in $(row).find('td, th')
231
+ for cell in jQuery(row).find('td, th')
232
232
  sig = @cellSignatureFor(cell)
233
233
  return sig if sig.right - signature.left >= 0 && sig.right > signature.left
234
234
  return null
@@ -245,22 +245,22 @@ $.extend Mercury.tableEditor, {
245
245
  # Tries to get the colspan of a cell, falling back to 1 if there's none
246
246
  # specified.
247
247
  colspanFor: (cell) ->
248
- return parseInt($(cell).attr('colspan')) || 1
248
+ return parseInt(jQuery(cell).attr('colspan')) || 1
249
249
 
250
250
 
251
251
  # Tries to get the rowspan of a cell, falling back to 1 if there's none
252
252
  # specified.
253
253
  rowspanFor: (cell) ->
254
- return parseInt($(cell).attr('rowspan')) || 1
254
+ return parseInt(jQuery(cell).attr('rowspan')) || 1
255
255
 
256
256
 
257
257
  # Sets the colspan of a cell, removing it if it's 1.
258
258
  setColspanFor: (cell, value) ->
259
- $(cell).attr('colspan', if value > 1 then value else null)
259
+ jQuery(cell).attr('colspan', if value > 1 then value else null)
260
260
 
261
261
 
262
262
  # Sets the rowspan of a cell, removing it if it's 1
263
263
  setRowspanFor: (cell, value) ->
264
- $(cell).attr('rowspan', if value > 1 then value else null)
264
+ jQuery(cell).attr('rowspan', if value > 1 then value else null)
265
265
 
266
266
  }
@@ -1,25 +1,24 @@
1
1
  class @Mercury.Toolbar.Button
2
2
 
3
- constructor: (@name, @title, @summary = null, @types = [], @options = {}) ->
3
+ constructor: (@name, @title, @summary = null, @types = {}, @options = {}) ->
4
4
  @build()
5
5
  @bindEvents()
6
6
  return @element
7
7
 
8
8
 
9
9
  build: ->
10
- @element = $('<div>', {title: @summary ? @title, class: "mercury-button mercury-#{@name}-button"}).html("<em>#{@title}</em>")
10
+ @element = jQuery('<div>', {title: @summary ? @title, class: "mercury-button mercury-#{@name}-button"}).html("<em>#{@title}</em>")
11
11
  @element.data('expander', "<div class=\"mercury-expander-button\" data-button=\"#{@name}\"><em></em><span>#{@title}</span></div>")
12
12
 
13
13
  @handled = []
14
14
  dialogOptions = {title: @summary || @title, preload: @types.preload, appendTo: @options.appendDialogsTo || 'body', for: @element}
15
- for type, mixed of @types
15
+ for own type, mixed of @types
16
16
  switch type
17
-
18
17
  when 'preload' then true
19
18
 
20
19
  when 'regions'
21
20
  @element.addClass('disabled')
22
- @handled[type] = if $.isFunction(mixed) then mixed.call(@, @name) else mixed
21
+ @handled[type] = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
23
22
 
24
23
  when 'toggle'
25
24
  @handled[type] = true
@@ -28,26 +27,26 @@ class @Mercury.Toolbar.Button
28
27
  @handled[type] = if mixed == true then @name else mixed
29
28
 
30
29
  when 'context'
31
- @handled[type] = if $.isFunction(mixed) then mixed else Mercury.Toolbar.Button.contexts[@name]
30
+ @handled[type] = if jQuery.isFunction(mixed) then mixed else Mercury.Toolbar.Button.contexts[@name]
32
31
 
33
32
  when 'palette'
34
33
  @element.addClass("mercury-button-palette")
35
- url = if $.isFunction(mixed) then mixed.call(@, @name) else mixed
34
+ url = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
36
35
  @handled[type] = new Mercury.Palette(url, @name, dialogOptions)
37
36
 
38
37
  when 'select'
39
38
  @element.addClass("mercury-button-select").find('em').html(@title)
40
- url = if $.isFunction(mixed) then mixed.call(@, @name) else mixed
39
+ url = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
41
40
  @handled[type] = new Mercury.Select(url, @name, dialogOptions)
42
41
 
43
42
  when 'panel'
44
43
  @element.addClass('mercury-button-panel')
45
- url = if $.isFunction(mixed) then mixed.call(@, @name) else mixed
44
+ url = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
46
45
  @handled['toggle'] = true
47
46
  @handled[type] = new Mercury.Panel(url, @name, dialogOptions)
48
47
 
49
48
  when 'modal'
50
- @handled[type] = if $.isFunction(mixed) then mixed.apply(@, @name) else mixed
49
+ @handled[type] = if jQuery.isFunction(mixed) then mixed.apply(@, @name) else mixed
51
50
 
52
51
  else throw "Unknown button type #{type} used for the #{@name} button."
53
52
 
@@ -57,7 +56,7 @@ class @Mercury.Toolbar.Button
57
56
  @element.click() if options.action == @name
58
57
 
59
58
  Mercury.bind 'region:update', (event, options) =>
60
- if @handled.context && options.region && $.type(options.region.currentElement) == 'function'
59
+ if @handled.context && options.region && jQuery.type(options.region.currentElement) == 'function'
61
60
  element = options.region.currentElement()
62
61
  if element.length && @handled.context.call(@, element, options.region.element)
63
62
  @element.addClass('active')
@@ -86,9 +85,8 @@ class @Mercury.Toolbar.Button
86
85
  if @element.closest('.disabled').length then return
87
86
 
88
87
  handled = false
89
- for type, mixed of @handled
88
+ for own type, mixed of @handled
90
89
  switch type
91
-
92
90
  when 'toggle'
93
91
  @togglePressed()
94
92
 
@@ -97,6 +95,7 @@ class @Mercury.Toolbar.Button
97
95
  Mercury.trigger('mode', {mode: mixed})
98
96
 
99
97
  when 'modal'
98
+ handled = true
100
99
  Mercury.modal(@handled.modal, {title: @summary || @title, handler: @name})
101
100
 
102
101
  when 'palette', 'select', 'panel'
@@ -116,9 +115,9 @@ class @Mercury.Toolbar.Button
116
115
  # Button contexts
117
116
  @Mercury.Toolbar.Button.contexts =
118
117
 
119
- backcolor: (node) -> @element.css('background-color', node.css('background-color'))
118
+ backColor: (node) -> @element.css('background-color', node.css('background-color'))
120
119
 
121
- forecolor: (node) -> @element.css('background-color', node.css('color'))
120
+ foreColor: (node) -> @element.css('background-color', node.css('color'))
122
121
 
123
122
  bold: (node) ->
124
123
  weight = node.css('font-weight')
@@ -139,14 +138,14 @@ class @Mercury.Toolbar.Button
139
138
 
140
139
  superscript: (node, region) -> !!node.closest('sup', region).length
141
140
 
142
- justifyleft: (node) -> node.css('text-align').indexOf('left') > -1
141
+ justifyLeft: (node) -> node.css('text-align').indexOf('left') > -1
143
142
 
144
- justifycenter: (node) -> node.css('text-align').indexOf('center') > -1
143
+ justifyCenter: (node) -> node.css('text-align').indexOf('center') > -1
145
144
 
146
- justifyright: (node) -> node.css('text-align').indexOf('right') > -1
145
+ justifyRight: (node) -> node.css('text-align').indexOf('right') > -1
147
146
 
148
- justifyfull: (node) -> node.css('text-align').indexOf('justify') > -1
147
+ justifyFull: (node) -> node.css('text-align').indexOf('justify') > -1
149
148
 
150
- insertorderedlist: (node, region) -> !!node.closest('ol', region.element).length
149
+ insertOrderedList: (node, region) -> !!node.closest('ol', region.element).length
151
150
 
152
- insertunorderedlist: (node, region) -> !!node.closest('ul', region.element).length
151
+ insertUnorderedList: (node, region) -> !!node.closest('ul', region.element).length