##// END OF EJS Templates
Merge pull request #7681 from mathieu1/tree-selector-ui...
Jonathan Frederic -
r20659:e83cb016 merge
parent child Browse files
Show More
@@ -8787,12 +8787,17 b' input.engine_num_input {'
8787 font-weight: bold;
8787 font-weight: bold;
8788 }
8788 }
8789 #tree-selector {
8789 #tree-selector {
8790 display: inline-block;
8791 padding-right: 0px;
8790 padding-right: 0px;
8792 }
8791 }
8793 #tree-selector input[type=checkbox] {
8792 #button-select-all {
8793 min-width: 50px;
8794 }
8795 #select-all {
8794 margin-left: 7px;
8796 margin-left: 7px;
8795 vertical-align: baseline;
8797 margin-right: 2px;
8798 }
8799 .menu_icon {
8800 margin-right: 2px;
8796 }
8801 }
8797 .tab-content .row {
8802 .tab-content .row {
8798 margin-left: 0px;
8803 margin-left: 0px;
@@ -122,12 +122,16 b' define(['
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 menu buttons.
124 // Bind events for selection menu buttons.
125 $('#tree-selector .select-all').click($.proxy(this.select_all, this));
125 $('#selector-menu').click(function(event){that.select($(event.target).attr('id'))});
126 $('#tree-selector .select-notebooks').click($.proxy(this.select_notebooks, this));
126 $('#select-all').change(function(){that.select($(this).is(':checked') ? 'select-all' : 'select-none')});
127 $('#tree-selector .select-running-notebooks').click($.proxy(this.select_running_notebooks, this));
127 $('#button-select-all').click(function(e) {
128 $('#tree-selector .select-files').click($.proxy(this.select_files, this));
128 // toggle checkbox if the click doesn't come from the checkbox already
129 $('#tree-selector .select-directories').click($.proxy(this.select_directories, this));
129 if (!$(e.target).is('input[type=checkbox]')) {
130 $('#tree-selector .deselect-all').click($.proxy(this.deselect_all, this));
130 var checkbox = $('#select-all');
131 checkbox.prop('checked', !checkbox.prop('checked'));
132 that.select(checkbox.prop('checked') ? 'select-all' : 'select-none');
133 }
134 });
131 }
135 }
132 };
136 };
133
137
@@ -377,74 +381,21 b' define(['
377 };
381 };
378
382
379 /**
383 /**
380 * Select all of the items in the tree.
384 * Select all items in the tree of specified type.
381 */
385 * selection_type : string among "select-all", "select-folders", "select-notebooks", "select-running-notebooks", "select-files"
382 NotebookList.prototype.select_all = function() {
386 * any other string (like "select-none") deselects all items
383 $('.list_item input[type=checkbox]').each(function(index, item) {
384 $(item).prop('checked', true);
385 });
386 this._selection_changed();
387 };
388
389 /**
390 * Select all of the notebooks in the tree.
391 */
392 NotebookList.prototype.select_notebooks = function() {
393 this.deselect_all();
394 $('.list_item').each(function(index, item) {
395 if ($(item).data('type') === 'notebook') {
396 $(item).find('input[type=checkbox]').prop('checked', true);
397 }
398 });
399 this._selection_changed();
400 };
401
402 /**
403 * Select all of the running notebooks in the tree.
404 */
387 */
405 NotebookList.prototype.select_running_notebooks = function() {
388 NotebookList.prototype.select = function(selection_type) {
406 this.deselect_all();
407 var that = this;
389 var that = this;
408 $('.list_item').each(function(index, item) {
390 $('.list_item').each(function(index, item) {
409 if ($(item).data('type') === 'notebook' && that.sessions[$(item).data('path')] !== undefined) {
391 var item_type = $(item).data('type');
410 $(item).find('input[type=checkbox]').prop('checked', true);
392 var state = false;
411 }
393 state = state || (selection_type === "select-all");
412 });
394 state = state || (selection_type === "select-folders" && item_type === 'directory');
413 this._selection_changed();
395 state = state || (selection_type === "select-notebooks" && item_type === 'notebook');
414 };
396 state = state || (selection_type === "select-running-notebooks" && item_type === 'notebook' && that.sessions[$(item).data('path')] !== undefined);
415
397 state = state || (selection_type === "select-files" && item_type === 'file');
416 /**
398 $(item).find('input[type=checkbox]').prop('checked', state);
417 * Select all of the files in the tree.
418 */
419 NotebookList.prototype.select_files = function() {
420 this.deselect_all();
421 $('.list_item').each(function(index, item) {
422 if ($(item).data('type') === 'file') {
423 $(item).find('input[type=checkbox]').prop('checked', true);
424 }
425 });
426 this._selection_changed();
427 };
428
429 /**
430 * Select all of the directories in the tree.
431 */
432 NotebookList.prototype.select_directories = function() {
433 this.deselect_all();
434 $('.list_item').each(function(index, item) {
435 if ($(item).data('type') === 'directory') {
436 $(item).find('input[type=checkbox]').prop('checked', true);
437 }
438 });
439 this._selection_changed();
440 };
441
442 /**
443 * Unselect everything selected in the tree.
444 */
445 NotebookList.prototype.deselect_all = function() {
446 $('.list_item input[type=checkbox]').each(function(index, item) {
447 $(item).prop('checked', false);
448 });
399 });
449 this._selection_changed();
400 this._selection_changed();
450 };
401 };
@@ -466,9 +417,10 b' define(['
466 $('.list_item :checked').each(function(index, item) {
417 $('.list_item :checked').each(function(index, item) {
467 var parent = $(item).parent().parent();
418 var parent = $(item).parent().parent();
468
419
469 // If the item doesn't have an upload button and it's not the
420 // If the item doesn't have an upload button, isn't the
470 // breadcrumbs, it can be selected. Breadcrumbs path == ''.
421 // breadcrumbs and isn't the parent folder '..', then it can be selected.
471 if (parent.find('.upload_button').length === 0 && parent.data('path') !== '') {
422 // Breadcrumbs path == ''.
423 if (parent.find('.upload_button').length === 0 && parent.data('path') !== '' && parent.data('path') !== utils.url_path_split(that.notebook_path)[0]) {
472 checked++;
424 checked++;
473 selected.push({
425 selected.push({
474 name: parent.data('name'),
426 name: parent.data('name'),
@@ -523,7 +475,7 b' define(['
523 var parent = $(item).parent().parent();
475 var parent = $(item).parent().parent();
524 // If the item doesn't have an upload button and it's not the
476 // If the item doesn't have an upload button and it's not the
525 // breadcrumbs, it can be selected. Breadcrumbs path == ''.
477 // breadcrumbs, it can be selected. Breadcrumbs path == ''.
526 if (parent.find('.upload_button').length === 0 && parent.data('path') !== '') {
478 if (parent.find('.upload_button').length === 0 && parent.data('path') !== '' && parent.data('path') !== utils.url_path_split(that.notebook_path)[0]) {
527 total++;
479 total++;
528 }
480 }
529 });
481 });
@@ -537,6 +489,8 b' define(['
537 $('#tree-selector input[type=checkbox]').prop('checked', false);
489 $('#tree-selector input[type=checkbox]').prop('checked', false);
538 $('#tree-selector input[type=checkbox]')[0].indeterminate = true;
490 $('#tree-selector input[type=checkbox]')[0].indeterminate = true;
539 }
491 }
492 // Update total counter
493 $('#counter-select-all').html(checked===0 ? ' ' : checked);
540 };
494 };
541
495
542 NotebookList.prototype.add_link = function (model, item) {
496 NotebookList.prototype.add_link = function (model, item) {
@@ -12,7 +12,6 b''
12 @btn_small_height: 24px;
12 @btn_small_height: 24px;
13 @btn_mini_height: 22px;
13 @btn_mini_height: 22px;
14 @dark_dashboard_color: @breadcrumb-color;
14 @dark_dashboard_color: @breadcrumb-color;
15 @list_stripe_color: lighten(@page-backdrop-color,3%);
16
15
17 // The left padding of the selector button's contents.
16 // The left padding of the selector button's contents.
18 @dashboard-selectorbtn-lpad: 7px;
17 @dashboard-selectorbtn-lpad: 7px;
@@ -191,13 +190,20 b' input.engine_num_input {'
191 }
190 }
192
191
193 #tree-selector {
192 #tree-selector {
194 display: inline-block;
195 padding-right: 0px;
193 padding-right: 0px;
194 }
196
195
197 input[type=checkbox] {
196 #button-select-all {
198 margin-left: @dashboard_lr_pad;
197 min-width: 50px;
199 vertical-align: baseline;
198 }
200 }
199
200 #select-all {
201 margin-left: @dashboard_lr_pad;
202 margin-right: 2px;
203 }
204
205 .menu_icon {
206 margin-right: 2px;
201 }
207 }
202
208
203 .tab-content .row {
209 .tab-content .row {
@@ -76,19 +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="dropdown" id='tree-selector'>
79 <div class="btn-group dropdown" id="tree-selector">
80 <button class="btn btn-default btn-xs dropdown-toggle" type="button" id="tree-selector-btn" data-toggle="dropdown" aria-expanded="true">
80 <button title="Select All / None" type="button" class="btn btn-default btn-xs" id="button-select-all">
81 <input type='checkbox'></input>
81 <input type="checkbox" class="pull-left tree-selector" id="select-all"><span id="counter-select-all">&nbsp;</span></input>
82 </button>
83 <button title="Select..." class="btn btn-default btn-xs dropdown-toggle" type="button" id="tree-selector-btn" data-toggle="dropdown" aria-expanded="true">
82 <span class="caret"></span>
84 <span class="caret"></span>
85 <span class="sr-only">Toggle Dropdown</span>
83 </button>
86 </button>
84 <ul 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">
85 <li role="presentation" class="select-all"><a role="menuitem" tabindex="-1" href="#">Select all</a></li>
88 <li role="presentation"><a id="select-folders" role="menuitem" tabindex="-1" href="#" title="Select All Folders"><i class="menu_icon folder_icon icon-fixed-width"></i> Folders</a></li>
86 <li role="presentation" class="select-notebooks"><a role="menuitem" tabindex="-1" href="#">Select notebooks</a></li>
89 <li role="presentation"><a id="select-notebooks" role="menuitem" tabindex="-1" href="#" title="Select All Notebooks"><i class="menu_icon notebook_icon icon-fixed-width"></i> All Notebooks</a></li>
87 <li role="presentation" class="select-running-notebooks"><a role="menuitem" tabindex="-1" href="#">Select running notebooks</a></li>
90 <li role="presentation"><a id="select-running-notebooks" role="menuitem" tabindex="-1" href="#" title="Select Running Notebooks"><i class="menu_icon running_notebook_icon icon-fixed-width"></i> Running</a></li>
88 <li role="presentation" class="select-files"><a role="menuitem" tabindex="-1" href="#">Select files</a></li>
91 <li role="presentation"><a id="select-files" role="menuitem" tabindex="-1" href="#" title="Select All Files"><i class="menu_icon file_icon icon-fixed-width"></i> Files</a></li>
89 <li role="presentation" class="select-directories"><a role="menuitem" tabindex="-1" href="#">Select directories</a></li>
90 <li role="presentation" class="divider"></li>
91 <li role="presentation" class="deselect-all"><a role="menuitem" tabindex="-1" href="#">Deselect all</a></li>
92 </ul>
92 </ul>
93 </div>
93 </div>
94 <div id="project_name">
94 <div id="project_name">
General Comments 0
You need to be logged in to leave comments. Login now