diff --git a/static/js/Editor.js b/static/js/Editor.js index d266abf..8f7c41c 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -320,7 +320,7 @@ Editor.prototype.blurred = function () { Editor.prototype.empty = function () { if ( !this.document || !this.document.body ) - return false; // we don't know yet whether it's empty + return true; // consider it empty as of now return ( scrapeText( this.document.body ).length == 0 ); } @@ -493,8 +493,12 @@ Editor.prototype.shutdown = function( event ) { disconnectAll( this.options_button ); disconnectAll( this.hide_button ); disconnectAll( iframe ); - disconnectAll( this.document.body ); - disconnectAll( this.document ); + + if ( this.document ) { + disconnectAll( this.document.body ); + disconnectAll( this.document ); + } + blindUp( iframe, options = { "duration": 0.5, afterFinish: function () { try { removeElement( note_controls ); diff --git a/static/js/Wiki.js b/static/js/Wiki.js index d1dcdfc..7a89139 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -729,6 +729,14 @@ Wiki.prototype.display_error = function ( text ) { this.clear_messages(); this.clear_pulldowns(); + // remove all empty editors, some of which might exist due to a problem reaching the server + var iframes = getElementsByTagAndClassName( "iframe", "note_frame" ); + for ( var i in iframes ) { + var editor = iframes[ i ].editor; + if ( editor.empty() ) + editor.shutdown(); + } + var inner_div = DIV( { "class": "error_inner" }, text ); var div = DIV( { "class": "error" }, inner_div ); appendChildNodes( "notes", div );