witten
/
luminotes
Archived
1
0
Fork 0

You can now add an existing note directly to the note tree, instead of having to click "options" -> "show on startup".

This commit is contained in:
Dan Helfman 2008-11-14 16:51:35 -08:00
parent 45c40a44af
commit e7038bfb1f
2 changed files with 60 additions and 21 deletions

4
NEWS
View File

@ -1,6 +1,8 @@
1.5.7: 1.5.7:
* Rearranged the links on the left and right side of the wiki editing page * Rearranged the links on the left and right side of the wiki editing page
so the note title links have a little more horizontal breathing room. so that the note title links have a little more horizontal breathing room.
* You can now add an existing note directly to the note tree, instead of
having to click "options" -> "show on startup".
* Fixed a bug in which search result note summaries were not showing the * Fixed a bug in which search result note summaries were not showing the
portion of the note that matched the search term. (Luminotes Server) portion of the note that matched the search term. (Luminotes Server)

View File

@ -440,6 +440,7 @@ Wiki.prototype.populate = function ( startup_notes, current_notes, note_read_wri
var new_note_tree_link_button = getElement( "new_note_tree_link" ); var new_note_tree_link_button = getElement( "new_note_tree_link" );
if ( new_note_tree_link_button ) { if ( new_note_tree_link_button ) {
connect( new_note_tree_link_button, "onclick", function ( event ) { connect( new_note_tree_link_button, "onclick", function ( event ) {
self.clear_pulldowns();
if ( self.note_tree ) if ( self.note_tree )
self.note_tree.start_link_add(); self.note_tree.start_link_add();
event.stop(); event.stop();
@ -3044,7 +3045,8 @@ Pulldown.prototype.update_position = function ( always_left_align ) {
} }
Pulldown.prototype.shutdown = function () { Pulldown.prototype.shutdown = function () {
removeElement( this.div ); if ( this.div && this.div.parentNode )
removeElement( this.div );
} }
@ -4440,6 +4442,7 @@ Note_tree.prototype.start_link_add = function () {
"name": "new_note_tree_link_field", "name": "new_note_tree_link_field",
"title": "Enter the title of an existing note.", "title": "Enter the title of an existing note.",
"size": "10", "size": "10",
"autocomplete": "off",
"class": "text_field" "class": "text_field"
} }
); );
@ -4465,10 +4468,7 @@ Note_tree.prototype.start_link_add = function () {
this.wiki, this.notebook_id, this.invoker, link_field, null, "", link_field this.wiki, this.notebook_id, this.invoker, link_field, null, "", link_field
); );
connect( this.suggest_pulldown, "suggestion_selected", function ( note ) { connect( this.suggest_pulldown, "suggestion_selected", function ( note ) {
replaceChildNodes( "new_note_tree_link_area", "" ); self.end_link_add( note );
self.suggest_pulldown.shutdown();
// TODO: actually set the startup flag on the note (on the server)
self.add_root_link( note.object_id, note.title, note.contents, true );
} ); } );
connect( form, "onsubmit", function ( event ) { connect( form, "onsubmit", function ( event ) {
@ -4487,27 +4487,64 @@ Note_tree.prototype.start_link_add = function () {
link_field.select(); link_field.select();
} }
Note_tree.prototype.end_link_add = function () { Note_tree.prototype.end_link_add = function ( note ) {
var note_name = getElement( "new_note_tree_link_field" ).value; // if no note is provided, load it based on the title
this.suggest_pulldown.shutdown(); if ( !note ) {
replaceChildNodes( "new_note_tree_link_area", "" ); var note_name = getElement( "new_note_tree_link_field" ).value;
replaceChildNodes( "new_note_tree_link_area", "" );
// if the new name is blank, bail // if the new name is blank, bail
if ( /^\s*$/.test( note_name ) ) if ( /^\s*$/.test( note_name ) )
return;
// load the requested note by title and add it as a root link
var self = this;
this.invoker.invoke( "/notebooks/load_note_by_title", "GET", {
"notebook_id": this.notebook_id,
"note_title": note_name
}, function ( result ) {
self.save_and_display_startup_note( result.note );
} );
// otherwise, a note is provided
} else {
replaceChildNodes( "new_note_tree_link_area", "" );
this.save_and_display_startup_note( note );
}
if ( this.suggest_pulldown ) {
this.suggest_pulldown.shutdown();
this.suggest_pulldown = null;
}
}
Note_tree.prototype.save_and_display_startup_note = function ( note ) {
if ( !note ) {
this.wiki.display_message( "Sorry, a note by that title doesn't exist. (If you're trying to create a new note, then simply click that large \"+\" button on the left.)" );
return; return;
}
// load the requested note by title and add it as a root link // if it's already a startup note, just highlight it and bail
if ( note.startup ) {
this.add_root_link( note.object_id, note.title, note.contents, true );
return;
}
// mark the note as a startup note on the client
this.wiki.startup_notes[ note.object_id ] = true;
var frame = getElement( "note_" + note.object_id );
if ( frame )
frame.editor.startup = true;
// save the note as a startup note on the server, and then add it to the note tree
var self = this; var self = this;
this.invoker.invoke( "/notebooks/load_note_by_title", "GET", { this.invoker.invoke( "/notebooks/save_note", "POST", {
"notebook_id": this.notebook_id, "notebook_id": this.notebook_id,
"note_title": note_name "note_id": note.object_id,
"contents": note.contents,
"startup": true,
"previous_revision": note.revision
}, function ( result ) { }, function ( result ) {
// TODO: actually set the startup flag on the note (on the server) self.add_root_link( note.object_id, note.title, note.contents, true );
var note = result.note;
if ( note )
self.add_root_link( note.object_id, note.title, note.contents, true );
else
self.wiki.display_message( "Sorry, a note by that title doesn't exist. (If you're trying to create a new note, then simply click that large \"+\" button on the left.)" );
} ); } );
} }