+
+ function drawIcons(){
+ while( ICON_ARRAY.length > 0 ){
+ ICON_ARRAY.shift().destroy();
+ }
+
+ var _index = ARTIST_ROOT_FILE.search( {
+ id: artistID,
+ type: pettanr.driver.FILE_TYPE.ARTIST
+ })[ 0 ],
+ _artistFile = ARTIST_ROOT_FILE.getChildFileByIndex( _index ),
+ _file;
+ if( _artistFile !== null ){
+ for(var i=0, l=_artistFile.getChildFileLength(); i<l; ++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 onFadeout(){
+ while( ICON_ARRAY.length > 0 ){
+ ICON_ARRAY.shift().destroy();
+ }
+ onUpdateFunction !== null && onUpdateData !== null && onUpdateFunction( onUpdateData );
+ onUpdateFunction = onUpdateData = null;
+ }
+
+ /* grobal method */
+ // this.rootElement = elmWrap;
+ this.displayName = 'premiumStage';
+ this.ID = 'premiumStage';
+ this.rootElement = elmWrap;
+ this.MIN_WIDTH = 320;
+ this.MIN_HEIGHT = 320;
+ this.init = function(){
+ jqContainer = $( elmContainer ).mousewheel( onMouseWheel );
+
+ // よくない! 一時的な処理,,,
+ //var tree = pettanr.driver.createPictureTree();
+ //tree.addTreeEventListener( pettanr.file.TREE_EVENT.UPDATE, drawIcons );
+
+ delete instance.init;
+ }
+ this.onOpen = function( _windowW, _windowH, _ARTISTIDorFILE, _onUpdateFunction ){
+ instance.init && instance.init();
+
+ if( pettanr.driver.isPettanrFileInstance( _ARTISTIDorFILE ) === true ){
+ var _data = pettanr.driver._getAPI().getFileData( _ARTISTIDorFILE );
+ if( _ARTISTIDorFILE.getType() === pettanr.driver.FILE_TYPE.ARTIST || pettanr.driver._getMyPicturesData() === _data ){
+ artistID = _data.id || -1;
+ }
+ } else
+ if( Type.isNumber( _ARTISTIDorFILE ) === true ){
+ artistID = _ARTISTIDorFILE;
+ }
+
+ onUpdateFunction = _onUpdateFunction || null;
+ onUpdateData = null;
+
+ drawIcons();
+
+ wrapX = 0;
+ containerW = ICON_ARRAY.length * itemW;
+
+ winW = _windowW;
+ winH = _windowH;
+ var w = winW > containerW ? winW : containerW,
+ h = _windowH > containerH ? containerH : _windowH,
+ MATH_FLOOR = Math.floor;
+
+ jqContainer.css( {
+ width: w,
+ height: 0,
+ left: 0,
+ top: MATH_FLOOR( _windowH /2)
+ }).stop().animate( {
+ height: h,
+ top: MATH_FLOOR( _windowH /2 -h /2)
+ }, onEnterShowImage );
+
+ elmButton.style.cssText = [
+ 'left:', MATH_FLOOR( winW /2 - buttonW /2), 'px;',
+ 'top:', MATH_FLOOR( _windowH /2 + containerH /2 +10), 'px'
+ ].join('');
+ }
+ this.onPaneResize = function( _windowW, _windowH ){
+ var w = _windowW > containerW ? _windowW : containerW,
+ h = _windowH > containerH ? containerH : _windowH,
+ MATH_FLOOR = Math.floor,
+ offsetW = MATH_FLOOR( _windowW /2 -winW /2);
+
+ winW = _windowW;
+ winH = _windowH;
+ if( offsetW <= 0){ // smaller
+ jqContainer.css( {
+ left: offsetW,
+ width: w
+ }).animate( {
+ left: 0,
+ top: MATH_FLOOR( _windowH /2 -h /2)
+ });
+ } else {
+ jqContainer.css( { // bigger
+ left: 0,
+ width: w,
+ borderLeftWidth: offsetW
+ }).animate( {
+ top: MATH_FLOOR( _windowH /2 -h /2),
+ borderLeftWidth: 0
+ });
+ }
+ elmButton.style.cssText = [
+ 'left:', MATH_FLOOR( _windowW /2 -buttonW /2), 'px;',
+ 'top:', MATH_FLOOR( _windowH /2 +containerH /2 +10), 'px'
+ ].join('');
+ onEnterShowImage();
+ }
+ this.onClose = function(){
+ jqContainer.stop().animate( {
+ height: 0,
+ top: Math.floor( winH /2 )
+ }, onFadeout );
+ onEnterInterval !== null && window.clearTimeout( onEnterInterval );
+ onEnterInterval = null;
+ }
+});
+
+
+/* ----------------------------------------
+ * Text Editor
+ * - overlay
+ */
+pettanr.textEditor = pettanr.view.registerApplication( function(){
+ var jqWrap, jqTextarea, jqButton,
+ textElement, onUpdateFunction,
+ ID = 'textEditor',
+ panelX, panelY,
+ instance = this;
+ //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK);
+
+ function clickOK(){
+ textElement && textElement.text( jqTextarea.val() );
+ window.setTimeout( asyncCallback, 0 );
+ }
+
+ function asyncCallback(){
+ onUpdateFunction && onUpdateFunction( textElement );
+ onUpdateFunction = textElement = null;
+ pettanr.textEditor.shutdown();
+ }
+
+ function keyCancel( e ){
+ if( e.keyCode === 69 && e.shiftKey === false && e.ctrlKey === true){
+ clickOK();
+ e.preventDefault();
+ e.keyCode = 0;
+ e.cancelBubble = true;
+ e.returnValue = false;
+ 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.displayName = 'textEditor';
+ this.ID = 'textEditor';
+ this.rootElement = document.getElementById( 'speach-editor-wrapper' );
+ this.MIN_WIDTH = 320;
+ this.MIN_HEIGHT = 320;
+ this.init = function(){
+ jqWrap = $( '#speach-editor-wrapper' ).hide();
+ jqTextarea = $( '#speach-editor' ).keydown( keyCancel );
+ jqButton = $( '#speach-edit-complete-button').click( clickOK );
+ delete instance.init;
+ }
+ this.onOpen = function( _w, _h, _panelX, _panelY, _textElement, _onUpdateFunction ){
+ instance.init && instance.init();
+
+ panelX = _panelX;
+ panelY = _panelY;
+ textElement = _textElement;
+ onUpdateFunction = _onUpdateFunction || null;
+
+ 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( textareaFitHeight, 0);
+ }
+ this.onPaneResize = function( _w, _h ){
+ jqWrap.css( {
+ left: textElement.x + panelX,
+ top: textElement.y + panelY,
+ width: textElement.w,
+ height: textElement.h
+ });
+ }
+ this.onClose = function(){
+ jqWrap.hide();
+ }
+});