OSDN Git Service

fixed overlay.hide()
[pettanr/pettanr.git] / public / assets / common.js
index af4816a..23649d6 100644 (file)
@@ -1,10 +1,78 @@
 /*\r
  * pettanR common.js\r
- *   version 0.4.7\r
+ *   version 0.4.21\r
  * \r
  * author: itozyun\r
  */\r
 \r
+/*\r
+ * http://pettanr.sourceforge.jp/test/type.html
+ */\r
+       var Type = {\r
+               isObject : function(v) {\r
+                       return v !== null && Type.isArray(v) === false && typeof v === 'object';\r
+               },\r
+               isFunction : function(v) {\r
+                       return typeof v === 'function';\r
+               },\r
+               isArray : function(v) {\r
+                       return Object.prototype.toString.call(v) === "[object Array]";\r
+               },\r
+               isBoolean : function(v) {\r
+                       return typeof v === 'boolean';\r
+               },\r
+               isString : function(v) {\r
+                       return typeof v === 'string';\r
+               },\r
+               isNumber : function(v) {\r
+                       return typeof v === 'number';\r
+               },\r
+               isFinite : function(v){\r
+                       return Type.isNumber(v) === true && isFinite(v);\r
+               },\r
+               isHTMLElement : function(v){\r
+                       if( 'HTMLElement' in window ){\r
+                               Type.isHTMLElement = function(v){\r
+                                       return v instanceof HTMLElement;\r
+                               }\r
+                       } else {\r
+                               Type.isHTMLElement = function(v) {\r
+                                       if( Type.isObject(v) === false ){\r
+                                               return false;\r
+                                       }\r
+                                       var r;\r
+                                       if(v && v.nodeType === 1){\r
+                                               try{\r
+                                                       r = v.cloneNode(false);\r
+                                               } catch(n) {\r
+                                                       return false;\r
+                                               }\r
+                                               if(r === v) return false;\r
+                                               try{\r
+                                                       r.nodeType = 9;\r
+                                                       return r.nodeType === 1;\r
+                                               } catch(n) {}\r
+                                               return true;\r
+                                       }\r
+                                       return false;\r
+                               }\r
+                       }\r
+                       return Type.isHTMLElement(v);\r
+               },\r
+               /*\r
+               isElementCollection : function(v) {\r
+                       return (Object.prototype.toString.call(v) === "[object HTMLCollection]");\r
+               },\r
+               */\r
+               isNull : function(v) {\r
+                       return v === null;\r
+               },\r
+               isUndefined : function(v) {\r
+                       return typeof v === 'undefined';\r
+               }\r
+       };\r
+\r
+\r
 var pettanr = ( function(){\r
        var     FUNCTION_ARRAY = [],\r
                URL = document.location.href.split( '#')[ 0],\r
@@ -22,7 +90,7 @@ var pettanr = ( function(){
                                        if( elm.length === 2){\r
                                                v = decodeURIComponent( elm[ 1]);\r
                                                if( '' + parseFloat( v) === v) v = parseFloat( v);\r
-                                               if( '' + parseInt( v) === '0' + v) v = parseInt( v);\r
+                                               if( '' + parseInt( v, 10 ) === '0' + v) v = parseInt( v, 10 );\r
                                                if( v === 'true') v = true;\r
                                                if( v === 'false') v = false;\r
                                                if( v === 'null') v = null;\r
@@ -37,10 +105,10 @@ var pettanr = ( function(){
                    }\r
                    return {};\r
                })(),\r
-               IS_DEBUG = typeof URL_PARAMS.debug === 'boolean' ? URL_PARAMS.debug : IS_LOCAL === true,\r
+               IS_DEBUG = Type.isBoolean( URL_PARAMS.debug ) ? URL_PARAMS.debug : IS_LOCAL === true,\r
                jqWindow , jqDocument , jqBody;\r
        return {\r
-               version: '0.4.6',\r
+               version: '0.4.21',\r
                init: function(){\r
                        jqWindow = $( window);\r
                        jqDocument = $( document);\r
@@ -50,7 +118,7 @@ var pettanr = ( function(){
                                _fn;\r
                        for( var i=0; i<l; i++){\r
                                _fn = FUNCTION_ARRAY[ i];\r
-                               _fn.init && _fn.init( _fn === pettanr.view ? FUNCTION_ARRAY : undefined);\r
+                               _fn.init && _fn.init( _fn === pettanr.view ? FUNCTION_ARRAY : undefined );\r
                        }\r
                        \r
                        delete pettanr.init;\r
@@ -248,7 +316,6 @@ pettanr.util = ( function(){
                        } else {\r
                                parentElm && parentElm.appendChild( img);\r
                        }\r
-                       return size;\r
                        \r
                /* LICENSE: MIT\r
                 * AUTHOR: uupaa.js@gmail.com\r
@@ -291,6 +358,8 @@ pettanr.util = ( function(){
                                // HTMLCanvasElement\r
                                return { width: image.width, height: image.height };\r
                        }\r
+                       \r
+                       return size;\r
                },\r
                loadImage: function( URLorELM, onLoad, onError, delay, timeout){\r
                        delay = delay || 250;\r
@@ -443,7 +512,7 @@ pettanr.util = ( function(){
                        return ret;\r
                },\r
                getChildIndex: function( _parent, _child){\r
-                       var _children = _parent.getElementsByTagName( _child.tagName),\r
+                       var _children = _parent.getElementsByTagName( _child.tagName ),\r
                                l = _children.length;\r
                        for(var i=0; i<l; ++i){\r
                                if( _children[ i] === _child) return i;\r
@@ -469,7 +538,7 @@ pettanr.util = ( function(){
                        }\r
                },\r
                getIndex: function( _array, _element){\r
-                       if( Array.prototype.indexof){\r
+                       if( Array.prototype.indexof ){\r
                                pettanr.util.getIndex = function( _array, _element){\r
                                        return _array.indexof( _element);\r
                                }\r
@@ -483,6 +552,13 @@ pettanr.util = ( function(){
                        }\r
                        return pettanr.util.getIndex( _array, _element);\r
                },\r
+               copyArray: function( _array ){\r
+                       var ret = new Array( l );\r
+                       for(var i=0, l = _array.length; i<l; ++i){\r
+                               ret[ i ] = _array[ i ];\r
+                       }\r
+                       return ret;\r
+               },\r
                /*\r
                 * \r
                 */\r
@@ -533,7 +609,15 @@ pettanr.util = ( function(){
                createIframe: function( id, callback){\r
                        var ua = pettanr.ua;\r
             var el = document.createElement( ua.isIE ? '<iframe name="' + id + '" frameborder="0" scrolling="no">' : 'iframe');\r
-            \r
+\r
+            if( ua.isIE){\r
+                               el.onreadystatechange = detect;\r
+            } else {\r
+               // iron(chrome) の場合、append の前に onload を指定しないと onload が呼ばれない\r
+               el.onload = onLoad;\r
+               //setTimeout( asynkCallback, 0 );\r
+                       }\r
+\r
                        document.body.appendChild( el);\r
             el.id = el.name = id;\r
             el.setAttribute( 'name', id);\r
@@ -544,18 +628,13 @@ pettanr.util = ( function(){
             \r
             window[id] = el;\r
 \r
-            if( ua.isIE){\r
-                               el.onreadystatechange = detect;\r
-            } else {\r
-               el.onload = onLoad;\r
-                       }\r
             function detect(){\r
                 if ( this.readyState === "complete") {\r
                     this.onreadystatechange = new Function();\r
                     this.onreadystatechange = null;\r
                     setTimeout( asynkCallback, 0 );\r
                 }\r
-            }                  \r
+            }\r
                        function onLoad(){\r
                                el.onload = null;\r
                                setTimeout( asynkCallback, 0 );\r
@@ -699,135 +778,57 @@ pettanr.CONST = ( function(){
        return {\r
                PETTANR_ROOT_PATH:                      PETTANR_ROOT_PATH,\r
                URL_ORIGINAL_PICTURES_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'original_pictures.json',\r
+               URL_RESOURCE_PICTURES_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'resource_pictures.json',\r
                URL_COMICS_JSON:                        ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'comics.json',\r
                URL_PANELS_JSON:                        ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'panels.json',\r
                NS_PETTANR_COMIC:                       'pettanr-comic',\r
-               RESOURCE_PICTURE_PATH:          ( isLocal === true ? pettanr.ROOT_PATH : PETTANR_ROOT_PATH) + 'resource_pictures\/',\r
+               RESOURCE_PICTURE_PATH:          ( isLocal === true ? '' : PETTANR_ROOT_PATH) + 'resource_pictures\/',\r
                CREATE_COMIC_JS:                        isLocal === true ? 'js\/create_new_comic.js' : PETTANR_ROOT_PATH + 'comics\/new.js',\r
+               CREATE_PANEL_JS:                        isLocal === true ? 'js\/create_new_panel.js' : PETTANR_ROOT_PATH + 'panels\/new.js',\r
                UPLOAD_PICTURE_JS:                      isLocal === true ? 'js\/upload_picture.js' : PETTANR_ROOT_PATH + 'original_pictures\/new.js',\r
+               REGISTER_ARTIST_JS:                     isLocal === true ? 'js\/register_artist.js' : PETTANR_ROOT_PATH + 'artists\/new.js',\r
                JQUERY_URL:                                     isLocal === true ? 'javascripts\/jquery-1.6.2.min.js' : PETTANR_ROOT_PATH + 'assets\/jquery-162_min.js'\r
        }\r
 })();\r
 \r
-\r
 pettanr.view = ( function(){\r
        /* create iframe overlay for user console */\r
        var location = document.location.pathname,\r
                isWorkPage =    document.location.href.indexOf( 'http:\/\/localhost:3000\/' ) === 0 ||\r
-                                               location.indexOf( pettanr.CONST.PETTANR_ROOT_PATH ) === 0 ||\r
+                                               document.location.href.indexOf( pettanr.CONST.PETTANR_ROOT_PATH ) === 0 ||\r
                                                location.indexOf( '\/work.html') !== -1 ||\r
-                                               location.indexOf( '\work.html') !== -1,\r
+                                               location.indexOf( '\work.html') !== -1, // for ie6\r
                deep =  location.indexOf( '\/diary\/') !== -1 ||\r
                                location.indexOf( '\/test\/') !== -1 ||\r
                                location.indexOf( '\/help\/') !== -1 ||\r
                                location.indexOf( '\/sitemap\/') !== -1 ||\r
                                location.indexOf( '\/wiki\/') !== -1,\r
                LoginUserNavi;\r
-       \r
-       if( isWorkPage === false){\r
-               LoginUserNavi = ( function(){\r
-                       var _body = document.body,\r
-                               _root = document.getElementsByTagName( 'html' )[ 0 ],\r
-                               filter,\r
-                               iframe, visible = false;\r
-                       return {\r
-                               show: function(){\r
-                                       document.location.href = [\r
-                                                       deep === true ? '../' : '',\r
-                                                       'work.html',\r
-                                                       typeof viewIndex === 'number' ? '?view=' + viewIndex : ''\r
-                                               ].join( '');\r
-                               },\r
-                               hide: function(){}\r
-                       }\r
-               })();\r
-       } else {\r
-               LoginUserNavi = ( function(){\r
-                       return {\r
-                               show: function(){\r
-                                       var i = pettanr.util.getChildIndex( this.parentNode, this );\r
-                                       i !== -1 && pettanr.view.show( i );\r
-                                       return false;\r
-                               },\r
-                               hide: function(){}\r
-                       }\r
-               })();\r
 \r
-               if( pettanr.IS_IFRAME === true){\r
-                       var _nodes = document.getElementsByTagName( 'a'),\r
-                               _a, _href;\r
-                       for(var i=0, l = _nodes.length; i<l; i++){\r
-                               _a = _nodes[ i];\r
-                               _href = _a.href.split('?')[0].split('#')[0];\r
-                               if( pettanr.util.getAbsolutePath( _href) !== location) _a.target = '_parent';\r
-                       }\r
+       if( isWorkPage === false){\r
+               LoginUserNavi = {\r
+                       show: function(){\r
+                               var i = pettanr.util.getChildIndex( this.parentNode, this );\r
+                               document.location.href = [\r
+                                               deep === true ? '../' : '',\r
+                                               'work.html',\r
+                                               typeof i === 'number' ? '?view=' + i : ''\r
+                                       ].join( '');\r
+                               return false;\r
+                       },\r
+                       hide: function(){}\r
                }\r
-               \r
-               if( pettanr.DEBUG === true){\r
-                       var elmDl = document.getElementById( 'useragent'),\r
-                               elmDt, elmDd,\r
-                               data = {\r
-                                       pettanR:        pettanr.version,\r
-                                       ua:                     navigator.userAgent,\r
-                                       platform:       navigator.platform,\r
-                                       appVersion:     navigator.appVersion,\r
-                                       appCodeName:navigator.appCodeName,\r
-                                       appName:        navigator.appName,\r
-                                       language:       navigator.browserLanguage || navigator.language,\r
-                                       ActiveX:        pettanr.ua.ACTIVEX\r
-                               },\r
-                               ua = pettanr.ua;\r
-                       if( ua.IE){\r
-                               //data.ua = 'Internet Explorer';\r
-                               data.version = ua.IE;\r
-                               if( ua.ieVersion >= 8) data.RenderingVersion = ua.ieRenderingVersion;\r
-                               data.browserType = ua.STANDALONE === true ? 'Standalone' : 'bundle';\r
-                               if( ua.ieVersion < 9) {\r
-                                       data.vml = ua.VML;\r
-                               } else {\r
-                                       data.svg = ua.SVG;\r
-                               }\r
-                       }\r
-                       data.RenderingMode = ua.isStanderdMode === true ? 'Standerd' : 'Quirks';\r
-                       \r
-                       for( var key in data){\r
-                               elmDt = document.createElement( 'dt');\r
-                               elmDt.innerHTML = key;\r
-                               elmDd = document.createElement( 'dd');\r
-                               elmDd.innerHTML = '' + data[ key];\r
-                               if( !data[ key]) elmDd.style.color = 'red';\r
-                               elmDl.appendChild( elmDt);\r
-                               elmDl.appendChild( elmDd);\r
-                       }\r
-               } else {\r
-                       var _debug = document.getElementById( 'debug');\r
-                       if( _debug){\r
-                               pettanr.util.removeAllChildren( _debug);\r
-                               _debug.parentNode.removeChild( _debug);\r
-                       }\r
+       } else {\r
+               LoginUserNavi = {\r
+                       show: function(){\r
+                               var i = pettanr.util.getChildIndex( this.parentNode, this );\r
+                               i !== -1 && bootApplication( i );\r
+                               return false;\r
+                       },\r
+                       hide: function(){}\r
                }\r
        }\r
 \r
-       /* global-navi */\r
-       var navi = document.getElementById('global-navi'),\r
-               origin = document.createElement('a'),\r
-               items = ( function(){\r
-                       var ret = ['Home', 'Comic list', 'Picture', 'Setting'];\r
-                       pettanr.DEBUG === true && ret.push( 'debug');\r
-                       return ret;\r
-               })(),\r
-               l = items.length,\r
-               item;\r
-       origin.href = '#';\r
-       for(var i=0; i<l; ++i){\r
-               item = origin.cloneNode( true);\r
-               item.appendChild( document.createTextNode( items[ i]) );\r
-               item.onclick = LoginUserNavi.show;\r
-               navi.appendChild( item);\r
-       }\r
-       navi.style.width = ( ( item.offsetWidth || 80) * l) +'px';\r
-       location = origin = item = null;\r
-       \r
        /* debug info */\r
        // ua version, lang, os, plugin ( vml, svg), standerdmode, balloon, rimg\r
 \r
@@ -839,124 +840,234 @@ pettanr.view = ( function(){
  */\r
 \r
        var jqWindow,\r
-               funcArray,\r
-               HOME_ID = 'entrance',\r
-               VIEW_ID_ARRAY = [ HOME_ID, 'cabinet', 'gallery', 'backyard'],\r
-               elmCurrent,\r
-               currentView,\r
-               currentID = ( function( _view){\r
-                       var _viewID;\r
-                       \r
-                       if( typeof _view === 'number' && _view < VIEW_ID_ARRAY.length){\r
-                               _viewID = VIEW_ID_ARRAY[ _view];\r
-                       } else\r
-                       if( typeof _view === 'string'){\r
-                               _viewID = _view;\r
+               APPLICATION_LIST = [],\r
+               LUNCHER_APPLICATION_LIST = [],\r
+               currentApplication = null;\r
+       \r
+       var AbstractBasicPane = function(){\r
+               this.onPaneResize = function( _w, _h ){}\r
+               this.resize = function( _w, _h ){\r
+                       if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){\r
+                               if( Type.isHTMLElement( this.rootElement ) === true ){\r
+                                       // 小さすぎる!、と表示\r
+                               }\r
+                               return;\r
+                       }\r
+                       this.onPaneResize( _w, _h );\r
+               }\r
+               this.MIN_WIDTH = 240;\r
+               this.MIN_HEIGHT = 240;\r
+       }\r
+       \r
+       var AbstractApplication = function(){\r
+               this.displayName = 'app name';\r
+               this.ID = 'app id';\r
+               this.rootElement = null;\r
+               this.parentElement = null;\r
+               this.nextSibling = null;\r
+               this.open = function( _w, _h /*, _option */ ){\r
+                       if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){\r
+                               if( Type.isHTMLElement( this.rootElement ) === true ){\r
+                                       // 小さすぎる!、と表示\r
+                               }\r
+                       }\r
+                       if( arguments.length > 2){\r
+                               // argumentsRellay( this.onOpen, arguments );\r
+                               this.onOpen.apply( this, arguments );\r
                        } else {\r
-                               _viewID = HOME_ID;\r
+                               this.onOpen( _w, _h );\r
                        }\r
-\r
-                       if( document.getElementById( _viewID)){\r
-                               return _viewID;\r
+               }\r
+               this.close = function(){\r
+                       if( this.onClose() === false ){\r
+                               return false;\r
                        }\r
-                       return HOME_ID;\r
-               })( pettanr.URL_PARAMS.view);\r
-       \r
-       pettanr.DEBUG === true && VIEW_ID_ARRAY.push( 'debug');\r
+               }\r
+               this.onOpen = function( _w, _h /*, _option */ ){\r
+                       // overrride\r
+               };\r
+               this.onClose = function(){\r
+                       // overrride\r
+                       return true;\r
+               } // false の場合、close の拒否 \r
+       }\r
+       AbstractApplication.prototype = new AbstractBasicPane();\r
        \r
-       show();\r
+       var ApplicationReference = function( application ){\r
+               this.inOverlay = false;\r
+               this.getUID = function(){\r
+                       return pettanr.util.getIndex( APPLICATION_LIST, application );\r
+               }\r
+               this.boot = function( /* _option */ ){\r
+                       if( arguments.length > 0 ){\r
+                               bootApplication( application, pettanr.util.copyArray( arguments ) );\r
+                       } else {\r
+                               bootApplication( application );\r
+                       }\r
+               }\r
+               this.bootInOverlay = function( /* _option */ ){\r
+                       this.inOverlay = true;\r
+                       pettanr.overlay.show( application, pettanr.util.copyArray( arguments ) );\r
+               }\r
+               this.shutdown = function(){\r
+                       if( this.inOverlay === true ){\r
+                               pettanr.overlay.hide();\r
+                               this.inOverlay = false;\r
+                       } else {\r
+                               bootApplication( 0 );\r
+                       }\r
+               }\r
+               this.addToLancher = function(){\r
+                       if( pettanr.util.getIndex( LUNCHER_APPLICATION_LIST, application ) !== -1 ) return;\r
+                       LUNCHER_APPLICATION_LIST.push( application );\r
        \r
-       function onWindowResize(){\r
-               var _fn,\r
-                       l = funcArray.length,\r
-                       w = jqWindow.width(),\r
-                       h = jqWindow.height();\r
-               //for( var i=0; i<l; ++i){\r
-               //      _fn = funcArray[ i];\r
-               //      _fn.onWindowResize && _fn.onWindowResize( w, h);\r
-               //}\r
-               currentView && currentView.onWindowResize && currentView.onWindowResize( w, h);\r
-               pettanr.overlay.currentID !== null && pettanr.overlay.onWindowResize( w, h);\r
+                       var navi = document.getElementById('global-navi'),\r
+                               item = document.createElement('a');\r
+                       navi.appendChild( item );\r
+                       navi.style.width = ( ( item.offsetWidth || 80 ) * LUNCHER_APPLICATION_LIST.length ) + 'px';\r
+                       item.href = '#';\r
+                       item.appendChild( document.createTextNode( application.displayName ));\r
+                       item.onclick = LoginUserNavi.show;\r
+               }\r
        }\r
-       function show(){\r
-               if( isWorkPage === false) return;\r
+\r
+       function bootApplication( APPLICATIONorINDEX, _arguments ){\r
+               if( isWorkPage === false ) return;\r
+\r
+               var _application,\r
+                       i, j, l, \r
+                       nodesA = document.getElementById('global-navi').getElementsByTagName( 'a') || [],\r
+                       _index = -1;\r
+               if( typeof APPLICATIONorINDEX === 'number' && APPLICATIONorINDEX < LUNCHER_APPLICATION_LIST.length){\r
+                       _application = LUNCHER_APPLICATION_LIST[ APPLICATIONorINDEX ];\r
+               } else\r
+               if( typeof APPLICATIONorINDEX === 'string' ){\r
+                       for( i=0, l=LUNCHER_APPLICATION_LIST.length; i<l; ++i ){\r
+                               if( APPLICATIONorINDEX === APPLICATION_LIST[ i ].ID ){\r
+                                       _application = APPLICATION_LIST[ i ];\r
+                                       break;\r
+                               }\r
+                       }\r
+               } else\r
+               if( pettanr.view.isApplicationInstance( APPLICATIONorINDEX ) === true ){\r
+                       _application = APPLICATIONorINDEX;\r
+               } else\r
+               if( !currentApplication ){\r
+                       _application = LUNCHER_APPLICATION_LIST[ 0 ];\r
+               } else {\r
+                       return;\r
+               }\r
                \r
-               var _elm = document.getElementById( currentID);\r
-               if( elmCurrent) elmCurrent.style.display = 'none';\r
-               _elm.style.display = 'block';\r
-               elmCurrent = _elm;\r
+               if( !_application ) return;\r
                \r
-               var     nodesA = navi.getElementsByTagName( 'a') || [],\r
-                       l = nodesA.length,\r
-                       _a;\r
-               for(var i=0; i<l; ++i){\r
-                       if( nodesA[ i]){\r
-                               nodesA[ i].className = VIEW_ID_ARRAY[ i] === currentID ? 'current' : '';\r
+               for( i=0, l=LUNCHER_APPLICATION_LIST.length; i<l; ++i ){\r
+                       if( _application === LUNCHER_APPLICATION_LIST[ i ] ){\r
+                               for( j=0, l=nodesA.length; j<l; ++j ){\r
+                                       nodesA[ j ].className = i === j ? 'current' : '';\r
+                               }                                       \r
+                               break;\r
                        }\r
                }\r
                \r
-               if( !pettanr.view || pettanr.view.init !== undefined) return;\r
-               currentView = pettanr[ currentID];\r
-               if( !currentView) return;\r
-               typeof currentView.onOpen === 'function' && currentView.onOpen();\r
-               setTimeout( onWindowResize, 0);\r
+               if( currentApplication === _application ) return;\r
+               if( currentApplication ){\r
+                       currentApplication.close();\r
+                       currentApplication.rootElement && currentApplication.rootElement.parentNode &&\r
+                               currentApplication.rootElement.parentNode.removeChild( currentApplication.rootElement );\r
+               }\r
+                       \r
+               currentApplication = _application;\r
+               \r
+               if( _application.nextSibling && _application.nextSibling.parentNode === _application.parentElement ){\r
+                       _application.parentElement.insertBefore( _application.rootElement, _application.nextSibling );\r
+               } else\r
+               if( _application.parentElement ){\r
+                       _application.parentElement.appendChild( _application.rootElement );\r
+               } else {\r
+                       _application.rootElement && document.body.appendChild( _application.rootElement );\r
+               }\r
+                       \r
+               if( _arguments ){\r
+                       _arguments.unshift( jqWindow.width(), jqWindow.height() );\r
+                       _application.open.apply( _application, _arguments );\r
+                       // argumentsRellay( _application.open, _arguments );\r
+               } else {\r
+                       _application.open( jqWindow.width(), jqWindow.height() );\r
+               }\r
+               pettanr.view.currentID = _application.ID;\r
        }\r
        \r
-       var AbstractBasicPane = function(){\r
-               this.UID = '', // element の ID と一致\r
-               this.onOpen = function(){};\r
-               this.onClose = function(){};\r
-               this.onPaneResize = function( _w, _h){};\r
-               this.MIN_WIDTH = 0;\r
-               this.MIN_HEIGHT = 0;\r
+       function argumentsRellay( _method, _arguments ){\r
+               alert( typeof _method )\r
+               l = _arguments.length;\r
+               if( l > 0 ){\r
+                       var _arg = [];\r
+                       for( i=0; i<l; ++i ){\r
+                               _arg.push( 'a[' + i + ']' );\r
+                       }\r
+                       window['_method'] = _method;\r
+                       //eval( '_method(' + _arg.join(',') + ')' );\r
+                       var f = new Function( 'a', '_method(' + _arg.join(',') + ')' );\r
+                       f( _arguments );\r
+                       window['_method'] = undefined;\r
+               } else {\r
+                       _method();\r
+               }               \r
        }\r
        \r
+       function onWindowResize(){\r
+               var w = jqWindow.width(),\r
+                       h = jqWindow.height();\r
+               currentApplication && currentApplication.resize( w, h );\r
+               pettanr.overlay.onWindowResize( w, h );\r
+       }\r
+\r
        return {\r
-               init: function( _funcArray){\r
-                       funcArray = _funcArray;\r
+               init: function( _funcArray ){\r
                        jqWindow = pettanr.jqWindow();\r
-                       jqWindow.resize( onWindowResize);\r
+                       jqWindow.resize( onWindowResize );\r
+                       \r
+                       var _option = {}; // urlパラメータ\r
                        \r
-                       currentView = currentView || pettanr[ currentID];\r
-                       currentView && typeof currentView.onOpen === 'function' && currentView.onOpen();\r
+                       onWindowResize();\r
                        \r
-                       setTimeout( onWindowResize, 100);\r
+                       bootApplication( pettanr.URL_PARAMS.view || 0 );\r
                        \r
                        delete pettanr.view.init;\r
                },\r
-               show: function( _viewID){\r
-                       if( typeof _viewID === 'number' && _viewID < VIEW_ID_ARRAY.length){\r
-                               _viewID = VIEW_ID_ARRAY[ _viewID];\r
-                       } else\r
-                       if( typeof _viewID === 'string'){\r
-                               _viewID = _viewID;\r
-                       } else {\r
-                               _viewID = HOME_ID;\r
-                       }\r
-                       for( var key in pettanr.view){\r
-                               if( pettanr.view[ key] === _viewID){\r
-                                       if( currentID !== _viewID && document.getElementById( _viewID)){\r
-                                               this.currentID = currentID = _viewID;\r
-                                               show();\r
-                                       }\r
-                                       return;\r
-                               }\r
-                       }\r
-                       alert( _viewID);\r
+               createBasicPane: function( _class, _options ){\r
+                       _class.prototype = new AbstractBasicPane();\r
+                       return new _class( _options );\r
                },\r
-               resisterAsBasicPane: function( _basicPane){\r
-                       if( pettanr.view.isBasicPaneInstance( _basicPane ) === true ) return;\r
-                       _basicPane.prototype = new AbstractBasicPane();\r
+               _getAbstractApplication: function(){\r
+                       return new AbstractApplication();\r
                },\r
-               isBasicPaneInstance: function( _basicPane){\r
+               registerApplication: function( _class, _options ){\r
+                       _class.prototype = new AbstractApplication();\r
+                       _application = new _class( _options );\r
+                       \r
+                       var elm = _application.rootElement;\r
+                       if( Type.isHTMLElement( elm ) === false ) return null;\r
+                        \r
+                       _application.parentElement = elm.parentNode;\r
+                       _application.nextSibling = elm.nextSibling;\r
+                       \r
+                       if( elm.parentNode ){\r
+                               elm.parentNode.removeChild( elm );\r
+                       }\r
+                       APPLICATION_LIST.push( _application );\r
+                       return new ApplicationReference( _application );\r
+               },\r
+               isBasicPaneInstance: function( _basicPane ){\r
                        return  _basicPane instanceof AbstractBasicPane;\r
                },\r
-               currentID:      currentID,\r
-               HOME:           HOME_ID,\r
-               COMICS:         VIEW_ID_ARRAY[ 1],\r
-               IMAGES:         VIEW_ID_ARRAY[ 2],\r
-               SETTING:        VIEW_ID_ARRAY[ 3],\r
-               DEBUG:          VIEW_ID_ARRAY[ 4],\r
+               isApplicationInstance: function( _application ){\r
+                       return _application instanceof AbstractApplication;\r
+               },\r
+               isApplicationReference: function( _reference ){\r
+                       return _reference instanceof ApplicationReference;\r
+               },\r
+               currentID:      null,\r
                EDITOR:         'editor',\r
                OVERLAY:        'overlay'\r
        }\r
@@ -964,82 +1075,93 @@ pettanr.view = ( function(){
 \r
 pettanr.overlay = ( function(){\r
        var SHADOW_OPACITY = 0.5,\r
+               ELM_CONTAINER = document.getElementById( 'overlay-container' ),\r
                jqConteiner, jqShadow, jqCloseButton,// jqBody, \r
                currentOverlay = null,\r
+               bootParams = null,\r
                visible = false,\r
                windowW, windowH;\r
 \r
-       function close(){\r
-               currentOverlay && currentOverlay.onClose && currentOverlay.onClose();\r
-               pettanr.overlay.hide();         \r
-       }\r
        function asyncResize(){\r
-               currentOverlay.onWindowResize( windowW, windowH);\r
+               currentOverlay.resize( windowW, windowH);\r
        }\r
        function onCloseClick( e){\r
-               close();\r
+               pettanr.overlay.hide();\r
                e.preventDefault();\r
                return false;           \r
        }\r
+       function onFadeInComplete(){\r
+\r
+       }\r
+       function onFadeOutComplete(){\r
+               if( currentOverlay.rootElement && currentOverlay.rootElement.parentNode === ELM_CONTAINER ){\r
+                       ELM_CONTAINER.removeChild( currentOverlay.rootElement );\r
+               }\r
+               currentOverlay = null;\r
+       }\r
        return {\r
                init: function(){\r
                        //jqBody = pettanr.jqBody();\r
                        jqConteiner = $( '#overlay-container');\r
                        jqShadow = $( '#overlay-shadow');\r
-                       jqCloseButton = $( '#overlay-close-button').click( onCloseClick);\r
+                       jqCloseButton = $( '#overlay-close-button').click( onCloseClick );\r
                        \r
-                       pettanr.key.addKeyDownEvent( pettanr.view.OVERLAY, 27, false, false, close); // 27.esc\r
+                       pettanr.key.addKeyDownEvent( pettanr.view.OVERLAY, 27, false, false, pettanr.overlay.hide ); // 27.esc\r
                        \r
                        delete pettanr.overlay.init;\r
                },\r
-               show: function( _currentOverlay){\r
-                       if( visible === true && currentOverlay === _currentOverlay) return;\r
+               show: function( _overlay, _bootParams ){\r
+                       if( visible === true && currentOverlay === _overlay ) return;\r
+                       if( pettanr.view.isApplicationInstance( _overlay ) === false ) return;\r
+                       \r
+                       document.body.style.overflow = 'hidden';\r
+                       \r
+                       this.visible = visible = true;\r
+                       this.currentID = _overlay.ID;\r
+                       currentOverlay = _overlay;\r
+                       bootParams = _bootParams;\r
+\r
                        jqConteiner.stop().css( {\r
                                filter:         '',\r
-                               opacity:        ''\r
-                       }).fadeIn();\r
-                       this.visible = visible = true;\r
-                       currentOverlay = _currentOverlay;\r
-                       this.currentID = _currentOverlay.ID;\r
-                       jqCloseButton.toggle( !!_currentOverlay.onClose);\r
+                               opacity:        '',\r
+                               top:            document.documentElement.scrollTop || document.body.scrollTop\r
+                       }).fadeIn( onFadeInComplete );\r
+\r
+                       ELM_CONTAINER.insertBefore( currentOverlay.rootElement, document.getElementById( 'overlay-close-button' ));\r
+       \r
+                       if( Type.isArray( bootParams ) === true ){\r
+                               bootParams.unshift( windowW, windowH )\r
+                               currentOverlay.open.apply( currentOverlay, bootParams );\r
+                       } else {\r
+                               currentOverlay.open( windowW, windowH, bootParams );\r
+                       }\r
                },\r
                hide: function(){\r
-                       currentOverlay = null;\r
                        if( visible === false) return;\r
+                       document.body.style.overflow = '';\r
                        jqConteiner.stop().css( {\r
                                filter:         '',\r
                                opacity:        ''\r
-                       }).fadeOut();\r
+                       }).fadeOut( onFadeOutComplete );\r
+                       currentOverlay.close();\r
                        this.visible = visible = false;\r
                        this.currentID = null;\r
                },\r
                visible: visible,\r
                currentID: null,\r
-               onWindowResize: function( _windowW, _windowH){\r
-                       jqConteiner.css( { height:      _windowH});\r
-                       jqShadow.css( { height: _windowH});\r
+               onWindowResize: function( _windowW, _windowH ){\r
                        windowW = _windowW;\r
-                       windowH = _windowH;\r
-                       // 先にeditorのcanvasを確定する。\r
-                       currentOverlay && currentOverlay.onWindowResize && setTimeout( asyncResize, 0);\r
-               },\r
-               resisterOverlay: function( _basicPane){\r
-                       pettanr.view.resisterAsBasicPane( _basicPane);\r
-                       // OverlayAPI\r
-                       return {\r
-                               show: function( _basicPane ){\r
-                                       \r
-                               },\r
-                               hide: function( _basciPane ){\r
-                                       \r
-                               },\r
-                               isCurrent: function( _basicPane ){\r
-                                       \r
-                               }\r
-                       }\r
-               },\r
-               isOverlay: function( _basicPane ){\r
+                       windowH = _windowH;                     \r
                        \r
+                       if( currentOverlay === null ) return;\r
+                       \r
+                       jqConteiner.css({\r
+                               height:         _windowH,\r
+                               top:            document.documentElement.scrollTop || document.body.scrollTop\r
+                       });\r
+                       jqShadow.css( { height: _windowH });\r
+                       // 先にeditorのcanvasを確定する。\r
+                       setTimeout( asyncResize, 0);\r
                }\r
        }\r
 })();\r
@@ -1203,14 +1325,14 @@ pettanr.form = ( function(){
        var InputTextClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater){\r
                validater = typeof validater === 'function' ? validater : null;\r
                \r
-               var elmValue = pettanr.util.getElementsByClassName( WRAPPER_ELM, 'editable-value')[ 0],\r
+               var elmValue = pettanr.util.getElementsByClassName( WRAPPER_ELM, 'editable-value' )[ 0],\r
                        value,\r
                        index = GROUP_ID ? FORM_GROUP_TABLE[ GROUP_ID].length : -1,\r
                        instance,\r
                        focus = false,\r
                        visible = true,\r
                        enabled = true,\r
-                       elmA = ELM_A_ORIGIN.cloneNode( true);\r
+                       elmA = ELM_A_ORIGIN.cloneNode( true );\r
                \r
                if( elmValue === undefined){\r
                        alert( 'error!');\r
@@ -1218,9 +1340,13 @@ pettanr.form = ( function(){
                value = elmValue.innerHTML;\r
                elmValue.innerHTML = '';\r
                elmValue.className += ' editable-text';\r
+               try {\r
+                       elmA.innerHTML = value;\r
+               } catch(e){\r
+                       alert( value + elmA)\r
+               }\r
                \r
-               elmA.innerHTML = value;\r
-               elmValue.appendChild( elmA);\r
+               elmValue.appendChild( elmA );\r
                WRAPPER_ELM.onclick = onClick;\r
                \r
                function onClick( e){\r
@@ -1298,8 +1424,8 @@ pettanr.form = ( function(){
                        instance,\r
                        focus = false,\r
                        visible = true,\r
-                       enabled = true,\r
-                       elmFileInput = WRAPPER_ELM.getElementsByTagName('input')[0] || elmFileInput || document.createElement( 'input');\r
+                       enabled = true;\r
+               elmFileInput = WRAPPER_ELM.getElementsByTagName('input')[0] || elmFileInput || document.createElement( 'input');\r
                elmFileInput.type = 'file';\r
                elmFileInput.style.visivility = 'hidden';\r
 \r
@@ -1750,7 +1876,7 @@ pettanr.image = ( function(){
                        }\r
                }\r
                var activexImage = css3Image;\r
-               var vmlImage = function( url, w, h, onLoadCallback){\r
+               var vmlImage = function( url, w, h, onLoadCallback ){\r
                        var elmWrap = document.createElement( 'div'),\r
                                vmlImg,\r
                                loaded = false,\r
@@ -1782,7 +1908,7 @@ pettanr.image = ( function(){
                                vmlImg.style.width = w < 0 ? -w : w +'px';\r
                                vmlImg.style.height = h < 0 ? -h : h +'px';\r
                                //if( flipH !== _flipH || flipV !== _flipV){\r
-                                       vmlImg.parentNode === elmWrap && elmWrap.removeChild( vmlImg);\r
+                                       vmlImg.parentNode === elmWrap && elmWrap.removeChild( vmlImg );\r
                                //}\r
                                        vmlImg.className = w < 0 || h < 0 ? ( 'img-flip-' + ( w < 0 && h < 0 ? 'vh' : ( w < 0 ? 'h' : 'v'))) : '';\r
                                        elmWrap.appendChild( vmlImg);\r
@@ -1802,15 +1928,15 @@ pettanr.image = ( function(){
                        \r
                }\r
                \r
-               return function( url, w, h, onLoadCallback){\r
+               return function( url, w, h, onLoadCallback ){\r
                                var flipH = w < 0,\r
                                        flipV = h < 0,\r
                                        onLoadCallbackAsync = onLoadCallback,// ? function(){ setTimeout( onLoadCallback, 0);} : undefined,// 一度読み込んだ画像は即座にonLoadになるため遅延\r
-                                       xBackendImage = ( function( urlIsXDomain){\r
-                                               if( BACKEND === IS_CSS3) return css3Image.apply( {}, [ url, w, h, onLoadCallbackAsync]);\r
-                                               if( BACKEND === IS_VML) return vmlImage.apply( {}, [ url, w, h, onLoadCallbackAsync]);\r
-                                               if( BACKEND === IS_ACTIVEX) return activexImage.apply( {}, [ url, w, h, onLoadCallbackAsync]);\r
-                                               return serverImage.apply( {}, [ url, w, h, onLoadCallbackAsync]);\r
+                                       xBackendImage = ( function( urlIsXDomain ){\r
+                                               if( BACKEND === IS_CSS3) return new css3Image( url, w, h, onLoadCallbackAsync );\r
+                                               if( BACKEND === IS_VML) return new vmlImage( url, w, h, onLoadCallbackAsync );\r
+                                               if( BACKEND === IS_ACTIVEX) return new activexImage( url, w, h, onLoadCallbackAsync );\r
+                                               return new serverImage( url, w, h, onLoadCallbackAsync );\r
                                        })();\r
                                return {\r
                                        elm: xBackendImage.elm,\r
@@ -2170,16 +2296,16 @@ var VisualEffect = ( function(){
                return {\r
                        elm:    ELM,\r
                        onEnterFrame: function(){\r
-                               var _updateCss = {};\r
+                               var _updateCss = {}, i;\r
                                if( numFrames === 1){\r
-                                       for( var i=0; i<l; ++i){\r
+                                       for( i=0; i<l; ++i){\r
                                                _updateCss[ targetAttributes[ i]] = endParameters[ i];\r
                                                ++i;\r
                                        }\r
                                        updateCss( ELM, currentParameters, targetAttributes, l);\r
                                        onComplete !== null && onComplete();\r
                                } else {\r
-                                       for( var i=0; i<l; ++i){\r
+                                       for( i=0; i<l; ++i){\r
                                                _updateCss[ targetAttributes[ i]] = currentParameters[ i] = Math.floor( currentParameters[ i] + offsetParameters[ i]);\r
                                                ++i;\r
                                        }\r
@@ -2198,7 +2324,7 @@ var VisualEffect = ( function(){
        var VisualEffectClass = function( ELM){\r
                var isHtmlElement;\r
                \r
-               function resisterAnime( _cssObject, _onComplete, _onEnterFrame, _time){\r
+               function registerAnime( _cssObject, _onComplete, _onEnterFrame, _time){\r
                        var _numFrames = Math.floor( _time / fpms);\r
                        startAnimation( ELM, _cssObject, _onComplete, _onEnterFrame, _numFrames);\r
                }\r
@@ -2213,7 +2339,7 @@ var VisualEffect = ( function(){
                        \r
                }\r
                \r
-               this.anime = resisterAnime;\r
+               this.anime = registerAnime;\r
                this.fadeIn = startFadeIn;\r
                this.fadeOut = startFadeOut;\r
                this.update = update;\r