if( !lock++ ){\r
size = X.Dom.getSize();\r
( w !== size[ 0 ] || h !== size[ 1 ] ) &&\r
- X.Dom.dispatch( { type : X.Dom.Event.VIEW_RESIZED, w : w = size[ 0 ], h : h = size[ 1 ] } );\r
+ X.Dom.asyncDispatch( 0, { type : X.Dom.Event.VIEW_RESIZED, w : w = size[ 0 ], h : h = size[ 1 ] } );\r
X.Timer.once( 1, unlock );\r
};\r
};\r
delayResize = function(){\r
var size = X.Dom.getSize();\r
( w !== size[ 0 ] || h !== size[ 1 ] ) &&\r
- X.Dom.dispatch( { type : X.Dom.Event.VIEW_RESIZED, w : w = size[ 0 ], h : h = size[ 1 ] } );\r
+ X.Dom.asyncDispatch( 0, { type : X.Dom.Event.VIEW_RESIZED, w : w = size[ 0 ], h : h = size[ 1 ] } );\r
X.Timer.once( 1, unlock );\r
};\r
};\r
var size = X.Dom.getSize();\r
\r
X.UA.IE && X.UA.IE < 9 ?\r
- X.Timer.add( 100, resize ) :\r
+ X.Timer.add( 200, resize ) :\r
X.Dom.Node._window.listen( 'resize', resize ); \r
X.Dom.readyState = X.Dom.Event.XDOM_READY;\r
X.Dom.asyncDispatch( 0, { type : X.Dom.Event.XDOM_READY, w : size[ 0 ], h : size[ 1 ] } );\r
};\r
\r
\r
-Node.create = function( tag, opt_attr, opt_css ){\r
- Node._newByTag = true;\r
- return new Node( tag, opt_attr, opt_css );\r
+Node.create = function( tag, opt_attrs, opt_css ){\r
+ switch( Node._getType( tag ) ){\r
+ case Node.IS_STRING :\r
+ Node._newByTag = true;\r
+ return new Node( tag, opt_attrs, opt_css );\r
+ case Node.IS_HTML_STRING :\r
+ return X.Dom.parse( tag, true )[ 0 ];\r
+ };\r
};\r
Node.createText = function( text ){\r
Node._newByText = true;\r
if( this._xnodeType !== 1 ) return;\r
if( !this._xnodes ) this._xnodes = [];\r
\r
- Node._newByTag = true;\r
- xnode = new Node( tag, opt_attrs, opt_css );\r
- xnode.parent = this;\r
+ xnode = Node.create( tag, opt_attrs, opt_css );\r
\r
- this._root && this._reserveUpdate();\r
+ xnode.parent = this;\r
this._xnodes[ this._xnodes.length ] = xnode;\r
+ this._root && this._reserveUpdate();\r
return xnode;\r
};\r
\r
parentElement.insertBefore( this._actualCreate(), nextElement ) :\r
parentElement.appendChild( this._actualCreate() );\r
this._afterActualCreate();\r
+ \r
+ \r
return elm || this._rawNode;\r
} else\r
if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ) {\r
};\r
// id\r
if( this._dirty & X.Dom.Dirty.ID ){\r
- //this._id ?\r
- ( elm.id = this._id )// :\r
- //elm.removeAttribute( 'id' );\r
+ if( X.UA.IE && X.UA.IE < 7 ){\r
+ elm.id = this._id;\r
+ } else {\r
+ this._id ? ( elm.id = this._id ) : elm.removeAttribute( 'id' ); \r
+ };\r
};\r
// className\r
- if( this._dirty & X.Dom.Dirty.CLASSNAME ) elm.className = this._className;\r
+ if( this._dirty & X.Dom.Dirty.CLASSNAME ){\r
+ if( X.UA.IE && X.UA.IE < 7 ){\r
+ elm.className = this._className;\r
+ } else {\r
+ this._className ? ( elm.className = this._className ) : elm.removeAttribute( 'class' ); \r
+ };\r
+ };\r
// style\r
if( this._dirty & X.Dom.Dirty.CSS ){\r
if( this._cssText || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
if( this._dirty & X.Dom.Dirty.CONTENT ) elm.setAttribute( 'id', this._id || ( 'ie4uid' + xnode._uid ) );\r
\r
// className\r
- if( this._dirty & X.Dom.Dirty.CLASSNAME ) elm.className = this._className;\r
+ if( this._dirty & X.Dom.Dirty.CLASSNAME ){\r
+ this._className ? ( elm.className = this._className ) : elm.removeAttribute( 'class' );\r
+ };\r
// style\r
if( this._dirty & X.Dom.Dirty.CSS ){\r
if( this._cssText || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){\r
\r
elm.removeAttribute( 'id' ); // ?\r
document.all[ this._id || ( 'ie4uid' + this._uid ) ] = null; // ?\r
- if( !isChild ){\r
- //alert( elm.tagName + this._uid + '\n' + document.all[ this._id || ( 'ie4uid' + this._uid ) ] + '\n' + elm.innerHTML );\r
- elm.outerHTML = '';\r
- };\r
+ if( !isChild ) elm.outerHTML = '';\r
delete this._rawNode;\r
}) :\r
(function(){});\r
// pre タグ以下はスペースの置換は行わない
node.childNodes && node.childNodes.length && me( node, skip || noncleanup.indexOf( tag ) !== -1, head );
};
- textNode = false;
+ textNode = false;
break;
case 3 :
content = skip ? node.data : X.Dom.cleanupWhiteSpace( node.data );
createTree =
body.childNodes ?
- (function( xnode, childNodes, skipCleanup ){
+ (function( xnode, childNodes, skipCleanup, textarea ){
var i = 0,
j = 0,
l = childNodes.length,
child, _xnode, f, tag, text, _xtext, doc;
childNodes = X.copyArray( childNodes );
+ if( textarea ){
+ xnode.attr( 'value', xnode.text() );
+ for( l = xnode._xnodes.length; i < l; ++i ){
+ xnode._xnodes[ i ].destroy();
+ };
+ xnode._xnodes.length = 0;
+ delete xnode._xnodes;
+ return;
+ };
+
for( ; i < l; ++i ){
child = childNodes[ i ];
tag = child.tagName;
- if( ( child.nodeType !== 1 && child.nodeType !== 3 ) || tag === '!' ||
- ( tag && tag.charAt( 0 ) === '/' ) ){
+ if( ( child.nodeType !== 1 && child.nodeType !== 3 ) || tag === '!' || ( tag && tag.charAt( 0 ) === '/' ) ){
child.parentNode.removeChild( child );
continue;
};
continue;
} else {
//alert( '[' +xnode._tag + '>' + _xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] === ' + tag + ' ' + (child.childNodes ? child.childNodes.length : '' ) + ' Hit\n' + child.outerHTML );
- child.childNodes && child.childNodes.length && createTree( _xnode, child.childNodes, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ) );
+ child.childNodes && child.childNodes.length && createTree( _xnode, child.childNodes, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ), tag === 'TEXTAREA' );
};
_xtext = null;
f = true;
};
} else
if( _xnode._xnodeType === 3 ){
+
if( child.nodeType !== 3 ){
if( !( text = _xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){
console.log( '[' +xnode._tag + '>' + _xnode._uid + '] destroy ... ' );
};
}) :
body.children ?
- (function( xnode, children, skipCleanup ){
+ (function( xnode, children, skipCleanup, textarea ){
var parent = xnode,
xnodes = parent._xnodes,
l = xnodes && xnodes.length,
elm, tag, xtext, text;
//children = X.copyArray( children );
+ if( textarea ){
+ xnode.attr( 'value', xnode.text() );
+ for( l = xnode._xnodes.length; i < l; ++i ){
+ xnode._xnodes[ i ].destroy();
+ };
+ xnode._xnodes.length = 0;
+ delete xnode._xnodes;
+ return;
+ };
+
for( ; i < xnodes.length; ++i ){
xnode = xnodes[ i ];
xnode.parent = parent;
--i;
break;
} else {
- xnode._xnodes && xnode._xnodes.length && createTree( xnode, elm.children, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ) );
+ xnode._xnodes && xnode._xnodes.length && createTree( xnode, elm.children, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ), tag === 'TEXTAREA' );
!xnode._id && elm.setAttribute( 'id', 'ie4uid' + xnode._uid );//( elm.id = 'ie4uid' + xnode._uid );
elm.setAttribute( 'UID', xnode._uid );
xnodes.push.apply( xnodes, X.Dom.parse( body.innerHTML, true ) );
delete Node.skipCreate;
- //alert(n + ' ' + body.innerHTML);
-
createTree( r, body.childNodes || body.children );
- //r._dirty = X.Dom.Dirty.IE4_TEXTNODE_FIX;
i = xnodes.length;
Node._systemNode = s = r.create( 'div' ).className( 'hidden-sysyem-node' );
//alert( i + ' -> ' + xnodes.length );
+ Node._fontSizeNode = r.create( 'div' ).className( 'hidden-sysyem-node' ).cssText( 'line-height:1;height:1em;' ).text( 'X' );
+
+ r.appendAt( 0, Node._systemNode, Node._fontSizeNode );
+
r._startUpdate();
//xnodes.splice( xnodes.indexOf( s ), 1 ); // hide from api user
//alert(n + ' ' + body.innerHTML);
+
+ X.Timer.add( 200, X.Dom.Event._detectFontSize );
} );
+Node._fontSizeNode = null;
+X.Dom.Event._lastFontSize = 0;
+X.Dom.Event._detectFontSize = function(){
+ var size = Node._fontSizeNode._rawNode.offsetHeight;
+ if( X.Dom.Event._lastFontSize !== size ){
+ X.Dom.Event._lastFontSize && X.Dom.asyncDispatch( 0, { type : X.Dom.Event.BASE_FONT_RESIZED, size : size } );
+ X.Dom.Event._lastFontSize = size;
+ };
+};
* \r
*/\r
X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){\r
- var attrs = this._attrs, newAttrs, f;\r
+ var attrs = this._attrs, newAttrs, f, p;\r
\r
if( this._xnodeType !== 1 ) return this;\r
\r
}) :
X.UA.IE && 5.5 <= X.UA.IE ?
(function(){
+ if( this === Node.root && X.Dom.Event._lastFontSize ) return X.Dom.Event._lastFontSize;
var font = this._rawNode.currentStyle.fontSize,
vu = X.Dom.Style._Util._splitValueAndUnit( font ),
v = vu[ 0 ],