* @memberof X.EventDispatcher\r
*/\r
\r
+ // TODO _rawObjectType EventTarget, XHR, Silverlight, ...\r
/**\r
* イベントリスナをイベント名(string)や数値(1~,フレームワーク内で定義)をキーとするArrayで記憶します。\r
* Arrayには、{k:種類,x:コンテキスト(thisObject),f:関数,s:サプリメントする引数の配列} というハッシュ、または関数が蓄えられています。\r
function X_EventDispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){\r
var list = this._listeners,\r
i, raw, add, f;\r
+\r
+ if( !type ) return this;\r
\r
if( this._dispatching ){\r
if( !this._reserves ) this._reserves = [];\r
raw = this._rawObject || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this );\r
add = raw && ( !list || !list[ type ] ) && X.Type.isString( type );\r
\r
- if( this.listening( type, opt_arg1, opt_arg2, opt_arg3 ) ) return this;\r
+ if( this.listening( type, opt_arg1 || this, opt_arg2, opt_arg3 ) ) return this;\r
\r
if( !list ) list = this._listeners = {};\r
if( !( list = list[ type ] ) ) list = this._listeners[ type ] = [];\r
X_EventDispatcher_lock = false;\r
};\r
\r
+// TODO this.listen(type) は this リスナの登録なのに、this.unlisten(type)は全てのtypeの削除、と不一致\r
+\r
/**\r
* \r
* @this {X.EventDispatcher}\r
X_Dom_detectFontSize = !( X_UA.IE < 9 || X_UA.iOS ) && function(){
var size = X_Node_fontSizeNode._rawObject.offsetHeight;
if( X_ViewPort_baseFontSize !== size ){
- X_ViewPort_baseFontSize && X_ViewPort.asyncDispatch( { type : X.Event.BASE_FONT_RESIZED, fontSize : size, w : X_ViewPort_width, h : X_ViewPort_height } );
+ X_ViewPort_baseFontSize && X_ViewPort.asyncDispatch( X.Event.BASE_FONT_RESIZED );
X_ViewPort_baseFontSize = size;
};
},
},
X_ViewPort_document = new X.EventDispatcher( document ),
+
+ X_ViewPort_postMessageAccessKey = Math.random() * 10000 | 0,
X_ViewPort = X_Class_override(
new X.EventDispatcher( window ),
var href;
switch( e.type ){
case 'beforeunload' :
-
// ie では a href="javascript" な要素でも beforeunload が起こる
href = e.target && e.target.attr && e.target.attr( 'href' );
if( href && href.indexOf && href.indexOf( 'javascript:' ) === 0 ) return X.Callback.PREVENT_DEFAULT | X.Callback.STOP_PROPAGATION;
return X_ViewPort.dispatch( X.Event.BEFORE_UNLOAD );
+
case 'unload' :
X_ViewPort.dispatch( X.Event.UNLOAD );
+ //alert('unload');
+ X_ViewPort_document.kill();
+ this.kill();
- X_ViewPort.unlisten();
- X_ViewPort_document.unlisten();
- X_Node__actualRemove( X_Node_html, true );
+ //X_System.dispatch( X.Event.SHUT_DOWN );
break;
+
case 'visibilitychange' :
- X_ViewPort.dispatch( { type : ( X_ViewPort_active = document[ 'hidden' ] ) ? X.Event.VIEW_DEACTIVATE : X.Event.VIEW_ACTIVATE } );
+ X_ViewPort.asyncDispatch( ( X_ViewPort_active = document[ 'hidden' ] ) ? X.Event.VIEW_DEACTIVATE : X.Event.VIEW_ACTIVATE );
break;
case 'webkitvisibilitychange' :
- X_ViewPort.dispatch( { type : ( X_ViewPort_active = document[ 'webkitHidden' ] ) ? X.Event.VIEW_DEACTIVATE : X.Event.VIEW_ACTIVATE } );
+ X_ViewPort.asyncDispatch( ( X_ViewPort_active = document[ 'webkitHidden' ] ) ? X.Event.VIEW_DEACTIVATE : X.Event.VIEW_ACTIVATE );
break;
+
case 'pageshow' :
case 'focus' :
- X_ViewPort_active = true;
- X_ViewPort.dispatch( X.Event.VIEW_ACTIVATE );
+ if( !X_ViewPort_active ){
+ X_ViewPort_active = true;
+ X_ViewPort.asyncDispatch( X.Event.VIEW_ACTIVATE );
+ };
break;
+
case 'pagehide' :
case 'blur' :
- X_ViewPort_active = false;
- X_ViewPort.dispatch( X.Event.VIEW_DEACTIVATE );
+ if( X_ViewPort_active ){
+ X_ViewPort_active = false;
+ X_ViewPort.asyncDispatch( X.Event.VIEW_DEACTIVATE );
+ };
+ break;
+
+ // TODO
+ case 'message' :
+ if( e.origin !== X.URL.BASE_URL ){
+
+ } else {
+ e.data;
+ };
break;
};
}
/*
* X.Event.XDOM_READY 以後に listen した場合の対策
*/
- X_ViewPort.asyncDispatch( { type : type, w : X_ViewPort_width, h : X_ViewPort_height } );
+ X_ViewPort.asyncDispatch( type );
};
+ // ie8-では keydown -> documentへ
type && arg1 && X_ViewPort.listen( type, arg1, arg2, arg3 );
return X.ViewPort;
},
/*
* X.Event.XDOM_READY 以後に listen した場合の対策
*/
- X_ViewPort.asyncDispatch( { type : type, w : X_ViewPort_width, h : X_ViewPort_height } );
+ X_ViewPort.asyncDispatch( type );
};
type && arg1 && X_ViewPort.listenOnce( type, arg1, arg2, arg3 );
return X.ViewPort;
//http://onozaty.hatenablog.com/entry/20060803/p1
// Safari2.0.4では標準・互換どちらも document.body
- X_Node_body._updateTimerID && X_Node_startUpdate();
+ X_Node_updateTimerID && X_Node_startUpdate();
/*X_UA.Opera ?
( document.documentElement && document.documentElement.clientWidth ?
new Function( 'return[document.documentElement.clientWidth,document.documentElement.clientHeight]' ) :
getScrollPosition :
window.pageXOffset !== undefined ?
( function(){
- X_Node_body._updateTimerID && X_Node_startUpdate();
+ X_Node_updateTimerID && X_Node_startUpdate();
return[ window.pageXOffset, window.pageYOffset ];
} ) :
window.scrollLeft !== undefined ?
( function(){
- X_Node_body._updateTimerID && X_Node_startUpdate();
+ X_Node_updateTimerID && X_Node_startUpdate();
return[ window.scrollLeft, window.scrollTop ];
} ) :
( function(){
- X_Node_body._updateTimerID && X_Node_startUpdate();
+ X_Node_updateTimerID && X_Node_startUpdate();
// body は Safari2-
return[ X_ViewPort_rootElement.scrollLeft || document.body.scrollLeft, X_ViewPort_rootElement.scrollTop || document.body.scrollTop ];
} ),
},
getBaseFontSize : function(){
- if( X_Node_body._updateTimerID ){
+ if( X_Node_updateTimerID ){
X_Node_startUpdate();
return X_ViewPort_baseFontSize = X_Node_fontSizeNode._rawObject.offsetHeight;
};
size = X_Node_fontSizeNode._rawObject.offsetHeight;
if( X_ViewPort_baseFontSize !== size ){
- X_ViewPort_baseFontSize && X_ViewPort.asyncDispatch( { type : X.Event.BASE_FONT_RESIZED, fontSize : size, w : X_ViewPort_width, h : X_ViewPort_height } );
+ X_ViewPort_baseFontSize && X_ViewPort.asyncDispatch( X.Event.BASE_FONT_RESIZED );
X_ViewPort_baseFontSize = size;
};
} else {
console.log( '-- detectFinishResizing : ' + X_Timer_now() );
- X_ViewPort.asyncDispatch( { type : X.Event.VIEW_RESIZED, fontSize : X_ViewPort_baseFontSize, w : X_ViewPort_width, h : X_ViewPort_height } );
+ X_ViewPort.asyncDispatch( X.Event.VIEW_RESIZED );
X_ViewPort_lock = false;
if( X_ViewPort_orientationFlag ){
X_ViewPort_orientationFlag = false;
//
if( X_Dom_orientationchange ){
- X_ViewPort.listen( 'orientationchange', X_Dom_orientationchange );
+ X_EventDispatcher_systemListen( X_ViewPort, 'orientationchange', X_Dom_orientationchange );
};
if( X_Dom_detectFontSize ){
- X_ViewPort.listen( 'resize', X_ViewPort_resize );
+ X_EventDispatcher_systemListen( X_ViewPort, 'resize', X_ViewPort_resize );
X.Timer.add( 333, X_Dom_detectFontSize );
} else {
X.Timer.add( 333, X_ViewPort_resize );
console.log( X_ViewPort.asyncDispatch( X_TEMP.SYSTEM_EVENT_PRE_INIT ) );
- X_ViewPort
- .listen( 'beforeunload', X_ViewPort )
- .listenOnce( 'unload', X_ViewPort );
+
+ X_EventDispatcher_systemListen( X_ViewPort, [ 'beforeunload', 'unload' ] );
//ブラウザの戻るボタンで戻ったときに呼ばれるイベントとかキャッシュとかそこらへんのこと
//http://d.hatena.ne.jp/koumiya/20080916/1221580149
if( document[ 'hidden' ] !== undefined ) {// iOS 7+
- X_ViewPort_document.listen( 'visibilitychange', X_ViewPort );
+ X_EventDispatcher_systemListen( X_ViewPort_document, 'visibilitychange', X_ViewPort );
} else
if( document[ 'webkitHidden' ] !== undefined ) {
- X_ViewPort_document.listen( 'webkitvisibilitychange', X_ViewPort );
+ X_EventDispatcher_systemListen( X_ViewPort_document, 'webkitvisibilitychange', X_ViewPort );
} else
if( X_UA.iOS && window[ 'onpageshow' ] !== undefined ) {
- X_ViewPort.listen( 'pageshow', X_ViewPort )
- .listen( 'pagehide', X_ViewPort );
+ X_EventDispatcher_systemListen( X_ViewPort, [ 'pageshow', 'pagehide' ] );
} else {
- X_ViewPort.listen( 'focus', X_ViewPort )
- .listen( 'blur', X_ViewPort );
+ X_EventDispatcher_systemListen( X_ViewPort, [ 'focus', 'blur' ] );
};
return X_Callback_UN_LISTEN;
CHILD_IS_DIRTY : 1,\r
ID : 2, // width, height, x, y\r
CONTENT : 4, // width, height, x, y textNode の内容\r
- CLASSNAME : 8, // _getCharSize, width, height, x, y\r
- ATTR : 16, // _getCharSize, width, height, x, y\r
- CSS : 32, // _getCharSize, width, height, x, y\r
+ CLASSNAME : 8, // X_Node_CSS_getCharSize, width, height, x, y\r
+ ATTR : 16, // X_Node_CSS_getCharSize, width, height, x, y\r
+ CSS : 32, // X_Node_CSS_getCharSize, width, height, x, y\r
IE_FILTER : X_UA.IE < 9 && !X_UA.MacIE ? 64 : 0,\r
UNKNOWN_TAG_FIX : 128,\r
IE4_TEXTNODE_FIX : 256\r
X_Node_State = {\r
DESTROYED : 0,\r
EXIST : 1, // XNODE_EXIDT, ELEMENT_EXIST\r
- BELONG_TREE : 2, // HAS_PARENT, BELONG_TREE_XNODE, BELONG_TREE_ELEMENT\r
- DISPLAY_NONE : 4, // VISIVILITY_HIDDEN & DISPALY_NONE\r
+ BELONG_TREE : 2, // HAS_PARENT, HAS_PARENT_ACTUAL, BELONG_TREE, BELONG_TREE_ACTUAL\r
+ DISPLAY_NONE : 4, // VISIVILITY_HIDDEN(opacity0), DISPALY_NONE\r
DISPLAY_BLOCK : 8, // remove\r
DISPLAY_INLINE : 16,// remove\r
POSITION_ABSOLUTE : 32,\r
\r
X_Node_useDocumentFragment = document.createDocumentFragment && ( !X_UA.IE || 5.5 <= X_UA.IE ) && document.createDocumentFragment(),\r
\r
- X_Node_newByTag = false,\r
+ X_Node_newByTag = false,\r
\r
- X_Node_newByText = false,\r
+ X_Node_newByText = false,\r
\r
- X_Node_outerXNode = null,\r
+ X_Node_outerXNode = null,\r
+ \r
+ X_Node_updateTimerID = 0,\r
/*\r
* Node( rawElement | rawTextnode | htmlString | textString )\r
*/ \r
*/\r
\r
function X_Node_reserveUpdate(){\r
- var root = X_Node_body;\r
- if( root && !root._updateTimerID ) root._updateTimerID = X.Timer.requestFrame( X_Node_startUpdate );\r
+ if( !X_Node_updateTimerID ) X_Node_updateTimerID = X.Timer.requestFrame( X_Node_startUpdate );\r
};\r
\r
function X_Node_startUpdate(){\r
var removal, i, xnode, tmp;\r
- if( X_ViewPort_readyState < X_TEMP.SYSTEM_EVENT_INIT ){\r
- return;\r
- };\r
- if( X_Node_body._updateTimerID ){\r
- X.Timer.cancelFrame( X_Node_body._updateTimerID );\r
- X_Node_body._updateTimerID = 0;\r
- } else {\r
+ \r
+ if( !X_Node_updateTimerID || X_ViewPort_readyState < X_TEMP.SYSTEM_EVENT_INIT ){\r
return;\r
};\r
+\r
+ X.Timer.cancelFrame( X_Node_updateTimerID );\r
+ X_Node_updateTimerID = 0;\r
+\r
+\r
// このイベントでサイズを取ると無限ループに\r
// X_ViewPort._listeners && X_ViewPort._listeners[ X.Event.BEFORE_UPDATE ] && X_ViewPort.dispatch( X.Dom.Event.BEFORE_UPDATE );\r
\r
frg.appendChild( X_Node__actualCreate( xnodes[ i ], true ) );\r
};\r
elm.appendChild( frg );\r
- for( i = 0; i < l; ++i ){\r
- X_Node__actualCreate( xnodes[ i ], true );\r
- };\r
} else {*/\r
for( ; l; ){\r
next = X_Node__commitUpdate( xnodes[ --l ], elm, next );\r
return;\r
};\r
};\r
+ \r
// style\r
// TODO display:none の場合、更新をスキップ\r
if( that._dirty & X_Node_Dirty.CSS ){\r
for( k in attrs ){\r
( v = attrs[ k ] ) === undefined ?\r
elm.removeAttribute( rename[ k ] || k ) :\r
- that._tag === 'TEXTAREA' && k === 'value' ?\r
- ( elm.innerText = v ) :\r
- elm.setAttribute( rename[ k ] || k, X_Node_Attr_noValue[ k ] ? k : v ); // TODO X_Node_Attr_noValue[ k ] ? k : v\r
+ //that._tag === 'TEXTAREA' && k === 'value' ?\r
+ // ( elm.innerText = v ) :\r
+ elm.setAttribute( rename[ k ] || k, X_Node_Attr_noValue[ k ] ? k : v );\r
};\r
delete that._newAttrs;\r
};\r
};\r
\r
if( !elm ) return;\r
- that._xnodeType === 1 && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避\r
- // elm.parentNode.tagName for ie7\r
+ that._listeners && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避\r
if( !X_UA.MacIE ){\r
+ // elm.parentNode.tagName for ie7 -> that.state & BELONG_TREE_ACTUAL\r
!isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm );\r
} else {\r
!isChild && elm.parentNode && elm.parentNode.tagName && X_TEMP._fixed_remove( elm, that );\r
};\r
\r
if( !elm ) return;\r
- that._xnodeType === 1 && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避\r
+ that._listeners && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避\r
\r
if( X_Node_Attr_HAS_VALUE[ that._tag ] && ( !that._newAttrs || !X_Object_inObject( 'value', that._newAttrs ) ) ){\r
that._attrs.value = elm.value;\r
delete that._rawObject;\r
}) :\r
(function(){});\r
+\r
+X_ViewPort.listenOnce( X.Event.UNLOAD, X_Node__actualRemove, [ X_Node_html, true ] );\r
+\r
};\r
this.buttons = e.button;\r
\r
+ this.deltaX = 0;\r
+ this.deltaY = e.wheelDelta / -120; \r
+ \r
if( type = X_Event_toPointer[ originalType ] ){\r
this.type = type;\r
this.clientX = e.clientX;\r
// this.offsetX = e.x - e.srcElement.offsetLeft; // e.x はイベント発生要素の親要素を基準にした座標。\r
// this.offsetY = e.y - e.srcElement.offsetTop; \r
//};\r
-\r
- this.deltaX = 0;\r
- this.deltaY = e.wheelDelta / -120;\r
\r
this.pointerId = 1;\r
this.radiusX = 0;\r
console.log( 'xnode.width() : no parent' );\r
return 0;\r
};\r
- X_Node_body._updateTimerID && X_Node_startUpdate();\r
+ X_Node_updateTimerID && X_Node_startUpdate();\r
if( !this._root ){\r
console.log( 'xnode.width() : not belong tree.' );\r
return 0;\r
console.log( 'xnode.height() : no parent' );\r
return 0;\r
};\r
- X_Node_body._updateTimerID && X_Node_startUpdate();\r
+ X_Node_updateTimerID && X_Node_startUpdate();\r
if( !this._root ){\r
console.log( 'xnode.height() : not belong tree.' );\r
return 0;\r
console.log( 'xnode.width() : no parent' );\r
return 0;\r
};\r
- X_Node_body._updateTimerID && X_Node_startUpdate();\r
+ X_Node_updateTimerID && X_Node_startUpdate();\r
if( !this._root ){\r
console.log( 'xnode.width() : not belong tree.' );\r
return 0;\r
console.log( 'xnode.height() : no parent' );\r
return 0;\r
};\r
- X_Node_body._updateTimerID && X_Node_startUpdate();\r
+ X_Node_updateTimerID && X_Node_startUpdate();\r
if( !this._root ){\r
console.log( 'xnode.height() : not belong tree.' );\r
return 0;\r
console.log( 'xnode.width() : no parent' );\r
return 0;\r
};\r
- X_Node_body._updateTimerID && X_Node_startUpdate();\r
+ X_Node_updateTimerID && X_Node_startUpdate();\r
if( !this._root ){\r
console.log( 'xnode.width() : not belong tree.' );\r
return 0;\r
console.log( 'xnode.height() : no parent' );\r
return 0;\r
};\r
- X_Node_body._updateTimerID && X_Node_startUpdate();\r
+ X_Node_updateTimerID && X_Node_startUpdate();\r
if( !this._root ){\r
console.log( 'xnode.height() : not belong tree.' );\r
return 0;\r
console.log( 'xnode.scrollLeft() : no parent' );\r
return 0;\r
};\r
- X_Node_body._updateTimerID && X_Node_startUpdate();\r
+ X_Node_updateTimerID && X_Node_startUpdate();\r
if( !this._root ){\r
console.log( 'xnode.scrollLeft() : not belong tree.' );\r
return 0;\r
console.log( 'xnode.scrollTop() : no parent' );\r
return 0;\r
};\r
- X_Node_body._updateTimerID && X_Node_startUpdate();\r
+ X_Node_updateTimerID && X_Node_startUpdate();\r
if( !this._root ){\r
console.log( 'xnode.scrollTop() : not belong tree.' );\r
return 0;\r
console.log( 'xnode.x() : no parent' );\r
return 0;\r
};\r
- X_Node_body._updateTimerID && X_Node_startUpdate();\r
+ X_Node_updateTimerID && X_Node_startUpdate();\r
if( !this._root ){\r
console.log( 'xnode.x() : not belong tree.' );\r
return 0;\r
console.log( 'xnode.y() : no parent' );\r
return 0;\r
};\r
- X_Node_body._updateTimerID && X_Node_startUpdate();\r
+ X_Node_updateTimerID && X_Node_startUpdate();\r
if( !this._root ){\r
console.log( 'xnode.y() : not belong tree.' );\r
return 0;\r
console.log( 'xnode.offset() : no parent' );\r
return { x : 0, y : 0 };\r
};\r
- X_Node_body._updateTimerID && X_Node_startUpdate();\r
+ X_Node_updateTimerID && X_Node_startUpdate();\r
if( !this._root ){\r
console.log( 'xnode.offset() : not belong tree.' );\r
return { x : 0, y : 0 };\r
INPUT : true,\r
TEXTAREA : true,\r
SELECT : true,\r
- BUTTON : true\r
+ BUTTON : true,\r
+ OBJECT : true,\r
+ PARAM : true // FlashVars が flash 側から書き換えられるケースがある\r
},\r
\r
X_Node_Attr_renameForTag = {};\r
if( u !== 'px' ){
this.value =
u === 'em' ?
- v / this.xnode._getCharSize() :
+ v / X_Node_CSS_getCharSize( this.xnode ) :
v / ( X_Node_CSS__UNIT_RATIO[ u ] || 1 );
};
},
u === 'px' ?
v :
( u === 'em' || ( u === '' && this.name === 'lineHeight' ) ) ?
- v * this.xnode._getCharSize() :
+ v * X_Node_CSS_getCharSize( this.xnode ) :
// u === '%'
v / ( X_Node_CSS__UNIT_RATIO[ u ] || 1 );
},
* TODO
* body に css attr がセットされた場合には X_ViewPort_baseFontSize をクリア
*/
-
-Node.prototype._getCharSize =
+var
+X_Node_CSS_getCharSize =
window.getComputedStyle ?
- (function(){
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- if( this._fontSize ) return this._fontSize;
- return this._fontSize = parseFloat( getComputedStyle( this._rawObject, null ).fontSize );
+ (function( that ){
+ X_Node_updateTimerID && X_Node_startUpdate();
+ if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+ if( that._fontSize ) return that._fontSize;
+ return that._fontSize = parseFloat( getComputedStyle( that._rawObject, null ).fontSize );
}) :
document.defaultView && document.defaultView.getComputedStyle ?
- (function(){
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- if( this._fontSize ) return this._fontSize;
- return this._fontSize = parseFloat( document.defaultView.getComputedStyle( this._rawObject, null ).fontSize );
+ (function( that ){
+ X_Node_updateTimerID && X_Node_startUpdate();
+ if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+ if( that._fontSize ) return that._fontSize;
+ return that._fontSize = parseFloat( document.defaultView.getComputedStyle( that._rawObject, null ).fontSize );
}) :
5.5 <= X_UA.IE ?
- (function(){
+ (function( that ){
var font, vu, v, u, _v;
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- if( this._fontSize ) return this._fontSize;
+ X_Node_updateTimerID && X_Node_startUpdate();
+ if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+ if( that._fontSize ) return that._fontSize;
- font = this._rawObject.currentStyle.fontSize;
- //font = this._css && this._css.fontSize || '1em';
+ font = that._rawObject.currentStyle.fontSize;
+ //font = that._css && that._css.fontSize || '1em';
vu = X_Node_CSS__splitValueAndUnit( font );
v = vu[ 0 ];
u = vu[ 1 ];
if( v === 0 ){
- if( v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return this._fontSize = v;
+ if( v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return that._fontSize = v;
} else {
- if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
+ if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return that._fontSize = v / _v;
};
switch( u ){
case 'px' :
- return this._fontSize = v;
+ return that._fontSize = v;
case 'em' :
// body まで辿ってしまった場合は?
- if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
+ if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v;
break;
case '%' :
// body まで辿ってしまった場合は?
- if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
+ if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v / 100;
};
return 0;
}) :
X_UA_DOM.W3C ?
- (function(){
+ (function( that ){
var elm, v;
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- if( this._fontSize ) return this._fontSize;
+ X_Node_updateTimerID && X_Node_startUpdate();
+ if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+ if( that._fontSize ) return that._fontSize;
- this._rawObject.appendChild( elm = document.createElement( 'span' ) );
+ that._rawObject.appendChild( elm = document.createElement( 'span' ) );
elm.style.cssText = 'display:block;position:absolute;top:0;left:0;visivility:hidden;line-height:1;height:1em;';
elm.innerHTML = 'X';
v = elm.offsetHeight;
- this._rawObject.removeChild( elm );
- return this._fontSize = v;
+ that._rawObject.removeChild( elm );
+ return that._fontSize = v;
}) :
X_UA_DOM.IE4 ?
- (function(){
+ (function( that ){
var font, vu, v, u, _v;
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- if( this._fontSize ) return this._fontSize;
+ X_Node_updateTimerID && X_Node_startUpdate();
+ if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+ if( that._fontSize ) return that._fontSize;
- if( this._css && ( font = this._css.fontSize ) ){
+ if( that._css && ( font = that._css.fontSize ) ){
vu = X_Node_CSS__splitValueAndUnit( font );
v = vu[ 0 ];
u = vu[ 1 ];
if( v === 0 ){
- if( _v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return this._fontSize = _v;
+ if( _v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return that._fontSize = _v;
} else {
- if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
+ if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return that._fontSize = v / _v;
};
} else {
v = 1;
switch( u ){
case 'px' :
- return this._fontSize = v;
+ return that._fontSize = v;
case 'em' :
// body まで辿ってしまった場合は?
- if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
+ if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v;
break;
case '%' :
// body まで辿ってしまった場合は?
- if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
+ if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v / 100;
};
return 0;
}) :
- // ie5?
- (function(){
- var elm, v;
- if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
- X_Node_body._updateTimerID && X_Node_startUpdate();
- if( this._fontSize ) return this._fontSize;
-
- elm = this._rawObject;
- elm.insertAdjacentHTML( 'BeforeEnd', '<span style="visivility:hidden;line-height:1;">X</span>' );
- elm = elm.children[ elm.children.length - 1 ];
- v = elm.offsetHeight;
- elm.outerHTML = '';
- return this._fontSize = v * 0.75;
- });
+ 0;
X.CSS = {
// TODO { a : 1, A : 2, _ : 3,,, }\r
X_Node_Selector__ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-0123456789\\',\r
X_Node_Selector__NUMBER = '+-0123456789';\r
- \r
+\r
+// XMLWrapper のために今だけ外部に公開\r
+X_NodeSelector_parse = X_Node_Selector__parse;\r
+ \r
/*\r
* セレクタ文字列の解析、但し一挙に行わず、ひと塊づつ\r
* 結合子 + 単体セレクタ( タグ,*,#,.,[],: )\r
\r
switch( e.type ){\r
case X.Event.AFTER_UPDATE :\r
- this._iwin = raw.contentWindow || raw.contentDocument && raw.contentDocument.parentWindow || window.frames[ this._name ];\r
+ this._iwin = raw.contentWindow || ( raw.contentDocument && raw.contentDocument.parentWindow ) || window.frames[ this._name ];\r
+ // http://d.hatena.ne.jp/NeoCat/20080921/1221940658\r
+ // こちらに名前をsetしないとtargetが動作しない\r
+ this._iwin.name = this._name;\r
\r
this.xnodeIframe.listen( X_UA.IE < 9 ? [ 'readystatechange', 'error' ] : [ 'load', 'error' ], this );\r
\r
var X_NET_JSONP_ACCESS_KEY = Math.random(),
- X_NET_JSONP_NinjaIframe;
+ X_NET_JSONP_NinjaIframe,
+
+ X_Net_JSONP_onloadCount;
function X_NET_JSONP_loadScriptInNinjaIframe( url ){
X_NET_JSONP_NinjaIframe || ( X_NET_JSONP_NinjaIframe = new X.Util.NinjaIframe() );
// TODO '<scr'+'ipt> 化 恐らくアンチウイルスソフトが反応しないための対策
-
+ // TODO postMessage の利用
+
+ // numonLoad
+
+ if( X_UA.Opera ){
+ html = [
+ ( window[ 'JSON' ] ? '' : '<script src="' + json2Path + '"></script>' ),
+ '<script>',
+ 'onunload=function(){im.onload=im.onerror=""};',
+ 'nw=+new Date;',
+ 'function cb(o){if(nw){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw);nw=0}}',
+ '</script>',
+ '<script id="jp"></script>',
+ '<img id="im" src="', url, '" onload="jp.src=im.src" onerror="jp.src=im.src">'
+ ];
+ X_Net_JSONP_onloadCount = 2;
+ } else
if( X_UA.IE8 ){
html = [
// http://blog.livedoor.jp/dankogai/archives/51503830.html
// Ajax - IE8にもJSON入ってます。使えるとは限らないけど
// Compatibility mode (別名Quirks mode) では、JSONオブジェクトは無効になります。iframeもだめです
- /* 以下のコードは XP ie8 では動くけど、win8 IE11(8モード)で動かない 開発の便宜を取って,setTimeout を挟む
- '<script>',
- 'function cb(o){window.parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',window.parent.JSON.stringify(o))}',
- '</script>',
- '<script src="', url, '"></script>' */
'<script id="jp"></script>',
'<script>',
+ 'onunload=function(){clearTimeout(id)};',
'nw=0;', // なぜか必要,,,
'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',parent.JSON.stringify(o),-nw)}',
'function tm(){jp.src="', url ,'";nw=+new Date}',
- 'setTimeout(tm,16);',
+ 'id=setTimeout(tm,16);',
'</script>'
+
+ /* 以下のコードは XP ie8 では動くけど、win8 IE11(8モード)で動かない 開発の便宜を取って,setTimeout を挟む
+ '<script>',
+ 'function cb(o){window.parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',window.parent.JSON.stringify(o))}',
+ '</script>',
+ '<script src="', url, '"></script>' */
];
+ X_Net_JSONP_onloadCount = 2;
} else
if( X_UA.IE9 ){
html = [
'<script id="jp"></script>',
'<script>',
+ 'onunload=function(){clearTimeout(id)};',
'function cb(o){nw-=+new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw)}',
'function tm(){jp.src="', url ,'";nw=+new Date}',
- 'setTimeout(tm,16);',
+ 'id=setTimeout(tm,16);',
'</script>'
];
+ X_Net_JSONP_onloadCount = 2;
} else
if( window[ 'JSON' ] ){
html = [
'</script>',
'<script src="', url, '"></script>'
];
+ X_Net_JSONP_onloadCount = 1;
} else
if( X_UA.IE4 || X_UA.MacIE ){
html = [
'<script id="jn"></script>',
'<script id="jp"></script>',
'<script>',
+ 'onunload=function(){clearTimeout(id)};',
'function cb(o){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw-16,', json2FileSize, ')}',
- 'function t1(){document.all.jn.src="', json2Path ,'";setTimeout("t2()",16);nw=+new Date}',
- 'setTimeout("t1()",16);',
- 'function t2(){if(window.JSON){document.all.jp.src="', url ,'"}else{setTimeout("t2()",16)}}',
+ 'function t1(){document.all.jn.src="', json2Path ,'";id=setTimeout("t2()",16);nw=+new Date}',
+ 'id=setTimeout("t1()",16);',
+ 'function t2(){if(window.JSON){document.all.jp.src="', url ,'"}else{id=setTimeout("t2()",16)}}',
'</script>'
];
+ X_Net_JSONP_onloadCount = 3;
} else
if( X_UA.IE < 8 ){ // ie5-7
html = [
'<script id="jn"></script>',
'<script id="jp"></script>',
'<script>',
+ 'onunload=function(){clearTimeout(id)};',
'function cb(o){nw-=new Date;parent.X.Net.JSONP.cb(' + X_NET_JSONP_ACCESS_KEY + ',JSON.stringify(o),-nw-16,', json2FileSize, ')}',
- 'function t1(){jn.src="', json2Path ,'";setTimeout(t2,16);nw=+new Date}',
- 'setTimeout(t1,16);',
- 'function t2(){if(window.JSON){jp.src="', url ,'"}else{setTimeout(t2,16)}}',
+ 'function t1(){jn.src="', json2Path ,'";id=setTimeout(t2,16);nw=+new Date}',
+ 'id=setTimeout(t1,16);',
+ 'function t2(){if(window.JSON){jp.src="', url ,'"}else{id=setTimeout(t2,16)}}',
'</script>'
];
+ X_Net_JSONP_onloadCount = 3;
} else {
html = [
'<script>',
'<script src="', json2Path, '"></script>',
'<script src="', url, '"></script>'
];
+ X_Net_JSONP_onloadCount = 1;
};
X_NET_JSONP_NinjaIframe
function X_NET_JSONP_iframeListener( e ){
switch( e.type ){
case X.Event.SUCCESS :
- console.log( 'iframe onload' );
-
+ console.log( 'iframe onload, but' );
+ if( ++X_NET_JSONPWrapper._onloadCount < X_Net_JSONP_onloadCount ) return;
+ // TODO callback が無ければ error
+ X_NET_JSONPWrapper.asyncDispatch( 1000, X.Event.ERROR );
break;
case X.Event.ERROR :
console.log( 'iframe onerror' );
- X_NET_JSONPWrapper.asyncDispatch( 0, X.Event.ERROR );
+ X_NET_JSONPWrapper.asyncDispatch( X.Event.ERROR );
break;
};
+ X_NET_JSONP_NinjaIframe.unlisten();
+ return X.Callback.UN_LISTEN;
};
new X.EventDispatcher(),
{
- _operaImage : null, // X.Net.Image();
_busy : false,
_canceled : false,
+ _onloadCount : 0,
load : function( url, data, timeout ){
//createURL
- if( X_NET_JSONP_operaImageHandleEvent ){
- this._operaImage = X.Net.Image( url, false )
- .listenOnce( [ X.Event.SUCCESS, X.Event.ERROR, X.Event.TIMEOUT ], X_NET_JSONP_operaImageHandleEvent );
- } else {
- X_NET_JSONP_loadScriptInNinjaIframe( url );
- };
+ X_NET_JSONP_loadScriptInNinjaIframe( url );
this._busy = true;
},
cancel : function(){
- if( this._operaImage ){
- this._operaImage
- .unlisten( [ X.Event.SUCCESS, X.Event.ERROR, X.Event.TIMEOUT ], X_NET_JSONP_operaImageHandleEvent )
- .cancel();
- delete this._operaImage;
- } else {
- this._canceled = true;
- };
+ this._canceled = true;
},
reset : function(){
this._busy = this._canceled = false;
+ this._onloadCount = 0;
}
}
);
-
-function X_NET_JSONP_operaImageHandleEvent( e ){
- switch( e.type ){
- case X.Event.SUCCESS :
- case X.Event.ERROR :
- X_NET_JSONP_loadScriptInNinjaIframe( e.src );
- break;
- case X.Event.TIMEOUT :
- X_NET_JSONPWrapper._operaImage
- .unlisten( [ X.Event.SUCCESS, X.Event.ERROR, X.Event.TIMEOUT ], X_NET_JSONP_operaImageHandleEvent )
- .reset();
- X_NET_JSONPWrapper.asyncDispatch( 0, X.Event.ERROR );
- break;
- };
-};
-if( !X_UA.Opera ) X_NET_JSONP_operaImageHandleEvent = null;
\ No newline at end of file
this.abspath = X.URL.toAbsolutePath( data.url );\r
this.delay = data.delay || 100;\r
this.timeout = data.timeout || 5000;\r
- this.timerID = X.Timer.add( this.delay, 0, this, this._detect );\r
- \r
- //X_Net_Image_hasImage ? ( this._rawObject.src = this.abspath ) : this.attr( 'src', this.abspath );\r
- /*\r
- if( X_UA.Opera7 ){\r
- X_EventDispatcher_toggleAllEvents( this, false );\r
- this._rawObject = new Image();\r
- X_EventDispatcher_toggleAllEvents( this, true );\r
- }; */\r
- \r
+ //this.timerID = X.Timer.add( this.delay, 0, this, this._detect );\r
+\r
this._rawObject.src = this.abspath;\r
- //alert( this._rawObject.src + ' ' + this._rawObject.complete );\r
+\r
if( X_UA.Opera7 && this._rawObject.complete ){\r
this.asyncDispatch( 'load' );\r
} else {\r
this.timerID = X.Timer.add( this.delay, 0, this, this._detect );\r
};\r
- //alert( this._rawObject.src + ' ' + this._rawObject.complete );\r
},\r
\r
handleEvent : function( e ){\r
cancel : function(){\r
// abort がある?\r
this._rawObject && this._rawObject.abort && this._rawObject.abort();\r
+ // this._rawObject.src = '';\r
this._busy = false;\r
this.finish = true;\r
this.asyncDispatch( X.Event.CANCELED );\r
var ok, mineType = 'audio/' + ext;\r
switch( ext ){\r
case 'mp3' :\r
- ok = X.UA.IE || X.UA.Chrome || X.UA.Safari; //( X.UA.OS === 'windows' && X.UA.Safari );\r
+ ok = X_UA.IE || X_UA.Chrome || X_UA.Safari; //( X_UA.OS === 'windows' && X_UA.Safari );\r
mineType = 'audio/mpeg';\r
break;\r
case 'ogg' :\r
- ok = 15 <= X.UA.Gecko || X.UA.Chrome || X.UA.Opera;\r
+ ok = 15 <= X_UA.Gecko || X_UA.Chrome || X_UA.Opera;\r
break;\r
case 'm4a' :\r
- ok = X.UA.IE || X.UA.WebKit;\r
+ ok = X_UA.IE || X_UA.WebKit;\r
mineType = 'audio/mp4';\r
break;\r
case 'webm' :\r
- ok = 2 <= X.UA.Gecko || 10.6 <= X.UA.Opera; // firefox4+(Gecko2+)\r
+ ok = 2 <= X_UA.Gecko || 10.6 <= X_UA.Opera; // firefox4+(Gecko2+)\r
break;\r
case 'wav' :\r
- ok = X.UA.Gecko || X.UA.Opera || X.UA.Safari; //( X.UA.OS === 'windows' && X.UA.Safari );\r
+ ok = X_UA.Gecko || X_UA.Opera || X_UA.Safari; //( X_UA.OS === 'windows' && X_UA.Safari );\r
//mineType = 'audio/wav'; // audio/x-wav ?\r
break;\r
default :\r
if( this._closed ) return;\r
this._lastUserAction = 'play';\r
\r
- if( X.UA.Chrome ){ // [CHROME][FIX] volume TODO どの version で 修正される?\r
+ if( X_UA.Chrome ){ // [CHROME][FIX] volume TODO どの version で 修正される?\r
// [!] delay\r
X.Timer.once( 0, this, this._fixForChrome, [ this._rawObject.volume ] );\r
this._rawObject.volume = 0;\r
},\r
\r
// [CHROME][FIX] volume\r
- _fixForChrome : X.UA.Chrome && function( volume ){\r
+ _fixForChrome : X_UA.Chrome && function( volume ){\r
!this._closed && ( this._rawObject.volume = volume );\r
},\r
\r
* http://www.atmarkit.co.jp/fdotnet/dotnettips/902slobjcallfromjs/slobjcallfromjs.html\r
* このページのサンプルは sl5+firefox32 環境で動いている。xaml を js から利用する形ではなく、.xap を sl4 以下で作るのがよさそう.\r
*/\r
+ \r
+ // TODO embed\r
this.proxy = proxy;\r
this._onload = 'XAudioSilverlightOnLoad' + ( ++X_Audio_SLAudio_uid );\r
this._callback = window[ this._onload ] = X_Callback_create( this, this.onSLReady, [ option.autoplay ] );\r
\r
window[ this._onload ] = null;\r
delete this._onload;\r
- this._callback.kill();\r
+ X_Callback_correct( this._callback );\r
delete this._callback;\r
\r
//if( sender.findName('media') ) alert( 'exist' );\r