リビジョン | 5568fa9f90ed70083505118d7c8fab58c34d9749 (tree) |
---|---|
日時 | 2012-11-15 21:04:00 |
作者 | itozyun <itozyun@gmai...> |
コミッター | itozyun |
version 0.5.20, fixed around AbstractApplication.
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* |
2 | 2 | * pettanR peta.apps.js |
3 | - * version 0.5.19 | |
3 | + * version 0.5.20 | |
4 | 4 | * |
5 | 5 | * author: |
6 | 6 | * itozyun |
@@ -487,7 +487,8 @@ var Cabinet = gOS.registerApplication( function(){ | ||
487 | 487 | nodeClose = null, |
488 | 488 | nodePath = null, |
489 | 489 | nodeBody = null, |
490 | - headerH = 0; | |
490 | + headerH = 0, | |
491 | + eventRoot = null; | |
491 | 492 | |
492 | 493 | this.bgColor = '#FFFFFF'; |
493 | 494 | this.MIN_WIDTH = 500; |
@@ -504,17 +505,15 @@ var Cabinet = gOS.registerApplication( function(){ | ||
504 | 505 | ].join( '' ); |
505 | 506 | |
506 | 507 | self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS ); |
507 | - self.useInteractiveLayer( 'mousemove', 'mousedown', 'mouseup', 'mouseout' ); | |
508 | 508 | |
509 | - tree = FileAPI.createTree( FILE_DATA_SERVICE_ROOT ); | |
509 | + tree = FileAPI.createTree( FILE_DATA_SERVICE_ROOT ); | |
510 | + eventRoot = self.getPointingDeviceEventTreeRoot(); | |
510 | 511 | |
511 | 512 | delete self.onInit; |
512 | 513 | }; |
513 | 514 | this.onOpen = function( _w, _h ){ |
514 | 515 | headerH = Util.getElementSize( document.getElementById( 'cabinet-header' ) ).height; |
515 | 516 | |
516 | - var eventRoot = self.getPointingDeviceEventTreeRoot(); | |
517 | - eventRoot.addEventListener( 'mousemove', new Function() ); | |
518 | 517 | nodeClose = eventRoot.createNode( document.getElementById( 'cabinet-close-button' ), false, false, 'close-button-hover', 'pointer' ); |
519 | 518 | nodeClose.addEventListener( 'click', Cabinet.shutdown ); |
520 | 519 | nodePath = eventRoot.createNode( document.getElementById( 'cabinet-path' ), false, false ); |
@@ -542,7 +541,8 @@ var Gallery = gOS.registerApplication( function(){ | ||
542 | 541 | tree = null, |
543 | 542 | nodePath = null, |
544 | 543 | nodeBody = null, |
545 | - headerH = 0; | |
544 | + headerH = 0, | |
545 | + eventRoot = null; | |
546 | 546 | |
547 | 547 | this.bgColor = '#FFFFFF'; |
548 | 548 | this.MIN_WIDTH = 500; |
@@ -559,7 +559,6 @@ var Gallery = gOS.registerApplication( function(){ | ||
559 | 559 | ].join( '' ); |
560 | 560 | |
561 | 561 | self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS ); |
562 | - self.useInteractiveLayer( 'mousemove', 'mousedown', 'mouseup', 'mouseout' ); | |
563 | 562 | |
564 | 563 | tree = FileAPI.createTree( FILE_DATA_PICTURE_ROOT ); |
565 | 564 | var _root = tree.getRootFile(), |
@@ -569,14 +568,14 @@ var Gallery = gOS.registerApplication( function(){ | ||
569 | 568 | _pic.getSeqentialFiles(); |
570 | 569 | _myPic.destroy(); |
571 | 570 | _pic.destroy(); |
571 | + | |
572 | + eventRoot = self.getPointingDeviceEventTreeRoot(); | |
572 | 573 | }; |
573 | 574 | this.onOpen = function( w, h ){ |
574 | 575 | headerH = Util.getElementSize( document.getElementById( 'gallery-header' ) ).height; |
575 | 576 | |
576 | 577 | self.addEventListener( document.getElementById( 'gallery-close-button' ), 'click', Gallery.shutdown ); |
577 | 578 | |
578 | - var eventRoot = self.getPointingDeviceEventTreeRoot(); | |
579 | - eventRoot.addEventListener( 'mousemove', new Function() ); | |
580 | 579 | nodePath = eventRoot.createNode( document.getElementById( 'gallery-path' ), false, false ); |
581 | 580 | nodeBody = eventRoot.createNode( document.getElementById( 'gallery-container' ), false, true, null, '', true ); |
582 | 581 |
@@ -585,8 +584,8 @@ var Gallery = gOS.registerApplication( function(){ | ||
585 | 584 | self.onPaneResize( w, h ); |
586 | 585 | }; |
587 | 586 | this.onClose = function(){ |
588 | - finder.destroy(); | |
589 | - tree.destroy(); | |
587 | + // finder.destroy(); | |
588 | + // tree.destroy(); | |
590 | 589 | finder = tree = null; |
591 | 590 | }; |
592 | 591 | this.onPaneResize = function( w, h ){ |
@@ -1282,7 +1281,6 @@ var Editor = gOS.registerApplication( function(){ | ||
1282 | 1281 | elm.style.borderStyle = this.border === true ? 'solid' : 'none'; |
1283 | 1282 | |
1284 | 1283 | this.node = nodeBox.createNode( elm, false, true, 'menubar-option-hover', 'pointer' ); |
1285 | - // this.node.addEventListener( 'click', this.callback, this.thisObject ); | |
1286 | 1284 | this.node.disabled( !this.visible ); |
1287 | 1285 | }, |
1288 | 1286 | hide : function(){ |
@@ -1414,17 +1412,6 @@ var Editor = gOS.registerApplication( function(){ | ||
1414 | 1412 | option = this.optionDataList[ i ]; |
1415 | 1413 | if( target === nodeBox ) return true; |
1416 | 1414 | option.fire(); |
1417 | - }, | |
1418 | - onMousemove : function( e ){ | |
1419 | - // if( currentMenu === -1 ) return; | |
1420 | - var x = e.clientX, | |
1421 | - y = e.clientY, | |
1422 | - boxX = nodeBox.x(); | |
1423 | - console.log( 'x:' + x + ' y:' + y + ' Box.x:' + nodeBox.x() + ' Box.y:' + nodeBox.y() + ' Box.w:' + nodeBox.width() + ' Box.h:' + nodeBox.height() ) | |
1424 | - console.log( 'x:' + x + ' y:' + y + ' Bar.x:' + nodeBar.x() + ' Bar.y:' + nodeBar.y() + ' Bar.w:' + nodeBar.width() + ' Bar.h:' + nodeBar.height() + ' hit:' + e.hit ) | |
1425 | - //if( barH < y && ( x < boxX || nodeBox.width() + boxX < x || barH + nodeBox.y() + nodeBox.height() < y ) ){ | |
1426 | - // this.menu.hide(); | |
1427 | - //}; | |
1428 | 1415 | } |
1429 | 1416 | }; |
1430 | 1417 | MenuPrivateDataClass.list = []; |
@@ -1472,7 +1459,7 @@ var Editor = gOS.registerApplication( function(){ | ||
1472 | 1459 | list[ i ].show( children[ i ] ); |
1473 | 1460 | }; |
1474 | 1461 | nodeBox.mesure(); |
1475 | - // eventRoot.addEventListener( 'mousemove', data.onMousemove, data ); | |
1462 | + | |
1476 | 1463 | nodeBar.addEventListener( 'mouseout', this.hide, this ); |
1477 | 1464 | nodeBox.addEventListener( 'click', data.onOptionClick, data ); |
1478 | 1465 | data.visible = true; |
@@ -1487,7 +1474,7 @@ var Editor = gOS.registerApplication( function(){ | ||
1487 | 1474 | }; |
1488 | 1475 | elmBar.parentNode.removeChild( elmBox ); |
1489 | 1476 | nodeBox.disabled( true ); |
1490 | - // eventRoot.removeEventListener( 'mousemove', data.onMousemove ); | |
1477 | + | |
1491 | 1478 | nodeBar.removeEventListener( 'mouseout', this.hide ); |
1492 | 1479 | nodeBox.removeEventListener( 'click', data.onOptionClick ); |
1493 | 1480 | data.visible = false; |
@@ -1559,6 +1546,7 @@ var Editor = gOS.registerApplication( function(){ | ||
1559 | 1546 | close : function(){ |
1560 | 1547 | var data; |
1561 | 1548 | while( data = MenuPrivateDataClass.list.shift() ) data.close(); |
1549 | + nodeBox.remove(); | |
1562 | 1550 | MenuPrivateDataClass.list = elmBar = layerBox = elmBox = null; |
1563 | 1551 | MENU_BAR_CONTROL.kill = kill; |
1564 | 1552 | MENU_BAR_CONTROL.kill(); |
@@ -2843,7 +2831,7 @@ var Editor = gOS.registerApplication( function(){ | ||
2843 | 2831 | delete CONSOLE_CONTROLER.init; |
2844 | 2832 | }, |
2845 | 2833 | open: function(){ |
2846 | - layerWrapper = app.createInteractContainer( elmConsoleWrapper ); | |
2834 | + // layerWrapper = app.createInteractContainer( elmConsoleWrapper ); | |
2847 | 2835 | |
2848 | 2836 | LAYER_BACK_BUTTON = MENU_BAR_CONTROL.EDIT.createOption( 'layer back', 'ctrl + B', layerBack, false, true, false ); |
2849 | 2837 | LAYER_FORWARD_BUTTON = MENU_BAR_CONTROL.EDIT.createOption( 'layer forward', 'ctrl + F', layerForward, false, false, false ); |
@@ -2898,7 +2886,7 @@ var Editor = gOS.registerApplication( function(){ | ||
2898 | 2886 | styleConsoleWrapper.left = CONSOLE_CONTROLER.x + 'px'; |
2899 | 2887 | styleConsoleWrapper.top = CONSOLE_CONTROLER.y + 'px'; |
2900 | 2888 | |
2901 | - layerWrapper.mesure(); | |
2889 | + // layerWrapper.mesure(); | |
2902 | 2890 | }, |
2903 | 2891 | hide: function(){ |
2904 | 2892 | if( visible === true ) styleConsoleWrapper.display = 'none'; |
@@ -2925,7 +2913,7 @@ var Editor = gOS.registerApplication( function(){ | ||
2925 | 2913 | return false; |
2926 | 2914 | } |
2927 | 2915 | // buttonClickable === false && buttonBackOrForward( false ); */ |
2928 | - layerWrapper.mesure(); | |
2916 | + // layerWrapper.mesure(); | |
2929 | 2917 | return false; |
2930 | 2918 | } |
2931 | 2919 | } |
@@ -4198,7 +4186,6 @@ var Editor = gOS.registerApplication( function(){ | ||
4198 | 4186 | ].join( '' ); |
4199 | 4187 | |
4200 | 4188 | app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS ); |
4201 | - app.useInteractiveLayer( 'mousemove', 'mousedown', 'mouseup', 'mouseout' ); | |
4202 | 4189 | eventRoot = app.getPointingDeviceEventTreeRoot(); |
4203 | 4190 | |
4204 | 4191 | delete app.onInit; |
@@ -4292,17 +4279,6 @@ var Editor = gOS.registerApplication( function(){ | ||
4292 | 4279 | |
4293 | 4280 | phase = 1; |
4294 | 4281 | |
4295 | - /* | |
4296 | - * MOUSE_LISTENER_ARRAY は、表示順に格納.手前の要素が最初 | |
4297 | - * MENU_BAR_CONTROL, | |
4298 | - * WINDOW_CONTROL, | |
4299 | - * PANEL_ELEMENT_CONTROL, | |
4300 | - * PANEL_CONTROL | |
4301 | - * .busy() === true なら、そのままmousemove()にイベントを流す. | |
4302 | - * mousemove()に流してみて、false が帰れば、次のリスナーにも流す. | |
4303 | - */ | |
4304 | - app.registerInteractiveListener( /* MENU_BAR_CONTROL, WINDOWS_CONTROL, PANEL_RESIZER_TOP, PANEL_RESIZER_BOTTOM, PANEL_ELEMENT_CONTROL, PANEL_CONTROL */ ); | |
4305 | - | |
4306 | 4282 | delete app.onOpen; |
4307 | 4283 | }; |
4308 | 4284 | this.onClose = function(){ |
@@ -192,7 +192,7 @@ | ||
192 | 192 | self.onPaneResize( _w, _h ); |
193 | 193 | |
194 | 194 | self.addEventListener( paddle1, 'click', Start ); |
195 | - self.addEventListener( close, 'click', self.close ); | |
195 | + self.addEventListener( close, 'click', self.close, self ); | |
196 | 196 | }; |
197 | 197 | this.onPaneResize = function( _w, _h ){ |
198 | 198 | var h = Util.getElementSize( self.rootElement ).height; |
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* |
2 | 2 | * pettanR system.js |
3 | - * version 0.5.19 | |
3 | + * version 0.5.20 | |
4 | 4 | * |
5 | 5 | * gadgetOS |
6 | 6 | * author: |
@@ -211,19 +211,19 @@ var SystemTimer = ( function(){ | ||
211 | 211 | }; |
212 | 212 | }; |
213 | 213 | |
214 | - var TimerTicketClass = function( _apiuser, _callback, _time, _once ){ | |
214 | + var TimerTicketClass = function( _apiuser, _callback, _time, _once, opt_thisObject ){ | |
215 | 215 | this.apiuser = _apiuser; |
216 | 216 | this.callback = _callback; |
217 | 217 | this.time = _time; |
218 | 218 | this.count = _time; |
219 | 219 | this.once = _once; |
220 | - _apiuser = _callback = null; | |
220 | + this.thisObj = opt_thisObject; | |
221 | 221 | }; |
222 | 222 | TimerTicketClass.prototype = new TicketBase(); |
223 | 223 | TimerTicketClass.prototype.call = function( c ){ |
224 | 224 | this.count -= c; |
225 | 225 | if( this.count <= 0 ){ |
226 | - this.callback(); | |
226 | + this.callback.call( this.thisObj || this.apiuser ); | |
227 | 227 | if( this.once === true ){ |
228 | 228 | this.destroy(); |
229 | 229 | TICKET_LIST.splice( Util.getIndex( TICKET_LIST, this ), 1 ); |
@@ -242,10 +242,10 @@ var SystemTimer = ( function(){ | ||
242 | 242 | }; |
243 | 243 | |
244 | 244 | return { |
245 | - add: function( _apiuser, _handler, _time, _once ){ | |
245 | + add: function( _apiuser, _handler, _time, _once, opt_thisObject ){ | |
246 | 246 | if( Type.isNumber( _time ) === false || _time < INTERVAL_TIME ) _time = INTERVAL_TIME; |
247 | 247 | |
248 | - var _ticket = new TimerTicketClass( _apiuser, _handler, Math.ceil( _time / INTERVAL_TIME ), _once ); | |
248 | + var _ticket = new TimerTicketClass( _apiuser, _handler, Math.ceil( _time / INTERVAL_TIME ), _once, opt_thisObject ); | |
249 | 249 | TICKET_LIST.push( _ticket ); |
250 | 250 | |
251 | 251 | update(); |
@@ -1049,35 +1049,8 @@ var File = ( function(){ | ||
1049 | 1049 | |
1050 | 1050 | var APPLICATION_LIST = []; |
1051 | 1051 | |
1052 | -var AbstractBasicPane = function(){ | |
1053 | - var instance = null; | |
1054 | - this.MIN_WIDTH = 240; | |
1055 | - this.MIN_HEIGHT = 240; | |
1056 | - this.init = function(){ | |
1057 | - instance = this; | |
1058 | - instance.onInit(); | |
1059 | - }; | |
1060 | - this.onInit = function(){}; | |
1061 | - this.resize = function( _w, _h ){ | |
1062 | - if( instance.MIN_WIDTH > _w || instance.MIN_HEIGHT > _h ){ | |
1063 | - if( Type.isHTMLElement( instance.rootElement ) === true ){ | |
1064 | - // 小さすぎる!、と表示 | |
1065 | - }; | |
1066 | - return; | |
1067 | - }; | |
1068 | - instance.onPaneResize( _w, _h ); | |
1069 | - }; | |
1070 | - this.onPaneResize = function( _w, _h ){}; | |
1071 | - this.close = function(){ | |
1072 | - instance.onClose(); | |
1073 | - instance = this; | |
1074 | - }; | |
1075 | -}; | |
1076 | - | |
1077 | -var ApplicationPrivateDataClass = function(){ | |
1078 | - | |
1079 | -}; | |
1080 | -ApplicationPrivateDataClass.prototype = { | |
1052 | +var ApplicationPrivateData = function(){}; | |
1053 | +ApplicationPrivateData.prototype = { | |
1081 | 1054 | appClass : null, |
1082 | 1055 | application : null, |
1083 | 1056 | displayName : null, |
@@ -1086,495 +1059,214 @@ ApplicationPrivateDataClass.prototype = { | ||
1086 | 1059 | bgColor : '#C1CACF', |
1087 | 1060 | uiList : null, |
1088 | 1061 | finderList : null, |
1089 | - layer : null, | |
1062 | + styleCursor : null, | |
1090 | 1063 | eventRoot : null, |
1091 | 1064 | fetchResource : 0, |
1092 | 1065 | bootParams : null, |
1093 | 1066 | phase : 0, |
1094 | - cursor : '' | |
1095 | -}; | |
1096 | - | |
1097 | -var AbstractApplication = function( displayName, appClass, isOverlay ){ | |
1098 | - var self = null, // init で設定 | |
1099 | - uiList = [], | |
1100 | - finderList = [], | |
1101 | - layer = null, | |
1102 | - root = null, | |
1103 | - fetchResource = 0, | |
1104 | - bootParams = null, | |
1105 | - phase = 0, | |
1106 | - cursor = ''; | |
1107 | - this.rootElement = document.createElement( 'div' ); | |
1108 | - this.bgColor = '#C1CACF'; | |
1109 | - this.getUID = function(){ | |
1110 | - return Util.getIndex( API_USER_LIST, appClass ); | |
1111 | - }; | |
1112 | - this.init = function(){ | |
1113 | - phase = 1; | |
1114 | - self = this; | |
1115 | - appClass === Page.appClass && Page.show(); | |
1116 | - self.onInit(); | |
1117 | - layer !== null && layer.start(); | |
1118 | - phase = 2; | |
1119 | - }; | |
1120 | - this.open = function( _w, _h /*, _option */ ){ | |
1121 | - phase = 3; | |
1122 | - bootParams = Util.copyArray( arguments ); | |
1123 | - | |
1124 | - if( this.rootElement.innerHTML && this.rootElement.innerHTML.length > 0 ){ | |
1125 | - SystemTimer.add( self, detect, 16 ); | |
1126 | - } else { | |
1127 | - onOpen(); | |
1067 | + cursor : '', | |
1068 | + w : 0, | |
1069 | + h : 0, | |
1070 | + init : function( displayName, appClass, isOverlay ){ | |
1071 | + // this.application = app; | |
1072 | + this.displayName = displayName; | |
1073 | + this.appClass = appClass; | |
1074 | + this.isOverlay = isOverlay; | |
1075 | + // app.rootElement = ; | |
1076 | + this.rootElement = document.createElement( 'div' ); | |
1077 | + this.styleCursor = this.rootElement.style; | |
1078 | + ApplicationPrivateData.list.push( this ); | |
1079 | + }, | |
1080 | + detect : function(){ | |
1081 | + if( this.rootElement.firstChild && this.fetchResource === 0 ){ | |
1082 | + SystemTimer.remove( this.application, this.detect ); | |
1083 | + this.onOpen(); | |
1128 | 1084 | }; |
1085 | + }, | |
1086 | + onOpen : function(){ | |
1087 | + this.rootElement.style.display = ''; | |
1129 | 1088 | |
1130 | - function detect(){ | |
1131 | - if( self.rootElement.firstChild && fetchResource === 0 ){ | |
1132 | - SystemTimer.remove( self, detect ); | |
1133 | - onOpen(); | |
1134 | - }; | |
1135 | - }; | |
1089 | + // this.layer !== null && this.layer.onResize( this.w, this.h ); | |
1136 | 1090 | |
1137 | - function onOpen(){ | |
1138 | - self.rootElement.style.display = ''; | |
1139 | - | |
1140 | - layer !== null && layer.onResize( _w, _h ); | |
1141 | - | |
1142 | - if( self.MIN_WIDTH > _w || self.MIN_HEIGHT > _h ){ | |
1143 | - if( Type.isHTMLElement( self.rootElement ) === true ){ | |
1144 | - // 小さすぎる!、と表示 | |
1145 | - }; | |
1146 | - }; | |
1147 | - if( bootParams.length > 2 ){ | |
1148 | - self.onOpen.apply( self, bootParams ); | |
1149 | - } else { | |
1150 | - self.onOpen( _w, _h ); | |
1091 | + if( this.application.MIN_WIDTH > this.w || this.application.MIN_HEIGHT > this.h ){ | |
1092 | + if( Type.isHTMLElement( this.rootElement ) === true ){ | |
1093 | + // 小さすぎる!、と表示 | |
1151 | 1094 | }; |
1152 | - phase = 4; | |
1153 | 1095 | }; |
1096 | + if( this.bootParams.length > 2 ){ | |
1097 | + this.application.onOpen.apply( this.application, this.bootParams ); | |
1098 | + } else { | |
1099 | + this.application.onOpen( this.w, this.h ); | |
1100 | + }; | |
1101 | + this.phase = 4; | |
1102 | + }, | |
1103 | + fetchResourceComplete : function(){ | |
1104 | + --this.fetchResource; | |
1105 | + } | |
1106 | +}; | |
1107 | +ApplicationPrivateData.list = []; | |
1108 | +ApplicationPrivateData.get = function( app ){ | |
1109 | + var list = ApplicationPrivateData.list, | |
1110 | + i = list.length; | |
1111 | + for( ; i; ){ | |
1112 | + if( app instanceof list[ --i ].appClass ) return list[ i ]; | |
1154 | 1113 | }; |
1155 | - this.resize = function( _w, _h ){ | |
1156 | - if( phase !== 4 ) return; | |
1157 | - if( self.MIN_WIDTH > _w || self.MIN_HEIGHT > _h ){ | |
1158 | - if( Type.isHTMLElement( self.rootElement ) === true ){ | |
1114 | + return null; | |
1115 | +}; | |
1116 | + | |
1117 | +var AbstractApplication = { | |
1118 | + getUID : function(){ | |
1119 | + var data = ApplicationPrivateData.get( this ); | |
1120 | + return Util.getIndex( API_USER_LIST, data.appClass ); | |
1121 | + }, | |
1122 | + init : function(){ | |
1123 | + var data = ApplicationPrivateData.get( this ); | |
1124 | + this.rootElement = data.rootElement; | |
1125 | + data.application = this; | |
1126 | + data.phase = 1; | |
1127 | + data.appClass === Page.appClass && Page.show(); | |
1128 | + this.onInit(); | |
1129 | + // data.layer && data.layer.start(); | |
1130 | + data.phase = 2; | |
1131 | + }, | |
1132 | + open : function( w, h /*, _option */ ){ | |
1133 | + var data = ApplicationPrivateData.get( this ); | |
1134 | + data.phase = 3; | |
1135 | + data.bootParams = Util.copyArray( arguments ); | |
1136 | + data.w = w; | |
1137 | + data.h = h; | |
1138 | + if( data.rootElement.innerHTML && data.rootElement.innerHTML.length > 0 ){ | |
1139 | + SystemTimer.add( this, data.detect, 16, false, data ); | |
1140 | + } else { | |
1141 | + data.onOpen(); | |
1142 | + }; | |
1143 | + }, | |
1144 | + resize : function( w, h ){ | |
1145 | + var data = ApplicationPrivateData.get( this ); | |
1146 | + if( data.phase !== 4 ) return; | |
1147 | + if( this.MIN_WIDTH > w || this.MIN_HEIGHT > h ){ | |
1148 | + if( Type.isHTMLElement( this.rootElement ) === true ){ | |
1159 | 1149 | // 小さすぎる!、と表示 |
1160 | 1150 | }; |
1161 | 1151 | return; |
1162 | 1152 | }; |
1163 | - self.onPaneResize( _w, _h ); | |
1164 | - layer !== null && layer.onResize( _w, _h ); | |
1165 | - }; | |
1166 | - this.close = function(){ | |
1167 | - phase = 5; | |
1168 | - if( self.onClose() === false ){ | |
1153 | + this.onPaneResize( w, h ); | |
1154 | + // data.layer !== null && data.layer.onResize( w, h ); | |
1155 | + }, | |
1156 | + close : function(){ | |
1157 | + var data = ApplicationPrivateData.get( this ); | |
1158 | + data.phase = 5; | |
1159 | + if( this.onClose() === false ){ | |
1169 | 1160 | return false; |
1170 | 1161 | }; |
1171 | - while( uiList.length > 0 ){ | |
1172 | - uiList.shift().destroy(); | |
1162 | + if( data.uiList ){ | |
1163 | + while( data.uiList.length > 0 ) data.uiList.shift().destroy(); | |
1173 | 1164 | }; |
1174 | - while( finderList.length > 0 ){ | |
1175 | - finderList.shift().destroy(); | |
1165 | + if( data.finderList ){ | |
1166 | + while( data.finderList.length > 0 ) data.finderList.shift().destroy(); | |
1176 | 1167 | }; |
1177 | 1168 | |
1178 | - root && PointingDeviceEventTree.destroyTree( root ); | |
1179 | - MouseEvent.remove( self ); | |
1180 | - KeyEvent.remove( self ); | |
1181 | - SystemTimer.remove( self ); | |
1182 | - AsyncCall.remove( self ); | |
1183 | - StyleSheet.unload( self ); | |
1184 | - | |
1185 | - layer !== null && layer.destroy(); | |
1186 | - layer = null; | |
1169 | + data.eventRoot && PointingDeviceEventTree.destroyTree( data.eventRoot ); | |
1170 | + MouseEvent.remove( this ); | |
1171 | + KeyEvent.remove( this ); | |
1172 | + SystemTimer.remove( this ); | |
1173 | + AsyncCall.remove( this ); | |
1174 | + StyleSheet.unload( this ); | |
1187 | 1175 | |
1176 | + // data.layer && data.layer.destroy(); | |
1188 | 1177 | |
1189 | - var elm = self.rootElement; | |
1178 | + var elm = this.rootElement; | |
1190 | 1179 | Util.removeAllChildren( elm ); |
1191 | 1180 | elm.parentNode.removeChild( elm ); |
1192 | - self.rootElement = null; | |
1193 | - | |
1194 | - Application.shutdown( self, isOverlay ); | |
1195 | 1181 | |
1196 | - appClass === Page.appClass && Page.hide(); | |
1182 | + Application.shutdown( this, data.isOverlay ); | |
1197 | 1183 | |
1198 | - self = appClass = uiList = null; | |
1199 | - | |
1200 | - phase = 6; | |
1201 | - }; | |
1202 | - this.createUIGroup = function(){ | |
1203 | - var _ui = UI.createUIGroup( self ); | |
1204 | - uiList.push( _ui ); | |
1205 | - return _ui; | |
1206 | - }; | |
1207 | - this.createFinder = function( _elmTarget, _tree, _onSelect, _viewerOption, _editorOption ){ | |
1208 | - var _finder = Finder.create( self, _elmTarget, _tree, _onSelect, _viewerOption, _editorOption ); | |
1209 | - finderList.push( _finder ); | |
1210 | - return _finder; | |
1211 | - }; | |
1212 | - this.createBasicPane = function( _class, _options ){ | |
1213 | - if( Type.isFunction( _class ) === false ) return null; | |
1214 | - _class.prototype = new AbstractBasicPane(); | |
1215 | - return new _class( _options ); | |
1216 | - }; | |
1217 | - this.createDHTML = function( _elm ){ | |
1218 | - return DHTML.create( self, _elm ); | |
1219 | - }; | |
1220 | - this.addEventListener = function( _element, _eventType, _handler, _opt_thisObject ){ | |
1221 | - if( layer !== null && layer.contain( _element ) === true ){ | |
1222 | - layer.addEvent( _element, _eventType, _handler, _opt_thisObject ); | |
1223 | - } else { | |
1224 | - MouseEvent.add( self, _element, _eventType, _handler, _opt_thisObject ); | |
1225 | - }; | |
1226 | - }; | |
1227 | - this.removeEventListener = function( _element, _eventType, _handler ){ | |
1228 | - if( layer !== null && layer.contain( _element ) === true ){ | |
1229 | - layer.removeEvent( _element, _eventType, _handler ); | |
1230 | - } else { | |
1231 | - MouseEvent.remove( self, _element, _eventType, _handler ); | |
1232 | - }; | |
1233 | - }; | |
1234 | - this.useInteractiveLayer = function( /* handleEvents */ ){ | |
1235 | - if( phase === 1 && layer === null ){ | |
1236 | - layer = InteractiveLayer.create( self, Util.copyArray( arguments ) ); | |
1237 | - root = PointingDeviceEventTree.create( self, layer ); | |
1238 | - }; | |
1239 | - }; | |
1240 | - this.getPointingDeviceEventTreeRoot = function(){ | |
1241 | - return root; | |
1242 | - }; | |
1243 | - this.createInteractContainer = function( elm ){ | |
1244 | - if( layer !== null ) return layer.createContainer( elm ); | |
1245 | - }; | |
1246 | - this.registerInteractiveListener = function( /* */ ){ | |
1247 | - layer !== null && layer.register( Util.copyArray( arguments ) ); | |
1248 | - }; | |
1249 | - this.isCurrentInteractiveEventListener = function( listener ){ | |
1250 | - layer !== null && layer.isCurrentListener( listener ); | |
1251 | - }; | |
1252 | - this.updateCoursor = function( _cursor ){ | |
1253 | - if( cursor !== _cursor ){ | |
1254 | - if( layer ){ | |
1255 | - layer.elm.style.cursor = cursor = _cursor; | |
1256 | - } else { | |
1257 | - self.rootElement.style.cursor = cursor = _cursor; | |
1258 | - }; | |
1259 | - }; | |
1260 | - }; | |
1261 | - this.fetchCSS = function( _url, opt_onload, opt_onerror ){ | |
1262 | - if( phase === 1 ){ | |
1263 | - ++fetchResource; | |
1264 | - StyleSheet.load( self, _url, fetchResourceComplete, fetchResourceComplete ); | |
1265 | - }; | |
1266 | - }; | |
1267 | - | |
1268 | - function fetchResourceComplete(){ | |
1269 | - --fetchResource; | |
1270 | - }; | |
1271 | -}; | |
1272 | - | |
1273 | -AbstractApplication.prototype = new AbstractBasicPane(); | |
1274 | -AbstractApplication.prototype.onInit = function(){ | |
1275 | - // overrride | |
1276 | -}; | |
1277 | -AbstractApplication.prototype.onOpen = function( _w, _h /*, _option */ ){ | |
1278 | - // overrride | |
1279 | -}; | |
1280 | -AbstractApplication.prototype.onClose = function(){ | |
1281 | - // overrride | |
1282 | - return true; | |
1283 | -}; // false の場合、close の拒否 | |
1284 | -AbstractApplication.prototype.addKeyEventListener = function( _eventType, _handler, _keyCode, _shift, _ctrl ){ | |
1285 | - KeyEvent.add( this, _eventType, _handler, _keyCode, _shift, _ctrl ); | |
1286 | -}; | |
1287 | -AbstractApplication.prototype.removeKeyEventListener = function( _eventType, _handler, _keyCode, _shift, _ctrl ){ | |
1288 | - KeyEvent.remove( this, _eventType, _handler, _keyCode, _shift, _ctrl ); | |
1289 | -}; | |
1290 | -AbstractApplication.prototype.shiftEnabled = function(){ | |
1291 | - return KeyEvent.shiftEnabled; | |
1292 | -}; | |
1293 | -AbstractApplication.prototype.ctrlEnabled = function(){ | |
1294 | - return KeyEvent.ctrlEnabled; | |
1295 | -}; | |
1296 | -AbstractApplication.prototype.addTimer = function( handler, time, once ){ | |
1297 | - SystemTimer.add( this, handler, time, !!once ); | |
1298 | -}; | |
1299 | -AbstractApplication.prototype.removeTimer = function( handler ){ | |
1300 | - SystemTimer.remove( this, handler ); | |
1301 | -}; | |
1302 | -AbstractApplication.prototype.addAsyncCall = function( _callback, _argments, _thisObject ){ | |
1303 | - AsyncCall.add( this, _callback, _argments, _thisObject ); | |
1304 | -}; | |
1305 | -AbstractApplication.prototype.removeAsyncCall = function( _callback ){ | |
1306 | - AsyncCall.remove( this, _callback ); | |
1307 | -}; | |
1308 | -AbstractApplication.prototype.fetchHTMLElement = function( id ){ | |
1309 | - var elm = document.getElementById( id ); | |
1310 | - if( elm ){ | |
1311 | - elm.removeAttribute( 'id' ); | |
1312 | - elm.parentNode.removeChild( elm ); | |
1313 | - return elm; | |
1314 | - }; | |
1315 | -}; | |
1316 | - | |
1184 | + data.appClass === Page.appClass && Page.hide(); | |
1317 | 1185 | |
1318 | -var InteractiveLayer = ( function(){ | |
1319 | - var LAYER_LIST = [], | |
1320 | - currentLayer = null, | |
1321 | - currentList = null, | |
1322 | - currentListener = null; | |
1323 | - | |
1324 | - function eventRellay( e ){ | |
1325 | - var _mouseX = e.clientX, | |
1326 | - _mouseY = e.clientY, | |
1327 | - _type = e.type === 'mouseout' ? 'mouseup' : e.type, | |
1328 | - _listener = currentListener, | |
1329 | - i, l; | |
1330 | - if( _listener !== null && _listener.busy() === true && _listener[ _type ] && _listener[ _type ]( _mouseX, _mouseY, e, _type ) === true ){ | |
1331 | - // currentListener[ _type ]( _mouseX, _mouseY, e, _type ); | |
1332 | - // console.log( '** current true : ' + _type + ' ' + Util.getIndex( currentList, _listener ) + ( _listener.id || _listener.elm.id ) ); | |
1333 | - } else { | |
1334 | - currentListener = null; | |
1335 | - for( i = 0, l = currentList.length; i<l; ++i ){ | |
1336 | - _listener = currentList[ i ]; | |
1337 | - if( _listener[ _type ] && _listener[ _type ]( _mouseX, _mouseY, e, _type ) === true ){ | |
1338 | - currentListener = _listener; | |
1339 | - // console.log( 'true : currentList.length = ' + l + ' ' + i ) | |
1340 | - break; | |
1341 | - }; | |
1342 | - }; | |
1343 | - | |
1344 | - }; | |
1345 | - // 文字選択の禁止 | |
1346 | - //!document.selection && window.getSelection().removeAllRanges(); | |
1347 | - return false; | |
1348 | - }; | |
1349 | - | |
1350 | - var LayerClass = function( apiuser ){ | |
1351 | - this.apiuser = apiuser; | |
1352 | - }; | |
1353 | - LayerClass.prototype = { | |
1354 | - init: function( events ){ | |
1355 | - this.elm = document.createElement( 'div' ); | |
1356 | - body.appendChild( this.elm ); | |
1357 | - // this.elm.style.cssText = 'position:absolute;top:0;left:0;height:100%;'; | |
1358 | - this.elm.className = 'mouse-operation-catcher'; | |
1359 | - this.elm.unselectable = 'on'; | |
1360 | - | |
1361 | - this.listeners = []; | |
1362 | - | |
1363 | - if( Type.isString( events ) === true ){ | |
1364 | - events = events.split( ',' ); | |
1365 | - } else | |
1366 | - if( Type.isArray( events ) === false ){ | |
1367 | - return; | |
1368 | - }; | |
1369 | - for( var i = events.length; i; ){ | |
1370 | - MouseEvent.add( this.apiuser, this.elm, events[ --i ], eventRellay ); | |
1371 | - }; | |
1372 | - }, | |
1373 | - register: function( listener ){ | |
1374 | - if( Type.isArray( listener ) === false ){ | |
1375 | - this.listeners.push( listener ); | |
1376 | - } else { | |
1377 | - this.listeners.push.apply( this.listeners, listener ); | |
1378 | - }; | |
1379 | - }, | |
1380 | - isCurrentListener : function( listener ){ | |
1381 | - return currentListener === listener; | |
1382 | - }, | |
1383 | - onResize : function( _w, _h ){ | |
1384 | - this.elm.style.height = _h + 'px'; | |
1385 | - }, | |
1386 | - contain : function( elm ){ | |
1387 | - return !!this.getContainer( elm ); | |
1388 | - }, | |
1389 | - getContainer : function( elm ){ | |
1390 | - var linstener; | |
1391 | - for( var i = this.listeners.length; i; ){ | |
1392 | - linstener = this.listeners[ --i ]; | |
1393 | - if( linstener instanceof InteractiveContainer ){ | |
1394 | - if( linstener.contain( elm ) === true ) return linstener; | |
1395 | - }; | |
1396 | - }; | |
1397 | - return null; | |
1398 | - }, | |
1399 | - createContainer : function( elm ){ | |
1400 | - if( this.contain( elm ) === true ) return null; | |
1401 | - var ret = new InteractiveContainer( this.apiuser, elm ); | |
1402 | - this.listeners.unshift( ret ); | |
1403 | - return ret; | |
1404 | - }, | |
1405 | - addEvent : function( element, eventType, handler, _opt_thisObject ){ | |
1406 | - //console.log( eventType ) | |
1407 | - currentListener = null; | |
1408 | - | |
1409 | - var container = this.getContainer( element ); | |
1410 | - container !== null && container.addEvent( element, eventType, handler, _opt_thisObject ); | |
1411 | - | |
1412 | - MouseEvent.add( this.apiuser, this.elm, eventType, eventRellay ); | |
1413 | - }, | |
1414 | - removeEvent : function( element, eventType, handler ){ | |
1415 | - currentListener = null; | |
1416 | - | |
1417 | - var container = this.getContainer( element ); | |
1418 | - container !== null && container.removeEvent( element, eventType, handler ); | |
1419 | - }, | |
1420 | - start : function(){ | |
1421 | - currentLayer = this; | |
1422 | - currentList = currentLayer.listeners; | |
1423 | - currentLayer.elm.style.display = ''; | |
1424 | - }, | |
1425 | - destroy: function(){ | |
1426 | - MouseEvent.remove( this.apiuser, this.elm ); | |
1427 | - body.removeChild( this.elm ); | |
1428 | - | |
1429 | - this.listeners.splice( 0, this.listeners.length ); | |
1430 | - | |
1431 | - LAYER_LIST.splice( Util.getIndex( LAYER_LIST, this ), 1 ); | |
1432 | - } | |
1433 | - }; | |
1434 | - | |
1435 | - return { | |
1436 | - create : function( apiuser, events ){ | |
1437 | - var ret = new LayerClass( apiuser ); | |
1438 | - ret.init( events ); | |
1439 | - LAYER_LIST.push( ret ); | |
1440 | - return ret; | |
1441 | - }, | |
1442 | - onCurrentApplicationChange : function( _application ){ | |
1443 | - for( var i = 0, l = LAYER_LIST.length; i < l; ++i ){ | |
1444 | - if( LAYER_LIST[ i ].apiuser === _application ){ | |
1445 | - currentLayer = LAYER_LIST[ i ]; | |
1446 | - currentList = currentLayer.listeners; | |
1447 | - currentLayer.elm.style.display = ''; | |
1448 | - return; | |
1449 | - }; | |
1450 | - }; | |
1451 | - if( currentLayer ) currentLayer.elm.style.display = 'none'; | |
1452 | - currentLayer = null; | |
1453 | - currentList = null; | |
1454 | - currentListener = null; | |
1455 | - }, | |
1456 | - onSystemShutdown : function(){ | |
1457 | - | |
1458 | - } | |
1459 | - }; | |
1460 | -})(); | |
1461 | - | |
1462 | -var InteractiveContainer = function( apiuser, elm ){ | |
1463 | - this.apiuser = apiuser; | |
1464 | - this.elm = elm; | |
1465 | - this.events = {}; | |
1466 | - this.mesure(); | |
1467 | -}; | |
1468 | -InteractiveContainer.prototype = { | |
1469 | - current : null, | |
1470 | - addEvent : function( element, eventType, handler, opt_thisObject ){ | |
1471 | - var list = this.events[ eventType ], i; | |
1472 | - if( !list ){ | |
1473 | - list = this.events[ eventType ] = []; | |
1474 | - this[ eventType ] = this._eventRellay; | |
1475 | - }; | |
1476 | - for( i = list.length; i; ){ | |
1477 | - if( list[ --i ].match( element, eventType, handler ) === true ){ | |
1478 | - return; | |
1479 | - }; | |
1480 | - }; | |
1481 | - var ticket = new InterractiveEventTicket( element, eventType, handler, this.elm, opt_thisObject ); | |
1482 | - ticket.init( Position.cumulativeOffset( this.elm ) ); | |
1483 | - list.push( ticket ); | |
1484 | - // AsyncCall.add( this.apiuser, ticket.init, Position.cumulativeOffset( this.elm ), ticket ); | |
1186 | + data.phase = 6; | |
1187 | + | |
1188 | + var list = ApplicationPrivateData.list; | |
1189 | + list.splice( Util.getIndex( list, data ), 1 ); | |
1485 | 1190 | }, |
1486 | - removeEvent : function( element, eventType, handler ){ | |
1487 | - var list, i; | |
1488 | - for( var type in this.events ){ | |
1489 | - list = this.events[ type ]; | |
1490 | - if( eventType && eventType !== type ) continue; | |
1491 | - if( Type.isArray( list ) === false ) continue; | |
1492 | - for( i = list.length; i; ){ | |
1493 | - if( list[ --i ].match( element, eventType, handler ) === true ){ | |
1494 | - list.splice( i, 1 ); | |
1495 | - if( list.length === 0 ){ | |
1496 | - delete this[ type ]; | |
1497 | - delete this.events[ type ]; | |
1498 | - }; | |
1499 | - }; | |
1500 | - }; | |
1501 | - }; | |
1191 | + createUIGroup : function(){ | |
1192 | + var data = ApplicationPrivateData.get( this ), | |
1193 | + ui = UI.createUIGroup( this ); | |
1194 | + if( data.uiList === null ) data.uiList = []; | |
1195 | + data.uiList.push( ui ); | |
1196 | + return ui; | |
1502 | 1197 | }, |
1503 | - mesured : false, | |
1504 | - mesure : function(){ | |
1505 | - var positon = Position.cumulativeOffset( this.elm ); | |
1506 | - this.x = positon[ 0 ]; | |
1507 | - this.y = positon[ 1 ]; | |
1508 | - this.mesured = true; | |
1198 | + createFinder : function( _elmTarget, _tree, _onSelect, _viewerOption, _editorOption ){ | |
1199 | + var data = ApplicationPrivateData.get( this ), | |
1200 | + finder = Finder.create( this, _elmTarget, _tree, _onSelect, _viewerOption, _editorOption ); | |
1201 | + if( data.finderList === null ) data.finderList = []; | |
1202 | + data.finderList.push( finder ); | |
1203 | + return finder; | |
1509 | 1204 | }, |
1510 | - asyncMesure : function(){ | |
1511 | - this.mesured === false && this.mesure(); | |
1205 | + createDHTML : function( _elm ){ | |
1206 | + return DHTML.create( this, _elm ); | |
1512 | 1207 | }, |
1513 | - setPositon : function( x, y ){ | |
1514 | - this.x = x; | |
1515 | - this.y = y; | |
1516 | - this.elm.style.left = x + 'px'; | |
1517 | - this.elm.style.top = y + 'px'; | |
1208 | + addEventListener : function( element, eventType, handler, opt_thisObject ){ | |
1209 | + MouseEvent.add( this, element, eventType, handler, opt_thisObject ); | |
1518 | 1210 | }, |
1519 | - contain : function( child ){ | |
1520 | - return this.elm === child || Util.contain( this.elm, child ); | |
1211 | + removeEventListener : function( element, eventType, handler ){ | |
1212 | + MouseEvent.remove( this, element, eventType, handler ); | |
1521 | 1213 | }, |
1522 | - busy : function(){ | |
1523 | - return this.current !== null; | |
1214 | + getPointingDeviceEventTreeRoot : function(){ | |
1215 | + var data = ApplicationPrivateData.get( this ); | |
1216 | + if( data.phase === 1 ){ | |
1217 | + data.eventRoot = PointingDeviceEventTree.create( this ); | |
1218 | + data.styleCursor = PointingDeviceEventTree._getNodePrivateData( data.eventRoot ).elmMouseCatch.style; | |
1219 | + }; | |
1220 | + return data.eventRoot; | |
1524 | 1221 | }, |
1525 | - _eventRellay : function( mouseX, mouseY, e, eventType ){ | |
1526 | - var list = this.events[ eventType ]; | |
1527 | - if( Type.isArray( list ) === false ) return false; | |
1528 | - // console.log( eventType + ' mX:' + mouseX + ' mY:' + mouseY + ' x:' + this.x + ' y:' + this.y + ' ' + this.elm.id ); | |
1529 | - var x = mouseX - this.x, | |
1530 | - y = mouseY - this.y, | |
1531 | - c = this.current, | |
1532 | - t, i; | |
1533 | - if( c !== null && c.type === eventType ){ | |
1534 | - if( c.x <= x && x <= c.x + c.target.offsetWidth && c.y <= y && y <= c.y + c.target.offsetHeight ){ | |
1535 | - c.handler.call( c.thisObj || c.target, e, x, y ); | |
1536 | - return true; | |
1537 | - }; | |
1222 | + updateCoursor : function( _cursor ){ | |
1223 | + var data = ApplicationPrivateData.get( this ); | |
1224 | + if( data.cursor !== _cursor ){ | |
1225 | + data.styleCursor.cursor = data.cursor = _cursor; | |
1538 | 1226 | }; |
1539 | - for( i = list.length; i; ){ | |
1540 | - t = list[ --i ]; | |
1541 | - if( t.x <= x && x <= t.x + t.target.offsetWidth && t.y <= y && y <= t.y + t.target.offsetHeight ){ | |
1542 | - t.handler.call( t.thisObj || t.target, e, x, y ); | |
1543 | - this.current = t; | |
1544 | - return true; | |
1545 | - }; | |
1227 | + }, | |
1228 | + fetchCSS : function( url, opt_onload, opt_onerror ){ | |
1229 | + var data = ApplicationPrivateData.get( this ); | |
1230 | + if( data.phase === 1 ){ | |
1231 | + ++data.fetchResource; | |
1232 | + StyleSheet.load( this, url, data.fetchResourceComplete, data.fetchResourceComplete, data ); | |
1546 | 1233 | }; |
1547 | - // console.log( 'false ' + this.elm.id ); | |
1548 | - this.current = null; | |
1549 | - return false; | |
1550 | - } | |
1551 | -}; | |
1552 | - | |
1553 | -var InterractiveEventTicket = function( elm, type, handler, parent, opt_thisObject ){ | |
1554 | - this.target = elm; | |
1555 | - this.type = type; | |
1556 | - this.handler = handler; | |
1557 | - this.parent = parent; | |
1558 | - this.thisObj = opt_thisObject; | |
1559 | -}; | |
1560 | -InterractiveEventTicket.prototype = { | |
1561 | - x : -99999, | |
1562 | - y : -99999, | |
1563 | - w : 0, | |
1564 | - h : 0, | |
1565 | - init : function( _positon ){ | |
1566 | - var positon = Position.cumulativeOffset( this.target ); | |
1567 | - this.x = positon[ 0 ] - _positon[ 0 ]; | |
1568 | - this.y = positon[ 1 ] - _positon[ 1 ]; | |
1569 | - this.w = this.target.offsetWidth; | |
1570 | - this.h = this.target.offsetHeight; | |
1571 | - // console.log( '- x: ' + this.x + ' y: ' + this.y + ' w: ' + this.w + ' h: ' + this.h + ' ' + ( this.target.id || '-' ) + ' ,' + this.type ); | |
1572 | 1234 | }, |
1573 | - match : function( element, eventType, handler ){ | |
1574 | - if( handler && this.handler !== handler ) return false; | |
1575 | - if( eventType && this.type !== eventType ) return false; | |
1576 | - if( element && this.target !== element ) return false; | |
1577 | - return true; | |
1235 | + onInit : function(){}, | |
1236 | + onOpen : function(){}, | |
1237 | + onClose : function(){ return true; }, | |
1238 | + onPaneResize : function( w, h ){}, | |
1239 | + addKeyEventListener : function( _eventType, _handler, _keyCode, _shift, _ctrl ){ | |
1240 | + KeyEvent.add( this, _eventType, _handler, _keyCode, _shift, _ctrl ); | |
1241 | + }, | |
1242 | + removeKeyEventListener : function( _eventType, _handler, _keyCode, _shift, _ctrl ){ | |
1243 | + KeyEvent.remove( this, _eventType, _handler, _keyCode, _shift, _ctrl ); | |
1244 | + }, | |
1245 | + shiftEnabled : function(){ | |
1246 | + return KeyEvent.shiftEnabled; | |
1247 | + }, | |
1248 | + ctrlEnabled : function(){ | |
1249 | + return KeyEvent.ctrlEnabled; | |
1250 | + }, | |
1251 | + addTimer : function( handler, time, once ){ | |
1252 | + SystemTimer.add( this, handler, time, !!once ); | |
1253 | + }, | |
1254 | + removeTimer : function( handler ){ | |
1255 | + SystemTimer.remove( this, handler ); | |
1256 | + }, | |
1257 | + addAsyncCall : function( _callback, _argments, _thisObject ){ | |
1258 | + AsyncCall.add( this, _callback, _argments, _thisObject ); | |
1259 | + }, | |
1260 | + removeAsyncCall : function( _callback ){ | |
1261 | + AsyncCall.remove( this, _callback ); | |
1262 | + }, | |
1263 | + fetchHTMLElement : function( id ){ | |
1264 | + var elm = document.getElementById( id ); | |
1265 | + if( elm ){ | |
1266 | + elm.removeAttribute( 'id' ); | |
1267 | + elm.parentNode.removeChild( elm ); | |
1268 | + return elm; | |
1269 | + }; | |
1578 | 1270 | } |
1579 | 1271 | }; |
1580 | 1272 |
@@ -2376,15 +2068,23 @@ var PointingDeviceEventTree = ( function(){ | ||
2376 | 2068 | })(); |
2377 | 2069 | |
2378 | 2070 | return { |
2379 | - create : function( apiuser, layer ){ | |
2071 | + create : function( apiuser ){ | |
2380 | 2072 | var root = new NodeClass( apiuser, null, null, apiuser.rootElement ), |
2381 | - data = NodePrivateData.get( root ); | |
2382 | - data.elmMouseCatch = layer.elm; | |
2073 | + data = NodePrivateData.get( root ), | |
2074 | + elm = document.createElement( 'div' ); | |
2075 | + body.appendChild( elm ); | |
2076 | + // elm.style.cssText = 'position:absolute;top:0;left:0;height:100%;'; | |
2077 | + elm.className = 'mouse-operation-catcher'; | |
2078 | + elm.unselectable = 'on'; | |
2079 | + data.elmMouseCatch = elm; | |
2080 | + | |
2383 | 2081 | data.eventCounter = {}; |
2384 | 2082 | ROOT_LIST.push( data ); |
2385 | 2083 | currentRootData = data; |
2386 | 2084 | targetNodeData = null; |
2387 | 2085 | forceNodeData = null; |
2086 | + | |
2087 | + MouseEvent.add( apiuser, elm, 'mousemove', eventRellay ); | |
2388 | 2088 | return root; |
2389 | 2089 | }, |
2390 | 2090 | onCurrentApplicationChange : function( _application ){ |
@@ -2399,6 +2099,9 @@ var PointingDeviceEventTree = ( function(){ | ||
2399 | 2099 | }; |
2400 | 2100 | }, |
2401 | 2101 | destroyTree : function( root ){ |
2102 | + var data = NodePrivateData.get( root ); | |
2103 | + MouseEvent.remove( data.apiuser, data.elmMouseCatch, 'mousemove', eventRellay ); | |
2104 | + body.removeChild( data.elmMouseCatch ); | |
2402 | 2105 | NodePrivateData.get( root )._destroy(); |
2403 | 2106 | ROOT_LIST.splice( Util.getIndex( ROOT_LIST, root ), 1 ); |
2404 | 2107 | }, |
@@ -2460,17 +2163,14 @@ var Application = ( function(){ | ||
2460 | 2163 | _tail === true && Home.add( _ref ); |
2461 | 2164 | return _ref; |
2462 | 2165 | }, |
2463 | - isBasicPaneInstance: function( _basicPane ){ | |
2464 | - return _basicPane instanceof AbstractBasicPane; | |
2465 | - }, | |
2466 | - isApplicationInstance: function( _application ){ | |
2467 | - return _application instanceof AbstractApplication; | |
2166 | + isApplicationInstance: function( app ){ | |
2167 | + return ApplicationPrivateData.get( app ) !== null; | |
2468 | 2168 | }, |
2469 | 2169 | isApplicationReference: function( _reference ){ |
2470 | 2170 | return _reference instanceof ApplicationReference; |
2471 | 2171 | }, |
2472 | - isCurrentAppplication: function( _application ){ | |
2473 | - return true | |
2172 | + isCurrentAppplication: function( app ){ | |
2173 | + return app === currentApplication; | |
2474 | 2174 | }, |
2475 | 2175 | boot: function( displayName, uid, appClass, isOverlay, arg ){ |
2476 | 2176 | if( currentApplication ){ |
@@ -2478,7 +2178,9 @@ var Application = ( function(){ | ||
2478 | 2178 | if( isOverlay === false && currentApplication.close() === false ) return null; |
2479 | 2179 | }; |
2480 | 2180 | |
2481 | - appClass.prototype = new AbstractApplication( displayName, appClass, isOverlay ); | |
2181 | + appClass.prototype = AbstractApplication; | |
2182 | + var data = new ApplicationPrivateData(); | |
2183 | + data.init( displayName, appClass, isOverlay ); | |
2482 | 2184 | var application = new appClass(); // new は boot で |
2483 | 2185 | |
2484 | 2186 | coveredApplication = isOverlay === true ? currentApplication : null; |
@@ -2488,8 +2190,8 @@ var Application = ( function(){ | ||
2488 | 2190 | if( isOverlay === false ){ |
2489 | 2191 | body.style.backgroundColor = application.bgColor; |
2490 | 2192 | |
2491 | - body.appendChild( application.rootElement ); | |
2492 | - application.rootElement.style.display = 'none'; | |
2193 | + body.appendChild( data.rootElement ); | |
2194 | + data.rootElement.style.display = 'none'; | |
2493 | 2195 | application.init(); |
2494 | 2196 | |
2495 | 2197 | application.addAsyncCall( asyncOpen, arg ); |
@@ -3422,22 +3124,21 @@ var ResizeEvent = ( function(){ | ||
3422 | 3124 | }; |
3423 | 3125 | }; |
3424 | 3126 | }, |
3425 | - remove: function( _apiuser, _element, _eventType, _handler ){ | |
3426 | - if( isApiUser( _apiuser ) === true ){ | |
3427 | - var _uid = _apiuser.getUID(), | |
3428 | - _events = EVENT_LIST_MAP[ _uid ], | |
3429 | - _removed, | |
3430 | - i = 0; | |
3431 | - if( Type.isArray( _events ) === false ) return; | |
3432 | - for( ;i < _events.length; ){ | |
3433 | - if( _events[ i ].destroy( _element, _eventType, _handler ) === true ){ | |
3434 | - _events.splice( i, 1 ); | |
3127 | + remove: function( apiuser, element, eventType, handler ){ | |
3128 | + if( isApiUser( apiuser ) === true ){ | |
3129 | + var uid = apiuser.getUID(), | |
3130 | + list = EVENT_LIST_MAP[ uid ], | |
3131 | + i = 0; | |
3132 | + if( Type.isArray( list ) === false ) return; | |
3133 | + for( ;i < list.length; ){ | |
3134 | + if( list[ i ].destroy( element, eventType, handler ) === true ){ | |
3135 | + list.splice( i, 1 ); | |
3435 | 3136 | } else { |
3436 | 3137 | ++i; |
3437 | 3138 | }; |
3438 | 3139 | }; |
3439 | - if( _events.length === 0 ){ | |
3440 | - _events = EVENT_LIST_MAP[ _uid ] = null; | |
3140 | + if( list.length === 0 ){ | |
3141 | + EVENT_LIST_MAP[ uid ] = null; | |
3441 | 3142 | }; |
3442 | 3143 | }; |
3443 | 3144 | }, |
@@ -3675,12 +3376,13 @@ var StyleSheet = ( function(){ | ||
3675 | 3376 | |
3676 | 3377 | var cssRules, sheet; |
3677 | 3378 | |
3678 | - var FetchCssTicketClass = function( _apiuser, _url, _elm, _onload, _onerror ){ | |
3379 | + var FetchCssTicketClass = function( _apiuser, _url, _elm, _onload, _onerror, opt_thisObject ){ | |
3679 | 3380 | this.apiusers = [ _apiuser ]; |
3680 | 3381 | this.url = _url; |
3681 | 3382 | this.elm = _elm; |
3682 | 3383 | this.onload = [ _onload ]; |
3683 | 3384 | this.onerror = [ _onerror ]; |
3385 | + this.thisObj = [ opt_thisObject ]; | |
3684 | 3386 | this.time = 0; |
3685 | 3387 | }; |
3686 | 3388 | FetchCssTicketClass.prototype = { |
@@ -3697,6 +3399,7 @@ var StyleSheet = ( function(){ | ||
3697 | 3399 | this.apiusers.splice( i, 1 ); |
3698 | 3400 | this.onload.splice( i, 1 ); |
3699 | 3401 | this.onerror.splice( i, 1 ); |
3402 | + this.thisObj.splice( i, 1 ); | |
3700 | 3403 | |
3701 | 3404 | if( this.apiusers.length !== 0 ) return false; |
3702 | 3405 |
@@ -3709,6 +3412,7 @@ var StyleSheet = ( function(){ | ||
3709 | 3412 | delete this.elm; |
3710 | 3413 | delete this.onload; |
3711 | 3414 | delete this.onerror; |
3415 | + delete this.thisObj; | |
3712 | 3416 | delete this.time; |
3713 | 3417 | |
3714 | 3418 | return true; |
@@ -3716,14 +3420,14 @@ var StyleSheet = ( function(){ | ||
3716 | 3420 | loaded: function(){ |
3717 | 3421 | for( var i = this.onload.length, f; i; ){ |
3718 | 3422 | f = this.onload[ --i ]; |
3719 | - Type.isFunction( f ) === true && AsyncCall.add( this.apiusers[ i ], f, this.url ); | |
3423 | + Type.isFunction( f ) === true && AsyncCall.add( this.apiusers[ i ], f, this.url, this.thisObj[ i ] || this.apiusers[ i ] ); | |
3720 | 3424 | this.onload[ i ] = this.onerror[ i ] = null; |
3721 | 3425 | }; |
3722 | 3426 | }, |
3723 | 3427 | error: function(){ |
3724 | 3428 | for( var i = this.onerror.length, f; i; ){ |
3725 | 3429 | f = this.onerror[ --i ]; |
3726 | - Type.isFunction( f ) === true && AsyncCall.add( this.apiusers[ i ], f, this.url ); | |
3430 | + Type.isFunction( f ) === true && AsyncCall.add( this.apiusers[ i ], f, this.url, this.thisObj[ i ] || this.apiusers[ i ] ); | |
3727 | 3431 | this.onload[ i ] = this.onerror[ i ] = null; |
3728 | 3432 | }; |
3729 | 3433 | }, |
@@ -3775,7 +3479,7 @@ var StyleSheet = ( function(){ | ||
3775 | 3479 | }; |
3776 | 3480 | |
3777 | 3481 | return { |
3778 | - load: function( _apiuser, _url, opt_onload, opt_onerror ){ | |
3482 | + load: function( _apiuser, _url, opt_onload, opt_onerror, opt_thisObject ){ | |
3779 | 3483 | _url = Util.getAbsolutePath( _url ); |
3780 | 3484 | var t; |
3781 | 3485 | for( var i=TICKET_LIST.length; i; ){ |
@@ -3785,6 +3489,7 @@ var StyleSheet = ( function(){ | ||
3785 | 3489 | t.apiusers.push( _apiuser ); |
3786 | 3490 | t.onload.push( opt_onload ); |
3787 | 3491 | t.onerror.push( opt_onerror ); |
3492 | + t.thisObj.push( opt_thisObject ); | |
3788 | 3493 | }; |
3789 | 3494 | SystemTimer.add( SUPER_USER_KEY, checkTimer, 333 ); |
3790 | 3495 | return; |
@@ -3806,7 +3511,7 @@ var StyleSheet = ( function(){ | ||
3806 | 3511 | }; |
3807 | 3512 | }; |
3808 | 3513 | |
3809 | - TICKET_LIST.push( new FetchCssTicketClass( _apiuser, _url, elm, opt_onload, opt_onerror ) ); | |
3514 | + TICKET_LIST.push( new FetchCssTicketClass( _apiuser, _url, elm, opt_onload, opt_onerror, opt_thisObject ) ); | |
3810 | 3515 | |
3811 | 3516 | SystemTimer.add( SUPER_USER_KEY, checkTimer, 333 ); |
3812 | 3517 | }, |
@@ -3978,15 +3683,12 @@ var Overlay = ( function(){ | ||
3978 | 3683 | Overlay.hide(); |
3979 | 3684 | return false; |
3980 | 3685 | }; |
3981 | - function asyncInit( /* arguments */ ){ | |
3982 | - | |
3983 | - //body.appendChild( application.rootElement ); | |
3686 | + function asyncInit( /* arguments */ ){ | |
3687 | + application.init(); | |
3984 | 3688 | elmContainer.insertBefore( application.rootElement, elmCloseButton ); |
3985 | 3689 | application.rootElement.style.display = 'none'; |
3986 | - application.init(); | |
3987 | 3690 | }; |
3988 | 3691 | function asyncOpen( /* arguments */ ){ |
3989 | - | |
3990 | 3692 | var _arg = Util.copyArray( arguments ); |
3991 | 3693 | _arg.unshift( windowW, windowH ); |
3992 | 3694 | application.open.apply( application, _arg ); |
@@ -4027,11 +3729,13 @@ var Overlay = ( function(){ | ||
4027 | 3729 | |
4028 | 3730 | elmContainer.style.display = 'none'; // hide for fadeIn |
4029 | 3731 | |
4030 | - _application.addAsyncCall( asyncInit ); | |
4031 | - _application.addAsyncCall( asyncOpen, _bootParams ); | |
4032 | - | |
4033 | 3732 | visible = true; |
4034 | 3733 | application = _application; |
3734 | + | |
3735 | + //asyncInit(); | |
3736 | + | |
3737 | + _application.addAsyncCall( asyncInit ); | |
3738 | + _application.addAsyncCall( asyncOpen, _bootParams ); | |
4035 | 3739 | }, |
4036 | 3740 | hide: function(){ |
4037 | 3741 | if( visible === false ) return; |
@@ -5002,16 +4706,22 @@ var Finder = ( function(){ | ||
5002 | 4706 | }, |
5003 | 4707 | destroy : function(){ |
5004 | 4708 | this.tree.removeTreeEventListener( Const.TREE.EVENT.UPDATE, this.draw ); |
5005 | - | |
5006 | - this.nodeRoot.remove(); | |
5007 | - this.nodePath && this.nodePath.remove(); | |
5008 | - | |
4709 | + | |
5009 | 4710 | if( this.pathList ){ |
5010 | 4711 | while( this.pathList.length > 0 ) this.pathList.shift().destroy(); |
5011 | 4712 | }; |
5012 | 4713 | while( this.iconList.length > 0 ) this.iconList.shift().destroy(); |
5013 | 4714 | |
5014 | - this.elmRoot.removeChild( this.elmRoot ); | |
4715 | + this.nodeRoot.remove(); | |
4716 | + // this.nodePath && this.nodePath.remove(); | |
4717 | + | |
4718 | + // this.elmRoot.removeChild( this.elmRoot ); | |
4719 | + | |
4720 | + FINDER_LIST.splice( Util.getIndex( FINDER_LIST, this.finder ), 1 ); | |
4721 | + var data = ApplicationPrivateData.get( this.apiuser ), | |
4722 | + list = data.finderList, | |
4723 | + i = Util.getIndex( list, this.finder ); | |
4724 | + i !== -1 && list.splice( i, 1 ); | |
5015 | 4725 | } |
5016 | 4726 | }; |
5017 | 4727 | FinderPrivateData.LIST = []; |
@@ -5032,35 +4742,34 @@ var Finder = ( function(){ | ||
5032 | 4742 | var FinderClass = function( application, elmRoot, tree, onSelect, viewerOption, editorOption ){ |
5033 | 4743 | ( new FinderPrivateData() ).init( this, application, elmRoot, tree, onSelect, viewerOption, editorOption ); |
5034 | 4744 | }; |
5035 | - FinderClass.prototype = new AbstractBasicPane(); | |
5036 | - FinderClass.prototype.MIN_WIDTH = 240; | |
5037 | - FinderClass.prototype.MIN_HEIGHT = 240; | |
5038 | - FinderClass.prototype.onInit = function(){ | |
4745 | + FinderClass.prototype = { | |
4746 | + MIN_WIDTH : 200, | |
4747 | + MIN_HEIGHT : 200, | |
4748 | + init : function(){ | |
5039 | 4749 | var data = FinderPrivateData.get( this ); |
5040 | - // var position = Util.getAbsolutePosition( elmPath ); | |
5041 | - // data.headX = position.x; | |
5042 | - // data.headY = position.y; | |
5043 | - // data.bodyY = Util.getAbsolutePosition( data.elmBody ).y; | |
5044 | - console.log( 'Finder onInit..........' ); | |
5045 | - data.apiuser.addEventListener( data.elmRoot, 'mousemove', data.mousemove, data ); | |
5046 | - data.apiuser.addEventListener( data.elmRoot, 'click', data.click, data ); | |
5047 | - data.apiuser.addEventListener( data.elmRoot, 'mousewheel', data.mousewheel, data ); | |
5048 | - }; | |
5049 | - FinderClass.prototype.onPaneResize = function( _w, _h ){ | |
5050 | - var data = FinderPrivateData.get( this ), | |
5051 | - i = data.iconList.length; | |
5052 | - //data.draw( _w, _h ); | |
5053 | - | |
5054 | - //data.elmRoot.style.height = ( _h - data.headH ) + 'px'; | |
5055 | - | |
5056 | - for( ; i; ) data.iconList[ --i ].resize( _w ); | |
5057 | - }; | |
5058 | - FinderClass.prototype.createPath = function( node ){ | |
5059 | - return FinderPrivateData.get( this ).createPath( node ); | |
5060 | - }; | |
5061 | - FinderClass.prototype.destroy = function(){ | |
5062 | - FinderPrivateData.get( this ).destroy(); | |
5063 | - FINDER_LIST.splice( Util.getIndex( FINDER_LIST, this ), 1 ); | |
4750 | + // var position = Util.getAbsolutePosition( elmPath ); | |
4751 | + // data.headX = position.x; | |
4752 | + // data.headY = position.y; | |
4753 | + // data.bodyY = Util.getAbsolutePosition( data.elmBody ).y; | |
4754 | + data.apiuser.addEventListener( data.elmRoot, 'mousemove', data.mousemove, data ); | |
4755 | + data.apiuser.addEventListener( data.elmRoot, 'click', data.click, data ); | |
4756 | + data.apiuser.addEventListener( data.elmRoot, 'mousewheel', data.mousewheel, data ); | |
4757 | + }, | |
4758 | + resize : function( w, h ){ | |
4759 | + var data = FinderPrivateData.get( this ), | |
4760 | + i = data.iconList.length; | |
4761 | + //data.draw( _w, _h ); | |
4762 | + | |
4763 | + //data.elmRoot.style.height = ( _h - data.headH ) + 'px'; | |
4764 | + | |
4765 | + for( ; i; ) data.iconList[ --i ].resize( w ); | |
4766 | + }, | |
4767 | + createPath : function( node ){ | |
4768 | + return FinderPrivateData.get( this ).createPath( node ); | |
4769 | + }, | |
4770 | + destroy : function(){ | |
4771 | + FinderPrivateData.get( this ).destroy(); | |
4772 | + } | |
5064 | 4773 | }; |
5065 | 4774 | |
5066 | 4775 | return { |