X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F05_util%2F01_XNinjaIframe.js;h=097335064508d21a132806b57d624d26541e6e1c;hb=d46b3c051de91e296153c953c17d3ac5032ef1b7;hp=93f62f16acb330659af036be9817666c95f532b4;hpb=dd02887497fa95f13d112b7fc2e5e7aefd0ffb08;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/05_util/01_XNinjaIframe.js b/0.6.x/js/05_util/01_XNinjaIframe.js index 93f62f1..0973350 100644 --- a/0.6.x/js/05_util/01_XNinjaIframe.js +++ b/0.6.x/js/05_util/01_XNinjaIframe.js @@ -3,6 +3,7 @@ * 孤立するとウィンドウ オブジェクトのプロパティが消去される */ +// TODO Node.inherits X.Util.NinjaIframe = X.EventDispatcher.inherits( 'NinjaIframe', { @@ -12,7 +13,7 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits( _iwin : null, - _html : '', + _contentHTML : '', _name : '', _ready : false, @@ -26,14 +27,15 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits( { className : 'hidden-iframe', scrolling : 'no', + allowtransparency : 'no', frameborder : 0, - allowtransparency : 'no', + tabindex : -1, name : this._name, id : this._name } ); - X.ViewPort.listenOnce( X.Event.AFTER_UPDATE, this ); + X_ViewPort.listenOnce( X.Event.AFTER_UPDATE, this ); // http://nanto.asablo.jp/blog/2011/12/08/6237308 // IE 6/7 で文書間通信を実現するための一案 @@ -45,35 +47,34 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits( this.xnodeIframe.css( { position : 'absolute' } ); }; - if( html ) this._html = html; + if( html ) this._contentHTML = html; }, handleEvent : function( e ){ - var raw = this.xnodeIframe._rawObject, - html, idoc; + var raw = this.xnodeIframe._rawObject; switch( e.type ){ case X.Event.AFTER_UPDATE : this._iwin = raw.contentWindow || ( raw.contentDocument && raw.contentDocument.parentWindow ) || window.frames[ this._name ]; // http://d.hatena.ne.jp/NeoCat/20080921/1221940658 // こちらに名前をsetしないとtargetが動作しない - this._iwin.name = this._name; + if( X_UA.IE ) this._iwin.name = this._name; - this.xnodeIframe.listen( X_UA.IE < 9 ? [ 'readystatechange', 'error' ] : [ 'load', 'error' ], this ); + this.xnodeIframe.listen( [ X_UA.IE < 9 ? 'readystatechange' : 'load', 'error' ], this ); if( !( X_UA.IE < 9 ) ){ - this._html && X_Util_NinjaIframe_writeToIframe( this ); + this._contentHTML && X_Util_NinjaIframe_writeToIframe( this ); this._ready = true; return; }; case 'readystatechange' : - if( ( raw.readyState !== 'complete' && raw.readyState !== 'loaded' ) ) return X.Callback.STOP_PROPAGATION; + if( ( raw.readyState !== 'complete' && raw.readyState !== 'loaded' ) ) break; // ie9- if( !this._ready ){ - this._html && X_Util_NinjaIframe_writeToIframe( this ); + this._contentHTML && X_Util_NinjaIframe_writeToIframe( this ); this._ready = true; - return; + break; }; // onload case 'load' : @@ -88,14 +89,14 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits( return X.Callback.STOP_PROPAGATION; }, - refresh : function( opt_html ){ + refresh : function( opt_contentHTML ){ var raw = this.xnodeIframe._rawObject, idoc; this._ready = false; if( !this._iwin ){ - this._html = opt_html; + this._contentHTML = opt_contentHTML; return this; }; @@ -105,9 +106,9 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits( this._iwin.location.reload(); }; - if( !opt_html ) return this; + if( !opt_contentHTML ) return this; - this._html = opt_html; + this._contentHTML = opt_contentHTML; X_UA.IE < 9 || X_Util_NinjaIframe_writeToIframe( this ); return this; @@ -125,9 +126,9 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits( function X_Util_NinjaIframe_writeToIframe( that ){ var raw = that.xnodeIframe._rawObject, idoc = raw.contentDocument || that._iwin.document, - html = that._html; + html = that._contentHTML; - delete that._html; + delete that._contentHTML; that._ready = true; idoc.open();