witten
/
luminotes
Archived
1
0
Fork 0

Removing the byline whenever a note is saved so it doesn't accidentally get written to the database.

This commit is contained in:
Dan Helfman 2009-02-16 13:41:11 -08:00
parent c74a18ae1e
commit 78cac16bde
2 changed files with 13 additions and 8 deletions

View File

@ -456,7 +456,7 @@ Editor.prototype.position_cursor = function ( div_range ) {
}
// otherwise, just move the text cursor to the end of the text
if ( this.iframe.contentWindow && this.iframe.contentWindow.getSelection ) { // browsers such as Firefox
if ( this.iframe && this.iframe.contentWindow && this.iframe.contentWindow.getSelection ) { // browsers such as Firefox
var selection = this.iframe.contentWindow.getSelection();
var last_node = this.document.body.lastChild;

View File

@ -1080,6 +1080,16 @@ Wiki.prototype.make_byline = function ( username, creation, note_id ) {
' | <a href="' + window.location.pathname + '?note_id=' + note_id + '" target="_top">permalink</a>';
}
Wiki.prototype.remove_byline = function ( editor ) {
if ( editor.document && editor.read_write ) {
var byline = getFirstElementByTagAndClassName( "div", "byline", editor.document );
if ( byline ) {
removeElement( byline );
editor.resize();
}
}
}
Wiki.prototype.editor_mouse_hovered = function ( editor, target ) {
var pulldowns = getElementsByTagAndClassName( "div", "pulldown" );
@ -1124,13 +1134,7 @@ Wiki.prototype.key_pressed = function ( event ) {
}
Wiki.prototype.editor_key_pressed = function ( editor, event ) {
if ( editor.document && editor.read_write ) {
var byline = getFirstElementByTagAndClassName( "div", "byline", editor.document );
if ( byline ) {
removeElement( byline );
editor.resize();
}
}
this.remove_byline( editor );
var code = event.key().code;
@ -1718,6 +1722,7 @@ Wiki.prototype.save_editor = function ( editor, fire_and_forget, callback, synch
if ( editor && editor.read_write && !editor.closed &&
( ( !editor.empty() && editor.dirty() ) || position_after || position_before ) ) {
editor.scrape_title();
this.remove_byline( editor );
this.invoker.invoke( "/notebooks/save_note", "POST", {
"notebook_id": this.notebook.object_id,