|
|
|
|
@ -118,7 +118,9 @@ var IPython = (function (IPython) {
|
|
|
|
|
* @method register_callback
|
|
|
|
|
* @param name {String} name to use to refer to the callback. It is advised to use a prefix with the name
|
|
|
|
|
* for easier sorting and avoid collision
|
|
|
|
|
* @param callback {function(div, cell)} callback that will be called to generate the ui element
|
|
|
|
|
* @param callback {function(div, cell)} callback that will be called to generate the ui element
|
|
|
|
|
* @param [cell_types] {List of String|undefined} optional list of cell types. If present the UI element
|
|
|
|
|
* will be added only to cells of types in the list.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* The callback will receive the following element :
|
|
|
|
|
@ -154,9 +156,9 @@ var IPython = (function (IPython) {
|
|
|
|
|
* // user the ability to use it later
|
|
|
|
|
* CellToolbar.register_callback('foo', toggle);
|
|
|
|
|
*/
|
|
|
|
|
CellToolbar.register_callback = function(name, callback){
|
|
|
|
|
CellToolbar.register_callback = function(name, callback, cell_types) {
|
|
|
|
|
// Overwrite if it already exists.
|
|
|
|
|
CellToolbar._callback_dict[name] = callback;
|
|
|
|
|
CellToolbar._callback_dict[name] = cell_types ? {callback: callback, cell_types: cell_types} : callback;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -256,6 +258,11 @@ var IPython = (function (IPython) {
|
|
|
|
|
var key = preset[i];
|
|
|
|
|
var callback = callbacks[key];
|
|
|
|
|
if (!callback) continue;
|
|
|
|
|
|
|
|
|
|
if (typeof callback === 'object') {
|
|
|
|
|
if (callback.cell_types.indexOf(this.cell.cell_type) === -1) continue;
|
|
|
|
|
callback = callback.callback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var local_div = $('<div/>').addClass('button_container');
|
|
|
|
|
try {
|
|
|
|
|
|