Make Contents.new more generic

Thomas Kluyver 12 years ago
parent 4452754a6b
commit 5279418acf

@ -89,8 +89,8 @@ define([
this.element.find('#new_notebook').click(function () {
// Create a new notebook in the same path as the current
// notebook's path.
that.contents.new_notebook(that.notebook.notebook_path,
{
that.contents.new(that.notebook.notebook_path, null, {
ext: ".ipynb",
success: function (data) {
window.open(
utils.url_join_encode(

@ -97,12 +97,23 @@ define([
*
* @method scroll_to_cell
* @param {String} path The path to create the new notebook at
* @param {String} name Name for new file. Chosen by server if unspecified.
* @param {Object} options:
* ext: file extension to use if name unspecified
*/
Contents.prototype.new_notebook = function(path, options) {
var error = options.error || function() {};
Contents.prototype.new = function(path, name, options) {
var method, data;
if (name) {
method = "PUT";
} else {
method = "POST";
data = JSON.stringify({ext: options.ext || ".ipynb"});
}
var settings = {
processData : false,
type : "POST",
type : method,
data: data,
dataType : "json",
success : options.success || function() {},
error : this.create_basic_error_handler(options.error)

@ -60,8 +60,8 @@ require([
login_widget = new loginwidget.LoginWidget('#login_widget', common_options);
$('#new_notebook').click(function (e) {
contents.new_notebook(common_options.notebook_path,
{
contents.new(common_options.notebook_path, null, {
ext: ".ipynb",
success: function (data) {
window.open(
utils.url_join_encode(

Loading…
Cancel
Save