/*
* pettanR system.js
- * version 0.4.26
+ * version 0.4.27
*
* author:
* itozyun
THUMB_PATH = BASE_PATH, // + 'thumbnail/',
LIMIT_FILESIZE = 1024 * 10; // 10KB
- var ImageGroupIconClass = function( INDEX, file ){
- var elmIconWrap = elmIconOrigin.cloneNode( true ),
- elmIconTitle = pettanr.util.getElementsByClassName( elmIconWrap, 'image-group-item-title' )[ 0 ],
- data = pettanr.driver._getAPI().getFileData( file ),
- SRC = [ BASE_PATH, data.id, '.', data.ext ].join( ''),
- LOW_SRC = data.filesize && data.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext ].join( '') : null,
+ var ImageGroupIconClass = function( INDEX, data ){
+ var elmIconWrap = elmIconOrigin.cloneNode( true ),
+ elmIconTitle = pettanr.util.getElementsByClassName( elmIconWrap, 'image-group-item-title' )[ 0 ],
+ SRC = [ BASE_PATH, data.id, '.', data.ext ].join( ''),
+ LOW_SRC = data.filesize && data.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext ].join( '') : null,
reversibleImage = null,
- onEnterFlag = false,
- imgW, imgH;
+ timer = null,
+ onEnterFlag = false,
+ instance = this;
elmContainer.appendChild( elmIconWrap );
elmIconWrap.style.left = ( INDEX * itemW ) + 'px';
elmIconTitle.appendChild( document.createTextNode( data.filesize + 'bytes' ) );
- file.destroy();
- file = null;
-
function onImageLoad( url, _imgW, _imgH ){
- if( reversibleImage === null) {
- alert( url);
- return;
- }
- data.width = imgW = _imgW || data.width || 64;
- data.height = imgH = _imgH || data.height || 64;
- elmIconTitle.firstChild.data = imgW + 'x' + imgH;
- var zoom = 128 /( imgW > imgH ? imgW : imgH),
- MATH_FLOOR = Math.floor
- h = MATH_FLOOR( imgH *zoom ),
- w = MATH_FLOOR( imgW *zoom );
+ data.width = _imgW = _imgW || data.width || 64;
+ data.height = _imgH = _imgH || data.height || 64;
+ elmIconTitle.firstChild.data = _imgW + 'x' + _imgH;
+ var zoom = 128 /( _imgW > _imgH ? _imgW : _imgH ),
+ MATH_FLOOR = Math.floor,
+ h = MATH_FLOOR( _imgH * zoom ),
+ w = MATH_FLOOR( _imgW * zoom );
reversibleImage.elm.style.cssText = [
- 'width:', w, 'px;',
- 'height:', h +'px;',
- 'margin:', MATH_FLOOR( itemH /2 -h /2 ), 'px ', MATH_FLOOR( itemW /2 -w /2 ), 'px 0'
+ 'width:', w, 'px;',
+ 'height:', h, 'px;',
+ 'margin:', MATH_FLOOR( itemH / 2 - h / 2 ), 'px ', MATH_FLOOR( itemW / 2 - w / 2 ), 'px 0'
].join('');
reversibleImage.resize( w, h );
elmIconWrap.onclick = onClick;
onUpdateData = data;
pettanr.premiumSatge.shutdown();
}
- return {
- onEnter: function(){
- if( onEnterFlag === true || data === null ) return; // data === null : destroyed
- reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onImageLoad );
- elmIconWrap.appendChild( reversibleImage.elm );
- onEnterFlag = true;
- },
- destroy: function(){
- reversibleImage && reversibleImage.destroy();
- // pettanr.util.removeAllChildren( elmIconWrap );
- elmContainer.removeChild( elmIconWrap );
- elmIconWrap.onclick = null;
- reversibleImage = elmIconWrap = elmIconTitle = data = null;
- delete this.destroy;
- }
+
+ function asyncDraw(){
+ reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onImageLoad );
+ elmIconWrap.appendChild( reversibleImage.elm );
+ onEnterFlag = true;
+ timer = null;
+ }
+
+ this.onEnter = function( delay ){
+ timer = window.setTimeout( asyncDraw, delay );
+ delete instance.onEnter;
+ }
+ this.destroy = function(){
+ delete instance.destroy;
+ timer && window.clearTimeout( timer );
+ reversibleImage && reversibleImage.destroy();
+ pettanr.util.removeAllChildren( elmIconWrap );
+ elmContainer.removeChild( elmIconWrap );
+ elmIconWrap.onclick = '';
+ reversibleImage = elmIconWrap = elmIconTitle = data = timer = null;
}
}
function onEnterShowImage(){
var l = ICON_ARRAY.length,
_start = -wrapX /itemW -1,
- _end = _start + winW /itemW +1;
- for( var i=0; i<l; ++i){
- _start < i && i < _end && ICON_ARRAY[ i ].onEnter();
+ _end = _start + winW /itemW +1,
+ _icon;
+ for( var i=0, c = 0; i<l; ++i){
+ _icon = ICON_ARRAY[ i ];
+ if( _start < i && i < _end && _icon.onEnter ){
+ _icon.onEnter( c * 100 );
+ c++;
+ }
}
onEnterInterval !== null && window.clearTimeout( onEnterInterval );
onEnterInterval = null;
id: artistID,
type: pettanr.driver.FILE_TYPE.ARTIST
})[ 0 ],
- _artistFile = ARTIST_ROOT_FILE.getChildFileByIndex( _index );
+ _artistFile = ARTIST_ROOT_FILE.getChildFileByIndex( _index ),
+ _file;
if( _artistFile !== null ){
for(var i=0, l=_artistFile.getChildFileLength(); i<l; ++i ){
- ICON_ARRAY.push( new ImageGroupIconClass( i, _artistFile.getChildFileByIndex( i ) ));
+ _file = _artistFile.getChildFileByIndex( i );
+ ICON_ARRAY.push( new ImageGroupIconClass( i, pettanr.driver._getAPI().getFileData( _file ) ));
+ _file.destroy();
}
elmName.firstChild.data = _artistFile.getName();
_artistFile.destroy();
function clickOK(){
textElement && textElement.text( jqTextarea.val() );
- onUpdateFunction && onUpdateFunction( textElement );
+ onUpdateFunction ? window.setTimeout( asyncCallback, 50 ) : pettanr.textEditor.shutdown();
+ }
+
+ function asyncCallback(){
+ onUpdateFunction( textElement );
pettanr.textEditor.shutdown();
}
return false;
}
}
+ function textareaFitHeight(){
+ var rows = 0;
+ while( jqTextarea.height() < textElement.h ){
+ rows++;
+ jqTextarea.attr( 'rows', rows );
+ }
+ rows > 1 && jqTextarea.attr( 'rows', --rows );
+ }
/* grobal method */
// this.rootElement = elmWrap;
this.MIN_WIDTH = 320;
this.MIN_HEIGHT = 320;
this.init = function(){
- instance.jqWrap = jqWrap = $( '#speach-editor-wrapper' ).hide();
+ jqWrap = $( '#speach-editor-wrapper' ).hide();
jqTextarea = $( '#speach-editor' ).keydown( keyCancel );
- jqButton = $( '#speach-edit-complete-button').click( clickOK );
+ jqButton = $( '#speach-edit-complete-button').click( clickOK );
delete instance.init;
}
- this.jqWrap = null;
this.onOpen = function( _w, _h, _panelX, _panelY, _textElement, _onUpdateFunction ){
instance.init && instance.init();
textElement = _textElement;
onUpdateFunction = _onUpdateFunction || null;
- var h = _textElement.h;
-
+ jqWrap.show();
instance.onPaneResize( _w, _h );
jqTextarea.val( _textElement.text() ).focus();
/*
* ie6,7は、textarea { width:100%}でも高さが変わらない。rowsを設定。
*/
- pettanr.ua.isIE === true && pettanr.ua.ieVersion <= 7 && setTimeout( function(){
- var rows = 0;
- while( jqTextarea.height() < h){
- rows++;
- jqTextarea.attr( 'rows', rows);
- }
- rows > 1 && jqTextarea.attr( 'rows', rows -1 );
- }, 0);
+ pettanr.ua.isIE === true && pettanr.ua.ieVersion <= 7 && setTimeout( textareaFitHeight, 0);
}
this.onPaneResize = function( _w, _h ){
- jqWrap.show().css( {
+ jqWrap.css( {
left: textElement.x + panelX,
top: textElement.y + panelY,
width: textElement.w,
}
this.onClose = function(){
jqWrap.hide();
- textElement = onUpdateFunction = null;
+ textElement = onUpdateFunction = null;
}
});
/*\r
* pettanR work.js\r
- * version 0.4.26\r
+ * version 0.4.27\r
* \r
* author:\r
* itozyun\r
function edit(){\r
if( currentElement === null || currentElement.type !== PANEL_ELEMENT_TYPE_TEXT) return;\r
pettanr.textEditor.bootInOverlay( PANEL_CONTROL.x(), PANEL_CONTROL.y(), currentElement );\r
- buttonBackOrForward( true);\r
+ buttonBackOrForward( true );\r
}\r
function change(){\r
if( currentElement === null) return;\r
})();\r
\r
var JQ_WRAPPER = jqTextElementOrigin.clone( true ),\r
- TEXT_ELM = JQ_WRAPPER.find( 'td,.speach-inner').eq( 0),\r
+ elmText = JQ_WRAPPER.find( 'td,.speach-inner' ).get( 0 ),\r
type = data.balloon_template_id,\r
text = ( function(){\r
var _speachs = data.speaches_attributes;\r
}\r
function updateText( _text ){\r
text = _text || text || '';\r
- TEXT_ELM.html( text );\r
+ elmText.firstChild.data = text;\r
}\r
function resizeBalloon(){\r
balloon && balloon.resize( a, w, h );\r
delete instance.init;\r
}\r
this.angle = function( _a ){\r
- _a !== undefined && instance.resize( undefined, undefined, undefined, undefined, _a );\r
+ _a !== undefined && instance.resize( x, y, w, h, _a );\r
return a;\r
}\r
- this.text = function( _text){\r
+ this.text = function( _text ){\r
if( _text && text !== _text) {\r
HISTORY_CONTROL.saveState( updateText, text || '', _text );\r
- updateText( _text);\r
+ updateText( _text );\r
}\r
return text;\r
}\r
animate !== true && resizeBalloon();\r
}\r
this.animate = function ( _x, _y, _w, _h, _a ){\r
- instance.resize( _x, _y, _w, _h, _a, true);\r
+ instance.resize( _x, _y, _w, _h, _a, true );\r
}\r
this.destroy = function(){\r
delete instance.destroy;\r
\r
JQ_WRAPPER.stop().remove();\r
balloon.destroy();\r
- JQ_WRAPPER = TEXT_ELM = data = balloon = instance = null;\r
+ JQ_WRAPPER = elmText = data = balloon = instance = null;\r
}\r
}\r
TextElementClass.prototype = new AbstractComicElement( PANEL_ELEMENT_TYPE_TEXT );\r