Permalink
Browse files

Merge jejacks0n-master in to master

  • Loading branch information...
2 parents b7edbc7 + 275d0c7 commit e9e625ce1621a8f87cca9899429551efb23008d9 @mixonic mixonic committed Mar 12, 2012
View
@@ -269,12 +269,12 @@ default it will use JSON, that JSON looks like:
}
Where it gets saved to is also up to you.. by default it submits a post to the current url, but you can adjust this by
-setting Mercury.saveURL, or passing it into the Mercury.PageEditor constructor.. how you do this is dependent on how
-you're using loading mercury (via the loader, or by using the route method). In both situations setting Mercury.saveURL
+setting Mercury.saveUrl, or passing it into the Mercury.PageEditor constructor.. how you do this is dependent on how
+you're using loading mercury (via the loader, or by using the route method). In both situations setting Mercury.saveUrl
is the most consistent.
jQuery(window).on('mercury:ready', function() {
- Mercury.saveURL = '/contents';
+ Mercury.saveUrl = '/contents';
});
Assuming you have a ContentsController and a RESTful route, this will make it through to the create action. Where you
View
@@ -23,15 +23,17 @@ Gem::Specification.new do |s|
# Development Dependencies
s.add_development_dependency('sprockets', '~> 2.1')
- s.add_development_dependency('rocco', '>= 0.8.2')
+ s.add_development_dependency('rocco')
s.add_development_dependency('uglifier')
- s.add_development_dependency('jquery-rails', '~> 1.0')
+ s.add_development_dependency('jquery-rails')
s.add_development_dependency('sqlite3')
s.add_development_dependency('ruby-debug19')
+ s.add_development_dependency('sprockets-helpers')
+
+ s.add_development_dependency('rspec-core', '>= 2.8.0')
s.add_development_dependency('evergreen', '>= 1.0.0')
s.add_development_dependency('selenium-webdriver', '>= 2.20.0')
s.add_development_dependency('cucumber-rails', '>= 1.3.0')
- s.add_development_dependency('fuubar-cucumber')
s.add_development_dependency('capybara')
s.add_development_dependency('capybara-firebug', '>= 1.1.0')
s.add_development_dependency('database_cleaner')
@@ -13475,6 +13475,9 @@ Showdown.converter = function() {
if (!(this.options.visible === false || this.options.visible === 'no')) {
this.options.visible = true;
}
+ if (!(this.options.saveDataType === false || this.options.saveDataType)) {
+ this.options.saveDataType = 'json';
+ }
this.visible = this.options.visible;
window.mercuryInstance = this;
this.regions = [];
@@ -13767,15 +13770,15 @@ Showdown.converter = function() {
PageEditor.prototype.save = function(callback) {
var data, method, url, _ref, _ref2,
_this = this;
- url = (_ref = (_ref2 = this.saveUrl) != null ? _ref2 : Mercury.saveURL) != null ? _ref : this.iframeSrc();
+ url = (_ref = (_ref2 = this.saveUrl) != null ? _ref2 : Mercury.saveUrl) != null ? _ref : this.iframeSrc();
data = this.serialize();
Mercury.log('saving', data);
if (this.options.saveStyle !== 'form') data = jQuery.toJSON(data);
if (this.options.saveMethod === 'PUT') method = 'PUT';
return jQuery.ajax(url, {
headers: Mercury.ajaxHeaders(),
type: method || 'POST',
- dataType: this.options.saveDataType || 'json',
+ dataType: this.options.saveDataType,
data: {
content: data,
_method: method
@@ -14471,7 +14474,7 @@ Showdown.converter = function() {
"class": 'mercury-panel loading',
style: 'display:none;'
});
- this.titleElement = jQuery("<h1>" + (Mercury.I18n(this.options.title)) + "</h1>").appendTo(this.element);
+ this.titleElement = jQuery("<h1><span>" + (Mercury.I18n(this.options.title)) + "<span></h1>").appendTo(this.element);
this.paneElement = jQuery('<div>', {
"class": 'mercury-panel-pane'
}).appendTo(this.element);
@@ -14600,7 +14603,7 @@ Showdown.converter = function() {
_this = this;
elementWidth = this.element.width();
return this.element.draggable({
- handle: 'h1',
+ handle: 'h1 span',
axis: 'x',
opacity: 0.70,
scroll: false,
@@ -15507,10 +15510,10 @@ Showdown.converter = function() {
_results.push(this.handled[type] = new Mercury.Panel(url, this.name, this.defaultDialogOptions()));
break;
case 'modal':
- _results.push(this.handled[type] = jQuery.isFunction(mixed) ? mixed.apply(this, this.name) : mixed);
+ _results.push(this.handled[type] = jQuery.isFunction(mixed) ? mixed.call(this, this.name) : mixed);
break;
case 'lightview':
- _results.push(this.handled[type] = jQuery.isFunction(mixed) ? mixed.apply(this, this.name) : mixed);
+ _results.push(this.handled[type] = jQuery.isFunction(mixed) ? mixed.call(this, this.name) : mixed);
break;
default:
throw Mercury.I18n('Unknown button type \"%s\" used for the \"%s\" button.', type, this.name);
@@ -15962,8 +15965,17 @@ Showdown.converter = function() {
};
Snippet.create = function(name, options) {
- var identity, instance;
- identity = "snippet_" + this.all.length;
+ var i, identity, instance, snippet, _len, _ref;
+ if (this.all.length > 0) {
+ identity = "snippet_0";
+ _ref = this.all;
+ for (i = 0, _len = _ref.length; i < _len; i++) {
+ snippet = _ref[i];
+ if (snippet.identity === identity) identity = "snippet_" + (i + 1);
+ }
+ } else {
+ identity = "snippet_" + this.all.length;
+ }
instance = new Mercury.Snippet(name, identity, options);
this.all.push(instance);
return instance;

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -260,6 +260,10 @@ form fieldset.buttons .commit input:hover {
cursor: move;
text-shadow: 1px 1px 2px rgba(0,0,0, .9);
}
+.mercury-panel h1 span {
+ display: block;
+ width: 100%;
+}
.mercury-panel h1 a.mercury-panel-close {
position: absolute;
right: -5px;
@@ -36,9 +36,9 @@ describe "Mercury.PageEditor", ->
expect(window.mercuryInstance).toEqual(@pageEditor)
it "accepts a saveUrl, and options", ->
- @pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar'})
+ @pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar', saveDataType: 'text'})
expect(@pageEditor.saveUrl).toEqual('/foo/1')
- expect(@pageEditor.options).toEqual({foo: 'bar', visible: true})
+ expect(@pageEditor.options).toEqual({foo: 'bar', saveDataType: 'text', visible: true})
it "sets the visible option to true unless it's set", ->
@pageEditor = new Mercury.PageEditor('/foo/1', {foo: 'bar', visible: false})
@@ -650,12 +650,12 @@ describe "Mercury.PageEditor", ->
expect(@ajaxSpy.argsForCall[0][0]).toEqual('/foo/bar')
@pageEditor.saveUrl = null
- Mercury.saveURL = '/foo/bit'
+ Mercury.saveUrl = '/foo/bit'
@pageEditor.save()
expect(@ajaxSpy.argsForCall[1][0]).toEqual('/foo/bit')
@pageEditor.saveUrl = null
- Mercury.saveURL = null
+ Mercury.saveUrl = null
@pageEditor.save()
expect(@ajaxSpy.argsForCall[2][0]).toEqual('/foo/baz')
@@ -22,7 +22,7 @@ describe "Mercury.Panel", ->
html = $('<div>').html(@panel.element).html()
expect(html).toContain('class="mercury-panel loading"')
expect(html).toContain('style="display:none;"')
- expect(html).toContain('<h1>foo panel</h1><div class="mercury-panel-pane"></div>')
+ expect(html).toContain('<h1><span>foo panel<span></span></span></h1><div class="mercury-panel-pane"></div>')
expect(html).not.toContain('class="mercury-panel-close"')
it "appends to any element", ->
@@ -159,16 +159,14 @@ describe "Mercury.Panel", ->
it "sets the element html to be the data passed to it", ->
@panel.loadContent('<span>hello world!</span>')
html = @panel.element.html()
- expect(html).toContain('<h1>foo panel</h1>')
expect(html).toContain('class="mercury-panel-pane"')
expect(html).toContain('style="visibility: hidden;')
expect(html).toContain('hello world!')
- it "sets the element html to be the data passed to it", ->
+ it "sets the element html to be the data passed to it -- translated", ->
Mercury.config.localization.enabled = true
@panel.loadContent('<span>hello world!</span>')
html = @panel.element.html()
- expect(html).toContain('<h1>foo panel</h1>')
expect(html).toContain('class="mercury-panel-pane"')
expect(html).toContain('style="visibility: hidden;')
expect(html).toContain('bork! bork!')
@@ -218,7 +218,15 @@ describe "Mercury.Snippet class methods", ->
it "pushes into the collection array", ->
Mercury.Snippet.create('foo', {foo: 'bar'})
expect(Mercury.Snippet.all.length).toEqual(1)
-
+
+ describe "when an snuppet exist with an identical identity", ->
+ it "generates a unique identity", ->
+ Mercury.Snippet.load
+ snippet_1: {name: 'foo', options: {foo: 'bar'}}
+ snippet_2: {name: 'bar', options: {baz: 'pizza'}}
+
+ ret = Mercury.Snippet.create('noobie', {noobie: 'one'})
+ expect(ret.identity).toEqual('snippet_0')
describe ".find", ->
@@ -9,6 +9,7 @@ class @Mercury.PageEditor
throw Mercury.I18n('Mercury.PageEditor can only be instantiated once.') if window.mercuryInstance
@options.visible = true unless (@options.visible == false || @options.visible == 'no')
+ @options.saveDataType = 'json' unless (@options.saveDataType == false || @options.saveDataType)
@visible = @options.visible
window.mercuryInstance = @
@@ -198,15 +199,15 @@ class @Mercury.PageEditor
save: (callback) ->
- url = @saveUrl ? Mercury.saveURL ? @iframeSrc()
+ url = @saveUrl ? Mercury.saveUrl ? @iframeSrc()
data = @serialize()
Mercury.log('saving', data)
data = jQuery.toJSON(data) unless @options.saveStyle == 'form'
method = 'PUT' if @options.saveMethod == 'PUT'
jQuery.ajax url, {
headers: Mercury.ajaxHeaders()
type: method || 'POST'
- dataType: @options.saveDataType || 'json'
+ dataType: @options.saveDataType,
data: {content: data, _method: method}
success: =>
Mercury.changes = false
@@ -6,7 +6,7 @@ class @Mercury.Panel extends Mercury.Dialog
build: ->
@element = jQuery('<div>', {class: 'mercury-panel loading', style: 'display:none;'})
- @titleElement = jQuery("<h1>#{Mercury.I18n(@options.title)}</h1>").appendTo(@element)
+ @titleElement = jQuery("<h1><span>#{Mercury.I18n(@options.title)}<span></h1>").appendTo(@element)
@paneElement = jQuery('<div>', {class: 'mercury-panel-pane'}).appendTo(@element)
if @options.closeButton
@@ -100,7 +100,7 @@ class @Mercury.Panel extends Mercury.Dialog
makeDraggable: ->
elementWidth = @element.width()
@element.draggable {
- handle: 'h1',
+ handle: 'h1 span',
axis: 'x',
opacity: 0.70
scroll: false,
@@ -1,7 +1,7 @@
class Mercury.PageEditor extends Mercury.PageEditor
save: ->
- url = @saveUrl ? Mercury.saveURL ? @iframeSrc()
+ url = @saveUrl ? Mercury.saveUrl ? @iframeSrc()
data = @serializeAsXml()
console.log('saving', data)
return
@@ -25,4 +25,4 @@ class Mercury.PageEditor extends Mercury.PageEditor
for snippetName, snippetProperties of regionProperties['snippets']
snippetNodes.push("<#{snippetName} name=\"#{snippetProperties['name']}\"><![CDATA[#{jQuery.toJSON(snippetProperties['options'])}]]></#{snippetName}>")
regionNodes.push("<region name=\"#{regionName}\" type=\"#{regionProperties['type']}\"><value>\n<![CDATA[#{regionProperties['value']}]]>\n</value><snippets>#{snippetNodes.join('')}</snippets></region>")
- return "<regions>#{regionNodes.join('')}</regions>"
+ return "<regions>#{regionNodes.join('')}</regions>"
@@ -12,7 +12,13 @@ class @Mercury.Snippet
@create: (name, options) ->
- identity = "snippet_#{@all.length}"
+ if @all.length > 0
+ identity = "snippet_0"
+ for snippet, i in @all
+ identity = "snippet_#{i+1}" if snippet.identity == identity
+ else
+ identity = "snippet_#{@all.length}"
+
instance = new Mercury.Snippet(name, identity, options)
@all.push(instance)
return instance
@@ -49,10 +49,10 @@ class @Mercury.Toolbar.Button
@handled[type] = new Mercury.Panel(url, @name, @defaultDialogOptions())
when 'modal'
- @handled[type] = if jQuery.isFunction(mixed) then mixed.apply(@, @name) else mixed
+ @handled[type] = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
when 'lightview'
- @handled[type] = if jQuery.isFunction(mixed) then mixed.apply(@, @name) else mixed
+ @handled[type] = if jQuery.isFunction(mixed) then mixed.call(@, @name) else mixed
else throw Mercury.I18n('Unknown button type \"%s\" used for the \"%s\" button.', type, @name)
@@ -78,6 +78,10 @@
cursor: move;
text-shadow: 1px 1px 2px rgba(0,0,0, .9);
}
+.mercury-panel h1 span {
+ display: block;
+ width: 100%;
+}
.mercury-panel h1 a.mercury-panel-close {
position: absolute;
right: -5px;

0 comments on commit e9e625c

Please sign in to comment.