##// END OF EJS Templates
Make maintoolbar select dropdowns look nice
Jonathan Frederic -
Show More
@@ -1,219 +1,221 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2011 The IPython Development Team
2 // Copyright (C) 2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // ToolBar
9 // ToolBar
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 var IPython = (function (IPython) {
13 "use strict";
13 "use strict";
14
14
15 var MainToolBar = function (selector) {
15 var MainToolBar = function (selector) {
16 IPython.ToolBar.apply(this, arguments);
16 IPython.ToolBar.apply(this, arguments);
17 this.construct();
17 this.construct();
18 this.add_celltype_list();
18 this.add_celltype_list();
19 this.add_celltoolbar_list();
19 this.add_celltoolbar_list();
20 this.bind_events();
20 this.bind_events();
21 };
21 };
22
22
23 MainToolBar.prototype = new IPython.ToolBar();
23 MainToolBar.prototype = new IPython.ToolBar();
24
24
25 MainToolBar.prototype.construct = function () {
25 MainToolBar.prototype.construct = function () {
26 this.add_buttons_group([
26 this.add_buttons_group([
27 {
27 {
28 id : 'save_b',
28 id : 'save_b',
29 label : 'Save and Checkpoint',
29 label : 'Save and Checkpoint',
30 icon : 'icon-save',
30 icon : 'icon-save',
31 callback : function () {
31 callback : function () {
32 IPython.notebook.save_checkpoint();
32 IPython.notebook.save_checkpoint();
33 }
33 }
34 }
34 }
35 ]);
35 ]);
36
36
37 this.add_buttons_group([
37 this.add_buttons_group([
38 {
38 {
39 id : 'insert_below_b',
39 id : 'insert_below_b',
40 label : 'Insert Cell Below',
40 label : 'Insert Cell Below',
41 icon : 'icon-plus-sign',
41 icon : 'icon-plus-sign',
42 callback : function () {
42 callback : function () {
43 IPython.notebook.insert_cell_below('code');
43 IPython.notebook.insert_cell_below('code');
44 IPython.notebook.select_next();
44 IPython.notebook.select_next();
45 IPython.notebook.focus_cell();
45 IPython.notebook.focus_cell();
46 }
46 }
47 }
47 }
48 ],'insert_above_below');
48 ],'insert_above_below');
49
49
50 this.add_buttons_group([
50 this.add_buttons_group([
51 {
51 {
52 id : 'cut_b',
52 id : 'cut_b',
53 label : 'Cut Cell',
53 label : 'Cut Cell',
54 icon : 'icon-cut',
54 icon : 'icon-cut',
55 callback : function () {
55 callback : function () {
56 IPython.notebook.cut_cell();
56 IPython.notebook.cut_cell();
57 }
57 }
58 },
58 },
59 {
59 {
60 id : 'copy_b',
60 id : 'copy_b',
61 label : 'Copy Cell',
61 label : 'Copy Cell',
62 icon : 'icon-copy',
62 icon : 'icon-copy',
63 callback : function () {
63 callback : function () {
64 IPython.notebook.copy_cell();
64 IPython.notebook.copy_cell();
65 }
65 }
66 },
66 },
67 {
67 {
68 id : 'paste_b',
68 id : 'paste_b',
69 label : 'Paste Cell Below',
69 label : 'Paste Cell Below',
70 icon : 'icon-paste',
70 icon : 'icon-paste',
71 callback : function () {
71 callback : function () {
72 IPython.notebook.paste_cell_below();
72 IPython.notebook.paste_cell_below();
73 }
73 }
74 }
74 }
75 ],'cut_copy_paste');
75 ],'cut_copy_paste');
76
76
77 this.add_buttons_group([
77 this.add_buttons_group([
78 {
78 {
79 id : 'move_up_b',
79 id : 'move_up_b',
80 label : 'Move Cell Up',
80 label : 'Move Cell Up',
81 icon : 'icon-arrow-up',
81 icon : 'icon-arrow-up',
82 callback : function () {
82 callback : function () {
83 IPython.notebook.move_cell_up();
83 IPython.notebook.move_cell_up();
84 }
84 }
85 },
85 },
86 {
86 {
87 id : 'move_down_b',
87 id : 'move_down_b',
88 label : 'Move Cell Down',
88 label : 'Move Cell Down',
89 icon : 'icon-arrow-down',
89 icon : 'icon-arrow-down',
90 callback : function () {
90 callback : function () {
91 IPython.notebook.move_cell_down();
91 IPython.notebook.move_cell_down();
92 }
92 }
93 }
93 }
94 ],'move_up_down');
94 ],'move_up_down');
95
95
96
96
97 this.add_buttons_group([
97 this.add_buttons_group([
98 {
98 {
99 id : 'run_b',
99 id : 'run_b',
100 label : 'Run Cell',
100 label : 'Run Cell',
101 icon : 'icon-play',
101 icon : 'icon-play',
102 callback : function () {
102 callback : function () {
103 // emulate default shift-enter behavior
103 // emulate default shift-enter behavior
104 IPython.notebook.execute_cell_and_select_below();
104 IPython.notebook.execute_cell_and_select_below();
105 }
105 }
106 },
106 },
107 {
107 {
108 id : 'interrupt_b',
108 id : 'interrupt_b',
109 label : 'Interrupt',
109 label : 'Interrupt',
110 icon : 'icon-stop',
110 icon : 'icon-stop',
111 callback : function () {
111 callback : function () {
112 IPython.notebook.session.interrupt_kernel();
112 IPython.notebook.session.interrupt_kernel();
113 }
113 }
114 },
114 },
115 {
115 {
116 id : 'repeat_b',
116 id : 'repeat_b',
117 label : 'Restart Kernel',
117 label : 'Restart Kernel',
118 icon : 'icon-repeat',
118 icon : 'icon-repeat',
119 callback : function () {
119 callback : function () {
120 IPython.notebook.restart_kernel();
120 IPython.notebook.restart_kernel();
121 }
121 }
122 }
122 }
123 ],'run_int');
123 ],'run_int');
124 };
124 };
125
125
126 MainToolBar.prototype.add_celltype_list = function () {
126 MainToolBar.prototype.add_celltype_list = function () {
127 this.element
127 this.element
128 .append($('<select/>')
128 .append($('<select/>')
129 .attr('id','cell_type')
129 .attr('id','cell_type')
130 .addClass('form-control select-xs')
130 // .addClass('ui-widget-content')
131 // .addClass('ui-widget-content')
131 .append($('<option/>').attr('value','code').text('Code'))
132 .append($('<option/>').attr('value','code').text('Code'))
132 .append($('<option/>').attr('value','markdown').text('Markdown'))
133 .append($('<option/>').attr('value','markdown').text('Markdown'))
133 .append($('<option/>').attr('value','raw').text('Raw NBConvert'))
134 .append($('<option/>').attr('value','raw').text('Raw NBConvert'))
134 .append($('<option/>').attr('value','heading1').text('Heading 1'))
135 .append($('<option/>').attr('value','heading1').text('Heading 1'))
135 .append($('<option/>').attr('value','heading2').text('Heading 2'))
136 .append($('<option/>').attr('value','heading2').text('Heading 2'))
136 .append($('<option/>').attr('value','heading3').text('Heading 3'))
137 .append($('<option/>').attr('value','heading3').text('Heading 3'))
137 .append($('<option/>').attr('value','heading4').text('Heading 4'))
138 .append($('<option/>').attr('value','heading4').text('Heading 4'))
138 .append($('<option/>').attr('value','heading5').text('Heading 5'))
139 .append($('<option/>').attr('value','heading5').text('Heading 5'))
139 .append($('<option/>').attr('value','heading6').text('Heading 6'))
140 .append($('<option/>').attr('value','heading6').text('Heading 6'))
140 );
141 );
141 };
142 };
142
143
143
144
144 MainToolBar.prototype.add_celltoolbar_list = function () {
145 MainToolBar.prototype.add_celltoolbar_list = function () {
145 var label = $('<span/>').addClass("navbar-text").text('Cell Toolbar:');
146 var label = $('<span/>').addClass("navbar-text").text('Cell Toolbar:');
146 var select = $('<select/>')
147 var select = $('<select/>')
147 // .addClass('ui-widget-content')
148 // .addClass('ui-widget-content')
148 .attr('id', 'ctb_select')
149 .attr('id', 'ctb_select')
150 .addClass('form-control select-xs')
149 .append($('<option/>').attr('value', '').text('None'));
151 .append($('<option/>').attr('value', '').text('None'));
150 this.element.append(label).append(select);
152 this.element.append(label).append(select);
151 select.change(function() {
153 select.change(function() {
152 var val = $(this).val()
154 var val = $(this).val()
153 if (val =='') {
155 if (val =='') {
154 IPython.CellToolbar.global_hide();
156 IPython.CellToolbar.global_hide();
155 delete IPython.notebook.metadata.celltoolbar;
157 delete IPython.notebook.metadata.celltoolbar;
156 } else {
158 } else {
157 IPython.CellToolbar.global_show();
159 IPython.CellToolbar.global_show();
158 IPython.CellToolbar.activate_preset(val);
160 IPython.CellToolbar.activate_preset(val);
159 IPython.notebook.metadata.celltoolbar = val;
161 IPython.notebook.metadata.celltoolbar = val;
160 }
162 }
161 });
163 });
162 // Setup the currently registered presets.
164 // Setup the currently registered presets.
163 var presets = IPython.CellToolbar.list_presets();
165 var presets = IPython.CellToolbar.list_presets();
164 for (var i=0; i<presets.length; i++) {
166 for (var i=0; i<presets.length; i++) {
165 var name = presets[i];
167 var name = presets[i];
166 select.append($('<option/>').attr('value', name).text(name));
168 select.append($('<option/>').attr('value', name).text(name));
167 }
169 }
168 // Setup future preset registrations.
170 // Setup future preset registrations.
169 $([IPython.events]).on('preset_added.CellToolbar', function (event, data) {
171 $([IPython.events]).on('preset_added.CellToolbar', function (event, data) {
170 var name = data.name;
172 var name = data.name;
171 select.append($('<option/>').attr('value', name).text(name));
173 select.append($('<option/>').attr('value', name).text(name));
172 });
174 });
173 // Update select value when a preset is activated.
175 // Update select value when a preset is activated.
174 $([IPython.events]).on('preset_activated.CellToolbar', function (event, data) {
176 $([IPython.events]).on('preset_activated.CellToolbar', function (event, data) {
175 if (select.val() !== data.name)
177 if (select.val() !== data.name)
176 select.val(data.name);
178 select.val(data.name);
177 });
179 });
178 };
180 };
179
181
180
182
181 MainToolBar.prototype.bind_events = function () {
183 MainToolBar.prototype.bind_events = function () {
182 var that = this;
184 var that = this;
183
185
184 this.element.find('#cell_type').change(function () {
186 this.element.find('#cell_type').change(function () {
185 var cell_type = $(this).val();
187 var cell_type = $(this).val();
186 if (cell_type === 'code') {
188 if (cell_type === 'code') {
187 IPython.notebook.to_code();
189 IPython.notebook.to_code();
188 } else if (cell_type === 'markdown') {
190 } else if (cell_type === 'markdown') {
189 IPython.notebook.to_markdown();
191 IPython.notebook.to_markdown();
190 } else if (cell_type === 'raw') {
192 } else if (cell_type === 'raw') {
191 IPython.notebook.to_raw();
193 IPython.notebook.to_raw();
192 } else if (cell_type === 'heading1') {
194 } else if (cell_type === 'heading1') {
193 IPython.notebook.to_heading(undefined, 1);
195 IPython.notebook.to_heading(undefined, 1);
194 } else if (cell_type === 'heading2') {
196 } else if (cell_type === 'heading2') {
195 IPython.notebook.to_heading(undefined, 2);
197 IPython.notebook.to_heading(undefined, 2);
196 } else if (cell_type === 'heading3') {
198 } else if (cell_type === 'heading3') {
197 IPython.notebook.to_heading(undefined, 3);
199 IPython.notebook.to_heading(undefined, 3);
198 } else if (cell_type === 'heading4') {
200 } else if (cell_type === 'heading4') {
199 IPython.notebook.to_heading(undefined, 4);
201 IPython.notebook.to_heading(undefined, 4);
200 } else if (cell_type === 'heading5') {
202 } else if (cell_type === 'heading5') {
201 IPython.notebook.to_heading(undefined, 5);
203 IPython.notebook.to_heading(undefined, 5);
202 } else if (cell_type === 'heading6') {
204 } else if (cell_type === 'heading6') {
203 IPython.notebook.to_heading(undefined, 6);
205 IPython.notebook.to_heading(undefined, 6);
204 }
206 }
205 });
207 });
206 $([IPython.events]).on('selected_cell_type_changed.Notebook', function (event, data) {
208 $([IPython.events]).on('selected_cell_type_changed.Notebook', function (event, data) {
207 if (data.cell_type === 'heading') {
209 if (data.cell_type === 'heading') {
208 that.element.find('#cell_type').val(data.cell_type+data.level);
210 that.element.find('#cell_type').val(data.cell_type+data.level);
209 } else {
211 } else {
210 that.element.find('#cell_type').val(data.cell_type);
212 that.element.find('#cell_type').val(data.cell_type);
211 }
213 }
212 });
214 });
213 };
215 };
214
216
215 IPython.MainToolBar = MainToolBar;
217 IPython.MainToolBar = MainToolBar;
216
218
217 return IPython;
219 return IPython;
218
220
219 }(IPython));
221 }(IPython));
@@ -1,42 +1,51 b''
1 .toolbar {
1 .toolbar {
2 padding: 0px;
2 padding: 0px;
3 margin-left: -5px;
3 margin-left: -5px;
4 margin-top: -5px;
4 margin-top: -5px;
5
5
6 select, label {
6 select, label {
7 width: auto;
7 width: auto;
8 vertical-align:middle;
8 vertical-align:middle;
9 margin-right:2px;
9 margin-right:2px;
10 margin-bottom:0px;
10 margin-bottom:0px;
11 display: inline;
11 display: inline;
12 font-size: 92%;
12 font-size: 92%;
13 margin-left:0.3em;
13 margin-left:0.3em;
14 margin-right:0.3em;
14 margin-right:0.3em;
15 padding: 0px;
15 padding: 0px;
16 padding-top: 3px;
16 padding-top: 3px;
17 }
17 }
18 .btn {
18 .btn {
19 padding: 2px 8px;
19 padding: 2px 8px;
20 }
20 }
21 }
21 }
22
22
23 .toolbar .btn-group {
23 .toolbar .btn-group {
24 margin-top: 0px;
24 margin-top: 0px;
25 margin-left: 5px;
25 margin-left: 5px;
26 }
26 }
27
27
28 .toolbar-inner {
28 .toolbar-inner {
29 border: none !important;
29 border: none !important;
30 .box-shadow(none) !important;
30 .box-shadow(none) !important;
31 }
31 }
32
32
33 #maintoolbar {
33 #maintoolbar {
34 margin-bottom: 0px;
34 margin-bottom: 0px;
35 margin-top: -2px;
35 margin-top: -2px;
36 border: 0px;
36 border: 0px;
37 min-height: 27px;
37 min-height: 27px;
38 }
38 }
39
39
40 #maintoolbar .navbar-text {
40 #maintoolbar .navbar-text {
41 float: none;
41 float: none;
42 vertical-align: middle;
43 text-align: right;
44 margin-left: 5px;
45 margin-right: 0px;
46 margin-top: 0px
47 }
48
49 .select-xs {
50 height: @btn_small_height;
42 }
51 }
@@ -1,149 +1,149 b''
1
1
2 /**
2 /**
3 * Primary styles
3 * Primary styles
4 *
4 *
5 * Author: IPython Development Team
5 * Author: IPython Development Team
6 */
6 */
7
7
8 @dashboard_tb_pad: 4px;
8 @dashboard_tb_pad: 4px;
9 @dashboard_lr_pad: 7px;
9 @dashboard_lr_pad: 7px;
10 // These are the total heights of the Bootstrap small and mini buttons. These values
10 // These are the total heights of the Bootstrap small and mini buttons. These values
11 // are not less variables so we have to track them statically.
11 // are not less variables so we have to track them statically.
12 @btn_small_height: 26px;
12 @btn_small_height: 24px;
13 @btn_mini_height: 22px;
13 @btn_mini_height: 22px;
14 @dark_dashboard_color: darken(@border_color, 30%);
14 @dark_dashboard_color: darken(@border_color, 30%);
15
15
16 ul#tabs {
16 ul#tabs {
17 margin-bottom: @dashboard_tb_pad;
17 margin-bottom: @dashboard_tb_pad;
18 }
18 }
19
19
20 ul#tabs a {
20 ul#tabs a {
21 padding-top: @dashboard_tb_pad;
21 padding-top: @dashboard_tb_pad;
22 padding-bottom: @dashboard_tb_pad;
22 padding-bottom: @dashboard_tb_pad;
23 }
23 }
24
24
25 ul.breadcrumb {
25 ul.breadcrumb {
26 a:focus, a:hover {
26 a:focus, a:hover {
27 text-decoration: none;
27 text-decoration: none;
28 }
28 }
29 i.icon-home {
29 i.icon-home {
30 font-size: 16px;
30 font-size: 16px;
31 margin-right: 4px;
31 margin-right: 4px;
32 }
32 }
33
33
34 span {
34 span {
35 color: @dark_dashboard_color;
35 color: @dark_dashboard_color;
36 }
36 }
37 }
37 }
38
38
39 .list_toolbar {
39 .list_toolbar {
40 padding: @dashboard_tb_pad 0 @dashboard_tb_pad 0;
40 padding: @dashboard_tb_pad 0 @dashboard_tb_pad 0;
41 vertical-align: middle;
41 vertical-align: middle;
42
42
43 .tree-buttons {
43 .tree-buttons {
44 padding-top: 2px;
44 padding-top: 2px;
45 }
45 }
46 }
46 }
47
47
48 .list_toolbar [class*="span"] {
48 .list_toolbar [class*="span"] {
49 min-height: @btn_small_height;
49 min-height: @btn_small_height;
50 }
50 }
51
51
52 .list_header {
52 .list_header {
53 font-weight: bold;
53 font-weight: bold;
54 }
54 }
55
55
56 .list_container {
56 .list_container {
57 margin-top: @dashboard_tb_pad;
57 margin-top: @dashboard_tb_pad;
58 margin-bottom: 5*@dashboard_tb_pad;
58 margin-bottom: 5*@dashboard_tb_pad;
59 border: 1px solid @border_color;
59 border: 1px solid @border_color;
60 border-radius: 4px;
60 border-radius: 4px;
61 }
61 }
62
62
63 .list_container > div {
63 .list_container > div {
64 border-bottom: 1px solid @border_color;
64 border-bottom: 1px solid @border_color;
65 &:hover .list-item{
65 &:hover .list-item{
66 background-color: red;
66 background-color: red;
67 };
67 };
68 }
68 }
69
69
70 .list_container > div:last-child {
70 .list_container > div:last-child {
71 border: none;
71 border: none;
72 }
72 }
73
73
74 .list_item {
74 .list_item {
75 &:hover .list_item {
75 &:hover .list_item {
76 background-color: #ddd;
76 background-color: #ddd;
77 };
77 };
78 a {text-decoration: none;}
78 a {text-decoration: none;}
79 }
79 }
80
80
81 .action_col {
81 .action_col {
82 text-align: right;
82 text-align: right;
83 }
83 }
84
84
85 .list_header>div, .list_item>div {
85 .list_header>div, .list_item>div {
86 padding-top: @dashboard_tb_pad;
86 padding-top: @dashboard_tb_pad;
87 padding-bottom: @dashboard_tb_pad;
87 padding-bottom: @dashboard_tb_pad;
88 padding-left: @dashboard_lr_pad;
88 padding-left: @dashboard_lr_pad;
89 padding-right: @dashboard_lr_pad;
89 padding-right: @dashboard_lr_pad;
90 line-height: @btn_mini_height;
90 line-height: @btn_mini_height;
91 }
91 }
92
92
93 .item_name {
93 .item_name {
94 line-height: @btn_mini_height;
94 line-height: @btn_mini_height;
95 height: @btn_small_height;
95 height: @btn_small_height;
96 }
96 }
97
97
98 .item_icon {
98 .item_icon {
99 font-size: 14px;
99 font-size: 14px;
100 color: @dark_dashboard_color;
100 color: @dark_dashboard_color;
101 margin-right: @dashboard_lr_pad;
101 margin-right: @dashboard_lr_pad;
102 }
102 }
103
103
104 .item_buttons {
104 .item_buttons {
105 line-height: 1em;
105 line-height: 1em;
106 }
106 }
107
107
108 .toolbar_info {
108 .toolbar_info {
109 height: @btn_small_height;
109 height: @btn_small_height;
110 line-height: @btn_small_height;
110 line-height: @btn_small_height;
111 }
111 }
112
112
113 input.nbname_input, input.engine_num_input {
113 input.nbname_input, input.engine_num_input {
114 // These settings give these inputs a height that matches @btn_mini_height = 22
114 // These settings give these inputs a height that matches @btn_mini_height = 22
115 padding-top: 3px;
115 padding-top: 3px;
116 padding-bottom: 3px;
116 padding-bottom: 3px;
117 height: @btn_mini_height;
117 height: @btn_mini_height;
118 line-height: 14px;
118 line-height: 14px;
119 margin: 0px;
119 margin: 0px;
120 }
120 }
121
121
122 input.engine_num_input {
122 input.engine_num_input {
123 width: 60px;
123 width: 60px;
124 }
124 }
125
125
126 .highlight_text {
126 .highlight_text {
127 color: blue;
127 color: blue;
128 }
128 }
129
129
130 #project_name > .breadcrumb {
130 #project_name > .breadcrumb {
131 padding: 0px;
131 padding: 0px;
132 margin-bottom: 0px;
132 margin-bottom: 0px;
133 background-color: transparent;
133 background-color: transparent;
134 font-weight: bold;
134 font-weight: bold;
135
135
136 }
136 }
137
137
138 .tab-content .row {
138 .tab-content .row {
139 margin-left: 0px;
139 margin-left: 0px;
140 margin-right: 0px;
140 margin-right: 0px;
141 }
141 }
142
142
143 .folder_icon:before {
143 .folder_icon:before {
144 .icon(@folder-close-alt)
144 .icon(@folder-close-alt)
145 }
145 }
146
146
147 .notebook_icon:before {
147 .notebook_icon:before {
148 .icon(@book)
148 .icon(@book)
149 }
149 }
General Comments 0
You need to be logged in to leave comments. Login now