enable dropdown preset change

pull/37/head
Matthias BUSSONNIER 13 years ago
parent 040a27cacc
commit 1c97a7232f

@ -17,6 +17,9 @@ var IPython = (function (IPython) {
this.construct();
this.add_drop_down_list();
this.bind_events();
$(this.selector)
.append($('<label/>').text('MetaUI'))
.append(IPython.MetaUI.dropdown_preset_selector)
};
MainToolBar.prototype = new IPython.ToolBar();
@ -115,18 +118,6 @@ var IPython = (function (IPython) {
}
}
],'run_int');
this.add_buttons_group([
{
id : 'show_meta',
label : 'Show Per Cell Toolbar',
icon : 'ui-icon-image',
callback : function () {
$('body').toggleClass('editmetaon');
}
}
],'meta_on');
};
MainToolBar.prototype.add_drop_down_list = function () {

@ -35,6 +35,22 @@ var IPython = (function (IPython) {
return this;
};
MetaUI.dropdown_preset_selector = $('<select/>')
.attr('id','metaui_selector')
.append($('<option/>').attr('value','').text('-'))
MetaUI.dropdown_preset_selector.change(function(){
var val = MetaUI.dropdown_preset_selector.val()
if(val ==''){
$('body').removeClass('editmetaon')
} else {
$('body').addClass('editmetaon')
MetaUI.set_preset(val)
}
})
/**
* Class variable that should contain a dict of all availlable callback
* we need to think of wether or not we allow nested namespace
@ -139,6 +155,9 @@ var IPython = (function (IPython) {
*/
MetaUI.register_preset = function(name, preset_list){
MetaUI._presets[name] = preset_list
MetaUI.dropdown_preset_selector.append(
$('<option/>').attr('value',name).text(name)
)
}
/**
* set an UI preset from `register_preset`
@ -160,6 +179,7 @@ var IPython = (function (IPython) {
}
}
// this is by design not a prototype.
/**
* This should be called on the class and not on a instance as it will trigger

Loading…
Cancel
Save