Skip to content
Snippets Groups Projects
Commit eaedda55 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

clean

parent 9f1eb1bf
No related branches found
No related tags found
No related merge requests found
......@@ -19,11 +19,7 @@ window.osuny.contentEditor = {
initTabs: function () {
'use strict';
var tabs = document.querySelectorAll('[data-bs-toggle="tab"]'),
i;
for (i = 0; i < tabs.length; i += 1) {
tabs[i].addEventListener('shown.bs.tab', this.tabChanged.bind(this));
}
this.addListeners('[data-bs-toggle="tab"]', 'shown.bs.tab', this.tabChanged);
},
initSortable: function () {
......@@ -107,11 +103,7 @@ window.osuny.contentEditor = {
initBlockCopyPaste: function () {
'use strict';
var buttons = document.querySelectorAll('.js-block__copy'),
i;
for (i = 0; i < buttons.length; i += 1) {
buttons[i].addEventListener('click', this.blockCopy.bind(this));
}
this.addListeners('.js-block__copy', 'click', this.blockCopy);
},
blockCopy: function (event) {
......@@ -125,6 +117,15 @@ window.osuny.contentEditor = {
}, 1000)
},
addListeners: function (selector, event, action) {
'use strict';
var elements = document.querySelectorAll(selector),
i;
for (i = 0; i < elements.length; i += 1) {
elements[i].addEventListener(event, action.bind(this));
}
},
invoke: function () {
'use strict';
return {
......
......@@ -61,7 +61,7 @@ class Admin::Communication::BlocksController < Admin::Communication::Application
about = PolymorphicObjectFinder.find(params, :about)
@block = @block.paste(about)
cookies.delete(Communication::Block::BLOCK_COPY_COOKIE, path: '/admin')
redirect_to about_path,
redirect_to about_path + "#block-#{@block.id}",
notice: t('admin.successfully_duplicated_html', model: @block.to_s)
end
......
<div class=" content-editor__elements__element
<div id="block-<%= block.id %>"
class=" content-editor__elements__element
content-editor__elements__element--block
js-content-editor-element"
data-id="<%= block.id %>"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment