##// END OF EJS Templates
Add event to kernel execution/shell reply....
Add event to kernel execution/shell reply. This should allow to hook more easily phantomjs for testing.

File last commit:

r8212:f0b03551
r8605:af999fb1
Show More
toolbar.js
96 lines | 3.0 KiB | application/javascript | JavascriptLexer
Brian Granger
First draft of toolbar....
r5993 //----------------------------------------------------------------------------
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 // Copyright (C) 2008 The IPython Development Team
Brian Granger
First draft of toolbar....
r5993 //
// Distributed under the terms of the BSD License. The full license is in
// the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------
//============================================================================
// ToolBar
//============================================================================
var IPython = (function (IPython) {
var ToolBar = function (selector) {
this.selector = selector;
if (this.selector !== undefined) {
this.element = $(selector);
this.style();
}
};
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 // add a group of button into the current toolbar.
//
// First argument : Mandatory
// list of dict as argument, each dict should contain
// 3 mandatory keys and values :
Matthias BUSSONNIER
dont use string as dict key, better redability
r7837 // label : string -- the text to show on hover
// icon : string -- the jQuery-ui icon to add on this button
// callback : function -- the callback to execute on a click
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 //
Matthias BUSSONNIER
optionally 1n, 2l
r8208 // and optionally an 'id' key that is assigned to the button element
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 //
Matthias BUSSONNIER
optionally 1n, 2l
r8208 // Second Argument, optional,
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 // string reprensenting the id to give to the button group.
//
// Example
//
Matthias BUSSONNIER
DeCamelCasify method names
r8051 // IPython.toolbar.add_button_group([
Matthias BUSSONNIER
dont use string as dict key, better redability
r7837 // {label:'my button',
// icon:'ui-icon-disk',
// callback:function(){alert('hoho'),
Matthias BUSSONNIER
optionally 1n, 2l
r8208 // id : 'my_button_id', // this is optional
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 // }
// },
Matthias BUSSONNIER
dont use string as dict key, better redability
r7837 // {label:'my second button',
// icon:'ui-icon-scissors',
// callback:function(){alert('be carefull I cut')}
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 // }
// ],
// "my_button_group_id"
// )
//
Matthias BUSSONNIER
reorder methods and fix typo
r8212 ToolBar.prototype.add_buttons_group = function (list, group_id) {
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 var span_group = $('<span/>');
Matthias BUSSONNIER
jslint 1
r8209 if( group_id != undefined ) {
span_group.attr('id',group_id);
}
for(var el in list) {
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 var button = $('<button/>').button({
Matthias BUSSONNIER
space around : , bis
r8211 icons : {primary : list[el].icon},
text : false,
label : list[el].label
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 });
Matthias BUSSONNIER
dont use string as dict key, better redability
r7837 var id = list[el].id;
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 if( id != undefined )
button.attr('id',id);
Matthias BUSSONNIER
dont use string as dict key, better redability
r7837 var fun = list[el].callback;
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 button.click(fun);
span_group.append(button);
}
span_group.buttonset();
Matthias BUSSONNIER
jslint 1
r8209 $(this.selector).append(span_group);
};
Brian Granger
First draft of toolbar....
r5993
ToolBar.prototype.style = function () {
Brian Granger
Major refactoring of notebook....
r6193 this.element.addClass('border-box-sizing').
Matthias BUSSONNIER
Allow toolbar construction in js...
r7832 addClass('ui-widget ui-widget-content toolbar').
Brian Granger
Major refactoring of notebook....
r6193 css('border-top-style','none').
css('border-left-style','none').
css('border-right-style','none');
Brian Granger
First draft of toolbar....
r5993 };
Brian Granger
Further work on the toolbar UI....
r5994 ToolBar.prototype.toggle = function () {
this.element.toggle();
Matthias BUSSONNIER
reorder methods and fix typo
r8212 if (IPython.layout_manager != undefined) {
IPython.layout_manager.do_resize();
}
Brian Granger
First draft of toolbar....
r5993 };
IPython.ToolBar = ToolBar;
return IPython;
}(IPython));