/*
* pettanR peta.apps.js
- * version 0.5.14
+ * version 0.5.15
*
* author:
* itozyun
};
}, false, true, 'Panel Editor', 'paneleditor', null, '#2D89F0' );
-var ConsoleApplicationBase = function( app ){
+var FormApplicationHelper = function( app ){
app.isUploading = false;
app.elmProgress = null;
app.elmUploader = null;
app.fetchScript = function(){
app.elmProgress = document.getElementById( app.elmProgressID );
- app.elmUploader = document.createElement( 'div' );
- app.rootElement.appendChild( app.elmUploader );
- app.elmUploader.id = app.elmUploaderID;
- app.elmUploader.style.cssText = 'height:1px;line-height:1px;visibility:hidden;overflow:hidden;';
+ if( !( app.elmUploader = document.getElementById( app.elmUploaderID ) ) ){
+ app.elmUploader = document.createElement( 'div' );
+ app.rootElement.appendChild( app.elmUploader );
+ app.elmUploader.id = app.elmUploaderID;
+ if( app.hideUploader === true ){
+ app.elmUploader.style.cssText = 'height:1px;line-height:1px;visibility:hidden;overflow:hidden;';
+ };
+ };
app.elmScript = document.createElement( 'script' );
document.body.appendChild( app.elmScript );
app.elmProgress.innerHTML = 'loading form.';
app.addTimer( app.detectForm, 250 );
+
+ delete app.fetchScript;
};
app.detectForm = function(){
app.elmForm = app.elmUploader.getElementsByTagName( 'form' )[ 0 ];
- if( app.elmForm ){
- app.removeTimer( app.detectForm );
-
- Util.createIframe( 'targetFrame', app.onCreateIframe );
- app.elmProgress.innerHTML = 'create iframe';
- };
+ if( !app.elmForm ) return;
+
+ app.removeTimer( app.detectForm );
+ Util.createIframe( 'targetFrame', app.onCreateIframe );
+ app.elmProgress.innerHTML = 'create iframe';
+
+ delete app.detectForm;
};
app.onCreateIframe = function( _iframe ){
app.elmUploader.appendChild( _iframe );
app.elmForm.target = _iframe.name;
app.elmProgress.innerHTML = '';
app.onFormReady && app.onFormReady();
+
+ delete app.onCreateIframe;
};
app.submit = function(){
app.elmProgress.innerHTML = 'submit!';
app.submitError && app.submitError();
return;
};
- if( UA.isIE ){
+ if( app.detectIframe ){
app.elmIframe.onreadystatechange = app.detectIframe;
} else {
app.elmIframe.onload = app.onIframeUpdate;
};
app.elmProgress.innerHTML = 'uploading..';
+
+ delete app.submit;
};
- app.detectIframe = function(){
- if ( this.readyState === 'complete' ){
- this.onreadystatechange = new Function();
- this.onreadystatechange = null;
- app.onIframeUpdate();
- };
+ if( UA.isIE ){
+ app.detectIframe = function(){
+ if ( this.readyState !== 'complete' ) return;
+ this.onreadystatechange = new Function();
+ this.onreadystatechange = null;
+ app.onIframeUpdate();
+ delete app.detectIframe;
+ };
};
app.onIframeUpdate = function(){
app.elmIframe.onload = null;
app.elmProgress.innerHTML = 'success!';
app.isUploading = false;
app.submitSuccess && app.submitSuccess();
+ delete app.onIframeUpdate;
+ };
+ app.destroyHelper = function(){
+ app = null;
};
};
var ComicConsole = gOS.registerApplication( function(){
var elmHeader, elmProgress,
- winW, winH,
+ windowW, windowH,
inputTitle, inputW, inputH,
comboboxVisible, // comboboxEditable,
buttonSubmit, buttonCancel,
- isUploading = false,
- instance = this;
- //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK);
-
+ app = this;
+
function clickOK(){
- if( !instance.elmForm || !instance.elmIframe || instance.isUploading === true ) return false;
+ if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
// validate
- var _inputList = instance.elmForm.getElementsByTagName( 'input' ),
+ var _inputList = app.elmForm.getElementsByTagName( 'input' ),
_input, _name;
for( var i = _inputList.length; i; ){
_input = _inputList[ --i ];
_input.value = inputH.value();
};
};
- var _selectList = instance.elmForm.getElementsByTagName( 'select' ),
+ var _selectList = app.elmForm.getElementsByTagName( 'select' ),
_select, _optionList;
for( i = _selectList.length; i; ){
_select = _selectList[ --i ];
// _select.selectedIndex = comboboxEditable.selectIndex();
};
};
- instance.submit();
+ app.submit();
};
function clickCancel(){
- if( instance.isUploading === true ) return false;
+ if( app.isUploading === true ) return false;
ComicConsole.shutdown();
};
this.MIN_WIDTH = 320;
this.MIN_HEIGHT = 320;
this.onInit = function(){
- instance.rootElement.id = 'comic-console-wrapper';
- instance.rootElement.className = 'console-wrapper';
- instance.rootElement.innerHTML = [
+ app.rootElement.id = 'comic-console-wrapper';
+ app.rootElement.className = 'console-wrapper';
+ app.rootElement.innerHTML = [
'<div id="comic-console-header" class="console-header">Create New Comic</div>',
'<div id="comic-console" class="console-inner">',
'<div id="comic-console-title" class="field">',
'</div>'
].join( '' );
- instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
+ app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
- delete instance.onInit;
+ delete app.onInit;
};
this.elmProgressID = 'comic-console-progress';
this.elmUploaderID = 'newcomic';
this.elmIframeName = 'targetFrameCreateComic'
this.scriptSrc = pettanr.CONST.CREATE_COMIC_JS;
- ConsoleApplicationBase( this );
+ this.hideUploader = true;
+ FormApplicationHelper( this );
this.onFormReady = function(){
- instance.onPaneResize( winW, winH );
+ app.onPaneResize( windowW, windowH );
- var selectList = instance.elmForm.getElementsByTagName( 'select' ),
+ var selectList = app.elmForm.getElementsByTagName( 'select' ),
select,
j, m,
optionList, option;
};
inputTitle.focus();
- delete instance.onFoemReady;
+ delete app.onFoemReady;
};
this.submitError = function(){
- instance.addTimer( clickCancel , 5000, true );
+ app.addTimer( clickCancel , 5000, true );
};
this.submitSuccess = function(){
- instance.addTimer( clickCancel , 5000, true );
+ app.addTimer( clickCancel , 5000, true );
};
this.onOpen = function( w, h ){
- var ui = instance.createUIGroup();
+ var ui = app.createUIGroup();
inputTitle = ui.createInputText( document.getElementById( 'comic-console-title') );
inputW = ui.createInputText( document.getElementById( 'comic-console-width') );
buttonSubmit = ui.createButton( document.getElementById( 'comic-console-post-button'), clickOK );
buttonCancel = ui.createButton( document.getElementById( 'comic-console-cancel-button'), clickCancel );
- instance.fetchScript();
- instance.onPaneResize( w, h );
- delete instance.onOpen;
+ app.onPaneResize( w, h );
+ app.fetchScript();
+ delete app.onOpen;
};
this.onPaneResize = function( _w, _h ){
- winW = _w;
- winH = _h;
- instance.rootElement.style.cssText = [
- 'left:', Math.floor( ( _w - instance.rootElement.offsetWidth ) /2 ), 'px;',
- 'top:', Math.floor( ( _h- instance.rootElement.offsetHeight ) /2 ), 'px;'
+ windowW = _w;
+ windowH = _h;
+ app.rootElement.style.cssText = [
+ 'left:', Math.floor( ( _w - app.rootElement.offsetWidth ) /2 ), 'px;',
+ 'top:', Math.floor( ( _h- app.rootElement.offsetHeight ) /2 ), 'px;'
].join( '' );
};
this.onClose = function(){
- instance = null;
- isUploading = false;
+ app.destroyHelper();
+ app = inputTitle = inputW = inputH = comboboxVisible = buttonSubmit = buttonCancel = null;
};
}, true, true, 'Comic Console', 'comicConsole', null, '#D44A26' );
var UploadConsole = gOS.registerApplication( function(){
var windowW, windowH,
- TARGET_FRAME_NAME = 'targetFrame',
- elmContainer,
- elmProgress,
- elmScript = null,
- elmForm = null,
- elmFile = null,
- elmIframe = null,
- isUploading = false,
- instance = this;
- /*
- * upload ボタンが押されたらまず iframe をつくる.
- */
+ buttonSubmit, buttonCancel,
+ elmFile,
+ app = this;
+
function clickOK(){
- if( !elmForm || !elmIframe || isUploading === true ) return false;
+ if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
if( elmFile.value.length === 0 ) return false;
- elmProgress.innerHTML = 'uploading.';
- isUploading = true;
- submit();
+ app.submit();
return false;
};
- /*
- * form の target に iframe を指定したのち submit();
- */
- function submit(){
- try {
- elmForm.submit();
- } catch( e){
- elmProgress.innerHTML = 'submit() err..';
- isUploading = false;
- instance.addTimer( clickCancel , 3000, true );
- return;
- };
-
- if( UA.isIE){
- elmIframe.onreadystatechange = detectIframe;
- } else {
- elmIframe.onload = onLoad;
- };
- elmProgress.innerHTML = 'uploading..';
- };
- /*
- * ie の 場合、readyState をチェック.
- */
- function detectIframe(){
- if ( elmIframe.readyState === 'complete') {
- elmIframe.onreadystatechange = new Function();
- elmIframe.onreadystatechange = null;
- onLoad();
- };
- };
- function onLoad(){
- elmIframe.onload = null;
- ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();
- elmProgress.innerHTML = 'success!';
- instance.addTimer( clickCancel , 1000 );
- isUploading = false;
- };
-
- function detectForm(){
- elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];
- if( elmForm ){
- var _inputList = elmForm.getElementsByTagName( 'input' ),
- _input;
- for( var i = _inputList.length; i; ){
- _input = _inputList[ --i ];
- if( _input.type === 'file' ){
- elmFile = _input;
- };
- if( _input.type === 'submit' ){
- _input.style.display = 'none';
- };
- };
- instance.removeTimer( detectForm );
- Util.createIframe( TARGET_FRAME_NAME, onCreateIframe );
- elmProgress.innerHTML = 'create iframe';
- };
- };
- function onCreateIframe( _iframe ){
- elmContainer.appendChild( _iframe );
- elmIframe = _iframe;
- elmForm.target = _iframe.name;
- elmProgress.innerHTML = '';
- instance.onPaneResize( windowW, windowH );
- };
function clickCancel(){
- if( isUploading === true ) return false;
+ if( app.isUploading === true ) return false;
UploadConsole.shutdown();
return false;
};
this.MIN_WIDTH = 320;
this.MIN_HEIGHT = 320;
this.onInit = function(){
- instance.rootElement.id = 'upload-console-wrapper';
- instance.rootElement.className = 'console-wrapper';
- instance.rootElement.innerHTML = [
+ app.rootElement.id = 'upload-console-wrapper';
+ app.rootElement.className = 'console-wrapper';
+ app.rootElement.innerHTML = [
'<div id="upload-console-header" class="console-header">Upload Picture</div>',
'<div id="upload-console" class="console-inner">',
'<div id="uploader"></div>',
'</div>'
].join( '' );
- instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
+ app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
- delete instance.onInit;
- }
+ delete app.onInit;
+ };
+ this.elmProgressID = 'upload-console-progress';
+ this.elmUploaderID = 'uploader';
+ this.elmIframeName = 'targetFrameUpload'
+ this.scriptSrc = pettanr.CONST.UPLOAD_PICTURE_JS;
+ this.hideUploader = false;
+ FormApplicationHelper( this );
+ this.onFormReady = function(){
+ app.onPaneResize( windowW, windowH );
+
+ var _inputList = app.elmForm.getElementsByTagName( 'input' ),
+ _input;
+ for( var i = _inputList.length; i; ){
+ _input = _inputList[ --i ];
+ if( _input.type === 'file' ){
+ elmFile = _input;
+ } else
+ if( _input.type === 'submit' ){
+ _input.style.display = 'none';
+ };
+ };
+ delete app.onFoemReady;
+ };
+ this.submitError = function(){
+ app.addTimer( clickCancel , 5000, true );
+ };
+ this.submitSuccess = function(){
+ app.addTimer( clickCancel , 5000, true );
+ };
this.onOpen = function( w, h ){
- elmContainer = document.getElementById( 'uploader' );
- elmProgress = document.getElementById( 'upload-console-progress' );
-
- instance.addMouseEventListener( document.getElementById( 'upload-console-post-button' ), 'click', clickOK );
- instance.addMouseEventListener( document.getElementById( 'upload-console-cancel-button' ), 'click', clickCancel );
- /*
- * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.
- */
- elmScript = document.createElement( 'script' );
- document.body.appendChild( elmScript );
- elmScript.type = 'text\/javascript';
- elmScript.src = pettanr.CONST.UPLOAD_PICTURE_JS;
+ var ui = app.createUIGroup();
+ buttonSubmit = ui.createButton( document.getElementById( 'upload-console-post-button'), clickOK );
+ buttonCancel = ui.createButton( document.getElementById( 'upload-console-cancel-button'), clickCancel );
- instance.addTimer( detectForm, 250 );
- instance.onPaneResize( w, h );
-
- elmProgress.innerHTML = 'loading form.';
+ app.onPaneResize( w, h );
+ app.fetchScript();
};
this.onPaneResize = function( _windowW, _windowH){
windowW = _windowW;
windowH = _windowH;
- instance.rootElement.style.cssText = [
- 'left:', Math.floor( ( _windowW - instance.rootElement.offsetWidth ) /2 ), 'px;',
- 'top:', Math.floor( ( _windowH - instance.rootElement.offsetHeight ) /2 ), 'px;'
+ app.rootElement.style.cssText = [
+ 'left:', Math.floor( ( _windowW - app.rootElement.offsetWidth ) /2 ), 'px;',
+ 'top:', Math.floor( ( _windowH - app.rootElement.offsetHeight ) /2 ), 'px;'
].join( '' );
- }
+ };
this.onClose = function(){
- elmHeader = elmProgress = elmForm = elmUploader = instance = null;
- isUploading = false;
- }
+ app.destroyHelper();
+ app = elmFile = buttonSubmit = buttonCancel = null;
+ };
}, true, true, 'Upload Console', 'uploadConsole', null, '#01A31C' );
var ArtistConsole = gOS.registerApplication( function(){
var windowW, windowH,
- TARGET_FRAME_NAME = 'targetFrameRegisterArtist',
- elmContainer, elmProgress,
- elmScript = null,
- elmForm = null,
- elmIframe = null,
- isUploading = false,
- instance = this;
- /*
- * upload ボタンが押されたらまず iframe をつくる.
- */
+ buttonSubmit, buttonCancel,
+ app = this;
+
function clickOK(){
- if( !elmForm || !elmIframe || isUploading === true ) return false;
- elmProgress.innerHTML = 'uploading.';
- isUploading = true;
- submit();
+ if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
+ app.submit();
return false;
- }
- /*
- * form の target に iframe を指定したのち submit();
- */
- function submit(){
- try {
- elmForm.submit();
- } catch( e){
- elmProgress.innerHTML = 'submit() err..';
- isUploading = false;
- instance.addTimer( clickCancel , 3000, true );
- return;
- }
-
- if( UA.isIE){
- elmIframe.onreadystatechange = detectIframe;
- } else {
- elmIframe.onload = onLoad;
- }
- elmProgress.innerHTML = 'uploading..';
- }
- /*
- * ie の 場合、readyState をチェック.
- */
- function detectIframe(){
- if ( elmIframe.readyState === 'complete' ){
- elmIframe.onreadystatechange = new Function();
- elmIframe.onreadystatechange = null;
- onLoad();
- }
- }
- function onLoad(){
- elmIframe.onload = null;
- ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();
- elmProgress.innerHTML = 'success!';
- instance.addTimer( clickCancel , 1000, true );
- isUploading = false;
- }
-
- function detectForm(){
- elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];
- if( elmForm){
- var _inputList = elmForm.getElementsByTagName( 'input' ),
- _input;
- for( var i = _inputList.length; i; ){
- _input = _inputList[ --i ];
- if( _input.type === 'submit' ){
- _input.style.display = 'none';
- }
- }
- instance.removeTimer( detectForm );
- Util.createIframe( TARGET_FRAME_NAME, onCreateIframe);
- elmProgress.innerHTML = 'create iframe';
- }
- }
- function onCreateIframe( _iframe ){
- elmContainer.appendChild( _iframe );
- elmIframe = _iframe;
- elmForm.target = _iframe.name;
- elmProgress.innerHTML = '';
- instance.onPaneResize( windowW, windowH );
- }
+ };
function clickCancel(){
- if( isUploading === true) return false;
+ if( app.isUploading === true) return false;
ArtistConsole.shutdown();
return false;
- }
+ };
/* grobal method */
this.MIN_WIDTH = 320;
this.MIN_HEIGHT = 320;
this.onInit = function(){
- instance.rootElement.id = 'artist-console-wrapper';
- instance.rootElement.className = 'console-wrapper';
- instance.rootElement.innerHTML = [
+ app.rootElement.id = 'artist-console-wrapper';
+ app.rootElement.className = 'console-wrapper';
+ app.rootElement.innerHTML = [
'<div id="artist-console-header" class="console-header">Register Artist</div>',
'<div id="artist-console" class="console-inner">',
'<div id="register"></div>',
'</div>'
].join( '' );
- instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
+ app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
- delete instance.onInit;
+ delete app.onInit;
+ };
+ this.elmProgressID = 'artist-console-progress';
+ this.elmUploaderID = 'register';
+ this.elmIframeName = 'targetFrameArtistRegister'
+ this.scriptSrc = pettanr.CONST.REGISTER_ARTIST_JS;
+ this.hideUploader = false;
+ FormApplicationHelper( this );
+ this.onFormReady = function(){
+ app.onPaneResize( windowW, windowH );
+
+ var _inputList = app.elmForm.getElementsByTagName( 'input' ),
+ _input;
+ for( var i = _inputList.length; i; ){
+ _input = _inputList[ --i ];
+ if( _input.type === 'submit' ){
+ _input.style.display = 'none';
+ };
+ };
+ delete app.onFoemReady;
+ };
+ this.submitError = function(){
+ app.addTimer( clickCancel , 5000, true );
+ };
+ this.submitSuccess = function(){
+ app.addTimer( clickCancel , 5000, true );
};
this.onOpen = function( w, h ){
- elmContainer = document.getElementById( 'register');
- elmProgress = document.getElementById( 'artist-console-progress');
-
- instance.addMouseEventListener( document.getElementById( 'artist-console-post-button' ), 'click', clickOK );
- instance.addMouseEventListener( document.getElementById( 'artist-console-cancel-button' ), 'click', clickCancel );
- /*
- * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.
- */
- elmScript = document.createElement( 'script' );
- document.body.appendChild( elmScript );
- elmScript.type = 'text\/javascript';
- elmScript.src = pettanr.CONST.REGISTER_ARTIST_JS;
+ var ui = app.createUIGroup();
+ buttonSubmit = ui.createButton( document.getElementById( 'artist-console-post-button'), clickOK );
+ buttonCancel = ui.createButton( document.getElementById( 'artist-console-cancel-button'), clickCancel );
- instance.addTimer( detectForm, 250 );
- instance.onPaneResize( w, h );
-
- elmProgress.innerHTML = 'loading form.';
+ app.onPaneResize( w, h );
+ app.fetchScript();
};
this.onPaneResize = function( _windowW, _windowH ){
windowW = _windowW;
windowH = _windowH;
- instance.rootElement.style.cssText = [
- 'left:', Math.floor( ( _windowW - instance.rootElement.offsetWidth ) /2 ), 'px;',
- 'top:', Math.floor( ( _windowH - instance.rootElement.offsetHeight ) /2 ), 'px;'
+ app.rootElement.style.cssText = [
+ 'left:', Math.floor( ( _windowW - app.rootElement.offsetWidth ) /2 ), 'px;',
+ 'top:', Math.floor( ( _windowH - app.rootElement.offsetHeight ) /2 ), 'px;'
].join( '' );
};
this.onClose = function(){
- elmHeader = elmProgress = elmForm = elmUploader = instance = null;
- isUploading = false;
+ app.destroyHelper();
+ app = buttonSubmit = buttonCancel = null;
};
}, true, true, 'Artist Console', 'artistConsole', null, '#FFC40D' );
windowW, windowH,
timing = 0,
comicID, panelID, panelTimming, panelW, panelH, borderSize, panelElementArray,
- instance = this,
+ app = this,
model = null;
function clickOK(){
this.MIN_WIDTH = 320;
this.MIN_HEIGHT = 320;
this.onInit = function(){
- instance.rootElement.id = 'output-console-wrapper';
- instance.rootElement.className = 'console-wrapper';
- instance.rootElement.innerHTML = [
+ app.rootElement.id = 'output-console-wrapper';
+ app.rootElement.className = 'console-wrapper';
+ app.rootElement.innerHTML = [
'<div id="output-console-header" class="console-header">Output Console</div>',
'<div id="output-console" class="console-inner">',
'<div id="output-console-format" class="field">',
'</div>'
].join( '' );
- instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
+ app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
- delete instance.onInit;
+ delete app.onInit;
};
this.onOpen = function( _w, _h, _comicID, _panelID, _panelTimming, _panelW, _panelH, _borderSize, _panelElementArray ){
elmOutputArea = document.getElementById( 'output-area' );
- var ui = instance.createUIGroup();
+ var ui = app.createUIGroup();
comboboxFormat = ui.createCombobox( document.getElementById( 'output-console-format' ), formatUpdate );
for( var i=0; FORMAT_LIST[ 0 ]; ++i ){
inputOption = ui.createInputText( document.getElementById( 'output-console-option' ), null );
// buttonPost = ui.createButton( document.getElementById( 'output-console-post-button' ), clickPost );
buttonClose = ui.createButton( document.getElementById( 'output-console-close-button' ), clickClose );
- instance.onPaneResize( _w, _h );
+
+ app.onPaneResize( _w, _h );
+
+ comboboxFormat.focus( true );
model = Model.createPanel( {
comicID : _comicID,
this.onPaneResize = function( _windowW, _windowH ){
windowW = _windowW;
windowH = _windowH;
- instance.rootElement.style.cssText = [
- 'left:', Math.floor( ( _windowW - instance.rootElement.offsetWidth ) /2 ), 'px;',
- 'top:', Math.floor( ( _windowH - instance.rootElement.offsetHeight ) /2 ), 'px;'
+ app.rootElement.style.cssText = [
+ 'left:', Math.floor( ( _windowW - app.rootElement.offsetWidth ) /2 ), 'px;',
+ 'top:', Math.floor( ( _windowH - app.rootElement.offsetHeight ) /2 ), 'px;'
].join( '' );
};
this.onClose = function(){
var PanelConsole = gOS.registerApplication( function(){
var windowW, windowH,
- TARGET_FRAME_NAME = 'targetFrameCreateNewPanel',
comboboxPublish, buttonPost, buttonClose,
- elmContainer, elmProgress, elmInput,
- elmScript = null,
- elmForm = null,
- elmIframe = null,
- isUploading = false,
- instance = this,
+ elmInput,
+ app = this,
model = null;
/*
* upload ボタンが押されたらまず iframe をつくる.
*/
function clickOK(){
- if( !elmForm || !elmIframe || isUploading === true ) return false;
- elmProgress.innerHTML = 'uploading.';
- isUploading = true;
- submit();
+ if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
+ app.submit();
return false;
}
- /*
- * form の target に iframe を指定したのち submit();
- */
- function submit(){
- try {
- elmForm.submit();
- } catch( e ){
- elmProgress.innerHTML = 'submit() err..';
- isUploading = false;
- instance.addTimer( clickCancel , 3000, true );
- return;
- }
-
- if( UA.isIE ){
- elmIframe.onreadystatechange = detectIframe;
- } else {
- elmIframe.onload = onLoad;
- }
- elmProgress.innerHTML = 'uploading..';
- }
- /*
- * ie の 場合、readyState をチェック.
- */
- function detectIframe(){
- if ( elmIframe.readyState === 'complete' ){
- elmIframe.onreadystatechange = new Function();
- elmIframe.onreadystatechange = null;
- onLoad();
- };
- };
- function onLoad(){
- try {
- console.log( ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).document.body.innerHTML );
- } catch(e){
-
- }
- elmIframe.onload = null;
- ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();
- elmProgress.innerHTML = 'success!';
- instance.addTimer( clickCancel , 1000, true );
- isUploading = false;
- };
-
- function detectForm(){
- elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];
- if( elmForm){
- var _inputList = elmForm.getElementsByTagName( 'input' ),
- _input;
- for( var i = _inputList.length; i; ){
- _input = _inputList[ --i ];
- if( _input.type === 'submit' ){
- _input.style.display = 'none';
- };
- if( _input.name === 'json' ){
- elmInput = _input;
- publishUpdate();
- };
- };
- instance.removeTimer( detectForm );
- Util.createIframe( TARGET_FRAME_NAME, onCreateIframe );
- elmProgress.innerHTML = 'create iframe';
- };
- };
- function onCreateIframe( _iframe ){
- elmContainer.appendChild( _iframe );
- elmIframe = _iframe;
- elmForm.target = _iframe.name;
- elmProgress.innerHTML = '';
- instance.onPaneResize( windowW, windowH );
- };
+
function clickCancel(){
- if( isUploading === true ) return false;
+ if( app.isUploading === true ) return false;
PanelConsole.shutdown();
return false;
};
this.MIN_WIDTH = 320;
this.MIN_HEIGHT = 320;
this.onInit = function(){
- instance.rootElement.id = 'panel-console-wrapper';
- instance.rootElement.className = 'console-wrapper';
- instance.rootElement.innerHTML = [
+ app.rootElement.id = 'panel-console-wrapper';
+ app.rootElement.className = 'console-wrapper';
+ app.rootElement.innerHTML = [
'<div id="panel-console-header" class="console-header">Create New Panel (dev)</div>',
'<div id="panel-console" class="console-inner">',
'<div id="newpanel"></div>',
'</div>'
].join( '' );
- instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
+ app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
- delete instance.onInit;
- }
- this.onOpen = function( w, h, _model ){
- var ui = instance.createUIGroup();
- // inputTitle = ui.createInputText( document.getElementById( 'comic-console-title') );
+ delete app.onInit;
+ };
+ this.elmProgressID = 'panel-console-progress';
+ this.elmUploaderID = 'newpanel';
+ this.elmIframeName = 'targetFrameNewPanel'
+ this.scriptSrc = pettanr.CONST.CREATE_PANEL_JS;
+ this.hideUploader = false;
+ FormApplicationHelper( this );
+ this.onFormReady = function(){
+ app.onPaneResize( windowW, windowH );
+
+ var _inputList = app.elmForm.getElementsByTagName( 'input' ),
+ _input;
+ for( var i = _inputList.length; i; ){
+ _input = _inputList[ --i ];
+ if( _input.type === 'submit' ){
+ _input.style.display = 'none';
+ };
+ if( _input.name === 'json' ){
+ elmInput = _input;
+ publishUpdate();
+ };
+ };
+ delete app.onFoemReady;
+ };
+ this.submitError = function(){
+ app.addTimer( clickCancel , 5000, true );
+ };
+ this.submitSuccess = function(){
+ app.addTimer( clickCancel , 5000, true );
+ };
+ this.onOpen = function( w, h, _model ){
+ var ui = app.createUIGroup(),
+ elm = document.getElementById( 'panel-console-publish' );
if( _model ){
- comboboxPublish = ui.createCombobox( document.getElementById( 'panel-console-publish'), publishUpdate );
+ comboboxPublish = ui.createCombobox( elm, publishUpdate );
comboboxPublish.createOption( 'only me', '0', _model.publish() === false );
comboboxPublish.createOption( 'publish', '1', _model.publish() === true );
model = _model;
} else {
- var elm = document.getElementById( 'panel-console-publish');
elm.parentNode.removeChild( elm );
};
buttonPost = ui.createButton( document.getElementById( 'panel-console-post-button' ), clickOK );
buttonClose = ui.createButton( document.getElementById( 'panel-console-cancel-button' ), clickCancel );
- elmContainer = document.getElementById( 'newpanel' );
- elmProgress = document.getElementById( 'panel-console-progress' );
-
- /*
- * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.
- */
- elmScript = document.createElement( 'script' );
- document.body.appendChild( elmScript );
- elmScript.type = 'text\/javascript';
- elmScript.src = pettanr.CONST.CREATE_PANEL_JS;
-
- instance.addTimer( detectForm, 250 );
- instance.onPaneResize( w, h );
-
- elmProgress.innerHTML = 'loading form.';
+ app.onPaneResize( w, h );
+ app.fetchScript();
};
this.onPaneResize = function( _windowW, _windowH ){
windowW = _windowW;
windowH = _windowH;
- instance.rootElement.style.cssText = [
- 'left:', Math.floor( ( _windowW - instance.rootElement.offsetWidth ) /2 ), 'px;',
- 'top:', Math.floor( ( _windowH - instance.rootElement.offsetHeight ) /2 ), 'px;'
+ app.rootElement.style.cssText = [
+ 'left:', Math.floor( ( _windowW - app.rootElement.offsetWidth ) /2 ), 'px;',
+ 'top:', Math.floor( ( _windowH - app.rootElement.offsetHeight ) /2 ), 'px;'
].join( '' );
};
this.onClose = function(){
+ app.destroyHelper();
model && model.destroy();
- elmHeader = elmProgress = elmForm = elmUploader = instance = model = null;
- comboboxPublish = buttonPost = buttonClose = null;
- isUploading = false;
+ app = model = comboboxPublish = buttonPost = buttonClose = elmInput = null;
};
}, true, true, 'Panel Console', 'panelConsole', null, '#603CBA' );