OSDN Git Service

client is version 0.5.15, brushup peta.apps, fixed system.UI.
authoritozyun <itozyun@gmail.com>
Tue, 11 Sep 2012 12:43:25 +0000 (21:43 +0900)
committeritozyun <itozyun@gmail.com>
Tue, 11 Sep 2012 12:43:25 +0000 (21:43 +0900)
app/assets/javascripts/peta.apps.js
app/assets/javascripts/system.js

index 17b54aa..f11646b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * pettanR peta.apps.js
- *   version 0.5.14
+ *   version 0.5.15
  *   
  * author:
  *   itozyun
@@ -4113,7 +4113,7 @@ var Editor = gOS.registerApplication( function(){
        };
 }, false, true, 'Panel Editor', 'paneleditor', null, '#2D89F0' );
 
-var ConsoleApplicationBase = function( app ){
+var FormApplicationHelper = function( app ){
        app.isUploading = false;
        app.elmProgress = null;
        app.elmUploader = null;
@@ -4123,10 +4123,14 @@ var ConsoleApplicationBase = function( app ){
        app.fetchScript = function(){
                app.elmProgress    = document.getElementById( app.elmProgressID );
                
-               app.elmUploader    = document.createElement( 'div' );
-               app.rootElement.appendChild( app.elmUploader );
-               app.elmUploader.id = app.elmUploaderID;
-               app.elmUploader.style.cssText = 'height:1px;line-height:1px;visibility:hidden;overflow:hidden;';
+               if( !( app.elmUploader = document.getElementById( app.elmUploaderID ) ) ){
+                       app.elmUploader    = document.createElement( 'div' );
+                       app.rootElement.appendChild( app.elmUploader );
+                       app.elmUploader.id = app.elmUploaderID;
+                       if( app.hideUploader === true ){
+                               app.elmUploader.style.cssText = 'height:1px;line-height:1px;visibility:hidden;overflow:hidden;';
+                       };                      
+               };
                
                app.elmScript        = document.createElement( 'script' );
                document.body.appendChild( app.elmScript );
@@ -4136,15 +4140,18 @@ var ConsoleApplicationBase = function( app ){
                app.elmProgress.innerHTML = 'loading form.';
                
                app.addTimer( app.detectForm, 250 );
+               
+               delete app.fetchScript;
        };
        app.detectForm = function(){
                app.elmForm = app.elmUploader.getElementsByTagName( 'form' )[ 0 ];
-               if( app.elmForm ){
-                       app.removeTimer( app.detectForm );
-                       
-                       Util.createIframe( 'targetFrame', app.onCreateIframe );
-                       app.elmProgress.innerHTML = 'create iframe';
-               };
+               if( !app.elmForm ) return;
+               
+               app.removeTimer( app.detectForm );
+               Util.createIframe( 'targetFrame', app.onCreateIframe );
+               app.elmProgress.innerHTML = 'create iframe';
+               
+               delete app.detectForm;
        };
        app.onCreateIframe = function( _iframe ){
                app.elmUploader.appendChild( _iframe );
@@ -4152,6 +4159,8 @@ var ConsoleApplicationBase = function( app ){
                app.elmForm.target        = _iframe.name;
                app.elmProgress.innerHTML = '';
                app.onFormReady && app.onFormReady();
+               
+               delete app.onCreateIframe;
        };
        app.submit = function(){
                app.elmProgress.innerHTML = 'submit!';
@@ -4163,19 +4172,23 @@ var ConsoleApplicationBase = function( app ){
                        app.submitError && app.submitError();
                        return;
                };
-               if( UA.isIE ){
+               if( app.detectIframe ){
                        app.elmIframe.onreadystatechange = app.detectIframe;
                } else {
                        app.elmIframe.onload = app.onIframeUpdate;
                };
                app.elmProgress.innerHTML = 'uploading..';
+               
+               delete app.submit;
        };
-       app.detectIframe = function(){
-        if ( this.readyState === 'complete' ){
-            this.onreadystatechange = new Function();
-            this.onreadystatechange = null;
-            app.onIframeUpdate();
-        };
+       if( UA.isIE ){
+               app.detectIframe = function(){
+               if ( this.readyState !== 'complete' ) return;
+               this.onreadystatechange = new Function();
+               this.onreadystatechange = null;
+               app.onIframeUpdate();
+               delete app.detectIframe;
+               };              
        };
        app.onIframeUpdate = function(){
                app.elmIframe.onload = null;
@@ -4190,24 +4203,26 @@ var ConsoleApplicationBase = function( app ){
                app.elmProgress.innerHTML = 'success!';
                app.isUploading = false;
                app.submitSuccess && app.submitSuccess();
+               delete app.onIframeUpdate;
+       };
+       app.destroyHelper = function(){
+               app = null;
        };
 };
 
 var ComicConsole = gOS.registerApplication( function(){
        var elmHeader, elmProgress,
-               winW, winH,
+               windowW, windowH,
                inputTitle, inputW, inputH,
                comboboxVisible, // comboboxEditable,
                buttonSubmit, buttonCancel,
-               isUploading = false,
-               instance    = this;
-       //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK);
-       
+               app         = this;
+
        function clickOK(){
-               if( !instance.elmForm || !instance.elmIframe || instance.isUploading === true ) return false;
+               if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
                // validate
 
-               var _inputList = instance.elmForm.getElementsByTagName( 'input' ),
+               var _inputList = app.elmForm.getElementsByTagName( 'input' ),
                        _input, _name;
                for( var i = _inputList.length; i; ){
                        _input = _inputList[ --i ];
@@ -4222,7 +4237,7 @@ var ComicConsole = gOS.registerApplication( function(){
                                _input.value = inputH.value();
                        };
                };
-               var _selectList = instance.elmForm.getElementsByTagName( 'select' ),
+               var _selectList = app.elmForm.getElementsByTagName( 'select' ),
                        _select, _optionList;
                for( i = _selectList.length; i; ){
                        _select = _selectList[ --i ];
@@ -4235,10 +4250,10 @@ var ComicConsole = gOS.registerApplication( function(){
                                // _select.selectedIndex = comboboxEditable.selectIndex();
                        };
                };
-               instance.submit();
+               app.submit();
        };
        function clickCancel(){
-               if( instance.isUploading === true ) return false;
+               if( app.isUploading === true ) return false;
                ComicConsole.shutdown();
        };
 
@@ -4246,9 +4261,9 @@ var ComicConsole = gOS.registerApplication( function(){
        this.MIN_WIDTH   = 320;
        this.MIN_HEIGHT  = 320;
        this.onInit = function(){
-               instance.rootElement.id = 'comic-console-wrapper';
-               instance.rootElement.className = 'console-wrapper';
-               instance.rootElement.innerHTML = [
+               app.rootElement.id = 'comic-console-wrapper';
+               app.rootElement.className = 'console-wrapper';
+               app.rootElement.innerHTML = [
                        '<div id="comic-console-header" class="console-header">Create New Comic</div>',
                        '<div id="comic-console" class="console-inner">',
                                '<div id="comic-console-title" class="field">',
@@ -4279,19 +4294,20 @@ var ComicConsole = gOS.registerApplication( function(){
                        '</div>'
                ].join( '' );
                
-               instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
+               app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
                
-               delete instance.onInit;
+               delete app.onInit;
        };
        this.elmProgressID   = 'comic-console-progress';
        this.elmUploaderID   = 'newcomic';
        this.elmIframeName   = 'targetFrameCreateComic'
        this.scriptSrc       = pettanr.CONST.CREATE_COMIC_JS;
-       ConsoleApplicationBase( this );
+       this.hideUploader    = true;
+       FormApplicationHelper( this );
        this.onFormReady     = function(){
-               instance.onPaneResize( winW, winH );
+               app.onPaneResize( windowW, windowH );
                
-               var selectList = instance.elmForm.getElementsByTagName( 'select' ),
+               var selectList = app.elmForm.getElementsByTagName( 'select' ),
                        select,
                        j, m,
                        optionList, option;
@@ -4310,16 +4326,16 @@ var ComicConsole = gOS.registerApplication( function(){
                };
                inputTitle.focus();
                
-               delete instance.onFoemReady;
+               delete app.onFoemReady;
        };
        this.submitError = function(){
-               instance.addTimer( clickCancel , 5000, true );
+               app.addTimer( clickCancel , 5000, true );
        };
        this.submitSuccess = function(){
-               instance.addTimer( clickCancel , 5000, true );
+               app.addTimer( clickCancel , 5000, true );
        };
        this.onOpen = function( w, h ){
-               var ui           = instance.createUIGroup();
+               var ui           = app.createUIGroup();
                
                inputTitle       = ui.createInputText( document.getElementById( 'comic-console-title') );
                inputW           = ui.createInputText( document.getElementById( 'comic-console-width') );
@@ -4329,112 +4345,38 @@ var ComicConsole = gOS.registerApplication( function(){
                buttonSubmit     = ui.createButton( document.getElementById( 'comic-console-post-button'), clickOK );
                buttonCancel     = ui.createButton( document.getElementById( 'comic-console-cancel-button'), clickCancel );
                
-               instance.fetchScript();
-               instance.onPaneResize( w, h );
-               delete instance.onOpen;
+               app.onPaneResize( w, h );
+               app.fetchScript();
+               delete app.onOpen;
        };
        this.onPaneResize = function( _w, _h ){
-               winW = _w;
-               winH = _h;
-               instance.rootElement.style.cssText = [
-                       'left:', Math.floor( ( _w - instance.rootElement.offsetWidth  ) /2 ), 'px;',
-                       'top:',  Math.floor( ( _h- instance.rootElement.offsetHeight ) /2 ), 'px;'
+               windowW = _w;
+               windowH = _h;
+               app.rootElement.style.cssText = [
+                       'left:', Math.floor( ( _w - app.rootElement.offsetWidth  ) /2 ), 'px;',
+                       'top:',  Math.floor( ( _h- app.rootElement.offsetHeight ) /2 ), 'px;'
                ].join( '' );
        };
        this.onClose = function(){
-               instance = null;
-               isUploading = false;
+               app.destroyHelper();
+               app = inputTitle = inputW = inputH = comboboxVisible = buttonSubmit = buttonCancel = null;
        };
 }, true, true, 'Comic Console', 'comicConsole', null, '#D44A26' );
 
 var UploadConsole = gOS.registerApplication( function(){
        var windowW, windowH,
-               TARGET_FRAME_NAME = 'targetFrame',
-               elmContainer,
-               elmProgress,
-               elmScript   = null,
-               elmForm     = null,
-               elmFile     = null,
-               elmIframe   = null,
-               isUploading = false,
-               instance    = this;
-       /*
-        * upload ボタンが押されたらまず iframe をつくる.
-        */
+               buttonSubmit, buttonCancel,
+               elmFile,
+               app = this;
+
        function clickOK(){
-               if( !elmForm || !elmIframe || isUploading === true ) return false;
+               if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
                if( elmFile.value.length === 0 ) return false;
-               elmProgress.innerHTML = 'uploading.';
-               isUploading = true;
-               submit();
+               app.submit();
                return false;
        };
-       /*
-        * form の target に iframe を指定したのち submit();
-        */
-               function submit(){
-                       try {
-                               elmForm.submit();
-                       } catch( e){
-                               elmProgress.innerHTML = 'submit() err..';
-                               isUploading = false;
-                               instance.addTimer( clickCancel , 3000, true );
-                               return;
-                       };
-                       
-                       if( UA.isIE){
-                               elmIframe.onreadystatechange = detectIframe;
-                       } else {
-                               elmIframe.onload = onLoad;
-                       };
-                       elmProgress.innerHTML = 'uploading..';
-               };
-       /*
-        * ie の 場合、readyState をチェック.
-        */
-                       function detectIframe(){
-                   if ( elmIframe.readyState === 'complete') {
-                       elmIframe.onreadystatechange = new Function();
-                       elmIframe.onreadystatechange = null;
-                       onLoad();
-                   };
-                       };
-                               function onLoad(){
-                                       elmIframe.onload = null;
-                                       ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();
-                                       elmProgress.innerHTML = 'success!';
-                                       instance.addTimer( clickCancel , 1000 );
-                                       isUploading = false;
-                               };
-       
-       function detectForm(){
-               elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];
-               if( elmForm ){
-                       var _inputList = elmForm.getElementsByTagName( 'input' ),
-                               _input;
-                       for( var i = _inputList.length; i; ){
-                               _input = _inputList[ --i ];
-                               if( _input.type === 'file' ){
-                                       elmFile = _input;
-                               };
-                               if( _input.type === 'submit' ){
-                                       _input.style.display = 'none';
-                               };
-                       };
-                       instance.removeTimer( detectForm );
-                       Util.createIframe( TARGET_FRAME_NAME, onCreateIframe );
-                       elmProgress.innerHTML = 'create iframe';
-               };
-       };
-       function onCreateIframe( _iframe ){
-               elmContainer.appendChild( _iframe );
-               elmIframe = _iframe;
-               elmForm.target = _iframe.name;
-               elmProgress.innerHTML = '';
-               instance.onPaneResize( windowW, windowH );
-       };
        function clickCancel(){
-               if( isUploading === true ) return false;
+               if( app.isUploading === true ) return false;
                UploadConsole.shutdown();
                return false;
        };
@@ -4443,9 +4385,9 @@ var UploadConsole = gOS.registerApplication( function(){
        this.MIN_WIDTH   = 320;
        this.MIN_HEIGHT  = 320;
        this.onInit = function(){
-               instance.rootElement.id = 'upload-console-wrapper';
-               instance.rootElement.className = 'console-wrapper';
-               instance.rootElement.innerHTML = [
+               app.rootElement.id = 'upload-console-wrapper';
+               app.rootElement.className = 'console-wrapper';
+               app.rootElement.innerHTML = [
                        '<div id="upload-console-header" class="console-header">Upload Picture</div>',
                        '<div id="upload-console" class="console-inner">',
                                '<div id="uploader"></div>',
@@ -4457,136 +4399,83 @@ var UploadConsole = gOS.registerApplication( function(){
                        '</div>'
                ].join( '' );
                
-               instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
+               app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
                
-               delete instance.onInit;
-       }
+               delete app.onInit;
+       };
+       this.elmProgressID   = 'upload-console-progress';
+       this.elmUploaderID   = 'uploader';
+       this.elmIframeName   = 'targetFrameUpload'
+       this.scriptSrc       = pettanr.CONST.UPLOAD_PICTURE_JS;
+       this.hideUploader    = false;
+       FormApplicationHelper( this );
+       this.onFormReady     = function(){
+               app.onPaneResize( windowW, windowH );
+
+               var _inputList = app.elmForm.getElementsByTagName( 'input' ),
+                       _input;
+               for( var i = _inputList.length; i; ){
+                       _input = _inputList[ --i ];
+                       if( _input.type === 'file' ){
+                               elmFile = _input;
+                       } else
+                       if( _input.type === 'submit' ){
+                               _input.style.display = 'none';
+                       };
+               };
+               delete app.onFoemReady;
+       };
+       this.submitError = function(){
+               app.addTimer( clickCancel , 5000, true );
+       };
+       this.submitSuccess = function(){
+               app.addTimer( clickCancel , 5000, true );
+       };
        this.onOpen = function( w, h ){
-               elmContainer = document.getElementById( 'uploader' );
-               elmProgress  = document.getElementById( 'upload-console-progress' );
-               
-               instance.addMouseEventListener( document.getElementById( 'upload-console-post-button' ), 'click', clickOK );
-               instance.addMouseEventListener( document.getElementById( 'upload-console-cancel-button' ), 'click', clickCancel );
-               /*
-                * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.
-                */                             
-               elmScript      = document.createElement( 'script' );
-               document.body.appendChild( elmScript );
-               elmScript.type = 'text\/javascript';
-               elmScript.src  = pettanr.CONST.UPLOAD_PICTURE_JS;
+               var ui           = app.createUIGroup();
+               buttonSubmit     = ui.createButton( document.getElementById( 'upload-console-post-button'), clickOK );
+               buttonCancel     = ui.createButton( document.getElementById( 'upload-console-cancel-button'), clickCancel );
 
-               instance.addTimer( detectForm, 250 );
-               instance.onPaneResize( w, h );
-               
-               elmProgress.innerHTML = 'loading form.';
+               app.onPaneResize( w, h );
+               app.fetchScript();
        };
        this.onPaneResize = function( _windowW, _windowH){
                windowW = _windowW;
                windowH = _windowH;
-               instance.rootElement.style.cssText = [
-                       'left:', Math.floor( ( _windowW - instance.rootElement.offsetWidth  ) /2 ), 'px;',
-                       'top:',  Math.floor( ( _windowH - instance.rootElement.offsetHeight ) /2 ), 'px;'
+               app.rootElement.style.cssText = [
+                       'left:', Math.floor( ( _windowW - app.rootElement.offsetWidth  ) /2 ), 'px;',
+                       'top:',  Math.floor( ( _windowH - app.rootElement.offsetHeight ) /2 ), 'px;'
                ].join( '' );
-       }
+       };
        this.onClose = function(){
-               elmHeader = elmProgress = elmForm  = elmUploader = instance = null;
-               isUploading = false;
-       }
+               app.destroyHelper();
+               app = elmFile = buttonSubmit = buttonCancel = null;
+       };
 }, true, true, 'Upload Console', 'uploadConsole', null, '#01A31C' );
 
 var ArtistConsole = gOS.registerApplication( function(){
        var windowW, windowH,
-               TARGET_FRAME_NAME = 'targetFrameRegisterArtist',
-               elmContainer, elmProgress,
-               elmScript   = null,
-               elmForm     = null,
-               elmIframe   = null,
-               isUploading = false,
-               instance    = this;
-       /*
-        * upload ボタンが押されたらまず iframe をつくる.
-        */
+               buttonSubmit, buttonCancel,
+               app = this;
+
        function clickOK(){
-               if( !elmForm || !elmIframe || isUploading === true ) return false;
-               elmProgress.innerHTML = 'uploading.';
-               isUploading = true;
-               submit();
+               if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
+               app.submit();
                return false;
-       }
-       /*
-        * form の target に iframe を指定したのち submit();
-        */
-               function submit(){
-                       try {
-                               elmForm.submit();
-                       } catch( e){
-                               elmProgress.innerHTML = 'submit() err..';
-                               isUploading = false;
-                               instance.addTimer( clickCancel , 3000, true );
-                               return;
-                       }
-                       
-                       if( UA.isIE){
-                               elmIframe.onreadystatechange = detectIframe;
-                       } else {
-                               elmIframe.onload = onLoad;
-                       }
-                       elmProgress.innerHTML = 'uploading..';
-               }
-       /*
-        * ie の 場合、readyState をチェック.
-        */
-                       function detectIframe(){
-                   if ( elmIframe.readyState === 'complete' ){
-                       elmIframe.onreadystatechange = new Function();
-                       elmIframe.onreadystatechange = null;
-                       onLoad();
-                   }
-                       }
-                               function onLoad(){
-                                       elmIframe.onload = null;
-                                       ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();
-                                       elmProgress.innerHTML = 'success!';
-                                       instance.addTimer( clickCancel , 1000, true );
-                                       isUploading = false;
-                               }
-       
-       function detectForm(){
-               elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];
-               if( elmForm){
-                       var _inputList = elmForm.getElementsByTagName( 'input' ),
-                               _input;
-                       for( var i = _inputList.length; i; ){
-                               _input = _inputList[ --i ];
-                               if( _input.type === 'submit' ){
-                                       _input.style.display = 'none';
-                               }
-                       }
-                       instance.removeTimer( detectForm );
-                       Util.createIframe( TARGET_FRAME_NAME, onCreateIframe);
-                       elmProgress.innerHTML = 'create iframe';
-               }
-       }
-       function onCreateIframe( _iframe ){
-               elmContainer.appendChild( _iframe );
-               elmIframe = _iframe;
-               elmForm.target = _iframe.name;
-               elmProgress.innerHTML = '';
-               instance.onPaneResize( windowW, windowH );
-       }
+       };
        function clickCancel(){
-               if( isUploading === true) return false;
+               if( app.isUploading === true) return false;
                ArtistConsole.shutdown();
                return false;
-       }
+       };
 
        /* grobal method */
        this.MIN_WIDTH   = 320;
        this.MIN_HEIGHT  = 320;
        this.onInit = function(){
-               instance.rootElement.id = 'artist-console-wrapper';
-               instance.rootElement.className = 'console-wrapper';
-               instance.rootElement.innerHTML = [
+               app.rootElement.id = 'artist-console-wrapper';
+               app.rootElement.className = 'console-wrapper';
+               app.rootElement.innerHTML = [
                        '<div id="artist-console-header" class="console-header">Register Artist</div>',
                        '<div id="artist-console" class="console-inner">',
                                '<div id="register"></div>',
@@ -4598,40 +4487,54 @@ var ArtistConsole = gOS.registerApplication( function(){
                        '</div>'
                ].join( '' );
                
-               instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
+               app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
                
-               delete instance.onInit;
+               delete app.onInit;
+       };
+       this.elmProgressID   = 'artist-console-progress';
+       this.elmUploaderID   = 'register';
+       this.elmIframeName   = 'targetFrameArtistRegister'
+       this.scriptSrc       = pettanr.CONST.REGISTER_ARTIST_JS;
+       this.hideUploader    = false;
+       FormApplicationHelper( this );
+       this.onFormReady     = function(){
+               app.onPaneResize( windowW, windowH );
+
+               var _inputList = app.elmForm.getElementsByTagName( 'input' ),
+                       _input;
+               for( var i = _inputList.length; i; ){
+                       _input = _inputList[ --i ];
+                       if( _input.type === 'submit' ){
+                               _input.style.display = 'none';
+                       };
+               };
+               delete app.onFoemReady;
+       };
+       this.submitError = function(){
+               app.addTimer( clickCancel , 5000, true );
+       };
+       this.submitSuccess = function(){
+               app.addTimer( clickCancel , 5000, true );
        };
        this.onOpen = function( w, h ){
-               elmContainer = document.getElementById( 'register');
-               elmProgress  = document.getElementById( 'artist-console-progress');
-               
-               instance.addMouseEventListener( document.getElementById( 'artist-console-post-button' ), 'click', clickOK );
-               instance.addMouseEventListener( document.getElementById( 'artist-console-cancel-button' ), 'click', clickCancel );
-               /*
-                * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.
-                */                             
-               elmScript = document.createElement( 'script' );
-               document.body.appendChild( elmScript );
-               elmScript.type = 'text\/javascript';
-               elmScript.src = pettanr.CONST.REGISTER_ARTIST_JS;
+               var ui           = app.createUIGroup();
+               buttonSubmit     = ui.createButton( document.getElementById( 'artist-console-post-button'), clickOK );
+               buttonCancel     = ui.createButton( document.getElementById( 'artist-console-cancel-button'), clickCancel );
 
-               instance.addTimer( detectForm, 250 );
-               instance.onPaneResize( w, h );
-               
-               elmProgress.innerHTML = 'loading form.';
+               app.onPaneResize( w, h );
+               app.fetchScript();
        };
        this.onPaneResize = function( _windowW, _windowH ){
                windowW = _windowW;
                windowH = _windowH;
-               instance.rootElement.style.cssText = [
-                       'left:', Math.floor( ( _windowW - instance.rootElement.offsetWidth  ) /2 ), 'px;',
-                       'top:',  Math.floor( ( _windowH - instance.rootElement.offsetHeight ) /2 ), 'px;'
+               app.rootElement.style.cssText = [
+                       'left:', Math.floor( ( _windowW - app.rootElement.offsetWidth  ) /2 ), 'px;',
+                       'top:',  Math.floor( ( _windowH - app.rootElement.offsetHeight ) /2 ), 'px;'
                ].join( '' );
        };
        this.onClose = function(){
-               elmHeader = elmProgress = elmForm  = elmUploader = instance = null;
-               isUploading = false;
+               app.destroyHelper();
+               app = buttonSubmit = buttonCancel = null;
        };
 }, true, true, 'Artist Console', 'artistConsole', null, '#FFC40D' );
 
@@ -4891,7 +4794,7 @@ var OutputConsole = gOS.registerApplication( function(){
                windowW, windowH,
                timing   = 0,
                comicID, panelID, panelTimming, panelW, panelH, borderSize, panelElementArray,
-               instance = this,
+               app      = this,
                model    = null;
        
        function clickOK(){
@@ -4930,9 +4833,9 @@ var OutputConsole = gOS.registerApplication( function(){
        this.MIN_WIDTH   = 320;
        this.MIN_HEIGHT  = 320;
        this.onInit = function(){
-               instance.rootElement.id = 'output-console-wrapper';
-               instance.rootElement.className = 'console-wrapper';
-               instance.rootElement.innerHTML = [
+               app.rootElement.id = 'output-console-wrapper';
+               app.rootElement.className = 'console-wrapper';
+               app.rootElement.innerHTML = [
                        '<div id="output-console-header" class="console-header">Output Console</div>',
                        '<div id="output-console" class="console-inner">',
                                '<div id="output-console-format" class="field">',
@@ -4948,14 +4851,14 @@ var OutputConsole = gOS.registerApplication( function(){
                        '</div>'
                ].join( '' );
 
-               instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
+               app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
 
-               delete instance.onInit;
+               delete app.onInit;
        };
        this.onOpen = function( _w, _h, _comicID, _panelID, _panelTimming, _panelW, _panelH, _borderSize, _panelElementArray ){
                elmOutputArea = document.getElementById( 'output-area' );
                
-               var ui = instance.createUIGroup();
+               var ui = app.createUIGroup();
                comboboxFormat = ui.createCombobox( document.getElementById( 'output-console-format' ), formatUpdate );
                
                for( var i=0; FORMAT_LIST[ 0 ]; ++i ){
@@ -4964,7 +4867,10 @@ var OutputConsole = gOS.registerApplication( function(){
                inputOption    = ui.createInputText( document.getElementById( 'output-console-option' ), null );
                // buttonPost     = ui.createButton( document.getElementById( 'output-console-post-button' ), clickPost );
                buttonClose    = ui.createButton( document.getElementById( 'output-console-close-button' ), clickClose );
-               instance.onPaneResize( _w, _h );
+               
+               app.onPaneResize( _w, _h );
+               
+               comboboxFormat.focus( true );
                
                model = Model.createPanel( {
                        comicID           : _comicID,
@@ -4982,9 +4888,9 @@ var OutputConsole = gOS.registerApplication( function(){
        this.onPaneResize = function( _windowW, _windowH ){
                windowW = _windowW;
                windowH = _windowH;
-               instance.rootElement.style.cssText = [
-                       'left:', Math.floor( ( _windowW - instance.rootElement.offsetWidth  ) /2 ), 'px;',
-                       'top:',  Math.floor( ( _windowH - instance.rootElement.offsetHeight ) /2 ), 'px;'
+               app.rootElement.style.cssText = [
+                       'left:', Math.floor( ( _windowW - app.rootElement.offsetWidth  ) /2 ), 'px;',
+                       'top:',  Math.floor( ( _windowH - app.rootElement.offsetHeight ) /2 ), 'px;'
                ].join( '' );
        };
        this.onClose = function(){
@@ -4997,98 +4903,22 @@ var OutputConsole = gOS.registerApplication( function(){
 
 var PanelConsole = gOS.registerApplication( function(){
        var windowW, windowH,
-               TARGET_FRAME_NAME = 'targetFrameCreateNewPanel',
                comboboxPublish, buttonPost, buttonClose,
-               elmContainer, elmProgress, elmInput,
-               elmScript   = null,
-               elmForm     = null,
-               elmIframe   = null,
-               isUploading = false,
-               instance    = this,
+               elmInput,
+               app         = this,
                model       = null;
                
        /*
         * upload ボタンが押されたらまず iframe をつくる.
         */
        function clickOK(){
-               if( !elmForm || !elmIframe || isUploading === true ) return false;
-               elmProgress.innerHTML = 'uploading.';
-               isUploading = true;
-               submit();
+               if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
+               app.submit();
                return false;
        }
-       /*
-        * form の target に iframe を指定したのち submit();
-        */
-               function submit(){
-                       try {
-                               elmForm.submit();
-                       } catch( e ){
-                               elmProgress.innerHTML = 'submit() err..';
-                               isUploading = false;
-                               instance.addTimer( clickCancel , 3000, true );
-                               return;
-                       }
-                       
-                       if( UA.isIE ){
-                               elmIframe.onreadystatechange = detectIframe;
-                       } else {
-                               elmIframe.onload = onLoad;
-                       }
-                       elmProgress.innerHTML = 'uploading..';
-               }
-       /*
-        * ie の 場合、readyState をチェック.
-        */
-                       function detectIframe(){
-                   if ( elmIframe.readyState === 'complete' ){
-                       elmIframe.onreadystatechange = new Function();
-                       elmIframe.onreadystatechange = null;
-                       onLoad();
-                   };
-                       };
-                               function onLoad(){
-                                       try {
-                                               console.log( ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).document.body.innerHTML );
-                                       } catch(e){
-                                               
-                                       }
-                                       elmIframe.onload = null;
-                                       ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();
-                                       elmProgress.innerHTML = 'success!';
-                                       instance.addTimer( clickCancel , 1000, true );
-                                       isUploading = false;
-                               };
-       
-       function detectForm(){
-               elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];
-               if( elmForm){
-                       var _inputList = elmForm.getElementsByTagName( 'input' ),
-                               _input;
-                       for( var i = _inputList.length; i; ){
-                               _input = _inputList[ --i ];
-                               if( _input.type === 'submit' ){
-                                       _input.style.display = 'none';
-                               };
-                               if( _input.name === 'json' ){
-                                       elmInput     = _input;
-                                       publishUpdate();
-                               };
-                       };
-                       instance.removeTimer( detectForm );
-                       Util.createIframe( TARGET_FRAME_NAME, onCreateIframe );
-                       elmProgress.innerHTML = 'create iframe';
-               };
-       };
-       function onCreateIframe( _iframe ){
-               elmContainer.appendChild( _iframe );
-               elmIframe = _iframe;
-               elmForm.target = _iframe.name;
-               elmProgress.innerHTML = '';
-               instance.onPaneResize( windowW, windowH );
-       };
+
        function clickCancel(){
-               if( isUploading === true ) return false;
+               if( app.isUploading === true ) return false;
                PanelConsole.shutdown();
                return false;
        };
@@ -5103,9 +4933,9 @@ var PanelConsole = gOS.registerApplication( function(){
        this.MIN_WIDTH   = 320;
        this.MIN_HEIGHT  = 320;
        this.onInit = function(){
-               instance.rootElement.id = 'panel-console-wrapper';
-               instance.rootElement.className = 'console-wrapper';
-               instance.rootElement.innerHTML = [
+               app.rootElement.id = 'panel-console-wrapper';
+               app.rootElement.className = 'console-wrapper';
+               app.rootElement.innerHTML = [
                        '<div id="panel-console-header" class="console-header">Create New Panel (dev)</div>',
                        '<div id="panel-console" class="console-inner">',
                                '<div id="newpanel"></div>',
@@ -5121,56 +4951,70 @@ var PanelConsole = gOS.registerApplication( function(){
                        '</div>'
                ].join( '' );
 
-               instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
+               app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
 
-               delete instance.onInit;
-       }
-       this.onOpen = function( w, h, _model ){
-               var ui           = instance.createUIGroup();
-               // inputTitle       = ui.createInputText( document.getElementById( 'comic-console-title') );
+               delete app.onInit;
+       };
+       this.elmProgressID   = 'panel-console-progress';
+       this.elmUploaderID   = 'newpanel';
+       this.elmIframeName   = 'targetFrameNewPanel'
+       this.scriptSrc       = pettanr.CONST.CREATE_PANEL_JS;
+       this.hideUploader    = false;
+       FormApplicationHelper( this );
+       this.onFormReady     = function(){
+               app.onPaneResize( windowW, windowH );
+
+               var _inputList = app.elmForm.getElementsByTagName( 'input' ),
+                       _input;
+               for( var i = _inputList.length; i; ){
+                       _input = _inputList[ --i ];
+                       if( _input.type === 'submit' ){
+                               _input.style.display = 'none';
+                       };
+                       if( _input.name === 'json' ){
+                               elmInput     = _input;
+                               publishUpdate();
+                       };
+               };
                
+               delete app.onFoemReady;
+       };
+       this.submitError = function(){
+               app.addTimer( clickCancel , 5000, true );
+       };
+       this.submitSuccess = function(){
+               app.addTimer( clickCancel , 5000, true );
+       };
+       this.onOpen = function( w, h, _model ){
+               var ui  = app.createUIGroup(),
+                       elm = document.getElementById( 'panel-console-publish' );
                if( _model ){
-                       comboboxPublish  = ui.createCombobox( document.getElementById( 'panel-console-publish'), publishUpdate );
+                       comboboxPublish  = ui.createCombobox( elm, publishUpdate );
                        comboboxPublish.createOption( 'only me', '0', _model.publish() === false );
                        comboboxPublish.createOption( 'publish', '1', _model.publish() === true );
                        model = _model;
                } else {
-                       var elm = document.getElementById( 'panel-console-publish');
                        elm.parentNode.removeChild( elm );
                };
                
                buttonPost       = ui.createButton( document.getElementById( 'panel-console-post-button' ), clickOK );
                buttonClose      = ui.createButton( document.getElementById( 'panel-console-cancel-button' ), clickCancel );
                
-               elmContainer = document.getElementById( 'newpanel' );
-               elmProgress  = document.getElementById( 'panel-console-progress' );
-
-               /*
-                * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.
-                */                             
-               elmScript = document.createElement( 'script' );
-               document.body.appendChild( elmScript );
-               elmScript.type = 'text\/javascript';
-               elmScript.src  = pettanr.CONST.CREATE_PANEL_JS;
-
-               instance.addTimer( detectForm, 250 );
-               instance.onPaneResize( w, h );
-               
-               elmProgress.innerHTML = 'loading form.';
+               app.onPaneResize( w, h );
+               app.fetchScript();
        };
        this.onPaneResize = function( _windowW, _windowH ){
                windowW = _windowW;
                windowH = _windowH;
-               instance.rootElement.style.cssText = [
-                       'left:', Math.floor( ( _windowW - instance.rootElement.offsetWidth  ) /2 ), 'px;',
-                       'top:',  Math.floor( ( _windowH - instance.rootElement.offsetHeight ) /2 ), 'px;'
+               app.rootElement.style.cssText = [
+                       'left:', Math.floor( ( _windowW - app.rootElement.offsetWidth  ) /2 ), 'px;',
+                       'top:',  Math.floor( ( _windowH - app.rootElement.offsetHeight ) /2 ), 'px;'
                ].join( '' );
        };
        this.onClose = function(){
+               app.destroyHelper();
                model && model.destroy();
-               elmHeader = elmProgress = elmForm  = elmUploader = instance = model = null;
-               comboboxPublish = buttonPost = buttonClose = null;
-               isUploading = false;
+               app = model = comboboxPublish = buttonPost = buttonClose = elmInput = null;
        };
 }, true, true, 'Panel Console', 'panelConsole', null, '#603CBA' );
 
index 8d1eb64..0158525 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
  * pettanR system.js\r
- *   version 0.5.14\r
+ *   version 0.5.15\r
  * \r
  * \r
  * Type\r
@@ -4273,7 +4273,7 @@ var UI = ( function(){
                                elmValue.data = _displayValue;\r
                        };                      \r
                        if( option === null ){\r
-                               option = new OptionClass( _displayValue, _value, _isSelected );\r
+                               option = new OptionDataClass( _displayValue, _value, _isSelected );\r
                                optionList.push( option );\r
                        };\r
                };\r
@@ -4285,7 +4285,7 @@ var UI = ( function(){
                };\r
                MouseEvent.add( apiuser, elmWrapper, 'click', instance.focus );\r
        };\r
-       var OptionClass = function( displayValue, value, isCurrent ){\r
+       var OptionDataClass = function( displayValue, value, isCurrent ){\r
                this.displayValue = displayValue;\r
                this.value        = value || displayValue;\r
                this.current      = isCurrent;\r
@@ -4380,7 +4380,7 @@ var UI = ( function(){
                };\r
                function change( e ){\r
                        var l   = OPTION_LIST.length,\r
-                               i   = currentIndex + ( e.keyCode === 40 ? 1 : -1 );\r
+                               i   = currentIndex + ( e.keyCode === 40 ? -1 : 1 );\r
                        if( currentCombobox === null || l < 2 ) return;\r
                        i = i < 0 ?\r
                                        l - 1 :\r
@@ -4410,6 +4410,8 @@ var UI = ( function(){
                                \r
                                updateCurrrentOption( _combobox.value(), false );\r
                                updateWrapperPosition();\r
+                               \r
+                               SystemTimer.add( SUPER_USER_KEY, updateWrapperPosition, 500 );\r
                        },\r
                        hide: function( _combobox ){\r
                                if( currentCombobox !== _combobox || currentCombobox === null ) return;\r
@@ -4427,6 +4429,8 @@ var UI = ( function(){
                                //KeyEvent.remove( SUPER_USER_KEY, Const.KEY.EVENT.KEY_DOWN, onEnter );\r
                                //KeyEvent.updateCurrentListener( apiuser );\r
                                \r
+                               SystemTimer.remove( SUPER_USER_KEY, updateWrapperPosition, 500 );\r
+                               \r
                                apiuser         = null;\r
                                currentCombobox = null;\r
                                currentOption   = null;\r
@@ -5057,7 +5061,7 @@ var Finder = ( function(){
  * zIndex                      ( order )
  */\r
 \r
-var VisualEffect = ( function(){\r
+var DHTML = ( function(){\r
        \r
        var ANIMATION_TICKET_ARRAY = [],\r
                fpms                   = 50;\r
@@ -5111,9 +5115,10 @@ var VisualEffect = ( function(){
                };\r
                \r
                currentStyle.clear();\r
+               targetStyle.clear();\r
                \r
                ANIMATION_TICKET_ARRAY.push( new AnimationTaskClass(\r
-                       targetStyle, inlineStyle,\r
+                       elm, inlineStyle,\r
                        _currentValues, _offsetValues, _endValues, _targetProperties, _units,\r
                        Type.isFunction( _onComplete ) === true   ? _onComplete   : null,\r
                        Type.isFunction( _onEnterFrame ) === true ? _onEnterFrame : null,\r