##// END OF EJS Templates
Merge pull request #6962 from takluyver/nb-dir-and-file-to-run...
Merge pull request #6962 from takluyver/nb-dir-and-file-to-run Allow starting the server with both file_to_run and notebook_dir

File last commit:

r17454:806bf0f9
r19004:2fda8e1a merge
Show More
rawcell.js
86 lines | 2.7 KiB | application/javascript | JavascriptLexer
Jonathan Frederic
Fixed cell toolbars
r17217 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
MinRK
add raw cell toolbar preset
r13671
Jonathan Frederic
Fixed cell toolbars
r17217 define([
'jquery',
'notebook/js/celltoolbar',
'base/js/dialog',
'base/js/keyboard',
], function($, celltoolbar, dialog, keyboard) {
"use strict";
MinRK
add raw cell toolbar preset
r13671
Jonathan Frederic
Fixed cell toolbars
r17217 var CellToolbar = celltoolbar.CellToolbar;
MinRK
add raw cell toolbar preset
r13671 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 || "-")
);
Jonathan Frederic
Fixed cell toolbars
r17217 dialog.modal({
MinRK
add dialog to raw cell toolbar
r13675 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) {
Jonathan Frederic
Fixed cell toolbars
r17217 if (event.which === 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
Raffaele De Feo
Adjusted "rawcell" toolbar preset to make us of the new "register_callback"...
r16437 "Raw NBConvert Format"
MinRK
add raw cell toolbar preset
r13671 );
Matthias BUSSONNIER
Use global event for celltoolbar
r17454 var register = function (notebook) {
Jonathan Frederic
Fixed cell toolbars
r17217 CellToolbar.register_callback('raw_cell.select', select_type, ['raw']);
raw_cell_preset.push('raw_cell.select');
MinRK
add raw cell toolbar preset
r13671
Matthias BUSSONNIER
Use global event for celltoolbar
r17454 CellToolbar.register_preset('Raw Cell Format', raw_cell_preset, notebook);
Jonathan Frederic
Fixed cell toolbars
r17217 console.log('Raw Cell Format toolbar preset loaded.');
};
return {'register': register};
MinRK
add raw cell toolbar preset
r13671
Jonathan Frederic
Fixed cell toolbars
r17217 });