From 4d7e467780ce2a08542b635e7491e15e8a366a13 Mon Sep 17 00:00:00 2001 From: Rob Moen Date: Wed, 20 Jun 2012 22:29:50 -0700 Subject: [PATCH] Properly hide and show inspectors. Change-Id: I1de85c8364df67bf547b4fec498829e61f7ab07f --- modules/ve/ui/ve.ui.Context.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/modules/ve/ui/ve.ui.Context.js b/modules/ve/ui/ve.ui.Context.js index d19f3a9ddb..7a9cc8d43f 100644 --- a/modules/ve/ui/ve.ui.Context.js +++ b/modules/ve/ui/ve.ui.Context.js @@ -179,15 +179,15 @@ ve.ui.Context.prototype.openInspector = function( name ) { throw 'Missing inspector error. Can not open nonexistent inspector: ' + name; } this.inspectors[name].open(); + this.resizeInspectorFrame( this.inspectors[name] ); this.positionOverlay( this.$inspectors ); - this.$inspectors.show(); this.inspector = name; }; ve.ui.Context.prototype.closeInspector = function( accept ) { if ( this.inspector ) { this.inspectors[this.inspector].close( accept ); - this.$inspectors.hide(); + this.hideInspectorFrame(); this.inspector = null; } }; @@ -214,7 +214,7 @@ ve.ui.Context.prototype.addInspector = function( name, inspector ) { 'rel': 'stylesheet', 'type': 'text/css', 'href': ve.ui.getStylesheetPath() + 've.ui.Inspector.css' - }).on( 'load', tweakIframeDimensions ); + }); var inspectorDoc = this.$inspectors.prop( 'contentWindow' ).document; var inspectorContent = '
'; @@ -222,22 +222,28 @@ ve.ui.Context.prototype.addInspector = function( name, inspector ) { inspectorDoc.write( inspectorContent ); inspectorDoc.close(); - $( 'head', inspectorDoc).append( $styleLink ); + $( 'head', inspectorDoc ).append( $styleLink ); $( '#ve-inspector-wrapper', inspectorDoc ).append( inspector.$ ); $( 'body', inspectorDoc ).css( { 'padding': '0px 5px 10px 5px', 'margin': 0 } ); + this.hideInspectorFrame(); +}; - // apply the dimensions of the inspector to the iframe, may need to be moved to open inspector - function tweakIframeDimensions() { - _this.$inspectors.css( { - 'width': inspector.$.outerWidth( true ) + 10, - 'height': inspector.$.outerHeight( true ) + 10 - } ); - } +ve.ui.Context.prototype.hideInspectorFrame = function ( inspector ) { + this.$inspectors.css({ + 'width': 0, + 'height': 0 + }); +}; +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 ) {