Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[notebook] read-only: disable name field #1132

Closed
wants to merge 3 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+13 −3
Split
@@ -27,6 +27,8 @@ var IPython = (function (IPython) {
NotebookList.prototype.bind_events = function () {
+ if (IPython.read_only)
+ {return}
var that = this;
this.element.bind('dragover', function () {
return false;
@@ -83,6 +85,9 @@ var IPython = (function (IPython) {
if (!IPython.read_only){
// hide delete buttons when readonly
this.add_delete_button(item);
+ $('#drag_info').removeClass('hidden');
+ } else {
+ $('#drag_info').remove();
}
};
};
@@ -106,6 +106,10 @@ $(document).ready(function () {
$('div#config_section').addClass('hidden');
$('div#kernel_section').addClass('hidden');
$('span#login_widget').removeClass('hidden');
+
+ // set the notebook name field as not modifiable
+ $('#notebook_name').attr('disabled','disabled')
@minrk

minrk Dec 11, 2011

Owner

Do you have an aesthetic preference for 'disabled' vs 'readonly'? Functionally identical, but disabled greys out the field. I'm 50-50 on this one.

@Carreau

Carreau Dec 11, 2011

Owner

I slightly prefer the 'disabled' because it's another visual clue of the read-only mode. I often myself mistaking both mode because you can still select things in RO-mode, especially the blinking cursor also.

@minrk

minrk Dec 12, 2011

Owner

Fair enough, it does serve as a decent indicator of read-only mode (along with the absence of the save button, etc.). We definitely don't want to do something like this to the regular notebook fields, which are just read-only. Those must remain selectable, and should probably not be aesthetically altered. The blinking cursor would maybe be nice to remove, but it should otherwise look unaltered.

+
// left panel starts collapsed, but the collapse must happen after
// elements start drawing. Don't draw contents of the panel until
// after they are collapsed
@@ -33,9 +33,10 @@ $(document).ready(function () {
IPython.login_widget = new IPython.LoginWidget('span#login_widget');
if (IPython.read_only){
- $('#new_notebook').addClass('hidden');
// unhide login button if it's relevant
$('span#login_widget').removeClass('hidden');
+ } else {
+ $('#new_notebook').removeClass('hidden');
}
IPython.notebook_list.load_list();
@@ -20,9 +20,9 @@
{% block content_panel %}
<div id="content_toolbar">
- <span id="drag_info">Drag files onto the list to import notebooks.</span>
+ <span id="drag_info" class="hidden">Drag files onto the list to import notebooks.</span>
<span id="notebooks_buttons">
- <button id="new_notebook">New Notebook</button>
+ <button id="new_notebook" class="hidden">New Notebook</button>
</span>
</div>
<div id="notebook_list">