OSDN Git Service

client is version 0.5.5, update around comic exproler.
[pettanr/pettanr.git] / app / assets / javascripts / peta.apps.js
index acf5646..304fbf6 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * pettanR system.js
- *   version 0.4.37
+ * pettanR peta.apps.js
+ *   version 0.5.5
  *   
  * author:
  *   itozyun
@@ -87,7 +87,7 @@
                                                _rule,
                                                _Math_pow = Math.pow,
                                                _bits = 0;
-                                       if( typeof _license === 'object'){
+                                       if( typeof _license === 'object' ){
                                                for( i=0, l=BASIC_LICENSES.length; i<l; ++i ){
                                                        _rule = _license[ BASIC_LICENSES[ i]];
                                                        if( typeof _rule === 'number' && _rule === 1 ){
                                } else
                                // Comic + Panels
                                if( _parent.type === FILE_TYPE.COMIC || _parent === FILE_DATA_COMICS_ROOT ){
-                                       var _panels = _data.panels,
+                                       var _panels = _data.stories,
                                                _panel;
                                        if( _panels && Type.isArray( _panels ) === true ){
                                                
-                                               for( i=0, l=_panels.length; i<l; ++i){
+                                               for( i=0, l=_panels.length; i<l; ++i ){
                                                        _panel = buildFileData( _panels[ i ], FILE_DATA_PANELS_ROOT );
                                                        /*
                                                         * 間違い! t 順に格納
                                                         */
                                                        addChildData( _data, _panel );
                                                };
-                                               delete _data.panels;
+                                               delete _data.stories;
                                        } else {
                                                if( _data.json !== null ){
                                                        _data.json = true;
                                        if( pettanr.CONST.SERVER_SUPPORT === false ){
                                                _json = [ 'json\/comics_', _data.id, '.json' ].join( '' );
                                        } else {
-                                               _json = [ pettanr.CONST.PETTANR_ROOT_PATH, 'comics\/', _data.id, '.json\/play\/' ].join( '' );
-                                       }
-                               }
+                                               _json = [ pettanr.CONST.PETTANR_ROOT_PATH, 'comics\/', _data.id, '.json' ].join( '' );
+                                       };
+                               };
                                if( typeof _json === 'string' ){
                                        FileAPI.getJson( _file, _json, onLoadJson, onErrorJson );
                                        _data.state = Const.FILE.STATE.LOADING;
                                        _data.json  = null;
                                        return;
-                               }
+                               };
                        };
                        this.getName = function( _file ){
                                var _data = FileAPI.getFileData( _file ),
                                        for( var key in _data ){
                                                ret[ key ] = _data[ key ]
                                        }
-                                       ret.panels = _data.children;
+                                       ret.stories = _data.children;
                                        return ret;
                                }
                                if( _type === FILE_TYPE.PANEL ){
 var Cabinet = gOS.registerApplication( function(){
        var self         = this,
                finder       = null,
-               tree         = null;
+               tree         = null,
+               headerH      = 0;
 
        this.bgColor     = '#FFFFFF';
        this.MIN_WIDTH   = 500;
        this.MIN_HEIGHT  = 300;
        this.onInit = function(){
                self.rootElement.id = 'cabinet-root';
-               self.rootElement.innerHTML = '<div id="cabinet-container" class="finder-container"></div>';
+               self.rootElement.innerHTML = [
+                       '<div id="cabinet-header">Cabinet<div id="cabinet-close-button">x</div></div>',
+                       '<div id="cabinet-container" class="finder-container"></div>'
+               ].join( '' );
                
                self.fetchCSS( '/assets/peta.apps.css' );
                
@@ -484,6 +488,10 @@ var Cabinet = gOS.registerApplication( function(){
                delete self.onInit;
        };
        this.onOpen = function( _w, _h ){
+               headerH = Util.getElementSize( document.getElementById( 'cabinet-header' ) ).height;
+               
+               self.addMouseEventListener( document.getElementById( 'cabinet-close-button' ), 'click', Cabinet.shutdown );
+               
                finder = self.createFinder( self.rootElement, tree );
                self.onPaneResize( _w, _h );
        };
@@ -493,21 +501,25 @@ var Cabinet = gOS.registerApplication( function(){
                finder = tree = null;
        };
        this.onPaneResize = function( _w, _h ){
-               finder.resize( _w, _h );
+               finder.resize( _w, _h - headerH );
        };
 }, false, true, 'Cabinet', 'cabinet', null, '#1C1C1C' );
 
 var Gallery = gOS.registerApplication( function(){
        var self         = this,
                finder       = null,
-               tree         = null;
+               tree         = null,
+               headerH      = 0;
 
        this.bgColor     = '#FFFFFF';
        this.MIN_WIDTH   = 500;
        this.MIN_HEIGHT  = 300;
        this.onInit = function(){
                self.rootElement.id        = 'gallery-root';
-               self.rootElement.innerHTML = '<div id="gallery-container" class="finder-container"></div>';
+               self.rootElement.innerHTML = [
+                       '<div id="gallery-header">Cabinet<div id="gallery-close-button">x</div></div>',
+                       '<div id="gallery-container" class="finder-container"></div>'
+               ].join( '' );
                
                self.fetchCSS( '/assets/peta.apps.css' );
                
@@ -521,6 +533,10 @@ var Gallery = gOS.registerApplication( function(){
                _pic.destroy();
        };
        this.onOpen = function( _w, _h ){
+               headerH = Util.getElementSize( document.getElementById( 'gallery-header' ) ).height;
+               
+               self.addMouseEventListener( document.getElementById( 'gallery-close-button' ), 'click', Gallery.shutdown );
+               
                finder = self.createFinder( self.rootElement, tree );
                self.onPaneResize( _w, _h );
        };
@@ -530,7 +546,7 @@ var Gallery = gOS.registerApplication( function(){
                finder = tree = null;
        };
        this.onPaneResize = function( _w, _h ){
-               finder.resize( _w, _h );
+               finder.resize( _w, _h - headerH );
        };
 }, false, true, 'Gallery', 'gallery', null, '#01A31C' );
 
@@ -1018,7 +1034,6 @@ var Reader = gOS.registerApplication( function(){
                } else {
                        
                };
-
                if( comicData !== null ){
                        elmTitle.data  = title;
                        elmAuthor.data = author;
@@ -1596,17 +1611,17 @@ var Editor = gOS.registerApplication( function(){
                                y = _y;
                                w = _w;
                                h = _h;
-                       }
+                       };
                        function bodyBackOrForward( isBack ){
-                               if( !self) return;
-                               if( bodyIsTachable === !isBack) return;
+                               if( !self ) return;
+                               if( bodyIsTachable === !isBack ) return;
                                elmBodyStyle.position = isBack === true ? 'relative' : 'absolute';
                                elmBodyStyle.left =             isBack === true ? 0  : x +'px';
-                               elmBodyStyle.top =              isBack === true ? 0  : y +headerH +'px';
-                               elmBodyStyle.width =    isBack === true ? '' : ( w -WINDOW_BODY_BODER_SIZE *2) +'px';
+                               elmBodyStyle.top =              isBack === true ? 0  : y + headerH + 'px';
+                               elmBodyStyle.width =    isBack === true ? '' : ( w - WINDOW_BODY_BODER_SIZE * 2 ) + 'px';
                                bodyIsTachable === isBack && isBack === true ? elmHeader.parentNode.insertBefore( elmBody, elmHeader.nextSibling ) : app.rootElement.appendChild( elmBody );
                                bodyIsTachable = !isBack;
-                       }
+                       };
 
                        this.init = function(){
                                self.elm      = elmWindowOrigin.cloneNode( true );
@@ -1683,7 +1698,7 @@ var Editor = gOS.registerApplication( function(){
                        };
                        this.onFadeOut = function(){
                                self.elm.parentNode.removeChild( self.elm );
-                               self.onClose && setTimeout( self.onClose, 0 );
+                               self.onClose &&  app.addAsyncCall( self.onClose );
                        };
                        this.close = function(){
                                if( visible === false) return;
@@ -1876,21 +1891,21 @@ var Editor = gOS.registerApplication( function(){
                function addImage(){
                        IMAGE_EXPLORER_WINDOW.open();// setTimeout( IMAGE_EXPLORER_WINDOW.open, 0);
                        TOOL_BOX_WINDOW.bodyBackOrForward( true );
-               }
+               };
                function addText(){
-                       setTimeout( PANEL_ELEMENT_CONTROL.createTextElement, 0 );
-               }
+                       app.addAsyncCall( PANEL_ELEMENT_CONTROL.createTextElement );
+               };
                function switchGrid(){
-                       setTimeout( GRID_CONTROL.update, 0 );
-               }
+                       app.addAsyncCall( GRID_CONTROL.update );
+               };
                function popupHelp(){
                        TOOL_BOX_WINDOW.bodyBackOrForward( true );
-                       setTimeout( HELP_DOCUMENTS_WINDOW.open, 0 );
-               }
+                       app.addAsyncCall( HELP_DOCUMENTS_WINDOW.open );
+               };
                function editBG( e ){
                        TOOL_BOX_WINDOW.bodyBackOrForward( true );
-                       setTimeout( INFOMATION_WINDOW.open, 0 );
-               }
+                       app.addAsyncCall( INFOMATION_WINDOW.open );
+               };
                
                return WINDOWS_CONTROL.createWindow(
                        {
@@ -2149,17 +2164,17 @@ var Editor = gOS.registerApplication( function(){
                        jqAjaxContents.removeClass( 'loading' ).append( elmNavi, elmPages );
                        
                        jqNaviItems = jqAjaxContents.find( 'a.' + elmItemOrigin.className ).click( onNaviClick );
-                       jqPages = jqAjaxContents.find( '.page-content' );
+                       jqPages     = jqAjaxContents.find( '.page-content' );
                        jqPages.find( 'a' ).click( onInnerLinkClick );
                        
-                       setTimeout( jumpPage, 0 );
+                       app.addAsyncCall( jumpPage );
                }
                function onSelectionClick( _pageIndex ){
                        HELP_DOCUMENTS_WINDOW.open();
                        jumpPage( _pageIndex );
                }
                function jumpPage( _index ){
-                       if( typeof _index === 'number' && 0 <= _index && _index < numPage && currentPageIndex !== _index ){
+                       if( Type.isNumber( _index ) === true && 0 <= _index && _index < numPage && currentPageIndex !== _index ){
                                currentPageIndex = _index;
                        }
                        jqNaviItems.removeClass( 'current' ).eq( currentPageIndex).addClass( 'current' );
@@ -2182,7 +2197,7 @@ var Editor = gOS.registerApplication( function(){
                                onInit: function(){
                                        help           = MENU_BAR_CONTROL.HELP;
                                        onLoadFunction = help.createAjaxSelection( onAjaxStart );
-                                       jqAjaxContents = $( HELP_DOCUMENTS_WINDOW.elm ).find( '.window-body' ).addClass( 'loading' );
+                                       jqAjaxContents = $( HELP_DOCUMENTS_WINDOW.elm ).find( '.window-body' ).addClass( 'loading' ).css( { overflow: 'auto' } );
                                        delete HELP_DOCUMENTS_WINDOW.onInit;
                                },
                                onFirstOpen: function( _w, _h ){
@@ -4099,7 +4114,7 @@ var ComicConsole = gOS.registerApplication( function(){
        var elmHeader, elmProgress,
                winW, winH,
                inputTitle, inputW, inputH,
-               comboboxVisible, comboboxEditable,
+               comboboxVisible, // comboboxEditable,
                buttonSubmit, buttonCancel,
                elmUploader = null,
                elmScript   = null,
@@ -4143,7 +4158,7 @@ var ComicConsole = gOS.registerApplication( function(){
                                        _select.selectedIndex = comboboxVisible.selectIndex();
                                } else
                                if( _name === 'comic[editable]'){
-                                       _select.selectedIndex = comboboxEditable.selectIndex();
+                                       // _select.selectedIndex = comboboxEditable.selectIndex();
                                };
                        };
                        try {
@@ -4173,6 +4188,12 @@ var ComicConsole = gOS.registerApplication( function(){
                        };
                                function onIframeUpdate(){
                                        elmIframe.onload = null;
+                                       try {
+                                               console.log( ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).document.body.innerHTML );
+                                       } catch(e){
+                                               
+                                       }
+                                       
                                        ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();
                                        elmIframe = null;
                                        elmProgress.innerHTML = 'success!';
@@ -4200,7 +4221,7 @@ var ComicConsole = gOS.registerApplication( function(){
                                                comboboxVisible.createOption( option.innerHTML, option.value, option.selected );
                                        } else
                                        if( select.name === 'comic[editable]' ){
-                                               comboboxEditable.createOption( option.innerHTML, option.value, option.selected );
+                                               // comboboxEditable.createOption( option.innerHTML, option.value, option.selected );
                                        };
                                };
                        };
@@ -4245,10 +4266,10 @@ var ComicConsole = gOS.registerApplication( function(){
                                        '<span class="field-label">Visible:</span>',
                                        '<span id="comic-console-visible-value" class="comic-console-value combobox"></span>',
                                '</div>',
-                               '<div id="comic-console-editable" class="field">',
-                                       '<span class="field-label">Editable:</span>',
-                                       '<span id="comic-console-editable-value" class="comic-console-value combobox"></span>',
-                               '</div>',
+                               //'<div id="comic-console-editable" class="field">',
+                               //      '<span class="field-label">Editable:</span>',
+                               //      '<span id="comic-console-editable-value" class="comic-console-value combobox"></span>',
+                               //'</div>',
                                '<div class="console-button-container">',
                                        '<div id="comic-console-post-button" class="button console-submit-button">create</div>',
                                        '<div id="comic-console-cancel-button" class="button console-cancel-button">cancel</div>',
@@ -4268,7 +4289,7 @@ var ComicConsole = gOS.registerApplication( function(){
                inputW           = ui.createInputText( document.getElementById( 'comic-console-width') );
                inputH           = ui.createInputText( document.getElementById( 'comic-console-height') );
                comboboxVisible  = ui.createCombobox( document.getElementById( 'comic-console-visible') );
-               comboboxEditable = ui.createCombobox( document.getElementById( 'comic-console-editable') );
+               // comboboxEditable = ui.createCombobox( document.getElementById( 'comic-console-editable') );
                buttonSubmit     = ui.createButton( document.getElementById( 'comic-console-post-button'), clickOK );
                buttonCancel     = ui.createButton( document.getElementById( 'comic-console-cancel-button'), clickCancel );
                
@@ -4503,6 +4524,11 @@ var PanelConsole = gOS.registerApplication( function(){
                    };
                        };
                                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!';
@@ -5024,10 +5050,10 @@ var OutputConsole = gOS.registerApplication( function(){
                elmOutputArea = document.getElementById( 'output-area' );
                
                var ui = instance.createUIGroup();
-               comboboxFormat = ui.createCombobox( document.getElementById( 'output-console-format' ) );
+               comboboxFormat = ui.createCombobox( document.getElementById( 'output-console-format' ), clickGenerate );
                
                for( var i=0; FORMAT_LIST[ 0 ]; ++i ){
-                       comboboxFormat.createOption( FORMAT_LIST.pop(), null, i === 0 );
+                       comboboxFormat.createOption( FORMAT_LIST.shift(), null, i === 0 );
                };
                inputOption    = ui.createInputText( document.getElementById( 'output-console-option' ), null );
                buttonGenerate = ui.createButton( document.getElementById( 'output-console-generate-button' ), clickGenerate );