##// END OF EJS Templates
remove references to defunct layout_manager in ToolBar
Min RK -
Show More
@@ -1,100 +1,96 b''
1 // Copyright (c) IPython Development Team.
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
2 // Distributed under the terms of the Modified BSD License.
3
3
4 define([
4 define([
5 'base/js/namespace',
5 'base/js/namespace',
6 'jquery',
6 'jquery',
7 ], function(IPython, $) {
7 ], function(IPython, $) {
8 "use strict";
8 "use strict";
9
9
10 /**
10 /**
11 * A generic toolbar on which one can add button
11 * A generic toolbar on which one can add button
12 * @class ToolBar
12 * @class ToolBar
13 * @constructor
13 * @constructor
14 * @param {Dom object} selector
14 * @param {Dom object} selector
15 */
15 */
16 var ToolBar = function (selector, layout_manager) {
16 var ToolBar = function (selector) {
17 this.selector = selector;
17 this.selector = selector;
18 this.layout_manager = layout_manager;
19 if (this.selector !== undefined) {
18 if (this.selector !== undefined) {
20 this.element = $(selector);
19 this.element = $(selector);
21 this.style();
20 this.style();
22 }
21 }
23 };
22 };
24
23
25 /**
24 /**
26 * add a group of button into the current toolbar.
25 * add a group of button into the current toolbar.
27 *
26 *
28 *
27 *
29 * @example
28 * @example
30 *
29 *
31 * IPython.toolbar.add_buttons_group([
30 * IPython.toolbar.add_buttons_group([
32 * {
31 * {
33 * label:'my button',
32 * label:'my button',
34 * icon:'icon-hdd',
33 * icon:'icon-hdd',
35 * callback:function(){alert('hoho')},
34 * callback:function(){alert('hoho')},
36 * id : 'my_button_id', // this is optional
35 * id : 'my_button_id', // this is optional
37 * },
36 * },
38 * {
37 * {
39 * label:'my second button',
38 * label:'my second button',
40 * icon:'icon-play',
39 * icon:'icon-play',
41 * callback:function(){alert('be carefull I cut')}
40 * callback:function(){alert('be carefull I cut')}
42 * }
41 * }
43 * ],
42 * ],
44 * "my_button_group_id"
43 * "my_button_group_id"
45 * )
44 * )
46 *
45 *
47 * @method add_buttons_group
46 * @method add_buttons_group
48 * @param list {List}
47 * @param list {List}
49 * List of button of the group, with the following paramter for each :
48 * List of button of the group, with the following paramter for each :
50 * @param list.label {string} text to show on button hover
49 * @param list.label {string} text to show on button hover
51 * @param list.icon {string} icon to choose from [Font Awesome](http://fortawesome.github.io/Font-Awesome)
50 * @param list.icon {string} icon to choose from [Font Awesome](http://fortawesome.github.io/Font-Awesome)
52 * @param list.callback {function} function to be called on button click
51 * @param list.callback {function} function to be called on button click
53 * @param [list.id] {String} id to give to the button
52 * @param [list.id] {String} id to give to the button
54 * @param [group_id] {String} optionnal id to give to the group
53 * @param [group_id] {String} optionnal id to give to the group
55 *
54 *
56 */
55 */
57 ToolBar.prototype.add_buttons_group = function (list, group_id) {
56 ToolBar.prototype.add_buttons_group = function (list, group_id) {
58 var btn_group = $('<div/>').addClass("btn-group");
57 var btn_group = $('<div/>').addClass("btn-group");
59 if( group_id !== undefined ) {
58 if( group_id !== undefined ) {
60 btn_group.attr('id',group_id);
59 btn_group.attr('id',group_id);
61 }
60 }
62 var el;
61 var el;
63 for(var i=0; i < list.length; i++) {
62 for(var i=0; i < list.length; i++) {
64 el = list[i];
63 el = list[i];
65 var button = $('<button/>')
64 var button = $('<button/>')
66 .addClass('btn btn-default')
65 .addClass('btn btn-default')
67 .attr("title", el.label)
66 .attr("title", el.label)
68 .append(
67 .append(
69 $("<i/>").addClass(el.icon).addClass('fa')
68 $("<i/>").addClass(el.icon).addClass('fa')
70 );
69 );
71 var id = el.id;
70 var id = el.id;
72 if( id !== undefined )
71 if( id !== undefined )
73 button.attr('id',id);
72 button.attr('id',id);
74 var fun = el.callback;
73 var fun = el.callback;
75 button.click(fun);
74 button.click(fun);
76 btn_group.append(button);
75 btn_group.append(button);
77 }
76 }
78 $(this.selector).append(btn_group);
77 $(this.selector).append(btn_group);
79 };
78 };
80
79
81 ToolBar.prototype.style = function () {
80 ToolBar.prototype.style = function () {
82 this.element.addClass('toolbar');
81 this.element.addClass('toolbar');
83 };
82 };
84
83
85 /**
84 /**
86 * Show and hide toolbar
85 * Show and hide toolbar
87 * @method toggle
86 * @method toggle
88 */
87 */
89 ToolBar.prototype.toggle = function () {
88 ToolBar.prototype.toggle = function () {
90 this.element.toggle();
89 this.element.toggle();
91 if (this.layout_manager !== undefined) {
92 this.layout_manager.do_resize();
93 }
94 };
90 };
95
91
96 // Backwards compatibility.
92 // Backwards compatibility.
97 IPython.ToolBar = ToolBar;
93 IPython.ToolBar = ToolBar;
98
94
99 return {'ToolBar': ToolBar};
95 return {'ToolBar': ToolBar};
100 });
96 });
General Comments 0
You need to be logged in to leave comments. Login now