From 5af7809cfb475642413a4275af29fbf7d783a170 Mon Sep 17 00:00:00 2001 From: itozyun Date: Fri, 23 Oct 2015 00:54:53 +0900 Subject: [PATCH] Version 0.6.182, fix X.UA. --- 0.6.x/js/01_core/01_X.js | 4 +-- 0.6.x/js/01_core/05_XArray.js | 8 +++--- 0.6.x/js/01_core/06_XString.js | 56 ++++++++++++++++++++++++-------------- 0.6.x/js/01_core/20_XSystem.js | 2 +- 0.6.x/js/07_audio/01_XWebAudio.js | 5 ++-- 0.6.x/js/07_audio/02_XHTMLAudio.js | 50 ++++++++++++++++++++-------------- 0.6.x/js/20_ui/02_XUI_Attr.js | 4 +-- 0.6.x/js/20_ui/15_ScrollBox.js | 19 +++++++++---- 8 files changed, 90 insertions(+), 58 deletions(-) diff --git a/0.6.x/js/01_core/01_X.js b/0.6.x/js/01_core/01_X.js index 5c0ef3d..1581967 100644 --- a/0.6.x/js/01_core/01_X.js +++ b/0.6.x/js/01_core/01_X.js @@ -46,9 +46,9 @@ var undefined, X_shortcutContext; /** - * バージョン文字列:"0.6.123" + * バージョン文字列:"0.6.xxx" * @type {string} */ -X[ 'VERSION' ] = '0.6.143'; +X[ 'VERSION' ] = '0.6.181'; /** * ブートタイム ms diff --git a/0.6.x/js/01_core/05_XArray.js b/0.6.x/js/01_core/05_XArray.js index 4154c56..c28834c 100644 --- a/0.6.x/js/01_core/05_XArray.js +++ b/0.6.x/js/01_core/05_XArray.js @@ -19,11 +19,11 @@ X[ 'Array' ] = { */ function X_Array_copy( ary ){ var ret = [], - i = ary.length; + i = 0, + l = ary.length; - if( !i ) return ret; - for( ; i; ){ - ret[ --i ] = ary[ i ]; + for( ; i < l; ++i ){ + ret[ i ] = ary[ i ]; }; return ret; }; diff --git a/0.6.x/js/01_core/06_XString.js b/0.6.x/js/01_core/06_XString.js index 7af321c..aa7d1f2 100644 --- a/0.6.x/js/01_core/06_XString.js +++ b/0.6.x/js/01_core/06_XString.js @@ -40,7 +40,8 @@ X[ 'String' ] = { * @return {*} */ function X_String_parse( v ){ - var _v, n; + var _v; + if( X_Type_isString( v ) ){ switch( v ){ case '' : return v; @@ -57,8 +58,7 @@ function X_String_parse( v ){ case 'undefined' : return; }; _v = v.split( ' ' ).join( '' ); - n = _v - 0; - if( '' + n === _v || '' + n === '0' + _v ) return n; + if( X_String_isNumberString( _v ) ) return _v - 0; }; return v; }; @@ -66,22 +66,32 @@ function X_String_parse( v ){ /** *

空白文字を半角スペースに変換します。\n\r,\t,\r,\n,\f,\b *

2つ以上の連続する半角スペースを一つの半角スペースにします。 + *

undefined, null が与えられた場合は '' を返します。 + *

数値,Object が与えられた場合は toString します。 * @alias X.String.cleanupWhiteSpace * @param {string} * @return {string} */ function X_String_cleanupWhiteSpace( text ){ - var _ = ' ', __ = ' ', CRLF = X_String_CRLF; + var _ = ' ', __ = ' '; //, CRLF = X_String_CRLF; - if( !text ) return ''; + if( text == null || text === '' ) return ''; //text.indexOf( CRLF ) !== -1 && ( text = text.split( CRLF ).join( _ ) ); - text.indexOf( '\n\r' ) !== -1 && ( text = text.split( '\n\r' ).join( _ ) ); + /*text.indexOf( '\n\r' ) !== -1 && ( text = text.split( '\n\r' ).join( _ ) ); text.indexOf( '\t' ) !== -1 && ( text = text.split( '\t' ).join( _ ) ); text.indexOf( '\r' ) !== -1 && ( text = text.split( '\r' ).join( _ ) ); text.indexOf( '\n' ) !== -1 && ( text = text.split( '\n' ).join( _ ) ); text.indexOf( '\f' ) !== -1 && ( text = text.split( '\f' ).join( _ ) ); - text.indexOf( '\b' ) !== -1 && ( text = text.split( '\b' ).join( _ ) ); + text.indexOf( '\b' ) !== -1 && ( text = text.split( '\b' ).join( _ ) ); */ + + text = text.toString() + .split( X_String_CRLF ).join( _ ) + .split( '\r' ).join( _ ) + .split( '\n' ).join( _ ) + .split( '\t' ).join( _ ) + .split( '\f' ).join( _ ) + .split( '\b' ).join( _ ); while( true ){ text = text.split( __ ); @@ -92,17 +102,19 @@ function X_String_cleanupWhiteSpace( text ){ /** * 空白文字列を <br> に変換します。タブを &nbsp; 4つに変換します。 + *

undefined, null が与えられた場合は '' を返します。 + *

数値,Object が与えられた場合は toString します。 * @alias X.String.whiteSpaceToTag * @param {string} * @return {string} html文字列 */ function X_String_whiteSpaceToTag( text ){ - if( text == null ) return ''; + if( text == null || text === '' ) return ''; return text.toString() //.split( '\r\n\r\n' ).join( '
' ) //.split( '\n\r\n\r' ).join( '
' ) //.split( '\r\n' ).join( '
' ) - .split( '\n\r' ).join( '
' ) + .split( X_String_CRLF ).join( '
' ) .split( '\r' ).join( '
' ) .split( '\n' ).join( '
' ) .split( '\t' ).join( '    ' ) @@ -112,40 +124,44 @@ function X_String_whiteSpaceToTag( text ){ /** * 一部の文字実体参照をデコードします。", &, <, >,   + *

undefined, null が与えられた場合は '' を返します。 + *

数値,Object が与えられた場合は toString します。 * @alias X.String.chrReferanceTo * @param {string} * @return {string} html文字列 */ function X_String_chrReferanceTo( str ){ - if( str == null ) return ''; + if( str == null || str === '' ) return ''; return str.toString() - .split( '"' ).join( '"' ) // first! - .split( '&' ).join( '&' ) - .split( '<' ).join( '<' ) - .split( '>' ).join( '>' ) - .split( ' ' ).join( ' ' ); + .split( '"' ).join( '"' ) + .split( ''' ).join( "'" ) + .split( '<' ).join( '<' ) + .split( '>' ).join( '>' ) + .split( ' ' ).join( ' ' ) + .split( '&' ).join( '&' ); // last! }; /** * htmlタグで使われる文字を文字実体参照に変換します。", &, <, >,   + *

undefined, null が与えられた場合は '' を返します。 + *

数値,Object が与えられた場合は toString します。 * @alias X.String.chrReferanceTo * @param {string} * @return {string} */ function X_String_toChrReferance( str ){ - if( str == null ) return ''; - str += ''; + if( str == null || str === '' ) return ''; return str.toString() - .split( '&' ).join( '&' ) + .split( '&' ).join( '&' ) // first! .split( '"' ).join( '"' ) - .split( '"' ).join( ''' ) + .split( "'" ).join( ''' ) .split( '<' ).join( '<' ) .split( '>' ).join( '>' ) .split( ' ' ).join( ' ' ); }; /** - * htmlタグで使われる文字を文字実体参照に変換します。", &, <, >,   + * 文字列化した数値か?調べます。 * @alias X.String.isNumberString * @param {string} * @return {boolean} diff --git a/0.6.x/js/01_core/20_XSystem.js b/0.6.x/js/01_core/20_XSystem.js index 3289140..feef443 100644 --- a/0.6.x/js/01_core/20_XSystem.js +++ b/0.6.x/js/01_core/20_XSystem.js @@ -56,7 +56,7 @@ X_TEMP.onRearchEndOfScript = function(){ var callbacks = X_TEMP.onSystemReady, i = callbacks.length, now = X_Timer_now(), - speed = now - X.bootTime; + speed = now - X[ 'bootTime' ]; X_System_javascriptScore = speed; console.log( 'js score ' + speed ); diff --git a/0.6.x/js/07_audio/01_XWebAudio.js b/0.6.x/js/07_audio/01_XWebAudio.js index c9fa1ed..966f667 100644 --- a/0.6.x/js/07_audio/01_XWebAudio.js +++ b/0.6.x/js/07_audio/01_XWebAudio.js @@ -78,9 +78,10 @@ if( X_Audio_constructor ){ }; -var X_WebAudio_context = !X_UA[ 'iPhone_4s' ] && !X_UA[ 'iPad_2Mini1' ] && !X_UA[ 'iPod_4' ] && +var X_WebAudio_context = // 4s 以下ではない iPad 2G または iPad mini 1G 以下ではない, iPod touch 4G 以下ではない + !X_UA[ 'iPhone_4s' ] && !X_UA[ 'iPad_2Mini1' ] && !X_UA[ 'iPod_4' ] && // Android2 + Gecko で WebAudio が極めて不安定 - !X_UA[ 'Fennec' ] && + !( X_UA[ 'Fennec' ] && X_UA[ 'Android' ] < 3 ) && // Firefox40.0.5 + Windows8 で音声が途中から鳴らなくなる // Firefox41.0.1 + Windows8 で音声が途中から鳴らなくなる !( 40 <= X_UA[ 'Gecko' ] && X_UA[ 'Gecko' ] < 42 && X_UA[ 'Windows' ] ) && diff --git a/0.6.x/js/07_audio/02_XHTMLAudio.js b/0.6.x/js/07_audio/02_XHTMLAudio.js index 1ab50db..4095242 100644 --- a/0.6.x/js/07_audio/02_XHTMLAudio.js +++ b/0.6.x/js/07_audio/02_XHTMLAudio.js @@ -83,6 +83,14 @@ if( X_Audio_constructor ){ _ready : false, _src : '', + // 0: + // 1: touch 要求完了 + // 2: touch による play 中 + // 4: duration 取得完了 currentTime へのセット + // 8: playing || loadeddata or canplaythrought + // 16: READY 発火済 + _readyState : 0, + _touchRequested : false, _touched : false, @@ -125,13 +133,6 @@ if( X_Audio_constructor ){ } else { raw = X_TEMP.rawAudio || new X_Audio_constructor( '' ); // X_Doc_create( 'audio', { src : source } )[ 'appendTo' ]( X.Doc.body ); - - raw.preload = 'auto'; - //if( X_UA[ 'AOSP' ] < 4.2 ){ - raw.autoplay = true; //raw.autobuffer = true; // Android 4.0-4.1.x で必要 - //} else { - // raw.autoplay = raw.autobuffer = false; - //}; //raw.autoplay = raw.autobuffer = raw.loop = false; // loop を使えば ended で止まること回避できるかも 但し ended イベントが起きなくなる if( X_TEMP.rawAudio ) delete X_TEMP.rawAudio; @@ -143,7 +144,7 @@ if( X_Audio_constructor ){ X_EVENT_KILL_INSTANCE, X_HTMLAudio_playTrigger, //'loadstart', 'load', - 'progress', 'error', + 'progress', //'error', // 'suspend', 'abort', 'emptied', 'stalled', // 'play', 'pause', 'seeked', 'ratechange', 'volumechange', 'loadedmetadata', 'loadeddata', 'canplay', 'canplaythrough', @@ -159,8 +160,15 @@ if( X_Audio_constructor ){ 'playing', 'waiting', 'seeking', 'durationchange', 'timeupdate', 'ended' ], this.onDebug ); - raw.src = source; - raw.load(); // Android4.1.1 HTL21 では必要! + if( X_HTMLAudio_need1stTouch ){ + raw.src = source; + } else { + raw.preload = 'auto'; + raw.autoplay = true; // Android 4.0-4.1.x で必要 + //raw.autobuffer = true; + raw.src = source; + raw.load(); // Android4.1.1 HTL21 では必要! + }; }, onDebug : function( e ){ @@ -215,9 +223,7 @@ if( X_Audio_constructor ){ }; case 'canplay' : // 今すぐに再生を再開できるが、バッファリングが不十分でコンテンツを最後まで表示できないと予測している場合に発生 if( X_HTMLAudio_durationFix && !X_HTMLAudio_need1stTouch && this._durationFixPhase === 1 ){ - console.log( '▲ DurationFix の開始 @' + e.type ); - this._durationFixPhase = 2; - raw.play(); + this.actualPlay(); raw.currentTime = 0; // 必要! }; if( this._endedFixON ){ @@ -271,10 +277,10 @@ if( X_Audio_constructor ){ //case 'abort' : // ダウンロードの完了前にコンテンツの取得を停止した場合に発生(この停止はエラーによるものではない) // break; - case 'error' : // コンテンツの取得実行中にエラーが発生した場合に発生 + //case 'error' : // コンテンツの取得実行中にエラーが発生した場合に発生 // Opera12 src = '' で error が発生、無視する // eventType = X_EVENT_ERROR; - break; + //break; case 'playing' : // 再生が開始された場合に発生 if( X_HTMLAudio_volumeFix ){ @@ -329,9 +335,10 @@ if( X_Audio_constructor ){ this._loaded = this._loaded || ready; // - if( X_HTMLAudio_need1stTouch && !this._touchRequested ){ + if( X_HTMLAudio_need1stTouch && !this._touchRequested ){ // !this._readyState if( e.type === X_HTMLAudio_playTrigger ){ this._touchRequested = true; + this._readyState = 1; this.disatcher[ 'asyncDispatch' ]( X_EVENT_MEDIA_CAN_TOUCH_LOAD ); }; } else @@ -354,12 +361,12 @@ if( X_Audio_constructor ){ if( this._loaded && this.duration && !this._ready ){ this._ready = true; this.disatcher[ 'asyncDispatch' ]( X_EVENT_READY ); - this.autoplay && !X_WebAudio_need1stTouch && X_Timer_once( 16, this, this.play ); + this.autoplay && !X_HTMLAudio_need1stTouch && X_Timer_once( 16, this, this.actualPlay ); console.log( '> Audio Loaded!! ' + e.type + ' d:' + ( this.duration | 0 ) ); } else if( eventType ){ this.disatcher[ 'dispatch' ]( eventType ); - eventType === X_EVENT_ERROR && this[ 'kill' ](); + // eventType === X_EVENT_ERROR && this[ 'kill' ](); }; }, @@ -377,15 +384,16 @@ if( X_Audio_constructor ){ //return; }; - if( this._touchRequested && !this._touched ){ + if( this._touchRequested && !this._touched ){ // this._readyState === 1 e = X_EventDispatcher_CURRENT_EVENTS[ X_EventDispatcher_CURRENT_EVENTS.length - 1 ]; if( !e || !e[ 'pointerType' ] ){ alert( 'タッチイベント以外での play! ' + e.type ); return; }; this._touched = true; + this._readyState = 2; } else - if( !this._ready && ( !X_HTMLAudio_durationFix || !X_HTMLAudio_need1stTouch ) ){ + if( !this._ready && ( !X_HTMLAudio_durationFix || !X_HTMLAudio_need1stTouch ) ){ // this._readyState < 2 this.autoplay = true; return; }; @@ -429,7 +437,7 @@ if( X_Audio_constructor ){ //また、GoogleChrome7 では currentTime = 0 直後に play() すると、pause()した位置前後の音が混ざることがある。(少なくとも自分の環境では) // iOS で duration が 0 の時に触ると error - if( !X_HTMLAudio_durationFix || this.duration ) raw.currentTime = this._lastCurrentTime; + if( !X_HTMLAudio_durationFix || this.duration ) raw.currentTime = this._lastCurrentTime; // 2 < this._readyState console.log( '[HTMLAudio] play ' + begin + ' -> ' + end + ' crt:' + ( raw.currentTime | 0 ) + ' last:' + this._lastCurrentTime ); diff --git a/0.6.x/js/20_ui/02_XUI_Attr.js b/0.6.x/js/20_ui/02_XUI_Attr.js index 26b9b3c..447c496 100644 --- a/0.6.x/js/20_ui/02_XUI_Attr.js +++ b/0.6.x/js/20_ui/02_XUI_Attr.js @@ -176,7 +176,7 @@ function XUI_Attr_copy( proto, supports ){ var support, p; for( p in supports ){ - if( X_EMPTY_OBJECT[ p ] ) continue; + //if( X_EMPTY_OBJECT[ p ] ) continue; if( p === '_last' ) continue; support = supports[ p ]; proto[ support.No ] = support[ 0 ]; @@ -205,7 +205,7 @@ function XUI_Attr_preset( baseKlass, opt_supports, opt_attrs ){ // setAttr に書き換え XUI_attrClassProto = proto; for( p in opt_attrs ){ - if( X_EMPTY_OBJECT[ p ] ) continue; + //if( X_EMPTY_OBJECT[ p ] ) continue; supports[ p ] && XUI_AbstractUINode.prototype.setAttr( p, supports[ p ], opt_attrs[ p ] ); }; XUI_attrClassProto = null; diff --git a/0.6.x/js/20_ui/15_ScrollBox.js b/0.6.x/js/20_ui/15_ScrollBox.js index 5e49890..817ebdb 100644 --- a/0.6.x/js/20_ui/15_ScrollBox.js +++ b/0.6.x/js/20_ui/15_ScrollBox.js @@ -1,4 +1,8 @@ - +/* + * scroll 要素は常にひとつ + * ScrollManager + * indicatorX, Y は再利用 + */ var X_UI_ScrollBox_SUPPORT_ATTRS = { @@ -76,6 +80,9 @@ var XUI_ScrollBox = XUI_ChromeBox.inherits( _containerNode : null, xnodeSlider : null, + xnodeIndicatorX : null, + xnodeIndicatorY : null, + Constructor : function( user, layout, args ){ this[ 'Super' ]( user, layout, args ); this._containerNode = X_Pair_get( this.containerNode ); @@ -136,14 +143,14 @@ function X_UI_ScrollBox_onLayoutBefore( e ){ }; this.scrollXRatio = this.scrollX ? this.scrollXMax / this.scrollX : 0; this.scrollYRatio = this.scrollY ? this.scrollYMax / this.scrollY : 0; - this.xnodeSlider.stop(); + this.xnodeSlider[ 'stop' ](); this.isInTransition = false; return X_CALLBACK_NONE; }; function X_UI_ScrollBox_onLayoutComplete( e ){ // scroll の停止、GPU の解除 - var font = this.fontSize = this.xnodeSlider.call( 'fontSize' ); + var font = this.fontSize = this.xnodeSlider[ 'call' ]( 'fontSize' ); this.scrollXMax = ( this.boxWidth - this._containerNode.boxWidth ) * font | 0; this.scrollYMax = ( this.boxHeight - this._containerNode.boxHeight ) * font | 0; @@ -182,7 +189,7 @@ function X_UI_ScrollBox_onLayoutComplete( e ){ if( this.scrolling ){ // scroller 削除 this[ 'unlisten' ]( XUI_Event._POINTER_DOWN, this, X_UI_ScrollBox_onStart ); - X_UI_rootData[ 'unlisten' ]( XUI_Event.LAYOUT_BEFORE, this, X_UI_ScrollBox_onLayoutBefore ); + X_UI_rootData[ 'unlisten' ]( XUI_Event.LAYOUT_BEFORE, this, X_UI_ScrollBox_onLayoutBefore ); ( this.scrollX !== 0 || this.scrollY !== 0 ) && X_UI_ScrollBox_translate( this, 0, 0, 100, '', 300 ); @@ -199,7 +206,7 @@ function X_UI_ScrollBox_onLayoutComplete( e ){ opt_easing = opt_easing === '' ? '' : opt_easing || 'circular'; opt_release = 0 <= opt_release ? opt_release : 300; - that.xnodeSlider.animate( + that.xnodeSlider[ 'animate' ]( { x : that.scrollX, y : that.scrollY @@ -247,7 +254,7 @@ function X_UI_ScrollBox_onStart( e ){ this.isInTransition = false; this[ 'dispatch' ]( XUI_Event.SCROLL_END ); // TODO current位置 - this.xnodeSlider.stop(); + this.xnodeSlider[ 'stop' ](); }; this.startX = this.scrollX; -- 2.11.0