mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 07:25:46 +01:00
closes #1100
This commit is contained in:
@@ -187,58 +187,63 @@ define(['forum/admin/settings'], function(Settings) {
|
|||||||
},
|
},
|
||||||
connectWith: "div"
|
connectWith: "div"
|
||||||
}).on('click', '.toggle-widget', function() {
|
}).on('click', '.toggle-widget', function() {
|
||||||
$(this).parents('.panel').children('.panel-body').toggleClass('hidden');
|
$(this).parents('.panel').children('.panel-body').toggleClass('hidden');
|
||||||
}).on('click', '.delete-widget', function() {
|
}).on('click', '.delete-widget', function() {
|
||||||
var panel = $(this).parents('.panel');
|
var panel = $(this).parents('.panel');
|
||||||
|
|
||||||
bootbox.confirm('Are you sure you wish to delete this widget?', function(confirm) {
|
bootbox.confirm('Are you sure you wish to delete this widget?', function(confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
panel.remove();
|
panel.remove();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}).on('dblclick', '.panel-heading', function() {
|
|
||||||
$(this).parents('.panel').children('.panel-body').toggleClass('hidden');
|
|
||||||
});
|
});
|
||||||
|
}).on('dblclick', '.panel-heading', function() {
|
||||||
|
$(this).parents('.panel').children('.panel-body').toggleClass('hidden');
|
||||||
|
});
|
||||||
|
|
||||||
$('#widgets .btn[data-template]').on('click', function() {
|
$('#widgets .btn[data-template]').on('click', saveWidgets);
|
||||||
var btn = $(this),
|
|
||||||
template = btn.attr('data-template'),
|
|
||||||
location = btn.attr('data-location'),
|
|
||||||
area = btn.parents('.area').children('.widget-area'),
|
|
||||||
widgets = [];
|
|
||||||
|
|
||||||
area.find('.panel[data-widget]').each(function() {
|
function saveWidgets() {
|
||||||
var widgetData = {},
|
$('#widgets .btn[data-template]').each(function(i, el) {
|
||||||
data = $(this).find('form').serializeArray();
|
el = $(el);
|
||||||
|
|
||||||
for (var d in data) {
|
var template = el.attr('data-template'),
|
||||||
if (data.hasOwnProperty(d)) {
|
location = el.attr('data-location'),
|
||||||
if (data[d].name) {
|
area = el.parents('.area').children('.widget-area'),
|
||||||
widgetData[data[d].name] = data[d].value;
|
widgets = [];
|
||||||
|
|
||||||
|
area.find('.panel[data-widget]').each(function() {
|
||||||
|
var widgetData = {},
|
||||||
|
data = $(this).find('form').serializeArray();
|
||||||
|
|
||||||
|
for (var d in data) {
|
||||||
|
if (data.hasOwnProperty(d)) {
|
||||||
|
if (data[d].name) {
|
||||||
|
widgetData[data[d].name] = data[d].value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
widgets.push({
|
widgets.push({
|
||||||
widget: $(this).attr('data-widget'),
|
widget: $(this).attr('data-widget'),
|
||||||
data: widgetData
|
data: widgetData
|
||||||
|
});
|
||||||
|
});
|
||||||
|
console.log(template, location, widgets);
|
||||||
|
socket.emit('admin.widgets.set', {
|
||||||
|
template: template,
|
||||||
|
location: location,
|
||||||
|
widgets: widgets
|
||||||
|
}, function(err) {
|
||||||
|
app.alert({
|
||||||
|
alert_id: 'admin:widgets',
|
||||||
|
type: err ? 'danger' : 'success',
|
||||||
|
title: err ? 'Error' : 'Widgets Updated',
|
||||||
|
message: err ? err.message : 'Successfully updated widgets in ' + template + '/' + location,
|
||||||
|
timeout: 2500
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
socket.emit('admin.widgets.set', {
|
|
||||||
template: template,
|
|
||||||
location: location,
|
|
||||||
widgets: widgets
|
|
||||||
}, function(err) {
|
|
||||||
app.alert({
|
|
||||||
alert_id: 'admin:widgets',
|
|
||||||
type: err ? 'danger' : 'success',
|
|
||||||
title: err ? 'Error' : 'Widgets Updated',
|
|
||||||
message: err ? err : 'Successfully updated widgets',
|
|
||||||
timeout: 2500
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function populateWidget(widget, data) {
|
function populateWidget(widget, data) {
|
||||||
widget.find('input, textarea').each(function() {
|
widget.find('input, textarea').each(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user