##// END OF EJS Templates
Merge pull request #7274 from Carreau/global-command...
Jonathan Frederic -
r19704:db30e1c6 merge
parent child Browse files
Show More
@@ -126,11 +126,6 b' define(['
126 } else {
126 } else {
127 this.element.addClass('unrendered');
127 this.element.addClass('unrendered');
128 }
128 }
129 if (this.mode === 'edit') {
130 this.element.addClass('edit_mode');
131 } else {
132 this.element.addClass('command_mode');
133 }
134 };
129 };
135
130
136 /**
131 /**
@@ -345,8 +340,6 b' define(['
345 */
340 */
346 Cell.prototype.command_mode = function () {
341 Cell.prototype.command_mode = function () {
347 if (this.mode !== 'command') {
342 if (this.mode !== 'command') {
348 this.element.addClass('command_mode');
349 this.element.removeClass('edit_mode');
350 this.mode = 'command';
343 this.mode = 'command';
351 return true;
344 return true;
352 } else {
345 } else {
@@ -361,8 +354,6 b' define(['
361 */
354 */
362 Cell.prototype.edit_mode = function () {
355 Cell.prototype.edit_mode = function () {
363 if (this.mode !== 'edit') {
356 if (this.mode !== 'edit') {
364 this.element.addClass('edit_mode');
365 this.element.removeClass('command_mode');
366 this.mode = 'edit';
357 this.mode = 'edit';
367 return true;
358 return true;
368 } else {
359 } else {
@@ -37,21 +37,27 b' define(['
37 var that = this;
37 var that = this;
38 var knw = this.new_notification_widget('kernel');
38 var knw = this.new_notification_widget('kernel');
39 var $kernel_ind_icon = $("#kernel_indicator_icon");
39 var $kernel_ind_icon = $("#kernel_indicator_icon");
40 var $modal_ind_icon = $("#modal_indicator_icon");
40 var $modal_ind_icon = $("#modal_indicator");
41 var $body = $('body')
41
42
42 // Command/Edit mode
43 // Command/Edit mode
43 this.events.on('edit_mode.Notebook', function () {
44 this.events.on('edit_mode.Notebook', function () {
44 that.save_widget.update_document_title();
45 that.save_widget.update_document_title();
45 $modal_ind_icon.attr('class','edit_mode_icon').attr('title','Edit Mode');
46 $body.addClass('edit_mode');
47 $body.removeClass('command_mode');
48 $modal_ind_icon.attr('title','Edit Mode');
46 });
49 });
47
50
48 this.events.on('command_mode.Notebook', function () {
51 this.events.on('command_mode.Notebook', function () {
49 that.save_widget.update_document_title();
52 that.save_widget.update_document_title();
50 $modal_ind_icon.attr('class','command_mode_icon').attr('title','Command Mode');
53 $body.removeClass('edit_mode');
54 $body.addClass('command_mode');
55 $modal_ind_icon.attr('title','Command Mode');
51 });
56 });
52
57
53 // Implicitly start off in Command mode, switching to Edit mode will trigger event
58 // Implicitly start off in Command mode, switching to Edit mode will trigger event
54 $modal_ind_icon.attr('class','command_mode_icon').attr('title','Command Mode');
59 $modal_ind_icon.addClass('modal_indicator').attr('title','Command Mode');
60 $body.addClass('command_mode')
55
61
56 // Kernel events
62 // Kernel events
57
63
@@ -14,7 +14,7 b' div.cell {'
14 }
14 }
15 }
15 }
16
16
17 &.edit_mode {
17 .edit_mode &.selected {
18 border-color: green;
18 border-color: green;
19 /* Don't border the cells when printing */
19 /* Don't border the cells when printing */
20 @media print {
20 @media print {
@@ -29,11 +29,11 b''
29 .indicator_area();
29 .indicator_area();
30 }
30 }
31
31
32 .edit_mode_icon:before {
32 .edit_mode .modal_indicator:before {
33 .icon(@fa-var-pencil)
33 .icon(@fa-var-pencil)
34 }
34 }
35
35
36 .command_mode_icon:before {
36 .command_mode .modal_indicator:before {
37 .icon(' ');
37 .icon(' ');
38 }
38 }
39
39
@@ -372,12 +372,12 b' div.cell.selected {'
372 border-color: transparent;
372 border-color: transparent;
373 }
373 }
374 }
374 }
375 div.cell.edit_mode {
375 .edit_mode div.cell.selected {
376 border-color: green;
376 border-color: green;
377 /* Don't border the cells when printing */
377 /* Don't border the cells when printing */
378 }
378 }
379 @media print {
379 @media print {
380 div.cell.edit_mode {
380 .edit_mode div.cell.selected {
381 border-color: transparent;
381 border-color: transparent;
382 }
382 }
383 }
383 }
@@ -8297,12 +8297,12 b' div.cell.selected {'
8297 border-color: transparent;
8297 border-color: transparent;
8298 }
8298 }
8299 }
8299 }
8300 div.cell.edit_mode {
8300 .edit_mode div.cell.selected {
8301 border-color: green;
8301 border-color: green;
8302 /* Don't border the cells when printing */
8302 /* Don't border the cells when printing */
8303 }
8303 }
8304 @media print {
8304 @media print {
8305 div.cell.edit_mode {
8305 .edit_mode div.cell.selected {
8306 border-color: transparent;
8306 border-color: transparent;
8307 }
8307 }
8308 }
8308 }
@@ -9867,7 +9867,7 b' ul#help_menu li a i {'
9867 z-index: 10;
9867 z-index: 10;
9868 text-align: center;
9868 text-align: center;
9869 }
9869 }
9870 .edit_mode_icon:before {
9870 .edit_mode .modal_indicator:before {
9871 display: inline-block;
9871 display: inline-block;
9872 font: normal normal normal 14px/1 FontAwesome;
9872 font: normal normal normal 14px/1 FontAwesome;
9873 font-size: inherit;
9873 font-size: inherit;
@@ -9876,13 +9876,13 b' ul#help_menu li a i {'
9876 -moz-osx-font-smoothing: grayscale;
9876 -moz-osx-font-smoothing: grayscale;
9877 content: "\f040";
9877 content: "\f040";
9878 }
9878 }
9879 .edit_mode_icon:before.pull-left {
9879 .edit_mode .modal_indicator:before.pull-left {
9880 margin-right: .3em;
9880 margin-right: .3em;
9881 }
9881 }
9882 .edit_mode_icon:before.pull-right {
9882 .edit_mode .modal_indicator:before.pull-right {
9883 margin-left: .3em;
9883 margin-left: .3em;
9884 }
9884 }
9885 .command_mode_icon:before {
9885 .command_mode .modal_indicator:before {
9886 display: inline-block;
9886 display: inline-block;
9887 font: normal normal normal 14px/1 FontAwesome;
9887 font: normal normal normal 14px/1 FontAwesome;
9888 font-size: inherit;
9888 font-size: inherit;
@@ -9891,10 +9891,10 b' ul#help_menu li a i {'
9891 -moz-osx-font-smoothing: grayscale;
9891 -moz-osx-font-smoothing: grayscale;
9892 content: ' ';
9892 content: ' ';
9893 }
9893 }
9894 .command_mode_icon:before.pull-left {
9894 .command_mode .modal_indicator:before.pull-left {
9895 margin-right: .3em;
9895 margin-right: .3em;
9896 }
9896 }
9897 .command_mode_icon:before.pull-right {
9897 .command_mode .modal_indicator:before.pull-right {
9898 margin-left: .3em;
9898 margin-left: .3em;
9899 }
9899 }
9900 .kernel_idle_icon:before {
9900 .kernel_idle_icon:before {
@@ -61,9 +61,7 b' class="notebook_app"'
61 <span class="kernel_indicator_name">Kernel</span>
61 <span class="kernel_indicator_name">Kernel</span>
62 <i id="kernel_indicator_icon"></i>
62 <i id="kernel_indicator_icon"></i>
63 </p>
63 </p>
64 <p id="modal_indicator" class="navbar-text">
64 <i id="modal_indicator" class="navbar-text"></i>
65 <i id="modal_indicator_icon"></i>
66 </p>
67 <span id="notification_area"></span>
65 <span id="notification_area"></span>
68 <div class="navbar-collapse collapse">
66 <div class="navbar-collapse collapse">
69 <ul class="nav navbar-nav">
67 <ul class="nav navbar-nav">
@@ -395,7 +395,7 b' casper.validate_notebook_state = function(message, mode, cell_index) {'
395 if (cell_index!==undefined) {
395 if (cell_index!==undefined) {
396 // Is the specified cell the only cell in edit mode?
396 // Is the specified cell the only cell in edit mode?
397 this.test.assert(this.is_only_cell_edit(cell_index),
397 this.test.assert(this.is_only_cell_edit(cell_index),
398 message + '; cell ' + cell_index + ' is the only cell in edit mode');
398 message + '; cell ' + cell_index + ' is the only cell in edit mode '+ this.cells_modes());
399 // Is the specified cell the only cell with a focused code mirror?
399 // Is the specified cell the only cell with a focused code mirror?
400 this.test.assert(this.is_cell_editor_focused(cell_index),
400 this.test.assert(this.is_cell_editor_focused(cell_index),
401 message + '; cell ' + cell_index + '\'s editor is appropriately focused');
401 message + '; cell ' + cell_index + '\'s editor is appropriately focused');
@@ -506,7 +506,19 b' casper.is_only_cell_selected = function(index) {'
506 casper.is_only_cell_edit = function(index) {
506 casper.is_only_cell_edit = function(index) {
507 // Check if a cell is the only cell in edit mode.
507 // Check if a cell is the only cell in edit mode.
508 // Pass null as the index to check if all of the cells are in command mode.
508 // Pass null as the index to check if all of the cells are in command mode.
509 return this.is_only_cell_on(index, 'edit_mode', 'command_mode');
509 var cells_length = this.get_cells_length();
510 for (var j = 0; j < cells_length; j++) {
511 if (j === index) {
512 if (!this.cell_mode_is(j, 'edit')) {
513 return false;
514 }
515 } else {
516 if (this.cell_mode_is(j, 'edit')) {
517 return false;
518 }
519 }
520 }
521 return true;
510 };
522 };
511
523
512 casper.is_only_cell_on = function(i, on_class, off_class) {
524 casper.is_only_cell_on = function(i, on_class, off_class) {
@@ -528,6 +540,24 b' casper.is_only_cell_on = function(i, on_class, off_class) {'
528 return true;
540 return true;
529 };
541 };
530
542
543 casper.cells_modes = function(){
544 return this.evaluate(function(){
545 return IPython.notebook.get_cells().map(function(x,c){return x.mode})
546 }, {});
547 };
548
549 casper.cell_mode_is = function(index, mode) {
550 // Check if a cell is in a specific mode
551 return this.evaluate(function(i, m) {
552 var cell = IPython.notebook.get_cell(i);
553 if (cell) {
554 return cell.mode === m;
555 }
556 return false;
557 }, {i : index, m: mode});
558 };
559
560
531 casper.cell_has_class = function(index, classes) {
561 casper.cell_has_class = function(index, classes) {
532 // Check if a cell has a class.
562 // Check if a cell has a class.
533 return this.evaluate(function(i, c) {
563 return this.evaluate(function(i, c) {
General Comments 0
You need to be logged in to leave comments. Login now