From 8535b69e52430dc9c985c7acfb35254d8a33029e Mon Sep 17 00:00:00 2001 From: itozyun Date: Sun, 15 Apr 2012 17:34:17 +0900 Subject: [PATCH 01/16] client is version0.4.20, added to boot image-exproler from artist-folder. --- app/views/layouts/application.html.erb | 160 ++++++++++++++------------- public/assets/common.js | 20 ++-- public/assets/system.js | 190 +++++++++++++++++++++------------ 3 files changed, 209 insertions(+), 161 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7739008f..0b1abb63 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -28,11 +28,11 @@
<%= yield %>

クイックアクセス

-

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

+

新しいコマを描く(開発用)

新しいコミックをつくる

画像のアップロード

コマの追加(開発用)

-

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

+

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

座長からのお知らせ

メンテナンスについて

@@ -196,7 +196,6 @@ @@ -287,101 +286,100 @@ + + +
+ +
- - - - - + +
+ +
OK
+
- - + +
+
+
Group Name
+
cancel
+
- -
-
Register Artist
-
-
-
-
register
-
cancel
-
-
 
+ +
+
Register Artist
+
+
+
+
register
+
cancel
+
 
+
- -
-
Create New Panel (dev)
-
-
-
-
post
-
cancel
-
-
 
+ +
+
Create New Panel (dev)
+
+
+
+
post
+
cancel
+
 
+
- -
-
Upload Picture
-
-
-
-
upload
-
cancel
-
-
 
+ +
+
Upload Picture
+
+
+
+
upload
+
cancel
+
 
+
- -
-
Create New Comic
-
-
- Title: - No Title -
-
- Default Width: - 300 -
-
- Default Height: - 200 -
-
- Visible: - 1 -
-
- Editable: - 1 -
-
-
post(update)
-
cancel
-
-
 
+ +
+
Create New Comic
+
+
+ Title: + No Title
+
+ Default Width: + 300 +
+
+ Default Height: + 200 +
+
+ Visible: + 1 +
+
+ Editable: + 1 +
+
+
post(update)
+
cancel
+
+
 
- -
x
-
+ -
-
-
Group Name
-
close
+
+
+
Group Name
+
close
diff --git a/public/assets/common.js b/public/assets/common.js index 3ce68ba4..1d6a8b5e 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1,6 +1,6 @@ /* * pettanR common.js - * version 0.4.22 + * version 0.4.23 * * author: itozyun */ diff --git a/public/assets/system.js b/public/assets/system.js index fea9d406..9ffc7886 100644 --- a/public/assets/system.js +++ b/public/assets/system.js @@ -1,6 +1,6 @@ /* * pettanR system.js - * version 0.4.22 + * version 0.4.23 * * author: * itozyun @@ -46,6 +46,8 @@ pettanr.file = ( function(){ var REQUEST_CONTROLER = ( function(){ var REQUEST_TICKET_RESISTER = [], + currentTicket = null, + currentData = null, DATA_TYPE_ARRAY = 'json,xml,html,text'.split( ','), DATA_IS_JSON = 0, DATA_IS_XML = 1, @@ -63,21 +65,34 @@ pettanr.file = ( function(){ }; function request(){ - if( REQUEST_TICKET_RESISTER.length === 0) return; - var _ticket = REQUEST_TICKET_RESISTER.shift(); + if( currentTicket !== null ) return; + currentTicket = REQUEST_TICKET_RESISTER.shift(); $.ajax({ - url: _ticket.url, - dataType: _ticket.type, - success: function( _data){ - _ticket.onLoad( _ticket.data, _data); - }, - error: function(){ - ++numError; - _ticket.onError( _ticket.data); - } + url: currentTicket.url, + dataType: currentTicket.type, + success: onSuccess, + error: onError }); } + function onSuccess( _data ){ + currentData = _data; + window.setTimeout( asyncSuccess, 0 ); + } + function asyncSuccess(){ + currentTicket.onLoad( currentTicket.data, currentData ); + currentTicket = currentData = null; + REQUEST_TICKET_RESISTER.length !== 0 && window.setTimeout( request, 0 ); + } + function onError(){ + ++numError; + window.setTimeout( asyncError, 0 ); + } + function asyncError(){ + currentTicket.onError( currentTicket.data ); + currentTicket = null; + REQUEST_TICKET_RESISTER.length !== 0 && window.setTimeout( request, 0 ); + } return { getNumTask: function(){ return REQUEST_TICKET_RESISTER.length; @@ -85,9 +100,9 @@ pettanr.file = ( function(){ getNumError: function(){ return numError; }, - getJson: function( _data, _url, _onLoad, _onError){ + getJson: function( _data, _url, _onLoad, _onError ){ REQUEST_TICKET_RESISTER.push( new RequestTicketClass( DATA_IS_JSON, _data, _url, _onLoad, _onError)); - request(); + currentTicket === null && request(); } } })(); @@ -166,11 +181,11 @@ pettanr.file = ( function(){ replace: function( _uid, _file, _newIndex){ }, - addEventListener: function( FILEorNULL, _eventType, _callback){ + addEventListener: function( FILEorNULL, _eventType, _callback ){ var _uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL; EVENT_LISTENER_REGISTER.push( new FileEventTicketClass( _uid, _eventType, _callback)); }, - removeEventListener: function( FILEorNULL, _eventType, _callback){ + removeEventListener: function( FILEorNULL, _eventType, _callback ){ var _uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL, _ticket; for(var i=0, l = EVENT_LISTENER_REGISTER.length; i 0 ){ + _stack.shift(); + } + if( STACK_LIST.length !== 0 ){ + window.setTimeout( dispatch, 0 ); + } + } + return { + addEvent: function( _callback, _eventType, _targetFile, _key, _value ){ + if( STACK_LIST.length === 0 ){ + window.setTimeout( dispatch, 0 ); + } + STACK_LIST.push( [ _callback, _eventType, _targetFile, _key, _value ] ); + } + } + })(); + var TreeClass = function( rootFileData ){ var PARENT_FILE_RESITER = [], ACCESS = { @@ -222,15 +261,15 @@ pettanr.file = ( function(){ _targetFile = e.targetFile, _uid = _targetFile.getUID(), _ticket, _type, _callback; - for(var i=0, l = EVENT_LISTENER_REGISTER.length; i LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext ].join( '') : null, @@ -1758,7 +1802,7 @@ pettanr.premiumSatge = pettanr.view.registerApplication( function(){ imgW, imgH; elmContainer.appendChild( elmIconWrap ); elmIconWrap.style.left = ( INDEX * itemW ) + 'px'; - elmIconTitle.appendChild( document.createTextNode( data.filesize + 'bytes' )); + elmIconTitle.appendChild( document.createTextNode( data.filesize + 'bytes' ) ); function onImageLoad( url, _imgW, _imgH ){ if( reversibleImage === null) { @@ -1783,32 +1827,14 @@ pettanr.premiumSatge = pettanr.view.registerApplication( function(){ 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; - }*/ + window[ _g_onUpdateFunction ]( data ); + window[ _g_onUpdateFunction ] = null; } pettanr.premiumSatge.shutdown(); } this.onEnter = function(){ - if( onEnterFlag === true ) return; + if( onEnterFlag === true || data === null ) return; // data === null : destroyed reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onImageLoad ); elmIconWrap.appendChild( reversibleImage.elm ); onEnterFlag = true; @@ -1828,7 +1854,7 @@ pettanr.premiumSatge = pettanr.view.registerApplication( function(){ _start = -wrapX /itemW -1, _end = _start + winW /itemW +1; for( var i=0; i 0 ){ + ICON_ARRAY.shift().destroy(); + } + + var _index = ARTIST_ROOT_FILE.search( { + id: artistID, + type: pettanr.driver.FILE_TYPE.ARTIST + })[ 0 ], + _artistFile = ARTIST_ROOT_FILE.getChildFileByIndex( _index ); + if( _artistFile !== null ){ + for(var i=0, l=_artistFile.getChildFileLength(); i containerH ? containerH : _windowH, MATH_FLOOR = Math.floor; - onEnterShowImage(); - jqContainer.css( { width: w, height: 0, @@ -1915,7 +1949,7 @@ pettanr.premiumSatge = pettanr.view.registerApplication( function(){ }).stop().animate( { height: h, top: MATH_FLOOR( _windowH /2 -h /2) - }); + }, onEnterShowImage ); elmButton.style.cssText = [ 'left:', MATH_FLOOR( winW /2 - buttonW /2), 'px;', diff --git a/public/assets/work.js b/public/assets/work.js index 733d313f..7239a90b 100644 --- a/public/assets/work.js +++ b/public/assets/work.js @@ -1,6 +1,6 @@ /* * pettanR work.js - * version 0.4.22 + * version 0.4.23 * * author: * itozyun -- 2.11.0 From 595800ecf7ccc10fae9da340324cc7bbfabd1244 Mon Sep 17 00:00:00 2001 From: itozyun Date: Fri, 20 Apr 2012 09:12:00 +0900 Subject: [PATCH 07/16] fixed css for finder-icon. --- app/assets/stylesheets/work.css | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/work.css b/app/assets/stylesheets/work.css index 5a8e9eb7..994a598b 100644 --- a/app/assets/stylesheets/work.css +++ b/app/assets/stylesheets/work.css @@ -1164,6 +1164,7 @@ width: 100%; border-bottom: 1px solid #ccc; clear: both; + overflow: hidden; /* for webkit */ } .finder-icon a, .finder-icon a:link, @@ -1184,10 +1185,9 @@ display: table-cell; vertical-align: middle; height: 74px; - *height: 64px; line-height: 1.3em; } - /* IE 6 */ + /* IE 6,7 */ .finder-icon-handle, .finder-icon-thumbnail, .finder-icon-filename, @@ -1252,7 +1252,8 @@ */ .finder-icon-filename { width: 200px; - padding: 5px; + padding: 5px 10px; + height: 64px; font-weight: bold; color: #333; } @@ -1261,7 +1262,8 @@ } .finder-icon-summary { width: 300px; - padding: 5px; + padding: 5px 10px; + height: 64px; color: #666; } .finder-icon-console { -- 2.11.0 From 96e7122d3293889e912c18b7426d6a3402065d16 Mon Sep 17 00:00:00 2001 From: itozyun Date: Sat, 21 Apr 2012 16:11:52 +0900 Subject: [PATCH 08/16] client is varsion0.4.24, fixed finder icon for ie7-. --- app/assets/stylesheets/common.css | 27 ++-- app/assets/stylesheets/work.css | 222 ++++++++++++++++++--------------- app/views/layouts/application.html.erb | 44 +++++-- public/assets/common.js | 6 +- public/assets/system.js | 60 ++++----- public/assets/work.js | 2 +- 6 files changed, 203 insertions(+), 158 deletions(-) diff --git a/app/assets/stylesheets/common.css b/app/assets/stylesheets/common.css index 5b12c930..98747d33 100644 --- a/app/assets/stylesheets/common.css +++ b/app/assets/stylesheets/common.css @@ -3,7 +3,7 @@ * * common.css * - * version 0.4.1 + * version 0.4.23 * */ @@ -17,13 +17,6 @@ /* Reset --------------------------------------------------------------------------------------*/ - html, body { - margin: 0; - padding: 0; - } - -/* Reset ---------------------------------------------------------------------------------------*/ /* Copyright (c) 2009, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: @@ -73,7 +66,8 @@ version: 2.7.0 /* http://e2designer.seesaa.net/article/152168876.html */ /* http://perishablepress.com/press/2010/06/01/wrapping-content/ */ - pre { + pre, + .break-word { white-space: pre; /* CSS 2.0 */ white-space: pre-wrap; /* CSS 2.1 */ white-space: pre-line; /* CSS 3.0 */ @@ -240,12 +234,12 @@ version: 2.7.0 /* Loading --------------------------------------------------------------------------------------*/ .loading { - background-image: url( loading.gif); + background-image: url(loading.gif); background-position: 50% 50%; background-repeat: no-repeat; } .error { - background-image: url( error.png); + background-image: url(error.png); background-position: 50% 50%; background-repeat: no-repeat; } @@ -265,7 +259,7 @@ version: 2.7.0 } #outer-wrapper { - padding-bottom: 200px;/* フッターの高さと同じ値にする */ + padding-bottom: 210px;/* フッターの高さと同じ値にする */ } #footer-content { @@ -357,6 +351,15 @@ version: 2.7.0 margin: 0 auto; } +/* breadcrumb +--------------------------------------------------------------------------------------*/ + #breadcrumb { + font-size: 12px; + color: #666; + margin: 0 0 10px 20px; + line-height: 1.2em; + text-align: right; + } /* main --------------------------------------------------------------------------------------*/ #main { diff --git a/app/assets/stylesheets/work.css b/app/assets/stylesheets/work.css index 994a598b..6806079c 100644 --- a/app/assets/stylesheets/work.css +++ b/app/assets/stylesheets/work.css @@ -3,7 +3,7 @@ * * work.css * - * version 0.4.1 + * version 0.4.23 * */ html, body { @@ -1157,129 +1157,151 @@ /* Finder Icon --------------------------------------------------------------------------------------*/ .finder-icon { - position: absolute; - top: 0; - left: 0; + position: relative; height: 74px; - width: 100%; border-bottom: 1px solid #ccc; clear: both; overflow: hidden; /* for webkit */ } - .finder-icon a, - .finder-icon a:link, - .finder-icon a:visited, - .finder-icon a:active { - display: block; + .finder-icon:hover { + background-color: #eee; + cursor: pointer; + } + .fnder-icon-modern .finder-icon-handle, + .fnder-icon-modern .finder-icon-thumbnail, + .fnder-icon-modern .finder-icon-filename, + .fnder-icon-modern .finder-icon-summary { + display: table-cell; + vertical-align: middle; + line-height: 1.3em; + } + + .finder-icon-handle { + width: 20px; + height: 74px; + } + + .finder-icon-thumbnail { + width: 64px; height: 74px; - text-decoration: none; - *background: #fff; + cursor: pointer; + background-repeat: no-repeat; + background-position: 50% 50%; + background-image: url('sprite.gif'); } - .finder-icon a:hover { - background-color: #eee; + + .finder-icon .file-type-folder { + background-position: 0 -75px; } - .finder-icon-handle, - .finder-icon-thumbnail, - .finder-icon-filename, - .finder-icon-summary { - display: table-cell; - vertical-align: middle; - height: 74px; - line-height: 1.3em; - } - /* IE 6,7 */ - .finder-icon-handle, - .finder-icon-thumbnail, - .finder-icon-filename, - .finder-icon-summary { - *display: inline; - zoom: 1; - } - /*\*//*/ - * html .finder-icon span { - display: inline-block; - } - /**/ - - .finder-icon-handle { - width: 20px; - } - - .finder-icon-thumbnail { - width: 64px; - cursor: pointer; - background-repeat: no-repeat; - background-position: 50% 50%; - } - .finder-icon-thumbnail { - background-image: url('sprite.gif'); + .finder-icon .file-type-album { + } + .finder-icon .file-type-author { + background-position: -70px -75px; + } + .finder-icon .file-type-comic { + background-position: 0 -145px; + } + .finder-icon .file-type-cabinet { + background-position: -70px -145px; + } + .finder-icon .file-type-panel { + background-position: 0 -215px; + } + .finder-icon .file-type-artist { + background-position: -70px -215px; + } + .finder-icon .file-type-balloon { + background-position: 0 -285px; + } + .finder-icon .file-type-charactor { + background-position: -70px -285px; + } + .has-thumbnail { + } + .fnder-icon-modern .finder-icon-filename { + width: 200px; + padding: 5px 10px; + height: 64px; + font-weight: bold; + color: #333; + } + .fnder-icon-modern .finder-icon-summary { + width: 300px; + padding: 5px 10px; + height: 64px; + color: #666; + } + + /* Finder Icon ie7- + --------------------------------------------------------------------------------------*/ + .finder-icon a, + .finder-icon a:link, + .finder-icon a:visited, + .finder-icon a:active { + display: block; + height: 74px; + text-decoration: none; + zoom: 1; + cursor: pointer; + } + .finder-icon a:hover { + _background-color: #eee; + color: #333; + } + .fnder-icon-ie7 .finder-icon-handle, + .fnder-icon-ie7 .finder-icon-thumbnail { + zoom: 1; + line-height: 1.3em; + } + .finder-icon-cell { + display: inline; + zoom: 1; + } + .finder-icon-vertical-middle-outer { + display: block; + height: 74px; + position: relative; } - - .finder-icon .file-type-folder { - background-position: 0 -75px; - } - .finder-icon .file-type-album { - } - .finder-icon .file-type-author { - background-position: -70px -75px; - } - .finder-icon .file-type-comic { - background-position: 0 -145px; - } - .finder-icon .file-type-cabinet { - background-position: -70px -145px; - } - .finder-icon .file-type-panel { - background-position: 0 -215px; - } - .finder-icon .file-type-artist { - background-position: -70px -215px; - } - .finder-icon .file-type-balloon { - background-position: 0 -285px; - } - .finder-icon .file-type-charactor { - background-position: -70px -285px; - } - .has-thumbnail { - } - /* - * http://www.iconfinder.com/icondetails/18336/64/folder_image_photo_icon - * http://www.iconfinder.com/icondetails/27849/48/folder_yellow_icon - * http://www.iconfinder.com/icondetails/45347/64/cabinet_icon - * http://www.iconfinder.com/icondetails/3659/64/broken_file_icon - * http://www.iconfinder.com/icondetails/44733/64/address_book_icon - */ - .finder-icon-filename { + .finder-icon-ie-filename .finder-icon-vertical-middle-outer { width: 200px; - padding: 5px 10px; - height: 64px; font-weight: bold; color: #333; } - a:hover .finder-icon-filename { - color: #000; - } - .finder-icon-summary { + .finder-icon-ie-summary .finder-icon-vertical-middle-outer { width: 300px; - padding: 5px 10px; - height: 64px; color: #666; } + .finder-icon-vertical-middle-inner { + display: block; + position: absolute; + top: 50%; + margin: 0 5px; + } + .fnder-icon-ie7 .finder-icon-filename, + .fnder-icon-ie7 .finder-icon-summary { + position: relative; + top: -50%; + } + + /* Finder Icon Console + --------------------------------------------------------------------------------------*/ .finder-icon-console { position: absolute; top: 0; right: 0; } - .finder-icon-console div { + .finder-icon-console a { + display: block; width: 74px; height: 74px; border-left: 1px solid #ccc; float: right; - cursor: pointer; - background-image: url('sprite.gif'); + background-image: url('sprite.gif') !important; background-repeat: no-repeat; } + .finder-icon-console a:hover { + background-color: #ccc !important; + } .finder-icon-console-action { background-position: 0px -355px; } @@ -1288,4 +1310,8 @@ } .finder-icon-console-viewer-apps { background-position: 0px -425px; - } \ No newline at end of file + } + + + + \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c9ef40a9..bcd54aeb 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -303,7 +303,7 @@
-
Group Name
+
NO DATA...
close
@@ -399,15 +399,41 @@
-
-
-
-
file name
-
file descriptiion
+
+ + + file name + file descriptiion
-
-
-
+ + + +
+
+ + diff --git a/public/assets/common.js b/public/assets/common.js index 1d6a8b5e..779050c0 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1,6 +1,6 @@ /* * pettanR common.js - * version 0.4.23 + * version 0.4.24 * * author: itozyun */ @@ -221,7 +221,7 @@ pettanr.util = ( function(){ } var i, l, _children = _elm.childNodes, _array = []; if( _children && typeof _children.length === 'number'){ - // liveNode > array + // liveNode > array for( i=0, l=_children.length; i tag:ペン次郎 > ペン次郎:笑う @@ -814,7 +800,11 @@ pettanr.file = ( function(){ pettanr.finder = ( function(){ var FINDER_ARRAY = [], ELM_ORIGIN_FINDER_LOCATION_ITEM = pettanr.util.pullHtmlAsTemplete( 'templete-finder-location-item'), - ELM_ORIGIN_FINDER_ICON = pettanr.util.pullHtmlAsTemplete( 'templete-finder-icon'), + ELM_ORIGIN_FINDER_ICON = ( function(){ + var forIE = pettanr.util.pullHtmlAsTemplete( 'templete-finder-icon-ie'), + modern = pettanr.util.pullHtmlAsTemplete( 'templete-finder-icon'); + return pettanr.ua.isIE === true && pettanr.ua.ieVersion < 8 ? forIE : modern; + })(), ELM_ORIGIN_CONTAINER = pettanr.util.pullHtmlAsTemplete( 'templete-finder-container'), ICON_HEIGHT = pettanr.util.getElementSize( ELM_ORIGIN_FINDER_ICON).height, ICON_CLASSNAME = 'finder-icon-thumbnail', @@ -833,14 +823,6 @@ pettanr.finder = ( function(){ file, w, index, style, instansce, onDownCallback, onEditorCallback, onViewerCallback, onActionCallback, viewerList, editorList; - ELM_WRAPPER.onmouseover = onOver; - function onOver(){ - ELM_WRAPPER.style.backgroundColor = '#eee'; - } - ELM_WRAPPER.onmouseout = onOut; - function onOut(){ - ELM_WRAPPER.style.backgroundColor = ''; - } ELM_WRAPPER.onclick = onDownClick; function onDownClick(){ @@ -886,7 +868,7 @@ pettanr.finder = ( function(){ }; } function resize(){ - ELM_WRAPPER.style.top = (index * ICON_HEIGHT) +'px'; + // ELM_WRAPPER.style.top = (index * ICON_HEIGHT) +'px'; } function onCollect(){ elmContainer.removeChild( ELM_WRAPPER ); @@ -1614,18 +1596,21 @@ pettanr.driver = ( function(){ })(); pettanr.entrance = pettanr.view.registerApplication( function(){ + var wrap = document.getElementById('inner-wrapper'), + pageHeaderH = pettanr.util.getElementSize( document.getElementById( 'header' ) ).height, + instance = this; this.displayName = 'Home'; this.ID = 'Home'; this.rootElement = document.getElementById('entrance'); this.onOpen = function( _w, _h, _option ){ - var pageHeaderH = pettanr.util.getElementSize( document.getElementById( 'header' ) ).height; - document.getElementById('inner-wrapper').style.height = ( _h - pageHeaderH ) + 'px'; + wrap.style.display = ''; + wrap.style.height = ( _h - pageHeaderH ) + 'px'; } this.onClose = function(){ - document.getElementById('inner-wrapper').style.height = '0px'; + wrap.style.display = 'none'; } this.onPaneResize = function( _w, _h){ - this.onOpen( _w, _h ); + instance.onOpen( _w, _h ); } }); pettanr.entrance.addToLancher(); @@ -1724,18 +1709,23 @@ if( pettanr.DEBUG === true){ elmDl.appendChild( elmDt); elmDl.appendChild( elmDd); } + + var wrap = document.getElementById('inner-wrapper'), + pageHeaderH = pettanr.util.getElementSize( document.getElementById( 'header' )).height, + instance = this; + this.displayName = 'Debug'; this.ID = 'debug'; this.rootElement = document.getElementById( 'debug' ); this.onOpen = function( _w, _h, _option ){ - var pageHeaderH = pettanr.util.getElementSize( document.getElementById( 'header' )).height; - document.getElementById( 'inner-wrapper' ).style.height = ( _h - pageHeaderH ) + 'px'; + wrap.style.display = ''; + wrap.style.height = ( _h - pageHeaderH ) + 'px'; } this.onClose = function(){ - document.getElementById( 'inner-wrapper' ).style.height = '0px'; + wrap.style.display = 'none'; } this.onPaneResize = function( _w, _h ){ - pettanr.debug.onOpen( _w, _h ); + instance.onOpen( _w, _h ); } }); pettanr.debug.addToLancher(); @@ -1814,8 +1804,8 @@ pettanr.premiumSatge = pettanr.view.registerApplication( function(){ elmIconTitle.firstChild.data = imgW + 'x' + imgH; var zoom = 128 /( imgW > imgH ? imgW : imgH), MATH_FLOOR = Math.floor - h = MATH_FLOOR( imgH *zoom ), - w = MATH_FLOOR( imgW *zoom ); + h = MATH_FLOOR( imgH *zoom ), + w = MATH_FLOOR( imgW *zoom ); reversibleImage.elm.style.cssText = [ 'width:', w, 'px;', 'height:', h +'px;', diff --git a/public/assets/work.js b/public/assets/work.js index 7239a90b..69d44699 100644 --- a/public/assets/work.js +++ b/public/assets/work.js @@ -1,6 +1,6 @@ /* * pettanR work.js - * version 0.4.23 + * version 0.4.24 * * author: * itozyun -- 2.11.0 From 602af7ce1047b7c3248365c70ce79855ba316b17 Mon Sep 17 00:00:00 2001 From: itozyun Date: Mon, 23 Apr 2012 05:23:11 +0900 Subject: [PATCH 09/16] client is version0.4.25, added combobox to pettanr.form. --- app/assets/stylesheets/common.css | 5 +- app/assets/stylesheets/work.css | 105 ++++++- app/views/layouts/application.html.erb | 6 +- public/assets/common.js | 521 ++++++++++++++++++++++++++------- public/assets/system.js | 3 +- public/assets/work.js | 61 ++-- 6 files changed, 559 insertions(+), 142 deletions(-) diff --git a/app/assets/stylesheets/common.css b/app/assets/stylesheets/common.css index 98747d33..2c05cd72 100644 --- a/app/assets/stylesheets/common.css +++ b/app/assets/stylesheets/common.css @@ -230,6 +230,9 @@ version: 2.7.0 -moz-border-radius: 3px; -webkit-border-radius: 3px; } + .button-has-focus { + border-color: #4D90FE; + } /* Loading --------------------------------------------------------------------------------------*/ @@ -259,7 +262,7 @@ version: 2.7.0 } #outer-wrapper { - padding-bottom: 210px;/* フッターの高さと同じ値にする */ + padding-bottom: 200px;/* フッターの高さと同じ値にする */ } #footer-content { diff --git a/app/assets/stylesheets/work.css b/app/assets/stylesheets/work.css index 6806079c..0b32939b 100644 --- a/app/assets/stylesheets/work.css +++ b/app/assets/stylesheets/work.css @@ -23,6 +23,8 @@ } + + /*-------------------------------------------------------------------------------------- * * overlay @@ -166,8 +168,11 @@ #comic-console-title-value { width: 180px; text-align:left;} #comic-console-height-value {} #comic-console-width-value {} - #comic-console-editable-value {} - #comic-console-visible-value {} + #comic-console-editable-value, + #comic-console-visible-value { + width: 180px; + text-align: center; + } #comic-console-button-container { margin-top: 20px; @@ -866,6 +871,7 @@ color: #333; text-decoration: none; display: block; + zoom: 1; outline: 0; background-color: #fff; } @@ -881,7 +887,100 @@ margin: 0; outline: 0; } - + + /* combobox + --------------------------------------------------------------------------------------*/ + .combobox { + display: inline-block; + color: #333; + } + .combobox a, + .combobox a:link, + .combobox a:visited, + .combobox a:hover, + .combobox a:active { + border: 1px solid #ccc; + font-size: 14px; + line-height: 16px; + padding: 3px; + color: #333; + text-decoration: none; + display: block; + zoom: 1; + outline: 0; + background-color: #fff; + position: relative; + } + .combobox a:hover { + background-color: #ccf; + } + .combobox a:active { + outline: 0; + } + .combobox-toggle { + position: absolute; + right: 5px; + top: 0; + display: block; + font-family: Arial,Helvetica,sans-serif; + font-size: 12px; + line-height: 20px; + color: #999; + } + .combobox a.combobox-has-focus .combobox-toggle { + color: #4D90FE; + } + + + .option-container { + position: absolute; + list-style: none; + top: 30px; + width: 200px; + margin: 0; + padding: 0; + background-color: #fff; + opacity: 0.9; + -moz-opacity: 0.9; + -khtml-opacity: 0.9; + color: #666; + border: 1px solid #ccc; + box-shadow: 1px 4px 9px #333; + -moz-box-shadow: 1px 4px 9px #333; + -webkit-box-shadow: 1px 4px 9px #333; + filter: alpha(opacity=90) progid:DXImageTransform.Microsoft.Shadow(color=#666666,direction=120,strength=9); + -ms-filter: alpha(opacity=90) progid:DXImageTransform.Microsoft.Shadow(color=#666666,direction=120,strength=9); + } + .option-container li { + display: block; + cursor: pointer; + height: 30px; + line-height: 30px; + } + .option-container a, + .option-container a:link, + .option-container a:visited { + color: #666; + position: relative; + display: block; + padding: 0 10px; + height: 30px; + line-height: 30px; + *cursor: pointer; + } + .current-option a, + .current-option a:link, + .current-option a:visited { + color: #e6e6ef; + background-color: #66f; + text-decoration: none; + } + .option-container a:hover { + color: #333; + background-color: #ccf; + text-decoration: none; + *cursor: pointer; + } /* Information Window --------------------------------------------------------------------------------------*/ diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index bcd54aeb..939ec7ec 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -364,14 +364,14 @@
Visible: - 1 +
Editable: - 1 +
-
post(update)
+
create
cancel
 
diff --git a/public/assets/common.js b/public/assets/common.js index 779050c0..0007b340 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1,12 +1,12 @@ /* * pettanR common.js - * version 0.4.24 + * version 0.4.25 * * author: itozyun */ /* - * http://pettanr.sourceforge.jp/test/type.html + * http://pettanr.sourceforge.jp/test/type.html */ var Type = { isObject : function(v) { @@ -1202,7 +1202,7 @@ pettanr.key = ( function(){ overlayEnabled = pettanr.overlay.visible === true, currentViewID = overlayEnabled === true ? pettanr.overlay.currentID : pettanr.view.currentID; if( callback === 'keypress') callback = 'keydown'; - if( pettanr.form.keyEventRellay( e) === false){ + if( pettanr.form.keyEventRellay( e ) === false){ var shift = e.shiftKey, ctrl = e.ctrlKey, l = KEYEVENT_ARRAY.length, @@ -1257,12 +1257,12 @@ pettanr.key = ( function(){ jqWindow = pettanr.jqWindow().focus(); keyOperationChatcher = pettanr.jqDocument() - .keydown( keyHit) - .keyup( keyHit) + .keydown( keyHit ) + .keyup( keyHit ) .mouseenter( function(){ jqWindow.focus(); }); - keyPress && keyOperationChatcher.keypress( keyPress); + keyPress && keyOperationChatcher.keypress( keyPress ); delete pettanr.key.init; }, @@ -1311,6 +1311,7 @@ pettanr.form = ( function(){ var FORM_GROUP_TABLE = {}, currentID = null, currentItem = null, + CLASSNAME_COMBOBOX_OPTION = 'combobox-option', ELM_A_ORIGIN = ( function(){ var ret = document.createElement( 'a'); ret.href = '#'; @@ -1320,21 +1321,34 @@ pettanr.form = ( function(){ var ret = document.createElement( 'input'); ret.type = 'text'; return ret; - })(); + })(), + ELM_COMBOBOX = ( function(){ + var ret = document.createElement( 'a'), + elmToggle = document.createElement( 'span' ), + elmValue = document.createElement( 'span' ); + ret.href = '#'; + ret.appendChild( elmToggle ); + ret.appendChild( elmValue ); + elmToggle.className = 'combobox-toggle'; + elmValue.className = 'combobox-value'; + + elmToggle.appendChild( document.createTextNode( '▼' )); + elmValue.appendChild( document.createTextNode( 'null' )); + return ret; + })() - var InputTextClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater){ - validater = typeof validater === 'function' ? validater : null; + var InputTextClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater ){ + validater = Type.isFunction( validater ) === true ? validater : null; var elmValue = pettanr.util.getElementsByClassName( WRAPPER_ELM, 'editable-value' )[ 0], value, - index = GROUP_ID ? FORM_GROUP_TABLE[ GROUP_ID].length : -1, - instance, + instance = this, focus = false, visible = true, enabled = true, elmA = ELM_A_ORIGIN.cloneNode( true ); - if( elmValue === undefined){ + if( elmValue === undefined ){ alert( 'error!'); } value = elmValue.innerHTML; @@ -1343,79 +1357,115 @@ pettanr.form = ( function(){ try { elmA.innerHTML = value; } catch(e){ - alert( value + elmA) + alert( value ) } elmValue.appendChild( elmA ); WRAPPER_ELM.onclick = onClick; - function onClick( e){ + function onClick(){ focus = true; - start( instance); + start( instance ); elmA.style.display = 'none'; - elmValue.appendChild( ELM_INPUT_TEXT); + elmValue.appendChild( ELM_INPUT_TEXT ); ELM_INPUT_TEXT.value = value; ELM_INPUT_TEXT.focus(); ELM_INPUT_TEXT.select(); - e && e.preventDefault(); return false; } - return { - init: function(){ - instance = this; - delete this.init; - }, - value: function( _value){ - if( _value !== undefined){ - elmA.innerHTML = _value; - value = _value; - - if( focus === true){ - ELM_INPUT_TEXT.value = value; - } - } - currentItem === instance && this.finish(); - return value; - }, - start: function(){ - onClick(); - }, - finish: function( keep){ - var _newValue = ELM_INPUT_TEXT.value, - _validated = validater !== null ? '' + validater( _newValue) : _newValue; - _newValue = keep !== true ? _validated : value; - - elmValue.removeChild( ELM_INPUT_TEXT); - - elmA.innerHTML = _newValue; - elmA.style.display = 'block'; + this.value = function( _value ){ + if( _value !== undefined){ + elmA.innerHTML = _value; + value = _value; - ON_UPDATE_FUNCTION && _newValue !== value && ON_UPDATE_FUNCTION( _newValue, value); - finish( instance); - value = _newValue; - focus = false; - }, - enabled: function(){ - return enabled; - }, - visible: function( _visible){ - if( _visible === true){ - WRAPPER_ELM.style.display = ''; - visible = true; - } else - if( _visible === false){ - WRAPPER_ELM.style.display = 'none'; - visible = false; + if( focus === true){ + ELM_INPUT_TEXT.value = value; } - return visible; - }, - index : index, - groupID: GROUP_ID + } + currentItem === instance && instance.blur(); + return value; + } + this.focus = function(){ + onClick(); + } + this.blur = function( keep ){ + var _newValue = ELM_INPUT_TEXT.value, + _validated = validater !== null ? '' + validater( _newValue ) : _newValue; + _newValue = keep !== 27 ? _validated : value; // 27:ESC + + elmValue.removeChild( ELM_INPUT_TEXT ); + + elmA.innerHTML = _newValue; + elmA.style.display = 'block'; + + ON_UPDATE_FUNCTION && _newValue !== value && ON_UPDATE_FUNCTION( _newValue, value ); + + value = _newValue; + focus = false; + + currentItem = null; + } + this.enabled = function(){ + return enabled; } + this.visible = function( _visible ){ + if( _visible === true){ + WRAPPER_ELM.style.display = ''; + visible = true; + } else + if( _visible === false){ + WRAPPER_ELM.style.display = 'none'; + visible = false; + } + return visible; + } + this.groupID = GROUP_ID; + } + + var ButtonClass = function( WRAPPER_ELM, ON_CLICK_FUNCTION, GROUP_ID ){ + var className = WRAPPER_ELM.className || '', + instance = this, + focus = false, + visible = true, + enabled = true; + + WRAPPER_ELM.onclick = onClick; + + function onClick(){ + focus = true; + ON_CLICK_FUNCTION(); + return false; + } + this.focus = function(){ + focus = true; + WRAPPER_ELM.className = className + ' button-has-focus'; + start( instance ); + } + this.blur = function( keyCode ){ + keyCode === 13 && ON_CLICK_FUNCTION(); + WRAPPER_ELM.className = className; + focus = false; + finish( instance ); + } + this.enabled = function(){ + return enabled; + } + this.visible = function( _visible ){ + if( _visible === true){ + WRAPPER_ELM.style.display = ''; + visible = true; + } else + if( _visible === false){ + WRAPPER_ELM.style.display = 'none'; + visible = false; + } + return visible; + } + this.groupID = GROUP_ID; } - var FileInputClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater, elmFileInput){ + var FileInputClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater, elmFileInput ){ validater = typeof validater === 'function' ? validater : null; var elmFilePath = pettanr.util.getElementsByClassName( WRAPPER_ELM, 'file-path')[ 0], @@ -1434,7 +1484,7 @@ pettanr.form = ( function(){ function onClick( e){ focus = true; - start( instance); + start( instance ); elmFileInput.click(); return false; } @@ -1447,10 +1497,10 @@ pettanr.form = ( function(){ instance = this; delete this.init; }, - start: function(){ + focus: function(){ onClick(); }, - finish: function( keep){ + blur: function( keep ){ focus = false; }, enabled: function(){ @@ -1472,30 +1522,257 @@ pettanr.form = ( function(){ } } + var ComboBoxClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID ){ + var elmBox = pettanr.util.getElementsByClassName( WRAPPER_ELM, 'combobox' )[ 0 ], + elmA = ELM_COMBOBOX.cloneNode( true ), + elmToggle = pettanr.util.getElementsByClassName( elmA, 'combobox-toggle' )[ 0 ], + elmValue = pettanr.util.getElementsByClassName( elmA, 'combobox-value' )[ 0 ].firstChild, + value, index = 0, + optionList = [], + instance = this, + oldBodyMouseupHandler, + focus = false, + visible = true, + enabled = true; + + elmBox.appendChild( elmA ); + WRAPPER_ELM.onclick = onClick; + + function onClick(){ + WRAPPER_ELM.onclick = null; + focus = true; + elmA.className = 'combobox-has-focus'; + start( instance ); + OptionControl.show( instance, optionList ); + return false; + } + this.elm = elmBox; + this.focus = function(){ + onClick(); + } + this.blur = function( keyCode ){ + OptionControl.hide( instance ); + focus = false; + elmA.className = ''; + finish( instance ); + WRAPPER_ELM.onclick = onClick; + } + this.enabled = function(){ + return enabled; + } + this.visible = function( _visible ){ + if( _visible === true){ + WRAPPER_ELM.style.display = ''; + visible = true; + } else + if( _visible === false){ + WRAPPER_ELM.style.display = 'none'; + visible = false; + } + return visible; + } + this.value = function( _value ){ + var i, j, + l=optionList.length, + _option; + if( Type.isString( _value ) === true && value !== _value ){ + for( i=0; i Date: Mon, 23 Apr 2012 05:47:55 +0900 Subject: [PATCH 10/16] client is version0.4.25, fixed petanr.form on windowResize. --- public/assets/common.js | 85 ++++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/public/assets/common.js b/public/assets/common.js index 0007b340..2b151660 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1020,6 +1020,7 @@ pettanr.view = ( function(){ h = jqWindow.height(); currentApplication && currentApplication.resize( w, h ); pettanr.overlay.onWindowResize( w, h ); + pettanr.form.onWindowResize( w, h ); } return { @@ -1083,7 +1084,7 @@ pettanr.overlay = ( function(){ windowW, windowH; function asyncResize(){ - currentOverlay.resize( windowW, windowH); + currentOverlay.resize( windowW, windowH ); } function onCloseClick( e){ pettanr.overlay.hide(); @@ -1312,6 +1313,7 @@ pettanr.form = ( function(){ currentID = null, currentItem = null, CLASSNAME_COMBOBOX_OPTION = 'combobox-option', + windowW, windowH, ELM_A_ORIGIN = ( function(){ var ret = document.createElement( 'a'); ret.href = '#'; @@ -1335,7 +1337,7 @@ pettanr.form = ( function(){ elmToggle.appendChild( document.createTextNode( '▼' )); elmValue.appendChild( document.createTextNode( 'null' )); return ret; - })() + })(); var InputTextClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater ){ validater = Type.isFunction( validater ) === true ? validater : null; @@ -1654,6 +1656,15 @@ pettanr.form = ( function(){ currentCombobox.blur(); OptionControl.hide( currentCombobox ); } + function updateWrapperPosition(){ + var position = pettanr.util.getAbsolutePosition( elm ); + + ELM_OPTION_WRAPPER.style.cssText = [ + 'width:', elm.offsetWidth - 2, 'px;', + 'left:', position.x, 'px;', + 'top:', position.y + elm.offsetHeight, 'px;' + ].join(''); + } return { show: function( _combobox, _optionList ){ if( currentItem !== _combobox || currentCombobox === _combobox ) return; @@ -1665,23 +1676,15 @@ pettanr.form = ( function(){ updateCurrrentOption( _combobox.value(), false ); - var position = pettanr.util.getAbsolutePosition( elm ), - _option; - for( var i=0, l=optionList.length; i Date: Mon, 23 Apr 2012 06:04:18 +0900 Subject: [PATCH 11/16] bugfix Combobox.selectIndex(). --- public/assets/work.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/assets/work.js b/public/assets/work.js index 04106ea1..8304a3a0 100644 --- a/public/assets/work.js +++ b/public/assets/work.js @@ -2939,10 +2939,10 @@ pettanr.comicConsole = pettanr.view.registerApplication( function(){ _name = _select.name; _optionList = _select.getElementsByTagName( 'option' ) if( _name === 'comic[visible]'){ - _select.selectedIndex = comboboxVisible.selectIndex; + _select.selectedIndex = comboboxVisible.selectIndex(); } else if( _name === 'comic[editable]'){ - _select.selectedIndex = comboboxEditable.selectIndex; + _select.selectedIndex = comboboxEditable.selectIndex(); } } try { -- 2.11.0 From 54b959972304a7c40f462f01b6309aabf90110ca Mon Sep 17 00:00:00 2001 From: itozyun Date: Tue, 24 Apr 2012 21:21:13 +0900 Subject: [PATCH 12/16] client is version0.4.26, fixed around image loader. --- public/assets/common.js | 651 ++++++++++++++++++++++++------------------------ public/assets/system.js | 72 +++--- public/assets/work.js | 52 ++-- 3 files changed, 384 insertions(+), 391 deletions(-) diff --git a/public/assets/common.js b/public/assets/common.js index 2b151660..eb4e36e7 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1,6 +1,6 @@ /* * pettanR common.js - * version 0.4.25 + * version 0.4.26 * * author: itozyun */ @@ -108,7 +108,7 @@ var pettanr = ( function(){ IS_DEBUG = Type.isBoolean( URL_PARAMS.debug ) ? URL_PARAMS.debug : IS_LOCAL === true, jqWindow , jqDocument , jqBody; return { - version: '0.4.21', + version: '0.4.26', init: function(){ jqWindow = $( window); jqDocument = $( document); @@ -361,114 +361,6 @@ pettanr.util = ( function(){ return size; }, - loadImage: function( URLorELM, onLoad, onError, delay, timeout){ - delay = delay || 250; - timeout = timeout || 5000; - var type = typeof URLorELM, - img, images, src, abstractPath; - if( type === 'string'){ - src = URLorELM; - // images = []; - } else - // http://d.hatena.ne.jp/hottolinkblog/20090228/1235823487 - if( type === 'object' && typeof URLorELM.hspace !== 'undefined' && typeof URLorELM.vspace !== 'undefined'){ - img = URLorELM; - images = [ img]; - src = img.src; - } else { - return; - } - abstractPath = this.getAbsolutePath( src); - - loadImage( images, abstractPath, onLoadAsync, onErrorAsync, delay, timeout); - - function onLoadAsync( abspath, actualW, actualH){ - if( abstractPath !== abspath) return; - var _g_onUpdateFunction = pettanr.util.createGlobalFunction( onLoad); - _onTimeout = pettanr.util.createGlobalFunc( [ - 'function(){', - 'window["', _g_onUpdateFunction, '"]( "', abspath, '", ', actualW, ', ', actualH, ');', - 'window["', _g_onUpdateFunction, '"] = null;', - '}' - ].join( '')); - onLoad && setTimeout( window[ _onTimeout], 0); - window[ _onTimeout] = null; - } - function onErrorAsync( abspath){ - if( abstractPath !== abspath) return; - var _g_onUpdateFunction = pettanr.util.createGlobalFunction( onError); - _onTimeout = pettanr.util.createGlobalFunc( [ - 'function(){', - 'window["', _g_onUpdateFunction, '"]( "', abspath, '");', - 'window["', _g_onUpdateFunction, '"] = null;', - '}' - ].join( '')); - onError && setTimeout( window[ _onTimeout], 0); - window[ _onTimeout] = null; - } - - /* LICENSE: MIT? - * URL: http://d.hatena.ne.jp/uupaa/20080413/1208067631 - * AUTHOR: uupaa.js@gmail.com - * - * fixed for ie6-8 by pettanr - * new Image -> document.createElement( 'img') - */ - function loadImage( images, abspath, onLoad, onError, delay, timeout) { - images = images || document.images; - var img, - i = 0, l = images.length, - tick = 0; - for(; i < l; ++i) { - img = images[i]; - if ( img.src === abspath && img.complete) { - var size = pettanr.util.getImageSize( img); - onLoad( abspath, size.width, size.height); - return; - } - } - img = document.createElement( 'img'); //var img = new Image(); ではieでimgのsizeが取れない、、、removeChildも失敗し、imgSizeGetterにimgが残る - img.finish = false; - img.onabort = img.onerror = function() { - if (img.finish) { return; } - img.finish = true; - onError(abspath); - img.onload = img.onabort = img.onerror = ""; - }; - img.onload = function() { - img.finish = true; - if (window.opera && !img.complete) { - onError(abspath); - img.onload = img.onabort = img.onerror = ""; - return; - } - var size = pettanr.util.getImageSize( img); - onLoad( abspath, size.width, size.height); - img.onload = img.onabort = img.onerror = ""; - //img = void 0; - }; - img.src = abspath; - if (!img.finish && timeout) { - setTimeout(function() { - if (img.finish) { return; } - if (img.complete) { - img.finish = true; - if (img.width) { return; } - onError(abspath); - img.onload = img.onabort = img.onerror = ""; - return; - } - if ((tick += delay) > timeout) { - img.finish = true; - onError(abspath); - img.onload = img.onabort = img.onerror = ""; - return; - } - setTimeout(arguments.callee, delay); - }, 0); - } - } - }, getAbsolutePath: function( path) { var e = document.createElement("div"); e.innerHTML = ''; @@ -1920,37 +1812,39 @@ pettanr.balloon = ( function() { })(), NUM_BALLOON_IMAGE = 24, vectorEnabled = ELM_BALLOON_ORIGIN !== null && pettanr.URL_PARAMS.vector !== false; - if( IS_VML === true && pettanr.ua.VML === false) vectorEnabled = false; + if( IS_VML === true && pettanr.ua.VML === false ) vectorEnabled = false; + + var cos = Math.cos, sin = Math.sin, + abs = Math.abs, pow = Math.pow, + round = Math.round, + floor = Math.floor, + TARGET = TAIL_WIDTH * TAIL_WIDTH, + DEG_TO_RAD = Math.PI / 180; var XBROWSER_BALLOON_CLASS = function( w, h, a ){ - var balloonElm = vectorEnabled === true ? ELM_BALLOON_ORIGIN.cloneNode( true) : document.createElement( 'img'), // pettanr.imageに変更 - path = balloonElm.getElementsByTagName( 'path')[ 0], - shape = balloonElm.getElementsByTagName( 'shape')[ 0], - cos = Math.cos, sin = Math.sin, - abs = Math.abs, pow = Math.pow, - round = Math.round, - floor = Math.floor, - TARGET = TAIL_WIDTH * TAIL_WIDTH, - DEG_TO_RAD = Math.PI / 180, + var balloonElm = vectorEnabled === true ? ELM_BALLOON_ORIGIN.cloneNode( true ) : document.createElement( 'img' ), // pettanr.imageに変更 + path = balloonElm.getElementsByTagName( 'path')[ 0 ], + shape = balloonElm.getElementsByTagName( 'shape')[ 0 ], + instance = this, l = ','; draw( a, w, h ); function draw( _a, _w, _h ){ a = _a !== undefined ? _a : a; - w = _w !== undefined ? _w - PADDING_TOP *2 : w; - h = _h !== undefined ? _h - PADDING_LEFT *2 : h; + w = _w !== undefined ? _w - PADDING_TOP * 2 : w; + h = _h !== undefined ? _h - PADDING_LEFT * 2 : h; if( vectorEnabled === false){ - balloonElm.setAttribute( 'src', balloonUrlBuilder( a)); + balloonElm.setAttribute( 'src', balloonUrlBuilder( a )); return; } var rx = w /2, ry = h /2, tailRad = a * DEG_TO_RAD, - tailX = rx +( rx +TAIL_HEIGHT) * cos( tailRad), - tailY = ry +( ry +TAIL_HEIGHT) * sin( tailRad), + tailX = rx +( rx +TAIL_HEIGHT ) * cos( tailRad ), + tailY = ry +( ry +TAIL_HEIGHT ) * sin( tailRad ), startX, startY, endX, endY; /* * tailの太さをTAIL_WIDTHに一致させるため、角度を絞りつつ計算 @@ -1960,16 +1854,16 @@ pettanr.balloon = ( function() { tailDeg = 0, d; for( var i = 45; i > 0.01; i /= 2){ - d = ( tailDeg +i) /2; - startRad = ( a +d) * DEG_TO_RAD; - endRad = ( a -d) * DEG_TO_RAD; + d = ( tailDeg + i ) /2; + startRad = ( a + d ) * DEG_TO_RAD; + endRad = ( a - d ) * DEG_TO_RAD; - _startX = rx +cos( startRad) *rx; - _startY = ry +sin( startRad) *ry; - _endX = rx +cos( endRad) *rx; - _endY = ry +sin( endRad) *ry; //円弧上のY位置=円中心Y+sin(角度×PI÷180)×円半径 + _startX = rx +cos( startRad ) * rx; + _startY = ry +sin( startRad ) * ry; + _endX = rx +cos( endRad) * rx; + _endY = ry +sin( endRad) * ry; //円弧上のY位置=円中心Y+sin(角度×PI÷180)×円半径 - if( pow( ( _startX -_endX), 2) + pow( ( _startY -_endY), 2) < TARGET){ + if( pow( ( _startX - _endX), 2 ) + pow( ( _startY - _endY ), 2 ) < TARGET ){ tailDeg += i; startX = _startX; startY = _startY; @@ -1981,7 +1875,7 @@ pettanr.balloon = ( function() { /* * */ - if( IS_VML === true){ + if( IS_VML === true ){ var _tailX = tailX *10, _tailY = tailY *10, __startX = startX *10, @@ -1991,67 +1885,65 @@ pettanr.balloon = ( function() { __w = w *10, __h = h *10; - shape.style.width = w +'px'; - shape.style.height = h +'px'; - shape.coordsize = [ __w, __h].join( l); + shape.style.width = w + 'px'; + shape.style.height = h + 'px'; + shape.coordsize = [ __w, __h ].join( l ); shape.path = [ ' ar ', 0, l, 0, l, __w, l, __h, l, - round( __endX), l, round( __endY), l, - round( __startX), l, round( __startY), - ' l ', round( _tailX), l, round( _tailY), + round( __endX ), l, round( __endY ), l, + round( __startX ), l, round( __startY ), + ' l ', round( _tailX ), l, round( _tailY ), ' x e' ].join( ''); - balloonElm.style.marginTop = _tailY < 0 ? floor( ( 60 +_tailY) /10) : 10; - balloonElm.style.marginLeft = _tailX < 0 ? floor( ( 60 +_tailX) /10) : 10; + balloonElm.style.marginTop = _tailY < 0 ? floor( ( 60 + _tailY) / 10 ) : 10; + balloonElm.style.marginLeft = _tailX < 0 ? floor( ( 60 + _tailX) / 10 ) : 10; } else { - balloonElm.setAttribute( 'width', w +PADDING_LEFT *2); - balloonElm.setAttribute( 'height', h +PADDING_TOP *2); + balloonElm.setAttribute( 'width', w + PADDING_LEFT *2 ); + balloonElm.setAttribute( 'height', h + PADDING_TOP *2 ); path.setAttribute( 'd', [ - 'M', cround( tailX + PADDING_LEFT), l, cround( tailY +PADDING_TOP), - 'L', cround( startX +PADDING_LEFT), l, cround( startY +PADDING_TOP), + 'M', cround( tailX + PADDING_LEFT ), l, cround( tailY + PADDING_TOP ), + 'L', cround( startX + PADDING_LEFT ), l, cround( startY + PADDING_TOP ), 'A', rx, l, ry, '0 1 1', // flag - cround( endX +PADDING_LEFT), l, cround( endY +PADDING_TOP), + cround( endX + PADDING_LEFT ), l, cround( endY + PADDING_TOP ), 'z' ].join( ' ')); } function cround( v, r){ r = r || ACCURACY; - return round( v *pow( 10.0, r)) /pow( 10.0, r); + return round( v * pow( 10.0, r )) / pow( 10.0, r ); } } function balloonUrlBuilder( _a ){ - var d = 360 /NUM_BALLOON_IMAGE; - _a += 90 +d /2; - return [ 'system_pictures\/_w', _a < 360 -d /2 ? floor( _a /d) : 0, '.gif'].join( ''); + var d = 360 / NUM_BALLOON_IMAGE; + _a += 90 + d / 2; + return [ 'system_pictures\/_w', _a < 360 - d / 2 ? floor( _a / d ) : 0, '.gif' ].join( '' ); } - return { - elm: balloonElm, - resize: draw, - angle: function( _a){ - _a !== undefined && _a !== a && - vectorEnabled === false ? balloonUrlBuilder( _a) : draw( _a); - return a; - }, - type: function( _type){ - //draw( _a); - }, - getURL: function(){ - return balloonUrlBuilder( a ); - }, - destroy: function(){ - balloonElm.parentNode && balloonElm.parentNode.removeChild( balloonElm); - balloonElm = null; - delete this.destroy; - } + this.elm = balloonElm; + this.resize = draw; + this.angle = function( _a ){ + _a !== undefined && _a !== a && + vectorEnabled === false ? balloonUrlBuilder( _a ) : draw( _a ); + return a; + } + this.type = function( _type ){ + //draw( _a); + } + this.getURL = function(){ + return balloonUrlBuilder( a ); + } + this.destroy = function(){ + delete instance.destroy; + balloonElm.parentNode && balloonElm.parentNode.removeChild( balloonElm ); + balloonElm = path = shape = instance = null; } }; IS_VML === false && vectorEnabled === true && ( function(){ - var detect = XBROWSER_BALLOON_CLASS.apply( {}, [ 100, 100, 0]), - size = pettanr.util.getElementSize( detect.elm); + var detect = new XBROWSER_BALLOON_CLASS( 100, 100, 0 ), + size = pettanr.util.getElementSize( detect.elm ); vectorEnabled = size.width !== 0 && size.height !== 0; detect.destroy(); detect = size = null; @@ -2059,7 +1951,7 @@ pettanr.balloon = ( function() { return { createBalloon: function( _w, _h, _a){ - return XBROWSER_BALLOON_CLASS.apply( {}, [ _w, _h, _a]); + return new XBROWSER_BALLOON_CLASS( _w, _h, _a ); }, TYPE_NONE: 0, TYPE_SPEACH_BALLOON: 1, @@ -2093,6 +1985,122 @@ pettanr.balloon = ( function() { * -moz-transform:scale( -1, -1); */ pettanr.image = ( function(){ + + var FetchImageControl = ( function(){ + var TASK_LIST = []; + + /* + * FetchClass original is + * + * LICENSE: MIT? + * URL: http://d.hatena.ne.jp/uupaa/20080413/1208067631 + * AUTHOR: uupaa.js@gmail.com + * + */ + + var FetchClass = function( abspath, onLoadCallback, onErrorCallback, delay, timeout ){ + var img, + size, + tick = 0, + timer = null, + finish = false; + /* + if( pettanr.ua.isIE === false && pettanr.ua.ieVersion < 8 ){ + var images = document.images, + i=0, l= images.length; + for( i=0; i timeout ){ + finish = true; + timer = window.setTimeout( asyncCallback, 10 ); + return; + } + timer = window.setTimeout( detect, delay ); + } + + function asyncCallback(){ + size ? onLoadCallback( abspath, size.width, size.height ) : onErrorCallback( abspath ); + destroy(); + } + function destroy(){ + finish = true; + img.src = img.onload = img.onabort = img.onerror = ''; + img = void 0 + size = onLoadCallback = onErrorCallback = timer = null; + } + this.stop = function(){ + timer !== null && window.clearTimeout( timer ); + destroy(); + } + } + + return { + load: function( URLorELM, onLoad, onError, delay, opt_timeout ){ + var src, fetch; + if( Type.isString( URLorELM ) === true ){ + src = URLorELM; + } else + if( Type.isHTMLElement( URLorELM ) === true && URLorELM.tagName.toLowerCase() === 'img' ){ + src = URLorELM.src; + } else { + return; + } + + fetch = new FetchClass( + pettanr.util.getAbsolutePath( src ), + onLoad, onError, + Type.isFinite( delay ) === true ? delay : 250, + Type.isFinite( opt_timeout ) === true ? opt_timeout : undefined + ); + // TASK_LIST.push( fetch ); + + return fetch; + } + } + })(); + var REG_PNG = /\.png?/i, IS_CSS3 = 0, IS_VML = 1, @@ -2103,169 +2111,154 @@ pettanr.image = ( function(){ IS_SERVER = 6, IS_ACTIVEX_SERVER = 7, BACKEND = ( function(){ - if( pettanr.DEBUG === true && pettanr.URL_PARAMS.rimg){ + if( pettanr.DEBUG === true && pettanr.URL_PARAMS.rimg ){ var rimg = pettanr.URL_PARAMS.rimg.toLowerCase(); - if( rimg === 'css3') return IS_CSS3; - if( rimg === 'activex') return IS_ACTIVEX; - if( rimg === 'vml') return IS_VML; - } - if( pettanr.ua.isIE === false || pettanr.ua.ieVersion >= 9) return IS_CSS3; // 不十分! - if( pettanr.ua.VML === true) return IS_VML; - if( pettanr.ua.ACTIVEX === true) return IS_ACTIVEX; - if( pettanr.FLASH === true) return IS_FLASH; - if( pettanr.SILVERLIGHT === true) return IS_SILVERLIGHT; + if( rimg === 'css3' ) return IS_CSS3; + if( rimg === 'activex' ) return IS_ACTIVEX; + if( rimg === 'vml' ) return IS_VML; + } + if( pettanr.ua.isIE === false || pettanr.ua.ieVersion >= 9 ) return IS_CSS3; // 不十分! + if( pettanr.ua.VML === true ) return IS_VML; + if( pettanr.ua.ACTIVEX === true ) return IS_ACTIVEX; + if( pettanr.FLASH === true ) return IS_FLASH; + if( pettanr.SILVERLIGHT === true ) return IS_SILVERLIGHT; return IS_SERVER; })(), BACKEND_WHEN_PNG = ( function(){ - if( pettanr.ua.isIE === false || pettanr.ua.ieVersion > 6) return BACKEND; - if( pettanr.ua.VML === true) return IS_VML; - if( pettanr.FLASH === true) return IS_FLASH; - if( pettanr.SILVERLIGHT === true) return IS_SILVERLIGHT; - if( pettanr.ua.ACTIVEX === true) return IS_ACTIVEX_SERVER; + if( pettanr.ua.isIE === false || pettanr.ua.ieVersion > 6 ) return BACKEND; + if( pettanr.ua.VML === true ) return IS_VML; + if( pettanr.FLASH === true ) return IS_FLASH; + if( pettanr.SILVERLIGHT === true ) return IS_SILVERLIGHT; + if( pettanr.ua.ACTIVEX === true ) return IS_ACTIVEX_SERVER; return IS_SERVER; })(), + CLASS_NAME = 'reversible-image-container', + CLASS_NAME_LOADING = CLASS_NAME + ' loading', + CLASS_NAME_ERROR = CLASS_NAME +' error', + RETRY_DELAY = 5000, + NUM_RETRY = 3, ReversibleImageClass, ReversibleImageClassWithPingfix; - var XBackendReversibleImageClass = ( function(){ - var CLASS_NAME = 'reversible-image-container', - CLASS_NAME_LOADING = CLASS_NAME + ' loading', - CLASS_NAME_ERROR = CLASS_NAME +' error', - RETRY_DELAY = 5000; - NUM_RETRY = 3; - - var css3Image = function( url, w, h, onLoadCallback){ - var elmWrap = document.createElement( 'div'), - elmImg, - loaded = false, - retryTimer = null; + var css3Image = function( url, w, h, onLoadCallback ){ + var elmWrap = document.createElement( 'div' ), + elmImg, + loaded = false, + retryTimer = null, + fetch = FetchImageControl.load( url, onLoad, onError, 100, 10000 ), + instance = this; + elmWrap.className = CLASS_NAME_LOADING; + + function onLoad( _url, _actualW, _actualH ){ + if( elmWrap === null ) return; + elmImg = new Image; // new Image でないと ie6,7 でクラッシュするかも、、、? + /* + * createElement 直後に append しないと、ie(ActiveX)で img が正しく表示されない. + */ + elmWrap.appendChild( elmImg ); + elmImg.setAttribute( 'src', url ); + elmWrap.className = CLASS_NAME; + onLoadCallback && onLoadCallback( _url, _actualW, _actualH ); + onLoadCallback = fetch = null; + loaded = true; + instance.resize( w, h ); + } + function onError( _url ){ + if( elmWrap === null ) return; + elmWrap.className = CLASS_NAME_ERROR; + retryTimer = window.setTimeout( retry, RETRY_DELAY ); + fetch = null; + } + function retry(){ elmWrap.className = CLASS_NAME_LOADING; - pettanr.util.loadImage( url, onLoad, onError, 100, 10000); - function onLoad( _url, _actualW, _actualH){ - if( elmWrap === null) return; - elmImg = new Image; - /* - * createElement 直後に append しないと、ie(ActiveX)で img が正しく表示されない. - */ - elmWrap.appendChild( elmImg); - elmImg.setAttribute( 'src', url); - elmWrap.className = CLASS_NAME; - onLoadCallback && onLoadCallback( _url, _actualW, _actualH); - onLoadCallback = null; - loaded = true; - resize( w, h); - } - function onError( _url){ - if( elmWrap === null) return; - elmWrap.className = CLASS_NAME_ERROR; - retryTimer = setTimeout( function(){ - elmWrap.className = CLASS_NAME_LOADING; - pettanr.util.loadImage( url, onLoad, onError, 100, 10000); - }, RETRY_DELAY); - } - function resize( _w, _h){ - w = _w !== undefined ? _w : w; - h = _h !== undefined ? _h : h; - if( loaded === false) return; - elmImg.className = w < 0 || h < 0 ? ( 'img-flip-' + ( w < 0 && h < 0 ? 'vh' : ( w < 0 ? 'h' : 'v'))) : ''; - } - return { - elm : elmWrap, - resize: resize, - destroy: function(){ - loaded === true && elmWrap.removeChild( elmImg); - retryTimer !== null && clearTimeout( retryTimer); - elmWrap = vmlImg = onLoadCallback = retryTimer = null; - elmWrap = elmImg = onLoadCallback = null; - delete this.destroy; - } - } + fetch = FetchImageControl.load( url, onLoad, onError, 100, 10000 ); + } + + this.elm = elmWrap; + this.resize = function( _w, _h ){ + w = _w !== undefined ? _w : w; + h = _h !== undefined ? _h : h; + if( loaded === false ) return; + elmImg.className = w < 0 || h < 0 ? ( 'img-flip-' + ( w < 0 && h < 0 ? 'vh' : ( w < 0 ? 'h' : 'v'))) : ''; } - var activexImage = css3Image; - var vmlImage = function( url, w, h, onLoadCallback ){ - var elmWrap = document.createElement( 'div'), - vmlImg, - loaded = false, - retryTimer = null; + this.destroy = function(){ + delete instance.destroy; + + loaded === true && elmWrap.removeChild( elmImg ); + retryTimer !== null && window.clearTimeout( retryTimer ); + fetch !== null && fetch.stop(); + elmWrap = elmImg = onLoadCallback = retryTimer = fetch = instance = null; + } + } + + var activexImage = css3Image; + + var vmlImage = function( url, w, h, onLoadCallback ){ + var elmWrap = document.createElement( 'div' ), + vmlImg, + loaded = false, + retryTimer = null, + fetch = FetchImageControl.load( url, onLoad, onError, 100, 10000 ), + instance = this; + elmWrap.className = CLASS_NAME_LOADING; + function onLoad( _url, _actualW, _actualH){ + if( elmWrap === null ) return; + elmWrap.className = CLASS_NAME; + vmlImg = document.createElement( 'v:image' ); + vmlImg.src = url; + onLoadCallback && onLoadCallback( _url, _actualW, _actualH ); + onLoadCallback = fetch = null; + loaded = true; + instance.resize( w, h ); + } + function onError( _url ){ + if( elmWrap === null) return; + elmWrap.className = CLASS_NAME_ERROR; + retryTimer = window.setTimeout( retry, RETRY_DELAY ); + fetch = null; + } + function retry(){ elmWrap.className = CLASS_NAME_LOADING; - pettanr.util.loadImage( url, onLoad, onError, 100, 10000); - function onLoad( _url, _actualW, _actualH){ - if( elmWrap === null) return; - elmWrap.className = CLASS_NAME; - vmlImg = document.createElement( 'v:image'); - vmlImg.src = url; - loaded = true; - resize( w, h); - onLoadCallback && onLoadCallback( _url, _actualW, _actualH); - onLoadCallback = null; - } - function onError( _url){ - if( elmWrap === null) return; - elmWrap.className = CLASS_NAME_ERROR; - retryTimer = setTimeout( function(){ - elmWrap.className = CLASS_NAME_LOADING; - pettanr.util.loadImage( url, onLoad, onError, 100, 10000); - }, RETRY_DELAY); - } - function resize( _w, _h){ - w = _w !== undefined ? _w : w; - h = _h !== undefined ? _h : h; - if( loaded !== true) return; - vmlImg.style.width = w < 0 ? -w : w +'px'; - vmlImg.style.height = h < 0 ? -h : h +'px'; - //if( flipH !== _flipH || flipV !== _flipV){ - vmlImg.parentNode === elmWrap && elmWrap.removeChild( vmlImg ); - //} - vmlImg.className = w < 0 || h < 0 ? ( 'img-flip-' + ( w < 0 && h < 0 ? 'vh' : ( w < 0 ? 'h' : 'v'))) : ''; - elmWrap.appendChild( vmlImg); - } - return { - elm : elmWrap, - resize: resize, - destroy: function(){ - loaded === true && elmWrap.removeChild( vmlImg); - retryTimer !== null && clearTimeout( retryTimer); - elmWrap = vmlImg = onLoadCallback = retryTimer = null; - delete this.destroy; - } - } + fetch = FetchImageControl.load( url, onLoad, onError, 100, 10000 ); } - var serverImage = function( url, w, h, onLoadCallback){ + + this.elm = elmWrap; + this.resize = function( _w, _h ){ + w = _w !== undefined ? _w : w; + h = _h !== undefined ? _h : h; + if( loaded !== true ) return; + vmlImg.style.width = w < 0 ? -w : w +'px'; + vmlImg.style.height = h < 0 ? -h : h +'px'; + //if( flipH !== _flipH || flipV !== _flipV){ + vmlImg.parentNode === elmWrap && elmWrap.removeChild( vmlImg ); + //} + vmlImg.className = w < 0 || h < 0 ? ( 'img-flip-' + ( w < 0 && h < 0 ? 'vh' : ( w < 0 ? 'h' : 'v'))) : ''; + elmWrap.appendChild( vmlImg ); + } + this.destroy = function(){ + instance.destroy; + loaded === true && elmWrap.removeChild( vmlImg ); + retryTimer !== null && window.clearTimeout( retryTimer ); + fetch !== null && fetch.stop(); + elmWrap = vmlImg = onLoadCallback = retryTimer = fetch = instance = null; } + } + + var serverImage = function( url, w, h, onLoadCallback ){ - return function( url, w, h, onLoadCallback ){ - var flipH = w < 0, - flipV = h < 0, - onLoadCallbackAsync = onLoadCallback,// ? function(){ setTimeout( onLoadCallback, 0);} : undefined,// 一度読み込んだ画像は即座にonLoadになるため遅延 - xBackendImage = ( function( urlIsXDomain ){ - if( BACKEND === IS_CSS3) return new css3Image( url, w, h, onLoadCallbackAsync ); - if( BACKEND === IS_VML) return new vmlImage( url, w, h, onLoadCallbackAsync ); - if( BACKEND === IS_ACTIVEX) return new activexImage( url, w, h, onLoadCallbackAsync ); - return new serverImage( url, w, h, onLoadCallbackAsync ); - })(); - return { - elm: xBackendImage.elm, - w: function( _w){ - _w !== undefined && xBackendImage.resize( _w, h); - return w; - }, - h: function( _h){ - _h !== undefined && xBackendImage.resize( w, _h); - return h; - }, - resize: xBackendImage.resize, - destroy: function(){ - xBackendImage.destroy && xBackendImage.destroy(); - xBackendImage = onLoadCallback = onLoadCallbackAsync = null; - delete this.destroy; - } - } - } - })(); + } + + if( BACKEND === IS_CSS3 ) ReversibleImageClass = css3Image; + if( BACKEND === IS_VML ) ReversibleImageClass = vmlImage; + if( BACKEND === IS_ACTIVEX ) ReversibleImageClass = activexImage; + if( BACKEND === IS_SERVER ) ReversibleImageClass = activexImage; + + css3Image = vmlImage = activexImage = activexImage = null; + return { createReversibleImage: function( url, w, h, onLoadCallback){ - return XBackendReversibleImageClass.apply( {}, [ url, w, h, onLoadCallback]); + return new ReversibleImageClass( url, w, h, onLoadCallback ); } } })(); @@ -2360,10 +2353,10 @@ pettanr.bind = ( function(){ for( var i=0, l=_comicElements.length; i 0 ){ + ICON_ARRAY.shift().destroy(); + } + onUpdateFunction !== null && onUpdateData !== null && onUpdateFunction( onUpdateData ); + onUpdateFunction = onUpdateData = null; + } + /* grobal method */ // this.rootElement = elmWrap; this.displayName = 'premiumStage'; @@ -1914,12 +1923,8 @@ pettanr.premiumSatge = pettanr.view.registerApplication( function(){ artistID = _ARTISTIDorFILE; } - //onUpdateFunction = _onUpdateFunction; - if( _onUpdateFunction ){ - _g_onUpdateFunction = pettanr.util.createGlobalFunction( _onUpdateFunction ); - } else { - _g_onUpdateFunction = null; - } + onUpdateFunction = _onUpdateFunction || null; + onUpdateData = null; drawIcons(); @@ -1983,12 +1988,9 @@ pettanr.premiumSatge = pettanr.view.registerApplication( function(){ jqContainer.stop().animate( { height: 0, top: Math.floor( winH /2 ) - }); - while( ICON_ARRAY.length > 0 ){ - ICON_ARRAY.shift().destroy(); - } + }, onFadeout ); onEnterInterval !== null && window.clearTimeout( onEnterInterval ); - onEnterInterval = _g_onUpdateFunction = null; + onEnterInterval = null; } }); diff --git a/public/assets/work.js b/public/assets/work.js index 8304a3a0..4a67e64b 100644 --- a/public/assets/work.js +++ b/public/assets/work.js @@ -1,6 +1,6 @@ /* * pettanR work.js - * version 0.4.25 + * version 0.4.26 * * author: * itozyun @@ -362,13 +362,13 @@ pettanr.editor = pettanr.view.registerApplication( function(){ if( Type.isArray( _argBack ) === true ){ // isArray while( _argBack.length > 0){ _value = _argBack.shift(); - _destroy === true && typeof _value.destroy === 'function' && _value.destroy(); + _destroy === true && Type.isFunction( _value.destroy ) === true && _value.destroy(); } } if( Type.isArray( _argForword ) === true ){ while( _argForword.length > 0){ _value = _argForword.shift(); - _destroy === true && typeof _value.destroy === 'function' && _value.destroy(); + _destroy === true && Type.isFunction( _value.destroy ) === true && _value.destroy(); } } } @@ -384,10 +384,10 @@ pettanr.editor = pettanr.view.registerApplication( function(){ MENUBAR_BACK.visible( false); MENUBAR_FORWARD.visible( false); while( STACK_BACK.length > 0){ - destroyStack( STACK_BACK.shift(), true); + destroyStack( STACK_BACK.shift(), true ); } while( STACK_FORWARD.length > 0){ - destroyStack( STACK_FORWARD.shift(), true); + destroyStack( STACK_FORWARD.shift(), true ); } }, saveState: function( _function, _argBack, _argForword, _destroy) { @@ -403,7 +403,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){ var _stack; while( STACK_FORWARD.length > 0){ _stack = STACK_FORWARD.shift(); - destroyStack( _stack, _stack.destroy); + destroyStack( _stack, _stack.destroy ); } MENUBAR_FORWARD.visible( false); } @@ -2215,8 +2215,6 @@ pettanr.editor = pettanr.view.registerApplication( function(){ jqImageElementOrigin = jqImageElementOrigin || $( $( '#imgElementTemplete').remove().html()); var JQ_WRAPPER = jqImageElementOrigin.clone( true ), - SAVE = HISTORY_CONTROL.saveState, - HIT_AREA = MOUSE_HIT_AREA, w = data.width, h = data.height, x, y, z, @@ -2231,7 +2229,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){ h = Math.floor( h ); function onAnimeComplete(){ - reversibleImage.resize( flipH * w, flipV * h ); + reversibleImage && reversibleImage.resize( flipH * w, flipV * h ); } function updateResourcePicture( _resourcePicture ){ resourcePicture = _resourcePicture; @@ -2278,7 +2276,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){ } this.resourcePicture = function( _resourcePicture ){ if( _resourcePicture && _resourcePicture !== resourcePicture ){ - SAVE( updateResourcePicture, resourcePicture, _resourcePicture ); + HISTORY_CONTROL.saveState( updateResourcePicture, resourcePicture, _resourcePicture ); updateResourcePicture( _resourcePicture ); } return resourcePicture; @@ -2305,13 +2303,14 @@ pettanr.editor = pettanr.view.registerApplication( function(){ 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); + instance.resize( _x, _y, _w, _h, true ); } this.destroy = function(){ + delete instance.destroy; + reversibleImage.destroy(); - JQ_WRAPPER.remove(); - JQ_WRAPPER = reversibleImage = resourcePicture = data = instance = SAVE = null; - delete this.destroy; + JQ_WRAPPER.stop().remove(); + JQ_WRAPPER = reversibleImage = resourcePicture = data = instance = null; } } ImageElementClass.prototype = new AbstractComicElement( PANEL_ELEMENT_TYPE_IMAGE ); @@ -2343,8 +2342,6 @@ pettanr.editor = pettanr.view.registerApplication( function(){ var JQ_WRAPPER = jqTextElementOrigin.clone( true ), TEXT_ELM = JQ_WRAPPER.find( 'td,.speach-inner').eq( 0), - HIT_AREA = MOUSE_HIT_AREA, - SAVE = HISTORY_CONTROL.saveState, type = data.balloon_template_id, text = ( function(){ var _speachs = data.speaches_attributes; @@ -2357,7 +2354,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){ x, y, w, h, a, instance = this; - JQ_WRAPPER.find( 'img').eq( 0).replaceWith( balloon.elm ); + JQ_WRAPPER.find( 'img' ).eq( 0 ).replaceWith( balloon.elm ); function updateType( _type ){ if( type !== _type ){ @@ -2375,6 +2372,9 @@ pettanr.editor = pettanr.view.registerApplication( function(){ text = _text || text || ''; TEXT_ELM.html( text ); } + function resizeBalloon(){ + balloon && balloon.resize( a, w, h ); + } /* global methods */ this.$ = JQ_WRAPPER; @@ -2390,12 +2390,12 @@ pettanr.editor = pettanr.view.registerApplication( function(){ delete instance.init; } this.angle = function( _a ){ - _a !== undefined && instance.resize( undefined, undefined, undefined, undefined, _a); + _a !== undefined && instance.resize( undefined, undefined, undefined, undefined, _a ); return a; } this.text = function( _text){ if( _text && text !== _text) { - SAVE( updateText, text || '', _text); + HISTORY_CONTROL.saveState( updateText, text || '', _text ); updateText( _text); } return text; @@ -2415,21 +2415,19 @@ pettanr.editor = pettanr.view.registerApplication( function(){ top: y, width: w, height: h - }, 250, - function(){ - balloon.resize( a, w, h); - } + }, 250, resizeBalloon ); - animate !== true && balloon.resize( a, w, h); + animate !== true && resizeBalloon(); } this.animate = function ( _x, _y, _w, _h, _a ){ instance.resize( _x, _y, _w, _h, _a, true); } this.destroy = function(){ - JQ_WRAPPER.remove(); - balloon.destroy(); - balloon = null; delete instance.destroy; + + JQ_WRAPPER.stop().remove(); + balloon.destroy(); + JQ_WRAPPER = TEXT_ELM = data = balloon = instance = null; } } TextElementClass.prototype = new AbstractComicElement( PANEL_ELEMENT_TYPE_TEXT ); -- 2.11.0 From 490a4b439ac9bc67e4ed08f4b79dc809cc34cf97 Mon Sep 17 00:00:00 2001 From: itozyun Date: Sat, 28 Apr 2012 06:06:45 +0900 Subject: [PATCH 13/16] client is version0.4.27, added timer for appendChild, but still clash at ie7-. --- app/views/layouts/application.html.erb | 4 +- public/assets/common.js | 12 +-- public/assets/system.js | 133 ++++++++++++++++++--------------- public/assets/work.js | 18 ++--- 4 files changed, 88 insertions(+), 79 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 939ec7ec..2148d108 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -180,7 +180,7 @@
-
+
 
@@ -189,7 +189,7 @@
-
+
 
diff --git a/public/assets/common.js b/public/assets/common.js index eb4e36e7..88b1ef95 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1,6 +1,6 @@ /* * pettanR common.js - * version 0.4.26 + * version 0.4.27 * * author: itozyun */ @@ -108,7 +108,7 @@ var pettanr = ( function(){ IS_DEBUG = Type.isBoolean( URL_PARAMS.debug ) ? URL_PARAMS.debug : IS_LOCAL === true, jqWindow , jqDocument , jqBody; return { - version: '0.4.26', + version: '0.4.27', init: function(){ jqWindow = $( window); jqDocument = $( document); @@ -1823,8 +1823,8 @@ pettanr.balloon = ( function() { var XBROWSER_BALLOON_CLASS = function( w, h, a ){ var balloonElm = vectorEnabled === true ? ELM_BALLOON_ORIGIN.cloneNode( true ) : document.createElement( 'img' ), // pettanr.imageに変更 - path = balloonElm.getElementsByTagName( 'path')[ 0 ], - shape = balloonElm.getElementsByTagName( 'shape')[ 0 ], + path = balloonElm.getElementsByTagName( 'path' )[ 0 ], + shape = balloonElm.getElementsByTagName( 'shape' )[ 0 ], instance = this, l = ','; @@ -1989,9 +1989,9 @@ pettanr.image = ( function(){ var FetchImageControl = ( function(){ var TASK_LIST = []; - /* + /* * FetchClass original is - * + * * LICENSE: MIT? * URL: http://d.hatena.ne.jp/uupaa/20080413/1208067631 * AUTHOR: uupaa.js@gmail.com diff --git a/public/assets/system.js b/public/assets/system.js index f7010b8a..448f1e87 100644 --- a/public/assets/system.js +++ b/public/assets/system.js @@ -1,6 +1,6 @@ /* * pettanR system.js - * version 0.4.26 + * version 0.4.27 * * author: * itozyun @@ -1782,38 +1782,31 @@ pettanr.premiumSatge = pettanr.view.registerApplication( function(){ THUMB_PATH = BASE_PATH, // + 'thumbnail/', LIMIT_FILESIZE = 1024 * 10; // 10KB - var ImageGroupIconClass = function( INDEX, file ){ - var elmIconWrap = elmIconOrigin.cloneNode( true ), - elmIconTitle = pettanr.util.getElementsByClassName( elmIconWrap, 'image-group-item-title' )[ 0 ], - data = pettanr.driver._getAPI().getFileData( file ), - SRC = [ BASE_PATH, data.id, '.', data.ext ].join( ''), - LOW_SRC = data.filesize && data.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext ].join( '') : null, + var ImageGroupIconClass = function( INDEX, data ){ + var elmIconWrap = elmIconOrigin.cloneNode( true ), + elmIconTitle = pettanr.util.getElementsByClassName( elmIconWrap, 'image-group-item-title' )[ 0 ], + 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; + timer = null, + onEnterFlag = false, + instance = this; elmContainer.appendChild( elmIconWrap ); elmIconWrap.style.left = ( INDEX * itemW ) + 'px'; elmIconTitle.appendChild( document.createTextNode( data.filesize + 'bytes' ) ); - file.destroy(); - file = null; - 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; - elmIconTitle.firstChild.data = imgW + 'x' + imgH; - var zoom = 128 /( imgW > imgH ? imgW : imgH), - MATH_FLOOR = Math.floor - h = MATH_FLOOR( imgH *zoom ), - w = MATH_FLOOR( imgW *zoom ); + data.width = _imgW = _imgW || data.width || 64; + data.height = _imgH = _imgH || data.height || 64; + elmIconTitle.firstChild.data = _imgW + 'x' + _imgH; + var zoom = 128 /( _imgW > _imgH ? _imgW : _imgH ), + MATH_FLOOR = Math.floor, + h = MATH_FLOOR( _imgH * zoom ), + w = MATH_FLOOR( _imgW * zoom ); reversibleImage.elm.style.cssText = [ - 'width:', w, 'px;', - 'height:', h +'px;', - 'margin:', MATH_FLOOR( itemH /2 -h /2 ), 'px ', MATH_FLOOR( itemW /2 -w /2 ), 'px 0' + 'width:', w, 'px;', + 'height:', h, 'px;', + 'margin:', MATH_FLOOR( itemH / 2 - h / 2 ), 'px ', MATH_FLOOR( itemW / 2 - w / 2 ), 'px 0' ].join(''); reversibleImage.resize( w, h ); elmIconWrap.onclick = onClick; @@ -1823,30 +1816,40 @@ pettanr.premiumSatge = pettanr.view.registerApplication( function(){ onUpdateData = data; pettanr.premiumSatge.shutdown(); } - return { - onEnter: function(){ - if( onEnterFlag === true || data === null ) return; // data === null : destroyed - reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onImageLoad ); - elmIconWrap.appendChild( reversibleImage.elm ); - onEnterFlag = true; - }, - destroy: function(){ - reversibleImage && reversibleImage.destroy(); - // pettanr.util.removeAllChildren( elmIconWrap ); - elmContainer.removeChild( elmIconWrap ); - elmIconWrap.onclick = null; - reversibleImage = elmIconWrap = elmIconTitle = data = null; - delete this.destroy; - } + + function asyncDraw(){ + reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onImageLoad ); + elmIconWrap.appendChild( reversibleImage.elm ); + onEnterFlag = true; + timer = null; + } + + this.onEnter = function( delay ){ + timer = window.setTimeout( asyncDraw, delay ); + delete instance.onEnter; + } + this.destroy = function(){ + delete instance.destroy; + timer && window.clearTimeout( timer ); + reversibleImage && reversibleImage.destroy(); + pettanr.util.removeAllChildren( elmIconWrap ); + elmContainer.removeChild( elmIconWrap ); + elmIconWrap.onclick = ''; + reversibleImage = elmIconWrap = elmIconTitle = data = timer = null; } } function onEnterShowImage(){ var l = ICON_ARRAY.length, _start = -wrapX /itemW -1, - _end = _start + winW /itemW +1; - for( var i=0; i 1 && jqTextarea.attr( 'rows', --rows ); + } /* grobal method */ // this.rootElement = elmWrap; @@ -2032,12 +2050,11 @@ pettanr.textEditor = pettanr.view.registerApplication( function(){ this.MIN_WIDTH = 320; this.MIN_HEIGHT = 320; this.init = function(){ - instance.jqWrap = jqWrap = $( '#speach-editor-wrapper' ).hide(); + jqWrap = $( '#speach-editor-wrapper' ).hide(); jqTextarea = $( '#speach-editor' ).keydown( keyCancel ); - jqButton = $( '#speach-edit-complete-button').click( clickOK ); + 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(); @@ -2046,25 +2063,17 @@ pettanr.textEditor = pettanr.view.registerApplication( function(){ textElement = _textElement; onUpdateFunction = _onUpdateFunction || null; - var h = _textElement.h; - + jqWrap.show(); 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); + pettanr.ua.isIE === true && pettanr.ua.ieVersion <= 7 && setTimeout( textareaFitHeight, 0); } this.onPaneResize = function( _w, _h ){ - jqWrap.show().css( { + jqWrap.css( { left: textElement.x + panelX, top: textElement.y + panelY, width: textElement.w, @@ -2073,7 +2082,7 @@ pettanr.textEditor = pettanr.view.registerApplication( function(){ } this.onClose = function(){ jqWrap.hide(); - textElement = onUpdateFunction = null; + textElement = onUpdateFunction = null; } }); diff --git a/public/assets/work.js b/public/assets/work.js index 4a67e64b..d3e33973 100644 --- a/public/assets/work.js +++ b/public/assets/work.js @@ -1,6 +1,6 @@ /* * pettanR work.js - * version 0.4.26 + * version 0.4.27 * * author: * itozyun @@ -1484,7 +1484,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){ function edit(){ if( currentElement === null || currentElement.type !== PANEL_ELEMENT_TYPE_TEXT) return; pettanr.textEditor.bootInOverlay( PANEL_CONTROL.x(), PANEL_CONTROL.y(), currentElement ); - buttonBackOrForward( true); + buttonBackOrForward( true ); } function change(){ if( currentElement === null) return; @@ -2341,7 +2341,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){ })(); var JQ_WRAPPER = jqTextElementOrigin.clone( true ), - TEXT_ELM = JQ_WRAPPER.find( 'td,.speach-inner').eq( 0), + elmText = JQ_WRAPPER.find( 'td,.speach-inner' ).get( 0 ), type = data.balloon_template_id, text = ( function(){ var _speachs = data.speaches_attributes; @@ -2370,7 +2370,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){ } function updateText( _text ){ text = _text || text || ''; - TEXT_ELM.html( text ); + elmText.firstChild.data = text; } function resizeBalloon(){ balloon && balloon.resize( a, w, h ); @@ -2390,13 +2390,13 @@ pettanr.editor = pettanr.view.registerApplication( function(){ delete instance.init; } this.angle = function( _a ){ - _a !== undefined && instance.resize( undefined, undefined, undefined, undefined, _a ); + _a !== undefined && instance.resize( x, y, w, h, _a ); return a; } - this.text = function( _text){ + this.text = function( _text ){ if( _text && text !== _text) { HISTORY_CONTROL.saveState( updateText, text || '', _text ); - updateText( _text); + updateText( _text ); } return text; } @@ -2420,14 +2420,14 @@ pettanr.editor = pettanr.view.registerApplication( function(){ animate !== true && resizeBalloon(); } this.animate = function ( _x, _y, _w, _h, _a ){ - instance.resize( _x, _y, _w, _h, _a, true); + instance.resize( _x, _y, _w, _h, _a, true ); } this.destroy = function(){ delete instance.destroy; JQ_WRAPPER.stop().remove(); balloon.destroy(); - JQ_WRAPPER = TEXT_ELM = data = balloon = instance = null; + JQ_WRAPPER = elmText = data = balloon = instance = null; } } TextElementClass.prototype = new AbstractComicElement( PANEL_ELEMENT_TYPE_TEXT ); -- 2.11.0 From 8a4acb122d7beff7253904a989df5f85eb33a243 Mon Sep 17 00:00:00 2001 From: itozyun Date: Wed, 2 May 2012 13:52:19 +0900 Subject: [PATCH 14/16] client is version0.4.28, fixed to clash at ie6&7 when shutdown overlay. --- public/assets/common.js | 19 ++++++++++-------- public/assets/system.js | 8 ++++---- public/assets/work.js | 51 +++++++++++++++++++++++++------------------------ 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/public/assets/common.js b/public/assets/common.js index 88b1ef95..c1b19d6e 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1,6 +1,6 @@ /* * pettanR common.js - * version 0.4.27 + * version 0.4.28 * * author: itozyun */ @@ -108,7 +108,7 @@ var pettanr = ( function(){ IS_DEBUG = Type.isBoolean( URL_PARAMS.debug ) ? URL_PARAMS.debug : IS_LOCAL === true, jqWindow , jqDocument , jqBody; return { - version: '0.4.27', + version: '0.4.28', init: function(){ jqWindow = $( window); jqDocument = $( document); @@ -987,10 +987,10 @@ pettanr.overlay = ( function(){ } function onFadeOutComplete(){ - if( currentOverlay.rootElement && currentOverlay.rootElement.parentNode === ELM_CONTAINER ){ - ELM_CONTAINER.removeChild( currentOverlay.rootElement ); - } - currentOverlay = null; + currentOverlay.close(); + currentOverlay.rootElement.style.display = 'none'; + currentOverlay.rootElement.style.visibility = 'hidden'; + currentOverlay = null; } return { init: function(){ @@ -1019,7 +1019,10 @@ pettanr.overlay = ( function(){ opacity: '', top: document.documentElement.scrollTop || document.body.scrollTop }).fadeIn( onFadeInComplete ); - + + currentOverlay.rootElement.style.display = ''; + currentOverlay.rootElement.style.visibility = 'visible'; + ELM_CONTAINER.insertBefore( currentOverlay.rootElement, document.getElementById( 'overlay-close-button' )); if( Type.isArray( bootParams ) === true ){ @@ -1032,11 +1035,11 @@ pettanr.overlay = ( function(){ hide: function(){ if( visible === false) return; document.body.style.overflow = ''; + jqConteiner.stop().css( { filter: '', opacity: '' }).fadeOut( onFadeOutComplete ); - currentOverlay.close(); this.visible = visible = false; this.currentID = null; }, diff --git a/public/assets/system.js b/public/assets/system.js index 448f1e87..46c3f1d5 100644 --- a/public/assets/system.js +++ b/public/assets/system.js @@ -1,6 +1,6 @@ /* * pettanR system.js - * version 0.4.27 + * version 0.4.28 * * author: * itozyun @@ -2015,11 +2015,12 @@ pettanr.textEditor = pettanr.view.registerApplication( function(){ function clickOK(){ textElement && textElement.text( jqTextarea.val() ); - onUpdateFunction ? window.setTimeout( asyncCallback, 50 ) : pettanr.textEditor.shutdown(); + window.setTimeout( asyncCallback, 0 ); } function asyncCallback(){ - onUpdateFunction( textElement ); + onUpdateFunction && onUpdateFunction( textElement ); + onUpdateFunction = textElement = null; pettanr.textEditor.shutdown(); } @@ -2082,7 +2083,6 @@ pettanr.textEditor = pettanr.view.registerApplication( function(){ } this.onClose = function(){ jqWrap.hide(); - textElement = onUpdateFunction = null; } }); diff --git a/public/assets/work.js b/public/assets/work.js index d3e33973..8565e27d 100644 --- a/public/assets/work.js +++ b/public/assets/work.js @@ -1,6 +1,6 @@ /* * pettanR work.js - * version 0.4.27 + * version 0.4.28 * * author: * itozyun @@ -2556,7 +2556,30 @@ pettanr.editor = pettanr.view.registerApplication( function(){ function restoreReplaceElement( arg){ replaceComicElement( arg[ 0], arg[ 1]); } - + + function onImageSelect( data, isPanelPictureData ){ + if( isPanelPictureData !== true ){ + data = { + resource_picture:data, + x: Math.floor( panelW /2 - data.width /2 ), + y: Math.floor( panelH /2 - data.height /2 ), + z: -1, + t: PANEL_ELEMENT_ARRAY.length, + width: data.width, + height: data.height + } + } + var _panelElement = new ImageElementClass( data ); + _panelElement.init && _panelElement.init(); + appendComicElement( _panelElement ); + _panelElement.animate( undefined, undefined, data.width, data.height ); + SAVE( restoreComicElement, [ false, _panelElement], [ true, _panelElement], true ); + } + function onTextInput( _panelElement ){ + appendComicElement( _panelElement ); + SAVE( restoreComicElement, [ false, _panelElement ], [ true, _panelElement ], true ); + } + return { init: function(){ log = $( '#operation-catcher-log'); @@ -2661,24 +2684,6 @@ pettanr.editor = pettanr.view.registerApplication( function(){ } else { onImageSelect( data, true ); } - function onImageSelect( data, isPanelPictureData ){ - if( isPanelPictureData !== true ){ - data = { - resource_picture:data, - x: Math.floor( panelW /2 - data.width /2 ), - y: Math.floor( panelH /2 - data.height /2 ), - z: -1, - t: PANEL_ELEMENT_ARRAY.length, - width: data.width, - height: data.height - } - } - var _panelElement = new ImageElementClass( data ); - _panelElement.init && _panelElement.init(); - appendComicElement( _panelElement ); - _panelElement.animate( undefined, undefined, data.width, data.height ); - SAVE( restoreComicElement, [ false, _panelElement], [ true, _panelElement], true ); - } }, createTextElement: function( data ){ var _panelElement; @@ -2707,14 +2712,10 @@ pettanr.editor = pettanr.view.registerApplication( function(){ _panelElement.init(); onTextInput( _panelElement ); } - function onTextInput( _panelElement ){ - appendComicElement( _panelElement ); - SAVE( restoreComicElement, [ false, _panelElement ], [ true, _panelElement ], true ); - } } } })(); - + /* * end of COMIC_ELEMENT_CONTROL */ -- 2.11.0 From 2dc4a19e472009653fdeddd554debd0b744de8ef Mon Sep 17 00:00:00 2001 From: itozyun Date: Mon, 14 May 2012 08:40:23 +0900 Subject: [PATCH 15/16] Client is version0.4.29, added exportConsole. --- app/assets/stylesheets/common.css | 10 +++ app/assets/stylesheets/work.css | 91 +++++++++++--------- app/views/layouts/application.html.erb | 45 ++++++---- public/assets/common.js | 61 +++++++++----- public/assets/system.js | 4 +- public/assets/work.js | 146 +++++++++++++++++++++++---------- 6 files changed, 236 insertions(+), 121 deletions(-) diff --git a/app/assets/stylesheets/common.css b/app/assets/stylesheets/common.css index 2c05cd72..13ea61f3 100644 --- a/app/assets/stylesheets/common.css +++ b/app/assets/stylesheets/common.css @@ -1,3 +1,5 @@ +@charset "UTF-8"; + /* * pettanR * @@ -562,6 +564,11 @@ version: 2.7.0 left: 0; top: 0; } + .pettanr-comic-panel img { + position: absolute; + left: 0; + top: 0; + } .pettanr-comic-balloon .pettanr-comic-speach { position: absolute; top: 0; @@ -579,6 +586,9 @@ version: 2.7.0 text-align: center; vertical-align: middle; } + .pettanr-comic-speach td { + padding: 16.66%; + } .pettanr-comic-speach { table-layout: fixed; /* ie6で上下中央にテキストがならない対処。固定レイアウトアルゴリズムになるので負荷を下げるらしい */ } \ No newline at end of file diff --git a/app/assets/stylesheets/work.css b/app/assets/stylesheets/work.css index 0b32939b..3c1755c6 100644 --- a/app/assets/stylesheets/work.css +++ b/app/assets/stylesheets/work.css @@ -1,3 +1,5 @@ +@charset "UTF-8"; + /* * pettanR * @@ -75,21 +77,6 @@ -moz-border-radius: 5px; -webkit-border-radius: 5px; } - - /* Output Console - --------------------------------------------------------------------------------------*/ - #output-console-wrapper { - position: absolute; - width: 80%; - height: 80%; - background-color: #fff; - } - #output-area { - width: 100%; - height: 100%; - border: 1px outset #ccc; - outline: 1px; - } /* Console Common --------------------------------------------------------------------------------------*/ @@ -138,28 +125,33 @@ margin-top: 15px; color: #666; } - + + /* Field + --------------------------------------------------------------------------------------*/ + .field { + margin: 10px 0; + padding-bottom: 5px; + border-bottom: 1px solid #ccc; + } + .field-label { + display: inline-block; + width: 120px; + line-height: 22px; + color: #666; + cursor: pointer; + } + /* Comic Console --------------------------------------------------------------------------------------*/ #comic-console { } - .comic-console-label { - display: inline-block; - width: 120px; - line-height: 22px; - color: #666; - cursor: pointer; - } + .comic-console-value { width: 40px; text-align: right; } - .comic-console-line { - margin: 10px 0; - padding-bottom: 5px; - border-bottom: 1px solid #ccc; - } + #comic-console-title, #comic-console-height, #comic-console-width, @@ -174,12 +166,33 @@ text-align: center; } - #comic-console-button-container { - margin-top: 20px; - position: relative; - } + + /* Output Console + --------------------------------------------------------------------------------------*/ + + #output-console-wrapper { + } + #output-console-format-value { + width: 180px; + text-align: center + } + #output-console-option-value { + width: 180px; + text-align: left; + } + #output-console-button-container { + margin: 10px 0; + position: relative; + } + #output-area { + width: 100%; + height: 200px; + border: 1px outset #ccc; + outline: 1px; + margin-bottom: 20px; + } /* Upload Console --------------------------------------------------------------------------------------*/ @@ -968,19 +981,19 @@ line-height: 30px; *cursor: pointer; } - .current-option a, - .current-option a:link, - .current-option a:visited { - color: #e6e6ef; - background-color: #66f; - text-decoration: none; - } .option-container a:hover { color: #333; background-color: #ccf; text-decoration: none; *cursor: pointer; } + .current-option a, + .current-option a:link, + .current-option a:visited { + color: #e6e6ef; + background-color: #66f; + text-decoration: none; + } /* Information Window --------------------------------------------------------------------------------------*/ diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2148d108..b78281b9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -288,11 +288,6 @@
x
- - -
- -
@@ -346,28 +341,48 @@
+ +
+
Output Console
+
+
+ Format: + +
+
+ Options: + absolute-path +
+
+
generate
+
close
+
+ +
+
+
Create New Comic
-
- Title: +
+ Title: No Title
-
- Default Width: +
+ Default Width: 300
-
- Default Height: +
+ Default Height: 200
-
- Visible: +
+ Visible:
-
- Editable: +
+ Editable:
diff --git a/public/assets/common.js b/public/assets/common.js index c1b19d6e..da0a9e5d 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1,6 +1,6 @@ /* * pettanR common.js - * version 0.4.28 + * version 0.4.29 * * author: itozyun */ @@ -10,7 +10,7 @@ */ var Type = { isObject : function(v) { - return v !== null && Type.isArray(v) === false && typeof v === 'object'; + return v !== null && typeof v === 'object'; }, isFunction : function(v) { return typeof v === 'function'; @@ -665,7 +665,13 @@ pettanr.ua = ( function(){ pettanr.CONST = ( function(){ var isLocal = pettanr.LOCAL === true || pettanr.URL_PARAMS.exjson === false, isLocalhost = document.location.href.indexOf( 'http:\/\/localhost:3000\/' ) === 0, - PETTANR_ROOT_PATH = isLocalhost === true ? 'http:\/\/localhost:3000\/' : 'http:\/\/pettanr.heroku.com\/'; + PETTANR_ROOT_PATH = isLocalhost === true ? 'http:\/\/localhost:3000\/' : 'http:\/\/pettanr.heroku.com\/', + location = document.location.pathname, + deep = location.indexOf( '\/diary\/' ) !== -1 || + location.indexOf( '\/test\/' ) !== -1 || + location.indexOf( '\/help\/' ) !== -1 || + location.indexOf( '\/sitemap\/' ) !== -1 || + location.indexOf( '\/wiki\/' ) !== -1; return { PETTANR_ROOT_PATH: PETTANR_ROOT_PATH, @@ -674,7 +680,7 @@ pettanr.CONST = ( function(){ URL_COMICS_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'comics.json', URL_PANELS_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'panels.json', NS_PETTANR_COMIC: 'pettanr-comic', - RESOURCE_PICTURE_PATH: ( isLocal === true ? '' : PETTANR_ROOT_PATH) + 'resource_pictures\/', + RESOURCE_PICTURE_PATH: ( isLocal === true ? ( deep === true ? '..\/' : '' ) : PETTANR_ROOT_PATH ) + 'resource_pictures\/', CREATE_COMIC_JS: isLocal === true ? 'js\/create_new_comic.js' : PETTANR_ROOT_PATH + 'comics\/new.js', CREATE_PANEL_JS: isLocal === true ? 'js\/create_new_panel.js' : PETTANR_ROOT_PATH + 'panels\/new.js', UPLOAD_PICTURE_JS: isLocal === true ? 'js\/upload_picture.js' : PETTANR_ROOT_PATH + 'original_pictures\/new.js', @@ -752,12 +758,14 @@ pettanr.view = ( function(){ } var AbstractApplication = function(){ + var instance; this.displayName = 'app name'; this.ID = 'app id'; this.rootElement = null; this.parentElement = null; this.nextSibling = null; this.open = function( _w, _h /*, _option */ ){ + instance = this; if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){ if( Type.isHTMLElement( this.rootElement ) === true ){ // 小さすぎる!、と表示 @@ -782,6 +790,9 @@ pettanr.view = ( function(){ // overrride return true; } // false の場合、close の拒否 + this.addEventListener = function(){ + + } } AbstractApplication.prototype = new AbstractBasicPane(); @@ -1093,21 +1104,21 @@ pettanr.key = ( function(){ log.html( [ e.keyCode, e.shiftKey, e.ctrlKey, e.altKey, e.type].join( ',')); //keyOperationChatcher.val( ''); var cancel = false, - callback = e.type, + type = e.type, key = e.keyCode, overlayEnabled = pettanr.overlay.visible === true, currentViewID = overlayEnabled === true ? pettanr.overlay.currentID : pettanr.view.currentID; - if( callback === 'keypress') callback = 'keydown'; - if( pettanr.form.keyEventRellay( e ) === false){ + if( type === 'keypress') type = 'keydown'; + if( pettanr.form.keyEventRellay( e ) === false ){ var shift = e.shiftKey, ctrl = e.ctrlKey, l = KEYEVENT_ARRAY.length, d; if( key === 16 || e.shiftKey === true){ - shiftEnabled = callback !== 'keyup'; + shiftEnabled = type !== 'keyup'; } if( key === 17 || e.ctrlKey === true){ - ctrlEnabled = callback !== 'keyup'; + ctrlEnabled = type !== 'keyup'; } for( var i=0; i Date: Tue, 15 May 2012 08:36:51 +0900 Subject: [PATCH 16/16] fixed exportConsole --- public/assets/common.js | 21 +++++++++++---------- public/assets/work.js | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/public/assets/common.js b/public/assets/common.js index da0a9e5d..3711638a 100644 --- a/public/assets/common.js +++ b/public/assets/common.js @@ -1109,7 +1109,7 @@ pettanr.key = ( function(){ overlayEnabled = pettanr.overlay.visible === true, currentViewID = overlayEnabled === true ? pettanr.overlay.currentID : pettanr.view.currentID; if( type === 'keypress') type = 'keydown'; - if( pettanr.form.keyEventRellay( e ) === false ){ + if( pettanr.form.keyEventRellay( e ) === false ){ var shift = e.shiftKey, ctrl = e.ctrlKey, l = KEYEVENT_ARRAY.length, @@ -1855,18 +1855,19 @@ pettanr.balloon = ( function() { draw( a, w, h ); function draw( _a, _w, _h ){ - a = _a !== undefined ? _a : a; - w = _w !== undefined ? _w - PADDING_TOP * 2 : w; - h = _h !== undefined ? _h - PADDING_LEFT * 2 : h; + a = _a !== undefined ? _a : a; + _a = a;// - 90; + w = _w !== undefined ? _w - PADDING_TOP * 2 : w; + h = _h !== undefined ? _h - PADDING_LEFT * 2 : h; if( vectorEnabled === false){ - balloonElm.setAttribute( 'src', balloonUrlBuilder( a )); + balloonElm.setAttribute( 'src', balloonUrlBuilder( _a )); return; } var rx = w /2, ry = h /2, - tailRad = a * DEG_TO_RAD, + tailRad = _a * DEG_TO_RAD, tailX = rx +( rx +TAIL_HEIGHT ) * cos( tailRad ), tailY = ry +( ry +TAIL_HEIGHT ) * sin( tailRad ), startX, startY, endX, endY; @@ -1879,8 +1880,8 @@ pettanr.balloon = ( function() { for( var i = 45; i > 0.01; i /= 2){ d = ( tailDeg + i ) /2; - startRad = ( a + d ) * DEG_TO_RAD; - endRad = ( a - d ) * DEG_TO_RAD; + startRad = ( _a + d ) * DEG_TO_RAD; + endRad = ( _a - d ) * DEG_TO_RAD; _startX = rx +cos( startRad ) * rx; _startY = ry +sin( startRad ) * ry; @@ -1942,7 +1943,7 @@ pettanr.balloon = ( function() { function balloonUrlBuilder( _a ){ var d = 360 / NUM_BALLOON_IMAGE; - _a += 90 + d / 2; + _a = ( _a >= _a ? _a : _a + 360 ) + d / 2; return [ 'system_pictures\/_w', _a < 360 - d / 2 ? floor( _a / d ) : 0, '.gif' ].join( '' ); } this.elm = balloonElm; @@ -2057,7 +2058,7 @@ pettanr.image = ( function(){ timer = window.setTimeout( asyncCallback, 10 ); } function onLoad(){ - // if( finish === true ) return; // これがあると firefox3.6 で駄目、、、 + // if( finish === true ) return; // これがあると firefox3.6 で駄目、、、 // if( timer ) return; // これがあると safari3.2 で駄目、、、 finish = true; timer !== null && window.clearTimeout( timer ); diff --git a/public/assets/work.js b/public/assets/work.js index 166f374f..e9495ec1 100644 --- a/public/assets/work.js +++ b/public/assets/work.js @@ -1599,7 +1599,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){ balloonW = _w !== undefined ? _w : balloonW; balloonH = _h !== undefined ? _h : balloonH; balloonA = _a !== undefined ? _a : balloonA; - radA = balloonA *DEG_TO_RAD; + radA = balloonA * DEG_TO_RAD; tailX = FLOOR( ( ( COS( radA) /2 +0.5) *( balloonW +SIZE)) -SIZE /2); tailY = FLOOR( ( ( SIN( radA) /2 +0.5) *( balloonH +SIZE)) -SIZE /2); ELM_MOVER.style.left = tailX +'px'; @@ -1647,7 +1647,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){ ATAN( _mouseY /_mouseX) *RAD_TO_DEG +( _mouseX < 0 ? 180 : 0) : _mouseY > 0 ? 90 : -90 ); - currentText && currentText.angle( balloonA); + currentText && currentText.angle( Math.floor( balloonA + 0.5 )); INFOMATION_WINDOW.update( currentText); }, onFinish: function(){ @@ -2380,7 +2380,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){ } this.angle = function( _a ){ _a !== undefined && instance.resize( x, y, w, h, _a ); - return a; + return a >= 0 ? a : a + 360; } this.text = function( _text ){ if( _text && text !== _text) { @@ -2680,7 +2680,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){ data = { balloon_template_id:1, size: 1, - tail: 0, + tail: 90, x: Math.floor( panelW /2 - 100 +Math.random() *10 ), y: Math.floor( panelH /2 - 100 +Math.random() *10 ), z: -1, @@ -3651,7 +3651,7 @@ pettanr.outputConsole = pettanr.view.registerApplication( function(){ _panelElement = getPanelElementByTiming(); if( _panelElement === null ) break; - ELEMENT_ARRAY.push( _panelElement.type === 0 ? imageToJson( _panelElement ) : balloonToJson( _panelElement )); + ELEMENT_ARRAY.push( _panelElement.type === 0 ? getImageJsonGET( _panelElement ) : balloonToJson( _panelElement )); } return [ '{', cr, @@ -3666,13 +3666,30 @@ pettanr.outputConsole = pettanr.view.registerApplication( function(){ panelTimming !== -1 ? ( '"t": ' + panelTimming + ',' + cr ) : '', '"width": ', panelW, ',', cr, '"height": ', panelH, ',', cr, - '"panel_elements": {', cr, + '"panel_elements": [', cr, ELEMENT_ARRAY.join( ',' + cr ), cr, - '},', cr, + ']', cr, '}', cr, '}' ].join( '' ); } + function getImageJsonGET( _imageElement ){ + var cr = pettanr.LINE_FEED_CODE_TEXTAREA; + return [ + '{', cr, + '"resource_picture": {', cr, + '"id": ', _imageElement.resourcePicture().id, ',', cr, + '"ext": ', '"',_imageElement.resourcePicture().ext, '"', cr, + '},', cr, + '"x": ', _imageElement.x, ',', cr, + '"y": ', _imageElement.y, ',', cr, + '"z": ', _imageElement.z, ',', cr, + '"width": ', _imageElement.flipH() * _imageElement.w, ',', cr, + '"height": ', _imageElement.flipV() * _imageElement.h, ',', cr, + '"t": ', timing, cr, + '}' + ].join( ''); + } function getJsonPostString(){ timing = 0; @@ -3688,8 +3705,8 @@ pettanr.outputConsole = pettanr.view.registerApplication( function(){ _panelElement = getPanelElementByTiming(); if( _panelElement === null) break; _panelElement.type === 0 ? - IMAGE_ARRAY.push( imageToJson( _panelElement )) : - BALLOON_ARRAY.push( balloonToJson( _panelElement ) ); + IMAGE_ARRAY.push( [ '"new', timing, '": ', imageToJson( _panelElement ) ].join( '' )) : + BALLOON_ARRAY.push( [ '"new', timing, '": ', balloonToJson( _panelElement ) ].join( '' ) ); } return [ '{', cr, @@ -3717,7 +3734,7 @@ pettanr.outputConsole = pettanr.view.registerApplication( function(){ function imageToJson( _imageElement ){ var cr = pettanr.LINE_FEED_CODE_TEXTAREA; return [ - '"new', timing, '": {', cr, + '{', cr, '"resource_picture_id": ', _imageElement.resourcePicture().id, ',', cr, '"x": ', _imageElement.x, ',', cr, '"y": ', _imageElement.y, ',', cr, @@ -3732,7 +3749,7 @@ pettanr.outputConsole = pettanr.view.registerApplication( function(){ function balloonToJson( _textElement ){ var cr = pettanr.LINE_FEED_CODE_TEXTAREA; return [ - '"new', timing, '": {', cr, + '{', cr, '"balloon_template_id": ', 1, ',', cr, '"system_picture_id": ', 1, ',', cr, '"size": ', 1, ',', cr, -- 2.11.0