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