11 ( function( pettanr, gOS, window, document, undefined ){
13 * PettanR service driver.
15 var MyAuthorID = 'current_author' in window ? current_author.id : ( pettanr.CONST.SERVER_SUPPORT === false ? 1 : -1 ),
16 MyArtistID = 'current_artist' in window ? current_artist.id : ( pettanr.CONST.SERVER_SUPPORT === false ? 1 : -1 ),
18 FileAPI = gOS.registerDriver( function(){
19 var self = Driver = this;
21 function onLoadJson( _file, _json ){
22 var _access = FileAPI.getFileDataAccess( _file ),
23 _data = _access !== null ? _access.DATA : null;
28 _data.state = Const.FILE.STATE.OK;
30 if( Type.isArray( _json ) === true ){
31 for( var i = 0, l = _json.length; i < l; ++i ){
32 buildFileData( _json[ i ], _data );
35 if( Type.isNumber( _json.id ) === true ){
36 buildFileData( _json, _data );
38 _file.dispatchEvent( FileAPI.createFileEvent( Const.FILE.EVENT.GET_SEQENTIAL_FILES, _file, 'children', null ) );
40 function onErrorJson( _file ){
41 var _data = FileAPI.getFileData( _file);
43 _data.state = Const.FILE.STATE.ERROR;
45 _file.dispatchEvent( FileAPI.createFileEvent( Const.FILE.EVENT.GET_SEQENTIAL_FILES, _file, 'children', null ) );
47 function buildFileData( _data, _parent ){
50 if( _parent === FILE_DATA_PANELS_ROOT || _parent === FILE_DATA_MY_PANELS_ROOT ){
51 _data.type = FILE_TYPE.PANEL;
55 if( _parent === FILE_DATA_COMICS_ROOT ){
56 _data.type = FILE_TYPE.COMIC;
59 if( _parent.type === FILE_TYPE.COMIC ){
63 if( _parent === FILE_DATA_LISENCE_ROOT ){
64 _data.type = FILE_TYPE.LICENSE;
65 _array = ORIGINAL_LICENSE_ARRAY;
68 if( _parent === FILE_DATA_AUTHOR_ROOT ){
69 _data.type = FILE_TYPE.AUTHOR;
70 _array = AUTHOR_ARRAY;
73 if( _parent === FILE_DATA_ARTIST_ROOT ){
74 _data.type = FILE_TYPE.ARTIST;
75 _array = ARTIST_ARRAY;
78 if( _parent === FILE_DATA_PICTURE_ROOT || _parent === FILE_DATA_MY_PICTURES_ROOT ){
79 _data.type = FILE_TYPE.PICTURE;
80 _array = RESOURCE_PICTURE_ARRAY;
81 // original_license を含まなければ、license object を削除して ビットデータ で保持
82 // original_license なら ファイルを作る buildFileData( _license, FILE_DATA_LISENCE_ROOT)
83 var _license = _data.license,
87 if( typeof _license === 'object' ){
88 for( i=0, l=BASIC_LICENSES.length; i<l; ++i ){
89 _rule = _license[ BASIC_LICENSES[ i]];
90 if( typeof _rule === 'number' && _rule === 1 ){
91 _bits += _Math_pow( 2, i );
94 _data.license = _bits;
100 _data.driver = Driver;
101 // alert( ' _array ' + _data.id + Type.isNumber( _data.id ) );
102 // _array に _data を格納 または 上書き
103 if( Type.isNumber( _data.id ) === true && _data.id > 0 ){
104 var _id = _data.id - 1,
105 __data = _array[ _id ],
106 _reserved = Const.FILE.DATA_PROPERTY_RESERVED.join( ', ' );
108 for( var key in _data ){
109 if( _reserved.indexOf( key ) === -1 ){
110 __data[ key ] = _data[ key ];
113 _data = __data; // このタイミングで参照が切れるので注意!!
115 _array[ _id ] = _data;
118 // alert( 'error' + _parent.name + ' ' + _data.id );
123 if( _parent === FILE_DATA_AUTHOR_ROOT || _parent === FILE_DATA_ARTIST_ROOT ){
124 addChildData( _parent, _data );
127 if( _parent.type === FILE_TYPE.COMIC || _parent === FILE_DATA_COMICS_ROOT ){
128 var _panels = _data.stories,
130 if( Type.isArray( _panels ) === true ){
132 for( i=0, l=_panels.length; i<l; ++i ){
133 _panel = buildFileData( _panels[ i ], FILE_DATA_PANELS_ROOT );
137 addChildData( _data, _panel );
139 delete _data.stories;
141 if( _data.json !== null ){
144 if( Type.isArray( _data.children ) === false ){
148 var _author = _data.author || getResource( AUTHOR_ARRAY, _data.author_id );
150 _data.author = _author = buildFileData( _author, FILE_DATA_AUTHOR_ROOT );
151 addChildData( _author, _data );
152 _author.id === MyAuthorID && addChildData( FILE_DATA_MY_COMICS_ROOT, _data );
154 if( _parent === FILE_DATA_COMICS_ROOT ){
155 addChildData( FILE_DATA_LATEST_COMICS, _data );
159 if( _parent === FILE_DATA_PANELS_ROOT || _parent === FILE_DATA_MY_PANELS_ROOT ){
160 _data.comic && buildFileData( _data.comic, FILE_DATA_COMICS_ROOT );
161 _data.author && buildFileData( _data.author, FILE_DATA_AUTHOR_ROOT );
163 _data.comic = getResource( COMIC_ARRAY, _data.comic_id );
164 _data.author = getResource( AUTHOR_ARRAY, _data.author_id );
166 // picture data をファイルに取り出し
167 var _elements = _data.panel_elements,
169 if( Type.isArray( _elements ) === true ){
170 for( i=0, l=_elements.length; i<l; ++i ){
171 _elm = _elements[ i];
172 if( _elm.resource_picture ){
173 _elm.resource_picture = buildFileData( _elm.resource_picture, FILE_DATA_PICTURE_ROOT ); // 上記参照切れに備えてここで上書き
175 _elm.resource_picture = getResource( RESOURCE_PICTURE_ARRAY, _elm.picture_id );
179 _data.publish === 1 && addChildData( FILE_DATA_LATEST_PANELS, _data );
180 _data.author_id === MyAuthorID && addChildData( FILE_DATA_MY_PANELS_ROOT, _data );
183 if( _data.type == FILE_TYPE.PICTURE ){
184 var _artist = _data.artist || getResource( ARTIST_ARRAY, _data.artist_id );
186 _data.artist = _artist = buildFileData( _artist, FILE_DATA_ARTIST_ROOT );
187 addChildData( _artist, _data );
188 if( _artist.id === MyArtistID ){
189 addChildData( FILE_DATA_MY_PICTURES_ROOT, _data );
190 //FILE_DATA_MY_PICTURES_ROOT.type = FILE_TYPE.ARTIST;
191 //FILE_DATA_MY_PICTURES_ROOT.id = MyArtistID;
197 function addChildData( _parent, _child ){
198 if( Type.isArray( _parent.children ) === false ){
199 _parent.children = [];
201 Util.getIndex( _parent.children, _child ) === -1 && _parent.children.push( _child );
203 function getResource( _array, _id ){
204 if( Type.isArray( _array ) === false || Type.isNumber( _id ) === false || _id < 1 ) return null;
205 var _data = _array[ _id - 1 ];
207 _data = _array[ _id - 1 ] = {};
212 this.getSeqentialFiles = function( _file ){
213 var _data = FileAPI.getFileData( _file ),
214 _json = _data !== null ? _data.json : null;
215 if( _json === true && _data.type === FILE_TYPE.COMIC ){
216 if( pettanr.CONST.SERVER_SUPPORT === false ){
217 _json = [ 'json\/comics_', _data.id, '.json' ].join( '' );
219 _json = [ pettanr.CONST.PETTANR_ROOT_PATH, 'comics\/', _data.id, '.json' ].join( '' );
222 if( typeof _json === 'string' ){
223 FileAPI.getJson( _file, _json, onLoadJson, onErrorJson );
224 _data.state = Const.FILE.STATE.LOADING;
229 this.getName = function( _file ){
230 var _data = FileAPI.getFileData( _file ),
231 _type = _data !== null ? _data.type : null;
232 if( _type === FILE_TYPE.PICTURE ){
233 return [ _data.id, _data.ext ].join( '.' );
235 if( _type === FILE_TYPE.PANEL ){
236 return [ 'id:' + _data.id + ', ' + ( _data.t || '' ) + ':', _data.comic ? _data.comic.title : 'no comic' ].join( '' );
238 if( _type === FILE_TYPE.COMIC ){
241 if( _type === FILE_TYPE.ARTIST ){
242 return [ _data.name, '画伯' ].join( '' );
244 if( _type === FILE_TYPE.AUTHOR ){
245 return [ _data.name, '先生' ].join( '' );
249 this.getThumbnail = function( _file ){
250 var _data = FileAPI.getFileData( _file ),
251 _type = _data !== null ? _data.type : null;
252 if( _type === FILE_TYPE.PICTURE ){
253 return { image: [ pettanr.CONST.THUMBNAIL_PATH, _data.id, '.', _data.ext ].join( '' )};
255 if( _data === FILE_DATA_COMICS_ROOT ){
256 return { className: 'file-type-cabinet' };
258 if( _type === FILE_TYPE.COMIC ){
259 return { className: 'file-type-comic' };
261 if( _type === FILE_TYPE.PANEL ){
262 return { className: 'file-type-panel' };
264 if( _type === FILE_TYPE.AUTHOR ){
265 return { className: 'file-type-author' };
267 if( _type === FILE_TYPE.ARTIST ){
268 return { className: 'file-type-artist' };
270 if( _type === FILE_TYPE.FOLDER){
271 return { className: 'file-type-folder' };
273 return { className: 'file-type-broken' };
275 this.getSummary = function( _file ){
276 var _data = FileAPI.getFileData( _file ),
277 _type = _data !== null ? _data.type : null;
278 if( _type === FILE_TYPE.PICTURE ){
279 return [ _data.width, 'x', _data.height, ', filesize:', _data.filesize, ', lisence:', _data.license ].join( '' );
281 if( _data === FILE_DATA_COMICS_ROOT ){
282 return 'cabinet file';
284 if( _type === FILE_TYPE.COMIC ){
285 return 'comic file, id:' + _data.id;
287 if( _type === FILE_TYPE.PANEL ){
288 return [ _data.width, 'x', _data.height ].join( '' );
290 if( _type === FILE_TYPE.AUTHOR ){
291 return 'author file, id:' + _data.id;
293 if( _type === FILE_TYPE.ARTIST ){
294 return [ 'id:', _data.id, ' Email:', _data.email || 'empty' , ', HP:', _data.homepage_url || 'empty' ].join( '' );
296 if( _type === FILE_TYPE.FOLDER ){
297 return 'pettanR folder';
299 return 'pettanR unknown file';
301 this.read = function( _file ){
302 var _data = FileAPI.getFileData( _file ),
303 _type = _data !== null ? _data.type : null,
305 if( _type === FILE_TYPE.COMIC ){
306 // children を panels に deepcopy
308 for( var key in _data ){
309 ret[ key ] = _data[ key ]
311 ret.stories = _data.children;
314 if( _type === FILE_TYPE.PANEL ){
316 if( _type === FILE_TYPE.PANEL_PICTURE ){
319 if( _type === FILE_TYPE.BALLOON ){
321 if( _type === FILE_TYPE.PICTURE ){
324 this.write = function( _file, _newData, _onUpdate ){
325 var _data = FileAPI.getFileData( _file ),
326 _type = _data !== null ? _data.type : null;
327 if( _type === FILE_TYPE.COMIC ){
329 if( _type === FILE_TYPE.PANEL ){
331 if( _type === FILE_TYPE.PANEL_PICTURE ){
334 if( _type === FILE_TYPE.BALLOON ){
336 if( _type === FILE_TYPE.PICTURE ){
339 this.viewerApplicationList = function( _file ){
340 var _data = FileAPI.getFileData( _file ),
341 _type = _data !== null ? _data.type : null;
342 if( _type === FILE_TYPE.PANEL ){
345 if( _type === FILE_TYPE.COMIC ){
348 if( _data === FILE_DATA_MY_PICTURES_ROOT ){
349 return [ PremiumSatge ];
351 if( _type === FILE_TYPE.ARTIST ){
352 return [ PremiumSatge ];
356 this.editorApplicationList = function( _file ){
357 var _data = FileAPI.getFileData( _file ),
358 _type = _data !== null ? _data.type : null;
359 if( _type === FILE_TYPE.PANEL ){
362 if( _type === FILE_TYPE.COMIC ){
363 return [Editor, ComicConsole ];
368 Const = FileAPI.getConst(),
369 FILE_TYPE = Util.extend(
372 COMIC: FileAPI.createFileTypeID(),
373 PANEL: FileAPI.createFileTypeID(),
374 PICTURE: FileAPI.createFileTypeID(),
375 PANEL_PICTURE: FileAPI.createFileTypeID(),
376 BALLOON: FileAPI.createFileTypeID(),
377 AUTHOR: FileAPI.createFileTypeID(),
378 ARTIST: FileAPI.createFileTypeID(),
379 LICENSE: FileAPI.createFileTypeID()
382 FILE_DATA_SERVICE_ROOT = {
383 name: 'PettanR root',
384 type: FILE_TYPE.FOLDER,
387 FILE_DATA_COMICS_ROOT = {
389 type: FILE_TYPE.FOLDER,
392 json: pettanr.CONST.URL_COMICS_JSON
394 FILE_DATA_PANELS_ROOT = {
396 type: FILE_TYPE.FOLDER,
399 json: pettanr.CONST.URL_PANELS_JSON
401 FILE_DATA_PICTURE_ROOT = {
403 type: FILE_TYPE.FOLDER,
406 json: pettanr.CONST.URL_RESOURCE_PICTURES_JSON
408 FILE_DATA_MY_COMICS_ROOT = {
410 type: FILE_TYPE.FOLDER,
415 FILE_DATA_LATEST_COMICS = {
416 name: 'Latest Comics',
417 type: FILE_TYPE.FOLDER,
420 FILE_DATA_LATEST_PANELS = {
421 name: 'Latest Panels',
422 type: FILE_TYPE.FOLDER,
425 FILE_DATA_MY_PANELS_ROOT = {
427 type: FILE_TYPE.FOLDER,
430 json: pettanr.CONST.URL_MY_PANELS_JSON
432 FILE_DATA_MY_PICTURES_ROOT = {
434 type: FILE_TYPE.FOLDER,
437 json: pettanr.CONST.URL_ORIGINAL_PICTURES_JSON,
440 FILE_DATA_AUTHOR_ROOT = {
442 type: FILE_TYPE.FOLDER,
445 FILE_DATA_ARTIST_ROOT = {
447 type: FILE_TYPE.FOLDER,
450 FILE_DATA_LISENCE_ROOT = {
451 name: 'Original Lisences',
452 type: FILE_TYPE.FOLDER,
455 FILE_DATA_BALLOON_ROOT = {
456 name: 'Balloon templetes',
457 type: FILE_TYPE.FOLDER,
464 RESOURCE_PICTURE_ARRAY = [],
465 BALLOON_TEMPLETE_ARRAY = [],
466 ORIGINAL_LICENSE_ARRAY = [],
467 BASIC_LICENSES = 'cc_by,cc_nc,cc_nd,cc_sa,keep_aspect_ratio,no_convert,no_flip,no_resize'.split( ',');
468 FILE_DATA_SERVICE_ROOT.children.push( FILE_DATA_COMICS_ROOT, FILE_DATA_PICTURE_ROOT, FILE_DATA_PANELS_ROOT, FILE_DATA_LISENCE_ROOT, FILE_DATA_BALLOON_ROOT );
469 FILE_DATA_COMICS_ROOT.children.push( FILE_DATA_MY_COMICS_ROOT, FILE_DATA_LATEST_COMICS, FILE_DATA_AUTHOR_ROOT );
470 FILE_DATA_PANELS_ROOT.children.push( FILE_DATA_LATEST_PANELS, FILE_DATA_MY_PANELS_ROOT );
471 FILE_DATA_PICTURE_ROOT.children.push( FILE_DATA_MY_PICTURES_ROOT, FILE_DATA_ARTIST_ROOT );
473 FileAPI.createFolderUnderRoot( FILE_DATA_SERVICE_ROOT );
475 Driver.isPettanrFileInstance = function( _file ){
476 if( FileAPI.isFileInstance( _file ) === true ){
477 var _data = FileAPI.getFileData( _file.getUID() );// _file でなく _file.getUID()
478 return _data !== null && _data.driver === Driver;
483 var Cabinet = gOS.registerApplication( function(){
493 this.bgColor = '#FFFFFF';
494 this.MIN_WIDTH = 500;
495 this.MIN_HEIGHT = 300;
496 this.onInit = function(){
497 self.rootElement.id = 'cabinet-root';
498 self.rootElement.innerHTML = [
499 '<div id="cabinet-header">',
500 '<div class="header-title">Cabinet</div>',
501 '<div id="cabinet-close-button">x</div>',
502 '<div id="cabinet-path" class="finder-path"></div>',
504 '<div id="cabinet-container" class="finder-container"></div>'
507 self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
509 tree = FileAPI.createTree( FILE_DATA_SERVICE_ROOT );
510 eventRoot = self.getPointingDeviceEventTreeRoot();
514 this.onOpen = function( _w, _h ){
515 headerH = Util.getElementSize( document.getElementById( 'cabinet-header' ) ).height;
517 nodeClose = eventRoot.createNode( document.getElementById( 'cabinet-close-button' ), false, false, 'close-button-hover', 'pointer' );
518 nodeClose.addEventListener( 'click', Cabinet.shutdown );
519 nodePath = eventRoot.createNode( document.getElementById( 'cabinet-path' ), false, false );
520 nodeBody = eventRoot.createNode( document.getElementById( 'cabinet-container' ), false, true, null, '', true );
522 finder = self.createFinder( nodeBody, tree );
523 finder.createPath( nodePath );
524 self.onPaneResize( _w, _h );
526 this.onClose = function(){
529 finder = tree = null;
531 this.onPaneResize = function( w, h ){
533 nodeBody.update( 0, headerH, w, h - headerH );
534 finder.resize( w, h - headerH );
536 }, false, true, 'Cabinet', 'cabinet', null, '#1C1C1C' );
538 var Gallery = gOS.registerApplication( function(){
548 this.bgColor = '#FFFFFF';
549 this.MIN_WIDTH = 500;
550 this.MIN_HEIGHT = 300;
551 this.onInit = function(){
552 self.rootElement.id = 'gallery-root';
553 self.rootElement.innerHTML = [
554 '<div id="gallery-header">',
555 '<div class="header-title">Gallery</div>',
556 '<div id="gallery-close-button">x</div>',
557 '<div id="gallery-path" class="finder-path"></div>',
559 '<div id="gallery-container" class="finder-container"></div>'
562 self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
564 tree = FileAPI.createTree( FILE_DATA_PICTURE_ROOT );
565 var _root = tree.getRootFile(),
566 _myPic = _root.getChildFileByIndex( 0 ),
567 _pic = _root.getChildFileByIndex( 1 );
568 _myPic.getSeqentialFiles();
569 _pic.getSeqentialFiles();
573 eventRoot = self.getPointingDeviceEventTreeRoot();
575 this.onOpen = function( w, h ){
576 headerH = Util.getElementSize( document.getElementById( 'gallery-header' ) ).height;
578 nodeClose = eventRoot.createNode( document.getElementById( 'gallery-close-button' ), false, false, 'close-button-hover', 'pointer' );
579 nodeClose.addEventListener( 'click', Gallery.shutdown );
580 nodePath = eventRoot.createNode( document.getElementById( 'gallery-path' ), false, false );
581 nodeBody = eventRoot.createNode( document.getElementById( 'gallery-container' ), false, true, null, '', true );
583 finder = self.createFinder( nodeBody, tree );
584 finder.createPath( nodePath );
585 self.onPaneResize( w, h );
587 this.onClose = function(){
590 finder = tree = null;
592 this.onPaneResize = function( w, h ){
594 nodeBody.update( 0, headerH, w, h - headerH );
595 finder.resize( w, h - headerH );
597 }, false, true, 'Gallery', 'gallery', null, '#01A31C' );
599 var Backyard = gOS.registerApplication( function(){
602 this.bgColor = '#FFFFFF';
603 this.MIN_WIDTH = 500;
604 this.MIN_HEIGHT = 300;
605 this.onInit = function(){
607 this.onOpen = function( _w, _h, _option ){
609 this.onClose = function(){
611 this.onPaneResize = function( _w, _h){
613 }, false, false, 'Settings', 'settings', null, '#DDDDDD' );
615 if( pettanr.DEBUG === true){
616 var Debug = gOS.registerApplication( function(){
621 pettanR: pettanr.version,
622 ua: navigator.userAgent,
623 platform: navigator.platform,
624 appVersion: navigator.appVersion,
625 appCodeName: navigator.appCodeName,
626 appName: navigator.appName,
627 language: navigator.browserLanguage || navigator.language,
629 RenderingMode: UA.isStanderdMode === true ? 'Standerd' : 'Quirks'
632 data.version = UA.IE;
633 if( UA.ieVersion >= 8 ) data.RenderingVersion = UA.ieRenderingVersion;
634 data.browserType = UA.STANDALONE === true ? 'Standalone' : 'bundle';
635 if( UA.ieVersion < 9 ) {
644 this.bgColor = '#FFFFFF';
645 this.MIN_WIDTH = 500;
646 this.MIN_HEIGHT = 300;
647 this.onInit = function(){
648 self.rootElement.id = 'debug-root';
649 self.rootElement.innerHTML = '<dl id="useragent" class="dl-table clearfix"></dl>';
651 this.onOpen = function( _w, _h, _option ){
652 elmDl = document.getElementById( 'useragent' );
654 for( var key in data ){
655 elmDt = document.createElement( 'dt' );
656 elmDt.innerHTML = key;
657 elmDd = document.createElement( 'dd' );
658 elmDd.innerHTML = '' + data[ key];
659 if( !data[ key ] ) elmDd.style.color = 'red';
660 elmDl.appendChild( elmDt );
661 elmDl.appendChild( elmDd );
664 this.onClose = function(){
667 this.onPaneResize = function( _w, _h ){
670 }, false, true, 'Debug', 'debug', null, '#01A31C' );
673 /* ----------------------------------------
674 * Image Group Exproler
677 var PremiumSatge = gOS.registerApplication( function(){
678 var BASE_PATH = pettanr.CONST.RESOURCE_PICTURE_PATH,
679 THUMB_PATH = pettanr.CONST.THUMBNAIL_PATH,
680 LIMIT_FILESIZE = 1024 * 100,
686 elmContainer, elmIconOrigin, elmName, elmButton,
687 containerW, containerH,
688 itemW, itemH, buttonW,
691 onUpdateContext = null,
694 var ImageGroupIconClass = function( index, data ){
695 var elmIconWrap = elmIconOrigin.cloneNode( true ),
696 elmIconTitle = Util.getElementsByClassName( elmIconWrap, 'image-group-item-title' )[ 0 ],
697 SRC = [ BASE_PATH, data.id, '.', data.ext ].join( ''),
698 LOW_SRC = data.filesize && data.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext ].join( '') : null,
699 reversibleImage = null,
703 elmContainer.appendChild( elmIconWrap );
704 elmIconWrap.style.left = ( index * itemW ) + 'px';
705 elmIconTitle.appendChild( document.createTextNode( data.filesize + 'bytes' ) );
707 function onImageLoad( url, _imgW, _imgH ){
708 data.width = _imgW = _imgW || data.width || 64;
709 data.height = _imgH = _imgH || data.height || 64;
710 elmIconTitle.firstChild.data = _imgW + 'x' + _imgH;
711 var zoom = 128 /( _imgW > _imgH ? _imgW : _imgH ),
712 MATH_FLOOR = Math.floor,
713 h = MATH_FLOOR( _imgH * zoom ),
714 w = MATH_FLOOR( _imgW * zoom );
715 reversibleImage.elm.style.cssText = [
718 'margin:', MATH_FLOOR( itemH / 2 - h / 2 ), 'px ', MATH_FLOOR( itemW / 2 - w / 2 ), 'px 0'
720 reversibleImage.resize( w, h );
721 self.addEventListener( elmIconWrap, 'click', onClick );
726 PremiumSatge.shutdown();
729 function asyncDraw(){
730 reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onImageLoad );
731 elmIconWrap.appendChild( reversibleImage.elm );
736 this.onEnter = function( delay ){
737 self.addTimer( asyncDraw, delay, true );
738 delete instance.onEnter;
740 this.destroy = function(){
741 delete instance.destroy;
742 // timer && window.clearTimeout( timer );
743 self.removeTimer( asyncDraw );
744 self.removeEventListener( elmIconWrap );
745 reversibleImage !== null && reversibleImage.destroy();
746 // Util.removeAllChildren( elmIconWrap );
747 // elmContainer.removeChild( elmIconWrap );
748 reversibleImage = elmIconWrap = elmIconTitle = data = timer = null;
752 function onEnterShowImage(){
753 var l = ICON_ARRAY.length,
754 _start = -wrapX /itemW -1,
755 _end = _start + winW /itemW +1,
757 for( var i=0, c = 0; i<l; ++i){
758 _icon = ICON_ARRAY[ i ];
759 if( _start < i && i < _end && _icon.onEnter ){
760 _icon.onEnter( c * 100 );
764 //onEnterInterval !== null && window.clearTimeout( onEnterInterval );
765 //onEnterInterval = null;
766 self.removeTimer( onEnterShowImage );
768 function clickClose(){
769 PremiumSatge.shutdown();
771 function onMouseWheel( e ){
772 if( winW < containerW ){
773 wrapX += e.wheelDelta / 2;
774 wrapX = wrapX > 0 ? 0 : wrapX < winW -containerW ? winW -containerW : wrapX;
775 elmContainer.style.left = wrapX + 'px';
777 self.removeTimer( onEnterShowImage );
778 self.addTimer( onEnterShowImage, 500 );
783 function drawIcons(){
784 while( ICON_ARRAY.length > 0 ){
785 ICON_ARRAY.shift().destroy();
787 var _index = rootFile.search( {
789 type: FILE_TYPE.ARTIST
791 _artistFile = rootFile.getChildFileByIndex( _index ),
793 if( _artistFile !== null ){
794 for(var i=0, l=_artistFile.getChildFileLength(); i<l; ++i ){
795 _file = _artistFile.getChildFileByIndex( i );
796 ICON_ARRAY.push( new ImageGroupIconClass( i, FileAPI.getFileData( _file ) ));
799 elmName.firstChild.data = _artistFile.getName();
800 _artistFile.destroy();
804 function onFadeout(){
805 while( ICON_ARRAY.length > 0 ){
806 ICON_ARRAY.shift().destroy();
808 onUpdate !== null && onUpdateData !== null && onUpdate.call( onUpdateContext, onUpdateData );
809 onUpdate = onUpdateData = onUpdateContext = null;
810 PremiumSatge.shutdown();
814 this.MIN_WIDTH = 320;
815 this.MIN_HEIGHT = 320;
816 this.onInit = function(){
817 self.rootElement.id = 'image-group-wrapper';
819 self.rootElement.innerHTML = [
820 '<div id="image-group-icon-container"></div>',
821 '<div id="image-group-name">NO DATA...</div>',
822 '<div id="image-group-button" class="button">close</div>'
825 self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
827 tree = FileAPI.createTree( FILE_DATA_ARTIST_ROOT );
828 rootFile = tree.getRootFile();
830 this.onOpen = function( _windowW, _windowH, _ARTISTIDorFILE, _onUpdate, opt_thisObj ){
831 elmContainer = document.getElementById( 'image-group-icon-container' );
832 containerH = Util.getElementSize( elmContainer ).height;
834 elmIconOrigin = ( function(){
835 var ret = document.createElement( 'div' ),
836 data = document.createElement( 'div' );
837 ret.appendChild( data );
838 ret.className = 'image-group-item';
839 data.className = 'image-group-item-title';
843 var size = Util.getElementSize( elmIconOrigin );
847 elmName = document.getElementById( 'image-group-name' );
848 elmButton = document.getElementById( 'image-group-button' );
850 buttonW = Util.getElementSize( elmButton ).width;
852 self.addEventListener( elmContainer, 'mousewheel', onMouseWheel );
853 self.addEventListener( elmButton, 'click', clickClose );
854 tree.addTreeEventListener( Const.TREE.EVENT.UPDATE, drawIcons );
856 if( Driver.isPettanrFileInstance( _ARTISTIDorFILE ) === true ){
857 var _data = FileAPI.getFileData( _ARTISTIDorFILE );
858 if( _ARTISTIDorFILE.getType() === FILE_TYPE.ARTIST || FILE_DATA_MY_PICTURES_ROOT === _data ){
859 artistID = _data.id || -1;
862 if( Type.isNumber( _ARTISTIDorFILE ) === true ){
863 artistID = _ARTISTIDorFILE;
866 onUpdate = _onUpdate || null;
867 onUpdateContext = opt_thisObj || null;
873 containerW = ICON_ARRAY.length * itemW;
877 var w = winW > containerW ? winW : containerW,
878 h = _windowH > containerH ? containerH : _windowH,
879 MATH_FLOOR = Math.floor;
881 $( elmContainer ).css( {
885 top: MATH_FLOOR( _windowH /2 )
888 top: MATH_FLOOR( _windowH /2 - h /2 )
889 }, onEnterShowImage );
891 elmButton.style.cssText = [
892 'left:', MATH_FLOOR( _windowW /2 - buttonW /2 ), 'px;',
893 'top:', MATH_FLOOR( _windowH /2 + containerH /2 +10 ), 'px'
896 this.onPaneResize = function( _windowW, _windowH ){
897 var w = _windowW > containerW ? _windowW : containerW,
898 h = _windowH > containerH ? containerH : _windowH,
899 MATH_FLOOR = Math.floor,
900 offsetW = MATH_FLOOR( _windowW /2 -winW /2 );
904 if( offsetW <= 0 ){ // smaller
905 $( elmContainer ).stop().css( {
910 top: MATH_FLOOR( _windowH /2 -h /2 )
913 $( elmContainer ).stop().css( { // bigger
916 borderLeftWidth: offsetW
918 top: MATH_FLOOR( _windowH /2 -h /2 ),
922 elmButton.style.cssText = [
923 'left:', MATH_FLOOR( _windowW /2 -buttonW /2 ), 'px;',
924 'top:', MATH_FLOOR( _windowH /2 +containerH /2 + 10 ), 'px'
928 this.onClose = function(){
929 if( tree === null ) return true;
930 $( elmContainer ).stop().animate( {
932 top: Math.floor( winH / 2 )
934 // onEnterInterval !== null && window.clearTimeout( onEnterInterval );
935 // onEnterInterval = null;
938 tree.removeTreeEventListener( Const.TREE.EVENT.UPDATE, drawIcons );
940 tree = rootFile = null;
944 }, true, true, 'Premium Stage', 'premiumStage', null, '#C3325F' );
947 /* ----------------------------------------
951 var TextEditor = gOS.registerApplication( function(){
952 var elmTextarea, elmButton,
953 textElement, onUpdate,
959 textElement && textElement.text( elmTextarea.value );
960 self.addAsyncCall( asyncCallback );
963 function asyncCallback(){
964 onUpdate && onUpdate( textElement );
965 onUpdate = textElement = null;
966 TextEditor.shutdown();
970 function textareaFitHeight(){
972 while( elmTextarea.offsetHeight < textElement.h ){
974 elmTextarea.rows = rows;
976 if( rows > 1 ) elmTextarea.rows = --rows;
981 this.MIN_WIDTH = 320;
982 this.MIN_HEIGHT = 320;
983 this.onInit = function(){
984 self.rootElement.id = 'speach-editor-wrapper';
985 self.rootElement.innerHTML = '<textarea id="speach-editor"></textarea><div id="speach-edit-complete-button" class="button">OK</div>';
987 this.onOpen = function( _w, _h, _panelX, _panelY, _textElement, _onUpdate ){
988 elmTextarea = document.getElementById( 'speach-editor' );
989 elmButton = document.getElementById( 'speach-edit-complete-button' );
991 self.addKeyEventListener( 'keydown', new Function( 'return false' ), 69, false, true );
992 self.addEventListener( elmButton, 'click', clickOK );
996 textElement = _textElement;
997 onUpdate = _onUpdate || null;
999 self.onPaneResize( _w, _h );
1000 elmTextarea.value = _textElement.content;
1001 elmTextarea.focus();
1004 * ie6,7は、textarea { width:100%}でも高さが変わらない。rowsを設定。
1006 UA.isIE === true && UA.ieVersion <= 7 && self.addAsyncCall( textareaFitHeight );
1008 this.onPaneResize = function( _w, _h ){
1009 self.rootElement.style.cssText = [
1010 'left:', textElement.x + panelX, 'px;',
1011 'top:', textElement.y + panelY, 'px;',
1012 'width:', textElement.w, 'px;',
1013 'height:', textElement.h, 'px;'
1016 this.onClose = function(){
1017 self.removeKeyEventListener();
1018 self.removeEventListener( elmButton );
1020 elmTextarea = elmButton = onUpdate = textElement = self = null;
1022 }, true, false, 'Tetxt Editor', 'texteditor', null, '#DDDDDD' );
1025 var Reader = gOS.registerApplication( function(){
1026 var windowW, windowH,
1030 elmContainer, elmTitle, elmAuthor, elmBackButton, elmNextButton,
1034 currentPanel = null,
1039 function onBackClick(){
1040 currentIndex -= ( currentIndex > 0 ? 1 : 0 );
1044 function onNextClick(){
1045 currentIndex += ( currentIndex < numPanel - 1 ? 1 : 0 );
1050 var elm = elmContainer.childNodes[ currentIndex ],
1051 h = windowH - headerH - consoleH,
1054 top = headerH - elm.offsetTop + Math.floor( ( h - elm.offsetHeight ) / 2 );
1057 $( elmContainer ).stop().animate( {
1061 function getCurrentTopPosition(){
1065 var fileData, title, author;
1067 if( Driver.isPettanrFileInstance( currentFile ) === true ){
1068 if( currentFile.getType() === FILE_TYPE.COMIC ){
1069 fileData = currentFile.read();
1070 title = fileData.title;
1071 author = fileData.author.name;
1072 comicData = fileData;
1073 numPanel = currentFile.getChildFileLength();
1075 if( currentFile.getType() === FILE_TYPE.PANEL ){
1076 fileData = currentFile.read();
1077 title = fileData.comic.title;
1078 author = fileData.comic.author.name;
1079 comicData = fileData;
1085 if( comicData !== null ){
1086 elmTitle.data = title;
1087 elmAuthor.data = author;
1088 bindWorker.json( comicData );
1089 self.addAsyncCall( asyncResize );
1092 function asyncResize(){
1093 self.onPaneResize( windowW, windowH );
1098 this.MIN_WIDTH = 320;
1099 this.MIN_HEIGHT = 320;
1100 this.onInit = function(){
1101 self.rootElement.id = 'comic-reader-wrapper';
1102 self.rootElement.innerHTML = [
1103 '<div id="comic-reader-panel-container"></div>',
1104 '<div class="comic-reader-shadow" style="top:0;height:40px;"></div>',
1105 '<div id="comic-reader-header">',
1106 '<div id="comic-reader-header-content">',
1107 '<span id="comic-reader-title">NO DATA...</span>',
1108 '<span id="comic-reader-author">NO DATA...</span>',
1111 '<div class="comic-reader-shadow" style="bottom:0;height:100px;"></div>',
1112 '<div id="comic-reader-console">',
1113 '<div id="comic-reader-button-centering">',
1114 '<a href="#" id="comic-reader-back-button">▲</da>',
1115 '<a href="#" id="comic-reader-forward-button">▼</a>',
1120 self.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
1123 this.onOpen = function( _w, _h, _file ){
1124 headerH = Util.getElementSize( document.getElementById( 'comic-reader-header' ) ).height;
1125 consoleH = Util.getElementSize( document.getElementById( 'comic-reader-console' ) ).height;
1126 elmContainer = document.getElementById( 'comic-reader-panel-container' );
1127 elmTitle = document.getElementById( 'comic-reader-title' ).firstChild;
1128 elmAuthor = document.getElementById( 'comic-reader-author' ).firstChild;
1129 elmBackButton = document.getElementById( 'comic-reader-back-button' );
1130 elmNextButton = document.getElementById( 'comic-reader-forward-button' );
1132 bindWorker = pettanr.bind.createBindWorker( elmContainer, null, false, false );
1134 self.addEventListener( elmBackButton, 'click', onBackClick );
1135 self.addEventListener( elmNextButton, 'click', onNextClick );
1137 numPanel = currentIndex = 0;
1139 elmContainer.style.cssText = 'left:' + ( _w / 2 ) + 'px;' + 'top:' + _h + 'px;';
1143 if( FileAPI.isFileInstance( _file ) === true ){
1144 currentFile = _file;
1145 _file.addEventListener( Const.FILE.EVENT.GET_SEQENTIAL_FILES, draw );
1146 _file.getSeqentialFiles();
1150 this.onPaneResize = function( _windowW, _windowH ){
1153 var panelH = elmContainer.offsetHeight,
1154 panelW = elmContainer.offsetWidth,
1155 h = _windowH - headerH - consoleH;
1156 $( elmContainer ).stop().animate(
1158 left: Math.floor( ( _windowW - panelW ) / 2 ),
1159 top: headerH + ( panelH < h ? Math.floor( ( h - panelH ) / 2 ) : 0 )
1163 this.onClose = function(){
1164 self.removeEventListener( elmBackButton );
1165 self.removeEventListener( elmNextButton );
1167 bindWorker.destroy();
1170 currentFile && currentFile.removeEventListener( Const.FILE.EVENT.GET_SEQENTIAL_FILES, draw );
1171 currentFile = comicData = currentPanel = null;
1173 elmContainer = elmTitle = elmAuthor = elmBackButton = elmNextButton = null;
1175 }, true, true, 'Comic Reader', 'comicreader', null, '#01A31C' );
1178 var Editor = gOS.registerApplication( function(){
1180 var PANEL_ELEMENT_TYPE_IMAGE = 0,
1181 PANEL_ELEMENT_TYPE_TEXT = 1,
1183 PANEL_ELEMENT_ARRAY = [],
1184 MIN_PANEL_HEIGHT = 20,
1185 MIN_ELEMENT_SIZE = 19,
1186 MOUSE_HIT_AREA = 10,
1196 var kill = function(){
1199 if( o.hasOwnProperty && !o.hasOwnProperty( p ) ) continue;
1204 /* ----------------------------------------
1206 * - mouseEventListener
1217 var MENU_BAR_CONTROL = ( function(){
1218 var ELM_ITEM_CLASSNAME = 'menubar-item',
1223 /** -----------------------------------------
1224 * PrivateOptionDataClass
1226 var PrivateOptionDataClass = function( menuData, option, title, shortcut, callback, visible, separateAfter, thisObject ){
1227 this.menuData = menuData;
1228 this.option = option;
1230 this.shortcut = shortcut || '';
1231 this.callback = callback;
1232 this.thisObject = thisObject;
1233 this.visible = visible;
1234 this.separateAfter = separateAfter;
1236 PrivateOptionDataClass.prototype = {
1241 visible : undefined,
1247 separateAfter : false,
1248 show : function( elm ){
1249 if( this.elm === elm ) return;
1251 elm = document.createElement( 'div' );
1252 elmBox.appendChild( elm );
1253 elm.appendChild( document.createElement( 'span' ) );
1254 elm.appendChild( document.createElement( 'kbd' ) );
1257 this.option.title( this.title );
1258 this.option.visible( !!this.visible );
1259 elm.lastChild.innerHTML = this.shortcut;
1260 elm.style.borderStyle = this.border === true ? 'solid' : 'none';
1262 this.node = nodeBox.createNode( elm, false, true, 'menubar-option-hover', 'pointer' );
1263 this.node.disabled( !this.visible );
1271 this.callback.call( this.thisObject || this.option, Util.getIndex( this.menuData.optionDataList, this ) );
1273 remove : function(){
1274 var list = PrivateOptionDataClass.list;
1275 list.splice( Util.getIndex( list, this ), 1 );
1278 PrivateOptionDataClass.list = [];
1279 PrivateOptionDataClass.get = function( OptionOrElm ){
1280 var list = PrivateOptionDataClass.list,
1285 if( data.option === OptionOrElm || data.elm === OptionOrElm ) return data;
1290 /** -----------------------------------------
1293 var OptionClass = function( menuData, title, shortcut, callback, visible, separateAfter, thisObject ){
1294 PrivateOptionDataClass.list.push( new PrivateOptionDataClass( menuData, this, title, shortcut, callback, visible, separateAfter, thisObject ) );
1296 OptionClass.prototype = {
1297 title: function( v ){
1298 var data = PrivateOptionDataClass.get( this );
1299 if( Type.isString( v ) === true ){
1301 if( data.elm ) data.elm.firstChild.innerHTML = v;
1305 visible : function( v ){
1306 var data = PrivateOptionDataClass.get( this );
1307 if( Type.isBoolean( v ) === true ){
1309 data.elm && Util.toggleClass( data.elm, 'menubar-option-disabled', !v );
1311 return data.visible;
1314 /** -----------------------------------------
1317 var AsyncOptionClass = function( menuData, callback, visible, separateAfter, thisObject ){
1318 var data = new PrivateOptionDataClass( menuData, this, null, null, callback, visible, separateAfter, thisObject );
1319 data.show = AsyncOptionClass.show;
1320 data.hide = AsyncOptionClass.hide;
1321 PrivateOptionDataClass.list.push( data );
1323 AsyncOptionClass.prototype = {
1324 title : function(){},
1325 visible : OptionClass.prototype.visible
1327 AsyncOptionClass.show = function( elm ){
1328 if( this.elm === elm ) return;
1330 elm = document.createElement( 'div' );
1331 elmBox.appendChild( elm );
1332 elm.appendChild( document.createElement( 'span' ) );
1333 elm.appendChild( document.createElement( 'kbd' ) );
1336 elm.className = 'loading';
1337 elm.style.height = '90px';
1338 elm.firstChild.innerHTML = this.elm.lastChild.innerHTML = '';
1339 elm.style.borderStyle = this.border === true ? 'solid' : 'none';
1343 AsyncOptionClass.hide = function(){
1344 this.elm.className = '';
1345 this.elm.style.height = '';
1349 /** -----------------------------------------
1350 * MenuPrivateDataClass
1352 var MenuPrivateDataClass = function( menu, title ){
1354 this.elm = document.createElement( 'div' );
1355 this.optionDataList = [];
1357 elmBar.appendChild( this.elm );
1358 this.elm.className = ELM_ITEM_CLASSNAME;
1359 this.elm.innerHTML = title;
1361 MenuPrivateDataClass.prototype = {
1368 optionDataList : null,
1370 this.elm.style.left = ( menuW * Util.getIndex( MenuPrivateDataClass.list, this ) ) + 'px';
1371 this.node = nodeBar.createNode( this.elm, false, false, ELM_ITEM_CLASSNAME + '-hover', 'pointer' );
1372 // this.node.addEventListener( 'click', this.onClick, this );
1373 this.node.addEventListener( 'click', this.onClick, this );
1377 while( o = this.optionDataList.shift() ) o.remove();
1381 onClick : function( e ){
1382 if( currentMenu !== this.menu ){
1383 currentMenu && currentMenu.hide();
1384 currentMenu = this.menu;
1388 onOptionClick : function( e ){
1389 var target = e.target,
1390 i = target.nodeIndex(),
1391 option = this.optionDataList[ i ];
1392 if( target === nodeBox ) return true;
1396 MenuPrivateDataClass.list = [];
1397 MenuPrivateDataClass.get = function( menu ){
1398 var list = MenuPrivateDataClass.list,
1401 if( list[ --i ].menu === menu ) return list[ i ];
1406 /** -----------------------------------------
1409 var MenuClass = function( title ){
1410 MenuPrivateDataClass.list.push( new MenuPrivateDataClass( this, title ) );
1412 MenuClass.prototype = {
1414 data = MenuPrivateDataClass.get( this );
1415 if( data.visible === true ) return;
1417 data.elm.className = ELM_ITEM_CLASSNAME + '-focus';
1420 elmBox = document.createElement( 'div' );
1421 elmBar.appendChild( elmBox );
1422 elmBox.className = 'menubar-option-box';
1423 nodeBox = nodeBar.createNode( elmBox, false, false, 'menubar-option-box-hover' );
1425 nodeBox.disabled( false );
1426 elmBar.parentNode.insertBefore( elmBox, elmBar.nextSibling ); // ie6 では elmBar の 子にすると 選択肢が表示されない
1428 nodeBox.setPosition( data.node.x(), barH );
1431 children = elmBox.childNodes,
1432 list = data.optionDataList
1434 while( l < children.length ){
1435 elmBox.removeChild( elmBox.firstChild );
1437 for( i = 0; i < l; ++i ){
1438 list[ i ].show( children[ i ] );
1442 nodeBar.addEventListener( 'mouseout', this.hide, this );
1443 nodeBox.addEventListener( 'click', data.onOptionClick, data );
1444 data.visible = true;
1447 data = MenuPrivateDataClass.get( this );
1448 if( data.visible === false ) return;
1450 data.elm.className = ELM_ITEM_CLASSNAME;
1451 for( var i = data.optionDataList.length; i; ){
1452 data.optionDataList[ --i ].hide();
1454 elmBar.parentNode.removeChild( elmBox );
1455 nodeBox.disabled( true );
1457 nodeBar.removeEventListener( 'mouseout', this.hide );
1458 nodeBox.removeEventListener( 'click', data.onOptionClick );
1459 data.visible = false;
1462 createOption: function( title, shortcut, callback, visible, separateBefore, separateAfter, thisObject ){
1463 var data = MenuPrivateDataClass.get( this ),
1464 before = data.optionDataList[ data.optionDataList.length - 1 ],
1465 ret = new OptionClass( data, title, shortcut, callback, visible, separateAfter, thisObject ),
1466 dataOption = PrivateOptionDataClass.get( ret );
1467 if( before ) before.border = separateBefore === true || before.separateAfter === true;
1468 data.optionDataList.push( dataOption );
1469 if( data.visible === true ){
1475 createAsyncOption: function( onOpen, visible, separateBefore, separateAfter, thisObject ){
1476 var data = MenuPrivateDataClass.get( this ),
1477 before = data.optionDataList[ data.optionDataList.length -1 ],
1478 ret = new AsyncOptionClass( data, onOpen, visible, separateAfter, thisObject ),
1479 dataOption = PrivateOptionDataClass.get( ret );
1480 if( before ) before.border = separateBefore === true || before.separateAfter === true;
1481 data.optionDataList.push( dataOption );
1482 data.visible === true && dataOption.show();
1485 remove : function( option ){
1486 var data = MenuPrivateDataClass.get( this ),
1487 optionData = PrivateOptionDataClass.get( option ),
1488 i = Util.getIndex( data.optionDataList, optionData );
1489 if( i === -1 ) return;
1491 data.optionDataList.splice( i, 1 );
1493 data.visible === true && elmBox.removeChild( optionData.elm ) && optionData.hide();
1494 optionData.remove();
1496 !( option instanceof AsyncOptionClass ) && data.optionDataList.length === 0 && this.hide();
1501 id : 'MENU_BAR_CONTROL',
1504 elmBar = document.getElementById( 'menu-bar' );
1505 nodeBar = eventRoot.createNode( elmBar, false, false, 'menu-bar-hover' );
1507 MENU_BAR_CONTROL.QUIT = MENU_BAR_CONTROL.createItem( 'Quit' );
1508 MENU_BAR_CONTROL.EDIT = MENU_BAR_CONTROL.createItem( 'Edit' );
1509 MENU_BAR_CONTROL.WINDOW = MENU_BAR_CONTROL.createItem( 'Window' );
1510 MENU_BAR_CONTROL.HELP = MENU_BAR_CONTROL.createItem( 'Help' );
1512 var size = Util.getElementSize( MenuPrivateDataClass.list[ 0 ].elm );
1514 barH = MENU_BAR_CONTROL.h = size.height;
1516 elmBar.style.top = ( - barH ) + 'px';
1517 $( elmBar ).animate( { top: 0 } );
1519 delete MENU_BAR_CONTROL.init;
1522 for( var i = MenuPrivateDataClass.list.length; i; ) MenuPrivateDataClass.list[ --i ].open();
1523 delete MENU_BAR_CONTROL.open;
1527 while( data = MenuPrivateDataClass.list.shift() ) data.close();
1529 MenuPrivateDataClass.list = elmBar = layerBox = elmBox = null;
1530 MENU_BAR_CONTROL.kill = kill;
1531 MENU_BAR_CONTROL.kill();
1533 createItem : function( title ){
1534 return new MenuClass( title );
1536 busy : function( _busy ){
1539 onWindowResize: function( _windowW, _windowH ){
1550 /* ----------------------------------------
1554 var HISTORY_CONTROL = ( function() {
1562 * currentを控えてstackForward.push(current)
1563 * stackBack.pop()を実行してcurrentに
1565 if( stackBack.length === 0 ) return;
1567 var s = stackBack.pop();
1568 s.callback.apply( s.thisObj || {}, s.argBack );
1569 menubarBack.visible( stackBack.length !== 0 );
1570 SAVE_CONTROL.panelUpdated( stackBack.length !== 0 );
1572 stackForward.push( s );
1573 menubarForward.visible( true );
1576 if( stackForward.length === 0 ) return;
1578 var s = stackForward.pop();
1579 s.callback.apply( s.thisObj || {}, s.argForword );
1580 menubarForward.visible( stackForward.length !== 0 );
1582 stackBack.push( s );
1583 menubarBack.visible( true );
1584 SAVE_CONTROL.panelUpdated( true );
1586 var RecordClass = function( callback, argBack, argForword, destroy, opt_thisObject ){
1587 this.callback = callback;
1588 this.argBack = argBack;
1589 this.argForword = argForword;
1590 this.destroy = !!destroy;
1591 this.thisObj = opt_thisObject;
1593 RecordClass.prototype.kill = function( _callDestroy ){
1594 var _argBack = this.argBack,
1595 _argForword = this.argForword,
1600 if( _callDestroy !== true ) return;
1602 if( Type.isArray( _argBack ) === true ){ // isArray
1603 while( v = _argBack.shift() ){
1604 _callDestroy === true && Type.isFunction( v.destroy ) === true && v.destroy();
1607 if( Type.isArray( _argForword ) === true ){
1608 while( v = _argForword.shift() ){
1609 _callDestroy === true && Type.isFunction( v.destroy ) === true && v.destroy();
1615 app.addKeyEventListener( 'keydown', back, 90, false, true ); // ctrl + Z
1616 app.addKeyEventListener( 'keydown', forward, 90, true, true ); // ctrl + shift + Z
1617 app.addKeyEventListener( 'keydown', forward, 89, false, true ); // ctrl + Y
1619 delete HISTORY_CONTROL.init;
1622 menubarBack = MENU_BAR_CONTROL.EDIT.createOption( 'back', 'ctrl + z', back, false );
1623 menubarForward = MENU_BAR_CONTROL.EDIT.createOption( 'forward', 'ctrl + y', forward, false, false, true );
1625 delete HISTORY_CONTROL.open;
1629 while( s = stackBack.shift() ) s.kill( true );
1630 while( s = stackForward.shift() ) s.kill( true );
1631 menubarBack = menubarForward = stackBack = stackForward = null;
1633 saveState: function( _function, _argBack, _argForword, _onRecordDestroy, opt_thisObject ){
1634 stackBack.push( new RecordClass( _function, _argBack, _argForword, _onRecordDestroy, opt_thisObject ));
1635 menubarBack.visible( true );
1636 SAVE_CONTROL.panelUpdated( true );
1639 while( s = stackForward.shift() ) s.kill( s.destroy );
1640 menubarForward.visible( false );
1645 /* ----------------------------------------
1649 var SAVE_CONTROL = ( function(){
1650 var save, saveQuit, eXport, quit,
1657 PanelConsole.boot( Model.createPanel( {
1660 panelTimming : panelTimming,
1661 panelW : PANEL_CONTROL.w,
1662 panelH : PANEL_CONTROL.h,
1664 panelElementArray : PANEL_ELEMENT_ARRAY,
1668 function onSaveQuit(){
1669 // Editor.shutdown();
1672 function onExport(){
1674 comicID, panelID, panelTimming,
1675 PANEL_CONTROL.w, PANEL_CONTROL.h,
1676 2, // border, BackgroundImage
1682 delete SAVE_CONTROL.init;
1685 save = MENU_BAR_CONTROL.QUIT.createOption( 'save', 'ctrl + S', onSave, false );
1686 saveQuit = MENU_BAR_CONTROL.QUIT.createOption( 'save & quit', null, onSaveQuit, false, false, true );
1687 eXport = MENU_BAR_CONTROL.QUIT.createOption( 'export', null, onExport, true, false, true );
1688 quit = MENU_BAR_CONTROL.QUIT.createOption( 'quit', null, quit, true, true );
1690 delete SAVE_CONTROL.open;
1693 save = saveQuit = eXport = quit = null;
1694 SAVE_CONTROL.kill = kill;
1695 SAVE_CONTROL.kill();
1698 panelUpdated: function( _updated ){
1699 if( Type.isBoolean( _updated ) === true ){
1700 save.visible( _updated );
1701 saveQuit.visible( _updated );
1712 /* ----------------------------------------
1715 * - mouseEventListener
1717 var WINDOWS_CONTROL = ( function(){
1719 * 表示上手前にあるwindowは、WINDOW_DATA_LISTの先頭にあり、htmlでは後ろにある。
1721 var DEFAULT_MIN_WINDOW_WIDTH = 200,
1722 DEFAULT_MIN_WINDOW_HEIGHT = 200,
1723 WINDOW_DATA_LIST = [],
1724 WINDOW_BODY_BODER_SIZE = 1,
1733 var WindowPrivateData = function(){};
1734 WindowPrivateData.prototype = {
1736 menubarOption : null,
1764 init : function( win, bodyTempleteID, title, x, y, w, h, visible, closeEnabled, resizeEnabled, minWindowW, minWindowH ){
1766 this.bodyTempleteID = bodyTempleteID;
1772 this.visible = visible;
1773 this.closeEnabled = closeEnabled;
1774 this.resizeEnabled = resizeEnabled;
1775 this.minWindowW = minWindowW;
1776 this.minWindowH = minWindowH;
1778 WINDOW_DATA_LIST.push( this );
1780 create : function(){
1781 var win = this.window;
1782 this.elm = win.elm = elmWindowOrigin.cloneNode( true );
1783 this.menubarOption = MENU_BAR_CONTROL.WINDOW.createOption(
1784 ( this.visible !== true ? 'show ' : 'hide ' ) + this.title,
1785 null, this.onMenubarClick,
1794 onMenubarClick : function(){
1795 this.window[ this.visible === true ? 'close' : 'open' ]();
1797 update : function( x, y, w, h ){
1798 var win = this.window, bodyH;
1800 x = x !== undefined ? x : this.x;
1801 y = y !== undefined ? y : this.y;
1802 y = y > MENU_BAR_CONTROL.h ? y : MENU_BAR_CONTROL.h;
1803 w = w !== undefined ? w : this.w;
1804 h = h !== undefined ? h : this.h;
1806 this.nodeWindow.update( x, y, w, h );
1807 this.nodeHead && this.nodeHead.update( 0, 0, w, this.headerH );
1808 console.log( '************ hewader' + this.headerH )
1809 this.nodeBody.update( 0, this.headerH, w, this.bodyH = h - this.headerH - this.footerH );
1810 ( this.w !== w || this.h !== h ) && win.onResize && win.onResize( w, this.bodyH );
1817 firstOpen : function(){
1818 var win = this.window,
1819 elmHead = this.elmHead = Util.getElementsByClassName( this.elm, 'window-header' )[ 0 ];
1820 elmBody = this.elmBody = Util.getElementsByClassName( this.elm, 'window-body' )[ 0 ],
1821 elmClose = Util.getElementsByClassName( this.elm, 'window-close-button' )[ 0 ],
1822 elmFoot = Util.getElementsByClassName( this.elm, 'window-footer' )[ 0 ],
1823 elmResize = Util.getElementsByClassName( this.elm, 'window-resize-button' )[ 0 ],
1824 replaceID = this.bodyTempleteID;
1826 this.nodeWindow = nodeContainer.createNode( this.elm, false, true, 'window-wrapper-hover' );
1827 this.nodeWindow.addEventListener( 'mousemove', this.mousemove, this );
1828 this.nodeWindow.addEventListener( 'mousedown', this.mousedown, this );
1829 this.nodeWindow.addEventListener( 'mouseup', this.mouseup, this );
1830 this.nodeWindow.addEventListener( 'mouseout', this.mouseup, this );
1832 // this.nodeHead = this.nodeWindow.createNode( elmHead );
1833 win.title( this.title );
1835 this.nodeBody = this.nodeWindow.createNode( elmBody, false, true, null, '', true );
1836 replaceID && elmBody.appendChild( document.getElementById( replaceID ) );
1838 if( this.closeEnabled === true ){
1839 // this.nodeClose = this.nodeHead.createNode( elmClose );
1840 // this.nodeClose.addEventListener( 'mousedown', win.close, data );
1842 elmClose.parentNode.removeChild( elmClose );
1845 if( this.resizeEnabled === true ){
1846 // this.nodeFoot = this.nodeWindow.createNode( elmFoot );
1847 this.footerH = Util.getElementSize( elmFoot ).height; // this.nodeFoot.height();
1849 // this.nodeResize = this.nodeFoot.createNode( elmResize );
1850 // this.nodeResize.addEventListener( 'mousedrag', this.resizeDrag, data );
1852 elmFoot.parentNode.removeChild( elmFoot );
1855 this.update( this.x, this.y, this.w, this.h );
1856 if( win.onFirstOpen ){
1857 win.onFirstOpen( this.w, this.bodyH, this.nodeBody );
1858 delete win.onFirtOpen;
1861 this.firstOpen = null;
1863 onFadeIn : function(){
1864 var data = WindowPrivateData.get( this ),
1866 data.firstOpen && data.firstOpen();
1867 win.onOpen && win.onOpen( data.w, data.bodyH );
1868 data.nodeWindow.disabled( false );
1871 onFadeOut : function(){
1872 var data = WindowPrivateData.get( this ),
1874 elmRoot.removeChild( data.elm );
1875 win.onClose && app.addAsyncCall( win.onClose, null, win );
1877 mousedown : function( e ){
1878 currentWindowData !== this && this.goFront();
1882 if( this.resizeEnabled === true && this.w - 20 <= x && x < this.w && this.headerH + this.bodyH < y && y <= this.h ){
1883 this.isResizing = true;
1884 //this.startX = this.x;
1885 //this.startY = this.y;
1886 this.startW = this.w;
1887 this.startH = this.h;
1890 // app.updateCoursor( 'nw-resize' );
1891 this.nodeWindow.cursor( 'nw-resize' );
1895 // if( x < 0 || y < 0 || this.w < x || this.headerH < y ) return false;
1896 if( this.closeEnabled === true && this.w - closeButtonWidth < x && y < this.headerH ){
1897 this.window.close();
1901 if( y < this.headerH ){
1902 this.isDragging = true;
1903 this.startX = this.x;
1904 this.startY = this.y;
1905 this.startW = this.w;
1906 this.startH = this.h;
1910 // app.updateCoursor( 'move' );
1911 this.nodeWindow.cursor( 'move' );
1915 mouseup : function( e ){
1916 if( this.isResizing === true || this.isDragging === true ){
1917 this.isDragging = this.isResizing = false;
1920 this.nodeWindow.cursor( '' );
1922 mousemove : function( e ){
1923 currentWindowData !== this && this.goFront();
1928 if( this.isResizing === true ){
1929 w = this.startW + x - this.offsetX;
1930 h = this.startH + y - this.offsetY;
1931 this.w = w = w < this.minWindowW ? this.minWindowW : w;
1932 this.h = h = h < this.minWindowH ? this.minWindowH : h;
1933 this.elm.style.width = w + 'px';
1934 this.elm.style.height = h + 'px';
1937 if( this.isDragging === true ){
1938 this.x = x = this.startX + x - this.offsetX;
1939 this.y = y = this.startY + y - this.offsetY;
1940 this.elm.style.left = x + 'px';
1941 this.elm.style.top = y + 'px';
1944 // if( e.hit === false || ( this.headerH < layerY && layerY < this.headerH + this.bodyH ) ) return false;
1945 this.nodeWindow.cursor( ( /*0 < layerX && layerX < this.w && 0 <= layerY &&*/ y <= this.headerH ) ? 'pointer' : '' );
1947 goFront : function(){
1948 currentWindowData = this;
1949 var i = nodeContainer.numNode() - 1;
1950 // console.log( this.nodeWindow.nodeIndex() + ' , ' + this.nodeWindow.numNode() )
1951 if( this.nodeWindow.nodeIndex() !== i ){
1952 this.nodeWindow.nodeIndex( i );
1953 elmRoot.appendChild( this.elm );
1957 return this.isDragging === true || this.isResizing === true;
1959 destroy : function(){
1963 WindowPrivateData.get = function( windowOrElement ){
1964 if( windowOrElement instanceof WindowPrivateData ) return windowOrElement;
1965 var list = WINDOW_DATA_LIST,
1970 if( data.window === windowOrElement || data.elm === windowOrElement ) return data;
1978 var WindowClass = function( bodyTempleteID, title, x, y, w, h, visible, closeEnabled, resizeEnabled, minWindowW, minWindowH ){
1979 ( new WindowPrivateData() ).init( this, bodyTempleteID, title, x, y, w, h, visible, closeEnabled, resizeEnabled, minWindowW, minWindowH );
1981 WindowClass.prototype = {
1984 var data = WindowPrivateData.get( this );
1985 if( data.visible === true ) return;
1987 data.visible = true;
1989 data.menubarOption.title( 'hide ' + data.title );
1991 // WINDOW_DATA_LIST.splice( Util.getIndex( WINDOW_DATA_LIST, data ), 1 );
1992 // WINDOW_DATA_LIST.unshift( data );
1993 currentWindowData = null;
1996 var data = WindowPrivateData.get( this );
1997 if( data.visible === false ) return;
1999 data.visible = false;
2000 $( data.elm ).fadeOut( data.onFadeOut );
2001 data.menubarOption.title( 'show ' + data.title );
2002 data.nodeWindow.disabled( true );
2004 title : function( _title ){
2005 if( Type.isString( _title ) === true ){
2006 var data = WindowPrivateData.get( this );
2007 data.elmHead.firstChild.innerHTML = data.title = _title;
2008 // data.nodeHead.mesure();
2009 //data.headerH = data.nodeHead.height();
2010 data.headerH = Util.getElementSize( data.elmHead ).height;
2014 createHeaderItem : function(){
2015 var data = WindowPrivateData.get( this ),
2016 elm = document.createElement( 'div' ),
2018 if( !data.nodeHead ) data.nodeHead = data.nodeWindow.createNode( data.elmHead, true, false );
2019 data.elmHead.appendChild( elm );
2020 elm.className = 'header-item finder-path';
2021 node = data.nodeHead.createNode( elm, false, true, 'header-item-hover', '' )
2022 // data.nodeHead.mesure();
2023 // data.headerH = data.nodeHead.height();
2025 data.headerH = Util.getElementSize( data.elmHead ).height;
2032 function openWindow( data ){
2033 if( data.visible !== true ) return;
2034 elmRoot.appendChild( data.elm );// appendした後に fadeIn() しないと ie で filterが適用されない.
2035 $( data.elm ).fadeIn( data.onFadeIn );
2040 id : 'WINDOWS_CONTROL',
2042 elmRoot = document.getElementById( 'window-container' );
2043 nodeContainer = eventRoot.createNode( elmRoot, true, false );
2044 elmWindowOrigin = app.fetchHTMLElement( 'windowTemplete' );
2045 closeButtonWidth = Util.getElementSize( Util.getElementsByClassName( elmWindowOrigin, 'window-close-button' )[ 0 ] ).width;
2047 delete WINDOWS_CONTROL.init;
2050 for( var i = WINDOW_DATA_LIST.length, data; i; ){
2051 data = WINDOW_DATA_LIST[ --i ];
2055 delete WINDOWS_CONTROL.open;
2059 onWindowResize : function( _windowW, _windowH ){
2064 createWindow : function( EXTENDS, bodyTempleteID, title, x, y, w, h, opt_visible, opt_closeEnabled, opt_resizeEnabled, opt_minWindowW, opt_minWindowH ){
2065 opt_visible = opt_visible !== false;
2066 opt_closeEnabled = opt_closeEnabled === true;
2067 opt_resizeEnabled = opt_resizeEnabled === true;
2068 opt_minWindowW = opt_minWindowW || ( w < DEFAULT_MIN_WINDOW_WIDTH ) ? w : DEFAULT_MIN_WINDOW_WIDTH;
2069 opt_minWindowH = opt_minWindowH || ( h < DEFAULT_MIN_WINDOW_HEIGHT ) ? h : DEFAULT_MIN_WINDOW_HEIGHT;
2071 var win = new WindowClass( bodyTempleteID, title, x, y, w, h, opt_visible, opt_closeEnabled, opt_resizeEnabled, opt_minWindowW, opt_minWindowH ),
2073 for( var key in EXTENDS ){
2074 win[ key ] = EXTENDS[ key ];
2076 if( Type.isUndefined( WINDOWS_CONTROL.init ) === true ){
2077 data = WindowPrivateData.get( win );
2086 /* ----------------------------------------
2090 var TOOL_BOX_WINDOW = ( function(){
2092 app.addKeyEventListener( 'keydown', addImage, 73, false, true );
2093 app.addKeyEventListener( 'keydown', addText, 84, false, true );
2094 app.addKeyEventListener( 'keydown', switchGrid, 71, false, true );
2096 function addImage(){
2097 // IMAGE_EXPLORER_WINDOW.open();
2098 app.addAsyncCall( IMAGE_EXPLORER_WINDOW.open, null, IMAGE_EXPLORER_WINDOW );
2099 //TOOL_BOX_WINDOW.bodyBackOrForward( true );
2102 app.addAsyncCall( PANEL_ELEMENT_CONTROL.createTextElement );
2104 function switchGrid(){
2105 app.addAsyncCall( GRID_CONTROL.update, null, GRID_CONTROL );
2107 function popupHelp(){
2108 //.bodyBackOrForward( true );
2109 app.addAsyncCall( HELP_DOCUMENTS_WINDOW.open, null, HELP_DOCUMENTS_WINDOW );
2111 function editBG( e ){
2112 //TOOL_BOX_WINDOW.bodyBackOrForward( true );
2113 app.addAsyncCall( INFOMATION_WINDOW.open, null, INFOMATION_WINDOW );
2116 return WINDOWS_CONTROL.createWindow(
2119 MENU_BAR_CONTROL.EDIT.createOption( 'Add Image', 'ctrl + I', addImage, true, true, false );
2120 MENU_BAR_CONTROL.EDIT.createOption( 'Add Text', 'ctrl + T', addText, true, false, true );
2121 MENU_BAR_CONTROL.EDIT.createOption( 'show Grid', 'ctrl + G', switchGrid, true, true, true );
2123 onFirstOpen: function( x, y, nodeBody ){
2124 nodeBody.createNode( document.getElementById( 'toolbox-add-image-button' ), false, true, 'button-hover', 'pointer' ).addEventListener( 'click', addImage );
2125 nodeBody.createNode( document.getElementById( 'toolbox-add-text-button' ), false, true, 'button-hover', 'pointer' ).addEventListener( 'click', addText );
2126 nodeBody.createNode( document.getElementById( 'toolbox-edit-bg-button' ), false, true, 'button-hover', 'pointer' ).addEventListener( 'click', editBG );
2127 nodeBody.createNode( document.getElementById( 'toolbox-switch-grid' ), false, true, 'button-hover', 'pointer' ).addEventListener( 'click', switchGrid );
2128 nodeBody.createNode( document.getElementById( 'toolbox-popup-help-button' ), false, true, 'button-hover', 'pointer' ).addEventListener( 'click', popupHelp );
2129 // nodeBody.createNode( document.getElementById( 'toolbox-add-text-button' ), false, true, 'button-hover', 'pointer' ).addEventListener( 'click', addText );
2132 'toolbox-window', 'Tool box', 0, 215, 110, 290, true
2137 /* ----------------------------------------
2141 var IMAGE_EXPLORER_WINDOW = ( function(){
2144 function onFileSelect( _file ){
2145 // 他の image ファイルも許可する?
2146 if( Driver.isPettanrFileInstance( _file ) === true ){
2147 if( _file.getType() === FILE_TYPE.PICTURE ){
2148 PANEL_ELEMENT_CONTROL.onImageSelect( FileAPI.getFileData( _file ) );
2153 return WINDOWS_CONTROL.createWindow(
2155 onInit: function(){},
2156 onFirstOpen: function( _w, _h, nodeBody ){
2157 tree = FileAPI.createTree( FILE_DATA_PICTURE_ROOT );
2158 var _root = tree.getRootFile(),
2159 _myPic = _root.getChildFileByIndex( 0 ),
2160 _pic = _root.getChildFileByIndex( 1 );
2161 _myPic.getSeqentialFiles();
2162 _pic.getSeqentialFiles();
2166 finder = app.createFinder(
2170 PANEL_ELEMENT_CONTROL.onImageSelect
2172 finder.createPath( IMAGE_EXPLORER_WINDOW.createHeaderItem() );
2174 onOpen: function( _w, _h ){
2175 finder.resize( _w, _h );
2177 onResize: function( _w, _h ){
2178 finder.resize( _w, _h );
2181 null, 'Album', 0, 215, 600, 350, false, true, true, 300, 300
2186 /* ----------------------------------------
2190 var INFOMATION_WINDOW = ( function(){
2191 var backgroundInfomationElm;
2193 return WINDOWS_CONTROL.createWindow(
2195 onFirstOpen: function( _w, _h ){
2196 backgroundInfomationElm = $( '#panel-background-information');
2198 onResize: function( _w, _h ){
2200 update: function( currentElement ){
2204 'infomation-window', 'Infomation', 0, 30, 200, 180, true
2208 /* ----------------------------------------
2212 var HELP_DOCUMENTS_WINDOW = ( function(){
2217 currentPageIndex = 0,
2221 function onAjaxStart( _pageIndex ){
2222 delete asyncOption.callback;
2224 currentPageIndex = _pageIndex || currentPageIndex;
2225 if( onHelpLoad !== null ){
2235 var onHelpLoad = function( _xml ){
2236 var jqXML = $( _xml ),
2237 helpTitle = jqXML.find( 'pages' ).eq( 0 ).attr( 'title' ),
2238 elmRoot = document.createElement( 'div' ),
2239 elmNavi = document.createElement( 'div' ),
2240 elmItemOrigin = document.createElement( 'a' ),
2241 elmPages = document.createElement( 'div' ),
2242 elmPageOrigin = document.createElement( 'div' ),
2243 elmTitleOrigin = document.createElement( 'h2' ),
2245 elmRoot.className = 'multi-page-container clearfix';
2246 elmNavi.className = 'sidenavi';
2247 elmItemOrigin.className = 'sidenavi-item';
2248 elmItemOrigin.href = '#';
2249 elmPages.className = 'page-contents';
2250 elmPageOrigin.className = 'page-content main';
2251 elmPageOrigin.appendChild( elmTitleOrigin);
2253 MENU_BAR_CONTROL.HELP.remove( asyncOption );
2256 jqXML.find( 'page' ).each( function(){
2257 var xmlPage = $( this ),
2258 title = xmlPage.attr( 'title' ),
2259 content = xmlPage.text();
2261 elmItemOrigin.innerHTML = title;
2262 elmNavi.appendChild( elmItemOrigin.cloneNode( true ) );
2264 elmTitleOrigin.innerHTML = title;
2266 elmPage = elmPageOrigin.cloneNode( true );
2267 elmPage.innerHTML = content;
2269 Util.cleanElement( elmPage);
2271 if( elmPage.childNodes.length > 0 ){
2272 elmPage.insertBefore( elmTitleOrigin.cloneNode( true ), elmPage.childNodes[0]);
2274 elmPage.appendChild( elmTitleOrigin.cloneNode( true ));
2276 elmPages.appendChild( elmPage );
2278 MENU_BAR_CONTROL.HELP.createOption( title, null, onSelectionClick, true );
2281 elmRoot.appendChild( elmNavi );
2282 elmRoot.appendChild( elmPages );
2283 jqAjaxContents.removeClass( 'loading' ).append( elmRoot );
2285 jqNaviItems = jqAjaxContents.find( 'a.' + elmItemOrigin.className ).click( onNaviClick );
2286 jqPages = jqAjaxContents.find( '.page-content' );
2287 jqPages.find( 'a' ).click( onInnerLinkClick );
2289 app.addAsyncCall( jumpPage );
2291 function onSelectionClick( _pageIndex ){
2292 HELP_DOCUMENTS_WINDOW.open();
2293 jumpPage( _pageIndex );
2295 function jumpPage( _index ){
2296 if( Type.isNumber( _index ) === true && 0 <= _index && _index < numPage && currentPageIndex !== _index ){
2297 currentPageIndex = _index;
2299 jqNaviItems.removeClass( 'current' ).eq( currentPageIndex ).addClass( 'current' );
2300 jqPages.hide().eq( currentPageIndex ).show();
2302 function onNaviClick( e ){
2304 jumpPage( Util.getChildIndex( this.parentNode, this ) );
2307 function onInnerLinkClick( e ){
2308 var jump = ( this.href || '' ).split( '#jump' ),
2311 jumpPage( '' + parseFloat( n ) === n ? parseFloat( n ) : -1 );
2314 return WINDOWS_CONTROL.createWindow(
2317 asyncOption = MENU_BAR_CONTROL.HELP.createAsyncOption( onAjaxStart );
2318 jqAjaxContents = $( HELP_DOCUMENTS_WINDOW.elm ).find( '.window-body' ).addClass( 'loading' ).css( { overflow: 'auto' } );
2320 onFirstOpen: function( _w, _h ){
2321 jqAjaxContents.css( { height: _h } );
2322 onAjaxStart !== null && onAjaxStart();
2324 onResize: function( _w, _h ){
2325 jqAjaxContents && jqAjaxContents.css( { height: _h } );
2328 null, 'Help', 0, 215, 400, 350, false, true, true, 300, 300
2332 /* ----------------------------------------
2335 * - panelResizeListener
2337 var GRID_CONTROL = ( function(){
2339 urlBG = "url('images/grid.gif')",
2344 elmGrid = document.getElementById( 'grid' );
2345 delete GRID_CONTROL.init;
2348 delete GRID_CONTROL.open;
2353 onPanelResize: function( _panelX, _panelY ){
2354 elmGrid.style.backgroundPosition = [ _panelX % 10, 'px ', _panelY % 10, 'px' ].join( '' );
2355 elmGrid.style.height = windowH +'px';
2357 enabled: function(){
2361 $( elmGrid ).stop().css( {
2364 })[ visible === true ? 'fadeOut' : 'fadeIn' ]();
2368 if( visible === true && urlBG !== null ){
2369 elmGrid.style.backgroundImage = urlBG;
2377 /* ----------------------------------------
2378 * WHITE_GLASS_CONTROL
2379 * - panelResizeListener
2381 var WHITE_GLASS_CONTROL = ( function(){
2382 var styleTop, styleLeft, styleRight, styleBottom;
2386 styleTop = document.getElementById( 'whiteGlass-top' ).style;
2387 styleLeft = document.getElementById( 'whiteGlass-left' ).style;
2388 styleRight = document.getElementById( 'whiteGlass-right' ).style;
2389 styleBottom = document.getElementById( 'whiteGlass-bottom' ).style;
2390 delete WHITE_GLASS_CONTROL.init;
2392 onPanelResize: function( _panelX, _panelY, _panelW, _panelH ){
2395 marginTop = _panelY,
2396 marginBottom = windowH -_h -marginTop,
2398 rightWidth = windowW -_w -marginX;
2400 styleTop.height = ( marginTop < 0 ? 0 : marginTop ) + 'px';
2402 styleLeft.top = marginTop + 'px';
2403 styleLeft.width = ( marginX < 0 ? 0 : marginX ) + 'px';
2404 styleLeft.height = ( _h + marginBottom ) + 'px';
2406 styleRight.top = marginTop + 'px';
2407 styleRight.left = _w +marginX + 'px';
2408 styleRight.width = ( rightWidth < 0 ? 0 : rightWidth ) + 'px';
2409 styleRight.height = ( _h + marginBottom ) + 'px';
2411 styleBottom.top = ( _h +marginTop ) + 'px';
2412 styleBottom.left = marginX + 'px';
2413 styleBottom.width = _w + 'px';
2414 styleBottom.height = ( marginBottom < 0 ? 0 : marginBottom ) + 'px';
2420 /* --------------------------------------------------------------------------------------------
2422 * - mouseEventListener
2424 var PanelResizerClass = function( id, isTop ){
2428 PanelResizerClass.BORDER_SIZE = 2;
2429 PanelResizerClass.HEIGHT = 30;
2430 PanelResizerClass.prototype = {
2435 x : - PanelResizerClass.BORDER_SIZE / 2,
2438 h : PanelResizerClass.HEIGHT,
2448 this.node = PANEL_CONTROL.node.createNode( document.getElementById( this.id ), false, false, 'panel-resizer-hover', 'pointer' );
2449 this.node.addEventListener( 'mousedown', this.mousedown, this );
2450 this.style = document.getElementById( this.id ).style;
2451 this.y = this.isTop === true ? ( -5 - PanelResizerClass.HEIGHT - PanelResizerClass.BORDER_SIZE ) : 0;
2453 mousedown : function( e ){
2455 var x = e.layerX, // - this.panelX,
2456 y = e.layerY; // - this.panelY;
2458 this.startY = this.panelY;
2459 this.startH = this.panelH;
2460 this.isDragging = true;
2461 // app.updateCoursor( 'n-resize' );
2462 this.node.addEventListener( 'mousemove', this.mousemove, this );
2463 this.node.addEventListener( 'mouseup', this.mouseup, this );
2464 this.node.cursor( 'n-resize' );
2467 mousemove : function( e ){
2468 var move = e.layerY - this.offsetY,
2471 if( this.isTop === true ){
2472 if( this.panelH - move < MIN_PANEL_HEIGHT ){
2473 move = this.panelH - MIN_PANEL_HEIGHT;
2475 PANEL_CONTROL.resizeElement( true, this.panelX, this.panelY + move, this.panelW, this.panelH - move );
2477 h = this.startH + move;
2478 if( 0 < h && h < windowH - this.panelY - PanelResizerClass.HEIGHT - 5 - PanelResizerClass.BORDER_SIZE ){
2479 PANEL_CONTROL.resizeElement( false, this.panelX, this.panelY, this.panelW, h < MIN_PANEL_HEIGHT ? MIN_PANEL_HEIGHT : h );
2484 mouseup : function( e ){
2485 if( this.isDragging !== true ) return;
2486 ( this.startY !== this.panelY || this.startH !== this.panelH ) &&
2487 HISTORY_CONTROL.saveState(
2489 [ undefined, this.startY, undefined, this.startH ],
2490 [ undefined, this.panelY, undefined, this.panelH ],
2493 this.isDragging = false;
2494 var move = e.layerY - this.offsetY,
2497 if( this.isTop === true ){
2498 if( this.panelH - move < MIN_PANEL_HEIGHT ){
2499 move = this.panelH - MIN_PANEL_HEIGHT;
2501 PANEL_CONTROL.resize( true, this.panelX, this.panelY + move, this.panelW, this.panelH - move );
2503 h = this.startH + move;
2504 if( 0 < h && h < windowH - this.panelY - PanelResizerClass.HEIGHT - 5 - PanelResizerClass.BORDER_SIZE ){
2505 PANEL_CONTROL.resize( false, this.panelX, this.panelY, this.panelW, h < MIN_PANEL_HEIGHT ? MIN_PANEL_HEIGHT : h );
2508 // app.updateCoursor( '' );
2509 this.node.removeEventListener( 'mousemove', this.mousemove );
2510 this.node.removeEventListener( 'mouseup', this.mouseup );
2511 this.node.cursor( 'pointer' );
2513 restoreState : function( x, y, w, h ){
2514 PANEL_CONTROL.resize( this.isTop, x || this.panelX, y || this.panelY, w || this.panelW, h || this.panelH );
2517 return this.isDragging;
2519 onPanelResize : function( x, y, w, h ){
2522 if( this.panelW !== w ){
2523 this.style.width = ( w + 2 ) + 'px';
2527 this.y = this.isTop === true ? this.y : ( this.panelH + 5 + PanelResizerClass.BORDER_SIZE );
2528 this.w = this.panelW + 2;
2529 this.node.update( undefined, undefined, this.w );
2533 /* ----------------------------------------
2536 * - mouseEventListener
2538 * panel-border の表示と onPanelResize の通知.
2542 var PANEL_CONTROL = ( function(){
2543 var elmPanel, stylePanel,
2545 DEFAULT_PANEL_WIDTH = 400,
2546 DEFAULT_PANEL_HEIGHT = 300,
2548 offsetX, offsetY, startX, startY,
2550 isDraggable = false,
2551 resizerTop = new PanelResizerClass( 'panel-resizer-top', true ),
2552 resizerBottom = new PanelResizerClass( 'panel-resizer-bottom', false );
2554 app.addKeyEventListener( 'keychange', onSpaceUpdate, 32, false, false );
2556 function onSpaceUpdate( e ){
2557 if( e.type === 'keyup' ){
2558 app.isCurrentInteractiveEventListener( null ) === true && app.updateCoursor( '' );
2559 isDraggable = false;
2561 app.isCurrentInteractiveEventListener( null ) === true && app.updateCoursor( 'move' );
2568 id : 'PANEL_CONTROL',
2576 elmPanel = this.elm = document.getElementById( 'panel-tools-container' );
2577 nodePanel = this.node = eventRoot.createNode( elmPanel, true, false );
2580 resizerBottom.init();
2582 stylePanel = elmPanel.style;
2583 delete PANEL_CONTROL.init;
2585 open: function( _panelW, _panelH, _borderSize ){
2586 PANEL_CONTROL.w = Type.isFinite( _panelW ) === true ? _panelW : DEFAULT_PANEL_WIDTH;
2587 PANEL_CONTROL.h = Type.isFinite( _panelH ) === true ? _panelH : DEFAULT_PANEL_HEIGHT;
2588 borderSize = Type.isFinite( _borderSize ) === true ? _borderSize : borderSize;
2590 delete PANEL_CONTROL.open;
2595 resize: function( isResizerTopAction, x, y, w, h ){
2596 PANEL_CONTROL.x = x = x !== undefined ? x : PANEL_CONTROL.x;
2597 PANEL_CONTROL.y = y = y !== undefined ? y : PANEL_CONTROL.y;
2598 PANEL_CONTROL.w = w = w !== undefined ? w : PANEL_CONTROL.w;
2599 PANEL_CONTROL.h = h = h !== undefined ? h : PANEL_CONTROL.h;
2601 nodePanel.update( x - borderSize, y - borderSize, w, h );
2604 resizerTop.onPanelResize( x, y, w, h );
2605 resizerBottom.onPanelResize( x, y, w, h );
2606 GRID_CONTROL.onPanelResize( x, y );
2607 WHITE_GLASS_CONTROL.onPanelResize( x, y, w, h );
2608 PANEL_ELEMENT_CONTROL.onPanelResize( x, y, w, h, isResizerTopAction === true );
2610 resizeElement : function( isResizerTopAction, x, y, w, h ){
2611 stylePanel.cssText = [ 'left:', ( x - borderSize ), 'px;',
2612 'top:', ( y - borderSize ), 'px;',
2614 'height:', h, 'px' ].join( '' );
2615 // PANEL_RESIZER_TOP.onPanelResize( x, y, w, h );
2616 // PANEL_RESIZER_BOTTOM.onPanelResize( x, y, w, h );
2617 GRID_CONTROL.onPanelResize( x, y );
2618 WHITE_GLASS_CONTROL.onPanelResize( x, y, w, h );
2619 PANEL_ELEMENT_CONTROL.onPanelResize( x, y, w, h, isResizerTopAction );
2621 onWindowResize: function( _windowW, _windowH ){
2622 PANEL_CONTROL.x = Math.floor( ( _windowW - PANEL_CONTROL.w ) / 2 );
2623 PANEL_CONTROL.y = Math.floor( ( _windowH - PANEL_CONTROL.h ) / 2 );
2624 PANEL_CONTROL.resize();
2626 mousemove: function( _mouseX, _mouseY ){
2627 if( isDraggable === true && isDragging === true ){
2628 PANEL_CONTROL.resize( false, startX + _mouseX - offsetX, startY + _mouseY - offsetY );
2631 mouseup: function( _mouseX, _mouseY ){
2632 if( isDraggable === true ){
2634 app.updateCoursor( '' );
2637 mousedown: function( _mouseX, _mouseY ){
2638 if( isDraggable === true ){
2641 startX = PANEL_CONTROL.x;
2642 startY = PANEL_CONTROL.y;
2644 app.updateCoursor( 'move' );
2649 return isDragging === true;
2654 /* --------------------------------------------------------------------------------------------
2656 * - panelElementOperator
2658 var TailOperator = ( function(){
2665 DEG_TO_RAD = Math.PI / 180,
2666 RAD_TO_DEG = 1 / DEG_TO_RAD,
2670 balloonW, balloonH, balloonA, radA,
2676 var elm = document.getElementById( 'balloon-tail-mover' );
2677 SIZE = Util.getElementSize( elm ).width;
2678 styleMover = elm.style;
2679 delete TailOperator.init;
2681 update: function ( _w, _h, _a ){
2682 balloonW = _w !== undefined ? _w : balloonW;
2683 balloonH = _h !== undefined ? _h : balloonH;
2684 balloonA = _a !== undefined ? _a : balloonA;
2685 radA = ( balloonA - 90 ) * DEG_TO_RAD;
2686 tailX = FLOOR( ( ( COS( radA ) / 2 + 0.5 ) * ( balloonW + SIZE )) - SIZE / 2 );
2687 tailY = FLOOR( ( ( SIN( radA ) / 2 + 0.5 ) * ( balloonH + SIZE )) - SIZE / 2 );
2688 styleMover.left = tailX + 'px';
2689 styleMover.top = tailY + 'px';
2691 show: function( _currentText ){
2693 * visibilityのほうがいい, display:none だと ie で描画が狂う
2695 styleMover.visibility = '';
2696 currentText = _currentText;
2697 TailOperator.update( _currentText.w, _currentText.h, _currentText.a );
2700 styleMover.visibility = 'hidden';
2703 hitTest: function( _mouseX, _mouseY ){
2704 var _x = tailX -SIZE / 2,
2705 _y = tailY -SIZE / 2,
2706 ret = _x <= _mouseX && _y <= _mouseY && _x + SIZE >= _mouseX && _y + SIZE >= _mouseY;
2707 ret === true && app.updateCoursor( 'move' );
2710 onStart: function( _mouseX, _mouseY ){
2711 if( currentText.type !== PANEL_ELEMENT_TYPE_TEXT ) return false;
2712 if( TailOperator.hitTest( _mouseX, _mouseY ) === true ){
2715 startA = currentText.a;
2720 onDrag: function( _mouseX, _mouseY ){
2721 _mouseX = _mouseX - w / 2;
2722 _mouseY = _mouseY - h / 2; //Balloonの中心を0,0とする座標系に変換
2723 TailOperator.update( w, h,
2725 ATAN( _mouseY / _mouseX ) * RAD_TO_DEG + ( _mouseX > 0 ? 90 : 270 ) :
2726 _mouseY > 0 ? 180 : 0
2728 currentText && currentText.angle( FLOOR( balloonA + 0.5 ) );
2729 CONSOLE_CONTROLER.update( currentText );
2731 onFinish: function(){
2732 startA !== currentText.a && PanelElementOperatorManager.saveStatus( undefined, undefined, w, h, startA );
2733 startA !== currentText.a && PanelElementOperatorManager.resize( undefined, undefined, w, h, currentText.a );
2735 onCancel: function(){
2736 currentText.angle( startA );
2737 PanelElementOperatorManager.resize( undefined, undefined, w, h, startA );
2742 /* --------------------------------------------------------------------------------------------
2744 * - panelElementOperator
2746 var ResizeOperator = ( function(){
2747 var HIT_AREA = MOUSE_HIT_AREA,
2748 POSITION_ARRAY = [],
2751 { cursor: 'n-resize', v: 3 },
2752 { cursor: 'e-resize', h: 2 },
2753 { cursor: 'e-resize', h: 1 },
2754 { cursor: 'n-resize', v: 0 },
2755 { cursor: 'nw-resize', h: 5, v: 6, vh: 7 },
2756 { cursor: 'ne-resize', h: 4, v: 7, vh: 6 },
2757 { cursor: 'ne-resize', h: 7, v: 4, vh: 5 },
2758 { cursor: 'nw-resize', h: 6, v: 5, vh: 4 }
2771 var RESIZE_WORK_ARRAY = [
2772 { x: 0, w: 0, y: 1, h: -1}, //top
2773 { x: 1, w: -1, y: 0, h: 0}, //left
2774 { x: 0, w: 1, y: 0, h: 0}, //right
2775 { x: 0, w: 0, y: 0, h: 1}, //bottom
2776 { x: 1, w: -1, y: 1, h: -1}, //top-left
2777 { x: 0, w: 1, y: 1, h: -1}, //top-right
2778 { x: 1, w: -1, y: 0, h: 1}, //bottom-left
2779 { x: 0, w: 1, y: 0, h: 1} //bottom-right
2781 startX, startY, startW, startH, startFilpV, startFilpH, startAspect,
2782 baseX, baseY, baseW, baseH,
2783 currentX, currentY, currentW, currentH,
2787 function update( _x, _y, _w, _h ){
2789 _x = _x !== undefined ? _x : currentX;
2790 _y = _y !== undefined ? _y : currentY;
2791 _w = _w !== undefined ? _w : currentW;
2792 _h = _h !== undefined ? _h : currentH;
2794 if( isSpeach === false && currentIndex > 3 && app.shiftEnabled() === true ){
2795 if( startAspect >= 1 ){
2797 _w = FLOOR( startAspect * _h );
2798 _x = _x + ( currentIndex % 2 === 0 ? __w - _w : 0 );
2801 _h = FLOOR( _w / startAspect );
2802 _y = _y + ( currentIndex <= 5 ? __h - _h : 0 );
2805 ResizeOperator.update( x = _x, y = _y, w = _w, h = _h );
2806 currentElement.resize( _x, _y, _w, _h );
2807 isSpeach === true && TailOperator.update( _w, _h );
2808 CONSOLE_CONTROLER.show( currentElement, _w, _h );
2809 // CONSOLE_CONTROLER.update( currentElement );
2812 function flip( _flipH, _flipV ){
2813 var p = CURSOR_AND_FLIP[ currentIndex ];
2814 currentIndex = _flipH === true || _flipV === true ? p[
2815 _flipH === true && _flipV === true ? 'vh' : ( _flipH === true ? 'h' : 'v' )
2817 app.updateCoursor( CURSOR_AND_FLIP[ currentIndex ].cursor );
2818 elmInner.className = 'current-resizer-is-' + currentIndex;
2819 currentElement.flip( _flipH, _flipV );
2823 elmInner = document.getElementById( 'comic-element-resizer-container-inner' );
2824 styleInner = elmInner.style;
2826 styleResizerTop = document.getElementById( 'comic-element-resizer-top' ).style;
2827 styleResizerLeft = document.getElementById( 'comic-element-resizer-left' ).style;
2828 styleResizerRight = document.getElementById( 'comic-element-resizer-right' ).style;
2829 styleResizerBottom = document.getElementById( 'comic-element-resizer-bottom' ).style;
2831 delete ResizeOperator.init;
2833 update: function( _x, _y, _w, _h ){
2834 x = _x = _x !== undefined ? _x : x;
2835 y = _y = _y !== undefined ? _y : y;
2836 w = _w = _w !== undefined ? _w : w;
2837 h = _h = _h !== undefined ? _h : h;
2839 PanelElementOperatorManager.resizeElement( _x, _y, _w, _h );
2841 styleInner.width = _w + 'px';
2842 styleInner.height = _h + 'px';
2844 styleResizerTop.left = styleResizerBottom.left = FLOOR( _w / 2 - 5 ) + 'px';
2845 styleResizerLeft.top = styleResizerRight.top = FLOOR( _h / 2 - 5 ) + 'px';
2847 POSITION_ARRAY.length = 0;
2848 POSITION_ARRAY.push(
2849 {x: 5, y: -HIT_AREA, w: _w - 5, h: HIT_AREA * 2 }, // top
2850 {x: -HIT_AREA, y: 5, w: HIT_AREA * 2, h: _h - 5 }, // left
2851 {x: _w - 5, y: HIT_AREA + 5, w: HIT_AREA * 2, h: _h - 5 }, // right
2852 {x: 5, y: _h - 5, w: _w - 5, h: HIT_AREA * 2 }, // bottom
2853 {x: -HIT_AREA, y: -HIT_AREA, w: HIT_AREA + 5, h: HIT_AREA + 5}, // top left
2854 {x: _w - 5, y: -HIT_AREA, w: HIT_AREA + 5, h: HIT_AREA + 5}, // top right
2855 {x: -HIT_AREA, y: _h - 5, w: HIT_AREA + 5, h: HIT_AREA + 5}, // bottom left
2856 {x: _w - 5, y: _h - 5, w: HIT_AREA + 5, h: HIT_AREA + 5} // bottom right
2859 index: function( _mouseX, _mouseY ){
2861 for( i = 4; i < 8; ++i ){
2862 p = POSITION_ARRAY[ i ];
2863 if( p.x <= _mouseX && p.y <= _mouseY && p.x + p.w >= _mouseX && p.y + p.h >= _mouseY ){
2864 app.updateCoursor( CURSOR_AND_FLIP[ i ].cursor );
2865 elmInner.className = 'current-resizer-is-' + i;
2866 return currentIndex = i;
2869 for( i = 0; i < 4; ++i ){
2870 p = POSITION_ARRAY[ i ];
2871 if( p.x <= _mouseX && _mouseX <= p.x + p.w && p.y <= _mouseY && _mouseY <= p.y + p.h ){
2872 app.updateCoursor( CURSOR_AND_FLIP[ i ].cursor );
2873 elmInner.className = 'current-resizer-is-' + i;
2874 return currentIndex = i;
2877 app.updateCoursor( '' );
2878 elmInner.className = '';
2881 show: function( _currentElement ){
2882 currentElement = _currentElement;
2883 isSpeach = _currentElement.type === PANEL_ELEMENT_TYPE_TEXT;
2884 ResizeOperator.update( _currentElement.x, _currentElement.y, _currentElement.w, _currentElement.h );
2887 currentElement = null;
2889 onStart: function( _mouseX, _mouseY ){
2890 isSpeach = currentElement.type === PANEL_ELEMENT_TYPE_TEXT;
2891 if( currentElement.keepSize === true ) return false;
2892 currentIndex = this.index( _mouseX, _mouseY );
2893 if( currentIndex === -1 ) return false;
2896 startX = baseX = currentElement.x;
2897 startY = baseY = currentElement.y;
2898 startW = baseW = currentElement.w;
2899 startH = baseH = currentElement.h;
2900 startFilpV = currentElement.flipV;
2901 startFilpH = currentElement.flipH;
2902 startAspect = startW / startH;
2905 onDrag: function( _mouseX, _mouseY ){
2906 var com = RESIZE_WORK_ARRAY[ currentIndex ],
2907 moveX = _mouseX - offsetX,
2908 moveY = _mouseY - offsetY,
2909 _updated = moveX !== 0 || moveY !== 0,
2916 * Opera 11+ often forget values, why ??
2918 while( _x === undefined || _y === undefined || _w === undefined || _h === undefined ){
2919 _x = _x !== undefined ? _x : baseX + moveX * com.x;
2920 _y = _y !== undefined ? _y : baseY + moveY * com.y;
2921 _w = _w !== undefined ? _w : baseW + moveX * com.w;
2922 _h = _h !== undefined ? _h : baseH + moveY * com.h;
2923 error += _thisError === 0 ? 0 : 1;
2925 if( _thisError > 9999 ){
2927 //alert( 'opera error' +error);
2933 if( _w >= MIN_ELEMENT_SIZE && _h >= MIN_ELEMENT_SIZE ){
2936 if( _w >= -MIN_ELEMENT_SIZE && _h >= -MIN_ELEMENT_SIZE ){
2938 if( _w < MIN_ELEMENT_SIZE){
2939 //_x += Math.abs( MIN_ELEMENT_SIZE -_w);
2941 _w = MIN_ELEMENT_SIZE;
2943 if( _h < MIN_ELEMENT_SIZE){
2944 //_y += Math.abs( MIN_ELEMENT_SIZE -_h);
2946 _h = MIN_ELEMENT_SIZE;
2949 if( currentElement.type === PANEL_ELEMENT_TYPE_TEXT ){
2952 if( _w < -MIN_ELEMENT_SIZE || _h < -MIN_ELEMENT_SIZE ){
2954 if( _w < -MIN_ELEMENT_SIZE && _h > MIN_ELEMENT_SIZE ){
2957 baseX = _x = _x +_w;
2959 baseW = _w = _memoryX -_x;
2961 flip( true, false );
2962 flipV = currentElement.flipV;
2964 if( _w > MIN_ELEMENT_SIZE && _h < -MIN_ELEMENT_SIZE ){
2968 baseY = _y = _y +_h;
2970 baseH = _h = _memoryY -_y;
2972 flipH = currentElement.flipH;
2977 baseX = _x = _x + _w;
2978 baseY = _y = _y + _h;
2979 baseW = _w = _memoryX - _x;
2980 baseH = _h = _memoryY - _y;
2982 flipV = currentElement.flipV;
2983 flipH = currentElement.flipH;
2993 _updated === true && update( _x, _y, _w, _h );
2996 'currentIndex:', currentIndex,
2997 'baseW', baseW, 'baseH', baseH,'<br>',
2998 'mouse', _mouseX, _mouseY,'<br>',
2999 'move', moveX, moveY,'<br>',
3000 'xy', _x, _y, 'wh',_w, _h,'<br>',
3001 'com.w', com.w, 'com.h', com.h,'<br>',
3002 'current',currentW, currentH,'<br>',
3007 onFinish: function(){
3008 app.updateCoursor( '' );
3009 if( w === startW && h === startH && x === startX && y === startY ) return;
3010 PanelElementOperatorManager.resize( x, y, w, h );
3011 currentElement.resize( x, y, w, h );
3012 PanelElementOperatorManager.saveStatus( startX, startY, startW, startH, undefined, startFilpV, startFilpH );
3014 onCancel: function(){
3015 app.updateCoursor( '' );
3016 PanelElementOperatorManager.resize( startX, startY, startW, startH );
3017 currentElement.type === PANEL_ELEMENT_TYPE_IMAGE ?
3018 currentElement.animate( startX, startY, startW, startH, startFilpV, startFilpH ) :
3019 currentElement.animate( startX, startY, startW, startH, angle );
3021 onShiftUpdate: update,
3022 onCtrlUpdate: update
3026 /* --------------------------------------------------------------------------------------------
3028 * - panelElementOperator
3030 var PositionOperator = ( function(){
3031 var HIT_AREA = MOUSE_HIT_AREA,
3037 function update( _x, _y ){
3038 x = _x !== undefined ? _x : x;
3039 y = _y !== undefined ? _y : y;
3040 // ResizeOperator.update( x, y );
3042 PanelElementOperatorManager.resizeElement( x, y );
3044 currentElement.resize( x, y );
3045 // CONSOLE_CONTROLER.update( currentElement );
3049 delete PositionOperator.init;
3051 show : function( _currentElement ){
3052 currentElement = _currentElement;
3055 currentElement = null;
3057 onStart: function( _mouseX, _mouseY ){
3060 startX = x = currentElement.x;
3061 startY = y = currentElement.y;
3062 app.updateCoursor( 'move' );
3064 onDrag: function( _mouseX, _mouseY ){
3065 var moveX = _mouseX - offsetX,
3066 moveY = _mouseY - offsetY,
3067 _x = startX + moveX,
3068 _y = startY + moveY;
3069 if( GRID_CONTROL.enabled() === true ){
3070 _x = Math.floor( _x / 10 ) * 10;
3071 _y = Math.floor( _y / 10 ) * 10;
3075 onFinish: function(){
3076 app.updateCoursor( '' );
3077 if( x === startX && y === startY ) return;
3078 PanelElementOperatorManager.resize( x, y );
3079 currentElement.resize( x, y );
3080 PanelElementOperatorManager.saveStatus( startX, startY );
3082 onCancel: function(){
3083 app.updateCoursor( '' );
3084 PanelElementOperatorManager.resize( startX, startY );
3085 currentElement.animate( startX, startY );
3087 onShiftUpdate: update,
3088 onCtrlUpdate: update
3093 /* --------------------------------------------------------------------------------------------
3094 * PanelElementOperatorManager
3096 var PanelElementOperatorManager = ( function(){
3097 var HIT_AREA = MOUSE_HIT_AREA,
3099 currentOperator = null,
3100 currentElement = null,
3102 styleContainer = null,
3103 currentX, currentY, currentW, currentH, angle, flipV, flipH;
3105 function mousedown( e ){
3106 var x = e.layerX - HIT_AREA / 2 - 5,
3107 y = e.layerY - HIT_AREA / 2 - 5;
3108 if( isSpeach === true && TailOperator.onStart( x, y ) === true ){
3109 currentOperator = TailOperator;
3111 if( ResizeOperator.onStart( x, y ) === true ){
3112 currentOperator = ResizeOperator;
3114 PositionOperator.onStart( x, y );
3115 currentOperator = PositionOperator;
3119 function mousemove( e ){
3120 var x = e.layerX - HIT_AREA / 2 - 5,
3121 y = e.layerY - HIT_AREA / 2 - 5;
3122 if( currentOperator !== null ){
3123 currentOperator.onDrag( x, y );
3126 if( currentElement !== null ){
3127 ( isSpeach === false || TailOperator.hitTest( x, y ) === false ) && ResizeOperator.index( x, y );
3130 function mouseup( e ){
3131 currentOperator !== null && currentOperator.onFinish();
3132 currentOperator = null;
3139 TailOperator.init();
3140 ResizeOperator.init();
3141 PositionOperator.init();
3142 CONSOLE_CONTROLER.init();
3144 app.addKeyEventListener( 'keychange', function( e ){
3145 currentOperator !== null && currentOperator.onShiftUpdate && currentOperator.onShiftUpdate();
3148 app.addKeyEventListener( 'keychange', function( e ){
3149 currentOperator !== null && currentOperator.onCtrlUpdate && currentOperator.onCtrlUpdate();
3152 app.addKeyEventListener( 'keydown', function( e ){
3153 currentOperator !== null && currentOperator.onCancel && currentOperator.onCancel();
3154 currentOperator = null;
3156 }, 27, false, false );
3158 delete PanelElementOperatorManager.init;
3161 var elm = document.getElementById( 'comic-element-resizer-container' );
3162 PanelElementOperatorManager.elm = elm;
3163 PanelElementOperatorManager.node = eventRoot.createNode( elm, false, false );
3164 PanelElementOperatorManager.node.addEventListener( 'mouseout', PanelElementOperatorManager.hide, PanelElementOperatorManager );
3165 styleContainer = elm.style;
3166 PanelElementOperatorManager.node.disabled( true );
3167 PanelElementOperatorManager.node.addEventListener( 'mousemove', mousemove );
3168 PanelElementOperatorManager.node.addEventListener( 'mousedown', mousedown );
3169 PanelElementOperatorManager.node.addEventListener( 'mouseup', mouseup );
3171 CONSOLE_CONTROLER.open();
3172 PanelElementOperatorManager.hide();
3174 delete PanelElementOperatorManager.open;
3179 show : function( _currentElement ){
3180 if( currentElement === null ){
3181 styleContainer.display = '';
3182 PanelElementOperatorManager.node.disabled( false );
3184 if( currentElement !== _currentElement ){
3185 currentElement = _currentElement;
3187 ResizeOperator.show( _currentElement );
3188 PositionOperator.show( _currentElement );
3190 isSpeach = ( _currentElement.type === PANEL_ELEMENT_TYPE_TEXT );
3191 isSpeach === true ? TailOperator.show( _currentElement ) : TailOperator.hide();
3193 flipV = _currentElement.flipV;
3194 flipH = _currentElement.flipH;
3196 PanelElementOperatorManager.resize(
3197 _currentElement.x, _currentElement.y, _currentElement.w, _currentElement.h,
3198 isSpeach === true ? _currentElement.a : 0
3203 if( currentElement !== null ){
3204 styleContainer.display = 'none';
3205 PanelElementOperatorManager.node.disabled( true );
3207 currentElement = null;
3208 app.updateCoursor( '' );
3209 TailOperator.hide();
3210 ResizeOperator.hide();
3211 PositionOperator.hide();
3212 CONSOLE_CONTROLER.hide();
3214 resizeElement : function( _x, _y, _w, _h, _angle ){
3215 _x = _x !== undefined ? _x : currentX;
3216 _y = _y !== undefined ? _y : currentY;
3217 _w = _w !== undefined ? _w : currentW;
3218 _h = _h !== undefined ? _h : currentH;
3220 var style = PanelElementOperatorManager.elm.style;
3221 style.left = ( PANEL_CONTROL.x + _x - HIT_AREA / 2 - 5 ) + 'px';
3222 style.top = ( PANEL_CONTROL.y + _y - HIT_AREA / 2 - 5 ) + 'px';
3223 style.width = ( _w + HIT_AREA + 5 ) + 'px';
3224 style.heught = ( _h + HIT_AREA + 5 ) + 'px';
3226 // ResizeOperator.update( _x, _y, _w, _h );
3227 isSpeach === true && TailOperator.update( _w, _h, angle );
3228 CONSOLE_CONTROLER.show( currentElement, _w, _h );
3230 resize: function( _x, _y, _w, _h, _angle ){
3231 currentX = _x = _x !== undefined ? _x : currentX;
3232 currentY = _y = _y !== undefined ? _y : currentY;
3233 currentW = _w = _w !== undefined ? _w : currentW;
3234 currentH = _h = _h !== undefined ? _h : currentH;
3235 angle = _angle = _angle !== undefined ? _angle : angle;
3237 // ResizeOperator.update( _x, _y, _w, _h );
3238 isSpeach === true && TailOperator.update( _w, _h, angle );
3239 CONSOLE_CONTROLER.show( currentElement, _w, _h );
3240 //CONSOLE_CONTROLER.update( currentElement );
3241 PanelElementOperatorManager.node.update( PANEL_CONTROL.x + _x - HIT_AREA / 2 - 5, PANEL_CONTROL.y + _y - HIT_AREA / 2 - 5, _w + HIT_AREA + 5, _h + HIT_AREA + 5 );
3244 restoreState: function( _currentElement, _x, _y, _w, _h, _a, _flipV, _flipH ){
3245 if( arguments.length !== 8 ) return;
3246 if( !_currentElement && !currentOperator ) return;
3247 _currentElement.type === PANEL_ELEMENT_TYPE_IMAGE ?
3248 _currentElement.animate( _x, _y, _w, _h, _flipV, _flipH ) :
3249 _currentElement.animate( _x, _y, _w, _h, _a );
3250 currentOperator !== null && currentOperator.onCancel && currentOperator.onCancel();
3251 currentOperator = null;
3252 currentElement === _currentElement ? PanelElementOperatorManager.resize( _x, _y, _w, _h, _a ) : PanelElementOperatorManager.show( _currentElement );
3254 saveStatus: function( startX, startY, startW, startH, startA, startFilpV, startFilpH ){
3255 startX = startX !== undefined ? startX : currentX;
3256 startY = startY !== undefined ? startY : currentY;
3257 startW = startW !== undefined ? startW : currentW;
3258 startH = startH !== undefined ? startH : currentH;
3259 startA = startA !== undefined ? startA : angle;
3260 startFilpV = startFilpV !== undefined ? startFilpV : flipV;
3261 startFilpH = startFilpH !== undefined ? startFilpH : flipH;
3262 currentElement && HISTORY_CONTROL.saveState( PanelElementOperatorManager.restoreState,
3263 [ currentElement, startX, startY, startW, startH, startA, startFilpV, startFilpH ],
3264 [ currentElement, currentX, currentY, currentW, currentH, angle, flipV, flipH ]
3270 * // PanelElementOperatorManager
3273 /* --------------------------------------------------------------------------------------------
3276 var CONSOLE_CONTROLER = ( function(){
3277 var LAYER_BACK_BUTTON, LAYER_FORWARD_BUTTON, DELETE_BUTTON, EDIT_BUTTON, CHANGE_BUTTON,
3278 PUSH_OUT_RATIO = 0.5,
3280 elmRoot, elmContainer, elmPushout, elmTail,
3287 ui, inputX, inputY, inputZ, inputA, inputW, inputH, inputAspectRatio,
3288 buttonBack, buttonForward, buttonDel, buttonEdit, butonChange;
3290 function layerBack(){
3291 if( currentElement === null ) return;
3292 if( PANEL_ELEMENT_CONTROL.replace( currentElement, false ) === false ) return;
3293 CONSOLE_CONTROLER.update( currentElement );
3294 HISTORY_CONTROL.saveState( PANEL_ELEMENT_CONTROL.replace, [ currentElement, true ], [ currentElement, false ] );
3295 var _z = currentElement.z;
3296 LAYER_BACK_BUTTON.visible( _z > 0 );
3297 LAYER_FORWARD_BUTTON.visible( _z < PANEL_ELEMENT_ARRAY.length - 1 );
3299 function layerForward(){
3300 if( currentElement === null ) return;
3301 if( PANEL_ELEMENT_CONTROL.replace( currentElement, true ) === false ) return;
3302 CONSOLE_CONTROLER.update( currentElement );
3303 HISTORY_CONTROL.saveState( PANEL_ELEMENT_CONTROL.replace, [ currentElement, false ], [ currentElement, true ] );
3304 var _z = currentElement.z;
3305 LAYER_BACK_BUTTON.visible( _z > 0 );
3306 LAYER_FORWARD_BUTTON.visible( _z < PANEL_ELEMENT_ARRAY.length - 1 );
3309 if( currentElement === null ) return;
3310 HISTORY_CONTROL.saveState( PANEL_ELEMENT_CONTROL.restore, [ true, currentElement ], [ false, currentElement ], false ); // true
3311 PANEL_ELEMENT_CONTROL.remove( currentElement );
3312 PanelElementOperatorManager.hide();
3315 if( currentElement === null || currentElement.type !== PANEL_ELEMENT_TYPE_TEXT ) return;
3316 TextEditor.boot( PANEL_CONTROL.x, PANEL_CONTROL.y, currentElement );
3319 if( currentElement === null ) return;
3320 PremiumSatge.boot( currentElement.artistID, currentElement.resourcePicture, currentElement );
3329 app.addKeyEventListener( 'keydown', layerBack, 66, false, true );
3330 app.addKeyEventListener( 'keydown', layerForward, 70, false, true );
3331 app.addKeyEventListener( 'keydown', del, 68, false, true );
3332 app.addKeyEventListener( 'keydown', edit, 69, false, true );
3333 app.addKeyEventListener( 'keydown', change, 85, false, true );
3335 elmContainer = document.getElementById( 'comic-element-consol-container' );
3336 elmRoot = elmContainer.parentNode;
3337 elmPushout = document.getElementById( 'comic-element-consol-pushout-wrapper' );
3338 elmTail = document.getElementById( 'comic-element-consol-pushout-tail' );
3339 delete CONSOLE_CONTROLER.init;
3342 LAYER_BACK_BUTTON = MENU_BAR_CONTROL.EDIT.createOption( 'layer back', 'ctrl + B', layerBack, false, true, false );
3343 LAYER_FORWARD_BUTTON = MENU_BAR_CONTROL.EDIT.createOption( 'layer forward', 'ctrl + F', layerForward, false, false, false );
3344 DELETE_BUTTON = MENU_BAR_CONTROL.EDIT.createOption( 'delete', 'ctrl + D', del, false, true, true );
3345 EDIT_BUTTON = MENU_BAR_CONTROL.EDIT.createOption( 'Edit Text', 'ctrl + E', edit, false, true, false );
3346 CHANGE_BUTTON = MENU_BAR_CONTROL.EDIT.createOption( 'change', 'ctrl + U', change, false, false, true );
3347 // inputAspectRatio = $( '#comic-element-keep-aspect' );
3349 delete CONSOLE_CONTROLER.open;
3351 onMouseover : function( e ){
3352 node.mesureChildren();
3355 show: function( _currentElement, w, h ){
3356 if( node === null ){
3357 node = CONSOLE_CONTROLER.node = PanelElementOperatorManager.node.createNode( elmContainer, false, false, 'comic-element-consol-container-hover' );
3358 node.addEventListener( 'mouseover', CONSOLE_CONTROLER.onMouseover, CONSOLE_CONTROLER );
3359 ui = app.createUIGroup( node );
3360 inputX = ui.createInputText( document.getElementById( 'comic-element-x' ), null );
3361 inputY = ui.createInputText( document.getElementById( 'comic-element-y' ), null );
3362 inputZ = ui.createInputText( document.getElementById( 'comic-element-z' ), null );
3363 inputA = ui.createInputText( document.getElementById( 'comic-element-a' ), null );
3364 inputW = ui.createInputText( document.getElementById( 'comic-element-w' ), null );
3365 inputH = ui.createInputText( document.getElementById( 'comic-element-h' ), null );
3366 inputPercentW = ui.createInputText( document.getElementById( 'comic-element-w-percent' ), null );
3367 inputPercentH = ui.createInputText( document.getElementById( 'comic-element-h-percent' ), null );
3368 butonChange = ui.createButton( document.getElementById( 'change-image-button' ), change ),
3369 buttonBack = ui.createButton( document.getElementById( 'layer-back-button' ), layerBack ),
3370 buttonDel = ui.createButton( document.getElementById( 'delete-button' ), del ),
3371 buttonForward = ui.createButton( document.getElementById( 'layer-forward-button' ), layerForward ),
3372 buttonEdit = ui.createButton( document.getElementById( 'edit-text-button' ), edit );
3375 currentElement = _currentElement;
3377 var type = currentElement.type,
3378 z = currentElement.z;
3380 LAYER_BACK_BUTTON.visible( z > 0 );
3381 buttonBack.enabled( z > 0 );
3382 LAYER_FORWARD_BUTTON.visible( z < PANEL_ELEMENT_ARRAY.length - 1 );
3383 buttonForward.enabled( z < PANEL_ELEMENT_ARRAY.length - 1 )
3384 DELETE_BUTTON.visible( true );
3385 EDIT_BUTTON.visible( type === PANEL_ELEMENT_TYPE_TEXT );
3386 CHANGE_BUTTON.visible( false );
3388 //CONSOLE_CONTROLER.x = Math.floor( ( _w - CONSOLE_CONTROLER.w ) / 2 );
3389 CONSOLE_CONTROLER.w = w;
3390 CONSOLE_CONTROLER.h = elmContainer.offsetHeight;
3391 CONSOLE_CONTROLER.y = h - CONSOLE_CONTROLER.h;
3393 if( h * PUSH_OUT_RATIO < CONSOLE_CONTROLER.h ){
3394 if( pushout === false ){
3396 elmPushout.lastChild.appendChild( elmContainer );
3397 elmPushout.style.display = 'block';
3398 pushoutW = elmPushout.offsetWidth;
3399 pushoutH = elmPushout.offsetHeight;
3400 elmTail.style.top = ( pushoutH / 2 - tailSize / 2 ) + 'px';
3402 elmPushout.style.left = ( -pushoutW ) + 'px';
3403 elmPushout.style.top = ( h / 2 - pushoutH / 2 ) + 'px';
3404 elmPushout.className = 'satellite-left';
3406 if( pushout === true ){
3408 elmRoot.insertBefore( elmContainer, elmRoot.firstChild );
3409 elmPushout.style.cssText = '';
3412 CONSOLE_CONTROLER.update( currentElement );
3416 update : function( _currentElement ){
3417 if( _currentElement === null ){
3421 currentElement = _currentElement;
3422 var type = currentElement.type,
3423 x = currentElement.x,
3424 y = currentElement.y,
3425 z = currentElement.z,
3426 a = type === PANEL_ELEMENT_TYPE_TEXT ? Math.floor( currentElement.a ) : 0,
3427 w = currentElement.w,
3428 h = currentElement.h,
3429 actualW = type === PANEL_ELEMENT_TYPE_IMAGE ? currentElement.actualW : 1,
3430 actualH = type === PANEL_ELEMENT_TYPE_IMAGE ? currentElement.actualH : 1,
3431 wPercent = type === PANEL_ELEMENT_TYPE_IMAGE ? Math.floor( w / actualW * 100 ) : 0,
3432 hPercent = type === PANEL_ELEMENT_TYPE_IMAGE ? Math.floor( h / actualH * 100 ) : 0,
3433 keepAspect = currentElement.keepAspect;
3435 if( currentType !== type ){
3436 if( type === PANEL_ELEMENT_TYPE_TEXT ){
3437 inputA.visible( true );
3438 inputPercentW.visible( false );
3439 inputPercentH.visible( false );
3440 buttonEdit.enabled( true );
3441 //inputAspectRatio.hide();
3443 inputA.visible( false );
3444 inputPercentW.visible( true );
3445 inputPercentH.visible( true );
3446 buttonEdit.enabled( false );
3447 //inputAspectRatio.show();
3455 type === 1 && inputA.value( a );
3458 type === 0 && inputPercentW.value( wPercent );
3459 type === 0 && inputPercentH.value( hPercent );
3462 // if( visible === true ) styleConsoleWrapper.display = 'none';
3463 ui && ui.visible( false );
3465 currentElement = null;
3466 LAYER_BACK_BUTTON.visible( false );
3467 LAYER_FORWARD_BUTTON.visible( false );
3468 DELETE_BUTTON.visible( false );
3469 EDIT_BUTTON.visible( false );
3470 CHANGE_BUTTON.visible( false );
3477 var AbstractPanelElement = function( COMIC_ELM_TYPE ){
3478 this.type = COMIC_ELM_TYPE;
3480 AbstractPanelElement.prototype = {
3494 shift : function( shiftX, shiftY ){
3495 this.resize( this.x + shiftX, this.y + shiftY );
3497 mouseover : function( e ){
3498 PanelElementOperatorManager.show( this );
3502 /* --------------------------------------------------------------------------------------------
3505 var jqImageElementOrigin;
3506 var ImageElementClass = function( data ){
3507 jqImageElementOrigin = jqImageElementOrigin || $( app.fetchHTMLElement( 'imgElementTemplete' ) );
3509 this.$ = jqImageElementOrigin.clone( true );
3512 this.timing = data.t || PANEL_ELEMENT_ARRAY.length + 1;
3513 this.keepSize = false;
3514 this.flipV = data.height < 0 ? -1 : 1;
3515 this.flipH = data.width < 0 ? -1 : 1;
3516 this.rPicture = data.resource_picture;
3517 this.artistID = this.rPicture.artist_id || this.rPicture.artist.id || -1;
3520 function animeComplete(){
3522 self._flipReversibleImage();
3524 this.animeComplete = animeComplete;
3526 ImageElementClass.prototype = Util.extend(
3527 new AbstractPanelElement( PANEL_ELEMENT_TYPE_IMAGE ),
3529 reversibleImage : null,
3531 this._updateResourcePicture( this.rPicture );
3532 this.node = PANEL_ELEMENT_CONTROL.node.createNode( this.$.get( 0 ), false, true );
3533 this.node.addEventListener( 'mouseover', this.mouseover, this );
3534 this.resize( this.data.x, this.data.y, Math.abs( this.data.width ), Math.abs( this.data.height ) );
3537 flip : function( updateH, updateV ){
3538 if( updateH !== true && updateV !== true ) return;
3539 this.flipH = updateH === true ? -this.flipH : this.flipH;
3540 this.flipV = updateV === true ? -this.flipV : this.flipV;
3541 this.reversibleImage.resize( this.flipH * this.w, this.flipV * this.h );
3543 resourcePicture : function( _rPicture ){
3544 if( _rPicture && _rPicture !== this.rPicture ){
3545 HISTORY_CONTROL.saveState( this._updateResourcePicture, this.rPicture, _rPicture, this );
3546 this._updateResourcePicture( _rPicture );
3548 return this.rPicture;
3550 resize : function( x, y, w, h, animate ){
3551 this.x = x = Type.isFinite( x ) === true ? x : this.x;
3552 this.y = y = Type.isFinite( y ) === true ? y : this.y;
3553 this.w = w = Type.isFinite( w ) === true ? w : this.w;
3554 this.h = h = Type.isFinite( h ) === true ? h : this.h;
3555 if( animate === true ){
3561 }, 250 , this.animeComplete );
3563 this.node.update( x, y, w, h );
3564 this._flipReversibleImage();
3567 animate : function ( x, y, w, h, flipH, flipV ){
3568 this.flipH = flipH !== undefined ? flipH : this.flipH;
3569 this.flipV = flipV !== undefined ? flipV : this.flipV;
3570 this.resize( x, y, w, h, true );
3572 destroy : function(){
3573 this.reversibleImage.destroy();
3574 this.$.stop().remove();
3577 this.destroy = null;
3579 _updateResourcePicture : function( _rPicture ){
3580 this.rPicture = _rPicture;
3582 this.actualW = _rPicture.width;
3583 this.actualH = _rPicture.height;
3585 var _reversibleImage = pettanr.image.createReversibleImage(
3586 [ pettanr.CONST.RESOURCE_PICTURE_PATH, _rPicture.id, '.', _rPicture.ext ].join(''),
3587 this.flipH * this.w, this.flipV * this.h
3589 if( this.reversibleImage !== null ){
3590 this.$.children( this.reversibleImage.elm ).replaceWith( _reversibleImage.elm );
3591 this.reversibleImage.destroy();
3593 this.$.append( _reversibleImage.elm );
3595 this.reversibleImage = _reversibleImage;
3597 _flipReversibleImage : function(){
3598 this.reversibleImage && this.reversibleImage.resize( this.flipH * this.w, this.flipV * this.h );
3605 * / ImageElementClass
3606 * --------------------------------------------------------------------------------------------
3610 /* --------------------------------------------------------------------------------------------
3618 * 4.black-box( dq style)
3619 * 5.blue-box( ff style)
3622 var jqTextElementOrigin;
3623 var TextElementClass = function( data ){
3624 jqTextElementOrigin = jqTextElementOrigin || ( function(){
3625 var _OLD_IE = $( app.fetchHTMLElement( 'textElementTempleteForOldIE' ) ),
3626 _MODERN = $( app.fetchHTMLElement( 'textElementTemplete' ) );
3627 return UA.isIE === true && UA.ieRenderingVersion < 8 ? _OLD_IE : _MODERN;
3630 this.$ = jqTextElementOrigin.clone( true );
3632 this.elmText = this.$.find( 'td,.speach-inner' ).get( 0 );
3633 this.type = data.balloon_template_id;
3634 this.content = ( function(){
3635 var _speachs = data.speeches_attributes;
3636 for( var k in _speachs ){
3637 return _speachs[ k ].content || '';
3641 this.balloon = pettanr.balloon.createBalloon( data.width, data.height, data.tail, this.type );
3643 this.timing = data.t || PANEL_ELEMENT_ARRAY.length + 1;
3645 this.$.find( 'img' ).eq( 0 ).replaceWith( this.balloon.elm );
3648 function animeComplete(){
3650 self._resizeBalloon();
3652 this.animeComplete = animeComplete;
3654 TextElementClass.prototype = Util.extend(
3655 new AbstractPanelElement( PANEL_ELEMENT_TYPE_TEXT ),
3659 this.node = PANEL_ELEMENT_CONTROL.node.createNode( this.$.get( 0 ), false, true );
3660 this.node.addEventListener( 'mouseover', this.mouseover, this );
3661 this.resize( this.data.x, this.data.y, this.data.width, this.data.height, this.data.tail );
3664 _updateType : function( _type ){
3665 if( this.type !== _type ){
3666 this.type = _type || this.type;
3667 this.balloon.type( this.type );
3670 _updateAngle : function( _a ){
3671 if( _a !== undefined && a !== _a ){
3672 this.a = _a !== undefined ? _a : this.a;
3673 this.balloon.angle( this.a );
3677 _updateText : function( _text ){
3678 this.content = _text || this.content || '';
3679 this.elmText.firstChild.data = this.content;
3681 _resizeBalloon : function(){
3682 this.balloon && this.balloon.resize( this.a, this.w, this.h );
3684 angle : function( _a ){
3685 _a !== undefined && this.resize( this.x, this.y, this.w, this.h, _a );
3688 text : function( _text ){
3689 if( _text && this.content !== _text ){
3690 HISTORY_CONTROL.saveState( this._updateText, this.content || '', _text, this );
3691 this._updateText( _text );
3693 return this.content;
3695 resize : function( x, y, w, h, a, animate ){
3696 this.x = x = x !== undefined ? x : this.x;
3697 this.y = y = y !== undefined ? y : this.y;
3698 this.w = w = w !== undefined ? w : this.w;
3699 this.h = h = h !== undefined ? h : this.h;
3700 this.a = a !== undefined ? a : this.a;
3702 if( animate === true ){
3708 }, 250 , this.animeComplete );
3710 this.node.update( x, y, w, h );
3711 this._resizeBalloon();
3714 animate : function ( _x, _y, _w, _h, _a ){
3715 this.resize( _x, _y, _w, _h, _a, true );
3717 destroy : function(){
3718 this.$.stop().remove();
3719 this.balloon.destroy();
3722 this.destroy = null;
3727 /* --------------------------------------------------------------------------------------------
3728 * PANEL_ELEMENT_CONTROL
3729 * - mouseEventListener
3731 var PANEL_ELEMENT_CONTROL = ( function(){
3732 var elmContainer = null,
3733 currentElement = null,
3735 panelX, panelY, panelW, panelH,
3738 * append, remove, replace
3740 * panelElement には、z-position と dom-index がある。
3741 * z-position は 表示上の位置。大きいほど前に表示される( z-index)
3742 * dom-index は 意味上の順番。htmlタグの登場順で、検索結果や音声読み上げブラウザで正しく意味が取れる順番。
3744 * editerでは、実際には z-index は使わず、htmlの順序で前後を表現する。
3745 * dom-index は、数値のみ保持して、投稿時にpanelElementを適宜に並び替える。
3747 * append panelElement
3748 * 1. 新しい panelElement の z-position を得る
3749 * 2. z の同じ panelElementを見つけ、その前に加える。または一番先頭へ。(PANEL_ELEMENT_ARRAY)
3750 * zが大きいほど、PANEL_ELEMENT_ARRAYの先頭へ。
3751 * 3. dom位置は、PANEL_ELEMENT_ARRAY とは反対に、前のものほど後ろへ。
3754 * remove panelElement
3758 function onFadeOut(){
3759 this.parentNode.removeChild( this );
3762 * PANEL_ELEMENT_ARRAY の順番を基準に、zの再計算
3765 function renumber(){
3766 var _panelElement, jqElm, jqAfter,
3767 i = PANEL_ELEMENT_ARRAY.length;
3769 _panelElement = PANEL_ELEMENT_ARRAY[ --i ];
3770 jqElm = _panelElement.$;
3771 !jqAfter && elmContainer.appendChild( jqElm.get( 0 ) );
3772 jqAfter && jqAfter.before( jqElm );
3774 _panelElement.z = i;
3775 _panelElement.node.nodeIndex( i );
3780 function onTextInput( _panelElement ){
3781 PANEL_ELEMENT_CONTROL.add( _panelElement );
3782 _panelElement.animate( undefined, undefined, _panelElement.w, _panelElement.h );
3783 HISTORY_CONTROL.saveState( PANEL_ELEMENT_CONTROL.restore, [ false, _panelElement ], [ true, _panelElement ], true, PANEL_ELEMENT_CONTROL );
3787 id : 'PANEL_ELEMENT_CONTROL',
3790 elmContainer = document.getElementById( 'comic-element-container' );
3791 node = PANEL_ELEMENT_CONTROL.node = eventRoot.createNode( elmContainer, true, false );
3792 node.nodeIndex( 0 );
3793 delete PANEL_ELEMENT_CONTROL.init;
3796 delete PANEL_ELEMENT_CONTROL.open;
3800 while( panelElm = PANEL_ELEMENT_ARRAY.shift() ){
3801 panelElm.destroy && panelElm.destroy();
3804 add : function( _panelElement ){
3805 var z = Type.isFinite( _panelElement.z ) === true ? _panelElement.z : -1,
3806 i = PANEL_ELEMENT_ARRAY.length,
3807 _jqElm = _panelElement.$.stop().css( {
3813 PANEL_ELEMENT_ARRAY.push( _panelElement );
3816 if( PANEL_ELEMENT_ARRAY[ --i ].z < z ){
3822 PANEL_ELEMENT_ARRAY.unshift( _panelElement );
3824 PANEL_ELEMENT_ARRAY.splice( i + 1, 0, _panelElement );
3829 _panelElement.node.disabled( false );
3831 remove : function( _panelElement ){
3832 for( var i = PANEL_ELEMENT_ARRAY.length; i; ){
3833 if( PANEL_ELEMENT_ARRAY[ --i ] === _panelElement ){
3834 console.log( PANEL_ELEMENT_ARRAY.length );
3835 PANEL_ELEMENT_ARRAY.splice( i, 1 );
3836 _panelElement.node.disabled( true );
3837 _panelElement.node.nodeIndex( PANEL_ELEMENT_ARRAY.length );
3839 _panelElement.$.stop().css( {
3842 }).fadeOut( onFadeOut );
3843 if( currentElement === _panelElement ) currentElement = null;
3849 restore : function( isAppend, panelElement ){
3850 PANEL_ELEMENT_CONTROL[ isAppend === true ? 'add' : 'remove' ]( panelElement );
3852 replace: function( _panelElement, goForward ){
3853 // PANEL_ELEMENT_ARRAYの再構築
3854 var l = PANEL_ELEMENT_ARRAY.length,
3858 if( PANEL_ELEMENT_ARRAY[ --j ] === _panelElement ){
3863 if( i !== j ) return false;
3864 if( goForward === true ){
3865 if( i === 0 ) return false;
3866 PANEL_ELEMENT_ARRAY.splice( i, 1 );
3867 PANEL_ELEMENT_ARRAY.splice( i + 1, 0, _panelElement );
3869 if( i === l - 1 ) return false;
3870 PANEL_ELEMENT_ARRAY.splice( i, 1 );
3871 PANEL_ELEMENT_ARRAY.splice( i - 1, 0, _panelElement );
3876 onPanelResize : function ( _panelX, _panelY, _panelW, _panelH, isResizerTopAction ){
3878 * リサイズが、ResizerTopによって行われた場合、panelElementのyを動かして見かけ上動かないようにする。
3880 if( isResizerTopAction === true ){
3881 var _shiftX = _panelW - panelW,
3882 _shiftY = _panelH - panelH;
3883 for( var i = PANEL_ELEMENT_ARRAY.length; i; ){
3884 PANEL_ELEMENT_ARRAY[ --i ].shift( _shiftX, _shiftY );
3887 node.update( panelX = _panelX, panelY = _panelY, panelW = _panelW, panelH = _panelH );
3889 createImageElement: function( data ){
3890 if( Type.isObject( data ) === false ){
3891 PremiumSatge.boot( 1, PANEL_ELEMENT_CONTROL.onImageSelect );
3893 PANEL_ELEMENT_CONTROL.onImageSelect( data, true );
3896 onImageSelect: function( data, isPanelPictureData ){
3898 if( isPanelPictureData !== true ){
3899 _panelElement = new ImageElementClass( {
3900 resource_picture:data,
3901 x: Math.floor( panelW / 2 - data.width / 2 ),
3902 y: Math.floor( panelH / 2 - data.height / 2 ),
3904 t: PANEL_ELEMENT_ARRAY.length + 1,
3908 _panelElement.init();
3909 PANEL_ELEMENT_CONTROL.add( _panelElement );
3910 _panelElement.animate( undefined, undefined, Math.abs( data.width ), Math.abs( data.height ) );
3912 _panelElement = new ImageElementClass( data );
3913 _panelElement.init();
3914 PANEL_ELEMENT_CONTROL.add( _panelElement );
3916 HISTORY_CONTROL.saveState( PANEL_ELEMENT_CONTROL.restore, [ false, _panelElement ], [ true, _panelElement ], true );
3918 createTextElement: function( data ){
3920 if( Type.isObject( data ) === false ){
3922 balloon_template_id:1,
3925 x: Math.floor( panelW / 2 - 100 + Math.random() * 10 ),
3926 y: Math.floor( panelH / 2 - 100 + Math.random() * 10 ),
3928 t: PANEL_ELEMENT_ARRAY.length + 1,
3931 speeches_attributes: {
3937 _panelElement = new TextElementClass( data );
3938 _panelElement.init();
3939 TextEditor.boot( PANEL_CONTROL.x, PANEL_CONTROL.y, _panelElement, onTextInput );
3941 _panelElement = new TextElementClass( data );
3942 _panelElement.init();
3943 onTextInput( _panelElement );
3950 * end of PANEL_ELEMENT_CONTROL
3953 function centering(){
3954 app.onPaneResize( windowW, windowH );
3959 this.MIN_WIDTH = 320;
3960 this.MIN_HEIGHT = 320;
3961 this.onInit = function(){
3962 app.rootElement.id = 'editor';
3963 app.rootElement.innerHTML = [
3964 '<div id="grid" style="display:none;"></div>',
3965 '<div id="comic-element-container"></div>',
3966 '<div id="whiteGlass-container">',
3967 '<div id="whiteGlass-top"></div>',
3968 '<div id="whiteGlass-left"></div>',
3969 '<div id="whiteGlass-right"></div>',
3970 '<div id="whiteGlass-bottom"></div>',
3972 '<div id="panel-tools-container">',
3973 '<div id="panel-resizer-top">▲</div>',
3974 '<div id="panel-resizer-bottom">▼</div>',
3976 '<div id="window-container"></div>',
3977 '<div id="comic-element-resizer-container">',
3978 '<div id="comic-element-resizer-container-inner">',
3979 '<div id="comic-element-consol-wrapper">',
3980 '<div id="comic-element-consol-container" class="clearfix">',
3981 '<div class="comic-element-consol-item">',
3982 '<div id="comic-element-x">',
3983 '<span class="comic-element-attribute-label">x:</span>',
3984 '<span id="comic-element-x-value" class="comic-element-attribute-value editable-value">0</span>',
3986 '<div id="comic-element-y">',
3987 '<span class="comic-element-attribute-label">y:</span>',
3988 '<span id="comic-element-y-value" class="comic-element-attribute-value editable-value">0</span>',
3991 '<div class="comic-element-consol-item">',
3992 '<div id="comic-element-z">',
3993 '<span class="comic-element-attribute-label">z:</span>',
3994 '<span id="comic-element-z-value" class="comic-element-attribute-value editable-value">0</span>',
3996 '<div id="comic-element-a">',
3997 '<span id="comic-element-a-value" class="comic-element-attribute-value editable-value">0</span>',
3998 '<span class="comic-element-attribute-label">°</span>',
4001 '<div class="comic-element-consol-item">',
4002 '<div id="comic-element-w">',
4003 '<span class="comic-element-attribute-label">w:</span>',
4004 '<span id="comic-element-w-value" class="comic-element-attribute-value editable-value">0</span>',
4006 '<div id="comic-element-h">',
4007 '<span class="comic-element-attribute-label">h:</span>',
4008 '<span id="comic-element-h-value" class="comic-element-attribute-value editable-value">0</span>',
4011 '<div class="comic-element-consol-item">',
4012 '<!-- <div id="comic-element-keep-aspect"></div> -->',
4013 '<div id="comic-element-w-percent">',
4014 '<span id="comic-element-w-percent-value" class="comic-element-attribute-value editable-value">0</span>',
4015 '<span class="comic-element-attribute-label">%</span>',
4017 '<div class="comic-element-consol-item" id="comic-element-h-percent">',
4018 '<span id="comic-element-h-percent-value" class="comic-element-attribute-value editable-value">0</span>',
4019 '<span class="comic-element-attribute-label">%</span>',
4022 '<div class="comic-element-consol-item-small">',
4023 '<div class="button" id="change-image-button">change</div>',
4025 '<div class="comic-element-consol-item-small">',
4026 '<div class="button" id="layer-back-button">back</div>',
4028 '<div class="comic-element-consol-item-small">',
4029 '<div class="button" id="delete-button">delete</div>',
4031 '<div class="comic-element-consol-item-small">',
4032 '<div class="button" id="layer-forward-button">forward</div>',
4034 '<div class="comic-element-consol-item-small">',
4035 '<div class="button" id="edit-text-button">edit</div>',
4037 '<!-- <div class="comic-element-consol-item-small">',
4038 '<div class="button" id="hide-text-tail-button">tail</div>',
4042 '<div class="comic-element-resizer" id="comic-element-resizer-top"></div>',
4043 '<div class="comic-element-resizer" id="comic-element-resizer-left"></div>',
4044 '<div class="comic-element-resizer" id="comic-element-resizer-right"></div>',
4045 '<div class="comic-element-resizer" id="comic-element-resizer-bottom"></div>',
4046 '<div class="comic-element-resizer" id="comic-element-resizer-top-left"></div>',
4047 '<div class="comic-element-resizer" id="comic-element-resizer-top-right"></div>',
4048 '<div class="comic-element-resizer" id="comic-element-resizer-bottom-left"></div>',
4049 '<div class="comic-element-resizer" id="comic-element-resizer-bottom-right"></div>',
4050 '<div id="comic-element-consol-pushout-wrapper">',
4051 '<div id="comic-element-consol-pushout-tail"></div>',
4052 '<div id="comic-element-consol-pushout-inner"></div>',
4054 '<div id="balloon-tail-mover"></div>',
4057 '<div id="menu-bar"></div>',
4059 '<div id="templete-container" style="display: none;">',
4060 '<div id="imgElementTemplete" class="comic-element-wrapper image-element"></div>',
4062 '<div id="textElementTemplete" class="comic-element-wrapper text-element">',
4064 '<div class="speach">',
4065 '<div class="speach-inner"> </div>',
4069 '<div id="textElementTempleteForOldIE" class="comic-element-wrapper text-element">',
4071 '<div class="speach">',
4072 '<table><tr><td> </td></tr></table>',
4076 '<div id="imageGroupItemTemplete" class="image-group-item">',
4077 '<div class="image-group-item-title">img-title</div>',
4080 '<div id="windowTemplete" class="window-wrapper">',
4081 '<div class="window-header">',
4082 '<div class="window-header-title">window title</div>',
4083 '<div class="window-close-button">x</div>',
4085 '<div class="window-body"></div>',
4086 '<div class="window-footer">',
4087 '<div class="window-resize-button"></div>',
4091 '<div id="infomation-window">',
4092 '<div id="panel-background-information">',
4093 '<div id="bg-pattern"></div>',
4094 '<div id="select-bg-pattern-button">pattern</div>',
4095 '<div id="reset-bg-pattern-button">x</div>',
4096 '<div id="bg-color"></div>',
4097 '<div id="select-bg-color-button">color</div>',
4098 '<div id="reset-bg-color-button">x</div>',
4099 '<!-- <div id="bg-pattern-x"></div>',
4100 '<div id="bg-pattern-y"></div>',
4101 '<div id="bg-pattern-repeat-x"></div>',
4102 '<div id="bg-pattern-repeat-y"></div> -->',
4106 '<div id="toolbox-window">',
4107 '<div id="toolbox-add-image-button" class="button">add image</div>',
4108 '<div id="toolbox-add-text-button" class="button">add text</div>',
4109 '<div id="toolbox-edit-bg-button" class="button">edit bg</div>',
4110 '<div id="toolbox-switch-grid" class="button">grid</div>',
4111 '<div id="toolbox-popup-help-button" class="button">?</div>',
4112 '<div id="toolbox-post-button" class="button">post</div>',
4118 app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
4119 eventRoot = app.getPointingDeviceEventTreeRoot();
4123 this.onOpen = function( _w, _h, _file ){
4124 // 表示奥の物から順に init() していく
4125 PANEL_ELEMENT_CONTROL.init();
4126 PANEL_CONTROL.init();
4127 // PANEL_RESIZER_BOTTOM.init();
4128 // PANEL_RESIZER_TOP.init();
4129 WINDOWS_CONTROL.init();
4130 MENU_BAR_CONTROL.init();
4132 // レイヤーにあまり関係ないモジュール
4133 HISTORY_CONTROL.init();
4134 SAVE_CONTROL.init();
4135 GRID_CONTROL.init();
4136 WHITE_GLASS_CONTROL.init();
4137 PanelElementOperatorManager.init();
4146 fileData, panelElements, panelElm;
4148 if( FileAPI.isFileInstance( _file ) === true ){
4149 if( Driver.isPettanrFileInstance( _file ) === true ){
4150 if( _file.getType() === FILE_TYPE.COMIC ){
4151 fileData = _file.read();
4152 panelW = fileData.width;
4153 panelH = fileData.height;
4154 comicID = fileData.id || -1;
4156 if( _file.getType() === FILE_TYPE.PANEL ){
4157 fileData = _file.read();
4158 panelW = fileData.width;
4159 panelH = fileData.height;
4160 borderSize = fileData.border;
4161 panelElements = fileData.panel_elements;
4162 comicID = fileData.comic ? fileData.comic.id || -1 : -1;
4163 panelID = fileData.id || -1;
4164 panelTimming = fileData.t || -1;
4171 // open() は各モジュールの init() 後に実施可能になる.
4172 HISTORY_CONTROL.open();
4173 SAVE_CONTROL.open();
4174 WINDOWS_CONTROL.open();
4176 GRID_CONTROL.open();
4177 PANEL_CONTROL.open( panelW, panelH, borderSize );
4178 PanelElementOperatorManager.open();
4179 PANEL_ELEMENT_CONTROL.open();
4182 MENU_BAR_CONTROL.open();
4186 app.onPaneResize( _w, _h );
4189 if( Type.isArray( panelElements ) === true ){
4190 for( var i=0; i<panelElements.length; ++i ){
4191 panelElm = panelElements[ i ];
4192 if( panelElm.resource_picture ){
4193 PANEL_ELEMENT_CONTROL.createImageElement( panelElm );
4195 if( panelElm.balloon_template_id ){
4196 PANEL_ELEMENT_CONTROL.createTextElement( panelElm );
4204 app.addKeyEventListener( 'keydown', centering, 96, false, true ); // ctrl + 0
4205 app.addKeyEventListener( 'krydown', centering, 48, false, true ); // ctrl + 0
4206 MENU_BAR_CONTROL.EDIT.createOption( 'centering', 'ctrl + 0', centering, true, true, true);
4212 this.onClose = function(){
4214 HISTORY_CONTROL.close();
4216 WINDOWS_CONTROL.close();
4218 GRID_CONTROL.close();
4219 PANEL_CONTROL.close();
4221 PanelElementOperatorManager.close();
4222 PANEL_ELEMENT_CONTROL.close();
4225 MENU_BAR_CONTROL.close();
4229 this.onPaneResize = function( _windowW, _windowH ){
4230 windowW = _windowW || windowW;
4231 windowH = _windowH || windowH;
4233 app.rootElement.style.height = _windowH + 'px';
4235 WINDOWS_CONTROL.onWindowResize( _windowW, _windowH );
4236 MENU_BAR_CONTROL.onWindowResize( _windowW, _windowH );
4237 PANEL_CONTROL.onWindowResize( _windowW, _windowH );
4239 }, false, true, 'Panel Editor', 'paneleditor', null, '#2D89F0' );
4241 var FormApplicationHelper = function( app ){
4242 app.isUploading = false;
4243 app.elmProgress = null;
4244 app.elmUploader = null;
4245 app.elmScript = null;
4246 app.elmIframe = null;
4248 app.fetchScript = function(){
4249 app.elmProgress = document.getElementById( app.elmProgressID );
4251 if( !( app.elmUploader = document.getElementById( app.elmUploaderID ) ) ){
4252 app.elmUploader = document.createElement( 'div' );
4253 app.rootElement.appendChild( app.elmUploader );
4254 app.elmUploader.id = app.elmUploaderID;
4255 if( app.hideUploader === true ){
4256 app.elmUploader.style.cssText = 'height:1px;line-height:1px;visibility:hidden;overflow:hidden;';
4260 app.elmScript = document.createElement( 'script' );
4261 document.body.appendChild( app.elmScript );
4262 app.elmScript.type = 'text\/javascript';
4263 app.elmScript.src = app.scriptSrc;
4265 app.elmProgress.innerHTML = 'loading form.';
4267 app.addTimer( app.detectForm, 250 );
4269 delete app.fetchScript;
4271 app.detectForm = function(){
4272 app.elmForm = app.elmUploader.getElementsByTagName( 'form' )[ 0 ];
4273 if( !app.elmForm ) return;
4275 app.removeTimer( app.detectForm );
4276 Util.createIframe( 'targetFrame', app.onCreateIframe );
4277 app.elmProgress.innerHTML = 'create iframe';
4279 delete app.detectForm;
4281 app.onCreateIframe = function( _iframe ){
4282 app.elmUploader.appendChild( _iframe );
4283 app.elmIframe = _iframe;
4284 app.elmForm.target = _iframe.name;
4285 app.elmProgress.innerHTML = '';
4286 app.onFormReady && app.onFormReady();
4288 delete app.onCreateIframe;
4290 app.submit = function(){
4291 app.elmProgress.innerHTML = 'submit!';
4293 app.elmForm.submit();
4294 app.isUploading = true;
4296 app.elmProgress.innerHTML = 'submit err..';
4297 app.submitError && app.submitError();
4300 if( app.detectIframe ){
4301 app.elmIframe.onreadystatechange = app.detectIframe;
4303 app.elmIframe.onload = app.onIframeUpdate;
4305 app.elmProgress.innerHTML = 'uploading..';
4310 app.detectIframe = function(){
4311 if ( this.readyState !== 'complete' ) return;
4312 this.onreadystatechange = new Function();
4313 this.onreadystatechange = null;
4314 app.onIframeUpdate();
4315 delete app.detectIframe;
4318 app.onIframeUpdate = function(){
4319 app.elmIframe.onload = null;
4321 console.log( ( app.elmIframe.contentWindow || app.elmIframe.contentDocument.parentWindow ).document.body.innerHTML );
4322 console.log( ( app.elmIframe.contentWindow || app.elmIframe.contentDocument.parentWindow )[ 'current_author' ] );
4326 ( app.elmIframe.contentWindow || app.elmIframe.contentDocument.parentWindow ).close();
4327 app.elmIframe = null;
4328 app.elmProgress.innerHTML = 'success!';
4329 app.isUploading = false;
4330 app.submitSuccess && app.submitSuccess();
4331 delete app.onIframeUpdate;
4333 app.destroyHelper = function(){
4338 var ComicConsole = gOS.registerApplication( function(){
4339 var elmHeader, elmProgress,
4341 inputTitle, inputW, inputH,
4343 comboboxVisible, // comboboxEditable,
4344 buttonSubmit, buttonCancel,
4348 if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
4351 var _inputList = app.elmForm.getElementsByTagName( 'input' ),
4353 for( var i = _inputList.length; i; ){
4354 _input = _inputList[ --i ];
4355 _name = _input.name;
4356 if( _name === 'comic[title]' ){
4357 _input.value = inputTitle.value();
4359 if( _name === 'comic[width]' ){
4360 _input.value = inputW.value();
4362 if( _name === 'comic[height]' ){
4363 _input.value = inputH.value();
4366 var _selectList = app.elmForm.getElementsByTagName( 'select' ),
4367 _select, _optionList;
4368 for( i = _selectList.length; i; ){
4369 _select = _selectList[ --i ];
4370 _name = _select.name;
4371 _optionList = _select.getElementsByTagName( 'option' )
4372 if( _name === 'comic[visible]' ){
4373 _select.selectedIndex = comboboxVisible.selectIndex();
4375 if( _name === 'comic[editable]' ){
4376 _select.selectedIndex = comboboxEditable.selectIndex();
4381 function clickCancel(){
4382 if( app.isUploading === true ) return false;
4383 ComicConsole.shutdown();
4387 this.MIN_WIDTH = 320;
4388 this.MIN_HEIGHT = 320;
4389 this.onInit = function(){
4390 app.rootElement.id = 'comic-console-wrapper';
4391 app.rootElement.className = 'console-wrapper';
4392 app.rootElement.innerHTML = [
4393 '<div id="comic-console-header" class="console-header">Create New Comic</div>',
4394 '<div id="comic-console" class="console-inner">',
4395 '<div id="comic-console-title" class="field">',
4396 '<span class="field-label">Title:</span>',
4397 '<span id="comic-console-title-value" class="comic-console-value editable-value">No Title</span>',
4399 '<div id="comic-console-width" class="field">',
4400 '<span class="field-label">Default Width:</span>',
4401 '<span id="comic-console-width-value" class="comic-console-value editable-value">300</span>',
4403 '<div id="comic-console-height" class="field">',
4404 '<span class="field-label">Default Height:</span>',
4405 '<span id="comic-console-height-value" class="comic-console-value editable-value">200</span>',
4407 '<div id="comic-console-visible" class="field">',
4408 '<span class="field-label">Visible:</span>',
4409 '<span id="comic-console-visible-value" class="comic-console-value combobox"></span>',
4411 //'<div id="comic-console-editable" class="field">',
4412 // '<span class="field-label">Editable:</span>',
4413 // '<span id="comic-console-editable-value" class="comic-console-value combobox"></span>',
4415 '<div class="console-button-container">',
4416 '<div id="comic-console-post-button" class="button console-submit-button">create</div>',
4417 '<div id="comic-console-cancel-button" class="button console-cancel-button">cancel</div>',
4419 '<div id="comic-console-progress" class="console-progress"> </div>',
4423 app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
4424 eventRoot = app.getPointingDeviceEventTreeRoot();
4428 this.elmProgressID = 'comic-console-progress';
4429 this.elmUploaderID = 'newcomic';
4430 this.elmIframeName = 'targetFrameCreateComic'
4431 this.scriptSrc = pettanr.CONST.CREATE_COMIC_JS;
4432 this.hideUploader = true;
4434 FormApplicationHelper( this );
4436 this.onOpen = function( w, h ){
4437 node = eventRoot.createNode( app.rootElement, true, true );
4439 var ui = app.createUIGroup( node );
4441 inputTitle = ui.createInputText( document.getElementById( 'comic-console-title') );
4442 inputW = ui.createInputText( document.getElementById( 'comic-console-width') );
4443 inputH = ui.createInputText( document.getElementById( 'comic-console-height') );
4444 comboboxVisible = ui.createCombobox( document.getElementById( 'comic-console-visible') );
4445 // comboboxEditable = ui.createCombobox( document.getElementById( 'comic-console-editable') );
4446 buttonSubmit = ui.createButton( document.getElementById( 'comic-console-post-button'), clickOK );
4447 buttonCancel = ui.createButton( document.getElementById( 'comic-console-cancel-button'), clickCancel );
4449 app.onPaneResize( w, h );
4453 this.onPaneResize = function( w, h ){
4456 //app.rootElement.style.cssText = [
4457 // 'left:', Math.floor( ( _w - app.rootElement.offsetWidth ) /2 ), 'px;',
4458 // 'top:', Math.floor( ( _h- app.rootElement.offsetHeight ) /2 ), 'px;'
4460 node.update( w / 2 - node.width() / 2, h / 2 - node.height() / 2 );
4462 this.onClose = function(){
4463 app.destroyHelper();
4464 app = inputTitle = inputW = inputH = comboboxVisible = buttonSubmit = buttonCancel = null;
4466 this.onFormReady = function(){
4467 var selectList = app.elmForm.getElementsByTagName( 'select' ),
4471 for( var i=0, l=selectList.length; i<l; ++i ){
4472 select = selectList[ i ];
4473 optionList = select.getElementsByTagName( 'option' );
4474 for( j=0, m=optionList.length; j<m; ++j ){
4475 option = optionList[ j ];
4476 if( select.name === 'comic[visible]' ){
4477 comboboxVisible.createOption( option.innerHTML, option.value, option.selected );
4479 if( select.name === 'comic[editable]' ){
4480 comboboxEditable.createOption( option.innerHTML, option.value, option.selected );
4487 app.onPaneResize( windowW, windowH );
4489 delete app.onFormReady;
4491 this.submitError = function(){
4492 app.addTimer( clickCancel , 5000, true );
4494 this.submitSuccess = function(){
4495 app.addTimer( clickCancel , 5000, true );
4497 }, true, true, 'Comic Console', 'comicConsole', null, '#D44A26' );
4499 var UploadConsole = gOS.registerApplication( function(){
4500 var windowW, windowH,
4501 eventRoot, node, nodeForm,
4502 buttonSubmit, buttonCancel,
4507 if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
4508 if( elmFile.value.length === 0 ) return false;
4512 function clickCancel(){
4513 if( app.isUploading === true ) return false;
4514 UploadConsole.shutdown();
4519 this.MIN_WIDTH = 320;
4520 this.MIN_HEIGHT = 320;
4521 this.onInit = function(){
4522 app.rootElement.id = 'upload-console-wrapper';
4523 app.rootElement.className = 'console-wrapper';
4524 app.rootElement.innerHTML = [
4525 '<div id="upload-console-header" class="console-header">Upload Picture</div>',
4526 '<div id="upload-console" class="console-inner">',
4527 '<div id="upload-console-uiform"></div>',
4528 '<div class="console-button-container">',
4529 '<div id="upload-console-post-button" class="button console-submit-button">upload</div>',
4530 '<div id="upload-console-cancel-button" class="button console-cancel-button">cancel</div>',
4532 '<div id="upload-console-progress" class="console-progress"> </div>',
4536 app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
4538 eventRoot = app.getPointingDeviceEventTreeRoot();
4539 document.body.appendChild( Util.pullHtmlAsTemplete( '<div id="uploader"></div>' ) );
4542 this.elmProgressID = 'upload-console-progress';
4543 this.elmUploaderID = 'uploader';
4544 this.elmIframeName = 'targetFrameUpload';
4545 this.scriptSrc = pettanr.CONST.UPLOAD_PICTURE_JS;
4546 this.hideUploader = false;
4547 FormApplicationHelper( this );
4548 this.onOpen = function( w, h ){
4549 node = eventRoot.createNode( app.rootElement, true, true );
4550 nodeForm = node.createNode( document.getElementById( 'upload-console-uiform' ), false, true );
4551 var ui = app.createUIGroup( node );
4553 buttonSubmit = ui.createButton( document.getElementById( 'upload-console-post-button' ), clickOK );
4554 buttonCancel = ui.createButton( document.getElementById( 'upload-console-cancel-button' ), clickCancel );
4556 app.onPaneResize( w, h );
4559 this.onPaneResize = function( w, h ){
4562 node.update( w / 2 - node.width() / 2, h / 2 - node.height() / 2 );
4564 this.onClose = function(){
4565 app.destroyHelper();
4566 app = elmFile = buttonSubmit = buttonCancel = null;
4568 this.onFormReady = function(){
4569 var elmForm = app.elmForm,
4570 _inputList = elmForm.getElementsByTagName( 'input' ),
4572 for( var i = _inputList.length; i; ){
4573 _input = _inputList[ --i ];
4574 if( _input.type === 'file' ){
4577 if( _input.type === 'submit' ){
4578 _input.style.display = 'none';
4581 app.onPaneResize( windowW, windowH );
4582 app.createUIForm( nodeForm, elmForm );
4584 node.mesureChildren();
4585 delete app.onFormReady;
4587 this.submitError = function(){
4588 app.addTimer( clickCancel , 5000, true );
4590 this.submitSuccess = function(){
4591 app.addTimer( clickCancel , 5000, true );
4593 }, true, true, 'Upload Console', 'uploadConsole', null, '#01A31C' );
4595 var ArtistConsole = gOS.registerApplication( function(){
4596 var windowW, windowH,
4598 elmName, elmLicense,
4599 inputName, inputLicense,
4600 buttonSubmit, buttonCancel,
4604 if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
4609 function clickCancel(){
4610 if( app.isUploading === true) return false;
4611 ArtistConsole.shutdown();
4614 function inputUpdate( v ){
4615 elmName.value = inputName.value();
4616 elmLicense.value = inputLicense.value();
4620 this.MIN_WIDTH = 320;
4621 this.MIN_HEIGHT = 320;
4622 this.onInit = function(){
4623 app.rootElement.id = 'artist-console-wrapper';
4624 app.rootElement.className = 'console-wrapper';
4625 app.rootElement.innerHTML = [
4626 '<div id="artist-console-header" class="console-header">Register Artist</div>',
4627 '<div id="artist-console" class="console-inner">',
4628 '<div id="artist-console-name" class="field">',
4629 '<span class="field-label">Name:</span>',
4630 '<span id="artist-console-name-value" class="comic-console-value editable-value">artist name here.</span>',
4632 '<div id="artist-console-license" class="field">',
4633 '<span class="field-label">License:</span>',
4634 '<span id="artist-console-license-value" class="comic-console-value editable-value">license here.</span>',
4636 '<div class="console-button-container">',
4637 '<div id="artist-console-post-button" class="button console-submit-button">register</div>',
4638 '<div id="artist-console-cancel-button" class="button console-cancel-button">cancel</div>',
4640 '<div id="artist-console-progress" class="console-progress"> </div>',
4641 '<div id="register" style="display:none;"></div>',
4645 app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
4646 eventRoot = app.getPointingDeviceEventTreeRoot();
4650 this.elmProgressID = 'artist-console-progress';
4651 this.elmUploaderID = 'register';
4652 this.elmIframeName = 'targetFrameArtistRegister'
4653 this.scriptSrc = pettanr.CONST.REGISTER_ARTIST_JS;
4654 this.hideUploader = false;
4655 FormApplicationHelper( this );
4656 this.onFormReady = function(){
4657 var _inputList = app.elmForm.getElementsByTagName( 'input' ),
4659 for( var i = _inputList.length; i; ){
4660 _input = _inputList[ --i ];
4661 if( _input.type === 'submit' ){
4662 _input.style.display = 'none';
4664 if( _input.name === 'artist[name]' ){
4667 if( _input.name === 'artist[default_license_id]' ){
4668 elmLicense = _input;
4673 app.onPaneResize( windowW, windowH );
4674 node.mesureChildren();
4676 delete app.onFormReady;
4678 this.submitError = function(){
4679 app.addTimer( clickCancel , 5000, true );
4681 this.submitSuccess = function(){
4682 app.addTimer( clickCancel , 5000, true );
4684 this.onOpen = function( w, h ){
4685 node = eventRoot.createNode( app.rootElement, true, true );
4686 var ui = app.createUIGroup( node );
4688 inputName = ui.createInputText( document.getElementById( 'artist-console-name' ), inputUpdate );
4689 inputLicense = ui.createInputText( document.getElementById( 'artist-console-license' ), inputUpdate );
4690 buttonSubmit = ui.createButton( document.getElementById( 'artist-console-post-button' ), clickOK );
4691 buttonCancel = ui.createButton( document.getElementById( 'artist-console-cancel-button' ), clickCancel );
4693 app.onPaneResize( w, h );
4696 this.onPaneResize = function( w, h ){
4699 //app.rootElement.style.cssText = [
4700 // 'left:', Math.floor( ( _w - app.rootElement.offsetWidth ) /2 ), 'px;',
4701 // 'top:', Math.floor( ( _h- app.rootElement.offsetHeight ) /2 ), 'px;'
4703 node.update( w / 2 - node.width() / 2, h / 2 - node.height() / 2 );
4705 this.onClose = function(){
4706 app.destroyHelper();
4707 app = buttonSubmit = buttonCancel = null;
4709 }, true, true, 'Artist Console', 'artistConsole', null, '#FFC40D' );
4711 var PanelConsole = gOS.registerApplication( function(){
4712 var windowW, windowH,
4713 eventRoot, node, inputData,
4714 comboboxPublish, buttonPost, buttonClose,
4720 * upload ボタンが押されたらまず iframe をつくる.
4723 if( !app.elmForm || !app.elmIframe || app.isUploading === true ) return false;
4729 function clickCancel(){
4730 if( app.isUploading === true ) return false;
4731 PanelConsole.shutdown();
4734 function publishUpdate(){
4736 model.publish( comboboxPublish.selectIndex() === 1 );
4737 elmInput.value = model.getJsonPostString().replace( /\n/g, '' );
4738 inputData.value( elmInput.value );
4740 elmInput.value = inputData.value();
4745 this.MIN_WIDTH = 320;
4746 this.MIN_HEIGHT = 320;
4747 this.onInit = function(){
4748 app.rootElement.id = 'panel-console-wrapper';
4749 app.rootElement.className = 'console-wrapper';
4750 app.rootElement.innerHTML = [
4751 '<div id="panel-console-header" class="console-header">Create New Panel (dev)</div>',
4752 '<div id="panel-console" class="console-inner">',
4753 '<div id="panel-console-data" class="field">',
4754 '<span class="field-label">POST DATA:</span>',
4755 '<span id="panel-console-data-value" class="comic-console-value editable-value">panel json here.</span>',
4757 '<div id="panel-console-publish" class="field">',
4758 '<span class="field-label">Publish:</span>',
4759 '<span id="panel-console-publish-value" class="combobox"></span>',
4761 '<div class="console-button-container">',
4762 '<div id="panel-console-post-button" class="button console-submit-button">post</div>',
4763 '<div id="panel-console-cancel-button" class="button console-cancel-button">cancel</div>',
4765 '<div id="panel-console-progress" class="console-progress"> </div>',
4766 '<div id="newpanel" style="display:none;"></div>',
4770 app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
4771 eventRoot = app.getPointingDeviceEventTreeRoot();
4775 this.elmProgressID = 'panel-console-progress';
4776 this.elmUploaderID = 'newpanel';
4777 this.elmIframeName = 'targetFrameNewPanel'
4778 this.scriptSrc = pettanr.CONST.CREATE_PANEL_JS;
4779 this.hideUploader = false;
4780 FormApplicationHelper( this );
4781 this.onFormReady = function(){
4782 var _inputList = app.elmForm.getElementsByTagName( 'input' ),
4784 for( var i = _inputList.length; i; ){
4785 _input = _inputList[ --i ];
4786 if( _input.type === 'submit' ){
4787 _input.style.display = 'none';
4789 if( _input.name === 'json' ){
4796 app.onPaneResize( windowW, windowH );
4797 node.mesureChildren();
4799 delete app.onFormReady;
4801 this.submitError = function(){
4802 app.addTimer( clickCancel , 5000, true );
4804 this.submitSuccess = function(){
4805 app.addTimer( clickCancel , 5000, true );
4807 this.onOpen = function( w, h, _model ){
4808 node = eventRoot.createNode( app.rootElement, true, true );
4809 var ui = app.createUIGroup( node ),
4810 elm = document.getElementById( 'panel-console-publish' );
4812 inputData = ui.createInputText( document.getElementById( 'panel-console-data' ), publishUpdate );
4815 comboboxPublish = ui.createCombobox( elm, publishUpdate );
4816 comboboxPublish.createOption( 'only me', '0', _model.publish() === false );
4817 comboboxPublish.createOption( 'publish', '1', _model.publish() === true );
4820 elm.parentNode.removeChild( elm );
4823 buttonPost = ui.createButton( document.getElementById( 'panel-console-post-button' ), clickOK );
4824 buttonClose = ui.createButton( document.getElementById( 'panel-console-cancel-button' ), clickCancel );
4826 app.onPaneResize( w, h );
4829 this.onPaneResize = function( w, h ){
4832 //app.rootElement.style.cssText = [
4833 // 'left:', Math.floor( ( _w - app.rootElement.offsetWidth ) /2 ), 'px;',
4834 // 'top:', Math.floor( ( _h- app.rootElement.offsetHeight ) /2 ), 'px;'
4836 node.update( w / 2 - node.width() / 2, h / 2 - node.height() / 2 );
4838 this.onClose = function(){
4839 app.destroyHelper();
4840 model && model.destroy();
4841 app = model = comboboxPublish = buttonPost = buttonClose = elmInput = null;
4843 }, true, true, 'Panel Console', 'panelConsole', null, '#603CBA' );
4845 var Model = ( function(){
4847 var PanelModelClass = function( panel ){
4848 var comicID = panel.comicID || -1,
4849 panelID = panel.panelID || -1,
4850 panelTimming = panel.panelTimming || -1,
4851 panelW = panel.panelW,
4852 panelH = panel.panelH,
4853 borderSize = panel.borderSize,
4854 panelElementArray = panel.panelElementArray,
4855 publish = panel.publish,
4858 function getPanelElementByTiming(){
4859 var i, l = panelElementArray.length;
4860 while( timing < l * 2 ){
4861 for( i=0; i<l; ++i ){
4862 if( timing === panelElementArray[ i ].timing ){
4863 // console.log( timing + ' , ' + panelElementArray[ i ].timing );
4865 return panelElementArray[ i ];
4872 function panelElementToHtml( _panelElement, isAbsoluteUrl, isXHTML ){
4874 if( _panelElement.type === 0 ){
4875 url = [ pettanr.CONST.RESOURCE_PICTURE_PATH, _panelElement.resourcePicture().id, '.', _panelElement.resourcePicture().ext ].join( '' );
4878 'src="', isAbsoluteUrl !== true ? url : Util.getAbsolutePath( url ), '" ',
4879 'width="', _panelElement.w, '" ',
4880 'height="', _panelElement.h, '" ',
4882 'left:', _panelElement.x, 'px;',
4883 'top:', _panelElement.y, 'px;',
4884 'z-index:', _panelElement.z, ';',
4886 isXHTML !== true ? '>' : ' \/>'
4889 url = pettanr.balloon.getBalloonUrl( _panelElement.w, _panelElement.h, _panelElement.a );
4892 'src="', isAbsoluteUrl !== true ? url : Util.getAbsolutePath( url ), '" ',
4893 'width="', _panelElement.w, '" ',
4894 'height="', _panelElement.h, '" ',
4896 'left:', _panelElement.x, 'px;',
4897 'top:', _panelElement.y, 'px;',
4898 'z-index:', _panelElement.z, ';',
4900 isXHTML !== true ? '>' : ' \/>',
4901 pettanr.LINE_FEED_CODE_TEXTAREA,
4902 '<div class="balloon" style="',
4903 'left:', _panelElement.x, 'px;',
4904 'top:', _panelElement.y, 'px;',
4905 'width:', _panelElement.w, 'px;',
4906 'height:', _panelElement.h, 'px;',
4907 'z-index:', _panelElement.z,
4908 '"><span>', _panelElement.content, '<\/span>', '<\/div>'
4913 function getImageJsonGET( _imageElement ){
4914 var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
4917 '"resource_picture": {', cr,
4918 '"id": ', _imageElement.resourcePicture().id, ',', cr,
4919 '"ext": ', '"',_imageElement.resourcePicture().ext, '"', cr,
4921 '"x": ', _imageElement.x, ',', cr,
4922 '"y": ', _imageElement.y, ',', cr,
4923 '"z": ', _imageElement.z, ',', cr,
4924 '"width": ', _imageElement.flipH * _imageElement.w, ',', cr,
4925 '"height": ', _imageElement.flipV * _imageElement.h, ',', cr,
4926 '"t": ', timing, cr,
4930 function imageToJson( _imageElement, _timing ){
4931 var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
4934 '"picture_id": ', _imageElement.resourcePicture().id, ',', cr,
4935 '"x": ', _imageElement.x, ',', cr,
4936 '"y": ', _imageElement.y, ',', cr,
4937 '"z": ', _imageElement.z + 1, ',', cr,
4938 '"t": ', _timing, ',', cr,
4939 '"width": ', _imageElement.flipH * _imageElement.w, ',', cr,
4940 '"height": ', _imageElement.flipV * _imageElement.h, cr,
4945 function balloonToJson( _textElement, _timing ){
4946 var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
4949 '"balloon_template_id": ', 1, ',', cr,
4950 '"system_picture_id": ', 1, ',', cr,
4951 '"size": ', 1, ',', cr,
4952 '"tail": ', _textElement.a, ',', cr,
4953 '"x": ', _textElement.x, ',', cr,
4954 '"y": ', _textElement.y, ',', cr,
4955 '"z": ', _textElement.z + 1, ',', cr,
4956 '"t": ', timing, ',', cr,
4957 '"width": ', _textElement.w, ',', cr,
4958 '"height": ', _textElement.h, ',', cr,
4959 '"speeches_attributes": {', cr,
4960 '"newf', timing, '": {', cr,
4961 '"content": "', _textElement.content, '",', cr,
4962 '"x": ', _textElement.x, ',', cr,
4963 '"y": ', _textElement.y, ',', cr,
4964 '"t": ', timing, ',', cr,
4965 '"width": ', _textElement.w, ',', cr,
4966 '"height": ', _textElement.h, cr,
4973 this.getJsonPostString = function(){
4976 var JSON_STRING_ARRAY = [],
4979 l = panelElementArray.length,
4981 cr = pettanr.LINE_FEED_CODE_TEXTAREA;
4983 while( IMAGE_ARRAY.length + BALLOON_ARRAY.length <= l ){
4984 _panelElement = getPanelElementByTiming();
4985 if( _panelElement === null) break;
4986 n = IMAGE_ARRAY.length + BALLOON_ARRAY.length;
4987 _panelElement.type === 0 ?
4988 IMAGE_ARRAY.push( [ '"new', n, '": ', imageToJson( _panelElement, n ) ].join( '' ) ) :
4989 BALLOON_ARRAY.push( [ '"new', n, '": ', balloonToJson( _panelElement, n ) ].join( '' ) );
4993 panelID !== -1 ? ( '"id": ' + panelID + ',' + cr ) : '',
4994 comicID !== -1 ? ( '"comic_id": ' + comicID + ',' + cr ) : '',
4995 '"width": ', panelW, ',', cr,
4996 '"height": ', panelH, ',', cr,
4997 '"border": ', borderSize, ',', cr,
4999 // '"picture_id": 1,', cr,
5000 '"x": ', 0, ',', cr,
5001 '"y": ', 0, ',', cr,
5002 '"z": ', 1, ',', cr,
5003 panelTimming !== -1 ? ( '"t": ' + panelTimming + ',' + cr ) : '',
5004 '"panel_pictures_attributes": {', cr,
5005 IMAGE_ARRAY.join( ',' + cr ), cr,
5007 '"speech_balloons_attributes": {', cr,
5008 BALLOON_ARRAY.join( ',' + cr ), cr,
5010 '"publish": ', ( publish === true ? 1 : 0 ), cr,
5014 this.getJsonGetString = function(){
5017 var JSON_STRING_ARRAY = [],
5019 l = panelElementArray.length,
5020 cr = pettanr.LINE_FEED_CODE_TEXTAREA,
5023 while( ELEMENT_ARRAY.length <= l){
5024 _panelElement = getPanelElementByTiming();
5025 if( _panelElement === null ) break;
5027 ELEMENT_ARRAY.push( _panelElement.type === 0 ? getImageJsonGET( _panelElement ) : balloonToJson( _panelElement ));
5032 //'"id": ', panelID, ',', cr,
5033 '"border": ', borderSize, ',', cr,
5034 // '"comic_id": ', comicID, ',', cr,
5035 // '"picture_id": 1,', cr,
5036 '"x": ', 0, ',', cr,
5037 '"y": ', 0, ',', cr,
5038 '"z": ', 1, ',', cr,
5039 // panelTimming !== -1 ? ( '"t": ' + panelTimming + ',' + cr ) : '',
5040 '"width": ', panelW, ',', cr,
5041 '"height": ', panelH, ',', cr,
5042 '"panel_elements": [', cr,
5043 ELEMENT_ARRAY.join( ',' + cr ), cr,
5049 this.getAsHtmlString = function( isAbsoluteUrl, isXHTML ){
5052 var HTML_ARRAY = [],
5053 l = panelElementArray.length,
5056 while( HTML_ARRAY.length < l ){
5057 _panelElement = getPanelElementByTiming();
5058 if( _panelElement === null) break;
5059 HTML_ARRAY.push( panelElementToHtml( _panelElement, isAbsoluteUrl, isXHTML ));
5064 '<div class="panel" ',
5066 'height:', panelH, 'px;',
5067 'background-color:', ';',
5072 HTML_ARRAY.push( '</div>');
5074 return HTML_ARRAY.join( pettanr.LINE_FEED_CODE_TEXTAREA );
5076 this.publish = function( v ){
5077 return publish = Type.isBoolean( v ) === true ? v : publish;
5079 this.destroy = function(){
5080 panel = panelElementArray = null;
5085 createPanel: function( panelData ){
5086 return new PanelModelClass( panelData );
5092 var OutputConsole = gOS.registerApplication( function(){
5093 var FORMAT_LIST = [ 'json[POST]', 'json[GET]', 'XML', 'HTML', 'XHTML', 'MT export', 'Blogger ATOM' ];
5096 comboboxFormat, inputOption,
5097 buttonPost, buttonClose,
5100 comicID, panelID, panelTimming, panelW, panelH, borderSize, panelElementArray,
5105 OutputConsole.shutdown();
5108 function formatUpdate(){
5109 var i = comboboxFormat.selectIndex(),
5111 // buttonPost.enabled( false );
5113 text = model.getJsonPostString();
5114 // buttonPost.enabled( true );
5117 text = model.getJsonGetString();
5120 text = model.getAsHtmlString( false, false );
5124 elmOutputArea.value = text;
5126 function clickClose(){
5127 OutputConsole.shutdown();
5131 function clickPost(){
5132 // PanelConsole.boot( elmOutputArea.value );
5137 this.MIN_WIDTH = 320;
5138 this.MIN_HEIGHT = 320;
5139 this.onInit = function(){
5140 app.rootElement.id = 'output-console-wrapper';
5141 app.rootElement.className = 'console-wrapper';
5142 app.rootElement.innerHTML = [
5143 '<div id="output-console-header" class="console-header">Output Console</div>',
5144 '<div id="output-console" class="console-inner">',
5145 '<div id="output-console-format" class="field">',
5146 '<span class="field-label">Format:</span>',
5147 '<span id="output-console-format-value" class="output-console-value combobox"></span>',
5149 '<div id="output-console-option" class="field">',
5150 '<span class="field-label">Options:</span>',
5151 '<span id="output-console-option-value" class="output-console-value editable-value">absolute-path</span>',
5153 '<textarea id="output-area" readonly></textarea>',
5154 '<div id="output-console-close-button" class="button">close</div>',
5158 app.fetchCSS( pettanr.CONST.URL_PETA_APPS_CSS );
5159 eventRoot = app.getPointingDeviceEventTreeRoot();
5163 this.onOpen = function( _w, _h, _comicID, _panelID, _panelTimming, _panelW, _panelH, _borderSize, _panelElementArray ){
5164 elmOutputArea = document.getElementById( 'output-area' );
5166 node = eventRoot.createNode( app.rootElement, true, true );
5167 var ui = app.createUIGroup( node );
5168 comboboxFormat = ui.createCombobox( document.getElementById( 'output-console-format' ), formatUpdate );
5170 for( var i=0; FORMAT_LIST[ 0 ]; ++i ){
5171 comboboxFormat.createOption( FORMAT_LIST.shift(), null, i === 0 );
5173 inputOption = ui.createInputText( document.getElementById( 'output-console-option' ), null );
5174 // buttonPost = ui.createButton( document.getElementById( 'output-console-post-button' ), clickPost );
5175 buttonClose = ui.createButton( document.getElementById( 'output-console-close-button' ), clickClose );
5177 app.onPaneResize( _w, _h );
5179 comboboxFormat.focus( true );
5181 model = Model.createPanel( {
5184 panelTimming : _panelTimming,
5187 borderSize : _borderSize,
5188 panelElementArray : _panelElementArray,
5194 this.onPaneResize = function( w, h ){
5197 //app.rootElement.style.cssText = [
5198 // 'left:', Math.floor( ( _windowW - app.rootElement.offsetWidth ) /2 ), 'px;',
5199 // 'top:', Math.floor( ( _windowH - app.rootElement.offsetHeight ) /2 ), 'px;'
5201 node.update( w / 2 - node.width() / 2, h / 2 - node.height() / 2 );
5203 this.onClose = function(){
5204 elmOutputArea.value = '';
5206 elmOutputArea = comboboxFormat = inputOption = buttonPost = buttonClose = panelElementArray = instance = model = null;
5208 }, true, false, 'Output Console', 'outputConsole', null, '#2D89F0' );
5210 })( pettanr, gOS, window, document );