##// END OF EJS Templates
DeCamelCasify method names
Matthias BUSSONNIER -
Show More
@@ -1,182 +1,182
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008 The IPython Development Team
2 // Copyright (C) 2008 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 MainToolBar = function (selector) {
14 var MainToolBar = function (selector) {
15 this.selector = selector;
15 this.selector = selector;
16 if (this.selector !== undefined) {
16 if (this.selector !== undefined) {
17 IPython.ToolBar.apply(this, arguments);
17 IPython.ToolBar.apply(this, arguments);
18 // move the rest ouside
18 // move the rest ouside
19 this.construct();
19 this.construct();
20 this.addDropDownList();
20 this.add_drop_down_list();
21 this.bind_events();
21 this.bind_events();
22 }
22 }
23 };
23 };
24
24
25 MainToolBar.prototype = new IPython.ToolBar();
25 MainToolBar.prototype = new IPython.ToolBar();
26
26
27 MainToolBar.prototype.addDropDownList = function() {
27 MainToolBar.prototype.add_drop_down_list = function() {
28 var select = $(this.selector)
28 var select = $(this.selector)
29 .append($('<select/>')
29 .append($('<select/>')
30 .attr('id','cell_type')
30 .attr('id','cell_type')
31 .addClass('ui-widget ui-widget-content')
31 .addClass('ui-widget ui-widget-content')
32 .append($('<option/>').attr('value','code').text('Code'))
32 .append($('<option/>').attr('value','code').text('Code'))
33 .append($('<option/>').attr('value','markdown').text('Markdown'))
33 .append($('<option/>').attr('value','markdown').text('Markdown'))
34 .append($('<option/>').attr('value','raw').text('Raw Text'))
34 .append($('<option/>').attr('value','raw').text('Raw Text'))
35 .append($('<option/>').attr('value','heading1').text('Heading 1'))
35 .append($('<option/>').attr('value','heading1').text('Heading 1'))
36 .append($('<option/>').attr('value','heading2').text('Heading 2'))
36 .append($('<option/>').attr('value','heading2').text('Heading 2'))
37 .append($('<option/>').attr('value','heading3').text('Heading 3'))
37 .append($('<option/>').attr('value','heading3').text('Heading 3'))
38 .append($('<option/>').attr('value','heading4').text('Heading 4'))
38 .append($('<option/>').attr('value','heading4').text('Heading 4'))
39 .append($('<option/>').attr('value','heading5').text('Heading 5'))
39 .append($('<option/>').attr('value','heading5').text('Heading 5'))
40 .append($('<option/>').attr('value','heading6').text('Heading 6'))
40 .append($('<option/>').attr('value','heading6').text('Heading 6'))
41 .append($('<option/>').attr('value','heading7').text('Heading 7'))
41 .append($('<option/>').attr('value','heading7').text('Heading 7'))
42 .append($('<option/>').attr('value','heading8').text('Heading 8'))
42 .append($('<option/>').attr('value','heading8').text('Heading 8'))
43 );
43 );
44 }
44 }
45
45
46 MainToolBar.prototype.construct = function() {
46 MainToolBar.prototype.construct = function() {
47 this.addButtonsGroup([
47 this.add_buttons_group([
48 {
48 {
49 id:'save_b',
49 id:'save_b',
50 label:'Save',
50 label:'Save',
51 icon:'ui-icon-disk',
51 icon:'ui-icon-disk',
52 callback:function(){
52 callback:function(){
53 IPython.notebook.save_notebook();
53 IPython.notebook.save_notebook();
54 },
54 },
55 },
55 },
56 ]);
56 ]);
57 this.addButtonsGroup([
57 this.add_buttons_group([
58 {
58 {
59 id:'cut_b',
59 id:'cut_b',
60 label:'Cut Cell',
60 label:'Cut Cell',
61 icon:'ui-icon-scissors',
61 icon:'ui-icon-scissors',
62 callback:function(){
62 callback:function(){
63 IPython.notebook.cut_cell();
63 IPython.notebook.cut_cell();
64 },
64 },
65 },
65 },
66 {
66 {
67 id:'copy_b',
67 id:'copy_b',
68 label:'Copy Cell',
68 label:'Copy Cell',
69 icon:'ui-icon-copy',
69 icon:'ui-icon-copy',
70 callback:function(){
70 callback:function(){
71 IPython.notebook.copy_cell();
71 IPython.notebook.copy_cell();
72 },
72 },
73 },
73 },
74 {
74 {
75 id:'paste_b',
75 id:'paste_b',
76 label:'Paste Cell',
76 label:'Paste Cell',
77 icon:'ui-icon-clipboard',
77 icon:'ui-icon-clipboard',
78 callback:function(){
78 callback:function(){
79 IPython.notebook.paste_cell();
79 IPython.notebook.paste_cell();
80 },
80 },
81 },
81 },
82 ],'cut_copy_paste');
82 ],'cut_copy_paste');
83
83
84 this.addButtonsGroup([
84 this.add_buttons_group([
85 {
85 {
86 id:'move_up_b',
86 id:'move_up_b',
87 label:'Move Cell Up',
87 label:'Move Cell Up',
88 icon:'ui-icon-arrowthick-1-n',
88 icon:'ui-icon-arrowthick-1-n',
89 callback:function(){
89 callback:function(){
90 IPython.notebook.move_cell_up();
90 IPython.notebook.move_cell_up();
91 },
91 },
92 },
92 },
93 {
93 {
94 id:'move_down_b',
94 id:'move_down_b',
95 label:'Move Cell Down',
95 label:'Move Cell Down',
96 icon:'ui-icon-arrowthick-1-s',
96 icon:'ui-icon-arrowthick-1-s',
97 callback:function(){
97 callback:function(){
98 IPython.notebook.move_cell_down();
98 IPython.notebook.move_cell_down();
99 },
99 },
100 },
100 },
101 ],'move_up_down');
101 ],'move_up_down');
102
102
103 this.addButtonsGroup([
103 this.add_buttons_group([
104 {
104 {
105 id:'insert_above_b',
105 id:'insert_above_b',
106 label:'Insert Cell Above',
106 label:'Insert Cell Above',
107 icon:'ui-icon-arrowthickstop-1-n',
107 icon:'ui-icon-arrowthickstop-1-n',
108 callback:function(){
108 callback:function(){
109 IPython.notebook.insert_cell_above('code');
109 IPython.notebook.insert_cell_above('code');
110 },
110 },
111 },
111 },
112 {
112 {
113 id:'insert_below_b',
113 id:'insert_below_b',
114 label:'Insert Cell Below',
114 label:'Insert Cell Below',
115 icon:'ui-icon-arrowthickstop-1-s',
115 icon:'ui-icon-arrowthickstop-1-s',
116 callback:function(){
116 callback:function(){
117 IPython.notebook.insert_cell_below('code');
117 IPython.notebook.insert_cell_below('code');
118 },
118 },
119 },
119 },
120 ],'insert_above_below');
120 ],'insert_above_below');
121
121
122 this.addButtonsGroup([
122 this.add_buttons_group([
123 {
123 {
124 id:'run_b',
124 id:'run_b',
125 label:'Run Cell',
125 label:'Run Cell',
126 icon:'ui-icon-play',
126 icon:'ui-icon-play',
127 callback:function(){
127 callback:function(){
128 IPython.notebook.execute_selected_cell();
128 IPython.notebook.execute_selected_cell();
129 },
129 },
130 },
130 },
131 {
131 {
132 id:'interrupt_b',
132 id:'interrupt_b',
133 label:'Interrupt',
133 label:'Interrupt',
134 icon:'ui-icon-stop',
134 icon:'ui-icon-stop',
135 callback:function(){
135 callback:function(){
136 IPython.notebook.kernel.interrupt();
136 IPython.notebook.kernel.interrupt();
137 },
137 },
138 },
138 },
139 ],'run_int');
139 ],'run_int');
140
140
141
141
142 }
142 }
143
143
144 MainToolBar.prototype.bind_events = function () {
144 MainToolBar.prototype.bind_events = function () {
145 var that = this;
145 var that = this;
146
146
147 this.element.find('#cell_type').change(function () {
147 this.element.find('#cell_type').change(function () {
148 var cell_type = $(this).val();
148 var cell_type = $(this).val();
149 if (cell_type === 'code') {
149 if (cell_type === 'code') {
150 IPython.notebook.to_code();
150 IPython.notebook.to_code();
151 } else if (cell_type === 'markdown') {
151 } else if (cell_type === 'markdown') {
152 IPython.notebook.to_markdown();
152 IPython.notebook.to_markdown();
153 } else if (cell_type === 'raw') {
153 } else if (cell_type === 'raw') {
154 IPython.notebook.to_raw();
154 IPython.notebook.to_raw();
155 } else if (cell_type === 'heading1') {
155 } else if (cell_type === 'heading1') {
156 IPython.notebook.to_heading(undefined, 1);
156 IPython.notebook.to_heading(undefined, 1);
157 } else if (cell_type === 'heading2') {
157 } else if (cell_type === 'heading2') {
158 IPython.notebook.to_heading(undefined, 2);
158 IPython.notebook.to_heading(undefined, 2);
159 } else if (cell_type === 'heading3') {
159 } else if (cell_type === 'heading3') {
160 IPython.notebook.to_heading(undefined, 3);
160 IPython.notebook.to_heading(undefined, 3);
161 } else if (cell_type === 'heading4') {
161 } else if (cell_type === 'heading4') {
162 IPython.notebook.to_heading(undefined, 4);
162 IPython.notebook.to_heading(undefined, 4);
163 } else if (cell_type === 'heading5') {
163 } else if (cell_type === 'heading5') {
164 IPython.notebook.to_heading(undefined, 5);
164 IPython.notebook.to_heading(undefined, 5);
165 } else if (cell_type === 'heading6') {
165 } else if (cell_type === 'heading6') {
166 IPython.notebook.to_heading(undefined, 6);
166 IPython.notebook.to_heading(undefined, 6);
167 };
167 };
168 });
168 });
169 $([IPython.events]).on('selected_cell_type_changed.Notebook', function (event, data) {
169 $([IPython.events]).on('selected_cell_type_changed.Notebook', function (event, data) {
170 if (data.cell_type === 'heading') {
170 if (data.cell_type === 'heading') {
171 that.element.find('#cell_type').val(data.cell_type+data.level);
171 that.element.find('#cell_type').val(data.cell_type+data.level);
172 } else {
172 } else {
173 that.element.find('#cell_type').val(data.cell_type);
173 that.element.find('#cell_type').val(data.cell_type);
174 }
174 }
175 });
175 });
176 };
176 };
177
177
178 IPython.MainToolBar = MainToolBar;
178 IPython.MainToolBar = MainToolBar;
179
179
180 return IPython;
180 return IPython;
181
181
182 }(IPython));
182 }(IPython));
@@ -1,94 +1,94
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008 The IPython Development Team
2 // Copyright (C) 2008 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 }
19 }
20 };
20 };
21
21
22 // add a group of button into the current toolbar.
22 // add a group of button into the current toolbar.
23 //
23 //
24 // First argument : Mandatory
24 // First argument : Mandatory
25 // list of dict as argument, each dict should contain
25 // list of dict as argument, each dict should contain
26 // 3 mandatory keys and values :
26 // 3 mandatory keys and values :
27 // label : string -- the text to show on hover
27 // label : string -- the text to show on hover
28 // icon : string -- the jQuery-ui icon to add on this button
28 // icon : string -- the jQuery-ui icon to add on this button
29 // callback : function -- the callback to execute on a click
29 // callback : function -- the callback to execute on a click
30 //
30 //
31 // and optionnaly an 'id' key that is assigned to the button element
31 // and optionnaly an 'id' key that is assigned to the button element
32 //
32 //
33 // Second Argument, optionnal,
33 // Second Argument, optionnal,
34 // string reprensenting the id to give to the button group.
34 // string reprensenting the id to give to the button group.
35 //
35 //
36 // Example
36 // Example
37 //
37 //
38 // IPython.toolbar.addButtonsGroup([
38 // IPython.toolbar.add_button_group([
39 // {label:'my button',
39 // {label:'my button',
40 // icon:'ui-icon-disk',
40 // icon:'ui-icon-disk',
41 // callback:function(){alert('hoho'),
41 // callback:function(){alert('hoho'),
42 // id : 'my_button_id', // this is optionnal
42 // id : 'my_button_id', // this is optionnal
43 // }
43 // }
44 // },
44 // },
45 // {label:'my second button',
45 // {label:'my second button',
46 // icon:'ui-icon-scissors',
46 // icon:'ui-icon-scissors',
47 // callback:function(){alert('be carefull I cut')}
47 // callback:function(){alert('be carefull I cut')}
48 // }
48 // }
49 // ],
49 // ],
50 // "my_button_group_id"
50 // "my_button_group_id"
51 // )
51 // )
52 //
52 //
53 ToolBar.prototype.addButtonsGroup = function(list, group_id){
53 ToolBar.prototype.add_button_group = function(list, group_id){
54 var span_group = $('<span/>');
54 var span_group = $('<span/>');
55 if( group_id != undefined )
55 if( group_id != undefined )
56 span_group.attr('id',group_id)
56 span_group.attr('id',group_id)
57 for(var el in list)
57 for(var el in list)
58 {
58 {
59 var button = $('<button/>').button({
59 var button = $('<button/>').button({
60 icons : {primary: list[el].icon},
60 icons : {primary: list[el].icon},
61 text : false,
61 text : false,
62 label: list[el].label,
62 label: list[el].label,
63 });
63 });
64 var id = list[el].id;
64 var id = list[el].id;
65 if( id != undefined )
65 if( id != undefined )
66 button.attr('id',id);
66 button.attr('id',id);
67 var fun = list[el].callback;
67 var fun = list[el].callback;
68 button.click(fun);
68 button.click(fun);
69 span_group.append(button);
69 span_group.append(button);
70 }
70 }
71 span_group.buttonset();
71 span_group.buttonset();
72 $(this.selector).append(span_group)
72 $(this.selector).append(span_group)
73 }
73 }
74
74
75 ToolBar.prototype.style = function () {
75 ToolBar.prototype.style = function () {
76 this.element.addClass('border-box-sizing').
76 this.element.addClass('border-box-sizing').
77 addClass('ui-widget ui-widget-content toolbar').
77 addClass('ui-widget ui-widget-content toolbar').
78 css('border-top-style','none').
78 css('border-top-style','none').
79 css('border-left-style','none').
79 css('border-left-style','none').
80 css('border-right-style','none');
80 css('border-right-style','none');
81 };
81 };
82
82
83
83
84 ToolBar.prototype.toggle = function () {
84 ToolBar.prototype.toggle = function () {
85 this.element.toggle();
85 this.element.toggle();
86 IPython.layout_manager.do_resize();
86 IPython.layout_manager.do_resize();
87 };
87 };
88
88
89
89
90 IPython.ToolBar = ToolBar;
90 IPython.ToolBar = ToolBar;
91
91
92 return IPython;
92 return IPython;
93
93
94 }(IPython));
94 }(IPython));
General Comments 0
You need to be logged in to leave comments. Login now