From: itozyun Date: Wed, 10 Sep 2014 22:41:52 +0000 (+0900) Subject: Version 0.6.76, changed _rawNode to _rawObject. X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=75567e2d410304d24a0240ad9feaf9482c0d7006;p=pettanr%2FclientJs.git Version 0.6.76, changed _rawNode to _rawObject. --- diff --git a/0.6.x/js/00_core/01_XUa.js b/0.6.x/js/00_core/01_XUa.js index 0f06a35..1f55c6f 100644 --- a/0.6.x/js/00_core/01_XUa.js +++ b/0.6.x/js/00_core/01_XUa.js @@ -42,11 +42,17 @@ X.UA = (function( n, undefined ){ acme.IE = document.documentMode || parseFloat(dua.split('MSIE ')[1]) || parseFloat(dua.split('rv:')[1]) || parseFloat(dav.split('MSIE ')[1]) || 0; acme.IE4 = acme.IE && acme.IE < 5; acme.IE5678 = 5 <= acme.IE && acme.IE < 9; + acme.IE5 = 5 <= acme.IE && acme.IE < 5.5; + acme.IE55 = 5.5 <= acme.IE && acme.IE < 6; + acme.IE6 = 6 <= acme.IE && acme.IE < 7; + acme.IE7 = 7 <= acme.IE && acme.IE < 8; + acme.IE8 = 8 <= acme.IE && acme.IE < 9; + acme.IE9 = 9 <= acme.IE && acme.IE < 10; acme.MacIE = dua.indexOf( 'Mac_PowerPC' ) !== -1 || dua.indexOf( 'Mac_PPC' ) !== -1 || dua.indexOf( 'Mac_68K' ) !== -1; acme.IEMobile = dua.toLowerCase().indexOf( 'iemobile' ) !== -1 || n.platform === 'WinCE'; acme.WinPhone = dua.toLowerCase().indexOf( 'windows phone' ) !== -1; console.log( '>> IE : ' + acme.IE + ' ActiveX : ' + acme.ActiveX ); - // TODO XBox360, XBox1 + // TODO XBox360, XBox1, Modern or Desktop, Standalone return acme; }; @@ -241,6 +247,7 @@ if( X.UA.Safari && X.UA.WebKit < 525.13 ){ if( X.UA.IE < 7 ){ // error @ NN7.2 // bonus: hotfix for IE6 SP1 (bug KB823727) + // multipleIEs IE6 standalone 版では不可 document.execCommand && document.execCommand( 'BackgroundImageCache', false, true ); }; diff --git a/0.6.x/js/00_core/05_XTimer.js b/0.6.x/js/00_core/05_XTimer.js index a034a14..2ee67e3 100644 --- a/0.6.x/js/00_core/05_XTimer.js +++ b/0.6.x/js/00_core/05_XTimer.js @@ -18,6 +18,33 @@ var _enterFrame = window.msCancelRequestAnimationFrame || false; +/* + * + * http://please-sleep.cou929.nu/script-yielding-with-setimmediate.html + * setImmediate での script yielding + * + * http://ie.microsoft.com/testdrive/Performance/setImmediateSorting/Default.html + * setImmediate API + * + * if( timer < 4ms ) useSetImmediate + * + * if (window.msSetImmediate) + { + this.timer = msSetImmediate(function () { t.stepper(); }); + } + else if (window.MozSetImmediate) + { + this.timer = MozSetImmediate(function () { t.stepper(); }); + } + else if (window.WebkitSetImmediate) { + this.timer = WebkitSetImmediate(function () { t.stepper(); }); + } + else if (window.OSetImmediate) + { + this.timer = OSetImmediate(function () { t.stepper(); }); + } + */ + X.Timer = { INTERVAL_TIME : 16, TICKET_LIST : [], @@ -63,21 +90,22 @@ X.Timer = { }; X.Timer.timerId = 0; X.Timer.busy = false; - X.Timer._update(); + X.Timer._update(); }, _update : function(){ var list = X.Timer.TICKET_LIST, i = list.length, - n = Infinity, - l; + n; if( i === 0 ){ X.Timer.timerId && window.clearTimeout( X.Timer.timerId ); X.Timer.timerId = 0; return; }; - for( ; i; ){ - ( l = list[ --i ].last ) < n && ( n = l ); - }; + + 1 < i && list.sort( x_timer_compareQueue ); + + n = list[ i - 1 ].last; + if( n < X.Timer.next || X.Timer.timerId === 0 ){ X.Timer.timerId && window.clearTimeout( X.Timer.timerId ); X.Timer.timerId = window.setTimeout( X.Timer._loop, X.Timer.INTERVAL_TIME * n ); @@ -205,6 +233,12 @@ X.Timer = { }; +// 大きい -> 小さい +function x_timer_compareQueue( a, b ){ + return a.last < b.last ? 1 : a.last === b.last ? 0 : -1; +}; + + // http://havelog.ayumusato.com/develop/javascript/e528-ios6_scrolling_timer_notcall.html // iOS6 スクロール中のタイマー発火絡みのバグ備忘 if( X.UA.iOS ){ diff --git a/0.6.x/js/00_core/06_XEventDispatcher.js b/0.6.x/js/00_core/06_XEventDispatcher.js index 72f1f73..7a4ca75 100644 --- a/0.6.x/js/00_core/06_XEventDispatcher.js +++ b/0.6.x/js/00_core/06_XEventDispatcher.js @@ -101,7 +101,7 @@ X.EventDispatcher = * @private * @type {Object} */ - _rawNode : null, + _rawObject : null, _handleEvent : null, _dispatching : 0, // dispatch 中の unlisten で使用 @@ -116,7 +116,7 @@ X.EventDispatcher = */ Constructor : function( rawObject ){ if( rawObject ){ - this._rawNode = rawObject; + this._rawObject = rawObject; }; }, @@ -370,16 +370,16 @@ function x_eventdispatcher_off( type, arg1, arg2, arg3 ){ }; -x_eventdispatcher_actualAddEvent = +var x_eventdispatcher_actualAddEvent = // Days on the Moon DOM Events とブラウザの実装 // http://nanto.asablo.jp/blog/2007/03/23/1339502 // Safari 2 では関数オブジェクトしか EventListener として使えませんが、Safari のナイトリービルドでは handleEvent メソッドを持つオブジェクトも EventListener として使えるようです。 x_eventdispatcher_temp.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3- (function( that, type ){ - var raw = that._rawNode; - if( !raw ) return; - that._handleEvent = that._handleEvent || X.Callback.create( that ); - type = X.Dom.Event.Rename[ type ] || type; + var raw = that._rawObject; + if( !raw ) return; + that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent ); + type = X.Dom.Event.Rename[ type] || type; if( raw.addEventListener ){ raw.addEventListener( type, that._handleEvent, false ); } else { @@ -389,34 +389,44 @@ x_eventdispatcher_actualAddEvent = }) : x_eventdispatcher_temp.EVENT_W3C ? (function( that, type ){ - that._rawNode && that._rawNode.addEventListener( X.Dom.Event.Rename[ type ] || type, that, false ); + if( that._rawObject ){ + that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent ); + that._rawObject.addEventListener( X.Dom.Event.Rename[ type ] || type, that._handleEvent, false ); + }; }) : x_eventdispatcher_temp.EVENT_IE ? (function( that, type ){ - var raw = that._rawNode; + var raw = that._rawObject; if( !raw ) return; type = X.Dom.Event.Rename[ type ] || type; //if( type === 'load' && that._tag && X.Dom.Event._LOAD_FIX_TAGS[ that._tag ] ){ // type = 'readystatechange'; //}; - that._handleEvent = that._handleEvent || X.Callback.create( that ); - if( raw.attachEvent ){ - raw.attachEvent( 'on' + type, that._handleEvent ); + if( that._isXHR ){ + // ie8- の XHR は window.event が更新されないため, eventType 毎に callback を指定する + raw[ 'on' + type ] = X.Callback.create( that, X.EventDispatcher.prototype.dispatch, [ type ] ); } else { - raw[ 'on' + type ] = that._handleEvent; + that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent ); + + if( raw.attachEvent ){ + raw.attachEvent( 'on' + type, that._handleEvent ); + } else { + raw[ 'on' + type ] = that._handleEvent; + }; }; + }) : (function( that, type ){ - var raw = that._rawNode || ( that._ie4getRawNode && that._ie4getRawNode() ); + var raw = that._rawObject || ( that._ie4getRawNode && that._ie4getRawNode() ); if( !raw ) return; - raw[ 'on' + ( X.Dom.Event.Rename[ type ] || type ) ] = that._handleEvent = that._handleEvent || X.Callback.create( that ); + raw[ 'on' + ( X.Dom.Event.Rename[ type ] || type ) ] = that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent ); }); -x_eventdispatcher_actualRemoveEvent = +var x_eventdispatcher_actualRemoveEvent = x_eventdispatcher_temp.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3- (function( that, type ){ - var raw = that._rawNode; + var raw = that._rawObject; if( !raw ) return; type = X.Dom.Event.Rename[ type ] || type; @@ -432,31 +442,42 @@ x_eventdispatcher_actualRemoveEvent = }) : x_eventdispatcher_temp.EVENT_W3C ? (function( that, type ){ - var raw = that._rawNode; + var raw = that._rawObject; if( !raw ) return; - raw.removeEventListener( X.Dom.Event.Rename[ type ] || type, that, false ); + raw.removeEventListener( X.Dom.Event.Rename[ type ] || type, that._handleEvent, false ); + if( !that._listeners ){ + X.Callback._correct( that._handleEvent ); + delete that._handleEvent; + }; }) : x_eventdispatcher_temp.EVENT_IE ? (function( that, type ){ - var raw = that._rawNode; + var raw = that._rawObject; if( !raw ) return; type = X.Dom.Event.Rename[ type ] || type; //if( type === 'load' && that._tag && X.Dom.Event._LOAD_FIX_TAGS[ that._tag ] ){ // type = 'readystatechange'; //}; - if( raw.attachEvent ){ - raw.detachEvent( 'on' + type, that._handleEvent ); - } else { + if( that._isXHR ){ + X.Callback._correct( raw[ 'on' + type ] ); raw[ 'on' + type ] = X.emptyFunction; raw[ 'on' + type ] = ''; - }; - if( !that._listeners ){ - X.Callback._correct( that._handleEvent ); - delete that._handleEvent; + } else { + if( raw.attachEvent ){ + raw.detachEvent( 'on' + type, that._handleEvent ); + } else { + raw[ 'on' + type ] = X.emptyFunction; + raw[ 'on' + type ] = ''; + }; + + if( !that._listeners ){ + X.Callback._correct( that._handleEvent ); + delete that._handleEvent; + }; }; }) : (function( that, type ){ - var raw = that._rawNode || ( that._ie4getRawNode && that._ie4getRawNode() ); + var raw = that._rawObject || ( that._ie4getRawNode && that._ie4getRawNode() ); if( !raw ) return; type = X.Dom.Event.Rename[ type ] || type; raw[ 'on' + type ] = X.emptyFunction; @@ -468,4 +489,69 @@ x_eventdispatcher_actualRemoveEvent = }); +// handleEvent を拡張可能にするために、クロージャに移動した +// Is this in regard to the Safari 1.x preventDefault bug on click/dblclick? +// https://groups.google.com/forum/#!msg/comp.lang.javascript/uYEuCHjHxnw/yKoHtZJPa1QJ +var x_eventdispatcher_actualHandleEvent = + X.UA.IE4 || X.UA.IE5678 ? // ie45678 EVENT_IE & EVENT_DOM0 for ie4 + (function(){ + var ret; + + if( event.type === 'readystatechange' && this._tag && X.Dom.Event._LOAD_FIX_TAGS[ this._tag ] ){ + //type = 'readystatechange'; + }; + + ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( event, this, this._rawObject ) ); + + if( ret & X.Callback.STOP_PROPAGATION ){ + event.cancelBubble = true; + }; + if( ret & X.Callback.PREVENT_DEFAULT ){ + this._tag === 'A' && this._rawObject.blur(); + return event.returnValue = false; + }; + }) : + //X.Dom.EVENT_W3C & EVENT_DOM0 + (function( e ){ + var ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( e, this ) ); + + if( ret & X.Callback.STOP_PROPAGATION ){ + e.stopPropagation(); + }; + if( ret & X.Callback.PREVENT_DEFAULT ){ + this._tag === 'A' && this._rawObject.blur(); + e.preventDefault(); + if( X.UA.WebKit < 525.13 ){ // Safari3- + if( e.type === 'click' || e.type === 'dbclick' ){ + X.Dom._safariPreventDefault = true; + }; + }; + return false; + }; + }); + + +// イベントの退避、dom が画面から抜かれる場合に実施しておく +X.EventDispatcher.prototype._migrateEvent = function(){ + var hash = this._listeners, + type; + if( !hash ) return; + for( type in hash ){ + // 数字イベントの除外 + '' + parseFloat( type ) !== type && x_eventdispatcher_actualRemoveEvent( this, type ); + }; +}; + +// 退避したイベントの復帰 +X.EventDispatcher.prototype._restoreEvent = function(){ + var hash = this._listeners, + type; + if( !hash ) return; + for( type in hash ){ + // 数字イベントの除外 + '' + parseFloat( type ) !== type && x_eventdispatcher_actualAddEvent( this, type ); + }; +}; + + console.log( 'X.Core.EventDispatcher' ); diff --git a/0.6.x/js/01_dom/10_XDom.js b/0.6.x/js/01_dom/10_XDom.js index b888971..d6f353b 100644 --- a/0.6.x/js/01_dom/10_XDom.js +++ b/0.6.x/js/01_dom/10_XDom.js @@ -53,7 +53,7 @@ X.Dom = X.Class._override( }; }; - size = Node._fontSizeNode._rawNode.offsetHeight; + size = Node._fontSizeNode._rawObject.offsetHeight; if( X.Dom.baseFontSize !== size ){ X.Dom.baseFontSize && X.Dom.asyncDispatch( 0, { type : X.Dom.Event.BASE_FONT_RESIZED, fontSize : size, w : X.Dom.w, h : X.Dom.h } ); X.Dom.baseFontSize = size; @@ -148,7 +148,7 @@ X.Dom = X.Class._override( X.Timer.add( 333, X.Dom._resize ); }; - X.Dom.baseFontSize = Node._fontSizeNode._rawNode.offsetHeight; + X.Dom.baseFontSize = Node._fontSizeNode._rawObject.offsetHeight; X.Dom.readyState = X.Dom.Event.XDOM_READY; X.Dom.asyncDispatch( 0, { type : X.Dom.Event.XDOM_READY, w : X.Dom.w = size[ 0 ], h : X.Dom.h = size[ 1 ] } ); @@ -292,7 +292,7 @@ X.Dom = X.Class._override( getBaseFontSize : function(){ if( Node._body._updateTimerID ){ Node._body._startUpdate(); - return Node._fontSizeNode._rawNode.offsetHeight; + return Node._fontSizeNode._rawObject.offsetHeight; }; return X.Dom.baseFontSize; } @@ -301,7 +301,7 @@ X.Dom = X.Class._override( if( !( X.UA.IE < 9 || X.UA.iOS ) ){ X.Dom._detectFontSize = function(){ - var size = Node._fontSizeNode._rawNode.offsetHeight; + var size = Node._fontSizeNode._rawObject.offsetHeight; if( X.Dom.baseFontSize !== size ){ X.Dom.baseFontSize && X.Dom.asyncDispatch( 0, { type : X.Dom.Event.BASE_FONT_RESIZED, fontSize : size, w : X.Dom.w, h : X.Dom.h } ); X.Dom.baseFontSize = size; diff --git a/0.6.x/js/01_dom/11_XDomNode.js b/0.6.x/js/01_dom/11_XDomNode.js index 0834efd..8d8d309 100644 --- a/0.6.x/js/01_dom/11_XDomNode.js +++ b/0.6.x/js/01_dom/11_XDomNode.js @@ -46,7 +46,7 @@ X.Dom.Node = X.EventDispatcher.inherits( _isNew : false, - _rawNode : null, + _rawObject : null, _rect : null, // _root : null, // xnode が文書ツリーに属しているか?はこれを見る @@ -79,7 +79,7 @@ X.Dom.Node = X.EventDispatcher.inherits( this._xnodeType = 1; this._state = X.Dom.State.DISPLAY_INLINE; // todo arguments[ 1 ] && this.attr( arguments[ 1 ] ); - css = arguments[ 2 ] || arguments[ 1 ]; + css = arguments[ 2 ]; css && this[ X.Type.isString( css ) ? 'cssText' : 'css' ]( css ); } else if( Node._newByText ){ @@ -102,7 +102,7 @@ X.Dom.Node = X.EventDispatcher.inherits( // v.parentNode || v.parentElement : dom1 || dom0 this.parent = ( parent = v.parentNode || v.parentElement ) && parent.tagName /* ie7- */ && Node._getXNode( parent ); this._root = this.parent ? this.parent._root : null; - this._rawNode = v; + this._rawObject = v; this._xnodeType = 1; this._state = X.Dom.State.DISPLAY_BLOCK; // todo this._tag = v.tagName.toUpperCase(); @@ -123,7 +123,7 @@ X.Dom.Node = X.EventDispatcher.inherits( if( xnode = Node._getXNode( v ) ) return xnode; this.parent = Node._getXNode( v.parentNode ); this._root = this.parent ? this.parent._root : null; - this._rawNode = v; + this._rawObject = v; this._xnodeType = 3; this._state = X.Dom.State.DISPLAY_INLINE; this._text = v.data; @@ -136,7 +136,7 @@ X.Dom.Node = X.EventDispatcher.inherits( return Node.none; case Node.IS_IMAGE : if( xnode = Node._getXNode( v ) ) return xnode; - this._rawNode = v; + this._rawObject = v; this._xnodeType = 4; v.UID = uid; this._state = X.Dom.State.EXIST; @@ -144,7 +144,7 @@ X.Dom.Node = X.EventDispatcher.inherits( case Node.IS_WINDOW : case Node.IS_DOCUMENT : if( xnode = Node._getXNode( v ) ) return xnode; - this._rawNode = v; + this._rawObject = v; this._xnodeType = 2; this._state = X.Dom.State.DISPLAY_BLOCK; break; @@ -214,7 +214,7 @@ Node._getXNode = function( v ){ case Node.IS_RAW_TEXT : if( v.UID ) return Node._chashe[ v.UID ]; for( chashe = Node._chashe, i = chashe.length; i; ){ - if( ( xnode = Node._chashe[ --i ] ) && ( xnode._rawNode === v ) ) return xnode; + if( ( xnode = Node._chashe[ --i ] ) && ( xnode._rawObject === v ) ) return xnode; }; }; }; @@ -242,7 +242,7 @@ Node.createText = function( text ){ Node.getRoot = function( xnode ){ return Node._document; - //return xNode._body._rawNode.documentElement ? node : node.ownerDocument || node.document; + //return xNode._body._rawObject.documentElement ? node : node.ownerDocument || node.document; }; // XMLかどうかを判別する Node.isXmlDocument = @@ -250,7 +250,7 @@ Node.isXmlDocument = X.emptyFunction : (function( root ){ if( X.Type.isBoolean( root.isXML ) ) return root.isXML; - return root.isXML = root._rawNode.createElement( 'p' ).tagName !== root._rawNode.createElement( 'P' ).tagName; + return root.isXML = root._rawObject.createElement( 'p' ).tagName !== root._rawObject.createElement( 'P' ).tagName; }); Node._chashe = []; @@ -265,10 +265,10 @@ Node._reserveRemoval = []; if( X.Dom.DOM_IE4 ){ Node.prototype._ie4getRawNode = function(){ - var elm = this._rawNode; + var elm = this._rawObject; return elm || - ( ( elm = document.all[ 'ie4uid' + this._uid ] ) && ( this._rawNode = elm ) ) || - ( this._id && ( elm = document.all[ this._id ] ) ) && ( this._rawNode = elm ); + ( ( elm = document.all[ 'ie4uid' + this._uid ] ) && ( this._rawObject = elm ) ) || + ( this._id && ( elm = document.all[ this._id ] ) ) && ( this._rawObject = elm ); }; }; @@ -589,7 +589,7 @@ Node.prototype.destroy = function( isChild ){ if( !this._state ) return; - elm = this._rawNode || this._ie4getRawNode && this._ie4getRawNode(); + elm = this._rawObject || this._ie4getRawNode && this._ie4getRawNode(); if( xnodes && ( i = xnodes.length ) ){ //for( ; i; ){ @@ -619,7 +619,7 @@ Node.prototype.contains = function( v ){ var elm, type, xnodes, i; if( !v || this._xnodeType !== 1 ) return false; // contains ie4+ - if( ( elm = this._rawNode || this._ie4getRawNode && this._ie4getRawNode() ) && document.contains && ( type = Node._getType( v ) ) && ( type === Node.IS_RAW_HTML || type === Node.IS_RAW_TEXT ) ){ + if( ( elm = this._rawObject || this._ie4getRawNode && this._ie4getRawNode() ) && document.contains && ( type = Node._getType( v ) ) && ( type === Node.IS_RAW_HTML || type === Node.IS_RAW_TEXT ) ){ return elm.contains( v ); }; //if( document.compareDocumentPosition ){ @@ -831,7 +831,7 @@ Node.prototype.text = function( text ){ * HTML要素に対して name の関数を実行しその戻り値を返す。関数に渡す引数も任意に設定できる。 */ Node.prototype.call = function( name /*, opt_args... */ ){ - var raw = this._rawNode || this._ie4getRawNode && this._ie4getRawNode(), + var raw = this._rawObject || this._ie4getRawNode && this._ie4getRawNode(), l = arguments.length - 1, func, args, params, i; if( !raw ) return; @@ -886,7 +886,7 @@ Node.prototype.each = function( func /*, opt_args */ ){ * Async commit update * * state: - * 0 : no_rawnode + * 0 : no_rawObject * 1 : no_parent * 2 : no_root * 3 : dirty @@ -919,8 +919,8 @@ Node.prototype._startUpdate = function(){ removal = Node._reserveRemoval; - tmp = this._rawNode.style.visibility; - //this._rawNode.style.visibility = 'hidden'; + tmp = this._rawObject.style.visibility; + //this._rawObject.style.visibility = 'hidden'; //console.log( '_actualRemove().' ); @@ -940,13 +940,13 @@ Node.prototype._startUpdate = function(){ //console.log( 'end of _startUpdate().' ); X.Dom._listeners && X.Dom._listeners[ X.Dom.Event.AFTER_UPDATE ] && X.Dom.asyncDispatch( 0, { type : X.Dom.Event.AFTER_UPDATE } ); - //this._rawNode.style.visibility = tmp; + //this._rawObject.style.visibility = tmp; }; Node.prototype._commitUpdate = X.Dom.DOM_W3C ? ( function( parentElement, nextElement ){ - var elm = this._rawNode, + var elm = this._rawObject, xnodes, l, i, frg, next, k, v; if( this._state & X.Dom.State.IE5_DISPLAY_NONE_FIX ){ @@ -961,7 +961,7 @@ Node.prototype._commitUpdate = parentElement.appendChild( this._actualCreate() ); this._afterActualCreate(); - return elm || this._rawNode; + return elm || this._rawObject; } else if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ) { @@ -989,7 +989,7 @@ Node.prototype._commitUpdate = }) : X.Dom.DOM_IE4 ? ( function( parentElement, prevElement ){ - var elm = this._rawNode || this._ie4getRawNode(), + var elm = this._rawObject || this._ie4getRawNode(), xnodes, l, i, html, text, prev; if( !elm ){ @@ -997,7 +997,7 @@ Node.prototype._commitUpdate = prevElement.insertAdjacentHTML( 'AfterEnd', this._actualCreate() ) : parentElement.insertAdjacentHTML( 'AfterBegin', this._actualCreate() ); this._afterActualCreate(); - return this._rawNode || this._ie4getRawNode(); + return this._rawObject || this._ie4getRawNode(); }; xnodes = this._xnodes; @@ -1089,9 +1089,11 @@ Node.prototype._updateRawNode = continue; }; }; - k = + ( v = attrs[ k ] ) === undefined ? elm.removeAttribute( rename[ k ] || k ) : + X.UA.IE === 8 ? + elm.setAttribute( rename[ k ] || k, X.Dom.Attr.noValue[ k ] ? k : v ) : ( elm[ rename[ k ] || k ] = X.Dom.Attr.noValue[ k ] ? k : v ); }; @@ -1134,7 +1136,7 @@ Node.prototype._updateRawNode = }; if( this._dirty & X.Dom.Dirty.IE_FILTER ){ - this._rawNode.style.filter = X.Dom.Style.SPECIAL_FIX( this._css ); + this._rawObject.style.filter = X.Dom.Style.SPECIAL_FIX( this._css ); }; // attr @@ -1171,13 +1173,13 @@ Node.prototype._updateRawNode = */ Node.prototype._actualCreate = X.Dom.DOM_W3C ? (function( isChild ){ - var elm = this._rawNode, + var elm = this._rawObject, xnodes, frg, i, l; if( this._xnodeType === 3 ){ if( elm ) return elm; delete this._dirty; - return this._rawNode = document.createTextNode( X.Dom.chrReferanceTo( this._text ) ); + return this._rawObject = document.createTextNode( X.Dom.chrReferanceTo( this._text ) ); }; if( !elm ){ @@ -1185,7 +1187,7 @@ Node.prototype._actualCreate = delete this._cssText; }; this._isNew = true; - this._rawNode = elm = + this._rawObject = elm = X.Dom._strictElmCreation ? document.createElement( [ '<', this._tag, @@ -1215,9 +1217,9 @@ Node.prototype._actualCreate = if( this._xnodeType === 3 ){ html = [ '', this._text, '' ];// fake textNode - delete this._rawNode; + delete this._rawObject; } else { - if( this._rawNode && !isChild ) this._actualRemove( true ); + if( this._rawObject && !isChild ) this._actualRemove( true ); if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ delete this._cssText; @@ -1255,7 +1257,7 @@ Node.prototype._actualCreate = Node.prototype._afterActualCreate = X.Dom.DOM_W3C ? (function(){ - var elm = this._rawNode, xnodes, l, attrs, k, i; + var elm = this._rawObject, xnodes, l, attrs, k, i; this._root = this.parent._root; @@ -1322,7 +1324,7 @@ Node.prototype._actualRemove = X.Dom.DOM_W3C ? ( function( isChild ){ var xnodes = this._xnodes, - elm = this._rawNode, + elm = this._rawObject, child, i, l; if( xnodes && ( l = xnodes.length ) ){ for( i = 0; i < l; ++i ){ @@ -1343,7 +1345,7 @@ Node.prototype._actualRemove = X.Dom.DOM_IE4 ? ( function( isChild ){ var xnodes = this._xnodes, - elm = this._rawNode || this._ie4getRawNode(), + elm = this._rawObject || this._ie4getRawNode(), i, l, xnode; if( xnodes && ( l = xnodes.length ) ){ for( i = 0; i < l; ++i ){ @@ -1360,7 +1362,7 @@ Node.prototype._actualRemove = elm.removeAttribute( 'id' ); // ? document.all[ this._id || ( 'ie4uid' + this._uid ) ] = null; // MacIE5 でエラー if( !isChild ) elm.outerHTML = ''; - delete this._rawNode; + delete this._rawObject; }) : (function(){}); diff --git a/0.6.x/js/01_dom/12_XDomEvent.js b/0.6.x/js/01_dom/12_XDomEvent.js index c0eb02e..3f906a5 100644 --- a/0.6.x/js/01_dom/12_XDomEvent.js +++ b/0.6.x/js/01_dom/12_XDomEvent.js @@ -104,11 +104,11 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ window.PointerEvent = window.MSPointerEvent; }; } else { - X.Dom.Event = function( e, xnode, element ){ + X.Dom.Event = function( e, xnode, element, opt_type ){ var btn; //this._event = e; - this.type = X.Dom.Event.RenameTo[ e.type ] || e.type; + this.type = X.Dom.Event.RenameTo[ e.type ] || e.type || opt_type; this.target = Node._getXNode( e.srcElement ); // xnode if( this.target && this.target._xnodeType === 3 ) this.target = this.target.parent; // ie4 の fake Textnode がヒットしていないか? this.currentTarget = xnode; // xnode @@ -292,71 +292,6 @@ if( navigator.msPointerEnabled && !navigator.pointerEnabled ){ })( X.Dom.Event.Rename, X.Dom.Event.RenameTo ); - -// TODO handleEvent を拡張可能にするために、クロージャに移動する -// Is this in regard to the Safari 1.x preventDefault bug on click/dblclick? -// https://groups.google.com/forum/#!msg/comp.lang.javascript/uYEuCHjHxnw/yKoHtZJPa1QJ -X.Dom.Node.prototype.handleEvent = - X.UA.IE4 || X.UA.IE5678 ? // ie45678 EVENT_IE & EVENT_DOM0 for ie4 - (function(){ - var ret; - - if( event.type === 'readystatechange' && this._tag && X.Dom.Event._LOAD_FIX_TAGS[ this._tag ] ){ - //type = 'readystatechange'; - }; - - ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( event, this, this._rawNode ) ); - - if( ret & X.Callback.STOP_PROPAGATION ){ - event.cancelBubble = true; - }; - if( ret & X.Callback.PREVENT_DEFAULT ){ - this._tag === 'A' && this._rawNode.blur(); - return event.returnValue = false; - }; - }) : - //X.Dom.EVENT_W3C & EVENT_DOM0 - (function( e ){ - var ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( e, this ) ); - - if( ret & X.Callback.STOP_PROPAGATION ){ - e.stopPropagation(); - }; - if( ret & X.Callback.PREVENT_DEFAULT ){ - this._tag === 'A' && this._rawNode.blur(); - e.preventDefault(); - if( X.UA.WebKit < 525.13 ){ // Safari3- - if( e.type === 'click' || e.type === 'dbclick' ){ - X.Dom._safariPreventDefault = true; - }; - }; - return false; - }; - }); - - -// イベントの退避、dom が画面から抜かれる場合に実施しておく -X.Dom.Node.prototype._migrateEvent = function(){ - var hash = this._listeners, - type; - if( !hash ) return; - for( type in hash ){ - // 数字イベントの除外 - /*'' + parseFloat( type ) !== type && */x_eventdispatcher_actualRemoveEvent( this, type ); - }; -}; - -// 退避したイベントの復帰 -X.Dom.Node.prototype._restoreEvent = function(){ - var hash = this._listeners, - type; - if( !hash ) return; - for( type in hash ){ - // 数字イベントの除外 - /*'' + parseFloat( type ) !== type && */ x_eventdispatcher_actualAddEvent( this, type ); - }; -}; - /* ----------------------------------------------- * Document Ready * Dean Edwards/Matthias Miller/John Resig diff --git a/0.6.x/js/01_dom/13_XDomBoxModel.js b/0.6.x/js/01_dom/13_XDomBoxModel.js index 9076194..3d6f78f 100644 --- a/0.6.x/js/01_dom/13_XDomBoxModel.js +++ b/0.6.x/js/01_dom/13_XDomBoxModel.js @@ -90,10 +90,10 @@ Node.prototype.width = function(){ if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; if( X.Dom.DOM_W3C ){ // this.css( X.Dom.Style.Unit.px, 'width' ); - return this._rawNode.offsetWidth; + return this._rawObject.offsetWidth; } else if( X.Dom.DOM_IE4 ){ - return ( this._rawNode || this._ie4getRawNode() ).offsetWidth; + return ( this._rawObject || this._ie4getRawNode() ).offsetWidth; } else { }; @@ -112,10 +112,10 @@ Node.prototype.height = function(){ if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; if( X.Dom.DOM_W3C ){ // this.css( X.Dom.Style.Unit.px, 'height' ); - return this._rawNode.offsetHeight; + return this._rawObject.offsetHeight; } else if( X.Dom.DOM_IE4 ){ - return ( this._rawNode || this._ie4getRawNode() ).offsetHeight; + return ( this._rawObject || this._ie4getRawNode() ).offsetHeight; } else { }; @@ -134,10 +134,10 @@ Node.prototype.clientWidth = function(){ if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; if( X.Dom.DOM_W3C ){ // this.css( X.Dom.Style.Unit.px, 'width' ); - return this._rawNode.clientWidth; + return this._rawObject.clientWidth; } else if( X.Dom.DOM_IE4 ){ - return ( this._rawNode || this._ie4getRawNode() ).clientWidth; + return ( this._rawObject || this._ie4getRawNode() ).clientWidth; } else { }; @@ -156,10 +156,10 @@ Node.prototype.clientHeight = function(){ if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; if( X.Dom.DOM_W3C ){ // this.css( X.Dom.Style.Unit.px, 'height' ); - return this._rawNode.clientHeight; + return this._rawObject.clientHeight; } else if( X.Dom.DOM_IE4 ){ - return ( this._rawNode || this._ie4getRawNode() ).clientHeight; + return ( this._rawObject || this._ie4getRawNode() ).clientHeight; } else { }; @@ -178,10 +178,10 @@ Node.prototype.scrollWidth = function(){ if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; if( X.Dom.DOM_W3C ){ // this.css( X.Dom.Style.Unit.px, 'width' ); - return this._rawNode.scrollWidth; + return this._rawObject.scrollWidth; } else if( X.Dom.DOM_IE4 ){ - return ( this._rawNode || this._ie4getRawNode() ).scrollWidth; + return ( this._rawObject || this._ie4getRawNode() ).scrollWidth; } else { }; @@ -200,10 +200,10 @@ Node.prototype.scrollHeight = function(){ if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; if( X.Dom.DOM_W3C ){ // this.css( X.Dom.Style.Unit.px, 'height' ); - return this._rawNode.scrollHeight; + return this._rawObject.scrollHeight; } else if( X.Dom.DOM_IE4 ){ - return ( this._rawNode || this._ie4getRawNode() ).scrollHeight; + return ( this._rawObject || this._ie4getRawNode() ).scrollHeight; } else { }; @@ -222,10 +222,10 @@ Node.prototype.scrollLeft = function(){ if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; if( X.Dom.DOM_W3C ){ // this.css( X.Dom.Style.Unit.px, 'width' ); - return this._rawNode.scrollLeft; + return this._rawObject.scrollLeft; } else if( X.Dom.DOM_IE4 ){ - return ( this._rawNode || this._ie4getRawNode() ).scrollLeft; + return ( this._rawObject || this._ie4getRawNode() ).scrollLeft; } else { }; @@ -244,10 +244,10 @@ Node.prototype.scrollTop = function(){ if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; if( X.Dom.DOM_W3C ){ // this.css( X.Dom.Style.Unit.px, 'width' ); - return this._rawNode.scrollTop; + return this._rawObject.scrollTop; } else if( X.Dom.DOM_IE4 ){ - return ( this._rawNode || this._ie4getRawNode() ).scrollTop; + return ( this._rawObject || this._ie4getRawNode() ).scrollTop; } else { }; @@ -275,10 +275,10 @@ Node.prototype.x = function(){ if( X.Dom.DOM_W3C ){ // this.css( X.Dom.Style.Unit.px, 'left' ); // this.css( X.Dom.Style.Unit.px, 'translateX' ); - return this._rawNode.offsetLeft; + return this._rawObject.offsetLeft; } else if( X.Dom.DOM_IE4 ){ - return ( this._rawNode || this._ie4getRawNode() ).offsetLeft; + return ( this._rawObject || this._ie4getRawNode() ).offsetLeft; } else { }; @@ -298,10 +298,10 @@ Node.prototype.y = function(){ if( X.Dom.DOM_W3C ){ // this.css( X.Dom.Style.Unit.px, 'top' ); // this.css( X.Dom.Style.Unit.px, 'transisitonY' ); - return this._rawNode.offsetTop; + return this._rawObject.offsetTop; } else if( X.Dom.DOM_IE4 ){ - return ( this._rawNode || this._ie4getRawNode() ).offsetTop; + return ( this._rawObject || this._ie4getRawNode() ).offsetTop; } else { }; @@ -326,10 +326,10 @@ Node.prototype.offset = function( /* xnodeParent */ ){ }; if( X.Dom.DOM_W3C ){ - elm = this._rawNode; + elm = this._rawObject; } else if( X.Dom.DOM_IE4 ){ - elm = this._rawNode || this._ie4getRawNode(); + elm = this._rawObject || this._ie4getRawNode(); } else { }; diff --git a/0.6.x/js/01_dom/14_XDomAttr.js b/0.6.x/js/01_dom/14_XDomAttr.js index 04a1891..86cd3f6 100644 --- a/0.6.x/js/01_dom/14_XDomAttr.js +++ b/0.6.x/js/01_dom/14_XDomAttr.js @@ -135,7 +135,7 @@ X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){ case 'selectedIndex' : if( X.Dom.Attr.HAS_VALUE[ this._tag ] ){ if( this._newAttrs && X.inObject( nameOrObj, this._newAttrs ) ) return this._newAttrs[ nameOrObj ]; - if( elm = X.Dom.DOM_IE4 ? this._rawNode || this._ie4getRawNode() : this._rawNode ){ + if( elm = X.Dom.DOM_IE4 ? this._rawObject || this._ie4getRawNode() : this._rawObject ){ attrs[ nameOrObj ] = elm[ nameOrObj ]; // getAttribute( nameOrObj )? }; return attrs[ nameOrObj ]; diff --git a/0.6.x/js/01_dom/15_XDomStyle.js b/0.6.x/js/01_dom/15_XDomStyle.js index dea4304..e5e0b94 100644 --- a/0.6.x/js/01_dom/15_XDomStyle.js +++ b/0.6.x/js/01_dom/15_XDomStyle.js @@ -1055,7 +1055,7 @@ X.Dom.Node.prototype.cssText = function( v ){ delete this._css; this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX; obj = {}; - v = v.split( ';' ); + v = v.split( ';' ); // TODO content ";" などにも対応 for( i = 0, l = v.length; i < l; ++i ){ attr = v[ i ].split( ':' ); ( name = attr[ 0 ] ) && ( obj[ name ] = attr[ 1 ] || true ); @@ -1081,14 +1081,14 @@ X.Dom.Node.prototype._getCharSize = Node._body._updateTimerID && Node._body._startUpdate(); if( this === Node._body && X.Dom.baseFontSize ) return X.Dom.baseFontSize; if( this._fontSize ) return this._fontSize; - return this._fontSize = parseFloat( getComputedStyle( this._rawNode, null ).fontSize ); + return this._fontSize = parseFloat( getComputedStyle( this._rawObject, null ).fontSize ); }) : document.defaultView && document.defaultView.getComputedStyle ? (function(){ Node._body._updateTimerID && Node._body._startUpdate(); if( this === Node._body && X.Dom.baseFontSize ) return X.Dom.baseFontSize; if( this._fontSize ) return this._fontSize; - return this._fontSize = parseFloat( document.defaultView.getComputedStyle( this._rawNode, null ).fontSize ); + return this._fontSize = parseFloat( document.defaultView.getComputedStyle( this._rawObject, null ).fontSize ); }) : X.UA.IE && 5.5 <= X.UA.IE ? (function(){ @@ -1097,7 +1097,7 @@ X.Dom.Node.prototype._getCharSize = if( this === Node._body && X.Dom.baseFontSize ) return X.Dom.baseFontSize; if( this._fontSize ) return this._fontSize; - font = this._rawNode.currentStyle.fontSize; + font = this._rawObject.currentStyle.fontSize; //font = this._css && this._css.fontSize || '1em'; vu = X.Dom.Style._splitValueAndUnit( font ); v = vu[ 0 ]; @@ -1128,11 +1128,11 @@ X.Dom.Node.prototype._getCharSize = if( this === Node._body && X.Dom.baseFontSize ) return X.Dom.baseFontSize; if( this._fontSize ) return this._fontSize; - this._rawNode.appendChild( elm = document.createElement( 'span' ) ); + this._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._rawNode.removeChild( elm ); + this._rawObject.removeChild( elm ); return this._fontSize = v; }) : X.Dom.DOM_IE4 ? @@ -1176,7 +1176,7 @@ X.Dom.Node.prototype._getCharSize = Node._body._updateTimerID && Node._body._startUpdate(); if( this._fontSize ) return this._fontSize; - elm = this._rawNode || this._ie4getRawNode(); + elm = this._rawObject || this._ie4getRawNode(); elm.insertAdjacentHTML( 'BeforeEnd', 'X' ); elm = elm.children[ elm.children.length - 1 ]; v = elm.offsetHeight; diff --git a/0.6.x/js/01_dom/20_XDomImage.js b/0.6.x/js/01_dom/20_XDomImage.js index f7823c1..e3ba959 100644 --- a/0.6.x/js/01_dom/20_XDomImage.js +++ b/0.6.x/js/01_dom/20_XDomImage.js @@ -23,12 +23,12 @@ X.Dom.Image = { } ); Node._body._startUpdate(); - img = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawNode; + img = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawObject; remove = true; } else { if( XnodeOrImageElemOrSrc.constructor === X.Dom.Node ){ xnode = XnodeOrImageElemOrSrc; - img = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawNode; + img = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawObject; } else if( X.Type.isHTMLElement( XnodeOrImageElemOrSrc ) ){ img = XnodeOrImageElemOrSrc; @@ -130,7 +130,7 @@ X.Dom.Image = { // if( timer ) return; // これがあると safari3.2 で駄目、、、 this.finish = true; this.timerID && X.Timer.remove( this.timerID ); - if( window.opera && !this.xnode._rawNode.complete ){ + if( window.opera && !this.xnode._rawObject.complete ){ this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } ); return; }; @@ -151,9 +151,9 @@ X.Dom.Image = { }, _detect : function(){ if( this.finish === true ) return; - if( this.xnode._rawNode && this.xnode._rawNode.complete ){ + if( this.xnode._rawObject && this.xnode._rawObject.complete ){ this.finish = true; - if( this.xnode._rawNode.width ) return; + if( this.xnode._rawObject.width ) return; this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } ); return; }; diff --git a/0.6.x/js/01_dom/22_XDomBuilder.js b/0.6.x/js/01_dom/22_XDomBuilder.js index 548d735..bf6cd4e 100644 --- a/0.6.x/js/01_dom/22_XDomBuilder.js +++ b/0.6.x/js/01_dom/22_XDomBuilder.js @@ -56,7 +56,7 @@ if( X.UA.MacIE ){ parent.parentNode.insertBefore( clone, parent ); parent.style.display = 'none'; if( xnode ){ - xnode.parent.parent._rawNode = clone; + xnode.parent.parent._rawObject = clone; }; } else { // ignore @@ -109,7 +109,7 @@ X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, X.Dom.DOM_W3C ? (function(){ var r = Node._body, - body = r._rawNode, + body = r._rawObject, copy, i, l, node, html, elmProgress; // TODO @@ -206,7 +206,7 @@ X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, X.Dom.DOM_IE4 ? (function(){ var r = Node._body, - body = r._rawNode, + body = r._rawObject, elmProgress = '_xdom_builder_progress', html; @@ -350,25 +350,26 @@ X.Dom._bindElementToXnode = if( xnode._tag !== tag ){ alert( '2:[' +parent._tag + '>' +xnode._tag + ' len:' + (xnode._xnodes ? xnode._xnodes.length : '' ) + '] !== ' + tag + ' ' + (elm.childNodes ? elm.childNodes.length : '' ) + '\n' + elm.outerHTML ); } else { - xnode._rawNode = elm; + xnode._rawObject = elm; //if( ( doc = elm.ownerDocument || elm.document ) && ( doc.createElement( 'p' ).tagName === doc.createElement( 'P' ).tagName ) ){ if( tag.charAt( 0 ) === '/' ) tag = tag.slice( 1 ); xnode._tag = tag; //}; xnode._root = parent._root; elm.UID = xnode._uid; + current.xtext = null; if( tag === 'TEXTAREA' ){ xnode.attr( 'value', xnode.html() ).empty(); - current.xtext = null; + } else - if( X.Dom._isCleanupTarget( elm ) ){// !xnode.hasClass( 'skip-cleanup' ) && ( X.Dom.cleanupTagNames[ tag ] || xnode.hasClass( 'cleanup-target' ) ) ){ // ie で body 内の script が2度よばれるのに対処 + //if( X.Dom._isCleanupTarget( elm ) ){// !xnode.hasClass( 'skip-cleanup' ) && ( X.Dom.cleanupTagNames[ tag ] || xnode.hasClass( 'cleanup-target' ) ) ){ // ie で body 内の script が2度よばれるのに対処 //alert( '[' +parent._tag + '>' + xnode._tag + '] remove ... ' ); - xnode.destroy(); - } else + //xnode.destroy(); + //} else if( elm.childNodes && elm.childNodes.length ){ //alert( '[' +parent._tag + '>' + xnode._tag + ' ' + (xnode._xnodes ? xnode._xnodes.length : '' ) + '] === ' + tag + ' ' + (elm.childNodes ? elm.childNodes.length : '' ) + ' Hit\n' + elm.outerHTML ); - current.xtext = null; + //current.xtext = null; ++current.j; return { @@ -383,6 +384,8 @@ X.Dom._bindElementToXnode = skipCleanup : skipCleanup || X.Dom.skipCleanupTagNames[ tag ] }; }; + // nochild + //current.xtext = null; }; ++current.j; break; @@ -402,7 +405,7 @@ X.Dom._bindElementToXnode = }; ++current.j; - xnode._rawNode = elm; + xnode._rawObject = elm; xnode._text = elm.data; // 正確 xnode._root = parent._root; if( !skipCleanup ){ @@ -483,7 +486,7 @@ X.Dom._bindElementToXnode = } else { ++current.j; - xnode._rawNode = elm; + xnode._rawObject = elm; xnode._root = parent._root; //xnode._tag = X.Dom.DTD.TAG_FIX[ tag ] || tag; if( X.Dom._isCleanupTarget( elm ) ){ //!xnode.hasClass( 'skip-cleanup' ) && ( X.Dom.cleanupTagNames[ tag ] || xnode.hasClass( 'cleanup-target' ) ) ){ @@ -522,7 +525,7 @@ X.Dom._bindElementToXnode = }; }; // for - if( !xnode._rawNode ){ + if( !xnode._rawObject ){ alert( xnode._tag + ' ' + xnode._id + ' !== none...' ); };