##// END OF EJS Templates
restore master behavior...
restore master behavior up arrow at the top line first goes to char 0, and only goes to the cell above if already on char 0. Same with down arrow on the bottom line: transition cursor to the end of the line, and only go down a cell if already at the end of the last line. this makes for an unhappy experience in code-mirror's vim mode for j and k keys, but we'll fix that in the next commit

File last commit:

r15619:957ea4d8
r15835:dc3c98b8
Show More
rawcell.js
89 lines | 3.0 KiB | application/javascript | JavascriptLexer
MinRK
add raw cell toolbar preset
r13671 //----------------------------------------------------------------------------
// Copyright (C) 2012 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.
//----------------------------------------------------------------------------
//============================================================================
// CellToolbar Example
//============================================================================
(function(IPython) {
"use strict";
var CellToolbar = IPython.CellToolbar;
var raw_cell_preset = [];
var select_type = CellToolbar.utils.select_ui_generator([
["None", "-"],
["LaTeX", "text/latex"],
MinRK
use reST in raw cell toolbar...
r13780 ["reST", "text/restructuredtext"],
MinRK
add raw cell toolbar preset
r13671 ["HTML", "text/html"],
MinRK
use reST in raw cell toolbar...
r13780 ["Markdown", "text/markdown"],
Thomas Kluyver
Condense raw_mimetype and mime_type traitlets into output_mimetype
r13832 ["Python", "text/x-python"],
MinRK
add dialog to raw cell toolbar
r13675 ["Custom", "dialog"],
MinRK
add raw cell toolbar preset
r13671
],
// setter
function(cell, value) {
MinRK
add dialog to raw cell toolbar
r13675 if (value === "-") {
delete cell.metadata.raw_mimetype;
MinRK
add raw cell toolbar preset
r13671 } else if (value === 'dialog'){
MinRK
add dialog to raw cell toolbar
r13675 var dialog = $('<div/>').append(
$("<p/>")
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 .text("Set the MIME type of the raw cell:")
MinRK
add dialog to raw cell toolbar
r13675 ).append(
$("<br/>")
).append(
$('<input/>').attr('type','text').attr('size','25')
.val(cell.metadata.raw_mimetype || "-")
);
IPython.dialog.modal({
title: "Raw Cell MIME Type",
body: dialog,
buttons : {
"Cancel": {},
"OK": {
class: "btn-primary",
click: function () {
console.log(cell);
cell.metadata.raw_mimetype = $(this).find('input').val();
console.log(cell.metadata);
}
}
},
open : function (event, ui) {
var that = $(this);
// Upon ENTER, click the OK button.
that.find('input[type="text"]').keydown(function (event, ui) {
Brian E. Granger
Removing old keyboard handling from IPython.utils.
r15619 if (event.which === IPython.keyboard.keycodes.enter) {
MinRK
add dialog to raw cell toolbar
r13675 that.find('.btn-primary').first().click();
return false;
}
});
that.find('input[type="text"]').focus().select();
}
});
MinRK
add raw cell toolbar preset
r13671 } else {
MinRK
add dialog to raw cell toolbar
r13675 cell.metadata.raw_mimetype = value;
MinRK
add raw cell toolbar preset
r13671 }
},
//getter
function(cell) {
MinRK
add dialog to raw cell toolbar
r13675 return cell.metadata.raw_mimetype || "";
MinRK
add raw cell toolbar preset
r13671 },
// name
"Raw NBConvert Format",
// cell_types
["raw"]
);
CellToolbar.register_callback('raw_cell.select', select_type);
raw_cell_preset.push('raw_cell.select');
CellToolbar.register_preset('Raw Cell Format', raw_cell_preset);
console.log('Raw Cell Format toolbar preset loaded.');
Thomas Kluyver
Condense raw_mimetype and mime_type traitlets into output_mimetype
r13832 }(IPython));