Allow duplicate content
[MAILPOET-968]
This commit is contained in:
@ -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({
|
||||
|
@ -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,
|
||||
},
|
||||
|
@ -135,6 +135,10 @@ define([
|
||||
it('does not have a settings tool', function () {
|
||||
expect(view.$('.mailpoet_edit_block')).to.have.length(0);
|
||||
});
|
||||
|
||||
it('has a duplication tool', function () {
|
||||
expect(view.$('.mailpoet_duplicate_block')).to.have.length(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip('on non-root levels', function () {
|
||||
@ -164,6 +168,10 @@ define([
|
||||
it('has a settings tool', function () {
|
||||
expect(view.$('.mailpoet_edit_block')).to.have.length(1);
|
||||
});
|
||||
|
||||
it('has a duplication tool', function () {
|
||||
expect(view.$('.mailpoet_duplicate_block')).to.have.length(1);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -3,7 +3,8 @@
|
||||
<%= source('newsletter/templates/svg/block-tools/settings-column.svg') %>
|
||||
</a>{{/if}}{{#if tools.settings}}<a href="javascript:;" class="mailpoet_tool mailpoet_edit_block mailpoet_ignore_drag" title="<%= __('Edit settings') %>">
|
||||
<%= source('newsletter/templates/svg/block-tools/settings.svg') %>
|
||||
</a>{{/if}}{{#if tools.delete}}<div class="mailpoet_delete_block mailpoet_ignore_drag"><a href="javascript:;" class="mailpoet_tool mailpoet_delete_block_activate" title="<%= __('Delete') %>"><%= source('newsletter/templates/svg/block-tools/trash.svg') %></a><a href="javascript:;" class="mailpoet_delete_block_confirm" title="<%= __('Confirm deletion') %>"><%= __('Delete') %></a><a href="javascript:;" class="mailpoet_delete_block_cancel" title="<%= __('Cancel deletion') %>"><%= __('Cancel') %></a></div>{{/if}}{{#if tools.move}}<a href="javascript:;" class="mailpoet_tool mailpoet_move_block" title="<%= __('Drag to move') %>">
|
||||
<%= source('newsletter/templates/svg/block-tools/move.svg') %>
|
||||
</a>{{/if}}{{#if tools.delete}}<div class="mailpoet_delete_block mailpoet_ignore_drag"><a href="javascript:;" class="mailpoet_tool mailpoet_delete_block_activate" title="<%= __('Delete') %>"><%= source('newsletter/templates/svg/block-tools/trash.svg') %></a><a href="javascript:;" class="mailpoet_delete_block_confirm" title="<%= __('Confirm deletion') %>"><%= __('Delete') %></a><a href="javascript:;" class="mailpoet_delete_block_cancel" title="<%= __('Cancel deletion') %>"><%= __('Cancel') %></a></div>{{/if}}{{#if tools.duplicate}}<a href="javascript:;" class="mailpoet_tool mailpoet_duplicate_block" title="<%= __('Duplicate') %>">
|
||||
<%= source('newsletter/templates/svg/block-tools/duplicate.svg') %></a>{{/if}}{{#if tools.move}}<a href="javascript:;" class="mailpoet_tool mailpoet_move_block" title="<%= __('Drag to move') %>">
|
||||
<%= source('newsletter/templates/svg/block-tools/move.svg') %>
|
||||
</a>{{/if}}
|
||||
</div>
|
||||
|
14
views/newsletter/templates/svg/block-tools/duplicate.svg
Normal file
14
views/newsletter/templates/svg/block-tools/duplicate.svg
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg class="mailpoet_tool_icon" viewBox="-0.39177295565605164 -0.7443126440048218 23.961435317993164 25.181514739990234" width="23.961435317993164" height="25.181514739990234" xmlns="http://www.w3.org/2000/svg" xmlns:bx="https://boxy-svg.com">
|
||||
<g id="Layer_1_copy" transform="matrix(0.038742002099752426, 0.0003900000301655382, -0.0003850000211969018, 0.03820900246500969, -0.11364900320768356, -3.403659105300903)" bx:origin="-2.323 -1.923">
|
||||
<circle fill="#AA3333" cx="306" cy="403.5" r="269.5"/>
|
||||
<rect id="_x3C_Slice_x3E__1_" y="69.6" fill="none" width="612" height="652.8"/>
|
||||
<g id="Layer_3"/>
|
||||
<g>
|
||||
<path d="M391.012,201.139c0,26.172,0,52.852,0,79.848c27.17,0,53.922,0,79.637,0C444.279,254.549,417.561,227.758,391.012,201.139 			z"/>
|
||||
<path d="M391.48,308.635c-16.219-0.014-27.92-11.744-27.938-27.984c-0.029-24.914-0.023-49.826-0.033-74.738 			c0-2.088,0-4.178,0-6.443c-45.664,0-90.881,0-136.412,0c0,109.457,0,218.557,0,327.592c82.055,0,163.816,0,245.443,0 			c0-72.98,0-145.631,0-218.418C445.285,308.643,418.383,308.66,391.48,308.635z M296.25,336.02 			c35.846-0.021,71.693-0.023,107.537-0.027c8.359,0,14.34,5.631,14.395,13.52c0.055,8.146-5.834,13.789-14.506,13.801 			c-18.066,0.025-36.131,0.01-54.195,0.008c-17.781,0-35.562,0.014-53.342-0.006c-8.723-0.01-14.635-5.58-14.617-13.699 			C281.541,341.568,287.514,336.023,296.25,336.02z M390.84,404.223c0.01,7.82-5.742,13.717-13.699,13.752 			c-18.197,0.082-36.398,0.078-54.594,0.031c-7.916-0.021-13.721-5.959-13.688-13.777c0.035-7.635,5.734-13.443,13.465-13.514 			c9.24-0.086,18.48-0.021,27.725-0.021c8.957,0,17.914-0.041,26.871,0.012C384.951,390.752,390.832,396.512,390.84,404.223z 			 M403.207,472.703c-35.99-0.01-71.977,0.002-107.967-0.043c-7.021-0.01-12.836-5.043-13.68-11.596 			c-0.891-6.891,3.061-13.186,9.664-15.16c1.465-0.438,3.074-0.535,4.619-0.537c18.064-0.035,36.131-0.023,54.197-0.023 			c0,0.01,0,0.018,0,0.025c17.781,0,35.561-0.012,53.342,0.006c8.758,0.012,14.787,5.535,14.822,13.512 			C418.242,467.08,412.133,472.705,403.207,472.703z"/>
|
||||
<path d="M228.396,554.674c-2.404,0-4.875-0.006-7.203-0.518c-13.977-3.07-21.723-13.842-21.719-29.912 			c0.012-88.398,0.018-176.795,0.027-265.191c0-1.637,0-3.275,0-4.848c-18.539,0-36.418,0-54.465,0c0,109.332,0,218.422,0,327.686 			c81.906,0,163.564,0,245.504,0c0-9.227,0-18.098,0-27.195c-2.312,0-4.293,0-6.277,0 			C332.309,554.695,280.354,554.701,228.396,554.674z"/>
|
||||
<path d="M305.816,93.684C136.918,93.684,0,230.602,0,399.5c0,168.896,136.918,305.816,305.816,305.816 			c168.896,0,305.815-136.919,305.815-305.816C611.633,230.602,474.714,93.684,305.816,93.684z M500.209,527.365 			c0,15.279-12.08,27.332-27.34,27.332c-16.941,0.002-33.885,0-50.824,0.018c-1.223,0-2.443,0.15-3.559,0.225 			c-0.145,0.645-0.258,0.916-0.26,1.188c-0.021,8.684,0.004,17.369-0.055,26.051c-0.08,12.018-7.312,21.973-18.686,25.852 			c-1.184,0.404-2.334,0.906-3.5,1.361c-85.434,0-170.871,0-256.307,0c-0.762-0.318-1.504-0.707-2.291-0.945 			c-12.221-3.705-19.896-13.922-19.898-26.664c-0.012-109.145-0.016-218.287,0.002-327.43c0.004-15.906,11.838-27.656,27.801-27.688 			c16.506-0.033,33.014-0.01,49.52-0.01c1.496,0,2.994,0,4.355,0c0.188-0.906,0.293-1.178,0.293-1.451 			c0.012-8.68-0.031-17.361,0.027-26.039c0.078-11.268,6.781-21.156,17.078-25.299c1.691-0.682,3.422-1.271,5.131-1.902 			c56.674,0,113.344,0,170.018,0c0.85,1.086,1.596,2.275,2.564,3.244c34.115,34.139,68.227,68.279,102.438,102.324 			c2.506,2.494,3.584,4.93,3.578,8.52C500.188,366.488,500.217,446.928,500.209,527.365z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.8 KiB |
Reference in New Issue
Block a user