##// END OF EJS Templates
Putting custom.css/custom.js in static/user.
Putting custom.css/custom.js in static/user.

File last commit:

r10705:b31ccdc2
r10710:2e4d4038
Show More
toolbar.js
111 lines | 3.4 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
//============================================================================
Matthias BUSSONNIER
document base of toolbar
r8769 /**
* @module IPython
* @namespace IPython
* @submodule ToolBar
*/
Brian Granger
First draft of toolbar....
r5993
var IPython = (function (IPython) {
Matthias BUSSONNIER
document base of toolbar
r8769 /**
* A generic toolbar on which one can add button
* @class ToolBar
* @constructor
* @param {Dom object} selector
*/
Brian Granger
First draft of toolbar....
r5993 var ToolBar = function (selector) {
this.selector = selector;
if (this.selector !== undefined) {
this.element = $(selector);
this.style();
}
};
Matthias BUSSONNIER
document base of toolbar
r8769 /**
* add a group of button into the current toolbar.
*
*
* @example
*
Matthias BUSSONNIER
Add a per cell toolbar....
r9055 * IPython.toolbar.add_buttons_group([
Matthias BUSSONNIER
document base of toolbar
r8769 * {
* label:'my button',
* icon:'ui-icon-disk',
Matthias BUSSONNIER
Method to show hide linenumber of cell...
r9542 * callback:function(){alert('hoho')},
Matthias BUSSONNIER
document base of toolbar
r8769 * id : 'my_button_id', // this is optional
* },
* {
* label:'my second button',
* icon:'ui-icon-scissors',
* callback:function(){alert('be carefull I cut')}
* }
* ],
* "my_button_group_id"
* )
*
* @method add_buttons_group
* @param list {List}
* List of button of the group, with the following paramter for each :
* @param list.label {string} text to show on button hover
* @param list.icon {string} icon to choose from [jQuery ThemeRoller](http://jqueryui.com/themeroller/)
* @param list.callback {function} function to be called on button click
* @param [list.id] {String} id to give to the button
* @param [group_id] {String} optionnal id to give to the group
*
*/
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
remove useless classes
r9264 addClass('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 };
Matthias BUSSONNIER
document base of toolbar
r8769 /**
* Show and hide toolbar
* @method toggle
*/
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));