From 027c36af3f26e24b8ceb8e507f397d859a742f0a Mon Sep 17 00:00:00 2001 From: itozyun Date: Tue, 17 Apr 2012 21:31:22 +0900 Subject: [PATCH] client is version0.4.21, brush up around boot application. --- public/assets/common.js | 165 ++++++++++++++++++++++-------------------------- public/assets/system.js | 74 ++++++++++++---------- public/assets/work.js | 29 ++++----- 3 files changed, 130 insertions(+), 138 deletions(-) diff --git a/public/assets/common.js b/public/assets/common.js index c37ca430..5369fd75 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1,6 +1,6 @@ /* * pettanR common.js - * version 0.4.19 + * version 0.4.21 * * author: itozyun */ @@ -108,7 +108,7 @@ var pettanr = ( function(){ IS_DEBUG = Type.isBoolean( URL_PARAMS.debug ) ? URL_PARAMS.debug : IS_LOCAL === true, jqWindow , jqDocument , jqBody; return { - version: '0.4.19', + version: '0.4.21', init: function(){ jqWindow = $( window); jqDocument = $( document); @@ -845,26 +845,27 @@ pettanr.view = ( function(){ currentApplication = null; var AbstractBasicPane = function(){ + this.onPaneResize = function( _w, _h ){} + this.resize = function( _w, _h ){ + if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){ + if( Type.isHTMLElement( this.rootElement ) === true ){ + // 小さすぎる!、と表示 + } + return; + } + this.onPaneResize( _w, _h ); + } + this.MIN_WIDTH = 240; + this.MIN_HEIGHT = 240; + } + + var AbstractApplication = function(){ + this.displayName = 'app name'; + this.ID = 'app id'; this.rootElement = null; this.parentElement = null; this.nextSibling = null; - this.onOpen = function( _w, _h /*, _option */ ){ - // overrride - }; - this.onClose = function(){ - // overrride - return true; - } // false の場合、close の拒否 - this.onPaneResize = function( _w, _h ){} this.open = function( _w, _h /*, _option */ ){ - if( this.nextSibling && this.nextSibling.parentNode === this.parentElement ){ - this.parentElement.insertBefore( this.rootElement, this.nextSibling ); - } else - if( this.parentElement ){ - this.parentElement.appendChild( this.rootElement ); - } else { - this.rootElement && document.body.appendChild( this.rootElement ); - } if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){ if( Type.isHTMLElement( this.rootElement ) === true ){ // 小さすぎる!、と表示 @@ -879,72 +880,57 @@ pettanr.view = ( function(){ } this.close = function(){ if( this.onClose() === false ){ - + return; } if( this.rootElement && this.rootElement.parentNode ){ this.rootElement.parentNode.removeChild( this.rootElement ); } } - this.resize = function( _w, _h ){ - if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){ - if( Type.isHTMLElement( this.rootElement ) === true ){ - // 小さすぎる!、と表示 - } - return; - } - this.onPaneResize( _w, _h ); - } - this.MIN_WIDTH = 240; - this.MIN_HEIGHT = 240; - } - - var AbstractApplication = function(){ - this.displayName = 'app name'; - this.ID = 'app id'; + this.onOpen = function( _w, _h /*, _option */ ){ + // overrride + }; + this.onClose = function(){ + // overrride + return true; + } // false の場合、close の拒否 } AbstractApplication.prototype = new AbstractBasicPane(); - var ApplicationReference = function( _application ){ + var ApplicationReference = function( application ){ this.inOverlay = false; + this.getUID = function(){ + return pettanr.util.getIndex( APPLICATION_LIST, application ); + } this.boot = function( /* _option */ ){ if( arguments.length > 0 ){ - bootApplication( _application, pettanr.util.copyArray( arguments ) ); + bootApplication( application, pettanr.util.copyArray( arguments ) ); } else { - bootApplication( _application ); + bootApplication( application ); } } this.bootInOverlay = function( /* _option */ ){ this.inOverlay = true; - pettanr.overlay.show( _application ); - - if( arguments.length > 0 ){ - var _arguments = pettanr.util.copyArray( arguments ); - _arguments.unshift( jqWindow.width(), jqWindow.height() ) - // argumentsRellay( _application.open, _arguments ); - _application.open.apply( _application, _arguments ); - } else { - _application.open( jqWindow.width(), jqWindow.height() ); - } + pettanr.overlay.show( application, pettanr.util.copyArray( arguments ) ); } this.shutdown = function(){ if( this.inOverlay === true ){ pettanr.overlay.hide(); - _application.close(); + application.close(); this.inOverlay = false; } else { bootApplication( 0 ); } } this.addToLancher = function(){ - if( pettanr.util.getIndex( LUNCHER_APPLICATION_LIST, _application ) !== -1 ) return; - LUNCHER_APPLICATION_LIST.push( _application ); + if( pettanr.util.getIndex( LUNCHER_APPLICATION_LIST, application ) !== -1 ) return; + LUNCHER_APPLICATION_LIST.push( application ); var navi = document.getElementById('global-navi'), item = document.createElement('a'); navi.appendChild( item ); navi.style.width = ( ( item.offsetWidth || 80 ) * LUNCHER_APPLICATION_LIST.length ) + 'px'; item.href = '#'; - item.appendChild( document.createTextNode( _application.displayName )); + item.appendChild( document.createTextNode( application.displayName )); item.onclick = LoginUserNavi.show; } } @@ -988,11 +974,18 @@ pettanr.view = ( function(){ } if( currentApplication === _application ) return; - currentApplication && currentApplication.close(); - currentApplication = _application; + if( _application.nextSibling && _application.nextSibling.parentNode === _application.parentElement ){ + _application.parentElement.insertBefore( _application.rootElement, _application.nextSibling ); + } else + if( _application.parentElement ){ + _application.parentElement.appendChild( _application.rootElement ); + } else { + _application.rootElement && document.body.appendChild( _application.rootElement ); + } + if( _arguments ){ _arguments.unshift( jqWindow.width(), jqWindow.height() ); _application.open.apply( _application, _arguments ); @@ -1024,8 +1017,8 @@ pettanr.view = ( function(){ function onWindowResize(){ var w = jqWindow.width(), h = jqWindow.height(); - currentApplication && currentApplication.resize && currentApplication.resize( w, h ); - pettanr.overlay.currentID !== null && pettanr.overlay.onWindowResize( w, h ); + currentApplication && currentApplication.resize( w, h ); + pettanr.overlay.onWindowResize( w, h ); } return { @@ -1034,7 +1027,9 @@ pettanr.view = ( function(){ jqWindow.resize( onWindowResize ); var _option = {}; // urlパラメータ - + + onWindowResize(); + bootApplication( pettanr.URL_PARAMS.view || 0 ); delete pettanr.view.init; @@ -1082,12 +1077,13 @@ pettanr.overlay = ( function(){ ELM_CONTAINER = document.getElementById( 'overlay-container' ), jqConteiner, jqShadow, jqCloseButton,// jqBody, currentOverlay = null, + bootParams = null, visible = false, windowW, windowH; function close(){ currentOverlay && currentOverlay.close(); - pettanr.overlay.hide(); + pettanr.overlay.hide(); } function asyncResize(){ currentOverlay.resize( windowW, windowH); @@ -1098,7 +1094,7 @@ pettanr.overlay = ( function(){ return false; } function onFadeInComplete(){ - + } function onFadeOutComplete(){ if( currentOverlay.rootElement && currentOverlay.rootElement.parentNode === ELM_CONTAINER ){ @@ -1117,23 +1113,31 @@ pettanr.overlay = ( function(){ delete pettanr.overlay.init; }, - show: function( _overlay ){ + show: function( _overlay, _bootParams ){ if( visible === true && currentOverlay === _overlay ) return; if( pettanr.view.isApplicationInstance( _overlay ) === false ) return; document.body.style.overflow = 'hidden'; - ELM_CONTAINER.insertBefore( _overlay.rootElement, document.getElementById( 'overlay-close-button' )); + this.visible = visible = true; + this.currentID = _overlay.ID; + currentOverlay = _overlay; + bootParams = _bootParams; + jqConteiner.stop().css( { filter: '', opacity: '', top: document.documentElement.scrollTop || document.body.scrollTop }).fadeIn( onFadeInComplete ); - - this.visible = visible = true; - currentOverlay = _overlay; - this.currentID = _overlay.ID; - // jqCloseButton.toggle( !!_overlay.onClose ); + + ELM_CONTAINER.insertBefore( currentOverlay.rootElement, document.getElementById( 'overlay-close-button' )); + + if( Type.isArray( bootParams ) === true ){ + bootParams.unshift( windowW, windowH ) + currentOverlay.open.apply( currentOverlay, bootParams ); + } else { + currentOverlay.open( windowW, windowH, bootParams ); + } }, hide: function(){ if( visible === false) return; @@ -1148,33 +1152,18 @@ pettanr.overlay = ( function(){ visible: visible, currentID: null, onWindowResize: function( _windowW, _windowH ){ + windowW = _windowW; + windowH = _windowH; + + if( currentOverlay === null ) return; + jqConteiner.css({ height: _windowH, top: document.documentElement.scrollTop || document.body.scrollTop }); - jqShadow.css( { height: _windowH}); - windowW = _windowW; - windowH = _windowH; + jqShadow.css( { height: _windowH }); // 先にeditorのcanvasを確定する。 - currentOverlay && setTimeout( asyncResize, 0); - }, - registerOverlay: function( _basicPane){ - var _api = pettanr.view.createBasicPane( _basicPane ); - // OverlayAPI - return { - show: function( _basicPane ){ - - }, - hide: function( _basciPane ){ - - }, - isCurrent: function( _basicPane ){ - - } - } - }, - isOverlay: function( _basicPane ){ - + setTimeout( asyncResize, 0); } } })(); diff --git a/public/assets/system.js b/public/assets/system.js index 22c8c97f..7710a756 100644 --- a/public/assets/system.js +++ b/public/assets/system.js @@ -1,6 +1,6 @@ /* * pettanR system.js - * version 0.4.20 + * version 0.4.21 * * author: * itozyun @@ -388,6 +388,14 @@ pettanr.file = ( function(){ } return -1; }, + getChildFileByIndex: function( _index ){ + var _access = FILE_CONTROLER.getFileDataAccess( this ), + _children = FILE_CONTROLER.getChildren( this ); + if( typeof _index !== 'number' || _index < 0 || Type.isArray( _children ) === false || _index >= _children.length) return null; + var _file = new FileClass( _access.TREE, _access.DATA, _children[ _index ]); + // _file.init(); + return _file; + }, getName: function(){ var driver = FILE_CONTROLER.getDriver( this ); if( typeof driver.getName === 'function'){ @@ -473,14 +481,6 @@ pettanr.file = ( function(){ onDelete: function(){ }, - getChildFileByIndex: function( _index ){ - var _access = FILE_CONTROLER.getFileDataAccess( this ), - _children = FILE_CONTROLER.getChildren( this ); - if( typeof _index !== 'number' || _index < 0 || Type.isArray( _children ) === false || _index >= _children.length) return null; - var _file = new FileClass( _access.TREE, _access.data, _children[ _index ]); - // _file.init(); - return _file; - }, move: function( _newFolder, _newIndex, opt_callback ){ var _access = FILE_CONTROLER.getFileDataAccess( this ); _access.TREE.move( _access.parentData, this.getUID(), _newFolder, _newIndex, opt_callback ); @@ -891,7 +891,7 @@ pettanr.finder = ( function(){ }, destroy: function(){ - elmContainer.removeChild( ELM_WRAPPER); + elmContainer.removeChild( ELM_WRAPPER ); file && file.destroy(); file = elmContainer = onDownCallback = onEditorCallback = onViewerCallback = onActionCallback = viewerList = editorList = null; FINDER_ICON_POOL.push( instansce); @@ -978,6 +978,7 @@ pettanr.finder = ( function(){ instance = this; tree.addTreeEventListener( pettanr.file.TREE_EVENT.UPDATE, draw ); + ELM_CONTAINER.appendChild( elmContainer ); function draw( _w, _h ){ w = Type.isFinite( _w ) === true ? _w : w; @@ -1057,20 +1058,16 @@ pettanr.finder = ( function(){ this.init = function(){ //$( elmLocation).click( onHeadClick); //$( elmContainer).click( onBodyClick); - var position = pettanr.util.getAbsolutePosition( elmLocation); + var position = pettanr.util.getAbsolutePosition( elmLocation ); headX = position.x; headY = position.y; bodyY = pettanr.util.getAbsolutePosition( elmBody ).y; delete instance.init; } - this.onOpen = function( _w, _h, _option ){ - instance.init && instance.init(); - draw( _w, _h ); - } - this.onClose = function(){ - return true; - } this.onPaneResize = function( _w, _h ){ + instance.init && instance.init(); + draw( _w, _h ); + w = _w; h = _h; elmBody.style.height = ( _h - headH ) + 'px'; @@ -1108,7 +1105,9 @@ pettanr.finder = ( function(){ init: function(){ }, - createFinder: function( _elmTarget, _tree, _header, _footer ){ + createFinder: function( _applicationReference, _elmTarget, _tree, _header, _footer ){ + if( pettanr.view.isApplicationReference( _applicationReference ) === false ) return; + var _finder = new FinderClass( _elmTarget, _tree, _header, _footer ); FINDER_ARRAY.push( _finder ); return _finder; @@ -1294,7 +1293,8 @@ pettanr.driver = ( function(){ name: 'My Comics', type: pettanr.file.FILE_TYPE.FOLDER, children: [], - driver: Driver + driver: Driver, + id: MyAuthorID }, FILE_DATA_LATEST_COMICS = { name: 'Latest Comics', @@ -1306,7 +1306,8 @@ pettanr.driver = ( function(){ type: pettanr.file.FILE_TYPE.FOLDER, children: [], driver: Driver, - json: pettanr.CONST.URL_ORIGINAL_PICTURES_JSON + json: pettanr.CONST.URL_ORIGINAL_PICTURES_JSON, + id: MyArtistID }, FILE_DATA_AUTHOR_ROOT = { name: 'Authors', @@ -1506,7 +1507,11 @@ pettanr.driver = ( function(){ if( _artist){ _data.artist = _artist = buildFileData( _artist, FILE_DATA_ARTIST_ROOT ); addChildData( _artist, _data ); - _artist.id === MyArtistID && addChildData( FILE_DATA_MY_PICTURES_ROOT, _data ); + if( _artist.id === MyArtistID ){ + addChildData( FILE_DATA_MY_PICTURES_ROOT, _data ); + //FILE_DATA_MY_PICTURES_ROOT.type = pettanr.driver.FILE_TYPE.ARTIST; + //FILE_DATA_MY_PICTURES_ROOT.id = MyArtistID; + } } } return _data; @@ -1549,6 +1554,9 @@ pettanr.driver = ( function(){ _getAPI: function(){ return FileAPI; }, + _getMyPicturesData: function(){ + return FILE_DATA_MY_PICTURES_ROOT; + }, FILE_TYPE: { COMIC: FileAPI.createFileTypeID(), PANEL: FileAPI.createFileTypeID(), @@ -1588,12 +1596,12 @@ pettanr.cabinet = pettanr.view.registerApplication( function(){ this.displayName = 'Comic list'; this.ID = 'Comiclist'; this.rootElement = elmContainer; - this.onOpen = function( _w, _h, _option ){ - finder = finder || pettanr.finder.createFinder( elmContainer, pettanr.driver.createComicTree() ); - finder.open( _w, _h - pageHeaderH, _option ); + this.onOpen = function( _w, _h ){ + finder = finder || pettanr.finder.createFinder( pettanr.cabinet, elmContainer, pettanr.driver.createComicTree() ); + finder.resize( _w, _h - pageHeaderH ); } this.onClose = function(){ - finder.close(); + // finder.close(); } this.onPaneResize = function( _w, _h){ finder.resize( _w, _h - pageHeaderH ); @@ -1610,12 +1618,12 @@ pettanr.gallery = pettanr.view.registerApplication( function(){ this.displayName = 'Pictures'; this.ID = 'pictures'; this.rootElement = elmContainer; - this.onOpen = function( _w, _h, _option ){ - finder = finder || pettanr.finder.createFinder( elmContainer, pettanr.driver.createPictureTree() ); - finder.open( _w, _h - pageHeaderH, _option ); + this.onOpen = function( _w, _h ){ + finder = finder || pettanr.finder.createFinder( pettanr.gallery, elmContainer, pettanr.driver.createPictureTree() ); + finder.resize( _w, _h - pageHeaderH ); } this.onClose = function(){ - finder.close(); + // finder.close(); } this.onPaneResize = function( _w, _h){ finder.resize( _w, _h - pageHeaderH ); @@ -1858,9 +1866,9 @@ pettanr.premiumSatge = pettanr.view.registerApplication( function(){ var _data, _artistID = -1; if( pettanr.driver.isPettanrFileInstance( _ARTISTIDorFILE ) === true ){ - if( _ARTISTIDorFILE.getType() === pettanr.driver.FILE_TYPE.ARTIST ){ - _data = pettanr.driver._getAPI().getFileData( _ARTISTIDorFILE ); - _artistID = _data !== null ? _data.id || 0 : -1; + _data = pettanr.driver._getAPI().getFileData( _ARTISTIDorFILE ); + if( _ARTISTIDorFILE.getType() === pettanr.driver.FILE_TYPE.ARTIST || pettanr.driver._getMyPicturesData() === _data ){ + _artistID = _data.id || -1; } } else if( Type.isNumber( _ARTISTIDorFILE ) === true ){ diff --git a/public/assets/work.js b/public/assets/work.js index 84e4a214..8433a9a8 100644 --- a/public/assets/work.js +++ b/public/assets/work.js @@ -1,6 +1,6 @@ /* * pettanR work.js - * version 0.4.19 + * version 0.4.21 * * author: * itozyun @@ -881,8 +881,8 @@ pettanr.editor = pettanr.view.registerApplication( function(){ delete this.onInit; }, onOpen: function( _w, _h){ - finder = finder || pettanr.finder.createFinder( document.getElementById( 'image-exproler-container'), pettanr.driver.createPictureTree()); - finder.open( _w, _h ); + finder = finder || pettanr.finder.createFinder( pettanr.editor, document.getElementById( 'image-exproler-container'), pettanr.driver.createPictureTree()); + finder.resize( _w, _h ); }, onResize: function( _w, _h ){ finder.resize( _w, _h ); @@ -3145,7 +3145,7 @@ pettanr.comicConsole = pettanr.view.registerApplication( function(){ this.MIN_WIDTH = 320; this.MIN_HEIGHT = 320; this.init = function(){ - instance.jqWrap = jqWrap = $( '#comic-console-wrapper').hide(); + jqWrap = $( '#comic-console-wrapper').hide(); $( '#comic-console-post-button').click( clickOK ); $( '#comic-console-cancel-button').click( clickCancel ); @@ -3158,7 +3158,6 @@ pettanr.comicConsole = pettanr.view.registerApplication( function(){ delete instance.init; } - this.jqWrap = null; this.onOpen = function( w, h ){ instance.init && instance.init(); @@ -3187,8 +3186,8 @@ pettanr.comicConsole = pettanr.view.registerApplication( function(){ this.onPaneResize = function( _windowW, _windowH){ jqWrap.css( { - left: Math.floor( ( _windowW -jqWrap.width()) /2), - top: Math.floor( ( _windowH -jqWrap.height()) /2) + left: Math.floor( ( _windowW - jqWrap.width()) /2), + top: Math.floor( ( _windowH - jqWrap.height()) /2) } ); } @@ -3315,13 +3314,12 @@ pettanr.uploadConsole = pettanr.view.registerApplication( function(){ this.MIN_WIDTH = 320; this.MIN_HEIGHT = 320; this.init = function(){ - instance.jqWrap = jqWrap = $( '#upload-console-wrapper').hide(); + jqWrap = $( '#upload-console-wrapper').hide(); $( '#upload-console-post-button').click( clickOK ); $( '#upload-console-cancel-button').click( clickCancel ); delete instance.init; } - this.jqWrap = null; this.onOpen = function( w, h){ instance.init && instance.init(); /* @@ -3469,13 +3467,12 @@ pettanr.panelConsole = pettanr.view.registerApplication( function(){ this.MIN_WIDTH = 320; this.MIN_HEIGHT = 320; this.init = function(){ - instance.jqWrap = jqWrap = $( '#panel-console-wrapper').hide(); + jqWrap = $( '#panel-console-wrapper').hide(); $( '#panel-console-post-button').click( clickOK ); $( '#panel-console-cancel-button').click( clickCancel ); delete instance.init; } - this.jqWrap = null; this.onOpen = function( w, h ){ instance.init && instance.init(); /* @@ -3623,13 +3620,12 @@ pettanr.artistConsole = pettanr.view.registerApplication( function(){ this.MIN_WIDTH = 320; this.MIN_HEIGHT = 320; this.init = function(){ - instance.jqWrap = jqWrap = $( '#artist-console-wrapper').hide(); + jqWrap = $( '#artist-console-wrapper').hide(); $( '#artist-console-post-button').click( clickOK ); $( '#artist-console-cancel-button').click( clickCancel ); delete instance.init; } - this.jqWrap = null; this.onOpen = function( w, h ){ instance.init && instance.init(); /* @@ -3696,19 +3692,18 @@ pettanr.outputConsole = pettanr.view.registerApplication( function(){ this.MIN_WIDTH = 320; this.MIN_HEIGHT = 320; this.init = function(){ - instance.jqWrap = jqWrap = $( '#output-console-wrapper').hide(); + jqWrap = $( '#output-console-wrapper').hide(); jqOutputArea = $( '#output-area'); delete instance.init; } - this.jqWrap = null; this.onOpen = function( _w, _h, _text ){ instance.init && instance.init(); jqWrap.show(); - instance.onWindowResize( _w, _h ); + instance.onPaneResize( _w, _h ); jqOutputArea.val( _text).focus(); } - this.onWindowResize = function( _w, _h){ + this.onPaneResize = function( _w, _h){ jqWrap.css( { left: Math.floor( ( _w -jqWrap.width()) /2), -- 2.11.0