Show More
@@ -1,102 +1,132 | |||||
1 | //---------------------------------------------------------------------------- |
|
1 | //---------------------------------------------------------------------------- | |
2 | // Copyright (C) 2008-2011 The IPython Development Team |
|
2 | // Copyright (C) 2008-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 |
|
13 | |||
14 | var ToolBar = function (selector) { |
|
14 | var ToolBar = function (selector) { | |
15 | this.selector = selector; |
|
15 | this.selector = selector; | |
16 | if (this.selector !== undefined) { |
|
16 | if (this.selector !== undefined) { | |
17 | this.element = $(selector); |
|
17 | this.element = $(selector); | |
18 | this.style(); |
|
18 | this.style(); | |
19 | this.bind_events(); |
|
19 | this.bind_events(); | |
20 | } |
|
20 | } | |
21 | }; |
|
21 | }; | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | ToolBar.prototype.style = function () { |
|
24 | ToolBar.prototype.style = function () { | |
25 | this.element.addClass('border-box-sizing'); |
|
25 | this.element.addClass('border-box-sizing'); | |
26 | this.element.find('#cell_type').addClass('ui-widget ui-widget-content'); |
|
26 | this.element.find('#cell_type').addClass('ui-widget ui-widget-content'); | |
27 | this.element.find('#save_b').button({ |
|
27 | this.element.find('#save_b').button({ | |
28 | icons : {primary: 'ui-icon-disk'}, |
|
28 | icons : {primary: 'ui-icon-disk'}, | |
29 | text : false |
|
29 | text : false | |
30 | }); |
|
30 | }); | |
31 | this.element.find('#cut_b').button({ |
|
31 | this.element.find('#cut_b').button({ | |
32 | icons: {primary: 'ui-icon-scissors'}, |
|
32 | icons: {primary: 'ui-icon-scissors'}, | |
33 | text : false |
|
33 | text : false | |
34 | }); |
|
34 | }); | |
35 | this.element.find('#copy_b').button({ |
|
35 | this.element.find('#copy_b').button({ | |
36 | icons: {primary: 'ui-icon-copy'}, |
|
36 | icons: {primary: 'ui-icon-copy'}, | |
37 | text : false |
|
37 | text : false | |
38 | }); |
|
38 | }); | |
39 | this.element.find('#paste_b').button({ |
|
39 | this.element.find('#paste_b').button({ | |
40 | icons: {primary: 'ui-icon-clipboard'}, |
|
40 | icons: {primary: 'ui-icon-clipboard'}, | |
41 | text : false |
|
41 | text : false | |
42 | }); |
|
42 | }); | |
43 | this.element.find('#cut_copy_paste').buttonset(); |
|
43 | this.element.find('#cut_copy_paste').buttonset(); | |
44 | this.element.find('#move_up_b').button({ |
|
44 | this.element.find('#move_up_b').button({ | |
45 | icons: {primary: 'ui-icon-arrowthick-1-n'}, |
|
45 | icons: {primary: 'ui-icon-arrowthick-1-n'}, | |
46 | text : false |
|
46 | text : false | |
47 | }); |
|
47 | }); | |
48 | this.element.find('#move_down_b').button({ |
|
48 | this.element.find('#move_down_b').button({ | |
49 | icons: {primary: 'ui-icon-arrowthick-1-s'}, |
|
49 | icons: {primary: 'ui-icon-arrowthick-1-s'}, | |
50 | text : false |
|
50 | text : false | |
51 | }); |
|
51 | }); | |
52 | this.element.find('#move_up_down').buttonset(); |
|
52 | this.element.find('#move_up_down').buttonset(); | |
53 | this.element.find('#insert_above_b').button({ |
|
53 | this.element.find('#insert_above_b').button({ | |
54 | icons: {primary: 'ui-icon-arrowthickstop-1-n'}, |
|
54 | icons: {primary: 'ui-icon-arrowthickstop-1-n'}, | |
55 | text : false |
|
55 | text : false | |
56 | }); |
|
56 | }); | |
57 | this.element.find('#insert_below_b').button({ |
|
57 | this.element.find('#insert_below_b').button({ | |
58 | icons: {primary: 'ui-icon-arrowthickstop-1-s'}, |
|
58 | icons: {primary: 'ui-icon-arrowthickstop-1-s'}, | |
59 | text : false |
|
59 | text : false | |
60 | }); |
|
60 | }); | |
61 | this.element.find('#insert_above_below').buttonset(); |
|
61 | this.element.find('#insert_above_below').buttonset(); | |
62 | this.element.find('#run_b').button({ |
|
62 | this.element.find('#run_b').button({ | |
63 | icons: {primary: 'ui-icon-play'}, |
|
63 | icons: {primary: 'ui-icon-play'}, | |
64 | text : false |
|
64 | text : false | |
65 | }); |
|
65 | }); | |
66 | this.element.find('#interrupt_b').button({ |
|
66 | this.element.find('#interrupt_b').button({ | |
67 | icons: {primary: 'ui-icon-stop'}, |
|
67 | icons: {primary: 'ui-icon-stop'}, | |
68 | text : false |
|
68 | text : false | |
69 | }); |
|
69 | }); | |
70 | this.element.find('#run_int').buttonset(); |
|
70 | this.element.find('#run_int').buttonset(); | |
71 | }; |
|
71 | }; | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | ToolBar.prototype.bind_events = function () { |
|
74 | ToolBar.prototype.bind_events = function () { | |
|
75 | this.element.find('#save_b').click(function () { | |||
|
76 | IPython.save_widget.save_notebook(); | |||
|
77 | }); | |||
|
78 | this.element.find('#cut_b').click(function () { | |||
|
79 | IPython.notebook.cut_cell(); | |||
|
80 | }); | |||
|
81 | this.element.find('#copy_b').click(function () { | |||
|
82 | IPython.notebook.copy_cell(); | |||
|
83 | }); | |||
|
84 | this.element.find('#paste_b').click(function () { | |||
|
85 | IPython.notebook.paste_cell(); | |||
|
86 | }); | |||
|
87 | this.element.find('#move_up_b').click(function () { | |||
|
88 | IPython.notebook.move_cell_up(); | |||
|
89 | }); | |||
|
90 | this.element.find('#move_down_b').click(function () { | |||
|
91 | IPython.notebook.move_cell_down(); | |||
|
92 | }); | |||
|
93 | this.element.find('#insert_above_b').click(function () { | |||
|
94 | IPython.notebook.insert_cell_above('code'); | |||
|
95 | }); | |||
|
96 | this.element.find('#insert_below_b').click(function () { | |||
|
97 | IPython.notebook.insert_cell_below('code'); | |||
|
98 | }); | |||
|
99 | this.element.find('#run_b').click(function () { | |||
|
100 | IPython.notebook.execute_selected_cell(); | |||
|
101 | }); | |||
|
102 | this.element.find('#interrupt_b').click(function () { | |||
|
103 | IPython.notebook.kernel.interrupt(); | |||
|
104 | }); | |||
75 | this.element.find('#cell_type').change(function () { |
|
105 | this.element.find('#cell_type').change(function () { | |
76 | var cell_type = $(this).val(); |
|
106 | var cell_type = $(this).val(); | |
77 | if (cell_type === 'code') { |
|
107 | if (cell_type === 'code') { | |
78 | IPython.notebook.to_code(); |
|
108 | IPython.notebook.to_code(); | |
79 | } else if (cell_type === 'markdown') { |
|
109 | } else if (cell_type === 'markdown') { | |
80 | IPython.notebook.to_markdown(); |
|
110 | IPython.notebook.to_markdown(); | |
81 | }; |
|
111 | }; | |
82 | }); |
|
112 | }); | |
83 |
|
113 | |||
84 | }; |
|
114 | }; | |
85 |
|
115 | |||
86 |
|
116 | |||
87 | ToolBar.prototype.set_cell_type = function (cell_type) { |
|
117 | ToolBar.prototype.set_cell_type = function (cell_type) { | |
88 | this.element.find('#cell_type').val(cell_type); |
|
118 | this.element.find('#cell_type').val(cell_type); | |
89 | }; |
|
119 | }; | |
90 |
|
120 | |||
91 |
|
121 | |||
92 | ToolBar.prototype.toggle = function () { |
|
122 | ToolBar.prototype.toggle = function () { | |
93 | this.element.toggle(); |
|
123 | this.element.toggle(); | |
94 | IPython.layout_manager.do_resize(); |
|
124 | IPython.layout_manager.do_resize(); | |
95 | }; |
|
125 | }; | |
96 |
|
126 | |||
97 |
|
127 | |||
98 | IPython.ToolBar = ToolBar; |
|
128 | IPython.ToolBar = ToolBar; | |
99 |
|
129 | |||
100 | return IPython; |
|
130 | return IPython; | |
101 |
|
131 | |||
102 | }(IPython)); |
|
132 | }(IPython)); |
General Comments 0
You need to be logged in to leave comments.
Login now