//---------------------------------------------------------------------------- // Copyright (C) 2008-2011 The IPython Development Team // // Distributed under the terms of the BSD License. The full license is in // the file COPYING, distributed as part of this software. //---------------------------------------------------------------------------- //============================================================================ // QuickHelp button //============================================================================ var IPython = (function (IPython) { "use strict"; var QuickHelp = function (selector) { }; QuickHelp.prototype.show_keyboard_shortcuts = function () { // toggles display of keyboard shortcut dialog var that = this; if ( this.force_rebuild ) { this.shortcut_dialog.remove(); delete(this.shortcut_dialog); this.force_rebuild = false; } if ( this.shortcut_dialog ){ // if dialog is already shown, close it $(this.shortcut_dialog).modal("toggle"); return; } var command_shortcuts = IPython.keyboard_manager.command_shortcuts.help(); var edit_shortcuts = IPython.keyboard_manager.edit_shortcuts.help(); var help, shortcut; var i, half, n; var element = $('
'); // The documentation var doc = $('').addClass('alert'); doc.append( $('').addClass('close').attr('data-dismiss','alert').html('×') ).append( 'The IPython Notebook has two different keyboard input modes. Edit mode '+ 'allows you to type code/text into a cell and is indicated by a green cell '+ 'border. Command mode binds the keyboard to notebook level actions '+ 'and is indicated by a grey cell border.' ); element.append(doc); // Command mode var cmd_div = this.build_command_help(); element.append(cmd_div); // Edit mode var edit_div = this.build_edit_help(); element.append(edit_div); this.shortcut_dialog = IPython.dialog.modal({ title : "Keyboard shortcuts", body : element, destroy : false, buttons : { Close : {} } }); $([IPython.events]).on('rebuild.QuickHelp', function() { that.force_rebuild = true;}); }; QuickHelp.prototype.build_command_help = function () { var command_shortcuts = IPython.keyboard_manager.command_shortcuts.help(); return build_div('Esc
to enable)" + k + "
";
continue; // leave individual keys lower-cased
}
keys[i] = ( special_case[k] ? special_case[k] : k.charAt(0).toUpperCase() + k.slice(1) );
keys[i] = "" + keys[i] + "
";
}
return keys.join('-');
};
QuickHelp.prototype.build_edit_help = function () {
var edit_shortcuts = IPython.keyboard_manager.edit_shortcuts.help();
// Edit mode
return build_div('Enter
to enable)