Merge pull request #993 from mailpoet/duplicate-content

Add an option to duplicate content blocks [MAILPOET-968]
This commit is contained in:
Tautvidas Sipavičius
2017-07-13 13:14:36 +03:00
committed by GitHub
5 changed files with 53 additions and 2 deletions

View File

@@ -52,6 +52,7 @@ define([
modelEvents: {
'change': 'render',
'delete': 'deleteBlock',
'duplicate': 'duplicateBlock',
},
events: {
"mouseenter": "showTools",
@@ -142,6 +143,9 @@ define([
this.model.destroy();
}.bind(this));
},
duplicateBlock: function() {
this.model.collection.add(this.model.toJSON(), {at: this.model.collection.findIndex(this.model)});
},
transitionIn: function() {
return this._transition('slideDown', 'fadeIn', 'easeOut');
},
@@ -180,11 +184,13 @@ define([
"click .mailpoet_delete_block_activate": "showDeletionConfirmation",
"click .mailpoet_delete_block_cancel": "hideDeletionConfirmation",
"click .mailpoet_delete_block_confirm": "deleteBlock",
"click .mailpoet_duplicate_block": "duplicateBlock",
},
// Markers of whether these particular tools will be used for this instance
tools: {
settings: true,
delete: true,
duplicate: true,
move: true,
},
getSettingsView: function() { return Module.BlockSettingsView; },
@@ -221,6 +227,11 @@ define([
this.model.trigger('delete');
return false;
},
duplicateBlock: function(event) {
event.preventDefault();
this.model.trigger('duplicate');
return false;
},
});
Module.BlockSettingsView = Marionette.View.extend({

View File

@@ -161,6 +161,7 @@ define([
tools: {
settings: this.renderOptions.depth === 1,
delete: this.renderOptions.depth === 1,
duplicate: true,
move: this.renderOptions.depth === 1,
layerSelector: false,
},