##// END OF EJS Templates
remove weird unicode space in the new copyright header...
remove weird unicode space in the new copyright header The bytes were actually: #\xe2\x80\x82Copyright...

File last commit:

r16141:8a7c5eab
r16141:8a7c5eab
Show More
quickhelp.js
171 lines | 6.2 KiB | application/javascript | JavascriptLexer
MinRK
remove weird unicode space in the new copyright header...
r16141 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
Fernando Perez
Add quick help button: broken ATM, style and binding aren't working....
r5023
//============================================================================
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
Paul Ivanov
Hi, I'm a Mac. And I'm a PC.
r16029 var platform = IPython.utils.platform;
MinRK
fix quickhelp widget...
r5066 var QuickHelp = function (selector) {
Fernando Perez
Add quick help button: broken ATM, style and binding aren't working....
r5023 };
Paul Ivanov
move hyphen to cmd_ctrl
r16045 var cmd_ctrl = 'Ctrl-';
Paul Ivanov
remove no-op placeholder edit mode "shortcuts"
r16034 var platform_specific;
Paul Ivanov
Hi, I'm a Mac. And I'm a PC.
r16029
if (platform === 'MacOS') {
Paul Ivanov
completed both sets of platform-specific shortcuts
r16032 // Mac OS X specific
Paul Ivanov
move hyphen to cmd_ctrl
r16045 cmd_ctrl = 'Cmd-';
Paul Ivanov
remove no-op placeholder edit mode "shortcuts"
r16034 platform_specific = [
Paul Ivanov
completed both sets of platform-specific shortcuts
r16032 { shortcut: "Cmd-Up", help:"go to cell start" },
{ shortcut: "Cmd-Down", help:"go to cell end" },
Paul Ivanov
remove cm_keyboard.rst and OS-level shortcuts
r16049 { shortcut: "Opt-Left", help:"go one word left" },
{ shortcut: "Opt-Right", help:"go one word right" },
{ shortcut: "Opt-Backspace", help:"del word before" },
{ shortcut: "Opt-Delete", help:"del word after" },
Paul Ivanov
remove no-op placeholder edit mode "shortcuts"
r16034 ];
Paul Ivanov
completed both sets of platform-specific shortcuts
r16032 } else {
// PC specific
Paul Ivanov
remove no-op placeholder edit mode "shortcuts"
r16034 platform_specific = [
Paul Ivanov
completed both sets of platform-specific shortcuts
r16032 { shortcut: "Ctrl-Home", help:"go to cell start" },
Paul Ivanov
ok, removed last few unnecessary shortcuts
r16051 { shortcut: "Ctrl-Up", help:"go to cell start" },
Paul Ivanov
completed both sets of platform-specific shortcuts
r16032 { shortcut: "Ctrl-End", help:"go to cell end" },
{ shortcut: "Ctrl-Down", help:"go to cell end" },
{ shortcut: "Ctrl-Left", help:"go one word left" },
{ shortcut: "Ctrl-Right", help:"go one word right" },
{ shortcut: "Ctrl-Backspace", help:"del word before" },
{ shortcut: "Ctrl-Delete", help:"del word after" },
Paul Ivanov
remove no-op placeholder edit mode "shortcuts"
r16034 ];
Paul Ivanov
Hi, I'm a Mac. And I'm a PC.
r16029 }
Fernando Perez
Add quick help button: broken ATM, style and binding aren't working....
r5023
Paul Ivanov
completed both sets of platform-specific shortcuts
r16032 var cm_shortcuts = [
Paul Ivanov
remove no-op placeholder edit mode "shortcuts"
r16034 { shortcut:"Tab", help:"code completion or indent" },
{ shortcut:"Shift-Tab", help:"tooltip" },
Paul Ivanov
move hyphen to cmd_ctrl
r16045 { shortcut: cmd_ctrl + "]", help:"indent" },
{ shortcut: cmd_ctrl + "[", help:"dedent" },
{ shortcut: cmd_ctrl + "a", help:"select all" },
{ shortcut: cmd_ctrl + "z", help:"undo" },
{ shortcut: cmd_ctrl + "Shift-z", help:"redo" },
{ shortcut: cmd_ctrl + "y", help:"redo" },
Paul Ivanov
completed both sets of platform-specific shortcuts
r16032 ].concat( platform_specific );
Paul Ivanov
CodeMirror shortcuts in QuickHelp...
r16010
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;
Paul Ivanov
rebuild.QuickHelp event sets the dirty bit...
r15771 if ( this.force_rebuild ) {
Paul Ivanov
remove stale modal dialog from the DOM
r15844 this.shortcut_dialog.remove();
Paul Ivanov
rebuild.QuickHelp event sets the dirty bit...
r15771 delete(this.shortcut_dialog);
this.force_rebuild = false;
}
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.'
Paul Ivanov
semicolon fixes buttress half of my js commits
r15840 );
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
Paul Ivanov
remove no-op placeholder edit mode "shortcuts"
r16034 var edit_div = this.build_edit_help(cm_shortcuts);
Brian E. Granger
Fixing design of quickhelp.
r14096 element.append(edit_div);
this.shortcut_dialog = IPython.dialog.modal({
title : "Keyboard shortcuts",
body : element,
destroy : false,
buttons : {
Close : {}
}
});
MinRK
use modal_stretch on keyboard shortcut dialog
r16023 this.shortcut_dialog.addClass("modal_stretch");
Paul Ivanov
rebuild.QuickHelp event sets the dirty bit...
r15771
$([IPython.events]).on('rebuild.QuickHelp', function() { that.force_rebuild = true;});
Brian E. Granger
Fixing design of quickhelp.
r14096 };
QuickHelp.prototype.build_command_help = function () {
var command_shortcuts = IPython.keyboard_manager.command_shortcuts.help();
Paul Ivanov
DRY: style in one place, removed code duplication
r15801 return build_div('<h4>Command Mode (press <code>Esc</code> to enable)</h4>', command_shortcuts);
Paul Ivanov
semicolon fixes buttress half of my js commits
r15840 };
Brian E. Granger
Fixing design of quickhelp.
r14096
Paul Ivanov
better handling of minus
r15876 var special_case = { pageup: "PageUp", pagedown: "Page Down", 'minus': '-' };
Paul Ivanov
prettify combo keyboard shortcuts
r15782 var prettify = function (s) {
Paul Ivanov
really fix the '-' key shortcuts now
r15877 s = s.replace(/-$/, 'minus'); // catch shortcuts using '-' key
Paul Ivanov
use - for shortcut separators
r15873 var keys = s.split('-');
Paul Ivanov
prettify combo keyboard shortcuts
r15782 var k, i;
for (i in keys) {
k = keys[i];
Paul Ivanov
DRY: style in one place, removed code duplication
r15801 if ( k.length == 1 ) {
keys[i] = "<code><strong>" + k + "</strong></code>";
continue; // leave individual keys lower-cased
}
Paul Ivanov
prettify combo keyboard shortcuts
r15782 keys[i] = ( special_case[k] ? special_case[k] : k.charAt(0).toUpperCase() + k.slice(1) );
Paul Ivanov
DRY: style in one place, removed code duplication
r15801 keys[i] = "<code><strong>" + keys[i] + "</strong></code>";
Paul Ivanov
prettify combo keyboard shortcuts
r15782 }
return keys.join('-');
Paul Ivanov
first pass at capitalizing keyboard shortcuts
r15781
};
Paul Ivanov
remove no-op placeholder edit mode "shortcuts"
r16034 QuickHelp.prototype.build_edit_help = function (cm_shortcuts) {
Brian E. Granger
Fixing design of quickhelp.
r14096 var edit_shortcuts = IPython.keyboard_manager.edit_shortcuts.help();
Paul Ivanov
remove no-op placeholder edit mode "shortcuts"
r16034 jQuery.extend(cm_shortcuts, edit_shortcuts);
return build_div('<h4>Edit Mode (press <code>Enter</code> to enable)</h4>', cm_shortcuts);
Paul Ivanov
semicolon fixes buttress half of my js commits
r15840 };
Paul Ivanov
DRY: style in one place, removed code duplication
r15801
var build_one = function (s) {
Paul Ivanov
semicolon fixes buttress half of my js commits
r15840 var help = s.help;
var shortcut = prettify(s.shortcut);
Paul Ivanov
DRY: style in one place, removed code duplication
r15801 return $('<div>').addClass('quickhelp').
append($('<span/>').addClass('shortcut_key').append($(shortcut))).
Paul Ivanov
semicolon fixes buttress half of my js commits
r15840 append($('<span/>').addClass('shortcut_descr').text(' : ' + help));
Paul Ivanov
DRY: style in one place, removed code duplication
r15801
Paul Ivanov
semicolon fixes buttress half of my js commits
r15840 };
Paul Ivanov
DRY: style in one place, removed code duplication
r15801
var build_div = function (title, shortcuts) {
var i, half, n;
var div = $('<div/>').append($(title));
var sub_div = $('<div/>').addClass('hbox');
MinRK
use box-flex to layout quickhelp
r15899 var col1 = $('<div/>').addClass('box-flex1');
var col2 = $('<div/>').addClass('box-flex1');
Paul Ivanov
DRY: style in one place, removed code duplication
r15801 n = shortcuts.length;
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 half = ~~(n/2); // Truncate :)
Paul Ivanov
semicolon fixes buttress half of my js commits
r15840 for (i=0; i<half; i++) { col1.append( build_one(shortcuts[i]) ); }
for (i=half; i<n; i++) { col2.append( build_one(shortcuts[i]) ); }
Paul Ivanov
DRY: style in one place, removed code duplication
r15801 sub_div.append(col1).append(col2);
div.append(sub_div);
return div;
Paul Ivanov
semicolon fixes buttress half of my js commits
r15840 };
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));