diff --git a/IPython/frontend/html/notebook/static/css/notebook.css b/IPython/frontend/html/notebook/static/css/notebook.css index 31ce62b9d..ec058d645 100644 --- a/IPython/frontend/html/notebook/static/css/notebook.css +++ b/IPython/frontend/html/notebook/static/css/notebook.css @@ -60,6 +60,10 @@ span#kernel_status { padding: 0px; } +.wijmo-wijmenu .wijmo-wijmenu-parent .wijmo-wijmenu-child { + width: 225px; +} + #kernel_persist { float: right; } @@ -347,7 +351,7 @@ p.dialog { .shortcut_key { display: inline-block; - width: 13ex; + width: 15ex; text-align: right; font-family: monospace; } diff --git a/IPython/frontend/html/notebook/static/js/menubar.js b/IPython/frontend/html/notebook/static/js/menubar.js index fffe310ec..037227678 100644 --- a/IPython/frontend/html/notebook/static/js/menubar.js +++ b/IPython/frontend/html/notebook/static/js/menubar.js @@ -26,6 +26,21 @@ var IPython = (function (IPython) { $('ul#menus').wijmenu("option", "showDelay", 200); $('ul#menus').wijmenu("option", "hideDelay", 200); $(".selector").wijmenu("option", "animation", {animated:"fade", duration: 200, easing: null}) + // Close all menus when a menu item is clicked. This is needed when + // menu shortcuts are used as they have a slightly different structure + // in the DOM. + $(".wijmo-wijmenu-text").parent().bind("click", function () { + $('ul#menus').wijmenu("hideAllMenus"); + console.log('I am closing you!'); + }); + // Make sure we hover over menu items correctly. This is needed when + // menu shortcuts are used as they have a slightly different structure + // in the DOM. + $(".wijmo-wijmenu-link").hover(function () { + $(this).addClass("ui-state-hover"); + }, function () { + $(this).removeClass("ui-state-hover"); + }); }; @@ -65,6 +80,12 @@ var IPython = (function (IPython) { this.element.find('#move_cell_down').click(function () { IPython.notebook.move_cell_down(); }); + this.element.find('#select_previous').click(function () { + IPython.notebook.select_prev(); + }); + this.element.find('#select_next').click(function () { + IPython.notebook.select_next(); + }); // Insert this.element.find('#insert_cell_above').click(function () { IPython.notebook.insert_code_cell_above(); @@ -101,6 +122,10 @@ var IPython = (function (IPython) { this.element.find('#restart_kernel').click(function () { IPython.notebook.restart_kernel(); }); + // Help + this.element.find('#keyboard_shortcuts').click(function () { + IPython.quick_help.show_keyboard_shortcuts(); + }); }; diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index 67607e551..515091bd7 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -213,50 +213,6 @@ var IPython = (function (IPython) { }; - Notebook.prototype.toggle_keyboard_shortcuts = function () { - // toggles display of keyboard shortcut dialog - var that = this; - if ( this.shortcut_dialog ){ - // if dialog is already shown, close it - this.shortcut_dialog.dialog("close"); - this.shortcut_dialog = null; - return; - } - var dialog = $('
'); - this.shortcut_dialog = dialog; - var shortcuts = [ - {key: 'Shift-Enter', help: 'run cell'}, - {key: 'Ctrl-Enter', help: 'run cell in-place'}, - {key: 'Ctrl-m d', help: 'delete cell'}, - {key: 'Ctrl-m a', help: 'insert cell above'}, - {key: 'Ctrl-m b', help: 'insert cell below'}, - {key: 'Ctrl-m t', help: 'toggle output'}, - {key: 'Ctrl-m l', help: 'toggle line numbers'}, - {key: 'Ctrl-m s', help: 'save notebook'}, - {key: 'Ctrl-m j', help: 'move cell down'}, - {key: 'Ctrl-m k', help: 'move cell up'}, - {key: 'Ctrl-m c', help: 'code cell'}, - {key: 'Ctrl-m m', help: 'markdown cell'}, - {key: 'Ctrl-m p', help: 'select previous'}, - {key: 'Ctrl-m n', help: 'select next'}, - {key: 'Ctrl-m i', help: 'interrupt kernel'}, - {key: 'Ctrl-m .', help: 'restart kernel'}, - {key: 'Ctrl-m h', help: 'show keyboard shortcuts'} - ]; - for (var i=0; i'). - append($('').addClass('shortcut_key').html(shortcuts[i].key)). - append($('').addClass('shortcut_descr').html(' : ' + shortcuts[i].help)) - ); - }; - dialog.bind('dialogclose', function(event) { - // dialog has been closed, allow it to be drawn again. - that.shortcut_dialog = null; - }); - dialog.dialog({title: 'Keyboard shortcuts'}); - }; - - Notebook.prototype.scroll_to_bottom = function () { this.element.animate({scrollTop:this.element.get(0).scrollHeight}, 0); }; @@ -691,6 +647,7 @@ var IPython = (function (IPython) { resizable: false, modal: true, title: "Restart kernel or continue running?", + closeText: '', buttons : { "Restart": function () { that.kernel.restart($.proxy(that.kernel_started, that)); diff --git a/IPython/frontend/html/notebook/static/js/quickhelp.js b/IPython/frontend/html/notebook/static/js/quickhelp.js index 4931fd01d..aa86abd6b 100644 --- a/IPython/frontend/html/notebook/static/js/quickhelp.js +++ b/IPython/frontend/html/notebook/static/js/quickhelp.js @@ -12,24 +12,49 @@ var IPython = (function (IPython) { var QuickHelp = function (selector) { - this.selector = selector; - if (this.selector !== undefined) { - this.element = $(selector); - this.style(); - this.bind_events(); - } - }; - - QuickHelp.prototype.style = function () { - this.element.find('button#quick_help').button(); - this.element.find('button#quick_help').attr('title', "Show/Hide the keyboard shortcuts for the IPython Notebook"); }; - QuickHelp.prototype.bind_events = function () { + QuickHelp.prototype.show_keyboard_shortcuts = function () { + // toggles display of keyboard shortcut dialog var that = this; - this.element.find("button#quick_help").click(function () { - IPython.notebook.toggle_keyboard_shortcuts(); + if ( this.shortcut_dialog ){ + // if dialog is already shown, close it + this.shortcut_dialog.dialog("close"); + this.shortcut_dialog = null; + return; + } + var dialog = $('
'); + this.shortcut_dialog = dialog; + var shortcuts = [ + {key: 'Shift-Enter', help: 'run cell'}, + {key: 'Ctrl-Enter', help: 'run cell in-place'}, + {key: 'Ctrl-m d', help: 'delete cell'}, + {key: 'Ctrl-m a', help: 'insert cell above'}, + {key: 'Ctrl-m b', help: 'insert cell below'}, + {key: 'Ctrl-m t', help: 'toggle output'}, + {key: 'Ctrl-m l', help: 'toggle line numbers'}, + {key: 'Ctrl-m s', help: 'save notebook'}, + {key: 'Ctrl-m j', help: 'move cell down'}, + {key: 'Ctrl-m k', help: 'move cell up'}, + {key: 'Ctrl-m c', help: 'code cell'}, + {key: 'Ctrl-m m', help: 'markdown cell'}, + {key: 'Ctrl-m p', help: 'select previous'}, + {key: 'Ctrl-m n', help: 'select next'}, + {key: 'Ctrl-m i', help: 'interrupt kernel'}, + {key: 'Ctrl-m .', help: 'restart kernel'}, + {key: 'Ctrl-m h', help: 'show keyboard shortcuts'} + ]; + for (var i=0; i'). + append($('').addClass('shortcut_key').html(shortcuts[i].key)). + append($('').addClass('shortcut_descr').html(' : ' + shortcuts[i].help)) + ); + }; + dialog.bind('dialogclose', function(event) { + // dialog has been closed, allow it to be drawn again. + that.shortcut_dialog = null; }); + dialog.dialog({title: 'Keyboard shortcuts', closeText: ''}); }; // Set module variables diff --git a/IPython/frontend/html/notebook/templates/notebook.html b/IPython/frontend/html/notebook/templates/notebook.html index 53e390e79..8dfdf84a4 100644 --- a/IPython/frontend/html/notebook/templates/notebook.html +++ b/IPython/frontend/html/notebook/templates/notebook.html @@ -48,9 +48,6 @@ - - - {% comment This is a temporary workaround to hide the logout button %} @@ -69,10 +66,15 @@