/*
* pettanR system.js
- * version 0.5.40
+ * version 0.5.41
*
* gadgetOS
* author:
*
*/
var Class = ( function(){
- var CLASS_LIST = [],
- DEF_LIST = [],
- CONSTRUCTOR = 'Constructor';
+ var CLASS_LIST = [],
+ DEF_LIST = [],
+ PRIVATE_CLASS_LIST = [],
+ PRIVATE_DEF_LIST = [],
+ CONSTRUCTOR = 'Constructor',
+ GET_INDEX = Util.getIndex,
+ abstractFlag = true,
+ privateFlag = true,
+ f = true,
+ c = Util.copyArray,
+ a; /* arguments */
function getClass( instance ){
- var clist = CLASS_LIST,
- dlist = DEF_LIST,
- i = clist.length,
- getIndex = Util.getIndex,
- klass, def, live, pool;
+ var cList = CLASS_LIST,
+ i = cList.length,
+ klass;
for( ; i; ){
- klass = clist[ --i ];
- //def = dlist[ i ];
- //if( def.live && getIndex( def.live, instance ) !== -1 ) return klass;
- if( def.pool && getIndex( def.pool, instance ) !== -1 ) return klass;
+ klass = cList[ --i ];
if( instance instanceof klass ) return klass;
};
- // throw new Error( 'Class not found!' );
+ cList = PRIVATE_CLASS_LIST;
+ i = cList.length;
+ for( ; i; ){
+ klass = cList[ --i ];
+ if( instance instanceof klass ) return klass;
+ };
+
+ if( GET_INDEX( cList, instance ) !== -1 ) return instance;
+ if( GET_INDEX( CLASS_LIST, instance ) !== -1 ) return instance;
};
function getClassDef( KlassOrInstance ){
- var i = Util.getIndex( CLASS_LIST, KlassOrInstance );
- if( i === -1 ) i = Util.getIndex( CLASS_LIST, getClass( KlassOrInstance ) );
+ var getIndex = GET_INDEX,
+ i = getIndex( CLASS_LIST, KlassOrInstance );
+ if( i === -1 ) i = getIndex( CLASS_LIST, getClass( KlassOrInstance ) );
if( i !== -1 ) return DEF_LIST[ i ];
+
+ i = getIndex( PRIVATE_CLASS_LIST, KlassOrInstance );
+ if( i === -1 ) i = getIndex( PRIVATE_CLASS_LIST, getClass( KlassOrInstance ) );
+ if( i !== -1 ) return PRIVATE_DEF_LIST[ i ];
+
+ if( GET_INDEX( DEF_LIST, KlassOrInstance ) !== -1 ) return KlassOrInstance;
+ if( GET_INDEX( PRIVATE_DEF_LIST, KlassOrInstance ) !== -1 ) return KlassOrInstance;
};
/* over のプロパティを target にコピーする.ただし target の プロパティが優先, force で解除 */
* var subClass = superClass.inherits( ... )
* http://d.hatena.ne.jp/m-hiyama/20051018/1129605002
*/
- function inherits( /* classSetting, opt_PrivateClass, props */ ){
+ function inherits( /* displayName, classSetting, opt_PrivateClass, props */ ){
var args = c( arguments ),
+ params = [],
Super = this,
superDef = getClassDef( Super ),
- classSetting = args[ 0 ],
+ displayName = args[ 0 ],
+ classSetting,
opt_super,
- opt_privateClass,
- Traits, klass;
+ klass;
if( superDef.Final === true ) throw new Error( 'Class is final!' );
- if( Type.isNumber( classSetting ) === true ){
- opt_super = classSetting & Class.SUPER_ACCESS === 1;
+
+ if( Type.isString( displayName ) === true ){
args.shift();
+ } else {
+ displayName = 'SubClass of ' + superDef.displayName;
+ };
+ params.push( displayName );
+
+ classSetting = args[ 0 ];
+ if( Type.isNumber( classSetting ) === true ){
+ opt_super = !!( classSetting & Class.SUPER_ACCESS );
+ params.push( args.shift() );
};
- opt_privateClass = getClass( args[ 0 ] );
- opt_privateClass && args.shift();
+ if( getClassDef( args[ 0 ] ) ){
+ params.push( args.shift() );
+ } else {
+ superDef.privateClass && params.push( superDef.privateClass );
+ };
+ params.push( override( new Super(), args[ 0 ], true ) ); /* props */
+
abstractFlag = false;
- Traits = new Super;
+ klass = Class.create.apply( null, params );
abstractFlag = true;
- klass = Class.create( classSetting, opt_privateClass || superDef.privateClass, override( Traits, args[ 0 ], true ) );
if( opt_super === true ) getClassDef( klass ).Super = Super.prototype;
return klass;
};
var ClassBase = {
kill : function(){
var instance = this,
- p,
klass = getClass( instance ),
def = getClassDef( klass ),
- privateData, i;
+ privateData, p, i;
Type.isFunction( instance.onKill ) === true && instance.onKill();
-
for( p in instance ){
if( instance.hasOwnProperty && !instance.hasOwnProperty( p ) ) continue;
delete instance[ p ];
};
if( def.pool ){
- def.live.splice( Util.getIndex( def.live, instance ), 1 );
+ def.live && def.live.splice( GET_INDEX( def.live, instance ), 1 );
def.pool.push( instance );
};
if( def.privateClass ){
privateData = klass.getPrivateData( instance );
if( privateData ){
privateData.kill();
- i = Util.getIndex( def.dataList, privateData );
+ i = GET_INDEX( def.dataList, privateData );
def.dataList.splice( i, 1 );
- def.userList.splice( i, 1 );
+ def.userList.splice( i, 1 );
};
};
// myCallback の削除
// myCallback を受け取った API への通知
},
- myCallback : function( callback ){
+ getMyCallback : function( callback ){
var def = getClassDef( this ),
iList = def.callbackInstanceList,
rList = def.callbackRegisterList,
- i, clist, myCallback;
+ i, cList, myCallback;
if( !iList ){
iList = def.callbackInstanceList = [];
rList = def.callbackRegisterList = [];
};
- i = Util.getIndex( iList, this );
- clist = rList[ i ];
+ i = GET_INDEX( iList, this );
if( index === -1 ){
index = iList.length;
cList = [];
iList.push( this );
rList.push( cList );
} else {
+ cList = rList[ i ];
for( i = cList.length; i; ){
if( cList[ --i ].callback === callback ) return cList[ i ];
};
myCallback = new Callback( this, callback );
cList.push( myCallback );
return myCallback;
+ },
+ releaseMyCallback : function( callback ){
+ var def = getClassDef( this ),
+ iList = def.callbackInstanceList,
+ rList = def.callbackRegisterList,
+ i, cList, myCallback;
+ if( !iList ) return;
+ i = GET_INDEX( iList, this );
+ if( index === -1 ) return;
+ cList = rList[ i ];
+ i = GET_INDEX( cList, callback );
+ if( i !== -1 ) return;
+ myCallback = cList[ i ];
+ cList.splice( i, 1 );
+ myCallback.kill();
}
};
+
/* privateDataclass をもつクラスに追加されるメソッド */
- function newPrivateData( instance /*, args */ ){
- var def = getClassDef( instance ),
+ function newPrivateData( /* instance, args */ ){
+ var args = c( arguments ),
+ user = args.shift(),
+ def = getClassDef( user ),
privateClass = def.privateClass,
- i = Util.getIndex( def.userList, instance ),
- args = c( arguments ),
+ privateDef = getClassDef( privateClass ),
+ i = -1,
data;
+ if( def.userList ){
+ i = GET_INDEX( def.userList, user );
+ } else {
+ def.userList = [];
+ def.dataList = [];
+ };
if( i !== -1 ){
throw new Error( 'PrivateData already exist!' );
};
privateFlag = false;
- args.unshift();
- data = I.apply( privateClass, args );
+ data = new privateClass();
privateFlag = false;
def.dataList.push( data );
- def.userList.push( instance );
+ def.userList.push( user );
+ privateDef[ CONSTRUCTOR ] && privateDef[ CONSTRUCTOR ].apply( data, args );
return data;
};
function getPrivateData( instance ){
var def = getClassDef( instance ),
- i = Util.getIndex( def.userList, instance );
+ i = GET_INDEX( def.userList, instance );
if( i !== -1 ) return def.dataList[ i ];
};
* new の実体.コンストラクタの機能は instance.Constructor に書く.
* これにより pool された オブジェクト(破棄されたインスタンス) を再利用できる
*/
- var abstractFlag = true,
- privateFlag = true,
- f = true,
- c = Util.copyArray,
- a;
- function I(){
+ /* Constructor Real for GeneralClass */
+ function G(){
var klass = this,
def = getClassDef( klass ),
- instance;
- if( def.Abstract === true || abstractFlag === false ){
- if( abstractFlag === true ){
- throw new Error( 'AbstractClass!' );
- };
+ instance;
+ if( def.pool && def.pool.length > 0 ){
+ instance = def.pool.shift();
+ } else {
f = false;
instance = new klass();
f = true;
- return instance;
};
- if( def.isPrivate === true && privateFlag === true ){
+ if( def.Super && !instance.Super ){
+ instance.Super = def.Super;
+ };
+ def.live && def.live.push( instance );
+ def[ CONSTRUCTOR ] && def[ CONSTRUCTOR ].apply( instance, c( arguments ) );
+ return instance;
+ };
+
+ /* Constructor Real for PrivateClass */
+ function P(){
+ var klass = this,
+ def = getClassDef( klass ),
+ instance;
+ if( privateFlag === true ){
throw new Error( 'use class.newPrivateData( instance, args )!' );
};
if( def.pool && def.pool.length > 0 ){
if( def.Super && !instance.Super ){
instance.Super = def.Super;
};
- def[ CONSTRUCTOR ] && def[ CONSTRUCTOR ].apply( instance, c( arguments ) );
- def.live && def.live.push( instance );
return instance;
};
+ /* Constructor Real for AbstractClass */
+ function A(){
+ var klass = this,
+ instance;
+ if( abstractFlag === true ){
+ throw new Error( 'AbstractClass!' );
+ };
+ f = false;
+ instance = new klass();
+ f = true;
+ return instance;
+ };
+
return {
POOL_OBJECT : 1,
ABSTRACT : 2,
FINAL : 4,
SUPER_ACCESS : 8,
- create : function( /* classSetting, opt_PrivateClass, props */ ){
- var args = c( arguments ),
- classSetting = args[ 0 ],
- opt_pool, opt_abstract, opt_final,
+ PRIVATE_DATA : 16,
+ create : function( /* displayName, classSetting, opt_PrivateClass, props */ ){
+ var args = c( arguments ),
+ displayName = args[ 0 ],
+ classSetting,
+ opt_pool, opt_abstract, opt_final, opt_private,
privateDef,
props,
klass,
classDef = {};
+ if( Type.isString( displayName ) === true ){
+ classDef.displayName = displayName;
+ args.shift();
+ };
+ classSetting = args[ 0 ];
if( Type.isNumber( classSetting ) === true ){
- opt_pool = classSetting & Class.POOL_OBJECT === 1;
- opt_abstract = classSetting & Class.ABSTRACT === 1;
- opt_final = classSetting & Class.FINAL === 1;
+ opt_pool = !!( classSetting & Class.POOL_OBJECT );
+ opt_abstract = !!( classSetting & Class.ABSTRACT );
+ opt_final = !!( classSetting & Class.FINAL );
+ opt_private = !!( classSetting & Class.PRIVATE_DATA );
+ if( opt_final === true && opt_abstract === true ){
+ throw new Error( 'final & Abstract!' );
+ };
args.shift();
};
- if( opt_final === true && opt_abstract === true ){
- throw new Error( 'final & Abstract!' );
- };
-
privateDef = getClassDef( args[ 0 ] );
if( privateDef ){
if( privateDef.isPrivate !== true ){
} else
if( privateDef.Abstract === true ){
throw new Error( 'PrivateClass is Abstract!' );
- } else {
- classDef.privateClass = args[ 0 ];
- klass.newPrivateData = newPrivateData;
- klass.getPrivateData = getPrivateData;
- args.shift();
- };
+ };
+ classDef.privateClass = args.shift();
};
- props = args[ 0 ]
+ props = args[ 0 ];
if( props === null || Type.isObject( props ) === false ){
throw new Error( 'No Class Def!' );
};
- klass = function(){ a = arguments; if( f ) return I.apply( a.callee, c( a ) )};
- klass.prototype = override( override( {}, props, true ), ClassBase, false );
-
if( Type.isFunction( props[ CONSTRUCTOR ] ) === true ){
classDef[ CONSTRUCTOR ] = props[ CONSTRUCTOR ];
};
- if( opt_final !== true ){
- klass.inherits = inherits;
- } else {
- def.Final = true;
- };
+
if( opt_abstract === true ){
+ klass = function(){ a = arguments; if( f ) return A.apply( a.callee, c( a ) )};
classDef.Abstract = true;
- } else
- if( opt_pool === true ){
- classDef.pool = [];
- classDef.live = [];
+ } else
+ if( opt_private === true ){
+ klass = function(){ a = arguments; if( f ) return P.apply( a.callee, c( a ) )};
+ if( opt_pool === true ) classDef.pool = [];
+ } else {
+ klass = function(){ a = arguments; if( f ) return G.apply( a.callee, c( a ) )};
+ if( opt_pool === true ){
+ classDef.pool = [];
+ classDef.live = [];
+ };
+ };
+ klass.prototype = override( override( {}, props, true ), ClassBase, false );
+
+ if( opt_final === true ){
+ classDef.Final = true;
+ } else {
+ klass.inherits = inherits;
+ };
+ if( opt_private === true ){
+ if( classDef.privateClass ){
+ throw new Error( 'Private Data Class has no PrivateClass!' );
+ };
+ classDef.isPrivate = true;
+ PRIVATE_CLASS_LIST.push( klass );
+ PRIVATE_DEF_LIST.push( classDef );
+ } else {
+ if( classDef.privateClass ){
+ klass.newPrivateData = newPrivateData;
+ klass.getPrivateData = getPrivateData;
+ };
+ CLASS_LIST.push( klass );
+ DEF_LIST.push( classDef );
};
- CLASS_LIST.push( klass );
- DEF_LIST.push( classDef );
- return klass;
- },
- createPrivateData : function( props, opt_abstract, opt_final ){
- var klass = Class.create( props, true, opt_abstract, opt_final ),
- classDef = getClassDef( klass );
- classDef.isPrivate = true;
- classDef.userList = [];
- classDef.dataList = [];
return klass;
},
onShutdown : function(){
+ },
+ getClass : function( instance ){
+
+ },
+ getClassDef : function(){
+
}
};
})();
};
},
registerUser : function( user ){
-
+ if( !this.userList ){
+ this.userList = [ user ];
+ } else {
+ Util.getIndex( this.userList, user ) === -1 && this.userList.push( user );
+ };
},
onKill : function(){
+ var instance = this.thisObject;
+ this.userList && Class.getClass( instance ) && instance.releaseMyCalllback( this );
}
});
-var TicketBase = function(){
- this.kill = function(){
- var t = this, v, p;
- for( p in t ){
- if( t.hasOwnProperty && !t.hasOwnProperty( p ) ) continue;
- v = t[ p ];
- v && v instanceof TicketBase && v.kill();
- delete t[ p ];
- };
- };
-};
-
-
/* --------------------------------------------------------------
* System Timer
var next = 0;
function loop(){
- for( var i = 0; i < TICKET_LIST.length; ) {
- if( TICKET_LIST[ i ].call( next ) !== false ) ++i;
+ var i = 0,
+ list = TICKET_LIST;
+ for( i = 0; i < list.length; ){
+ if( list[ i ].fire( next ) !== false ) ++i;
};
timerId = undefined;
update();
};
function update(){
- var l = TICKET_LIST.length,
- n = 99999999,
+ var list = TICKET_LIST,
+ l = list.length,
+ n = 99999999,
c;
if( l === 0 ){
timerId !== undefined && clearTimeout( timerId );
timerId = undefined;
return;
};
- for( var i = 0; i<l; i++ ){
- c = TICKET_LIST[ i ].count;
+ for( ; l; ){
+ c = list[ --l ].count;
if( n > c ) n = c;
};
if( next > n || timerId === undefined ){
};
};
- var TimerTicketClass = function( _apiuser, _callback, _time, _once, opt_thisObject ){
- this.apiuser = _apiuser;
- this.callback = _callback;
- this.time = _time;
- this.count = _time;
- this.once = _once;
- this.thisObj = opt_thisObject;
- };
- TimerTicketClass.prototype = new TicketBase();
- TimerTicketClass.prototype.call = function( c ){
- this.count -= c;
- if( this.count <= 0 ){
- this.callback.call( this.thisObj || this.apiuser );
- if( this.once === true ){
- this.destroy();
- TICKET_LIST.splice( Util.getIndex( TICKET_LIST, this ), 1 );
- return false;
- } else {
- this.count = this.time;
- };
- };
- };
- TimerTicketClass.prototype.destroy = function( _apiuser, _callback ){
- if( _apiuser && _apiuser !== this.apiuser ) return false;
- if( _callback && _callback !== this.callback ) return false;
-
- this.kill();
- return true;
- };
+ var TimerTicket = Class.create(
+ Class.POOL_OBJECT, {
+ Constructor : function( apiuser, callback, time, once, opt_thisObject ){
+ this.apiuser = apiuser;
+ this.callback = callback;
+ this.time = time;
+ this.count = time;
+ if( once ) this.once = once;
+ this.thisObj = opt_thisObject || apiuser;
+ },
+ fire : function( c ){
+ this.count -= c;
+ if( 0 < this.count ) return;
+ this.callback.call( this.thisObj );
+ if( this.once === true ){
+ this.destroy();
+ TICKET_LIST.splice( Util.getIndex( TICKET_LIST, this ), 1 );
+ return false;
+ } else {
+ this.count = this.time;
+ };
+ },
+ destroy : function( apiuser, callback ){
+ if( apiuser && apiuser !== this.apiuser ) return false;
+ if( callback && callback !== this.callback ) return false;
+
+ this.kill();
+ return true;
+ }
+ }
+ );
return {
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, opt_thisObject );
+ var _ticket = new TimerTicket( _apiuser, _handler, Math.ceil( _time / INTERVAL_TIME ), _once, opt_thisObject );
TICKET_LIST.push( _ticket );
update();
*/
var AsyncCall = ( function(){
var CALLBACK_LIST = [];
-
- var CallbackTicketClass = function( _apiuser, _callback, _argments, _thisObject ){
- this.apiuser = _apiuser;
- this.callback = _callback;
- this.argments = _argments;
- this.thisObject = _thisObject;
- };
- CallbackTicketClass.prototype = new TicketBase();
- CallbackTicketClass.prototype.call = function(){
- var f = this.callback,
- a = this.argments,
- t = this.thisObject;
- this.destroy();
- if( Type.isArray( a ) === true ){
- f.apply( t, a );
- } else {
- f.call( t, a );
- };
- };
- CallbackTicketClass.prototype.destroy = function( _apiuser, _callback ){
- if( _apiuser && _apiuser !== this.apiuser ) return false;
- if( _callback && _callback !== this.callback ) return false;
-
- this.kill();
- return true;
- };
+
+ var CallbackTicket = Class.create(
+ Class.POOL_OBJECT, {
+ Constructor : function( apiuser, callback, args, thisObject ){
+ this.apiuser = apiuser;
+ this.callback = callback;
+ this.args = args;
+ this.thisObj = thisObject || apiuser;
+ },
+ fire : function(){
+ var f = this.callback,
+ a = this.args,
+ t = this.thisObj;
+ this.destroy();
+ if( Type.isArray( a ) === true ){
+ f.apply( t, a );
+ } else {
+ f.call( t, a );
+ };
+ },
+ destroy : function( apiuser, callback ){
+ if( apiuser && apiuser !== this.apiuser ) return false;
+ if( callback && callback !== this.callback ) return false;
+
+ this.kill();
+ return true;
+ }
+ });
function dispatch(){
var _ticket = CALLBACK_LIST.shift();
if( _ticket ){
- _ticket.call();
+ _ticket.fire();
CALLBACK_LIST.length !== 0 && SystemTimer.add( SUPER_USER_KEY, dispatch, 1, true );
};
};
return {
add: function( _apiuser, _callback, _argments, _thisObject ){
CALLBACK_LIST.length === 0 && SystemTimer.add( SUPER_USER_KEY, dispatch, 1, true );
- CALLBACK_LIST.push( new CallbackTicketClass( _apiuser, _callback, _argments, _thisObject || _apiuser ) );
+ CALLBACK_LIST.push( new CallbackTicket( _apiuser, _callback, _argments, _thisObject ) );
},
remove: function( _apiuser, _callback ){
var _ticket,
var REQUEST_TICKET_RESISTER = [],
currentTicket = null,
currentData = null,
- DATA_TYPE_ARRAY = 'json,xml,html,text'.split( ','),
+ DATA_TYPE_ARRAY = 'json,xml,html,text'.split( ',' ),
DATA_IS_JSON = 0,
DATA_IS_XML = 1,
DATA_IS_HTML = 2,
DATA_IS_TEXT = 3,
numError = 0;
- var RequestTicketClass = function( _apiuser, _type, _data, _url, _onLoad, _onError ){
- this.apiuser = _apiuser;
- this.type = _type;
- this.data = _data;
- this.url = _url;
- this.onLoad = _onLoad;
- this.onError = _onError;
- this.state = 0;
- _apiuser = _type = _data = _onLoad = _onError = null;
- };
- RequestTicketClass.prototype = new TicketBase();
- RequestTicketClass.prototype.load = function( _data ){
- AsyncCall.add( this.apiuser, this.onLoad, [ this.data, _data ] );
- };
- RequestTicketClass.prototype.error = function(){
- AsyncCall.add( this.apiuser, this.onError, this.data );
- };
+ var RequestTicket = Class.create(
+ Class.POOL_OBJECT, {
+ Constructor : function( apiuser, type, data, url, onLoad, onError ){
+ this.apiuser = apiuser;
+ this.type = type;
+ this.data = data;
+ this.url = url;
+ this.onLoad = onLoad;
+ this.onError = onError;
+ this.state = 0;
+ },
+ load : function( data ){
+ AsyncCall.add( this.apiuser, this.onLoad, [ this.data, data ] );
+ },
+ error : function(){
+ AsyncCall.add( this.apiuser, this.onError, this.data );
+ }
+ });
function request(){
if( currentTicket !== null || REQUEST_TICKET_RESISTER.length === 0 ) return;
return numError;
},
getJson: function( _apiuser, _data, _url, _onLoad, _onError ){
- REQUEST_TICKET_RESISTER.push( new RequestTicketClass( _apiuser, DATA_IS_JSON, _data, _url, _onLoad, _onError ));
+ REQUEST_TICKET_RESISTER.push( new RequestTicket( _apiuser, DATA_IS_JSON, _data, _url, _onLoad, _onError ));
currentTicket === null && request();
}
};
},
addEventListener: function( FILEorNULL, _eventType, _callback, opt_thisObject ){
var _uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL;
- EVENT_LISTENER_REGISTER.push( new FileEventTicketClass( _uid, _eventType, _callback, opt_thisObject ));
- },
- removeEventListener: function( FILEorNULL, _eventType, _callback ){
- var _uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL,
- _ticket;
- for(var i=0, l = EVENT_LISTENER_REGISTER.length; i<l; ++i ){
- _ticket = EVENT_LISTENER_REGISTER[ i ];
- if( _ticket.fileUID === _uid && _ticket.eventType === _eventType && _ticket.callBack === _callback ){
- EVENT_LISTENER_REGISTER.splice( i, 1 );
- _ticket.kill();
+ EVENT_LISTENER_REGISTER.push( new FileEventTicket( _uid, _eventType, _callback, opt_thisObject ));
+ },
+ removeEventListener: function( FILEorNULL, eventType, callback ){
+ var uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL,
+ list = EVENT_LISTENER_REGISTER,
+ i = 0,
+ ticket;
+ for( ; i < list.length; ){
+ ticket = list[ i ];
+ if( ticket.fileUID === uid && ticket.eventType === eventType && ticket.callBack === callback ){
+ list.splice( i, 1 );
+ ticket.kill();
+ } else {
+ ++i;
};
};
},
return true;
};
};
-
- var FileEventTicketClass = function( uid, eventType, callback, opt_thisObject ){
- this.fileUID = uid;
- this.eventType = eventType;
- this.callBack = callback;
- this.thisObject = opt_thisObject;
- };
- FileEventTicketClass.prototype = new TicketBase();
+
+ var FileEventTicket = Class.create(
+ Class.POOL_OBJECT, {
+ Constructor : function( uid, eventType, callback, opt_thisObject ){
+ this.fileUID = uid;
+ this.eventType = eventType;
+ this.callBack = callback;
+ this.thisObject = opt_thisObject;
+ }
+ });
var FileEventClass = function( eventType, file, key, value ){
this.eventType = eventType;
var that = this;
this.button = ui.createButton( this.elm, function(){
that.onClick();
- that = null;
+ // that = null;
} );
this.app = app;
/**
* FinderPrivateData
*/
- var FinderPrivateData = function(){};
- FinderPrivateData.MIN_PATH_WIDTH = 25;
- FinderPrivateData.prototype = {
+ var FinderPrivateData = Class.create(
+ Class.PRIVATE_DATA, {
finder : null,
apiuser : null,
elmRoot : null,
panOutPage : null,
pageDetail : null,
currentFile : null,
- init : function( finder, apiuser, elm, tree, onSelect, viewerOption, editorOption ){
+ Constructor : function( finder, apiuser, elm, tree, onSelect, viewerOption, editorOption ){
this.finder = finder;
this.apiuser = apiuser;
if( PointingDeviceEventTree.isNodeInstance( elm ) === true ){
this.pageIcons1.init( this.nodeRoot, this.elmRoot, this.elmScroll );
this.pageIcons2.init( this.nodeRoot, this.elmRoot, this.elmScroll );
this.pageDetail.init( this );
- FinderPrivateData.LIST.push( this );
},
onIconClick : function( e ){
if( this.panInPage === this.pageDetail ) return;
AsyncCall.add( this.apiuser, this.draw, null, this );
};
},
- destroy : function(){
+ onKill : function(){
this.tree.removeTreeEventListener( Const.TREE.EVENT.UPDATE, this.draw );
if( this.pathList ){
i = Util.getIndex( list, this.finder );
i !== -1 && list.splice( i, 1 );
}
- };
- FinderPrivateData.LIST = [];
- FinderPrivateData.get = function( finderOrTree ){
- var list = FinderPrivateData.LIST,
- i = list.length,
- data;
- for( ; i; ){
- data = list[ --i ];
- if( data === finderOrTree || data.finder === finderOrTree || data.tree === finderOrTree ) return data;
- };
- return null;
- };
-
+ });
+ FinderPrivateData.MIN_PATH_WIDTH = 25;
+
/**
* FinderClass
*/
- var FinderClass = function( application, elmRoot, tree, onSelect, viewerOption, editorOption ){
- ( new FinderPrivateData() ).init( this, application, elmRoot, tree, onSelect, viewerOption, editorOption );
- };
- FinderClass.prototype = {
+ var Finder = Class.create(
+ FinderPrivateData, {
+ Constructor : function( application, elmRoot, tree, onSelect, viewerOption, editorOption ){
+ Finder.newPrivateData( this, this, application, elmRoot, tree, onSelect, viewerOption, editorOption );
+ },
MIN_WIDTH : 200,
MIN_HEIGHT : 200,
- init : function(){
- },
resize : function( w, h ){
- var data = FinderPrivateData.get( this );
+ var data = Finder.getPrivateData( this );
data.panInPage && data.panInPage.resize( w );
},
createPath : function( node ){
- return FinderPrivateData.get( this ).createPath( node );
+ return Finder.getPrivateData( this ).createPath( node );
},
destroy : function(){
- FinderPrivateData.get( this ).destroy();
+ this.kill();
}
- };
+ });
return {
init: function(){
create: function( application, elmTarget, tree, onSelect, viewerOption, editorOption ){
//if( Application.isApplicationInstance( _application ) === false ) return;
- var finder = new FinderClass( application, elmTarget, tree, onSelect, viewerOption, editorOption );
- finder.init();
+ var finder = new Finder( application, elmTarget, tree, onSelect, viewerOption, editorOption );
FINDER_LIST.push( finder );
return finder;
},
},
isFinderInstance: function( _finder ){
- return _finder instanceof FinderClass;
+ return _finder instanceof Finder;
},
isFinderPaneInstance: function(){