11 * ----------------------------------------
\r
18 * THIS_IS_CONST = 'this is const';
\r
24 * jqWrapper, JQ_WRAPPER
\r
26 * value of dom element
\r
27 * elmWrapper, ELM_WRAP
\r
29 * value of vml element
\r
35 /* ----------------------------------------
\r
37 * - MENU_BAR_CONTROL
\r
42 * - INFOMATION_WINDOW
\r
44 * - HELP_DOCUMENTS_WINDOW
\r
47 * - WHITE_GLASS_CONTROL
\r
51 * - PanelResizerClass
\r
52 * - PANEL_RESIZER_TOP
\r
53 * - PANEL_RESIZER_BOTTOM
\r
54 * - CONSOLE_CONTROLER
\r
58 * - POSITION_OPERATOR
\r
59 * - COMIC_ELEMENT_OPERATION_MANAGER
\r
61 * - ImageElementClass
\r
62 * - TextElementClass
\r
64 * - COMIC_ELEMENT_CONTROL
\r
68 pettanr.editor = pettanr.view.registerApplication( function(){
\r
70 var PANEL_ELEMENT_TYPE_IMAGE = 0,
\r
71 PANEL_ELEMENT_TYPE_TEXT = 1,
\r
72 MOUSE_LISTENER_ARRAY = [],
\r
73 PANEL_ELEMENT_ARRAY = [],
\r
74 ELM_MOUSE_EVENT_CHATCHER = document.getElementById( 'mouse-operation-catcher'),
\r
75 MIN_PANEL_HEIGHT = 20,
\r
76 MIN_ELEMENT_SIZE = 19,
\r
77 MOUSE_HIT_AREA = 10,
\r
78 jqMouseEventChacher,
\r
81 currentListener = null,
\r
90 /* ----------------------------------------
\r
92 * - mouseEventListener
\r
103 var MENU_BAR_CONTROL = ( function(){
\r
104 var ELM_BAR = document.getElementById( 'menu-bar'),
\r
105 ELM_ITEM_CLASSNAME = 'menu-bar-item',
\r
106 ELM_ITEM_ORIGN = ( function(){
\r
107 var ret = document.createElement( 'div'),
\r
108 div = document.createElement( 'div'),
\r
109 ul = document.createElement( 'ul');
\r
110 ret.className = ELM_ITEM_CLASSNAME;
\r
111 ret.appendChild( div);
\r
112 ret.appendChild( ul);
\r
115 ELM_SELECTION_ORIGN = ( function(){
\r
116 var ret = document.createElement( 'li'),
\r
117 a = document.createElement( 'a'),
\r
118 span = document.createElement( 'span'),
\r
119 key = document.createElement( 'kbd');
\r
120 a.appendChild( span);
\r
121 a.appendChild( key);
\r
122 ret.appendChild( a);
\r
127 barH = pettanr.util.getElementSize( ELM_BAR).height,
\r
128 itemW = pettanr.util.getElementSize( ELM_ITEM_ORIGN).width,
\r
129 selectionW = pettanr.util.getElementSize( ELM_ITEM_ORIGN.getElementsByTagName( 'ul')[ 0]).width,
\r
131 ELM_BAR.style.top = ( -barH) +'px';
\r
133 var MenubarSelectionClass = function( container, title, shortcut, visible, separateAfter ){
\r
134 var ELM_WRAPPER = ELM_SELECTION_ORIGN.cloneNode( true),
\r
135 ELM_TITLE = ELM_WRAPPER.getElementsByTagName( 'span')[ 0],
\r
136 elmShortcut = ELM_WRAPPER.getElementsByTagName( 'kbd')[ 0];
\r
139 elmShortcut.innerHTML = shortcut;
\r
141 elmShortcut.parentNode.removeChild( elmShortcut);
\r
143 elmShortcut = null;
\r
145 container.appendChild( ELM_WRAPPER);
\r
147 updateTitle( title);
\r
148 updateVisible( visible);
\r
150 function updateTitle( _title){
\r
151 ELM_TITLE.innerHTML = title = _title;
\r
153 function updateVisible( _visible){
\r
154 if( _visible !== undefined){
\r
155 visible = !!_visible;
\r
156 ELM_WRAPPER.className = visible === true ? '' : 'disabled';
\r
161 title: function( _title){
\r
162 _title !== undefined && updateTitle( _title);
\r
165 visible: function( _visible){
\r
166 visible !== !!_visible && updateVisible( _visible);
\r
169 separateAfter: separateAfter
\r
173 var MenuBarItemClass = function( title){
\r
174 var ELM_WRAPPER = ELM_ITEM_ORIGN.cloneNode( true),
\r
175 ELM_TITLE = ELM_WRAPPER.getElementsByTagName( 'div')[ 0],
\r
176 ELM_SELECTION = ELM_WRAPPER.getElementsByTagName( 'ul')[ 0],
\r
177 INDEX = ITEM_ARRAY.length,
\r
178 SELECTION_CALLBACK_ARRAY = [],
\r
181 ELM_TITLE.innerHTML = title;
\r
183 ELM_WRAPPER.style.left = ( itemW * INDEX) +'px';
\r
184 ELM_BAR.appendChild( ELM_WRAPPER);
\r
186 function onClick( e){
\r
187 var i = pettanr.util.getChildIndex( this.parentNode, this);
\r
188 i !== -1 && this.className !== 'disabled' && SELECTION_CALLBACK_ARRAY[ i]( i);
\r
189 e.stopPropagation();
\r
196 $( ELM_SELECTION).children( 'li').click( onClick);
\r
200 if( visible === true) return;
\r
201 jqStage.append( ELM_WRAPPER);
\r
202 ELM_WRAPPER.className = ELM_ITEM_CLASSNAME +'-focus';
\r
203 this.onShow && setTimeout( this.onShow, 0);
\r
207 if( visible === false) return;
\r
208 ELM_BAR.appendChild( ELM_WRAPPER);
\r
209 ELM_WRAPPER.className = ELM_ITEM_CLASSNAME;
\r
210 this.onHide && setTimeout( this.onHide, 0);
\r
213 createSelection: function( title, shortcut, callback, visible, separateBefore, separateAfter){
\r
214 var ret = MenubarSelectionClass.apply( {}, [ ELM_SELECTION, title, shortcut, visible, separateAfter]),
\r
215 before = SELECTION_CALLBACK_ARRAY.length > 0 ? SELECTION_CALLBACK_ARRAY[ SELECTION_CALLBACK_ARRAY.length -1] : null;
\r
216 SELECTION_CALLBACK_ARRAY.push( callback);
\r
217 if( before !== null && ( separateBefore === true || before.separateAfter === true)){
\r
218 ret.elm.style.borderTop = '1px solid #ccc';
\r
226 function createMenubarItem( title){
\r
227 var _item = new MenuBarItemClass( title);
\r
228 ITEM_ARRAY.push( _item);
\r
233 jqStage = jqEditor;
\r
234 jqBar = $( ELM_BAR).animate( { top: 0});
\r
236 var l = ITEM_ARRAY.length;
\r
237 for( var i=0; i<l; ++i){
\r
238 ITEM_ARRAY[ i].init();
\r
241 delete MENU_BAR_CONTROL.init;
\r
244 MENU_BAR_CONTROL.init && MENU_BAR_CONTROL.init();
\r
245 // ELM_BAR.style.top = ( -barH) +'px';
\r
249 var l = ITEM_ARRAY.length;
\r
250 for( var i=0; i<l; ++i){
\r
251 ITEM_ARRAY[ i].hide();
\r
255 onMouseMove: function( _mouseX, _mouseY){
\r
256 if( barH >= _mouseY){
\r
259 var l = ITEM_ARRAY.length;
\r
260 for( var i=0; i<l; ++i){
\r
261 ITEM_ARRAY[ i].hide();
\r
265 onMouseUp: function( _mouseX, _mouseY){
\r
268 onMouseDown: function( _mouseX, _mouseY){
\r
269 var l = ITEM_ARRAY.length;
\r
270 if( barH < _mouseY || itemW * l < _mouseX) return false;
\r
271 for( var i=0; i<l; ++i){
\r
272 if( i * itemW <= _mouseX && _mouseX < ( i +1) * itemW){
\r
273 ITEM_ARRAY[ i].show();
\r
275 ITEM_ARRAY[ i].hide();
\r
280 busy: function( _busy){
\r
283 onWindowResize: function( _windowW, _windowH){
\r
286 QUIT: createMenubarItem( 'Quit'),
\r
287 EDIT: createMenubarItem( 'Edit'),
\r
288 WINDOW: createMenubarItem( 'Window'),
\r
289 HELP: pettanr.util.extend( createMenubarItem( 'Help'), {
\r
290 createAjaxSelection: function( callback){
\r
291 var elmLoading = document.createElement( 'li'),
\r
293 elmSelection = this.elm.getElementsByTagName( 'ul')[ 0];
\r
294 elmSelection.appendChild( elmLoading);
\r
295 elmLoading.className = 'loading';
\r
296 elmLoading.style.height = '90px';
\r
298 this.onShow = callback;
\r
301 delete this.createAjaxSelection;
\r
303 elmSelection.removeChild( elmLoading);
\r
304 $( elmSelection).children( 'li').click( that.onClick);
\r
305 elmLoading = elmSelection = null;
\r
306 delete that.onShow;
\r
315 /* ----------------------------------------
\r
319 var HISTORY_CONTROL = ( function() {
\r
320 var STACK_BACK = [],
\r
321 STACK_FORWARD = [],
\r
322 MENUBAR_BACK = MENU_BAR_CONTROL.EDIT.createSelection( 'back', 'ctrl + z', back, false),
\r
323 MENUBAR_FORWARD = MENU_BAR_CONTROL.EDIT.createSelection( 'forward', 'ctrl + y', forward, false, false, true),
\r
326 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 90, false, true, back); // ctrl + Z
\r
327 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 90, true, true, forward); // ctrl + shift + Z
\r
328 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 89, false, true, forward); // ctrl + Y
\r
332 * currentを控えてSTACK_FORWARD.push(current)
\r
333 * STACK_BACK.pop()を実行してcurrentに
\r
335 if( STACK_BACK.length === 0) return;
\r
337 var state = STACK_BACK.pop();
\r
338 state && state.fn( state.argBack);
\r
339 MENUBAR_BACK.visible( STACK_BACK.length !== 0);
\r
340 SAVE_CONTROL.panelUpdated( STACK_BACK.length !== 0);
\r
342 STACK_FORWARD.push( state);
\r
343 MENUBAR_FORWARD.visible( true);
\r
345 function forward(){
\r
346 if( STACK_FORWARD.length === 0) return;
\r
348 var state = STACK_FORWARD.pop();
\r
349 state.fn( state.argForword);
\r
350 MENUBAR_FORWARD.visible( STACK_FORWARD.length !== 0);
\r
352 STACK_BACK.push( state);
\r
353 MENUBAR_BACK.visible( true);
\r
354 SAVE_CONTROL.panelUpdated( true);
\r
356 function destroyStack( _stack, _destroy){
\r
359 var _argBack = _stack.argBack,
\r
360 _argForword = _stack.argForword,
\r
362 if( Type.isArray( _argBack ) === true ){ // isArray
\r
363 while( _argBack.length > 0){
\r
364 _value = _argBack.shift();
\r
365 _destroy === true && Type.isFunction( _value.destroy ) === true && _value.destroy();
\r
368 if( Type.isArray( _argForword ) === true ){
\r
369 while( _argForword.length > 0){
\r
370 _value = _argForword.shift();
\r
371 _destroy === true && Type.isFunction( _value.destroy ) === true && _value.destroy();
\r
377 log = $( '#history-log');
\r
378 delete HISTORY_CONTROL.init;
\r
381 HISTORY_CONTROL.init && HISTORY_CONTROL.init();
\r
384 MENUBAR_BACK.visible( false);
\r
385 MENUBAR_FORWARD.visible( false);
\r
386 while( STACK_BACK.length > 0){
\r
387 destroyStack( STACK_BACK.shift(), true );
\r
389 while( STACK_FORWARD.length > 0){
\r
390 destroyStack( STACK_FORWARD.shift(), true );
\r
393 saveState: function( _function, _argBack, _argForword, _destroy) {
\r
397 argForword: _argForword,
\r
400 MENUBAR_BACK.visible( true);
\r
401 SAVE_CONTROL.panelUpdated( true);
\r
404 while( STACK_FORWARD.length > 0){
\r
405 _stack = STACK_FORWARD.shift();
\r
406 destroyStack( _stack, _stack.destroy );
\r
408 MENUBAR_FORWARD.visible( false);
\r
413 /* ----------------------------------------
\r
417 var SAVE_CONTROL = ( function(){
\r
418 var SAVE = MENU_BAR_CONTROL.QUIT.createSelection( 'save', 'ctrl + S', quit, false),
\r
419 SAVE_AND_QUIT = MENU_BAR_CONTROL.QUIT.createSelection( 'save & quit', null, quit, false, false, true),
\r
420 EXPORT = MENU_BAR_CONTROL.QUIT.createSelection( 'export', null, onExport, true, false, true),
\r
421 QUIT = MENU_BAR_CONTROL.QUIT.createSelection( 'quit', null, quit, true, true),
\r
425 pettanr.editor.shutdown();
\r
428 function onExport(){
\r
429 pettanr.outputConsole.bootInOverlay(
\r
430 comicID, panelID, panelTimming,
\r
431 PANEL_CONTROL.w(), PANEL_CONTROL.h(),
\r
432 2, // border, BackgroundImage
\r
433 PANEL_ELEMENT_ARRAY
\r
437 open: function(){},
\r
438 close: function(){},
\r
440 panelUpdated: function( _updated){
\r
441 if( _updated !== undefined && updated !== _updated ){
\r
442 SAVE.visible( !!_updated );
\r
443 SAVE_AND_QUIT.visible( !!_updated );
\r
444 updated = !!_updated;
\r
454 /* ----------------------------------------
\r
457 * - mouseEventListener
\r
459 var WINDOWS_CONTROL = ( function(){
\r
461 * 表示上手前にあるwindowは、WINDOW_ARRAYの先頭にあり、htmlでは後ろにある。
\r
463 var DEFAULT_MIN_WINDOW_WIDTH = 200,
\r
464 DEFAULT_MIN_WINDOW_HEIGHT = 200,
\r
466 WINDOW_BODY_BODER_SIZE = 1,
\r
469 currentWindowIndex = -1,
\r
472 var jqWindowOrigin,
\r
474 var WindowClass = function( bodyTempleteID, title, x, y, w, h, visible, CLOSE_BUTTON_ENABLED, RESIZE_BUTTON_ENABLED, minWindowW, minWindowH){
\r
475 var MOUSE_CURSOR = updateMouseCursor,
\r
476 MENUBAR_SELWCTION = MENU_BAR_CONTROL.WINDOW.createSelection(
\r
477 ( visible !== true ? 'show ' : 'hide ') +title,
\r
478 null, onMenuClick, true
\r
481 jqWrapper, jqHeader, jqFooter = null,
\r
482 elmBody, elmBodyStyle,
\r
483 startX, startY, startW, startH,
\r
485 headerH, bodyH, footerH = 0,
\r
486 isDragging = false,
\r
487 isResizing = false,
\r
488 bodyIsTachable = false,
\r
491 function onMenuClick(){
\r
492 visible === true ? instance.close() : instance.open();
\r
494 function update( _x, _y, _w, _h){
\r
495 _x = _x !== undefined ? _x : x;
\r
496 _y = _y !== undefined ? _y : y;
\r
497 _y = _y > MENU_BAR_CONTROL.h ? _y : MENU_BAR_CONTROL.h;
\r
498 _w = _w !== undefined ? _w : w;
\r
499 _h = _h !== undefined ? _h : h;
\r
506 bodyH = _h -headerH -footerH;
\r
507 elmBodyStyle.height = bodyH +'px';
\r
508 ( w !== _w || h !== _h) && instance.onResize && instance.onResize( _w, bodyH);
\r
514 function bodyBackOrForward( isBack){
\r
515 if( !instance) return;
\r
516 if( bodyIsTachable === !isBack) return;
\r
517 elmBodyStyle.position = isBack === true ? 'relative' : 'absolute';
\r
518 elmBodyStyle.left = isBack === true ? 0 : x +'px';
\r
519 elmBodyStyle.top = isBack === true ? 0 : y +headerH +'px';
\r
520 elmBodyStyle.width = isBack === true ? '' : ( w -WINDOW_BODY_BODER_SIZE *2) +'px';
\r
521 bodyIsTachable === isBack && isBack === true ? jqHeader.after( elmBody) : jqStage.append( elmBody);
\r
522 bodyIsTachable = !isBack;
\r
524 function onWindowResize( e){
\r
525 bodyBackOrForward( true);
\r
533 MOUSE_CURSOR( 'nw-resize');
\r
534 e.stopPropagation();
\r
538 init: function( jqContainer){
\r
540 * setTimeout で呼ばれるグローバルメソッド内では、this でなく instance を使う.
\r
544 jqWindowOrigin = jqWindowOrigin || ( function(){
\r
545 return $( $( '#windowTemplete').remove().html());
\r
547 closeButtonWidth = closeButtonWidth || ( function(){
\r
548 return pettanr.util.getElementSize( jqWindowOrigin.clone( true).find( '.window-close-button').get( 0)).width;
\r
551 jqStage = jqEditor;
\r
552 this.$ = jqWrapper = jqWindowOrigin.clone( true);
\r
553 jqHeader = jqWrapper.children( '.window-header').eq( 0).html( title);
\r
554 headerH = pettanr.util.getElementSize( jqHeader.get( 0)).height;
\r
555 elmBody = jqWrapper.children( '.window-body').get( 0);
\r
556 elmBodyStyle = elmBody.style;
\r
558 if( bodyTempleteID) {
\r
559 jqWrapper.find( '.window-body-insert-position').replaceWith( $( $( '#' +bodyTempleteID).remove().html()));
\r
561 jqWrapper.find( '.window-body-insert-position').remove();
\r
563 CLOSE_BUTTON_ENABLED !== true && jqWrapper.find( '.window-close-button').remove();
\r
565 this.onInit && this.onInit();
\r
568 x: function(){ return x;},
\r
569 y: function(){ return y;},
\r
570 w: function(){ return w;},
\r
571 h: function(){ return h;},
\r
573 title: function( _title){
\r
574 typeof _title === 'string' && jqHeader.html( _title);
\r
575 title = typeof _title === 'string' ? _title : title;
\r
579 firstOpen: function(){
\r
580 if( RESIZE_BUTTON_ENABLED === true){
\r
581 footerH = pettanr.util.getElementSize( jqWrapper.find( '.window-footer').get( 0)).height;
\r
582 //jqWrapper.find( '.window-resize-button').eq( 0).mousedown( onWindowResize);
\r
584 jqWrapper.find( '.window-footer').remove();
\r
586 this.onFirstOpen && this.onFirstOpen( w, h -headerH -footerH);
\r
588 update( x, y, w, h);
\r
590 delete this.firstOpen;
\r
593 if( visible === true) return;
\r
594 instance.visible = visible = true;
\r
595 openWindow( instance);
\r
596 MENUBAR_SELWCTION.title( 'hide ' +title);
\r
598 for( var i=0, l = WINDOW_ARRAY.length; i<l; ++i){
\r
599 if( WINDOW_ARRAY[ i] === instance){
\r
600 WINDOW_ARRAY.splice( i, 1);
\r
601 WINDOW_ARRAY.unshift( instance);
\r
602 currentWindow = null;
\r
603 currentWindowIndex = -1;
\r
607 onFadeIn: function(){
\r
608 instance.firstOpen && instance.firstOpen();
\r
609 instance.onOpen && setTimeout( callOnOpen, 0);
\r
610 function callOnOpen(){
\r
611 instance.onOpen( w, bodyH);
\r
614 onFadeOut: function(){
\r
615 var elmWrapper = jqWrapper.get(0);
\r
616 elmWrapper.parentNode.removeChild( elmWrapper);
\r
617 instance.onClose && setTimeout( instance.onClose, 0);
\r
620 if( visible === false) return;
\r
621 instance.visible = visible = false;
\r
622 jqWrapper.fadeOut( instance.onFadeOut);
\r
623 MENUBAR_SELWCTION.title( 'show ' +title);
\r
625 bodyBackOrForward: bodyBackOrForward,
\r
626 onMouseDown: function( _mouseX, _mouseY){
\r
627 if( RESIZE_BUTTON_ENABLED === true && x +w -20 <= _mouseX && _mouseX < x +w && y +headerH +bodyH < _mouseY && _mouseY <= y +h){
\r
628 bodyBackOrForward( true);
\r
636 MOUSE_CURSOR( 'nw-resize');
\r
640 if( x > _mouseX || y > _mouseY || x +w < _mouseX || y +headerH < _mouseY ) return;
\r
641 if( CLOSE_BUTTON_ENABLED === true && x +w -closeButtonWidth < _mouseX){
\r
647 MOUSE_CURSOR( 'move');
\r
655 onMouseUp: function( _mouseX, _mouseY){
\r
656 isDragging = isResizing = false;
\r
659 onMouseMove: function( _mouseX, _mouseY){
\r
660 var _updateX = _mouseX -offsetX,
\r
661 _updateY = _mouseY -offsetY;
\r
663 if( isResizing === true){
\r
664 var _w = startW +_updateX,
\r
665 _h = startH +_updateY;
\r
666 update( startX, startY, _w < minWindowW ? minWindowW : _w, _h < minWindowH ? minWindowH : _h);
\r
669 if( isDragging === true) {
\r
670 update( startX +_updateX, startY +_updateY);
\r
673 if( x > _mouseX || x +w < _mouseX ) return;
\r
675 ( y <= _mouseY && y +headerH >= _mouseY ) ?
\r
676 MOUSE_CURSOR( 'pointer') : // hit to header
\r
678 bodyBackOrForward( y +headerH > _mouseY || y +headerH +bodyH < _mouseY);
\r
680 onMouseOut: function( _mouseX, _mouseY){
\r
681 bodyIsTachable === true && bodyBackOrForward( true);
\r
682 isDragging = false;
\r
686 return isDragging === true || isResizing === true;
\r
688 bodyHeight: function(){
\r
694 function getCurrentIndex( _mouseX, _mouseY){
\r
695 if( currentWindow && currentWindow.busy() === true) return currentWindowIndex;
\r
696 var l = WINDOW_ARRAY.length,
\r
697 _currentWindow = null,
\r
699 currentWindowIndex = -1;
\r
700 for( var i=0; i<l; i++){
\r
701 _win = WINDOW_ARRAY[ i];
\r
702 if( _win.visible !== true) continue;
\r
705 if( _x <= _mouseX && _y <= _mouseY && _x +_win.w() >= _mouseX && _y +_win.h() >= _mouseY){
\r
706 _currentWindow = _win;
\r
707 currentWindowIndex = i;
\r
711 currentWindow && currentWindow !== _currentWindow && currentWindow.onMouseOut( _mouseX, _mouseY);
\r
712 currentWindow = _currentWindow;
\r
713 return currentWindowIndex;
\r
715 function openWindow( _window){
\r
716 if( _window.visible !== true) return;
\r
717 var _jqWindow = _window.$;
\r
718 jqContainer.append( _jqWindow);// appendした後に fadeIn() しないと ie で filterが適用されない.
\r
719 _jqWindow.fadeIn( _window.onFadeIn);
\r
725 jqContainer = $( '#window-container');
\r
727 var l = WINDOW_ARRAY.length,
\r
729 for( var i=l-1; i >= 0; --i){
\r
730 _window = WINDOW_ARRAY[ i];
\r
731 _window.init && _window.init( jqContainer);
\r
732 _window.visible === true && openWindow( _window);
\r
734 log = $( '#window-log');
\r
736 delete WINDOWS_CONTROL.init;
\r
739 WINDOWS_CONTROL.init && WINDOWS_CONTROL.init();
\r
744 onMouseMove: function( _mouseX, _mouseY){
\r
745 var _index = getCurrentIndex( _mouseX, _mouseY);
\r
747 currentWindow.onMouseMove( _mouseX, _mouseY);
\r
750 if( _index > 0){ // 先頭のクリックでない場合
\r
752 WINDOW_ARRAY.splice( currentWindowIndex, 1);
\r
753 WINDOW_ARRAY.unshift( currentWindow);
\r
755 jqContainer.append( currentWindow.$);
\r
756 currentWindowIndex = 0;
\r
761 onMouseUp: function( _mouseX, _mouseY){
\r
762 if( getCurrentIndex( _mouseX, _mouseY) === 0){
\r
763 currentWindow.onMouseUp( _mouseX, _mouseY);
\r
768 onMouseDown: function( _mouseX, _mouseY){
\r
769 if( getCurrentIndex( _mouseX, _mouseY) === 0){
\r
770 currentWindow.onMouseDown( _mouseX, _mouseY);
\r
776 return currentWindow !== null;
\r
778 onWindowResize: function( _windowW, _windowH){
\r
783 createWindow: function( EXTENDS, bodyTempleteID, title, x, y, w, h, opt_visible, opt_closeButtonEnabled, opt_resizeButtonEnabled, opt_minWindowW, opt_minWindowH){
\r
784 opt_visible = opt_visible !== false;
\r
785 opt_closeButtonEnabled = opt_closeButtonEnabled === true;
\r
786 opt_resizeButtonEnabled = opt_resizeButtonEnabled === true;
\r
787 opt_minWindowW = opt_minWindowW || ( w < DEFAULT_MIN_WINDOW_WIDTH) ? w : DEFAULT_MIN_WINDOW_WIDTH;
\r
788 opt_minWindowH = opt_minWindowH || ( h < DEFAULT_MIN_WINDOW_HEIGHT) ? h : DEFAULT_MIN_WINDOW_HEIGHT;
\r
790 var _window = pettanr.util.extend(
\r
792 bodyTempleteID, title, x, y, w, h, opt_visible, opt_closeButtonEnabled, opt_resizeButtonEnabled, opt_minWindowW, opt_minWindowH
\r
796 WINDOW_ARRAY.unshift( _window);
\r
797 WINDOWS_CONTROL.init === undefined && _window.init( jqContainer);
\r
798 WINDOWS_CONTROL.init === undefined && openWindow( _window);
\r
804 /* ----------------------------------------
\r
808 var TOOL_BOX_WINDOW = ( function(){
\r
809 var addImageButton, addTextButton, editBgButton, switchGridButton, popupHelpButton, postButton,
\r
812 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 73, false, true, addImage);
\r
813 MENU_BAR_CONTROL.EDIT.createSelection( 'Add Image', 'ctrl + I', addImage, true, true, false);
\r
815 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 84, false, true, addText);
\r
816 MENU_BAR_CONTROL.EDIT.createSelection( 'Add Text', 'ctrl + T', addText, true, false, true);
\r
818 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 71, false, true, switchGrid);
\r
819 MENU_BAR_CONTROL.EDIT.createSelection( 'show Grid', 'ctrl + G', switchGrid, true, true, true);
\r
821 function addImage( e){
\r
822 setTimeout( IMAGE_EXPLORER_WINDOW.open, 0);
\r
823 instance.bodyBackOrForward( true );
\r
824 e && e.preventDefault && e.preventDefault();
\r
827 function addText( e){
\r
828 setTimeout( COMIC_ELEMENT_CONTROL.createTextElement, 0);
\r
829 e && e.preventDefault && e.preventDefault();
\r
832 function switchGrid( e){
\r
833 setTimeout( GRID_CONTROL.update, 0);
\r
834 e && e.preventDefault && e.preventDefault();
\r
837 function popupHelp( e){
\r
838 instance.bodyBackOrForward( true);
\r
839 setTimeout( HELP_DOCUMENTS_WINDOW.open, 0);
\r
840 e && e.preventDefault && e.preventDefault();
\r
843 function editBG( e){
\r
844 instance.bodyBackOrForward( true);
\r
845 setTimeout( INFOMATION_WINDOW.open, 0);
\r
846 e && e.preventDefault && e.preventDefault();
\r
850 return WINDOWS_CONTROL.createWindow(
\r
852 onInit: function(){
\r
854 delete this.onInit;
\r
856 onFirstOpen: function(){
\r
857 addImageButton = $( '#toolbox-add-image-button').click( addImage);
\r
858 addTextButton = $( '#toolbox-add-text-button').click( addText);
\r
859 editBgButton = $( '#toolbox-edit-bg-button').click( editBG);
\r
860 switchGridButton = $( '#toolbox-switch-grid').click( switchGrid);
\r
861 popupHelpButton = $( '#toolbox-popup-help-button').click( popupHelp);
\r
863 postButton = $( '#toolbox-post-button');
\r
865 delete this.onFirstOpen;
\r
868 'toolbox-window', 'Tool box', 0, 215, 110, 290, true
\r
873 /* ----------------------------------------
\r
877 var IMAGE_EXPLORER_WINDOW = ( function(){
\r
878 var instance, finder;
\r
880 function onFileSelect( _file ){
\r
881 // 他の image ファイルも許可する?
\r
882 if( pettanr.driver.isPettanrFileInstance( _file ) === true ){
\r
883 if( _file.getType() === pettanr.driver.FILE_TYPE.PICTURE ){
\r
884 COMIC_ELEMENT_CONTROL.onImageSelect( pettanr.driver._getAPI().getFileData( _file ) );
\r
889 return WINDOWS_CONTROL.createWindow(
\r
891 onInit: function(){
\r
893 delete this.onInit;
\r
895 onOpen: function( _w, _h){
\r
896 finder = finder || pettanr.finder.createFinder(
\r
898 document.getElementById( 'image-exproler-container'),
\r
899 pettanr.driver.createPictureTree(),
\r
902 COMIC_ELEMENT_CONTROL.onImageSelect
\r
905 finder.resize( _w, _h );
\r
907 onResize: function( _w, _h ){
\r
908 finder.resize( _w, _h );
\r
911 'image-exproler', 'Album', 0, 215, 600, 350, false, true, true, 300, 300
\r
916 /* ----------------------------------------
\r
917 * INFOMATION_WINDOW
\r
920 var INFOMATION_WINDOW = ( function(){
\r
921 var FADE_EFFECT_ENABLED = true, //pettanr.ua.isIE === false || pettanr.ua.ieVersion >= 8,
\r
922 FADE_IN_EFFECT = FADE_EFFECT_ENABLED === true ? 'fadeIn' : 'show',
\r
923 FADE_OUT_EFFECT = FADE_EFFECT_ENABLED === true ? 'fadeOut' : 'hide',
\r
924 backgroundInfomationElm,
\r
925 jqComicElementInformation,
\r
926 inputX, inputY, inputZ, inputA, inputW, inputH, inputAspectRatio,
\r
927 inputPercentW, inputPercentH,
\r
928 currentComicElement = null,
\r
929 currentElementType = -1,
\r
930 currentLock = false;
\r
932 return WINDOWS_CONTROL.createWindow(
\r
934 onFirstOpen: function( _w, _h){
\r
935 backgroundInfomationElm = $( '#panel-background-information');
\r
937 jqComicElementInformation = $( '#comic-element-infomation').hide().css( {
\r
940 var TAB_GROUP_ID = 'comic-element-attribute';
\r
941 var CREATER = pettanr.form.createInputText;//pettanr.key.createEditableText;
\r
942 inputX = CREATER( document.getElementById( 'comic-element-x'), null, TAB_GROUP_ID);
\r
943 inputY = CREATER( document.getElementById( 'comic-element-y'), null, TAB_GROUP_ID);
\r
944 inputZ = CREATER( document.getElementById( 'comic-element-z'), null, TAB_GROUP_ID);
\r
945 inputA = CREATER( document.getElementById( 'comic-element-a'), null, TAB_GROUP_ID);
\r
946 inputW = CREATER( document.getElementById( 'comic-element-w'), null, TAB_GROUP_ID);
\r
947 inputH = CREATER( document.getElementById( 'comic-element-h'), null, TAB_GROUP_ID);
\r
948 inputPercentW = CREATER( document.getElementById( 'comic-element-w-percent'), null, TAB_GROUP_ID);
\r
949 inputPercentH = CREATER( document.getElementById( 'comic-element-h-percent'), null, TAB_GROUP_ID);
\r
950 inputAspectRatio = $( '#comic-element-keep-aspect');
\r
951 delete this.onFirstOpen;
\r
953 onResize: function( _w, _h){
\r
954 jqComicElementInformation.css( {
\r
958 update: function( currentElement){
\r
960 if( currentLock === true && currentElement === null) return;
\r
962 var _elementType = currentElement === null ? -1 : currentElement.type,
\r
963 x = currentElement !== null ? currentElement.x : 0,
\r
964 y = currentElement !== null ? currentElement.y : 0,
\r
965 z = currentElement !== null ? currentElement.z : 0,
\r
966 a = _elementType === PANEL_ELEMENT_TYPE_TEXT ? Math.floor( currentElement.angle()) : 0,
\r
967 w = currentElement !== null ? currentElement.w : 0,
\r
968 h = currentElement !== null ? currentElement.h : 0,
\r
969 actualW = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? currentElement.actualW() : 1,
\r
970 actualH = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? currentElement.actualH() : 1,
\r
971 wPercent = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? Math.floor( w / actualW *100) : 0,
\r
972 hPercent = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? Math.floor( h / actualH *100) : 0,
\r
973 keepAspect = currentElement !== null && currentElement.keepAspect === true;
\r
975 if( currentElementType !== _elementType){
\r
976 if( _elementType !== -1){
\r
977 if( _elementType === 1){
\r
978 inputA.visible( true);
\r
979 inputPercentW.visible( false);
\r
980 inputPercentH.visible( false);
\r
981 inputAspectRatio.hide();
\r
983 inputA.visible( false);
\r
984 inputPercentW.visible( true);
\r
985 inputPercentH.visible( true);
\r
986 inputAspectRatio.show();
\r
988 currentElementType === -1 && jqComicElementInformation.stop().css( {
\r
991 })[ FADE_IN_EFFECT]();
\r
993 currentElementType !== -1 && jqComicElementInformation.stop().css({
\r
996 })[ FADE_OUT_EFFECT]();
\r
998 currentElementType = _elementType;
\r
1000 if( currentElementType !== -1){
\r
1004 _elementType === 1 && inputA.value( a);
\r
1007 _elementType === 0 && inputPercentW.value( wPercent);
\r
1008 _elementType === 0 && inputPercentH.value( hPercent);
\r
1013 lock: function( _currentLock){
\r
1014 currentLock = !!_currentLock;
\r
1015 this.bodyBackOrForward( !currentLock);
\r
1018 'infomation-window', 'Infomation', 0, 30, 200, 180, true
\r
1022 /* ----------------------------------------
\r
1026 var HELP_DOCUMENTS_WINDOW = ( function(){
\r
1027 var visible = true,
\r
1031 currentPageIndex = 0,
\r
1033 HELP = MENU_BAR_CONTROL.HELP,
\r
1034 onLoadFunction = HELP.createAjaxSelection( onAjaxStart),
\r
1037 function onAjaxStart( _pageIndex){
\r
1038 currentPageIndex = _pageIndex || currentPageIndex;
\r
1039 if( onHelpLoad !== null){
\r
1041 url: 'help/jp.xml',
\r
1043 success: onHelpLoad
\r
1045 onHelpLoad = null;
\r
1047 onAjaxStart = new Function;
\r
1049 var onHelpLoad = function( _xml){
\r
1050 var jqXML = $( _xml),
\r
1051 helpTitle = jqXML.find( 'pages').eq( 0).attr( 'title'),
\r
1052 elmNavi = document.createElement( 'div'),
\r
1053 elmItemOrigin = document.createElement( 'a'),
\r
1054 elmPages = document.createElement( 'div'),
\r
1055 elmPageOrigin = document.createElement( 'div'),
\r
1056 elmTitleOrigin = document.createElement( 'h2'),
\r
1058 elmNavi.className = 'sidenavi';
\r
1059 elmItemOrigin.className = 'sidenavi-item';
\r
1060 elmItemOrigin.href = '#';
\r
1061 elmPages.className = 'page-contents';
\r
1062 elmPageOrigin.className = 'page-content main';
\r
1063 elmPageOrigin.appendChild( elmTitleOrigin);
\r
1065 //helpTitle && instance.title( helpTitle);
\r
1067 jqXML.find( 'page').each( function(){
\r
1068 var xmlPage = $( this),
\r
1069 title = xmlPage.attr( 'title'),
\r
1070 content = xmlPage.text();
\r
1072 elmItemOrigin.innerHTML = title;
\r
1073 elmNavi.appendChild( elmItemOrigin.cloneNode( true));
\r
1075 elmTitleOrigin.innerHTML = title;
\r
1077 elmPage = elmPageOrigin.cloneNode( true);
\r
1078 elmPage.innerHTML = content;
\r
1080 pettanr.util.cleanElement( elmPage);
\r
1082 if( elmPage.childNodes.length > 0){
\r
1083 elmPage.insertBefore( elmTitleOrigin.cloneNode( true), elmPage.childNodes[0]);
\r
1085 elmPage.appendChild( elmTitleOrigin.cloneNode( true));
\r
1087 elmPages.appendChild( elmPage);
\r
1089 HELP.createSelection( title, null, onSelectionClick, true);
\r
1093 onLoadFunction = null;
\r
1095 jqAjaxContents.removeClass( 'loading').append( elmNavi, elmPages);
\r
1097 jqNaviItems = jqAjaxContents.find( 'a.' +elmItemOrigin.className).click( onNaviClick);
\r
1098 jqPages = jqAjaxContents.find( '.page-content');
\r
1099 jqPages.find( 'a').click( onInnerLinkClick);
\r
1101 setTimeout( jumpPage, 0);
\r
1103 function onSelectionClick( _pageIndex){
\r
1104 HELP_DOCUMENTS_WINDOW.open();
\r
1105 jumpPage( _pageIndex);
\r
1107 function jumpPage( _index){
\r
1108 if( typeof _index === 'number' && 0 <= _index && _index < numPage && currentPageIndex !== _index){
\r
1109 currentPageIndex = _index;
\r
1111 jqNaviItems.removeClass( 'current').eq( currentPageIndex).addClass( 'current');
\r
1112 jqPages.hide().eq( currentPageIndex).show();
\r
1114 function onNaviClick( e){
\r
1116 jumpPage( pettanr.util.getChildIndex( this.parentNode, this));
\r
1117 e.stopPropagation();
\r
1120 function onInnerLinkClick( e){
\r
1121 var jump = ( this.href || '').split( '#jump'),
\r
1124 jumpPage( '' + parseFloat( n) === n ? parseFloat( n) : -1);
\r
1125 e.stopPropagation();
\r
1128 return WINDOWS_CONTROL.createWindow(
\r
1130 onInit: function(){
\r
1132 jqAjaxContents = this.$.find( '.window-body').addClass( 'loading');
\r
1133 delete this.onInit;
\r
1135 onFirstOpen: function( _w, _h){
\r
1136 jqAjaxContents.css( { height: _h});
\r
1138 delete this.onFirstOpen;
\r
1140 onResize: function( _w, _h){
\r
1141 jqAjaxContents && jqAjaxContents.css( { height: _h});
\r
1144 null, 'Help', 0, 215, 400, 350, false, true, true, 300, 300
\r
1148 /* ----------------------------------------
\r
1151 * - panelResizeListener
\r
1153 var GRID_CONTROL = ( function(){
\r
1154 var ELM_GRID = document.getElementById( 'grid'),
\r
1155 BG_URL = "url('images/grid.gif')",
\r
1161 jqGrid = $( ELM_GRID);
\r
1162 delete GRID_CONTROL.init;
\r
1165 GRID_CONTROL.init && GRID_CONTROL.init();
\r
1167 close: function(){
\r
1170 onPanelResize: function( _panelX, _panelY){
\r
1171 ELM_GRID.style.backgroundPosition = [ _panelX % 10, 'px ', _panelY % 10, 'px'].join( '');
\r
1172 ELM_GRID.style.height = windowH +'px';
\r
1174 enabled: function(){
\r
1177 update: function(){
\r
1181 }).stop()[ visible === true ? 'fadeOut' : 'fadeIn']();
\r
1183 visible = !visible;
\r
1185 if( visible === true && BG_URL !== null){
\r
1186 ELM_GRID.style.backgroundImage = BG_URL;
\r
1194 /* ----------------------------------------
\r
1195 * WHITE_GLASS_CONTROL
\r
1196 * - panelResizeListener
\r
1198 var WHITE_GLASS_CONTROL = ( function(){
\r
1199 var styleTop = document.getElementById( 'whiteGlass-top').style,
\r
1200 styleLeft = document.getElementById( 'whiteGlass-left').style,
\r
1201 styleRight = document.getElementById( 'whiteGlass-right').style,
\r
1202 styleBottom = document.getElementById( 'whiteGlass-bottom').style;
\r
1205 onPanelResize: function( _panelX, _panelY, _panelW, _panelH){
\r
1208 marginTop = _panelY,
\r
1209 marginBottom = windowH -_h -marginTop,
\r
1210 marginX = _panelX,
\r
1211 rightWidth = windowW -_w -marginX;
\r
1213 styleTop.height = ( marginTop < 0 ? 0 : marginTop) +'px';
\r
1215 styleLeft.top = marginTop +'px';
\r
1216 styleLeft.width = ( marginX < 0 ? 0 : marginX) +'px';
\r
1217 styleLeft.height = ( _h + marginBottom) +'px';
\r
1219 styleRight.top = marginTop +'px';
\r
1220 styleRight.left = _w +marginX +'px';
\r
1221 styleRight.width = ( rightWidth < 0 ? 0 : rightWidth) +'px';
\r
1222 styleRight.height = ( _h + marginBottom) +'px';
\r
1224 styleBottom.top = ( _h +marginTop) +'px';
\r
1225 styleBottom.left = marginX +'px';
\r
1226 styleBottom.width = _w +'px';
\r
1227 styleBottom.height = ( marginBottom < 0 ? 0 : marginBottom) +'px';
\r
1233 /* ----------------------------------------
\r
1236 * - mouseEventListener
\r
1238 * panel-border の表示と onPanelResize の通知.
\r
1242 var PANEL_CONTROL = ( function(){
\r
1243 var ELM_PANEL = document.getElementById('panel-tools-container'),
\r
1244 ELM_PANEL_STYLE = ELM_PANEL.style,
\r
1245 DEFAULT_PANEL_WIDTH = 400,
\r
1246 DEFAULT_PANEL_HEIGHT = 300,
\r
1248 panelW, panelH, panelX, panelY,
\r
1249 offsetX, offsetY, startX, startY,
\r
1250 isDragging = false,
\r
1251 isDraggable = false;
\r
1253 pettanr.key.addKeyUpdateEvent( pettanr.view.EDITOR, 32, false, false, onSpaceUpdate);
\r
1255 function onSpaceUpdate(e){
\r
1256 if( e.type === 'keyup'){
\r
1257 currentListener === null && updateMouseCursor( '');
\r
1258 isDraggable = false;
\r
1260 currentListener === null && updateMouseCursor( 'move');
\r
1261 isDraggable = true;
\r
1266 open: function( _panelW, _panelH, _borderSize ){
\r
1267 panelW = Type.isFinite( _panelW ) === true ? _panelW : DEFAULT_PANEL_WIDTH;
\r
1268 panelH = Type.isFinite( _panelH ) === true ? _panelH : DEFAULT_PANEL_HEIGHT;
\r
1269 //panelX = Math.floor( ( windowW -panelW) /2);
\r
1270 //panelY = Math.floor( ( windowH -panelH) /2);
\r
1271 borderSize = Type.isFinite( _borderSize ) === true ? _borderSize : borderSize;
\r
1273 //setTimeout( PANEL_CONTROL.resize, 0);
\r
1275 close: function(){
\r
1290 resize: function( isResizerTopAction, _x, _y, _w, _h){
\r
1291 panelX = _x !== undefined ? _x : panelX;
\r
1292 panelY = _y !== undefined ? _y : panelY;
\r
1293 panelW = _w !== undefined ? _w : panelW;
\r
1294 panelH = _h !== undefined ? _h : panelH;
\r
1296 ELM_PANEL_STYLE.left = ( panelX -borderSize) +'px';
\r
1297 ELM_PANEL_STYLE.top = ( panelY -borderSize) +'px';
\r
1298 ELM_PANEL_STYLE.width = panelW +'px';
\r
1299 ELM_PANEL_STYLE.height = panelH +'px';
\r
1301 PANEL_RESIZER_TOP.onPanelResize( panelX, panelY, panelW, panelH);
\r
1302 PANEL_RESIZER_BOTTOM.onPanelResize( panelX, panelY, panelW, panelH);
\r
1303 GRID_CONTROL.onPanelResize( panelX, panelY);
\r
1304 WHITE_GLASS_CONTROL.onPanelResize( panelX, panelY, panelW, panelH);
\r
1305 COMIC_ELEMENT_CONTROL.onPanelResize( panelX, panelY, panelW, panelH, isResizerTopAction === true);
\r
1307 onWindowResize: function( _windowW, _windowH){
\r
1308 panelX = Math.floor(( _windowW - panelW) / 2);
\r
1309 panelY = Math.floor(( _windowH - panelH) / 2);
\r
1310 PANEL_CONTROL.resize();
\r
1312 onMouseMove: function( _mouseX, _mouseY){
\r
1313 if( isDraggable === true && isDragging === true){
\r
1314 PANEL_CONTROL.resize( false, startX +_mouseX -offsetX, startY +_mouseY -offsetY);
\r
1317 onMouseUp: function( _mouseX, _mouseY){
\r
1318 if( isDraggable === true){
\r
1319 isDragging = false;
\r
1320 updateMouseCursor( '');
\r
1323 onMouseDown: function( _mouseX, _mouseY){
\r
1324 if( isDraggable === true){
\r
1325 offsetX = _mouseX;
\r
1326 offsetY = _mouseY;
\r
1329 isDragging = true;
\r
1330 updateMouseCursor( 'move');
\r
1335 return isDragging === true;
\r
1340 /* --------------------------------------------------------------------------------------------
\r
1341 * PanelResizerClass
\r
1342 * - mouseEventListener
\r
1344 var PanelResizerClass = function( ID, isTop){
\r
1345 var ELM = document.getElementById( ID),
\r
1347 RESIZER_HEIGHT = 30,
\r
1348 x = -BORDER_WIDTH /2,
\r
1349 y = isTop === true ? ( -5 -RESIZER_HEIGHT -BORDER_WIDTH) : 0,
\r
1351 h = RESIZER_HEIGHT,
\r
1352 panelX, panelY, panelW, panelH,
\r
1353 offsetY, startY, startH,
\r
1354 isDragging = false,
\r
1355 MOUSE_CURSOR = updateMouseCursor;
\r
1357 function restoreState( arg){
\r
1358 if( arg && arg.length > 3){
\r
1359 PANEL_CONTROL.resize( isTop, arg[ 0] || panelX, arg[ 1] || panelY, arg[ 2] || panelW, arg[ 3] || panelH);
\r
1363 this.onMouseDown = function( _mouseX, _mouseY){
\r
1364 var _x = _mouseX -panelX,
\r
1365 _y = _mouseY -panelY;
\r
1366 if( _x < x || x + w < _x || _y < y || y + h < _y) return false;
\r
1370 isDragging = true;
\r
1371 MOUSE_CURSOR( 'n-resize');
\r
1374 this.onMouseMove = function( _mouseX, _mouseY){
\r
1375 var _x = _mouseX -panelX,
\r
1376 _y = _mouseY -panelY;
\r
1377 if( isDragging !== true){
\r
1378 if( _x < x || x + w < _x || _y < y || y + h < _y) return false;
\r
1379 COMIC_ELEMENT_OPERATION_MANAGER.hide();
\r
1380 MOUSE_CURSOR( 'pointer');
\r
1383 var move = _y -offsetY;
\r
1384 if( isTop === true){
\r
1385 if( panelH - move < MIN_PANEL_HEIGHT){
\r
1386 move = panelH -MIN_PANEL_HEIGHT;
\r
1388 PANEL_CONTROL.resize( true, panelX, panelY + move, panelW, panelH - move);
\r
1390 var _h = startH +move;
\r
1391 if( 0 < _h && _h < windowH -panelY -RESIZER_HEIGHT -5 -BORDER_WIDTH){
\r
1392 PANEL_CONTROL.resize( false, panelX, panelY, panelW, _h < MIN_PANEL_HEIGHT ? MIN_PANEL_HEIGHT : _h);
\r
1398 this.onMouseUp = function( _mouseX, _mouseY){
\r
1399 if( isDragging !== true) return;
\r
1400 ( startY !== panelY || startH !== panelH) && HISTORY_CONTROL.saveState( restoreState, [ NaN, startY, NaN, startH], [ NaN, panelY, NaN, panelH]);
\r
1401 isDragging = false;
\r
1402 MOUSE_CURSOR( '');
\r
1404 this.busy = function(){
\r
1407 this.onPanelResize = function( _x, _y, _w, _h){
\r
1410 if( panelW !== _w){
\r
1411 ELM.style.width = ( _w +2) +'px';
\r
1415 y = isTop === true ? y : ( panelH +5 +BORDER_WIDTH);
\r
1419 var PANEL_RESIZER_TOP = new PanelResizerClass( 'panel-resizer-top', true ),
\r
1420 PANEL_RESIZER_BOTTOM = new PanelResizerClass( 'panel-resizer-bottom', false );
\r
1422 PanelResizerClass = undefined;
\r
1424 /* --------------------------------------------------------------------------------------------
\r
1425 * CONSOLE_CONTROLER
\r
1427 var CONSOLE_CONTROLER = ( function(){
\r
1428 var LAYER_BACK_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'layer back', 'ctrl + B', layerBack, false, true, false),
\r
1429 LAYER_FORWARD_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'layer forward', 'ctrl + F', layerForward, false, false, false),
\r
1430 DELETE_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'delete', 'ctrl + D', del, false, true, true),
\r
1431 EDIT_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'Edit Text', 'ctrl + E', edit, false, true, false),
\r
1432 CHANGE_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'change', 'ctrl + U', change, false, false, true),
\r
1433 SAVE = HISTORY_CONTROL.saveState,
\r
1438 jqImgConsole, jqTextConsole,
\r
1439 currentElement = null,
\r
1442 imgConsoleWidth, imgConsoleHeight,
\r
1443 textConsoleWidth, textConsoleHeight,
\r
1444 consoleWidth, consoleHeight,
\r
1445 consoleX, consoleY,
\r
1447 buttonClickable = false;
\r
1449 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 66, false, true, layerBack);
\r
1450 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 70, false, true, layerForward);
\r
1452 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 68, false, true, del);
\r
1453 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 69, false, true, edit);
\r
1454 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 85, false, true, change);
\r
1456 function buttonBackOrForward( isBack){
\r
1457 var offest = jqConsoleWrapper.offset();
\r
1458 jqConsoleWrapper.css( {
\r
1459 position: isBack === true ? '' : 'absolute',
\r
1460 left: isBack === true ? consoleX : offest.left,
\r
1461 top: isBack === true ? consoleY : offest.top
\r
1463 buttonClickable === isBack && ( isBack === true ? jqConsoleParent : jqStage).append( jqConsoleWrapper);
\r
1464 buttonClickable = !isBack;
\r
1466 function layerBack(){
\r
1467 if( currentElement === null) return;
\r
1468 if( COMIC_ELEMENT_CONTROL.replace( currentElement, false) === false) return;
\r
1469 INFOMATION_WINDOW.update( currentElement);
\r
1470 SAVE( COMIC_ELEMENT_CONTROL.restoreReplace, [ currentElement, true], [ currentElement, false]);
\r
1471 var _z = currentElement.z;
\r
1472 LAYER_BACK_BUTTON.visible( _z > 0);
\r
1473 LAYER_FORWARD_BUTTON.visible( _z < PANEL_ELEMENT_ARRAY.length -1);
\r
1475 function layerForward(){
\r
1476 if( currentElement === null) return;
\r
1477 if( COMIC_ELEMENT_CONTROL.replace( currentElement, true) === false) return;
\r
1478 INFOMATION_WINDOW.update( currentElement);
\r
1479 SAVE( COMIC_ELEMENT_CONTROL.restoreReplace, [ currentElement, false], [ currentElement, true]);
\r
1480 var _z = currentElement.z;
\r
1481 LAYER_BACK_BUTTON.visible( _z > 0);
\r
1482 LAYER_FORWARD_BUTTON.visible( _z < PANEL_ELEMENT_ARRAY.length -1);
\r
1485 if( currentElement === null) return;
\r
1486 buttonBackOrForward( true);
\r
1487 COMIC_ELEMENT_CONTROL.remove( currentElement);
\r
1488 SAVE( COMIC_ELEMENT_CONTROL.restore, [ true, currentElement], [ false, currentElement], true);
\r
1489 COMIC_ELEMENT_OPERATION_MANAGER.hide();
\r
1492 if( currentElement === null || currentElement.type !== PANEL_ELEMENT_TYPE_TEXT) return;
\r
1493 pettanr.textEditor.bootInOverlay( PANEL_CONTROL.x(), PANEL_CONTROL.y(), currentElement );
\r
1494 buttonBackOrForward( true );
\r
1496 function change(){
\r
1497 if( currentElement === null) return;
\r
1498 buttonBackOrForward( true);
\r
1499 pettanr.premiumSatge.bootInOverlay( currentElement.getArtistID(), currentElement.resourcePicture );
\r
1501 function onImageSelect( resourcePicture ){
\r
1502 currentElement.resourcePicture( resourcePicture );
\r
1506 jqStage = jqEditor;
\r
1507 jqConsoleTail = $( '#comic-element-consol-tail');
\r
1508 jqImgConsole = $( '#image-element-consol').hide();
\r
1509 var imgConsoleSize = pettanr.util.getElementSize( jqImgConsole.get( 0));
\r
1510 imgConsoleWidth = imgConsoleSize.width;
\r
1511 imgConsoleHeight = imgConsoleSize.height;
\r
1513 jqTextConsole = $( '#text-element-consol').hide();
\r
1514 var textConsoleSize = pettanr.util.getElementSize( jqTextConsole.get( 0));
\r
1515 textConsoleWidth = textConsoleSize.width;
\r
1516 textConsoleHeight = textConsoleSize.height;
\r
1518 jqConsoleWrapper = $( '#comic-element-consol-wrapper').hide();
\r
1519 jqConsoleParent = jqConsoleWrapper.parent();
\r
1521 $( '#edit-text-button').click( edit);
\r
1522 $( '#delete-image-button, #delete-text-button').click( del);
\r
1523 $( '#change-image-button').click( change);
\r
1524 $( '#layer-forward-button, #forward-text-button').click( layerForward);
\r
1525 $( '#layer-back-button, #back-text-button').click( layerBack);
\r
1527 delete CONSOLE_CONTROLER.init;
\r
1529 show: function( _currentElement, _w, _h ){
\r
1530 CONSOLE_CONTROLER.init && CONSOLE_CONTROLER.init();
\r
1532 visible === false && jqConsoleWrapper.show();
\r
1534 currentElement = _currentElement;
\r
1535 var _currentType = _currentElement.type,
\r
1536 _z = _currentElement.z;
\r
1537 if( currentType !== _currentType){
\r
1538 currentType = _currentType;
\r
1539 jqImgConsole.toggle( _currentType === PANEL_ELEMENT_TYPE_IMAGE);
\r
1540 jqTextConsole.toggle( _currentType === PANEL_ELEMENT_TYPE_TEXT);
\r
1541 consoleWidth = _currentType === PANEL_ELEMENT_TYPE_IMAGE ? imgConsoleWidth : textConsoleWidth;
\r
1542 consoleHeight = _currentType === PANEL_ELEMENT_TYPE_IMAGE ? imgConsoleHeight : textConsoleHeight;
\r
1544 consoleX = Math.floor( ( _w -consoleWidth) /2);
\r
1546 LAYER_BACK_BUTTON.visible( _z > 0);
\r
1547 LAYER_FORWARD_BUTTON.visible( _z < PANEL_ELEMENT_ARRAY.length -1);
\r
1548 DELETE_BUTTON.visible( true);
\r
1549 EDIT_BUTTON.visible( _currentType === PANEL_ELEMENT_TYPE_TEXT);
\r
1550 CHANGE_BUTTON.visible( false);
\r
1552 if( _w > consoleWidth * 1.5 && _h > consoleHeight * 1.5){
\r
1553 consoleY = Math.floor( ( _h -consoleHeight) /2);
\r
1554 jqConsoleWrapper.css( {
\r
1557 }).removeClass( 'console-out');
\r
1559 consoleY = _h +tailSize;
\r
1560 jqConsoleWrapper.css( {
\r
1563 }).addClass( 'console-out');
\r
1566 hide: function (){
\r
1567 visible === true && jqConsoleWrapper.hide();
\r
1569 currentElement = null;
\r
1570 LAYER_BACK_BUTTON.visible( false);
\r
1571 LAYER_FORWARD_BUTTON.visible( false);
\r
1572 DELETE_BUTTON.visible( false);
\r
1573 EDIT_BUTTON.visible( false);
\r
1574 CHANGE_BUTTON.visible( false);
\r
1576 x: function(){ return consoleX;},
\r
1577 y: function(){ return consoleY;},
\r
1578 w: function(){ return consoleWidth;},
\r
1579 h: function(){ return consoleHeight;},
\r
1580 onMouseMove: function( _mouseX, _mouseY){
\r
1581 if( consoleX > _mouseX || consoleY > _mouseY || consoleX +consoleWidth < _mouseX || consoleY +consoleHeight < _mouseY){
\r
1582 buttonClickable === true && buttonBackOrForward( true);
\r
1585 buttonClickable === false && buttonBackOrForward( false);
\r
1588 onMouseOut: function( _mouseX, _mouseY){
\r
1589 buttonClickable === true && buttonBackOrForward( true);
\r
1594 /* --------------------------------------------------------------------------------------------
\r
1596 * - comicElementOperator
\r
1598 var TAIL_OPERATOR = ( function(){
\r
1599 var MOUSE_CURSOR = updateMouseCursor,
\r
1600 ELM_MOVER = document.getElementById( 'balloon-tail-mover'),
\r
1601 SIZE = pettanr.util.getElementSize( ELM_MOVER).width,
\r
1605 FLOOR = Math.floor,
\r
1606 DEG_TO_RAD = Math.PI / 180,
\r
1607 RAD_TO_DEG = 1 /DEG_TO_RAD,
\r
1608 currentText = null,
\r
1611 balloonW, balloonH, balloonA, radA,
\r
1616 update: function ( _w, _h, _a){
\r
1617 balloonW = _w !== undefined ? _w : balloonW;
\r
1618 balloonH = _h !== undefined ? _h : balloonH;
\r
1619 balloonA = _a !== undefined ? _a : balloonA;
\r
1620 radA = balloonA * DEG_TO_RAD;
\r
1621 tailX = FLOOR( ( ( COS( radA) /2 +0.5) *( balloonW +SIZE)) -SIZE /2);
\r
1622 tailY = FLOOR( ( ( SIN( radA) /2 +0.5) *( balloonH +SIZE)) -SIZE /2);
\r
1623 ELM_MOVER.style.left = tailX +'px';
\r
1624 ELM_MOVER.style.top = tailY +'px';
\r
1625 //log.html( [ balloonW, balloonH, balloonA].join());
\r
1627 show: function( _currentText){
\r
1629 * visibilityのほうがいい, display:none だと ie で描画が狂う
\r
1631 ELM_MOVER.style.visibility = '';
\r
1632 this.update( _currentText.w, _currentText.h, _currentText.angle());
\r
1633 currentText = _currentText;
\r
1635 hitTest: function( _mouseX, _mouseY){
\r
1636 var _x = tailX -SIZE /2,
\r
1637 _y = tailY -SIZE /2;
\r
1638 ret = _x <= _mouseX && _y <= _mouseY && _x +SIZE >= _mouseX && _y +SIZE >= _mouseY;
\r
1639 ret === true && MOUSE_CURSOR( 'move');
\r
1643 ELM_MOVER.style.visibility = 'hidden';
\r
1644 currentText = null;
\r
1646 onStart: function( _currentText, _mouseX, _mouseY){
\r
1647 if( _currentText.type !== PANEL_ELEMENT_TYPE_TEXT) return false;
\r
1648 x = _currentText.x;
\r
1649 y = _currentText.y;
\r
1650 if( this.hitTest( _mouseX -x, _mouseY -y) === true){
\r
1651 w = _currentText.w;
\r
1652 h = _currentText.h;
\r
1653 currentText = _currentText;
\r
1654 startA = _currentText.angle();
\r
1659 onDrag: function( _mouseX, _mouseY){
\r
1660 _mouseX = _mouseX -x -w /2;
\r
1661 _mouseY = _mouseY -y -h /2; //Balloonの中心を0,0とする座標系に変換
\r
1663 this.update( w, h,
\r
1665 ATAN( _mouseY /_mouseX) *RAD_TO_DEG +( _mouseX < 0 ? 180 : 0) :
\r
1666 _mouseY > 0 ? 90 : -90
\r
1668 currentText && currentText.angle( Math.floor( balloonA + 0.5 ));
\r
1669 INFOMATION_WINDOW.update( currentText);
\r
1671 onFinish: function(){
\r
1672 startA !== currentText.angle() && COMIC_ELEMENT_OPERATION_MANAGER.saveStatus( x, y, w, h, startA);
\r
1673 startA !== currentText.angle() && COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y, w, h, currentText.angle());
\r
1674 currentText = null;
\r
1676 onCancel: function(){
\r
1677 currentText.angle( startA);
\r
1678 COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y, w, h, startA);
\r
1679 currentText = null;
\r
1684 /* --------------------------------------------------------------------------------------------
\r
1686 * - comicElementOperator
\r
1688 var RESIZE_OPERATOR = ( function(){
\r
1689 var MOUSE_CURSOR = updateMouseCursor,
\r
1690 GRID_ENABLED = GRID_CONTROL.enabled;
\r
1692 var HIT_AREA = MOUSE_HIT_AREA,
\r
1693 POSITION_ARRAY = [],
\r
1694 FLOOR = Math.floor,
\r
1695 CURSOR_AND_FLIP = [
\r
1696 { cursor: 'n-resize', v: 3},
\r
1697 { cursor: 'e-resize', h: 2},
\r
1698 { cursor: 'e-resize', h: 1},
\r
1699 { cursor: 'n-resize', v: 0},
\r
1700 { cursor: 'nw-resize', h: 5, v: 6, vh: 7},
\r
1701 { cursor: 'ne-resize', h: 4, v: 7, vh: 6},
\r
1702 { cursor: 'ne-resize', h: 7, v: 4, vh: 5},
\r
1703 { cursor: 'nw-resize', h: 6, v: 5, vh: 4}
\r
1705 elmResizerContainer = document.getElementById( 'comic-element-resizer-container'),
\r
1706 elmResizerContainerStyle = elmResizerContainer.style,
\r
1707 elmResizerTopStyle = document.getElementById( 'comic-element-resizer-top').style,
\r
1708 elmResizerLeftStyle = document.getElementById( 'comic-element-resizer-left').style,
\r
1709 elmResizerRightStyle = document.getElementById( 'comic-element-resizer-right').style,
\r
1710 elmResizerBottomStyle = document.getElementById( 'comic-element-resizer-bottom').style,
\r
1712 currentIndex = -1,
\r
1714 currentIsTextElement = false;
\r
1716 elmResizerContainerStyle.display = 'none';
\r
1718 var RESIZE_WORK_ARRAY = [
\r
1719 { x: 0, w: 0, y: 1, h: -1}, //top
\r
1720 { x: 1, w: -1, y: 0, h: 0}, //left
\r
1721 { x: 0, w: 1, y: 0, h: 0}, //right
\r
1722 { x: 0, w: 0, y: 0, h: 1}, //bottom
\r
1723 { x: 1, w: -1, y: 1, h: -1}, //top-left
\r
1724 { x: 0, w: 1, y: 1, h: -1}, //top-right
\r
1725 { x: 1, w: -1, y: 0, h: 1}, //bottom-left
\r
1726 { x: 0, w: 1, y: 0, h: 1} //bottom-right
\r
1728 startX, startY, startW, startH, startFilpV, startFilpH, startAspect,
\r
1729 baseX, baseY, baseW, baseH,
\r
1730 currentX, currentY, currentW, currentH,
\r
1735 function draw( _x, _y, _w, _h){
\r
1736 x = _x !== undefined ? _x : x;
\r
1737 y = _y !== undefined ? _y : y;
\r
1738 w = _w !== undefined ? _w : w;
\r
1739 h = _h !== undefined ? _h : h;
\r
1741 elmResizerContainerStyle.left = x +'px';
\r
1742 elmResizerContainerStyle.top = y +'px';
\r
1743 elmResizerContainerStyle.width = w +'px';
\r
1744 elmResizerContainerStyle.height = h +'px';
\r
1745 elmResizerTopStyle.left = FLOOR( w /2 -10 /2) +'px';
\r
1746 elmResizerLeftStyle.top = FLOOR( h /2 -10 /2) +'px';
\r
1747 elmResizerRightStyle.top = FLOOR( h /2 -10 /2) +'px';
\r
1748 elmResizerBottomStyle.left = FLOOR( w /2 -10 /2) +'px';
\r
1750 alert( [x, y, w, h].join( ','));
\r
1755 POSITION_ARRAY.splice( 0, POSITION_ARRAY.length);
\r
1756 POSITION_ARRAY.push(
\r
1757 {x: x +5, y: y -HIT_AREA, w: w -5 *2, h: HIT_AREA +5},
\r
1758 {x: x -HIT_AREA, y: y +HIT_AREA +5, w: HIT_AREA +5, h: h -5 *2},
\r
1759 {x: x +w -5, y: y +HIT_AREA +5, w: HIT_AREA +5, h: h -5 *2},
\r
1760 {x: x +5, y: y +h -5, w: w -5 *2, h: HIT_AREA +5},
\r
1761 {x: x -HIT_AREA, y: y -HIT_AREA, w: HIT_AREA +5, h: HIT_AREA +5},
\r
1762 {x: x +w -HIT_AREA, y: y -HIT_AREA, w: HIT_AREA +5, h: HIT_AREA +5},
\r
1763 {x: x -HIT_AREA, y: y +h -5, w: HIT_AREA +5, h: HIT_AREA +5},
\r
1764 {x: x +w -5, y: y +h -5, w: HIT_AREA +5, h: HIT_AREA +5}
\r
1768 function update( _x, _y, _w, _h){
\r
1769 x = _x !== undefined ? _x : currentX;
\r
1770 y = _y !== undefined ? _y : currentY;
\r
1771 w = _w !== undefined ? _w : currentW;
\r
1772 h = _h !== undefined ? _h : currentH;
\r
1774 if( currentIsTextElement === false && currentIndex > 3 && pettanr.key.shiftEnabled() === true){
\r
1775 if( startAspect >= 1){
\r
1777 w = Math.floor( startAspect * h);
\r
1778 x = x +( currentIndex % 2 === 0 ? _w -w : 0);
\r
1781 h = Math.floor( w / startAspect);
\r
1782 y = y + ( currentIndex <= 5 ? _h -h : 0);
\r
1785 draw( x, y, w, h);
\r
1786 currentElement.resize( x, y, w, h);
\r
1787 currentIsTextElement === true && TAIL_OPERATOR.update( w, h);
\r
1788 CONSOLE_CONTROLER.show( currentElement, w, h);
\r
1789 INFOMATION_WINDOW.update( currentElement);
\r
1792 function flip( _flipH, _flipV){
\r
1793 var p = CURSOR_AND_FLIP[ currentIndex];
\r
1794 currentIndex = _flipH === true || _flipV === true ? p[
\r
1795 _flipH === true && _flipV === true ? 'vh' : ( _flipH === true ? 'h' : 'v')
\r
1797 MOUSE_CURSOR( CURSOR_AND_FLIP[ currentIndex].cursor);
\r
1798 elmResizerContainer.className = 'current-resizer-is-' +currentIndex;
\r
1799 currentElement.flip( _flipH, _flipV);
\r
1803 index: function( _mouseX, _mouseY){
\r
1805 for( i=4; i<8; i++){
\r
1806 p = POSITION_ARRAY[ i];
\r
1807 if( p.x <= _mouseX && p.y <= _mouseY && p.x + p.w >= _mouseX && p.y +p.h >= _mouseY){
\r
1808 MOUSE_CURSOR( CURSOR_AND_FLIP[ i].cursor);
\r
1809 elmResizerContainer.className = 'current-resizer-is-' +i;
\r
1810 return currentIndex = i;
\r
1813 for( i=0; i<4; i++){
\r
1814 p = POSITION_ARRAY[ i];
\r
1815 if( p.x <= _mouseX && p.y <= _mouseY && p.x + p.w >= _mouseX && p.y +p.h >= _mouseY){
\r
1816 MOUSE_CURSOR( CURSOR_AND_FLIP[ i].cursor);
\r
1817 elmResizerContainer.className = 'current-resizer-is-' +i;
\r
1818 return currentIndex = i;
\r
1821 MOUSE_CURSOR( '');
\r
1822 elmResizerContainer.className = '';
\r
1825 show: function( _currentElement){
\r
1826 currentElement = _currentElement;
\r
1827 currentIsTextElement = _currentElement.type === PANEL_ELEMENT_TYPE_TEXT;
\r
1828 elmResizerContainerStyle.display = '';
\r
1831 currentElement = null;
\r
1832 elmResizerContainerStyle.display = 'none';
\r
1834 onStart: function( _currentElement, _mouseX, _mouseY){
\r
1835 currentElement = _currentElement;
\r
1836 currentIsTextElement = _currentElement.type === PANEL_ELEMENT_TYPE_TEXT;
\r
1837 if( _currentElement.keepSize === true) return false;
\r
1838 currentIndex = this.index( _mouseX, _mouseY);
\r
1839 if( currentIndex === -1) return false;
\r
1840 offsetX = _mouseX;
\r
1841 offsetY = _mouseY;
\r
1842 startX = baseX = _currentElement.x;
\r
1843 startY = baseY = _currentElement.y;
\r
1844 startW = baseW = _currentElement.w;
\r
1845 startH = baseH = _currentElement.h;
\r
1846 if( _currentElement.type === PANEL_ELEMENT_TYPE_IMAGE){
\r
1847 startFilpV = _currentElement.flipV();
\r
1848 startFilpH = _currentElement.flipH();
\r
1850 startAspect = startW /startH;
\r
1853 onDrag: function( _mouseX, _mouseY){
\r
1854 var com = RESIZE_WORK_ARRAY[ currentIndex],
\r
1855 moveX = _mouseX -offsetX,
\r
1856 moveY = _mouseY -offsetY,
\r
1857 _updated = moveX !== 0 || moveY !== 0,
\r
1866 * Opera 11+ often forget values, why ??
\r
1868 while( _x === undefined || _y === undefined || _w === undefined || _h === undefined){
\r
1869 _x = _x !== undefined ? _x : baseX +moveX *com.x;
\r
1870 _y = _y !== undefined ? _y : baseY +moveY *com.y;
\r
1871 _w = _w !== undefined ? _w : baseW +moveX *com.w;
\r
1872 _h = _h !== undefined ? _h : baseH +moveY *com.h;
\r
1873 error += _thisError === 0 ? 0 : 1;
\r
1875 if( _thisError > 9999){
\r
1877 //alert( 'opera error' +error);
\r
1883 if( _w >= MIN_ELEMENT_SIZE && _h >= MIN_ELEMENT_SIZE){
\r
1886 if( _w >= -MIN_ELEMENT_SIZE && _h >= -MIN_ELEMENT_SIZE){
\r
1888 if( _w < MIN_ELEMENT_SIZE){
\r
1889 //_x += Math.abs( MIN_ELEMENT_SIZE -_w);
\r
1891 _w = MIN_ELEMENT_SIZE;
\r
1893 if( _h < MIN_ELEMENT_SIZE){
\r
1894 //_y += Math.abs( MIN_ELEMENT_SIZE -_h);
\r
1896 _h = MIN_ELEMENT_SIZE;
\r
1899 if( currentElement.type === PANEL_ELEMENT_TYPE_TEXT){
\r
1902 if( _w < -MIN_ELEMENT_SIZE || _h < -MIN_ELEMENT_SIZE){
\r
1904 if( _w < -MIN_ELEMENT_SIZE && _h > MIN_ELEMENT_SIZE){
\r
1907 baseX = _x = _x +_w;
\r
1909 baseW = _w = _memoryX -_x;
\r
1911 flip( true, false);
\r
1912 flipV = currentElement.flipV();
\r
1914 if( _w > MIN_ELEMENT_SIZE && _h < -MIN_ELEMENT_SIZE){
\r
1918 baseY = _y = _y +_h;
\r
1920 baseH = _h = _memoryY -_y;
\r
1921 flip( false, true);
\r
1922 flipH = currentElement.flipH();
\r
1927 baseX = _x = _x +_w;
\r
1928 baseY = _y = _y +_h;
\r
1929 baseW = _w = _memoryX -_x;
\r
1930 baseH = _h = _memoryY -_y;
\r
1931 flip( true, true);
\r
1932 flipV = currentElement.flipV();
\r
1933 flipH = currentElement.flipH();
\r
1936 offsetX = _mouseX;
\r
1937 offsetY = _mouseY;
\r
1943 _updated === true && update( _x, _y, _w, _h);
\r
1946 'currentIndex:', currentIndex,
\r
1947 'baseW', baseW, 'baseH', baseH,'<br>',
\r
1948 'mouse', _mouseX, _mouseY,'<br>',
\r
1949 'move', moveX, moveY,'<br>',
\r
1950 'xy', _x, _y, 'wh',_w, _h,'<br>',
\r
1951 'com.w', com.w, 'com.h', com.h,'<br>',
\r
1952 'current',currentW, currentH,'<br>',
\r
1957 onFinish: function(){
\r
1958 MOUSE_CURSOR( '');
\r
1959 if( w === startW && h === startH && x === startX && y === startY) return;
\r
1960 COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y, w, h);
\r
1961 currentElement.resize( x, y, w, h);
\r
1962 COMIC_ELEMENT_OPERATION_MANAGER.saveStatus( startX, startY, startW, startH, undefined, startFilpV, startFilpH);
\r
1964 onCancel: function(){
\r
1965 MOUSE_CURSOR( '');
\r
1966 COMIC_ELEMENT_OPERATION_MANAGER.resize( startX, startY, startW, startH);
\r
1967 currentElement.type === PANEL_ELEMENT_TYPE_IMAGE ?
\r
1968 currentElement.animate( startX, startY, startW, startH, startFilpV, startFilpH) :
\r
1969 currentElement.animate( startX, startY, startW, startH, angle);
\r
1971 lock: function( _lock){
\r
1972 if( _lock !== undefined){
\r
1973 elmResizerContainerStyle.borderColor = _lock === true ? 'blue' : '';
\r
1978 onShiftUpdate: update,
\r
1979 onCtrlUpdate: update
\r
1983 /* --------------------------------------------------------------------------------------------
\r
1984 * POSITION_OPERATOR
\r
1985 * - comicElementOperator
\r
1987 var POSITION_OPERATOR = ( function(){
\r
1988 var MOUSE_CURSOR = updateMouseCursor,
\r
1989 GRID_ENABLED = GRID_CONTROL.enabled;
\r
1991 var currentElement,
\r
1997 function update( _x, _y){
\r
1998 x = _x !== undefined ? _x : x;
\r
1999 y = _y !== undefined ? _y : y;
\r
2000 RESIZE_OPERATOR.update( x, y);
\r
2001 currentElement.resize( x, y);
\r
2002 INFOMATION_WINDOW.update( currentElement);
\r
2006 onStart: function( _currentElement, _mouseX, _mouseY){
\r
2007 currentElement = _currentElement;
\r
2008 offsetX = _mouseX;
\r
2009 offsetY = _mouseY;
\r
2010 startX = x = _currentElement.x;
\r
2011 startY = y = _currentElement.y;
\r
2012 MOUSE_CURSOR( 'move');
\r
2014 onDrag: function( _mouseX, _mouseY){
\r
2015 var moveX = _mouseX -offsetX,
\r
2016 moveY = _mouseY -offsetY,
\r
2017 _x = startX +moveX,
\r
2018 _y = startY +moveY;
\r
2019 if( GRID_ENABLED() === true){
\r
2020 _x = Math.floor( _x / 10) * 10;
\r
2021 _y = Math.floor( _y / 10) * 10;
\r
2025 onFinish: function(){
\r
2026 MOUSE_CURSOR( '');
\r
2027 if( x === startX && y === startY) return;
\r
2028 COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y);
\r
2029 currentElement.resize( x, y);
\r
2030 COMIC_ELEMENT_OPERATION_MANAGER.saveStatus( startX, startY);
\r
2032 onCancel: function(){
\r
2033 MOUSE_CURSOR( '');
\r
2034 COMIC_ELEMENT_OPERATION_MANAGER.resize( startX, startY);
\r
2035 currentElement.animate( startX, startY);
\r
2037 onShiftUpdate: update,
\r
2038 onCtrlUpdate: update
\r
2043 /* --------------------------------------------------------------------------------------------
\r
2044 * COMIC_ELEMENT_OPERATION_MANAGER
\r
2046 var COMIC_ELEMENT_OPERATION_MANAGER = ( function(){
\r
2047 var MOUSE_CURSOR = updateMouseCursor,
\r
2048 SAVE = HISTORY_CONTROL.saveState,
\r
2049 GRID_ENABLED = GRID_CONTROL.enabled,
\r
2050 HIT_AREA = MOUSE_HIT_AREA,
\r
2051 currentIsTextElement = false,
\r
2052 currentOperator = null,
\r
2053 currentElement = null,
\r
2054 currentx, currenty, currentw, currenth, angle, flipV, flipH;
\r
2056 function resize( _x, _y, _w, _h, _angle){
\r
2057 currentx = _x !== undefined ? _x : currentx;
\r
2058 currenty = _y !== undefined ? _y : currenty;
\r
2059 currentw = _w !== undefined ? _w : currentw;
\r
2060 currenth = _h !== undefined ? _h : currenth;
\r
2061 angle = _angle !== undefined ? _angle : angle;
\r
2063 RESIZE_OPERATOR.update( currentx, currenty, currentw, currenth);
\r
2064 currentIsTextElement === true && TAIL_OPERATOR.update( currentw, currenth, angle);
\r
2065 CONSOLE_CONTROLER.show( currentElement, currentw, currenth);
\r
2066 INFOMATION_WINDOW.update( currentElement);
\r
2068 function show( _currentElement){
\r
2069 currentElement === null && RESIZE_OPERATOR.show( _currentElement);
\r
2070 if( currentElement !== _currentElement){
\r
2071 currentElement = _currentElement;
\r
2073 currentIsTextElement = ( _currentElement.type === PANEL_ELEMENT_TYPE_TEXT);
\r
2074 currentIsTextElement === true ? TAIL_OPERATOR.show( _currentElement) : TAIL_OPERATOR.hide();
\r
2076 flipV = currentIsTextElement === false ? _currentElement.flipV() : 0;
\r
2077 flipH = currentIsTextElement === false ? _currentElement.flipH() : 0;
\r
2080 _currentElement.x, _currentElement.y, _currentElement.w, _currentElement.h,
\r
2081 currentIsTextElement === true ? _currentElement.angle() : 0
\r
2086 pettanr.key.addKeyUpdateEvent( pettanr.view.EDITOR, 16, undefined, undefined, function( e){
\r
2087 currentOperator !== null && currentOperator.onShiftUpdate && currentOperator.onShiftUpdate();
\r
2089 pettanr.key.addKeyUpdateEvent( pettanr.view.EDITOR, 17, undefined, undefined, function( e){
\r
2090 currentOperator !== null && currentOperator.onCtrlUpdate && currentOperator.onCtrlUpdate();
\r
2092 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 27, false, false, function( e){
\r
2093 currentOperator !== null && currentOperator.onCancel && currentOperator.onCancel();
\r
2094 currentOperator = null;
\r
2100 close: function(){
\r
2104 currentElement !== null && RESIZE_OPERATOR.hide();
\r
2105 currentElement = null;
\r
2106 MOUSE_CURSOR( '');
\r
2107 TAIL_OPERATOR.hide();
\r
2108 CONSOLE_CONTROLER.hide();
\r
2109 INFOMATION_WINDOW.update( null);
\r
2112 restoreState: function( arg){
\r
2113 if( arg && arg.length !== 8) return;
\r
2114 var _currentElement = arg[ 0],
\r
2115 _x = arg[ 1], _y = arg[ 2], _w = arg[ 3], _h = arg[ 4],
\r
2117 _flipV = arg[ 6], _flipH = arg[ 7];
\r
2118 if( !_currentElement && !currentOperator) return;
\r
2119 _currentElement.type === PANEL_ELEMENT_TYPE_IMAGE ?
\r
2120 _currentElement.animate( _x, _y, _w, _h, _flipV, _flipH) :
\r
2121 _currentElement.animate( _x, _y, _w, _h, _a);
\r
2122 currentOperator !== null && currentOperator.onCancel && currentOperator.onCancel();
\r
2123 currentOperator = null;
\r
2124 currentElement === _currentElement ? resize( _x, _y, _w, _h, _a) : show( _currentElement);
\r
2126 saveStatus: function( startX, startY, startW, startH, startA, startFilpV, startFilpH){
\r
2127 startX = startX !== undefined ? startX : currentx;
\r
2128 startY = startY !== undefined ? startY : currenty;
\r
2129 startW = startW !== undefined ? startW : currentw;
\r
2130 startH = startH !== undefined ? startH : currenth;
\r
2131 startA = startA !== undefined ? startA : angle;
\r
2132 startFilpV = startFilpV !== undefined ? startFilpV : flipV;
\r
2133 startFilpH = startFilpH !== undefined ? startFilpH : flipH;
\r
2134 currentElement && SAVE( COMIC_ELEMENT_OPERATION_MANAGER.restoreState,
\r
2135 [ currentElement, startX, startY, startW, startH, startA, startFilpV, startFilpH],
\r
2136 [ currentElement, currentx, currenty, currentw, currenth, angle, flipV, flipH]
\r
2140 return currentOperator !== null;
\r
2142 hitTest: function( _mouseX, _mouseY, _panelElement ){
\r
2143 var _x, _y, _w, _h;
\r
2144 if( _panelElement === currentElement){
\r
2145 var _consoleX = CONSOLE_CONTROLER.x();
\r
2146 _x = currentx +( _consoleX < 0 ? _consoleX : 0) -HIT_AREA;
\r
2147 _y = currenty -HIT_AREA;
\r
2148 var _consoleW = CONSOLE_CONTROLER.w();
\r
2149 _w = ( _consoleW < currentw ? currentw : _consoleW) +HIT_AREA *2;
\r
2150 var _consoleY = CONSOLE_CONTROLER.y();
\r
2151 _h = ( _consoleY < currenth ? currenth : _consoleY +CONSOLE_CONTROLER.h()) +HIT_AREA *2;
\r
2153 _x = _panelElement.x -HIT_AREA;
\r
2154 _y = _panelElement.y -HIT_AREA;
\r
2155 _w = _panelElement.w +HIT_AREA *2;
\r
2156 _h = _panelElement.h +HIT_AREA *2;
\r
2158 log.html( [ _x, _y, _w, _h ].join( ' ') );
\r
2159 return _x <= _mouseX && _mouseX <= _x + _w && _y <= _mouseY && _mouseY <= _y + _h;
\r
2161 onMouseDown: function( _currentElement, _mouseX, _mouseY){
\r
2162 //show( _currentElement);
\r
2163 if( currentIsTextElement === true && TAIL_OPERATOR.onStart( _currentElement, _mouseX, _mouseY) === true){
\r
2164 currentOperator = TAIL_OPERATOR;
\r
2166 if( RESIZE_OPERATOR.onStart( _currentElement, _mouseX, _mouseY) === true){
\r
2167 currentOperator = RESIZE_OPERATOR;
\r
2169 POSITION_OPERATOR.onStart( _currentElement, _mouseX, _mouseY)
\r
2170 currentOperator = POSITION_OPERATOR;
\r
2173 onMouseMove: function( _currentElement, _mouseX, _mouseY){
\r
2174 show( _currentElement);
\r
2175 if( currentOperator !== null){
\r
2176 currentOperator.onDrag( _mouseX, _mouseY);
\r
2178 if( currentElement !== null){
\r
2179 CONSOLE_CONTROLER.onMouseMove( _mouseX -currentx, _mouseY -currenty);
\r
2180 if( currentIsTextElement === false || TAIL_OPERATOR.hitTest( _mouseX -currentx, _mouseY -currenty) === false){
\r
2181 RESIZE_OPERATOR.index( _mouseX, _mouseY);
\r
2185 onMouseUp: function( _currentElement, _mouseX, _mouseY){
\r
2186 currentOperator !== null && currentOperator.onFinish();
\r
2187 currentOperator = null;
\r
2192 * // COMIC_ELEMENT_OPERATION_MANAGER
\r
2195 var AbstractComicElement = function( COMIC_ELM_TYPE ){
\r
2196 this.type = COMIC_ELM_TYPE;
\r
2197 this.hitTest = function( _mouseX, _mouseY ){
\r
2198 return COMIC_ELEMENT_OPERATION_MANAGER.hitTest( _mouseX, _mouseY, this );
\r
2200 this.shift = function( _shiftX, _shiftY ){
\r
2201 this.resize( this.x + _shiftX, this.y + _shiftY);
\r
2203 this.busy = function(){
\r
2204 return COMIC_ELEMENT_OPERATION_MANAGER.busy();
\r
2206 this.onMouseMove = function( _mouseX, _mouseY ){
\r
2207 COMIC_ELEMENT_OPERATION_MANAGER.onMouseMove( this, _mouseX, _mouseY );
\r
2209 this.onMouseUp = function( _mouseX, _mouseY ){
\r
2210 COMIC_ELEMENT_OPERATION_MANAGER.onMouseUp( this, _mouseX, _mouseY );
\r
2212 this.onMouseDown = function( _mouseX, _mouseY ){
\r
2213 COMIC_ELEMENT_OPERATION_MANAGER.onMouseDown( this, _mouseX, _mouseY );
\r
2217 /* --------------------------------------------------------------------------------------------
\r
2218 * ImageElementClass
\r
2220 var jqImageElementOrigin;
\r
2221 var ImageElementClass = function( data ){
\r
2222 jqImageElementOrigin = jqImageElementOrigin || $( $( '#imgElementTemplete').remove().html());
\r
2224 var JQ_WRAPPER = jqImageElementOrigin.clone( true ),
\r
2228 flipH = w < 0 ? -1 : 1,
\r
2229 flipV = h < 0 ? -1 : 1,
\r
2230 resourcePicture = data.resource_picture,
\r
2231 actualW = data.resource_picture.width,
\r
2232 actualH = data.resource_picture.height,
\r
2233 reversibleImage = null,
\r
2235 w = Math.floor( w );
\r
2236 h = Math.floor( h );
\r
2238 function onAnimeComplete(){
\r
2239 reversibleImage && reversibleImage.resize( flipH * w, flipV * h );
\r
2241 function updateResourcePicture( _resourcePicture ){
\r
2242 resourcePicture = _resourcePicture;
\r
2244 actualW = _resourcePicture.width;
\r
2245 actualH = _resourcePicture.height;
\r
2247 var _reversibleImage = pettanr.image.createReversibleImage(
\r
2248 [ pettanr.CONST.RESOURCE_PICTURE_PATH, _resourcePicture.id, '.', _resourcePicture.ext ].join(''),
\r
2249 flipH * w, flipV * h
\r
2251 if( reversibleImage !== null){
\r
2252 JQ_WRAPPER.children( reversibleImage.elm ).replaceWith( _reversibleImage.elm );
\r
2253 reversibleImage.destroy();
\r
2255 JQ_WRAPPER.append( _reversibleImage.elm );
\r
2257 reversibleImage = _reversibleImage;
\r
2259 /* global methods */
\r
2260 this.$ = JQ_WRAPPER;
\r
2266 this.timing = data.t;
\r
2267 this.init = function(){
\r
2268 updateResourcePicture( data.resource_picture );
\r
2269 instance.resize( data.x, data.y, data.width, data.height );
\r
2270 delete instance.init;
\r
2272 this.flip = function( _updateH, _updateV ){
\r
2273 if( _updateH !== true && _updateV !== true ) return;
\r
2274 flipH = _updateH === true ? -flipH : flipH;
\r
2275 flipV = _updateV === true ? -flipV : flipV;
\r
2276 reversibleImage.resize( flipH * w, flipV * h );
\r
2278 this.flipV = function(){
\r
2281 this.flipH = function(){
\r
2284 this.resourcePicture = function( _resourcePicture ){
\r
2285 if( _resourcePicture && _resourcePicture !== resourcePicture ){
\r
2286 HISTORY_CONTROL.saveState( updateResourcePicture, resourcePicture, _resourcePicture );
\r
2287 updateResourcePicture( _resourcePicture );
\r
2289 return resourcePicture;
\r
2291 this.getArtistID = function(){
\r
2292 return resourcePicture.artist_id || resourcePicture.artist.id || -1;
\r
2294 this.actualW = function(){ return actualW;}
\r
2295 this.actualH = function(){ return actualH;}
\r
2296 this.keepSize = false;
\r
2297 this.resize = function( _x, _y, _w, _h, animate ){
\r
2298 instance.x = x = _x !== undefined ? _x : x;
\r
2299 instance.y = y = _y !== undefined ? _y : y;
\r
2300 instance.w = w = _w !== undefined ? _w : w;
\r
2301 instance.h = h = _h !== undefined ? _h : h;
\r
2302 JQ_WRAPPER[ animate === true ? 'animate' : 'css' ]( {
\r
2307 }, 250, onAnimeComplete );
\r
2308 animate !== true && onAnimeComplete();
\r
2310 this.animate = function ( _x, _y, _w, _h, _flipH, _flipV ){
\r
2311 flipH = _flipH !== undefined ? _flipH : flipH;
\r
2312 flipV = _flipV !== undefined ? _flipV : flipV;
\r
2313 instance.resize( _x, _y, _w, _h, true );
\r
2315 this.destroy = function(){
\r
2316 delete instance.destroy;
\r
2318 reversibleImage.destroy();
\r
2319 JQ_WRAPPER.stop().remove();
\r
2320 JQ_WRAPPER = reversibleImage = resourcePicture = data = instance = null;
\r
2323 ImageElementClass.prototype = new AbstractComicElement( PANEL_ELEMENT_TYPE_IMAGE );
\r
2325 * / ImageElementClass
\r
2326 * --------------------------------------------------------------------------------------------
\r
2330 /* --------------------------------------------------------------------------------------------
\r
2331 * TextElementClass
\r
2335 * 1.speach balloon
\r
2338 * 4.black-box( dq style)
\r
2339 * 5.blue-box( ff style)
\r
2342 var jqTextElementOrigin;
\r
2343 var TextElementClass = function( data ){
\r
2344 jqTextElementOrigin = jqTextElementOrigin || ( function(){
\r
2345 var _OLD_IE = $( $( '#textElementTempleteForOldIE').remove().html()),
\r
2346 _MODERN = $( $( '#textElementTemplete').remove().html());
\r
2347 return pettanr.ua.isIE === true && pettanr.ua.ieRenderingVersion < 8 ? _OLD_IE : _MODERN;
\r
2350 var JQ_WRAPPER = jqTextElementOrigin.clone( true ),
\r
2351 elmText = JQ_WRAPPER.find( 'td,.speach-inner' ).get( 0 ),
\r
2352 type = data.balloon_template_id,
\r
2353 text = ( function(){
\r
2354 var _speachs = data.speaches_attributes;
\r
2355 for( var k in _speachs ){
\r
2356 return _speachs[ k ].content || '';
\r
2360 balloon = pettanr.balloon.createBalloon( data.width, data.height, data.tail, type ),
\r
2364 JQ_WRAPPER.find( 'img' ).eq( 0 ).replaceWith( balloon.elm );
\r
2366 function updateType( _type ){
\r
2367 if( type !== _type ){
\r
2368 type = _type || type;
\r
2369 balloon.type( type );
\r
2372 function updateAngle( _a ){
\r
2373 if( _a !== undefined && a !== _a ){
\r
2374 a = _a !== undefined ? _a : a;
\r
2375 balloon.angle( a );
\r
2378 function updateText( _text ){
\r
2379 text = _text || text || '';
\r
2380 elmText.firstChild.data = text;
\r
2382 function resizeBalloon(){
\r
2383 balloon && balloon.resize( a, w, h );
\r
2386 /* global methods */
\r
2387 this.$ = JQ_WRAPPER;
\r
2393 this.timing = data.t;
\r
2394 this.init = function(){
\r
2396 instance.resize( data.x, data.y, data.width, data.height, data.tail );
\r
2397 delete instance.init;
\r
2399 this.angle = function( _a ){
\r
2400 _a !== undefined && instance.resize( x, y, w, h, _a );
\r
2401 return a >= 0 ? a : a + 360;
\r
2403 this.text = function( _text ){
\r
2404 if( _text && text !== _text) {
\r
2405 HISTORY_CONTROL.saveState( updateText, text || '', _text );
\r
2406 updateText( _text );
\r
2410 this.getBalloonURL = function(){
\r
2411 return balloon.getURL();
\r
2413 this.resize = function( _x, _y, _w, _h, _a, animate ){
\r
2414 instance.x = x = _x !== undefined ? _x : x;
\r
2415 instance.y = y = _y !== undefined ? _y : y;
\r
2416 instance.w = w = _w !== undefined ? _w : w;
\r
2417 instance.h = h = _h !== undefined ? _h : h;
\r
2418 a = _a !== undefined ? _a : a;
\r
2420 JQ_WRAPPER[ animate === true ? 'animate' : 'css']( {
\r
2425 }, 250, resizeBalloon
\r
2427 animate !== true && resizeBalloon();
\r
2429 this.animate = function ( _x, _y, _w, _h, _a ){
\r
2430 instance.resize( _x, _y, _w, _h, _a, true );
\r
2432 this.destroy = function(){
\r
2433 delete instance.destroy;
\r
2435 JQ_WRAPPER.stop().remove();
\r
2436 balloon.destroy();
\r
2437 JQ_WRAPPER = elmText = data = balloon = instance = null;
\r
2440 TextElementClass.prototype = new AbstractComicElement( PANEL_ELEMENT_TYPE_TEXT );
\r
2442 /* --------------------------------------------------------------------------------------------
\r
2443 * COMIC_ELEMENT_CONTROL
\r
2444 * - mouseEventListener
\r
2446 var COMIC_ELEMENT_CONTROL = ( function(){
\r
2447 var SAVE = HISTORY_CONTROL.saveState,
\r
2448 ELM_CONTAINER = document.getElementById( 'comic-element-container'),
\r
2449 currentElement = null,
\r
2450 currentLockTest = false,
\r
2451 currentLock = false,
\r
2452 panelX, panelY, panelW, panelH,
\r
2455 * append, remove, replace
\r
2457 * comicElement には、z-position と dom-index がある。
\r
2458 * z-position は 表示上の位置。大きいほど前に表示される( z-index)
\r
2459 * dom-index は 意味上の順番。htmlタグの登場順で、検索結果や音声読み上げブラウザで正しく意味が取れる順番。
\r
2461 * editerでは、実際には z-index は使わず、htmlの順序で前後を表現する。
\r
2462 * dom-index は、数値のみ保持して、投稿時にcomicElementを適宜に並び替える。
\r
2464 * append comicElement
\r
2465 * 1. 新しい comicElement の z-position を得る
\r
2466 * 2. z の同じ comicElementを見つけ、その前に加える。または一番先頭へ。(PANEL_ELEMENT_ARRAY)
\r
2467 * zが大きいほど、PANEL_ELEMENT_ARRAYの先頭へ。
\r
2468 * 3. dom位置は、PANEL_ELEMENT_ARRAY とは反対に、前のものほど後ろへ。
\r
2471 * remove comicElement
\r
2475 function appendComicElement( _panelElement ) {
\r
2476 var z = _panelElement.z,
\r
2477 l = PANEL_ELEMENT_ARRAY.length,
\r
2478 _jqElm = _panelElement.$.stop().css( {
\r
2482 if( typeof z !== 'number' || z < 0 || z >= l ){
\r
2483 PANEL_ELEMENT_ARRAY.unshift( _panelElement );
\r
2484 ELM_CONTAINER.appendChild( _jqElm.get( 0 ));
\r
2488 PANEL_ELEMENT_ARRAY.push( _panelElement );
\r
2489 ELM_CONTAINER.appendChild( _jqElm.get( 0 ));
\r
2491 var insertIndex = 0;
\r
2492 for( var i = 0; i < l; ++i ){
\r
2493 if( PANEL_ELEMENT_ARRAY[ i ].z <= z ){
\r
2498 PANEL_ELEMENT_ARRAY[ insertIndex ].$.before( _jqElm.fadeIn() );
\r
2499 PANEL_ELEMENT_ARRAY.splice( insertIndex, 0, _panelElement );
\r
2503 function removeComicElement( _panelElement ) {
\r
2504 var l = PANEL_ELEMENT_ARRAY.length;
\r
2505 for( var i=0; i<l; ++i){
\r
2506 if( PANEL_ELEMENT_ARRAY[ i ] === _panelElement ){
\r
2507 PANEL_ELEMENT_ARRAY.splice( i, 1 );
\r
2509 _panelElement.$.stop().css( {
\r
2512 }).fadeOut( onFadeOut );
\r
2513 currentElement = currentElement === _panelElement ? null : currentElement;
\r
2517 function onFadeOut(){
\r
2518 this.parentNode.removeChild( this );
\r
2521 function restoreComicElement( arg ){
\r
2522 var isAppend = arg[ 0 ],
\r
2523 comicElement = arg[ 1 ];
\r
2524 isAppend === true ? appendComicElement( comicElement ) : removeComicElement( comicElement );
\r
2527 * PANEL_ELEMENT_ARRAY の順番を基準に、zの再計算
\r
2530 function renumber(){
\r
2531 var l = PANEL_ELEMENT_ARRAY.length,
\r
2532 _panelElement, jqElm, jqNext;
\r
2533 for( var i=0; i < l; ++i){
\r
2534 _panelElement = PANEL_ELEMENT_ARRAY[ i ];
\r
2535 jqElm = _panelElement.$;
\r
2536 jqNext && jqNext.before( jqElm );
\r
2537 _panelElement.z = l -i -1;
\r
2541 function replaceComicElement( _panelElement, goForward ){
\r
2542 // PANEL_ELEMENT_ARRAYの再構築
\r
2543 var l = PANEL_ELEMENT_ARRAY.length,
\r
2545 for( var ret = 0; ret < l; ++ret ){
\r
2546 if( PANEL_ELEMENT_ARRAY[ ret] === _panelElement ) return ret;
\r
2550 if( i === -1) return false;
\r
2551 if( goForward === true){
\r
2552 if( i === 0) return false;
\r
2553 PANEL_ELEMENT_ARRAY.splice( i, 1);
\r
2554 PANEL_ELEMENT_ARRAY.splice( i -1, 0, _panelElement);
\r
2556 if( i === l -1) return false;
\r
2557 PANEL_ELEMENT_ARRAY.splice( i, 1);
\r
2558 PANEL_ELEMENT_ARRAY.splice( i +1, 0, _panelElement);
\r
2563 function restoreReplaceElement( arg){
\r
2564 replaceComicElement( arg[ 0], arg[ 1]);
\r
2566 function onTextInput( _panelElement ){
\r
2567 appendComicElement( _panelElement );
\r
2568 SAVE( restoreComicElement, [ false, _panelElement ], [ true, _panelElement ], true );
\r
2573 log = $( '#operation-catcher-log');
\r
2575 delete COMIC_ELEMENT_CONTROL.init;
\r
2578 COMIC_ELEMENT_CONTROL.init && COMIC_ELEMENT_CONTROL.init();
\r
2580 close: function(){
\r
2582 while( PANEL_ELEMENT_ARRAY.length > 0){
\r
2583 _comicElm = PANEL_ELEMENT_ARRAY.shift();
\r
2584 _comicElm.destroy && _comicElm.destroy();
\r
2587 remove: removeComicElement,
\r
2588 restore: restoreComicElement,
\r
2589 replace: replaceComicElement,
\r
2590 restoreReplace: restoreReplaceElement,
\r
2591 onPanelResize : function ( _panelX, _panelY, _panelW, _panelH, isResizerTopAction ){
\r
2593 * リサイズが、ResizerTopによって行われた場合、comicElementのyを動かして見かけ上動かないようにする。
\r
2595 if( isResizerTopAction === true){
\r
2596 var _shiftX = _panelW -panelW,
\r
2597 _shiftY = _panelH -panelH,
\r
2598 l = PANEL_ELEMENT_ARRAY.length;
\r
2599 for( var i = 0; i < l; i++){
\r
2600 PANEL_ELEMENT_ARRAY[ i].shift( _shiftX, _shiftY);
\r
2608 ELM_CONTAINER.style.width = _panelW +'px';
\r
2609 ELM_CONTAINER.style.height = _panelH +'px';
\r
2610 ELM_CONTAINER.style.left = _panelX +'px';
\r
2611 ELM_CONTAINER.style.top = _panelY +'px';
\r
2613 onMouseMove: function( _mouseX, _mouseY ){
\r
2614 var l = PANEL_ELEMENT_ARRAY.length,
\r
2615 _x = _mouseX -panelX,
\r
2616 _y = _mouseY -panelY,
\r
2617 _elm = currentElement;
\r
2619 if( _elm !== null){
\r
2620 currentLockTest = currentLockTest === true && _x === 0 && _y === 0;
\r
2621 if( _elm.busy() === true ){
\r
2622 _elm.onMouseMove( _x, _y);
\r
2625 if( _elm.hitTest( _x, _y) === true ){
\r
2626 _elm.onMouseMove( _x, _y ); // cursor
\r
2629 if( currentLock === true){
\r
2630 currentLockTest = true;
\r
2634 for( var i=0; i<l; i++){
\r
2635 _elm = PANEL_ELEMENT_ARRAY[ i ];
\r
2637 if( _elm.hitTest( _x, _y ) === true ){
\r
2638 _elm.onMouseMove( _x, _y ); // cursor
\r
2639 log.html( [ _x, _y, i].join( ','));
\r
2640 currentElement = _elm;
\r
2643 log.html( [ _elm.x, _elm.y, i].join( ','));
\r
2646 currentElement = null;
\r
2647 COMIC_ELEMENT_OPERATION_MANAGER.hide();
\r
2650 onMouseUp: function( _mouseX, _mouseY){
\r
2651 var ret = currentElement !== null && currentElement.busy() === true;
\r
2652 ret === true && currentElement.onMouseUp( _mouseX -startX || panelX, _mouseY -startY || panelY);
\r
2653 currentLock = currentLockTest === true && currentElement.hitTest( _mouseX -panelX, _mouseY -panelY) === true;
\r
2654 RESIZE_OPERATOR.lock( currentLock);
\r
2655 INFOMATION_WINDOW.lock( currentLock);
\r
2658 onMouseDown: function( _mouseX, _mouseY){
\r
2661 if( currentElement === null) return false
\r
2662 currentElement.onMouseDown( _mouseX -startX, _mouseY -startY);
\r
2663 currentLockTest = true;
\r
2667 return currentElement !== null;
\r
2669 createImageElement: function( data ){
\r
2670 if( Type.isObject( data ) === false ){
\r
2671 pettanr.premiumSatge.bootInOverlay( 1, COMIC_ELEMENT_CONTROL.onImageSelect );
\r
2673 COMIC_ELEMENT_CONTROL.onImageSelect( data, true );
\r
2676 onImageSelect: function( data, isPanelPictureData ){
\r
2677 if( isPanelPictureData !== true ){
\r
2679 resource_picture:data,
\r
2680 x: Math.floor( panelW /2 - data.width /2 ),
\r
2681 y: Math.floor( panelH /2 - data.height /2 ),
\r
2683 t: PANEL_ELEMENT_ARRAY.length,
\r
2684 width: data.width,
\r
2685 height: data.height
\r
2688 var _panelElement = new ImageElementClass( data );
\r
2689 _panelElement.init && _panelElement.init();
\r
2690 appendComicElement( _panelElement );
\r
2691 _panelElement.animate( undefined, undefined, data.width, data.height );
\r
2692 SAVE( restoreComicElement, [ false, _panelElement], [ true, _panelElement], true );
\r
2694 createTextElement: function( data ){
\r
2695 var _panelElement;
\r
2696 if( Type.isObject( data ) === false ){
\r
2698 balloon_template_id:1,
\r
2701 x: Math.floor( panelW /2 - 100 +Math.random() *10 ),
\r
2702 y: Math.floor( panelH /2 - 100 +Math.random() *10 ),
\r
2704 t: PANEL_ELEMENT_ARRAY.length,
\r
2707 speaches_attributes: {
\r
2713 _panelElement = new TextElementClass( data );
\r
2714 _panelElement.init();
\r
2715 pettanr.textEditor.bootInOverlay( PANEL_CONTROL.x(), PANEL_CONTROL.y(), _panelElement, onTextInput );
\r
2717 _panelElement = new TextElementClass( data );
\r
2718 _panelElement.init();
\r
2719 onTextInput( _panelElement );
\r
2726 * end of COMIC_ELEMENT_CONTROL
\r
2731 function updateMouseCursor( _cursor){
\r
2732 if( currentCursor !== _cursor){
\r
2733 currentCursor = _cursor;
\r
2734 setTimeout( update, 0);
\r
2736 function update(){
\r
2737 ELM_MOUSE_EVENT_CHATCHER.style.cursor = currentCursor;
\r
2740 function centering(){
\r
2741 instance.onPaneResize( windowW, windowH);
\r
2743 function mouseEventRellay( e){
\r
2744 var _mouseX = e.pageX,
\r
2745 _mouseY = e.pageY,
\r
2746 rellayMethod = e.type === 'mousedown' ?
\r
2748 ( e.type === 'mousemove' ? 'onMouseMove' : 'onMouseUp');
\r
2749 if( currentListener !== null && currentListener.busy() === true){
\r
2750 currentListener[ rellayMethod]( _mouseX, _mouseY);
\r
2752 currentListener = null;
\r
2753 var l = MOUSE_LISTENER_ARRAY.length,
\r
2755 for( var i=0; i<l; ++i){
\r
2756 _listener = MOUSE_LISTENER_ARRAY[ i];
\r
2757 if( _listener[ rellayMethod]( _mouseX, _mouseY) === true){
\r
2758 currentListener = _listener;
\r
2764 //!document.selection && window.getSelection().removeAllRanges();
\r
2765 e.stopPropagation();
\r
2769 /* grobal method */
\r
2770 this.rootElement = document.getElementById( 'editor' );
\r
2771 this.displayName = pettanr.view.EDITOR;
\r
2772 this.ID = pettanr.view.EDITOR;
\r
2773 this.MIN_WIDTH = 320;
\r
2774 this.MIN_HEIGHT = 320;
\r
2775 this.firstOpen = function(){
\r
2777 * MOUSE_LISTENER_ARRAY は、表示順に格納.手前の要素が最初
\r
2778 * MENU_BAR_CONTROL,
\r
2780 * COMIC_ELEMENT_CONTROL,
\r
2782 * .busy() === true なら、そのままonMouseMove()にイベントを流す.
\r
2783 * onMouseMove()に流してみて、false が帰れば、次にリスナーにも流す.
\r
2785 MOUSE_LISTENER_ARRAY.push( MENU_BAR_CONTROL, WINDOWS_CONTROL, PANEL_RESIZER_TOP, PANEL_RESIZER_BOTTOM, COMIC_ELEMENT_CONTROL, PANEL_CONTROL);
\r
2789 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 96, false, true, centering); // ctrl + 0
\r
2790 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 48, false, true, centering); // ctrl + 0
\r
2791 MENU_BAR_CONTROL.EDIT.createSelection( 'centering', 'ctrl + 0', centering, true, true, true);
\r
2793 * jqMouseEventChacher は透明な要素で、
\r
2794 * マウスイベントをcurrentElement(currentElement)に伝えるのが仕事
\r
2795 * このような実装になるのは、ここの表示オブジェクトにイベントを設定した場合、表示が追いつかずマウスカーソルが外れたタイミングでイベントが終わってしまうため。
\r
2797 jqMouseEventChacher = $( ELM_MOUSE_EVENT_CHATCHER)
\r
2798 .mousemove( mouseEventRellay)
\r
2799 .mousedown( mouseEventRellay)
\r
2800 .mouseup( mouseEventRellay)
\r
2801 .mouseout( mouseEventRellay);
\r
2803 delete instance.firstOpen;
\r
2805 this.onOpen = function( _w, _h, _file ){
\r
2808 panelTimming = -1;
\r
2810 var panelW, panelH,
\r
2812 fileData, panelElements, panelElm;
\r
2814 if( pettanr.file.isFileInstance( _file ) === true ){
\r
2815 if( pettanr.driver.isPettanrFileInstance( _file ) === true ){
\r
2816 if( _file.getType() === pettanr.driver.FILE_TYPE.COMIC ){
\r
2817 fileData = _file.read();
\r
2818 panelW = fileData.width;
\r
2819 panelH = fileData.height;
\r
2820 comicID = fileData.id || -1;
\r
2822 if( _file.getType() === pettanr.driver.FILE_TYPE.PANEL ){
\r
2823 fileData = _file.read();
\r
2824 panelW = fileData.width;
\r
2825 panelH = fileData.height;
\r
2826 borderSize = fileData.border;
\r
2827 panelElements = fileData.panel_elements;
\r
2828 comicID = fileData.comic ? fileData.comic.id || -1 : -1;
\r
2829 panelID = fileData.id || -1;
\r
2830 panelTimming = fileData.t || -1;
\r
2831 if( Type.isArray( panelElements ) === true ){
\r
2832 for( var i=0; i<panelElements.length; ++i){
\r
2833 panelElm = panelElements[ i ];
\r
2834 if( panelElm.resource_picture ){
\r
2835 COMIC_ELEMENT_CONTROL.createImageElement( panelElm );
\r
2837 if( panelElm.balloon_template_id ){
\r
2838 COMIC_ELEMENT_CONTROL.createTextElement( panelElm );
\r
2847 jqEditor = jqEditor || $( '#editor');
\r
2849 HISTORY_CONTROL.open();
\r
2851 WINDOWS_CONTROL.open();
\r
2853 GRID_CONTROL.open();
\r
2854 PANEL_CONTROL.open( panelW, panelH, borderSize );
\r
2856 COMIC_ELEMENT_OPERATION_MANAGER.open();
\r
2857 COMIC_ELEMENT_CONTROL.open();
\r
2859 instance.firstOpen !== undefined && instance.firstOpen();
\r
2862 MENU_BAR_CONTROL.open();
\r
2866 instance.onPaneResize( _w, _h );
\r
2868 this.onClose = function(){
\r
2869 HISTORY_CONTROL.close();
\r
2871 WINDOWS_CONTROL.close();
\r
2873 GRID_CONTROL.close();
\r
2874 PANEL_CONTROL.close();
\r
2876 COMIC_ELEMENT_OPERATION_MANAGER.close();
\r
2877 COMIC_ELEMENT_CONTROL.close();
\r
2880 MENU_BAR_CONTROL.open();
\r
2882 this.onPaneResize = function( _windowW, _windowH){
\r
2883 windowW = _windowW || windowW;
\r
2884 windowH = _windowH || windowH;
\r
2888 jqEditor.get( 0).style.height = _windowH +'px';
\r
2889 ELM_MOUSE_EVENT_CHATCHER.style.height = _windowH +'px';
\r
2891 WINDOWS_CONTROL.onWindowResize( _windowW, _windowH);
\r
2892 MENU_BAR_CONTROL.onWindowResize( _windowW, _windowH);
\r
2893 PANEL_CONTROL.onWindowResize( _windowW, _windowH);
\r
2898 pettanr.comicConsole = pettanr.view.registerApplication( function(){
\r
2900 ID = 'comicConsole',
\r
2901 elmWrap = document.getElementById( 'comic-console-wrapper' ),
\r
2902 elmHeader = document.getElementById( 'comic-console-header' ),
\r
2903 elmProgress = document.getElementById( 'comic-console-progress' ),
\r
2904 inputTitle, inputW, inputH,
\r
2905 comboboxVisible, comboboxEditable,
\r
2906 buttonSubmit, buttonCancel,
\r
2907 elmUploader = null,
\r
2912 isUploading = false,
\r
2914 //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK);
\r
2916 function clickOK(){
\r
2917 if( !elmForm || !elmIframe || isUploading === true ) return false;
\r
2919 isUploading = true;
\r
2920 elmProgress.innerHTML = '■';
\r
2924 function copyAndSubmit(){
\r
2925 var _inputList = elmForm.getElementsByTagName( 'input' ),
\r
2927 for( var i=0, l= _inputList.length; i<l; ++i){
\r
2928 _input = _inputList[ i ];
\r
2929 _name = _input.name;
\r
2930 if( _name === 'comic[title]'){
\r
2931 _input.value = inputTitle.value();
\r
2933 if( _name === 'comic[width]'){
\r
2934 _input.value = inputW.value();
\r
2936 if( _name === 'comic[height]'){
\r
2937 _input.value = inputH.value();
\r
2940 var _selectList = elmForm.getElementsByTagName( 'select' ),
\r
2941 _select, _optionList;
\r
2942 for( i=0, l= _selectList.length; i<l; ++i){
\r
2943 _select = _selectList[ i ];
\r
2944 _name = _select.name;
\r
2945 _optionList = _select.getElementsByTagName( 'option' )
\r
2946 if( _name === 'comic[visible]'){
\r
2947 _select.selectedIndex = comboboxVisible.selectIndex();
\r
2949 if( _name === 'comic[editable]'){
\r
2950 _select.selectedIndex = comboboxEditable.selectIndex();
\r
2956 elmProgress.innerHTML = 'submit() err..';
\r
2957 isUploading = false;
\r
2958 setTimeout( clickCancel , 3000);
\r
2961 if( pettanr.ua.isIE){
\r
2962 elmIframe.onreadystatechange = detectIframe;
\r
2964 elmIframe.onload = onIframeUpdate;
\r
2966 elmProgress.innerHTML = 'uploading..';
\r
2969 * ie の 場合、readyState をチェック.
\r
2971 function detectIframe(){
\r
2972 if ( elmIframe.readyState === 'complete') {
\r
2973 elmIframe.onreadystatechange = new Function();
\r
2974 elmIframe.onreadystatechange = null;
\r
2978 function onIframeUpdate(){
\r
2979 elmIframe.onload = null;
\r
2980 ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();
\r
2982 elmProgress.innerHTML = 'success!';
\r
2983 setTimeout( clickCancel , 1000);
\r
2984 isUploading = false;
\r
2987 function clickCancel(){
\r
2988 if( isUploading === true) return false;
\r
2989 pettanr.comicConsole.shutdown();
\r
2991 function detectForm(){
\r
2992 elmForm = elmUploader.getElementsByTagName( 'form' )[ 0 ];
\r
2994 var selectList = elmForm.getElementsByTagName( 'select' ),
\r
2997 optionList, option;
\r
2998 for( var i=0, l=selectList.length; i<l; ++i ){
\r
2999 select = selectList[ i ];
\r
3000 optionList = select.getElementsByTagName( 'option' );
\r
3001 for( j=0, m=optionList.length; j<m; ++j ){
\r
3002 option = optionList[ j ];
\r
3003 if( select.name === 'comic[visible]' ){
\r
3004 comboboxVisible.createOption( option.innerHTML, option.value, option.selected );
\r
3006 if( select.name === 'comic[editable]' ){
\r
3007 comboboxEditable.createOption( option.innerHTML, option.value, option.selected );
\r
3012 window.clearInterval( timer);
\r
3014 pettanr.util.createIframe( 'targetFrameCreateComic', onCreateIframe );
\r
3015 elmProgress.innerHTML = 'create iframe';
\r
3018 function onCreateIframe( _iframe ){
\r
3019 elmUploader.appendChild( _iframe );
\r
3020 elmIframe = _iframe;
\r
3021 elmForm.target = _iframe.name;
\r
3022 elmProgress.innerHTML = '';
\r
3025 /* grobal method */
\r
3026 this.rootElement = document.getElementById( 'comic-console-wrapper' );
\r
3027 this.displayName = ID;
\r
3029 this.MIN_WIDTH = 320;
\r
3030 this.MIN_HEIGHT = 320;
\r
3031 this.init = function(){
\r
3032 jqWrap = $( '#comic-console-wrapper').hide();
\r
3034 inputTitle = pettanr.form.createInputText( document.getElementById( 'comic-console-title'), null, ID);
\r
3035 inputW = pettanr.form.createInputText( document.getElementById( 'comic-console-width'), null, ID);
\r
3036 inputH = pettanr.form.createInputText( document.getElementById( 'comic-console-height'), null, ID);
\r
3037 comboboxVisible = pettanr.form.createCombobox( document.getElementById( 'comic-console-visible'), null, ID);
\r
3038 comboboxEditable = pettanr.form.createCombobox( document.getElementById( 'comic-console-editable'), null, ID);
\r
3039 buttonSubmit = pettanr.form.createButton( document.getElementById( 'comic-console-post-button'), clickOK, ID);
\r
3040 buttonCancel = pettanr.form.createButton( document.getElementById( 'comic-console-cancel-button'), clickCancel, ID);
\r
3042 delete instance.init;
\r
3044 this.onOpen = function( w, h ){
\r
3045 instance.init && instance.init();
\r
3049 inputTitle.focus();
\r
3051 elmUploader = document.createElement( 'div' );
\r
3052 elmUploader.id = 'newcomic';
\r
3053 elmUploader.style.cssText = 'height:1px;line-height:1px;visibility:hidden;overflow:hidden;';
\r
3054 elmWrap.appendChild( elmUploader);
\r
3056 var elmScript = document.createElement( 'script');
\r
3057 elmScript.type = 'text\/javascript';
\r
3058 elmScript.src = pettanr.CONST.CREATE_COMIC_JS;
\r
3059 elmWrap.appendChild( elmScript );
\r
3061 elmProgress.innerHTML = 'loading form.';
\r
3063 if( timer === null){
\r
3064 timer = window.setInterval( detectForm, 250);
\r
3067 instance.onPaneResize( w, h );
\r
3069 this.onPaneResize = function( _windowW, _windowH){
\r
3072 left: Math.floor( ( _windowW - jqWrap.width()) /2),
\r
3073 top: Math.floor( ( _windowH - jqWrap.height()) /2)
\r
3077 this.onClose = function(){
\r
3078 elmForm !== null && $( elmUploader ).remove();
\r
3080 isUploading = false;
\r
3082 if( elmScript !== null ){
\r
3083 document.body.removeChild( elmScript);
\r
3084 elmScript = null;
\r
3086 if( timer !== null){
\r
3087 window.clearInterval( timer);
\r
3095 pettanr.uploadConsole = pettanr.view.registerApplication( function(){
\r
3096 var jqWrap, windowW, windowH,
\r
3097 ID = 'uploadConsole',
\r
3098 TARGET_FRAME_NAME = 'targetFrame',
\r
3099 elmContainer = document.getElementById( 'uploader'),
\r
3100 elmProgress = document.getElementById( 'upload-console-progress'),
\r
3106 isUploading = false,
\r
3109 * upload ボタンが押されたらまず iframe をつくる.
\r
3111 function clickOK(){
\r
3112 if( !elmForm || !elmIframe || isUploading === true ) return false;
\r
3113 if( elmFile.value.length === 0) return false;
\r
3114 elmProgress.innerHTML = 'uploading.';
\r
3115 isUploading = true;
\r
3120 * form の target に iframe を指定したのち submit();
\r
3122 function submit(){
\r
3126 elmProgress.innerHTML = 'submit() err..';
\r
3127 isUploading = false;
\r
3128 setTimeout( clickCancel , 3000);
\r
3132 if( pettanr.ua.isIE){
\r
3133 elmIframe.onreadystatechange = detectIframe;
\r
3135 elmIframe.onload = onLoad;
\r
3137 elmProgress.innerHTML = 'uploading..';
\r
3140 * ie の 場合、readyState をチェック.
\r
3142 function detectIframe(){
\r
3143 if ( elmIframe.readyState === 'complete') {
\r
3144 elmIframe.onreadystatechange = new Function();
\r
3145 elmIframe.onreadystatechange = null;
\r
3149 function onLoad(){
\r
3150 elmIframe.onload = null;
\r
3151 ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();
\r
3152 elmProgress.innerHTML = 'success!';
\r
3153 setTimeout( clickCancel , 1000);
\r
3154 isUploading = false;
\r
3157 function detectForm(){
\r
3158 elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];
\r
3160 var _inputList = elmForm.getElementsByTagName( 'input' ),
\r
3162 for( var i=0, l= _inputList.length; i<l; ++i){
\r
3163 _input = _inputList[ i ];
\r
3164 if( _input.type === 'file'){
\r
3167 if( _input.type === 'submit'){
\r
3168 _input.style.display = 'none';
\r
3171 window.clearInterval( timer);
\r
3173 pettanr.util.createIframe( TARGET_FRAME_NAME, onCreateIframe);
\r
3174 elmProgress.innerHTML = 'create iframe';
\r
3177 function onCreateIframe( _iframe ){
\r
3178 elmContainer.appendChild( _iframe );
\r
3179 elmIframe = _iframe;
\r
3180 elmForm.target = _iframe.name;
\r
3181 elmProgress.innerHTML = '';
\r
3182 instance.onPaneResize( windowW, windowH );
\r
3187 function clickCancel(){
\r
3188 if( isUploading === true) return false;
\r
3189 pettanr.uploadConsole.shutdown();
\r
3193 /* grobal method */
\r
3194 this.rootElement = document.getElementById( 'upload-console-wrapper' );
\r
3195 this.displayName = ID;
\r
3197 this.MIN_WIDTH = 320;
\r
3198 this.MIN_HEIGHT = 320;
\r
3199 this.init = function(){
\r
3200 jqWrap = $( '#upload-console-wrapper').hide();
\r
3201 $( '#upload-console-post-button').click( clickOK );
\r
3202 $( '#upload-console-cancel-button').click( clickCancel );
\r
3204 delete instance.init;
\r
3206 this.onOpen = function( w, h){
\r
3207 instance.init && instance.init();
\r
3209 * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.
\r
3211 elmScript = document.createElement( 'script');
\r
3212 elmScript.type = 'text\/javascript';
\r
3213 elmScript.src = pettanr.CONST.UPLOAD_PICTURE_JS;
\r
3214 document.body.appendChild( elmScript);
\r
3218 if( timer === null){
\r
3219 timer = window.setInterval( detectForm, 250);
\r
3222 elmProgress.innerHTML = 'loading form.';
\r
3224 instance.onPaneResize( w, h);
\r
3226 this.onPaneResize = function( _windowW, _windowH){
\r
3227 windowW = _windowW;
\r
3228 windowH = _windowH;
\r
3231 left: Math.floor( ( _windowW -jqWrap.width()) /2),
\r
3232 top: Math.floor( ( _windowH -jqWrap.height()) /2)
\r
3236 this.onClose = function(){
\r
3237 elmForm !== null && $( elmContainer.children ).remove();
\r
3238 elmForm = elmFile = elmIframe = null;
\r
3239 isUploading = false;
\r
3241 if( elmScript !== null ){
\r
3242 document.body.removeChild( elmScript);
\r
3243 elmScript = null;
\r
3245 if( timer !== null){
\r
3246 window.clearInterval( timer);
\r
3253 pettanr.panelConsole = pettanr.view.registerApplication( function(){
\r
3254 var jqWrap, windowW, windowH,
\r
3255 ID = 'panelConsole',
\r
3256 TARGET_FRAME_NAME = 'targetFrameCreateNewPanel',
\r
3257 elmContainer = document.getElementById( 'newpanel'),
\r
3258 elmProgress = document.getElementById( 'panel-console-progress'),
\r
3263 isUploading = false,
\r
3266 * upload ボタンが押されたらまず iframe をつくる.
\r
3268 function clickOK(){
\r
3269 if( !elmForm || !elmIframe || isUploading === true ) return false;
\r
3270 elmProgress.innerHTML = 'uploading.';
\r
3271 isUploading = true;
\r
3276 * form の target に iframe を指定したのち submit();
\r
3278 function submit(){
\r
3282 elmProgress.innerHTML = 'submit() err..';
\r
3283 isUploading = false;
\r
3284 setTimeout( clickCancel , 3000);
\r
3288 if( pettanr.ua.isIE){
\r
3289 elmIframe.onreadystatechange = detectIframe;
\r
3291 elmIframe.onload = onLoad;
\r
3293 elmProgress.innerHTML = 'uploading..';
\r
3296 * ie の 場合、readyState をチェック.
\r
3298 function detectIframe(){
\r
3299 if ( elmIframe.readyState === 'complete') {
\r
3300 elmIframe.onreadystatechange = new Function();
\r
3301 elmIframe.onreadystatechange = null;
\r
3305 function onLoad(){
\r
3306 elmIframe.onload = null;
\r
3307 ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();
\r
3308 elmProgress.innerHTML = 'success!';
\r
3309 setTimeout( clickCancel , 1000);
\r
3310 isUploading = false;
\r
3313 function detectForm(){
\r
3314 elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];
\r
3316 var _inputList = elmForm.getElementsByTagName( 'input' ),
\r
3318 for( var i=0, l= _inputList.length; i<l; ++i){
\r
3319 _input = _inputList[ i ];
\r
3320 if( _input.type === 'submit'){
\r
3321 _input.style.display = 'none';
\r
3324 window.clearInterval( timer);
\r
3326 pettanr.util.createIframe( TARGET_FRAME_NAME, onCreateIframe);
\r
3327 elmProgress.innerHTML = 'create iframe';
\r
3330 function onCreateIframe( _iframe ){
\r
3331 elmContainer.appendChild( _iframe );
\r
3332 elmIframe = _iframe;
\r
3333 elmForm.target = _iframe.name;
\r
3334 elmProgress.innerHTML = '';
\r
3335 instance.onPaneResize( windowW, windowH );
\r
3340 function clickCancel(){
\r
3341 if( isUploading === true) return false;
\r
3342 pettanr.panelConsole.shutdown();
\r
3346 /* grobal method */
\r
3347 this.rootElement = document.getElementById( 'panel-console-wrapper' );
\r
3348 this.displayName = ID;
\r
3350 this.MIN_WIDTH = 320;
\r
3351 this.MIN_HEIGHT = 320;
\r
3352 this.init = function(){
\r
3353 jqWrap = $( '#panel-console-wrapper').hide();
\r
3354 $( '#panel-console-post-button').click( clickOK );
\r
3355 $( '#panel-console-cancel-button').click( clickCancel );
\r
3357 delete instance.init;
\r
3359 this.onOpen = function( w, h ){
\r
3360 instance.init && instance.init();
\r
3362 * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.
\r
3364 elmScript = document.createElement( 'script');
\r
3365 elmScript.type = 'text\/javascript';
\r
3366 elmScript.src = pettanr.CONST.CREATE_PANEL_JS;
\r
3367 document.body.appendChild( elmScript);
\r
3371 if( timer === null){
\r
3372 timer = window.setInterval( detectForm, 250 );
\r
3375 elmProgress.innerHTML = 'loading form.';
\r
3377 instance.onPaneResize( w, h );
\r
3379 this.onPaneResize = function( _windowW, _windowH ){
\r
3380 windowW = _windowW;
\r
3381 windowH = _windowH;
\r
3384 left: Math.floor( ( _windowW -jqWrap.width()) /2),
\r
3385 top: Math.floor( ( _windowH -jqWrap.height()) /2)
\r
3389 this.onClose = function(){
\r
3390 elmForm !== null && $( elmContainer.children ).remove();
\r
3391 elmForm = elmIframe = null;
\r
3392 isUploading = false;
\r
3394 if( elmScript !== null ){
\r
3395 document.body.removeChild( elmScript);
\r
3396 elmScript = null;
\r
3398 if( timer !== null){
\r
3399 window.clearInterval( timer);
\r
3406 pettanr.artistConsole = pettanr.view.registerApplication( function(){
\r
3407 var jqWrap, windowW, windowH,
\r
3408 ID = 'artistConsole',
\r
3409 TARGET_FRAME_NAME = 'targetFrameRegisterArtist',
\r
3410 elmContainer = document.getElementById( 'register'),
\r
3411 elmProgress = document.getElementById( 'artist-console-progress'),
\r
3416 isUploading = false,
\r
3419 * upload ボタンが押されたらまず iframe をつくる.
\r
3421 function clickOK(){
\r
3422 if( !elmForm || !elmIframe || isUploading === true ) return false;
\r
3423 elmProgress.innerHTML = 'uploading.';
\r
3424 isUploading = true;
\r
3429 * form の target に iframe を指定したのち submit();
\r
3431 function submit(){
\r
3435 elmProgress.innerHTML = 'submit() err..';
\r
3436 isUploading = false;
\r
3437 setTimeout( clickCancel , 3000);
\r
3441 if( pettanr.ua.isIE){
\r
3442 elmIframe.onreadystatechange = detectIframe;
\r
3444 elmIframe.onload = onLoad;
\r
3446 elmProgress.innerHTML = 'uploading..';
\r
3449 * ie の 場合、readyState をチェック.
\r
3451 function detectIframe(){
\r
3452 if ( elmIframe.readyState === 'complete') {
\r
3453 elmIframe.onreadystatechange = new Function();
\r
3454 elmIframe.onreadystatechange = null;
\r
3458 function onLoad(){
\r
3459 elmIframe.onload = null;
\r
3460 ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();
\r
3461 elmProgress.innerHTML = 'success!';
\r
3462 setTimeout( clickCancel , 1000);
\r
3463 isUploading = false;
\r
3466 function detectForm(){
\r
3467 elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];
\r
3469 var _inputList = elmForm.getElementsByTagName( 'input' ),
\r
3471 for( var i=0, l= _inputList.length; i<l; ++i){
\r
3472 _input = _inputList[ i ];
\r
3473 if( _input.type === 'submit'){
\r
3474 _input.style.display = 'none';
\r
3477 window.clearInterval( timer);
\r
3479 pettanr.util.createIframe( TARGET_FRAME_NAME, onCreateIframe);
\r
3480 elmProgress.innerHTML = 'create iframe';
\r
3483 function onCreateIframe( _iframe ){
\r
3484 elmContainer.appendChild( _iframe );
\r
3485 elmIframe = _iframe;
\r
3486 elmForm.target = _iframe.name;
\r
3487 elmProgress.innerHTML = '';
\r
3488 instance.onPaneResize( windowW, windowH );
\r
3493 function clickCancel(){
\r
3494 if( isUploading === true) return false;
\r
3495 pettanr.artistConsole.shutdown();
\r
3499 /* grobal method */
\r
3500 this.rootElement = document.getElementById( 'artist-console-wrapper' );
\r
3501 this.displayName = ID;
\r
3503 this.MIN_WIDTH = 320;
\r
3504 this.MIN_HEIGHT = 320;
\r
3505 this.init = function(){
\r
3506 jqWrap = $( '#artist-console-wrapper').hide();
\r
3507 $( '#artist-console-post-button').click( clickOK );
\r
3508 $( '#artist-console-cancel-button').click( clickCancel );
\r
3510 delete instance.init;
\r
3512 this.onOpen = function( w, h ){
\r
3513 instance.init && instance.init();
\r
3515 * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.
\r
3517 elmScript = document.createElement( 'script' );
\r
3518 elmScript.type = 'text\/javascript';
\r
3519 elmScript.src = pettanr.CONST.REGISTER_ARTIST_JS;
\r
3520 document.body.appendChild( elmScript );
\r
3524 if( timer === null){
\r
3525 timer = window.setInterval( detectForm, 250 );
\r
3528 elmProgress.innerHTML = 'loading form.';
\r
3530 instance.onPaneResize( w, h );
\r
3532 this.onPaneResize = function( _windowW, _windowH ){
\r
3533 windowW = _windowW;
\r
3534 windowH = _windowH;
\r
3537 left: Math.floor( ( _windowW -jqWrap.width()) /2),
\r
3538 top: Math.floor( ( _windowH -jqWrap.height()) /2)
\r
3542 this.onClose = function(){
\r
3543 elmForm !== null && $( elmContainer.children ).remove();
\r
3544 elmForm = elmIframe = null;
\r
3545 isUploading = false;
\r
3547 if( elmScript !== null ){
\r
3548 document.body.removeChild( elmScript);
\r
3549 elmScript = null;
\r
3551 if( timer !== null){
\r
3552 window.clearInterval( timer);
\r
3559 pettanr.outputConsole = pettanr.view.registerApplication( function(){
\r
3560 var FORMAT_LIST = [ 'json[POST]', 'json[GET]', 'XML', 'HTML', 'XHTML', 'MT export', 'Blogger ATOM' ];
\r
3561 var jqWrap, jqOutputArea,
\r
3562 comboboxFormat, inputOption,
\r
3563 buttonGenerate, buttonClose,
\r
3564 ID = 'outputConsole',
\r
3566 comicID, panelID, panelTimming, panelW, panelH, borderSize, panelElementArray,
\r
3568 //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK);
\r
3570 function clickOK(){
\r
3571 pettanr.outputConsole.shutdown();
\r
3574 function getPanelElementByTiming(){
\r
3575 var l = panelElementArray.length;
\r
3576 while( timing < l * 2){
\r
3577 for(var i=0; i<l; ++i){
\r
3578 if( timing === panelElementArray[ i ].timing ){
\r
3580 return panelElementArray[ i ];
\r
3588 function getAsHtmlString( isAbsoluteUrl, isXHTML ){
\r
3591 var HTML_ARRAY = [],
\r
3592 l = panelElementArray.length,
\r
3595 while( HTML_ARRAY.length < l ){
\r
3596 _panelElement = getPanelElementByTiming();
\r
3597 if( _panelElement === null) break;
\r
3598 HTML_ARRAY.push( panelElementToHtml( _panelElement, isAbsoluteUrl, isXHTML ));
\r
3601 HTML_ARRAY.unshift(
\r
3603 '<div class="panel" ',
\r
3605 'height:', panelH, 'px;',
\r
3606 'background-color:', ';',
\r
3611 HTML_ARRAY.push( '</div>');
\r
3613 return HTML_ARRAY.join( pettanr.LINE_FEED_CODE_TEXTAREA);
\r
3616 function panelElementToHtml( _panelElement, isAbsoluteUrl, isXHTML ){
\r
3618 if( _panelElement.type === 0 ){
\r
3619 url = [ pettanr.CONST.RESOURCE_PICTURE_PATH, _panelElement.resourcePicture().id, '.', _panelElement.resourcePicture().ext ].join( '' );
\r
3622 'src="', isAbsoluteUrl !== true ? url : pettanr.util.getAbsolutePath( url ), '" ',
\r
3623 'width="', _panelElement.w, '" ',
\r
3624 'height="', _panelElement.h, '" ',
\r
3626 'left:', _panelElement.x, 'px;',
\r
3627 'top:', _panelElement.y, 'px;',
\r
3628 'z-index:', _panelElement.z, ';',
\r
3630 isXHTML !== true ? '>' : ' \/>'
\r
3633 url = _panelElement.getBalloonURL();
\r
3636 'src="', isAbsoluteUrl !== true ? url : pettanr.util.getAbsolutePath( url ), '" ',
\r
3637 'width="', _panelElement.w, '" ',
\r
3638 'height="', _panelElement.h, '" ',
\r
3640 'left:', _panelElement.x, 'px;',
\r
3641 'top:', _panelElement.y, 'px;',
\r
3642 'z-index:', _panelElement.z, ';',
\r
3644 isXHTML !== true ? '>' : ' \/>',
\r
3645 pettanr.LINE_FEED_CODE_TEXTAREA,
\r
3646 '<div class="balloon" style="',
\r
3647 'left:', _panelElement.x, 'px;',
\r
3648 'top:', _panelElement.y, 'px;',
\r
3649 'width:', _panelElement.w, 'px;',
\r
3650 'height:', _panelElement.h, 'px;',
\r
3651 'z-index:', _panelElement.z,
\r
3652 '"><span>', _panelElement.text(), '<\/span>', '<\/div>'
\r
3658 function getJsonGetString(){
\r
3661 var JSON_STRING_ARRAY = [],
\r
3662 ELEMENT_ARRAY = [],
\r
3663 l = panelElementArray.length,
\r
3664 cr = pettanr.LINE_FEED_CODE_TEXTAREA,
\r
3667 while( ELEMENT_ARRAY.length <= l){
\r
3668 _panelElement = getPanelElementByTiming();
\r
3669 if( _panelElement === null ) break;
\r
3671 ELEMENT_ARRAY.push( _panelElement.type === 0 ? getImageJsonGET( _panelElement ) : balloonToJson( _panelElement ));
\r
3676 '"id": ', panelID, ',', cr,
\r
3677 '"border": ', borderSize, ',', cr,
\r
3678 '"comic_id": ', comicID, ',', cr,
\r
3679 '"resource_picture_id": 1,', cr,
\r
3680 '"x": ', 0, ',', cr,
\r
3681 '"y": ', 0, ',', cr,
\r
3682 '"z": ', 0, ',', cr,
\r
3683 panelTimming !== -1 ? ( '"t": ' + panelTimming + ',' + cr ) : '',
\r
3684 '"width": ', panelW, ',', cr,
\r
3685 '"height": ', panelH, ',', cr,
\r
3686 '"panel_elements": [', cr,
\r
3687 ELEMENT_ARRAY.join( ',' + cr ), cr,
\r
3693 function getImageJsonGET( _imageElement ){
\r
3694 var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
\r
3697 '"resource_picture": {', cr,
\r
3698 '"id": ', _imageElement.resourcePicture().id, ',', cr,
\r
3699 '"ext": ', '"',_imageElement.resourcePicture().ext, '"', cr,
\r
3701 '"x": ', _imageElement.x, ',', cr,
\r
3702 '"y": ', _imageElement.y, ',', cr,
\r
3703 '"z": ', _imageElement.z, ',', cr,
\r
3704 '"width": ', _imageElement.flipH() * _imageElement.w, ',', cr,
\r
3705 '"height": ', _imageElement.flipV() * _imageElement.h, ',', cr,
\r
3706 '"t": ', timing, cr,
\r
3711 function getJsonPostString(){
\r
3714 var JSON_STRING_ARRAY = [],
\r
3716 BALLOON_ARRAY = [],
\r
3717 l = panelElementArray.length,
\r
3719 cr = pettanr.LINE_FEED_CODE_TEXTAREA;
\r
3721 while( IMAGE_ARRAY.length + BALLOON_ARRAY.length <= l){
\r
3722 _panelElement = getPanelElementByTiming();
\r
3723 if( _panelElement === null) break;
\r
3724 _panelElement.type === 0 ?
\r
3725 IMAGE_ARRAY.push( [ '"new', timing, '": ', imageToJson( _panelElement ) ].join( '' )) :
\r
3726 BALLOON_ARRAY.push( [ '"new', timing, '": ', balloonToJson( _panelElement ) ].join( '' ) );
\r
3731 '"id": ', panelID, ',', cr,
\r
3732 '"border": ', borderSize, ',', cr,
\r
3733 '"comic_id": ', comicID, ',', cr,
\r
3734 '"resource_picture_id": 1,', cr,
\r
3735 '"x": ', 0, ',', cr,
\r
3736 '"y": ', 0, ',', cr,
\r
3737 '"z": ', 0, ',', cr,
\r
3738 panelTimming !== -1 ? ( '"t": ' + panelTimming + ',' + cr ) : '',
\r
3739 '"width": ', panelW, ',', cr,
\r
3740 '"height": ', panelH, ',', cr,
\r
3741 '"panel_pictures_attributes": {', cr,
\r
3742 IMAGE_ARRAY.join( ',' + cr ), cr,
\r
3744 '"balloons_attributes": {', cr,
\r
3745 BALLOON_ARRAY.join( ',' + cr ), cr,
\r
3751 function imageToJson( _imageElement ){
\r
3752 var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
\r
3755 '"resource_picture_id": ', _imageElement.resourcePicture().id, ',', cr,
\r
3756 '"x": ', _imageElement.x, ',', cr,
\r
3757 '"y": ', _imageElement.y, ',', cr,
\r
3758 '"z": ', _imageElement.z, ',', cr,
\r
3759 '"width": ', _imageElement.flipH() * _imageElement.w, ',', cr,
\r
3760 '"height": ', _imageElement.flipV() * _imageElement.h, ',', cr,
\r
3761 '"t": ', timing, cr,
\r
3766 function balloonToJson( _textElement ){
\r
3767 var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
\r
3770 '"balloon_template_id": ', 1, ',', cr,
\r
3771 '"system_picture_id": ', 1, ',', cr,
\r
3772 '"size": ', 1, ',', cr,
\r
3773 '"tail": ', _textElement.angle(), ',', cr,
\r
3774 '"x": ', _textElement.x, ',', cr,
\r
3775 '"y": ', _textElement.y, ',', cr,
\r
3776 '"z": ', _textElement.z, ',', cr,
\r
3777 '"t": ', timing, ',', cr,
\r
3778 '"width": ', _textElement.w, ',', cr,
\r
3779 '"height": ', _textElement.h, ',', cr,
\r
3780 '"speaches_attributes": {', cr,
\r
3781 '"newf', timing, '": {', cr,
\r
3782 '"content": "', _textElement.text(), '",', cr,
\r
3783 '"x": ', _textElement.x, ',', cr,
\r
3784 '"y": ', _textElement.y, ',', cr,
\r
3785 '"t": ', timing, ',', cr,
\r
3786 '"width": ', _textElement.w, ',', cr,
\r
3787 '"height": ', _textElement.h, cr,
\r
3794 function clickGenerate(){
\r
3795 var i = comboboxFormat.selectIndex(),
\r
3796 text = 'sorry...';
\r
3798 text = getJsonPostString();
\r
3801 text = getJsonGetString();
\r
3804 text = getAsHtmlString( false, false );
\r
3808 jqOutputArea.val( text );
\r
3810 function clickClose(){
\r
3811 pettanr.outputConsole.shutdown();
\r
3815 /* grobal method */
\r
3816 this.rootElement = document.getElementById( 'output-console-wrapper' );
\r
3817 this.displayName = ID;
\r
3820 this.MIN_WIDTH = 320;
\r
3821 this.MIN_HEIGHT = 320;
\r
3822 this.init = function(){
\r
3823 jqWrap = $( '#output-console-wrapper').hide();
\r
3824 jqOutputArea = $( '#output-area');
\r
3826 comboboxFormat = pettanr.form.createCombobox( document.getElementById( 'output-console-format' ), null, ID );
\r
3827 for( var i=0, l = FORMAT_LIST.length; i<l; ++i ){
\r
3828 comboboxFormat.createOption( FORMAT_LIST[ i ], null, i === 0 );
\r
3830 inputOption = pettanr.form.createInputText( document.getElementById( 'output-console-option' ), null, ID );
\r
3831 buttonGenerate = pettanr.form.createButton( document.getElementById( 'output-console-generate-button' ), clickGenerate, ID );
\r
3832 buttonClose = pettanr.form.createButton( document.getElementById( 'output-console-close-button' ), clickClose, ID );
\r
3833 delete instance.init;
\r
3835 this.onOpen = function( _w, _h, _comicID, _panelID, _panelTimming, _panelW, _panelH, _borderSize, _panelElementArray ){
\r
3836 instance.init && instance.init();
\r
3839 instance.onPaneResize( _w, _h );
\r
3842 comicID = _comicID;
\r
3843 panelID = _panelID;
\r
3844 panelTimming = _panelTimming;
\r
3847 borderSize = _borderSize;
\r
3848 panelElementArray = _panelElementArray;
\r
3852 this.onPaneResize = function( _w, _h){
\r
3855 left: Math.floor( ( _w -jqWrap.width()) /2),
\r
3856 top: Math.floor( ( _h -jqWrap.height()) /2)
\r
3860 this.onClose = function(){
\r
3862 jqOutputArea.val('');
\r