X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.5.x%2Fjavascripts%2Fpeta-apps.js;h=16cabfe634a836ebc16269affd39ed410626ead7;hb=2621070c032954702155d4a315535b8b1aafd616;hp=c03b3c60fbc370f140b1a392f4b7c74c2aaaa9c7;hpb=b3105489eb5c3c994695642b80e8827d4bfe393a;p=pettanr%2FclientJs.git diff --git a/0.5.x/javascripts/peta-apps.js b/0.5.x/javascripts/peta-apps.js index c03b3c6..16cabfe 100644 --- a/0.5.x/javascripts/peta-apps.js +++ b/0.5.x/javascripts/peta-apps.js @@ -1,6 +1,6 @@ /* * pettanR peta.apps.js - * version 0.5.38 + * version 0.5.49 * * author: * itozyun @@ -16,353 +16,483 @@ MyArtistID = 'current_artist' in window ? current_artist.id : ( pettanr.CONST.SERVER_SUPPORT === false ? 1 : -1 ), Driver = null, FileAPI = gOS.registerDriver( function(){ - var self = Driver = this; + var self = Driver = this, + unregisteredFileDataJsonList = []; - function onLoadJson( _file, _json ){ - var _access = FileAPI.getFileDataAccess( _file ), - _data = _access !== null ? _access.DATA : null, - i, l; - if( _data === null ){ - onErrorJson( _file ); + function onLoadJson( file, json ){ + var access = FileAPI.getFileDataAccess( file ), + data = access !== null ? access.DATA : null, + i, l, args; + if( data === null ){ + onErrorJson( file ); return; }; - _data.state = Const.FILE.STATE.OK; - - if( Type.isArray( _json ) === true ){ - for( i = 0, l = _json.length; i < l; ++i ){ - buildFileData( _json[ i ], _data ); + data.state = Const.FILE.STATE.OK; + if( Type.isArray( json ) === true ){ + for( i = 0, l = json.length; i < l; ++i ){ + registerFileData( json[ i ], data ); }; } else - if( Type.isNumber( _json.id ) === true ){ - buildFileData( _json, _data ); + if( Type.isNumber( json.id ) === true ){ + registerFileData( json, data ); + }; + while( 0 < unregisteredFileDataJsonList.length ){ + args = unregisteredFileDataJsonList.shift(); + registerFileData( args[ 0 ], args[ 1 ] ); + //alert( unregisteredFileDataJsonList.length ) }; - _file.dispatchEvent( FileAPI.createFileEvent( Const.FILE.EVENT.GET_SEQENTIAL_FILES, _file, 'children', null ) ); + file.dispatchEvent( FileAPI.createFileEvent( Const.FILE.EVENT.GET_SEQENTIAL_FILES, file, 'children', null ) ); }; - function onErrorJson( _file ){ - var _data = FileAPI.getFileData( _file); - if( _data !== null){ - _data.state = Const.FILE.STATE.ERROR; + function onErrorJson( file ){ + var data = FileAPI.getFileData( file ); + if( data !== null){ + data.state = Const.FILE.STATE.ERROR; }; - _file.dispatchEvent( FileAPI.createFileEvent( Const.FILE.EVENT.GET_SEQENTIAL_FILES, _file, 'children', null ) ); + file.dispatchEvent( FileAPI.createFileEvent( Const.FILE.EVENT.GET_SEQENTIAL_FILES, file, 'children', null ) ); }; - function buildFileData( _data, _parent ){ - var _array, i, l; - // Panel - if( _parent === FILE_DATA_PANELS_ROOT || _parent === FILE_DATA_MY_PANELS_ROOT ){ - _data.type = FILE_TYPE.PANEL; - _array = PANEL_ARRAY; - } else - // Comic - if( _parent === FILE_DATA_COMICS_ROOT ){ - _data.type = FILE_TYPE.COMIC; - _array = COMIC_ARRAY; - } else - if( _parent.type === FILE_TYPE.COMIC ){ - _array = COMIC_ARRAY; - } else - // Lisence - if( _parent === FILE_DATA_LISENCE_ROOT ){ - _data.type = FILE_TYPE.LICENSE; - _array = ORIGINAL_LICENSE_ARRAY; - } else - // Author - if( _parent === FILE_DATA_AUTHOR_ROOT ){ - _data.type = FILE_TYPE.AUTHOR; - _array = AUTHOR_ARRAY; - } else - // Artist - if( _parent === FILE_DATA_ARTIST_ROOT ){ - _data.type = FILE_TYPE.ARTIST; - _array = ARTIST_ARRAY; - } else - // Picture - if( _parent === FILE_DATA_PICTURE_ROOT || _parent === FILE_DATA_MY_PICTURES_ROOT ){ - _data.type = FILE_TYPE.PICTURE; - _array = RESOURCE_PICTURE_ARRAY; - // original_license を含まなければ、license object を削除して ビットデータ で保持 - // original_license なら ファイルを作る buildFileData( _license, FILE_DATA_LISENCE_ROOT) - var _license = _data.license, - _rule, - _Math_pow = Math.pow, - _bits = 0; - if( typeof _license === 'object' ){ - for( i=0, l=BASIC_LICENSES.length; i 0 ){ - var _id = _data.id - 1, - __data = _array[ _id ], - _reserved = Const.FILE.DATA_PROPERTY_RESERVED.join( ', ' ); - if( __data ){ - for( var key in _data ){ - if( _reserved.indexOf( key ) === -1 ){ - __data[ key ] = _data[ key ]; - }; + // Resource Picture + case FILE_DATA_RESOURCE_PICTURES_ROOT : + case FILE_DATA_MY_RESOURCE_PICTURES_ROOT : + case RESOURCE_PICTURE_ARRAY : + json.type = FILE_TYPE.RESOURCE_PICTURE; + data = createFileData( json, RESOURCE_PICTURE_ARRAY, 'ext' ); + if( data.artist ){ + addChildData( data.artist, data ); + data.artist.id === MyArtistID && addChildData( FILE_DATA_MY_RESOURCE_PICTURES_ROOT, data ); }; - _data = __data; // このタイミングで参照が切れるので注意!! - } else { - _array[ _id ] = _data; - }; - } else { - // alert( 'error' + _parent.name + ' ' + _data.id ); - }; - - // Author - // Artist - if( _parent === FILE_DATA_AUTHOR_ROOT || _parent === FILE_DATA_ARTIST_ROOT ){ - addChildData( _parent, _data ); - } else - // Comic + Panels - if( _parent.type === FILE_TYPE.COMIC || _parent === FILE_DATA_COMICS_ROOT ){ - var _panels = _data.stories, - _panel; - if( Type.isArray( _panels ) === true ){ - - for( i=0, l=_panels.length; i LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext ].join( '') : null, + LOW_SRC = originalPicture.filesize && originalPicture.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext ].join( '' ) : null, reversibleImage = null, timer = null, onEnterFlag = false, instance = this; elmContainer.appendChild( elmIconWrap ); elmIconWrap.style.left = ( index * itemW ) + 'px'; - elmIconTitle.appendChild( document.createTextNode( data.filesize + 'bytes' ) ); + elmIconTitle.appendChild( document.createTextNode( originalPicture.filesize + 'bytes' ) ); function onImageLoad( url, _imgW, _imgH ){ - data.width = _imgW = _imgW || data.width || 64; - data.height = _imgH = _imgH || data.height || 64; + data.width = _imgW = _imgW || originalPicture.width || 64; + data.height = _imgH = _imgH || originalPicture.height || 64; elmIconTitle.firstChild.data = _imgW + 'x' + _imgH; var zoom = 128 /( _imgW > _imgH ? _imgW : _imgH ), MATH_FLOOR = Math.floor, @@ -777,56 +953,56 @@ var PremiumSatge = gOS.registerApplication( function(){ self.removeTimer( onEnterShowImage ); self.addTimer( onEnterShowImage, 500 ); - } + }; return false; - } + }; function drawIcons(){ while( ICON_ARRAY.length > 0 ){ ICON_ARRAY.shift().destroy(); - } + }; var _index = rootFile.search( { - id: artistID, - type: FILE_TYPE.ARTIST + id : artistID, + type : FILE_TYPE.ARTIST })[ 0 ], _artistFile = rootFile.getChildFileAt( _index ), - _file; + file; if( _artistFile !== null ){ - for(var i=0, l=_artistFile.getChildFileLength(); i 0 ){ ICON_ARRAY.shift().destroy(); - } + }; onUpdate !== null && onUpdateData !== null && onUpdate.call( onUpdateContext, onUpdateData ); onUpdate = onUpdateData = onUpdateContext = null; PremiumSatge.shutdown(); - } + }; this.MIN_WIDTH = 320; this.MIN_HEIGHT = 320; this.onInit = function(){ - self.rootElement.id = 'image-group-wrapper'; + self.rootElement.id = 'image-group-wrapper'; - self.rootElement.innerHTML = [ - '
', - '
NO DATA...
', - '
close
' - ].join( '' ); - - self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS ); - - tree = FileAPI.createTree( FILE_DATA_ARTIST_ROOT ); - rootFile = tree.getRootFile(); + self.rootElement.innerHTML = [ + '
', + '
NO DATA...
', + '
close
' + ].join( '' ); + + self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS ); + + tree = FileAPI.createTree( FILE_DATA_ARTIST_ROOT ); + rootFile = tree.getRootFile(); }; this.onOpen = function( _windowW, _windowH, _ARTISTIDorFILE, _onUpdate, opt_thisObj ){ elmContainer = document.getElementById( 'image-group-icon-container' ); @@ -855,11 +1031,13 @@ var PremiumSatge = gOS.registerApplication( function(){ tree.addTreeEventListener( Const.TREE.EVENT.UPDATE, drawIcons ); var data = FileAPI.getFileData( _ARTISTIDorFILE ); - if( data.type === FILE_TYPE.ARTIST || FILE_DATA_MY_PICTURES_ROOT === data ){ + if( !data ){ + artistID = MyArtistID || -1; + } else + if( data.type === FILE_TYPE.ARTIST || FILE_DATA_MY_ORIGINAL_PICTURES_ROOT === data ){ artistID = data.id || -1; } else if( Type.isNumber( _ARTISTIDorFILE ) === true ){ - alert( _ARTISTIDorFILE ) artistID = _ARTISTIDorFILE; }; @@ -1062,30 +1240,41 @@ var Reader = gOS.registerApplication( function(){ } function draw(){ - var fileData, title, author; + var fileData, title, author, story; if( Driver.isPettanrFileInstance( currentFile ) === true ){ - if( currentFile.getType() === FILE_TYPE.COMIC ){ - fileData = currentFile.read(); - title = fileData.title; - author = fileData.author.name; - comicData = fileData; - numPanel = currentFile.getChildFileLength(); - } else - if( currentFile.getType() === FILE_TYPE.PANEL ){ - fileData = currentFile.read(); - title = fileData.comic.title; - author = fileData.comic.author.name; - comicData = fileData; - numPanel = 1; - } + switch( currentFile.getType() ){ + case FILE_TYPE.COMIC : + fileData = currentFile.read(); + title = fileData.title; + author = fileData.author.name; + comicData = fileData; + numPanel = currentFile.getChildFileLength(); + break; + case FILE_TYPE.STORY : + story = currentFile.read(); + fileData = story.panel; + title = story.comic.title; + author = fileData.author.name; + comicData = fileData; + numPanel = 1; + break; + case FILE_TYPE.PANEL : + fileData = currentFile.read(); + title = 'No comic'; + author = fileData.author.name; + comicData = fileData; + numPanel = 1; + break; + }; } else { }; if( comicData !== null ){ elmTitle.data = title; elmAuthor.data = author; - bindWorker.json( comicData ); + // bindWorker.json( comicData ); + bindWorker.file( currentFile ); self.addAsyncCall( asyncResize ); }; } @@ -1120,7 +1309,7 @@ var Reader = gOS.registerApplication( function(){ self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS ); }; - this.onOpen = function( _w, _h, _file ){ + this.onOpen = function( _w, _h, file ){ headerH = Util.getElementSize( document.getElementById( 'comic-reader-header' ) ).height; consoleH = Util.getElementSize( document.getElementById( 'comic-reader-console' ) ).height; elmContainer = document.getElementById( 'comic-reader-panel-container' ); @@ -1140,10 +1329,10 @@ var Reader = gOS.registerApplication( function(){ windowW = _w; windowH = _h; - if( FileAPI.isFileInstance( _file ) === true ){ - currentFile = _file; - _file.addEventListener( Const.FILE.EVENT.GET_SEQENTIAL_FILES, draw ); - _file.getSeqentialFiles(); + if( FileAPI.isFileInstance( file ) === true ){ + currentFile = file; + file.addEventListener( Const.FILE.EVENT.GET_SEQENTIAL_FILES, draw ); + file.getSeqentialFiles(); draw(); }; }; @@ -1218,7 +1407,7 @@ var Editor = gOS.registerApplication( function(){ var ELM_ITEM_CLASSNAME = 'menubar-item', currentMenu = null, elmBar, elmBox, - nodeBar, nodeBox, + nodeBar, nodeBox, layerBox, barH, menuW; /** ----------------------------------------- * PrivateOptionDataClass @@ -1411,7 +1600,7 @@ var Editor = gOS.registerApplication( function(){ }; MenuClass.prototype = { show: function(){ - data = MenuPrivateDataClass.get( this ); + var data = MenuPrivateDataClass.get( this ); if( data.visible === true ) return; data.elm.className = ELM_ITEM_CLASSNAME + '-focus'; @@ -1816,7 +2005,7 @@ var Editor = gOS.registerApplication( function(){ }, firstOpen : function(){ var win = this.window, - elmHead = this.elmHead = Util.getElementsByClassName( this.elm, 'window-header' )[ 0 ]; + elmHead = this.elmHead = Util.getElementsByClassName( this.elm, 'window-header' )[ 0 ], elmBody = this.elmBody = Util.getElementsByClassName( this.elm, 'window-body' )[ 0 ], elmClose = Util.getElementsByClassName( this.elm, 'window-close-button' )[ 0 ], elmFoot = Util.getElementsByClassName( this.elm, 'window-footer' )[ 0 ], @@ -2141,11 +2330,11 @@ var Editor = gOS.registerApplication( function(){ var IMAGE_EXPLORER_WINDOW = ( function(){ var tree, finder; - function onFileSelect( _file ){ + function onFileSelect( file ){ // 他の image ファイルも許可する? - if( Driver.isPettanrFileInstance( _file ) === true ){ - if( _file.getType() === FILE_TYPE.PICTURE ){ - PANEL_ELEMENT_CONTROL.onImageSelect( FileAPI.getFileData( _file ) ); + if( Driver.isPettanrFileInstance( file ) === true ){ + if( file.getType() === FILE_TYPE.RESOURCE_PICTURE ){ + PANEL_ELEMENT_CONTROL.onImageSelect( FileAPI.getFileData( file ) ); }; }; }; @@ -2154,7 +2343,7 @@ var Editor = gOS.registerApplication( function(){ { onInit: function(){}, onFirstOpen: function( _w, _h, nodeBody ){ - tree = FileAPI.createTree( FILE_DATA_PICTURE_ROOT ); + tree = FileAPI.createTree( FILE_DATA_RESOURCE_PICTURES_ROOT ); var _root = tree.getRootFile(), _myPic = _root.getChildFileAt( 0 ), _pic = _root.getChildFileAt( 1 ); @@ -2166,8 +2355,7 @@ var Editor = gOS.registerApplication( function(){ finder = app.createFinder( nodeBody, tree, - onFileSelect, - PANEL_ELEMENT_CONTROL.onImageSelect + onFileSelect ); finder.createPath( IMAGE_EXPLORER_WINDOW.createHeaderItem() ); }, @@ -2778,7 +2966,8 @@ var Editor = gOS.registerApplication( function(){ { x: 1, w: -1, y: 0, h: 1}, //bottom-left { x: 0, w: 1, y: 0, h: 1} //bottom-right ], - startX, startY, startW, startH, startFilpV, startFilpH, startAspect, + startX, startY, startW, startH, + flipV, flipH, startFilpV, startFilpH, startAspect, baseX, baseY, baseW, baseH, currentX, currentY, currentW, currentH, offsetX, offsetY, @@ -3282,9 +3471,10 @@ var Editor = gOS.registerApplication( function(){ pushoutH = 0, pushout = false, currentType = -1, + currentElement = null, visible = false, node = null, - ui, inputX, inputY, inputZ, inputA, inputW, inputH, inputAspectRatio, + ui, inputX, inputY, inputZ, inputA, inputW, inputH, inputPercentW, inputPercentH, inputAspectRatio, buttonBack, buttonForward, buttonDel, buttonEdit, butonChange; function layerBack(){ @@ -3317,7 +3507,7 @@ var Editor = gOS.registerApplication( function(){ }; function change(){ if( currentElement === null ) return; - PremiumSatge.boot( currentElement.artistID, currentElement.resourcePicture, currentElement ); + PremiumSatge.boot( currentElement.artistID, currentElement.realPicture, currentElement ); }; return { @@ -3509,12 +3699,11 @@ var Editor = gOS.registerApplication( function(){ this.$ = jqImageElementOrigin.clone( true ); this.data = data; this.z = data.z; - this.timing = data.t || PANEL_ELEMENT_ARRAY.length + 1; + this.timing = data.t || PANEL_ELEMENT_ARRAY.length; this.keepSize = false; this.flipV = data.height < 0 ? -1 : 1; this.flipH = data.width < 0 ? -1 : 1; - this.rPicture = data.resource_picture; - this.artistID = this.rPicture.artist_id || this.rPicture.artist.id || -1; + this.rPicture = data.picture; var self = this; function animeComplete(){ @@ -3540,7 +3729,7 @@ var Editor = gOS.registerApplication( function(){ this.flipV = updateV === true ? -this.flipV : this.flipV; this.reversibleImage.resize( this.flipH * this.w, this.flipV * this.h ); }, - resourcePicture : function( _rPicture ){ + realPicture : function( _rPicture ){ if( _rPicture && _rPicture !== this.rPicture ){ HISTORY_CONTROL.saveState( this._updateResourcePicture, this.rPicture, _rPicture, this ); this._updateResourcePicture( _rPicture ); @@ -3578,12 +3767,14 @@ var Editor = gOS.registerApplication( function(){ }, _updateResourcePicture : function( _rPicture ){ this.rPicture = _rPicture; - - this.actualW = _rPicture.width; - this.actualH = _rPicture.height; + this.oPicture = this.rPicture.original_picture; + this.artistID = this.oPicture.artist.id || -1; + + this.actualW = this.oPicture.width; + this.actualH = this.oPicture.height; var _reversibleImage = pettanr.image.createReversibleImage( - [ pettanr.CONST.RESOURCE_PICTURE_PATH, _rPicture.id, '.', _rPicture.ext ].join(''), + [ pettanr.CONST.PICTURE_PATH, this.rPicture.id, '.', this.rPicture.ext ].join( '' ), this.flipH * this.w, this.flipV * this.h ); if( this.reversibleImage !== null ){ @@ -3640,7 +3831,7 @@ var Editor = gOS.registerApplication( function(){ })(); this.balloon = pettanr.balloon.createBalloon( data.width, data.height, data.tail, this.type ); this.z = data.z; - this.timing = data.t || PANEL_ELEMENT_ARRAY.length + 1; + this.timing = data.t || PANEL_ELEMENT_ARRAY.length; this.$.find( 'img' ).eq( 0 ).replaceWith( this.balloon.elm ); @@ -3897,17 +4088,17 @@ var Editor = gOS.registerApplication( function(){ var _panelElement; if( isPanelPictureData !== true ){ _panelElement = new ImageElementClass( { - resource_picture:data, - x: Math.floor( panelW / 2 - data.width / 2 ), - y: Math.floor( panelH / 2 - data.height / 2 ), - z: -1, - t: PANEL_ELEMENT_ARRAY.length + 1, - width: 1, - height: 1 + picture : data.picture, + x : Math.floor( panelW / 2 - data.width / 2 ), + y : Math.floor( panelH / 2 - data.height / 2 ), + z : -1, + t : 0, + width : 1, + height : 1 }); _panelElement.init(); PANEL_ELEMENT_CONTROL.add( _panelElement ); - _panelElement.animate( undefined, undefined, Math.abs( data.width ), Math.abs( data.height ) ); + _panelElement.animate( undefined, undefined, Math.abs( data.picture.original_picture.width ), Math.abs( data.picture.original_picture.height ) ); } else { _panelElement = new ImageElementClass( data ); _panelElement.init(); @@ -3925,7 +4116,7 @@ var Editor = gOS.registerApplication( function(){ x: Math.floor( panelW / 2 - 100 + Math.random() * 10 ), y: Math.floor( panelH / 2 - 100 + Math.random() * 10 ), z: -1, - t: PANEL_ELEMENT_ARRAY.length + 1, + t: 0, width: 200, height: 200, speeches_attributes: { @@ -4120,7 +4311,7 @@ var Editor = gOS.registerApplication( function(){ delete app.onInit; }; - this.onOpen = function( _w, _h, _file ){ + this.onOpen = function( _w, _h, file ){ // 表示奥の物から順に init() していく PANEL_ELEMENT_CONTROL.init(); PANEL_CONTROL.init(); @@ -4145,20 +4336,20 @@ var Editor = gOS.registerApplication( function(){ borderSize, fileData, panelElements, panelElm; - if( FileAPI.isFileInstance( _file ) === true ){ - if( Driver.isPettanrFileInstance( _file ) === true ){ - if( _file.getType() === FILE_TYPE.COMIC ){ - fileData = _file.read(); + if( FileAPI.isFileInstance( file ) === true ){ + if( Driver.isPettanrFileInstance( file ) === true ){ + if( file.getType() === FILE_TYPE.COMIC ){ + fileData = file.read(); panelW = fileData.width; panelH = fileData.height; comicID = fileData.id || -1; } else - if( _file.getType() === FILE_TYPE.PANEL ){ - fileData = _file.read(); + if( file.getType() === FILE_TYPE.PANEL ){ + fileData = file.read(); panelW = fileData.width; panelH = fileData.height; borderSize = fileData.border; - panelElements = fileData.panel_elements; + panelElements = fileData.elements; comicID = fileData.comic ? fileData.comic.id || -1 : -1; panelID = fileData.id || -1; panelTimming = fileData.t || -1; @@ -4189,7 +4380,7 @@ var Editor = gOS.registerApplication( function(){ if( Type.isArray( panelElements ) === true ){ for( var i=0; i