/*\r
* pettanR common.js\r
- * version 0.4.15\r
+ * version 0.4.16\r
* \r
* author: itozyun\r
*/\r
var location = document.location.pathname,\r
isWorkPage = document.location.href.indexOf( 'http:\/\/localhost:3000\/' ) === 0 ||\r
location.indexOf( pettanr.CONST.PETTANR_ROOT_PATH ) === 0 ||\r
- location.indexOf( '\/work.html') !== -1 ||\r
- location.indexOf( '\work.html') !== -1,\r
+ location.indexOf( '\/work.html') !== -1,\r
deep = location.indexOf( '\/diary\/') !== -1 ||\r
location.indexOf( '\/test\/') !== -1 ||\r
location.indexOf( '\/help\/') !== -1 ||\r
LoginUserNavi;\r
\r
if( isWorkPage === false){\r
- LoginUserNavi = ( function(){\r
- var _body = document.body,\r
- _root = document.getElementsByTagName( 'html' )[ 0 ],\r
- filter,\r
- iframe, visible = false;\r
- return {\r
- show: function(){\r
- document.location.href = [\r
- deep === true ? '../' : '',\r
- 'work.html',\r
- typeof viewIndex === 'number' ? '?view=' + viewIndex : ''\r
- ].join( '');\r
- },\r
- hide: function(){}\r
- }\r
- })();\r
- } else {\r
- LoginUserNavi = ( function(){\r
- return {\r
- show: function(){\r
- var i = pettanr.util.getChildIndex( this.parentNode, this );\r
- i !== -1 && pettanr.view.show( i );\r
- return false;\r
- },\r
- hide: function(){}\r
- }\r
- })();\r
-\r
- if( pettanr.IS_IFRAME === true){\r
- var _nodes = document.getElementsByTagName( 'a'),\r
- _a, _href;\r
- for(var i=0, l = _nodes.length; i<l; i++){\r
- _a = _nodes[ i];\r
- _href = _a.href.split('?')[0].split('#')[0];\r
- if( pettanr.util.getAbsolutePath( _href) !== location) _a.target = '_parent';\r
- }\r
+ LoginUserNavi = {\r
+ show: function(){\r
+ var i = pettanr.util.getChildIndex( this.parentNode, this );\r
+ document.location.href = [\r
+ deep === true ? '../' : '',\r
+ 'work.html',\r
+ typeof i === 'number' ? '?view=' + i : ''\r
+ ].join( '');\r
+ return false;\r
+ },\r
+ hide: function(){}\r
}\r
- \r
- if( pettanr.DEBUG === true){\r
- var elmDl = document.getElementById( 'useragent'),\r
- elmDt, elmDd,\r
- data = {\r
- pettanR: pettanr.version,\r
- ua: navigator.userAgent,\r
- platform: navigator.platform,\r
- appVersion: navigator.appVersion,\r
- appCodeName:navigator.appCodeName,\r
- appName: navigator.appName,\r
- language: navigator.browserLanguage || navigator.language,\r
- ActiveX: pettanr.ua.ACTIVEX\r
- },\r
- ua = pettanr.ua;\r
- if( ua.IE){\r
- //data.ua = 'Internet Explorer';\r
- data.version = ua.IE;\r
- if( ua.ieVersion >= 8) data.RenderingVersion = ua.ieRenderingVersion;\r
- data.browserType = ua.STANDALONE === true ? 'Standalone' : 'bundle';\r
- if( ua.ieVersion < 9) {\r
- data.vml = ua.VML;\r
- } else {\r
- data.svg = ua.SVG;\r
- }\r
- }\r
- data.RenderingMode = ua.isStanderdMode === true ? 'Standerd' : 'Quirks';\r
- \r
- for( var key in data){\r
- elmDt = document.createElement( 'dt');\r
- elmDt.innerHTML = key;\r
- elmDd = document.createElement( 'dd');\r
- elmDd.innerHTML = '' + data[ key];\r
- if( !data[ key]) elmDd.style.color = 'red';\r
- elmDl.appendChild( elmDt);\r
- elmDl.appendChild( elmDd);\r
- }\r
- } else {\r
- var _debug = document.getElementById( 'debug');\r
- if( _debug){\r
- pettanr.util.removeAllChildren( _debug);\r
- _debug.parentNode.removeChild( _debug);\r
- }\r
+ } else {\r
+ LoginUserNavi = {\r
+ show: function(){\r
+ var i = pettanr.util.getChildIndex( this.parentNode, this );\r
+ i !== -1 && pettanr.view.show( i );\r
+ return false;\r
+ },\r
+ hide: function(){}\r
}\r
}\r
\r
- /* global-navi */\r
- var navi = document.getElementById('global-navi'),\r
- origin = document.createElement('a'),\r
- items = ( function(){\r
- var ret = ['Home', 'Comic list', 'Picture', 'Setting'];\r
- pettanr.DEBUG === true && ret.push( 'debug');\r
- return ret;\r
- })(),\r
- item;\r
- origin.href = '#';\r
- for(var i=0, l = items.length; i<l; ++i){\r
- item = origin.cloneNode( true);\r
- item.appendChild( document.createTextNode( items[ i]) );\r
- item.onclick = LoginUserNavi.show;\r
- navi.appendChild( item);\r
- }\r
- navi.style.width = ( ( item.offsetWidth || 80) * l) +'px';\r
- location = origin = item = null;\r
- \r
/* debug info */\r
// ua version, lang, os, plugin ( vml, svg), standerdmode, balloon, rimg\r
\r
*/\r
\r
var jqWindow,\r
- funcArray,\r
- HOME_ID = 'entrance',\r
- VIEW_ID_ARRAY = [ HOME_ID, 'cabinet', 'gallery', 'backyard'],\r
- elmCurrent,\r
- currentView,\r
- currentID = ( function( _view){\r
- var _viewID;\r
- \r
- if( typeof _view === 'number' && _view < VIEW_ID_ARRAY.length){\r
- _viewID = VIEW_ID_ARRAY[ _view];\r
- } else\r
- if( typeof _view === 'string'){\r
- _viewID = _view;\r
- } else {\r
- _viewID = HOME_ID;\r
- }\r
-\r
- if( document.getElementById( _viewID)){\r
- return _viewID;\r
- }\r
- return HOME_ID;\r
- })( pettanr.URL_PARAMS.view);\r
- \r
- pettanr.DEBUG === true && VIEW_ID_ARRAY.push( 'debug');\r
- \r
- open();\r
+ APPLICATION_LIST = [],\r
+ LUNCHER_APPLICATION_LIST = [],\r
+ navi = document.getElementById('global-navi'),\r
+ currentApplication;\r
\r
function onWindowResize(){\r
- var _fn,\r
- l = funcArray.length,\r
- w = jqWindow.width(),\r
+ var w = jqWindow.width(),\r
h = jqWindow.height();\r
- //for( var i=0; i<l; ++i){\r
- // _fn = funcArray[ i];\r
- // _fn.onWindowResize && _fn.onWindowResize( w, h);\r
- //}\r
- currentView && currentView.onWindowResize && currentView.onWindowResize( w, h);\r
+ currentApplication && currentApplication.onWindowResize && currentApplication.onWindowResize( w, h);\r
pettanr.overlay.currentID !== null && pettanr.overlay.onWindowResize( w, h);\r
}\r
- function open( _option ){\r
- if( isWorkPage === false) return;\r
- \r
- var _elm = document.getElementById( currentID);\r
- if( elmCurrent) elmCurrent.style.display = 'none';\r
- _elm.style.display = 'block';\r
- elmCurrent = _elm;\r
- \r
- var nodesA = navi.getElementsByTagName( 'a') || [],\r
- l = nodesA.length,\r
- _a;\r
- for(var i=0; i<l; ++i){\r
- if( nodesA[ i]){\r
- nodesA[ i].className = VIEW_ID_ARRAY[ i] === currentID ? 'current' : '';\r
- }\r
- }\r
- \r
- if( !pettanr.view || pettanr.view.init !== undefined) return;\r
- currentView = pettanr[ currentID];\r
- if( !currentView) return;\r
- typeof currentView.onOpen === 'function' && currentView.onOpen( jqWindow.width(), jqWindow.height(), _option );\r
- // setTimeout( onWindowResize, 0);\r
- }\r
\r
var AbstractBasicPane = function(){\r
- this.UID = ''; // element の ID と一致\r
- this.elm = null;\r
+ this.rootElement = null;\r
this.onOpen = function( _w, _h, _option ){};\r
this.onClose = function(){ return true; } // false の場合、close の拒否 \r
this.onPaneResize = function( _w, _h ){}\r
this.resize = function( _w, _h ){\r
if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){\r
- if( Type.isHTMLElement( this.elm ) === true ){\r
+ if( Type.isHTMLElement( this.rootElement ) === true ){\r
// 小さすぎる!、と表示\r
}\r
return;\r
this.MIN_WIDTH = 240;\r
this.MIN_HEIGHT = 240;\r
}\r
+ var AbstractApplication = function(){\r
+ this.displayName = 'app name';\r
+ this.ID = 'app id';\r
+ }\r
+ AbstractApplication.prototype = new AbstractBasicPane();\r
\r
return {\r
- init: function( _funcArray){\r
- funcArray = _funcArray;\r
+ init: function( _funcArray ){\r
jqWindow = pettanr.jqWindow();\r
jqWindow.resize( onWindowResize);\r
\r
- currentView = currentView || pettanr[ currentID ];\r
var _option = {}; // urlパラメータ\r
- currentView && typeof currentView.onOpen === 'function' && currentView.onOpen( jqWindow.width(), jqWindow.height(), _option );\r
\r
- // setTimeout( onWindowResize, 100);\r
+ pettanr.view.show( pettanr.URL_PARAMS.view || 0, _option );\r
\r
delete pettanr.view.init;\r
},\r
- show: function( _viewID){\r
- if( typeof _viewID === 'number' && _viewID < VIEW_ID_ARRAY.length){\r
- _viewID = VIEW_ID_ARRAY[ _viewID];\r
+ show: function( APPLICATIONorINDEX, _option ){\r
+ if( isWorkPage === false ) return;\r
+ \r
+ var _applicetion,\r
+ _elm, i, l,\r
+ nodesA = navi.getElementsByTagName( 'a') || [],\r
+ _index = -1;\r
+ if( typeof APPLICATIONorINDEX === 'number' && APPLICATIONorINDEX < LUNCHER_APPLICATION_LIST.length){\r
+ _applicetion = LUNCHER_APPLICATION_LIST[ APPLICATIONorINDEX ];\r
+ } else\r
+ if( typeof APPLICATIONorINDEX === 'string' ){\r
+ for( i=0, l=LUNCHER_APPLICATION_LIST.length; i<l; ++i ){\r
+ if( APPLICATIONorINDEX === APPLICATION_LIST[ i ].ID ){\r
+ _applicetion = APPLICATION_LIST[ i ];\r
+ break;\r
+ }\r
+ }\r
+ } else\r
+ if( pettanr.view.isApplicationInstance( APPLICATIONorINDEX ) === true ){\r
+ _applicetion = APPLICATIONorINDEX;\r
} else\r
- if( typeof _viewID === 'string'){\r
- _viewID = _viewID;\r
+ if( !currentApplication ){\r
+ _applicetion = LUNCHER_APPLICATION_LIST[ 0 ];\r
} else {\r
- _viewID = HOME_ID;\r
+ return;\r
}\r
- for( var key in pettanr.view){\r
- if( pettanr.view[ key] === _viewID){\r
- if( currentID !== _viewID && document.getElementById( _viewID)){\r
- this.currentID = currentID = _viewID;\r
- open();\r
- }\r
- return;\r
+ \r
+ if( !_applicetion ) return;\r
+ for( i=0, l=LUNCHER_APPLICATION_LIST.length; i<l; ++i ){\r
+ if( _applicetion === LUNCHER_APPLICATION_LIST[ i ] ){\r
+ _index = i;\r
+ break;\r
}\r
}\r
- alert( _viewID);\r
+ if( _index !== -1 ){\r
+ for( i=0, l=nodesA.length; i<l; ++i ){\r
+ nodesA[ i ].className = _index === i ? 'current' : '';\r
+ }\r
+ }\r
+ \r
+ if( currentApplication === _applicetion ) return;\r
+ \r
+ if( currentApplication ){\r
+ _elm = currentApplication.rootElement;\r
+ if( _elm ){\r
+ _elm.style.display = 'none';\r
+ }\r
+ typeof currentApplication.onClose === 'function' && currentApplication.onClose();\r
+ }\r
+ currentApplication = _applicetion;\r
+ \r
+ _elm = _applicetion.rootElement;\r
+ if( _elm ){\r
+ _elm.style.display = 'block';\r
+ }\r
+ typeof _applicetion.onOpen === 'function' && _applicetion.onOpen( jqWindow.width(), jqWindow.height(), _option );\r
+ \r
+ this.currentID = _applicetion.ID;\r
},\r
registerAsBasicPane: function( _basicPane ){\r
if( pettanr.view.isBasicPaneInstance( _basicPane ) === true ) return;\r
_basicPane.prototype = new AbstractBasicPane();\r
},\r
+ registerApplication: function( _application, _addToLancher ){\r
+ if( pettanr.view.isApplicationInstance( _application ) === true ) return;\r
+ _application.prototype = new AbstractApplication();\r
+ APPLICATION_LIST.push( _application );\r
+ if( _addToLancher === true ){\r
+ pettanr.view.addApplicationToLancher( _application );\r
+ }\r
+ },\r
+ addApplicationToLancher: function( _application ){\r
+ // if( pettanr.view.isApplicationInstance( _application ) === false ) return;\r
+ \r
+ if( pettanr.util.getIndex( LUNCHER_APPLICATION_LIST, _application ) !== -1 ) return;\r
+ LUNCHER_APPLICATION_LIST.push( _application );\r
+\r
+ var item = document.createElement('a');\r
+ navi.appendChild( item );\r
+ navi.style.width = ( ( item.offsetWidth || 80 ) * LUNCHER_APPLICATION_LIST.length ) + 'px';\r
+ item.href = '#';\r
+ item.appendChild( document.createTextNode( _application.displayName ));\r
+ item.onclick = LoginUserNavi.show;\r
+ },\r
isBasicPaneInstance: function( _basicPane ){\r
return _basicPane instanceof AbstractBasicPane;\r
},\r
- currentID: currentID,\r
- HOME: HOME_ID,\r
- COMICS: VIEW_ID_ARRAY[ 1],\r
- IMAGES: VIEW_ID_ARRAY[ 2],\r
- SETTING: VIEW_ID_ARRAY[ 3],\r
- DEBUG: VIEW_ID_ARRAY[ 4],\r
+ isApplicationInstance: function( _application ){\r
+ return pettanr.util.getIndex( APPLICATION_LIST, _application ) !== -1;\r
+ // return _application instanceof AbstractApplication;\r
+ },\r
+ currentID: null,\r
EDITOR: 'editor',\r
OVERLAY: 'overlay'\r
}\r
/*
* pettanR system.js
- * version 0.4.15
+ * version 0.4.16
*
* author:
* itozyun
}
}
},
- fileEventRellay: function( _targetFile, _targetTree, _event){
- var _uid = _targetTree.getUID(),
- _access = TREE_ACCESS_ARRAY[ _uid ],
- _data = FILE_CONTROLER.getFileData( _targetFile ),
+ getTreeAccess: function(){
+
+ },
+ fileEventRellay: function( _uid, _event ){
+ var _fileAccess = FILE_CONTROLER.getFileDataAccess( _uid );
+ if( _fileAccess === null ) return;
+ var _treeUID = _fileAccess.TREE.getUID(),
+ _treeAccess = TREE_ACCESS_ARRAY[ _treeUID ],
+ _data = _fileAccess.DATA,
_tree;
- _access && _access.dispatchFileEvent( _event );
+ if( !_treeAccess ) return;
+ _treeAccess.dispatchFileEvent( _event );
for( var i=0, l = TREE_ARRAY.length; i<l; ++i){
- if( i !== _uid){
+ if( i !== _treeUID ){
_tree = TREE_ARRAY[ i ];
if( FILE_CONTROLER.getFileData( _tree.getCurrentFile() ) === _data ){
- _access = TREE_ACCESS_ARRAY[ _tree.getUID() ];
- _access && _access.dispatchFileEvent( _event);
+ _treeAccess = TREE_ACCESS_ARRAY[ _tree.getUID() ];
+ _treeAccess && _treeAccess.dispatchFileEvent( _event );
}
}
}
}
}
- var TreeClass = function( ROOTFILE_DATA){
- var UID = TREE_ACCESS_ARRAY.length,
- PARENT_FILE_RESITER = [],
+ var TreeClass = function( rootFileData ){
+ var PARENT_FILE_RESITER = [],
ACCESS = {
- dispatchFileEvent: dispatchFileEvent,
- destroy: onDestroy
+ dispatchFileEvent: dispatchFileEvent
},
EVENT_LISTENER_ARRAY = [],
rootFile,
- rootFileData,
currentFile,
- currentFileData,
instance;
- TREE_ACCESS_ARRAY.push( ACCESS);
+ TREE_ACCESS_ARRAY.push( ACCESS );
- function onDestroy(){
-
- }
-
- function dispatchFileEvent( e){
+ function dispatchFileEvent( e ){
var _eventType = e.eventType,
_targetFile = e.targetFile,
_uid = _targetFile.getUID(),
_ticket, _type, _callback;
- for(var i=0, l = EVENT_LISTENER_REGISTER.length; i<l; ++i){
- _ticket = EVENT_LISTENER_REGISTER[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);
+ if( _eventType === _type && _uid === _ticket.fileUID ){
+ _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);
+ if( _type === pettanr.file.TREE_EVENT.UPDATE && _eventType === pettanr.file.FILE_EVENT.GET_SEQENTIAL_FILES ){
+ _callback( _eventType, _targetFile );
}
}
}
return {
init: function(){
instance = this;
- currentFile = rootFile = new FileClass( this, null, ROOTFILE_DATA);
+ currentFile = rootFile = new FileClass( instance, null, rootFileData );
// rootFile.init();
currentFile.getSeqentialFiles();
delete this.init;
},
- getUID: function(){ return UID},
+ getUID: function(){
+ return pettanr.util.getIndex( TREE_ACCESS_ARRAY, ACCESS );
+ },
getRootFile : function(){
return rootFile;
},
},
down: function( _index){
if( typeof _index !== 'number' || _index < 0 || _index >= currentFile.getChildFileLength()) return;
- PARENT_FILE_RESITER.unshift( currentFile);
- currentFile = currentFile.getChildFileByIndex( _index);
+ PARENT_FILE_RESITER.unshift( currentFile );
+ currentFile = currentFile.getChildFileByIndex( _index );
currentFile.getSeqentialFiles();
return currentFile;
},
up: function( _index){
var l = PARENT_FILE_RESITER.length;
if( l === 0) return null;
+
+ if( currentFile ){
+ var _currentFile = currentFile;
+ currentFile = null;
+ _currentFile.destroy();
+ }
if( typeof _index === 'number'){
if( _index >= l) return null;
- currentFile = this.getParentFileAt( _index);
+ currentFile = this.getParentFileAt( _index );
PARENT_FILE_RESITER.splice( 0, l -_index);
} else {
currentFile = PARENT_FILE_RESITER.shift();
FILE_CONTROLER.removeEventListener( null, _eventType, _callback);
},
destroy: function(){
- FILE_CONTROLER.destroyTree( UID);
+ FILE_CONTROLER.destroyTree( instance.getUID() );
+ // removeEvent
+ var _currentFile = currentFile;
+ currentFile = rootFile = rootFileData = null;
+ _currentFile.destroy();
+ while( PARENT_FILE_RESITER.length > 0 ){
+ _currentFile = PARENT_FILE_RESITER.shift();
+ _currentFile.destroy();
+ }
+ instance = null;
}
}
};
* 他の tree も data の共通する currentFile に対してのみは、file の変更イベントを受け取って流す.
*/
- var FileClass = function( TREE, parentFile, data){
+ var FileClass = function( tree, parentFile, data ){
var uid = pettanr.util.getIndex( FILEDATA_RESITER, data ),
instance = this;
FILEDATA_ACCESS.push(
{
+ TREE: tree,
+ parentFile: parentFile,
DATA: data,
- updateParent: updateParent,
dispatchFileEvent: dispatchEvent
}
);
-
- function updateParent( _parent){
- parentFile = _parent;
- }
- function dispatchEvent( e){
- FILE_CONTROLER.fileEventRellay( instance, TREE, e);
- }
- /* grobal Methods */
-
+ tree = parentFile = data = null;
+
+ function dispatchEvent( e ){
+ FILE_CONTROLER.fileEventRellay( uid, e );
+ }
this.getUID = function(){
return uid;
}
- /*
- * ファイル構造は TRON のような ハイパーリンク方式 だが、文脈上の 親ファイルが存在する.その親ファイルを使う操作は.prototype に置く事ができない.
- * 同様に TREE を使う操作も .prototype に置く事ができない.
- */
- this.getChildFileByIndex = function( _index){
- var _children = FILE_CONTROLER.getChildren( instance );
- if( typeof _index !== 'number' || _index < 0 || typeof _children.length !== 'number' || _index >= _children.length) return null;
- var _file = new FileClass( TREE, this, _children[ _index]);
- // _file.init();
- return _file;
- }
- this.move = function( _newFolder, _newIndex, opt_callback){
- TREE.move( parentFile, UID, _newFolder, _newIndex, opt_callback);
- }
- this.replace = function( _newIndex, opt_callback){
- TREE.replace( parentFile, UID, _newIndex, opt_callback);
- }
- this.destroy = function(){
- var _access = FILE_CONTROLER.getFileDataAccess( instance );
- _index = getChildIndex( FILEDATA_ACCESS, _access );
- if( _index === -1 || _access === null) return;
- FILEDATA_ACCESS.splice( _index, 1);
- TREE = parentFile = data = null;
- delete _access.DATA;
- delete _access.updateParent;
- delete _access.dispatchFileEvent;
- }
};
FileClass.prototype = {
return FileDriverBase.getSummary( this);
},
isWritable: function(){
- return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.WRITE);
+ return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.WRITE );
},
isSortable: function(){
- return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.SORT);
+ return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.SORT );
},
isCreatable: function(){
- return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.CREATE);
+ return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.CREATE );
},
isRenamable: function(){
- return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.RENAME);
+ return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.RENAME );
+ },
+ isDeletable: function(){
+ return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.DELETE );
},
read: function(){
// simpleDeepCopy
- return false;
+ var driver = FILE_CONTROLER.getDriver( this );
+ if( typeof driver.read === 'function'){
+ return driver.read( this );
+ }
+ return FileDriverBase.read( this );
},
- write: function( _newName, _newData){
- return false;
+ write: function( _newName, _newData ){
+ var driver = FILE_CONTROLER.getDriver( this );
+ if( typeof driver.write === 'function'){
+ return driver.write( this, _newName, _newData );
+ }
+ return FileDriverBase.write( this, _newName, _newData );
},
- viwerApplicationList: function(){
+ viewerApplicationList: function(){
var driver = FILE_CONTROLER.getDriver( this );
- if( typeof driver.viwerApplicationList === 'function'){
- return driver.viwerApplicationList( this );
+ if( typeof driver.viewerApplicationList === 'function'){
+ return driver.viewerApplicationList( this );
}
- return FileDriverBase.viwerApplicationList( this );
+ return FileDriverBase.viewerApplicationList( this );
},
editorApplicationList: function(){
- var driver = FILE_CONTROLER.editorApplicationList( this );
+ var driver = FILE_CONTROLER.getDriver( this );
if( typeof driver.editorApplicationList === 'function'){
return driver.editorApplicationList( this );
}
},
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, this, _children[ _index ]);
+ // _file.init();
+ return _file;
+ },
+ move: function( _newFolder, _newIndex, opt_callback ){
+ var _access = FILE_CONTROLER.getFileDataAccess( this );
+ _access.TREE.move( _access.parentFile, this.getUID(), _newFolder, _newIndex, opt_callback );
+ },
+ replace: function( _newIndex, opt_callback){
+ var _access = FILE_CONTROLER.getFileDataAccess( this );
+ _access.TREE.replace( _access.parentFile, this.getUID(), _newIndex, opt_callback);
+ },
+ destroy: function(){
+ var _access = FILE_CONTROLER.getFileDataAccess( this );
+ var TREE = _access.TREE;
+ if( TREE.getCurrentFile() === this ) return;
+ if( TREE.getRootFile() === this ) return;
+ for( var i=0, l = TREE.hierarchy(); i<l; ++i ){
+ if( TREE.getParentFileAt( i ) === this ){
+ return;
+ }
+ }
+ var _index = pettanr.util.getIndex( FILEDATA_ACCESS, _access );
+ if( _index === -1 || _access === null ) return;
+ // event の 削除
+ FILEDATA_ACCESS.splice( _index, 1 );
+ delete _access.DATA;
+ delete _access.TREE;
+ delete _access.parentFile;
+ delete _access.dispatchFileEvent;
}
}
}
return '';
},
- getUpdatePolicy: function( _file){
+ getUpdatePolicy: function( _file ){
// debug用 全てのメニューを許可
- return pettanr.file.FILE_UPDATE_POLICY.SRWC;
+ return pettanr.file.FILE_UPDATE_POLICY.DSRWC;
},
- read: function(){
+ read: function( _file ){
+ var _data = FILE_CONTROLER.getFileData( _file ),
+ _type = _data.type;
return false;
},
- write: function( _newName, _newData){
+ write: function( _file, _newName, _newData){
+ var _data = FILE_CONTROLER.getFileData( _file ),
+ _type = _data.type;
return false;
},
- viwerApplicationList: function(){
+ viewerApplicationList: function(){
return [];
},
editorApplicationList: function(){
BROKEN: 4
},
FILE_UPDATE_POLICY: {
- ____: parseInt( '0000', 2),
- ___C: parseInt( '0001', 2), // hasCreateMenu
- __W_: parseInt( '0010', 2), // isWritable
- __WC: parseInt( '0011', 2), // isWritable
- _R__: parseInt( '0000', 2), // isRenamable
- _R_C: parseInt( '0101', 2), // hasCreateMenu
- _RW_: parseInt( '0110', 2), // isWritable
- _RWC: parseInt( '0111', 2), // isWritable
- S___: parseInt( '1000', 2), // childrenIsSortable
- S__C: parseInt( '1001', 2),
- S_W_: parseInt( '1010', 2),
- S_WC: parseInt( '1011', 2),
- SR__: parseInt( '1000', 2),
- SR_C: parseInt( '1101', 2),
- SRW_: parseInt( '1110', 2),
- SRWC: parseInt( '1111', 2),
+ _____: parseInt( '00000', 2),
+ ____C: parseInt( '00001', 2), // hasCreateMenu
+ ___W_: parseInt( '00010', 2), // isWritable
+ ___WC: parseInt( '00011', 2), // isWritable
+ __R__: parseInt( '00100', 2), // isRenamable
+ __R_C: parseInt( '00101', 2), // hasCreateMenu
+ __RW_: parseInt( '00110', 2), // isWritable
+ __RWC: parseInt( '00111', 2), // isWritable
+ _S___: parseInt( '01000', 2), // childrenIsSortable
+ _S__C: parseInt( '01001', 2),
+ _S_W_: parseInt( '01010', 2),
+ _S_WC: parseInt( '01011', 2),
+ _SR__: parseInt( '01100', 2),
+ _SR_C: parseInt( '01101', 2),
+ _SRW_: parseInt( '01110', 2),
+ _SRWC: parseInt( '01111', 2),
+ D____: parseInt( '10000', 2),
+ D___C: parseInt( '10001', 2), // hasCreateMenu
+ D__W_: parseInt( '10010', 2), // isWritable
+ D__WC: parseInt( '10011', 2), // isWritable
+ D_R__: parseInt( '10100', 2), // isRenamable
+ D_R_C: parseInt( '10101', 2), // hasCreateMenu
+ D_RW_: parseInt( '10110', 2), // isWritable
+ D_RWC: parseInt( '10111', 2), // isWritable
+ DS___: parseInt( '11000', 2), // childrenIsSortable
+ DS__C: parseInt( '11001', 2),
+ DS_W_: parseInt( '11010', 2),
+ DS_WC: parseInt( '11011', 2),
+ DSR__: parseInt( '11100', 2),
+ DSR_C: parseInt( '11101', 2),
+ DSRW_: parseInt( '11110', 2),
+ DSRWC: parseInt( '11111', 2),
CREATE: 1,
WRAITE: 2,
RENAME: 4,
- SORT: 8
+ SORT: 8,
+ DELETE: 16
},
TREE_EVENT: {
UPDATE: 'onTreeUpdate'
ELM_THUMBNAIL = pettanr.util.getElementsByClassName( ELM_WRAPPER, ICON_CLASSNAME )[0],
ELM_FILENAME = pettanr.util.getElementsByClassName( ELM_WRAPPER, 'finder-icon-filename' )[0],
ELM_DESCRIPTION = pettanr.util.getElementsByClassName( ELM_WRAPPER, 'finder-icon-summary' )[0],
- file, w, index, style, instansce, callback;
+ ELM_EDITOR_BUTTON = pettanr.util.getElementsByClassName( ELM_WRAPPER, 'finder-icon-console-editor-apps' )[0],
+ ELM_VIEWER_BUTTON = pettanr.util.getElementsByClassName( ELM_WRAPPER, 'finder-icon-console-viewer-apps' )[0],
+ ELM_ACTION_BUTTON = pettanr.util.getElementsByClassName( ELM_WRAPPER, 'finder-icon-console-action' )[0],
+ file, w, index, style, instansce,
+ onDownCallback, onEditorCallback, onViewerCallback, onActionCallback,
+ viewerList, editorList;
+ ELM_WRAPPER.onmouseover = onOver;
+ function onOver(){
+ ELM_WRAPPER.style.backgroundColor = '#eee';
+ }
+ ELM_WRAPPER.onmouseout = onOut;
+ function onOut(){
+ ELM_WRAPPER.style.backgroundColor = '';
+ }
- ELM_WRAPPER.onclick = onClick;
- function onClick(){
- callback( index);
+ ELM_WRAPPER.onclick = onDownClick;
+ function onDownClick(){
+ onDownCallback( index );
+ }
+ ELM_EDITOR_BUTTON.onclick = onEditorClick;
+ function onEditorClick(){
+ onEditorCallback( index );
+ }
+ ELM_VIEWER_BUTTON.onclick = onViwerClick;
+ function onViwerClick(){
+ onViewerCallback( index );
+ }
+ ELM_ACTION_BUTTON.onclick = onActionClick;
+ function onActionClick(){
+ onActionCallback( index );
}
-
function draw(){
var _thumb = file.getThumbnail();
- if( _thumb.image){
+ if( _thumb.image ){
ELM_THUMBNAIL.className = ICON_CLASSNAME + ' has-thumbnail';
ELM_THUMBNAIL.style.backgroundImage = [ 'url(', _thumb.image, ')'].join( '');
} else {
- ELM_THUMBNAIL.className = ICON_CLASSNAME + ' ' +_thumb.className;
+ ELM_THUMBNAIL.className = ICON_CLASSNAME + ' ' + _thumb.className;
ELM_THUMBNAIL.style.backgroundImage = '';
}
- ELM_FILENAME.innerHTML = file.getName();
- ELM_DESCRIPTION.innerHTML = file.getSummary();
+ ELM_FILENAME.firstChild.data = file.getName();
+ ELM_DESCRIPTION.firstChild.data = file.getSummary();
+
+ if( Type.isArray( viewerList ) === true && viewerList.length > 0 ){
+ ELM_VIEWER_BUTTON.style.display = '';
+ } else {
+ ELM_VIEWER_BUTTON.style.display = 'none';
+ };
+ if( Type.isArray( editorList ) === true && editorList.length > 0 ){
+ ELM_EDITOR_BUTTON.style.display = '';
+ } else {
+ ELM_EDITOR_BUTTON.style.display = 'none';
+ };
}
function resize(){
ELM_WRAPPER.style.top = (index * ICON_HEIGHT) +'px';
}
return {
- init: function( _file, _elmContainer, _w, _index, _style, _callback){
+ init: function( _file, _elmContainer, _w, _index, _style, _onDownCallback, _onEditorCallback, _onViewerCallback, _onActionCallback ){
instansce = this;
if( elmContainer !== _elmContainer){
_elmContainer.appendChild( ELM_WRAPPER);
elmContainer = _elmContainer;
}
if( file !== _file){
+ file && file.destroy();
file = _file;
+ viewerList = file.viewerApplicationList();
+ editorList = file.editorApplicationList();
draw();
}
if( index !== _index){
index = _index;
resize();
}
- callback = _callback;
+ onDownCallback = _onDownCallback;
+ onEditorCallback = _onEditorCallback;
+ onViewerCallback = _onViewerCallback;
+ onActionCallback = _onActionCallback;
},
elm: ELM_WRAPPER,
index: function( _index){
return style;
},
- onResize: function( w){
+ onResize: function( w ){
},
destroy: function(){
elmContainer.removeChild( ELM_WRAPPER);
- file = elmContainer = null;
+ file && file.destroy();
+ file = elmContainer = onDownCallback = onEditorCallback = onViewerCallback = onActionCallback = viewerList = editorList = null;
FINDER_ICON_POOL.push( instansce);
}
}
}
return {
- init: function( _file, _elmContainer, _index, _callback){
+ init: function( _file, _elmContainer, _index, _callback ){
instansce = this;
if( elmContainer !== _elmContainer){
_elmContainer.appendChild( ELM_WRAPPER);
destroy: function(){
elmContainer.removeChild( ELM_WRAPPER);
file = elmContainer = null;
- BREAD_OBJECT_POOL.push( this);
+ BREAD_OBJECT_POOL.push( this );
}
}
}
var FinderClass = function( ELM_CONTAINER, tree, header, footer ){
var ICON_ARRAY = [],
BREAD_ARRAY = [],
- elmContainer = ELM_ORIGIN_CONTAINER.cloneNode( true),
- elmLocation = elmContainer.getElementsByTagName( 'ul')[0],
- nodesDiv = elmContainer.getElementsByTagName( 'div'),
+ elmContainer = ELM_ORIGIN_CONTAINER.cloneNode( true ),
+ elmLocation = elmContainer.getElementsByTagName( 'ul' )[0],
+ nodesDiv = elmContainer.getElementsByTagName( 'div' ),
elmSidebarButton = nodesDiv[1],
elmStyleButton = nodesDiv[2],
elmActionButton = nodesDiv[3],
if( i < m){
BREAD_ARRAY[ i].init( _file, elmLocation, i, onHeadClick);
} else {
- BREAD_ARRAY.push( getBreadcrumb( _file, elmLocation, i, onHeadClick));
+ BREAD_ARRAY.push( getBreadcrumb( _file, elmLocation, i, onHeadClick ));
}
}
while( l < BREAD_ARRAY.length){
for( i=0; i<l; ++i){
if( i < m){
- ICON_ARRAY[ i].init( _file.getChildFileByIndex( i), elmBody, w, i, style, onBodyClick);
+ ICON_ARRAY[ i ].init( _file.getChildFileByIndex( i), elmBody, w, i, style, onDown, onEditor, onViwer, onAction );
} else {
- ICON_ARRAY.push( getFinderIcon( _file.getChildFileByIndex( i), elmBody, _w, i, style, onBodyClick));
+ ICON_ARRAY.push( getFinderIcon( _file.getChildFileByIndex( i), elmBody, _w, i, style, onDown, onEditor, onViwer, onAction ));
}
}
if( _file.getState() === pettanr.file.FILE_STATE.LOADING ){
}
}
}
- function onBodyClick( i){
- var l = ICON_ARRAY.length;
- if( i < l){
- var _file = tree.getCurrentFile().getChildFileByIndex( i);
+ function onDown( i ){
+ if( i < ICON_ARRAY.length ){
+ var _file = tree.getCurrentFile().getChildFileByIndex( i );
if( _file !== null && ( _file.getChildFileLength() !== -1 || _file.getType() === pettanr.file.FILE_TYPE.FOLDER)){
- tree.down( i);
+ tree.down( i );
draw( w, h );
}
}
}
+ function onEditor( i ){
+ if( i < ICON_ARRAY.length ){
+ var _file = tree.getCurrentFile().getChildFileByIndex( i );
+ }
+ }
+ function onViwer( i ){
+ if( i < ICON_ARRAY.length ){
+ var _file = tree.getCurrentFile().getChildFileByIndex( i );
+ }
+ }
+ function onAction( i ){
+ if( i < ICON_ARRAY.length ){
+ var _file = tree.getCurrentFile().getChildFileByIndex( i );
+
+ }
+ }
this.init = function(){
ELM_CONTAINER.appendChild( elmContainer);
pettanr.view.registerAsBasicPane( FinderClass );
- function getFinderIcon( _file, _elmContainer, w, index, style, callback){
+ function getFinderIcon( _file, _elmContainer, w, index, style, onDown, onEditor, onViwer, onAction){
var _icon;
if( FINDER_ICON_POOL.length > 0){
_icon = FINDER_ICON_POOL.shift();
} else {
_icon = new FinderIconClass();
}
- _icon.init( _file, _elmContainer, w, index, style, callback);
+ _icon.init( _file, _elmContainer, w, index, style, onDown, onEditor, onViwer, onAction );
return _icon;
}
if( _type === pettanr.driver.FILE_TYPE.AUTHOR ){
return [ _data.id , ':', _data.name, '先生' ].join( '');
}
- return _data.name + _data.type;
+ return _data.name;
},
getThumbnail: function( _file){
var _data = FileAPI.getFileData( _file),
}
return 'pettanR unknown file';
},
- viwerApplicationList: function( _file ){
+ viewerApplicationList: function( _file ){
var _data = FileAPI.getFileData( _file ),
_type = _data !== null ? _data.type : null;
return [];
editorApplicationList: function( _file ){
var _data = FileAPI.getFileData( _file ),
_type = _data !== null ? _data.type : null;
+ if( _type === pettanr.driver.FILE_TYPE.PANEL ){
+ return [ pettanr.editor ];
+ }
+ if( _type === pettanr.driver.FILE_TYPE.COMIC ){
+ return [ pettanr.editor, pettanr.comicConsole ];
+ }
return [];
}
},
FileAPI.createFolderUnderRoot( FILE_DATA_SERVICE_ROOT);
- function onLoadJson( _file, _json){
+ function onLoadJson( _file, _json ){
var _access = FileAPI.getFileDataAccess( _file),
_data = _access !== null ? _access.DATA : null,
l;
}
})();
+pettanr.entrance = {
+ displayName: 'Home',
+ rootElement: document.getElementById('entrance'),
+ onOpen: function( _w, _h, _option ){
+ var pageHeaderH = pettanr.util.getElementSize( document.getElementById('header') ).height;
+ document.getElementById('inner-wrapper').style.height = ( _h - pageHeaderH ) + 'px';
+ },
+ onClose: function(){
+ document.getElementById('inner-wrapper').style.height = '0px';
+ },
+ onWindowResize: function( _w, _h){
+ pettanr.entrance.onOpen( _w, _h );
+ }
+}
+pettanr.view.registerApplication( pettanr.entrance, true );
-pettanr.gallery = ( function(){
+pettanr.cabinet = ( function(){
var finder,
- elmContainer = document.getElementById( 'gallery'),
+ elmContainer = document.getElementById( 'cabinet'),
option,
pageHeaderH = pettanr.util.getElementSize( document.getElementById('header') ).height;
+
return {
+ displayName: 'Comic list',
+ rootElement: elmContainer,
init: function( _option){
option = _option;
- delete pettanr.gallery.init;
- },
- firstOpen: function(){
- finder = pettanr.finder.createFinder( elmContainer, pettanr.driver.createPictureTree());
- delete pettanr.gallery.firstOpen;
+ delete pettanr.cabinet.init;
},
onOpen: function( _w, _h, _option ){
- pettanr.gallery.firstOpen !== undefined && pettanr.gallery.firstOpen();
+ finder = finder || pettanr.finder.createFinder( elmContainer, pettanr.driver.createComicTree());
finder.onOpen( _w, _h - pageHeaderH, _option );
},
finder.onClose();
},
onWindowResize: function( _w, _h){
- finder.resize( _w, _h - pageHeaderH );
+ finder.resize( _w, _h - pageHeaderH);
}
}
})();
+pettanr.view.registerApplication( pettanr.cabinet, true );
-pettanr.cabinet = ( function(){
+pettanr.gallery = ( function(){
var finder,
- elmContainer = document.getElementById( 'cabinet'),
+ elmContainer = document.getElementById( 'gallery' ),
option,
pageHeaderH = pettanr.util.getElementSize( document.getElementById('header') ).height;
-
return {
+ displayName: 'Pictures',
+ rootElement: elmContainer,
init: function( _option){
option = _option;
- delete pettanr.cabinet.init;
- },
- firstOpen: function(){
- finder = pettanr.finder.createFinder( elmContainer, pettanr.driver.createComicTree());
- delete pettanr.cabinet.firstOpen;
+ delete pettanr.gallery.init;
},
onOpen: function( _w, _h, _option ){
- pettanr.cabinet.firstOpen !== undefined && pettanr.cabinet.firstOpen();
+ finder = finder || pettanr.finder.createFinder( elmContainer, pettanr.driver.createPictureTree());
finder.onOpen( _w, _h - pageHeaderH, _option );
-
},
onClose: function(){
finder.onClose();
},
onWindowResize: function( _w, _h){
- finder.resize( _w, _h - pageHeaderH);
+ finder.resize( _w, _h - pageHeaderH );
}
}
})();
+pettanr.view.registerApplication( pettanr.gallery, true );
+
+pettanr.backyard = {
+ displayName: 'Settings',
+ rootElement: document.getElementById( 'backyard' ),
+ onOpen: function( _w, _h, _option ){
+ },
+ onClose: function(){
+ },
+ onWindowResize: function( _w, _h){
+ }
+}
+pettanr.view.registerApplication( pettanr.backyard, true );
+
+if( pettanr.DEBUG === true){
+ pettanr.debug = ( function(){
+ var elmDl = document.getElementById( 'useragent'),
+ elmDt, elmDd,
+ data = {
+ pettanR: pettanr.version,
+ ua: navigator.userAgent,
+ platform: navigator.platform,
+ appVersion: navigator.appVersion,
+ appCodeName:navigator.appCodeName,
+ appName: navigator.appName,
+ language: navigator.browserLanguage || navigator.language,
+ ActiveX: pettanr.ua.ACTIVEX
+ },
+ ua = pettanr.ua;
+ if( ua.IE){
+ //data.ua = 'Internet Explorer';
+ data.version = ua.IE;
+ if( ua.ieVersion >= 8) data.RenderingVersion = ua.ieRenderingVersion;
+ data.browserType = ua.STANDALONE === true ? 'Standalone' : 'bundle';
+ if( ua.ieVersion < 9) {
+ data.vml = ua.VML;
+ } else {
+ data.svg = ua.SVG;
+ }
+ }
+ data.RenderingMode = ua.isStanderdMode === true ? 'Standerd' : 'Quirks';
+
+ for( var key in data){
+ elmDt = document.createElement( 'dt');
+ elmDt.innerHTML = key;
+ elmDd = document.createElement( 'dd');
+ elmDd.innerHTML = '' + data[ key];
+ if( !data[ key]) elmDd.style.color = 'red';
+ elmDl.appendChild( elmDt);
+ elmDl.appendChild( elmDd);
+ }
+ return {
+ displayName: 'Debug',
+ rootElement: document.getElementById( 'debug' ),
+ onOpen: function( _w, _h, _option ){
+ var pageHeaderH = pettanr.util.getElementSize( document.getElementById('header') ).height;
+ document.getElementById('inner-wrapper').style.height = ( _h - pageHeaderH ) + 'px';
+ },
+ onClose: function(){
+ document.getElementById('inner-wrapper').style.height = '0px';
+ },
+ onWindowResize: function( _w, _h){
+ pettanr.debug.onOpen( _w, _h );
+ }
+ }
+ })();
+ pettanr.view.registerApplication( pettanr.debug, true );
+
+} else {
+ var _debug = document.getElementById( 'debug');
+ if( _debug){
+ pettanr.util.removeAllChildren( _debug);
+ _debug.parentNode.removeChild( _debug);
+ _debug = null;
+ }
+}
// i18n
// login