diff --git a/assets/js/src/newsletter_editor/blocks/automatedLatestContent.js b/assets/js/src/newsletter_editor/blocks/automatedLatestContent.js index 016a9e9671..430e0a1496 100644 --- a/assets/js/src/newsletter_editor/blocks/automatedLatestContent.js +++ b/assets/js/src/newsletter_editor/blocks/automatedLatestContent.js @@ -189,11 +189,6 @@ define([ "click .mailpoet_done_editing": "close", }; }, - templateContext: function() { - return { - model: this.model.toJSON(), - }; - }, onRender: function() { var that = this; diff --git a/assets/js/src/newsletter_editor/blocks/base.js b/assets/js/src/newsletter_editor/blocks/base.js index 151e5472b9..7e5a172305 100644 --- a/assets/js/src/newsletter_editor/blocks/base.js +++ b/assets/js/src/newsletter_editor/blocks/base.js @@ -125,6 +125,12 @@ define([ return this.model.clone(); }.bind(this); }, + disableDragging: function() { + this.$el.addClass('mailpoet_ignore_drag'); + }, + enableDragging: function() { + this.$el.removeClass('mailpoet_ignore_drag'); + }, showBlock: function() { if (this._isFirstRender) { this.transitionIn(); @@ -240,6 +246,11 @@ define([ MailPoet.Modal.panel(panelParams); } }, + templateContext: function() { + return { + model: this.model.toJSON() + }; + }, close: function(event) { this.destroy(); }, diff --git a/assets/js/src/newsletter_editor/blocks/button.js b/assets/js/src/newsletter_editor/blocks/button.js index d42b0eb015..8afafe3486 100644 --- a/assets/js/src/newsletter_editor/blocks/button.js +++ b/assets/js/src/newsletter_editor/blocks/button.js @@ -99,11 +99,10 @@ define([ }; }, templateContext: function() { - return { - model: this.model.toJSON(), + return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), { availableStyles: App.getAvailableStyles().toJSON(), renderOptions: this.renderOptions, - }; + }); }, applyToAll: function() { App.getChannel().trigger('replaceAllButtonStyles', _.pick(this.model.toJSON(), 'styles', 'type')); diff --git a/assets/js/src/newsletter_editor/blocks/divider.js b/assets/js/src/newsletter_editor/blocks/divider.js index f0c4a92e63..e46275d09f 100644 --- a/assets/js/src/newsletter_editor/blocks/divider.js +++ b/assets/js/src/newsletter_editor/blocks/divider.js @@ -105,11 +105,10 @@ define([ }; }, templateContext: function() { - return { - model: this.model.toJSON(), + return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), { availableStyles: App.getAvailableStyles().toJSON(), renderOptions: this.renderOptions, - }; + }); }, changeStyle: function(event) { var style = jQuery(event.currentTarget).data('style'); diff --git a/assets/js/src/newsletter_editor/blocks/footer.js b/assets/js/src/newsletter_editor/blocks/footer.js index 597a48acd2..cb8e047d83 100644 --- a/assets/js/src/newsletter_editor/blocks/footer.js +++ b/assets/js/src/newsletter_editor/blocks/footer.js @@ -68,12 +68,6 @@ define([ this.enableDragging(); this.enableShowingTools(); }, - disableDragging: function() { - this.$('.mailpoet_content').addClass('mailpoet_ignore_drag'); - }, - enableDragging: function() { - this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag'); - }, }); Module.FooterBlockToolsView = base.BlockToolsView.extend({ @@ -97,10 +91,9 @@ define([ }; }, templateContext: function() { - return { - model: this.model.toJSON(), + return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), { availableStyles: App.getAvailableStyles().toJSON(), - }; + }); }, }); diff --git a/assets/js/src/newsletter_editor/blocks/header.js b/assets/js/src/newsletter_editor/blocks/header.js index 27f0f09c2f..eb74ed46d0 100644 --- a/assets/js/src/newsletter_editor/blocks/header.js +++ b/assets/js/src/newsletter_editor/blocks/header.js @@ -68,12 +68,6 @@ define([ this.enableDragging(); this.enableShowingTools(); }, - disableDragging: function() { - this.$('.mailpoet_content').addClass('mailpoet_ignore_drag'); - }, - enableDragging: function() { - this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag'); - }, }); Module.HeaderBlockToolsView = base.BlockToolsView.extend({ @@ -97,10 +91,9 @@ define([ }; }, templateContext: function() { - return { - model: this.model.toJSON(), + return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), { availableStyles: App.getAvailableStyles().toJSON(), - }; + }); }, }); diff --git a/assets/js/src/newsletter_editor/blocks/social.js b/assets/js/src/newsletter_editor/blocks/social.js index 9046bfd272..3d99a128fb 100644 --- a/assets/js/src/newsletter_editor/blocks/social.js +++ b/assets/js/src/newsletter_editor/blocks/social.js @@ -103,60 +103,19 @@ define([ childView: SocialIconView, }); - Module.SocialBlockView = Marionette.View.extend({ + Module.SocialBlockView = base.BlockView.extend({ className: 'mailpoet_block mailpoet_social_block mailpoet_droppable_block', getTemplate: function() { return templates.socialBlock; }, - modelEvents: { - 'change': 'render', - 'delete': 'deleteBlock', - }, - events: { - "mouseover": "showTools", - "mouseout": "hideTools", - }, - regions: { - toolsRegion: '> .mailpoet_tools', + regions: _.extend({}, base.BlockView.prototype.regions, { icons: '.mailpoet_social' - }, + }), ui: { tools: '> .mailpoet_tools' }, - behaviors: { - DraggableBehavior: { - cloneOriginal: true, - hideOriginal: true, - onDrop: function(options) { - // After a clone of model has been dropped, cleanup - // and destroy self - options.dragBehavior.view.model.destroy(); - }, - onDragSubstituteBy: function(behavior) { - var WidgetView, node; - // When block is being dragged, display the widget icon instead. - // This will create an instance of block's widget view and - // use it's rendered DOM element instead of the content block - if (_.isFunction(behavior.view.onDragSubstituteBy)) { - WidgetView = new (behavior.view.onDragSubstituteBy())(); - WidgetView.render(); - node = WidgetView.$el.get(0).cloneNode(true); - WidgetView.destroy(); - return node; - } - }, - }, - HighlightEditingBehavior: {}, + behaviors: _.extend({}, base.BlockView.prototype.behaviors, { ShowSettingsBehavior: {}, - }, + }), onDragSubstituteBy: function() { return Module.SocialWidgetView; }, - initialize: function() { - this.on('showSettings', this.showSettings, this); - }, - templateContext: function() { - return { - model: this.model.toJSON(), - viewCid: this.cid, - }; - }, onRender: function() { this.toolsView = new Module.SocialBlockToolsView({ model: this.model }); this.showChildView('toolsRegion', this.toolsView); @@ -164,56 +123,6 @@ define([ collection: this.model.get('icons') })) }, - showTools: function(_event) { - this.$(this.ui.tools).addClass('mailpoet_display_tools'); - _event.stopPropagation(); - }, - hideTools: function(_event) { - this.$(this.ui.tools).removeClass('mailpoet_display_tools'); - _event.stopPropagation(); - }, - showSettings: function(options) { - this.toolsView.triggerMethod('showSettings', options); - }, - getDropFunc: function() { - return function() { - return this.model.clone(); - }.bind(this); - }, - deleteBlock: function() { - this.transitionOut().done(function() { - this.model.destroy(); - }.bind(this)); - }, - transitionIn: function() { - return this._transition('slideDown', 'fadeIn', 'easeIn'); - }, - transitionOut: function() { - return this._transition('slideUp', 'fadeOut', 'easeOut'); - }, - _transition: function(slideDirection, fadeDirection, easing) { - var promise = jQuery.Deferred(); - - this.$el.velocity( - slideDirection, - { - duration: 250, - easing: easing, - complete: function() { - promise.resolve(); - }.bind(this), - } - ).velocity( - fadeDirection, - { - duration: 250, - easing: easing, - queue: false, // Do not enqueue, trigger animation in parallel - } - ); - - return promise; - }, }); Module.SocialBlockToolsView = base.BlockToolsView.extend({ @@ -270,12 +179,11 @@ define([ // Construct icon type list of format [{iconType: 'type', title: 'Title'}, ...] availableIconTypes = _.map(_.keys(icons.attributes), function(key) { return { iconType: key, title: icons.get(key).get('title') }; }), allIconSets = App.getAvailableStyles().get('socialIconSets'); - return { - model: this.model.toJSON(), + return _.extend({}, base.BlockView.prototype.templateContext.apply(this, arguments), { iconTypes: availableIconTypes, currentType: icons.get(this.model.get('iconType')).toJSON(), allIconSets: allIconSets.toJSON(), - }; + }); }, deleteIcon: function() { this.model.destroy(); diff --git a/assets/js/src/newsletter_editor/blocks/text.js b/assets/js/src/newsletter_editor/blocks/text.js index 42135d87b2..0d7c66e841 100644 --- a/assets/js/src/newsletter_editor/blocks/text.js +++ b/assets/js/src/newsletter_editor/blocks/text.js @@ -71,13 +71,6 @@ define([ this.enableDragging(); this.enableShowingTools(); }, - - disableDragging: function() { - this.$('.mailpoet_content').addClass('mailpoet_ignore_drag'); - }, - enableDragging: function() { - this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag'); - }, }); Module.TextBlockToolsView = base.BlockToolsView.extend({ diff --git a/views/newsletter/templates/blocks/container/settings.hbs b/views/newsletter/templates/blocks/container/settings.hbs index 72d7ad4154..1ecf80f3c8 100644 --- a/views/newsletter/templates/blocks/container/settings.hbs +++ b/views/newsletter/templates/blocks/container/settings.hbs @@ -2,7 +2,7 @@
diff --git a/views/newsletter/templates/blocks/image/settings.hbs b/views/newsletter/templates/blocks/image/settings.hbs index dda9f0f4ea..4592b5c918 100644 --- a/views/newsletter/templates/blocks/image/settings.hbs +++ b/views/newsletter/templates/blocks/image/settings.hbs @@ -3,7 +3,7 @@
@@ -11,7 +11,7 @@ @@ -19,14 +19,14 @@
diff --git a/views/newsletter/templates/blocks/spacer/settings.hbs b/views/newsletter/templates/blocks/spacer/settings.hbs index 61110daa2a..11045a8a3e 100644 --- a/views/newsletter/templates/blocks/spacer/settings.hbs +++ b/views/newsletter/templates/blocks/spacer/settings.hbs @@ -1,7 +1,7 @@

<%= __('Spacer') %>

- +
<%= __('Background') %>
diff --git a/views/newsletter/templates/blocks/text/settings.hbs b/views/newsletter/templates/blocks/text/settings.hbs index 4d6435a04a..36472cb5a3 100644 --- a/views/newsletter/templates/blocks/text/settings.hbs +++ b/views/newsletter/templates/blocks/text/settings.hbs @@ -1,2 +1,2 @@

<%= __('Text') %>

-<%= __('Text') %>: +<%= __('Text') %>: