##// END OF EJS Templates
Fixing Cell menu to update cell type select box.
Brian Granger -
Show More
@@ -1,148 +1,148 b''
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 75 var that = this;
76 76 this.element.find('#save_b').click(function () {
77 77 IPython.notebook.save_notebook();
78 78 });
79 79 this.element.find('#cut_b').click(function () {
80 80 IPython.notebook.cut_cell();
81 81 });
82 82 this.element.find('#copy_b').click(function () {
83 83 IPython.notebook.copy_cell();
84 84 });
85 85 this.element.find('#paste_b').click(function () {
86 86 IPython.notebook.paste_cell();
87 87 });
88 88 this.element.find('#move_up_b').click(function () {
89 89 IPython.notebook.move_cell_up();
90 90 });
91 91 this.element.find('#move_down_b').click(function () {
92 92 IPython.notebook.move_cell_down();
93 93 });
94 94 this.element.find('#insert_above_b').click(function () {
95 95 IPython.notebook.insert_cell_above('code');
96 96 });
97 97 this.element.find('#insert_below_b').click(function () {
98 98 IPython.notebook.insert_cell_below('code');
99 99 });
100 100 this.element.find('#run_b').click(function () {
101 101 IPython.notebook.execute_selected_cell();
102 102 });
103 103 this.element.find('#interrupt_b').click(function () {
104 104 IPython.notebook.kernel.interrupt();
105 105 });
106 106 this.element.find('#cell_type').change(function () {
107 107 var cell_type = $(this).val();
108 108 if (cell_type === 'code') {
109 109 IPython.notebook.to_code();
110 110 } else if (cell_type === 'markdown') {
111 111 IPython.notebook.to_markdown();
112 112 } else if (cell_type === 'plaintext') {
113 113 IPython.notebook.to_plaintext();
114 114 } else if (cell_type === 'heading1') {
115 115 IPython.notebook.to_heading(undefined, 1);
116 116 } else if (cell_type === 'heading2') {
117 117 IPython.notebook.to_heading(undefined, 2);
118 118 } else if (cell_type === 'heading3') {
119 119 IPython.notebook.to_heading(undefined, 3);
120 120 } else if (cell_type === 'heading4') {
121 121 IPython.notebook.to_heading(undefined, 4);
122 122 } else if (cell_type === 'heading5') {
123 123 IPython.notebook.to_heading(undefined, 5);
124 124 } else if (cell_type === 'heading6') {
125 125 IPython.notebook.to_heading(undefined, 6);
126 126 };
127 127 });
128 $([IPython.events]).on('selected_cell_type_changed', function (event, data) {
128 $([IPython.events]).on('selected_cell_type_changed.Notebook', function (event, data) {
129 129 if (data.cell_type === 'heading') {
130 130 that.element.find('#cell_type').val(data.cell_type+data.level);
131 131 } else {
132 132 that.element.find('#cell_type').val(data.cell_type);
133 133 }
134 134 });
135 135 };
136 136
137 137
138 138 ToolBar.prototype.toggle = function () {
139 139 this.element.toggle();
140 140 IPython.layout_manager.do_resize();
141 141 };
142 142
143 143
144 144 IPython.ToolBar = ToolBar;
145 145
146 146 return IPython;
147 147
148 148 }(IPython));
General Comments 0
You need to be logged in to leave comments. Login now