mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 05:55:48 +01:00
drag & drop routes
This commit is contained in:
@@ -25,8 +25,31 @@ define('admin/general/navigation', function() {
|
||||
|
||||
$('#save').on('click', saveNavigation);
|
||||
|
||||
$('#enabled').sortable();
|
||||
$('#enabled').disableSelection();
|
||||
$('#enabled')
|
||||
.sortable()
|
||||
.droppable({
|
||||
accept: $('#available li')
|
||||
})
|
||||
.disableSelection();
|
||||
|
||||
$('#available li')
|
||||
.draggable({
|
||||
connectToSortable: '#enabled',
|
||||
helper: 'clone',
|
||||
distance: 10,
|
||||
stop: function(ev, ui) {
|
||||
var id = ui.helper.attr('data-id'),
|
||||
el = $('#enabled [data-id="' + id + '"]'),
|
||||
data = id === 'custom' ? {} : available[id];
|
||||
|
||||
templates.parse('admin/general/navigation', 'enabled', {enabled: [data]}, function(li) {
|
||||
li = $(li);
|
||||
el.after(li);
|
||||
el.remove();
|
||||
});
|
||||
}
|
||||
})
|
||||
.disableSelection();
|
||||
};
|
||||
|
||||
function saveNavigation() {
|
||||
@@ -58,5 +81,13 @@ define('admin/general/navigation', function() {
|
||||
});
|
||||
}
|
||||
|
||||
function getDefaultsByRoute(route) {
|
||||
available.forEach(function(item) {
|
||||
if (item.route.match(route)) {
|
||||
return item;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return navigation;
|
||||
});
|
||||
Reference in New Issue
Block a user