From ac5c8f6174572814e27f1c97aeb3958d02915d07 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 29 Jul 2008 16:38:35 -0700 Subject: [PATCH] By popular demand, added a "save" button that becomes grayed out when everything is saved. --- NEWS | 5 +++++ static/css/style.css | 8 ++++++++ static/js/Wiki.js | 22 ++++++++++++++++++++++ view/Link_area.py | 15 +++++++++++++-- 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index f73282e..1dfd4c0 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +1.4.20: + * By popular demand, added a "save" button that becomes grayed out when + everything is saved. + * Now displaying "saving" status text in addition to "loading". + 1.4.19: July 29, 2008: * When scrolling to and then highlighting a note, do so serially instead of in parallel. diff --git a/static/css/style.css b/static/css/style.css index 043b696..f70befc 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -477,6 +477,14 @@ h1 { background-color: #ffcc66; } +.note_button[disabled]:hover { + background-color: #d0e0f0; +} + +#save_button { + margin-left: 0.5em; +} + .note_frame { margin: 0em; padding: 0em; diff --git a/static/js/Wiki.js b/static/js/Wiki.js index 53743db..2bbcc5e 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -332,6 +332,14 @@ Wiki.prototype.populate = function ( startup_notes, current_notes, note_read_wri ); } + var save_button = getElement( "save_button" ); + if ( save_button ) { + connect( save_button, "onclick", function ( event ) { + self.save_editor( null ); + } ); + save_button.disabled = true; + } + var download_html_link = getElement( "download_html_link" ); if ( download_html_link ) { connect( download_html_link, "onclick", function ( event ) { @@ -806,6 +814,14 @@ Wiki.prototype.editor_state_changed = function ( editor, link_clicked ) { if ( !link_clicked ) this.display_link_pulldown( editor ); + if ( editor.dirty() ) { + var save_button = getElement( "save_button" ); + if ( save_button && save_button.disabled ) { + save_button.disabled = false; + save_button.value = "save"; + } + } + signal( this, "note_state_changed", editor ); } @@ -1474,6 +1490,12 @@ Wiki.prototype.save_editor = function ( editor, fire_and_forget, callback, synch self.display_storage_usage( result.storage_bytes ); editor.mark_clean(); + var save_button = getElement( "save_button" ); + if ( save_button ) { + save_button.disabled = true; + save_button.value = "saved"; + } + if ( editor.startup ) self.startup_notes[ editor.id ] = true; else if ( self.startup_notes[ editor.id ] ) diff --git a/view/Link_area.py b/view/Link_area.py index 60610c6..36be5d7 100644 --- a/view/Link_area.py +++ b/view/Link_area.py @@ -1,4 +1,4 @@ -from Tags import Div, P, Span, H4, A, Strong, Img +from Tags import Div, P, Span, H4, A, Strong, Img, Input from Rounded_div import Rounded_div from Search_form import Search_form @@ -15,7 +15,18 @@ class Link_area( Div ): self, Div( Div( - H4( u"this notebook", id = u"this_notebook_area_title" ), + H4( + u"this notebook", + notebook.read_write and Input( + type = u"button", + class_ = u"note_button small_text", + id = u"save_button", + value = u"saved", + disabled = u"true", + title = u"save your work", + ) or None, + id = u"this_notebook_area_title", + ), Div( Search_form(), class_ = u"link_area_item",