Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 3 commits into from

2 participants

@Carreau
Owner

everything in title...

Carreau added some commits
@Carreau Carreau [notebook] read-only: disable name field eff6c07
@Carreau Carreau [notebook] read-only disable element
    * remove the drag file to upload text
    * prevent drag binding to show upload form
4973176
IPython/frontend/html/notebook/static/js/notebooklist.js
@@ -83,6 +85,8 @@ var IPython = (function (IPython) {
if (!IPython.read_only){
// hide delete buttons when readonly
this.add_delete_button(item);
+ } else {
+ $('#drag_info').remove();
@minrk Owner
minrk added a note

On this one, the approach we have gone with elsewhere is to start with class=hidden, and remove that once we know that we are not read-only. That way, we don't flash text on the screen.

@Carreau Owner
Carreau added a note

Ok, done, this wasn't the case for surrounding element like new_notebook button, I've changed it also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@minrk minrk commented on the diff
IPython/frontend/html/notebook/static/js/notebookmain.js
@@ -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 Owner
minrk added a note

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 Owner
Carreau added a note

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 Owner
minrk added a note

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@minrk
Owner

Okay, I think this looks good, thanks! You may have noticed that the read-only mode is not really fully implemented. It was tossed together as a demo, but some people found the functionality so useful that it was merged before being more rigorously done.

@Carreau
Owner

It's ok for me. PR are coming so fast that you can't think of all cases and UI detail. I fix it because I got caught thinking this was a RW-notebook, and knowing myself it would have happend more than once.

@minrk minrk referenced this pull request from a commit
@minrk minrk Merge PR #1132
Improve read-only style

closes #1132
8e021bb
@minrk minrk closed this pull request from a commit
@minrk minrk Merge PR #1132
Improve read-only style

closes #1132
8e021bb
@minrk minrk closed this in 8e021bb
@ellisonbg ellisonbg referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@mattvonrocketstein mattvonrocketstein referenced this pull request from a commit in mattvonrocketstein/ipython
@minrk minrk Merge PR #1132
Improve read-only style

closes #1132
5349a6e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 9, 2011
  1. @Carreau
  2. @Carreau

    [notebook] read-only disable element

    Carreau authored
        * remove the drag file to upload text
        * prevent drag binding to show upload form
Commits on Dec 11, 2011
  1. @Carreau
This page is out of date. Refresh to see the latest.
View
5 IPython/frontend/html/notebook/static/js/notebooklist.js
@@ -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();
}
};
};
View
4 IPython/frontend/html/notebook/static/js/notebookmain.js
@@ -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 Owner
minrk added a note

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 Owner
Carreau added a note

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 Owner
minrk added a note

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
// 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
View
3  IPython/frontend/html/notebook/static/js/projectdashboardmain.js
@@ -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();
View
4 IPython/frontend/html/notebook/templates/projectdashboard.html
@@ -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">
Something went wrong with that request. Please try again.