return UA.isIE === true && UA.ieRenderingVersion < 8 ? _OLD_IE : _MODERN;
})();
- this.$ = jqTextElementOrigin.clone( true );
- this.data = data;
- this.elmText = this.$.find( 'td,.speach-inner' ).get( 0 );
- this.type = data.balloon_template_id || data.balloon_template.id;
- this.content = '';
-
- var speachs = data.speeches;
- for( var k in speachs ){
- this.content += speachs[ k ].content || '';
+ this.$ = jqTextElementOrigin.clone( true );
+ this.data = data;
+ this.elmText = this.$.find( 'td,.speach-inner' ).get( 0 );
+ this.templete = data.balloon_template_id || data.balloon_template.id;
+ this.tempName = data.classname;
+ this.content = '';
+
+ var speaches = data.speeches;
+ for( var k in speaches ){
+ this.content += speaches[ k ].content || '';
};
var balloons = data.balloons,
break;
};
};
- // this.balloon = pettanr.balloon.createBalloon( data.width, data.height, data.tail, this.type );
- this.balloon = pettanr.newBalloon.create( this.type, balloonData.width, balloonData.height, balloonData.settings );
+
+ this.balloon = pettanr.newBalloon.create( this.templete, balloonData.width, balloonData.height, data.settings || balloonData.settings );
+ this.a = this.balloon.a;
data.x = balloonData.x;
data.y = balloonData.y;
data.width = balloonData.width;
this.resize( this.data.x, this.data.y, this.data.width, this.data.height, this.data.tail );
this.init = null;
},
- /*
- _updateType : function( _type ){
- if( this.type !== _type ){
- this.type = _type || this.type;
- this.balloon.type( this.type );
- };
- }, */
_updateAngle : function( _a ){
if( _a !== undefined && a !== _a ){
this.a = _a !== undefined ? _a : this.a;
if( data.classname ){
data = {
balloon_template_id : data.id,
+ classname : data.classname,
z : -1,
t : 0,
balloons : {
height : 200,
x : Math.floor( panelW / 2 - 100 + Math.random() * 10 ),
y : Math.floor( panelH / 2 - 100 + Math.random() * 10 ),
- settings : {}
+ settings : '0'
}
},
speeches : {
'"width": ', _imageElement.flipH * _imageElement.w, ',', cr,
'"height": ', _imageElement.flipV * _imageElement.h, cr,
'}'
- ].join( '');
+ ].join( '' );
};
function balloonToJson( _textElement, t ){
var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
return [
'{', cr,
- '"speech_balloon_template_id": ', _textElement.type, ',', cr,
- '"classname": "Square",',
+ '"speech_balloon_template_id": ', _textElement.templete, ',', cr,
+ '"classname": "', _textElement.tempName, '",', cr,
'"z": ', _textElement.z + 1, ',', cr,
'"t": ', t, ',', cr,
- '"settings": "{\'tail\':' + _textElement.a + '}",',
+ '"settings": "', _textElement.a, '",', cr,
'"balloons_attributes": {', cr,
'"newb', t, '": {', cr,
'"system_picture_id": ', _textElement.balloon.src, ',', cr,
return [
'{', cr,
panelID !== -1 ? ( '"id": ' + panelID + ',' + cr ) : '',
+ //panelID !== -1 ? ( '"panel_id": ' + panelID + ',' + cr ) : '',
// comicID !== -1 ? ( '"comic_id": ' + comicID + ',' + cr ) : '',
'"width": ', panelW, ',', cr,
'"height": ', panelH, ',', cr,
/*\r
* pettanR peta.common.js\r
- * version 0.5.52\r
+ * version 0.5.53\r
* \r
* author:\r
* itozyun\r
round = Math.round,\r
floor = Math.floor,\r
TARGET = TAIL_WIDTH * TAIL_WIDTH,\r
- isFinit = Type.isFinite,\r
+ isFinite = Type.isFinite,\r
ACCURACY = 1, // 有効少数桁 \r
cround = function( v, r ){\r
r = r || ACCURACY;\r
h : 0,\r
a : 0,\r
resize : function ( _a, _w, _h ){\r
- this.w = isFinit( _w ) === true ? _w - PADDING_TOP * 2 : this.w;\r
- this.h = isFinit( _h ) === true ? _h - PADDING_LEFT * 2 : this.h;\r
+ this.w = isFinite( _w ) === true ? _w - PADDING_TOP * 2 : this.w;\r
+ this.h = isFinite( _h ) === true ? _h - PADDING_LEFT * 2 : this.h;\r
// ie6 でリサイズが反応しない対策\r
if( vectorEnabled === false && UA.isIE === true && UA.ieVersion < 7 ){\r
var parent = this.elm.parentNode;\r
this.angle( _a );\r
},\r
angle : function( _a ){\r
- if( isFinit( _a ) === true ){\r
+ if( isFinite( _a ) === true ){\r
this.a = _a;\r
if( vectorEnabled === false ){\r
this.elm.src = pettanr.balloon.getBalloonUrl( this.w, this.h, _a );\r
shape.strokecolor = "black";\r
shape.strokeweight = STROKE_WIDTH;\r
shape.fillcolor = "white";\r
- ret.appendChild( shape);\r
+ ret.appendChild( shape );\r
} else {\r
var kSVGNS = 'http://www.w3.org/2000/svg';\r
// http://modernizr.com/downloads/modernizr.js\r
getPath : null,\r
args : null,\r
update : IS_VML === true ?\r
- function( /* w, h [, angle, ,,, ] */ ){\r
+ ( function( /* w, h [, angle, ,,, ] */ ){\r
var w = arguments[ 0 ],\r
h = arguments[ 1 ];\r
- var path = this.getPath.call( this.klass, arguments );\r
+ var path = this.getPath.apply( this.klass, arguments );\r
if( !path ) return false;\r
path = /* SVG2VML */ path;\r
this.path.style.width = w + 'px';\r
this.path.path = path;\r
// this.elm.style.marginTop = _tailY < 0 ? floor( ( 60 + _tailY) / 10 ) : 10;\r
// this.elm.style.marginLeft = _tailX < 0 ? floor( ( 60 + _tailX) / 10 ) : 10;\r
- } :\r
- function( /* w, h [, angle, ,,, ] */ ){\r
+ }) :\r
+ ( function( /* w, h [, angle, ,,, ] */ ){\r
var w = arguments[ 0 ],\r
h = arguments[ 1 ],\r
- d = this.getPath.call( this.klass, arguments );\r
+ d = this.getPath.apply( this.klass, arguments );\r
if( !d ) return false;\r
this.elm.width = w + PADDING_LEFT * 2;\r
this.elm.height = h + PADDING_TOP * 2;\r
this.path.setAttribute( 'd', d );\r
- },\r
+ }),\r
destroy : function(){\r
this.elm.parentNode && this.elm.parentNode.removeChild( this.elm );\r
delete this.elm;\r
getPictureID : null,\r
args : null,\r
update : function( /* w, h [, angle, ,,, ] */ ){\r
- var id = this.getPictureID.call( this.klass, arguments );\r
+ var id = this.getPictureID.aplly( this.klass, arguments );\r
if( id !== 0 && !id ) return false;\r
this.elm.src = PICTURE_PATH + id + '.gif';\r
},\r
//this.defaultW = templete.default_width;\r
//this.defaultH = templete.default_height;\r
//this.sizeCount = templete.size_count;\r
- this.wOffset = templete.speech_balloon.width_offset;\r
- this.hOffset = templete.speech_balloon.height_offset;\r
- this.wStep = templete.speech_balloon.width_step;\r
- this.hStep = templete.speech_balloon.height_step;\r
- // r_offset\r
- // r_steps\r
+ var sb = templete.speech_balloon;\r
+ var v, p;\r
\r
- var obj = templete, v, p;\r
+ this.wOffset = sb.width_offset;\r
+ this.hOffset = sb.height_offset;\r
+ this.wStep = sb.width_step;\r
+ this.hStep = sb.height_step;\r
+\r
// 2013.3.31 itozyun's memo\r
// 以下の使いやすく加工する処理は pettanr.balloon.register() 内に移動してもよさそう\r
// new TempleteClass( templeteJson );\r
// NonVectorBalloon.templete.defaultW みたいにアクセス\r
- if( templete.speech_balloon.size_count && 1 < templete.speech_balloon.size_count ){\r
+ if( sb.size_count && 1 < sb.size_count ){\r
this.picIDs = []; // system picture id list\r
for( p in templete ){\r
if( p === 'speech_balloon' ) continue;\r
- v = obj[ p ];\r
+ if( '' + parseInt( p ) === p ) continue;\r
+ v = templete[ p ];\r
this.picIDs[ this.picIDs.length ] = v.balloon.system_picture_id;\r
- }; \r
+ };\r
+ if( !this.rOffset ) return;\r
+ // tail\r
+ //\r
+ } else\r
+ if( sb.r_offset && sb.r_step ){\r
+ this.rOffset = sb.r_offset;\r
+ this.rSteps = sb.r_step;\r
+ this.tailIDs = [];\r
+ for( p in templete ){\r
+ if( '' + parseInt( p ) !== p ) continue;\r
+ v = templete[ p ];\r
+ this.tailIDs[ this.tailIDs.length ] = v.balloon.system_picture_id;\r
+ };\r
} else {\r
- for( p in obj ){\r
+ for( p in templete ){\r
if( p === 'speech_balloon' ) continue;\r
- v = obj[ p ];\r
+ if( '' + parseInt( p ) === p ) continue;\r
+ v = templete[ p ];\r
this.picID = v.balloon.system_picture_id;\r
break;\r
};\r
args : null,\r
picIDs : null,\r
picID : 0,\r
+ tailIDs : null,\r
src : 0,\r
w : 0,\r
h : 0,\r
- update : function( w, h /* [, angle, ,,, ] */ ){\r
- var l, id, _w, _h;\r
+ a : 0,\r
+ update : function( w, h, a /* [, ,,, ] */ ){\r
+ var l, id, _w, _h, d;\r
if( this.picIDs ){\r
_w = ( w - this.wOffset ) / this.wStep;\r
_h = ( h - this.hOffset ) / this.hStep;\r
_w = _w < 0 ? 0 : ( _w > l ? l : _w );\r
_h = _h < 0 ? 0 : ( _h > l ? l : _h );\r
id = this.picIDs[ Math.floor( _w > _h ? _w : _h ) ];\r
+ // tail\r
+ //\r
+ } else\r
+ if( this.tailIDs ){\r
+ this.a = a;\r
+ d = this.rSteps;\r
+ a = a + d / 2;\r
+ id = this.tailIDs[ a < 360 - d / 2 ? Math.floor( a / d ) : 0 ];\r
} else {\r
id = this.picID;\r
};\r
+\r
if( this.src !== id ){\r
this.elm.src = PICTURE_PATH + id + '.gif';\r
this.src = id;\r
TEMPLETES[ id ] = templete;\r
};\r
},\r
- create : function( idOrName, w, h /* [, angle, ,,, ] */ ){\r
- var ret;\r
+ create : function( idOrName, w, h, settings ){\r
+ var ret,\r
+ args = settings.split( ',' ),\r
+ i = args.length,\r
+ v;\r
if( Type.isString( idOrName ) === true && idOrName in window ){\r
ret = new BalloonClass( window[ idOrName ] );\r
} else {\r
ret = new NonVectorBalloonClass( TEMPLETES[ idOrName ] );\r
};\r
- ret.update( w, h /* [, angle, ,,, ] */ );\r
+ for( ; i; ){\r
+ v = args[ --i ];\r
+ args[ i ] = parseInt( v );\r
+ };\r
+ args.unshift( h );\r
+ args.unshift( w );\r
+ ret.update.apply( ret, args );\r
return ret;\r
},\r
isTemplete : function( templete ){\r