• R/O
  • HTTP
  • SSH
  • HTTPS

clientJs: コミット

クライアント側 js 開発用


コミットメタ情報

リビジョン9f1658e2858d8eed1c3933184aa7858596015b61 (tree)
日時2014-08-19 22:43:15
作者itozyun <itozyun@user...>
コミッターitozyun

ログメッセージ

Version 0.6.64, fixed X.Callback & function-hash, working Touch & Pointer Event.

変更サマリ

差分

--- a/0.6.x/css/xui.css
+++ b/0.6.x/css/xui.css
@@ -79,7 +79,6 @@ html, body {
7979 .ActiveX-enabled .mouse-operation-catcher {
8080 background-color : #fff;
8181 filter : alpha( opacity=0 );
82- -ms-filter : alpha( opacity=0 );
8382 }
8483 /*
8584 * ie では、背景を設定しないと、 mousemove が働かない。
@@ -99,7 +98,7 @@ html, body {
9998 left : 0;
10099 top : 0;
101100 visibility : hidden;
102- z-index : 99;
101+ /*z-index : 99;*/
103102 }
104103
105104 /* Scrollbox
--- a/0.6.x/js/core/01_XUa.js
+++ b/0.6.x/js/core/01_XUa.js
@@ -10,9 +10,12 @@ X.UA = (function( n, undefined ){
1010 i, j, v;
1111
1212 console.log( ' userAgent : ' + dua );
13+ console.log( '-' );
1314 console.log( ' appVersion : ' + dav );
15+ console.log( '-' );
1416 console.log( ' platform : ' + n.platform );
15-
17+ console.log( '-' );
18+
1619 if( window.opera ){
1720 i = dua.indexOf( 'Opera' ); // Opera/
1821 j = dua.indexOf( 'Version/' );
@@ -125,6 +128,8 @@ X.UA = (function( n, undefined ){
125128 acme.WebKit = i = parseFloat(dua.split("WebKit\/")[1]) || undefined;
126129 acme.Chrome = parseFloat(dua.split("Chrome\/")[1]) || undefined;
127130
131+ console.log( '>>Webkit : ' + acme.WebKit );
132+
128133 if( i && !acme.Chrome && dua.indexOf( 'Safari' ) !== -1 ){
129134 if( dav.indexOf( 'Version/' ) !== -1 ){
130135 acme.Safari = parseFloat( dav.split("Version/")[1] );
@@ -164,7 +169,7 @@ X.UA = (function( n, undefined ){
164169
165170 // Mozilla/5.0 (Android; Linux armv7l; rv:9.0) Gecko/20111216 Firefox/9.0 Fennec/9.0
166171 if( ( i = dua.toLowerCase().indexOf( 'android' ) ) !== -1 ){
167- acme.Android = parseFloat( ua.substr( i + 8 ) ) || 1.5;
172+ acme.Android = parseFloat( dua.substr( i + 8 ) ) || 1.5;
168173 console.log( '>> Android : ' + acme.Android );
169174 } else
170175 if( dua.indexOf( 'iPhone;' ) !== -1 || dua.indexOf( 'iPad;' ) !== -1 || dua.indexOf( 'iPod;' ) !== -1 ){
--- a/0.6.x/js/core/03_XCallback.js
+++ b/0.6.x/js/core/03_XCallback.js
@@ -10,168 +10,182 @@ X.Callback = {
1010 MONOPOLY : 16, // move event を独占する
1111 SYS_CANCEL : 32 | 4 | 2,
1212
13+ _USE_CLOSURE : false,
14+
1315 _LIVE_LIST : [],
1416 _POOL_LIST : [],
1517
18+ _THIS_FUNC : 1,
19+ _HANDLEEVENT : 2,
20+ _FUNC_ONLY : 3,
21+
1622 create : function( arg0, arg1, arg2 /* [ listener || ( context + function ) || function ][ args... ] */ ){
17- var self = X.Callback,
18- live = self._LIVE_LIST,
19- f, listener, context, callback;
23+ var live = X.Callback._LIVE_LIST,
24+ hash = X.Callback._checkCallbackArgs( arg0, arg1, arg2 ),
25+ f;
2026
21- if( typeof arg1 === 'function' ){
22- context = arg0;
23- callback = arg1;
24- } else
25- if( typeof arg0 === 'function' ){
26- callback = arg0;
27- if( !( arg2 = arg1 ) ) return callback; // function のみの場合 callback オブジェクトを作らない
28- } else
29- if( arg0 && typeof arg0.handleEvent === 'function' ){
30- listener = arg0;
31- arg2 = arg1;
32- } else {
33- var v = '';
34- for( var k in arg0 ){
35- v += k + '=' + arg0[ k ] + ' ';
36- };
37- alert( 'Callback.create() fail! ' + v );
38- };
27+ if( !hash.k ) return hash;
3928
40- f = self._POOL_LIST.pop();
29+ f = X.Callback._POOL_LIST.pop();
4130 if( !f ){
42- f = new Function( 'var a=arguments,f=a.callee;f.a=a;return f.c()' ); // f.t=this;
43- f.kill = self._kill;
44- f.same = self._same;
31+ f = new Function( 'var a=arguments,f=a.callee;f.a=a;return f._(f)' ); // f.x=this;
32+ f[ 'kill' ] = X.Callback._kill;
33+ f[ 'same' ] = X.Callback._same;
34+ f._ = X.Callback._proxyCallback;
4535 };
36+
4637 live[ live.length ] = f;
47- if( listener ){
48- f.c = self._contextCallback;
49- f.listener = listener;
50- f.context = listener;
51- f.callback = listener.handleEvent;
52- } else
53- if( context ){
54- f.c = self._contextCallback;
55- f.context = context;
56- f.callback = callback;
57- } else {
58- f.c = self._generalCallback;
59- f.callback = callback;
38+
39+ switch( f.k = hash.k ){
40+ case X.Callback._THIS_FUNC :
41+ f.x = hash.x;
42+ f.f = hash.f;
43+ break;
44+ case X.Callback._HANDLEEVENT :
45+ f.x = hash.x;
46+ f.f = hash.f;
47+ break;
48+ case X.Callback._FUNC_ONLY :
49+ f.f = hash.f;
50+ break;
6051 };
6152
62- if( X.Type.isArray( arg2 ) ){
63- f.add = arg2;
64- };
53+ if( hash.s ) f.s = hash.s;
6554 return f;
6655 },
6756
68- _contextCallback : function(){
69- var f = this,
70- a = f.a,
71- s = f.add,
72- c = f.callback,
73- x = f.context,
74- i = 0,
75- ary, r;
76- //s && s.push.apply( a, s );
77- if( s && s.length ){
78- ary = [];
79- a.length &&
80- (
81- a.length === 1 ?
82- ( ary[ 0 ] = a[ 0 ] ) :
83- ary.push.apply( ary, a )
84- );
85- s.length === 1 ?
86- ( ary[ ary.length ] = s[ 0 ] ) :
87- ary.push.apply( ary, s );
88- a = ary;
57+ _createClosure : function( obj ){
58+ return function(){
59+ obj.a = arguments;
60+ return obj._( obj );
61+ };
62+ },
63+
64+ _checkCallbackArgs : function( arg1, arg2, arg3, alt_context ){
65+ var obj;
66+
67+ if( arg1 && X.Type.isFunction( arg2 ) ){
68+ obj = { x : arg1, f : arg2, k : X.Callback._THIS_FUNC };
69+ } else
70+ if( arg1 && X.Type.isFunction( arg1[ 'handleEvent' ] ) ){
71+ obj = { x : arg1, f : arg1[ 'handleEvent' ], k : X.Callback._HANDLEEVENT };
72+ arg3 = arg2;
73+ } else
74+ if( X.Type.isFunction( arg1 ) ){
75+ arg3 = arg2;
76+ if( alt_context ){
77+ obj = { x : alt_context, f : arg1, k : X.Callback._THIS_FUNC };
78+ } else {
79+ obj = { f : arg1, k : X.Callback._FUNC_ONLY };
80+ };
81+ } else
82+ if( X.Type.isFunction( arg2 ) ){
83+ console.log( 'X.Callback._checkCallbackArgs : arg1 が ' + arg1 + 'です' );
84+ if( alt_context ){
85+ obj = { x : alt_context, f : arg2, k : X.Callback._THIS_FUNC };
86+ } else {
87+ obj = { f : arg2, k : X.Callback._FUNC_ONLY };
88+ };
89+ } else
90+ if( alt_context && X.Type.isFunction( alt_context[ 'handleEvent' ] ) ){
91+ obj = { x : alt_context, f : alt_context[ 'handleEvent' ], k : X.Callback._HANDLEEVENT };
92+ arg3 = arg1;
93+ } else {
94+ console.log( '不正 ' + arg1 );
95+ console.dir( arg1 );
96+ return;
97+ };
98+
99+ if( X.Type.isArray( arg3 )){
100+ obj.s = arg3;
89101 };
90- r = a.length === 0 ? c.call( x ) : c.apply( x, a );
91- delete f.a;
92- //delete f.t;
93- return r;
102+ return ( obj.x || obj.s ) ? obj : arg1;
94103 },
95- _generalCallback : function(){
96- var f = this,
97- a = f.a,
98- s = f.add,
99- c = f.callback,
100- i = 0,
101- ary, r;
102- //s && s.push.apply( a, s );
103- if( s && s.length ){
104- ary = [];
105- a.length &&
104+
105+ _proxyCallback : function( xfunc ){
106+ var args = xfunc.a || [],
107+ thisObj = xfunc.x,
108+ func = xfunc.f,
109+ supp = xfunc.s,
110+ temp, ret;
111+
112+ delete xfunc.a;
113+
114+ if( supp && supp.length ){
115+ temp = [];
116+ args.length &&
106117 (
107- a.length === 1 ?
108- ( ary[ 0 ] = a[ 0 ] ) :
109- ary.push.apply( ary, a )
118+ args.length === 1 ?
119+ ( temp[ 0 ] = args[ 0 ] ) :
120+ temp.push.apply( temp, args )
110121 );
111- s.length === 1 ?
112- ( ary[ ary.length ] = s[ 0 ] ) :
113- ary.push.apply( ary, s );
114- a = ary;
122+ supp.length === 1 ?
123+ ( temp[ temp.length ] = supp[ 0 ] ) :
124+ temp.push.apply( temp, supp );
125+ args = temp;
126+ };
127+
128+ switch( xfunc.k ){
129+
130+ case X.Callback._THIS_FUNC :
131+ return args.length === 0 ? func.call( thisObj ) : func.apply( thisObj, args );
132+
133+ case X.Callback._HANDLEEVENT :
134+ temp = thisObj[ 'handleEvent' ];
135+ if( temp !== func && X.Type.isFunction( temp ) ){
136+ return args.length === 0 ? thisObj[ 'handleEvent' ]() : temp.apply( thisObj, args );
137+ } else
138+ if( X.Type.isFunction( thisObj ) ){
139+ return args.length === 0 ? thisObj.call( thisObj ) : thisObj.apply( thisObj, args );
140+ };
141+ return args.length === 0 ? func.call( thisObj ) : func.apply( thisObj, args );
142+
143+ case X.Callback._FUNC_ONLY :
144+ return args.length === 0 ?
145+ func() :
146+ args.length === 1 ?
147+ func( args[ 0 ] ) :
148+ func.apply( null, args );
115149 };
116- r = a.length === 0 ?
117- c() :
118- a.length === 1 ?
119- c( a[ 0 ] ) :
120- c.apply( null, a );
121- delete f.a;
122- //delete f.t;
123- return r;
124150 },
151+
125152 _kill : function(){
126153 X.Callback._correct( this );
127154 },
128155 _same : function( arg0, arg1, arg2 ){
129- var listener, context, callback,
130- f = this;
131-
132- if( arg0.kill === X.Callback._kill ){ // arg0 === X.Callback toString() で判定は?
133- return this === arg0;
134- } else
135- if( typeof arg1 === 'function' ){
136- context = arg0;
137- callback = arg1;
138- } else
139- if( typeof arg0 === 'function' ){
140- callback = arg0;
141- arg2 = arg1;
142- } else
143- if( arg0 && typeof arg0.handleEvent === 'function' ){
144- listener = arg0;
145- arg2 = arg1;
146- };
156+ var hash, kind;
147157
148- if( arg2 && f.add !== arg2 ){
149- return false;
150- };
158+ if( arg0 && arg0[ 'kill' ] === X.Callback._kill ) return this === arg0;
151159
152- if( listener && f.listener === listener ){
153- return true;
154- } else
155- if( context && f.context === context && f.callback === callback ){
156- return true;
157- } else
158- if( f.callback === callback ){
159- return true;
160+ hash = X.Callback._checkCallbackArgs( arg0, arg1, arg2 ),
161+ kind = hash.k;
162+
163+ if( this.k !== kind ) return false;
164+
165+ switch( kind ){
166+ case X.Callback._THIS_FUNC :
167+ return this.x === hash.x && this.f === hash.f && this.s === hash.s;
168+
169+ case X.Callback._HANDLEEVENT :
170+ return this.x === hash.x && this.f === hash.f && this.s === hash.s;
171+
172+ case X.Callback._FUNC_ONLY :
173+ return this.f === hash.f && this.s === hash.s;
160174 };
161175 return false;
162176 },
163177 _correct : function( f ){
164- var self = X.Callback,
165- i = self._LIVE_LIST.indexOf( f );
166- if( f.c ) delete f.c;
167- if( f.listener ) delete f.listener;
168- if( f.context ) delete f.context;
169- if( f.callback ) delete f.callback;
170- if( f.add ) delete f.add;
178+ var i = X.Callback._LIVE_LIST.indexOf( f );
179+ //delete f._;
180+ delete f.k;
181+ if( f.x ) delete f.x;
182+ if( f.f ) delete f.f;
183+ if( f.s ) delete f.s;
171184 if( i === -1 ) return;
172- self._LIVE_LIST.splice( i, 1 );
173- self._POOL_LIST.push( f );
185+ X.Callback._LIVE_LIST.splice( i, 1 );
186+ X.Callback._POOL_LIST.push( f );
174187 },
188+
175189 sys_monitor : function(){
176190 return {
177191 'Live callback' : X.Callback._LIVE_LIST.length,
@@ -179,13 +193,14 @@ X.Callback = {
179193 };
180194 },
181195 sys_gc : function(){
182- var self = X.Callback,
183- list = self._POOL_LIST, f;
196+ var list = X.Callback._POOL_LIST,
197+ f;
184198 while( 0 < list.length ){
185199 f = list.shift();
186- self._correct( f );
187- delete f.kill;
188- delete f.same;
200+ X.Callback._correct( f );
201+ delete f[ '_' ];
202+ delete f[ 'kill' ];
203+ delete f[ 'same' ];
189204 };
190205 }
191206 };
--- a/0.6.x/js/core/05_XTimer.js
+++ b/0.6.x/js/core/05_XTimer.js
@@ -27,8 +27,8 @@ X.Timer = {
2727 next : 0,
2828 busy : false, // for Opera7
2929
30- REQUEST_FRAME_LIST : [],
31- requestID : 0,
30+ REQ_FRAME_LIST : [],
31+ requestID : 0,
3232
3333 _loop : function(){
3434 var next = X.Timer.next,
@@ -44,17 +44,23 @@ X.Timer = {
4444
4545 for( ; i; ){
4646 q = list[ --i ];
47- if( 0 < ( q.l -= next ) ) continue;
48- f = q.f;
49- c = q.c;
50- if( f() & X.Callback.UN_LISTEN || c === 1 ){
47+ if( 0 < ( q.last -= next ) ) continue;
48+ c = q.count;
49+
50+ if( q.k ){
51+ q.a = [];
52+ r = X.Callback._proxyCallback( q );
53+ } else {
54+ r = q.f();
55+ };
56+
57+ if( r & X.Callback.UN_LISTEN || c === 1 ){
5158 list.splice( i, 1 );
52- f.kill && f.kill();
53- //queue.length = 0;
59+ //f.kill && f.kill();
5460 continue;
5561 } else
56- if( 1 < c ) --q.c;
57- q.l = q.t;
62+ if( 1 < c ) --q.count;
63+ q.last = q.time;
5864 };
5965 X.Timer.timerId = 0;
6066 X.Timer.busy = false;
@@ -71,7 +77,7 @@ X.Timer = {
7177 return;
7278 };
7379 for( ; i; ){
74- ( l = list[ --i ].l ) < n && ( n = l );
80+ ( l = list[ --i ].last ) < n && ( n = l );
7581 };
7682 if( n < X.Timer.next || X.Timer.timerId === 0 ){
7783 X.Timer.timerId && window.clearTimeout( X.Timer.timerId );
@@ -82,36 +88,45 @@ X.Timer = {
8288 },
8389
8490 _onEnterFrame : function ( time ){
85- var list = X.Timer.REQUEST_FRAME_LIST,
91+ var list = X.Timer.REQ_FRAME_LIST,
8692 i = list.length,
87- f;
93+ q;
8894 time = time || ( Date.now ? Date.now() : +new Date );
8995 for( ; i; ){
90- ( f = list[ --i ] )( time );
91- delete f.uid;
92- f.kill && f.kill();
96+ q = list[ --i ];
97+
98+ if( q.k ){
99+ q.a = [ time ];
100+ X.Callback._proxyCallback( q );
101+ } else {
102+ q.f( time );
103+ };
104+ //delete f.uid;
105+ //f.kill && f.kill();
93106 };
94107 list.length = 0;
95108 },
96109
97110 add : function( time, opt_count, args1, args2, args3 ){
98- var list = X.Timer.TICKET_LIST;
99- time = time < X.Timer.INTERVAL_TIME ? 1 : ( time / X.Timer.INTERVAL_TIME ) | 0; // 正の数で使える「Math.floor(x)」を「(x | 0)」に;
111+ var list = X.Timer.TICKET_LIST,
112+ hash, obj;
113+ time = time < X.Timer.INTERVAL_TIME ? 1 : time / X.Timer.INTERVAL_TIME | 0; // 正の数で使える「Math.floor(x)」を「(x | 0)」に;
100114
101- if( typeof opt_count !== 'number' ){
115+ if( !X.Type.isNumber( opt_count ) ){
102116 args3 = args2;
103117 args2 = args1;
104118 args1 = opt_count;
105119 opt_count = 0;
106120 };
107-
108- list[ list.length ] = {
109- t : time,
110- l : time,
111- c : opt_count,
112- f : X.Callback.create( args1, args2, args3 ),
113- u : ++X.Timer.uid
114- };
121+
122+ hash = X.Callback._checkCallbackArgs( args1, args2, args3 );
123+ if( !hash.k ) hash = { f : hash };
124+ hash.time = time;
125+ hash.last = time;
126+ hash.count = opt_count;
127+ hash.uid = ++X.Timer.uid;
128+ list[ list.length ] = hash;
129+
115130 !X.Timer.busy && X.Timer._update();
116131 return X.Timer.uid;
117132 },
@@ -126,10 +141,10 @@ X.Timer = {
126141 for( ; i; ){
127142 // TODO
128143 // fire 中の cancel
129- if( ( q = list[ --i ] ).u === uid ){
144+ if( ( q = list[ --i ] ).uid === uid ){
130145 list.splice( i, 1 );
131- f = q.f;
132- f.kill && f.kill();
146+ //f = q.f;
147+ //f.kill && f.kill();
133148 !X.Timer.busy && ( /* q[ INDEX_COUNT ] <= next || */ l === 1 ) && X.Timer._update();
134149 //q.length = 0;
135150 break;
@@ -139,23 +154,23 @@ X.Timer = {
139154
140155 requestFrame : _enterFrame ?
141156 (function( args1, args2, args3 ){
142- var i = X.Timer.REQUEST_FRAME_LIST.length,
157+ var i = X.Timer.REQ_FRAME_LIST.length,
143158 f;
144159 i === 0 && ( X.Timer.requestID = _enterFrame( X.Timer._onEnterFrame ) );
145- f = X.Timer.REQUEST_FRAME_LIST[ i ] = X.Callback.create( args1, args2, args3 );
160+ f = X.Timer.REQ_FRAME_LIST[ i ] = X.Callback._checkCallbackArgs( args1, args2, args3 );
146161 return f.uid = ++X.Timer.uid;
147162 }) :
148163 (function( args1, args2, args3 ){
149- var i = X.Timer.REQUEST_FRAME_LIST.length,
164+ var i = X.Timer.REQ_FRAME_LIST.length,
150165 f;
151166 i === 0 && ( X.Timer.requestID = X.Timer.add( 0, 1, X.Timer._onEnterFrame ) );
152- f = X.Timer.REQUEST_FRAME_LIST[ i ] = X.Callback.create( args1, args2, args3 );
167+ f = X.Timer.REQ_FRAME_LIST[ i ] = X.Callback._checkCallbackArgs( args1, args2, args3 );
153168 return f.uid = ++X.Timer.uid;
154169 }),
155170
156171 cancelFrame : _cancelFrame ?
157172 (function( uid ){
158- var list = X.Timer.REQUEST_FRAME_LIST,
173+ var list = X.Timer.REQ_FRAME_LIST,
159174 l = list.length,
160175 i = l,
161176 f;
@@ -165,15 +180,15 @@ X.Timer = {
165180 // TODO
166181 // fire 中の cancel
167182 list.splice( i, 1 );
168- delete f.uid;
169- f.kill && f.kill();
183+ //delete f.uid;
184+ //f.kill && f.kill();
170185 l === 1 && _cancelFrame( X.Timer.requestID );
171186 break;
172187 };
173188 };
174189 }) :
175190 (function( uid ){
176- var list = X.Timer.REQUEST_FRAME_LIST,
191+ var list = X.Timer.REQ_FRAME_LIST,
177192 l = list.length,
178193 i = l,
179194 f;
@@ -181,8 +196,8 @@ X.Timer = {
181196 if( ( f = list[ --i ] ).uid < uid ) break;
182197 if( f.uid === uid ){
183198 list.splice( i, 1 );
184- delete f.uid;
185- f.kill && f.kill();
199+ //delete f.uid;
200+ //f.kill && f.kill();
186201 l === 1 && X.Timer.remove( X.Timer.requestID );
187202 break;
188203 };
@@ -194,15 +209,15 @@ X.Timer = {
194209 // http://havelog.ayumusato.com/develop/javascript/e528-ios6_scrolling_timer_notcall.html
195210 // iOS6 スクロール中のタイマー発火絡みのバグ備忘
196211 if( X.UA.iOS ){
197- window.addEventListener( 'scroll', function(){
198- if( X.Timer.timerId ){
199- window.clearTimeout( X.Timer.timerId );
200- X.Timer.timerId = window.setTimeout( X.Timer._loop, Math.max( 0, X.Timer.endTime - X.getTime() ) );
201- };
202- } );
212+ window.addEventListener( 'scroll', function(){
213+ if( X.Timer.timerId ){
214+ window.clearTimeout( X.Timer.timerId );
215+ X.Timer.timerId = window.setTimeout( X.Timer._loop, Math.max( 0, X.Timer.endTime - X.getTime() ) );
216+ };
217+ });
203218 };
204219
205-if( X.UA.IE && ( X.UA.IE < 5 || X.UA.MacIE ) ){
220+if( X.UA.IE < 5 || X.UA.MacIE ){
206221 X.Timer[ '_ie_loop' ] = X.Timer._loop;
207222 X.Timer._loop = 'X.Timer._ie_loop()';
208223 };
--- a/0.6.x/js/core/06_XEventDispatcher.js
+++ b/0.6.x/js/core/06_XEventDispatcher.js
@@ -35,8 +35,6 @@ X.EventDispatcher =
3535 var list = this._listeners,
3636 r, f;
3737 if( this._dispatching ){
38- // todo
39- // reserve
4038 if( !this._reserves ) this._reserves = [];
4139 this._reserves[ this._reserves.length ] = [ type, arg1, arg2, arg3, X.EventDispatcher._once ];
4240 return this;
@@ -45,11 +43,17 @@ X.EventDispatcher =
4543
4644 if( !list ) list = this._listeners = {};
4745 if( !( list = list[ type ] ) ) list = this._listeners[ type ] = [];
48- list[ list.length ] = f =
49- ( arg1 && !arg2 ) ?
50- arg1 :
51- X.Callback.create( arg1, arg2, arg3 ); // TODO create しないで、arg1~arg3 を保持
46+
47+ f = X.Callback._checkCallbackArgs( arg1, arg2, arg3 );
48+ if( !f.k ){
49+ f = X.Callback._checkCallbackArgs( this, arg1 );
50+ } else
51+ if( f.k === X.Callback._FUNC_ONLY ){
52+ f = X.Callback._checkCallbackArgs( this, f.f, f.s );
53+ };
54+ list[ list.length ] = f;
5255 f.once = X.EventDispatcher._once;
56+
5357 return this;
5458 },
5559 listenOnce : function( type, arg1, arg2, arg3 ){
@@ -116,19 +120,32 @@ X.EventDispatcher =
116120 return this;
117121 },
118122 listening : function( type, arg1, arg2, arg3 ){
119- var list = this._listeners, unlistens, i, f;
123+ var list = this._listeners, unlistens, i, f, hash;
120124 if( type === undefined ) return !!list;
121125 if( !list || !( list = list[ type ] ) ) return false;
122126 if( arg1 === undefined ) return true;
127+
128+ if( arg1.k ){
129+ hash = arg1;
130+ } else {
131+ hash = X.Callback._checkCallbackArgs( arg1, arg2, arg3 );
132+ if( !hash.k ){
133+ hash = X.Callback._checkCallbackArgs( this, arg1 );
134+ } else
135+ if( hash.k === X.Callback._FUNC_ONLY ){
136+ hash = X.Callback._checkCallbackArgs( this, hash.f, hash.s );
137+ };
138+ };
139+
123140 if( ( unlistens = this._unlistens ) && ( unlistens = unlistens[ type ] ) ){
124141 for( i = unlistens.length; i; ){
125142 f = unlistens[ --i ];
126- if( f === arg1 || ( f.same && f.same( arg1, arg2, arg3 ) ) ) return false;
143+ if( f === hash || ( f.x === hash.x && f.f === hash.f && f.s === hash.s ) ) return false;
127144 };
128145 };
129146 for( i = list.length; i; ){
130147 f = list[ --i ];
131- if( f === arg1 || ( f.same && f.same( arg1, arg2, arg3 ) ) ) return this._needsIndex ? i : true;
148+ if( f === hash || ( f.x === hash.x && f.f === hash.f && f.s === hash.s ) ) return this._needsIndex ? i : true;
132149 };
133150 return false;
134151 },
@@ -166,10 +183,16 @@ X.EventDispatcher =
166183 unlistens = this._unlistens[ type ];
167184 };
168185 if( unlistens && unlistens.indexOf( f ) !== -1 ) continue;
169-
170- r = typeof f === 'function' ? f( e ) : f.handleEvent( e ); // dispatch 中に unlisten が作られることがある
186+
187+ if( f.k ){
188+ f.a = [ e ];
189+ r = X.Callback._proxyCallback( f );
190+ } else {
191+ r = f.call( this, e );
192+ };
171193
172194 if( f.once || r & X.Callback.UN_LISTEN ){
195+ // dispatch 中に unlisten が作られることがある
173196 if( !unlistens ){
174197 unlistens = this._unlistens || ( this._unlistens = {} );
175198 unlistens = unlistens[ type ] || ( unlistens[ type ] = [] );
@@ -226,7 +249,7 @@ X.EventDispatcher =
226249 },
227250
228251 asyncDispatch : function( delay, e ){
229- return X.Timer.once( delay, this, this.dispatch, [ e ] );
252+ return X.Timer.add( delay, 1, this, this.dispatch, [ e ] );
230253 }
231254 }
232255 );
--- a/0.6.x/js/dom/10_XDom.js
+++ b/0.6.x/js/dom/10_XDom.js
@@ -43,6 +43,8 @@ X.Dom = X.Class._override(
4343
4444 }) :
4545 (function( e ){
46+ console.log( '-- resize : ' + X.getTime() );
47+
4648 !X.Dom._lock && ( X.Dom._lock = true ) && X.Timer.once( 100, X.Dom._detectFinishResizing );
4749 return X.Callback.PREVENT_DEFAULT | X.Callback.STOP_PROPAGATION;
4850 }),
@@ -54,8 +56,14 @@ X.Dom = X.Class._override(
5456 X.Dom.h = size[ 1 ];
5557 X.Timer.once( 100, X.Dom._detectFinishResizing );
5658 } else {
59+ console.log( '-- detectFinishResizing : ' + X.getTime() );
60+
5761 X.Dom.asyncDispatch( 0, { type : X.Dom.Event.VIEW_RESIZED, w : X.Dom.w, h : X.Dom.h } );
5862 X.Dom._lock = false;
63+ if( X.Dom._orientationFlag ){
64+ X.Dom._orientationFlag = false;
65+ X.Dom.asyncDispatch( 100, { type : X.Dom.Event.VIEW_TURNED, orientation : window.orientation } );
66+ };
5967 };
6068 },
6169
@@ -79,6 +87,9 @@ X.Dom = X.Class._override(
7987 null;
8088
8189 r = Node._body = new Node( document.body );
90+
91+ Node.root = r; // 後方互換
92+
8293 h.appendTo = h.appendToRoot = h.before = h.after = h.clone = h.remove = h.destroy = h.prevNode = h.nextNode = h.createText = h.append = h.appendAt = h.empty = h.html = h.text =
8394 r.appendTo = r.appendToRoot = r.before = r.after = r.clone = r.remove = r.destroy = r.prevNode = r.nextNode = new Function( 'return this' );
8495
@@ -104,7 +115,11 @@ X.Dom = X.Class._override(
104115
105116 X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
106117 var size = X.Dom._getSize();
107-
118+
119+ if( X.Dom._orientationchange ){
120+ X.Dom.Node._window.listen( 'orientationchange', X.Dom._orientationchange );
121+ };
122+
108123 if( X.Dom._detectFontSize ){
109124 X.Dom.Node._window.listen( 'resize', X.Dom._resize );
110125 X.Timer.add( 333, X.Dom._detectFontSize );
@@ -409,4 +424,12 @@ X.Dom.getAbsolutePath = function( path ){
409424 return [ _ary[ 0 ], ss, ary.join( s ), s, path ].join( '' );
410425 };
411426
427+if( window[ 'orientation' ] !== undefined ){
428+ X.Dom._orientationchange = function( e ){
429+ X.Dom._orientationFlag = true;
430+ console.log( '-- orientationchange : ' + X.getTime() );
431+ };
432+};
433+
434+
412435 console.log( 'X.Dom dom:w3c=' + X.Dom.DOM_W3C + ' ev:w3c=' + X.Dom.EVENT_W3C );
--- a/0.6.x/js/dom/11_XDomNode.js
+++ b/0.6.x/js/dom/11_XDomNode.js
@@ -783,6 +783,10 @@ Node.prototype.text = function( text ){
783783 return this;
784784 };
785785 if( !text ) return this.empty();
786+ if( ( xnodes = this._xnodes ) && xnodes.length === 1 && xnodes[ 0 ]._xnodeType === 3 ){
787+ xnodes[ 0 ].text( text );
788+ return this;
789+ };
786790 this.empty().createText( text );
787791 return this;
788792 };
@@ -855,7 +859,7 @@ Node.prototype._startUpdate = function(){
855859 removal.length = 0;
856860 };
857861
858- console.log( 'start _startUpdate().' );
862+ //console.log( 'start _startUpdate().' );
859863
860864 Node._html._dirty ? Node._html._commitUpdate() : this._commitUpdate();
861865
--- a/0.6.x/js/dom/12_XDomEvent.js
+++ b/0.6.x/js/dom/12_XDomEvent.js
@@ -7,6 +7,7 @@
77
88 if( X.Dom.EVENT_W3C ){
99 X.Dom.Event = function( e, xnode ){
10+ var touch0;
1011 //this._event = e;
1112 this.type = X.Dom.Event.RenameTo[ e.type ] || e.type;
1213
@@ -63,6 +64,16 @@ if( X.Dom.EVENT_W3C ){
6364 this.targetTouches = e.targetTouches;
6465 this.metaKey = e.metaKey;
6566 this.force = e.force || e.webkitForce || 0;
67+ //
68+ if( this.touches.length ){
69+ touch0 = this.touches[ 0 ];
70+ this.clientX = touch0.clientX;
71+ this.clientY = touch0.clientY;
72+ this.pageX = touch0.pageX;
73+ this.pageY = touch0.pageY;
74+ this.offsetX = touch0.offsetX || touch0.layerX;
75+ this.offsetY = touch0.offsetY || touch0.layerY;
76+ };
6677 } else
6778 if( e.constructor === window.PointerEvent ){
6879 // PointerEvent;
@@ -80,6 +91,9 @@ if( X.Dom.EVENT_W3C ){
8091 this.tiltY = e.tiltY;
8192 };
8293 };
94+ if( !window.PointerEvent && window.MSPointerEvent ){
95+ window.PointerEvent = window.MSPointerEvent;
96+ };
8397 } else {
8498 X.Dom.Event = function( e, xnode, element ){
8599 var btn;
@@ -150,6 +164,7 @@ X.Dom.Event.XDOM_READY = ++X.Event._LAST_EVENT;
150164 X.Dom.Event.VIEW_ACTIVATE = ++X.Event._LAST_EVENT;
151165 X.Dom.Event.VIEW_DEACTIVATE = ++X.Event._LAST_EVENT;
152166 X.Dom.Event.VIEW_RESIZED = ++X.Event._LAST_EVENT;
167+X.Dom.Event.VIEW_TURNED = ++X.Event._LAST_EVENT;
153168 X.Dom.Event.BASE_FONT_RESIZED = ++X.Event._LAST_EVENT;
154169 // same_page_jump
155170 // on_screen_keyboard_show
@@ -177,6 +192,7 @@ X.Dom.Event.RenameTo = {};
177192 // https://github.com/georgeadamson/jQuery.prefixfree-events/blob/master/jQuery.prefixfree-events.js
178193
179194 if( window.onwebkitanimationend !== undefined && window.onanimationend === undefined ){
195+ console.log( 'animationend <= webkitAnimationEnd' );
180196 X.Dom.Event.Rename[ 'animationend' ] = 'webkitAnimationEnd';
181197 X.Dom.Event.RenameTo[ 'webkitAnimationEnd' ] = 'animationend';
182198 X.Dom.Event.Rename[ 'animationstart' ] = 'webkitAnimationStart';
@@ -185,6 +201,7 @@ if( window.onwebkitanimationend !== undefined && window.onanimationend === undef
185201 X.Dom.Event.RenameTo[ 'webkitAnimationIteration' ] = 'animationiteration';
186202 } else
187203 if( window.onoanimationend !== undefined && window.onanimationend === undefined ){
204+ console.log( 'animationend <= oAnimationEnd' );
188205 X.Dom.Event.Rename[ 'animationend' ] = 'oAnimationEnd';
189206 X.Dom.Event.RenameTo[ 'oAnimationEnd' ] = 'animationend';
190207 X.Dom.Event.Rename[ 'animationstart' ] = 'oAnimationStart';
@@ -202,6 +219,7 @@ if( window.onmozanimationend !== undefined && window.onanimationend === undefine
202219 X.Dom.Event.RenameTo[ 'mozAnimationIteration' ] = 'animationiteration';
203220 } else*/
204221 if( document.documentElement && document.documentElement.style.msAnimation !== undefined && document.documentElement.style.animation === undefined ){ //document.documentElement.style.msAnimation
222+ console.log( 'animationend <= MSAnimationEnd' );
205223 X.Dom.Event.Rename[ 'animationend' ] = 'MSAnimationEnd';
206224 X.Dom.Event.RenameTo[ 'MSAnimationEnd' ] = 'animationend';
207225 X.Dom.Event.Rename[ 'animationstart' ] = 'MSAnimationStart';
@@ -212,25 +230,30 @@ if( document.documentElement && document.documentElement.style.msAnimation !== u
212230 // https://developer.mozilla.org/en-US/docs/Web/Events/transitionend
213231 // chrome1+, firefox4+, IE10+, Opera10.5+, Safari3.2+, Android2.1+
214232 if( window.onwebkittransitionend !== undefined && window.ontransitionend === undefined ){
233+ console.log( 'transitionend <= webkitTransitionEnd' );
215234 X.Dom.Event.Rename[ 'transitionend' ] = 'webkitTransitionEnd';
216235 X.Dom.Event.RenameTo[ 'webkitTransitionEnd' ] = 'transitionend';
217236 } else
218237 if( window.onotransitionend !== undefined && window.ontransitionend === undefined ){
219238 if( X.UA.Opera < 12 ){
239+ console.log( 'transitionend <= oTransitionEnd|ver.' + X.UA.Opera );
220240 X.Dom.Event.Rename[ 'transitionend' ] = 'oTransitionEnd';
221241 X.Dom.Event.RenameTo[ 'oTransitionEnd' ] = 'transitionend';
222242 } else {
243+ console.log( 'transitionend <= otransitionEnd|ver.' + X.UA.Opera );
223244 X.Dom.Event.Rename[ 'transitionend' ] = 'otransitionEnd';
224245 X.Dom.Event.RenameTo[ 'otransitionEnd' ] = 'transitionend';
225246 };
226247 } else
227248 if( window.onmoztransitionend !== undefined && window.ontransitionend === undefined ){
249+ console.log( 'transitionend <= mozTransitionEnd' );
228250 X.Dom.Event.Rename[ 'transitionend' ] = 'mozTransitionEnd';
229251 X.Dom.Event.RenameTo[ 'mozTransitionEnd' ] = 'transitionend';
230252 };
231253
232254
233255 if( navigator.msPointerEnabled && !navigator.pointerEnabled ){
256+ console.log( 'pointerdown <= MSPointerDown' );
234257 X.Dom.Event.Rename[ 'pointerdown' ] = 'MSPointerDown';
235258 X.Dom.Event.RenameTo[ 'MSPointerDown' ] = 'pointerdown';
236259 X.Dom.Event.Rename[ 'pointerup' ] = 'MSPointerUp';
@@ -243,16 +266,12 @@ if( navigator.msPointerEnabled && !navigator.pointerEnabled ){
243266
244267
245268
246-X.Dom.Node.prototype.listen = function( type, arg1, arg2, arg3 /* [ listener || ( context + function ) || function ][ arguments ] */ ){
247- var elm;
248-
249- if( this._xnodeType === 0 || this._xnodeType === 3 || !arg1 ) return this;
269+X.Dom.Node.prototype.listen = function( type /* , arg1, arg2, arg3[ listener || ( context + function ) || function ][ arguments ] */ ){
270+ if( this._xnodeType === 0 || this._xnodeType === 3 ) return this;
250271
251272 ( !this._listeners || !this._listeners[ type ] ) && X.Type.isString( type ) && this._addEvent( type );
252273
253- return typeof arg1 === 'function' ?
254- X.EventDispatcher.prototype.listen.call( this, type, this, arg1, arg2 ) :
255- X.EventDispatcher.prototype.listen.apply( this, arguments );
274+ return X.EventDispatcher.prototype.listen.apply( this, arguments );
256275 };
257276
258277 X.Dom.Node.prototype._addEvent =
--- a/0.6.x/js/main.js
+++ b/0.6.x/js/main.js
@@ -70,4 +70,5 @@ _text = X.Class._getPrivate( text );
7070
7171 function _onClick( e ){
7272 alert( e.type );
73+ console.log( e.type + ' -----------' );
7374 };
--- a/0.6.x/js/ui/05_XUI_Gesture.js
+++ b/0.6.x/js/ui/05_XUI_Gesture.js
@@ -38,6 +38,7 @@
3838 pointerType, i, l, touches, ret, active, gesture, startEv,
3939 hammer, deltaTime, deltaX, deltaY, velocity;
4040
41+ //console.log( 'Hammer@handleEvent ' + X.UI.Event.IdToName[ e.type ] + ' ' + e.pointerType );
4142 if( !type ) return;
4243
4344 if( e.pointerType ){
@@ -212,7 +213,7 @@
212213 // only when the instance options have enabled this gesture
213214 active[ gesture.name ] &&
214215 // if a handler returns false, we stop with the detection
215- ( ret |= ( gesture.handler.call( gesture, e, hammer ) || X.Callback.NONE ) );
216+ ( ret |= ( gesture.handler( e, hammer ) || X.Callback.NONE ) );
216217 };
217218
218219 // endevent, but not the last touch, so dont stop
@@ -325,6 +326,8 @@
325326
326327 // detect touchevents
327328 Hammer.HAS_POINTEREVENTS = navigator.pointerEnabled || navigator.msPointerEnabled;
329+ Hammer.HAS_POINTEREVENTS && console.log( 'Hammer.HAS_POINTEREVENTS : true' );
330+
328331
329332 // eventtypes per touchevent (start, move, end)
330333 // are filled by HamEvent.determineEventTypes on setup
--- a/0.6.x/js/ui/06_AbstractUINode.js
+++ b/0.6.x/js/ui/06_AbstractUINode.js
@@ -72,8 +72,8 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits(
7272 this.dispatch( { type : X.UI.Event.INIT } );
7373 },
7474
75- addToParent : function( parentElement ){
76- parentElement && parentElement.append( this.xnode );
75+ addToParent : function( xnodeParent ){
76+ xnodeParent && xnodeParent.append( this.xnode );
7777
7878 this.phase = 2;
7979 this.dispatch( { type : X.UI.Event.ADDED } );
@@ -745,7 +745,6 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits(
745745 y -= this.boxY;
746746
747747 if( 0 <= x && x < this.boxWidth && 0 <= y && y < this.boxHeight ){
748-
749748 !this.hovering && ( this.rootData.hoverList[ this.rootData.hoverList.length ] = this );
750749 this.rootData.targetNodeData = this;
751750 return true;
@@ -754,7 +753,7 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits(
754753
755754
756755 listen : function( type, arg1, arg2, arg3 ){
757- var root, events, counter;
756+ var root, events, counter, f;
758757 if( X.UI.Event._START_POINTER <= type && type <= X.UI.Event._END_POINTER ){
759758 if( this.phase < 3 ){
760759 if( !( events = this.reserveEvents ) ) this.reserveEvents = events = [];
@@ -763,12 +762,12 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits(
763762 };
764763 if( X.UI.Event._START_XUI_EVENT < type && type < X.UI.Event._END_XUI_EVENT ){
765764 if( !this.gesture ){
766- this.gesture = new X.UI.Gesture( this.root, this, type );
765+ this.gesture = new X.UI.Gesture( this.rootData, this, type );
767766 } else {
768767 this.gesture.listen( type );
769768 };
770769 } else {
771- console.log( type )
770+ console.log( type );
772771 root = this.rootData;
773772 counter = root.eventCounter;
774773 if( counter[ type ] ){
@@ -779,10 +778,14 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits(
779778 };
780779 };
781780 };
782- if( typeof arg1 === 'function' ){
783- return X.EventDispatcher.prototype.listen.apply( this, [ type, this.User, arg1, arg2 ] );
781+ f = X.Callback._checkCallbackArgs( arg1, arg2, arg3 );
782+ if( !f.k ){
783+ return X.EventDispatcher.prototype.listen.apply( this, [ type, this.User, f ] );
784+ } else
785+ if( f.k === X.Callback._FUNC_ONLY ){
786+ return X.EventDispatcher.prototype.listen.apply( this, [ type, this.User, f.f, f.s ] );
784787 };
785- return X.EventDispatcher.prototype.listen.apply( this, [ type, arg1 || this.User, arg2 || arg1, arg3 || arg2 ] );
788+ return X.EventDispatcher.prototype.listen.apply( this, arguments );
786789 },
787790 unlisten : function( type, arg1, arg2, arg3 ){
788791 var root, events, i, ev, counter;
@@ -812,10 +815,14 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits(
812815 };
813816 };
814817 };
815- if( typeof arg1 === 'function' ){
816- return X.EventDispatcher.prototype.unlisten.apply( this, [ type, this.User, arg1, arg2 ] );
818+ f = X.Callback._checkCallbackArgs( arg1, arg2, arg3 );
819+ if( !f.k ){
820+ return X.EventDispatcher.prototype.unlisten.apply( this, [ type, this.User, f ] );
821+ } else
822+ if( f.k === X.Callback._FUNC_ONLY ){
823+ return X.EventDispatcher.prototype.unlisten.apply( this, [ type, this.User, f.f, f.s ] );
817824 };
818- return X.EventDispatcher.prototype.unlisten.apply( this, [ type, arg1 || this.User, arg2 || arg1, arg3 || arg2 ] );
825+ return X.EventDispatcher.prototype.unlisten.apply( this, arguments );
819826 },
820827
821828 dispatch : function( e ){
@@ -918,6 +925,9 @@ X.UI.AbstractUINode = X.Class.create(
918925 X.Class._getPrivate( this ).listenOnce( type, arg1, arg2, arg3 );
919926 return this;
920927 },
928+ listening : function( type, arg1, arg2, arg3 ){
929+ return X.Class._getPrivate( this ).listening( type, arg1, arg2, arg3 );
930+ },
921931 unlisten : function( type, arg1, arg2, arg3 ){
922932 X.Class._getPrivate( this ).unlisten( type, arg1, arg2, arg3 );
923933 return this;
--- a/0.6.x/js/ui/20_PageRoot.js
+++ b/0.6.x/js/ui/20_PageRoot.js
@@ -14,14 +14,14 @@ X.UI._eventRellay = function( e ){
1414 data._eventBusy = true;
1515
1616 if( type !== '' + X.UI.Event._POINTER_MOVE && type !== '' + X.UI.Event._TOUCH_MOVE && type !== '' + X.UI.Event._MOUSE_MOVE ){
17- // console.log( e.type + ' ' + type + ' x:' + x + ', y:' + y );
17+ //console.log( e.type + ' ' + type + ' x:' + x + ', y:' + y );
1818 };
1919
2020 e.type = type;
2121
2222 if( data && ( data = data.monopolyNodeData ) && ( ret = data.dispatch( e ) ) & X.Callback.MONOPOLY ){
2323 delete X.UI.currentRootData._eventBusy;
24- return ret;
24+ return ret | X.Callback.PREVENT_DEFAULT;
2525 };
2626
2727 list = X.UI.currentRootData.hoverList;
@@ -56,7 +56,7 @@ X.UI._eventRellay = function( e ){
5656 };
5757 };
5858 delete X.UI.currentRootData._eventBusy;
59- return ret;
59+ return ret | X.Callback.PREVENT_DEFAULT;
6060 };
6161
6262 /*
--- a/0.6.x/logger.html
+++ b/0.6.x/logger.html
@@ -78,6 +78,7 @@
7878 font-weight : bold;
7979 z-index : 999;
8080 cursor : pointer;
81+ -webkit-tap-highlight-color : rgba(0,0,0,0);
8182 }
8283 .toggle_close #log,
8384 .toggle_none #toggle {
@@ -194,7 +195,7 @@
194195 body.className = toggleOpen ? 'toggle_open' : 'toggle_close';
195196 };
196197 };
197- btn.innerHTML = toggleOpen ? '&#9658;' : '&#9660;';
198+ btn.innerHTML = toggleOpen ? '&#9654;' : '&#9660;';//&#9658;&#9656;
198199 };
199200 function __readyTrans(){
200201 var body = document.body,
@@ -238,4 +239,5 @@
238239 </noscript>
239240 </head>
240241 <body onload="__resize()" onresize="__resize()" scroll="no"><div id="log">-- console.log() --</div><iframe src="index.html" width="500" height="100%" scrolling="yes" frameborder="0"></iframe><div id="toggle" onclick="__ontoggle();"></div></body>
241-</html>
\ No newline at end of file
242+</html>
243+<xmp class="cleanup-target" style="display:none"><plaintext style="display:none"><!-- plainetext は nds 用 -->
\ No newline at end of file
旧リポジトリブラウザで表示