4 * <li>win.kill() で別窓を閉じる
\r
5 * <li>win.kill() 以外で閉じられた場合、ユーザーの[x]ボタン操作や、他のscriptによって閉じられた場合、X.Event.UNLOAD イベントを発して自身を kill する。
\r
9 * <dt>X.Event.UNLOAD<dd>win.kill() 以外で閉じられた場合に通知、自身はkillする
\r
10 * <dt>X.Event.ERROR<dd>他ドメインに遷移した等の理由で win.write() による書き換えに失敗した場合
\r
13 * @example // 別ページの表示
\r
14 * win = X.Util.Window( { url : 'other.html' } );
\r
16 * win = X.Util.Window( { html : '<p>Hello,world!</p>' } );
\r
20 * @alias X.Util.Window
\r
21 * @class Window 別窓(別タブ)
\r
22 * @extends {EventDispatcher}
\r
24 var X_Window = X[ 'Util' ][ 'Window' ] = X_EventDispatcher[ 'inherits' ](
\r
27 /** @lends X.Util.Window.prototype */
\r
37 'Constructor' : function( options ){
\r
38 var url = options[ 'url' ],
\r
39 page = window.open( url || ''/* 'about:blank' */, options[ 'name' ] || '', options[ 'params' ] || '' ),
\r
40 html = options[ 'html' ],
\r
41 doc = X_Script_try( X_Object_find, [ page, 'document' ] );
\r
43 X_Pair_create( this, page );
\r
46 this[ 'write' ]( html );
\r
49 X_ViewPort[ 'listenOnce' ]( X_EVENT_UNLOAD, this, X_Util_Window_handleEvent );
\r
50 this[ 'listenOnce' ]( [ X_EVENT_UNLOAD, X_EVENT_KILL_INSTANCE ], X_Util_Window_handleEvent );
\r
52 this._timerID = X_Timer_add( options[ 'interval' ] || 500, 0, this, X_Util_Window_onTimer );
\r
58 * <li>ユーザーの[x]クリック操作等
\r
59 * <li>別窓内の script, または他の script
\r
63 'closed' : function(){
\r
64 return X_Script_try( X_Object_find, [ X_Pair_get( this ), 'closed' ] );
\r
69 * @param {string=} opt_html html文字列
\r
70 * @return {Window} チェーンメソッド
\r
72 'write' : function( opt_html ){
\r
73 var doc = X_Script_try( X_Object_find, [ X_Pair_get( this ), 'document' ] );
\r
77 doc.write( opt_html || '' ); // TODO 無毒化
\r
80 this[ 'asyncDispatch' ]( X_EVENT_ERROR );
\r
91 function X_Util_Window_onTimer( e ){
\r
92 if( this[ 'closed' ]() ){
\r
93 this[ 'asyncDispatch' ]( X_EVENT_UNLOAD );
\r
94 delete this._timerID;
\r
95 return X_CALLBACK_UN_LISTEN;
\r
99 function X_Util_Window_handleEvent( e ){
\r
100 var page = X_Pair_get( this );
\r
103 case X_EVENT_UNLOAD :
\r
107 case X_EVENT_KILL_INSTANCE :
\r
108 if( page && !this[ 'closed' ]() ){
\r
109 if( 9 < X_UA[ 'IEHost' ] ){
\r
112 page.open( 'about:blank', '_self' ).close();
\r
114 X_Pair_release( this, page );
\r
116 this._timerID && X_Timer_remove( this._timerID );
\r
117 X_ViewPort[ 'unlisten' ]( X_EVENT_UNLOAD, this, X_Util_Window_handleEvent );
\r