リビジョン | 43b7875a2aadc07439db67724e60644f129bcc90 (tree) |
---|---|
日時 | 2015-11-20 00:27:14 |
作者 | itozyun <itozyun@user...> |
コミッター | itozyun |
Version 0.6.196, bug fixes X.XML & X.UI.ScrollBox.
@@ -9,20 +9,20 @@ var X_Script_VBS_ENABLED = X_UA[ 'Windows' ] && !X_UA[ 'WinCE' ] && !X_UA[ 'WinP | ||
9 | 9 | * @type {object} |
10 | 10 | */ |
11 | 11 | X[ 'Script' ] = { |
12 | - 'tryCatch' : X_Script_try | |
12 | + | |
13 | + 'tryIfSafe' : X_Script_try, | |
13 | 14 | |
15 | + /** | |
16 | + * Visual Basic Script が使えるか? | |
17 | + * @alias X.Script.VBS | |
18 | + * @type {boolean} | |
19 | + */ | |
20 | + 'VBS' : X_Script_VBS_ENABLED | |
14 | 21 | // git, strict mode, asm.js, |
15 | 22 | }; |
16 | 23 | |
17 | 24 | if( X_Script_VBS_ENABLED ){ |
18 | 25 | |
19 | -/** | |
20 | - * Visual Basic Script が使えるか? | |
21 | - * @alias X.Script.VBS | |
22 | - * @type {boolean} | |
23 | - */ | |
24 | - X[ 'Script' ][ 'VBS' ] = true; | |
25 | - | |
26 | 26 | X_Script_gte15 || document.write( '<script type=text/vbscript>' + |
27 | 27 | [ |
28 | 28 | 'Function vbs_testAXO(v)', |
@@ -66,6 +66,12 @@ if( X_Script_VBS_ENABLED ){ | ||
66 | 66 | // byte Array を扱う vba |
67 | 67 | }; |
68 | 68 | |
69 | +/** | |
70 | + * try-catch 構文が使えて安全に実行できるなら、コードを実行する | |
71 | + * @alias X.Script.tryIfSafe | |
72 | + * @param {funciton} func | |
73 | + * @param {array=} 引数の入った配列 | |
74 | + */ | |
69 | 75 | function X_Script_try( func, args ){ |
70 | 76 | if( !X_Script_gte15 ){ |
71 | 77 | //return func.apply( {}, args ); |
@@ -65,7 +65,7 @@ X_ViewPort[ 'listenOnce' ]( X_EVENT_INIT, function(){ | ||
65 | 65 | function X_Node_BoxModel_mesure( that, name ){ |
66 | 66 | var flags = that[ '_flags' ], elm; |
67 | 67 | |
68 | - if( !this[ '_tag' ] || ( ( flags & X_NodeFlags_IN_TREE ) === 0 ) || ( flags & X_NodeFlags_STYLE_IS_DISPLAY_NONE ) ) return 0; | |
68 | + if( !that[ '_tag' ] || ( ( flags & X_NodeFlags_IN_TREE ) === 0 ) || ( flags & X_NodeFlags_STYLE_IS_DISPLAY_NONE ) ) return 0; | |
69 | 69 | |
70 | 70 | X_Node_updateTimerID && X_Node_startUpdate(); |
71 | 71 |
@@ -196,7 +196,7 @@ function X_Node_Selector__parse( query, last ){ | ||
196 | 196 | not = true; |
197 | 197 | selector = 0; |
198 | 198 | phase = 0x0; |
199 | - name = null; | |
199 | + name = null; | |
200 | 200 | }; |
201 | 201 | //continue; |
202 | 202 | } else |
@@ -445,6 +445,7 @@ function X_Node_toggleInGPUFlag( gpuRoot, xnodes, flag ){ | ||
445 | 445 | */ |
446 | 446 | function X_Node_create( tag, opt_attrs, opt_css ){ |
447 | 447 | var xnode; |
448 | + | |
448 | 449 | if( !this[ '_tag' ] ) return; |
449 | 450 | this[ 'append' ]( xnode = X_Doc_create( tag, opt_attrs, opt_css ) ); |
450 | 451 | return xnode; |
@@ -171,7 +171,7 @@ function XMLWrapper_val( queryString, type ){ | ||
171 | 171 | n = -1; |
172 | 172 | isMulti = isMulti || 1 < l; |
173 | 173 | |
174 | - console.log( 'combinator ' + combinator ); | |
174 | + //console.log( 'combinator ' + combinator ); | |
175 | 175 | |
176 | 176 | switch( combinator ){ |
177 | 177 | // > TagName|* |
@@ -222,12 +222,12 @@ function XMLWrapper_val( queryString, type ){ | ||
222 | 222 | break; |
223 | 223 | default : |
224 | 224 | if( combinator === 1 || ( isStart && selector < 7 ) ){ |
225 | - console.log( l + ' > ' + xmlList.length + ' tag:' + tagName ); | |
225 | + //console.log( l + ' > ' + xmlList.length + ' tag:' + tagName ); | |
226 | 226 | for( ; i < l; ++i ){ |
227 | 227 | xml = parents[ i ]; |
228 | 228 | xml.childNodes && xml.childNodes.length && XMLWrapper_fetchElements( xmlList, xml, isAll ? null : tagName ); |
229 | 229 | }; |
230 | - console.log( l + ' >> ' + xmlList.length + ' tag:' + tagName ); | |
230 | + //console.log( l + ' >> ' + xmlList.length + ' tag:' + tagName ); | |
231 | 231 | }; |
232 | 232 | }; |
233 | 233 |
@@ -245,7 +245,7 @@ function XMLWrapper_val( queryString, type ){ | ||
245 | 245 | // :, 擬似クラス |
246 | 246 | case 4 : |
247 | 247 | if( !( filter = XMLWrapper_filter[ name ] ) ){ |
248 | - return XMLListWrapper_0;; | |
248 | + return XMLListWrapper_0; | |
249 | 249 | }; |
250 | 250 | break; |
251 | 251 | // [] 属性 |
@@ -267,7 +267,7 @@ function XMLWrapper_val( queryString, type ){ | ||
267 | 267 | filter = [ 'class', 3, name ]; break; |
268 | 268 | // :, 擬似クラス |
269 | 269 | case 4 : |
270 | - if( !( filter = X_Node_Selector__filter[ name ] ) ){ | |
270 | + if( !( filter = XMLWrapper_filter[ name ] ) ){ | |
271 | 271 | return []; |
272 | 272 | }; |
273 | 273 | break; |
@@ -442,13 +442,13 @@ function XMLWrapper_val( queryString, type ){ | ||
442 | 442 | function XMLWrapper_funcSelectorChild( type, flag_all, flags, xmlList ){ |
443 | 443 | var res = [], |
444 | 444 | flag_not = flags.not, |
445 | - i = 0, n = -1, xnode, node, | |
445 | + i = 0, n = -1, xml, node, | |
446 | 446 | tagName, tmp; |
447 | - for( ; xnode = xmlList[ i ]; ++i ){ | |
448 | - tagName = flag_all || xnode.tagName; | |
447 | + for( ; xml = xmlList[ i ]; ++i ){ | |
448 | + tagName = flag_all || xml.tagName; | |
449 | 449 | tmp = null; |
450 | 450 | if( /* tmp === null && */ type <= 0 ){ |
451 | - for( node = xnode.previousSibling; node; node = node.previousSibling ){ | |
451 | + for( node = xml.previousSibling; node; node = node.previousSibling ){ | |
452 | 452 | if( node.nodeType === 1 && ( flag_all || tagName === node.tagName ) ){ |
453 | 453 | tmp = false; |
454 | 454 | break; |
@@ -456,7 +456,7 @@ function XMLWrapper_val( queryString, type ){ | ||
456 | 456 | }; |
457 | 457 | }; |
458 | 458 | if( tmp === null && 0 <= type ){ |
459 | - for( node = xnode.nextSibling; node; node = node.nextSibling ){ | |
459 | + for( node = xml.nextSibling; node; node = node.nextSibling ){ | |
460 | 460 | if( node.nodeType === 1 && ( flag_all || tagName === node.tagName ) ){ |
461 | 461 | tmp = false; |
462 | 462 | break; |
@@ -464,29 +464,32 @@ function XMLWrapper_val( queryString, type ){ | ||
464 | 464 | }; |
465 | 465 | }; |
466 | 466 | if( tmp === null ) tmp = true; |
467 | - if( tmp ^ flag_not ) res[ ++n ] = xnode; | |
467 | + if( tmp ^ flag_not ) res[ ++n ] = xml; | |
468 | 468 | }; |
469 | 469 | return res; |
470 | 470 | }; |
471 | 471 | function XMLWrapper_funcSelectorNth( pointer, sibling, flag_all, flags, xmlList, a, b ){ |
472 | - var res = [], | |
472 | + var uids = X_Array_copy( xmlList ), | |
473 | + res = [], | |
473 | 474 | checked = {}, |
474 | 475 | flag_not = flags.not, |
475 | - i = 0, n = -1, uid, | |
476 | - c, xnode, tmp, node, tagName; | |
477 | - for( ; xnode = xmlList[ i ]; ++i ){ | |
478 | - uid = xnode._uid; | |
479 | - tmp = checked[ uid ]; | |
476 | + i = 0, n = -1, | |
477 | + c, xml, tmp, node, tagName, uid; | |
478 | + | |
479 | + for( ; xml = xmlList[ i ]; ++i ){ | |
480 | + tmp = checked[ i ]; | |
480 | 481 | if( tmp === undefined ){ |
481 | - for( c = 0, node = xnode.parentNode[ pointer ], tagName = flag_all || xnode.tagName; node; node = node[ sibling ] ){ | |
482 | + for( c = 0, node = xml.parentNode[ pointer ], tagName = flag_all || xml.tagName; node; node = node[ sibling ] ){ | |
482 | 483 | if( node.nodeType === 1 && ( flag_all || tagName === node.tagName ) ){ |
483 | 484 | ++c; |
484 | - checked[ node._uid ] = a === 0 ? c === b : (c - b) % a === 0 && (c - b) / a >= 0; | |
485 | - }; | |
485 | + uid = uids.indexOf( node ); | |
486 | + if( uid === -1 ) uids[ uid = uids.length ] = node; | |
487 | + checked[ uid ] = a === 0 ? c === b : (c - b) % a === 0 && (c - b) / a >= 0; | |
488 | + }; | |
486 | 489 | }; |
487 | - tmp = checked[ uid ]; | |
490 | + tmp = checked[ i ]; | |
488 | 491 | }; |
489 | - if( tmp ^ flag_not ) res[ ++n ] = xnode; | |
492 | + if( tmp ^ flag_not ) res[ ++n ] = xml; | |
490 | 493 | }; |
491 | 494 | return res; |
492 | 495 | }; |
@@ -494,9 +497,9 @@ function XMLWrapper_val( queryString, type ){ | ||
494 | 497 | function XMLWrapper_funcSelectorProp( prop, flag, flags, xmlList ){ |
495 | 498 | var res = [], |
496 | 499 | flag_not = flag ? flags.not : !flags.not, |
497 | - i = 0, n = -1, xnode; | |
498 | - for( ; xnode = xmlList[ i ]; ++i ){ | |
499 | - if( xnode.getAttributeNode( prop ) ^ flag_not ) res[ ++n ] = xnode; | |
500 | + i = 0, n = -1, xml; | |
501 | + for( ; xml = xmlList[ i ]; ++i ){ | |
502 | + if( xml.getAttributeNode( prop ) ^ flag_not ) res[ ++n ] = xml; | |
500 | 503 | }; |
501 | 504 | return res; |
502 | 505 | }; */ |
@@ -536,16 +539,16 @@ var XMLWrapper_filter = { | ||
536 | 539 | m : function( flags, xmlList ){ |
537 | 540 | var res = [], |
538 | 541 | flag_not = flags.not, |
539 | - i = 0, n = -1, xnode, tmp, node; | |
540 | - for( ; xnode = xmlList[i]; ++i ){ | |
542 | + i = 0, n = -1, xml, tmp, node; | |
543 | + for( ; xml = xmlList[i]; ++i ){ | |
541 | 544 | tmp = true; |
542 | - for( node = xnode.firstChild; node; node = node.nextSibling ){ | |
545 | + for( node = xml.firstChild; node; node = node.nextSibling ){ | |
543 | 546 | if( node.nodeType === 1 || ( node.nodeType === 3 && node.nodeValue ) ){ |
544 | 547 | tmp = false; |
545 | 548 | break; |
546 | 549 | }; |
547 | 550 | }; |
548 | - if( tmp ^ flag_not ) res[ ++n ] = xnode; | |
551 | + if( tmp ^ flag_not ) res[ ++n ] = xml; | |
549 | 552 | }; |
550 | 553 | return res; |
551 | 554 | } |
@@ -554,20 +557,19 @@ var XMLWrapper_filter = { | ||
554 | 557 | m : function( flags, xmlList, arg ){ |
555 | 558 | var res = [], |
556 | 559 | flag_not = flags.not, |
557 | - i = 0, n = -1, xnode, text = ''; | |
560 | + i = 0, n = -1, xml, text = ''; | |
558 | 561 | |
559 | - for( ; xnode = xmlList[ i ]; ++i ){ | |
560 | - switch( xnode.nodeType ){ | |
562 | + for( ; xml = xmlList[ i ]; ++i ){ | |
563 | + switch( xml.nodeType ){ | |
561 | 564 | case 1 : |
562 | - text = xml.nodeType === 1 ? xml.innerText || xml.text || xml.textContent : xml.nodeValue; | |
565 | + text = xml.innerText || xml.text || xml.textContent; | |
563 | 566 | break; |
564 | 567 | //case 2 : |
565 | 568 | case 3 : |
566 | - text = xnode.nodeValue; | |
569 | + text = xml.nodeValue; | |
567 | 570 | break; |
568 | 571 | }; |
569 | - console.log( text + ' ' + arg ); | |
570 | - if ( ( -1 < text.indexOf( arg ) ) ^ flag_not ) res[ ++n ] = xnode; | |
572 | + if ( ( -1 < text.indexOf( arg ) ) ^ flag_not ) res[ ++n ] = xml; | |
571 | 573 | }; |
572 | 574 | return res; |
573 | 575 | } |
@@ -259,7 +259,7 @@ function XUI_Gesture_handleEvent( e ){ | ||
259 | 259 | isMouse = e.pointerType === 'mouse', |
260 | 260 | touches = [], |
261 | 261 | numTouches = 0,// count the total touches on the screen |
262 | - i, p, l, j, captured, ret, activated, gesture, startEv, | |
262 | + i, p, l, j, captured, hammerEvent, ret, activated, gesture, startEv, | |
263 | 263 | deltaTime, deltaX, deltaY, velocity, center, startCenter; |
264 | 264 | |
265 | 265 | if( !isStart && !hammer.gestureStartEvent ) return; |
@@ -12,8 +12,10 @@ function XUI_ScrollBox_start( scrollBox ){ | ||
12 | 12 | if( scrollBox.hasVScroll ){ |
13 | 13 | if( !XUI_ScrollBox_indicatorV ){ |
14 | 14 | XUI_ScrollBox_indicatorV = X_Doc_create( 'div' )[ 'className' ]( 'ScrollBox-IndicatorV' ); |
15 | - | |
16 | 15 | }; |
16 | + if( XUI_ScrollBox_current ) | |
17 | + XUI_ScrollBox_current[ 'unlisten' ]( [ X_EVENT_CANCELED, XUI_Event.SCROLL_END ], XUI_ScrollBox_indicatorV, XUI_ScrollBox_indicatorHandleEvent ); | |
18 | + | |
17 | 19 | scrollBox.xnode[ 'append' ]( XUI_ScrollBox_indicatorV ); |
18 | 20 | XUI_ScrollBox_indicatorV[ 'animate' ]( |
19 | 21 | { opacity : 0 }, |
@@ -22,11 +24,17 @@ function XUI_ScrollBox_start( scrollBox ){ | ||
22 | 24 | ); |
23 | 25 | scrollBox |
24 | 26 | [ 'listenOnce' ]( [ X_EVENT_CANCELED, XUI_Event.SCROLL_END ], XUI_ScrollBox_indicatorV, XUI_ScrollBox_indicatorHandleEvent ); |
27 | + } else | |
28 | + if( XUI_ScrollBox_indicatorV ){ | |
29 | + XUI_ScrollBox_indicatorV[ 'remove' ](); | |
25 | 30 | }; |
31 | + | |
26 | 32 | if( scrollBox.hasHScroll ){ |
27 | 33 | if( !XUI_ScrollBox_indicatorH ){ |
28 | 34 | XUI_ScrollBox_indicatorH = X_Doc_create( 'div' )[ 'className' ]( 'ScrollBox-IndicatorH' ); |
29 | 35 | }; |
36 | + if( XUI_ScrollBox_current ) | |
37 | + XUI_ScrollBox_current[ 'unlisten' ]( [ X_EVENT_CANCELED, XUI_Event.SCROLL_END ], XUI_ScrollBox_indicatorH, XUI_ScrollBox_indicatorHandleEvent ); | |
30 | 38 | scrollBox.xnode[ 'append' ]( XUI_ScrollBox_indicatorH ); |
31 | 39 | XUI_ScrollBox_indicatorH[ 'animate' ]( |
32 | 40 | { opacity : 0 }, |
@@ -35,7 +43,11 @@ function XUI_ScrollBox_start( scrollBox ){ | ||
35 | 43 | ); |
36 | 44 | scrollBox |
37 | 45 | [ 'listenOnce' ]( [ X_EVENT_CANCELED, XUI_Event.SCROLL_END ], XUI_ScrollBox_indicatorH, XUI_ScrollBox_indicatorHandleEvent ); |
46 | + } else | |
47 | + if( XUI_ScrollBox_indicatorH ){ | |
48 | + XUI_ScrollBox_indicatorH[ 'remove' ](); | |
38 | 49 | }; |
50 | + XUI_ScrollBox_current = scrollBox; | |
39 | 51 | }; |
40 | 52 | |
41 | 53 | function XUI_ScrollBox_indicatorHandleEvent( e ){ |