Properly hide and show inspectors.

Change-Id: I1de85c8364df67bf547b4fec498829e61f7ab07f
This commit is contained in:
Rob Moen 2012-06-20 22:29:50 -07:00
parent 48bba8fcb8
commit 4d7e467780

View file

@ -179,15 +179,15 @@ ve.ui.Context.prototype.openInspector = function( name ) {
throw 'Missing inspector error. Can not open nonexistent inspector: ' + name; throw 'Missing inspector error. Can not open nonexistent inspector: ' + name;
} }
this.inspectors[name].open(); this.inspectors[name].open();
this.resizeInspectorFrame( this.inspectors[name] );
this.positionOverlay( this.$inspectors ); this.positionOverlay( this.$inspectors );
this.$inspectors.show();
this.inspector = name; this.inspector = name;
}; };
ve.ui.Context.prototype.closeInspector = function( accept ) { ve.ui.Context.prototype.closeInspector = function( accept ) {
if ( this.inspector ) { if ( this.inspector ) {
this.inspectors[this.inspector].close( accept ); this.inspectors[this.inspector].close( accept );
this.$inspectors.hide(); this.hideInspectorFrame();
this.inspector = null; this.inspector = null;
} }
}; };
@ -214,7 +214,7 @@ ve.ui.Context.prototype.addInspector = function( name, inspector ) {
'rel': 'stylesheet', 'rel': 'stylesheet',
'type': 'text/css', 'type': 'text/css',
'href': ve.ui.getStylesheetPath() + 've.ui.Inspector.css' 'href': ve.ui.getStylesheetPath() + 've.ui.Inspector.css'
}).on( 'load', tweakIframeDimensions ); });
var inspectorDoc = this.$inspectors.prop( 'contentWindow' ).document; var inspectorDoc = this.$inspectors.prop( 'contentWindow' ).document;
var inspectorContent = '<div id="ve-inspector-wrapper"></div>'; var inspectorContent = '<div id="ve-inspector-wrapper"></div>';
@ -222,22 +222,28 @@ ve.ui.Context.prototype.addInspector = function( name, inspector ) {
inspectorDoc.write( inspectorContent ); inspectorDoc.write( inspectorContent );
inspectorDoc.close(); inspectorDoc.close();
$( 'head', inspectorDoc).append( $styleLink ); $( 'head', inspectorDoc ).append( $styleLink );
$( '#ve-inspector-wrapper', inspectorDoc ).append( inspector.$ ); $( '#ve-inspector-wrapper', inspectorDoc ).append( inspector.$ );
$( 'body', inspectorDoc ).css( { $( 'body', inspectorDoc ).css( {
'padding': '0px 5px 10px 5px', 'padding': '0px 5px 10px 5px',
'margin': 0 'margin': 0
} ); } );
this.hideInspectorFrame();
};
// apply the dimensions of the inspector to the iframe, may need to be moved to open inspector ve.ui.Context.prototype.hideInspectorFrame = function ( inspector ) {
function tweakIframeDimensions() { this.$inspectors.css({
_this.$inspectors.css( { 'width': 0,
'width': inspector.$.outerWidth( true ) + 10, 'height': 0
'height': inspector.$.outerHeight( true ) + 10 });
} ); };
}
ve.ui.Context.prototype.resizeInspectorFrame = function( inspector ){
this.$inspectors.css( {
'width': inspector.$.outerWidth( true ) + 10,
'height': inspector.$.outerHeight( true ) + 10
} );
}; };
ve.ui.Context.prototype.removeInspector = function( name ) { ve.ui.Context.prototype.removeInspector = function( name ) {