##// END OF EJS Templates
Prevent list items from being deselected on redraw.
Jonathan Frederic -
Show More
@@ -219,6 +219,9 b' define(['
219 var type_order = {'directory':0,'notebook':1,'file':2};
219 var type_order = {'directory':0,'notebook':1,'file':2};
220
220
221 NotebookList.prototype.draw_notebook_list = function (list, error_msg) {
221 NotebookList.prototype.draw_notebook_list = function (list, error_msg) {
222 // Remember what was selected before the refresh.
223 var selected_before = this.selected;
224
222 list.content.sort(function(a, b) {
225 list.content.sort(function(a, b) {
223 if (type_order[a['type']] < type_order[b['type']]) {
226 if (type_order[a['type']] < type_order[b['type']]) {
224 return -1;
227 return -1;
@@ -265,7 +268,20 b' define(['
265 }
268 }
266 // Trigger an event when we've finished drawing the notebook list.
269 // Trigger an event when we've finished drawing the notebook list.
267 events.trigger('draw_notebook_list.NotebookList');
270 events.trigger('draw_notebook_list.NotebookList');
268 this._selection_changed();
271
272 // Reselect the items that were selected before. Notify listeners
273 // that the selected items may have changed. O(n^2) operation.
274 selected_before.forEach(function(item) {
275 var list_items = $('.list_item');
276 for (var i=0; i<list_items.length; i++) {
277 var $list_item = $(list_items[i]);
278 if ($list_item.data('path') == item.path) {
279 $list_item.find('input[type=checkbox]').prop('checked', true);
280 break;
281 }
282 }
283 });
284 this._selection_changed();
269 };
285 };
270
286
271
287
General Comments 0
You need to be logged in to leave comments. Login now