From fc32c9ed9fef79ae977b8a0b3bcbf82fda2fedb8 Mon Sep 17 00:00:00 2001 From: itozyun Date: Sat, 2 Feb 2013 19:55:39 +0900 Subject: [PATCH] Client is version 0.5.44, fetch pettanR resourcies working! --- app/assets/javascripts/libs.js | 315 ++++--- app/assets/javascripts/peta-apps.js | 997 ++++++++++++-------- app/assets/javascripts/peta-common.js | 86 +- app/assets/javascripts/system.js | 1659 ++++++++++++++++++++++++++++++--- 4 files changed, 2336 insertions(+), 721 deletions(-) diff --git a/app/assets/javascripts/libs.js b/app/assets/javascripts/libs.js index a21377f4..aee98fec 100644 --- a/app/assets/javascripts/libs.js +++ b/app/assets/javascripts/libs.js @@ -1,6 +1,6 @@ /* * pettanR libs.js - * version 0.5.39 + * version 0.5.44 * * * Type @@ -317,21 +317,32 @@ var getFunctionName = function( f ){ }; }, 0 ); - function clone( src ) { - var ret; + var objSrc = [], + objCopy = [], + getIndex; + function clone( src ){ + var ret, i, key; if( Type.isArray(src) === true ){ + i = getIndex( objSrc, src ); + if( i !== -1 ) return objCopy[ i ]; ret = []; + objSrc[ objSrc.length ] = src; + objCopy[ objCopy.length ] = ret; } else if( Type.isObject(src) === true ){ + i = getIndex( objSrc, src ); + if( i !== -1 ) return objCopy[ i ]; ret = {}; + objSrc[ objSrc.length ] = src; + objCopy[ objCopy.length ] = ret; } else if( Type.isNumber(src) === true || Type.isString(src) === true || Type.isBoolean( src ) === true ){ return src; } else { return null; }; - for( var key in src ){ - ret[ key ] = clone( src[ key ]); + for( key in src ){ + ret[ key ] = clone( src[ key ] ); }; return ret; }; @@ -365,6 +376,8 @@ var getFunctionName = function( f ){ return target; }, copy: function( objOrArray ){ + objSrc.length = objCopy.length = 0; + getIndex = Util.getIndex; return clone( objOrArray ); }, cleanCommentNode: function ( _targetElm ){ @@ -645,21 +658,21 @@ var getFunctionName = function( f ){ _node.parentNode && _node.parentNode.removeChild( _node); } }, - getIndex: function( _array, _element ){ + getIndex: function( array, element ){ if( Array.prototype.indexof ){ - Util.getIndex = function( _array, _element ){ - return _array.indexof( _element ); + Util.getIndex = function( array, element ){ + return array.indexof( element ); }; } else { - Util.getIndex = function( _array, _element ){ - var i = _array.length; + Util.getIndex = function( array, element ){ + var i = array.length; for( ; i; ){ - if( _array[ --i ] === _element ) return i; + if( array[ --i ] === element ) return i; }; return -1; }; }; - return Util.getIndex( _array, _element ); + return Util.getIndex( array, element ); }, copyArray: function( _array ){ var l = _array.length, @@ -797,126 +810,95 @@ var CSS = ( function( window, documwnt, undefined ){ return _special; })(); - - function cssToObject( css ){ - var ret = {}, i, nv, n, v, - parse = Util.parse, - isNumber = Type.isNumber, - camelize = Util.camelize; - if( Type.isString( css ) === true ){ - css = css.split( ';' ); - for( i = css.length; i; ){ - nv = css[ --i ].split( ':' ); // filter の場合, progid: がくる - n = nv.shift(); - if( isNumber( parse( n ) ) === true ) continue; - v = nv.join( '' ); - while( v.charAt( 0 ) === ' ' ) v = v.substr( 1 ); - ret[ camelize( n ) ] = parse( v ); - }; - } else { - for( n in css ){ - if( Type.isNumber( parse( n ) ) === false ) ret[ n ] = parse( css[ n ] ); - }; - }; - - if( SPECIAL.setFilters ){ - SPECIAL.setFilters( ret ); - } else { - ret.opacity = SPECIAL.opacity !== null ? ret[ SPECIAL.opacity ] : 1; - }; - - SPECIAL.setBackgroundPositionXY && SPECIAL.setBackgroundPositionXY( ret ); - SPECIAL.setClipTopRightBottomLeft && SPECIAL.setClipTopRightBottomLeft( ret ); - - return ret; - }; var COLOR = ( function(){ var ret = {}, v, name, list = [ - 0, 'BLACK', - parseInt( 'FF0000', 16 ), 'RED', - parseInt( '00FF00', 16 ), 'LIME', - parseInt( '0000FF', 16 ), 'BLUE', - parseInt( 'FFFF00', 16 ), 'YELLOW', - parseInt( '00FFFF', 16 ), 'AQUA or CYAN', - parseInt( 'FF00FF', 16 ), 'FUCHSIA or MAGENTA', - parseInt( 'FFFFFF', 16 ), 'WHITE', - parseInt( '008000', 16 ), 'GREEN', - parseInt( '800080', 16 ), 'PURPLE', - parseInt( '800000', 16 ), 'MAROON', - parseInt( '000080', 16 ), 'NAVY', - parseInt( '808000', 16 ), 'OLIVE', - parseInt( '008080', 16 ), 'TEAL', - parseInt( '808080', 16 ), 'GRAY', - parseInt( 'C0C0C0', 16 ), 'SILVER', - parseInt( '696969', 16 ), 'DIMGRAY', - parseInt( '708090', 16 ), 'SLATEGRAY', - parseInt( 'A9A9A9', 16 ), 'DARKGRAY', - parseInt( 'DCDCDC', 16 ), 'GAINSBORO', - parseInt( '191970', 16 ), 'MIDNIGHTBLUE', - parseInt( '6A5ACD', 16 ), 'SLATEBLUE', - parseInt( '0000CD', 16 ), 'MEDIUMBLUE', - parseInt( '4169E1', 16 ), 'ROYALBLUE', - parseInt( '1E90FF', 16 ), 'DODGERBLUE', - parseInt( '87CEEB', 16 ), 'SKYBLUE', - parseInt( '4682B4', 16 ), 'STEELBLUE', - parseInt( 'ADD8E6', 16 ), 'LIGHTBLUE', - parseInt( 'AFEEEE', 16 ), 'PALETURQUOISE', - parseInt( '40E0D0', 16 ), 'TURQUOISE', - parseInt( 'E0FFFF', 16 ), 'LIGHTCYAN', - parseInt( '7FFFD4', 16 ), 'AQUAMARINE', - parseInt( '006400', 16 ), 'DARKGREEN', - parseInt( '2E8B57', 16 ), 'SEAGREEN', - parseInt( '90EE90', 16 ), 'LIGHTGREEN', - parseInt( '7FFF00', 16 ), 'CHARTREUSE', - parseInt( 'ADFF2F', 16 ), 'GREENYELLOW', - parseInt( '32CD32', 16 ), 'LIMEGREEN', - parseInt( '9ACD32', 16 ), 'YELLOWGREEN', - parseInt( '6B8E23', 16 ), 'OLIVEDRAB', - parseInt( 'BCB76B', 16 ), 'DARKKHAKI', - parseInt( 'EEE8AA', 16 ), 'PALEGOLDENROD', - parseInt( 'FFFFE0', 16 ), 'LIGHTYELLOW', - parseInt( 'FFD700', 16 ), 'GOLD', - parseInt( 'DAA520', 16 ), 'GOLDENROD', - parseInt( 'B8860B', 16 ), 'DARKGOLDENROD', - parseInt( 'BC8F8F', 16 ), 'ROSYBROWN', - parseInt( 'CD5C5C', 16 ), 'INDIANRED', - parseInt( '8B4513', 16 ), 'SADDLEBROWN', - parseInt( 'A0522D', 16 ), 'SIENNA', - parseInt( 'CD853F', 16 ), 'PERU', - parseInt( 'DEB887', 16 ), 'BURLYWOOD', - parseInt( 'F5F5DC', 16 ), 'BEIGE', - parseInt( 'F5DEB3', 16 ), 'WHEAT', - parseInt( 'F4A460', 16 ), 'SANDYBROWN', - parseInt( 'D2B48C', 16 ), 'TAN', - parseInt( 'D2691E', 16 ), 'CHOCOLATE', - parseInt( 'B22222', 16 ), 'FIREBRICK', - parseInt( 'A52A2A', 16 ), 'BROWN', - parseInt( 'FA8072', 16 ), 'SALMON', - parseInt( 'FFA500', 16 ), 'ORANGE', - parseInt( 'FF7F50', 16 ), 'CORAL', - parseInt( 'FF6347', 16 ), 'TOMATO', - parseInt( 'FF69B4', 16 ), 'HOTPINK', - parseInt( 'FFC0CB', 16 ), 'PINK', - parseInt( 'FF1493', 16 ), 'DEEPPINK', - parseInt( 'DB7093', 16 ), 'PALEVIOLETRED', - parseInt( 'EE82EE', 16 ), 'VIOLET', - parseInt( 'DDA0DD', 16 ), 'PLUM', - parseInt( 'DA70D6', 16 ), 'ORCHILD', - parseInt( '9400D3', 16 ), 'DARKVIOLET', - parseInt( '8A2BE2', 16 ), 'BLUEVIOLET', - parseInt( '9370DB', 16 ), 'MEDIUMPURPLE', - parseInt( 'D8BFD8', 16 ), 'THISTLE', - parseInt( 'E6E6FA', 16 ), 'LAVENDER', - parseInt( 'FFE4E1', 16 ), 'MISTYROSE', - parseInt( 'FFFFF0', 16 ), 'IVORY', - parseInt( 'FFFACD', 16 ), 'LEMONCHIFFON' + '0', 'BLACK', + 'FF0000', 'RED', + '00FF00', 'LIME', + '0000FF', 'BLUE', + 'FFFF00', 'YELLOW', + '00FFFF', 'AQUA', + '00FFFF', 'CYAN', + 'FF00FF', 'MAGENTA', + 'FF00FF', 'FUCHSIA', + 'FFFFFF', 'WHITE', + '008000', 'GREEN', + '800080', 'PURPLE', + '800000', 'MAROON', + '000080', 'NAVY', + '808000', 'OLIVE', + '008080', 'TEAL', + '808080', 'GRAY', + 'C0C0C0', 'SILVER', + '696969', 'DIMGRAY', + '708090', 'SLATEGRAY', + 'A9A9A9', 'DARKGRAY', + 'DCDCDC', 'GAINSBORO', + '191970', 'MIDNIGHTBLUE', + '6A5ACD', 'SLATEBLUE', + '0000CD', 'MEDIUMBLUE', + '4169E1', 'ROYALBLUE', + '1E90FF', 'DODGERBLUE', + '87CEEB', 'SKYBLUE', + '4682B4', 'STEELBLUE', + 'ADD8E6', 'LIGHTBLUE', + 'AFEEEE', 'PALETURQUOISE', + '40E0D0', 'TURQUOISE', + 'E0FFFF', 'LIGHTCYAN', + '7FFFD4', 'AQUAMARINE', + '006400', 'DARKGREEN', + '2E8B57', 'SEAGREEN', + '90EE90', 'LIGHTGREEN', + '7FFF00', 'CHARTREUSE', + 'ADFF2F', 'GREENYELLOW', + '32CD32', 'LIMEGREEN', + '9ACD32', 'YELLOWGREEN', + '6B8E23', 'OLIVEDRAB', + 'BCB76B', 'DARKKHAKI', + 'EEE8AA', 'PALEGOLDENROD', + 'FFFFE0', 'LIGHTYELLOW', + 'FFD700', 'GOLD', + 'DAA520', 'GOLDENROD', + 'B8860B', 'DARKGOLDENROD', + 'BC8F8F', 'ROSYBROWN', + 'CD5C5C', 'INDIANRED', + '8B4513', 'SADDLEBROWN', + 'A0522D', 'SIENNA', + 'CD853F', 'PERU', + 'DEB887', 'BURLYWOOD', + 'F5F5DC', 'BEIGE', + 'F5DEB3', 'WHEAT', + 'F4A460', 'SANDYBROWN', + 'D2B48C', 'TAN', + 'D2691E', 'CHOCOLATE', + 'B22222', 'FIREBRICK', + 'A52A2A', 'BROWN', + 'FA8072', 'SALMON', + 'FFA500', 'ORANGE', + 'FF7F50', 'CORAL', + 'FF6347', 'TOMATO', + 'FF69B4', 'HOTPINK', + 'FFC0CB', 'PINK', + 'FF1493', 'DEEPPINK', + 'DB7093', 'PALEVIOLETRED', + 'EE82EE', 'VIOLET', + 'DDA0DD', 'PLUM', + 'DA70D6', 'ORCHILD', + '9400D3', 'DARKVIOLET', + '8A2BE2', 'BLUEVIOLET', + '9370DB', 'MEDIUMPURPLE', + 'D8BFD8', 'THISTLE', + 'E6E6FA', 'LAVENDER', + 'FFE4E1', 'MISTYROSE', + 'FFFFF0', 'IVORY', + 'FFFACD', 'LEMONCHIFFON' ]; - for( i=list.length; i; ){ + for( i = list.length; i; ){ v = list[ --i ]; name = list[ --i ]; - ret[ name ] = v; + ret[ name ] = parseInt( v, 16 ); }; return ret; })(); @@ -1054,8 +1036,8 @@ var CSS = ( function( window, documwnt, undefined ){ // top, bottom, left, right, topbottom, leftright, all }; FrexiblePropertyClass.prototype = PropertyGroupClass.prototype = { - name: '', - equal: function( prop ){ + name : '', + equal : function( prop ){ var ps = this.props, i = ps.length; for( ; i; ){ --i; @@ -1063,27 +1045,27 @@ var CSS = ( function( window, documwnt, undefined ){ }; return true; }, - convert: function( prop ){ + convert : function( prop ){ var ps = this.props, i = ps.length; for( ; i; ){ --i; ps[ i ].convert( prop[ i ] ); }; }, - setValue: function( ary ){ + setValue : function( ary ){ var ps = this.props, i = 0, l = ps.length; for( ; i this.r || 0 > this.g || 0 > this.b ) return false; @@ -1471,12 +1453,43 @@ var CSS = ( function( window, documwnt, undefined ){ obj[ _p ] = obj[ _p ] || obj[ p ]; delete obj[ p ]; }; + return obj; + }; + function cssToObject( css ){ + var ret = {}, i, nv, n, v, + parse = Util.parse, + isNumber = Type.isNumber, + camelize = Util.camelize; + if( Type.isString( css ) === true ){ + css = css.split( ';' ); + for( i = css.length; i; ){ + nv = css[ --i ].split( ':' ); // filter の場合, progid: がくる + n = nv.shift(); + if( isNumber( parse( n ) ) === true ) continue; + v = nv.join( '' ); + while( v.charAt( 0 ) === ' ' ) v = v.substr( 1 ); + ret[ camelize( n ) ] = parse( v ); + }; + } else { + for( n in css ){ + if( Type.isNumber( parse( n ) ) === false ) ret[ n ] = parse( css[ n ] ); + }; + }; + + if( SPECIAL.setFilters ){ + SPECIAL.setFilters( ret ); + } else { + ret.opacity = SPECIAL.opacity !== null ? ret[ SPECIAL.opacity ] : 1; + }; + + SPECIAL.setBackgroundPositionXY && SPECIAL.setBackgroundPositionXY( ret ); + SPECIAL.setClipTopRightBottomLeft && SPECIAL.setClipTopRightBottomLeft( ret ); + + return ret; }; - return { getWrappedStyle: function( elm, opt_css ){ - opt_css && camelizeHash( opt_css ); - return new WrappedStyleClass( elm, opt_css || CSS.getComputedStyle( elm ) ); + return new WrappedStyleClass( elm, opt_css ? camelizeHash( opt_css ) : CSS.getComputedStyle( elm ) ); }, getInlineStyle: function( _elm ){ return cssToObject( _elm.style.cssText ); diff --git a/app/assets/javascripts/peta-apps.js b/app/assets/javascripts/peta-apps.js index 81aaa519..0b1a9310 100644 --- a/app/assets/javascripts/peta-apps.js +++ b/app/assets/javascripts/peta-apps.js @@ -1,6 +1,6 @@ /* * pettanR peta.apps.js - * version 0.5.39 + * version 0.5.44 * * author: * itozyun @@ -16,352 +16,469 @@ 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 || _parent === FILE_DATA_MY_COMICS_ROOT ){ - _data.type = FILE_TYPE.COMIC; - _array = COMIC_ARRAY; - } else - if( _parent.type === FILE_TYPE.COMIC ){ - _array = PANEL_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 === FILE_DATA_COMICS_ROOT || _parent === FILE_DATA_MY_COMICS_ROOT ){ - var _stories = _data.stories, - _panel; - if( Type.isArray( _stories ) === true ){ - for( i=0, l=_stories.length; i LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext ].join( '') : null, + LOW_SRC = originalPicture.filesize && originalPicture.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', originalPicture.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 +936,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 +1014,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 +1223,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 +1292,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 +1312,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(); }; }; @@ -2141,11 +2313,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 +2326,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 ); @@ -3512,8 +3684,9 @@ var Editor = gOS.registerApplication( function(){ 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; + //this.oPicture = this.rPicture.original_picture; + //this.artistID = this.oPicture.artist.id || -1; var self = this; function animeComplete(){ @@ -3577,12 +3750,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.RESOURCE_PICTURE_PATH, this.rPicture.id, '.', this.rPicture.ext ].join( '' ), this.flipH * this.w, this.flipV * this.h ); if( this.reversibleImage !== null ){ @@ -3896,17 +4071,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, + 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 }); _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(); @@ -4119,7 +4294,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(); @@ -4144,16 +4319,16 @@ 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; @@ -4188,7 +4363,7 @@ var Editor = gOS.registerApplication( function(){ if( Type.isArray( panelElements ) === true ){ for( var i=0; i 0 ){ - instance = def.pool.shift(); - } else { - f = false; - instance = new klass(); - f = 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(){ + function C( args ){ 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 ){ - instance = def.pool.shift(); - } else { - f = false; - instance = new klass(); - f = true; - }; - if( def.Super && !instance.Super ){ - instance.Super = def.Super; - }; - return instance; - }; - /* Constructor Real for AbstractClass */ - function A(){ - var klass = this, - instance; - if( abstractFlag === true ){ + instance, + userDef; + if( def.Abstract === true ){ throw new Error( 'AbstractClass!' ); }; + if( def.isPrivate === true && dataUser === null ){ + throw new Error( 'use myClass.newPrivateData( instance, ...args )!' ); + }; f = false; - instance = new klass(); + instance = def.pool && def.pool.length > 0 ? def.pool.shift() : instance = new klass(); f = true; + if( def.Super && !instance.Super ) instance.Super = def.Super; + if( def.isPrivate === true ){ + userDef = getClassDef( dataUser ); + userDef.dataList.push( instance ); + userDef.userList.push( dataUser ); + } else { + def.live && def.live.push( instance ); + args = c( arguments ); + }; + def[ CONSTRUCTOR ] && def[ CONSTRUCTOR ].apply( instance, args ); return instance; }; - return { POOL_OBJECT : 1, ABSTRACT : 2, @@ -412,10 +397,11 @@ var Class = ( function(){ }; args.shift(); }; - privateDef = getClassDef( args[ 0 ] ); - if( privateDef ){ + + if( GET_INDEX( PRIVATE_CLASS_LIST, args[ 0 ] ) !== -1 ){ + privateDef = getClassDef( args[ 0 ] ); if( privateDef.isPrivate !== true ){ - throw new Error( 'PrivateClass not found! please, Class.createPrivateData().' ); + throw new Error( 'PrivateClass not found! please, Class.create( Class.PRIVATE, {...} ).' ); } else if( privateDef.Abstract === true ){ throw new Error( 'PrivateClass is Abstract!' ); @@ -430,23 +416,17 @@ var Class = ( function(){ if( Type.isFunction( props[ CONSTRUCTOR ] ) === true ){ classDef[ CONSTRUCTOR ] = props[ CONSTRUCTOR ]; }; - + + klass = function(){ a = arguments; if( f ) return C.apply( a.callee, c( a ) )}; + klass.prototype = override( override( traits || {}, props, true ), CommonProps, false ); + if( opt_abstract === true ){ - klass = function(){ a = arguments; if( f ) return A.apply( a.callee, c( a ) )}; classDef.Abstract = true; } 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_pool === true ){ + classDef.pool = []; + if( opt_private === false )classDef.live = []; + }; if( opt_final === true ){ classDef.Final = true; } else { @@ -461,8 +441,8 @@ var Class = ( function(){ PRIVATE_DEF_LIST.push( classDef ); } else { if( classDef.privateClass ){ - klass.newPrivateData = newPrivateData; - klass.getPrivateData = getPrivateData; + klass.newPrivateData = newPrivateData; + klass.getPrivateData = getPrivateData; }; CLASS_LIST.push( klass ); DEF_LIST.push( classDef ); @@ -473,7 +453,7 @@ var Class = ( function(){ }, getClass : function( instance ){ - + return getClass( instance ); }, getClassDef : function(){ @@ -1089,7 +1069,7 @@ var File = ( function(){ if( typeof driver.getName === 'function'){ return driver.getName( this ); } - return BASE_DRIVER.getName( this); + return BASE_DRIVER.getName( this ); }, getThumbnail: function(){ var driver = FILE_CONTROLER.getDriver( this ); @@ -1132,9 +1112,9 @@ var File = ( function(){ // simpleDeepCopy var driver = FILE_CONTROLER.getDriver( this ), data; - if( typeof driver.read === 'function'){ + if( Type.isFunction( driver.read ) === true ){ data = driver.read( this ); - } + }; return BASE_DRIVER.read( data || this ); }, write: function( _newData, _onUpdateFunction ){ @@ -1292,36 +1272,46 @@ var File = ( function(){ // debug用 全てのメニューを許可 return Const.FILE.UPDATE_POLICY.DSRWC; }; - this.read = function( _FILEorDATA ){ + this.read = function( FILEorDATA ){ var data, - protects = Const.FILE.DATA_PROPERTY_RESERVED; - if( _FILEorDATA instanceof FileClass ){ - data = FILE_CONTROLER.getFileData( _FILEorDATA ) + protects = Const.FILE.DATA_PROPERTY_RESERVED, + objSrc = [], + objCopy = [], + getIndex = Util.getIndex; + if( FILEorDATA instanceof FileClass ){ + data = FILE_CONTROLER.getFileData( FILEorDATA ) } else { - data = _FILEorDATA; - } - + data = FILEorDATA; + }; + function clone( src ) { - var ret; - if( Type.isArray(src) === true ){ + var ret, i, key; + if( Type.isArray( src ) === true ){ + i = getIndex( objSrc, src ); + if( i !== -1 ) return objCopy[ i ]; ret = []; + objSrc[ objSrc.length ] = src; + objCopy[ objCopy.length ] = ret; } else - if( Type.isObject(src) === true ){ + if( Type.isObject( src ) === true ){ + i = getIndex( objSrc, src ); + if( i !== -1 ) return objCopy[ i ]; ret = {}; + objSrc[ objSrc.length ] = src; + objCopy[ objCopy.length ] = ret; } else - if( Type.isNumber(src) === true || Type.isString(src) === true || Type.isBoolean( src ) === true ){ + if( Type.isNumber( src ) === true || Type.isString( src ) === true || Type.isBoolean( src ) === true ){ return src; } else { - return null; - } - for( var key in src ){ - if( Util.getIndex( protects, key ) === -1 ){ + return src; + }; + for( key in src ){ + if( getIndex( protects, key ) === -1 ){ ret[ key ] = clone( src[ key ]); - } - } + }; + }; return ret; - }; - + }; return clone( data ); }; this.write = function( _file, _newData, _onUpdateFunction ){ @@ -6342,4 +6332,1411 @@ var DHTML = ( function(){ gOS.registerApplication = Application.register; gOS.registerDriver = File.registerDriver; +var BoxModel + +var DOM = ( function( window, document ){ + var DIV_LIST = [], + SPAN_LIST = [], + TEXT_LIST = []; + + var elmTextSize; + + function correctNodes( node ){ + var child; + if( node && node.parentNode ){ + while( node.lastChild ) correctNodes( node.lastChild ); + node.parentNode.removeChild( node ); + if( node.nodeType === 1 ){ + switch( node.tagName ){ + case 'DIV': + DIV_LIST.push( node ); + break; + case 'SPAN': + SPAN_LIST.push( node ); + break; + + }; + node.removeAttribute( 'className' ); + node.removeAttribute( 'style' ); + node.removeAttribute( 'id' ); + } else + if( node.nodeType === 3 ){ + node.data = ''; + TEXT_LIST.push( node ); + }; + }; + }; + + return { + createDiv : function(){ + return 0 < DIV_LIST.length ? DIV_LIST.shift() : document.createElement( 'div' ); + }, + createSpan : function(){ + + }, + createText : function(){ + + }, + getTextSize : function( elm, content ){ + var span = DOM.createSpan(), + text = DOM.createText(), + w, h; + elm.appendChild( span ); + span.style.cssText = 'visibility:hidden;position:absolute;'; + span.appendChild( text ); + text.data = content; + w = span.offsetWidth; + h = span.offsetHeight; + DOM.correctNodes( span ); + return [ w, h ]; + }, + correctNodes : function( node ){ + var child; + if( node && node.parentNode ){ + while( node.lastChild ) DOM.correctNodes( node.lastChild ); + node.parentNode.removeChild( node ); + if( node.nodeType === 1 ){ + switch( node.tagName ){ + case 'DIV': + DIV_LIST.push( node ); + break; + case 'SPAN': + SPAN_LIST.push( node ); + break; + + }; + node.removeAttribute( 'className' ); + node.removeAttribute( 'style' ); + node.removeAttribute( 'id' ); + } else + if( node.nodeType === 3 ){ + node.data = ''; + TEXT_LIST.push( node ); + }; + }; + } + } +})( window, document ); + +var XBrowserStyle = ( function(){ + var EMPTY = '', + CORON = ':', + SEMICORON = ';', + SPACE = ' ', + UNITS = 'px,cm,mm,in,pt,pc,em,%'.split( ',' ), + CLIP_SEPARATOR = UA.isIE === true && UA.ieVersion < 8 ? ' ' : ','; + + var SPECIAL = ( function(){ + var special = {}; + if( UA.isIE === true && UA.ieVersion < 9 ){ + if( UA.ACTIVEX === true ){ + // special.opacity = 'ActiveXOpacity'; + special.setFilters = function( style ){ + var filters = ( style.filter || '' ).split( ') ' ), + data = {}, + i = filters.length, + filter, names, props, prop, j, l, key, v; + for( ; i; ){ + filter = filters[ --i ].split( ' ' ).join( '' ).split( '(' ); + if( filter.length !== 2 ) continue; + names = filter[ 0 ].split( '.' ); // progid:DXImageTransform.Microsoft.Shadow(color=#666666,direction=120,strength=9) + props = filter[ 1 ].split( ',' ); // + filter = {}; + for( j = 0, l = props.length; j < l; ++j ){ + prop = props[ j ].split( '=' ); + key = prop[ 0 ].toLowerCase(); + v = prop[ 1 ]; + filter[ key ] = v; //v.charAt( 0 ) === '#' ? v : parseInt( v ); + }; + data[ names[ names.length - 1 ] ] = filter; + }; + + style.filter = data; + style.opacity = data.alpha && data.alpha.opacity ? data.alpha.opacity / 100 : 1; + }; + special.hasLayout = function( elm ){ + return elm.currentStyle.hasLayout; + }; + } else { + special.opacity = null; + }; + } else { + var style = document.documentElement.style; + special.opacity = style.opacity !== undefined ? 'opacity' : + style.MozOpacity !== undefined ? 'MozOpacity' : + style.KhtmlOpacity !== undefined ? 'KhtmlOpacity' : + style[ '-khtml-opacity' ] !== undefined ? 'KhtmlOpacity' : null; + + // if( style.backgroundPositionX === undefined ){ + special.setBackgroundPositionXY = function( style ){ + var bgp = ( style.backgroundPosition || '' ).split( ' ' ); + style.backgroundPositionX = bgp[ 0 ] || 0; + style.backgroundPositionY = bgp[ 1 ] || 0; + }; + // }; + if( style.clipTop === undefined && style[ 'clip-top' ] === undefined ){ + special.setClipTopRightBottomLeft = function( style ){ + var clip = style.clip; + if( !cliop || clip.indexOf( 'rect(' ) === -1 ){ + style.clipTop = 0; + style.clipRight = 0; + style.clipBottom = 0; + style.clipLeft = 0; + return; + }; + clip = clip.split( '(' )[ 1 ].split( ')' )[ 0 ].split( clip.indexOf( ',' ) !== -1 ? ',' : ' ' ); + ret.clipTop = clip[ 0 ]; + ret.clipRight = clip[ 1 ]; + ret.clipBottom = clip[ 2 ]; + ret.clipLeft = clip[ 3 ]; + }; + }; + }; + return special; + })(); + + function cssToObject( css ){ + var ret = {}, i, nv, n, v, + parse = Util.parse, + isNumber = Type.isNumber, + camelize = Util.camelize; + if( Type.isString( css ) === true ){ + css = css.split( SEMICORON ); + for( i = css.length; i; ){ + nv = css[ --i ].split( CORON ); // filter の場合, progid: がくる + n = nv.shift(); + if( isNumber( parse( n ) ) === true ) continue; + v = nv.join( EMPTY ); + while( v.charAt( 0 ) === ' ' ) v = v.substr( 1 ); + ret[ camelize( n ) ] = parse( v ); + }; + } else { + for( n in css ){ + if( Type.isNumber( parse( n ) ) === false ) ret[ n ] = parse( css[ n ] ); + }; + }; + + if( SPECIAL.setFilters ){ + SPECIAL.setFilters( ret ); + } else { + ret.opacity = SPECIAL.opacity !== null ? ret[ SPECIAL.opacity ] : 1; + }; + + SPECIAL.setBackgroundPositionXY && SPECIAL.setBackgroundPositionXY( ret ); + SPECIAL.setClipTopRightBottomLeft && SPECIAL.setClipTopRightBottomLeft( ret ); + + return ret; + }; + + var COLOR = ( function(){ + var ret = {}, v, name, + list = [ + '0', 'BLACK', + 'FF0000', 'RED', + '00FF00', 'LIME', + '0000FF', 'BLUE', + 'FFFF00', 'YELLOW', + '00FFFF', 'AQUA', + '00FFFF', 'CYAN', + 'FF00FF', 'MAGENTA', + 'FF00FF', 'FUCHSIA', + 'FFFFFF', 'WHITE', + '008000', 'GREEN', + '800080', 'PURPLE', + '800000', 'MAROON', + '000080', 'NAVY', + '808000', 'OLIVE', + '008080', 'TEAL', + '808080', 'GRAY', + 'C0C0C0', 'SILVER', + '696969', 'DIMGRAY', + '708090', 'SLATEGRAY', + 'A9A9A9', 'DARKGRAY', + 'DCDCDC', 'GAINSBORO', + '191970', 'MIDNIGHTBLUE', + '6A5ACD', 'SLATEBLUE', + '0000CD', 'MEDIUMBLUE', + '4169E1', 'ROYALBLUE', + '1E90FF', 'DODGERBLUE', + '87CEEB', 'SKYBLUE', + '4682B4', 'STEELBLUE', + 'ADD8E6', 'LIGHTBLUE', + 'AFEEEE', 'PALETURQUOISE', + '40E0D0', 'TURQUOISE', + 'E0FFFF', 'LIGHTCYAN', + '7FFFD4', 'AQUAMARINE', + '006400', 'DARKGREEN', + '2E8B57', 'SEAGREEN', + '90EE90', 'LIGHTGREEN', + '7FFF00', 'CHARTREUSE', + 'ADFF2F', 'GREENYELLOW', + '32CD32', 'LIMEGREEN', + '9ACD32', 'YELLOWGREEN', + '6B8E23', 'OLIVEDRAB', + 'BCB76B', 'DARKKHAKI', + 'EEE8AA', 'PALEGOLDENROD', + 'FFFFE0', 'LIGHTYELLOW', + 'FFD700', 'GOLD', + 'DAA520', 'GOLDENROD', + 'B8860B', 'DARKGOLDENROD', + 'BC8F8F', 'ROSYBROWN', + 'CD5C5C', 'INDIANRED', + '8B4513', 'SADDLEBROWN', + 'A0522D', 'SIENNA', + 'CD853F', 'PERU', + 'DEB887', 'BURLYWOOD', + 'F5F5DC', 'BEIGE', + 'F5DEB3', 'WHEAT', + 'F4A460', 'SANDYBROWN', + 'D2B48C', 'TAN', + 'D2691E', 'CHOCOLATE', + 'B22222', 'FIREBRICK', + 'A52A2A', 'BROWN', + 'FA8072', 'SALMON', + 'FFA500', 'ORANGE', + 'FF7F50', 'CORAL', + 'FF6347', 'TOMATO', + 'FF69B4', 'HOTPINK', + 'FFC0CB', 'PINK', + 'FF1493', 'DEEPPINK', + 'DB7093', 'PALEVIOLETRED', + 'EE82EE', 'VIOLET', + 'DDA0DD', 'PLUM', + 'DA70D6', 'ORCHILD', + '9400D3', 'DARKVIOLET', + '8A2BE2', 'BLUEVIOLET', + '9370DB', 'MEDIUMPURPLE', + 'D8BFD8', 'THISTLE', + 'E6E6FA', 'LAVENDER', + 'FFE4E1', 'MISTYROSE', + 'FFFFF0', 'IVORY', + 'FFFACD', 'LEMONCHIFFON' + ]; + for( i = list.length; i; ){ + v = list[ --i ]; + name = list[ --i ]; + ret[ name ] = parseInt( v, 16 ); + }; + return ret; + })(); + + var PARAMS = ( function(){ + var ret = {}; + register( ret.percent = {}, + 'marginBottom,marginLeft,marginRight,marginTop,paddingBottom,paddingLeft,paddingRight,paddingTop,fontSize,textIndent' + ); + register( ret.offset = {}, + 'height,width,bottom,left,right,top' + ); + register( ret.size = {}, + 'borderBottomWidth,borderLeftWidth,borderRightWidth,borderTopWidth,letterSpacing' + ); + register( ret.color = {}, + 'backgroundColor,borderBottomColor,borderLeftColor,borderRightColor,borderTopColor,color' + ); + register( ret.region = {}, + 'margin,padding,borderWidth,borderColor' + ); + register( ret.special = {}, + 'clip,backgroundPosition,opacity,lineHeight,zIndex' + ); + register( ret.unit = {}, 'px,cm,mm,in,pt,pc,em,%' ); + + register( ret.margin = {}, 'marginBottom,marginLeft,marginRight,marginTop,paddingBottom' ); + register( ret.padding = {}, 'paddingBottom,paddingLeft,paddingRight,paddingTop' ); + register( ret.borderWidth = {}, 'borderBottomWidth,borderLeftWidth,borderRightWidth,borderTopWidth' ); + register( ret.borderColor = {}, 'borderBottomColor,borderLeftColor,borderRightColor,borderTopColor' ); + + function register( obj, params ){ + params = params.split( ',' ); + for( var i=params.length; i; ) obj[ params[ --i ] ] = true; + }; + return ret; + })(); + + /* + * + */ + var Property = Class.create( + 'Property', + Class.POOL_OBJECT, + { + Constructor : function( name, value, unit, pxPerEm ){ + this.name = name; + this.value = value; + this.unit = unit; + this.pxPerEm = pxPerEm; // XXpx = 1em; + }, + name : '', + value : 0, + pxPerEm : 12, // 1em === ??px + unit : '', + equal : function( prop ){ + if( this.unit === prop.unit ){ + return this.value === prop.value; + }; + return Math.abs( this.toPx() - prop.toPx() ) < 1; + }, + convert: function( prop ){ + var u = prop.unit, v; + if( this.unit === u ) return; + this.value = v = this.toPx(); + this.unit = u; + if( u !== px ){ + this.value = u === 'em' ? v / this.pxPerEm : Util.pxTo( v, u ); + }; + }, + setValue: function( v ){ + this.value = v; + }, + getValue: function(){ + return this.value; + }, + getOffset: function( prop ){ + return prop.value - this.value; + }, + getUnit: function(){ + return this.unit; + }, + getValueText: function(){ + return this.value === 0 ? '0' : this.value + this.unit; + }, + toPx: function(){ + var v = this.value, u = this.unit; + if( u === px ) return v; + if( u === 'em' ) return v * this.pxPerEm; + if( u === '' && this.name === 'lineHeight' ) return v * this.pxPerEm; + return Util.toPx( v, u ); + }, + isValid: function( t ){ + t = t || this; + var n = t.name, + v = t.value, + u = t.unit, + z = u !== '' ? true : v === 0; + if( PARAMS.percent[ n ] === true ) return z; + if( PARAMS.offset[ n ] === true ) return z; + if( PARAMS.size[ n ] === true ) return z && u !== '%'; + if( PARAMS.special[ n ] === true ){ + if( n === 'lineHeight' ) return true; + if( n === 'opacity' ) return 0 <= v && v <= 1 && u === ''; + if( n === 'zIndex' ) return u === ''; + }; + return false; + } + } + ); + + /** + * backgroundPosition, clip + */ + var PropertyGroup = Class.create( + 'PropertyGroup', + Class.POOL_OBJECT, + { + Constructor : function( name ){ + this.name = name; + this.props = []; + for( var i = 1, l = arguments.length; i 1 ) return false; + }; + return true; + }, + convert : function( prop ){ + var u = prop.pct, x; + if( this.pct === u ) return; + x = u === true ? 100 / 255 : 2.55; + this.r *= x; + this.g *= x; + this.b *= x; + this.pct = u; + }, + setValue : function( rgb ){ + this.r = rgb[ 0 ]; + this.g = rgb[ 1 ]; + this.b = rgb[ 2 ]; + }, + getValue : function(){ + return [ this.r, this.g, this.b ]; + }, + getOffset : function( prop ){ + return [ prop.r - this.r, prop.g - this.g, prop.b - this.b ]; + }, + getUnit : function(){ + return this.pct === true ? '%' : ''; + }, + getValueText : function(){ + if( this.pct === true ){ + return [ 'rgb(', this.r, '%,', this.g, '%,', this.b, '%)' ].join( '' ); + }; + var round = Math.round; + //return [ 'rgb(', round( this.r ), ',', round( this.g ), ',', round( this.b ), ')' ].join( '' ); + + var rgb = '00000' + ( ( round( this.r ) << 16 ) + ( round( this.g ) << 8 ) + round( this.b ) ).toString( 16 ); + return '#' + rgb.substr( rgb.length - 6 ); + }, + _toPct : function(){ + if( this.pct === true ) return [ this.r, this.g, this.b ]; + return [ this.r / 2.55, this.g / 2.55, this.b / 2.55 ]; + }, + isValid : function( t ){ + var isFinite = window.isFinite; + if( !isFinite( this.r ) || !isFinite( this.g ) || !isFinite( this.b ) ) return false; + if( 0 > this.r || 0 > this.g || 0 > this.b ) return false; + if( this.pct === true ) return this.r <= 100 && this.g <= 100 && this.b <= 100; + return this.r <= 255 && this.g <= 255 && this.b <= 255; + } + } + ); + + var isString = Type.isString, + isNumber = Type.isNumber; + var REG_UINIT = /.*\d(\w{1,2})?/, + $1 = '$1', + px = 'px', + REG_XXXXXX = /^#[\da-fA-F]{6}?/, + REG_XXX = /^#[\da-fA-F]{3}?/; + + var WrappedStyle = Class.create( + 'WrappedStyle', + Class.POOL_OBJECT, + { + Constructor : function( style ){ + this.style = style; + var fontsize = this.get( 'fontSize' ); + this.pxPerEm = fontsize.toPx(); + fonstsize.kill(); + }, + get: function( p ){ + if( PARAMS.special[ p ] === true || PARAMS.region[ p ] === true ){ + if( p === 'clip' ) return this.getClip(); + if( p === 'margin' ) return this.getMarginPaddingBorder( p, '' ); + if( p === 'padding' ) return this.getMarginPaddingBorder( p, '' ); + if( p === 'borderWidth' ) return this.getMarginPaddingBorder( 'border', 'Width' ); + if( p === 'borderColor' ) return this.getBorderColor( 'borderColor' ); + if( p === 'backgroundPosition' ) return this.getBackgroundPosition( p ); + // opacity, zindex, lineHeight + return new Property( p, this.getValue( x ), this.getUnit( x ), this.pxPerEm ); + }; + var x = this.style[ p ], e, v, u; + if( PARAMS.offset[ p ] === true ){ + return new Property( p, this.getValue( x ), this.getUnit( x, p ), this.pxPerEm ); + /* + e = this.elm; + if( p === 'width' ) v = e.offsetWidth; + if( p === 'height' ) v = e.offsetHeight; + if( p === 'top' ) v = e.offsetTop; + if( p === 'bottom' ) v = e.offsetBottom; + if( p === 'left' ) v = e.offsetLeft; + if( p === 'right' ) v = e.offsetRight; + u = this.getUnit( x, p ); + // alert( p + this.pxTo( v, u ) + u ) + return new Property( p, this.pxTo( v, u ), u, this.pxPerEm ); */ + }; + if( p === 'fontSize' ){ // xx-small 等 + v = Util.absoluteFontSizeToPx( x ); + if( v !== 0 ){ + return new Property( p, v, px, this.pxPerEm ); + }; + }; + if( PARAMS.percent[ p ] === true ){ + // alert( p + ' , ' + x + ' , ' + this.getUnit( x, p ) ) + return new Property( p, this.getValue( x ), this.getUnit( x, p ), this.pxPerEm ); + }; + if( PARAMS.size[ p ] === true ){ + return new Property( p, this.getValue( x ), this.getUnit( x, p ), this.pxPerEm ); + }; + if( PARAMS.color[ p ] === true ){ + return this.getColor( x, p ); + }; + }, + pxTo: function( px, unit ){ + if( unit === 'em' ) return px / this.pxPerEm; + return Util.pxTo( px, unit ); + }, + getValue: function( x ){ + return isString( x ) === true ? parseInt( x ) : + isNumber( x ) === true ? x : 0; + }, + getUnit: function( x, p ){ + var u; + if( isString( x ) === true ){ + u = x.replace( REG_UINIT, $1 ); + if( p === 'lineHeight' ) return u; + if( PARAMS.unit[ u ] !== true ) return px; + return u; + }; + return px; + }, + getColor: function( x, p ){ + var rgb = COLOR[ x.toUpperCase() ], + pct = false, + r = 0, + g = 0, + b = 0; + if( isNumber( rgb ) === true ){ + r = ( rgb & 0xff0000 ) >> 16; + g = ( rgb & 0xff00 ) >> 8; + b = ( rgb & 0xff ); + } else + if( x.match( REG_XXXXXX ) ){ + r = parseInt( x.charAt( 1 ) + x.charAt( 2 ), 16 ); + g = parseInt( x.charAt( 3 ) + x.charAt( 4 ), 16 ); + b = parseInt( x.charAt( 5 ) + x.charAt( 6 ), 16 ); + //alert( x + ' g: ' + g ) + } else + if( x.match( REG_XXX ) ){ + r = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 ); + g = parseInt( x.charAt( 2 ) + x.charAt( 2 ), 16 ); + b = parseInt( x.charAt( 3 ) + x.charAt( 3 ), 16 ); + } else + if( x.indexOf( 'rgb(' ) === 0 ){ + rgb = x.substr( 4 ).split( ',' ); + r = parseFloat( rgb[ 0 ] ); + g = parseFloat( rgb[ 1 ] ); + b = parseFloat( rgb[ 2 ] ); + if( x.indexOf( '%' ) !== -1 ) pct = true; + } else { + r = 255; + g = 255; + b = 255; + }; + return new ColorProperty( p, r, g, b, pct ); + }, + getClip: function( name ){ + // rect(...) クリップします。, は上端からの、 , は左端からのオフセットで指定します。Internet Explorer 4~7 では、カンマの代わりにスペースで区切る必要があります。 + // position:absolute または position:fixed を適用した要素に対してのみ有効です。 + var top = this.get( name + 'Top' ), + right = this.get( name + 'Right' ), + bottom = this.get( name + 'Bottom' ), + left = this.get( name + 'Left' ), + ret = new PropertyGroup( name, top, right, bottom, left ); + if( ret.isValid() === true ) return ret; + ret.kill(); + all = this.style[ name ].split( '(' )[ 1 ].split( ')' )[ 0 ].split( CLIP_SEPARATOR ); + return new PropertyGroup( name, + new Property( name + 'Top', all[ 0 ], px, this.pxPerEm ), + new Property( name + 'Right', all[ 1 ], px, this.pxPerEm ), + new Property( name + 'Bottom', all[ 2 ], px, this.pxPerEm ), + new Property( name + 'Left', all[ 3 ], px, this.pxPerEm ) + ); + }, + getBackgroundPosition: function( name ){ + var x = this.get( name + 'X' ), + y = this.get( name + 'Y' ), + ret = new PropertyGroup( name, x, y ), + xy; + if( ret.isValid() === true ) return ret; + ret.kill(); + xy = this.style[ name ].split( ' ' ); + return new PropertyGroup( name, + new Property( name + 'X', this.getValue( xy[ 0 ] ), this.getUnit( xy[ 0 ] ), this.pxPerEm ), + new Property( name + 'Y', this.getValue( xy[ 1 ] ), this.getUnit( xy[ 1 ] ), this.pxPerEm ) + ); + }, + getMarginPaddingBorder: function( name, width ){ + var props = [ name + 'Top' + width, + name + 'Right' + width, + name + 'Bottom' + width, + name + 'Left' + width ], + top = this.get( props[ 0 ] ), + right = this.get( props[ 1 ] ), + bottom = this.get( props[ 2 ] ), + left = this.get( props[ 3 ] ), + ret = new FrexibleProperty( name, top, right, bottom, left ), + klass, pxPerEm, getValue, getUnit, + all, _0, _1, _2, _3, v, u; + if( ret.isValid() === true ) return ret; + ret.kill(); + klass = Property; + pxPerEm = this.pxPerEm; + getValue = this.getValue; + getUnit = this.getUnit; + all = this.style[ name + width ].split( ' ' ); + _0 = all[ 0 ]; + _1 = all[ 1 ]; + _2 = all[ 2 ]; + _3 = all[ 3 ]; + v = getValue( _0 ); + u = getUnit( _0 ); + switch( all.length ){ + case 1 : + top = new klass( props[ 0 ], v, u, pxPerEm ); + right = new klass( props[ 1 ], v, u, pxPerEm ); + bottom = new klass( props[ 2 ], v, u, pxPerEm ); + left = new klass( props[ 3 ], v, u, pxPerEm ); + break; + case 2 : + top = new klass( props[ 0 ], v, u, pxPerEm ); + bottom = new klass( props[ 2 ], v, u, pxPerEm ); + v = getValue( _1 ); + u = getUnit( _1 ); + right = new klass( props[ 1 ], v, u, pxPerEm ); + left = new klass( props[ 3 ], v, u, pxPerEm ); + break; + case 3 : + top = new klass( props[ 0 ], v, u, pxPerEm ); + v = getValue( _1 ); + u = getUnit( _1 ); + right = new klass( props[ 1 ], v, u, pxPerEm ); + left = new klass( props[ 3 ], v, u, pxPerEm ); + bottom = new klass( props[ 2 ], getValue( _2 ), getUnit( _2 ), pxPerEm ); + break; + case 4 : + top = new klass( props[ 0 ], v, u, pxPerEm ); + right = new klass( props[ 1 ], getValue( _1 ), getUnit( _1 ), pxPerEm ); + bottom = new klass( props[ 2 ], getValue( _2 ), getUnit( _2 ), pxPerEm ); + left = new klass( props[ 3 ], getValue( _3 ), getUnit( _3 ), pxPerEm ); + break; + }; + return new FrexibleProperty( name, top, right, bottom, left ); + }, + getBorderColor: function( name ){ + var props = 'borderTopColor,borderRightColor,borderBottomColor,borderLeftColor'.split( ',' ), + top = this.get( props[ 0 ] ), + right = this.get( props[ 1 ] ), + bottom = this.get( props[ 2 ] ), + left = this.get( props[ 3 ] ), + ret = new FrexibleProperty( name, top, right, bottom, left ), + all, _0, _1, getColor; + if( ret.isValid() === true ) return ret; + ret.kill(); + getColor = this.getColor; + all = this.style[ name ].split( ' ' ); + _0 = all[ 0 ]; + _1 = all[ 1 ]; + switch( all.length ){ + case 1 : + top = getColor( _0, props[ 0 ] ); + right = getColor( _0, props[ 1 ] ); + bottom = getColor( _0, props[ 2 ] ); + left = getColor( _0, props[ 3 ] ); + break; + case 2 : + top = getColor( _0, props[ 0 ] ); + right = getColor( _1, props[ 1 ] ); + bottom = getColor( _0, props[ 2 ] ); + left = getColor( _1, props[ 3 ] ); + break; + case 3 : + top = getColor( _0, props[ 0 ] ); + right = getColor( _1, props[ 1 ] ); + bottom = getColor( all[ 2 ], props[ 2 ] ); + left = getColor( _1, props[ 3 ] ); + break; + case 4 : + top = getColor( _0, props[ 0 ] ); + right = getColor( _1, props[ 1 ] ); + bottom = getColor( all[ 2 ], props[ 2 ] ); + left = getColor( all[ 3 ], props[ 3 ] ); + break; + }; + return new FrexibleProperty( name, top, right, bottom, left ); + } + } + ); + function camelizeHash( obj ){ + var p, _p, came = Util.camelize; + for( p in obj ){ + _p = came( p ); + if( _p === p ) continue; + obj[ _p ] = obj[ _p ] || obj[ p ]; + delete obj[ p ]; + }; + }; + return { + create: function( css ){ + return new WrappedStyle( camelizeHash( p ) ); + } + }; +})(); + +var XDocument = ( function( window, document ){ + + var getIndex = Util.getIndex; + + var DEF_ATTRS = []; + + var AbstractLayoutManager = Class.create( + 'AbstractLayoutManager', + Class.ABSTRACT, { + reflow : function(){} + } + ); + + var BasicLayoutManager = AbstractLayoutManager.inherits( + 'BasicLayoutManager', + { + Constructor : function(){ + + } + } + ); + + var AbstractStylePrivate = Class.create( + Class.ABSTRACT | Class.PRIVATE_DATA, + { + register : function( node ){ + var list = this.nodeList; + if( !list ){ + this.nodeList = [ node ]; + return; + }; + if( getIndex( list, node ) === -1 ) list[ list.length ] = node; + }, + unRegister : function( node ){ + var list = this.nodeList, + i = getIndex( list, node ); + if( i !== -1 && list.splice( i, 1 ) && list.length === 0 ) delete this.nodeList; + }, + clone : function(){ + var styleClass = Class.getClass( this.User ), + dataClass = Class.getClass( this ); + }, + attr : function( prop, v ){ + var update = prop[ 0 ], + propID = prop[ 1 ], + type = prop[ 2 ], + list = prop[ 3 ], + length = !!( type & DEF_ATTRS.LENGTH ), + percent = !!( type & DEF_ATTRS.PERCENT ), + color = !!( type & DEF_ATTRS.COLOR ), + uDecimal = !!( type & DEF_ATTRS.U_DECIMAL ), + numerical = !!( type & DEF_ATTRS.NUMERICAL ), + flag = !!( type & DEF_ATTRS.BOOLEAN ), + quartet = !!( type & DEF_ATTRS.QUARTET ), + url = !!( type & DEF_ATTRS.URL ), + fontName = !!( type & DEF_ATTRS.FONT_NAME ), + list = !!( type & DEF_ATTRS.LIST ), + combi = !!( type & DEF_ATTRS.COMBI ), + data = this.data, + _v = -1, + _type, i, l, nodes; + + if( v !== undefined ){ + if( Type.isNumber( v ) === true ){ + if( numerical === false ){ + if( uDecimal === false || v < 0 || 1 < v ) throw new Error( '' ); + }; + } else + if( Type.isBoolean( v ) === true ){ + if( flag === false ) throw new Error( '' ); + } else + if( Type.isString( v ) === true ){ + if( url === false && fontName === false ){ + if( v.indexOf( ' ' ) !== -1 ){ + v = v.split( ' ' ); + } else { + if( length === false && percent === false && color === false ) throw new Error( '' ); + }; + }; + }; + if( Type.isArray( v ) === true ){ + if( v.length <= 4 && quartet === true ){ + _type = type ^ DEF_ATTRS.QUARTET; + } else + if( v.length === 2 && combi === true ){ + _type = type ^ DEF_ATTRS.COMBI; + } else { + throw new Error( '' ); + }; + switch( v.length ){ + case 1 : + this.attr( [ propID , _type, list ], v[ 0 ] ); + this.attr( [ ++propID, _type, list ], v[ 0 ] ); + this.attr( [ ++propID, _type, list ], v[ 0 ] ); + this.attr( [ ++propID, _type, list ], v[ 0 ] ); + break; + case 2 : + this.attr( [ propID , _type, list ], v[ 0 ] ); + this.attr( [ ++propID, _type, list ], v[ 1 ] ); + this.attr( [ ++propID, _type, list ], v[ 0 ] ); + this.attr( [ ++propID, _type, list ], v[ 1 ] ); + break; + case 3 : + this.attr( [ propID , _type, list ], v[ 0 ] ); + this.attr( [ ++propID, _type, list ], v[ 1 ] ); + this.attr( [ ++propID, _type, list ], v[ 2 ] ); + this.attr( [ ++propID, _type, list ], v[ 1 ] ); + break; + case 4 : + this.attr( [ propID , _type, list ], v[ 0 ] ); + this.attr( [ ++propID, _type, list ], v[ 1 ] ); + this.attr( [ ++propID, _type, list ], v[ 2 ] ); + this.attr( [ ++propID, _type, list ], v[ 3 ] ); + break; + default : + }; + return this.User; + }; + if( this.invalidateLayout < update ) this.invalidate = update; + + if( list ) _v = Util.getIndex( list, v ); + data[ propID ] = _v !== -1 ? _v : v; + return this.User; + }; + if( this.invalidate === DEF_ATTRS.REFLOW ){ + nodes = this.nodeList; + if( nodes ){ + for( i = 0, l = nodes.length; i < l; ++i ){ + nodes[ i ].reflow(); + }; + }; + }; + v = data[ propID ]; + if( quartet === true ) return [ v, data[ ++propID ], data[ ++propID ], data[ ++propID ] ]; + if( combi === true ) return [ v, data[ ++propID ] ]; + if( list && Type.isNumber( v ) === true ) return list[ v ]; + return v; + } + } + ); + + var PaintPrivate = AbstractStylePrivate.inherits( + 'PaintPrivate', + Class.PRIVATE_DATA | Class.POOL_OBJECT, + { + Constructor : function(){ + this.data = []; + this.invalidate = 0; + }, + cssText : function(){ + + }, + cssObject : function(){ + + }, + paint : function( node ){ + + } + } + ); + + var PaintStyle = Class.create( + 'PaintStyle', + Class.POOL_OBJECT, + PaintPrivate, + { + Constructor : function(){ + PaintStyle.newPrivateData( this ); + }, + borderWidth : function( v ){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.borderWidth, v ); + }, + borderColor : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.borderColor, v ); + }, + borderStyle : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.borderStyle, v ); + }, + cornerRadius : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.cornerRadius, v ); + }, + bgColor : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.bgColor, v ); + }, + bgAlpha : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.bgAlpha, v ); + }, + bgImgUrl : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.bgImgUrl, v ); + }, + bgImgRepeatX : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.bgImgRepeatX, v ); + }, + bgImgRepeatY : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.bgImgRepeatY, v ); + }, + bgImgPositionX : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.bgImgPositionX, v ); + }, + bgImgPositionY : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.bgImgPositionY, v ); + }, + shadowColor : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.shadowColor, v ); + }, + shadowAlpha : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.shadowAlpha, v ); + }, + shadowOffsetX : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.shadowOffsetX, v ); + }, + shadowOffsetY : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.shadowOffsetY, v ); + }, + shadowBlur : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.shadowBlur, v ); + }, + shadowSpread : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.shadowSpread, v ); + }, + shadowInset : function(){ + return PaintStyle.getPrivateData( this ).attr( PaintPrivate.shadowInset, v ); + } + } + ); + + var TypoPrivate = AbstractStylePrivate.inherits( + 'TypoPrivate', + Class.PRIVATE_DATA | Class.POOL_OBJECT, + { + Constructor : function(){ + this.data = []; + this.invalidate = 0; + }, + cssText : function(){ + + }, + cssObject : function(){ + + } + } + ); + + var TypoStyle = Class.create( + 'TypoStyle', + Class.POOL_OBJECT, + TypoPrivate, + { + Constructor : function( v ){ + TypoStyle.newPrivateData( this ); + }, + color : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.color, v ); + }, + fontFamily : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.fontFamily, v ); + }, + fontSize : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.fontSize, v ); + }, + bold : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.bold, v ); + }, + italic : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.italic, v ); + }, + lineHeight : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.lineHeight, v ); + }, + letterSpacing : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.letterSpacing, v ); + }, + wordSpacing : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.wordSpacing, v ); + }, + align : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.align, v ); + }, + decoration : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.decoration, v ); + }, + transform : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.transform, v ); + }, + shadowColor : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.shadowColor, v ); + }, + shadowOffsetX : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.shadowOffsetX, v ); + }, + shadowOffsetY : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.shadowOffsetY, v ); + }, + shadowBlur : function( v ){ + return TypoStyle.getPrivateData( this ).attr( TypoPrivate.shadowBlur, v ); + } + } + ); + + var LayoutPrivate = AbstractStylePrivate.inherits( + 'LayoutPrivate', + Class.PRIVATE_DATA | Class.POOL_OBJECT, + { + Constructor : function(){ + this.data = []; + this.invalidate = 0; + }, + cssText : function(){ + + }, + cssObject : function(){ + + } + } + ); + + DEF_ATTRS.LENGTH = 1; + DEF_ATTRS.PERCENT = 2; + DEF_ATTRS.COLOR = 4; + DEF_ATTRS.U_DECIMAL = 8; + DEF_ATTRS.NUMERICAL = 16; + DEF_ATTRS.BOOLEAN = 32; + DEF_ATTRS.QUARTET = 64; + DEF_ATTRS.URL = 128; + DEF_ATTRS.FONT_NAME = 256; + DEF_ATTRS.LIST = 512; + DEF_ATTRS.AUTO = 1024; + DEF_ATTRS.COMBI = 2048; + DEF_ATTRS.BORDER_STYLE = 'none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset'.split(','); + DEF_ATTRS.POSITION_X = 'left,center,right'.split(','); + DEF_ATTRS.POSITION_Y = 'top,center,bottom'.split(','); + DEF_ATTRS.ALIGN = 'left,center,right,justify'.split(','); + DEF_ATTRS.TEXT_DECORATION = 'none,underline,overline,line-through,blink'.split(','); + DEF_ATTRS.TEXT_TRANSFORM = 'none,capitalize,lowercase,uppercase'.split(','); + DEF_ATTRS.WIDTH_HEIGHT = 'auto'.split(','); + DEF_ATTRS.PAINT = 1; // 再描画のみ必要 + DEF_ATTRS.REFLOW = 2; // レイアウトの再計算が必要 + + PaintPrivate.borderWidth = [ DEF_ATTRS.REFLOW, 0, DEF_ATTRS.QUARTET | DEF_ATTRS.LENGTH ]; // em [ top, right, bottom, left ] + PaintPrivate.borderColor = [ DEF_ATTRS.PAINT, 4, DEF_ATTRS.QUARTET | DEF_ATTRS.DEF_COLOR ]; // color [ top, right, bottom, left ] + PaintPrivate.borderStyle = [ DEF_ATTRS.REFLOW, 8, DEF_ATTRS.QUARTET | DEF_ATTRS.LIST, DEF_ATTRS.BORDER_STYLE ]; // string [ top, right, bottom, left ] + PaintPrivate.cornerRadius = [ DEF_ATTRS.PAINT, 12, DEF_ATTRS.QUARTET | DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT ]; // em, px [ top, right, bottom, left ] + PaintPrivate.bgColor = [ DEF_ATTRS.PAINT, 16, DEF_ATTRS.COLOR ]; // color + PaintPrivate.bgAlpha = [ DEF_ATTRS.PAINT, 17, DEF_ATTRS.U_DECIMAL ]; // 0 - 1 + PaintPrivate.bgImgUrl = [ DEF_ATTRS.PAINT, 18, DEF_ATTRS.URL ]; // url + PaintPrivate.bgImgRepeatX = [ DEF_ATTRS.PAINT, 19, DEF_ATTRS.BOOLEAN ]; // true / false + PaintPrivate.bgImgRepeatY = [ DEF_ATTRS.PAINT, 20, DEF_ATTRS.BOOLEAN ]; // true / false + PaintPrivate.bgImgPositionX = [ DEF_ATTRS.PAINT, 21, DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT | DEF_ATTRS.LIST, DEF_ATTRS.POSITION_X ]; // em %, px, string + PaintPrivate.bgImgPositionY = [ DEF_ATTRS.PAINT, 22, DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT | DEF_ATTRS.LIST, DEF_ATTRS.POSITION_Y ]; // em %, px, string + PaintPrivate.shadowColor = [ DEF_ATTRS.PAINT, 23, DEF_ATTRS.COLOR ]; // color + PaintPrivate.shadowAlpha = [ DEF_ATTRS.PAINT, 24, DEF_ATTRS.U_DECIMAL ]; // 0 - 1 + PaintPrivate.shadowOffsetX = [ DEF_ATTRS.PAINT, 25, DEF_ATTRS.LENGTH ]; // em + PaintPrivate.shadowOffsetY = [ DEF_ATTRS.PAINT, 26, DEF_ATTRS.LENGTH ]; // em + PaintPrivate.shadowBlur = [ DEF_ATTRS.PAINT, 27, DEF_ATTRS.LENGTH ]; // em + PaintPrivate.shadowSpread = [ DEF_ATTRS.PAINT, 28, DEF_ATTRS.LENGTH ]; // em + PaintPrivate.shadowInset = [ DEF_ATTRS.PAINT, 29, DEF_ATTRS.BOOLEAN ]; // true / false + + TypoPrivate.color = [ DEF_ATTRS.PAINT, 0, DEF_ATTRS.COLOR ]; // color + TypoPrivate.fontFamily = [ DEF_ATTRS.REFLOW, 1, DEF_ATTRS.FONT_NAME ]; // string + TypoPrivate.fontSize = [ DEF_ATTRS.REFLOW, 2, DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT ]; // em, % + TypoPrivate.bold = [ DEF_ATTRS.REFLOW, 3, DEF_ATTRS.BOOLEAN ]; // true / false + TypoPrivate.italic = [ DEF_ATTRS.REFLOW, 4, DEF_ATTRS.BOOLEAN ]; // true / false + TypoPrivate.lineHeight = [ DEF_ATTRS.REFLOW, 5, DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT | DEF_ATTRS.NUMERICAL ]; // em, %, + TypoPrivate.letterSpacing = [ DEF_ATTRS.REFLOW, 6, DEF_ATTRS.LENGTH ]; // em + TypoPrivate.wordSpacing = [ DEF_ATTRS.REFLOW, 7, DEF_ATTRS.LENGTH ]; + TypoPrivate.align = [ DEF_ATTRS.REFLOW, 8, DEF_ATTRS.LIST, DEF_ATTRS.ALIGN ]; + TypoPrivate.decoration = [ DEF_ATTRS.PAINT, 9, DEF_ATTRS.LIST, DEF_ATTRS.TEXT_DECORATION ]; + TypoPrivate.transform = [ DEF_ATTRS.REFLOW, 10, DEF_ATTRS.LIST, DEF_ATTRS.TEXT_TRANSFORM ]; + TypoPrivate.shadowColor = [ DEF_ATTRS.PAINT, 11, DEF_ATTRS.COLOR ]; + TypoPrivate.shadowOffsetX = [ DEF_ATTRS.PAINT, 12, DEF_ATTRS.LENGTH ]; + TypoPrivate.shadowOffsetY = [ DEF_ATTRS.PAINT, 13, DEF_ATTRS.LENGTH ]; + TypoPrivate.shadowBlur = [ DEF_ATTRS.PAINT, 14, DEF_ATTRS.LENGTH ]; + + LayoutPrivate.width = [ DEF_ATTRS.REFLOW, 0, DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT, DEF_ATTRS.WIDTH_HEIGHT ]; + LayoutPrivate.minWidth = [ DEF_ATTRS.REFLOW, 1, DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT ]; + LayoutPrivate.maxWidth = [ DEF_ATTRS.REFLOW, 2, DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT ]; + LayoutPrivate.height = [ DEF_ATTRS.REFLOW, 3, DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT, DEF_ATTRS.WIDTH_HEIGHT ]; + LayoutPrivate.minHeight = [ DEF_ATTRS.REFLOW, 4, DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT ]; + LayoutPrivate.maxHeight = [ DEF_ATTRS.REFLOW, 5, DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT ]; + LayoutPrivate.padding = [ DEF_ATTRS.REFLOW, 6, DEF_ATTRS.QUARTET | DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT ]; + LayoutPrivate.margin = [ DEF_ATTRS.REFLOW, 10, DEF_ATTRS.QUARTET | DEF_ATTRS.LENGTH | DEF_ATTRS.PERCENT ]; + + + var NodePrivate = Class.create( + 'NodePrivate', + Class.PRIVATE_DATA | Class.POOL_OBJECT, + { + elmWrap : null, + textNode : null, + contentWidth : 0, + contentHeight : 0, + Constructor : function( __root, __parent ){ + this.__root = __root; + if( __parent ) this.__parent = __parent; + }, + paint : function( v ){ + if( v instanceof PaintStyle ){ + this.__paint && this.__paint.unRegister( this ); + this._paint = v; + this.__paint = PaintStyle.getPrivateData( v ); + this.__paint.register( this ); + return this.User; + } else + if( v === null ){ + this.__paint && this.__paint.unRegister( this ); + delete this._paint; + delete this.__paint; + return this.User; + }; + return this._paint; + }, + typo : function( v ){ + if( v instanceof TypoStyle ){ + this.__typo && this.__typo.unRegister( this ); + this._typo = v; + this.__typo = TypoStyle.getPrivateData( v ); + this.__typo.register( this ); + return this.User; + } else + if( v === null ){ + this.__typo && this.__typo.unRegister( this ); + delete this._typo; + delete this.__typo; + return this.User; + }; + return this._typo; + }, + /** + * 1. 要素の追加・削除 + * 2. auto 指定時は要素の高さ取得. + * 3. 親の許す子の最大サイズと自信のスタイル指定から、自身の位置とサイズを計算 + * 4. 描画更新リストに追加 + */ + reflow : function(){ + var content = this._textContent, + layout = this.__layout, + targetW = this.__parent.childWidth, + targetH = this.__parent.childHeight, + size, data, w, h; + + if( content || ( this.__paint && this.__paint.hasStyle === true ) || ( this.__typo && this.__typo.hasStyle === true ) ){ + if( !this.elmWrap ) this.elmWrap = DOM.createDiv(); + this.__parent.addDiv( this ); + if( conetnt ){ + if( !this.textNode ){ + this.textNode = DOM.cerateText(); + this.elmWrap.appendChild( this.textNode ); + }; + if( layout && ( layout.autoWidth === true || layout.autoHeight === true ) ){ + size = DOM.getTextSize( this.elmWrap, content ); + this.contentWidth = size[ 0 ]; + this.conetntHeight = size[ 1 ]; + }; + this.textNode.data = content; + } else + if( this.textNode ){ + DOM.correct( this.textNode ); + delete this.textNode; + delete this.contentWidth; + delete this.conetntHeight; + }; + this.currentWidth = this.elmWrap.offsetWidth; + this.currentHeight = this.elmWrap.offsetHeight; + } else + if( this.elmWrap ){ + DOM.correct( this.elmWrap ); + delete this.elmWrap; + delete this.textNode; + delete this.contentWidth; + delete this.conetntHeight; + delete this.currentWidth; + delete this.currentHeight + }; + + // this.__parent.layoutManager.reflow(); + }, + addDiv : function( nodeData ){ + + } + } + ); + var Node = Class.create( + 'Node', + Class.POOL_OBJECT, + NodePrivate, + { + Constructor : function( root, parent ){ + Node.newPrivateData( this, LayoutBox.getPrivateData( root ), parent ? LayoutBox.getPrivateData( parent ) : undefined, this ); + }, + paint : function( v ){ + return Node.getPrivateData( this ).paint( v ); + }, + typo : function( v ){ + return Node.getPrivateData( this ).typo( v ); + }, + remove : function(){ + Node.getPrivateData( this ).remove(); + }, + nodeIndex : function( v ){ + return Node.getPrivateData( this ).nodeIndex( v ); + }, + displayIndex : function(){ + + }, + disabled : function( v ){ + return Node.getPrivateData( this ).disabled( v ); + }, + cursor : function( v ){ + return Node.getPrivateData( this ).cursor( v ); + }, + getAbsolutePositionX : function(){ + return Node.getPrivateData( this ).getAbsolutePositionX(); + }, + getAbsolutePositionY : function(){ + return Node.getPrivateData( this ).getAbsolutePositionY(); + }, + addEventListener : function( type, handler, opt_thisObject ){ + Node.getPrivateData( this ).addEventListener( type, handler, opt_thisObject ); + }, + removeEventListener : function( type, handler ){ + Node.getPrivateData( this ).removeEventListener( type, handler ); + }, + scrollTo : function( x, y ){ + Node.getPrivateData( this ).scrollTo( x, y ); + }, + scrollX : function( v ){ + return Node.getPrivateData( this ).scrollX( v ); + }, + scrollY : function( v ){ + return Node.getPrivateData( this ).scrollY( v ); + } + } + ); + + var LayoutBoxPrivate = NodePrivate.inherits( + 'LayoutBoxPrivate', + Class.POOL_OBJECT, + { + Constructor : function( layoutManager, root, parent ){ + this.layoutManager = layoutManager; + this._root = _root; + if( _parent ) this._parent = _parent; + }, + reflow : function(){ + this.manager.reflow( this ); + }, + repaint : function(){ + this.manager.repaint( this ); + } + } + ); + + var LayoutBox = Node.inherits( + 'LayoutBox', + Class.POOL_OBJECT, + LayoutBoxPrivate, + { + Constructor : function( layoutManager, root, parent ){ + LayoutBox.newPrivateData( this, layoutManager, LayoutBox.getPrivateData( root ), parent ? LayoutBox.getPrivateData( parent ) : undefined ); + }, + layoutManager : function( v ){ + + }, + createLayoutBox : function(){ + + }, + createContentBox : function(){ + + } + } + ); + +})( window, document ); + })( window, document ); -- 2.11.0