diff --git a/assets/js/src/newsletter_editor/blocks/button.js b/assets/js/src/newsletter_editor/blocks/button.js index 8fd8b9ea6e..53b0e05660 100644 --- a/assets/js/src/newsletter_editor/blocks/button.js +++ b/assets/js/src/newsletter_editor/blocks/button.js @@ -32,6 +32,7 @@ define([ fontColor: '#000000', fontFamily: 'Arial', fontSize: '16px', + fontWeight: 'normal', // 'normal'|'bold' textAlign: 'center', }, }, @@ -72,6 +73,7 @@ define([ "change .mailpoet_field_button_font_size": _.partial(this.changeField, "styles.block.fontSize"), "change .mailpoet_field_button_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"), "change .mailpoet_field_button_border_color": _.partial(this.changeColorField, "styles.block.borderColor"), + "change .mailpoet_field_button_font_weight": "changeFontWeight", "input .mailpoet_field_button_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)), "change .mailpoet_field_button_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)), @@ -128,6 +130,13 @@ define([ this.$(fieldToUpdate).val(jQuery(event.target).val()); callable(event); }, + changeFontWeight: function(event) { + var checked = !!jQuery(event.target).prop('checked'); + this.model.set( + 'styles.block.fontWeight', + (checked) ? jQuery(event.target).val() : 'normal' + ); + } }); Module.ButtonWidgetView = base.WidgetView.extend({ diff --git a/assets/js/src/newsletter_editor/blocks/posts.js b/assets/js/src/newsletter_editor/blocks/posts.js index f93b7ac3d0..7bf302ae0c 100644 --- a/assets/js/src/newsletter_editor/blocks/posts.js +++ b/assets/js/src/newsletter_editor/blocks/posts.js @@ -111,7 +111,7 @@ define([ data.posts = this.get('_selectedPosts').pluck('ID'); if (data.posts.length === 0) { - this.get('_transformedPosts.blocks').reset(); + this.get('_transformedPosts').get('blocks').reset(); return; } diff --git a/lib/Config/PopulatorData/Templates/FranksRoastHouseTemplate.php b/lib/Config/PopulatorData/Templates/FranksRoastHouseTemplate.php index 1772d3d98b..9230cc3920 100644 --- a/lib/Config/PopulatorData/Templates/FranksRoastHouseTemplate.php +++ b/lib/Config/PopulatorData/Templates/FranksRoastHouseTemplate.php @@ -168,6 +168,7 @@ class FranksRoastHouseTemplate { "fontColor" => "#ffffff", "fontFamily" => "Arial", "fontSize" => "14px", + "fontWeight" => "normal", "textAlign" => "center" ) ) diff --git a/lib/Config/PopulatorData/Templates/PostNotificationsBlankTemplate.php b/lib/Config/PopulatorData/Templates/PostNotificationsBlankTemplate.php index c763f3f1d3..39a9615e68 100644 --- a/lib/Config/PopulatorData/Templates/PostNotificationsBlankTemplate.php +++ b/lib/Config/PopulatorData/Templates/PostNotificationsBlankTemplate.php @@ -325,6 +325,7 @@ class PostNotificationsBlankTemplate { "fontColor" => "#ffffff", "fontFamily" => "Arial", "fontSize" => "18px", + "fontWeight" => "normal", "textAlign" => "center" ) ) diff --git a/tests/javascript/newsletter_editor/blocks/button.spec.js b/tests/javascript/newsletter_editor/blocks/button.spec.js index 327439006f..6343933094 100644 --- a/tests/javascript/newsletter_editor/blocks/button.spec.js +++ b/tests/javascript/newsletter_editor/blocks/button.spec.js @@ -63,6 +63,10 @@ define([ expect(model.get('styles.block.fontSize')).to.match(/^\d+px$/); }); + it("has a text font weight", function () { + expect(model.get('styles.block.fontWeight')).to.match(/^(bold|normal)$/); + }); + it("has width", function () { expect(model.get('styles.block.width')).to.match(/^\d+px$/); }); @@ -78,7 +82,7 @@ define([ }); it("triggers autosave if any attribute changes", function () { - var mock = sinon.mock().exactly(11).withArgs('autoSave'); + var mock = sinon.mock().exactly(12).withArgs('autoSave'); EditorApplication.getChannel = sinon.stub().returns({ trigger: mock, }); @@ -93,6 +97,7 @@ define([ model.set('styles.block.fontColor', '#345678'); model.set('styles.block.fontFamily', 'Some other style'); model.set('styles.block.fontSize', '10px'); + model.set('styles.block.fontWeight', 'bold'); mock.verify(); }); @@ -114,6 +119,7 @@ define([ fontColor: '#345678', fontFamily: 'Tahoma', fontSize: '30px', + fontWeight: 'bold', }, }, }, @@ -133,6 +139,7 @@ define([ expect(model.get('styles.block.fontColor')).to.equal('#345678'); expect(model.get('styles.block.fontFamily')).to.equal('Tahoma'); expect(model.get('styles.block.fontSize')).to.equal('30px'); + expect(model.get('styles.block.fontWeight')).to.equal('bold'); }); }); @@ -179,6 +186,7 @@ define([ fontColor: '#345678', fontFamily: 'Arial', fontSize: '12px', + fontWeight: 'bold', }, }, }); @@ -235,6 +243,10 @@ define([ it('has a specified font size', function () { expect(view.$('.mailpoet_editor_button').css('font-size')).to.equal(model.get('styles.block.fontSize')); }); + + it('has a specified font weight', function () { + expect(view.$('.mailpoet_editor_button').css('font-weight')).to.equal(model.get('styles.block.fontWeight')); + }); }); }); @@ -318,6 +330,12 @@ define([ expect(model.get('styles.block.fontSize')).to.equal(newValue); }); + it('updates the model when font weight changes', function () { + var newValue = 'bold'; + view.$('.mailpoet_field_button_font_weight').prop('checked', true).change(); + expect(model.get('styles.block.fontWeight')).to.equal(newValue); + }); + it('updates the model when background color changes', function () { var newValue = '#cccccc'; diff --git a/tests/javascript/newsletter_editor/blocks/posts.spec.js b/tests/javascript/newsletter_editor/blocks/posts.spec.js index 63c0b2cb84..a2bd864d93 100644 --- a/tests/javascript/newsletter_editor/blocks/posts.spec.js +++ b/tests/javascript/newsletter_editor/blocks/posts.spec.js @@ -1,8 +1,9 @@ define([ 'newsletter_editor/App', 'newsletter_editor/components/communication', - 'newsletter_editor/blocks/posts' - ], function(EditorApplication, CommunicationComponent, PostsBlock) { + 'newsletter_editor/blocks/posts', + 'newsletter_editor/blocks/container' + ], function(EditorApplication, CommunicationComponent, PostsBlock, ContainerBlock) { describe('Posts', function () { Backbone.Radio = { @@ -255,7 +256,7 @@ define([ global.stubConfig(EditorApplication, { blockDefaults: {}, }); - EditorApplication.getBlockTypeModel = sinon.stub().returns(Backbone.Model); + EditorApplication.getBlockTypeModel = sinon.stub().returns(ContainerBlock.ContainerBlockModel); model = new (PostsBlock.PostsBlockModel)(); view = new (PostsBlock.PostsBlockSettingsView)({model: model}); }); diff --git a/tests/javascript/newsletter_editor/components/save.spec.js b/tests/javascript/newsletter_editor/components/save.spec.js index 880c4ab0f1..17a5e63ce7 100644 --- a/tests/javascript/newsletter_editor/components/save.spec.js +++ b/tests/javascript/newsletter_editor/components/save.spec.js @@ -147,7 +147,11 @@ define([ }, }, 'newsletter_editor/App': EditorApplication, - 'html2canvas': function() { return html2canvasMock; }, + 'html2canvas': function() { + return { + then: function() { return html2canvasMock; } + }; + }, }); var view = new (module.SaveView)(); view.render(); diff --git a/views/newsletter/form.html b/views/newsletter/form.html index 5ef90b3345..de668fc40b 100644 --- a/views/newsletter/form.html +++ b/views/newsletter/form.html @@ -947,6 +947,7 @@ fontColor: '#00ddff', fontFamily: 'Arial', fontSize: '20px', + fontWeight: 'normal', textAlign: 'center', } } @@ -982,6 +983,7 @@ fontColor: '#ffffff', fontFamily: 'Verdana', fontSize: '18px', + fontWeight: 'normal', textAlign: 'center', }, }, @@ -1069,6 +1071,7 @@ fontColor: '#000000', fontFamily: 'Arial', fontSize: '20px', + fontWeight: 'normal', textAlign: 'center', }, }, diff --git a/views/newsletter/templates/blocks/button/block.hbs b/views/newsletter/templates/blocks/button/block.hbs index 8c98e598ef..7dd3e26758 100644 --- a/views/newsletter/templates/blocks/button/block.hbs +++ b/views/newsletter/templates/blocks/button/block.hbs @@ -1,5 +1,5 @@
diff --git a/views/newsletter/templates/blocks/button/settings.hbs b/views/newsletter/templates/blocks/button/settings.hbs index 6ad613c702..6ed483fddd 100644 --- a/views/newsletter/templates/blocks/button/settings.hbs +++ b/views/newsletter/templates/blocks/button/settings.hbs @@ -56,6 +56,14 @@