manager: give empty cell lists height to used as drop target (#12565)

This commit is contained in:
Frédéric Péters 2016-07-13 13:06:27 +02:00
parent 1dbda6fa72
commit 447ec4f9db
2 changed files with 33 additions and 0 deletions

View File

@ -318,3 +318,14 @@ p.hint {
select#id_groups {
height: 15em;
}
div.empty-cell-list {
min-height: 2ex;
transition: min-height ease 0.2s;
}
body.dragging-cell div.empty-cell-list {
min-height: 5ex;
box-sizing: border-box;
border: 1px solid #eee;
box-shadow: rgba(0, 0, 0, 0.04) 0px 1px 1px 0px;
}

View File

@ -107,15 +107,37 @@ $(function() {
return false;
});
init_pages_list();
function init_cells_lists() {
$('.cell-list').each(function() {
if ($(this).find('div.cell').length == 0) {
$(this).addClass('empty-cell-list');
} else {
$(this).removeClass('empty-cell-list');
}
});
}
init_cells_lists();
$('.cell-list').sortable({
handle: '.handle',
connectWith: '.cell-list',
helper: 'clone',
placeholder: 'empty-cell',
tolerance: 'pointer',
start: function(event, ui) {
if (ui.helper.parent().find('div.cell').length <= 2) {
/* cell + placeholder */
ui.helper.parent().addClass('empty-cell-list');
}
$('body').addClass('dragging-cell');
ui.helper.removeClass('toggled').addClass('untoggled').css('height',
ui.helper.find('h3').outerHeight());
},
stop: function(event, ui) {
$('body').removeClass('dragging-cell');
init_cells_lists();
},
update: function(event, ui) {
var new_order = Object();
$('.cell').each(function(i, x) {