|
|
|
|
@ -26,20 +26,20 @@ var IPython = (function (IPython) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.style = function () {
|
|
|
|
|
this.element.find('input#notebook_name').addClass('ui-widget ui-widget-content');
|
|
|
|
|
this.element.find('input#notebook_name').attr('tabindex','1');
|
|
|
|
|
this.element.find('button#save_notebook').button();
|
|
|
|
|
this.element.find('button#save_notebook').attr('title', 'Save the Notebook');
|
|
|
|
|
this.element.find('span#save_widget').addClass('ui-widget');
|
|
|
|
|
this.element.find('span#notebook_name').addClass('ui-widget ui-widget-content');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.bind_events = function () {
|
|
|
|
|
var that = this;
|
|
|
|
|
this.element.find('button#save_notebook').click(function () {
|
|
|
|
|
that.save_notebook();
|
|
|
|
|
this.element.find('span#notebook_name').click(function () {
|
|
|
|
|
that.rename_notebook();
|
|
|
|
|
});
|
|
|
|
|
this.element.find('input#notebook_name').keyup(function () {
|
|
|
|
|
that.is_renaming();
|
|
|
|
|
this.element.find('span#notebook_name').hover(function () {
|
|
|
|
|
$(this).addClass("ui-state-hover");
|
|
|
|
|
}, function () {
|
|
|
|
|
$(this).removeClass("ui-state-hover");
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -49,28 +49,59 @@ var IPython = (function (IPython) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.rename_notebook = function () {
|
|
|
|
|
var that = this;
|
|
|
|
|
var dialog = $('<div/>');
|
|
|
|
|
dialog.append(
|
|
|
|
|
$('<h3/>').html('Enter a new notebook name:')
|
|
|
|
|
.css({'margin-bottom': '10px'})
|
|
|
|
|
);
|
|
|
|
|
dialog.append(
|
|
|
|
|
$('<input/>').attr('type','text')
|
|
|
|
|
.attr('value',this.get_notebook_name()).wijtextbox()
|
|
|
|
|
);
|
|
|
|
|
$(document).append(dialog);
|
|
|
|
|
dialog.dialog({
|
|
|
|
|
resizable: false,
|
|
|
|
|
modal: true,
|
|
|
|
|
title: "Rename Notebook",
|
|
|
|
|
closeText: "",
|
|
|
|
|
buttons : {
|
|
|
|
|
"OK": function () {
|
|
|
|
|
var new_name = $(this).find('input').attr('value');
|
|
|
|
|
if (!that.test_notebook_name(new_name)) {
|
|
|
|
|
$(this).find('h3').html(
|
|
|
|
|
"Invalid notebook name. " +
|
|
|
|
|
"Notebook names can contain any characters " +
|
|
|
|
|
"except / and \\. Please enter a new notebook name:"
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
that.set_notebook_name(new_name);
|
|
|
|
|
that.save_notebook();
|
|
|
|
|
$(this).dialog('close');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"Cancel": function () {
|
|
|
|
|
$(this).dialog('close');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.notebook_saved = function () {
|
|
|
|
|
this.set_document_title();
|
|
|
|
|
this.last_saved_name = this.get_notebook_name();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.is_renaming = function () {
|
|
|
|
|
if (this.get_notebook_name() !== this.last_saved_name) {
|
|
|
|
|
this.status_rename();
|
|
|
|
|
} else {
|
|
|
|
|
this.status_save();
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.get_notebook_name = function () {
|
|
|
|
|
return this.element.find('input#notebook_name').attr('value');
|
|
|
|
|
return this.element.find('span#notebook_name').html();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.set_notebook_name = function (nbname) {
|
|
|
|
|
this.element.find('input#notebook_name').attr('value',nbname);
|
|
|
|
|
this.element.find('span#notebook_name').html(nbname);
|
|
|
|
|
this.set_document_title();
|
|
|
|
|
this.last_saved_name = nbname;
|
|
|
|
|
};
|
|
|
|
|
@ -95,18 +126,10 @@ var IPython = (function (IPython) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.test_notebook_name = function () {
|
|
|
|
|
var nbname = this.get_notebook_name();
|
|
|
|
|
SaveWidget.prototype.test_notebook_name = function (nbname) {
|
|
|
|
|
if (this.notebook_name_blacklist_re.test(nbname) == false) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
var bad_name = $('<div/>');
|
|
|
|
|
bad_name.html(
|
|
|
|
|
"The notebook name you entered (" +
|
|
|
|
|
nbname +
|
|
|
|
|
") is not valid. Notebook names can contain any characters except / and \\."
|
|
|
|
|
);
|
|
|
|
|
bad_name.dialog({title: 'Invalid name', modal: true});
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
@ -118,26 +141,18 @@ var IPython = (function (IPython) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.status_save = function () {
|
|
|
|
|
this.element.find('button#save_notebook').button('option', 'label', '<u>S</u>ave');
|
|
|
|
|
this.element.find('button#save_notebook').button('enable');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.status_saving = function () {
|
|
|
|
|
this.element.find('button#save_notebook').button('option', 'label', 'Saving');
|
|
|
|
|
this.element.find('button#save_notebook').button('disable');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.status_loading = function () {
|
|
|
|
|
this.element.find('button#save_notebook').button('option', 'label', 'Loading');
|
|
|
|
|
this.element.find('button#save_notebook').button('disable');
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SaveWidget.prototype.status_rename = function () {
|
|
|
|
|
this.element.find('button#save_notebook').button('option', 'label', 'Rename');
|
|
|
|
|
this.element.find('button#save_notebook').button('enable');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|