##// END OF EJS Templates
rename css class names to be consistent with current style
rename css class names to be consistent with current style

File last commit:

r15705:18448000
r15847:5c22c5ca
Show More
quickhelp.js
133 lines | 5.1 KiB | application/javascript | JavascriptLexer
Fernando Perez
Add quick help button: broken ATM, style and binding aren't working....
r5023 //----------------------------------------------------------------------------
// 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.
//----------------------------------------------------------------------------
//============================================================================
MinRK
fix quickhelp widget...
r5066 // QuickHelp button
Fernando Perez
Add quick help button: broken ATM, style and binding aren't working....
r5023 //============================================================================
var IPython = (function (IPython) {
Matthias BUSSONNIER
"use strict" in most (if not all) our javascript...
r12103 "use strict";
Fernando Perez
Add quick help button: broken ATM, style and binding aren't working....
r5023
MinRK
fix quickhelp widget...
r5066 var QuickHelp = function (selector) {
Fernando Perez
Add quick help button: broken ATM, style and binding aren't working....
r5023 };
Brian Granger
Cleaning up menu code....
r5858 QuickHelp.prototype.show_keyboard_shortcuts = function () {
// toggles display of keyboard shortcut dialog
Fernando Perez
Add quick help button: broken ATM, style and binding aren't working....
r5023 var that = this;
Brian Granger
Cleaning up menu code....
r5858 if ( this.shortcut_dialog ){
// if dialog is already shown, close it
MinRK
tweak quick-help...
r10939 $(this.shortcut_dialog).modal("toggle");
Brian Granger
Cleaning up menu code....
r5858 return;
}
Brian E. Granger
Fixing bugs and adding automatic KB shortcut help.
r14037 var command_shortcuts = IPython.keyboard_manager.command_shortcuts.help();
var edit_shortcuts = IPython.keyboard_manager.edit_shortcuts.help();
var help, shortcut;
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 var i, half, n;
Brian E. Granger
Fixing bugs and adding automatic KB shortcut help.
r14037 var element = $('<div/>');
Brian E. Granger
Adding back doc in Keyboard Shortcut.
r14066 // The documentation
var doc = $('<div/>').addClass('alert');
doc.append(
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 $('<button/>').addClass('close').attr('data-dismiss','alert').html('&times;')
Brian E. Granger
Adding back doc in Keyboard Shortcut.
r14066 ).append(
'The IPython Notebook has two different keyboard input modes. <b>Edit mode</b> '+
Preston Holmes
Fixed typos in quick-help text
r14949 'allows you to type code/text into a cell and is indicated by a green cell '+
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 'border. <b>Command mode</b> binds the keyboard to notebook level actions '+
'and is indicated by a grey cell border.'
Brian E. Granger
Adding back doc in Keyboard Shortcut.
r14066 )
element.append(doc);
Brian E. Granger
Fixing bugs and adding automatic KB shortcut help.
r14037 // Command mode
Brian E. Granger
Fixing design of quickhelp.
r14096 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 : {}
}
});
};
QuickHelp.prototype.build_command_help = function () {
var command_shortcuts = IPython.keyboard_manager.command_shortcuts.help();
var help, shortcut;
var i, half, n;
// Command mode
Paul Ivanov
oops, <tt> went the way of the dodo, using <code>
r15705 var cmd_div = $('<div/>').append($('<h4>Command Mode (press <code>esc</code> to enable)</h4>'));
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 var cmd_sub_div = $('<div/>').addClass('hbox');
var cmd_col1 = $('<div/>').addClass('box-flex0');
var cmd_col2 = $('<div/>').addClass('box-flex0');
n = command_shortcuts.length;
half = ~~(n/2); // Truncate :)
for (i=0; i<half; i++) {
Brian E. Granger
Fixing bugs and adding automatic KB shortcut help.
r14037 help = command_shortcuts[i]['help'];
shortcut = command_shortcuts[i]['shortcut'];
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 cmd_col1.append($('<div>').addClass('quickhelp').
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 append($('<span/>').addClass('shortcut_key').text(shortcut)).
append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 );
Brian E. Granger
Fixing bugs and adding automatic KB shortcut help.
r14037 };
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 for (i=half; i<n; i++) {
help = command_shortcuts[i]['help'];
shortcut = command_shortcuts[i]['shortcut'];
cmd_col2.append($('<div>').addClass('quickhelp').
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 append($('<span/>').addClass('shortcut_key').text(shortcut)).
append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 );
};
cmd_sub_div.append(cmd_col1).append(cmd_col2);
cmd_div.append(cmd_sub_div);
Brian E. Granger
Fixing design of quickhelp.
r14096 return cmd_div;
}
QuickHelp.prototype.build_edit_help = function () {
var edit_shortcuts = IPython.keyboard_manager.edit_shortcuts.help();
var help, shortcut;
var i, half, n;
Brian E. Granger
Fixing bugs and adding automatic KB shortcut help.
r14037
// Edit mode
Paul Ivanov
oops, <tt> went the way of the dodo, using <code>
r15705 var edit_div = $('<div/>').append($('<h4>Edit Mode (press <code>enter</code> to enable)</h4>'));
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 var edit_sub_div = $('<div/>').addClass('hbox');
var edit_col1 = $('<div/>').addClass('box-flex0');
var edit_col2 = $('<div/>').addClass('box-flex0');
n = edit_shortcuts.length;
half = ~~(n/2); // Truncate :)
for (i=0; i<half; i++) {
Brian E. Granger
Fixing bugs and adding automatic KB shortcut help.
r14037 help = edit_shortcuts[i]['help'];
shortcut = edit_shortcuts[i]['shortcut'];
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 edit_col1.append($('<div>').addClass('quickhelp').
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 append($('<span/>').addClass('shortcut_key').text(shortcut)).
append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 );
};
for (i=half; i<n; i++) {
help = edit_shortcuts[i]['help'];
shortcut = edit_shortcuts[i]['shortcut'];
edit_col2.append($('<div>').addClass('quickhelp').
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 append($('<span/>').addClass('shortcut_key').text(shortcut)).
append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 );
Brian Granger
Cleaning up menu code....
r5858 };
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 edit_sub_div.append(edit_col1).append(edit_col2);
edit_div.append(edit_sub_div);
Brian E. Granger
Fixing design of quickhelp.
r14096 return edit_div;
}
Fernando Perez
Add quick help button: broken ATM, style and binding aren't working....
r5023
// Set module variables
MinRK
fix quickhelp widget...
r5066 IPython.QuickHelp = QuickHelp;
Fernando Perez
Add quick help button: broken ATM, style and binding aren't working....
r5023
return IPython;
}(IPython));