From: itozyun Date: Thu, 30 Apr 2015 15:35:44 +0000 (+0900) Subject: Version 0.6.144, fix Gesture for iOS4, fix Node.css, fix X.Net. X-Git-Url: http://git.osdn.jp/view?p=pettanr%2FclientJs.git;a=commitdiff_plain;h=36f999435e807f3d04f899b2a84eb1dc31df34b7 Version 0.6.144, fix Gesture for iOS4, fix Node.css, fix X.Net. --- diff --git a/0.6.x/js/01_core/09_XPair.js b/0.6.x/js/01_core/09_XPair.js new file mode 100644 index 0000000..60fb3dc --- /dev/null +++ b/0.6.x/js/01_core/09_XPair.js @@ -0,0 +1,76 @@ +X[ 'Pair' ] = { + 'create' : X_Pair_create, + + 'get' : X_Pair_get, + + 'release' : X_Pair_release +}; + +var X_Pair_SIZE = 1000, + X_Pair_KEY_STORE_LIST = [[]], + X_Pair_PAIR_STORE_LIST = [[]], + X_Pair_functionString = new Function( 's', 'p', 'k', (function(){ + var ret = 'var i=0,l=s.length,a;' + + 'for(;i がある場合、' ), - '', - '', - '' - ]; - X_Net_JSONP_onloadCount = 2; - } else - if( X_UA[ 'IE8' ] ){ - html = [ - // JavaScriptでunicode文字列をunescapeする - // http://perutago.seesaa.net/article/202801583.html + _busy : false, + _canceled : false, - // http://blog.livedoor.jp/dankogai/archives/51503830.html - // Ajax - IE8にもJSON入ってます。使えるとは限らないけど - // Compatibility mode (別名Quirks mode) では、JSONオブジェクトは無効になります。iframeもだめです - '', - '' + load : function( option ){ + //createURL + var url = option[ 'url' ], + json2Path = 'js/libs/json2.js', + json2FileSize = 18103, + html; + + // TODO ' 化 恐らくアンチウイルスソフトが反応しないための対策 + // document.postMessage()→window.postMessage() (Opera 9.50 build 9841 -) + // http://d.hatena.ne.jp/cnrd/20080518/1211099169 + // 最近の仕様変更(引数のtargetOriginとかMessageEventのoriginとか)にはまだ対応してないみたい - /* 以下のコードは XP ie8 では動くけど、win8 IE11(8モード)で動かない 開発の便宜を取って,setTimeout を挟む - '', - '' */ - ]; - X_Net_JSONP_onloadCount = 2; - } else - if( X_UA[ 'IE9' ] ){ - html = [ - '', - '' - ]; - X_Net_JSONP_onloadCount = 2; - } else - if( window[ 'JSON' ] ){ - html = [ - '', - '' - ]; - X_Net_JSONP_onloadCount = 1; - } else - if( X_UA[ 'IE4' ] || X_UA[ 'MacIE' ] ){ - html = [ - '', - '', - '' - ]; - X_Net_JSONP_onloadCount = 3; - } else - if( X_UA[ 'IE' ] < 8 ){ // ie5-7 - html = [ - '', - '', - '' - ]; - X_Net_JSONP_onloadCount = 3; - } else { - html = [ - '', - '', - '' - ]; - X_Net_JSONP_onloadCount = 1; - }; - - X_NET_JSONP_NinjaIframe - [ 'refresh' ]( html.join( '' ) ) - [ 'listen' ]( [ X_EVENT_SUCCESS, X_EVENT_ERROR ], X_NET_JSONPWrapper, X_NET_JSONP_iframeListener ); + if( X_UA[ 'Opera' ] ){ + html = [ + ( window[ 'JSON' ] ? '' : '' ), + '', + '', + '' + ]; + X_Net_JSONP_maxOnloadCount = 2; + } else + if( X_UA[ 'IE8' ] ){ + html = [ + // JavaScriptでunicode文字列をunescapeする + // http://perutago.seesaa.net/article/202801583.html + + // http://blog.livedoor.jp/dankogai/archives/51503830.html + // Ajax - IE8にもJSON入ってます。使えるとは限らないけど + // Compatibility mode (別名Quirks mode) では、JSONオブジェクトは無効になります。iframeもだめです + '', + '' + + /* 以下のコードは XP ie8 では動くけど、win8 IE11(8モード)で動かない 開発の便宜を取って,setTimeout を挟む + '', + '' */ + ]; + X_Net_JSONP_maxOnloadCount = 2; + } else + if( X_UA[ 'IE9' ] ){ + html = [ + '', + '' + ]; + X_Net_JSONP_maxOnloadCount = 2; + } else + if( window[ 'JSON' ] ){ + html = [ + '', + '' + ]; + X_Net_JSONP_maxOnloadCount = 1; + } else + if( X_UA[ 'IE4' ] || X_UA[ 'MacIE' ] ){ + html = [ + '', + '', + '' + ]; + X_Net_JSONP_maxOnloadCount = 3; + } else + if( X_UA[ 'IE' ] < 8 ){ // ie5-7 + html = [ + '', + '', + '' + ]; + X_Net_JSONP_maxOnloadCount = 3; + } else { + html = [ + '', + '', + '' + ]; + X_Net_JSONP_maxOnloadCount = 2; + }; + + X_NET_JSONPWrapper + [ 'refresh' ]( html.join( '' ) ) + [ 'listen' ]( [ 'ninjaload', 'ninjaerror' ], X_NET_JSONP_iframeListener ); + + X_NET_JSONPWrapper._busy = true; + }, + + cancel : function(){ + X_NET_JSONPWrapper.reset(); + X_NET_JSONPWrapper._canceled = true; + }, + + reset : function(){ + X_NET_JSONPWrapper._busy = X_NET_JSONPWrapper._canceled = false; + X_Net_JSONP_onloadCount = 0; + X_NET_JSONPWrapper[ 'unlisten' ]( [ 'ninjaload', 'ninjaerror' ], X_NET_JSONP_iframeListener ); + X_NET_JSONPWrapper[ 'refresh' ]( '' ); + X_Net_JSONP_errorTimerID && X_Timer_remove( X_Net_JSONP_errorTimerID ); + } + } + ); }; - function X_NET_JSONP_iframeListener( e ){ switch( e.type ){ - case X_EVENT_SUCCESS : - console.log( 'iframe onload, but ' + X_NET_JSONPWrapper._onloadCount + ' < ' + X_Net_JSONP_onloadCount ); - if( ++X_NET_JSONPWrapper._onloadCount < X_Net_JSONP_onloadCount ) return; - // TODO callback が無ければ error - X_NET_JSONPWrapper[ 'asyncDispatch' ]( 1000, X_EVENT_ERROR ); + case 'ninjaload' : + console.log( 'iframe onload, but ' + X_Net_JSONP_onloadCount + ' < ' + X_Net_JSONP_maxOnloadCount ); + if( ++X_Net_JSONP_onloadCount < X_Net_JSONP_maxOnloadCount ) return; + + // TODO callback が無ければ error -> timeout を観る? + X_Net_JSONP_errorTimerID = X_NET_JSONPWrapper[ 'asyncDispatch' ]( 1000, X_EVENT_ERROR ); break; - case X_EVENT_ERROR : + case 'ninjaerror' : console.log( 'iframe onerror' ); X_NET_JSONPWrapper[ 'asyncDispatch' ]( X_EVENT_ERROR ); break; }; - X_EventDispatcher_unlistenAll( X_NET_JSONP_NinjaIframe ); return X_Callback_UN_LISTEN; }; - -// TODO extend NinjaIframe -X_NET_JSONPWrapper = X_Class_override( - X_EventDispatcher(), - { - - _busy : false, - _canceled : false, - _onloadCount : 0, - - load : function( url, data, timeout ){ - //createURL - X_NET_JSONP_loadScriptInNinjaIframe( url ); - - this._busy = true; - }, - - cancel : function(){ - this._canceled = true; - }, - - reset : function(){ - this._busy = this._canceled = false; - this._onloadCount = 0; - } - } -); diff --git a/0.6.x/js/06_net/04_XNetImage.js b/0.6.x/js/06_net/04_XNetImage.js index 9f5be7a..7ec0e7d 100644 --- a/0.6.x/js/06_net/04_XNetImage.js +++ b/0.6.x/js/06_net/04_XNetImage.js @@ -26,6 +26,11 @@ if( X_Net_Image_isElement ){ * * Opera7 では毎回 image を作る必要あり、src が異なればOK? */ + +X_TEMP.X_NET_Image_init = function(){ + +delete X_TEMP.X_NET_Image_init; + X_NET_ImageWrapper = X_Class_override( !X_Net_Image_isElement ? X_EventDispatcher( X_Net_Image_image ) : Node( X_Net_Image_image ), { @@ -40,71 +45,16 @@ X_NET_ImageWrapper = X_Class_override( load : function( data ){ this._busy = true; - this.abspath = X.URL.toAbsolutePath( data.url ); - this.delay = data.delay || 100; - this.timeout = data.timeout || 5000; + this.abspath = X_URL_toAbsolutePath( data[ 'url' ] ); + this.delay = data[ 'delay' ] || 100; + this.timeout = data[ 'timeout' ] || 5000; this[ '_rawObject' ].src = this.abspath; if( X_UA[ 'Opera7' ] && this[ '_rawObject' ].complete ){ this[ 'asyncDispatch' ]( 'load' ); } else { - this.timerID = X_Timer_add( this.delay, 0, this, this._detect ); - }; - }, - - handleEvent : function( e ){ - var size; - switch( e.type ){ - case 'error' : - //case 'abort' : // TODO ?? - if( this.finish ) return; - this._busy = false; - this.finish = true; - this.timerID && X_Timer_remove( this.timerID ); - this.timerID = this[ 'asyncDispatch' ]( /*e.type === 'error' ?*/ X_EVENT_ERROR /*: X_EVENT_CANCELED*/ ); - break; - case 'load' : - // if( finish === true ) return; // これがあると firefox3.6 で駄目、、、 - // if( timer ) return; // これがあると safari3.2 で駄目、、、 - this._busy = false; - this.finish = true; - this.timerID && X_Timer_remove( this.timerID ); - if( X_UA[ 'Opera' ] && !this[ '_rawObject' ].complete ){ - this.timerID = this[ 'asyncDispatch' ]( X_EVENT_ERROR ); - return; - }; - size = X.Util.Image.getActualDimension( !X_Net_Image_isElement ? this.abspath : this ); - this.timerID = this[ 'asyncDispatch' ]( { - type : X_EVENT_SUCCESS, - src : this.abspath, - w : size[ 0 ], - h : size[ 1 ] - // TODO feedback net speed - // time , this[ '_rawObject' ].fileSize - } ); - break; - case X_EVENT_KILL_INSTANCE : - this.reset(); - !X_Net_Image_hasImage && this[ 'kill' ](); // if xnode - break; - }; - }, - - _detect : function(){ - if( this.finish ) return; - if( this[ '_rawObject' ] && this[ '_rawObject' ].complete ){ - this._busy = false; - this.finish = true; - if( this[ '_rawObject' ].width ) return; - X_Timer_remove( this.timerID ); - this.timerID = this[ 'asyncDispatch' ]( X_EVENT_ERROR ); - } else - if( this.timeout < ( this.tick += this.delay ) ){ - this._busy = false; - this.finish = true; - X_Timer_remove( this.timerID ); - this.timerID = this[ 'asyncDispatch' ]( X_EVENT_TIMEOUT ); + this.timerID = X_Timer_add( this.delay, 0, this, X_NET_Image_detect ); }; }, @@ -114,7 +64,6 @@ X_NET_ImageWrapper = X_Class_override( // this[ '_rawObject' ].src = ''; this._busy = false; this.finish = true; - this[ 'asyncDispatch' ]( X_EVENT_CANCELED ); }, reset : function(){ @@ -129,6 +78,70 @@ X_NET_ImageWrapper = X_Class_override( } ); -X_NET_ImageWrapper[ 'listen' ]( [ 'load', 'error' /*, 'abort'*/, X_EVENT_KILL_INSTANCE ] ); +X_NET_ImageWrapper[ 'listen' ]( [ 'load', 'error' /*, 'abort'*/, X_EVENT_KILL_INSTANCE ], X_NET_Image_handleEvent ); + +return X_NET_ImageWrapper; + +}; + +function X_NET_Image_detect(){ + if( this.finish ) return; + if( this[ '_rawObject' ] && this[ '_rawObject' ].complete ){ + this._busy = false; + this.finish = true; + if( this[ '_rawObject' ].width ) return; + X_Timer_remove( this.timerID ); + this.timerID = this[ 'asyncDispatch' ]( X_EVENT_ERROR ); + } else + if( this.timeout < ( this.tick += this.delay ) ){ + this._busy = false; + this.finish = true; + X_Timer_remove( this.timerID ); + this.timerID = this[ 'asyncDispatch' ]( X_EVENT_TIMEOUT ); + }; +}; + +function X_NET_Image_handleEvent( e ){ + var size; + + switch( e.type ){ + case 'error' : + //case 'abort' : // TODO ?? + if( this.finish ) return; + this._busy = false; + this.finish = true; + this.timerID && X_Timer_remove( this.timerID ); + this.timerID = this[ 'asyncDispatch' ]( /*e.type === 'error' ?*/ X_EVENT_ERROR /*: X_EVENT_CANCELED*/ ); + break; + + case 'load' : + // if( finish === true ) return; // これがあると firefox3.6 で駄目、、、 + // if( timer ) return; // これがあると safari3.2 で駄目、、、 + this._busy = false; + this.finish = true; + this.timerID && X_Timer_remove( this.timerID ); + if( X_UA[ 'Opera' ] && !this[ '_rawObject' ].complete ){ + this.timerID = this[ 'asyncDispatch' ]( X_EVENT_ERROR ); + return; + }; + + size = X_Util_Image_getActualDimension( !X_Net_Image_isElement ? this.abspath : this ); + this.timerID = this[ 'asyncDispatch' ]( { + type : X_EVENT_SUCCESS, + src : this.abspath, + w : size[ 0 ], + h : size[ 1 ] + // TODO feedback net speed + // time , this[ '_rawObject' ].fileSize + } ); + break; + + case X_EVENT_KILL_INSTANCE : + this.reset(); + !X_Net_Image_hasImage && this[ 'kill' ](); // if xnode + break; + }; +}; + // X_Net_Image_isElement && X_NET_ImageWrapper[ 'appendAt' ]( X.X_Node_systemNode ); diff --git a/0.6.x/js/07_audio/01_XWebAudio.js b/0.6.x/js/07_audio/01_XWebAudio.js index 8a5e1ed..958b441 100644 --- a/0.6.x/js/07_audio/01_XWebAudio.js +++ b/0.6.x/js/07_audio/01_XWebAudio.js @@ -69,7 +69,7 @@ if( X_Audio_WebAudio_context ){ // TODO 当てにしていたaudioがclose 等した場合 audio.proxy[ 'listenOnce' ]( 'canplaythrough', this, this._onBufferReady ); } else { - this.xhr = X.Net.xhrGet( url, { type : 'arraybuffer' } ) + this.xhr = X.Net( { 'xhr' : url, 'type' : 'arraybuffer' } ) [ 'listen' ]( X_EVENT_PROGRESS, this ) [ 'listenOnce' ]( [ X_EVENT_SUCCESS, X_EVENT_COMPLETE, X_EVENT_CANCELED ], this ); }; diff --git a/0.6.x/js/20_ui/05_XUI_Gesture.js b/0.6.x/js/20_ui/05_XUI_Gesture.js index 355fbaf..bcf156f 100644 --- a/0.6.x/js/20_ui/05_XUI_Gesture.js +++ b/0.6.x/js/20_ui/05_XUI_Gesture.js @@ -79,34 +79,17 @@ // and we are now handling a mouse event, we stop that to prevent conflicts if( enable_detect ){ // update pointerevent - if( Hammer.HAS_POINTEREVENTS ){ //eventType !== Hammer.EVENT_END ){ - console.log( 'e.pointerId = ' + e.pointerId ); - POINTERS[ e.identifier = e.pointerId ] = type & END ? null : e; - touches = []; - numTouches = -1; - // we can use forEach since pointerEvents only is in IE10 - for( i = 0, l = POINTERS.length; i < l; ++i ){ - POINTERS[ i ] && ( touches[ ++numTouches ] = POINTERS[ i ] ); - }; - numTouches = touches.length; - - ///console.log( 'numTouches ' + numTouches ); - } else - // touch - if ( type & TOUCH ){ //sourceEventType.match(/touch/)) { - touches = Hammer.DO_TOUCHES_FIX && type & END ? [] : e.touches; - numTouches = touches.length; - } else - // mouse - if( !touch_triggered ){ - numTouches = ( type & END ) ? 0 : 1; - touches = numTouches === 0 ? [] : [{ - identifier : 1, - pageX : e.pageX, - pageY : e.pageY, - target : e.target - }]; + + POINTERS[ e.pointerId ] = type & END ? null : e; + touches = []; + numTouches = -1; + // we can use forEach since pointerEvents only is in IE10 + for( i in POINTERS ){ + POINTERS[ i ] && ( touches[ ++numTouches ] = POINTERS[ i ] ); }; + ++numTouches; + ///console.log( 'numTouches ' + numTouches ); + // if we are in a end event, but when we remove one touch and // we still have enough, set eventType to move if( 0 < numTouches && type & END ){ // eventType === Hammer.EVENT_END ){ diff --git a/0.6.x/js/import.js b/0.6.x/js/import.js index 4b34d64..e260590 100644 --- a/0.6.x/js/import.js +++ b/0.6.x/js/import.js @@ -14,7 +14,8 @@ document.write( [ 'js/01_core/04_XObject.js', 'js/01_core/05_XString.js', 'js/01_core/06_XURL.js', - + + 'js/01_core/09_XPair.js', 'js/01_core/10_XCallback.js', 'js/01_core/11_XClass.js', 'js/01_core/12_XEvent.js',