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
34 pettanr.LINE_FEED_CODE_TEXTAREA = ( function(){
\r
35 var text = document.getElementById( 'shadowTxtarea'),
\r
36 form = text.parentNode;
\r
37 form.parentNode.removeChild( form);
\r
40 pettanr.LINE_FEED_CODE_PRE = ( function(){
\r
41 var pre = document.getElementById( 'shadowPre');
\r
42 pre.parentNode.removeChild( pre);
\r
43 return pettanr.ua.isIE === true ? this.LINE_FEED_CODE_TEXTAREA : pre.innerHTML; // ie ??
\r
46 /* ----------------------------------------
\r
48 * - MENU_BAR_CONTROL
\r
51 * - TEXT_EDITOR_CONTROL
\r
52 * - IMAGE_GROUP_EXPROLER
\r
55 * - INFOMATION_WINDOW
\r
57 * - HELP_DOCUMENTS_WINDOW
\r
60 * - WHITE_GLASS_CONTROL
\r
64 * - PanelResizerClass
\r
65 * - PANEL_RESIZER_TOP
\r
66 * - PANEL_RESIZER_BOTTOM
\r
67 * - CONSOLE_CONTROLER
\r
71 * - POSITION_OPERATOR
\r
72 * - COMIC_ELEMENT_OPERATION_MANAGER
\r
74 * - ImageElementClass
\r
75 * - TextElementClass
\r
77 * - COMIC_ELEMENT_CONTROL
\r
81 pettanr.editor = ( function(){
\r
83 var COMIC_ELEMENT_TYPE_IMAGE = 0,
\r
84 COMIC_ELEMENT_TYPE_TEXT = 1,
\r
85 MOUSE_LISTENER_ARRAY = [],
\r
86 COMIC_ELEMENT_ARRAY = [],
\r
87 ELM_MOUSE_EVENT_CHATCHER = document.getElementById( 'mouse-operation-catcher'),
\r
88 MIN_PANEL_HEIGHT = 20,
\r
89 MIN_OBJECT_SIZE = 19,
\r
90 MOUSE_HIT_AREA = 10,
\r
91 jqMouseEventChacher,
\r
94 currentListener = null,
\r
99 /* ----------------------------------------
\r
109 var MENU_BAR_CONTROL = ( function(){
\r
110 var ELM_BAR = document.getElementById( 'menu-bar'),
\r
111 ELM_ITEM_CLASSNAME = 'menu-bar-item',
\r
112 ELM_ITEM_ORIGN = ( function(){
\r
113 var ret = document.createElement( 'div'),
\r
114 div = document.createElement( 'div'),
\r
115 ul = document.createElement( 'ul');
\r
116 ret.className = ELM_ITEM_CLASSNAME;
\r
117 ret.appendChild( div);
\r
118 ret.appendChild( ul);
\r
121 ELM_SELECTION_ORIGN = ( function(){
\r
122 var ret = document.createElement( 'li'),
\r
123 a = document.createElement( 'a'),
\r
124 span = document.createElement( 'span'),
\r
125 key = document.createElement( 'kbd');
\r
126 a.appendChild( span);
\r
127 a.appendChild( key);
\r
128 ret.appendChild( a);
\r
132 EMPTY_FUNCTION = new Function,
\r
134 barH = pettanr.util.getElementSize( ELM_BAR).height,
\r
135 itemW = pettanr.util.getElementSize( ELM_ITEM_ORIGN).width,
\r
136 selectionW = pettanr.util.getElementSize( ELM_ITEM_ORIGN.getElementsByTagName( 'ul')[ 0]).width,
\r
138 ELM_BAR.style.top = ( -barH) +'px';
\r
140 var MenubarSelectionClass = function( container, title, shortcut, visible, separateAfter){
\r
141 var ELM_WRAPPER = ELM_SELECTION_ORIGN.cloneNode( true),
\r
142 ELM_TITLE = ELM_WRAPPER.getElementsByTagName( 'span')[ 0],
\r
143 elmShortcut = ELM_WRAPPER.getElementsByTagName( 'kbd')[ 0];
\r
146 elmShortcut.innerHTML = shortcut;
\r
148 elmShortcut.parentNode.removeChild( elmShortcut);
\r
150 elmShortcut = null;
\r
152 container.appendChild( ELM_WRAPPER);
\r
154 updateTitle( title);
\r
155 updateVisible( visible);
\r
157 function updateTitle( _title){
\r
158 ELM_TITLE.innerHTML = title = _title;
\r
160 function updateVisible( _visible){
\r
161 if( _visible !== undefined){
\r
162 visible = !!_visible;
\r
163 ELM_WRAPPER.className = visible === true ? '' : 'disabled';
\r
168 title: function( _title){
\r
169 _title !== undefined && updateTitle( _title);
\r
172 visible: function( _visible){
\r
173 visible !== !!_visible && updateVisible( _visible);
\r
176 separateAfter: separateAfter
\r
180 var MenuBarItemClass = function( title, opt_callbackArray){
\r
181 var ELM_WRAPPER = ELM_ITEM_ORIGN.cloneNode( true),
\r
182 ELM_TITLE = ELM_WRAPPER.getElementsByTagName( 'div')[ 0],
\r
183 ELM_SELECTION = ELM_WRAPPER.getElementsByTagName( 'ul')[ 0],
\r
184 INDEX = ITEM_ARRAY.length,
\r
185 SELECTION_CALLBACK_ARRAY = opt_callbackArray || [],
\r
188 ELM_TITLE.innerHTML = title;
\r
190 ELM_WRAPPER.style.left = ( itemW * INDEX) +'px';
\r
191 ELM_BAR.appendChild( ELM_WRAPPER);
\r
193 function onClick( e){
\r
196 var parent = that.parentNode,
\r
197 children = parent.getElementsByTagName( 'li'),
\r
198 l = children.length;
\r
199 for(var i=0; i<l; ++i){
\r
200 if( children[ i] === that) return i;
\r
204 i !== -1 && this.className !== 'disabled' && SELECTION_CALLBACK_ARRAY[ i]();
\r
205 e.stopPropagation();
\r
212 $( ELM_SELECTION).children( 'li').click( onClick);
\r
216 if( visible === true) return;
\r
217 jqStage.append( ELM_WRAPPER);
\r
218 ELM_WRAPPER.className = ELM_ITEM_CLASSNAME +'-focus';
\r
219 this.onShow && setTimeout( this.onShow, 0);
\r
223 if( visible === false) return;
\r
224 ELM_BAR.appendChild( ELM_WRAPPER);
\r
225 ELM_WRAPPER.className = ELM_ITEM_CLASSNAME;
\r
226 this.onHide && setTimeout( this.onHide, 0);
\r
229 createSelection: function( title, shortcut, callback, visible, separateBefore, separateAfter){
\r
230 var ret = MenubarSelectionClass.apply( {}, [ ELM_SELECTION, title, shortcut, visible, separateAfter]),
\r
231 before = SELECTION_CALLBACK_ARRAY.length > 0 ? SELECTION_CALLBACK_ARRAY[ SELECTION_CALLBACK_ARRAY.length -1] : null;
\r
232 SELECTION_CALLBACK_ARRAY.push( callback);
\r
233 if( before !== null && ( separateBefore === true || before.separateAfter === true)){
\r
234 ret.elm.style.borderTop = '1px solid #ccc';
\r
242 function createMenubarItem( title){
\r
243 var _item = MenuBarItemClass.apply( {}, [ title]);
\r
244 ITEM_ARRAY.push( _item);
\r
249 jqStage = jqEditor;
\r
250 jqBar = $( ELM_BAR).animate( { top: 0});
\r
252 var l = ITEM_ARRAY.length;
\r
253 for( var i=0; i<l; ++i){
\r
254 ITEM_ARRAY[ i].init();
\r
257 delete MENU_BAR_CONTROL.init;
\r
260 onMouseMove: function( _mouseX, _mouseY){
\r
261 if( barH >= _mouseY){
\r
264 var l = ITEM_ARRAY.length;
\r
265 for( var i=0; i<l; ++i){
\r
266 ITEM_ARRAY[ i].hide();
\r
270 onMouseUp: function( _mouseX, _mouseY){
\r
273 onMouseDown: function( _mouseX, _mouseY){
\r
274 var l = ITEM_ARRAY.length;
\r
275 if( barH < _mouseY || itemW * l < _mouseX) return false;
\r
276 for( var i=0; i<l; ++i){
\r
277 if( i * itemW <= _mouseX && _mouseX < ( i +1) * itemW){
\r
278 ITEM_ARRAY[ i].show();
\r
280 ITEM_ARRAY[ i].hide();
\r
285 busy: function( _busy){
\r
288 onWindowResize: function( _windowW, _windowH){
\r
291 QUIT: createMenubarItem( 'Quit'),
\r
292 EDIT: createMenubarItem( 'Edit'),
\r
293 WINDOW: createMenubarItem( 'Window'),
\r
294 HELP: pettanr.util.extend( createMenubarItem( 'Help'), {
\r
295 createAjaxSelection: function( callback){
\r
296 var elmLoading = document.createElement( 'li'),
\r
298 elmSelection = this.elm.getElementsByTagName( 'ul')[ 0];
\r
299 elmSelection.appendChild( elmLoading);
\r
300 elmLoading.className = 'loading';
\r
301 elmLoading.style.height = '90px';
\r
303 this.onShow = callback;
\r
306 delete this.createAjaxSelection;
\r
308 elmSelection.removeChild( elmLoading);
\r
309 $( elmSelection).children( 'li').click( that.onClick);
\r
310 elmLoading = elmSelection = null;
\r
311 delete that.onShow;
\r
320 /* ----------------------------------------
\r
323 var HISTORY = ( function() {
\r
324 var STACK_BACK = [],
\r
325 STACK_FORWARD = [],
\r
326 MENUBAR_BACK = MENU_BAR_CONTROL.EDIT.createSelection( 'back', 'ctrl + z', back, false),
\r
327 MENUBAR_FORWARD = MENU_BAR_CONTROL.EDIT.createSelection( 'forward', 'ctrl + y', forward, false, false, true),
\r
330 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 90, false, true, back); // ctrl + Z
\r
331 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 90, true, true, forward); // ctrl + shift + Z
\r
332 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 89, false, true, forward); // ctrl + Y
\r
336 * currentを控えてSTACK_FORWARD.push(current)
\r
337 * STACK_BACK.pop()を実行してcurrentに
\r
339 if( STACK_BACK.length === 0) return;
\r
341 var state = STACK_BACK.pop();
\r
342 state && state.fn( state.argBack);
\r
343 MENUBAR_BACK.visible( STACK_BACK.length !== 0);
\r
344 SAVE_CONTROL.panelUpdated( STACK_BACK.length !== 0);
\r
346 STACK_FORWARD.push( state);
\r
347 MENUBAR_FORWARD.visible( true);
\r
349 function forward(){
\r
350 if( STACK_FORWARD.length === 0) return;
\r
352 var state = STACK_FORWARD.pop();
\r
353 state.fn( state.argForword);
\r
354 MENUBAR_FORWARD.visible( STACK_FORWARD.length !== 0);
\r
356 STACK_BACK.push( state);
\r
357 MENUBAR_BACK.visible( true);
\r
358 SAVE_CONTROL.panelUpdated( true);
\r
362 log = $( '#history-log');
\r
363 delete HISTORY.init;
\r
365 saveState: function( _function, _argBack, _argForword, _destory) {
\r
369 argForword: _argForword,
\r
372 MENUBAR_BACK.visible( true);
\r
373 SAVE_CONTROL.panelUpdated( true);
\r
375 while( STACK_FORWARD.length > 0){
\r
376 var _stack = STACK_FORWARD.shift(),
\r
377 _destroy = _stack.destroy,
\r
379 _argBack = _stack.argBack;
\r
380 _argForword = _stack.argForword;
\r
382 if( typeof _argBack === 'array'){
\r
383 while( _argBack.length > 0){
\r
384 _value = _argBack.shift();
\r
385 _destroy === true && typeof _value.destroy === 'function' && _value.destroy();
\r
388 if( typeof _argForword === 'array'){
\r
389 while( _argForword.length > 0){
\r
390 _value = _argForword.shift();
\r
391 _destroy === true && typeof _value.destroy === 'function' && _value.destroy();
\r
395 MENUBAR_FORWARD.visible( false);
\r
401 /* ----------------------------------------
\r
405 var SAVE_CONTROL = ( function(){
\r
406 var SAVE = MENU_BAR_CONTROL.QUIT.createSelection( 'save', 'ctrl + S', quit, false),
\r
407 SAVE_AND_QUIT = MENU_BAR_CONTROL.QUIT.createSelection( 'save & quit', null, quit, false, false, true),
\r
408 SAVE_AS_HTML = MENU_BAR_CONTROL.QUIT.createSelection( 'get as html', null, outputAsHtml, true, false, true),
\r
409 SAVE_AS_JSON_STRING = MENU_BAR_CONTROL.QUIT.createSelection( 'get JsonStr', null, outputAsJsonString, true, false, true),
\r
410 QUIT = MENU_BAR_CONTROL.QUIT.createSelection( 'quit', null, quit, true, true),
\r
416 function outputAsHtml(){
\r
417 alert( COMIC_ELEMENT_CONTROL.getAsHTML( true, false));
\r
419 function outputAsJsonString(){
\r
420 alert( COMIC_ELEMENT_CONTROL.getAsJsonString());
\r
424 panelUpdated: function( _updated){
\r
425 if( _updated !== undefined && updated !== _updated){
\r
426 SAVE.visible( !!_updated);
\r
427 SAVE_AND_QUIT.visible( !!_updated);
\r
428 updated = !!_updated;
\r
438 /* ----------------------------------------
\r
439 * Text Editor (Overlay)
\r
442 var TEXT_EDITOR_CONTROL = ( function(){
\r
443 var jqWrap, jqTextarea, jqButton,
\r
444 textElement, onUpdateFunction;
\r
446 pettanr.key.addKeyDownEvent( this.ID, 69, false, false, clickOK);
\r
450 textElement = onUpdateFunction = null;
\r
452 function clickOK(){
\r
453 pettanr.overlay.hide();
\r
454 textElement && textElement.text( jqTextarea.val());
\r
455 onUpdateFunction && onUpdateFunction( textElement);
\r
460 this.jqWrap = jqWrap = $( '#speach-editor-wrapper').hide();
\r
461 jqTextarea = $( '#speach-editor').keydown( function( e){
\r
462 if( e.keyCode === 69 && e.shiftKey === false && e.ctrlKey === true){
\r
464 e.preventDefault();
\r
466 e.cancelBubble = true;
\r
467 e.returnValue = false;
\r
471 jqButton = $( '#speach-edit-complete-button').click( clickOK);
\r
472 delete TEXT_EDITOR_CONTROL.init;
\r
475 show: function( _textElement, _onUpdateFunction){
\r
476 textElement = _textElement;
\r
477 onUpdateFunction = _onUpdateFunction || null;
\r
478 pettanr.overlay.show( this);
\r
479 var h = _textElement.h;
\r
480 jqWrap.show().css( {
\r
481 left: _textElement.x +PANEL_CONTROL.x(),
\r
482 top: _textElement.y +PANEL_CONTROL.y(),
\r
483 width: _textElement.w,
\r
486 jqTextarea.val( _textElement.text()).focus();
\r
489 * ie6,7は、textarea { width:100%}でも高さが変わらない。rowsを設定。
\r
491 pettanr.ua.isIE === true && pettanr.ua.ieVersion <= 7 && setTimeout( function(){
\r
493 while( jqTextarea.height() < h){
\r
495 jqTextarea.attr( 'rows', rows);
\r
497 rows > 1 && jqTextarea.attr( 'rows', rows -1);
\r
500 onWindowResize: function(){
\r
501 textElement && this.show( textElement);
\r
508 /* ----------------------------------------
\r
509 * Image Group Exproler (Overlay)
\r
511 var IMAGE_GROUP_EXPROLER = ( function(){
\r
512 var ICON_ARRAY = [],
\r
514 containerW, containerH, wrapX,
\r
515 jqWrap, jqContainer, jqItemOrigin,
\r
517 jqName, jqButton, buttonW,
\r
520 onEnterInterval = null;
\r
522 var BASE_PATH = pettanr.LOCAL === false ? 'http://pettan.heroku.com/resource_pictures/' : 'resource_pictures/',
\r
523 THUMB_PATH = BASE_PATH, // + 'thumbnail/',
\r
524 LIMIT_FILESIZE = 1024 * 10; // 10KB
\r
528 "created_at": "2011-11-13T08:57:39Z",
\r
533 "updated_at": "2011-11-13T08:57:39Z",
\r
537 "created_at": "2011-11-13T08:57:54Z",
\r
542 "updated_at": "2011-11-13T08:57:54Z",
\r
546 "created_at": "2011-11-13T08:58:06Z",
\r
551 "updated_at": "2011-11-13T08:58:06Z",
\r
555 "created_at": "2011-11-13T08:58:23Z",
\r
560 "updated_at": "2011-11-13T08:58:23Z",
\r
564 "created_at": "2011-11-13T08:58:33Z",
\r
566 "filesize": 11061,
\r
569 "updated_at": "2011-11-13T08:58:33Z",
\r
573 "created_at": "2011-11-20T09:50:43Z",
\r
578 "updated_at": "2011-11-20T09:50:43Z",
\r
582 "created_at": "2011-11-20T09:50:55Z",
\r
587 "updated_at": "2011-11-20T09:50:55Z",
\r
591 "created_at": "2011-11-20T11:33:12Z",
\r
593 "filesize": 17919,
\r
596 "updated_at": "2011-11-20T11:33:12Z",
\r
600 "created_at": "2011-11-20T11:33:12Z",
\r
602 "filesize": 17919,
\r
605 "updated_at": "2011-11-20T11:33:12Z",
\r
609 "created_at": "2011-11-20T11:33:12Z",
\r
611 "filesize": 17919,
\r
614 "updated_at": "2011-11-20T11:33:12Z",
\r
618 "created_at": "2011-11-20T11:33:12Z",
\r
620 "filesize": 17919,
\r
623 "updated_at": "2011-11-20T11:33:12Z",
\r
627 "created_at": "2011-11-22T09:17:20Z",
\r
632 "updated_at": "2011-11-22T09:17:20Z",
\r
636 "created_at": "2011-11-22T10:11:07Z",
\r
641 "updated_at": "2011-11-22T10:11:07Z",
\r
645 "created_at": "2011-11-24T09:05:12Z",
\r
650 "updated_at": "2011-11-24T09:05:12Z",
\r
654 "created_at": "2011-11-26T04:52:12Z",
\r
659 "updated_at": "2011-11-26T04:52:12Z",
\r
663 "created_at": "2011-11-26T04:52:12Z",
\r
668 "updated_at": "2011-11-26T04:52:12Z",
\r
672 "created_at": "2011-11-26T04:52:12Z",
\r
677 "updated_at": "2011-11-26T04:52:12Z",
\r
681 "created_at": "2011-11-26T04:52:12Z",
\r
686 "updated_at": "2011-11-26T04:52:12Z",
\r
690 "created_at": "2011-11-26T04:52:12Z",
\r
695 "updated_at": "2011-11-26T04:52:12Z",
\r
701 var ImageGroupIconClass = function( INDEX, data){
\r
702 var JQ_ICON_WRAP = jqItemOrigin.clone( true),
\r
703 SRC = [ BASE_PATH, data.id, '.', data.ext].join( ''),
\r
704 LOW_SRC = data.filesize && data.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext].join( '') : null,
\r
705 reversibleImage = null,
\r
706 onEnterFlag = false;
\r
707 JQ_ICON_WRAP.children( 'div').eq( 0).html( data.filesize + 'bytes');
\r
708 jqContainer.append( JQ_ICON_WRAP.css( { left: INDEX * itemW}));
\r
711 onEnter: function(){
\r
712 if( onEnterFlag === true) return;
\r
713 reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, function( url, imgW, imgH){
\r
714 if( reversibleImage === null) {
\r
721 imgW = imgW || data.width || 64;
\r
722 imgH = imgH || data.height || 64;
\r
723 JQ_ICON_WRAP.children( 'div').eq( 1).html( imgW +'x' +imgH);
\r
724 var zoom = 128 /( imgW > imgH ? imgW : imgH),
\r
725 h = Math.floor( imgH *zoom),
\r
726 w = Math.floor( imgW *zoom);
\r
727 reversibleImage.elm.style.width = w +'px';
\r
728 reversibleImage.elm.style.height = h +'px';
\r
729 reversibleImage.elm.style.margin = Math.floor( itemH /2 -h /2)+'px 0 0';
\r
730 reversibleImage.resize( w, h);
\r
731 JQ_ICON_WRAP.click( function( e){
\r
732 pettanr.overlay.hide();
\r
733 if (onUpdateFunction) {
\r
734 if( LOW_SRC === null){
\r
735 onUpdateFunction( SRC, imgW, imgH);
\r
737 ( function( onUpdate){
\r
738 pettanr.util.loadImage( SRC,
\r
739 function( _abspath, imgW, imgH){
\r
740 onUpdate( SRC, imgW, imgH);
\r
743 function( _abspath){
\r
744 onUpdate( SRC, data.width || 64, data.height || 64);
\r
748 })( onUpdateFunction); // close()で値が消えるので、クロージャに保持
\r
754 JQ_ICON_WRAP.children( 'img').replaceWith( reversibleImage.elm);
\r
755 onEnterFlag = true;
\r
757 destroy: function(){
\r
758 reversibleImage && reversibleImage.destroy();
\r
759 JQ_ICON_WRAP.remove();
\r
760 reversibleImage = JQ_ICON_WRAP = null;
\r
761 delete this.destroy;
\r
767 jqContainer.stop().animate( {
\r
769 top: Math.floor( windowH /2)
\r
773 while( ICON_ARRAY.length > 0){
\r
774 ICON_ARRAY.shift().destroy();
\r
776 onEnterInterval !== null && window.clearTimeout( onEnterInterval);
\r
777 onUpdateFunction = onEnterInterval = null;
\r
779 function onEnterShowImage(){
\r
780 var l = ICON_ARRAY.length,
\r
781 _start = -wrapX /itemW -1,
\r
782 _end = _start + winW /itemW +1;
\r
783 for( var i=0; i<l; ++i){
\r
784 _start < i && i < _end && ICON_ARRAY[ i].onEnter();
\r
786 onEnterInterval !== null && window.clearTimeout( onEnterInterval);
\r
787 onEnterInterval = null;
\r
789 function clickOK(){
\r
790 pettanr.overlay.hide();
\r
791 // onUpdateFunction && onUpdateFunction( textElement);
\r
796 this.jqWrap = jqWrap = $( '#image-gruop-wrapper').hide();
\r
797 jqContainer = $( '#image-icon-container').mousewheel(
\r
798 function( e, delta){
\r
799 if( winW < containerW){
\r
800 wrapX += delta *WHEEL_DELTA;
\r
801 wrapX = wrapX > 0 ? 0 : wrapX < winW -containerW ? winW -containerW : wrapX;
\r
802 jqContainer.css( { left: wrapX});
\r
804 onEnterInterval !== null && window.clearTimeout( onEnterInterval);
\r
805 onEnterInterval = window.setTimeout( onEnterShowImage, 500);
\r
807 //e.stopPropagation();
\r
810 containerH = pettanr.util.getElementSize( jqContainer.get( 0)).height;
\r
811 jqItemOrigin = $( $( '#imageGruopItemTemplete').remove().html());
\r
812 var itemSize = pettanr.util.getElementSize( jqItemOrigin.get( 0));
\r
813 itemW = itemSize.width;
\r
814 itemH = itemSize.height;
\r
815 jqName = $( '#gruop-name-display');
\r
816 jqButton = $( '#image-gruop-button').click( clickOK);
\r
817 buttonW = pettanr.util.getElementSize( jqButton.get( 0)).width;
\r
819 delete IMAGE_GROUP_EXPROLER.init;
\r
822 show: function( _onUpdateFunction){
\r
823 onUpdateFunction = _onUpdateFunction;
\r
824 pettanr.overlay.show( this);
\r
826 var CURRENT_GROUP_ARRAY = IMAGE_DATA[ 'pen001'] || [],
\r
827 l = CURRENT_GROUP_ARRAY.length;
\r
828 for( var i=0; i<l; ++i){
\r
829 ICON_ARRAY.push( ImageGroupIconClass.apply( {}, [ i, CURRENT_GROUP_ARRAY[ i]]));
\r
832 containerW = l * itemW;
\r
835 var w = winW > containerW ? winW : containerW,
\r
836 h = windowH > containerH ? containerH : windowH;
\r
843 top: Math.floor( windowH /2)
\r
844 }).stop().animate( {
\r
846 top: Math.floor( windowH /2 -h /2)
\r
850 left: Math.floor( winW /2 -buttonW /2),
\r
851 top: Math.floor( windowH /2 +containerH /2 +10)
\r
854 onEnterShowImage();
\r
856 onWindowResize: function( _windowW, _windowH){
\r
857 var w = _windowW > containerW ? _windowW : containerW,
\r
858 h = _windowH > containerH ? containerH : _windowH,
\r
859 offsetW = Math.floor( _windowW /2 -winW /2);
\r
861 if( offsetW <= 0){ // smaller
\r
867 top: Math.floor( _windowH /2 -h /2)
\r
870 jqContainer.css( { // bigger
\r
873 borderLeftWidth: offsetW
\r
875 top: Math.floor( _windowH /2 -h /2),
\r
880 left: Math.floor( _windowW /2 -buttonW /2),
\r
881 top: Math.floor( _windowH /2 +containerH /2 +10)
\r
883 onEnterShowImage();
\r
886 ID: 'imageGroupExproler'
\r
890 /* ----------------------------------------
\r
893 var WINDOWS_CONTROL = ( function(){
\r
895 * 表示上手前にあるwindowは、WINDOW_ARRAYの先頭にあり、htmlでは後ろにある。
\r
897 var DEFAULT_MIN_WINDOW_WIDTH = 200,
\r
898 DEFAULT_MIN_WINDOW_HEIGHT = 200,
\r
900 WINDOW_BODY_BODER_SIZE = 1,
\r
903 currentWindowIndex = -1,
\r
906 var jqWindowOrigin,
\r
908 var WindowClass = function( bodyTempleteID, title, x, y, w, h, visible, CLOSE_BUTTON_ENABLED, RESIZE_BUTTON_ENABLED, minWindowW, minWindowH){
\r
909 var MOUSE_CURSOR = updateMouseCursor,
\r
910 MENUBAR_SELWCTION = MENU_BAR_CONTROL.WINDOW.createSelection(
\r
911 ( visible !== true ? 'show ' : 'hide ') +title,
\r
912 null, onMenuClick, true
\r
915 jqWrapper, jqHeader, jqFooter = null,
\r
916 elmBody, elmBodyStyle,
\r
917 startX, startY, startW, startH,
\r
919 headerH, bodyH, footerH = 0,
\r
920 isDragging = false,
\r
921 isResizing = false,
\r
922 bodyIsTachable = false,
\r
925 function onMenuClick(){
\r
926 visible === true ? instance.close() : instance.open();
\r
928 function update( _x, _y, _w, _h){
\r
929 _x = _x !== undefined ? _x : x;
\r
930 _y = _y !== undefined ? _y : y;
\r
931 _y = _y > MENU_BAR_CONTROL.h ? _y : MENU_BAR_CONTROL.h;
\r
932 _w = _w !== undefined ? _w : w;
\r
933 _h = _h !== undefined ? _h : h;
\r
940 bodyH = _h -headerH -footerH;
\r
941 elmBodyStyle.height = bodyH +'px';
\r
942 ( w !== _w || h !== _h) && instance.onResize && instance.onResize( _w, bodyH);
\r
948 function bodyBackOrForward( isBack){
\r
949 if( !instance) return;
\r
950 if( bodyIsTachable === !isBack) return;
\r
951 elmBodyStyle.position = isBack === true ? 'relative' : 'absolute';
\r
952 elmBodyStyle.left = isBack === true ? 0 : x +'px';
\r
953 elmBodyStyle.top = isBack === true ? 0 : y +headerH +'px';
\r
954 elmBodyStyle.width = isBack === true ? '' : ( w -WINDOW_BODY_BODER_SIZE *2) +'px';
\r
955 bodyIsTachable === isBack && isBack === true ? jqHeader.after( elmBody) : jqStage.append( elmBody);
\r
956 bodyIsTachable = !isBack;
\r
958 function onWindowResize( e){
\r
959 bodyBackOrForward( true);
\r
967 MOUSE_CURSOR( 'nw-resize');
\r
968 e.stopPropagation();
\r
972 init: function( jqContainer){
\r
974 * setTimeout で呼ばれるグローバルメソッド内では、this でなく instance を使う.
\r
978 jqWindowOrigin = jqWindowOrigin || ( function(){
\r
979 return $( $( '#windowTemplete').remove().html());
\r
981 closeButtonWidth = closeButtonWidth || ( function(){
\r
982 return pettanr.util.getElementSize( jqWindowOrigin.clone( true).find( '.window-close-button').get( 0)).width;
\r
985 jqStage = jqEditor;
\r
986 this.$ = jqWrapper = jqWindowOrigin.clone( true);
\r
987 jqHeader = jqWrapper.children( '.window-header').eq( 0).html( title);
\r
988 headerH = pettanr.util.getElementSize( jqHeader.get( 0)).height;
\r
989 elmBody = jqWrapper.children( '.window-body').get( 0);
\r
990 elmBodyStyle = elmBody.style;
\r
992 if( bodyTempleteID) {
\r
993 jqWrapper.find( '.window-body-insert-position').replaceWith( $( $( '#' +bodyTempleteID).remove().html()));
\r
995 jqWrapper.find( '.window-body-insert-position').remove();
\r
997 CLOSE_BUTTON_ENABLED !== true && jqWrapper.find( '.window-close-button').remove();
\r
999 this.onInit && this.onInit();
\r
1002 x: function(){ return x;},
\r
1003 y: function(){ return y;},
\r
1004 w: function(){ return w;},
\r
1005 h: function(){ return h;},
\r
1007 title: function( _title){
\r
1008 typeof _title === 'string' && jqHeader.html( _title);
\r
1009 title = typeof _title === 'string' ? _title : title;
\r
1013 firstOpen: function(){
\r
1014 if( RESIZE_BUTTON_ENABLED === true){
\r
1015 footerH = pettanr.util.getElementSize( jqWrapper.find( '.window-footer').get( 0)).height;
\r
1016 //jqWrapper.find( '.window-resize-button').eq( 0).mousedown( onWindowResize);
\r
1018 jqWrapper.find( '.window-footer').remove();
\r
1020 update( x, y, w, h);
\r
1022 this.onFirstOpen && this.onFirstOpen();
\r
1024 delete this.firstOpen;
\r
1027 if( visible === true) return;
\r
1028 instance.visible = visible = true;
\r
1029 openWindow( instance);
\r
1030 MENUBAR_SELWCTION.title( 'hide ' +title);
\r
1032 for( var i=0, l = WINDOW_ARRAY.length; i<l; ++i){
\r
1033 if( WINDOW_ARRAY[ i] === instance){
\r
1034 WINDOW_ARRAY.splice( i, 1);
\r
1035 WINDOW_ARRAY.unshift( instance);
\r
1036 currentWindow = null;
\r
1037 currentWindowIndex = -1;
\r
1041 close: function(){
\r
1042 if( visible === false) return;
\r
1043 instance.visible = visible = false;
\r
1044 instance.onClose && setTimeout( instance.onClose, 0);
\r
1045 closeWindow( instance);
\r
1046 MENUBAR_SELWCTION.title( 'show ' +title);
\r
1048 bodyBackOrForward: bodyBackOrForward,
\r
1049 onMouseDown: function( _mouseX, _mouseY){
\r
1050 if( RESIZE_BUTTON_ENABLED === true && x +w -20 <= _mouseX && _mouseX < x +w && y +headerH +bodyH < _mouseY && _mouseY <= y +h){
\r
1051 bodyBackOrForward( true);
\r
1052 isResizing = true;
\r
1057 offsetX = _mouseX;
\r
1058 offsetY = _mouseY;
\r
1059 MOUSE_CURSOR( 'nw-resize');
\r
1063 if( x > _mouseX || y > _mouseY || x +w < _mouseX || y +headerH < _mouseY ) return;
\r
1064 if( CLOSE_BUTTON_ENABLED === true && x +w -closeButtonWidth < _mouseX){
\r
1069 isDragging = true;
\r
1070 MOUSE_CURSOR( 'move');
\r
1075 offsetX = _mouseX;
\r
1076 offsetY = _mouseY;
\r
1078 onMouseUp: function( _mouseX, _mouseY){
\r
1079 isDragging = isResizing = false;
\r
1080 MOUSE_CURSOR( '');
\r
1082 onMouseMove: function( _mouseX, _mouseY){
\r
1083 var _updateX = _mouseX -offsetX,
\r
1084 _updateY = _mouseY -offsetY;
\r
1086 if( isResizing === true){
\r
1087 var _w = startW +_updateX,
\r
1088 _h = startH +_updateY;
\r
1089 update( startX, startY, _w < minWindowW ? minWindowW : _w, _h < minWindowH ? minWindowH : _h);
\r
1092 if( isDragging === true) {
\r
1093 update( startX +_updateX, startY +_updateY);
\r
1096 if( x > _mouseX || x +w < _mouseX ) return;
\r
1098 ( y <= _mouseY && y +headerH >= _mouseY ) ?
\r
1099 MOUSE_CURSOR( 'pointer') : // hit to header
\r
1100 MOUSE_CURSOR( '');
\r
1101 bodyBackOrForward( y +headerH > _mouseY || y +headerH +bodyH < _mouseY);
\r
1103 onMouseOut: function( _mouseX, _mouseY){
\r
1104 bodyIsTachable === true && bodyBackOrForward( true);
\r
1105 isDragging = false;
\r
1106 MOUSE_CURSOR( '');
\r
1109 return isDragging === true || isResizing === true;
\r
1111 bodyHeight: function(){
\r
1117 function getCurrentWindow( _mouseX, _mouseY){
\r
1118 if( currentWindow && currentWindow.busy() === true) return currentWindowIndex;
\r
1119 var l = WINDOW_ARRAY.length,
\r
1120 _currentWindow = null,
\r
1122 currentWindowIndex = -1;
\r
1123 for( var i=0; i<l; i++){
\r
1124 _win = WINDOW_ARRAY[ i];
\r
1125 if( _win.visible !== true) continue;
\r
1128 if( _x <= _mouseX && _y <= _mouseY && _x +_win.w() >= _mouseX && _y +_win.h() >= _mouseY){
\r
1129 _currentWindow = _win;
\r
1130 currentWindowIndex = i;
\r
1134 currentWindow && currentWindow !== _currentWindow && currentWindow.onMouseOut( _mouseX, _mouseY);
\r
1135 currentWindow = _currentWindow;
\r
1136 return currentWindowIndex;
\r
1138 function openWindow( _window){
\r
1139 if( _window.visible !== true) return;
\r
1140 var _jqWindow = _window.$;
\r
1141 jqContainer.append( _jqWindow);// appendした後に fadeIn() しないと ie で filterが適用されない.
\r
1144 _window.firstOpen && _window.firstOpen();
\r
1145 _window.onOpen && setTimeout( _window.onOpen, 0);
\r
1150 function closeWindow( _window){
\r
1151 if( _window.visible !== false) return;
\r
1152 var l = WINDOW_ARRAY.length;
\r
1153 for( var i=0; i<l; ++i){
\r
1154 if( WINDOW_ARRAY[ i] === _window){
\r
1155 //WINDOW_ARRAY.splice( i, 1);
\r
1156 //WINDOW_ARRAY.push( _window);
\r
1157 _window.$.stop().fadeOut( function(){
\r
1158 this.parentNode.removeChild( this);
\r
1167 jqContainer = $( '#window-container');
\r
1169 var l = WINDOW_ARRAY.length,
\r
1171 for( var i=l-1; i >= 0; --i){
\r
1172 _window = WINDOW_ARRAY[ i];
\r
1173 _window.init && _window.init( jqContainer);
\r
1174 _window.visible === true && openWindow( _window);
\r
1176 log = $( '#window-log');
\r
1178 delete WINDOWS_CONTROL.init;
\r
1180 onMouseMove: function( _mouseX, _mouseY){
\r
1181 var _index = getCurrentWindow( _mouseX, _mouseY);
\r
1182 if( _index === 0){
\r
1183 currentWindow.onMouseMove( _mouseX, _mouseY);
\r
1186 if( _index !== -1){ // 先頭のクリックでない場合
\r
1188 WINDOW_ARRAY.splice( currentWindowIndex, 1);
\r
1189 WINDOW_ARRAY.unshift( currentWindow);
\r
1191 jqContainer.append( currentWindow.$);
\r
1192 currentWindowIndex = 0;
\r
1197 onMouseUp: function( _mouseX, _mouseY){
\r
1198 if( getCurrentWindow( _mouseX, _mouseY) === 0){
\r
1199 currentWindow.onMouseUp( _mouseX, _mouseY);
\r
1204 onMouseDown: function( _mouseX, _mouseY){
\r
1205 if( getCurrentWindow( _mouseX, _mouseY) === 0){
\r
1206 currentWindow.onMouseDown( _mouseX, _mouseY);
\r
1212 return currentWindow !== null;
\r
1214 onWindowResize: function( _windowW, _windowH){
\r
1219 createWindow: function( scope, EXTENDS, bodyTempleteID, title, x, y, w, h, opt_visible, opt_closeButtonEnabled, opt_resizeButtonEnabled, opt_minWindowW, opt_minWindowH){
\r
1220 opt_visible = opt_visible !== false;
\r
1221 opt_closeButtonEnabled = opt_closeButtonEnabled === true;
\r
1222 opt_resizeButtonEnabled = opt_resizeButtonEnabled === true;
\r
1223 opt_minWindowW = opt_minWindowW || ( w < DEFAULT_MIN_WINDOW_WIDTH) ? w : DEFAULT_MIN_WINDOW_WIDTH;
\r
1224 opt_minWindowH = opt_minWindowH || ( h < DEFAULT_MIN_WINDOW_HEIGHT) ? h : DEFAULT_MIN_WINDOW_HEIGHT;
\r
1226 var _window = pettanr.util.extend(
\r
1227 WindowClass.apply( scope, [ bodyTempleteID, title, x, y, w, h, opt_visible, opt_closeButtonEnabled, opt_resizeButtonEnabled, opt_minWindowW, opt_minWindowH]),
\r
1230 WINDOW_ARRAY.unshift( _window);
\r
1231 WINDOWS_CONTROL.init === undefined && _window.init( jqContainer);
\r
1232 WINDOWS_CONTROL.init === undefined && openWindow( _window);
\r
1238 /* ----------------------------------------
\r
1241 var TOOL_BOX_WINDOW = ( function(){
\r
1242 var addImageButton, addTextButton, editBgButton, switchGridButton, popupHelpButton, postButton,
\r
1245 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 73, false, true, addImage);
\r
1246 MENU_BAR_CONTROL.EDIT.createSelection( 'Add Image', 'ctrl + I', addImage, true, true, false);
\r
1248 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 84, false, true, addText);
\r
1249 MENU_BAR_CONTROL.EDIT.createSelection( 'Add Text', 'ctrl + T', addText, true, false, true);
\r
1251 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 71, false, true, switchGrid);
\r
1252 MENU_BAR_CONTROL.EDIT.createSelection( 'show Grid', 'ctrl + G', switchGrid, true, true, true);
\r
1254 function addImage( e){
\r
1255 setTimeout( COMIC_ELEMENT_CONTROL.createImageElement, 0);
\r
1256 e && e.preventDefault();
\r
1259 function addText( e){
\r
1260 setTimeout( COMIC_ELEMENT_CONTROL.createTextElement, 0);
\r
1261 e && e.preventDefault();
\r
1264 function switchGrid( e){
\r
1265 setTimeout( GRID_CONTROL.update, 0);
\r
1266 e && e.preventDefault();
\r
1269 function popupHelp( e){
\r
1270 instance.bodyBackOrForward( true);
\r
1271 setTimeout( HELP_DOCUMENTS_WINDOW.open, 0);
\r
1272 e && e.preventDefault();
\r
1275 function editBG( e){
\r
1276 instance.bodyBackOrForward( true);
\r
1277 setTimeout( INFOMATION_WINDOW.open, 0);
\r
1278 e && e.preventDefault();
\r
1282 return WINDOWS_CONTROL.createWindow(
\r
1285 onInit: function(){
\r
1287 delete this.onInit;
\r
1289 onFirstOpen: function(){
\r
1290 addImageButton = $( '#toolbox-add-image-button').click( addImage);
\r
1291 addTextButton = $( '#toolbox-add-text-button').click( addText);
\r
1292 editBgButton = $( '#toolbox-edit-bg-button').click( editBG);
\r
1293 switchGridButton = $( '#toolbox-switch-grid').click( switchGrid);
\r
1294 popupHelpButton = $( '#toolbox-popup-help-button').click( popupHelp);
\r
1296 postButton = $( '#toolbox-post-button');
\r
1298 delete this.onFirstOpen;
\r
1301 'toolbox-window', 'Tool box', 0, 215, 110, 290, true
\r
1306 /* ----------------------------------------
\r
1309 var IMAGE_EXPLORER_WINDOW = ( function(){
\r
1310 var instance, finder;
\r
1312 return WINDOWS_CONTROL.createWindow(
\r
1315 onInit: function(){
\r
1317 delete this.onInit;
\r
1319 onFirstOpen: function(){
\r
1320 finder = pettanr.finder.createFinder( document.getElementById( 'image-exproler-container'), pettanr.file.TREE_TYPE_IS_IMAGE);
\r
1321 delete this.onFirstOpen;
\r
1323 onOpen: function(){
\r
1326 onResize: function( _w, _h){
\r
1327 finder.onWindowResize( _w, _h);
\r
1330 'image-exproler', 'Album', 0, 215, 400, 350, false, true, true, 300, 300
\r
1335 /* ----------------------------------------
\r
1336 * INFOMATION_WINDOW
\r
1338 var INFOMATION_WINDOW = ( function(){
\r
1339 var FADE_EFFECT_ENABLED = pettanr.ua.isIE === false || pettanr.ua.ieVersion >= 8,
\r
1340 FADE_IN_EFFECT = FADE_EFFECT_ENABLED === true ? 'fadeIn' : 'show',
\r
1341 FADE_OUT_EFFECT = FADE_EFFECT_ENABLED === true ? 'fadeOut' : 'hide',
\r
1342 backgroundInfomationElm,
\r
1343 jqComicElementInformation,
\r
1344 elmValueX, elmValueY, elmValueZ, elmValueA, elmValueW, elmValueH, elmAspect,
\r
1345 elmPercentW, elmPercentH,
\r
1346 currentComicElement = null,
\r
1347 currentElementType = -1;
\r
1349 return WINDOWS_CONTROL.createWindow(
\r
1352 onFirstOpen: function(){
\r
1353 backgroundInfomationElm = $( '#panel-background-information');
\r
1355 jqComicElementInformation = $( '#comic-element-infomation').hide().css( {
\r
1356 height: this.bodyHeight()
\r
1358 var TAB_GROUP_ID = 'comic-element-attribute';
\r
1359 var CREATER = pettanr.key.createEditableText;
\r
1360 elmValueX = CREATER( $( '#comic-element-x'), null, TAB_GROUP_ID);
\r
1361 elmValueY = CREATER( $( '#comic-element-y'), null, TAB_GROUP_ID);
\r
1362 elmValueZ = CREATER( $( '#comic-element-z'), null, TAB_GROUP_ID);
\r
1363 elmValueA = CREATER( $( '#comic-element-a'), null, TAB_GROUP_ID);
\r
1364 elmValueW = CREATER( $( '#comic-element-w'), null, TAB_GROUP_ID);
\r
1365 elmValueH = CREATER( $( '#comic-element-h'), null, TAB_GROUP_ID);
\r
1366 elmPercentW = CREATER( $( '#comic-element-w-percent'), null, TAB_GROUP_ID);
\r
1367 elmPercentH = CREATER( $( '#comic-element-h-percent'), null, TAB_GROUP_ID);
\r
1368 elmAspect = $( '#comic-element-keep-aspect');
\r
1369 delete this.onFirstOpen;
\r
1371 onResize: function( w, h){
\r
1372 jqComicElementInformation && jqComicElementInformation.css( {
\r
1376 update: function( _elementType, x, y, z, a, w, h, wPercent, hPercent, keepAspect){
\r
1377 if( !backgroundInfomationElm) return; // なぜか !backgroundInfomationElm が必要
\r
1378 if( currentElementType !== _elementType){
\r
1379 if( _elementType !== -1){
\r
1380 if( _elementType === 1){
\r
1382 elmPercentW.hide();
\r
1383 elmPercentH.hide();
\r
1387 elmPercentW.show();
\r
1388 elmPercentH.show();
\r
1391 currentElementType === -1 && jqComicElementInformation.stop().css( {
\r
1394 })[ FADE_IN_EFFECT]();
\r
1396 currentElementType !== -1 && jqComicElementInformation.stop().css({
\r
1399 })[ FADE_OUT_EFFECT]();
\r
1401 currentElementType = _elementType;
\r
1403 if( currentElementType !== -1){
\r
1404 elmValueX.update( x);
\r
1405 elmValueY.update( y);
\r
1406 elmValueZ.update( z);
\r
1407 _elementType === 1 && elmValueA.update( a);
\r
1408 elmValueW.update( w);
\r
1409 elmValueH.update( h);
\r
1410 _elementType === 0 && elmPercentW.update( wPercent);
\r
1411 _elementType === 0 && elmPercentH.update( hPercent);
\r
1417 'infomation-window', 'Infomation', 0, 30, 200, 180, true
\r
1421 /* ----------------------------------------
\r
1424 var HELP_DOCUMENTS_WINDOW = ( function(){
\r
1425 var visible = true,
\r
1426 hasAjaxContents = false,
\r
1430 HELP = MENU_BAR_CONTROL.HELP,
\r
1431 onLoadFunction = HELP.createAjaxSelection( onFirstOpen),
\r
1433 function jumpPage( _index){
\r
1436 function onFirstOpen( _pageIndex){
\r
1437 _pageIndex = _pageIndex || 0;
\r
1438 if( hasAjaxContents === false){
\r
1440 url: 'help/jp.xml',
\r
1442 success: function( _xml){
\r
1443 var jqXML = $( _xml),
\r
1444 helpTitle = jqXML.find( 'pages').eq( 0).attr( 'title'),
\r
1445 elmNavi = document.createElement( 'div'),
\r
1446 elmItemOrigin = document.createElement( 'a'),
\r
1447 elmPages = document.createElement( 'div'),
\r
1448 elmPageOrigin = document.createElement( 'div'),
\r
1449 elmTitleOrigin = document.createElement( 'h2'),
\r
1452 elmNavi.className = 'sidenavi';
\r
1453 elmItemOrigin.className = 'sidenavi-item';
\r
1454 elmItemOrigin.href = '#';
\r
1455 elmPages.className = 'page-contents';
\r
1456 elmPageOrigin.className = 'page-content';
\r
1457 elmPageOrigin.appendChild( elmTitleOrigin);
\r
1459 // helpTitle && instance.title( helpTitle);
\r
1461 jqXML.find( 'page').each( function(){
\r
1462 var xmlPage = $( this),
\r
1463 title = xmlPage.attr( 'title'),
\r
1464 content = xmlPage.text();
\r
1466 elmItemOrigin.innerHTML = title;
\r
1467 elmNavi.appendChild( elmItemOrigin.cloneNode( true));
\r
1469 elmTitleOrigin.innerHTML = title;
\r
1470 elmPage = elmPageOrigin.cloneNode( true);
\r
1471 elmPage.innerHTML = content;
\r
1473 pettanr.util.cleanElement( elmPage);
\r
1475 if( elmPage.childNodes.length > 0){
\r
1476 elmPage.insertBefore( elmTitleOrigin.cloneNode( true), elmPage.childNodes[0]);
\r
1478 elmPage.appendChild( elmTitleOrigin.cloneNode( true));
\r
1480 elmPages.appendChild( elmPage);
\r
1482 HELP.createSelection( title, null, ( function( _pageIndex){
\r
1483 return function(){
\r
1484 HELP_DOCUMENTS_WINDOW.open();
\r
1485 onOpen( _pageIndex);
\r
1487 })( numPage), true);
\r
1491 onLoadFunction = null;
\r
1493 jqAjaxContents.removeClass( 'loading').append( elmNavi, elmPages);
\r
1495 jqNaviItems = jqAjaxContents.find( 'a.' +elmItemOrigin.className)
\r
1496 .click( function( e){
\r
1498 parent = this.parentNode,
\r
1500 var children = parent.getElementsByTagName( 'a'),
\r
1501 l = children.length;
\r
1502 for( var i=0; i<l; ++i){
\r
1503 if( children[ i] === that) return i;
\r
1507 e.stopPropagation();
\r
1508 if( i === -1) return false;
\r
1509 jqNaviItems.removeClass( 'current').eq( i).addClass( 'current');
\r
1510 jqPages.hide().eq( i).show();
\r
1514 jqAjaxContents.find( '.' +elmPageOrigin.className).find( 'a')
\r
1515 .click( function( e){
\r
1518 var href = that.href,
\r
1519 i = href.split( '#jump'),
\r
1521 if( n && '' +parseFloat( n) === n){
\r
1522 return parseFloat( n)
\r
1526 e.stopPropagation();
\r
1527 if( i === -1) return false;
\r
1528 jqNaviItems.removeClass( 'current').eq( i).addClass( 'current');
\r
1529 jqPages.hide().eq( i).show();
\r
1533 jqNaviItems.eq( _pageIndex).addClass( 'current');
\r
1534 jqPages = jqAjaxContents.find( '.page-content');
\r
1535 jqPages.eq( _pageIndex).show();
\r
1538 hasAjaxContents = true;
\r
1540 function onOpen( _pageIndex){
\r
1541 _pageIndex = _pageIndex || 0;
\r
1542 jqNaviItems.removeClass( 'current').eq( _pageIndex).addClass( 'current');
\r
1543 jqPages.hide().eq( _pageIndex).show();
\r
1546 return WINDOWS_CONTROL.createWindow(
\r
1549 onInit: function(){
\r
1551 jqAjaxContents = this.$.find( '.window-body').addClass( 'loading').css( { height: this.bodyHeight()});
\r
1552 delete this.onInit;
\r
1554 onFirstOpen: onFirstOpen,
\r
1555 onResize: function( w, h){
\r
1556 jqAjaxContents && jqAjaxContents.css( { height: h});
\r
1558 setAjaxContent: function( html){
\r
1560 delete this.onLoadAjaxContent;
\r
1563 null, 'Help', 0, 215, 400, 350, false, true, true, 300, 300
\r
1567 /* ----------------------------------------
\r
1570 var GRID_CONTROL = ( function(){
\r
1571 var ELM_GRID = document.getElementById( 'grid'),
\r
1577 jqGrid = $( ELM_GRID);
\r
1578 delete GRID_CONTROL.init;
\r
1580 onPanelResize: function( _panelX, _panelY){
\r
1581 ELM_GRID.style.backgroundPosition = [ _panelX % 10, 'px ', _panelY % 10, 'px'].join( '');
\r
1582 ELM_GRID.style.height = windowH +'px';
\r
1584 enabled: function(){
\r
1587 update: function(){
\r
1591 }).stop()[ visible === true ? 'fadeOut' : 'fadeIn']();
\r
1593 visible = !visible;
\r
1595 if( visible === true && !ELM_GRID.style.backgroundImage){
\r
1596 ELM_GRID.style.backgroundImage = "url('images/grid.gif')";
\r
1604 * WHITE_GLASS_CONTROL
\r
1606 var WHITE_GLASS_CONTROL = ( function(){
\r
1607 var styleTop = document.getElementById( 'whiteGlass-top').style,
\r
1608 styleLeft = document.getElementById( 'whiteGlass-left').style,
\r
1609 styleRight = document.getElementById( 'whiteGlass-right').style,
\r
1610 styleBottom = document.getElementById( 'whiteGlass-bottom').style;
\r
1613 onPanelResize: function( _panelX, _panelY, _panelW, _panelH){
\r
1616 marginTop = _panelY,
\r
1617 marginBottom = windowH -_h -marginTop,
\r
1618 marginX = _panelX,
\r
1619 rightWidth = windowW -_w -marginX;
\r
1621 styleTop.height = ( marginTop < 0 ? 0 : marginTop) +'px';
\r
1623 styleLeft.top = marginTop +'px';
\r
1624 styleLeft.width = ( marginX < 0 ? 0 : marginX) +'px';
\r
1625 styleLeft.height = ( _h + marginBottom) +'px';
\r
1627 styleRight.top = marginTop +'px';
\r
1628 styleRight.left = _w +marginX +'px';
\r
1629 styleRight.width = ( rightWidth < 0 ? 0 : rightWidth) +'px';
\r
1630 styleRight.height = ( _h + marginBottom) +'px';
\r
1632 styleBottom.top = ( _h +marginTop) +'px';
\r
1633 styleBottom.left = marginX +'px';
\r
1634 styleBottom.width = _w +'px';
\r
1635 styleBottom.height = ( marginBottom < 0 ? 0 : marginBottom) +'px';
\r
1643 * panel-border の表示と onPanelResize の通知.
\r
1647 var PANEL_CONTROL = ( function(){
\r
1648 var ELM_PANEL = document.getElementById('panel-tools-container'),
\r
1649 ELM_PANEL_STYLE = ELM_PANEL.style,
\r
1650 DEFAULT_PANEL_WIDTH = 400,
\r
1651 DEFAULT_PANEL_HEIGHT = 300,
\r
1653 panelW, panelH, panelX, panelY,
\r
1654 offsetX, offsetY, startX, startY,
\r
1655 isDragging = false,
\r
1656 isDraggable = false;
\r
1658 function onSpaceUpdate(e){
\r
1659 if( e.type === 'keyup'){
\r
1660 currentListener === null && updateMouseCursor( '');
\r
1661 isDraggable = false;
\r
1663 currentListener === null && updateMouseCursor( 'move');
\r
1664 isDraggable = true;
\r
1669 init: function( _panelW, _panelH, _borderSize){
\r
1670 panelW = _panelW || DEFAULT_PANEL_WIDTH;
\r
1671 panelH = _panelH || DEFAULT_PANEL_HEIGHT;
\r
1672 panelX = Math.floor( ( windowW -panelW) /2);
\r
1673 panelY = Math.floor( ( windowH -panelH) /2);
\r
1674 borderSize = _borderSize !== undefined ? _borderSize : borderSize;
\r
1676 pettanr.key.addKeyUpdateEvent( pettanr.view.EDITOR, 32, false, false, onSpaceUpdate);
\r
1678 setTimeout( PANEL_CONTROL.resize, 0);
\r
1680 delete PANEL_CONTROL.init;
\r
1688 resize: function( isResizerTopAction, _x, _y, _w, _h){
\r
1689 panelX = _x !== undefined ? _x : panelX;
\r
1690 panelY = _y !== undefined ? _y : panelY;
\r
1691 panelW = _w !== undefined ? _w : panelW;
\r
1692 panelH = _h !== undefined ? _h : panelH;
\r
1694 ELM_PANEL_STYLE.left = ( panelX -borderSize) +'px';
\r
1695 ELM_PANEL_STYLE.top = ( panelY -borderSize) +'px';
\r
1696 ELM_PANEL_STYLE.width = panelW +'px';
\r
1697 ELM_PANEL_STYLE.height = panelH +'px';
\r
1699 PANEL_RESIZER_TOP.onPanelResize( panelX, panelY, panelW, panelH);
\r
1700 PANEL_RESIZER_BOTTOM.onPanelResize( panelX, panelY, panelW, panelH);
\r
1701 GRID_CONTROL.onPanelResize( panelX, panelY);
\r
1702 WHITE_GLASS_CONTROL.onPanelResize( panelX, panelY, panelW, panelH);
\r
1703 COMIC_ELEMENT_CONTROL.onPanelResize( panelX, panelY, panelW, panelH, isResizerTopAction === true);
\r
1705 onWindowResize: function( _windowW, _windowH){
\r
1706 panelX = Math.floor(( _windowW - panelW) / 2);
\r
1707 panelY = Math.floor(( _windowH - panelH) / 2);
\r
1708 PANEL_CONTROL.resize();
\r
1710 onMouseMove: function( _mouseX, _mouseY){
\r
1711 if( isDraggable === true && isDragging === true){
\r
1712 PANEL_CONTROL.resize( false, startX +_mouseX -offsetX, startY +_mouseY -offsetY);
\r
1715 onMouseUp: function( _mouseX, _mouseY){
\r
1716 if( isDraggable === true){
\r
1717 isDragging = false;
\r
1718 updateMouseCursor( '');
\r
1721 onMouseDown: function( _mouseX, _mouseY){
\r
1722 if( isDraggable === true){
\r
1723 offsetX = _mouseX;
\r
1724 offsetY = _mouseY;
\r
1727 isDragging = true;
\r
1728 updateMouseCursor( 'move');
\r
1733 return isDragging === true;
\r
1739 * --------------------------------------------------------------------------------------------
\r
1742 var PanelResizerClass = function( ID, isTop){
\r
1743 var ELM = document.getElementById( ID),
\r
1745 RESIZER_HEIGHT = 30,
\r
1746 x = -BORDER_WIDTH /2,
\r
1747 y = isTop === true ? ( -5 -RESIZER_HEIGHT -BORDER_WIDTH) : 0,
\r
1749 h = RESIZER_HEIGHT,
\r
1750 panelX, panelY, panelW, panelH,
\r
1751 offsetY, startY, startH,
\r
1752 isDragging = false,
\r
1753 MOUSE_CURSOR = updateMouseCursor;
\r
1755 function restoreState( arg){
\r
1756 if( arg && arg.length > 3){
\r
1757 PANEL_CONTROL.resize( isTop, arg[ 0] || panelX, arg[ 1] || panelY, arg[ 2] || panelW, arg[ 3] || panelH);
\r
1763 return isDragging;
\r
1765 onMouseDown: function( _mouseX, _mouseY){
\r
1766 var _x = _mouseX -panelX,
\r
1767 _y = _mouseY -panelY;
\r
1768 if( _x < x || x + w < _x || _y < y || y + h < _y) return false;
\r
1772 isDragging = true;
\r
1773 MOUSE_CURSOR( 'n-resize');
\r
1776 onMouseMove: function( _mouseX, _mouseY){
\r
1777 var _x = _mouseX -panelX,
\r
1778 _y = _mouseY -panelY;
\r
1779 if( isDragging !== true){
\r
1780 if( _x < x || x + w < _x || _y < y || y + h < _y) return false;
\r
1781 COMIC_ELEMENT_OPERATION_MANAGER.hide();
\r
1782 MOUSE_CURSOR( 'pointer');
\r
1785 var move = _y -offsetY;
\r
1786 if( isTop === true){
\r
1787 if( panelH - move < MIN_PANEL_HEIGHT){
\r
1788 move = panelH -MIN_PANEL_HEIGHT;
\r
1790 PANEL_CONTROL.resize( true, panelX, panelY + move, panelW, panelH - move);
\r
1792 var _h = startH +move;
\r
1793 if( 0 < _h && _h < windowH -panelY -RESIZER_HEIGHT -5 -BORDER_WIDTH){
\r
1794 PANEL_CONTROL.resize( false, panelX, panelY, panelW, _h < MIN_PANEL_HEIGHT ? MIN_PANEL_HEIGHT : _h);
\r
1800 onMouseUp: function( _mouseX, _mouseY){
\r
1801 if( isDragging !== true) return;
\r
1802 ( startY !== panelY || startH !== panelH) && HISTORY.saveState( restoreState, [ NaN, startY, NaN, startH], [ NaN, panelY, NaN, panelH]);
\r
1803 isDragging = false;
\r
1804 MOUSE_CURSOR( '');
\r
1809 onPanelResize: function( _x, _y, _w, _h){
\r
1812 if( panelW !== _w){
\r
1813 ELM.style.width = ( _w +2) +'px';
\r
1817 y = isTop === true ? y : ( panelH +5 +BORDER_WIDTH);
\r
1822 var PANEL_RESIZER_TOP = new PanelResizerClass( 'panel-resizer-top', true),
\r
1823 PANEL_RESIZER_BOTTOM = new PanelResizerClass( 'panel-resizer-bottom', false);
\r
1825 PanelResizerClass = undefined;
\r
1828 var CONSOLE_CONTROLER = ( function(){
\r
1829 var LAYER_BACK_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'layer back', 'ctrl + B', layerBack, false, true, false),
\r
1830 LAYER_FORWARD_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'layer forward', 'ctrl + F', layerForward, false, false, false),
\r
1831 DELETE_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'delete', 'ctrl + D', del, false, true, true),
\r
1832 EDIT_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'Edit Text', 'ctrl + E', edit, false, true, false),
\r
1833 CHANGE_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'change', 'ctrl + U', change, false, false, true),
\r
1834 SAVE = HISTORY.saveState,
\r
1839 jqImgConsole, jqTextConsole,
\r
1840 currentElement = null,
\r
1843 imgConsoleWidth, imgConsoleHeight,
\r
1844 textConsoleWidth, textConsoleHeight,
\r
1845 consoleWidth, consoleHeight,
\r
1846 consoleX, consoleY,
\r
1848 buttonClickable = false;
\r
1850 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 66, false, true, layerBack);
\r
1851 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 70, false, true, layerForward);
\r
1853 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 68, false, true, del);
\r
1854 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 69, false, true, edit);
\r
1855 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 85, false, true, change);
\r
1857 function buttonBackOrForward( isBack){
\r
1858 var offest = jqConsoleWrapper.offset();
\r
1859 jqConsoleWrapper.css( {
\r
1860 position: isBack === true ? '' : 'absolute',
\r
1861 left: isBack === true ? consoleX : offest.left,
\r
1862 top: isBack === true ? consoleY : offest.top
\r
1864 buttonClickable === isBack && ( isBack === true ? jqConsoleParent : jqStage).append( jqConsoleWrapper);
\r
1865 buttonClickable = !isBack;
\r
1867 function layerBack(){
\r
1868 if( currentElement === null) return;
\r
1869 COMIC_ELEMENT_CONTROL.replaceComicElement( currentElement, false);
\r
1870 updateInfomation();
\r
1871 SAVE( COMIC_ELEMENT_CONTROL.restoreReplaceObject, [ currentElement, true], [ currentElement, false]);
\r
1872 var _z = currentElement.z;
\r
1873 LAYER_BACK_BUTTON.visible( _z > 0);
\r
1874 LAYER_FORWARD_BUTTON.visible( _z < COMIC_ELEMENT_ARRAY.length -1);
\r
1876 function layerForward(){
\r
1877 if( currentElement === null) return;
\r
1878 COMIC_ELEMENT_CONTROL.replaceComicElement( currentElement, true);
\r
1879 updateInfomation();
\r
1880 SAVE( COMIC_ELEMENT_CONTROL.restoreReplaceObject, [ currentElement, false], [ currentElement, true]);
\r
1881 var _z = currentElement.z;
\r
1882 LAYER_BACK_BUTTON.visible( _z > 0);
\r
1883 LAYER_FORWARD_BUTTON.visible( _z < COMIC_ELEMENT_ARRAY.length -1);
\r
1886 if( currentElement === null) return;
\r
1887 buttonBackOrForward( true);
\r
1888 COMIC_ELEMENT_CONTROL.removeComicElement( currentElement);
\r
1889 SAVE( COMIC_ELEMENT_CONTROL.restoreComicElement, [ true, currentElement], [ false, currentElement], true);
\r
1890 COMIC_ELEMENT_OPERATION_MANAGER.hide();
\r
1893 if( currentElement === null || currentElement.type !== COMIC_ELEMENT_TYPE_TEXT) return;
\r
1894 TEXT_EDITOR_CONTROL.show( currentElement);
\r
1895 buttonBackOrForward( true);
\r
1897 function change(){
\r
1898 if( currentElement === null) return;
\r
1899 buttonBackOrForward( true);
\r
1900 IMAGE_GROUP_EXPROLER.show( currentElement.url);
\r
1904 jqStage = jqEditor;
\r
1905 jqConsoleTail = $( '#comic-element-consol-tail');
\r
1906 jqImgConsole = $( '#image-element-consol').hide();
\r
1907 var imgConsoleSize = pettanr.util.getElementSize( jqImgConsole.get( 0));
\r
1908 imgConsoleWidth = imgConsoleSize.width;
\r
1909 imgConsoleHeight = imgConsoleSize.height;
\r
1911 jqTextConsole = $( '#text-element-consol').hide();
\r
1912 var textConsoleSize = pettanr.util.getElementSize( jqTextConsole.get( 0));
\r
1913 textConsoleWidth = textConsoleSize.width;
\r
1914 textConsoleHeight = textConsoleSize.height;
\r
1916 jqConsoleWrapper = $( '#comic-element-consol-wrapper').hide();
\r
1917 jqConsoleParent = jqConsoleWrapper.parent();
\r
1919 $( '#edit-text-button').click( edit);
\r
1920 $( '#delete-image-button, #delete-text-button').click( del);
\r
1921 $( '#change-image-button').click( change);
\r
1922 $( '#layer-forward-button, #forward-text-button').click( layerForward);
\r
1923 $( '#layer-back-button, #back-text-button').click( layerBack);
\r
1925 delete CONSOLE_CONTROLER.init;
\r
1927 show: function( _currentElement, _w, _h){
\r
1928 visible === false && jqConsoleWrapper.show();
\r
1930 currentElement = _currentElement;
\r
1931 var _currentType = _currentElement.type,
\r
1932 _z = _currentElement.z;
\r
1933 if( currentType !== _currentType){
\r
1934 currentType = _currentType;
\r
1935 jqImgConsole.toggle( _currentType === COMIC_ELEMENT_TYPE_IMAGE);
\r
1936 jqTextConsole.toggle( _currentType === COMIC_ELEMENT_TYPE_TEXT);
\r
1937 consoleWidth = _currentType === COMIC_ELEMENT_TYPE_IMAGE ? imgConsoleWidth : textConsoleWidth;
\r
1938 consoleHeight = _currentType === COMIC_ELEMENT_TYPE_IMAGE ? imgConsoleHeight : textConsoleHeight;
\r
1940 consoleX = Math.floor( ( _w -consoleWidth) /2);
\r
1942 LAYER_BACK_BUTTON.visible( _z > 0);
\r
1943 LAYER_FORWARD_BUTTON.visible( _z < COMIC_ELEMENT_ARRAY.length -1);
\r
1944 DELETE_BUTTON.visible( true);
\r
1945 EDIT_BUTTON.visible( _currentType === COMIC_ELEMENT_TYPE_TEXT);
\r
1946 CHANGE_BUTTON.visible( false);
\r
1948 if( _w > consoleWidth * 1.5 && _h > consoleHeight * 1.5){
\r
1949 consoleY = Math.floor( ( _h -consoleHeight) /2);
\r
1950 jqConsoleWrapper.css( {
\r
1953 }).removeClass( 'console-out');
\r
1955 consoleY = _h +tailSize;
\r
1956 jqConsoleWrapper.css( {
\r
1959 }).addClass( 'console-out');
\r
1962 hide: function (){
\r
1963 visible === true && jqConsoleWrapper.hide();
\r
1965 currentElement = null;
\r
1966 LAYER_BACK_BUTTON.visible( false);
\r
1967 LAYER_FORWARD_BUTTON.visible( false);
\r
1968 DELETE_BUTTON.visible( false);
\r
1969 EDIT_BUTTON.visible( false);
\r
1970 CHANGE_BUTTON.visible( false);
\r
1972 x: function(){ return consoleX;},
\r
1973 y: function(){ return consoleY;},
\r
1974 w: function(){ return consoleWidth;},
\r
1975 h: function(){ return consoleHeight;},
\r
1976 onMouseMove: function( _mouseX, _mouseY){
\r
1977 if( consoleX > _mouseX || consoleY > _mouseY || consoleX +consoleWidth < _mouseX || consoleY +consoleHeight < _mouseY){
\r
1978 buttonClickable === true && buttonBackOrForward( true);
\r
1981 buttonClickable === false && buttonBackOrForward( false);
\r
1984 onMouseOut: function( _mouseX, _mouseY){
\r
1985 buttonClickable === true && buttonBackOrForward( true);
\r
1991 var TAIL_OPERATOR = ( function(){
\r
1992 var MOUSE_CURSOR = updateMouseCursor,
\r
1993 ELM_MOVER = document.getElementById( 'balloon-tail-mover'),
\r
1994 SIZE = pettanr.util.getElementSize( ELM_MOVER).width,
\r
1998 FLOOR = Math.floor,
\r
1999 DEG_TO_RAD = Math.PI / 180,
\r
2000 RAD_TO_DEG = 1 /DEG_TO_RAD,
\r
2001 currentText = null,
\r
2004 balloonW, balloonH, balloonA, radA,
\r
2009 update: function ( _w, _h, _a){
\r
2010 balloonW = _w !== undefined ? _w : balloonW;
\r
2011 balloonH = _h !== undefined ? _h : balloonH;
\r
2012 balloonA = _a !== undefined ? _a : balloonA;
\r
2013 radA = balloonA *DEG_TO_RAD;
\r
2014 tailX = FLOOR( ( ( COS( radA) /2 +0.5) *( balloonW +SIZE)) -SIZE /2);
\r
2015 tailY = FLOOR( ( ( SIN( radA) /2 +0.5) *( balloonH +SIZE)) -SIZE /2);
\r
2016 ELM_MOVER.style.left = tailX +'px';
\r
2017 ELM_MOVER.style.top = tailY +'px';
\r
2018 //log.html( [ balloonW, balloonH, balloonA].join());
\r
2020 show: function( _currentText){
\r
2022 * visibilityのほうがいい, display:none だと ie で描画が狂う
\r
2024 ELM_MOVER.style.visibility = '';
\r
2025 this.update( _currentText.w, _currentText.h, _currentText.angle());
\r
2026 currentText = _currentText;
\r
2028 hitTest: function( _mouseX, _mouseY){
\r
2029 var _x = tailX -SIZE /2,
\r
2030 _y = tailY -SIZE /2;
\r
2031 ret = _x <= _mouseX && _y <= _mouseY && _x +SIZE >= _mouseX && _y +SIZE >= _mouseY;
\r
2032 ret === true && MOUSE_CURSOR( 'move');
\r
2036 ELM_MOVER.style.visibility = 'hidden';
\r
2037 currentText = null;
\r
2039 onStart: function( _currentText, _mouseX, _mouseY){
\r
2040 if( _currentText.type !== COMIC_ELEMENT_TYPE_TEXT) return false;
\r
2041 x = _currentText.x;
\r
2042 y = _currentText.y;
\r
2043 if( this.hitTest( _mouseX -x, _mouseY -y) === true){
\r
2044 w = _currentText.w;
\r
2045 h = _currentText.h;
\r
2046 currentText = _currentText;
\r
2047 startA = _currentText.angle();
\r
2052 onDrag: function( _mouseX, _mouseY){
\r
2053 _mouseX = _mouseX -x -w /2;
\r
2054 _mouseY = _mouseY -y -h /2; //Balloonの中心を0,0とする座標系に変換
\r
2056 this.update( w, h,
\r
2058 ATAN( _mouseY /_mouseX) *RAD_TO_DEG +( _mouseX < 0 ? 180 : 0) :
\r
2059 _mouseY > 0 ? 90 : -90
\r
2061 currentText && currentText.angle( balloonA);
\r
2062 COMIC_ELEMENT_OPERATION_MANAGER.updateInfomation( undefined, undefined, undefined, balloonA);
\r
2064 onFinish: function(){
\r
2065 startA !== currentText.angle() && COMIC_ELEMENT_OPERATION_MANAGER.saveStatus( x, y, w, h, startA);
\r
2066 startA !== currentText.angle() && COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y, w, h, currentText.angle());
\r
2067 currentText = null;
\r
2069 onCancel: function(){
\r
2070 currentText.angle( startA);
\r
2071 COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y, w, h, startA);
\r
2072 currentText = null;
\r
2076 RESIZE_OPERATOR = ( function(){
\r
2077 var MOUSE_CURSOR = updateMouseCursor,
\r
2078 GRID_ENABLED = GRID_CONTROL.enabled;
\r
2080 var HIT_AREA = MOUSE_HIT_AREA,
\r
2081 POSITION_ARRAY = [],
\r
2082 FLOOR = Math.floor,
\r
2083 CURSOR_AND_FLIP = [
\r
2084 { cursor: 'n-resize', v: 3},
\r
2085 { cursor: 'e-resize', h: 2},
\r
2086 { cursor: 'e-resize', h: 1},
\r
2087 { cursor: 'n-resize', v: 0},
\r
2088 { cursor: 'nw-resize', h: 5, v: 6, vh: 7},
\r
2089 { cursor: 'ne-resize', h: 4, v: 7, vh: 6},
\r
2090 { cursor: 'ne-resize', h: 7, v: 4, vh: 5},
\r
2091 { cursor: 'nw-resize', h: 6, v: 5, vh: 4}
\r
2093 elmResizerContainer = document.getElementById( 'comic-element-resizer-container'),
\r
2094 elmResizerContainerStyle = elmResizerContainer.style,
\r
2095 elmResizerTopStyle = document.getElementById( 'comic-element-resizer-top').style,
\r
2096 elmResizerLeftStyle = document.getElementById( 'comic-element-resizer-left').style,
\r
2097 elmResizerRightStyle = document.getElementById( 'comic-element-resizer-right').style,
\r
2098 elmResizerBottomStyle = document.getElementById( 'comic-element-resizer-bottom').style,
\r
2100 currentIndex = -1,
\r
2102 currentIsTextElement = false;
\r
2104 elmResizerContainerStyle.display = 'none';
\r
2106 var RESIZE_WORK_ARRAY = [
\r
2107 { x: 0, w: 0, y: 1, h: -1}, //top
\r
2108 { x: 1, w: -1, y: 0, h: 0}, //left
\r
2109 { x: 0, w: 1, y: 0, h: 0}, //right
\r
2110 { x: 0, w: 0, y: 0, h: 1}, //bottom
\r
2111 { x: 1, w: -1, y: 1, h: -1}, //top-left
\r
2112 { x: 0, w: 1, y: 1, h: -1}, //top-right
\r
2113 { x: 1, w: -1, y: 0, h: 1}, //bottom-left
\r
2114 { x: 0, w: 1, y: 0, h: 1} //bottom-right
\r
2116 startX, startY, startW, startH, startFilpV, startFilpH, startAspect,
\r
2117 baseX, baseY, baseW, baseH,
\r
2118 currentX, currentY, currentW, currentH,
\r
2123 function draw( _x, _y, _w, _h){
\r
2124 x = _x !== undefined ? _x : x;
\r
2125 y = _y !== undefined ? _y : y;
\r
2126 w = _w !== undefined ? _w : w;
\r
2127 h = _h !== undefined ? _h : h;
\r
2128 elmResizerContainerStyle.left = x +'px';
\r
2129 elmResizerContainerStyle.top = y +'px';
\r
2130 elmResizerContainerStyle.width = w +'px';
\r
2131 elmResizerContainerStyle.height = h +'px';
\r
2132 elmResizerTopStyle.left = FLOOR( w /2 -10 /2) +'px';
\r
2133 elmResizerLeftStyle.top = FLOOR( h /2 -10 /2) +'px';
\r
2134 elmResizerRightStyle.top = FLOOR( h /2 -10 /2) +'px';
\r
2135 elmResizerBottomStyle.left = FLOOR( w /2 -10 /2) +'px';
\r
2137 POSITION_ARRAY.splice( 0, POSITION_ARRAY.length);
\r
2138 POSITION_ARRAY.push(
\r
2139 {x: x +5, y: y -HIT_AREA, w: w -5 *2, h: HIT_AREA +5},
\r
2140 {x: x -HIT_AREA, y: y +HIT_AREA +5, w: HIT_AREA +5, h: h -5 *2},
\r
2141 {x: x +w -5, y: y +HIT_AREA +5, w: HIT_AREA +5, h: h -5 *2},
\r
2142 {x: x +5, y: y +h -5, w: w -5 *2, h: HIT_AREA +5},
\r
2143 {x: x -HIT_AREA, y: y -HIT_AREA, w: HIT_AREA +5, h: HIT_AREA +5},
\r
2144 {x: x +w -HIT_AREA, y: y -HIT_AREA, w: HIT_AREA +5, h: HIT_AREA +5},
\r
2145 {x: x -HIT_AREA, y: y +h -5, w: HIT_AREA +5, h: HIT_AREA +5},
\r
2146 {x: x +w -5, y: y +h -5, w: HIT_AREA +5, h: HIT_AREA +5}
\r
2150 function update( _x, _y, _w, _h){
\r
2151 x = _x !== undefined ? _x : currentX;
\r
2152 y = _y !== undefined ? _y : currentY;
\r
2153 w = _w !== undefined ? _w : currentW;
\r
2154 h = _h !== undefined ? _h : currentH;
\r
2156 if( currentIsTextElement === false && currentIndex > 3 && pettanr.key.shiftEnabled() === true){
\r
2157 if( startAspect >= 1){
\r
2159 w = Math.floor( startAspect * h);
\r
2160 x = x +( currentIndex % 2 === 0 ? _w -w : 0);
\r
2163 h = Math.floor( w / startAspect);
\r
2164 y = y + ( currentIndex <= 5 ? _h -h : 0);
\r
2167 draw( x, y, w, h);
\r
2168 currentElement.resize( x, y, w, h);
\r
2169 currentIsTextElement === true && TAIL_OPERATOR.update( w, h);
\r
2170 CONSOLE_CONTROLER.show( currentElement, w, h);
\r
2171 COMIC_ELEMENT_OPERATION_MANAGER.updateInfomation( x, y, undefined, undefined, w, h);
\r
2174 function flip( _flipV, _flipH){
\r
2175 var p = CURSOR_AND_FLIP[ currentIndex];
\r
2176 currentIndex = _flipH === true || _flipV === true ? p[
\r
2177 _flipH === true && _flipV === true ? 'vh' : ( _flipH === true ? 'h' : 'v')
\r
2179 MOUSE_CURSOR( CURSOR_AND_FLIP[ currentIndex].cursor);
\r
2180 elmResizerContainer.className = 'current-resizer-is-' +currentIndex;
\r
2181 currentElement.flip( _flipV, _flipH);
\r
2185 index: function( _mouseX, _mouseY){
\r
2187 for( var i=4; i<8; i++){
\r
2188 p = POSITION_ARRAY[ i];
\r
2189 if( p.x <= _mouseX && p.y <= _mouseY && p.x + p.w >= _mouseX && p.y +p.h >= _mouseY){
\r
2190 MOUSE_CURSOR( CURSOR_AND_FLIP[ i].cursor);
\r
2191 elmResizerContainer.className = 'current-resizer-is-' +i;
\r
2192 return currentIndex = i;
\r
2195 for( var i=0; i<4; i++){
\r
2196 p = POSITION_ARRAY[ i];
\r
2197 if( p.x <= _mouseX && p.y <= _mouseY && p.x + p.w >= _mouseX && p.y +p.h >= _mouseY){
\r
2198 MOUSE_CURSOR( CURSOR_AND_FLIP[ i].cursor);
\r
2199 elmResizerContainer.className = 'current-resizer-is-' +i;
\r
2200 return currentIndex = i;
\r
2203 MOUSE_CURSOR( '');
\r
2204 elmResizerContainer.className = '';
\r
2207 show: function( _currentElement){
\r
2208 currentElement = _currentElement;
\r
2209 currentIsTextElement = _currentElement.type === COMIC_ELEMENT_TYPE_TEXT;
\r
2210 elmResizerContainerStyle.display = '';
\r
2213 currentElement = null;
\r
2214 elmResizerContainerStyle.display = 'none';
\r
2216 onStart: function( _currentElement, _mouseX, _mouseY){
\r
2217 currentElement = _currentElement;
\r
2218 currentIsTextElement = _currentElement.type === COMIC_ELEMENT_TYPE_TEXT;
\r
2219 if( _currentElement.keepSize === true) return false;
\r
2220 currentIndex = this.index( _mouseX, _mouseY);
\r
2221 if( currentIndex === -1) return false;
\r
2222 offsetX = _mouseX;
\r
2223 offsetY = _mouseY;
\r
2224 startX = baseX = _currentElement.x;
\r
2225 startY = baseY = _currentElement.y;
\r
2226 startW = baseW = _currentElement.w;
\r
2227 startH = baseH = _currentElement.h;
\r
2228 if( _currentElement.type === COMIC_ELEMENT_TYPE_IMAGE){
\r
2229 startFilpV = _currentElement.flipV();
\r
2230 startFilpH = _currentElement.flipH();
\r
2232 startAspect = startW /startH;
\r
2235 onDrag: function( _mouseX, _mouseY){
\r
2236 var com = RESIZE_WORK_ARRAY[ currentIndex],
\r
2237 moveX = _mouseX -offsetX,
\r
2238 moveY = _mouseY -offsetY,
\r
2239 _updated = moveX !== 0 || moveY !== 0,
\r
2248 * Opera 11+ often forget values, why ??
2250 while( _x === undefined || _y === undefined || _w === undefined || _h === undefined){
\r
2251 _x = _x !== undefined ? _x : baseX +moveX *com.x;
\r
2252 _y = _y !== undefined ? _y : baseY +moveY *com.y;
\r
2253 _w = _w !== undefined ? _w : baseW +moveX *com.w;
\r
2254 _h = _h !== undefined ? _h : baseH +moveY *com.h;
\r
2255 error += _thisError === 0 ? 0 : 1;
\r
2257 if( _thisError > 9999){
\r
2259 //alert( 'opera error' +error);
\r
2265 if( _w >= MIN_OBJECT_SIZE && _h >= MIN_OBJECT_SIZE){
\r
2268 if( _w >= -MIN_OBJECT_SIZE && _h >= -MIN_OBJECT_SIZE){
\r
2270 if( _w < MIN_OBJECT_SIZE){
\r
2271 //_x += Math.abs( MIN_OBJECT_SIZE -_w);
\r
2273 _w = MIN_OBJECT_SIZE;
\r
2275 if( _h < MIN_OBJECT_SIZE){
\r
2276 //_y += Math.abs( MIN_OBJECT_SIZE -_h);
\r
2278 _h = MIN_OBJECT_SIZE;
\r
2281 if( currentElement.type === COMIC_ELEMENT_TYPE_TEXT){
\r
2284 if( _w < -MIN_OBJECT_SIZE || _h < -MIN_OBJECT_SIZE){
\r
2286 if( _w < -MIN_OBJECT_SIZE && _h > MIN_OBJECT_SIZE){
\r
2289 baseX = _x = _x +_w;
\r
2291 baseW = _w = _memoryX -_x;
\r
2293 flip( false, true);
\r
2294 flipV = currentElement.flipV();
\r
2296 if( _w > MIN_OBJECT_SIZE && _h < -MIN_OBJECT_SIZE){
\r
2300 baseY = _y = _y +_h;
\r
2302 baseH = _h = _memoryY -_y;
\r
2303 flip( true, false);
\r
2304 flipH = currentElement.flipH();
\r
2309 baseX = _x = _x +_w;
\r
2310 baseY = _y = _y +_h;
\r
2311 baseW = _w = _memoryX -_x;
\r
2312 baseH = _h = _memoryY -_y;
\r
2313 flip( true, true);
\r
2314 flipV = currentElement.flipV();
\r
2315 flipH = currentElement.flipH();
\r
2318 offsetX = _mouseX;
\r
2319 offsetY = _mouseY;
\r
2325 _updated === true && update( _x, _y, _w, _h);
\r
2328 'currentIndex:', currentIndex,
\r
2329 'baseW', baseW, 'baseH', baseH,'<br>',
\r
2330 'mouse', _mouseX, _mouseY,'<br>',
\r
2331 'move', moveX, moveY,'<br>',
\r
2332 'xy', _x, _y, 'wh',_w, _h,'<br>',
\r
2333 'com.w', com.w, 'com.h', com.h,'<br>',
\r
2334 'current',currentW, currentH,'<br>',
\r
2339 onFinish: function(){
\r
2340 MOUSE_CURSOR( '');
\r
2341 if( w === startW && h === startH && x === startX && y === startY) return;
\r
2342 COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y, w, h);
\r
2343 currentElement.resize( x, y, w, h);
\r
2344 COMIC_ELEMENT_OPERATION_MANAGER.saveStatus( startX, startY, startW, startH, undefined, startFilpV, startFilpH);
\r
2346 onCancel: function(){
\r
2347 MOUSE_CURSOR( '');
\r
2348 COMIC_ELEMENT_OPERATION_MANAGER.resize( startX, startY, startW, startH);
\r
2349 currentElement.type === COMIC_ELEMENT_TYPE_IMAGE ?
\r
2350 currentElement.animate( startX, startY, startW, startH, startFilpV, startFilpH) :
\r
2351 currentElement.animate( startX, startY, startW, startH, angle);
\r
2353 lock: function( _lock){
\r
2354 if( _lock !== undefined){
\r
2355 elmResizerContainerStyle.borderColor = _lock === true ? 'blue' : '';
\r
2360 onShiftUpdate: update,
\r
2361 onCtrlUpdate: update
\r
2364 POSITION_OPERATOR = ( function(){
\r
2365 var MOUSE_CURSOR = updateMouseCursor,
\r
2366 GRID_ENABLED = GRID_CONTROL.enabled;
\r
2368 var currentElement,
\r
2374 function update( _x, _y){
\r
2375 x = _x !== undefined ? _x : x;
\r
2376 y = _y !== undefined ? _y : y;
\r
2377 RESIZE_OPERATOR.update( x, y);
\r
2378 currentElement.resize( x, y);
\r
2379 COMIC_ELEMENT_OPERATION_MANAGER.updateInfomation( x, y);
\r
2383 onStart: function( _currentElement, _mouseX, _mouseY){
\r
2384 currentElement = _currentElement;
\r
2385 offsetX = _mouseX;
\r
2386 offsetY = _mouseY;
\r
2387 startX = x = _currentElement.x;
\r
2388 startY = y = _currentElement.y;
\r
2389 MOUSE_CURSOR( 'move');
\r
2391 onDrag: function( _mouseX, _mouseY){
\r
2392 var moveX = _mouseX -offsetX,
\r
2393 moveY = _mouseY -offsetY,
\r
2394 _x = startX +moveX,
\r
2395 _y = startY +moveY;
\r
2396 if( GRID_ENABLED() === true){
\r
2397 _x = Math.floor( _x / 10) * 10;
\r
2398 _y = Math.floor( _y / 10) * 10;
\r
2402 onFinish: function(){
\r
2403 MOUSE_CURSOR( '');
\r
2404 if( x === startX && y === startY) return;
\r
2405 COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y);
\r
2406 currentElement.resize( x, y);
\r
2407 COMIC_ELEMENT_OPERATION_MANAGER.saveStatus( startX, startY);
\r
2409 onCancel: function(){
\r
2410 MOUSE_CURSOR( '');
\r
2411 COMIC_ELEMENT_OPERATION_MANAGER.resize( startX, startY);
\r
2412 currentElement.animate( startX, startY);
\r
2414 onShiftUpdate: update,
\r
2415 onCtrlUpdate: update
\r
2421 * --------------------------------------------------------------------------------------------
\r
2422 * COMIC_ELEMENT_OPERATION_MANAGER
\r
2424 var COMIC_ELEMENT_OPERATION_MANAGER = ( function(){
\r
2425 var MOUSE_CURSOR = updateMouseCursor,
\r
2426 SAVE = HISTORY.saveState,
\r
2427 GRID_ENABLED = GRID_CONTROL.enabled,
\r
2428 HIT_AREA = MOUSE_HIT_AREA,
\r
2429 currentIsTextElement = false,
\r
2430 currentOperator = null,
\r
2431 currentElement = null,
\r
2432 currentx, currenty, currentw, currenth, angle, flipV, flipH;
\r
2434 function resize( _x, _y, _w, _h, _angle){
\r
2435 currentx = _x !== undefined ? _x : currentx;
\r
2436 currenty = _y !== undefined ? _y : currenty;
\r
2437 currentw = _w !== undefined ? _w : currentw;
\r
2438 currenth = _h !== undefined ? _h : currenth;
\r
2439 angle = _angle !== undefined ? _angle : angle;
\r
2441 RESIZE_OPERATOR.update( currentx, currenty, currentw, currenth);
\r
2442 currentIsTextElement === true && TAIL_OPERATOR.update( currentw, currenth, angle);
\r
2443 CONSOLE_CONTROLER.show( currentElement, currentw, currenth);
\r
2444 updateInfomation( currentx, currenty, currentElement.z, angle, currentw, currenth);
\r
2446 function updateInfomation( _x, _y, _z, _a, _w, _h, keepAspect){
\r
2447 _w = _w !== undefined ? _w : currentw;
\r
2448 _h = _h !== undefined ? _h : currenth;
\r
2449 INFOMATION_WINDOW.update(
\r
2450 currentElement === null ? -1 : currentElement.type,
\r
2451 _x !== undefined ? _x : currentx,
\r
2452 _y !== undefined ? _y : currenty,
\r
2453 _z !== undefined ? _z : ( currentElement === null ? '*' : currentElement.z),
\r
2454 _a !== undefined ? Math.floor( _a) : ( currentIsTextElement === true ? Math.floor( angle) : '-'),
\r
2457 currentElement === null || currentIsTextElement === true ? '-' : ( currentElement.actualW() === 0 ? '?' : Math.floor( _w / currentElement.actualW() *100)),
\r
2458 currentElement === null || currentIsTextElement === true ? '-' : ( currentElement.actualH() === 0 ? '?' : Math.floor( _h / currentElement.actualH() *100)),
\r
2459 currentElement === null || currentIsTextElement === true ? '-' : currentElement.keepAspect
\r
2462 function show( _currentElement){
\r
2463 currentElement === null && RESIZE_OPERATOR.show( _currentElement);
\r
2464 if( currentElement !== _currentElement){
\r
2465 currentElement = _currentElement;
\r
2467 currentIsTextElement = ( _currentElement.type === COMIC_ELEMENT_TYPE_TEXT);
\r
2468 currentIsTextElement === true ? TAIL_OPERATOR.show( _currentElement) : TAIL_OPERATOR.hide();
\r
2470 flipV = currentIsTextElement === false ? _currentElement.flipV() : 0;
\r
2471 flipH = currentIsTextElement === false ? _currentElement.flipH() : 0;
\r
2474 _currentElement.x, _currentElement.y, _currentElement.w, _currentElement.h,
\r
2475 currentIsTextElement === true ? _currentElement.angle() : 0
\r
2480 currentElement !== null && RESIZE_OPERATOR.hide();
\r
2481 currentElement = null;
\r
2482 MOUSE_CURSOR( '');
\r
2483 TAIL_OPERATOR.hide();
\r
2484 CONSOLE_CONTROLER.hide();
\r
2485 updateInfomation();
\r
2487 function restoreState( arg){
\r
2488 if( arg && arg.length !== 8) return;
\r
2489 var _currentElement = arg[ 0],
\r
2490 _x = arg[ 1], _y = arg[ 2], _w = arg[ 3], _h = arg[ 4],
\r
2492 _flipV = arg[ 6], _flipH = arg[ 7];
\r
2493 if( !_currentElement && !currentOperator) return;
\r
2494 _currentElement.type === COMIC_ELEMENT_TYPE_IMAGE ?
\r
2495 _currentElement.animate( _x, _y, _w, _h, _flipV, _flipH) :
\r
2496 _currentElement.animate( _x, _y, _w, _h, _a);
\r
2497 currentOperator !== null && currentOperator.onCancel && currentOperator.onCancel();
\r
2498 currentOperator = null;
\r
2499 currentElement === _currentElement ? resize( _x, _y, _w, _h, _a) : show( _currentElement);
\r
2501 function saveComicElementStatus( startX, startY, startW, startH, startA, startFilpV, startFilpH){
\r
2502 startX = startX !== undefined ? startX : currentx;
\r
2503 startY = startY !== undefined ? startY : currenty;
\r
2504 startW = startW !== undefined ? startW : currentw;
\r
2505 startH = startH !== undefined ? startH : currenth;
\r
2506 startA = startA !== undefined ? startA : angle;
\r
2507 startFilpV = startFilpV !== undefined ? startFilpV : flipV;
\r
2508 startFilpH = startFilpH !== undefined ? startFilpH : flipH;
\r
2509 currentElement && SAVE( restoreState,
\r
2510 [ currentElement, startX, startY, startW, startH, startA, startFilpV, startFilpH],
\r
2511 [ currentElement, currentx, currenty, currentw, currenth, angle, flipV, flipH]
\r
2514 pettanr.key.addKeyUpdateEvent( pettanr.view.EDITOR, 16, undefined, undefined, function( e){
\r
2515 currentOperator !== null && currentOperator.onShiftUpdate && currentOperator.onShiftUpdate();
\r
2517 pettanr.key.addKeyUpdateEvent( pettanr.view.EDITOR, 17, undefined, undefined, function(){
\r
2518 currentOperator !== null && currentOperator.onCtrlUpdate && currentOperator.onCtrlUpdate();
\r
2520 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 27, false, false, function(){
\r
2521 currentOperator !== null && currentOperator.onCancel && currentOperator.onCancel();
\r
2522 currentOperator = null;
\r
2527 delete COMIC_ELEMENT_OPERATION_MANAGER.init;
\r
2531 restoreState: restoreState,
\r
2532 updateInfomation: updateInfomation,
\r
2533 saveStatus: saveComicElementStatus,
\r
2535 return currentOperator !== null;
\r
2537 hitareaX: function( _comicElement, _x){
\r
2538 if( _comicElement === currentElement){
\r
2539 var _consoleX = CONSOLE_CONTROLER.x();
\r
2540 return currentx +( _consoleX < 0 ? _consoleX : 0) -HIT_AREA;
\r
2542 return _x -HIT_AREA;
\r
2544 hitareaY: function( _comicElement, _y){
\r
2545 return _y -HIT_AREA;
\r
2547 hitareaW: function( _comicElement, _w){
\r
2548 if( _comicElement === currentElement){
\r
2549 var _consoleW = CONSOLE_CONTROLER.w();
\r
2550 return ( _consoleW < currentw ? currentw : _consoleW) +HIT_AREA *2;
\r
2552 return _w +HIT_AREA *2;
\r
2554 hitareaH: function( _comicElement, _h){
\r
2555 if( _comicElement === currentElement){
\r
2556 var _consoleY = CONSOLE_CONTROLER.y();
\r
2557 return ( _consoleY < currenth ? currenth : _consoleY +CONSOLE_CONTROLER.h()) +HIT_AREA *2;
\r
2559 return _h +HIT_AREA *2;
\r
2561 hitTest: function( _mouseX, _mouseY, _comicElement){
\r
2562 var _x, _y, _w, _h;
\r
2563 if( _comicElement === currentElement){
\r
2564 var _consoleX = CONSOLE_CONTROLER.x();
\r
2565 _x = currentx +( _consoleX < 0 ? _consoleX : 0) -HIT_AREA;
\r
2566 _y = currenty -HIT_AREA;
\r
2567 var _consoleW = CONSOLE_CONTROLER.w();
\r
2568 _w = ( _consoleW < currentw ? currentw : _consoleW) +HIT_AREA *2;
\r
2569 var _consoleY = CONSOLE_CONTROLER.y();
\r
2570 _h = ( _consoleY < currenth ? currenth : _consoleY +CONSOLE_CONTROLER.h()) +HIT_AREA *2;
\r
2572 _x = _comicElement.x -HIT_AREA;
\r
2573 _y = _comicElement.y -HIT_AREA;
\r
2574 _w = _comicElement.w +HIT_AREA *2;
\r
2575 _h = _comicElement.h +HIT_AREA *2;
\r
2577 return _x <= _mouseX && _mouseX <= _x + _w && _y <= _mouseY && _mouseY <= _y + _h;
\r
2579 onMouseDown: function( _currentElement, _mouseX, _mouseY){
\r
2580 //show( _currentElement);
\r
2581 if( currentIsTextElement === true && TAIL_OPERATOR.onStart( _currentElement, _mouseX, _mouseY) === true){
\r
2582 currentOperator = TAIL_OPERATOR;
\r
2584 if( RESIZE_OPERATOR.onStart( _currentElement, _mouseX, _mouseY) === true){
\r
2585 currentOperator = RESIZE_OPERATOR;
\r
2587 POSITION_OPERATOR.onStart( _currentElement, _mouseX, _mouseY)
\r
2588 currentOperator = POSITION_OPERATOR;
\r
2591 onMouseMove: function( _currentElement, _mouseX, _mouseY){
\r
2592 show( _currentElement);
\r
2593 if( currentOperator !== null){
\r
2594 currentOperator.onDrag( _mouseX, _mouseY);
\r
2596 if( currentElement !== null){
\r
2597 CONSOLE_CONTROLER.onMouseMove( _mouseX -currentx, _mouseY -currenty);
\r
2598 if( currentIsTextElement === false || TAIL_OPERATOR.hitTest( _mouseX -currentx, _mouseY -currenty) === false){
\r
2599 RESIZE_OPERATOR.index( _mouseX, _mouseY);
\r
2603 onMouseUp: function( _currentElement, _mouseX, _mouseY){
\r
2604 currentOperator !== null && currentOperator.onFinish();
\r
2605 currentOperator = null;
\r
2610 * // COMIC_ELEMENT_OPERATION_MANAGER
\r
2613 var AbstractComicElement = function( JQ_WAPPER, COMIC_ELM_TYPE, update, x, y, w, h, z, timing){
\r
2614 var OPERATOR = COMIC_ELEMENT_OPERATION_MANAGER;
\r
2617 type: COMIC_ELM_TYPE,
\r
2624 hitareaX: function(){ return OPERATOR.hitareaX( this, this.x);},
\r
2625 hitareaY: function(){ return OPERATOR.hitareaY( this, this.y);},
\r
2626 hitareaW: function(){ return OPERATOR.hitareaW( this, this.w);},
\r
2627 hitareaH: function(){ return OPERATOR.hitareaH( this, this.h);},
\r
2628 hitTest: function( _mouseX, _mouseY){ return OPERATOR.hitTest( _mouseX, _mouseY, this);},
\r
2629 shift: function( _shiftX, _shiftY){
\r
2630 update( this.x +_shiftX, this.y +_shiftY);
\r
2633 return OPERATOR.busy();
\r
2635 onMouseMove: function( _mouseX, _mouseY){
\r
2636 OPERATOR.onMouseMove( this, _mouseX, _mouseY);
\r
2638 onMouseUp: function( _mouseX, _mouseY){
\r
2639 OPERATOR.onMouseUp( this, _mouseX, _mouseY);
\r
2641 onMouseDown: function( _mouseX, _mouseY){
\r
2642 OPERATOR.onMouseDown( this, _mouseX, _mouseY);
\r
2647 * --------------------------------------------------------------------------------------------
\r
2648 * ImageElementClass
\r
2650 var jqImageElementOrigin;
\r
2651 var ImageElementClass = function( url, IMAGE_SET_ID, x, y, z, w, h, timing){
\r
2652 jqImageElementOrigin = jqImageElementOrigin || $( $( '#imgElementTemplete').remove().html());
\r
2654 var JQ_WRAPPER = jqImageElementOrigin.clone( true),
\r
2655 OPERATOR = COMIC_ELEMENT_OPERATION_MANAGER,
\r
2656 SAVE = HISTORY.saveState,
\r
2657 HIT_AREA = MOUSE_HIT_AREA,
\r
2658 reversibleImage = null,
\r
2659 actualW = 0, actualH = 0,
\r
2660 flipH = w < 0 ? -1 : 1,
\r
2661 flipV = h < 0 ? -1 : 1,
\r
2663 w = Math.floor( w);
\r
2664 h = Math.floor( h);
\r
2666 function update( _x, _y, _w, _h, animate){
\r
2667 instance.x = x = _x !== undefined ? _x : x;
\r
2668 instance.y = y = _y !== undefined ? _y : y;
\r
2669 instance.w = w = _w !== undefined ? _w : w;
\r
2670 instance.h = h = _h !== undefined ? _h : h;
\r
2671 JQ_WRAPPER[ animate === true ? 'animate' : 'css']( {
\r
2676 }, 250, onAnimeComplete);
\r
2677 animate !== true && onAnimeComplete();
\r
2679 function onAnimeComplete(){
\r
2680 reversibleImage.resize( flipH * w, flipV * h);
\r
2683 function updateUrl( _url){
\r
2684 if( url === _url) return;
\r
2685 url = _url || url;
\r
2686 var _reversibleImage = pettanr.image.createReversibleImage( url, flipH * w, flipV * h, function( _url, _actualW, _actualH){
\r
2687 actualW = _actualW;
\r
2688 actualH = _actualH;
\r
2690 if( reversibleImage !== null){
\r
2691 JQ_WRAPPER.children( reversibleImage.elm).replaceWith( _reversibleImage.elm);
\r
2692 reversibleImage.destroy();
\r
2694 JQ_WRAPPER.append( _reversibleImage.elm);
\r
2696 reversibleImage = _reversibleImage;
\r
2698 return pettanr.util.extend(
\r
2699 new AbstractComicElement( JQ_WRAPPER, COMIC_ELEMENT_TYPE_IMAGE, update, x, y, w, h, z, timing),
\r
2707 flip: function( _flipH, _flipV){
\r
2708 if( _flipH !== true && _flipV !== true) return;
\r
2709 flipH = _flipH === true ? -flipH : flipH;
\r
2710 flipV = _flipV === true ? -flipV : flipV;
\r
2711 reversibleImage.resize( flipH * w, flipV * h);
\r
2713 flipV: function(){
\r
2716 flipH: function(){
\r
2719 url: function( _url, _actualW, _actualH){
\r
2720 if( _url && _url !== url){
\r
2721 SAVE( updateUrl, url, _url);
\r
2722 actualW = _actualW;
\r
2723 actualH = _actualH;
\r
2728 actualW: function(){ return actualW;},
\r
2729 actualH: function(){ return actualH;},
\r
2732 animate: function ( _x, _y, _w, _h, _flipH, _flipV){
\r
2733 flipH = _flipH !== undefined ? _flipH : flipH;
\r
2734 flipV = _flipV !== undefined ? _flipV : flipV;
\r
2735 update( _x, _y, _w, _h, true);
\r
2737 getAsHTML: function( isAbsoluteUrl, isXHTML){
\r
2740 'src="', isAbsoluteUrl !== true ? url : pettanr.util.getAbsolutePath( url), '" ',
\r
2741 'width="', w, '" ',
\r
2742 'height="', h, '" ',
\r
2744 'left:', x, 'px;',
\r
2746 'z-index:', this.z, ';',
\r
2748 isXHTML !== true ? '>' : ' \/>'
\r
2751 getAsJsonString: function(){
\r
2752 var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
\r
2754 '"new', this.timing, '": {', cr,
\r
2755 '"resource_picture_id": 1,', cr,
\r
2756 '"x": ', x, ',', cr,
\r
2757 '"y": ', y, ',', cr,
\r
2758 '"z": ', this.z, ',', cr,
\r
2759 '"width": ', w, ',', cr,
\r
2760 '"height": ', h, ',', cr,
\r
2761 '"flipv": ', flipV === true ? 1 : 0, ',', cr,
\r
2762 '"fliph": ', flipH === true ? 1 : 0, ',', cr,
\r
2763 '"t": ', this.timing, cr,
\r
2767 destroy: function(){
\r
2768 reversibleImage.destroy();
\r
2769 JQ_WRAPPER.remove();
\r
2770 JQ_WRAPPER = reversibleImage = OPERATOR = null;
\r
2771 delete this.destroy;
\r
2777 * / ImageElementClass
\r
2778 * --------------------------------------------------------------------------------------------
\r
2783 * --------------------------------------------------------------------------------------------
\r
2784 * TextElementClass
\r
2786 * ELM はpettanr.domで書き出したものを突っ込むcreateの場合
\r
2790 * 1.speach balloon
\r
2793 * 4.black-box( dq style)
\r
2794 * 5.blue-box( ff style)
\r
2797 var jqTextElementOrigin;
\r
2798 var TextElementClass = function( type, a, text, x, y, z, w, h, timing){
\r
2799 jqTextElementOrigin = jqTextElementOrigin || ( function(){
\r
2800 var _OLD_IE = $( $( '#textElementTempleteForOldIE').remove().html()),
\r
2801 _MODERN = $( $( '#textElementTemplete').remove().html());
\r
2802 return pettanr.ua.isIE === true && pettanr.ua.ieRenderingVersion < 8 ? _OLD_IE : _MODERN;
\r
2805 var JQ_WRAPPER = jqTextElementOrigin.clone( true),
\r
2806 XBROWSER_BALLOON = pettanr.balloon.createBalloon( w, h, a, type),
\r
2807 TEXT_ELM = JQ_WRAPPER.find( 'td,.speach-inner').eq( 0),
\r
2808 OPERATOR = COMIC_ELEMENT_OPERATION_MANAGER,
\r
2809 HIT_AREA = MOUSE_HIT_AREA,
\r
2810 SAVE = HISTORY.saveState,
\r
2813 JQ_WRAPPER.find( 'img').eq( 0).replaceWith( XBROWSER_BALLOON.elm);
\r
2815 function update( _x, _y, _w, _h, _a, animate){
\r
2816 instance.x = x = _x !== undefined ? _x : x;
\r
2817 instance.y = y = _y !== undefined ? _y : y;
\r
2818 instance.w = w = _w !== undefined ? _w : w;
\r
2819 instance.h = h = _h !== undefined ? _h : h;
\r
2820 a = _a !== undefined ? _a : a;
\r
2822 JQ_WRAPPER[ animate === true ? 'animate' : 'css']( {
\r
2829 XBROWSER_BALLOON.resize( a, w, h);
\r
2832 animate !== true && XBROWSER_BALLOON.resize( a, w, h);
\r
2835 function updateType( _type){
\r
2836 if( type !== _type){
\r
2837 type = _type || type;
\r
2838 XBROWSER_BALLOON.type( type);
\r
2841 function updateAngle( _a){
\r
2842 if( _a !== undefined && a !== _a){
\r
2843 a = _a !== undefined ? _a : a;
\r
2844 XBROWSER_BALLOON.angle( a);
\r
2847 function updateText( _text){
\r
2848 text = _text || text || '';
\r
2849 TEXT_ELM.html( text);
\r
2852 return pettanr.util.extend(
\r
2853 new AbstractComicElement( JQ_WRAPPER, COMIC_ELEMENT_TYPE_TEXT, update, x, y, w, h, z, timing),
\r
2861 angle: function( _a){
\r
2862 _a !== undefined && update( undefined, undefined, undefined, undefined, _a);
\r
2865 text: function( _text){
\r
2866 if( _text && text !== _text) {
\r
2867 SAVE( updateText, text || '', _text);
\r
2868 updateText( _text);
\r
2873 animate: function ( _x, _y, _w, _h, _a){
\r
2874 update( _x, _y, _w, _h, _a, true);
\r
2876 destroy: function(){
\r
2877 JQ_WRAPPER.remove();
\r
2878 XBROWSER_BALLOON.destroy();
\r
2880 delete this.destroy;
\r
2882 getAsJSON: function(){
\r
2885 getAsJsonString: function(){
\r
2886 var cr = pettanr.LINE_FEED_CODE_TEXTAREA;
\r
2888 '"new', this.timing, '": {', cr,
\r
2889 '"balloon_template_id": ', 1, ',', cr,
\r
2890 '"system_picture_id": ', 1, ',', cr,
\r
2891 '"size": ', 1, ',', cr,
\r
2892 '"tail": ', a, ',', cr,
\r
2893 '"x": ', x, ',', cr,
\r
2894 '"y": ', y, ',', cr,
\r
2895 '"z": ', this.z, ',', cr,
\r
2896 '"t": ', this.timing, ',', cr,
\r
2897 '"width": ', w, ',', cr,
\r
2898 '"height": ', h, ',', cr,
\r
2899 '"speaches_attributes": {', cr,
\r
2900 '"newf', this.timing, '": {', cr,
\r
2901 '"content": "', text, '",', cr,
\r
2902 '"x": ', x, ',', cr,
\r
2903 '"y": ', y, ',', cr,
\r
2904 '"t": ', 0, ',', cr,
\r
2905 '"width": ', w, ',', cr,
\r
2906 '"height": ', h, cr,
\r
2912 getAsHTML: function( isAbsoluteUrl, isXHTML){
\r
2913 var url = XBROWSER_BALLOON.getURL();
\r
2916 'src="', isAbsoluteUrl !== true ? url : pettanr.util.getAbsolutePath( url), '" ',
\r
2917 'width="', w, '" ',
\r
2918 'height="', h, '" ',
\r
2920 'left:', x, 'px;',
\r
2922 'z-index:', this.z, ';',
\r
2924 isXHTML !== true ? '>' : ' \/>',
\r
2925 pettanr.LINE_FEED_CODE_TEXTAREA,
\r
2926 '<div class="balloon" style="',
\r
2927 'left:', x, 'px;',
\r
2929 'width:', w, 'px;',
\r
2930 'height:', h, 'px;',
\r
2931 'z-index:', this.z,
\r
2932 '"><span>', text, '<\/span>', '<\/div>'
\r
2936 getAsXML: function(){}
\r
2943 var COMIC_ELEMENT_CONTROL = ( function(){
\r
2944 var SAVE = HISTORY.saveState,
\r
2945 ELM_CONTAINER = document.getElementById( 'comic-element-container'),
\r
2946 currentElement = null,
\r
2947 currentLockTest = false,
\r
2948 currentLock = false,
\r
2949 panelX, panelY, panelW, panelH,
\r
2953 * append, remove, replace
\r
2955 * comicElement には、z-position と dom-index がある。
\r
2956 * z-position は 表示上の位置。大きいほど前に表示される( z-index)
\r
2957 * dom-index は 意味上の順番。htmlタグの登場順で、検索結果や音声読み上げブラウザで正しく意味が取れる順番。
\r
2959 * editerでは、実際には z-index は使わず、htmlの順序で前後を表現する。
\r
2960 * dom-index は、数値のみ保持して、投稿時にcomicElementを適宜に並び替える。
\r
2962 * append comicElement
\r
2963 * 1. 新しい comicElement の z-position を得る
\r
2964 * 2. z の同じ comicElementを見つけ、その前に加える。または一番先頭へ。(COMIC_ELEMENT_ARRAY)
\r
2965 * zが大きいほど、COMIC_ELEMENT_ARRAYの先頭へ。
\r
2966 * 3. dom位置は、COMIC_ELEMENT_ARRAY とは反対に、前のものほど後ろへ。
\r
2969 * remove comicElement
\r
2973 function appendComicElement( _comicElement) {
\r
2974 _comicElement.init && _comicElement.init();
\r
2975 var z = _comicElement.z,
\r
2976 l = COMIC_ELEMENT_ARRAY.length,
\r
2977 _jqElm = _comicElement.$.stop().css( {
\r
2981 if( typeof z !== 'number' || z < 0 || z >= l){
\r
2982 COMIC_ELEMENT_ARRAY.unshift( _comicElement);
\r
2983 ELM_CONTAINER.appendChild( _jqElm.get( 0));
\r
2986 var insertIndex = 0;
\r
2987 for( var i = 0; i < l; ++i){
\r
2988 if( COMIC_ELEMENT_ARRAY[ i].z <= z){
\r
2993 COMIC_ELEMENT_ARRAY[ insertIndex].$.before( _jqElm.fadeIn());
\r
2994 COMIC_ELEMENT_ARRAY.splice( insertIndex, 0, _comicElement);
\r
2996 numberingComicElement();
\r
2998 function removeComicElement( _comicElement) {
\r
2999 var l = COMIC_ELEMENT_ARRAY.length;
\r
3000 for( var i=0; i<l; ++i){
\r
3001 if( COMIC_ELEMENT_ARRAY[ i] === _comicElement){
\r
3002 COMIC_ELEMENT_ARRAY.splice( i, 1);
\r
3003 numberingComicElement();
\r
3004 _comicElement.$.stop().css( {
\r
3007 }).fadeOut( onFadeOut);
\r
3008 currentElement = currentElement === _comicElement ? null : currentElement;
\r
3012 function onFadeOut(){
\r
3013 this.parentNode.removeChild( this);
\r
3016 function restoreComicElement( arg){
\r
3017 var isAppend = arg[ 0],
\r
3018 comicElement = arg[ 1];
\r
3019 isAppend === true ? appendComicElement( comicElement) : removeComicElement( comicElement);
\r
3022 * COMIC_ELEMENT_ARRAY の順番を基準に、zの再計算
\r
3025 function numberingComicElement(){
\r
3026 var l = COMIC_ELEMENT_ARRAY.length,
\r
3027 _comicElement, jqElm, jqNext;
\r
3028 for( var i=0; i < l; ++i){
\r
3029 _comicElement = COMIC_ELEMENT_ARRAY[ i];
\r
3030 jqElm = _comicElement.$;
\r
3031 jqNext && jqNext.before( jqElm);
\r
3032 _comicElement.z = l -i -1;
\r
3036 function replaceComicElement( _comicElement, goForward){
\r
3037 // COMIC_ELEMENT_ARRAYの再構築
\r
3038 var l = COMIC_ELEMENT_ARRAY.length,
\r
3040 for( var ret = 0; ret < l; ++ret){
\r
3041 if( COMIC_ELEMENT_ARRAY[ ret] === _comicElement) return ret;
\r
3045 if( i === -1) return;
\r
3046 if( goForward === true){
\r
3047 if( i === 0) return;
\r
3048 COMIC_ELEMENT_ARRAY.splice( i, 1);
\r
3049 COMIC_ELEMENT_ARRAY.splice( i -1, 0, _comicElement);
\r
3051 if( i === l -1) return;
\r
3052 COMIC_ELEMENT_ARRAY.splice( i, 1);
\r
3053 COMIC_ELEMENT_ARRAY.splice( i +1, 0, _comicElement);
\r
3055 numberingComicElement();
\r
3057 function restoreReplaceObject( arg){
\r
3058 replaceComicElement( arg[ 0], arg[ 1]);
\r
3064 appendComicElement( ImageElementClass.apply( {}, [ 'resource_pictures/13.gif', 'penchan', 10, 10, 0, 100, 140, 0]));
\r
3065 appendComicElement( TextElementClass.apply( {}, [ 0, 270, 'Hello', 50, 70, 1, 200, 160, 1]));
\r
3069 log = $( '#operation-catcher-log');
\r
3071 delete COMIC_ELEMENT_CONTROL.init;
\r
3073 removeComicElement: removeComicElement,
\r
3074 restoreComicElement: restoreComicElement,
\r
3075 replaceComicElement: replaceComicElement,
\r
3076 restoreReplaceObject: restoreReplaceObject,
\r
3077 onPanelResize : function ( _panelX, _panelY, _panelW, _panelH, isResizerTopAction){
\r
3079 * リサイズが、ResizerTopによって行われた場合、comicElementのyを動かして見かけ上動かないようにする。
\r
3081 if( isResizerTopAction === true){
\r
3082 var _shiftX = _panelW -panelW,
\r
3083 _shiftY = _panelH -panelH,
\r
3084 l = COMIC_ELEMENT_ARRAY.length;
\r
3085 for( var i = 0; i < l; i++){
\r
3086 COMIC_ELEMENT_ARRAY[ i].shift( _shiftX, _shiftY);
\r
3094 ELM_CONTAINER.style.width = _panelW +'px';
\r
3095 ELM_CONTAINER.style.height = _panelH +'px';
\r
3096 ELM_CONTAINER.style.left = _panelX +'px';
\r
3097 ELM_CONTAINER.style.top = _panelY +'px';
\r
3099 onMouseMove: function( _mouseX, _mouseY){
\r
3100 var l = COMIC_ELEMENT_ARRAY.length,
\r
3101 _x = _mouseX -panelX,
\r
3102 _y = _mouseY -panelY,
\r
3103 _elm = currentElement;
\r
3105 if( _elm !== null){
\r
3106 currentLockTest = currentLockTest === true && _x === 0 && _y === 0;
\r
3107 if( _elm.busy() === true){
\r
3108 _elm.onMouseMove( _x, _y);
\r
3111 if( _elm.hitTest( _x, _y) === true){
\r
3112 _elm.onMouseMove( _x, _y); // cursor
\r
3115 if( currentLock === true){
\r
3116 currentLockTest = true;
\r
3120 for( var i=0; i<l; i++){
\r
3121 _elm = COMIC_ELEMENT_ARRAY[ i];
\r
3123 if( _elm.hitTest( _x, _y) === true){
\r
3124 _elm.onMouseMove( _x, _y); // cursor
\r
3125 log.html( [ _x, _y, i].join( ','));
\r
3126 currentElement = _elm;
\r
3130 currentElement = null;
\r
3131 COMIC_ELEMENT_OPERATION_MANAGER.hide();
\r
3132 log.html( [ _x, _y].join( ','));
\r
3135 onMouseUp: function( _mouseX, _mouseY){
\r
3136 var ret = currentElement !== null && currentElement.busy() === true;
\r
3137 ret === true && currentElement.onMouseUp( _mouseX -startX || panelX, _mouseY -startY || panelY);
\r
3138 RESIZE_OPERATOR.lock( currentLockTest);
\r
3139 currentLock = currentLockTest;
\r
3142 onMouseDown: function( _mouseX, _mouseY){
\r
3145 if( currentElement === null) return false
\r
3146 currentElement.onMouseDown( _mouseX -startX, _mouseY -startY);
\r
3147 currentLockTest = true;
\r
3151 return currentElement !== null;
\r
3153 createImageElement: function( url, imagesetID, x, y, z, w, h){
\r
3154 w = w || 200; //ActualWidth
\r
3155 h = h || 150; //ActualHeight
\r
3156 x = x || Math.floor( panelW /2 -w /2);
\r
3157 y = y || Math.floor( panelH /2 -h /2);
\r
3158 IMAGE_GROUP_EXPROLER.show( function( _url, _w, _h){
\r
3159 var _comicElement = ImageElementClass.apply( {}, [ _url, imagesetID, x, y, z || -1, w, h, COMIC_ELEMENT_ARRAY.length]);
\r
3160 appendComicElement( _comicElement);
\r
3161 _comicElement.animate( undefined, undefined, _w, _h);
\r
3162 SAVE( restoreComicElement, [ false, _comicElement], [ true, _comicElement], true);
\r
3165 createTextElement: function( type, angle, text, x, y, z, w, h){
\r
3167 angle = angle || 0;
\r
3168 text = text || '';
\r
3171 x = x || Math.floor( panelW /2 -w /2 +Math.random() *10);
\r
3172 y = y || Math.floor( panelH /2 -h /2 +Math.random() *10);
\r
3173 var _comicElement = TextElementClass.apply( {}, [ type, angle, text, x, y, z || -1, w, h, COMIC_ELEMENT_ARRAY.length]);
\r
3174 TEXT_EDITOR_CONTROL.show( _comicElement, function( _comicElement){
\r
3175 appendComicElement( _comicElement);
\r
3176 SAVE( restoreComicElement, [ false, _comicElement], [ true, _comicElement], true);
\r
3179 getAsHTML: function( isAbsoluteUrl, isXHTML){
\r
3180 var HTML_ARRAY = [],
\r
3181 l = COMIC_ELEMENT_ARRAY.length,
\r
3185 while( HTML_ARRAY.length < l){
\r
3186 _comicElement = getComicElementByTiming();
\r
3187 if( _comicElement === null) break;
\r
3188 HTML_ARRAY.push( _comicElement.getAsHTML( isAbsoluteUrl, isXHTML));
\r
3190 function getComicElementByTiming(){
\r
3191 while( _timing < l *2){
\r
3192 for(var i=0; i<l; ++i){
\r
3193 if( _timing === COMIC_ELEMENT_ARRAY[ i].timing){
\r
3195 return COMIC_ELEMENT_ARRAY[ i];
\r
3202 HTML_ARRAY.unshift(
\r
3204 '<div class="panel" ',
\r
3206 'height:', panelH, 'px;',
\r
3207 'background-color:', ';',
\r
3212 HTML_ARRAY.push( '</div>');
\r
3214 return HTML_ARRAY.join( pettanr.LINE_FEED_CODE_TEXTAREA);
\r
3216 getAsJsonString: function(){
\r
3217 var JSON_STRING_ARRAY = [],
\r
3219 BALLOON_ARRAY = [],
\r
3220 l = COMIC_ELEMENT_ARRAY.length,
\r
3223 cr = pettanr.LINE_FEED_CODE_TEXTAREA;
\r
3225 while( IMAGE_ARRAY.length + BALLOON_ARRAY.length < l){
\r
3226 _comicElement = getComicElementByTiming();
\r
3227 if( _comicElement === null) break;
\r
3228 _comicElement.type === COMIC_ELEMENT_TYPE_IMAGE ?
\r
3229 IMAGE_ARRAY.push( _comicElement.getAsJsonString()) :
\r
3230 BALLOON_ARRAY.push( _comicElement.getAsJsonString());
\r
3232 function getComicElementByTiming(){
\r
3233 while( _timing < l *2){
\r
3234 for(var i=0; i<l; ++i){
\r
3235 if( _timing === COMIC_ELEMENT_ARRAY[ i].timing){
\r
3237 return COMIC_ELEMENT_ARRAY[ i];
\r
3247 '"border": 1,', cr,
\r
3248 '"comic_id": 5,', cr,
\r
3249 '"resource_picture_id": 1,', cr,
\r
3250 '"x": ', 0, ',', cr,
\r
3251 '"y": ', 0, ',', cr,
\r
3252 '"z": ', 0, ',', cr,
\r
3253 '"t": ', 0, ',', cr,
\r
3254 '"width": ', panelW, ',', cr,
\r
3255 '"height": ', panelH, ',', cr,
\r
3256 '"panel_pictures_attributes": {', cr,
\r
3257 IMAGE_ARRAY.join( ',' +cr), cr,
\r
3259 '"balloons_attributes": {', cr,
\r
3260 BALLOON_ARRAY.join( ',' +cr), cr,
\r
3270 * end of COMIC_ELEMENT_CONTROL
\r
3275 function updateMouseCursor( _cursor){
\r
3276 if( currentCursor !== _cursor){
\r
3277 currentCursor = _cursor;
\r
3278 setTimeout( update, 0);
\r
3280 function update(){
\r
3281 ELM_MOUSE_EVENT_CHATCHER.style.cursor = currentCursor;
\r
3284 function centering(){
\r
3285 pettanr.editor.onWindowResize( windowW, windowH);
\r
3287 function mouseEventRellay( e){
\r
3288 var _mouseX = e.pageX,
\r
3289 _mouseY = e.pageY,
\r
3290 rellayMethod = e.type === 'mousedown' ?
\r
3292 ( e.type === 'mousemove' ? 'onMouseMove' : 'onMouseUp');
\r
3293 if( currentListener !== null && currentListener.busy() === true){
\r
3294 currentListener[ rellayMethod]( _mouseX, _mouseY);
\r
3296 currentListener = null;
\r
3297 var l = MOUSE_LISTENER_ARRAY.length,
\r
3299 for( var i=0; i<l; ++i){
\r
3300 _listener = MOUSE_LISTENER_ARRAY[ i];
\r
3301 if( _listener[ rellayMethod]( _mouseX, _mouseY) === true){
\r
3302 currentListener = _listener;
\r
3308 //!document.selection && window.getSelection().removeAllRanges();
\r
3309 e.stopPropagation();
\r
3314 init: function( _option){
\r
3317 firstOpen: function(){
\r
3318 var jqWindow = pettanr.jqWindow();
\r
3319 windowW = jqWindow.width();
\r
3320 windowH = jqWindow.height();
\r
3322 jqEditor = $( '#editor');
\r
3325 * MOUSE_LISTENER_ARRAY は、表示順に格納.手前の要素が最初
\r
3326 * MENU_BAR_CONTROL,
\r
3328 * COMIC_ELEMENT_CONTROL,
\r
3330 * .busy() === true なら、そのままonMouseMove()にイベントを流す.これはArrayの後ろから、奥の表示要素から
\r
3331 * onMouseMove()に流してみて、false が帰れば、次にリスナーにも流す.
\r
3333 MOUSE_LISTENER_ARRAY.push( MENU_BAR_CONTROL, WINDOWS_CONTROL, PANEL_RESIZER_TOP, PANEL_RESIZER_BOTTOM, COMIC_ELEMENT_CONTROL, PANEL_CONTROL);
\r
3337 WINDOWS_CONTROL.init();
\r
3339 GRID_CONTROL.init();
\r
3340 PANEL_CONTROL.init();
\r
3341 CONSOLE_CONTROLER.init();
\r
3342 COMIC_ELEMENT_OPERATION_MANAGER.init();
\r
3343 COMIC_ELEMENT_CONTROL.init();
\r
3346 MENU_BAR_CONTROL.init();
\r
3348 TEXT_EDITOR_CONTROL.init();
\r
3349 IMAGE_GROUP_EXPROLER.init();
\r
3354 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 96, false, true, centering); // ctrl + 0
\r
3355 pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 48, false, true, centering); // ctrl + 0
\r
3356 MENU_BAR_CONTROL.EDIT.createSelection( 'centering', 'ctrl + 0', centering, true, true, true);
\r
3358 * jqMouseEventChacher は透明な要素で、
\r
3359 * マウスイベントをcurrentElement(currentElement)に伝えるのが仕事
\r
3360 * このような実装になるのは、ここの表示オブジェクトにイベントを設定した場合、表示が追いつかずマウスカーソルが外れたタイミングでイベントが終わってしまうため。
\r
3362 jqMouseEventChacher = $( ELM_MOUSE_EVENT_CHATCHER)
\r
3363 .mousemove( mouseEventRellay)
\r
3364 .mousedown( mouseEventRellay)
\r
3365 .mouseup( mouseEventRellay)
\r
3366 .mouseout( mouseEventRellay);
\r
3368 delete pettanr.editor.firstOpen;
\r
3370 onOpen: function( _option){
\r
3371 pettanr.editor.firstOpen !== undefined && pettanr.editor.firstOpen();
\r
3373 // HISTORY.onOpen();
\r
3374 // WINDOWS_CONTROL.onOpen();
\r
3375 // COMIC_ELEMENT_CONTROL.onOpen();
\r
3376 // MENU_BAR_CONTROL.onOpen();
\r
3377 // TEXT_EDITOR_CONTROL.onOpen();
\r
3378 // IMAGE_GROUP_EXPROLER.onOpen();
\r
3380 onClose: function(){
\r
3382 onWindowResize: function( _windowW, _windowH){
\r
3383 windowW = _windowW;
\r
3384 windowH = _windowH;
\r
3389 jqEditor.get( 0).style.height = _windowH +'px';
\r
3390 ELM_MOUSE_EVENT_CHATCHER.style.height = _windowH +'px';
\r
3392 WINDOWS_CONTROL.onWindowResize( _windowW, _windowH);
\r
3393 MENU_BAR_CONTROL.onWindowResize( _windowW, _windowH);
\r
3394 PANEL_CONTROL.onWindowResize( _windowW, _windowH);
\r