From 427d907328dadd487acc03c45f2977196f6d286d Mon Sep 17 00:00:00 2001 From: itozyun Date: Tue, 12 Mar 2013 06:31:34 +0900 Subject: [PATCH] cleanup pettanr.balloon --- 0.5.x/javascripts/peta-apps.js | 29 ++++++-- 0.5.x/javascripts/peta-common.js | 139 ++++++++++++++++++++++----------------- 0.5.x/javascripts/system.js | 10 ++- 0.5.x/javascripts/xdoc.js | 10 +-- 4 files changed, 116 insertions(+), 72 deletions(-) diff --git a/0.5.x/javascripts/peta-apps.js b/0.5.x/javascripts/peta-apps.js index 1d822e6..08ae46d 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.47 + * version 0.5.48 * * author: * itozyun @@ -87,7 +87,15 @@ data = createFileData( json, LICENSE_GROUP_ARRAY, 'name,caption,url,classname' ); addChildData( FILE_DATA_LISENCE_GROUP, data ); break; - + + // Speech Balloon Templete + case FILE_DATA_BALLOON_ROOT : + case BALLOON_TEMPLETE_ARRAY : + json.type = FILE_TYPE.BALLOON_TEMPLETE; + data = createFileData( json, BALLOON_TEMPLETE_ARRAY, 'name,caption,classname,settings' ); + addChildData( FILE_DATA_BALLOON_ROOT, data ); + break; + // Author case FILE_DATA_AUTHOR_ROOT : case AUTHOR_ARRAY : @@ -338,6 +346,8 @@ return [ data.name, '先生' ].join( '' ); case FILE_TYPE.ARTIST : return [ data.name, '画伯' ].join( '' ); + case FILE_TYPE.BALLOON_TEMPLETE : + return [ data.id, data.caption ].join( ':' ); case FILE_TYPE.FOLDER : }; return data.name; @@ -370,6 +380,8 @@ return { className: 'file-type-author' }; case FILE_TYPE.ARTIST : return { className: 'file-type-artist' }; + case FILE_TYPE.BALLOON_TEMPLETE : + return { className: 'file-type-balloon' }; case FILE_TYPE.FOLDER : return { className: 'file-type-folder' }; }; @@ -400,6 +412,8 @@ return 'author id:' + data.id; case FILE_TYPE.ARTIST : return [ 'artist id:', data.id, ' Email:', data.email || 'empty' , ', HP:', data.homepage_url || 'empty' ].join( '' ); + case FILE_TYPE.BALLOON_TEMPLETE : + return data.name + ', ' + data.settings; case FILE_TYPE.FOLDER : return 'pettanR folder'; }; @@ -488,14 +502,15 @@ STORY : FileAPI.createFileTypeID(), PANEL : FileAPI.createFileTypeID(), PANEL_ELEMENT : FileAPI.createFileTypeID(), - BALLOON : FileAPI.createFileTypeID(), + BALLOON : FileAPI.createFileTypeID(), + BALLOON_TEMPLETE : FileAPI.createFileTypeID(), ORIGINAL_PICTURE : FileAPI.createFileTypeID(), RESOURCE_PICTURE : FileAPI.createFileTypeID(), PICTURE : FileAPI.createFileTypeID(), AUTHOR : FileAPI.createFileTypeID(), ARTIST : FileAPI.createFileTypeID(), LICENSE : FileAPI.createFileTypeID(), - LICENSE_GROUP : FileAPI.createFileTypeID() + LICENSE_GROUP : FileAPI.createFileTypeID(), } ), AUTHOR_ARRAY = [], @@ -616,9 +631,11 @@ children: [] }, FILE_DATA_BALLOON_ROOT = { - name: 'Balloon templetes', + name: 'Balloon Templetes', type: FILE_TYPE.FOLDER, - children: [] + children: [], + driver: Driver, + json: pettanr.CONST.SPEECH_BALOON_TEMPLETE }; FILE_DATA_SERVICE_ROOT.children.push( FILE_DATA_COMICS_ROOT, FILE_DATA_RESOURCE_PICTURES_ROOT, FILE_DATA_ORIGINAL_PICTURES_ROOT, FILE_DATA_LISENCE_ROOT, FILE_DATA_BALLOON_ROOT ); FILE_DATA_COMICS_ROOT.children.push( FILE_DATA_MY_COMICS_ROOT, FILE_DATA_LATEST_COMICS, FILE_DATA_AUTHOR_ROOT, FILE_DATA_STORY_ROOT, FILE_DATA_PANELS_ROOT ); diff --git a/0.5.x/javascripts/peta-common.js b/0.5.x/javascripts/peta-common.js index 8b49c55..0237fc7 100644 --- a/0.5.x/javascripts/peta-common.js +++ b/0.5.x/javascripts/peta-common.js @@ -1,6 +1,6 @@ /* * pettanR peta.common.js - * version 0.5.47 + * version 0.5.48 * * author: * itozyun @@ -93,6 +93,7 @@ pettanr.CONST = ( function(){ URL_MY_COMICS_JSON : ( SERVER_SUPPORT === false ? 'json\/' : PETTANR_ROOT_PATH ) + 'home\/comic.json', URL_PANELS_JSON : ( SERVER_SUPPORT === false ? 'json\/' : PETTANR_ROOT_PATH ) + 'panels.json', URL_MY_PANELS_JSON : ( SERVER_SUPPORT === false ? 'json\/' : PETTANR_ROOT_PATH ) + 'home\/panel.json', + SPEECH_BALOON_TEMPLETE : ( SERVER_SUPPORT === false ? 'json\/' : PETTANR_ROOT_PATH ) + 'speech_balloon_templates.json\/', NS_PETTANR_COMIC : 'pettanr-comic', THUMBNAIL_PATH : SERVER_SUPPORT === false ? RELATIVE + 'resource_pictures\/thumbnail\/' : PETTANR_ROOT_PATH + 'resource_pictures\/', RESOURCE_PICTURE_PATH : SERVER_SUPPORT === false ? RELATIVE + 'resource_pictures\/' : PETTANR_ROOT_PATH + 'resource_pictures\/full\/', @@ -147,7 +148,7 @@ pettanr.balloon = ( function() { ELM_BALLOON_ORIGIN = ( function(){ var ret; try { - if( IS_VML === true){ + if( IS_VML === true ){ ret = document.createElement( 'DIV'); var shape = document.createElement( 'v:shape'); shape.coordorigin = "0,0"; @@ -187,22 +188,57 @@ pettanr.balloon = ( function() { TARGET = TAIL_WIDTH * TAIL_WIDTH, isFinit = Type.isFinite, ACCURACY = 1, // 有効少数桁 - cround = function ( v, r ){ + cround = function( v, r ){ r = r || ACCURACY; return round( v * pow( 10.0, r )) / pow( 10.0, r ); }, DEG_TO_RAD = Math.PI / 180; var XBROWSER_BALLOON_CLASS = function( w, h, a ){ - var balloonElm = vectorEnabled === true ? ELM_BALLOON_ORIGIN.cloneNode( true ) : document.createElement( 'img' ), // pettanr.imageに変更 - path = balloonElm.getElementsByTagName( 'path' )[ 0 ], - shape = balloonElm.getElementsByTagName( 'shape' )[ 0 ], - instance = this, - l = ','; - - function draw( _a ){ - var rx = w / 2, - ry = h / 2, + this.elm = vectorEnabled === true ? ELM_BALLOON_ORIGIN.cloneNode( true ) : document.createElement( 'img' ); // pettanr.imageに変更 + this.path = this.elm.getElementsByTagName( IS_VML === true ? 'shape' : 'path' )[ 0 ]; + this.resize( a, w, h ); + }; + XBROWSER_BALLOON_CLASS.prototype = { + elm : null, + path : null, + w : 0, + h : 0, + a : 0, + resize : function ( _a, _w, _h ){ + this.w = isFinit( _w ) === true ? _w - PADDING_TOP * 2 : this.w; + this.h = isFinit( _h ) === true ? _h - PADDING_LEFT * 2 : this.h; + // ie6 でリサイズが反応しない対策 + if( vectorEnabled === false && UA.isIE === true && UA.ieVersion < 7 ){ + var parent = this.elm.parentNode; + parent.removeChild( this.elm ); + parent.insertBefore( this.elm, parent.firstChild ); + }; + this.angle( _a ); + }, + angle : function( _a ){ + if( isFinit( _a ) === true ){ + this.a = _a; + if( vectorEnabled === false ){ + this.elm.src = pettanr.balloon.getBalloonUrl( this.w, this.h, _a ); + } else { + this.draw( _a ); + }; + }; + return this.a; + }, + type : function( _type ){ + //draw( _a); + }, + destroy : function(){ + this.elm.parentNode && this.elm.parentNode.removeChild( this.elm ); + delete this.elm; + delete this.path; + }, + draw : function( _a ){ + var rx = this.w / 2, + ry = this.h / 2, + l = ',', tailRad = _a * DEG_TO_RAD, tailX = rx + ( rx + TAIL_HEIGHT ) * sin( tailRad ), tailY = ry - ( ry + TAIL_HEIGHT ) * cos( tailRad ), @@ -215,7 +251,7 @@ pettanr.balloon = ( function() { tailDeg = 0, d; for( var i = 45; i > 0.01; i /= 2){ - d = ( tailDeg + i ) /2; + d = ( tailDeg + i ) / 2; startRad = ( _a + d ) * DEG_TO_RAD; endRad = ( _a - d ) * DEG_TO_RAD; @@ -239,27 +275,27 @@ pettanr.balloon = ( function() { if( IS_VML === true ){ var _tailX = tailX *10, _tailY = tailY *10, - __w = w *10, - __h = h *10; + __w = this.w *10, + __h = this.h *10; - shape.style.width = w + 'px'; - shape.style.height = h + 'px'; - shape.coordsize = [ __w, __h ].join( l ); - shape.path = [ + this.path.style.width = this.w + 'px'; + this.path.style.height = this.h + 'px'; + this.path.coordsize = [ __w, __h ].join( l ); + this.path.path = [ ' ar ', 0, l, 0, l, __w, l, __h, l, round( endX * 10 ), l, round( endY * 10 ), l, round( startX * 10 ), l, round( startY * 10 ), ' l ', round( _tailX ), l, round( _tailY ), ' x e' - ].join( ''); + ].join( '' ); - balloonElm.style.marginTop = _tailY < 0 ? floor( ( 60 + _tailY) / 10 ) : 10; - balloonElm.style.marginLeft = _tailX < 0 ? floor( ( 60 + _tailX) / 10 ) : 10; + this.elm.style.marginTop = _tailY < 0 ? floor( ( 60 + _tailY) / 10 ) : 10; + this.elm.style.marginLeft = _tailX < 0 ? floor( ( 60 + _tailX) / 10 ) : 10; } else { - balloonElm.setAttribute( 'width', w + PADDING_LEFT *2 ); - balloonElm.setAttribute( 'height', h + PADDING_TOP *2 ); - path.setAttribute( 'd', [ - 'M', cround( tailX + PADDING_LEFT ), l, cround( tailY + PADDING_TOP ), + this.elm.setAttribute( 'width', this.w + PADDING_LEFT *2 ); + this.elm.setAttribute( 'height', this.h + PADDING_TOP *2 ); + this.path.setAttribute( 'd', [ + 'M', cround( tailX + PADDING_LEFT ), l, cround( tailY + PADDING_TOP ), 'L', cround( startX + PADDING_LEFT ), l, cround( startY + PADDING_TOP ), 'A', rx, l, ry, '0 1 1', // flag @@ -268,40 +304,6 @@ pettanr.balloon = ( function() { ].join( ' ')); } } - - this.elm = balloonElm; - this.resize = function ( _a, _w, _h ){ - w = isFinit( _w ) === true ? _w - PADDING_TOP * 2 : w; - h = isFinit( _h ) === true ? _h - PADDING_LEFT * 2 : h; - // ie6 でリサイズが反応しない対策 - if( vectorEnabled === false && UA.isIE === true && UA.ieVersion < 7 ){ - var parent = balloonElm.parentNode; - parent.removeChild( balloonElm ); - parent.insertBefore( balloonElm, parent.firstChild ); - } - instance.angle( _a ); - }; - this.angle = function( _a ){ - if( isFinit( _a ) === true ){ - a = _a; - if( vectorEnabled === false ){ - balloonElm.src = pettanr.balloon.getBalloonUrl( w, h, _a ); - } else { - draw( _a ); - } - } - return a; - } - this.type = function( _type ){ - //draw( _a); - } - this.destroy = function(){ - delete instance.destroy; - balloonElm.parentNode && balloonElm.parentNode.removeChild( balloonElm ); - balloonElm = path = shape = instance = null; - } - - instance.resize( a, w, h ); }; return { @@ -329,6 +331,20 @@ pettanr.balloon = ( function() { } })(); +pettanr.newBalloon = ( function(){ + return { + register : function( className ){ + + }, + isBalloonClass : function(){ + + }, + isBalloonInstance : function(){ + + } + } +})(); + /* ---------------------------------------- * pettanr.image * @@ -348,7 +364,8 @@ pettanr.balloon = ( function() { * - VML * - flash(lite) * - silverlight - * + * - pettan server + * * -moz-transform:scale( -1, -1); */ pettanr.image = ( function(){ diff --git a/0.5.x/javascripts/system.js b/0.5.x/javascripts/system.js index 7ab89d8..364938c 100644 --- a/0.5.x/javascripts/system.js +++ b/0.5.x/javascripts/system.js @@ -1,6 +1,6 @@ /* * pettanR system.js - * version 0.5.47 + * version 0.5.48 * * gadgetOS * author: @@ -301,6 +301,14 @@ var Class = ( function(){ if( iList.length !== 0 ) return; delete def.callbackInstanceList; delete def.callbackRegisterList; + }, + listenTo : function( eventDispatcher, eventType, callback ){ + //if( eventDispatcher instanceof EventDsipatcher ){ + eventDispatcher.addEventListener( eventType, callback, this ); + //} + }, + unlistenTo : function( eventDispatcher, eventType, callback ){ + } }; diff --git a/0.5.x/javascripts/xdoc.js b/0.5.x/javascripts/xdoc.js index 712ba3d..c47c14f 100644 --- a/0.5.x/javascripts/xdoc.js +++ b/0.5.x/javascripts/xdoc.js @@ -1463,10 +1463,12 @@ var XDocument = ( function( window, document ){ }, style : function( v ){ if( v instanceof NodeStyle ){ - this.__style && this.__style.unRegister( this ); - this._style = v; - this.__style = StylePrivate.getPrivateData( v ); - this.__style.register( this ); + if( v !== this._style ){ + this.__style && this.__style.unRegister( this ); + this._style = v; + this.__style = StylePrivate.getPrivateData( v ); + this.__style.register( this ); + }; return this.User; } else if( v === null ){ -- 2.11.0