/*
* pettanR peta.apps.js
- * version 0.5.11
+ * version 0.5.12
*
* author:
* itozyun
};
};
};
- addChildData( _data.author_id === MyAuthorID ? FILE_DATA_MY_PANELS_ROOT : FILE_DATA_LATEST_PANELS, _data );
+ _data.publish === 1 && addChildData( FILE_DATA_LATEST_PANELS, _data );
+ _data.author_id === MyAuthorID && addChildData( FILE_DATA_MY_PANELS_ROOT, _data );
} else
// Picture
if( _data.type == FILE_TYPE.PICTURE ){
return [ _data.id, _data.ext ].join( '.' );
} else
if( _type === FILE_TYPE.PANEL ){
- return [ _data.t, ':', _data.comic ? _data.comic.title : 'free panel' ].join( '' );
+ return [ 'id:' + _data.id + ', ' + ( _data.t || '' ) + ':', _data.comic ? _data.comic.title : 'no comic' ].join( '' );
} else
if( _type === FILE_TYPE.COMIC ){
return _data.title;
Editor.shutdown();
};
function onSave(){
- var model = Model.createPanel( {
+ PanelConsole.boot( 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();
+ panelElementArray : PANEL_ELEMENT_ARRAY,
+ publish : true
+ } ) );
};
function onSaveQuit(){
// Editor.shutdown();
elmIframe.onload = null;
try {
console.log( ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).document.body.innerHTML );
- console.log( ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow[ '' ] ) )
+ console.log( ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow[ 'current_author' ] ) )
} catch(e){
}
var Model = ( function(){
var PanelModelClass = function( panel ){
- var comicID = panel.comicID,
- panelID = panel.panelID,
- panelTimming = panel.panelTimming,
+ var comicID = panel.comicID || -1,
+ panelID = panel.panelID || -1,
+ panelTimming = panel.panelTimming || -1,
panelW = panel.panelW,
panelH = panel.panelH,
borderSize = panel.borderSize,
panelElementArray = panel.panelElementArray,
+ publish = panel.publish,
timing = 0;
function getPanelElementByTiming(){
};
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": ', 1, ',', 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,
+ panelID !== -1 ? ( '"id": ' + panelID + ',' + cr ) : '',
+ comicID !== -1 ? ( '"comic_id": ' + comicID + ',' + cr ) : '',
+ '"width": ', panelW, ',', cr,
+ '"height": ', panelH, ',', cr,
+ '"border": ', borderSize, ',', cr,
+
+ // '"picture_id": 1,', cr,
+ '"x": ', 0, ',', cr,
+ '"y": ', 0, ',', cr,
+ '"z": ', 1, ',', cr,
+ panelTimming !== -1 ? ( '"t": ' + panelTimming + ',' + cr ) : '',
+ '"panel_pictures_attributes": {', cr,
+ IMAGE_ARRAY.join( ',' + cr ), cr,
+ '},', cr,
+ '"speech_balloons_attributes": {', cr,
+ BALLOON_ARRAY.join( ',' + cr ), cr,
+ '}', ',', cr,
+ '"publish": ', ( publish === true ? 1 : 0 ), cr,
'}'
].join( '' );
};
return HTML_ARRAY.join( pettanr.LINE_FEED_CODE_TEXTAREA );
};
+ this.publish = function( v ){
+ return publish = Type.isBoolean( v ) === true ? v : publish;
+ };
this.destroy = function(){
panel = panelElementArray = null;
};
panelW : _panelW,
panelH : _panelH,
borderSize : _borderSize,
- panelElementArray : _panelElementArray
+ panelElementArray : _panelElementArray,
+ publish : true
} );
formatUpdate();
var PanelConsole = gOS.registerApplication( function(){
var windowW, windowH,
TARGET_FRAME_NAME = 'targetFrameCreateNewPanel',
- elmContainer, elmProgress,
- elmScript = null,
- elmForm = null,
- elmIframe = null,
+ comboboxPublish, buttonPost, buttonClose,
+ elmContainer, elmProgress, elmInput,
+ elmScript = null,
+ elmForm = null,
+ elmIframe = null,
isUploading = false,
- instance = this,
- json;
+ instance = this,
+ model = null;
+
/*
* upload ボタンが押されたらまず iframe をつくる.
*/
if( _input.type === 'submit' ){
_input.style.display = 'none';
};
- if( _input.name === 'json' && Type.isString( json ) === true ){
- _input.value = json;
+ if( _input.name === 'json' ){
+ elmInput = _input;
+ publishUpdate();
};
};
instance.removeTimer( detectForm );
instance.onPaneResize( windowW, windowH );
};
function clickCancel(){
- if( isUploading === true) return false;
+ if( isUploading === true ) return false;
PanelConsole.shutdown();
return false;
};
+ function publishUpdate(){
+ if( model ){
+ model.publish( comboboxPublish.selectIndex() === 1 );
+ elmInput.value = model.getJsonPostString().replace( /\n/g, '' );
+ };
+ };
/* grobal method */
this.MIN_WIDTH = 320;
'<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 id="panel-console-publish" class="field">',
+ '<span class="field-label">Publish:</span>',
+ '<span id="panel-console-publish-value" class="combobox"></span>',
+ '</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>',
delete instance.onInit;
}
- this.onOpen = function( w, h, _json ){
+ this.onOpen = function( w, h, _model ){
+ var ui = instance.createUIGroup();
+ // inputTitle = ui.createInputText( document.getElementById( 'comic-console-title') );
+
+ if( _model ){
+ comboboxPublish = ui.createCombobox( document.getElementById( 'panel-console-publish'), 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' );
-
- 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 に追加.
*/
instance.addTimer( detectForm, 250 );
instance.onPaneResize( w, h );
- json = _json;
-
elmProgress.innerHTML = 'loading form.';
};
this.onPaneResize = function( _windowW, _windowH ){
].join( '' );
};
this.onClose = function(){
- elmHeader = elmProgress = elmForm = elmUploader = instance = null;
+ model && model.destroy();
+ elmHeader = elmProgress = elmForm = elmUploader = instance = model = null;
+ comboboxPublish = buttonPost = buttonClose = null;
isUploading = false;
};
}, true, true, 'Panel Console', 'panelConsole', null, '#603CBA' );