mercury-rails 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +8 -3
- data/VERSION +1 -1
- data/app/assets/javascripts/mercury/dialogs/style.js.coffee +1 -1
- data/app/assets/javascripts/mercury/mercury.js.coffee +2 -2
- data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +3 -6
- data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +6 -6
- data/app/assets/javascripts/mercury/modals/insertsnippet.js.coffee +3 -2
- data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +8 -8
- data/app/assets/javascripts/mercury/page_editor.js.coffee +6 -0
- data/app/assets/javascripts/mercury/snippet.js.coffee +1 -1
- data/app/assets/stylesheets/mercury/dialog.scss +1 -0
- data/app/assets/stylesheets/mercury/mercury.scss +8 -0
- data/app/assets/stylesheets/mercury/modal.scss +3 -1
- data/app/assets/stylesheets/mercury/statusbar.scss +1 -0
- data/app/views/layouts/mercury.html.haml +4 -4
- data/mercury-rails.gemspec +24 -2
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +39 -0
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +39 -0
- data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +27 -0
- data/spec/javascripts/mercury/dialogs/objectspanel_spec.js.coffee +32 -0
- data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +27 -0
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +32 -0
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +30 -0
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +216 -0
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +167 -0
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +54 -0
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +162 -0
- data/spec/javascripts/mercury/panel_spec.js.coffee +1 -1
- data/spec/javascripts/mercury/snippet_spec.js.coffee +1 -1
- data/spec/javascripts/spec_helper.js +0 -1
- data/spec/javascripts/templates/mercury/dialogs/backcolor.html +5 -0
- data/spec/javascripts/templates/mercury/dialogs/forecolor.html +5 -0
- data/spec/javascripts/templates/mercury/dialogs/formatblock.html +3 -0
- data/spec/javascripts/templates/mercury/dialogs/objectspanel.html +16 -0
- data/spec/javascripts/templates/mercury/dialogs/style.html +3 -0
- data/spec/javascripts/templates/mercury/modals/htmleditor.html +5 -0
- data/spec/javascripts/templates/mercury/modals/insertcharacter.html +5 -0
- data/spec/javascripts/templates/mercury/modals/insertlink.html +30 -0
- data/spec/javascripts/templates/mercury/modals/insertmedia.html +35 -0
- data/spec/javascripts/templates/mercury/modals/insertsnippet.html +6 -0
- data/spec/javascripts/templates/mercury/modals/inserttable.html +27 -0
- metadata +25 -3
data/README.rdoc
CHANGED
@@ -104,12 +104,17 @@ The feature list is actually pretty long, so here's a short list that need highl
|
|
104
104
|
|
105
105
|
== Installation
|
106
106
|
|
107
|
-
Include the gem in your Gemfile
|
107
|
+
Include the gem in your Gemfile and bundle to install the gem.
|
108
108
|
|
109
109
|
gem 'mercury-rails'
|
110
110
|
|
111
|
-
|
112
|
-
|
111
|
+
There's a migration for images that you'll need as well.
|
112
|
+
|
113
|
+
rake mercury_engine:install:migrations
|
114
|
+
rake db:migrate
|
115
|
+
|
116
|
+
To access the editor on any page simply browse to any existing content page and prefix it's url with /edit, so for
|
117
|
+
instance, localhost:3000/edit/content/page to edit the content on /content/page.
|
113
118
|
|
114
119
|
|
115
120
|
== Usage
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -261,7 +261,7 @@
|
|
261
261
|
#
|
262
262
|
injectedStyles: '''
|
263
263
|
.mercury-region, .mercury-textarea { min-height: 10px; outline: 1px dotted #09F }
|
264
|
-
.mercury-textarea { box-sizing: border-box; -moz-box-sizing: border-box; resize: vertical; }
|
264
|
+
.mercury-textarea { box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; resize: vertical; }
|
265
265
|
.mercury-region:focus, .mercury-region.focus, .mercury-textarea.focus { outline: none; -webkit-box-shadow: 0 0 10px #09F, 0 0 1px #045; box-shadow: 0 0 10px #09F, 0 0 1px #045 }
|
266
266
|
.mercury-region:after { content: '\00a0'; display: block; visibility: hidden; clear: both; height: 0; overflow: hidden; }
|
267
267
|
.mercury-region table, .mercury-region td { border: 1px dotted red; }
|
@@ -281,7 +281,7 @@
|
|
281
281
|
|
282
282
|
log: ->
|
283
283
|
if Mercury.debug && console
|
284
|
-
return if arguments[0] == 'hide:toolbar'
|
284
|
+
return if arguments[0] == 'hide:toolbar' || arguments[0] == 'show:toolbar'
|
285
285
|
try console.debug(arguments) catch e
|
286
286
|
|
287
287
|
|
@@ -22,7 +22,7 @@
|
|
22
22
|
selection = Mercury.region.selection()
|
23
23
|
|
24
24
|
# if we're editing a link prefill the information
|
25
|
-
container = selection.commonAncestor(true).closest('a') if selection.commonAncestor
|
25
|
+
container = selection.commonAncestor(true).closest('a') if selection && selection.commonAncestor
|
26
26
|
if container && container.length
|
27
27
|
existingLink = container
|
28
28
|
|
@@ -55,9 +55,6 @@
|
|
55
55
|
@element.find('#link_popup_height').val(href.match(/height=(\d+),/)[1])
|
56
56
|
@element.find('#popup_options').show()
|
57
57
|
|
58
|
-
# get the text content
|
59
|
-
@element.find('#link_text').val(selection.textContent())
|
60
|
-
|
61
58
|
# build the link on form submission
|
62
59
|
@element.find('form').submit (event) =>
|
63
60
|
event.preventDefault()
|
@@ -68,7 +65,7 @@
|
|
68
65
|
|
69
66
|
switch type
|
70
67
|
when 'existing_bookmark' then attrs = {href: "##{@element.find('#link_existing_bookmark').val()}"}
|
71
|
-
when 'new_bookmark' then attrs = {name: "
|
68
|
+
when 'new_bookmark' then attrs = {name: "#{@element.find('#link_new_bookmark').val()}"}
|
72
69
|
else attrs = {href: @element.find("#link_#{type}").val()}
|
73
70
|
|
74
71
|
switch target
|
@@ -89,4 +86,4 @@
|
|
89
86
|
else
|
90
87
|
Mercury.trigger('action', {action: 'insertLink', value: value})
|
91
88
|
|
92
|
-
|
89
|
+
@hide()
|
@@ -26,14 +26,14 @@
|
|
26
26
|
if src.indexOf('http://www.youtube.com') > -1
|
27
27
|
# it's a youtube video
|
28
28
|
@element.find('#media_youtube_url').val("http://youtu.be/#{src.match(/\/embed\/(\w+)/)[1]}")
|
29
|
-
@element.find('#media_youtube_width').val(iframe.
|
30
|
-
@element.find('#media_youtube_height').val(iframe.
|
29
|
+
@element.find('#media_youtube_width').val(iframe.width())
|
30
|
+
@element.find('#media_youtube_height').val(iframe.height())
|
31
31
|
@element.find('#media_youtube_url').focus()
|
32
32
|
else if src.indexOf('http://player.vimeo.com') > -1
|
33
33
|
# it's a vimeo video
|
34
34
|
@element.find('#media_vimeo_url').val("http://vimeo.com/#{src.match(/\/video\/(\w+)/)[1]}")
|
35
|
-
@element.find('#media_vimeo_width').val(iframe.
|
36
|
-
@element.find('#media_vimeo_height').val(iframe.
|
35
|
+
@element.find('#media_vimeo_width').val(iframe.width())
|
36
|
+
@element.find('#media_vimeo_height').val(iframe.height())
|
37
37
|
@element.find('#media_vimeo_url').focus()
|
38
38
|
|
39
39
|
# build the image or youtube embed on form submission
|
@@ -64,9 +64,9 @@
|
|
64
64
|
value = $('<iframe>', {
|
65
65
|
width: @element.find('#media_vimeo_width').val() || 400,
|
66
66
|
height: @element.find('#media_vimeo_height').val() || 225,
|
67
|
-
src: "http://player.vimeo.com/video/#{code}?title=1&
|
67
|
+
src: "http://player.vimeo.com/video/#{code}?title=1&byline=1&portrait=0&color=ffffff",
|
68
68
|
frameborder: 0,
|
69
69
|
})
|
70
70
|
Mercury.trigger('action', {action: 'insertHTML', value: value})
|
71
71
|
|
72
|
-
|
72
|
+
@hide()
|
@@ -1,11 +1,12 @@
|
|
1
1
|
@Mercury.modalHandlers.insertsnippet = ->
|
2
2
|
@element.find('form').submit (event) =>
|
3
3
|
event.preventDefault()
|
4
|
+
serializedForm = @element.find('form').serializeObject()
|
4
5
|
if Mercury.snippet
|
5
6
|
snippet = Mercury.snippet
|
6
|
-
snippet.setOptions(
|
7
|
+
snippet.setOptions(serializedForm)
|
7
8
|
Mercury.snippet = null
|
8
9
|
else
|
9
|
-
snippet = Mercury.Snippet.create(
|
10
|
+
snippet = Mercury.Snippet.create(@options.snippetName, serializedForm)
|
10
11
|
Mercury.trigger('action', {action: 'insertsnippet', value: snippet})
|
11
12
|
@hide()
|
@@ -1,12 +1,13 @@
|
|
1
1
|
@Mercury.modalHandlers.inserttable = ->
|
2
2
|
table = @element.find('#table_display table')
|
3
|
+
|
3
4
|
# make td's selectable
|
4
5
|
table.click (event) =>
|
5
6
|
cell = $(event.target)
|
6
7
|
table = cell.closest('table')
|
7
8
|
table.find('.selected').removeClass('selected')
|
8
9
|
cell.addClass('selected')
|
9
|
-
|
10
|
+
Mercury.tableEditor(table, cell)
|
10
11
|
|
11
12
|
# select the first td
|
12
13
|
firstCell = table.find('td, th').first()
|
@@ -34,11 +35,11 @@
|
|
34
35
|
table.attr({align: @element.find('#table_alignment').val()})
|
35
36
|
|
36
37
|
# set the border
|
37
|
-
@element.find('#table_border').
|
38
|
+
@element.find('#table_border').keyup =>
|
38
39
|
table.attr({border: parseInt(@element.find('#table_border').val())})
|
39
40
|
|
40
41
|
# set the cellspacing
|
41
|
-
@element.find('#table_spacing').
|
42
|
+
@element.find('#table_spacing').keyup =>
|
42
43
|
table.attr({cellspacing: parseInt(@element.find('#table_spacing').val())})
|
43
44
|
|
44
45
|
# build the table on form submission
|
@@ -47,10 +48,9 @@
|
|
47
48
|
table.find('.selected').removeClass('selected')
|
48
49
|
table.find('td, th').html(' ')
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
tableHTML = tableHTML.replace(/(<\/.*?>|<table.*?>|<tbody>|<tr>)/g, '$1\n')
|
51
|
+
html = $('<div>').html(table).html()
|
52
|
+
value = html.replace(/^\s+|\n/gm, '').replace(/(<\/.*?>|<table.*?>|<tbody>|<tr>)/g, '$1\n')
|
53
53
|
|
54
|
-
Mercury.trigger('action', {action: 'insertHTML', value:
|
55
|
-
|
54
|
+
Mercury.trigger('action', {action: 'insertHTML', value: value})
|
55
|
+
@hide()
|
56
56
|
|
@@ -31,6 +31,12 @@ class @Mercury.PageEditor
|
|
31
31
|
@document = $(@iframe.get(0).contentWindow.document)
|
32
32
|
$("<style mercury-styles=\"true\">").html(Mercury.config.injectedStyles).appendTo(@document.find('head'))
|
33
33
|
|
34
|
+
# jquery: make jQuery evaluate scripts within the context of the iframe window -- note that this means that we
|
35
|
+
# can't use eval in mercury (eg. script tags in ajax responses) because it will eval in the wrong context (you can
|
36
|
+
# use top.Mercury though, if you keep it in mind)
|
37
|
+
iframeWindow = @iframe.get(0).contentWindow
|
38
|
+
$.globalEval = (data) -> (iframeWindow.execScript || (data) -> iframeWindow["eval"].call(iframeWindow, data))(data) if (data && /\S/.test(data))
|
39
|
+
|
34
40
|
@bindEvents()
|
35
41
|
@initializeRegions()
|
36
42
|
@finalizeInterface()
|
@@ -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'})
|
6
|
+
Mercury.modal("/mercury/snippets/#{name}/options", {title: 'Snippet Options', handler: 'insertsnippet', snippetName: name})
|
7
7
|
Mercury.snippet = null
|
8
8
|
|
9
9
|
|
@@ -74,6 +74,14 @@ form, form ul, form ol, form li, form fieldset, form p, .filter {
|
|
74
74
|
width: 74%;
|
75
75
|
box-sizing: border-box;
|
76
76
|
-moz-box-sizing: border-box;
|
77
|
+
-webkit-box-sizing: border-box;
|
78
|
+
}
|
79
|
+
li.boolean {
|
80
|
+
margin-left: 23%;
|
81
|
+
padding-left: 9px;
|
82
|
+
label {
|
83
|
+
width: auto;
|
84
|
+
}
|
77
85
|
}
|
78
86
|
fieldset.buttons {
|
79
87
|
clear: both;
|
@@ -77,8 +77,9 @@
|
|
77
77
|
position: relative;
|
78
78
|
overflow: auto;
|
79
79
|
float: left;
|
80
|
-
-moz-box-sizing: border-box;
|
81
80
|
box-sizing: border-box;
|
81
|
+
-moz-box-sizing: border-box;
|
82
|
+
-webkit-box-sizing: border-box;
|
82
83
|
padding: 20px 20px 10px;
|
83
84
|
font-family: Helvetica, Tahoma, Arial, sans-serif;
|
84
85
|
color: #000;
|
@@ -109,6 +110,7 @@
|
|
109
110
|
padding: 0;
|
110
111
|
box-sizing: border-box;
|
111
112
|
-moz-box-sizing: border-box;
|
113
|
+
-webkit-box-sizing: border-box;
|
112
114
|
}
|
113
115
|
}
|
114
116
|
/*
|
@@ -5,8 +5,8 @@
|
|
5
5
|
= csrf_meta_tags
|
6
6
|
= stylesheet_link_tag "mercury"
|
7
7
|
= javascript_include_tag "mercury"
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
-#:javascript
|
9
|
+
-# Mercury.Snippet.load({
|
10
|
+
-# 'snippet_1': {name: 'example', options: {'options[favorite_beer]': "miller_lite", 'options[first_name]': "1"}},
|
11
|
+
-# });
|
12
12
|
%body= javascript_tag 'new Mercury.PageEditor()'
|
data/mercury-rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mercury-rails}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeremy Jackson"]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-19}
|
13
13
|
s.description = %q{A fully featured and advanced HTML5 WYSIWYG editor written in CoffeeScript on top of Rails 3.1}
|
14
14
|
s.email = %q{jejacks0n@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -120,8 +120,19 @@ Gem::Specification.new do |s|
|
|
120
120
|
"log/.gitkeep",
|
121
121
|
"mercury-rails.gemspec",
|
122
122
|
"spec/javascripts/mercury/dialog_spec.js.coffee",
|
123
|
+
"spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee",
|
124
|
+
"spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee",
|
125
|
+
"spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee",
|
126
|
+
"spec/javascripts/mercury/dialogs/objectspanel_spec.js.coffee",
|
127
|
+
"spec/javascripts/mercury/dialogs/style_spec.js.coffee",
|
123
128
|
"spec/javascripts/mercury/history_buffer_spec.js.coffee",
|
124
129
|
"spec/javascripts/mercury/mercury_spec.js.coffee",
|
130
|
+
"spec/javascripts/mercury/modals/htmleditor_spec.js.coffee",
|
131
|
+
"spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee",
|
132
|
+
"spec/javascripts/mercury/modals/insertlink_spec.js.coffee",
|
133
|
+
"spec/javascripts/mercury/modals/insertmedia_spec.js.coffee",
|
134
|
+
"spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee",
|
135
|
+
"spec/javascripts/mercury/modals/inserttable_spec.js.coffee",
|
125
136
|
"spec/javascripts/mercury/native_extensions_spec.js.coffee",
|
126
137
|
"spec/javascripts/mercury/page_editor_spec.js.coffee",
|
127
138
|
"spec/javascripts/mercury/palette_spec.js.coffee",
|
@@ -144,6 +155,17 @@ Gem::Specification.new do |s|
|
|
144
155
|
"spec/javascripts/responses/blank.html",
|
145
156
|
"spec/javascripts/spec_helper.js",
|
146
157
|
"spec/javascripts/templates/mercury/dialog.html",
|
158
|
+
"spec/javascripts/templates/mercury/dialogs/backcolor.html",
|
159
|
+
"spec/javascripts/templates/mercury/dialogs/forecolor.html",
|
160
|
+
"spec/javascripts/templates/mercury/dialogs/formatblock.html",
|
161
|
+
"spec/javascripts/templates/mercury/dialogs/objectspanel.html",
|
162
|
+
"spec/javascripts/templates/mercury/dialogs/style.html",
|
163
|
+
"spec/javascripts/templates/mercury/modals/htmleditor.html",
|
164
|
+
"spec/javascripts/templates/mercury/modals/insertcharacter.html",
|
165
|
+
"spec/javascripts/templates/mercury/modals/insertlink.html",
|
166
|
+
"spec/javascripts/templates/mercury/modals/insertmedia.html",
|
167
|
+
"spec/javascripts/templates/mercury/modals/insertsnippet.html",
|
168
|
+
"spec/javascripts/templates/mercury/modals/inserttable.html",
|
147
169
|
"spec/javascripts/templates/mercury/page_editor.html",
|
148
170
|
"spec/javascripts/templates/mercury/palette.html",
|
149
171
|
"spec/javascripts/templates/mercury/panel.html",
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require '/assets/mercury/mercury.js'
|
2
|
+
|
3
|
+
describe "Mercury.dialogHandlers.backcolor", ->
|
4
|
+
|
5
|
+
template 'mercury/dialogs/backcolor.html'
|
6
|
+
|
7
|
+
beforeEach ->
|
8
|
+
@dialog = {element: $('#test'), button: $('#button')}
|
9
|
+
Mercury.dialogHandlers.backcolor.call(@dialog)
|
10
|
+
|
11
|
+
describe "when a .picker or .last-picked element is clicked", ->
|
12
|
+
|
13
|
+
it "sets the last picked color to whatever was selected", ->
|
14
|
+
$('.last-picked').css({background: '#0000FF'})
|
15
|
+
jasmine.simulate.click($('#white').get(0))
|
16
|
+
expect($('.last-picked').css('backgroundColor')).toEqual('rgb(255, 255, 255)')
|
17
|
+
jasmine.simulate.click($('#red').get(0))
|
18
|
+
expect($('.last-picked').css('backgroundColor')).toEqual('rgb(255, 0, 0)')
|
19
|
+
|
20
|
+
it "sets the background color of the button", ->
|
21
|
+
$('#button').css({background: '#0000FF'})
|
22
|
+
jasmine.simulate.click($('#white').get(0))
|
23
|
+
expect($('#button').css('backgroundColor')).toEqual('rgb(255, 255, 255)')
|
24
|
+
jasmine.simulate.click($('#red').get(0))
|
25
|
+
expect($('#button').css('backgroundColor')).toEqual('rgb(255, 0, 0)')
|
26
|
+
|
27
|
+
it "triggers an action", ->
|
28
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
29
|
+
jasmine.simulate.click($('#white').get(0))
|
30
|
+
expect(spy.callCount).toEqual(1)
|
31
|
+
expect(spy.argsForCall[0]).toEqual(['action', {action: 'backcolor', value: 'rgb(255, 255, 255)'}])
|
32
|
+
|
33
|
+
|
34
|
+
describe "when any other element is clicked", ->
|
35
|
+
|
36
|
+
it "does nothing", ->
|
37
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
38
|
+
jasmine.simulate.click($('#green').get(0))
|
39
|
+
expect(spy.callCount).toEqual(0)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require '/assets/mercury/mercury.js'
|
2
|
+
|
3
|
+
describe "Mercury.dialogHandlers.forecolor", ->
|
4
|
+
|
5
|
+
template 'mercury/dialogs/forecolor.html'
|
6
|
+
|
7
|
+
beforeEach ->
|
8
|
+
@dialog = {element: $('#test'), button: $('#button')}
|
9
|
+
Mercury.dialogHandlers.forecolor.call(@dialog)
|
10
|
+
|
11
|
+
describe "when a .picker or .last-picked element is clicked", ->
|
12
|
+
|
13
|
+
it "sets the last picked color to whatever was selected", ->
|
14
|
+
$('.last-picked').css({background: '#0000FF'})
|
15
|
+
jasmine.simulate.click($('#white').get(0))
|
16
|
+
expect($('.last-picked').css('backgroundColor')).toEqual('rgb(255, 255, 255)')
|
17
|
+
jasmine.simulate.click($('#red').get(0))
|
18
|
+
expect($('.last-picked').css('backgroundColor')).toEqual('rgb(255, 0, 0)')
|
19
|
+
|
20
|
+
it "sets the background color of the button", ->
|
21
|
+
$('#button').css({background: '#0000FF'})
|
22
|
+
jasmine.simulate.click($('#white').get(0))
|
23
|
+
expect($('#button').css('backgroundColor')).toEqual('rgb(255, 255, 255)')
|
24
|
+
jasmine.simulate.click($('#red').get(0))
|
25
|
+
expect($('#button').css('backgroundColor')).toEqual('rgb(255, 0, 0)')
|
26
|
+
|
27
|
+
it "triggers an action", ->
|
28
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
29
|
+
jasmine.simulate.click($('#white').get(0))
|
30
|
+
expect(spy.callCount).toEqual(1)
|
31
|
+
expect(spy.argsForCall[0]).toEqual(['action', {action: 'forecolor', value: 'rgb(255, 255, 255)'}])
|
32
|
+
|
33
|
+
|
34
|
+
describe "when any other element is clicked", ->
|
35
|
+
|
36
|
+
it "does nothing", ->
|
37
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
38
|
+
jasmine.simulate.click($('#green').get(0))
|
39
|
+
expect(spy.callCount).toEqual(0)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require '/assets/mercury/mercury.js'
|
2
|
+
|
3
|
+
describe "Mercury.dialogHandlers.formatblock", ->
|
4
|
+
|
5
|
+
template 'mercury/dialogs/formatblock.html'
|
6
|
+
|
7
|
+
beforeEach ->
|
8
|
+
@dialog = {element: $('#test')}
|
9
|
+
Mercury.dialogHandlers.formatblock.call(@dialog)
|
10
|
+
|
11
|
+
describe "when an element with a data-tag attribute is clicked", ->
|
12
|
+
|
13
|
+
it "triggers an action", ->
|
14
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
15
|
+
jasmine.simulate.click($('#h1').get(0))
|
16
|
+
expect(spy.callCount).toEqual(1)
|
17
|
+
expect(spy.argsForCall[0]).toEqual(['action', {action: 'formatblock', value: 'h1'}])
|
18
|
+
jasmine.simulate.click($('#div').get(0))
|
19
|
+
expect(spy.argsForCall[1]).toEqual(['action', {action: 'formatblock', value: 'pre'}])
|
20
|
+
|
21
|
+
|
22
|
+
describe "when any other element is clicked", ->
|
23
|
+
|
24
|
+
it "does nothing", ->
|
25
|
+
spy = spyOn(Mercury, 'trigger').andCallFake(=>)
|
26
|
+
jasmine.simulate.click($('#em').get(0))
|
27
|
+
expect(spy.callCount).toEqual(0)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require '/assets/mercury/mercury.js'
|
2
|
+
|
3
|
+
describe "Mercury.dialogHandlers.backcolor", ->
|
4
|
+
|
5
|
+
template 'mercury/dialogs/objectspanel.html'
|
6
|
+
|
7
|
+
beforeEach ->
|
8
|
+
@dialog = {element: $('#test'), button: $('#button')}
|
9
|
+
Mercury.dialogHandlers.objectspanel.call(@dialog)
|
10
|
+
|
11
|
+
describe "filter", ->
|
12
|
+
|
13
|
+
it "filters on keypress", ->
|
14
|
+
$('#filter').val('foo')
|
15
|
+
jasmine.simulate.keyup($('#filter').get(0))
|
16
|
+
expect($('#first').css('display')).toNotEqual('none')
|
17
|
+
expect($('#second').css('display')).toEqual('none')
|
18
|
+
|
19
|
+
$('#filter').val('b')
|
20
|
+
jasmine.simulate.keyup($('#filter').get(0))
|
21
|
+
expect($('#first').css('display')).toNotEqual('none')
|
22
|
+
expect($('#second').css('display')).toNotEqual('none')
|
23
|
+
|
24
|
+
$('#filter').val('baz')
|
25
|
+
jasmine.simulate.keyup($('#filter').get(0))
|
26
|
+
expect($('#first').css('display')).toEqual('none')
|
27
|
+
expect($('#second').css('display')).toNotEqual('none')
|
28
|
+
|
29
|
+
|
30
|
+
describe "dragging an image with a data-snippet attribute", ->
|
31
|
+
|
32
|
+
it "sets the active snippet", ->
|