drag & drop routes

This commit is contained in:
psychobunny
2015-02-25 16:19:14 -05:00
parent afc690d67b
commit 809ed255d1
3 changed files with 39 additions and 4 deletions

View File

@@ -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;
});