/*\r
* pettanR common.js\r
- * version 0.4.19\r
+ * version 0.4.21\r
* \r
* author: itozyun\r
*/\r
IS_DEBUG = Type.isBoolean( URL_PARAMS.debug ) ? URL_PARAMS.debug : IS_LOCAL === true,\r
jqWindow , jqDocument , jqBody;\r
return {\r
- version: '0.4.19',\r
+ version: '0.4.21',\r
init: function(){\r
jqWindow = $( window);\r
jqDocument = $( document);\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.onOpen = function( _w, _h /*, _option */ ){\r
- // overrride\r
- };\r
- this.onClose = function(){\r
- // overrride\r
- return true;\r
- } // false の場合、close の拒否 \r
- this.onPaneResize = function( _w, _h ){}\r
this.open = function( _w, _h /*, _option */ ){\r
- if( this.nextSibling && this.nextSibling.parentNode === this.parentElement ){\r
- this.parentElement.insertBefore( this.rootElement, this.nextSibling );\r
- } else\r
- if( this.parentElement ){\r
- this.parentElement.appendChild( this.rootElement );\r
- } else {\r
- this.rootElement && document.body.appendChild( this.rootElement );\r
- }\r
if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){\r
if( Type.isHTMLElement( this.rootElement ) === true ){\r
// 小さすぎる!、と表示\r
}\r
this.close = function(){\r
if( this.onClose() === false ){\r
- \r
+ return;\r
}\r
if( this.rootElement && this.rootElement.parentNode ){\r
this.rootElement.parentNode.removeChild( this.rootElement );\r
}\r
}\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.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
- var ApplicationReference = function( _application ){\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
+ bootApplication( application, pettanr.util.copyArray( arguments ) );\r
} else {\r
- bootApplication( _application );\r
+ bootApplication( application );\r
}\r
}\r
this.bootInOverlay = function( /* _option */ ){\r
this.inOverlay = true;\r
- pettanr.overlay.show( _application );\r
- \r
- if( arguments.length > 0 ){\r
- var _arguments = pettanr.util.copyArray( arguments );\r
- _arguments.unshift( jqWindow.width(), jqWindow.height() )\r
- // argumentsRellay( _application.open, _arguments );\r
- _application.open.apply( _application, _arguments );\r
- } else {\r
- _application.open( jqWindow.width(), jqWindow.height() );\r
- }\r
+ pettanr.overlay.show( application, pettanr.util.copyArray( arguments ) );\r
}\r
this.shutdown = function(){\r
if( this.inOverlay === true ){\r
pettanr.overlay.hide();\r
- _application.close();\r
+ application.close();\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
+ if( pettanr.util.getIndex( LUNCHER_APPLICATION_LIST, application ) !== -1 ) return;\r
+ LUNCHER_APPLICATION_LIST.push( application );\r
\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.appendChild( document.createTextNode( application.displayName ));\r
item.onclick = LoginUserNavi.show;\r
}\r
}\r
}\r
\r
if( currentApplication === _application ) return;\r
- \r
currentApplication && currentApplication.close();\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
function onWindowResize(){\r
var w = jqWindow.width(),\r
h = jqWindow.height();\r
- currentApplication && currentApplication.resize && currentApplication.resize( w, h );\r
- pettanr.overlay.currentID !== null && pettanr.overlay.onWindowResize( w, h );\r
+ currentApplication && currentApplication.resize( w, h );\r
+ pettanr.overlay.onWindowResize( w, h );\r
}\r
\r
return {\r
jqWindow.resize( onWindowResize );\r
\r
var _option = {}; // urlパラメータ\r
-\r
+ \r
+ onWindowResize();\r
+ \r
bootApplication( pettanr.URL_PARAMS.view || 0 );\r
\r
delete pettanr.view.init;\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.close();\r
- pettanr.overlay.hide(); \r
+ pettanr.overlay.hide();\r
}\r
function asyncResize(){\r
currentOverlay.resize( windowW, windowH);\r
return false; \r
}\r
function onFadeInComplete(){\r
- \r
+\r
}\r
function onFadeOutComplete(){\r
if( currentOverlay.rootElement && currentOverlay.rootElement.parentNode === ELM_CONTAINER ){\r
\r
delete pettanr.overlay.init;\r
},\r
- show: function( _overlay ){\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
- ELM_CONTAINER.insertBefore( _overlay.rootElement, document.getElementById( 'overlay-close-button' ));\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
top: document.documentElement.scrollTop || document.body.scrollTop\r
}).fadeIn( onFadeInComplete );\r
- \r
- this.visible = visible = true;\r
- currentOverlay = _overlay;\r
- this.currentID = _overlay.ID;\r
- // jqCloseButton.toggle( !!_overlay.onClose );\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
if( visible === false) return;\r
visible: visible,\r
currentID: null,\r
onWindowResize: function( _windowW, _windowH ){\r
+ windowW = _windowW;\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
- windowW = _windowW;\r
- windowH = _windowH;\r
+ jqShadow.css( { height: _windowH });\r
// 先にeditorのcanvasを確定する。\r
- currentOverlay && setTimeout( asyncResize, 0);\r
- },\r
- registerOverlay: function( _basicPane){\r
- var _api = pettanr.view.createBasicPane( _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
- \r
+ setTimeout( asyncResize, 0);\r
}\r
}\r
})();\r