From: itozyun Date: Sat, 14 Apr 2012 14:24:37 +0000 (+0900) Subject: client is version0.4.18, update around applications. X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=commitdiff_plain;h=ab4996db9a7ac70d56241f9e2c7fa9f036763567 client is version0.4.18, update around applications. --- diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2fba7841..7739008f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -28,11 +28,11 @@
<%= yield %>

クイックアクセス

-

新しいコマを描く(いまだけ)

-

新しいコミックをつくる

-

画像のアップロード

-

コマの追加(開発用)

-

アーティスト登録(すでに登録している場合も操作可能)

+

新しいコマを描く(いまだけ)

+

新しいコミックをつくる

+

画像のアップロード

+

コマの追加(開発用)

+

アーティスト登録(すでに登録している場合も操作可能)

座長からのお知らせ

メンテナンスについて

diff --git a/public/assets/common.js b/public/assets/common.js index 540227ff..eb8e2705 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1,6 +1,6 @@ /* * pettanR common.js - * version 0.4.17 + * version 0.4.18 * * author: itozyun */ @@ -511,7 +511,7 @@ pettanr.util = ( function(){ return ret; }, getChildIndex: function( _parent, _child){ - var _children = _parent.getElementsByTagName( _child.tagName), + var _children = _parent.getElementsByTagName( _child.tagName ), l = _children.length; for(var i=0; i _w || this.MIN_HEIGHT > _h ){ if( Type.isHTMLElement( this.rootElement ) === true ){ // 小さすぎる!、と表示 } - return; } - this.onOpen( _w, _h, _option ); + if( arguments.length > 2){ + argumentsRellay( this.onOpen, arguments ); + } else { + this.onOpen( _w, _h ); + } } this.close = function(){ if( this.onClose() === false ){ @@ -879,81 +881,157 @@ pettanr.view = ( function(){ this.MIN_WIDTH = 240; this.MIN_HEIGHT = 240; } + var AbstractApplication = function(){ this.displayName = 'app name'; this.ID = 'app id'; } AbstractApplication.prototype = new AbstractBasicPane(); - return { - init: function( _funcArray ){ - jqWindow = pettanr.jqWindow(); - jqWindow.resize( onWindowResize); - - var _option = {}; // urlパラメータ - - pettanr.view.show( pettanr.URL_PARAMS.view || 0, _option ); - - delete pettanr.view.init; - }, - show: function( APPLICATIONorINDEX, _option ){ - if( isWorkPage === false ) return; - - var _applicetion, - _elm, i, l, - nodesA = navi.getElementsByTagName( 'a') || [], - _index = -1; - if( typeof APPLICATIONorINDEX === 'number' && APPLICATIONorINDEX < LUNCHER_APPLICATION_LIST.length){ - _applicetion = LUNCHER_APPLICATION_LIST[ APPLICATIONorINDEX ]; - } else - if( typeof APPLICATIONorINDEX === 'string' ){ - for( i=0, l=LUNCHER_APPLICATION_LIST.length; i 0 ){ + bootApplication( _application, pettanr.util.copyArray( arguments ) ); } else { - return; + bootApplication( _application ); } + } + this.bootInOverlay = function( /* _option */ ){ + this.inOverlay = true; + pettanr.overlay.show( _application ); - if( !_applicetion ) return; + if( arguments.length > 0 ){ + var _arguments = pettanr.util.copyArray( arguments ); + _arguments.unshift( jqWindow.width(), jqWindow.height() ) + // argumentsRellay( _application.open, _arguments ); + _application.open.apply( _application, _arguments ); + } else { + _application.open( jqWindow.width(), jqWindow.height() ); + } + } + this.shutdown = function(){ + if( this.inOverlay === true ){ + pettanr.overlay.hide(); + _application.close(); + this.inOverlay = false; + } else { + bootApplication( 0 ); + } + } + this.addToLancher = function(){ + if( pettanr.util.getIndex( LUNCHER_APPLICATION_LIST, _application ) !== -1 ) return; + LUNCHER_APPLICATION_LIST.push( _application ); + + var navi = document.getElementById('global-navi'), + item = document.createElement('a'); + navi.appendChild( item ); + navi.style.width = ( ( item.offsetWidth || 80 ) * LUNCHER_APPLICATION_LIST.length ) + 'px'; + item.href = '#'; + item.appendChild( document.createTextNode( _application.displayName )); + item.onclick = LoginUserNavi.show; + } + } + + function bootApplication( APPLICATIONorINDEX, _arguments ){ + if( isWorkPage === false ) return; + + var _application, + _elm, i, l, + nodesA = document.getElementById('global-navi').getElementsByTagName( 'a') || [], + _index = -1; + if( typeof APPLICATIONorINDEX === 'number' && APPLICATIONorINDEX < LUNCHER_APPLICATION_LIST.length){ + _application = LUNCHER_APPLICATION_LIST[ APPLICATIONorINDEX ]; + } else + if( typeof APPLICATIONorINDEX === 'string' ){ for( i=0, l=LUNCHER_APPLICATION_LIST.length; i 0 ){ + var _arg = []; + for( i=0; i 0 ){ _currentFile = PARENT_FILE_RESITER.shift(); @@ -353,28 +354,28 @@ pettanr.file = ( function(){ }, getSeqentialFiles: function(){ var _driver = FILE_CONTROLER.getDriver( this ); - if( _driver !== null && typeof _driver.getSeqentialFiles === 'function'){ + if( _driver !== null && typeof _driver.getSeqentialFiles === 'function' ){ _driver.getSeqentialFiles( this ); } }, - addEventListener: function( _eventType, _callback){ - FILE_CONTROLER.addEventListener( this, _eventType, _callback); + addEventListener: function( _eventType, _callback ){ + FILE_CONTROLER.addEventListener( this, _eventType, _callback ); }, - removeEventListener: function( _eventType, _callback){ - FILE_CONTROLER.removeEventListener( this, _eventType, _callback); + removeEventListener: function( _eventType, _callback ){ + FILE_CONTROLER.removeEventListener( this, _eventType, _callback ); }, getChildFileLength: function(){ - var children = FILE_CONTROLER.getChildren( this); + var children = FILE_CONTROLER.getChildren( this ); return Type.isArray( children ) === true ? children.length : -1; }, - getChildFileIndex: function( _FILEorFILEDATA){ + getChildFileIndex: function( _FILEorFILEDATA ){ var children = FILE_CONTROLER.getChildren( this); - if( Type.isArray( children.length ) === false ) return -1; + if( Type.isArray( children ) === false ) return -1; var l = children.length, - _fileData = FILE_CONTROLER.getFileData( _FILEorFILEDATA); - if( _fileData === null) return -1; - for(var i=0; i LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext ].join( '') : null, + reversibleImage = null, + onEnterFlag = false, + imgW, imgH; + JQ_ICON_WRAP.children( 'div').eq( 0 ).html( data.filesize + 'bytes' ); + jqContainer.append( JQ_ICON_WRAP.css( { left: INDEX * itemW})); + + function onImageLoad( url, _imgW, _imgH ){ + if( reversibleImage === null) { + alert( url); + return; + } + data.width = imgW = _imgW || data.width || 64; + data.height = imgH = _imgH || data.height || 64; + JQ_ICON_WRAP.children( 'div').eq( 1).html( imgW +'x' +imgH); + var zoom = 128 /( imgW > imgH ? imgW : imgH), + h = Math.floor( imgH *zoom ), + w = Math.floor( imgW *zoom ); + reversibleImage.elm.style.width = w +'px'; + reversibleImage.elm.style.height = h +'px'; + reversibleImage.elm.style.margin = Math.floor( itemH /2 -h /2)+'px 0 0'; + reversibleImage.resize( w, h); + JQ_ICON_WRAP.click( onClick ); + } + + function onClick( e ){ + if( _g_onUpdateFunction ) { + //if( LOW_SRC === null){ + window[ _g_onUpdateFunction]( data ); + window[ _g_onUpdateFunction] = null; + /* + } else { + var _onLoad = pettanr.util.createGlobalFunc( [ + 'function( url, w, h ){', + 'window["', _g_onUpdateFunction, '"]( url, w || ', data.width,', h || ', data.height,');', + 'window["', _g_onUpdateFunction, '"] = null;', + '}' + ].join( '')), + _onError = pettanr.util.createGlobalFunc( [ + 'function( url){', + 'window["', _g_onUpdateFunction, '"]( url, ', data.width || 64 ,', ', data.height || 64,');', + 'window["', _g_onUpdateFunction, '"] = null;', + '}' + ].join( '')); + pettanr.util.loadImage( SRC, window[ _onLoad], window[ _onError]); + window[ _onLoad] = window[ _onError] = undefined; + }*/ + } + pettanr.premiumSatge.shutdown(); + } + + this.onEnter = function(){ + if( onEnterFlag === true ) return; + reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onImageLoad ); + JQ_ICON_WRAP.children( 'img' ).replaceWith( reversibleImage.elm ); + onEnterFlag = true; + } + this.destroy = function(){ + reversibleImage && reversibleImage.destroy(); + JQ_ICON_WRAP.remove(); + file.destroy(); + reversibleImage = JQ_ICON_WRAP = data = null; + delete this.destroy; + } + } + + function onEnterShowImage(){ + var l = ICON_ARRAY.length, + _start = -wrapX /itemW -1, + _end = _start + winW /itemW +1; + for( var i=0; i 0 ? 0 : wrapX < winW -containerW ? winW -containerW : wrapX; + jqContainer.css( { left: wrapX}); + + onEnterInterval !== null && window.clearTimeout( onEnterInterval ); + onEnterInterval = window.setTimeout( onEnterShowImage, 500); + } + //e.stopPropagation(); + return false; + } + + /* grobal method */ + // this.rootElement = elmWrap; + this.displayName = 'premiumStage'; + this.ID = 'premiumStage'; + this.MIN_WIDTH = 320; + this.MIN_HEIGHT = 320; + this.init = function(){ + instance.jqWrap = jqWrap = $( '#image-gruop-wrapper').hide(); + jqContainer = $( '#image-icon-container').mousewheel( onMouseWheel); + containerH = pettanr.util.getElementSize( jqContainer.get( 0)).height; + jqItemOrigin = $( $( '#imageGruopItemTemplete').remove().html()); + var itemSize = pettanr.util.getElementSize( jqItemOrigin.get( 0)); + itemW = itemSize.width; + itemH = itemSize.height; + jqName = $( '#gruop-name-display'); + jqButton = $( '#image-gruop-button').click( clickOK); + buttonW = pettanr.util.getElementSize( jqButton.get( 0)).width; + + delete instance.init; + } + this.jqWrap = null; + this.onOpen = function( _windowW, _windowH, _artistID, _onUpdateFunction ){ + instance.init && instance.init(); + //onUpdateFunction = _onUpdateFunction; + if( _onUpdateFunction){ + _g_onUpdateFunction = pettanr.util.createGlobalFunction( _onUpdateFunction); + } else { + _g_onUpdateFunction = null; + } + + var _index = ARTIST_ROOT_FILE.search( { id: _artistID } )[ 0 ], + _artistFile = ARTIST_ROOT_FILE.getChildFileByIndex( _index ), + i, l = 0; + if( _artistFile !== null ){ + for( i=0, l=_artistFile.getChildFileLength(); i containerW ? winW : containerW, + h = _windowH > containerH ? containerH : _windowH; + + jqWrap.show(); + jqContainer.css( { + width: w, + height: 0, + left: 0, + top: Math.floor( _windowH /2) + }).stop().animate( { + height: h, + top: Math.floor( _windowH /2 -h /2) + }); + + jqButton.css( { + left: Math.floor( winW /2 - buttonW /2), + top: Math.floor( _windowH /2 + containerH /2 +10) + }); + + onEnterShowImage(); + } + this.onPaneResize = function( _windowW, _windowH ){ + var w = _windowW > containerW ? _windowW : containerW, + h = _windowH > containerH ? containerH : _windowH, + offsetW = Math.floor( _windowW /2 -winW /2); + winW = _windowW; + winH = _windowH; + if( offsetW <= 0){ // smaller + jqContainer.css( { + left: offsetW, + width: w + }).animate( { + left: 0, + top: Math.floor( _windowH /2 -h /2) + }); + } else { + jqContainer.css( { // bigger + left: 0, + width: w, + borderLeftWidth: offsetW + }).animate( { + top: Math.floor( _windowH /2 -h /2), + borderLeftWidth: 0 + }); + } + jqButton.css( { + left: Math.floor( _windowW /2 -buttonW /2), + top: Math.floor( _windowH /2 +containerH /2 +10) + }); + onEnterShowImage(); + } + this.onClose = function(){ + jqContainer.stop().animate( { + height: 0, + top: Math.floor( winH /2 ) + }, function(){ + jqWrap.hide(); + }); + while( ICON_ARRAY.length > 0 ){ + ICON_ARRAY.shift().destroy(); + } + onEnterInterval !== null && window.clearTimeout( onEnterInterval ); + onEnterInterval = _g_onUpdateFunction = null; + } +}); + + +/* ---------------------------------------- + * Text Editor + * - overlay + */ +pettanr.textEditor = pettanr.view.registerApplication( function(){ + var jqWrap, jqTextarea, jqButton, + textElement, onUpdateFunction, + ID = 'textEditor', + panelX, panelY, + instance = this; + //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK); + + function clickOK(){ + textElement && textElement.text( jqTextarea.val() ); + onUpdateFunction && onUpdateFunction( textElement ); + pettanr.textEditor.shutdown(); + } + + function keyCancel( e ){ + if( e.keyCode === 69 && e.shiftKey === false && e.ctrlKey === true){ + clickOK(); + e.preventDefault(); + e.keyCode = 0; + e.cancelBubble = true; + e.returnValue = false; + return false; + } + } + + /* grobal method */ + // this.rootElement = elmWrap; + this.displayName = 'textEditor'; + this.ID = 'textEditor'; + this.MIN_WIDTH = 320; + this.MIN_HEIGHT = 320; + this.init = function(){ + instance.jqWrap = jqWrap = $( '#speach-editor-wrapper' ).hide(); + jqTextarea = $( '#speach-editor' ).keydown( keyCancel ); + jqButton = $( '#speach-edit-complete-button').click( clickOK ); + delete instance.init; + } + this.jqWrap = null; + this.onOpen = function( _w, _h, _panelX, _panelY, _textElement, _onUpdateFunction ){ + instance.init && instance.init(); + + panelX = _panelX; + panelY = _panelY; + textElement = _textElement; + onUpdateFunction = _onUpdateFunction || null; + + var h = _textElement.h; + + instance.onPaneResize( _w, _h ); + jqTextarea.val( _textElement.text() ).focus(); + + /* + * ie6,7は、textarea { width:100%}でも高さが変わらない。rowsを設定。 + */ + pettanr.ua.isIE === true && pettanr.ua.ieVersion <= 7 && setTimeout( function(){ + var rows = 0; + while( jqTextarea.height() < h){ + rows++; + jqTextarea.attr( 'rows', rows); + } + rows > 1 && jqTextarea.attr( 'rows', rows -1 ); + }, 0); + } + this.onPaneResize = function( _w, _h ){ + jqWrap.show().css( { + left: textElement.x + panelX, + top: textElement.y + panelY, + width: textElement.w, + height: textElement.h + }); + } + this.onClose = function(){ + jqWrap.hide(); + textElement = onUpdateFunction = null; + } +}); + // i18n // login // lib @@ -1642,10 +1998,6 @@ pettanr.fn( pettanr.key); pettanr.fn( pettanr.balloon); pettanr.fn( pettanr.editor); -pettanr.fn( pettanr.comicConsole); -pettanr.fn( pettanr.uploadConsole); -pettanr.fn( pettanr.panelConsole); -pettanr.fn( pettanr.artistConsole); pettanr.fn( pettanr.file); pettanr.fn( pettanr.finder); diff --git a/public/assets/work.js b/public/assets/work.js index 7dd9b67c..7a978f46 100644 --- a/public/assets/work.js +++ b/public/assets/work.js @@ -1,6 +1,6 @@ /* * pettanR work.js - * version 0.4.17 + * version 0.4.18 * * author: * itozyun @@ -37,8 +37,6 @@ * - MENU_BAR_CONTROL * - HISTORY_CONTROL * - SAVE_CONTROL - * - TEXT_EDITOR_CONTROL - * - IMAGE_GROUP_EXPROLER * - WINDOW_CONTROL * - WindowClass * - INFOMATION_WINDOW @@ -67,10 +65,10 @@ * * */ -pettanr.editor = pettanr.view.createApplication( function(){ +pettanr.editor = pettanr.view.registerApplication( function(){ - var COMIC_ELEMENT_TYPE_IMAGE = 0, - COMIC_ELEMENT_TYPE_TEXT = 1, + var PANEL_ELEMENT_TYPE_IMAGE = 0, + PANEL_ELEMENT_TYPE_TEXT = 1, MOUSE_LISTENER_ARRAY = [], COMIC_ELEMENT_ARRAY = [], ELM_MOUSE_EVENT_CHATCHER = document.getElementById( 'mouse-operation-catcher'), @@ -82,6 +80,7 @@ pettanr.editor = pettanr.view.createApplication( function(){ windowW, windowH, currentListener = null, currentCursor = '', + instance = this, option, log; @@ -358,13 +357,13 @@ pettanr.editor = pettanr.view.createApplication( function(){ var _argBack = _stack.argBack, _argForword = _stack.argForword, _value; - if( typeof _argBack.length === 'number'){ // isArray + if( Type.isArray( _argBack ) === true ){ // isArray while( _argBack.length > 0){ _value = _argBack.shift(); _destroy === true && typeof _value.destroy === 'function' && _value.destroy(); } } - if( typeof _argForword.length === 'number'){ + if( Type.isArray( _argForword ) === true ){ while( _argForword.length > 0){ _value = _argForword.shift(); _destroy === true && typeof _value.destroy === 'function' && _value.destroy(); @@ -409,58 +408,6 @@ pettanr.editor = pettanr.view.createApplication( function(){ } })(); - -/* ---------------------------------------- - * OUTPUT_CONSOLE - * - overlay - */ - var OUTPUT_CONSOLE = ( function(){ - var jqWrap, jqOutputArea, - ID = 'outputConsole'; - //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK); - - function close(){ - jqWrap.hide(); - jqOutputArea.val(''); - } - function clickOK(){ - pettanr.overlay.hide(); - close(); - } - return { - init: function(){ - this.jqWrap = jqWrap = $( '#output-console-wrapper').hide(); - jqOutputArea = $( '#output-area'); - delete OUTPUT_CONSOLE.init; - }, - jqWrap: null, - show: function( _text){ - jqWrap.show(); - - - pettanr.overlay.show( this); - jqWrap.css( - { - left: Math.floor( ( windowW -jqWrap.width()) /2), - top: Math.floor( ( windowH -jqWrap.height()) /2) - } - ); - - jqOutputArea.val( _text).focus(); - }, - onWindowResize: function(){ - jqWrap.css( - { - left: Math.floor( ( windowW -jqWrap.width()) /2), - top: Math.floor( ( windowH -jqWrap.height()) /2) - } - ); - }, - onClose: close, - ID: 'textEditor' - } - })(); - /* ---------------------------------------- * SAVE_CONTROL * - controler @@ -475,23 +422,23 @@ pettanr.editor = pettanr.view.createApplication( function(){ function quit(){ // 本来は os.application.close(); - pettanr.view.show( 0 ); + pettanr.editor.shutdown(); } function outputAsHtml(){ - OUTPUT_CONSOLE.show( COMIC_ELEMENT_CONTROL.getAsHTML( true, false)); + pettanr.outputConsole.bootInOverlay( COMIC_ELEMENT_CONTROL.getAsHTML( true, false)); } function outputAsJsonString(){ - OUTPUT_CONSOLE.show( COMIC_ELEMENT_CONTROL.getAsJsonString()); + pettanr.outputConsole.bootInOverlay( COMIC_ELEMENT_CONTROL.getAsJsonString()); } return { open: function(){}, close: function(){}, quit: quit, panelUpdated: function( _updated){ - if( _updated !== undefined && updated !== _updated){ - SAVE.visible( !!_updated); - SAVE_AND_QUIT.visible( !!_updated); + if( _updated !== undefined && updated !== _updated ){ + SAVE.visible( !!_updated ); + SAVE_AND_QUIT.visible( !!_updated ); updated = !!_updated; } return updated; @@ -503,469 +450,6 @@ pettanr.editor = pettanr.view.createApplication( function(){ })(); /* ---------------------------------------- - * Text Editor - * - overlay - */ - var TEXT_EDITOR_CONTROL = ( function(){ - var jqWrap, jqTextarea, jqButton, - textElement, onUpdateFunction, - ID = 'textEditor'; - //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK); - - function close(){ - jqWrap.hide(); - textElement = onUpdateFunction = null; - } - function clickOK(){ - pettanr.overlay.hide(); - textElement && textElement.text( jqTextarea.val()); - onUpdateFunction && onUpdateFunction( textElement); - close(); - } - return { - init: function(){ - this.jqWrap = jqWrap = $( '#speach-editor-wrapper').hide(); - jqTextarea = $( '#speach-editor').keydown( function( e){ - if( e.keyCode === 69 && e.shiftKey === false && e.ctrlKey === true){ - clickOK(); - e.preventDefault(); - e.keyCode = 0; - e.cancelBubble = true; - e.returnValue = false; - return false; - } - }); - jqButton = $( '#speach-edit-complete-button').click( clickOK); - delete TEXT_EDITOR_CONTROL.init; - }, - jqWrap: null, - show: function( _textElement, _onUpdateFunction){ - textElement = _textElement; - onUpdateFunction = _onUpdateFunction || null; - pettanr.overlay.show( this); - var h = _textElement.h; - jqWrap.show().css( { - left: _textElement.x +PANEL_CONTROL.x(), - top: _textElement.y +PANEL_CONTROL.y(), - width: _textElement.w, - height: h - }); - jqTextarea.val( _textElement.text()).focus(); - - /* - * ie6,7は、textarea { width:100%}でも高さが変わらない。rowsを設定。 - */ - pettanr.ua.isIE === true && pettanr.ua.ieVersion <= 7 && setTimeout( function(){ - var rows = 0; - while( jqTextarea.height() < h){ - rows++; - jqTextarea.attr( 'rows', rows); - } - rows > 1 && jqTextarea.attr( 'rows', rows -1); - }, 0); - }, - onWindowResize: function(){ - textElement && this.show( textElement); - }, - onClose: close, - ID: ID - } - })(); - -/* ---------------------------------------- - * Image Group Exproler - * - overlay - */ - var IMAGE_GROUP_EXPROLER = ( function(){ - var ICON_ARRAY = [], - WHEEL_DELTA = 64, - containerW, containerH, wrapX, - jqWrap, jqContainer, jqItemOrigin, - itemW, itemH, - jqName, jqButton, buttonW, - //onUpdateFunction, - _g_onUpdateFunction, - winW, - onEnterInterval = null; - - var BASE_PATH = pettanr.LOCAL === false ? 'http://pettan.heroku.com/resource_pictures/' : 'resource_pictures/', - THUMB_PATH = BASE_PATH, // + 'thumbnail/', - LIMIT_FILESIZE = 1024 * 10; // 10KB - var IMAGE_DATA = { - pen001: [ - { - "created_at": "2011-11-13T08:57:39Z", - "ext": "png", - "filesize": 9969, - "height": 463, - "id": 1, - "updated_at": "2011-11-13T08:57:39Z", - "width": 441 - }, - { - "created_at": "2011-11-13T08:57:54Z", - "ext": "gif", - "filesize": 5418, - "height": 500, - "id": 2, - "updated_at": "2011-11-13T08:57:54Z", - "width": 500 - }, - { - "created_at": "2011-11-13T08:58:06Z", - "ext": "gif", - "filesize": 8758, - "height": 464, - "id": 3, - "updated_at": "2011-11-13T08:58:06Z", - "width": 366 - }, - { - "created_at": "2011-11-13T08:58:23Z", - "ext": "gif", - "filesize": 9383, - "height": 480, - "id": 4, - "updated_at": "2011-11-13T08:58:23Z", - "width": 392 - }, - { - "created_at": "2011-11-13T08:58:33Z", - "ext": "gif", - "filesize": 11061, - "height": 500, - "id": 5, - "updated_at": "2011-11-13T08:58:33Z", - "width": 500 - }, - { - "created_at": "2011-11-20T09:50:43Z", - "ext": "gif", - "filesize": 1131, - "height": 126, - "id": 6, - "updated_at": "2011-11-20T09:50:43Z", - "width": 259 - }, - { - "created_at": "2011-11-20T09:50:55Z", - "ext": "gif", - "filesize": 1125, - "height": 126, - "id": 7, - "updated_at": "2011-11-20T09:50:55Z", - "width": 259 - }, - { - "created_at": "2011-11-20T11:33:12Z", - "ext": "gif", - "filesize": 17919, - "height": 600, - "id": 8, - "updated_at": "2011-11-20T11:33:12Z", - "width": 800 - }, - { - "created_at": "2011-11-20T11:33:12Z", - "ext": "gif", - "filesize": 17919, - "height": 600, - "id": 9, - "updated_at": "2011-11-20T11:33:12Z", - "width": 800 - }, - { - "created_at": "2011-11-20T11:33:12Z", - "ext": "gif", - "filesize": 17919, - "height": 600, - "id": 10, - "updated_at": "2011-11-20T11:33:12Z", - "width": 800 - }, - { - "created_at": "2011-11-20T11:33:12Z", - "ext": "gif", - "filesize": 17919, - "height": 600, - "id": 11, - "updated_at": "2011-11-20T11:33:12Z", - "width": 800 - }, - { - "created_at": "2011-11-22T09:17:20Z", - "ext": "gif", - "filesize": 9055, - "height": 473, - "id": 12, - "updated_at": "2011-11-22T09:17:20Z", - "width": 405 - }, - { - "created_at": "2011-11-22T10:11:07Z", - "ext": "gif", - "filesize": 8758, - "height": 464, - "id": 13, - "updated_at": "2011-11-22T10:11:07Z", - "width": 366 - }, - { - "created_at": "2011-11-24T09:05:12Z", - "ext": "gif", - "filesize": 6431, - "height": 386, - "id": 16, - "updated_at": "2011-11-24T09:05:12Z", - "width": 453 - }, - { - "created_at": "2011-11-26T04:52:12Z", - "ext": "gif", - "filesize": 6421, - "height": 426, - "id": 17, - "updated_at": "2011-11-26T04:52:12Z", - "width": 306 - }, - { - "created_at": "2011-11-26T04:52:12Z", - "ext": "gif", - "filesize": 6421, - "height": 426, - "id": 18, - "updated_at": "2011-11-26T04:52:12Z", - "width": 306 - }, - { - "created_at": "2011-11-26T04:52:12Z", - "ext": "gif", - "filesize": 6421, - "height": 426, - "id": 19, - "updated_at": "2011-11-26T04:52:12Z", - "width": 306 - }, - { - "created_at": "2011-11-26T04:52:12Z", - "ext": "gif", - "filesize": 6421, - "height": 426, - "id": 20, - "updated_at": "2011-11-26T04:52:12Z", - "width": 306 - }, - { - "created_at": "2011-11-26T04:52:12Z", - "ext": "gif", - "filesize": 6421, - "height": 426, - "id": 21, - "updated_at": "2011-11-26T04:52:12Z", - "width": 306 - } - ] - } - - var ImageGroupIconClass = function( INDEX, data){ - var JQ_ICON_WRAP = jqItemOrigin.clone( true), - SRC = [ BASE_PATH, data.id, '.', data.ext].join( ''), - LOW_SRC = data.filesize && data.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext].join( '') : null, - reversibleImage = null, - onEnterFlag = false, - imgW, imgH; - JQ_ICON_WRAP.children( 'div').eq( 0).html( data.filesize + 'bytes'); - jqContainer.append( JQ_ICON_WRAP.css( { left: INDEX * itemW})); - - function onImageLoad( url, _imgW, _imgH){ - if( reversibleImage === null) { - alert( url); - return; - } - imgW = _imgW || data.width || 64; - imgH = _imgH || data.height || 64; - JQ_ICON_WRAP.children( 'div').eq( 1).html( imgW +'x' +imgH); - var zoom = 128 /( imgW > imgH ? imgW : imgH), - h = Math.floor( imgH *zoom), - w = Math.floor( imgW *zoom); - reversibleImage.elm.style.width = w +'px'; - reversibleImage.elm.style.height = h +'px'; - reversibleImage.elm.style.margin = Math.floor( itemH /2 -h /2)+'px 0 0'; - reversibleImage.resize( w, h); - JQ_ICON_WRAP.click( onClick); - } - - function onClick( e){ - pettanr.overlay.hide(); - if( _g_onUpdateFunction) { - if( LOW_SRC === null){ - window[ _g_onUpdateFunction]( SRC, imgW, imgH); - window[ _g_onUpdateFunction] = null; - } else { - var _onLoad = pettanr.util.createGlobalFunc( [ - 'function( url, w, h){', - 'window["', _g_onUpdateFunction, '"]( url, w || ', data.width,', h || ', data.height,');', - 'window["', _g_onUpdateFunction, '"] = null;', - '}' - ].join( '')), - _onError = pettanr.util.createGlobalFunc( [ - 'function( url){', - 'window["', _g_onUpdateFunction, '"]( url, ', data.width || 64 ,', ', data.height || 64,');', - 'window["', _g_onUpdateFunction, '"] = null;', - '}' - ].join( '')); - pettanr.util.loadImage( SRC, window[ _onLoad], window[ _onError]); - window[ _onLoad] = window[ _onError] = undefined; - } - } - close(); - } - - return { - onEnter: function(){ - if( onEnterFlag === true) return; - reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onImageLoad); - JQ_ICON_WRAP.children( 'img').replaceWith( reversibleImage.elm); - onEnterFlag = true; - }, - destroy: function(){ - reversibleImage && reversibleImage.destroy(); - JQ_ICON_WRAP.remove(); - reversibleImage = JQ_ICON_WRAP = null; - delete this.destroy; - } - } - } - - function close(){ - jqContainer.stop().animate( { - height: 0, - top: Math.floor( windowH /2) - }, function(){ - jqWrap.hide() - }); - while( ICON_ARRAY.length > 0){ - ICON_ARRAY.shift().destroy(); - } - onEnterInterval !== null && window.clearTimeout( onEnterInterval); - onEnterInterval = _g_onUpdateFunction = null; - } - function onEnterShowImage(){ - var l = ICON_ARRAY.length, - _start = -wrapX /itemW -1, - _end = _start + winW /itemW +1; - for( var i=0; i 0 ? 0 : wrapX < winW -containerW ? winW -containerW : wrapX; - jqContainer.css( { left: wrapX}); - - onEnterInterval !== null && window.clearTimeout( onEnterInterval); - onEnterInterval = window.setTimeout( onEnterShowImage, 500); - } - //e.stopPropagation(); - return false; - } - return { - init: function(){ - this.jqWrap = jqWrap = $( '#image-gruop-wrapper').hide(); - jqContainer = $( '#image-icon-container').mousewheel( onMouseWheel); - containerH = pettanr.util.getElementSize( jqContainer.get( 0)).height; - jqItemOrigin = $( $( '#imageGruopItemTemplete').remove().html()); - var itemSize = pettanr.util.getElementSize( jqItemOrigin.get( 0)); - itemW = itemSize.width; - itemH = itemSize.height; - jqName = $( '#gruop-name-display'); - jqButton = $( '#image-gruop-button').click( clickOK); - buttonW = pettanr.util.getElementSize( jqButton.get( 0)).width; - - delete IMAGE_GROUP_EXPROLER.init; - }, - jqWrap: null, - show: function( _onUpdateFunction){ - //onUpdateFunction = _onUpdateFunction; - if( _onUpdateFunction){ - _g_onUpdateFunction = pettanr.util.createGlobalFunction( _onUpdateFunction); - } else { - _g_onUpdateFunction = null; - } - pettanr.overlay.show( this); - - var CURRENT_GROUP_ARRAY = IMAGE_DATA[ 'pen001'] || [], - l = CURRENT_GROUP_ARRAY.length; - for( var i=0; i containerW ? winW : containerW, - h = windowH > containerH ? containerH : windowH; - - jqWrap.show(); - jqContainer.css( { - width: w, - height: 0, - left: 0, - top: Math.floor( windowH /2) - }).stop().animate( { - height: h, - top: Math.floor( windowH /2 -h /2) - }); - - jqButton.css( { - left: Math.floor( winW /2 -buttonW /2), - top: Math.floor( windowH /2 +containerH /2 +10) - }); - - onEnterShowImage(); - }, - onWindowResize: function( _windowW, _windowH){ - var w = _windowW > containerW ? _windowW : containerW, - h = _windowH > containerH ? containerH : _windowH, - offsetW = Math.floor( _windowW /2 -winW /2); - winW = _windowW; - if( offsetW <= 0){ // smaller - jqContainer.css( { - left: offsetW, - width: w - }).animate( { - left: 0, - top: Math.floor( _windowH /2 -h /2) - }); - } else { - jqContainer.css( { // bigger - left: 0, - width: w, - borderLeftWidth: offsetW - }).animate( { - top: Math.floor( _windowH /2 -h /2), - borderLeftWidth: 0 - }); - } - jqButton.css( { - left: Math.floor( _windowW /2 -buttonW /2), - top: Math.floor( _windowH /2 +containerH /2 +10) - }); - onEnterShowImage(); - }, - onClose: close, - ID: 'imageGroupExproler' - } - })(); - -/* ---------------------------------------- * WINDOWS_CONTROL * - contloler * - mouseEventListener @@ -1396,15 +880,12 @@ pettanr.editor = pettanr.view.createApplication( function(){ instance = this; delete this.onInit; }, - onFirstOpen: function( _w, _h){ - finder = pettanr.finder.createFinder( document.getElementById( 'image-exproler-container'), pettanr.driver.createPictureTree()); - delete this.onFirstOpen; - }, onOpen: function( _w, _h){ - finder.onOpen( _w, _h); + finder = finder || pettanr.finder.createFinder( document.getElementById( 'image-exproler-container'), pettanr.driver.createPictureTree()); + finder.open( _w, _h ); }, - onResize: function( _w, _h){ - finder.resize( _w, _h); + onResize: function( _w, _h ){ + finder.resize( _w, _h ); } }, 'image-exproler', 'Album', 0, 215, 400, 350, false, true, true, 300, 300 @@ -1462,13 +943,13 @@ pettanr.editor = pettanr.view.createApplication( function(){ x = currentElement !== null ? currentElement.x : 0, y = currentElement !== null ? currentElement.y : 0, z = currentElement !== null ? currentElement.z : 0, - a = _elementType === COMIC_ELEMENT_TYPE_TEXT ? Math.floor( currentElement.angle()) : 0, + a = _elementType === PANEL_ELEMENT_TYPE_TEXT ? Math.floor( currentElement.angle()) : 0, w = currentElement !== null ? currentElement.w : 0, h = currentElement !== null ? currentElement.h : 0, - actualW = _elementType === COMIC_ELEMENT_TYPE_IMAGE ? currentElement.actualW() : 1, - actualH = _elementType === COMIC_ELEMENT_TYPE_IMAGE ? currentElement.actualH() : 1, - wPercent = _elementType === COMIC_ELEMENT_TYPE_IMAGE ? Math.floor( w / actualW *100) : 0, - hPercent = _elementType === COMIC_ELEMENT_TYPE_IMAGE ? Math.floor( h / actualH *100) : 0, + actualW = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? currentElement.actualW() : 1, + actualH = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? currentElement.actualH() : 1, + wPercent = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? Math.floor( w / actualW *100) : 0, + hPercent = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? Math.floor( h / actualH *100) : 0, keepAspect = currentElement !== null && currentElement.keepAspect === true; if( currentElementType !== _elementType){ @@ -1853,66 +1334,64 @@ pettanr.editor = pettanr.view.createApplication( function(){ } } - return { - onMouseDown: function( _mouseX, _mouseY){ - var _x = _mouseX -panelX, - _y = _mouseY -panelY; + this.onMouseDown = function( _mouseX, _mouseY){ + var _x = _mouseX -panelX, + _y = _mouseY -panelY; + if( _x < x || x + w < _x || _y < y || y + h < _y) return false; + offsetY = _y; + startY = panelY; + startH = panelH; + isDragging = true; + MOUSE_CURSOR( 'n-resize'); + return true; + } + this.onMouseMove = function( _mouseX, _mouseY){ + var _x = _mouseX -panelX, + _y = _mouseY -panelY; + if( isDragging !== true){ if( _x < x || x + w < _x || _y < y || y + h < _y) return false; - offsetY = _y; - startY = panelY; - startH = panelH; - isDragging = true; - MOUSE_CURSOR( 'n-resize'); + COMIC_ELEMENT_OPERATION_MANAGER.hide(); + MOUSE_CURSOR( 'pointer'); return true; - }, - onMouseMove: function( _mouseX, _mouseY){ - var _x = _mouseX -panelX, - _y = _mouseY -panelY; - if( isDragging !== true){ - if( _x < x || x + w < _x || _y < y || y + h < _y) return false; - COMIC_ELEMENT_OPERATION_MANAGER.hide(); - MOUSE_CURSOR( 'pointer'); - return true; + } else { + var move = _y -offsetY; + if( isTop === true){ + if( panelH - move < MIN_PANEL_HEIGHT){ + move = panelH -MIN_PANEL_HEIGHT; + } + PANEL_CONTROL.resize( true, panelX, panelY + move, panelW, panelH - move); } else { - var move = _y -offsetY; - if( isTop === true){ - if( panelH - move < MIN_PANEL_HEIGHT){ - move = panelH -MIN_PANEL_HEIGHT; - } - PANEL_CONTROL.resize( true, panelX, panelY + move, panelW, panelH - move); - } else { - var _h = startH +move; - if( 0 < _h && _h < windowH -panelY -RESIZER_HEIGHT -5 -BORDER_WIDTH){ - PANEL_CONTROL.resize( false, panelX, panelY, panelW, _h < MIN_PANEL_HEIGHT ? MIN_PANEL_HEIGHT : _h); - } + var _h = startH +move; + if( 0 < _h && _h < windowH -panelY -RESIZER_HEIGHT -5 -BORDER_WIDTH){ + PANEL_CONTROL.resize( false, panelX, panelY, panelW, _h < MIN_PANEL_HEIGHT ? MIN_PANEL_HEIGHT : _h); } } - return true; - }, - onMouseUp: function( _mouseX, _mouseY){ - if( isDragging !== true) return; - ( startY !== panelY || startH !== panelH) && HISTORY_CONTROL.saveState( restoreState, [ NaN, startY, NaN, startH], [ NaN, panelY, NaN, panelH]); - isDragging = false; - MOUSE_CURSOR( ''); - }, - busy: function(){ - return isDragging - }, - onPanelResize: function( _x, _y, _w, _h){ - panelX = _x; - panelY = _y; - if( panelW !== _w){ - ELM.style.width = ( _w +2) +'px'; - panelW = _w; - } - panelH = _h; - y = isTop === true ? y : ( panelH +5 +BORDER_WIDTH); - w = panelW +2; } + return true; + } + this.onMouseUp = function( _mouseX, _mouseY){ + if( isDragging !== true) return; + ( startY !== panelY || startH !== panelH) && HISTORY_CONTROL.saveState( restoreState, [ NaN, startY, NaN, startH], [ NaN, panelY, NaN, panelH]); + isDragging = false; + MOUSE_CURSOR( ''); + } + this.busy = function(){ + return isDragging + } + this.onPanelResize = function( _x, _y, _w, _h){ + panelX = _x; + panelY = _y; + if( panelW !== _w){ + ELM.style.width = ( _w +2) +'px'; + panelW = _w; + } + panelH = _h; + y = isTop === true ? y : ( panelH +5 +BORDER_WIDTH); + w = panelW +2; } }; - var PANEL_RESIZER_TOP = new PanelResizerClass( 'panel-resizer-top', true), - PANEL_RESIZER_BOTTOM = new PanelResizerClass( 'panel-resizer-bottom', false); + var PANEL_RESIZER_TOP = new PanelResizerClass( 'panel-resizer-top', true ), + PANEL_RESIZER_BOTTOM = new PanelResizerClass( 'panel-resizer-bottom', false ); PanelResizerClass = undefined; @@ -1984,14 +1463,17 @@ pettanr.editor = pettanr.view.createApplication( function(){ COMIC_ELEMENT_OPERATION_MANAGER.hide(); } function edit(){ - if( currentElement === null || currentElement.type !== COMIC_ELEMENT_TYPE_TEXT) return; - TEXT_EDITOR_CONTROL.show( currentElement); + if( currentElement === null || currentElement.type !== PANEL_ELEMENT_TYPE_TEXT) return; + pettanr.textEditor.bootInOverlay( PANEL_CONTROL.x(), PANEL_CONTROL.y(), currentElement ); buttonBackOrForward( true); } function change(){ if( currentElement === null) return; buttonBackOrForward( true); - IMAGE_GROUP_EXPROLER.show( currentElement.url); + pettanr.premiumSatge.bootInOverlay( currentElement.getArtistID(), currentElement.resourcePicture ); + } + function onImageSelect( resourcePicture ){ + currentElement.resourcePicture( resourcePicture ); } return { init: function(){ @@ -2018,7 +1500,9 @@ pettanr.editor = pettanr.view.createApplication( function(){ delete CONSOLE_CONTROLER.init; }, - show: function( _currentElement, _w, _h){ + show: function( _currentElement, _w, _h ){ + CONSOLE_CONTROLER.init && CONSOLE_CONTROLER.init(); + visible === false && jqConsoleWrapper.show(); visible = true; currentElement = _currentElement; @@ -2026,17 +1510,17 @@ pettanr.editor = pettanr.view.createApplication( function(){ _z = _currentElement.z; if( currentType !== _currentType){ currentType = _currentType; - jqImgConsole.toggle( _currentType === COMIC_ELEMENT_TYPE_IMAGE); - jqTextConsole.toggle( _currentType === COMIC_ELEMENT_TYPE_TEXT); - consoleWidth = _currentType === COMIC_ELEMENT_TYPE_IMAGE ? imgConsoleWidth : textConsoleWidth; - consoleHeight = _currentType === COMIC_ELEMENT_TYPE_IMAGE ? imgConsoleHeight : textConsoleHeight; + jqImgConsole.toggle( _currentType === PANEL_ELEMENT_TYPE_IMAGE); + jqTextConsole.toggle( _currentType === PANEL_ELEMENT_TYPE_TEXT); + consoleWidth = _currentType === PANEL_ELEMENT_TYPE_IMAGE ? imgConsoleWidth : textConsoleWidth; + consoleHeight = _currentType === PANEL_ELEMENT_TYPE_IMAGE ? imgConsoleHeight : textConsoleHeight; } consoleX = Math.floor( ( _w -consoleWidth) /2); LAYER_BACK_BUTTON.visible( _z > 0); LAYER_FORWARD_BUTTON.visible( _z < COMIC_ELEMENT_ARRAY.length -1); DELETE_BUTTON.visible( true); - EDIT_BUTTON.visible( _currentType === COMIC_ELEMENT_TYPE_TEXT); + EDIT_BUTTON.visible( _currentType === PANEL_ELEMENT_TYPE_TEXT); CHANGE_BUTTON.visible( false); if( _w > consoleWidth * 1.5 && _h > consoleHeight * 1.5){ @@ -2134,7 +1618,7 @@ pettanr.editor = pettanr.view.createApplication( function(){ currentText = null; }, onStart: function( _currentText, _mouseX, _mouseY){ - if( _currentText.type !== COMIC_ELEMENT_TYPE_TEXT) return false; + if( _currentText.type !== PANEL_ELEMENT_TYPE_TEXT) return false; x = _currentText.x; y = _currentText.y; if( this.hitTest( _mouseX -x, _mouseY -y) === true){ @@ -2314,7 +1798,7 @@ pettanr.editor = pettanr.view.createApplication( function(){ }, show: function( _currentElement){ currentElement = _currentElement; - currentIsTextElement = _currentElement.type === COMIC_ELEMENT_TYPE_TEXT; + currentIsTextElement = _currentElement.type === PANEL_ELEMENT_TYPE_TEXT; elmResizerContainerStyle.display = ''; }, hide: function(){ @@ -2323,7 +1807,7 @@ pettanr.editor = pettanr.view.createApplication( function(){ }, onStart: function( _currentElement, _mouseX, _mouseY){ currentElement = _currentElement; - currentIsTextElement = _currentElement.type === COMIC_ELEMENT_TYPE_TEXT; + currentIsTextElement = _currentElement.type === PANEL_ELEMENT_TYPE_TEXT; if( _currentElement.keepSize === true) return false; currentIndex = this.index( _mouseX, _mouseY); if( currentIndex === -1) return false; @@ -2333,7 +1817,7 @@ pettanr.editor = pettanr.view.createApplication( function(){ startY = baseY = _currentElement.y; startW = baseW = _currentElement.w; startH = baseH = _currentElement.h; - if( _currentElement.type === COMIC_ELEMENT_TYPE_IMAGE){ + if( _currentElement.type === PANEL_ELEMENT_TYPE_IMAGE){ startFilpV = _currentElement.flipV(); startFilpH = _currentElement.flipH(); } @@ -2386,7 +1870,7 @@ pettanr.editor = pettanr.view.createApplication( function(){ _h = MIN_ELEMENT_SIZE; } } else - if( currentElement.type === COMIC_ELEMENT_TYPE_TEXT){ + if( currentElement.type === PANEL_ELEMENT_TYPE_TEXT){ return; } else if( _w < -MIN_ELEMENT_SIZE || _h < -MIN_ELEMENT_SIZE){ @@ -2454,7 +1938,7 @@ pettanr.editor = pettanr.view.createApplication( function(){ onCancel: function(){ MOUSE_CURSOR( ''); COMIC_ELEMENT_OPERATION_MANAGER.resize( startX, startY, startW, startH); - currentElement.type === COMIC_ELEMENT_TYPE_IMAGE ? + currentElement.type === PANEL_ELEMENT_TYPE_IMAGE ? currentElement.animate( startX, startY, startW, startH, startFilpV, startFilpH) : currentElement.animate( startX, startY, startW, startH, angle); }, @@ -2560,7 +2044,7 @@ pettanr.editor = pettanr.view.createApplication( function(){ if( currentElement !== _currentElement){ currentElement = _currentElement; - currentIsTextElement = ( _currentElement.type === COMIC_ELEMENT_TYPE_TEXT); + currentIsTextElement = ( _currentElement.type === PANEL_ELEMENT_TYPE_TEXT); currentIsTextElement === true ? TAIL_OPERATOR.show( _currentElement) : TAIL_OPERATOR.hide(); flipV = currentIsTextElement === false ? _currentElement.flipV() : 0; @@ -2606,7 +2090,7 @@ pettanr.editor = pettanr.view.createApplication( function(){ _a = arg[ 5], _flipV = arg[ 6], _flipH = arg[ 7]; if( !_currentElement && !currentOperator) return; - _currentElement.type === COMIC_ELEMENT_TYPE_IMAGE ? + _currentElement.type === PANEL_ELEMENT_TYPE_IMAGE ? _currentElement.animate( _x, _y, _w, _h, _flipV, _flipH) : _currentElement.animate( _x, _y, _w, _h, _a); currentOperator !== null && currentOperator.onCancel && currentOperator.onCancel(); @@ -2629,7 +2113,7 @@ pettanr.editor = pettanr.view.createApplication( function(){ busy: function(){ return currentOperator !== null; }, - hitTest: function( _mouseX, _mouseY, _comicElement){ + hitTest: function( _mouseX, _mouseY, _comicElement ){ var _x, _y, _w, _h; if( _comicElement === currentElement){ var _consoleX = CONSOLE_CONTROLER.x(); @@ -2645,6 +2129,7 @@ pettanr.editor = pettanr.view.createApplication( function(){ _w = _comicElement.w +HIT_AREA *2; _h = _comicElement.h +HIT_AREA *2; } + log.html( [ _x, _y, _w, _h ].join( ' ') ); return _x <= _mouseX && _mouseX <= _x + _w && _y <= _mouseY && _mouseY <= _y + _h; }, onMouseDown: function( _currentElement, _mouseX, _mouseY){ @@ -2681,33 +2166,25 @@ pettanr.editor = pettanr.view.createApplication( function(){ * // COMIC_ELEMENT_OPERATION_MANAGER */ - var AbstractComicElement = function( JQ_WAPPER, COMIC_ELM_TYPE, update, x, y, w, h, z, timing){ - var OPERATOR = COMIC_ELEMENT_OPERATION_MANAGER; - return { - $: JQ_WAPPER, - type: COMIC_ELM_TYPE, - x: x, - y: y, - w: w, - h: h, - z: z, - timing: timing, - hitTest: function( _mouseX, _mouseY){ return OPERATOR.hitTest( _mouseX, _mouseY, this);}, - shift: function( _shiftX, _shiftY){ - update( this.x +_shiftX, this.y +_shiftY); - }, - busy: function(){ - return OPERATOR.busy(); - }, - onMouseMove: function( _mouseX, _mouseY){ - OPERATOR.onMouseMove( this, _mouseX, _mouseY); - }, - onMouseUp: function( _mouseX, _mouseY){ - OPERATOR.onMouseUp( this, _mouseX, _mouseY); - }, - onMouseDown: function( _mouseX, _mouseY){ - OPERATOR.onMouseDown( this, _mouseX, _mouseY); - } + var AbstractComicElement = function( COMIC_ELM_TYPE ){ + this.type = COMIC_ELM_TYPE; + this.hitTest = function( _mouseX, _mouseY ){ + return COMIC_ELEMENT_OPERATION_MANAGER.hitTest( _mouseX, _mouseY, this ); + } + this.shift = function( _shiftX, _shiftY ){ + this.resize( this.x + _shiftX, this.y + _shiftY); + } + this.busy = function(){ + return COMIC_ELEMENT_OPERATION_MANAGER.busy(); + } + this.onMouseMove = function( _mouseX, _mouseY ){ + COMIC_ELEMENT_OPERATION_MANAGER.onMouseMove( this, _mouseX, _mouseY ); + } + this.onMouseUp = function( _mouseX, _mouseY ){ + COMIC_ELEMENT_OPERATION_MANAGER.onMouseUp( this, _mouseX, _mouseY ); + } + this.onMouseDown = function( _mouseX, _mouseY ){ + COMIC_ELEMENT_OPERATION_MANAGER.onMouseDown( this, _mouseX, _mouseY ); } }; @@ -2715,131 +2192,140 @@ pettanr.editor = pettanr.view.createApplication( function(){ * ImageElementClass */ var jqImageElementOrigin; - var ImageElementClass = function( url, IMAGE_SET_ID, x, y, z, w, h, timing){ + var ImageElementClass = function( data ){ jqImageElementOrigin = jqImageElementOrigin || $( $( '#imgElementTemplete').remove().html()); - var JQ_WRAPPER = jqImageElementOrigin.clone( true), - OPERATOR = COMIC_ELEMENT_OPERATION_MANAGER, + var JQ_WRAPPER = jqImageElementOrigin.clone( true ), SAVE = HISTORY_CONTROL.saveState, HIT_AREA = MOUSE_HIT_AREA, - reversibleImage = null, - actualW = 0, actualH = 0, + w = data.width, + h = data.height, + x, y, z, timing, flipH = w < 0 ? -1 : 1, flipV = h < 0 ? -1 : 1, - instance; - w = Math.floor( w); - h = Math.floor( h); - - function update( _x, _y, _w, _h, animate){ + resourcePicture, + actualW, + actualH, + reversibleImage = null, + instance = this; + w = Math.floor( w ); + h = Math.floor( h ); + + function onAnimeComplete(){ + reversibleImage.resize( flipH * w, flipV * h ); + } + function updateResourcePicture( _resourcePicture ){ + resourcePicture = _resourcePicture; + + actualW = _resourcePicture.width; + actualH = _resourcePicture.height; + + var _reversibleImage = pettanr.image.createReversibleImage( + [ pettanr.CONST.RESOURCE_PICTURE_PATH, _resourcePicture.id, '.', _resourcePicture.ext ].join(''), + flipH * w, flipV * h + ); + if( reversibleImage !== null){ + JQ_WRAPPER.children( reversibleImage.elm ).replaceWith( _reversibleImage.elm ); + reversibleImage.destroy(); + } else { + JQ_WRAPPER.append( _reversibleImage.elm ); + } + reversibleImage = _reversibleImage; + } + /* global methods */ + this.$ = JQ_WRAPPER; + //this.x = x; + //this.y = y; + //this.w = w; + //this.h = h; + this.z = data.z; + this.timing = timing; + this.init = function(){ + updateResourcePicture( data.resource_picture ); + instance.resize( data.x, data.y, data.width, data.height ); + delete instance.init; + } + this.flip = function( _updateH, _updateV ){ + if( _updateH !== true && _updateV !== true ) return; + flipH = _updateH === true ? -flipH : flipH; + flipV = _updateV === true ? -flipV : flipV; + reversibleImage.resize( flipH * w, flipV * h ); + } + this.flipV = function(){ + return flipV; + } + this.flipH = function(){ + return flipH; + } + this.resourcePicture = function( _resourcePicture ){ + if( _resourcePicture && _resourcePicture !== resourcePicture ){ + SAVE( updateResourcePicture, resourcePicture, _resourcePicture ); + updateResourcePicture( _resourcePicture ); + } + return resourcePicture; + } + this.getArtistID = function(){ + return resourcePicture.artist_id || resourcePicture.artist.id || -1; + } + this.actualW = function(){ return actualW;} + this.actualH = function(){ return actualH;} + this.keepSize = false; + this.resize = function( _x, _y, _w, _h, animate ){ instance.x = x = _x !== undefined ? _x : x; instance.y = y = _y !== undefined ? _y : y; instance.w = w = _w !== undefined ? _w : w; instance.h = h = _h !== undefined ? _h : h; - JQ_WRAPPER[ animate === true ? 'animate' : 'css']( { + JQ_WRAPPER[ animate === true ? 'animate' : 'css' ]( { left: x, top: y, width: w, height: h - }, 250, onAnimeComplete); + }, 250, onAnimeComplete ); animate !== true && onAnimeComplete(); } - function onAnimeComplete(){ - reversibleImage.resize( flipH * w, flipV * h); - } - - function updateUrl( _url){ - if( url === _url) return; - url = _url || url; - var _reversibleImage = pettanr.image.createReversibleImage( url, flipH * w, flipV * h, function( _url, _actualW, _actualH){ - actualW = _actualW; - actualH = _actualH; - }); - if( reversibleImage !== null){ - JQ_WRAPPER.children( reversibleImage.elm).replaceWith( _reversibleImage.elm); - reversibleImage.destroy(); - } else { - JQ_WRAPPER.append( _reversibleImage.elm); - } - reversibleImage = _reversibleImage; + this.animate = function ( _x, _y, _w, _h, _flipH, _flipV ){ + flipH = _flipH !== undefined ? _flipH : flipH; + flipV = _flipV !== undefined ? _flipV : flipV; + instance.resize( _x, _y, _w, _h, true); + } + this.getAsHTML = function( isAbsoluteUrl, isXHTML ){ + return [ + '' : ' \/>' + ].join( ''); + } + this.getAsJsonString = function(){ + var cr = pettanr.LINE_FEED_CODE_TEXTAREA; + return [ + '"new', this.timing, '": {', cr, + '"resource_picture_id": 1,', cr, + '"x": ', x, ',', cr, + '"y": ', y, ',', cr, + '"z": ', this.z, ',', cr, + '"width": ', w, ',', cr, + '"height": ', h, ',', cr, + '"flipv": ', flipV === true ? 1 : 0, ',', cr, + '"fliph": ', flipH === true ? 1 : 0, ',', cr, + '"t": ', this.timing, cr, + '}' + ].join( ''); + } + this.destroy = function(){ + reversibleImage.destroy(); + JQ_WRAPPER.remove(); + JQ_WRAPPER = reversibleImage = resourcePicture = data = instance = SAVE = null; + delete this.destroy; } - return pettanr.util.extend( - new AbstractComicElement( JQ_WRAPPER, COMIC_ELEMENT_TYPE_IMAGE, update, x, y, w, h, z, timing), - { - init: function(){ - instance = this; - updateUrl(); - update(); - delete this.init; - }, - flip: function( _flipH, _flipV){ - if( _flipH !== true && _flipV !== true) return; - flipH = _flipH === true ? -flipH : flipH; - flipV = _flipV === true ? -flipV : flipV; - reversibleImage.resize( flipH * w, flipV * h); - }, - flipV: function(){ - return flipV; - }, - flipH: function(){ - return flipH; - }, - url: function( _url, _actualW, _actualH){ - if( _url && _url !== url){ - SAVE( updateUrl, url, _url); - actualW = _actualW; - actualH = _actualH; - updateUrl( _url); - } - return url; - }, - actualW: function(){ return actualW;}, - actualH: function(){ return actualH;}, - keepSize: false, - resize: update, - animate: function ( _x, _y, _w, _h, _flipH, _flipV){ - flipH = _flipH !== undefined ? _flipH : flipH; - flipV = _flipV !== undefined ? _flipV : flipV; - update( _x, _y, _w, _h, true); - }, - getAsHTML: function( isAbsoluteUrl, isXHTML){ - return [ - '' : ' \/>' - ].join( ''); - }, - getAsJsonString: function(){ - var cr = pettanr.LINE_FEED_CODE_TEXTAREA; - return [ - '"new', this.timing, '": {', cr, - '"resource_picture_id": 1,', cr, - '"x": ', x, ',', cr, - '"y": ', y, ',', cr, - '"z": ', this.z, ',', cr, - '"width": ', w, ',', cr, - '"height": ', h, ',', cr, - '"flipv": ', flipV === true ? 1 : 0, ',', cr, - '"fliph": ', flipH === true ? 1 : 0, ',', cr, - '"t": ', this.timing, cr, - '}' - ].join( ''); - }, - destroy: function(){ - reversibleImage.destroy(); - JQ_WRAPPER.remove(); - JQ_WRAPPER = reversibleImage = OPERATOR = null; - delete this.destroy; - } - } - ); } + ImageElementClass.prototype = new AbstractComicElement( PANEL_ELEMENT_TYPE_IMAGE ); /* * / ImageElementClass * -------------------------------------------------------------------------------------------- @@ -2859,24 +2345,73 @@ pettanr.editor = pettanr.view.createApplication( function(){ * */ var jqTextElementOrigin; - var TextElementClass = function( type, a, text, x, y, z, w, h, timing){ + var TextElementClass = function( data ){ jqTextElementOrigin = jqTextElementOrigin || ( function(){ var _OLD_IE = $( $( '#textElementTempleteForOldIE').remove().html()), _MODERN = $( $( '#textElementTemplete').remove().html()); return pettanr.ua.isIE === true && pettanr.ua.ieRenderingVersion < 8 ? _OLD_IE : _MODERN; })(); - var JQ_WRAPPER = jqTextElementOrigin.clone( true), - XBROWSER_BALLOON = pettanr.balloon.createBalloon( w, h, a, type), + var JQ_WRAPPER = jqTextElementOrigin.clone( true ), TEXT_ELM = JQ_WRAPPER.find( 'td,.speach-inner').eq( 0), - OPERATOR = COMIC_ELEMENT_OPERATION_MANAGER, HIT_AREA = MOUSE_HIT_AREA, - SAVE = HISTORY_CONTROL.saveState, - instance; - - JQ_WRAPPER.find( 'img').eq( 0).replaceWith( XBROWSER_BALLOON.elm); + SAVE = HISTORY_CONTROL.saveState, + type = data.balloon_template_id, + text = ( function(){ + var _speachs = data.speaches_attributes; + for( var k in _speachs ){ + return _speachs[ k ].content || ''; + } + return ''; + }), + balloon = pettanr.balloon.createBalloon( data.width, data.height, data.tail, type ), + x, y, w, h, a, + instance = this; + + JQ_WRAPPER.find( 'img').eq( 0).replaceWith( balloon.elm ); + + function updateType( _type ){ + if( type !== _type ){ + type = _type || type; + balloon.type( type ); + } + } + function updateAngle( _a){ + if( _a !== undefined && a !== _a ){ + a = _a !== undefined ? _a : a; + balloon.angle( a ); + } + } + function updateText( _text){ + text = _text || text || ''; + TEXT_ELM.html( text ); + } - function update( _x, _y, _w, _h, _a, animate){ + /* global methods */ + this.$ = JQ_WRAPPER; + //this.x = x; + //this.y = y; + //this.w = w; + //this.h = h; + this.z = data.z; + this.timing = data.t; + this.init = function(){ + updateText(); + instance.resize( data.x, data.y, data.width, data.height, data.tail ); + delete instance.init; + } + this.angle = function( _a){ + _a !== undefined && instance.resize( undefined, undefined, undefined, undefined, _a); + return a; + } + this.text = function( _text){ + if( _text && text !== _text) { + SAVE( updateText, text || '', _text); + updateText( _text); + } + return text; + } + this.resize = function( _x, _y, _w, _h, _a, animate ){ instance.x = x = _x !== undefined ? _x : x; instance.y = y = _y !== undefined ? _y : y; instance.w = w = _w !== undefined ? _w : w; @@ -2890,117 +2425,77 @@ pettanr.editor = pettanr.view.createApplication( function(){ height: h }, 250, function(){ - XBROWSER_BALLOON.resize( a, w, h); + balloon.resize( a, w, h); } ); - animate !== true && XBROWSER_BALLOON.resize( a, w, h); + animate !== true && balloon.resize( a, w, h); } - - function updateType( _type){ - if( type !== _type){ - type = _type || type; - XBROWSER_BALLOON.type( type); - } + this.animate = function ( _x, _y, _w, _h, _a ){ + instance.resize( _x, _y, _w, _h, _a, true); } - function updateAngle( _a){ - if( _a !== undefined && a !== _a){ - a = _a !== undefined ? _a : a; - XBROWSER_BALLOON.angle( a); - } + this.destroy = function(){ + JQ_WRAPPER.remove(); + balloon.destroy(); + balloon = null; + delete instance.destroy; } - function updateText( _text){ - text = _text || text || ''; - TEXT_ELM.html( text); + this.getAsJSON = function(){ + } - - return pettanr.util.extend( - new AbstractComicElement( JQ_WRAPPER, COMIC_ELEMENT_TYPE_TEXT, update, x, y, w, h, z, timing), - { - init: function(){ - instance = this; - updateText(); - update(); - delete this.init; - }, - angle: function( _a){ - _a !== undefined && update( undefined, undefined, undefined, undefined, _a); - return a; - }, - text: function( _text){ - if( _text && text !== _text) { - SAVE( updateText, text || '', _text); - updateText( _text); - } - return text; - }, - resize: update, - animate: function ( _x, _y, _w, _h, _a){ - update( _x, _y, _w, _h, _a, true); - }, - destroy: function(){ - JQ_WRAPPER.remove(); - XBROWSER_BALLOON.destroy(); - OPERATOR = null; - delete this.destroy; - }, - getAsJSON: function(){ - - }, - getAsJsonString: function(){ - var cr = pettanr.LINE_FEED_CODE_TEXTAREA; - return [ - '"new', this.timing, '": {', cr, - '"balloon_template_id": ', 1, ',', cr, - '"system_picture_id": ', 1, ',', cr, - '"size": ', 1, ',', cr, - '"tail": ', a, ',', cr, + this.getAsJsonString = function(){ + var cr = pettanr.LINE_FEED_CODE_TEXTAREA; + return [ + '"new', this.timing, '": {', cr, + '"balloon_template_id": ', 1, ',', cr, + '"system_picture_id": ', 1, ',', cr, + '"size": ', 1, ',', cr, + '"tail": ', a, ',', cr, + '"x": ', x, ',', cr, + '"y": ', y, ',', cr, + '"z": ', this.z, ',', cr, + '"t": ', this.timing, ',', cr, + '"width": ', w, ',', cr, + '"height": ', h, ',', cr, + '"speaches_attributes": {', cr, + '"newf', this.timing, '": {', cr, + '"content": "', text, '",', cr, '"x": ', x, ',', cr, '"y": ', y, ',', cr, - '"z": ', this.z, ',', cr, - '"t": ', this.timing, ',', cr, + '"t": ', 0, ',', cr, '"width": ', w, ',', cr, - '"height": ', h, ',', cr, - '"speaches_attributes": {', cr, - '"newf', this.timing, '": {', cr, - '"content": "', text, '",', cr, - '"x": ', x, ',', cr, - '"y": ', y, ',', cr, - '"t": ', 0, ',', cr, - '"width": ', w, ',', cr, - '"height": ', h, cr, - '}', cr, - '}', cr, - '}' - ].join( ''); - }, - getAsHTML: function( isAbsoluteUrl, isXHTML){ - var url = XBROWSER_BALLOON.getURL(); - return [ - '' : ' \/>', - pettanr.LINE_FEED_CODE_TEXTAREA, - '
', text, '<\/span>', '<\/div>' - - ].join( ''); - }, - getAsXML: function(){} - } - ); + '"height": ', h, cr, + '}', cr, + '}', cr, + '}' + ].join( ''); + } + this.getAsHTML = function( isAbsoluteUrl, isXHTML){ + var url = balloon.getURL(); + return [ + '' : ' \/>', + pettanr.LINE_FEED_CODE_TEXTAREA, + '
', text, '<\/span>', '<\/div>' + + ].join( ''); + } + this.getAsXML = function(){} } + TextElementClass.prototype = new AbstractComicElement( PANEL_ELEMENT_TYPE_TEXT ); /* -------------------------------------------------------------------------------------------- * COMIC_ELEMENT_CONTROL @@ -3035,53 +2530,52 @@ pettanr.editor = pettanr.view.createApplication( function(){ * 1. remove * 2. renumber z */ - function appendComicElement( _comicElement) { - _comicElement.init && _comicElement.init(); + function appendComicElement( _comicElement ) { var z = _comicElement.z, l = COMIC_ELEMENT_ARRAY.length, _jqElm = _comicElement.$.stop().css( { filter: '', opacity: '' }); - if( typeof z !== 'number' || z < 0 || z >= l){ - COMIC_ELEMENT_ARRAY.unshift( _comicElement); - ELM_CONTAINER.appendChild( _jqElm.get( 0)); + if( typeof z !== 'number' || z < 0 || z >= l ){ + COMIC_ELEMENT_ARRAY.unshift( _comicElement ); + ELM_CONTAINER.appendChild( _jqElm.get( 0 )); _jqElm.fadeIn(); } else { var insertIndex = 0; - for( var i = 0; i < l; ++i){ - if( COMIC_ELEMENT_ARRAY[ i].z <= z){ + for( var i = 0; i < l; ++i ){ + if( COMIC_ELEMENT_ARRAY[ i ].z <= z ){ insertIndex = i; break; } } - COMIC_ELEMENT_ARRAY[ insertIndex].$.before( _jqElm.fadeIn()); - COMIC_ELEMENT_ARRAY.splice( insertIndex, 0, _comicElement); + COMIC_ELEMENT_ARRAY[ insertIndex ].$.before( _jqElm.fadeIn() ); + COMIC_ELEMENT_ARRAY.splice( insertIndex, 0, _comicElement ); } renumber(); } - function removeComicElement( _comicElement) { + function removeComicElement( _comicElement ) { var l = COMIC_ELEMENT_ARRAY.length; for( var i=0; i