A non-ideal solution, but now repositioning iframe periodically after a resize in case the div its tracking has moved.
This commit is contained in:
parent
4dbef86061
commit
941feb1dbf
|
@ -239,14 +239,6 @@ Editor.prototype.claim_iframe = function ( position_after ) {
|
||||||
if ( this.iframe )
|
if ( this.iframe )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// hack to prevent iframe from being incorrectly positioned if there is a closing (and thus
|
|
||||||
// moving) message or error box
|
|
||||||
if ( getElementsByTagAndClassName( "div", "message" ).length > 0 ||
|
|
||||||
getElementsByTagAndClassName( "div", "error" ).length > 0 ) {
|
|
||||||
setTimeout( function() { self.claim_iframe( position_after ); }, 25 );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// claim the reusable iframe for this note, stealing it from the note that's using it (if any)
|
// claim the reusable iframe for this note, stealing it from the note that's using it (if any)
|
||||||
this.iframe = Editor.shared_iframe.iframe;
|
this.iframe = Editor.shared_iframe.iframe;
|
||||||
this.iframe.setAttribute( "id", iframe_id );
|
this.iframe.setAttribute( "id", iframe_id );
|
||||||
|
@ -260,14 +252,6 @@ Editor.prototype.claim_iframe = function ( position_after ) {
|
||||||
this.note_controls = getElement( "note_controls_" + this.id );
|
this.note_controls = getElement( "note_controls_" + this.id );
|
||||||
this.connect_note_controls( true );
|
this.connect_note_controls( true );
|
||||||
|
|
||||||
// give the invisible iframe the exact same position as the div it will replace. subtract the
|
|
||||||
// position of the center_content_area container, which is relatively positioned
|
|
||||||
position = getElementPosition( this.div );
|
|
||||||
container_position = getElementPosition( "center_content_area" );
|
|
||||||
position.x -= container_position.x;
|
|
||||||
position.y -= container_position.y;
|
|
||||||
setElementPosition( this.iframe, position );
|
|
||||||
|
|
||||||
// give the iframe the note's current contents and then resize it based on the size of the div
|
// give the iframe the note's current contents and then resize it based on the size of the div
|
||||||
var range = this.add_selection_bookmark();
|
var range = this.add_selection_bookmark();
|
||||||
this.set_iframe_contents( this.contents() );
|
this.set_iframe_contents( this.contents() );
|
||||||
|
@ -656,6 +640,27 @@ Editor.prototype.resize = function ( get_height_from_div ) {
|
||||||
size = { "h": height };
|
size = { "h": height };
|
||||||
setElementDimensions( this.iframe, size );
|
setElementDimensions( this.iframe, size );
|
||||||
setElementDimensions( this.div, size );
|
setElementDimensions( this.div, size );
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
this.reposition();
|
||||||
|
}
|
||||||
|
|
||||||
|
Editor.prototype.reposition = function ( repeat ) {
|
||||||
|
// give the iframe the exact same position as the div it replaces. subtract the position of the
|
||||||
|
// center_content_area container, which is relatively positioned
|
||||||
|
var position = getElementPosition( this.div );
|
||||||
|
var orig_position = getElementPosition( this.iframe );
|
||||||
|
if ( repeat && position.x == orig_position.x && position.y == orig_position.y )
|
||||||
|
return;
|
||||||
|
|
||||||
|
var container_position = getElementPosition( "center_content_area" );
|
||||||
|
position.x -= container_position.x;
|
||||||
|
position.y -= container_position.y;
|
||||||
|
|
||||||
|
setElementPosition( this.iframe, position );
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
setTimeout( function () { self.reposition( true ); }, 50 );
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor.prototype.key_pressed = function ( event ) {
|
Editor.prototype.key_pressed = function ( event ) {
|
||||||
|
|
|
@ -2522,6 +2522,7 @@ Wiki.prototype.move_current_notebook_down = function ( event ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Wiki.prototype.display_message = function ( text, nodes, position_after ) {
|
Wiki.prototype.display_message = function ( text, nodes, position_after ) {
|
||||||
|
var self = this;
|
||||||
this.clear_messages();
|
this.clear_messages();
|
||||||
this.clear_pulldowns();
|
this.clear_pulldowns();
|
||||||
|
|
||||||
|
@ -2536,7 +2537,7 @@ Wiki.prototype.display_message = function ( text, nodes, position_after ) {
|
||||||
"title": "dismiss this message"
|
"title": "dismiss this message"
|
||||||
} );
|
} );
|
||||||
appendChildNodes( inner_div, ok_button );
|
appendChildNodes( inner_div, ok_button );
|
||||||
connect( ok_button, "onclick", this.clear_messages );
|
connect( ok_button, "onclick", function () { self.clear_messages(); } );
|
||||||
|
|
||||||
var div = DIV( { "class": "message" }, inner_div );
|
var div = DIV( { "class": "message" }, inner_div );
|
||||||
div.nodes = nodes;
|
div.nodes = nodes;
|
||||||
|
@ -2550,11 +2551,13 @@ Wiki.prototype.display_message = function ( text, nodes, position_after ) {
|
||||||
insertSiblingNodesAfter( "notes_top", div );
|
insertSiblingNodesAfter( "notes_top", div );
|
||||||
|
|
||||||
this.scroll_to( div );
|
this.scroll_to( div );
|
||||||
|
this.resize_editor();
|
||||||
|
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wiki.prototype.display_error = function ( text, nodes, position_after ) {
|
Wiki.prototype.display_error = function ( text, nodes, position_after ) {
|
||||||
|
var self = this;
|
||||||
this.clear_messages();
|
this.clear_messages();
|
||||||
this.clear_pulldowns();
|
this.clear_pulldowns();
|
||||||
|
|
||||||
|
@ -2569,7 +2572,7 @@ Wiki.prototype.display_error = function ( text, nodes, position_after ) {
|
||||||
"title": "dismiss this message"
|
"title": "dismiss this message"
|
||||||
} );
|
} );
|
||||||
appendChildNodes( inner_div, ok_button );
|
appendChildNodes( inner_div, ok_button );
|
||||||
connect( ok_button, "onclick", this.clear_messages );
|
connect( ok_button, "onclick", function () { self.clear_messages(); } );
|
||||||
|
|
||||||
var div = DIV( { "class": "error" }, inner_div );
|
var div = DIV( { "class": "error" }, inner_div );
|
||||||
div.nodes = nodes;
|
div.nodes = nodes;
|
||||||
|
@ -2583,6 +2586,7 @@ Wiki.prototype.display_error = function ( text, nodes, position_after ) {
|
||||||
insertSiblingNodesAfter( "notes_top", div );
|
insertSiblingNodesAfter( "notes_top", div );
|
||||||
|
|
||||||
this.scroll_to( div );
|
this.scroll_to( div );
|
||||||
|
this.resize_editor();
|
||||||
|
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
@ -2596,10 +2600,11 @@ Wiki.prototype.scroll_to = function ( node ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Wiki.prototype.clear_messages = function () {
|
Wiki.prototype.clear_messages = function () {
|
||||||
var results = getElementsByTagAndClassName( "div", "message" );
|
var message_results = getElementsByTagAndClassName( "div", "message" );
|
||||||
|
var error_results = getElementsByTagAndClassName( "div", "error" );
|
||||||
|
|
||||||
for ( var i in results ) {
|
for ( var i in message_results ) {
|
||||||
var result = results[ i ];
|
var result = message_results[ i ];
|
||||||
|
|
||||||
// only close the message if it's been open at least a quarter second
|
// only close the message if it's been open at least a quarter second
|
||||||
if ( new Date() - result.init_time < 250 )
|
if ( new Date() - result.init_time < 250 )
|
||||||
|
@ -2614,10 +2619,8 @@ Wiki.prototype.clear_messages = function () {
|
||||||
} } );
|
} } );
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = getElementsByTagAndClassName( "div", "error" );
|
for ( var i in error_results ) {
|
||||||
|
var result = error_results[ i ];
|
||||||
for ( var i in results ) {
|
|
||||||
var result = results[ i ];
|
|
||||||
|
|
||||||
if ( new Date() - result.init_time < 250 )
|
if ( new Date() - result.init_time < 250 )
|
||||||
continue
|
continue
|
||||||
|
@ -2628,6 +2631,9 @@ Wiki.prototype.clear_messages = function () {
|
||||||
} catch ( e ) { }
|
} catch ( e ) { }
|
||||||
} } );
|
} } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( message_results.length || error_results.length )
|
||||||
|
this.resize_editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
Wiki.prototype.clear_pulldowns = function ( ephemeral_only ) {
|
Wiki.prototype.clear_pulldowns = function ( ephemeral_only ) {
|
||||||
|
|
Reference in New Issue