/*\r
* pettanR common.js\r
- * version 0.4.18\r
+ * version 0.4.19\r
* \r
* author: itozyun\r
*/\r
}\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.17',\r
+ version: '0.4.19',\r
init: function(){\r
jqWindow = $( window);\r
jqDocument = $( document);\r
_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
} else {\r
parentElm && parentElm.appendChild( img);\r
}\r
- return size;\r
\r
/* LICENSE: MIT\r
* AUTHOR: uupaa.js@gmail.com\r
// 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
/* 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
- location.indexOf( '\/work.html') !== -1,\r
+ document.location.href.indexOf( pettanr.CONST.PETTANR_ROOT_PATH ) === 0 ||\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
+\r
if( isWorkPage === false){\r
LoginUserNavi = {\r
show: function(){\r
\r
var AbstractBasicPane = function(){\r
this.rootElement = null;\r
+ this.parentElement = null;\r
+ this.nextSibling = null;\r
this.onOpen = function( _w, _h /*, _option */ ){\r
// overrride\r
};\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.rootElement === null ){\r
+ alert( this.ID )\r
+ }\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
+ // argumentsRellay( this.onOpen, arguments );\r
+ this.onOpen.apply( this, arguments );\r
} else {\r
this.onOpen( _w, _h );\r
}\r
if( this.onClose() === false ){\r
\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
\r
function bootApplication( APPLICATIONorINDEX, _arguments ){\r
if( isWorkPage === false ) return;\r
- \r
+\r
var _application,\r
- _elm, i, l,\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
\r
for( i=0, l=LUNCHER_APPLICATION_LIST.length; i<l; ++i ){\r
if( _application === LUNCHER_APPLICATION_LIST[ i ] ){\r
- for(var j=0, l=nodesA.length; j<l; ++j ){\r
+ for( j=0, l=nodesA.length; j<l; ++j ){\r
nodesA[ j ].className = i === j ? 'current' : '';\r
} \r
break;\r
\r
if( currentApplication === _application ) return;\r
\r
- if( currentApplication ){\r
- _elm = currentApplication.rootElement;\r
- if( _elm ){\r
- _elm.style.display = 'none';\r
- }\r
- currentApplication.close();\r
- }\r
+ currentApplication && currentApplication.close();\r
+\r
currentApplication = _application;\r
\r
- _elm = _application.rootElement;\r
- if( _elm ){\r
- _elm.style.display = 'block';\r
- }\r
- \r
if( _arguments ){\r
_arguments.unshift( jqWindow.width(), jqWindow.height() );\r
_application.open.apply( _application, _arguments );\r
- // argumentsRellay( _application.open, _arguments ); \r
+ // argumentsRellay( _application.open, _arguments );\r
} else {\r
_application.open( jqWindow.width(), jqWindow.height() );\r
}\r
}\r
\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( '_arguments[' + i + ']' );\r
+ _arg.push( 'a[' + i + ']' );\r
}\r
window['_method'] = _method;\r
- eval( '_method(' + _arg.join(',') + ')' );\r
- delete window['_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
jqWindow.resize( onWindowResize );\r
\r
var _option = {}; // urlパラメータ\r
- \r
- for( var i=0, l=APPLICATION_LIST.length; i<l; ++i){\r
- APPLICATION_LIST[ i ].init && APPLICATION_LIST[ i ].init();\r
- }\r
+\r
bootApplication( pettanr.URL_PARAMS.view || 0 );\r
\r
delete pettanr.view.init;\r
_class.prototype = new AbstractBasicPane();\r
return new _class( _options );\r
},\r
- registerAsBasicPane: function( _class ){\r
- _class.prototype = new AbstractBasicPane();\r
+ _getAbstractApplication: function(){\r
+ return new AbstractApplication();\r
},\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
\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
visible = false,\r
return false; \r
}\r
function onFadeInComplete(){\r
- \r
+ ELM_CONTAINER.insertBefore( currentOverlay.rootElement, document.getElementById( 'overlay-close-button' ));\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
\r
delete pettanr.overlay.init;\r
},\r
- show: function( _currentOverlay ){\r
- if( visible === true && currentOverlay === _currentOverlay ) return;\r
+ show: function( _overlay ){\r
+ if( visible === true && currentOverlay === _overlay ) return;\r
+ if( pettanr.view.isApplicationInstance( _overlay ) === false ) return;\r
+ \r
document.body.style.overflow = 'hidden';\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 = _currentOverlay;\r
- this.currentID = _currentOverlay.ID;\r
- jqCloseButton.toggle( !!_currentOverlay.onClose );\r
+ currentOverlay = _overlay;\r
+ this.currentID = _overlay.ID;\r
+ // jqCloseButton.toggle( !!_overlay.onClose );\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
this.visible = visible = false;\r
this.currentID = null;\r
},\r
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
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
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
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
/*\r
* pettanR work.js\r
- * version 0.4.18\r
+ * version 0.4.19\r
* \r
* author:\r
* itozyun\r
return {\r
update: draw,\r
index: function( _mouseX, _mouseY){\r
- var p;\r
- for( var i=4; i<8; i++){\r
+ var p, i;\r
+ for( i=4; i<8; i++){\r
p = POSITION_ARRAY[ i];\r
if( p.x <= _mouseX && p.y <= _mouseY && p.x + p.w >= _mouseX && p.y +p.h >= _mouseY){\r
MOUSE_CURSOR( CURSOR_AND_FLIP[ i].cursor);\r
return currentIndex = i;\r
}\r
}\r
- for( var i=0; i<4; i++){\r
+ for( i=0; i<4; i++){\r
p = POSITION_ARRAY[ i];\r
if( p.x <= _mouseX && p.y <= _mouseY && p.x + p.w >= _mouseX && p.y +p.h >= _mouseY){\r
MOUSE_CURSOR( CURSOR_AND_FLIP[ i].cursor);\r
}\r
},\r
createTextElement: function( data ){\r
+ var _comicElement;\r
if( Type.isObject( data ) === false ){\r
data = {\r
balloon_template_id:1,\r
}\r
}\r
}\r
- var _comicElement = new TextElementClass( data );\r
+ _comicElement = new TextElementClass( data );\r
_comicElement.init();\r
pettanr.textEditor.bootInOverlay( PANEL_CONTROL.x(), PANEL_CONTROL.y(), _comicElement, onTextInput );\r
} else {\r
- var _comicElement = new TextElementClass( data );\r
+ _comicElement = new TextElementClass( data );\r
_comicElement.init();\r
onTextInput( _comicElement );\r
}\r
});\r
\r
\r
-pettanr.comicConsole =pettanr.view.registerApplication( function(){\r
+pettanr.comicConsole = pettanr.view.registerApplication( function(){\r
var jqWrap,\r
ID = 'comicConsole',\r
elmWrap = document.getElementById( 'comic-console-wrapper' ),\r
elmProgress = document.getElementById( 'comic-console-progress' ),\r
inputTitle, inputW, inputH, inputVisible, inputEditable,\r
elmUploader = null,\r
- elmScript = null\r
+ elmScript = null,\r
elmIframe = null,\r
elmForm = null,\r
timer = null,\r
}\r
}\r
var _selectList = elmForm.getElementsByTagName( 'select' ),\r
- _select, _name, _optionList;\r
+ _select, _optionList;\r
for( i=0, l= _selectList.length; i<l; ++i){\r
_select = _selectList[ i ];\r
_name = _select.name;\r
}\r
\r
/* grobal method */\r
- // this.rootElement = elmWrap;\r
+ this.rootElement = document.getElementById( 'comic-console-wrapper' );\r
this.displayName = ID;\r
this.ID = ID;\r
this.MIN_WIDTH = 320;\r
this.MIN_HEIGHT = 320;\r
this.init = function(){\r
- this.jqWrap = jqWrap = $( '#comic-console-wrapper').hide();\r
+ instance.jqWrap = jqWrap = $( '#comic-console-wrapper').hide();\r
$( '#comic-console-post-button').click( clickOK );\r
$( '#comic-console-cancel-button').click( clickCancel );\r
\r
\r
inputTitle.start();\r
\r
- elmUploader = document.createElement( 'div');\r
- elmUploader.id = "newcomic";\r
+ elmUploader = document.createElement( 'div' );\r
+ elmUploader.id = 'newcomic';\r
elmUploader.style.cssText = 'height:1px;line-height:1px;visibility:hidden;overflow:hidden;';\r
elmWrap.appendChild( elmUploader);\r
\r
}\r
\r
/* grobal method */\r
- // this.rootElement = elmWrap;\r
+ this.rootElement = document.getElementById( 'upload-console-wrapper' );\r
this.displayName = ID;\r
this.ID = ID;\r
this.MIN_WIDTH = 320;\r
this.MIN_HEIGHT = 320;\r
this.init = function(){\r
- this.jqWrap = jqWrap = $( '#upload-console-wrapper').hide();\r
+ instance.jqWrap = jqWrap = $( '#upload-console-wrapper').hide();\r
$( '#upload-console-post-button').click( clickOK );\r
$( '#upload-console-cancel-button').click( clickCancel );\r
\r
}\r
\r
/* grobal method */\r
- // this.rootElement = elmWrap;\r
+ this.rootElement = document.getElementById( 'panel-console-wrapper' );\r
this.displayName = ID;\r
this.ID = ID;\r
this.MIN_WIDTH = 320;\r
}\r
\r
/* grobal method */\r
- // this.rootElement = elmWrap;\r
+ this.rootElement = document.getElementById( 'artist-console-wrapper' );\r
this.displayName = ID;\r
this.ID = ID;\r
this.MIN_WIDTH = 320;\r
this.MIN_HEIGHT = 320;\r
this.init = function(){\r
- this.jqWrap = jqWrap = $( '#artist-console-wrapper').hide();\r
+ instance.jqWrap = jqWrap = $( '#artist-console-wrapper').hide();\r
$( '#artist-console-post-button').click( clickOK );\r
$( '#artist-console-cancel-button').click( clickCancel );\r
\r
\r
function clickOK(){\r
pettanr.overlay.hide();\r
- instance.onClose();\r
+ pettanr.outputConsole.shutdown();\r
}\r
\r
/* grobal method */\r
- // this.rootElement = elmWrap;\r
+ this.rootElement = document.getElementById( 'output-console-wrapper' );\r
this.displayName = ID;\r
this.ID = ID;\r
+ \r
this.MIN_WIDTH = 320;\r
this.MIN_HEIGHT = 320;\r
this.init = function(){\r
- this.jqWrap = jqWrap = $( '#output-console-wrapper').hide();\r
+ instance.jqWrap = jqWrap = $( '#output-console-wrapper').hide();\r
jqOutputArea = $( '#output-area');\r
delete instance.init;\r
}\r