Several fixes for shared iframe releasing / focus interaction.
This commit is contained in:
parent
59f9134a8c
commit
51a568c39c
|
@ -215,7 +215,7 @@ Editor.prototype.claim_iframe = function ( position_after, click_position ) {
|
|||
this.iframe.setAttribute( "name", iframe_id );
|
||||
|
||||
if ( this.iframe.editor )
|
||||
this.iframe.editor.blur();
|
||||
this.iframe.editor.release_iframe();
|
||||
this.iframe.editor = this;
|
||||
|
||||
// setup the note controls
|
||||
|
@ -983,11 +983,16 @@ Editor.prototype.focus = function ( suppress_signal ) {
|
|||
}
|
||||
|
||||
Editor.prototype.blur = function () {
|
||||
this.scrape_title();
|
||||
|
||||
removeElementClass( this.iframe || this.div, "focused_note_frame" );
|
||||
}
|
||||
|
||||
Editor.prototype.release_iframe = function () {
|
||||
if ( !this.iframe )
|
||||
return;
|
||||
|
||||
this.scrape_title();
|
||||
var div = null;
|
||||
var contents = this.contents();
|
||||
|
||||
disconnectAll( this.iframe.contentWindow );
|
||||
disconnectAll( this.iframe );
|
||||
|
@ -996,6 +1001,9 @@ Editor.prototype.blur = function () {
|
|||
this.iframe.editor = null;
|
||||
this.document = null;
|
||||
|
||||
var static_contents = getFirstElementByTagAndClassName( "span", "static_note_contents", this.div );
|
||||
static_contents.innerHTML = contents;
|
||||
|
||||
if ( this.div )
|
||||
removeElementClass( this.div, "invisible" );
|
||||
addElementClass( this.iframe, "invisible" );
|
||||
|
@ -1003,15 +1011,15 @@ Editor.prototype.blur = function () {
|
|||
}
|
||||
|
||||
Editor.prototype.contents = function () {
|
||||
if ( this.iframe && this.document && this.document.body )
|
||||
return this.document.body.innerHTML;
|
||||
|
||||
if ( this.div ) {
|
||||
var static_contents = getFirstElementByTagAndClassName( "span", "static_note_contents", this.div );
|
||||
if ( static_contents )
|
||||
return static_contents.innerHTML;
|
||||
}
|
||||
|
||||
if ( this.document && this.document.body )
|
||||
return this.document.body.innerHTML;
|
||||
|
||||
return this.initial_text || "";
|
||||
}
|
||||
|
||||
|
|
|
@ -1010,6 +1010,10 @@ Wiki.prototype.editor_focused = function ( editor, synchronous ) {
|
|||
this.focused_editor.blur();
|
||||
this.clear_pulldowns();
|
||||
|
||||
// if there is no focused editor anymore, release the iframe of the previously focused editor
|
||||
if ( editor == null )
|
||||
this.focused_editor.release_iframe();
|
||||
|
||||
// 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() ) {
|
||||
signal( this, "note_removed", this.focused_editor.id );
|
||||
|
@ -1024,6 +1028,7 @@ Wiki.prototype.editor_focused = function ( editor, synchronous ) {
|
|||
|
||||
this.focused_editor = editor;
|
||||
this.update_toolbar();
|
||||
|
||||
}
|
||||
|
||||
Wiki.prototype.make_byline = function ( username, creation, note_id ) {
|
||||
|
@ -1431,7 +1436,7 @@ Wiki.prototype.hide_editor = function ( event, editor ) {
|
|||
if ( editor == this.focused_editor )
|
||||
this.focused_editor = null;
|
||||
if ( this.focused_editor )
|
||||
this.focused_editor.blur();
|
||||
this.editor_focused( null );
|
||||
|
||||
if ( !editor ) {
|
||||
editor = this.focused_editor;
|
||||
|
@ -1470,7 +1475,7 @@ Wiki.prototype.delete_editor = function ( event, editor ) {
|
|||
this.clear_pulldowns();
|
||||
|
||||
if ( this.focused_editor )
|
||||
this.focused_editor.blur();
|
||||
this.editor_focused( null );
|
||||
|
||||
if ( !editor ) {
|
||||
editor = this.focused_editor;
|
||||
|
|
Reference in New Issue