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
@@ -2,7 +2,7 @@
2
2
  Mercury.modal.show(url, options)
3
3
  return Mercury.modal
4
4
 
5
- $.extend Mercury.modal, {
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 = $('<div>', {class: 'mercury-modal loading'})
23
+ @element = jQuery('<div>', {class: 'mercury-modal loading'})
24
24
  @element.html('<h1 class="mercury-modal-title"><span></span><a>&times;</a></h1>')
25
25
  @element.append('<div class="mercury-modal-content-container"><div class="mercury-modal-content"></div></div>')
26
26
 
27
- @overlay = $('<div>', {class: 'mercury-modal-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($(@options.appendTo).get(0) ? 'body')
34
- @overlay.appendTo($(@options.appendTo).get(0) ? 'body')
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 = $(window).height()
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: ($(window).width() - width) / 2, width: width, height: height}, 200, 'easeInOutSine', =>
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 = $(window).width()
91
- viewportHeight = $(window).height()
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
- $.ajax @url, {
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.htmleditor = ->
1
+ @Mercury.modalHandlers.htmlEditor = ->
2
2
  # fill the text area with the content
3
- @element.find('textarea').val(Mercury.region.html(null, true, false))
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.insertcharacter = ->
1
+ @Mercury.modalHandlers.insertCharacter = ->
2
2
  @element.find('.character').click ->
3
- Mercury.trigger('action', {action: 'insertHTML', value: "&#{$(@).attr('data-entity')};"})
3
+ Mercury.trigger('action', {action: 'insertHTML', value: "&#{jQuery(@).attr('data-entity')};"})
4
4
  Mercury.modal.hide()
@@ -1,10 +1,10 @@
1
- @Mercury.modalHandlers.insertlink = ->
1
+ @Mercury.modalHandlers.insertLink = ->
2
2
  # make the inputs work with the radio buttons
3
3
  @element.find('label input').click (event) ->
4
- $(@).closest('label').next('.selectable').focus()
4
+ jQuery(@).closest('label').next('.selectable').focus()
5
5
 
6
6
  @element.find('.selectable').focus ->
7
- $(@).prev('label').find('input[type=radio]').prop("checked", true)
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 $('a[name]', window.mercuryInstance.document)
18
- bookmarkSelect.append($('<option>', {value: $(link).attr('name')}).text($(link).text()))
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', '#{$.param(args).replace(/&/g, ',')}'))"
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.insertmedia = ->
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
- $(@).closest('label').next('.selectable').focus()
4
+ jQuery(@).closest('label').next('.selectable').focus()
5
5
 
6
6
  @element.find('.selectable').focus (event) =>
7
- element = $(event.target)
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 = $('<iframe>', {
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 = $('<iframe>', {
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.insertsnippet = ->
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: 'insertsnippet', value: snippet})
11
+ Mercury.trigger('action', {action: 'insertSnippet', value: snippet})
12
12
  @hide()
@@ -1,9 +1,9 @@
1
- @Mercury.modalHandlers.inserttable = ->
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 = $(event.target)
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 = $(event.target).attr('name')
19
+ action = jQuery(event.target).attr('name')
20
20
  switch action
21
-
22
- when 'insertrowbefore' then Mercury.tableEditor.addRow('before')
23
- when 'insertrowafter' then Mercury.tableEditor.addRow('after')
24
- when 'deleterow' then Mercury.tableEditor.removeRow()
25
- when 'insertcolumnbefore' then Mercury.tableEditor.addColumn('before')
26
- when 'insertcolumnafter' then Mercury.tableEditor.addColumn('after')
27
- when 'deletecolumn' then Mercury.tableEditor.removeColumn()
28
- when 'increasecolspan' then Mercury.tableEditor.increaseColspan()
29
- when 'decreasecolspan' then Mercury.tableEditor.decreaseColspan()
30
- when 'increaserowspan' then Mercury.tableEditor.increaseRowspan()
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('&nbsp;')
50
49
 
51
- html = $('<div>').html(table).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+|^(&nbsp;)+/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 = $('<div>').html(@.toString())
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 = $('meta[name="csrf-token"]').attr('content')
13
+ Mercury.csrfToken = token if token = jQuery('meta[name="csrf-token"]').attr('content')
14
14
 
15
15
 
16
16
  initializeInterface: ->
17
- @focusableElement = $('<input>', {type: 'text', style: 'position:absolute;opacity:0'}).appendTo(@options.appendTo ? 'body')
18
- @iframe = $('<iframe>', {class: 'mercury-iframe', seamless: 'true', frameborder: '0', src: 'about:blank', style: 'position:absolute;top:0;width:100%;visibility:hidden'})
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.attr('src', @iframeSrc())
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 = $(@iframe.get(0).contentWindow.document)
32
- $("<style mercury-styles=\"true\">").html(Mercury.config.injectedStyles).appendTo(@document.find('head'))
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
- $.globalEval = (data) -> (iframeWindow.execScript || (data) -> iframeWindow["eval"].call(iframeWindow, data))(data) if (data && /\S/.test(data))
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($(region)) for region in $('.mercury-region', @document)
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, 100)
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
- @save() if options.action == 'save'
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 $(event.target).closest('.mercury-region').get(0) == Mercury.region.element.get(0)
84
+ Mercury.trigger('unfocus:regions') unless jQuery(event.target).closest('.mercury-region').get(0) == Mercury.region.element.get(0)
84
85
 
85
- $(window).resize => @resize()
86
+ jQuery(window).resize => @resize()
86
87
  window.onbeforeunload = @beforeUnload
87
88
 
88
89
 
89
90
  resize: ->
90
- width = $(window).width()
91
- height = $(window).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 - statusbarHeight - toolbarHeight}
95
+ Mercury.displayRect = {top: toolbarHeight, left: 0, width: width, height: height - toolbarHeight}
96
96
 
97
97
  @iframe.css {
98
- top: toolbarHeight,
99
- width: width,
100
- height: height - statusbarHeight - toolbarHeight
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]:\/\/.[^\/]*)\/edit\/?(.*)/i, "$1/$2")
107
+ (url ? window.location.href).replace(/([http|https]:\/\/.[^\/]*)\/editor\/?(.*)/i, "$1/$2")
108
108
 
109
109
 
110
110
  hijackLinks: ->
111
- for link in $('a', @document)
111
+ for link in jQuery('a', @document)
112
112
  ignored = false
113
113
  for classname in @options.ignoredLinks || []
114
- if $(link).hasClass(classname)
114
+ if jQuery(link).hasClass(classname)
115
115
  ignored = true
116
116
  continue
117
- if !ignored && (link.target == '' || link.target == '_self') && !$(link).closest('.mercury-region').length
118
- $(link).attr('target', '_top')
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 = $.toJSON(data) unless @options.saveStyle == 'form'
132
- $.ajax url, {
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 = $('<div>', {class: "mercury-palette mercury-#{@name}-palette loading", style: 'display:none'})
9
- @element.appendTo($(@options.appendTo).get(0) ? 'body')
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 > $(window).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 = $('<div>', {class: 'mercury-panel loading', style: 'display:none;'})
9
- @titleElement = $("<h1>#{@options.title}</h1>").appendTo(@element)
10
- @paneElement = $('<div>', {class: 'mercury-panel-pane'}).appendTo(@element)
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($(@options.appendTo).get(0) ? 'body');
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 = $(event.target).closest('.mercury-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
- html: (value = null, filterSnippets = false) ->
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 = $('<div>').appendTo(@document.createDocumentFragment())
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 = $(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(@html())
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($(element).data('snippet'))
93
- snippet.setVersion($(element).data('version'))
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: @html(null, true)
100
+ type: @type
101
+ value: @content(null, true)
102
102
  snippets: @snippets()
103
103
  }