OSDN Git Service

client is version0.4.27, added timer for appendChild, but still clash at ie7-.
authoritozyun <itozyun@gmail.com>
Fri, 27 Apr 2012 21:06:45 +0000 (06:06 +0900)
committeritozyun <itozyun@gmail.com>
Fri, 27 Apr 2012 21:06:45 +0000 (06:06 +0900)
app/views/layouts/application.html.erb
public/assets/common.js
public/assets/system.js
public/assets/work.js

index 939ec7e..2148d10 100644 (file)
                                <div class="comic-element-wrapper text-element">\r
                                        <img>\r
                                        <div class="speach">\r
-                                               <div class="speach-inner"></div>\r
+                                               <div class="speach-inner">&nbsp;</div>\r
                                        </div>\r
                                </div>\r
                        </script>\r
                                <div class="comic-element-wrapper text-element">\r
                                        <img>\r
                                        <div class="speach">\r
-                                               <table><tr><td></td></tr></table>\r
+                                               <table><tr><td>&nbsp;</td></tr></table>\r
                                        </div>\r
                                </div>\r
                        </script>\r
index eb4e36e..88b1ef9 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
  * pettanR common.js\r
- *   version 0.4.26\r
+ *   version 0.4.27\r
  * \r
  * author: itozyun\r
  */\r
@@ -108,7 +108,7 @@ var pettanr = ( function(){
                IS_DEBUG = Type.isBoolean( URL_PARAMS.debug ) ? URL_PARAMS.debug : IS_LOCAL === true,\r
                jqWindow , jqDocument , jqBody;\r
        return {\r
-               version: '0.4.26',\r
+               version: '0.4.27',\r
                init: function(){\r
                        jqWindow = $( window);\r
                        jqDocument = $( document);\r
@@ -1823,8 +1823,8 @@ pettanr.balloon = ( function() {
 \r
        var XBROWSER_BALLOON_CLASS = function( w, h, a ){\r
                var balloonElm = vectorEnabled === true ? ELM_BALLOON_ORIGIN.cloneNode( true ) : document.createElement( 'img' ), // pettanr.imageに変更\r
-                       path = balloonElm.getElementsByTagName( 'path')[ 0 ],\r
-                       shape = balloonElm.getElementsByTagName( 'shape')[ 0 ],\r
+                       path = balloonElm.getElementsByTagName( 'path' )[ 0 ],\r
+                       shape = balloonElm.getElementsByTagName( 'shape' )[ 0 ],\r
                        instance = this,\r
                        l = ',';\r
                \r
@@ -1989,9 +1989,9 @@ pettanr.image = ( function(){
        var FetchImageControl = ( function(){\r
                var TASK_LIST = [];\r
 \r
-               /* 
+               /* \r
                 * FetchClass original is\r
-                * 
+                * \r
                 * LICENSE: MIT?\r
                 *  URL: http://d.hatena.ne.jp/uupaa/20080413/1208067631\r
                 *  AUTHOR: uupaa.js@gmail.com\r
index f7010b8..448f1e8 100644 (file)
@@ -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<l; ++i){
-                       _start < i && i < _end && ICON_ARRAY[ i ].onEnter();
+                       _end = _start + winW /itemW +1,
+                       _icon;
+               for( var i=0, c = 0; i<l; ++i){
+                       _icon = ICON_ARRAY[ i ];
+                       if( _start < i && i < _end && _icon.onEnter ){
+                               _icon.onEnter( c * 100 );
+                               c++;
+                       }
                }
                onEnterInterval !== null && window.clearTimeout( onEnterInterval );
                onEnterInterval = null;
@@ -1876,10 +1879,13 @@ pettanr.premiumSatge = pettanr.view.registerApplication( function(){
                                id:   artistID,
                                type: pettanr.driver.FILE_TYPE.ARTIST
                        })[ 0 ],
-                       _artistFile = ARTIST_ROOT_FILE.getChildFileByIndex( _index );
+                       _artistFile = ARTIST_ROOT_FILE.getChildFileByIndex( _index ),
+                       _file;
                if( _artistFile !== null ){
                        for(var i=0, l=_artistFile.getChildFileLength(); i<l; ++i ){
-                               ICON_ARRAY.push( new ImageGroupIconClass( i, _artistFile.getChildFileByIndex( i ) ));
+                               _file = _artistFile.getChildFileByIndex( i );
+                               ICON_ARRAY.push( new ImageGroupIconClass( i, pettanr.driver._getAPI().getFileData( _file ) ));
+                               _file.destroy();
                        }
                        elmName.firstChild.data = _artistFile.getName();
                        _artistFile.destroy();
@@ -2009,7 +2015,11 @@ pettanr.textEditor = pettanr.view.registerApplication( function(){
        
        function clickOK(){
                textElement && textElement.text( jqTextarea.val() );
-               onUpdateFunction && onUpdateFunction( textElement );
+               onUpdateFunction ? window.setTimeout( asyncCallback, 50 ) : pettanr.textEditor.shutdown();
+       }
+       
+       function asyncCallback(){
+               onUpdateFunction( textElement );
                pettanr.textEditor.shutdown();
        }
        
@@ -2023,6 +2033,14 @@ pettanr.textEditor = pettanr.view.registerApplication( function(){
                        return false;
                }       
        }
+       function textareaFitHeight(){
+               var rows = 0;
+               while( jqTextarea.height() < textElement.h ){
+                       rows++;
+                       jqTextarea.attr( 'rows', rows );
+               }
+               rows > 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;
        }
 });
 
index 4a67e64..d3e3397 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
  * pettanR work.js\r
- *   version 0.4.26\r
+ *   version 0.4.27\r
  *   \r
  * author:\r
  *   itozyun\r
@@ -1484,7 +1484,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){
                function edit(){\r
                        if( currentElement === null || currentElement.type !== PANEL_ELEMENT_TYPE_TEXT) return;\r
                        pettanr.textEditor.bootInOverlay( PANEL_CONTROL.x(), PANEL_CONTROL.y(), currentElement );\r
-                       buttonBackOrForward( true);\r
+                       buttonBackOrForward( true );\r
                }\r
                function change(){\r
                        if( currentElement === null) return;\r
@@ -2341,7 +2341,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){
                })();\r
                \r
                var JQ_WRAPPER = jqTextElementOrigin.clone( true ),\r
-                       TEXT_ELM = JQ_WRAPPER.find( 'td,.speach-inner').eq( 0),\r
+                       elmText = JQ_WRAPPER.find( 'td,.speach-inner' ).get( 0 ),\r
                        type     = data.balloon_template_id,\r
                        text     = ( function(){\r
                                var _speachs = data.speaches_attributes;\r
@@ -2370,7 +2370,7 @@ pettanr.editor = pettanr.view.registerApplication( function(){
                }\r
                function updateText( _text ){\r
                        text = _text || text || '';\r
-                       TEXT_ELM.html( text );\r
+                       elmText.firstChild.data = text;\r
                }\r
                function resizeBalloon(){\r
                        balloon && balloon.resize( a, w, h );\r
@@ -2390,13 +2390,13 @@ pettanr.editor = pettanr.view.registerApplication( function(){
                        delete instance.init;\r
                }\r
                this.angle = function( _a ){\r
-                       _a !== undefined && instance.resize( undefined, undefined, undefined, undefined, _a );\r
+                       _a !== undefined && instance.resize( x, y, w, h, _a );\r
                        return a;\r
                }\r
-               this.text = function( _text){\r
+               this.text = function( _text ){\r
                        if( _text && text !== _text) {\r
                                HISTORY_CONTROL.saveState( updateText, text || '', _text );\r
-                               updateText( _text);\r
+                               updateText( _text );\r
                        }\r
                        return text;\r
                }\r
@@ -2420,14 +2420,14 @@ pettanr.editor = pettanr.view.registerApplication( function(){
                        animate !== true && resizeBalloon();\r
                }\r
                this.animate = function ( _x, _y, _w, _h, _a ){\r
-                       instance.resize( _x, _y, _w, _h, _a, true);\r
+                       instance.resize( _x, _y, _w, _h, _a, true );\r
                }\r
                this.destroy = function(){\r
                        delete instance.destroy;\r
                        \r
                        JQ_WRAPPER.stop().remove();\r
                        balloon.destroy();\r
-                       JQ_WRAPPER = TEXT_ELM = data = balloon = instance = null;\r
+                       JQ_WRAPPER = elmText = data = balloon = instance = null;\r
                }\r
        }\r
        TextElementClass.prototype = new AbstractComicElement( PANEL_ELEMENT_TYPE_TEXT );\r