Skip to content

Commit

Permalink
Reverted back to some older code- un-nested clone function to make it…
Browse files Browse the repository at this point in the history
… standalone
  • Loading branch information
dhanya-cmu committed Sep 6, 2024
1 parent 0296129 commit 0ee3b19
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions public/src/admin/extend/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,23 @@ define('admin/extend/widgets', [
});
}

function clone(location, template) {
console.log('Dhanya Shah');
const widgets = $('#active-widgets .tab-pane[data-template="' + template + '"] [data-location="' + location + '"] [data-widget]');
widgets.each(function () {
const widget = $(this).clone(true);
appendClonedWidget(widget, location);
});
}
function appendClonedWidget(widget, location) {
$('#active-widgets .active.tab-pane[data-template]:not([data-template="global"]) [data-location="' + location + '"] .widget-area').append(widget);
}

function setupCloneButton() {
const clone = $('[component="clone"]');
const cloneContainer = $('[component="clone"]');
const cloneBtn = $('[component="clone/button"]');

clone.find('.dropdown-menu li').on('click', function () {
cloneContainer.find('.dropdown-menu li').on('click', function () {
const template = $(this).find('a').text();
cloneBtn.translateHtml('[[admin/extend/widgets:clone-from]] <strong>' + template + '</strong>');
cloneBtn.attr('data-template', template);
Expand All @@ -281,21 +293,6 @@ define('admin/extend/widgets', [
return currentAreas.indexOf(location) !== -1 ? location : undefined;
}).get().filter(function (i) { return i; });

function clone(location, template) {
console.log('Dhanya Shah');
const widgets = $('#active-widgets .tab-pane[data-template="' + template + '"] [data-location="' + location + '"] [data-widget]');
for (let i = 0; i < widgets.length; i++) {
processWidget($(widgets[i]), location);
}
}
function processWidget(widget, location) {
const clonedWidget = widget.clone(true);
appendClonedWidget(clonedWidget, location);
}
function appendClonedWidget(widget, location) {
$('#active-widgets .active.tab-pane[data-template]:not([data-template="global"]) [data-location="' + location + '"] .widget-area').append(widget);
}

for (let i = 0, ii = areasToClone.length; i < ii; i++) {
const location = areasToClone[i];
clone(location, template);
Expand Down

0 comments on commit 0ee3b19

Please sign in to comment.