/*
* pettanR peta.apps.js
- * version 0.5.5
+ * version 0.5.6
*
* author:
* itozyun
if( _elm.resource_picture ){
_elm.resource_picture = buildFileData( _elm.resource_picture, FILE_DATA_PICTURE_ROOT ); // 上記参照切れに備えてここで上書き
} else {
- _elm.resource_picture = getResource( RESOURCE_PICTURE_ARRAY, _elm.resource_picture_id );
+ _elm.resource_picture = getResource( RESOURCE_PICTURE_ARRAY, _elm.picture_id );
};
};
};
'<div id="cabinet-container" class="finder-container"></div>'
].join( '' );
- self.fetchCSS( '/assets/peta.apps.css' );
+ self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
tree = FileAPI.createTree( FILE_DATA_SERVICE_ROOT );
'<div id="gallery-container" class="finder-container"></div>'
].join( '' );
- self.fetchCSS( '/assets/peta.apps.css' );
+ self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
tree = FileAPI.createTree( FILE_DATA_PICTURE_ROOT );
var _root = tree.getRootFile(),
'<div id="image-group-button" class="button">close</div>'
].join( '' );
- self.fetchCSS( '/assets/peta.apps.css' );
+ self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
tree = FileAPI.createTree( FILE_DATA_ARTIST_ROOT );
rootFile = tree.getRootFile();
'</div>'
].join( '' );
- self.fetchCSS( '/assets/peta.apps.css' );
+ self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
};
this.onOpen = function( _w, _h, _file ){
function quit(){
Editor.shutdown();
- }
+ };
+ function onSave(){
+ var model = Model.createPanel( {
+ comicID : comicID,
+ panelID : panelID,
+ panelTimming : panelTimming,
+ panelW : PANEL_CONTROL.w,
+ panelH : PANEL_CONTROL.h,
+ borderSize : 2,
+ panelElementArray : PANEL_ELEMENT_ARRAY
+ } );
+ PanelConsole.boot( model.getJsonPostString().replace( /\n/g, '' ) );
+ model.destroy();
+ };
+ function onSaveQuit(){
+ // Editor.shutdown();
+ onSave();
+ };
function onExport(){
OutputConsole.boot(
comicID, panelID, panelTimming,
2, // border, BackgroundImage
PANEL_ELEMENT_ARRAY
);
- }
+ };
return {
init: function(){
delete SAVE_CONTROL.init;
},
open: function(){
- save = MENU_BAR_CONTROL.QUIT.createOption( 'save', 'ctrl + S', quit, false );
- saveQuit = MENU_BAR_CONTROL.QUIT.createOption( 'save & quit', null, quit, false, false, true );
+ save = MENU_BAR_CONTROL.QUIT.createOption( 'save', 'ctrl + S', onSave, false );
+ saveQuit = MENU_BAR_CONTROL.QUIT.createOption( 'save & quit', null, onSaveQuit, false, false, true );
eXport = MENU_BAR_CONTROL.QUIT.createOption( 'export', null, onExport, true, false, true );
quit = MENU_BAR_CONTROL.QUIT.createOption( 'quit', null, quit, true, true );
'</div>'
].join( '' );
- app.fetchCSS( '/assets/peta.apps.css' );
+ app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
delete app.onInit;
};
'</div>'
].join( '' );
- instance.fetchCSS( '/assets/peta.apps.css' );
+ instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
delete instance.onInit;
};
'</div>'
].join( '' );
- instance.fetchCSS( '/assets/peta.apps.css' );
+ instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
delete instance.onInit;
}
}
}, true, true, 'Upload Console', 'uploadConsole', null, '#01A31C' );
-var PanelConsole = gOS.registerApplication( function(){
- var windowW, windowH,
- TARGET_FRAME_NAME = 'targetFrameCreateNewPanel',
- elmContainer, elmProgress,
- elmScript = null,
- elmForm = null,
- elmIframe = null,
- isUploading = false,
- instance = this;
- /*
- * upload ボタンが押されたらまず iframe をつくる.
- */
- function clickOK(){
- if( !elmForm || !elmIframe || isUploading === true ) return false;
- elmProgress.innerHTML = 'uploading.';
- isUploading = true;
- 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';
- };
- };
- 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;
- PanelConsole.shutdown();
- return false;
- };
-
- /* grobal method */
- 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 = [
- '<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 class="console-button-container">',
- '<div id="panel-console-post-button" class="button console-submit-button">post</div>',
- '<div id="panel-console-cancel-button" class="button console-cancel-button">cancel</div>',
- '</div>',
- '<div id="panel-console-progress" class="console-progress"> </div>',
- '</div>'
- ].join( '' );
-
- instance.fetchCSS( '/assets/peta.apps.css' );
-
- delete instance.onInit;
- }
- this.onOpen = function( w, h ){
- elmContainer = document.getElementById( 'newpanel' );
- elmProgress = document.getElementById( 'panel-console-progress' );
-
- instance.addMouseEventListener( document.getElementById( 'panel-console-post-button' ), 'click', clickOK );
- instance.addMouseEventListener( document.getElementById( 'panel-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.CREATE_PANEL_JS;
-
- instance.addTimer( detectForm, 250 );
- instance.onPaneResize( w, h );
-
- elmProgress.innerHTML = 'loading form.';
- };
- 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;'
- ].join( '' );
- };
- this.onClose = function(){
- elmHeader = elmProgress = elmForm = elmUploader = instance = null;
- isUploading = false;
- };
-}, true, true, 'Panel Console', 'panelConsole', null, '#603CBA' );
-
var ArtistConsole = gOS.registerApplication( function(){
var windowW, windowH,
TARGET_FRAME_NAME = 'targetFrameRegisterArtist',
'</div>'
].join( '' );
- instance.fetchCSS( '/assets/peta.apps.css' );
+ instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
delete instance.onInit;
};
};
}, true, true, 'Artist Console', 'artistConsole', null, '#FFC40D' );
-var OutputConsole = gOS.registerApplication( function(){
- var FORMAT_LIST = [ 'json[POST]', 'json[GET]', 'XML', 'HTML', 'XHTML', 'MT export', 'Blogger ATOM' ];
- var elmOutputArea,
- comboboxFormat, inputOption,
- buttonGenerate, buttonClose,
- windowW, windowH,
- timing = 0,
- comicID, panelID, panelTimming, panelW, panelH, borderSize, panelElementArray,
- instance = this;
- //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK);
-
- function clickOK(){
- OutputConsole.shutdown();
- };
-
- function getPanelElementByTiming(){
- var i, l = panelElementArray.length;
- while( timing < l * 2){
- for( i=0; i<l; ++i ){
- if( timing === panelElementArray[ i ].timing ){
- ++timing;
- return panelElementArray[ i ];
- }
- }
- ++timing;
- }
- return null;
- };
-
- function getAsHtmlString( isAbsoluteUrl, isXHTML ){
- timing = 0;
-
- var HTML_ARRAY = [],
- l = panelElementArray.length,
- _panelElement;
- while( HTML_ARRAY.length < l ){
- _panelElement = getPanelElementByTiming();
- if( _panelElement === null) break;
- HTML_ARRAY.push( panelElementToHtml( _panelElement, isAbsoluteUrl, isXHTML ));
+var Model = ( function(){
+
+ var PanelModelClass = function( panel ){
+ var comicID = panel.comicID,
+ panelID = panel.panelID,
+ panelTimming = panel.panelTimming,
+ panelW = panel.panelW,
+ panelH = panel.panelH,
+ borderSize = panel.borderSize,
+ panelElementArray = panel.panelElementArray,
+ timing = 0;
+
+ function getPanelElementByTiming(){
+ var i, l = panelElementArray.length;
+ while( timing < l * 2){
+ for( i=0; i<l; ++i ){
+ if( timing === panelElementArray[ i ].timing ){
+ ++timing;
+ return panelElementArray[ i ];
+ };
+ };
+ ++timing;
+ };
+ return null;
};
-
- HTML_ARRAY.unshift(
- [
- '<div class="panel" ',
- 'style="',
- 'height:', panelH, 'px;',
- 'background-color:', ';',
- '"',
- '>'
- ].join( '')
- );
- HTML_ARRAY.push( '</div>');
-
- return HTML_ARRAY.join( pettanr.LINE_FEED_CODE_TEXTAREA);
- };
-
function panelElementToHtml( _panelElement, isAbsoluteUrl, isXHTML ){
var url;
if( _panelElement.type === 0 ){
].join( '');
};
};
-
- function getJsonGetString(){
- timing = 0;
-
- var JSON_STRING_ARRAY = [],
- ELEMENT_ARRAY = [],
- l = panelElementArray.length,
- cr = pettanr.LINE_FEED_CODE_TEXTAREA,
- _panelElement;
-
- while( ELEMENT_ARRAY.length <= l){
- _panelElement = getPanelElementByTiming();
- if( _panelElement === null ) break;
-
- ELEMENT_ARRAY.push( _panelElement.type === 0 ? getImageJsonGET( _panelElement ) : balloonToJson( _panelElement ));
- };
- return [
- '{', cr,
- '"panel": {', cr,
- '"id": ', panelID, ',', cr,
- '"border": ', borderSize, ',', cr,
- '"comic_id": ', comicID, ',', cr,
- '"resource_picture_id": 1,', cr,
- '"x": ', 0, ',', cr,
- '"y": ', 0, ',', cr,
- '"z": ', 0, ',', cr,
- panelTimming !== -1 ? ( '"t": ' + panelTimming + ',' + cr ) : '',
- '"width": ', panelW, ',', cr,
- '"height": ', panelH, ',', cr,
- '"panel_elements": [', cr,
- ELEMENT_ARRAY.join( ',' + cr ), cr,
- ']', cr,
- '}', cr,
- '}'
- ].join( '' );
- };
function getImageJsonGET( _imageElement ){
var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
return [
'}'
].join( '');
};
-
- function getJsonPostString(){
- timing = 0;
-
- var JSON_STRING_ARRAY = [],
- IMAGE_ARRAY = [],
- BALLOON_ARRAY = [],
- l = panelElementArray.length,
- _panelElement,
- cr = pettanr.LINE_FEED_CODE_TEXTAREA;
-
- while( IMAGE_ARRAY.length + BALLOON_ARRAY.length <= l){
- _panelElement = getPanelElementByTiming();
- if( _panelElement === null) break;
- _panelElement.type === 0 ?
- IMAGE_ARRAY.push( [ '"new', timing, '": ', imageToJson( _panelElement ) ].join( '' )) :
- BALLOON_ARRAY.push( [ '"new', timing, '": ', balloonToJson( _panelElement ) ].join( '' ) );
- };
- return [
- '{', cr,
- '"panel": {', cr,
- '"id": ', panelID, ',', cr,
- '"border": ', borderSize, ',', cr,
- '"comic_id": ', comicID, ',', cr,
- '"resource_picture_id": 1,', cr,
- '"x": ', 0, ',', cr,
- '"y": ', 0, ',', cr,
- '"z": ', 0, ',', cr,
- '"t": ', panelTimming, ',', cr,
- '"width": ', panelW, ',', cr,
- '"height": ', panelH, ',', cr,
- '"panel_pictures_attributes": {', cr,
- IMAGE_ARRAY.join( ',' + cr ), cr,
- '},', cr,
- '"balloons_attributes": {', cr,
- BALLOON_ARRAY.join( ',' + cr ), cr,
- '}', cr,
- '}', cr,
- '}'
- ].join( '' );
- };
function imageToJson( _imageElement ){
var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
return [
'{', cr,
- '"resource_picture_id": ', _imageElement.resourcePicture().id, ',', cr,
- '"x": ', _imageElement.x, ',', cr,
- '"y": ', _imageElement.y, ',', cr,
- '"z": ', _imageElement.z, ',', cr,
- '"width": ', _imageElement.flipH() * _imageElement.w, ',', cr,
- '"height": ', _imageElement.flipV() * _imageElement.h, ',', cr,
- '"t": ', timing, cr,
+ '"picture_id": ', _imageElement.resourcePicture().id, ',', cr,
+ '"x": ', _imageElement.x, ',', cr,
+ '"y": ', _imageElement.y, ',', cr,
+ '"z": ', _imageElement.z, ',', cr,
+ '"t": ', timing, ',', cr,
+ '"width": ', _imageElement.flipH() * _imageElement.w, ',', cr,
+ '"height": ', _imageElement.flipV() * _imageElement.h, cr,
'}'
].join( '');
};
'}'
].join( '');
};
+
+ this.getJsonPostString = function(){
+ timing = 0;
+
+ var JSON_STRING_ARRAY = [],
+ IMAGE_ARRAY = [],
+ BALLOON_ARRAY = [],
+ l = panelElementArray.length,
+ _panelElement,
+ cr = pettanr.LINE_FEED_CODE_TEXTAREA;
- function clickGenerate(){
+ while( IMAGE_ARRAY.length + BALLOON_ARRAY.length <= l ){
+ _panelElement = getPanelElementByTiming();
+ if( _panelElement === null) break;
+ _panelElement.type === 0 ?
+ IMAGE_ARRAY.push( [ '"new', timing, '": ', imageToJson( _panelElement ) ].join( '' ) ) :
+ BALLOON_ARRAY.push( [ '"new', timing, '": ', balloonToJson( _panelElement ) ].join( '' ) );
+ };
+ return [
+ '{', cr,
+ //'"panel": {', cr,
+ //'"id": ', panelID, ',', cr,
+ '"width": ', panelW, ',', cr,
+ '"height": ', panelH, ',', cr,
+ '"border": ', borderSize, ',', cr,
+ // '"comic_id": ', comicID, ',', cr,
+ // '"picture_id": 1,', cr,
+ '"x": ', 0, ',', cr,
+ '"y": ', 0, ',', cr,
+ '"z": ', 0, ',', cr,
+ // '"t": ', panelTimming, ',', cr,
+ '"panel_pictures_attributes": {', cr,
+ IMAGE_ARRAY.join( ',' + cr ), cr,
+ '},', cr,
+ '"speech_balloons_attributes": {', cr,
+ BALLOON_ARRAY.join( ',' + cr ), cr,
+ '}', cr,
+ //'}', cr,
+ '}'
+ ].join( '' );
+ };
+ this.getJsonGetString = function(){
+ timing = 0;
+
+ var JSON_STRING_ARRAY = [],
+ ELEMENT_ARRAY = [],
+ l = panelElementArray.length,
+ cr = pettanr.LINE_FEED_CODE_TEXTAREA,
+ _panelElement;
+
+ while( ELEMENT_ARRAY.length <= l){
+ _panelElement = getPanelElementByTiming();
+ if( _panelElement === null ) break;
+
+ ELEMENT_ARRAY.push( _panelElement.type === 0 ? getImageJsonGET( _panelElement ) : balloonToJson( _panelElement ));
+ };
+ return [
+ '{', cr,
+ //'"panel": {', cr,
+ //'"id": ', panelID, ',', cr,
+ '"border": ', borderSize, ',', cr,
+ // '"comic_id": ', comicID, ',', cr,
+ // '"picture_id": 1,', cr,
+ '"x": ', 0, ',', cr,
+ '"y": ', 0, ',', cr,
+ '"z": ', 0, ',', cr,
+ // panelTimming !== -1 ? ( '"t": ' + panelTimming + ',' + cr ) : '',
+ '"width": ', panelW, ',', cr,
+ '"height": ', panelH, ',', cr,
+ '"panel_elements": [', cr,
+ ELEMENT_ARRAY.join( ',' + cr ), cr,
+ ']', cr,
+ //'}', cr,
+ '}'
+ ].join( '' );
+ };
+ this.getAsHtmlString = function( isAbsoluteUrl, isXHTML ){
+ timing = 0;
+
+ var HTML_ARRAY = [],
+ l = panelElementArray.length,
+ _panelElement;
+
+ while( HTML_ARRAY.length < l ){
+ _panelElement = getPanelElementByTiming();
+ if( _panelElement === null) break;
+ HTML_ARRAY.push( panelElementToHtml( _panelElement, isAbsoluteUrl, isXHTML ));
+ };
+
+ HTML_ARRAY.unshift(
+ [
+ '<div class="panel" ',
+ 'style="',
+ 'height:', panelH, 'px;',
+ 'background-color:', ';',
+ '"',
+ '>'
+ ].join( '')
+ );
+ HTML_ARRAY.push( '</div>');
+
+ return HTML_ARRAY.join( pettanr.LINE_FEED_CODE_TEXTAREA );
+ };
+ this.destroy = function(){
+ panel = panelElementArray = null;
+ };
+ };
+
+ return {
+ createPanel: function( panelData ){
+ return new PanelModelClass( panelData );
+ }
+ };
+} )();
+
+
+var OutputConsole = gOS.registerApplication( function(){
+ var FORMAT_LIST = [ 'json[POST]', 'json[GET]', 'XML', 'HTML', 'XHTML', 'MT export', 'Blogger ATOM' ];
+ var elmOutputArea,
+ comboboxFormat, inputOption,
+ buttonPost, buttonClose,
+ windowW, windowH,
+ timing = 0,
+ comicID, panelID, panelTimming, panelW, panelH, borderSize, panelElementArray,
+ instance = this,
+ model = null;
+
+ function clickOK(){
+ OutputConsole.shutdown();
+ };
+
+ function formatUpdate(){
var i = comboboxFormat.selectIndex(),
text = 'sorry...';
+ // buttonPost.enabled( false );
if( i === 0 ){
- text = getJsonPostString();
+ text = model.getJsonPostString();
+ // buttonPost.enabled( true );
} else
if( i === 1 ){
- text = getJsonGetString();
+ text = model.getJsonGetString();
} else
if( i === 3 ){
- text = getAsHtmlString( false, false );
+ text = model.getAsHtmlString( false, false );
} else {
};
return false;
};
+ function clickPost(){
+ // PanelConsole.boot( elmOutputArea.value );
+ return false;
+ }
+
/* grobal method */
this.MIN_WIDTH = 320;
this.MIN_HEIGHT = 320;
'<span id="output-console-option-value" class="output-console-value editable-value">absolute-path</span>',
'</div>',
'<div id="output-console-button-container" class="clearfix">',
- '<div id="output-console-generate-button" class="button console-submit-button">generate</div>',
+ // '<div id="output-console-post-button" class="button console-submit-button">post</div>',
'<div id="output-console-close-button" class="button console-cancel-button">close</div>',
'</div>',
'<textarea id="output-area" readonly></textarea>',
'</div>'
].join( '' );
- instance.fetchCSS( '/assets/peta.apps.css' );
+ instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
delete instance.onInit;
};
elmOutputArea = document.getElementById( 'output-area' );
var ui = instance.createUIGroup();
- comboboxFormat = ui.createCombobox( document.getElementById( 'output-console-format' ), clickGenerate );
+ comboboxFormat = ui.createCombobox( document.getElementById( 'output-console-format' ), formatUpdate );
for( var i=0; FORMAT_LIST[ 0 ]; ++i ){
comboboxFormat.createOption( FORMAT_LIST.shift(), null, i === 0 );
};
inputOption = ui.createInputText( document.getElementById( 'output-console-option' ), null );
- buttonGenerate = ui.createButton( document.getElementById( 'output-console-generate-button' ), clickGenerate );
+ // buttonPost = ui.createButton( document.getElementById( 'output-console-post-button' ), clickPost );
buttonClose = ui.createButton( document.getElementById( 'output-console-close-button' ), clickClose );
instance.onPaneResize( _w, _h );
- comicID = _comicID;
- panelID = _panelID;
- panelTimming = _panelTimming;
- panelW = _panelW;
- panelH = _panelH;
- borderSize = _borderSize;
- panelElementArray = _panelElementArray;
+ model = Model.createPanel( {
+ comicID : _comicID,
+ panelID : _panelID,
+ panelTimming : _panelTimming,
+ panelW : _panelW,
+ panelH : _panelH,
+ borderSize : _borderSize,
+ panelElementArray : _panelElementArray
+ } );
- clickGenerate();
+ formatUpdate();
};
this.onPaneResize = function( _windowW, _windowH ){
windowW = _windowW;
};
this.onClose = function(){
elmOutputArea.value = '';
- elmOutputArea = comboboxFormat = inputOption = buttonGenerate = buttonClose = panelElementArray = instance = null;
+ model.destroy();
+ elmOutputArea = comboboxFormat = inputOption = buttonPost = buttonClose = panelElementArray = instance = model = null;
};
}, true, false, 'Output Console', 'outputConsole', null, '#2D89F0' );
+
+var PanelConsole = gOS.registerApplication( function(){
+ var windowW, windowH,
+ TARGET_FRAME_NAME = 'targetFrameCreateNewPanel',
+ elmContainer, elmProgress,
+ elmScript = null,
+ elmForm = null,
+ elmIframe = null,
+ isUploading = false,
+ instance = this,
+ json;
+ /*
+ * upload ボタンが押されたらまず iframe をつくる.
+ */
+ function clickOK(){
+ if( !elmForm || !elmIframe || isUploading === true ) return false;
+ elmProgress.innerHTML = 'uploading.';
+ isUploading = true;
+ 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' && Type.isString( json ) === true ){
+ _input.value = json;
+ };
+ };
+ 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;
+ PanelConsole.shutdown();
+ return false;
+ };
+
+ /* grobal method */
+ 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 = [
+ '<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 class="console-button-container">',
+ '<div id="panel-console-post-button" class="button console-submit-button">post</div>',
+ '<div id="panel-console-cancel-button" class="button console-cancel-button">cancel</div>',
+ '</div>',
+ '<div id="panel-console-progress" class="console-progress"> </div>',
+ '</div>'
+ ].join( '' );
+
+ instance.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
+
+ delete instance.onInit;
+ }
+ this.onOpen = function( w, h, _json ){
+ elmContainer = document.getElementById( 'newpanel' );
+ elmProgress = document.getElementById( 'panel-console-progress' );
+
+ instance.addMouseEventListener( document.getElementById( 'panel-console-post-button' ), 'click', clickOK );
+ instance.addMouseEventListener( document.getElementById( 'panel-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.CREATE_PANEL_JS;
+
+ instance.addTimer( detectForm, 250 );
+ instance.onPaneResize( w, h );
+
+ json = _json;
+
+ elmProgress.innerHTML = 'loading form.';
+ };
+ 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;'
+ ].join( '' );
+ };
+ this.onClose = function(){
+ elmHeader = elmProgress = elmForm = elmUploader = instance = null;
+ isUploading = false;
+ };
+}, true, true, 'Panel Console', 'panelConsole', null, '#603CBA' );
+
+
})( pettanr, gOS, window );