/*
* pettanR system.js
- * version 0.4.22
+ * version 0.4.23
*
* author:
* itozyun
var REQUEST_CONTROLER = ( function(){
var REQUEST_TICKET_RESISTER = [],
+ currentTicket = null,
+ currentData = null,
DATA_TYPE_ARRAY = 'json,xml,html,text'.split( ','),
DATA_IS_JSON = 0,
DATA_IS_XML = 1,
};
function request(){
- if( REQUEST_TICKET_RESISTER.length === 0) return;
- var _ticket = REQUEST_TICKET_RESISTER.shift();
+ if( currentTicket !== null ) return;
+ currentTicket = REQUEST_TICKET_RESISTER.shift();
$.ajax({
- url: _ticket.url,
- dataType: _ticket.type,
- success: function( _data){
- _ticket.onLoad( _ticket.data, _data);
- },
- error: function(){
- ++numError;
- _ticket.onError( _ticket.data);
- }
+ url: currentTicket.url,
+ dataType: currentTicket.type,
+ success: onSuccess,
+ error: onError
});
}
+ function onSuccess( _data ){
+ currentData = _data;
+ window.setTimeout( asyncSuccess, 0 );
+ }
+ function asyncSuccess(){
+ currentTicket.onLoad( currentTicket.data, currentData );
+ currentTicket = currentData = null;
+ REQUEST_TICKET_RESISTER.length !== 0 && window.setTimeout( request, 0 );
+ }
+ function onError(){
+ ++numError;
+ window.setTimeout( asyncError, 0 );
+ }
+ function asyncError(){
+ currentTicket.onError( currentTicket.data );
+ currentTicket = null;
+ REQUEST_TICKET_RESISTER.length !== 0 && window.setTimeout( request, 0 );
+ }
return {
getNumTask: function(){
return REQUEST_TICKET_RESISTER.length;
getNumError: function(){
return numError;
},
- getJson: function( _data, _url, _onLoad, _onError){
+ getJson: function( _data, _url, _onLoad, _onError ){
REQUEST_TICKET_RESISTER.push( new RequestTicketClass( DATA_IS_JSON, _data, _url, _onLoad, _onError));
- request();
+ currentTicket === null && request();
}
}
})();
replace: function( _uid, _file, _newIndex){
},
- addEventListener: function( FILEorNULL, _eventType, _callback){
+ addEventListener: function( FILEorNULL, _eventType, _callback ){
var _uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL;
EVENT_LISTENER_REGISTER.push( new FileEventTicketClass( _uid, _eventType, _callback));
},
- removeEventListener: function( FILEorNULL, _eventType, _callback){
+ 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){
}
}
}
-
+
+ var AsyncEventDispatcher = ( function(){
+ var STACK_LIST = [];
+
+ function dispatch(){
+ var _stack = STACK_LIST.shift();
+ _stack[ 0 ]( _stack[ 1 ], _stack[ 2 ], _stack[ 3 ], _stack[ 4 ] );
+
+ while( _stack.length > 0 ){
+ _stack.shift();
+ }
+ if( STACK_LIST.length !== 0 ){
+ window.setTimeout( dispatch, 0 );
+ }
+ }
+ return {
+ addEvent: function( _callback, _eventType, _targetFile, _key, _value ){
+ if( STACK_LIST.length === 0 ){
+ window.setTimeout( dispatch, 0 );
+ }
+ STACK_LIST.push( [ _callback, _eventType, _targetFile, _key, _value ] );
+ }
+ }
+ })();
+
var TreeClass = function( rootFileData ){
var PARENT_FILE_RESITER = [],
ACCESS = {
_targetFile = e.targetFile,
_uid = _targetFile.getUID(),
_ticket, _type, _callback;
- for(var i=0, l = EVENT_LISTENER_REGISTER.length; i<l; ++i ){
+ for( var i=0, l = EVENT_LISTENER_REGISTER.length; i<l; ++i ){
_ticket = EVENT_LISTENER_REGISTER[ i ];
_type = _ticket.eventType;
_callback = _ticket.callBack;
if( _eventType === _type && _uid === _ticket.fileUID ){
- _callback( _eventType, _targetFile, e.key, e.value );
+ AsyncEventDispatcher.addEvent( _callback, _eventType, _targetFile, e.key, e.value );
} else
if( _type === pettanr.file.TREE_EVENT.UPDATE && _eventType === pettanr.file.FILE_EVENT.GET_SEQENTIAL_FILES ){
- _callback( _eventType, _targetFile );
+ AsyncEventDispatcher.addEvent( _callback, _eventType, _targetFile );
}
}
}
} else {
elmBody.className = 'finder-body';
}
+
elmBody.style.height = bodyH + 'px';
while( l < ICON_ARRAY.length){
return _data.title;
} else
if( _type === pettanr.driver.FILE_TYPE.ARTIST ){
- return [ _data.id , ':', _data.name, '画伯' ].join( '');
+ return [ _data.name, '画伯' ].join( '');
} else
if( _type === pettanr.driver.FILE_TYPE.AUTHOR ){
- return [ _data.id , ':', _data.name, '先生' ].join( '');
+ return [ _data.name, '先生' ].join( '');
}
return _data.name;
},
return 'cabinet file';
}
if( _type === pettanr.driver.FILE_TYPE.COMIC){
- return 'comic file';
+ return 'comic file, id:' + _data.id;
}
if( _type === pettanr.driver.FILE_TYPE.PANEL){
return [ _data.width, 'x', _data.height ].join( '' );
}
if( _type === pettanr.driver.FILE_TYPE.AUTHOR){
- return 'author file';
+ return 'author file, id:' + _data.id;
}
if( _type === pettanr.driver.FILE_TYPE.ARTIST){
- return [ 'Email:', _data.email || 'empty' , ', HP:', _data.homepage_url || 'empty' ].join( '' );
+ return [ 'id:', _data.id, ' Email:', _data.email || 'empty' , ', HP:', _data.homepage_url || 'empty' ].join( '' );
}
if( _type === pettanr.file.FILE_TYPE.FOLDER){
return 'pettanR folder';
_getAPI: function(){
return FileAPI;
},
+ _getPictureRootData: function(){
+ return FILE_DATA_PICTURE_ROOT;
+ },
_getMyPicturesData: function(){
return FILE_DATA_MY_PICTURES_ROOT;
},
instance = this,
winW, winH,
wrapX,
- elmWrap = document.getElementById( 'image-gruop-wrapper' ),
- elmContainer = document.getElementById( 'image-icon-container' ),
+ elmWrap = document.getElementById( 'image-group-wrapper' ),
+ elmContainer = document.getElementById( 'image-group-icon-container' ),
containerW,
containerH = pettanr.util.getElementSize( elmContainer ).height,
elmIconOrigin = ( function(){
var ret = document.createElement( 'div' ),
data = document.createElement( 'div' );
ret.appendChild( data );
- ret.className = 'image-gruop-item';
- data.className = 'image-gruop-item-title';
+ ret.className = 'image-group-item';
+ data.className = 'image-group-item-title';
return ret;
})(),
jqContainer,
size = pettanr.util.getElementSize( elmIconOrigin ),
itemW = size.width,
itemH = size.height,
- elmName = document.getElementById( 'gruop-name-display' ),
- elmButton = document.getElementById( 'image-gruop-button' ),
+ elmName = document.getElementById( 'image-group-name' ),
+ elmButton = document.getElementById( 'image-group-button' ),
buttonW = pettanr.util.getElementSize( elmButton ).width,
//onUpdateFunction,
_g_onUpdateFunction,
+ artistID = -1,
onEnterInterval = null;
elmButton.onclick = clickOK;
var ImageGroupIconClass = function( INDEX, file ){
var elmIconWrap = elmIconOrigin.cloneNode( true ),
- elmIconTitle = pettanr.util.getElementsByClassName( elmIconWrap, 'image-gruop-item-title' )[ 0 ],
+ elmIconTitle = pettanr.util.getElementsByClassName( elmIconWrap, 'image-group-item-title' )[ 0 ],
data = pettanr.driver._getAPI().getFileData( file ),
SRC = [ BASE_PATH, data.id, '.', data.ext ].join( ''),
LOW_SRC = data.filesize && data.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext ].join( '') : null,
imgW, imgH;
elmContainer.appendChild( elmIconWrap );
elmIconWrap.style.left = ( INDEX * itemW ) + 'px';
- elmIconTitle.appendChild( document.createTextNode( data.filesize + 'bytes' ));
+ elmIconTitle.appendChild( document.createTextNode( data.filesize + 'bytes' ) );
function onImageLoad( url, _imgW, _imgH ){
if( reversibleImage === null) {
function onClick( e ){
if( _g_onUpdateFunction ) {
- //if( LOW_SRC === null){
- window[ _g_onUpdateFunction]( data );
- window[ _g_onUpdateFunction] = null;
- /*
- } else {
- var _onLoad = pettanr.util.createGlobalFunc( [
- 'function( url, w, h ){',
- 'window["', _g_onUpdateFunction, '"]( url, w || ', data.width,', h || ', data.height,');',
- 'window["', _g_onUpdateFunction, '"] = null;',
- '}'
- ].join( '')),
- _onError = pettanr.util.createGlobalFunc( [
- 'function( url){',
- 'window["', _g_onUpdateFunction, '"]( url, ', data.width || 64 ,', ', data.height || 64,');',
- 'window["', _g_onUpdateFunction, '"] = null;',
- '}'
- ].join( ''));
- pettanr.util.loadImage( SRC, window[ _onLoad], window[ _onError]);
- window[ _onLoad] = window[ _onError] = undefined;
- }*/
+ window[ _g_onUpdateFunction ]( data );
+ window[ _g_onUpdateFunction ] = null;
}
pettanr.premiumSatge.shutdown();
}
this.onEnter = function(){
- if( onEnterFlag === true ) return;
+ if( onEnterFlag === true || data === null ) return; // data === null : destroyed
reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onImageLoad );
elmIconWrap.appendChild( reversibleImage.elm );
onEnterFlag = true;
_start = -wrapX /itemW -1,
_end = _start + winW /itemW +1;
for( var i=0; i<l; ++i){
- _start < i && i < _end && ICON_ARRAY[ i].onEnter();
+ _start < i && i < _end && setTimeout( ICON_ARRAY[ i ].onEnter, i * 100 );
}
onEnterInterval !== null && window.clearTimeout( onEnterInterval );
onEnterInterval = null;
jqContainer.css( { left: wrapX});
onEnterInterval !== null && window.clearTimeout( onEnterInterval );
- onEnterInterval = window.setTimeout( onEnterShowImage, 500);
+ onEnterInterval = window.setTimeout( onEnterShowImage, 500 );
}
//e.stopPropagation();
return false;
}
+ function drawIcons(){
+ while( ICON_ARRAY.length > 0 ){
+ ICON_ARRAY.shift().destroy();
+ }
+
+ var _index = ARTIST_ROOT_FILE.search( {
+ id: artistID,
+ type: pettanr.driver.FILE_TYPE.ARTIST
+ })[ 0 ],
+ _artistFile = ARTIST_ROOT_FILE.getChildFileByIndex( _index );
+ if( _artistFile !== null ){
+ for(var i=0, l=_artistFile.getChildFileLength(); i<l; ++i ){
+ ICON_ARRAY.push( new ImageGroupIconClass( i, _artistFile.getChildFileByIndex( i ) ));
+ }
+ elmName.firstChild.data = _artistFile.getName();
+ _artistFile.destroy();
+ }
+ }
+
/* grobal method */
// this.rootElement = elmWrap;
this.displayName = 'premiumStage';
this.MIN_HEIGHT = 320;
this.init = function(){
jqContainer = $( elmContainer ).mousewheel( onMouseWheel );
+
+ // よくない! 一時的な処理,,,
+ //var tree = pettanr.driver.createPictureTree();
+ //tree.addTreeEventListener( pettanr.file.TREE_EVENT.UPDATE, drawIcons );
+
delete instance.init;
}
this.onOpen = function( _windowW, _windowH, _ARTISTIDorFILE, _onUpdateFunction ){
instance.init && instance.init();
- var _data, _artistID = -1;
-
if( pettanr.driver.isPettanrFileInstance( _ARTISTIDorFILE ) === true ){
- _data = pettanr.driver._getAPI().getFileData( _ARTISTIDorFILE );
+ var _data = pettanr.driver._getAPI().getFileData( _ARTISTIDorFILE );
if( _ARTISTIDorFILE.getType() === pettanr.driver.FILE_TYPE.ARTIST || pettanr.driver._getMyPicturesData() === _data ){
- _artistID = _data.id || -1;
+ artistID = _data.id || -1;
}
} else
if( Type.isNumber( _ARTISTIDorFILE ) === true ){
- _artistID = _ARTISTIDorFILE;
+ artistID = _ARTISTIDorFILE;
}
//onUpdateFunction = _onUpdateFunction;
if( _onUpdateFunction ){
- _g_onUpdateFunction = pettanr.util.createGlobalFunction( _onUpdateFunction);
+ _g_onUpdateFunction = pettanr.util.createGlobalFunction( _onUpdateFunction );
} else {
_g_onUpdateFunction = null;
}
- var _index = ARTIST_ROOT_FILE.search( {
- id: _artistID,
- type: pettanr.driver.FILE_TYPE.ARTIST
- } )[ 0 ],
- _artistFile = ARTIST_ROOT_FILE.getChildFileByIndex( _index ),
- i, l = 0;
- if( _artistFile !== null ){
- for( i=0, l=_artistFile.getChildFileLength(); i<l; ++i ){
- ICON_ARRAY.push( new ImageGroupIconClass( i, _artistFile.getChildFileByIndex( i ) ));
- }
- elmName.firstChild.data = _artistFile.getName() + l;
- _artistFile.destroy();
- }
+ drawIcons();
wrapX = 0;
- containerW = l * itemW;
+ containerW = ICON_ARRAY.length * itemW;
winW = _windowW;
winH = _windowH;
h = _windowH > containerH ? containerH : _windowH,
MATH_FLOOR = Math.floor;
- onEnterShowImage();
-
jqContainer.css( {
width: w,
height: 0,
}).stop().animate( {
height: h,
top: MATH_FLOOR( _windowH /2 -h /2)
- });
+ }, onEnterShowImage );
elmButton.style.cssText = [
'left:', MATH_FLOOR( winW /2 - buttonW /2), 'px;',