##// END OF EJS Templates
keep only basic changes...
Mathieu -
Show More
@@ -8789,11 +8789,8 b' input.engine_num_input {'
8789 margin-left: 7px;
8789 margin-left: 7px;
8790 margin-right: 2px;
8790 margin-right: 2px;
8791 }
8791 }
8792 #tree-selector-menu {
8792 .menu_icon {
8793 width: 200px;
8793 margin-right: 2px;
8794 }
8795 #tree-selector-menu input[type=checkbox] {
8796 margin-left: 0px;
8797 }
8794 }
8798 .tab-content .row {
8795 .tab-content .row {
8799 margin-left: 0px;
8796 margin-left: 0px;
@@ -121,7 +121,8 b' define(['
121 $('.duplicate-button').click($.proxy(this.duplicate_selected, this));
121 $('.duplicate-button').click($.proxy(this.duplicate_selected, this));
122 $('.delete-button').click($.proxy(this.delete_selected, this));
122 $('.delete-button').click($.proxy(this.delete_selected, this));
123
123
124 // Bind events for selection checkboxes.
124 // Bind events for selection menu buttons.
125 $('#selector-menu').click(function(event){that.select($(event.target).attr('id'),true)});
125 $('.tree-selector').change(function(){that.select($(this).attr('id'),$(this).is(':checked'))});
126 $('.tree-selector').change(function(){that.select($(this).attr('id'),$(this).is(':checked'))});
126 $('#button-select-all').click(function(e) {
127 $('#button-select-all').click(function(e) {
127 // toggle checkbox if the click doesn't come from the checkbox already
128 // toggle checkbox if the click doesn't come from the checkbox already
@@ -131,24 +132,10 b' define(['
131 that.select('select-all',checkbox.prop('checked'));
132 that.select('select-all',checkbox.prop('checked'));
132 }
133 }
133 });
134 });
134
135 // Make the dropdown sticky
136 // Dirty solution by stopping click propagation
137 // $('#tree-selector-menu').click(function(event){event.stopPropagation();})
138 // Cleaner solution by reimplementing the open-close dynamics (and removing data-toggle="dropdown" in html)
139 $('#tree-selector-btn').on('click', function(event) {
140 $(this).parent().toggleClass('open');
141 });
142 $('body').on('click', function (e) {
143 // Close the menu if a click happens outside of the menu list (and of the tree-selector-btn)
144 if (!$('#tree-selector-btn').is(e.target) && $('#tree-selector-btn').has(e.target).length === 0 && $('#tree-selector-menu').has(e.target).length === 0) {
145 $('#tree-selector-btn').parent().removeClass('open');
146 }
147 });
148 }
135 }
149 };
136 };
150
137
151 NotebookList.prototype.handleFilesUpload = function(event, dropOrForm) {
138 NotebookList.prototype.handleFilesUpload = function(event, dropOrForm) {
152 var that = this;
139 var that = this;
153 var files;
140 var files;
154 if(dropOrForm =='drop'){
141 if(dropOrForm =='drop'){
@@ -308,7 +295,7 b' define(['
308 }
295 }
309 }
296 }
310 });
297 });
311 this._selection_changed();
298 this._selection_changed();
312 };
299 };
313
300
314
301
@@ -400,18 +387,18 b' define(['
400
387
401 /**
388 /**
402 * Select all items in the tree of specified type.
389 * Select all items in the tree of specified type.
403 * checkbox_id : string among "select-all, "select-folders", "select-notebooks", "select-running-notebooks", "select-files"
390 * selection_type : string among "select-all, "select-folders", "select-notebooks", "select-running-notebooks", "select-files"
404 * state : boolean, true to select and false to deselect
391 * state : boolean, true to select and false to deselect
405 */
392 */
406 NotebookList.prototype.select = function(checkbox_id,state) {
393 NotebookList.prototype.select = function(selection_type,state) {
407 var that = this;
394 var that = this;
408 $('.list_item').each(function(index, item) {
395 $('.list_item').each(function(index, item) {
409 // For each item, determine if the state should be set, depending on the checkbox_id that triggered select
396 // For each item, determine if the state should be set, depending on the selection_type that triggered select
410 var set_state = (checkbox_id === "select-all");
397 var set_state = (selection_type === "select-all");
411 set_state = set_state || (checkbox_id === "select-folders" && $(item).data('type') === 'directory');
398 set_state = set_state || (selection_type === "select-folders" && $(item).data('type') === 'directory');
412 set_state = set_state || (checkbox_id === "select-notebooks" && $(item).data('type') === 'notebook');
399 set_state = set_state || (selection_type === "select-notebooks" && $(item).data('type') === 'notebook');
413 set_state = set_state || (checkbox_id === "select-running-notebooks" && $(item).data('type') === 'notebook' && that.sessions[$(item).data('path')] !== undefined);
400 set_state = set_state || (selection_type === "select-running-notebooks" && $(item).data('type') === 'notebook' && that.sessions[$(item).data('path')] !== undefined);
414 set_state = set_state || (checkbox_id === "select-files" && $(item).data('type') === 'file');
401 set_state = set_state || (selection_type === "select-files" && $(item).data('type') === 'file');
415 if (set_state) {
402 if (set_state) {
416 $(item).find('input[type=checkbox]').prop('checked', state);
403 $(item).find('input[type=checkbox]').prop('checked', state);
417 }
404 }
@@ -424,61 +411,37 b' define(['
424 * Handles when any row selector checkbox is toggled.
411 * Handles when any row selector checkbox is toggled.
425 */
412 */
426 NotebookList.prototype._selection_changed = function() {
413 NotebookList.prototype._selection_changed = function() {
427 // Use a JQuery selector to find each row with a checkbox. If
414 // Use a JQuery selector to find each row with a checked checkbox. If
428 // we decide to add more checkboxes in the future, this code will need
415 // we decide to add more checkboxes in the future, this code will need
429 // to be changed to distinguish which checkbox is the row selector.
416 // to be changed to distinguish which checkbox is the row selector.
430 var selected = [];
417 var selected = [];
431 var num_sel_notebook = 0;
418 var has_running_notebook = false;
432 var num_sel_running_notebook = 0;
419 var has_directory = false;
433 var num_sel_directory = 0;
420 var has_file = false;
434 var num_sel_file = 0;
435 var num_notebook = 0;
436 var num_running_notebook = 0;
437 var num_directory = 0;
438 var num_file = 0;
439 var that = this;
421 var that = this;
440
422 var checked = 0;
441 $('.list_item input[type=checkbox]').each(function(index, item) {
423 $('.list_item :checked').each(function(index, item) {
442 var parent = $(item).parent().parent();
424 var parent = $(item).parent().parent();
425
443 // If the item doesn't have an upload button, isn't the
426 // If the item doesn't have an upload button, isn't the
444 // breadcrumbs and isn't the parent folder '..', then it can be selected.
427 // breadcrumbs and isn't the parent folder '..', then it can be selected.
445 // Breadcrumbs path == ''.
428 // Breadcrumbs path == ''.
446 if (parent.find('.upload_button').length === 0 && parent.data('path') !=='' && parent.data('path') !== utils.url_path_split(that.notebook_path)[0]) {
429 if (parent.find('.upload_button').length === 0 && parent.data('path') !== '' && parent.data('path') !== utils.url_path_split(that.notebook_path)[0]) {
447 if (parent.data('type') == 'notebook') {
430 checked++;
448 num_notebook++;
431 selected.push({
449 if (that.sessions[parent.data('path')] !== undefined) {
450 num_running_notebook++;
451 }
452 } else if (parent.data('type') == 'file') {
453 num_file++;
454 } else if (parent.data('type') == 'directory') {
455 num_directory++;
456 }
457 if ($(item).is(':checked')) {
458 selected.push({
459 name: parent.data('name'),
432 name: parent.data('name'),
460 path: parent.data('path'),
433 path: parent.data('path'),
461 type: parent.data('type')
434 type: parent.data('type')
462 });
435 });
463 if (parent.data('type') == 'notebook') {
436
464 num_sel_notebook++;
437 // Set flags according to what is selected. Flags are later
465 if (that.sessions[parent.data('path')] !== undefined) {
438 // used to decide which action buttons are visible.
466 num_sel_running_notebook++;
439 has_running_notebook = has_running_notebook ||
467 }
440 (parent.data('type') == 'notebook' && that.sessions[parent.data('path')] !== undefined);
468 } else if (parent.data('type') == 'file') {
441 has_file = has_file || parent.data('type') == 'file';
469 num_sel_file++;
442 has_directory = has_directory || parent.data('type') == 'directory';
470 } else if (parent.data('type') == 'directory') {
471 num_sel_directory++;
472 }
473 }
474 }
443 }
475 });
444 });
476
477 // Set flags according to what is selected. Flags are later
478 // used to decide which action buttons are visible.
479 var has_running_notebook = num_sel_running_notebook > 0;
480 var has_directory = num_sel_directory > 0;
481 var has_file = num_sel_file > 0;
482 this.selected = selected;
445 this.selected = selected;
483
446
484 // Rename is only visible when one item is selected.
447 // Rename is only visible when one item is selected.
@@ -511,45 +474,29 b' define(['
511 }
474 }
512
475
513 // If all of the items are selected, show the selector as checked. If
476 // If all of the items are selected, show the selector as checked. If
514 // some of the items are selected, show it as indeterminate. Otherwise,
477 // some of the items are selected, show it as checked. Otherwise,
515 // uncheck it.
478 // uncheck it.
516 var checkbox_ids = ['select-all','select-folders','select-notebooks','select-running-notebooks','select-files'];
479 var total = 0;
517 var total_nums = [num_file+num_directory+num_notebook, num_directory, num_notebook, num_running_notebook, num_file];
480 $('.list_item input[type=checkbox]').each(function(index, item) {
518 var selected_nums = [num_sel_file+num_sel_directory+num_sel_notebook, num_sel_directory, num_sel_notebook, num_sel_running_notebook, num_sel_file];
481 var parent = $(item).parent().parent();
519
482 // If the item doesn't have an upload button and it's not the
520 // Disable the main checkbox if the list is empty
483 // breadcrumbs, it can be selected. Breadcrumbs path == ''.
521 $('#'+checkbox_ids[0]).parent().prop('disabled',total_nums[0] === 0);
484 if (parent.find('.upload_button').length === 0 && parent.data('path') !== '' && parent.data('path') !== utils.url_path_split(that.notebook_path)[0]) {
522 for (var i=0; i < 5; i++) {
485 total++;
523 if (i>0) {
524 // Disable each menu item if there is nothing to select
525 $('#'+checkbox_ids[i]).prop('disabled',total_nums[i] === 0);
526 if (total_nums[i] === 0) {
527 $('#'+checkbox_ids[i]).parent().parent().addClass('disabled');
528 } else {
529 $('#'+checkbox_ids[i]).parent().parent().removeClass('disabled');
530 }
531 }
532 // Update counters
533 // Turn empty counter into a '&nbsp;' on the main checkbox for correct button height.
534 var empty_counter = i===0 ? '&nbsp;' : '';
535 $('#counter-'+checkbox_ids[i]).html(selected_nums[i]===0 ? empty_counter : selected_nums[i]);
536 // Alternative : display selected/total
537 // $('#counter-'+checkbox_ids[i]).html(selected_nums[i]===0 ? empty_counter : selected_nums[i] + '/' + total_nums[i]);
538
539 // Update each checkbox status
540 if (selected_nums[i] === 0) {
541 $('#'+checkbox_ids[i])[0].indeterminate = false;
542 $('#'+checkbox_ids[i]).prop('checked', false);
543 } else {
544 if (selected_nums[i] === total_nums[i]) {
545 $('#'+checkbox_ids[i])[0].indeterminate = false;
546 $('#'+checkbox_ids[i]).prop('checked', true);
547 } else {
548 $('#'+checkbox_ids[i]).prop('checked', false);
549 $('#'+checkbox_ids[i])[0].indeterminate = true;
550 }
551 }
486 }
487 });
488 if (checked === 0) {
489 $('#tree-selector input[type=checkbox]')[0].indeterminate = false;
490 $('#tree-selector input[type=checkbox]').prop('checked', false);
491 } else if (checked === total) {
492 $('#tree-selector input[type=checkbox]')[0].indeterminate = false;
493 $('#tree-selector input[type=checkbox]').prop('checked', true);
494 } else {
495 $('#tree-selector input[type=checkbox]').prop('checked', false);
496 $('#tree-selector input[type=checkbox]')[0].indeterminate = true;
552 }
497 }
498 // Update total counter
499 $('#counter-select-all').html(checked===0 ? '&nbsp;' : checked);
553 };
500 };
554
501
555 NotebookList.prototype.add_link = function (model, item) {
502 NotebookList.prototype.add_link = function (model, item) {
@@ -194,11 +194,8 b' input.engine_num_input {'
194 margin-right: 2px;
194 margin-right: 2px;
195 }
195 }
196
196
197 #tree-selector-menu {
197 .menu_icon {
198 width: 200px;
198 margin-right: 2px;
199 input[type=checkbox] {
200 margin-left: 0px;
201 }
202 }
199 }
203
200
204 .tab-content .row {
201 .tab-content .row {
@@ -76,55 +76,19 b' data-terminals-available="{{terminals_available}}"'
76 </div>
76 </div>
77 <div id="notebook_list">
77 <div id="notebook_list">
78 <div id="notebook_list_header" class="row list_header">
78 <div id="notebook_list_header" class="row list_header">
79 <div class="btn-group dropdown" id='tree-selector'>
79 <div class="btn-group dropdown" id="tree-selector">
80 <button type="button" class="btn btn-default btn-xs" id="button-select-all">
80 <button type="button" class="btn btn-default btn-xs" id="button-select-all">
81 <input type="checkbox" class="tree-selector pull-left" id="select-all"><span id="counter-select-all">&nbsp;</span></input>
81 <input type="checkbox" class="pull-left tree-selector" id="select-all"><span id="counter-select-all">&nbsp;</span></input>
82 </button>
82 </button>
83 <button class="btn btn-default btn-xs dropdown-toggle" type="button" id="tree-selector-btn" aria-expanded="true">
83 <button class="btn btn-default btn-xs dropdown-toggle" type="button" id="tree-selector-btn" data-toggle="dropdown" aria-expanded="true">
84 <span class="caret"></span>
84 <span class="caret"></span>
85 <span class="sr-only">Toggle Dropdown</span>
85 <span class="sr-only">Toggle Dropdown</span>
86 </button>
86 </button>
87 <ul id="tree-selector-menu" class="dropdown-menu" role="menu" aria-labelledby="tree-selector-btn">
87 <ul id='selector-menu' class="dropdown-menu" role="menu" aria-labelledby="tree-selector-btn">
88 <li role="presentation">
88 <li role="presentation"><a id="select-folders" role="menuitem" tabindex="-1" href="#"><i class="menu_icon folder_icon icon-fixed-width"></i> Folders</a></li>
89 <a role="menuitem">
89 <li role="presentation"><a id="select-notebooks" role="menuitem" tabindex="-1" href="#"><i class="menu_icon notebook_icon icon-fixed-width"></i> All Notebooks</a></li>
90 <span class="badge pull-right" id="counter-select-folders"></span>
90 <li role="presentation"><a id="select-running-notebooks" role="menuitem" tabindex="-1" href="#"><i class="menu_icon running_notebook_icon icon-fixed-width"></i> Running</a></li>
91 <input type="checkbox" class="tree-selector" id="select-folders"></input>
91 <li role="presentation"><a id="select-files" role="menuitem" tabindex="-1" href="#"><i class="menu_icon file_icon icon-fixed-width"></i> Files</a></li>
92 <label for="select-folders">
93 <i class="folder_icon icon-fixed-width"></i>
94 Folders
95 </label>
96 </a>
97 </li>
98 <li role="presentation">
99 <a role="menuitem">
100 <span class="badge pull-right" id="counter-select-notebooks"></span>
101 <input type="checkbox" class="tree-selector" id="select-notebooks"></input>
102 <label for="select-notebooks">
103 <i class="notebook_icon icon-fixed-width"></i>
104 All Notebooks
105 </label>
106 </a>
107 </li>
108 <li role="presentation">
109 <a role="menuitem">
110 <span class="badge pull-right" id="counter-select-running-notebooks"></span>
111 <input type="checkbox" class="tree-selector" id="select-running-notebooks"></input>
112 <label for="select-running-notebooks">
113 <i class="running_notebook_icon icon-fixed-width"></i>
114 Running
115 </label>
116 </a>
117 </li>
118 <li role="presentation">
119 <a role="menuitem">
120 <span class="badge pull-right" id="counter-select-files"></span>
121 <input type="checkbox" class="tree-selector" id="select-files"></input>
122 <label for="select-files">
123 <i class="file_icon icon-fixed-width"></i>
124 Files
125 </label>
126 </a>
127 </li>
128 </ul>
92 </ul>
129 </div>
93 </div>
130 <div id="project_name">
94 <div id="project_name">
General Comments 0
You need to be logged in to leave comments. Login now