OSDN Git Service

Version 0.6.106, bugfix for X.EventDispatcher, cleanup X.Node, Image JSONP for Opera1...
[pettanr/clientJs.git] / 0.6.x / js / 02_dom / 06_XNodeCSS.js
index 643a8fd..f0f3309 100644 (file)
@@ -133,12 +133,12 @@ X_Node_CSS_objToCssText = function( obj ){
        },
        
 X_Node_CSS_IE_FILTER_FIX =
-               X.UA.IE && X.UA.IE < 9 && !X.UA.MacIE ?
+               X_UA.IE && X_UA.IE < 9 && !X_UA.MacIE ?
                        {
                                opacity : 1,
                                textShadow : 1
                        } :
-               9 <= X.UA.IE && X.UA.IE < 10 ? // == 9
+               9 <= X_UA.IE && X_UA.IE < 10 ? // == 9
                        {} :
                        {},
        
@@ -332,7 +332,7 @@ X_Node_CSS_PARAMS = ( function(){
                return ret;
        })(),
        
-X_Node_CSS__CLIP_SEPARATOR = X.UA.IE && X.UA.IE < 8 ? ' ' : ',',
+X_Node_CSS__CLIP_SEPARATOR = X_UA.IE && X_UA.IE < 8 ? ' ' : ',',
        
        /*
         * 
@@ -367,7 +367,7 @@ X_Node_CSS_Property = X.Class.create(
                                if( u !== 'px' ){
                                        this.value =
                                                u === 'em' ?
-                                                       v / this.xnode._getCharSize() :
+                                                       v / X_Node_CSS_getCharSize( this.xnode ) :
                                                        v / ( X_Node_CSS__UNIT_RATIO[ u ] || 1 );
                                };
                        },
@@ -392,7 +392,7 @@ X_Node_CSS_Property = X.Class.create(
                                        u === 'px' ?
                                                v :
                                        ( u === 'em' || ( u === '' && this.name === 'lineHeight' ) ) ?
-                                               v * this.xnode._getCharSize() :
+                                               v * X_Node_CSS_getCharSize( this.xnode ) :
                                        // u === '%'
                                                v / ( X_Node_CSS__UNIT_RATIO[ u ] || 1 );
                        },
@@ -870,7 +870,7 @@ var X_Node_CSS__GET_VALUE_WITH_UNIT = {
        
 var X_Node_CSS_SPECIAL_FIX =
        // ~IE8
-       X.UA.IE && X.UA.IE < 9 && !X.UA.MacIE?
+       X_UA.IE && X_UA.IE < 9 && !X_UA.MacIE?
                (function( obj ){
                        var test    = X_Node_CSS_SPECIAL_FIX_PROP,
                                filters = [],
@@ -909,7 +909,7 @@ var X_Node_CSS_SPECIAL_FIX =
                        return filters.join( ' ' );
                }) :
        // IE9 textShadow に filter を使用
-       X.UA.IE && 9 <= X.UA.IE && X.UA.IE < 10 ?
+       X_UA.IE && 9 <= X_UA.IE && X_UA.IE < 10 ?
                (function( obj ){
                        var test    = X_Node_CSS_SPECIAL_FIX_PROP,
                                filters = [], p, id, v;
@@ -1067,85 +1067,85 @@ Node.prototype.cssText = function( v ){
  * TODO
  * body に css attr がセットされた場合には X_ViewPort_baseFontSize をクリア
  */
-
-Node.prototype._getCharSize =
+var
+X_Node_CSS_getCharSize =
        window.getComputedStyle ?
-               (function(){
-                       X_Node_body._updateTimerID && X_Node_startUpdate();
-                       if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
-                       if( this._fontSize ) return this._fontSize;
-                       return this._fontSize = parseFloat( getComputedStyle( this._rawObject, null ).fontSize );
+               (function( that ){
+                       X_Node_updateTimerID && X_Node_startUpdate();
+                       if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+                       if( that._fontSize ) return that._fontSize;
+                       return that._fontSize = parseFloat( getComputedStyle( that._rawObject, null ).fontSize );
                }) :
 
        document.defaultView && document.defaultView.getComputedStyle ?
-               (function(){
-                       X_Node_body._updateTimerID && X_Node_startUpdate();
-                       if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
-                       if( this._fontSize ) return this._fontSize;
-                       return this._fontSize = parseFloat( document.defaultView.getComputedStyle( this._rawObject, null ).fontSize );
+               (function( that ){
+                       X_Node_updateTimerID && X_Node_startUpdate();
+                       if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+                       if( that._fontSize ) return that._fontSize;
+                       return that._fontSize = parseFloat( document.defaultView.getComputedStyle( that._rawObject, null ).fontSize );
                }) :
 
-       5.5 <= X.UA.IE ?
-               (function(){
+       5.5 <= X_UA.IE ?
+               (function( that ){
                        var font, vu, v, u, _v;
-                       X_Node_body._updateTimerID && X_Node_startUpdate();
-                       if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
-                       if( this._fontSize ) return this._fontSize;
+                       X_Node_updateTimerID && X_Node_startUpdate();
+                       if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+                       if( that._fontSize ) return that._fontSize;
                        
-                       font = this._rawObject.currentStyle.fontSize;
-                       //font = this._css && this._css.fontSize || '1em';
+                       font = that._rawObject.currentStyle.fontSize;
+                       //font = that._css && that._css.fontSize || '1em';
                        vu   = X_Node_CSS__splitValueAndUnit( font );
                        v    = vu[ 0 ];
                        u    = vu[ 1 ];
 
                        if( v === 0 ){
-                               if( v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return this._fontSize = v;
+                               if( v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return that._fontSize = v;
                        } else {
-                               if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
+                               if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return that._fontSize = v / _v;
                        };
                        switch( u ){
                                case 'px' :
-                                       return this._fontSize = v;
+                                       return that._fontSize = v;
                                case 'em' :
                                // body まで辿ってしまった場合は?
-                                       if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
+                                       if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v;
                                        break;
                                case '%' :
                                // body まで辿ってしまった場合は?
-                                       if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
+                                       if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v / 100;
                        };
                        return 0;
                }) :
        X_UA_DOM.W3C ?
-               (function(){
+               (function( that ){
                        var elm, v;
-                       X_Node_body._updateTimerID && X_Node_startUpdate();
-                       if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
-                       if( this._fontSize ) return this._fontSize;
+                       X_Node_updateTimerID && X_Node_startUpdate();
+                       if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+                       if( that._fontSize ) return that._fontSize;
 
-                       this._rawObject.appendChild( elm = document.createElement( 'span' ) );
+                       that._rawObject.appendChild( elm = document.createElement( 'span' ) );
                        elm.style.cssText = 'display:block;position:absolute;top:0;left:0;visivility:hidden;line-height:1;height:1em;';
                        elm.innerHTML = 'X';
                        v = elm.offsetHeight;
-                       this._rawObject.removeChild( elm );
-                       return this._fontSize = v;
+                       that._rawObject.removeChild( elm );
+                       return that._fontSize = v;
                }) :
        X_UA_DOM.IE4 ?
-               (function(){
+               (function( that ){
                        var font, vu, v, u, _v;
-                       X_Node_body._updateTimerID && X_Node_startUpdate();
-                       if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
-                       if( this._fontSize ) return this._fontSize;
+                       X_Node_updateTimerID && X_Node_startUpdate();
+                       if( that === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
+                       if( that._fontSize ) return that._fontSize;
                        
-                       if( this._css && ( font = this._css.fontSize ) ){
+                       if( that._css && ( font = that._css.fontSize ) ){
                                vu = X_Node_CSS__splitValueAndUnit( font );
                                v  = vu[ 0 ];
                                u  = vu[ 1 ];
                                
                                if( v === 0 ){
-                                       if( _v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return this._fontSize = _v;
+                                       if( _v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return that._fontSize = _v;
                                } else {
-                                       if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
+                                       if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return that._fontSize = v / _v;
                                };
                        } else {
                                v = 1;
@@ -1154,31 +1154,18 @@ Node.prototype._getCharSize =
 
                        switch( u ){
                                case 'px' :
-                                       return this._fontSize = v;
+                                       return that._fontSize = v;
                                case 'em' :
                                // body まで辿ってしまった場合は?
-                                       if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
+                                       if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v;
                                        break;
                                case '%' :
                                // body まで辿ってしまった場合は?
-                                       if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
+                                       if( that.parent ) return that._fontSize = X_Node_CSS_getCharSize( that.parent ) * v / 100;
                        };
                        return 0;
                }) :
-               // ie5?
-               (function(){
-                       var elm, v;
-                       if( this === X_Node_body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize;
-                       X_Node_body._updateTimerID && X_Node_startUpdate();
-                       if( this._fontSize ) return this._fontSize;
-                       
-                       elm = this._rawObject;
-                       elm.insertAdjacentHTML( 'BeforeEnd', '<span style="visivility:hidden;line-height:1;">X</span>' );
-                       elm = elm.children[ elm.children.length - 1 ];
-                       v   = elm.offsetHeight;
-                       elm.outerHTML = '';
-                       return this._fontSize = v * 0.75;
-               });
+               0;
 
 
 X.CSS = {
@@ -1195,7 +1182,7 @@ X.CSS = {
 var X_Node_CSS_Support, X_Node_CSS_SPECIAL_FIX_PROP;
 
 ( function(){
-       var testStyle = X.UA.IE4 ? {} : ( document.documentElement || document.createElement( 'div' ) ).style,
+       var testStyle = X_UA.IE4 ? {} : ( document.documentElement || document.createElement( 'div' ) ).style,
                temp      = testStyle.cssText,
                prefix    = X_Node_CSS_VENDER_PREFIX,
                vendors   = 'webkit,Webkit,Moz,moz,Ms,ms,O,o,khtml,Khtml'.split( ',' ),
@@ -1235,7 +1222,7 @@ var X_Node_CSS_Support, X_Node_CSS_SPECIAL_FIX_PROP;
        
        X_Node_CSS_SPECIAL_FIX_PROP =
                // ~IE8
-               X.UA.IE < 9 && !X.UA.MacIE ?
+               X_UA.IE < 9 && !X_UA.MacIE ?
                        {
                                filter          : 1,
                                opacity         : 2//, uinode ChromeNode で行う
@@ -1244,7 +1231,7 @@ var X_Node_CSS_Support, X_Node_CSS_SPECIAL_FIX_PROP;
                                //backgroundImage : 5
                        } :
                // IE9
-               9 <= X.UA.IE && X.UA.IE < 10 ?
+               9 <= X_UA.IE && X_UA.IE < 10 ?
                        {
                                filter          : 1//,
                                //textShadow      : 1