editor: Update defaults in social block and use stored defaults for new social block
This commit is contained in:
@@ -69,6 +69,7 @@ define([
|
||||
initialize: function () {
|
||||
this.get('icons').on('add remove change', this._iconsChanged, this);
|
||||
this.on('change:iconSet', this.changeIconSet, this);
|
||||
this.on('change', this._updateDefaults, this);
|
||||
},
|
||||
getIconSet: function () {
|
||||
return App.getAvailableStyles().get('socialIconSets').get(this.get('iconSet'));
|
||||
@@ -80,6 +81,7 @@ define([
|
||||
});
|
||||
},
|
||||
_iconsChanged: function () {
|
||||
this._updateDefaults();
|
||||
App.getChannel().trigger('autoSave');
|
||||
}
|
||||
});
|
||||
@@ -270,30 +272,7 @@ define([
|
||||
DraggableBehavior: {
|
||||
cloneOriginal: true,
|
||||
drop: function () {
|
||||
return new Module.SocialBlockModel({
|
||||
type: 'social',
|
||||
iconSet: 'default',
|
||||
icons: [
|
||||
{
|
||||
type: 'socialIcon',
|
||||
iconType: 'facebook',
|
||||
link: 'http://www.facebook.com',
|
||||
image: App.getAvailableStyles().get('socialIconSets.default.facebook'),
|
||||
height: '32px',
|
||||
width: '32px',
|
||||
text: 'Facebook'
|
||||
},
|
||||
{
|
||||
type: 'socialIcon',
|
||||
iconType: 'twitter',
|
||||
link: 'http://www.twitter.com',
|
||||
image: App.getAvailableStyles().get('socialIconSets.default.twitter'),
|
||||
height: '32px',
|
||||
width: '32px',
|
||||
text: 'Twitter'
|
||||
}
|
||||
]
|
||||
}, { parse: true });
|
||||
return new Module.SocialBlockModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,10 +9,17 @@ define([
|
||||
describe('Social', function () {
|
||||
describe('block model', function () {
|
||||
var model;
|
||||
var sandbox;
|
||||
|
||||
beforeEach(function () {
|
||||
global.stubChannel(EditorApplication);
|
||||
global.stubConfig(EditorApplication);
|
||||
model = new (SocialBlock.SocialBlockModel)();
|
||||
sandbox = sinon.sandbox.create();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it('has a social type', function () {
|
||||
@@ -39,6 +46,22 @@ define([
|
||||
|
||||
expect(model.get('iconSet')).to.equal('customConfigIconSet');
|
||||
});
|
||||
|
||||
it('updates blockDefaults.social when changed', function () {
|
||||
var stub = sandbox.stub(EditorApplication.getConfig(), 'set');
|
||||
model.trigger('change');
|
||||
expect(stub.callCount).to.equal(1);
|
||||
expect(stub.getCall(0).args[0]).to.equal('blockDefaults.social');
|
||||
expect(stub.getCall(0).args[1]).to.deep.equal(model.toJSON());
|
||||
});
|
||||
|
||||
it('updates blockDefaults.social when icons changed', function () {
|
||||
var stub = sandbox.stub(EditorApplication.getConfig(), 'set');
|
||||
model.get('icons').trigger('change');
|
||||
expect(stub.callCount).to.equal(1);
|
||||
expect(stub.getCall(0).args[0]).to.equal('blockDefaults.social');
|
||||
expect(stub.getCall(0).args[1]).to.deep.equal(model.toJSON());
|
||||
});
|
||||
});
|
||||
|
||||
describe('icon model', function () {
|
||||
|
Reference in New Issue
Block a user