/*
* pettanR system.js
- * version 0.5.19
+ * version 0.5.20
*
* gadgetOS
* author:
};
};
- var TimerTicketClass = function( _apiuser, _callback, _time, _once ){
+ var TimerTicketClass = function( _apiuser, _callback, _time, _once, opt_thisObject ){
this.apiuser = _apiuser;
this.callback = _callback;
this.time = _time;
this.count = _time;
this.once = _once;
- _apiuser = _callback = null;
+ this.thisObj = opt_thisObject;
};
TimerTicketClass.prototype = new TicketBase();
TimerTicketClass.prototype.call = function( c ){
this.count -= c;
if( this.count <= 0 ){
- this.callback();
+ this.callback.call( this.thisObj || this.apiuser );
if( this.once === true ){
this.destroy();
TICKET_LIST.splice( Util.getIndex( TICKET_LIST, this ), 1 );
};
return {
- add: function( _apiuser, _handler, _time, _once ){
+ add: function( _apiuser, _handler, _time, _once, opt_thisObject ){
if( Type.isNumber( _time ) === false || _time < INTERVAL_TIME ) _time = INTERVAL_TIME;
- var _ticket = new TimerTicketClass( _apiuser, _handler, Math.ceil( _time / INTERVAL_TIME ), _once );
+ var _ticket = new TimerTicketClass( _apiuser, _handler, Math.ceil( _time / INTERVAL_TIME ), _once, opt_thisObject );
TICKET_LIST.push( _ticket );
update();
var APPLICATION_LIST = [];
-var AbstractBasicPane = function(){
- var instance = null;
- this.MIN_WIDTH = 240;
- this.MIN_HEIGHT = 240;
- this.init = function(){
- instance = this;
- instance.onInit();
- };
- this.onInit = function(){};
- this.resize = function( _w, _h ){
- if( instance.MIN_WIDTH > _w || instance.MIN_HEIGHT > _h ){
- if( Type.isHTMLElement( instance.rootElement ) === true ){
- // 小さすぎる!、と表示
- };
- return;
- };
- instance.onPaneResize( _w, _h );
- };
- this.onPaneResize = function( _w, _h ){};
- this.close = function(){
- instance.onClose();
- instance = this;
- };
-};
-
-var ApplicationPrivateDataClass = function(){
-
-};
-ApplicationPrivateDataClass.prototype = {
+var ApplicationPrivateData = function(){};
+ApplicationPrivateData.prototype = {
appClass : null,
application : null,
displayName : null,
bgColor : '#C1CACF',
uiList : null,
finderList : null,
- layer : null,
+ styleCursor : null,
eventRoot : null,
fetchResource : 0,
bootParams : null,
phase : 0,
- cursor : ''
-};
-
-var AbstractApplication = function( displayName, appClass, isOverlay ){
- var self = null, // init で設定
- uiList = [],
- finderList = [],
- layer = null,
- root = null,
- fetchResource = 0,
- bootParams = null,
- phase = 0,
- cursor = '';
- this.rootElement = document.createElement( 'div' );
- this.bgColor = '#C1CACF';
- this.getUID = function(){
- return Util.getIndex( API_USER_LIST, appClass );
- };
- this.init = function(){
- phase = 1;
- self = this;
- appClass === Page.appClass && Page.show();
- self.onInit();
- layer !== null && layer.start();
- phase = 2;
- };
- this.open = function( _w, _h /*, _option */ ){
- phase = 3;
- bootParams = Util.copyArray( arguments );
-
- if( this.rootElement.innerHTML && this.rootElement.innerHTML.length > 0 ){
- SystemTimer.add( self, detect, 16 );
- } else {
- onOpen();
+ cursor : '',
+ w : 0,
+ h : 0,
+ init : function( displayName, appClass, isOverlay ){
+ // this.application = app;
+ this.displayName = displayName;
+ this.appClass = appClass;
+ this.isOverlay = isOverlay;
+ // app.rootElement = ;
+ this.rootElement = document.createElement( 'div' );
+ this.styleCursor = this.rootElement.style;
+ ApplicationPrivateData.list.push( this );
+ },
+ detect : function(){
+ if( this.rootElement.firstChild && this.fetchResource === 0 ){
+ SystemTimer.remove( this.application, this.detect );
+ this.onOpen();
};
+ },
+ onOpen : function(){
+ this.rootElement.style.display = '';
- function detect(){
- if( self.rootElement.firstChild && fetchResource === 0 ){
- SystemTimer.remove( self, detect );
- onOpen();
- };
- };
+ // this.layer !== null && this.layer.onResize( this.w, this.h );
- function onOpen(){
- self.rootElement.style.display = '';
-
- layer !== null && layer.onResize( _w, _h );
-
- if( self.MIN_WIDTH > _w || self.MIN_HEIGHT > _h ){
- if( Type.isHTMLElement( self.rootElement ) === true ){
- // 小さすぎる!、と表示
- };
- };
- if( bootParams.length > 2 ){
- self.onOpen.apply( self, bootParams );
- } else {
- self.onOpen( _w, _h );
+ if( this.application.MIN_WIDTH > this.w || this.application.MIN_HEIGHT > this.h ){
+ if( Type.isHTMLElement( this.rootElement ) === true ){
+ // 小さすぎる!、と表示
};
- phase = 4;
};
+ if( this.bootParams.length > 2 ){
+ this.application.onOpen.apply( this.application, this.bootParams );
+ } else {
+ this.application.onOpen( this.w, this.h );
+ };
+ this.phase = 4;
+ },
+ fetchResourceComplete : function(){
+ --this.fetchResource;
+ }
+};
+ApplicationPrivateData.list = [];
+ApplicationPrivateData.get = function( app ){
+ var list = ApplicationPrivateData.list,
+ i = list.length;
+ for( ; i; ){
+ if( app instanceof list[ --i ].appClass ) return list[ i ];
};
- this.resize = function( _w, _h ){
- if( phase !== 4 ) return;
- if( self.MIN_WIDTH > _w || self.MIN_HEIGHT > _h ){
- if( Type.isHTMLElement( self.rootElement ) === true ){
+ return null;
+};
+
+var AbstractApplication = {
+ getUID : function(){
+ var data = ApplicationPrivateData.get( this );
+ return Util.getIndex( API_USER_LIST, data.appClass );
+ },
+ init : function(){
+ var data = ApplicationPrivateData.get( this );
+ this.rootElement = data.rootElement;
+ data.application = this;
+ data.phase = 1;
+ data.appClass === Page.appClass && Page.show();
+ this.onInit();
+ // data.layer && data.layer.start();
+ data.phase = 2;
+ },
+ open : function( w, h /*, _option */ ){
+ var data = ApplicationPrivateData.get( this );
+ data.phase = 3;
+ data.bootParams = Util.copyArray( arguments );
+ data.w = w;
+ data.h = h;
+ if( data.rootElement.innerHTML && data.rootElement.innerHTML.length > 0 ){
+ SystemTimer.add( this, data.detect, 16, false, data );
+ } else {
+ data.onOpen();
+ };
+ },
+ resize : function( w, h ){
+ var data = ApplicationPrivateData.get( this );
+ if( data.phase !== 4 ) return;
+ if( this.MIN_WIDTH > w || this.MIN_HEIGHT > h ){
+ if( Type.isHTMLElement( this.rootElement ) === true ){
// 小さすぎる!、と表示
};
return;
};
- self.onPaneResize( _w, _h );
- layer !== null && layer.onResize( _w, _h );
- };
- this.close = function(){
- phase = 5;
- if( self.onClose() === false ){
+ this.onPaneResize( w, h );
+ // data.layer !== null && data.layer.onResize( w, h );
+ },
+ close : function(){
+ var data = ApplicationPrivateData.get( this );
+ data.phase = 5;
+ if( this.onClose() === false ){
return false;
};
- while( uiList.length > 0 ){
- uiList.shift().destroy();
+ if( data.uiList ){
+ while( data.uiList.length > 0 ) data.uiList.shift().destroy();
};
- while( finderList.length > 0 ){
- finderList.shift().destroy();
+ if( data.finderList ){
+ while( data.finderList.length > 0 ) data.finderList.shift().destroy();
};
- root && PointingDeviceEventTree.destroyTree( root );
- MouseEvent.remove( self );
- KeyEvent.remove( self );
- SystemTimer.remove( self );
- AsyncCall.remove( self );
- StyleSheet.unload( self );
-
- layer !== null && layer.destroy();
- layer = null;
+ data.eventRoot && PointingDeviceEventTree.destroyTree( data.eventRoot );
+ MouseEvent.remove( this );
+ KeyEvent.remove( this );
+ SystemTimer.remove( this );
+ AsyncCall.remove( this );
+ StyleSheet.unload( this );
+ // data.layer && data.layer.destroy();
- var elm = self.rootElement;
+ var elm = this.rootElement;
Util.removeAllChildren( elm );
elm.parentNode.removeChild( elm );
- self.rootElement = null;
-
- Application.shutdown( self, isOverlay );
- appClass === Page.appClass && Page.hide();
+ Application.shutdown( this, data.isOverlay );
- self = appClass = uiList = null;
-
- phase = 6;
- };
- this.createUIGroup = function(){
- var _ui = UI.createUIGroup( self );
- uiList.push( _ui );
- return _ui;
- };
- this.createFinder = function( _elmTarget, _tree, _onSelect, _viewerOption, _editorOption ){
- var _finder = Finder.create( self, _elmTarget, _tree, _onSelect, _viewerOption, _editorOption );
- finderList.push( _finder );
- return _finder;
- };
- this.createBasicPane = function( _class, _options ){
- if( Type.isFunction( _class ) === false ) return null;
- _class.prototype = new AbstractBasicPane();
- return new _class( _options );
- };
- this.createDHTML = function( _elm ){
- return DHTML.create( self, _elm );
- };
- this.addEventListener = function( _element, _eventType, _handler, _opt_thisObject ){
- if( layer !== null && layer.contain( _element ) === true ){
- layer.addEvent( _element, _eventType, _handler, _opt_thisObject );
- } else {
- MouseEvent.add( self, _element, _eventType, _handler, _opt_thisObject );
- };
- };
- this.removeEventListener = function( _element, _eventType, _handler ){
- if( layer !== null && layer.contain( _element ) === true ){
- layer.removeEvent( _element, _eventType, _handler );
- } else {
- MouseEvent.remove( self, _element, _eventType, _handler );
- };
- };
- this.useInteractiveLayer = function( /* handleEvents */ ){
- if( phase === 1 && layer === null ){
- layer = InteractiveLayer.create( self, Util.copyArray( arguments ) );
- root = PointingDeviceEventTree.create( self, layer );
- };
- };
- this.getPointingDeviceEventTreeRoot = function(){
- return root;
- };
- this.createInteractContainer = function( elm ){
- if( layer !== null ) return layer.createContainer( elm );
- };
- this.registerInteractiveListener = function( /* */ ){
- layer !== null && layer.register( Util.copyArray( arguments ) );
- };
- this.isCurrentInteractiveEventListener = function( listener ){
- layer !== null && layer.isCurrentListener( listener );
- };
- this.updateCoursor = function( _cursor ){
- if( cursor !== _cursor ){
- if( layer ){
- layer.elm.style.cursor = cursor = _cursor;
- } else {
- self.rootElement.style.cursor = cursor = _cursor;
- };
- };
- };
- this.fetchCSS = function( _url, opt_onload, opt_onerror ){
- if( phase === 1 ){
- ++fetchResource;
- StyleSheet.load( self, _url, fetchResourceComplete, fetchResourceComplete );
- };
- };
-
- function fetchResourceComplete(){
- --fetchResource;
- };
-};
-
-AbstractApplication.prototype = new AbstractBasicPane();
-AbstractApplication.prototype.onInit = function(){
- // overrride
-};
-AbstractApplication.prototype.onOpen = function( _w, _h /*, _option */ ){
- // overrride
-};
-AbstractApplication.prototype.onClose = function(){
- // overrride
- return true;
-}; // false の場合、close の拒否
-AbstractApplication.prototype.addKeyEventListener = function( _eventType, _handler, _keyCode, _shift, _ctrl ){
- KeyEvent.add( this, _eventType, _handler, _keyCode, _shift, _ctrl );
-};
-AbstractApplication.prototype.removeKeyEventListener = function( _eventType, _handler, _keyCode, _shift, _ctrl ){
- KeyEvent.remove( this, _eventType, _handler, _keyCode, _shift, _ctrl );
-};
-AbstractApplication.prototype.shiftEnabled = function(){
- return KeyEvent.shiftEnabled;
-};
-AbstractApplication.prototype.ctrlEnabled = function(){
- return KeyEvent.ctrlEnabled;
-};
-AbstractApplication.prototype.addTimer = function( handler, time, once ){
- SystemTimer.add( this, handler, time, !!once );
-};
-AbstractApplication.prototype.removeTimer = function( handler ){
- SystemTimer.remove( this, handler );
-};
-AbstractApplication.prototype.addAsyncCall = function( _callback, _argments, _thisObject ){
- AsyncCall.add( this, _callback, _argments, _thisObject );
-};
-AbstractApplication.prototype.removeAsyncCall = function( _callback ){
- AsyncCall.remove( this, _callback );
-};
-AbstractApplication.prototype.fetchHTMLElement = function( id ){
- var elm = document.getElementById( id );
- if( elm ){
- elm.removeAttribute( 'id' );
- elm.parentNode.removeChild( elm );
- return elm;
- };
-};
-
+ data.appClass === Page.appClass && Page.hide();
-var InteractiveLayer = ( function(){
- var LAYER_LIST = [],
- currentLayer = null,
- currentList = null,
- currentListener = null;
-
- function eventRellay( e ){
- var _mouseX = e.clientX,
- _mouseY = e.clientY,
- _type = e.type === 'mouseout' ? 'mouseup' : e.type,
- _listener = currentListener,
- i, l;
- if( _listener !== null && _listener.busy() === true && _listener[ _type ] && _listener[ _type ]( _mouseX, _mouseY, e, _type ) === true ){
- // currentListener[ _type ]( _mouseX, _mouseY, e, _type );
- // console.log( '** current true : ' + _type + ' ' + Util.getIndex( currentList, _listener ) + ( _listener.id || _listener.elm.id ) );
- } else {
- currentListener = null;
- for( i = 0, l = currentList.length; i<l; ++i ){
- _listener = currentList[ i ];
- if( _listener[ _type ] && _listener[ _type ]( _mouseX, _mouseY, e, _type ) === true ){
- currentListener = _listener;
- // console.log( 'true : currentList.length = ' + l + ' ' + i )
- break;
- };
- };
-
- };
- // 文字選択の禁止
- //!document.selection && window.getSelection().removeAllRanges();
- return false;
- };
-
- var LayerClass = function( apiuser ){
- this.apiuser = apiuser;
- };
- LayerClass.prototype = {
- init: function( events ){
- this.elm = document.createElement( 'div' );
- body.appendChild( this.elm );
- // this.elm.style.cssText = 'position:absolute;top:0;left:0;height:100%;';
- this.elm.className = 'mouse-operation-catcher';
- this.elm.unselectable = 'on';
-
- this.listeners = [];
-
- if( Type.isString( events ) === true ){
- events = events.split( ',' );
- } else
- if( Type.isArray( events ) === false ){
- return;
- };
- for( var i = events.length; i; ){
- MouseEvent.add( this.apiuser, this.elm, events[ --i ], eventRellay );
- };
- },
- register: function( listener ){
- if( Type.isArray( listener ) === false ){
- this.listeners.push( listener );
- } else {
- this.listeners.push.apply( this.listeners, listener );
- };
- },
- isCurrentListener : function( listener ){
- return currentListener === listener;
- },
- onResize : function( _w, _h ){
- this.elm.style.height = _h + 'px';
- },
- contain : function( elm ){
- return !!this.getContainer( elm );
- },
- getContainer : function( elm ){
- var linstener;
- for( var i = this.listeners.length; i; ){
- linstener = this.listeners[ --i ];
- if( linstener instanceof InteractiveContainer ){
- if( linstener.contain( elm ) === true ) return linstener;
- };
- };
- return null;
- },
- createContainer : function( elm ){
- if( this.contain( elm ) === true ) return null;
- var ret = new InteractiveContainer( this.apiuser, elm );
- this.listeners.unshift( ret );
- return ret;
- },
- addEvent : function( element, eventType, handler, _opt_thisObject ){
- //console.log( eventType )
- currentListener = null;
-
- var container = this.getContainer( element );
- container !== null && container.addEvent( element, eventType, handler, _opt_thisObject );
-
- MouseEvent.add( this.apiuser, this.elm, eventType, eventRellay );
- },
- removeEvent : function( element, eventType, handler ){
- currentListener = null;
-
- var container = this.getContainer( element );
- container !== null && container.removeEvent( element, eventType, handler );
- },
- start : function(){
- currentLayer = this;
- currentList = currentLayer.listeners;
- currentLayer.elm.style.display = '';
- },
- destroy: function(){
- MouseEvent.remove( this.apiuser, this.elm );
- body.removeChild( this.elm );
-
- this.listeners.splice( 0, this.listeners.length );
-
- LAYER_LIST.splice( Util.getIndex( LAYER_LIST, this ), 1 );
- }
- };
-
- return {
- create : function( apiuser, events ){
- var ret = new LayerClass( apiuser );
- ret.init( events );
- LAYER_LIST.push( ret );
- return ret;
- },
- onCurrentApplicationChange : function( _application ){
- for( var i = 0, l = LAYER_LIST.length; i < l; ++i ){
- if( LAYER_LIST[ i ].apiuser === _application ){
- currentLayer = LAYER_LIST[ i ];
- currentList = currentLayer.listeners;
- currentLayer.elm.style.display = '';
- return;
- };
- };
- if( currentLayer ) currentLayer.elm.style.display = 'none';
- currentLayer = null;
- currentList = null;
- currentListener = null;
- },
- onSystemShutdown : function(){
-
- }
- };
-})();
-
-var InteractiveContainer = function( apiuser, elm ){
- this.apiuser = apiuser;
- this.elm = elm;
- this.events = {};
- this.mesure();
-};
-InteractiveContainer.prototype = {
- current : null,
- addEvent : function( element, eventType, handler, opt_thisObject ){
- var list = this.events[ eventType ], i;
- if( !list ){
- list = this.events[ eventType ] = [];
- this[ eventType ] = this._eventRellay;
- };
- for( i = list.length; i; ){
- if( list[ --i ].match( element, eventType, handler ) === true ){
- return;
- };
- };
- var ticket = new InterractiveEventTicket( element, eventType, handler, this.elm, opt_thisObject );
- ticket.init( Position.cumulativeOffset( this.elm ) );
- list.push( ticket );
- // AsyncCall.add( this.apiuser, ticket.init, Position.cumulativeOffset( this.elm ), ticket );
+ data.phase = 6;
+
+ var list = ApplicationPrivateData.list;
+ list.splice( Util.getIndex( list, data ), 1 );
},
- removeEvent : function( element, eventType, handler ){
- var list, i;
- for( var type in this.events ){
- list = this.events[ type ];
- if( eventType && eventType !== type ) continue;
- if( Type.isArray( list ) === false ) continue;
- for( i = list.length; i; ){
- if( list[ --i ].match( element, eventType, handler ) === true ){
- list.splice( i, 1 );
- if( list.length === 0 ){
- delete this[ type ];
- delete this.events[ type ];
- };
- };
- };
- };
+ createUIGroup : function(){
+ var data = ApplicationPrivateData.get( this ),
+ ui = UI.createUIGroup( this );
+ if( data.uiList === null ) data.uiList = [];
+ data.uiList.push( ui );
+ return ui;
},
- mesured : false,
- mesure : function(){
- var positon = Position.cumulativeOffset( this.elm );
- this.x = positon[ 0 ];
- this.y = positon[ 1 ];
- this.mesured = true;
+ createFinder : function( _elmTarget, _tree, _onSelect, _viewerOption, _editorOption ){
+ var data = ApplicationPrivateData.get( this ),
+ finder = Finder.create( this, _elmTarget, _tree, _onSelect, _viewerOption, _editorOption );
+ if( data.finderList === null ) data.finderList = [];
+ data.finderList.push( finder );
+ return finder;
},
- asyncMesure : function(){
- this.mesured === false && this.mesure();
+ createDHTML : function( _elm ){
+ return DHTML.create( this, _elm );
},
- setPositon : function( x, y ){
- this.x = x;
- this.y = y;
- this.elm.style.left = x + 'px';
- this.elm.style.top = y + 'px';
+ addEventListener : function( element, eventType, handler, opt_thisObject ){
+ MouseEvent.add( this, element, eventType, handler, opt_thisObject );
},
- contain : function( child ){
- return this.elm === child || Util.contain( this.elm, child );
+ removeEventListener : function( element, eventType, handler ){
+ MouseEvent.remove( this, element, eventType, handler );
},
- busy : function(){
- return this.current !== null;
+ getPointingDeviceEventTreeRoot : function(){
+ var data = ApplicationPrivateData.get( this );
+ if( data.phase === 1 ){
+ data.eventRoot = PointingDeviceEventTree.create( this );
+ data.styleCursor = PointingDeviceEventTree._getNodePrivateData( data.eventRoot ).elmMouseCatch.style;
+ };
+ return data.eventRoot;
},
- _eventRellay : function( mouseX, mouseY, e, eventType ){
- var list = this.events[ eventType ];
- if( Type.isArray( list ) === false ) return false;
- // console.log( eventType + ' mX:' + mouseX + ' mY:' + mouseY + ' x:' + this.x + ' y:' + this.y + ' ' + this.elm.id );
- var x = mouseX - this.x,
- y = mouseY - this.y,
- c = this.current,
- t, i;
- if( c !== null && c.type === eventType ){
- if( c.x <= x && x <= c.x + c.target.offsetWidth && c.y <= y && y <= c.y + c.target.offsetHeight ){
- c.handler.call( c.thisObj || c.target, e, x, y );
- return true;
- };
+ updateCoursor : function( _cursor ){
+ var data = ApplicationPrivateData.get( this );
+ if( data.cursor !== _cursor ){
+ data.styleCursor.cursor = data.cursor = _cursor;
};
- for( i = list.length; i; ){
- t = list[ --i ];
- if( t.x <= x && x <= t.x + t.target.offsetWidth && t.y <= y && y <= t.y + t.target.offsetHeight ){
- t.handler.call( t.thisObj || t.target, e, x, y );
- this.current = t;
- return true;
- };
+ },
+ fetchCSS : function( url, opt_onload, opt_onerror ){
+ var data = ApplicationPrivateData.get( this );
+ if( data.phase === 1 ){
+ ++data.fetchResource;
+ StyleSheet.load( this, url, data.fetchResourceComplete, data.fetchResourceComplete, data );
};
- // console.log( 'false ' + this.elm.id );
- this.current = null;
- return false;
- }
-};
-
-var InterractiveEventTicket = function( elm, type, handler, parent, opt_thisObject ){
- this.target = elm;
- this.type = type;
- this.handler = handler;
- this.parent = parent;
- this.thisObj = opt_thisObject;
-};
-InterractiveEventTicket.prototype = {
- x : -99999,
- y : -99999,
- w : 0,
- h : 0,
- init : function( _positon ){
- var positon = Position.cumulativeOffset( this.target );
- this.x = positon[ 0 ] - _positon[ 0 ];
- this.y = positon[ 1 ] - _positon[ 1 ];
- this.w = this.target.offsetWidth;
- this.h = this.target.offsetHeight;
- // console.log( '- x: ' + this.x + ' y: ' + this.y + ' w: ' + this.w + ' h: ' + this.h + ' ' + ( this.target.id || '-' ) + ' ,' + this.type );
},
- match : function( element, eventType, handler ){
- if( handler && this.handler !== handler ) return false;
- if( eventType && this.type !== eventType ) return false;
- if( element && this.target !== element ) return false;
- return true;
+ onInit : function(){},
+ onOpen : function(){},
+ onClose : function(){ return true; },
+ onPaneResize : function( w, h ){},
+ addKeyEventListener : function( _eventType, _handler, _keyCode, _shift, _ctrl ){
+ KeyEvent.add( this, _eventType, _handler, _keyCode, _shift, _ctrl );
+ },
+ removeKeyEventListener : function( _eventType, _handler, _keyCode, _shift, _ctrl ){
+ KeyEvent.remove( this, _eventType, _handler, _keyCode, _shift, _ctrl );
+ },
+ shiftEnabled : function(){
+ return KeyEvent.shiftEnabled;
+ },
+ ctrlEnabled : function(){
+ return KeyEvent.ctrlEnabled;
+ },
+ addTimer : function( handler, time, once ){
+ SystemTimer.add( this, handler, time, !!once );
+ },
+ removeTimer : function( handler ){
+ SystemTimer.remove( this, handler );
+ },
+ addAsyncCall : function( _callback, _argments, _thisObject ){
+ AsyncCall.add( this, _callback, _argments, _thisObject );
+ },
+ removeAsyncCall : function( _callback ){
+ AsyncCall.remove( this, _callback );
+ },
+ fetchHTMLElement : function( id ){
+ var elm = document.getElementById( id );
+ if( elm ){
+ elm.removeAttribute( 'id' );
+ elm.parentNode.removeChild( elm );
+ return elm;
+ };
}
};
})();
return {
- create : function( apiuser, layer ){
+ create : function( apiuser ){
var root = new NodeClass( apiuser, null, null, apiuser.rootElement ),
- data = NodePrivateData.get( root );
- data.elmMouseCatch = layer.elm;
+ data = NodePrivateData.get( root ),
+ elm = document.createElement( 'div' );
+ body.appendChild( elm );
+ // elm.style.cssText = 'position:absolute;top:0;left:0;height:100%;';
+ elm.className = 'mouse-operation-catcher';
+ elm.unselectable = 'on';
+ data.elmMouseCatch = elm;
+
data.eventCounter = {};
ROOT_LIST.push( data );
currentRootData = data;
targetNodeData = null;
forceNodeData = null;
+
+ MouseEvent.add( apiuser, elm, 'mousemove', eventRellay );
return root;
},
onCurrentApplicationChange : function( _application ){
};
},
destroyTree : function( root ){
+ var data = NodePrivateData.get( root );
+ MouseEvent.remove( data.apiuser, data.elmMouseCatch, 'mousemove', eventRellay );
+ body.removeChild( data.elmMouseCatch );
NodePrivateData.get( root )._destroy();
ROOT_LIST.splice( Util.getIndex( ROOT_LIST, root ), 1 );
},
_tail === true && Home.add( _ref );
return _ref;
},
- isBasicPaneInstance: function( _basicPane ){
- return _basicPane instanceof AbstractBasicPane;
- },
- isApplicationInstance: function( _application ){
- return _application instanceof AbstractApplication;
+ isApplicationInstance: function( app ){
+ return ApplicationPrivateData.get( app ) !== null;
},
isApplicationReference: function( _reference ){
return _reference instanceof ApplicationReference;
},
- isCurrentAppplication: function( _application ){
- return true
+ isCurrentAppplication: function( app ){
+ return app === currentApplication;
},
boot: function( displayName, uid, appClass, isOverlay, arg ){
if( currentApplication ){
if( isOverlay === false && currentApplication.close() === false ) return null;
};
- appClass.prototype = new AbstractApplication( displayName, appClass, isOverlay );
+ appClass.prototype = AbstractApplication;
+ var data = new ApplicationPrivateData();
+ data.init( displayName, appClass, isOverlay );
var application = new appClass(); // new は boot で
coveredApplication = isOverlay === true ? currentApplication : null;
if( isOverlay === false ){
body.style.backgroundColor = application.bgColor;
- body.appendChild( application.rootElement );
- application.rootElement.style.display = 'none';
+ body.appendChild( data.rootElement );
+ data.rootElement.style.display = 'none';
application.init();
application.addAsyncCall( asyncOpen, arg );
};
};
},
- remove: function( _apiuser, _element, _eventType, _handler ){
- if( isApiUser( _apiuser ) === true ){
- var _uid = _apiuser.getUID(),
- _events = EVENT_LIST_MAP[ _uid ],
- _removed,
- i = 0;
- if( Type.isArray( _events ) === false ) return;
- for( ;i < _events.length; ){
- if( _events[ i ].destroy( _element, _eventType, _handler ) === true ){
- _events.splice( i, 1 );
+ remove: function( apiuser, element, eventType, handler ){
+ if( isApiUser( apiuser ) === true ){
+ var uid = apiuser.getUID(),
+ list = EVENT_LIST_MAP[ uid ],
+ i = 0;
+ if( Type.isArray( list ) === false ) return;
+ for( ;i < list.length; ){
+ if( list[ i ].destroy( element, eventType, handler ) === true ){
+ list.splice( i, 1 );
} else {
++i;
};
};
- if( _events.length === 0 ){
- _events = EVENT_LIST_MAP[ _uid ] = null;
+ if( list.length === 0 ){
+ EVENT_LIST_MAP[ uid ] = null;
};
};
},
var cssRules, sheet;
- var FetchCssTicketClass = function( _apiuser, _url, _elm, _onload, _onerror ){
+ var FetchCssTicketClass = function( _apiuser, _url, _elm, _onload, _onerror, opt_thisObject ){
this.apiusers = [ _apiuser ];
this.url = _url;
this.elm = _elm;
this.onload = [ _onload ];
this.onerror = [ _onerror ];
+ this.thisObj = [ opt_thisObject ];
this.time = 0;
};
FetchCssTicketClass.prototype = {
this.apiusers.splice( i, 1 );
this.onload.splice( i, 1 );
this.onerror.splice( i, 1 );
+ this.thisObj.splice( i, 1 );
if( this.apiusers.length !== 0 ) return false;
delete this.elm;
delete this.onload;
delete this.onerror;
+ delete this.thisObj;
delete this.time;
return true;
loaded: function(){
for( var i = this.onload.length, f; i; ){
f = this.onload[ --i ];
- Type.isFunction( f ) === true && AsyncCall.add( this.apiusers[ i ], f, this.url );
+ Type.isFunction( f ) === true && AsyncCall.add( this.apiusers[ i ], f, this.url, this.thisObj[ i ] || this.apiusers[ i ] );
this.onload[ i ] = this.onerror[ i ] = null;
};
},
error: function(){
for( var i = this.onerror.length, f; i; ){
f = this.onerror[ --i ];
- Type.isFunction( f ) === true && AsyncCall.add( this.apiusers[ i ], f, this.url );
+ Type.isFunction( f ) === true && AsyncCall.add( this.apiusers[ i ], f, this.url, this.thisObj[ i ] || this.apiusers[ i ] );
this.onload[ i ] = this.onerror[ i ] = null;
};
},
};
return {
- load: function( _apiuser, _url, opt_onload, opt_onerror ){
+ load: function( _apiuser, _url, opt_onload, opt_onerror, opt_thisObject ){
_url = Util.getAbsolutePath( _url );
var t;
for( var i=TICKET_LIST.length; i; ){
t.apiusers.push( _apiuser );
t.onload.push( opt_onload );
t.onerror.push( opt_onerror );
+ t.thisObj.push( opt_thisObject );
};
SystemTimer.add( SUPER_USER_KEY, checkTimer, 333 );
return;
};
};
- TICKET_LIST.push( new FetchCssTicketClass( _apiuser, _url, elm, opt_onload, opt_onerror ) );
+ TICKET_LIST.push( new FetchCssTicketClass( _apiuser, _url, elm, opt_onload, opt_onerror, opt_thisObject ) );
SystemTimer.add( SUPER_USER_KEY, checkTimer, 333 );
},
Overlay.hide();
return false;
};
- function asyncInit( /* arguments */ ){
-
- //body.appendChild( application.rootElement );
+ function asyncInit( /* arguments */ ){
+ application.init();
elmContainer.insertBefore( application.rootElement, elmCloseButton );
application.rootElement.style.display = 'none';
- application.init();
};
function asyncOpen( /* arguments */ ){
-
var _arg = Util.copyArray( arguments );
_arg.unshift( windowW, windowH );
application.open.apply( application, _arg );
elmContainer.style.display = 'none'; // hide for fadeIn
- _application.addAsyncCall( asyncInit );
- _application.addAsyncCall( asyncOpen, _bootParams );
-
visible = true;
application = _application;
+
+ //asyncInit();
+
+ _application.addAsyncCall( asyncInit );
+ _application.addAsyncCall( asyncOpen, _bootParams );
},
hide: function(){
if( visible === false ) return;
},
destroy : function(){
this.tree.removeTreeEventListener( Const.TREE.EVENT.UPDATE, this.draw );
-
- this.nodeRoot.remove();
- this.nodePath && this.nodePath.remove();
-
+
if( this.pathList ){
while( this.pathList.length > 0 ) this.pathList.shift().destroy();
};
while( this.iconList.length > 0 ) this.iconList.shift().destroy();
- this.elmRoot.removeChild( this.elmRoot );
+ this.nodeRoot.remove();
+ // this.nodePath && this.nodePath.remove();
+
+ // this.elmRoot.removeChild( this.elmRoot );
+
+ FINDER_LIST.splice( Util.getIndex( FINDER_LIST, this.finder ), 1 );
+ var data = ApplicationPrivateData.get( this.apiuser ),
+ list = data.finderList,
+ i = Util.getIndex( list, this.finder );
+ i !== -1 && list.splice( i, 1 );
}
};
FinderPrivateData.LIST = [];
var FinderClass = function( application, elmRoot, tree, onSelect, viewerOption, editorOption ){
( new FinderPrivateData() ).init( this, application, elmRoot, tree, onSelect, viewerOption, editorOption );
};
- FinderClass.prototype = new AbstractBasicPane();
- FinderClass.prototype.MIN_WIDTH = 240;
- FinderClass.prototype.MIN_HEIGHT = 240;
- FinderClass.prototype.onInit = function(){
+ FinderClass.prototype = {
+ MIN_WIDTH : 200,
+ MIN_HEIGHT : 200,
+ init : function(){
var data = FinderPrivateData.get( this );
- // var position = Util.getAbsolutePosition( elmPath );
- // data.headX = position.x;
- // data.headY = position.y;
- // data.bodyY = Util.getAbsolutePosition( data.elmBody ).y;
- console.log( 'Finder onInit..........' );
- data.apiuser.addEventListener( data.elmRoot, 'mousemove', data.mousemove, data );
- data.apiuser.addEventListener( data.elmRoot, 'click', data.click, data );
- data.apiuser.addEventListener( data.elmRoot, 'mousewheel', data.mousewheel, data );
- };
- FinderClass.prototype.onPaneResize = function( _w, _h ){
- var data = FinderPrivateData.get( this ),
- i = data.iconList.length;
- //data.draw( _w, _h );
-
- //data.elmRoot.style.height = ( _h - data.headH ) + 'px';
-
- for( ; i; ) data.iconList[ --i ].resize( _w );
- };
- FinderClass.prototype.createPath = function( node ){
- return FinderPrivateData.get( this ).createPath( node );
- };
- FinderClass.prototype.destroy = function(){
- FinderPrivateData.get( this ).destroy();
- FINDER_LIST.splice( Util.getIndex( FINDER_LIST, this ), 1 );
+ // var position = Util.getAbsolutePosition( elmPath );
+ // data.headX = position.x;
+ // data.headY = position.y;
+ // data.bodyY = Util.getAbsolutePosition( data.elmBody ).y;
+ data.apiuser.addEventListener( data.elmRoot, 'mousemove', data.mousemove, data );
+ data.apiuser.addEventListener( data.elmRoot, 'click', data.click, data );
+ data.apiuser.addEventListener( data.elmRoot, 'mousewheel', data.mousewheel, data );
+ },
+ resize : function( w, h ){
+ var data = FinderPrivateData.get( this ),
+ i = data.iconList.length;
+ //data.draw( _w, _h );
+
+ //data.elmRoot.style.height = ( _h - data.headH ) + 'px';
+
+ for( ; i; ) data.iconList[ --i ].resize( w );
+ },
+ createPath : function( node ){
+ return FinderPrivateData.get( this ).createPath( node );
+ },
+ destroy : function(){
+ FinderPrivateData.get( this ).destroy();
+ }
};
return {