witten
/
luminotes
Archived
1
0
Fork 0

* In the trash, now showing "the trash is empty" when you delete/hide/undelete enough notes to make it empty.

* Wiki.create_editor() returns the editors it just created.
 * Wiki.open_editors initialized with startup notes.
This commit is contained in:
Dan Helfman 2007-09-05 18:49:28 +00:00
parent 7bf6d8685f
commit f21610eaf7
2 changed files with 30 additions and 7 deletions

View File

@ -8,6 +8,7 @@ function Editor( id, notebook_id, note_text, deleted_from, revisions_list, inser
this.startup = startup || false; // whether this Editor is for a startup note this.startup = startup || false; // whether this Editor is for a startup note
this.init_highlight = highlight || false; this.init_highlight = highlight || false;
this.init_focus = focus || false; this.init_focus = focus || false;
this.closed = false;
var iframe_id = "note_" + id; var iframe_id = "note_" + id;
var self = this; var self = this;
@ -487,6 +488,7 @@ Editor.prototype.contents = function () {
Editor.prototype.shutdown = function( event ) { Editor.prototype.shutdown = function( event ) {
signal( this, "title_changed", this, this.title, null ); signal( this, "title_changed", this, this.title, null );
this.closed = true;
var iframe = this.iframe; var iframe = this.iframe;
var note_controls = this.note_controls; var note_controls = this.note_controls;
disconnectAll( this ); disconnectAll( this );

View File

@ -194,7 +194,8 @@ Wiki.prototype.populate = function ( result ) {
// don't actually create an editor if a particular note was provided in the result // don't actually create an editor if a particular note was provided in the result
if ( !result.note ) { if ( !result.note ) {
this.create_editor( note.object_id, note.contents, note.deleted_from, note.revisions_list, undefined, this.read_write, false, focus ); var editor = this.create_editor( note.object_id, note.contents, note.deleted_from, note.revisions_list, undefined, this.read_write, false, focus );
this.open_editors[ note.title ] = editor;
focus = false; focus = false;
} }
} }
@ -205,8 +206,8 @@ Wiki.prototype.populate = function ( result ) {
if ( result.note ) if ( result.note )
this.create_editor( result.note.object_id, result.note.contents, result.note.deleted_from, result.note.revisions_list, undefined, read_write, false, true ); this.create_editor( result.note.object_id, result.note.contents, result.note.deleted_from, result.note.revisions_list, undefined, read_write, false, true );
if ( !this.notebook.trash && result.startup_notes.length == 0 && !result.note ) if ( result.startup_notes.length == 0 && !result.note )
this.display_message( "The trash is empty." ) this.display_empty_message();
} }
Wiki.prototype.create_blank_editor = function ( event ) { Wiki.prototype.create_blank_editor = function ( event ) {
@ -228,7 +229,8 @@ Wiki.prototype.create_blank_editor = function ( event ) {
} }
} }
this.blank_editor_id = this.create_editor( undefined, undefined, undefined, undefined, undefined, this.read_write, true, true ); var editor = this.create_editor( undefined, undefined, undefined, undefined, undefined, this.read_write, true, true );
this.blank_editor_id = editor.id;
} }
Wiki.prototype.load_editor = function ( note_title, note_id, revision, link ) { Wiki.prototype.load_editor = function ( note_title, note_id, revision, link ) {
@ -391,7 +393,8 @@ Wiki.prototype.parse_loaded_editor = function ( result, note_title, revision, li
else else
var read_write = this.read_write; var read_write = this.read_write;
id = this.create_editor( id, note_text, deleted_from, revisions_list, note_title, read_write, true, false ); var editor = this.create_editor( id, note_text, deleted_from, revisions_list, note_title, read_write, true, false );
id = editor.id;
// if a link that launched this editor was provided, update it with the created note's id // if a link that launched this editor was provided, update it with the created note's id
if ( link && id ) if ( link && id )
@ -440,7 +443,7 @@ Wiki.prototype.create_editor = function ( id, note_text, deleted_from, revisions
self.invoker.invoke( url, "POST", null, null, form ); self.invoker.invoke( url, "POST", null, null, form );
} ); } );
return id; return editor;
} }
Wiki.prototype.editor_state_changed = function ( editor ) { Wiki.prototype.editor_state_changed = function ( editor ) {
@ -495,6 +498,7 @@ Wiki.prototype.editor_focused = function ( editor, fire_and_forget ) {
// if the formerly focused editor is completely empty, then remove it as the user leaves it and switches to this editor // if the formerly focused editor is completely empty, then remove it as the user leaves it and switches to this editor
if ( this.focused_editor.empty() ) { if ( this.focused_editor.empty() ) {
this.focused_editor.shutdown(); this.focused_editor.shutdown();
this.display_empty_message();
} else { } else {
// when switching editors, save the one being left // when switching editors, save the one being left
this.save_editor( null, fire_and_forget ); this.save_editor( null, fire_and_forget );
@ -618,6 +622,7 @@ Wiki.prototype.hide_editor = function ( event, editor ) {
this.save_editor( editor ); this.save_editor( editor );
editor.shutdown(); editor.shutdown();
this.display_empty_message();
} }
event.stop(); event.stop();
@ -664,6 +669,7 @@ Wiki.prototype.delete_editor = function ( event, editor ) {
} }
editor.shutdown(); editor.shutdown();
this.display_empty_message();
} }
event.stop(); event.stop();
@ -695,6 +701,7 @@ Wiki.prototype.undelete_editor_via_trash = function ( event, editor ) {
this.focused_editor = null; this.focused_editor = null;
editor.shutdown(); editor.shutdown();
this.display_empty_message();
} }
event.stop(); event.stop();
@ -952,11 +959,25 @@ Wiki.prototype.delete_all_editors = function ( event ) {
editor.shutdown(); editor.shutdown();
} }
this.display_message( "The trash is empty." ); this.display_empty_message();
event.stop(); event.stop();
} }
Wiki.prototype.display_empty_message = function () {
var iframes = getElementsByTagAndClassName( "iframe", "note_frame" );
// if there are any open editors, bail
for ( var i in iframes ) {
var iframe = iframes[ i ];
if ( iframe.editor.closed == false )
return;
}
if ( this.parent_id )
this.display_message( "The trash is empty." )
}
Wiki.prototype.brief_revision = function ( revision ) { Wiki.prototype.brief_revision = function ( revision ) {
return revision.split( /\.\d/ )[ 0 ]; // strip off seconds from the timestamp return revision.split( /\.\d/ )[ 0 ]; // strip off seconds from the timestamp
} }