Merge pull request #825 from parleur/selectbox

Fix the selectbox celltype behavior when multiselected
Matthias Bussonnier 11 years ago
commit 166b709a6a

@ -89,19 +89,27 @@ define([
// encountered when building a toolbar.
MainToolBar.prototype._pseudo_actions.add_celltype_list = function () {
var that = this;
var multiselect = $('<option/>').attr('value','multiselect').attr('disabled','').text('-');
var sel = $('<select/>')
.attr('id','cell_type')
.addClass('form-control select-xs')
.append($('<option/>').attr('value','code').text('Code'))
.append($('<option/>').attr('value','markdown').text('Markdown'))
.append($('<option/>').attr('value','raw').text('Raw NBConvert'))
.append($('<option/>').attr('value','heading').text('Heading'));
.append($('<option/>').attr('value','heading').text('Heading'))
.append(multiselect);
this.notebook.keyboard_manager.register_events(sel);
this.events.on('selected_cell_type_changed.Notebook', function (event, data) {
if (data.cell_type === 'heading') {
sel.val('Markdown');
if ( that.notebook.get_selected_cells_indices().length > 1) {
multiselect.show();
sel.val('multiselect');
} else {
sel.val(data.cell_type);
multiselect.hide()
if (data.cell_type === 'heading') {
sel.val('Markdown');
} else {
sel.val(data.cell_type);
}
}
});
sel.change(function () {
@ -121,6 +129,8 @@ define([
that.notebook.to_heading();
sel.val('markdown');
break;
case 'multiselect':
break;
default:
console.log("unrecognized cell type:", cell_type);
}

@ -709,6 +709,7 @@ define(function (require) {
}
var cell = this.get_cell(index);
cell.select(moveanchor);
this.update_soft_selection();
if (cell.cell_type === 'heading') {
this.events.trigger('selected_cell_type_changed.Notebook',
{'cell_type':cell.cell_type,level:cell.level}
@ -719,7 +720,6 @@ define(function (require) {
);
}
}
this.update_soft_selection();
return this;
};

Loading…
Cancel
Save