From 9f5ab564d20a8bd6438693146ae73209c78a2c5e Mon Sep 17 00:00:00 2001 From: itozyun Date: Mon, 13 Oct 2014 19:10:38 +0900 Subject: [PATCH] Version 0.6.103, cleanup. --- 0.6.x/js/02_dom/02_XNode.js | 616 ++++++++++++++++-------------- 0.6.x/js/02_dom/04_XBoxModel.js | 123 +++--- 0.6.x/js/02_dom/05_XNodeAttr.js | 62 ++- 0.6.x/js/02_dom/06_XNodeCSS.js | 303 ++++++++------- 0.6.x/js/02_dom/07_XNodeList.js | 20 +- 0.6.x/js/02_dom/08_XNodeSelector.js | 100 +++-- 0.6.x/js/02_dom/09_XHTMLParser.js | 99 +++-- 0.6.x/js/02_dom/22_XTreeBuilder.js | 14 +- 0.6.x/js/04_util/01_XNinjaIframe.js | 2 +- 0.6.x/js/04_util/03_XUtilImage.js | 12 +- 0.6.x/js/05_net/01_XNetXHR.js | 2 +- 0.6.x/js/05_net/02_XNetJSONP.js | 2 +- 0.6.x/js/05_net/04_XNetImage.js | 8 +- 0.6.x/js/06_audio/01_XHTML5Audio.js | 4 +- 0.6.x/js/06_audio/02_XSilverlightAudio.js | 6 +- 0.6.x/js/20_ui/00_XUI.js | 2 +- 0.6.x/js/20_ui/06_AbstractUINode.js | 46 +-- 0.6.x/js/20_ui/08_Box.js | 36 +- 0.6.x/js/20_ui/14_ChromeBox.js | 28 +- 0.6.x/js/20_ui/15_ScrollBox.js | 26 +- 0.6.x/js/20_ui/17_Text.js | 6 +- 0.6.x/js/20_ui/20_PageRoot.js | 4 +- 22 files changed, 769 insertions(+), 752 deletions(-) diff --git a/0.6.x/js/02_dom/02_XNode.js b/0.6.x/js/02_dom/02_XNode.js index 5cc5b5f..db20195 100644 --- a/0.6.x/js/02_dom/02_XNode.js +++ b/0.6.x/js/02_dom/02_XNode.js @@ -45,11 +45,16 @@ var X_Node_strictElmCreation = !X.UA.MacIE && X.UA.IE5678,// && !X.UA.MacIE; X_Node_useDocumentFragment = document.createDocumentFragment && ( !X.UA.IE || 5.5 <= X.UA.IE ) && document.createDocumentFragment(), - + + X_Node_newByTag = false, + + X_Node_newByText = false, + + X_Node_outerXNode = null, /* * Node( rawElement | rawTextnode | htmlString | textString ) */ - Node = X.Dom.Node = X.EventDispatcher.inherits( + Node = X.Node = X.EventDispatcher.inherits( 'XDomNode', X.Class.POOL_OBJECT, { @@ -72,11 +77,11 @@ var _id : null, _className : '', - _attrs : null, // X_Node_Attr + _attrs : null, // see X_Node_Attr _newAttrs : null, - _attrText : '', // X_Node_Attr.objToAttrText が必要な場合は false が入っている + _attrText : '', // X_Node_Attr_objToAttrText が必要な場合は false が入っている - _css : null, // X.Dom.Style + _css : null, // see X_Node_CSS _cssText : null, _fontSize : 0, @@ -87,10 +92,10 @@ var * TODO Node の継承ができない! */ Constructor : function( v ){ - var css, xnodes, xnode, parent, uid = Node._chashe.length; + var css, xnodes, xnode, parent, uid = X_Node_CHASHE.length; - if( Node._newByTag ){ - Node._newByTag = false; + if( X_Node_newByTag ){ + X_Node_newByTag = false; this._tag = v.toUpperCase(); this._xnodeType = 1; this._state = X_Node_State.DISPLAY_INLINE; // todo @@ -98,15 +103,15 @@ var css = arguments[ 2 ]; css && this[ X.Type.isString( css ) ? 'cssText' : 'css' ]( css ); } else - if( Node._newByText ){ - Node._newByText = false; + if( X_Node_newByText ){ + X_Node_newByText = false; this._text = v; this._xnodeType = 3; this._state = X_Node_State.DISPLAY_INLINE; } else { - if( 1 < arguments.length ) return new X.Dom.NodeList( arguments ); - if( X.Type.isArray( v ) && v.length ) return new X.Dom.NodeList( v ); - //if( !this || this.append !== Node.prototype.append ){ + if( 1 < arguments.length ) return new X_NodeList( arguments ); + if( X.Type.isArray( v ) && v.length ) return new X_NodeList( v ); + //if( !this || this.append !== X_Node_append ){ // return new Node( v ); //}; switch( X_Node_getType( v ) ){ @@ -147,9 +152,9 @@ var break; case X_Node_TYPE.HTML_STRING : case X_Node_TYPE.STRING : - if( xnodes = X_HtmlParser_parse( v, true ) && 1 < xnodes.length ) return new X.Dom.NodeList( xnodes ); + if( xnodes = X_HtmlParser_parse( v, true ) && 1 < xnodes.length ) return new X_NodeList( xnodes ); if( xnodes.length ) return xnodes[ 0 ]; - return Node.none; + return X_Node_none; case X_Node_TYPE.IMAGE : if( xnode = X_Node_getXNode( v ) ) return xnode; this._rawObject = v; @@ -166,13 +171,71 @@ var this._state = X_Node_State.DISPLAY_BLOCK; break; */ default : - if( Node.none ) return Node.none; + if( X_Node_none ) return X_Node_none; return; }; }; - Node._chashe[ this._uid = uid ] = this; - } + X_Node_CHASHE[ this._uid = uid ] = this; + }, + + create : X_Node_create, + + createAt : X_Node_createAt, + + createText : X_Node_createText, + + createTextAt : X_Node_createTextAt, + + clone : X_Node_clone, + + append : X_Node_append, + + appendAt : X_Node_appendAt, + + appendTo : X_Node_appendTo, + + appendToRoot : X_Node_appendToRoot, + + before : X_Node_before, // remove + + prevNode : X_Node_before, // -> prev + + after : X_Node_after, // remove + + nextNode : X_Node_after, // -> next + + replace : X_Node_replace, // remove + + swap : X_Node_replace, + + remove : X_Node_remove, + + empty : X_Node_empty, + + destroy : X_Node_destroy, // -> kill && kill event + + contains : X_Node_contains, + + getChildAt : X_Node_getChildAt, + + firstChild : X_Node_firstChild, + + lastChild : X_Node_lastChild, + + getOrder : X_Node_getOrder, + + className : X_Node_className, + addClass : X_Node_addClass, + removeClass : X_Node_removeClass, + toggleClass : X_Node_toggleClass, + hasClass : X_Node_hasClass, + + html : X_Node_html, + text : X_Node_text, + call : X_Node_call, + each : X_Node_each + } ); @@ -182,7 +245,7 @@ function X_Node_getType( v ){ if( v === window ) return X_Node_TYPE.WINDOW; if( v === document ) return X_Node_TYPE.DOCUMENT; if( v.constructor === Node ) return X_Node_TYPE.XNODE; - if( v.constructor === X.Dom.NodeList ) return X_Node_TYPE.XNODE_LIST; + if( v.constructor === X_NodeList ) return X_Node_TYPE.XNODE_LIST; if( X.Type.isHTMLElement( v ) ) return X_Node_TYPE.RAW_HTML; if( v.nodeType === 3 ) return X_Node_TYPE.RAW_TEXT; if( X.Type.isImage( v ) ) return X_Node_TYPE.IMAGE; @@ -203,27 +266,27 @@ function X_Node_getXNode( v ){ // fake TextNode too. if( X_UA_DOM.IE4 ){ uid = v.getAttribute( 'UID' ); - return uid && Node._chashe[ uid ]; + return uid && X_Node_CHASHE[ uid ]; }; - return v.UID && Node._chashe[ v.UID ]; + return v.UID && X_Node_CHASHE[ v.UID ]; case X_Node_TYPE.WINDOW : return X.ViewPort; case X_Node_TYPE.DOCUMENT : return X_ViewPort_document; case X_Node_TYPE.RAW_TEXT : - if( v.UID ) return Node._chashe[ v.UID ]; - for( chashe = Node._chashe, i = chashe.length; i; ){ - if( ( xnode = Node._chashe[ --i ] ) && ( xnode._rawObject === v ) ) return xnode; + if( v.UID ) return X_Node_CHASHE[ v.UID ]; + for( chashe = X_Node_CHASHE, i = chashe.length; i; ){ + if( ( xnode = X_Node_CHASHE[ --i ] ) && ( xnode._rawObject === v ) ) return xnode; }; }; }; -Node.create = function( tag, opt_attrs, opt_css ){ +X.Doc.create = Node.create = function( tag, opt_attrs, opt_css ){ var list, i; switch( X_Node_getType( tag ) ){ case X_Node_TYPE.STRING : - Node._newByTag = true; + X_Node_newByTag = true; return new Node( tag, opt_attrs, opt_css ); case X_Node_TYPE.HTML_STRING : list = X_HtmlParser_parse( tag, true ); @@ -233,48 +296,46 @@ Node.create = function( tag, opt_attrs, opt_css ){ return list[ 0 ]; }; }; -Node.createText = function( text ){ - Node._newByText = true; +X.Doc.createText = Node.createText = function( text ){ + X_Node_newByText = true; return new Node( text ); }; -Node.getRoot = function( xnode ){ +function X_Node_getRoot( xnode ){ return X_ViewPort_document; - //return xNode._body._rawObject.documentElement ? node : node.ownerDocument || node.document; + //return X_Node_body._rawObject.documentElement ? node : node.ownerDocument || node.document; }; // XMLかどうかを判別する -Node.isXmlDocument = +var X_Node_isXmlDocument = X_UA_DOM.IE4 ? X.emptyFunction : (function( root ){ if( X.Type.isBoolean( root.isXML ) ) return root.isXML; return root.isXML = root._rawObject.createElement( 'p' ).tagName !== root._rawObject.createElement( 'P' ).tagName; - }); - -Node._chashe = []; -Node.none = Node._chashe[ 0 ] = new Node(); -Node._html = null; // = Node._chashe[ 1 ] -Node._head = null; // = Node._chashe[ 2 ] -Node._body = null; // = Node._chashe[ 3 ] -Node._systemNode = null; // = Node._chashe[ ? ] - -Node._reserveRemoval = []; - -if( X_UA_DOM.IE4 ){ - Node.prototype._ie4getRawNode = function(){ - var elm = this._rawObject; + }), + X_Node_CHASHE = [], + X_Node_none = X_Node_CHASHE[ 0 ] = new Node(), + X_Node_html, // = X_Node_CHASHE[ 1 ] + X_Node_head, // = X_Node_CHASHE[ 2 ] + X_Node_body, // = X_Node_CHASHE[ 3 ] + X_Node_systemNode, // = X_Node_CHASHE[ ? ] + X_Node_fontSizeNode, + X_Node_reserveRemoval = []; + + +var X_Node__ie4getRawNode = X_UA_DOM.IE4 && function ( that ){ + var elm = that._rawObject; return elm || - ( ( elm = document.all[ 'ie4uid' + this._uid ] ) && ( this._rawObject = elm ) ) || - ( this._id && ( elm = document.all[ this._id ] ) ) && ( this._rawObject = elm ); + ( ( elm = document.all[ 'ie4uid' + that._uid ] ) && ( that._rawObject = elm ) ) || + ( that._id && ( elm = document.all[ that._id ] ) ) && ( that._rawObject = elm ); }; -}; /* -------------------------------------- * Create */ -Node.prototype.create = function( tag, opt_attrs, opt_css ){ +function X_Node_create( tag, opt_attrs, opt_css ){ var xnode; if( this._xnodeType !== 1 ) return; if( !this._xnodes ) this._xnodes = []; @@ -283,10 +344,10 @@ Node.prototype.create = function( tag, opt_attrs, opt_css ){ xnode.parent = this; this._xnodes[ this._xnodes.length ] = xnode; - this._root && this._reserveUpdate(); + this._root && X_Node_reserveUpdate(); return xnode; }; -Node.prototype.createAt = function( index, tag, opt_attrs, opt_css ){ +function X_Node_createAt( index, tag, opt_attrs, opt_css ){ var xnode = Node.create( tag, opt_attrs, opt_css ); this.appendAt( index, xnode ); return xnode; @@ -295,20 +356,20 @@ Node.prototype.createAt = function( index, tag, opt_attrs, opt_css ){ /* -------------------------------------- * CreateText */ -Node.prototype.createText = function( text ){ +function X_Node_createText( text ){ var xnode; if( this._xnodeType !== 1 ) return; if( !this._xnodes ) this._xnodes = []; - Node._newByText = true; + X_Node_newByText = true; xnode = new Node( text ); xnode.parent = this; - this._root && this._reserveUpdate(); + this._root && X_Node_reserveUpdate(); this._xnodes[ this._xnodes.length ] = xnode; return xnode; }; -Node.prototype.createTextAt = function( index, text ){ +function X_Node_createTextAt( index, text ){ var xtext = Node.createText( text ); this.appendAt( index, xtext ); return xtext; @@ -319,11 +380,11 @@ Node.prototype.createTextAt = function( index, text ){ * http://d.hatena.ne.jp/think49/20110724/1311472811 * http://d.hatena.ne.jp/uupaa/20100508/1273299874 */ -Node.prototype.clone = function( opt_clone_children ){ +function X_Node_clone( opt_clone_children ){ var xnode, xnodes, i, l; switch( this._xnodeType ){ case 1 : - Node._newByTag = true; + X_Node_newByTag = true; xnode = new Node( this._tag, X_Object_clone( this._attrs ), X_Object_clone( this._css ) ) .attr( { 'id' : this._id } ) .className( this._className ); @@ -334,7 +395,7 @@ Node.prototype.clone = function( opt_clone_children ){ }; return xnode; case 3 : - Node._newByText = true; + X_Node_newByText = true; xnode = new Node( this._text ); return xnode; @@ -349,7 +410,7 @@ Node.prototype.clone = function( opt_clone_children ){ * Node * HtmlElement の場合は内部使用専用 そのため event の破棄等しない */ -Node.prototype.append = function( v ){ +function X_Node_append( v ){ var i, l, xnodes, frg; if( this._xnodeType !== 1 ) return; @@ -383,9 +444,9 @@ Node.prototype.append = function( v ){ //}; };// else - //if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){ + //if( ( i = X_Node_reserveRemoval.indexOf( v ) ) !== -1 ){ // if( !this._state ) alert( 'xnode already destroyed!' ); - // Node._reserveRemoval.splice( i, 1 ); + // X_Node_reserveRemoval.splice( i, 1 ); //}; break; default : @@ -394,12 +455,12 @@ Node.prototype.append = function( v ){ v.parent = this; xnodes[ xnodes.length ] = v; - this._root && this._reserveUpdate(); + this._root && X_Node_reserveUpdate(); return this; }; -Node.prototype.appendAt = function( start, v ){ +function X_Node_appendAt( start, v ){ var xnodes, l, i; if( this._xnodeType !== 1 ) return this; @@ -447,9 +508,9 @@ Node.prototype.appendAt = function( start, v ){ //}; };// else - //if( ( i = Node._reserveRemoval.indexOf( v ) ) !== -1 ){ + //if( ( i = X_Node_reserveRemoval.indexOf( v ) ) !== -1 ){ // if( !this._state ) alert( 'xnode already destroyed!' ); - // Node._reserveRemoval.splice( i, 1 ); + // X_Node_reserveRemoval.splice( i, 1 ); //}; break; default : @@ -458,11 +519,11 @@ Node.prototype.appendAt = function( start, v ){ v.parent = this; this._xnodes.splice( start, 0, v ); - this._root && this._reserveUpdate(); + this._root && X_Node_reserveUpdate(); return this; }; -Node.prototype.appendTo = function( parent, opt_index ){ +function X_Node_appendTo( parent, opt_index ){ switch( X_Node_getType( parent ) ){ case X_Node_TYPE.RAW_HTML : parent = new Node( parent ); @@ -479,15 +540,15 @@ Node.prototype.appendTo = function( parent, opt_index ){ return this; }; -Node.prototype.appendToRoot = function( opt_index ){ - opt_index === undefined ? Node._body.append( this ) : Node._body.appendAt( opt_index, this ); +function X_Node_appendToRoot( opt_index ){ + opt_index === undefined ? X_Node_body.append( this ) : X_Node_body.appendAt( opt_index, this ); return this; }; /* -------------------------------------- * Before , After, Replace */ -Node.prototype.before = Node.prototype.prevNode = function( v ){ +function X_Node_before( v ){ var parent = this.parent, xnodes, i, l, start; // getter @@ -512,7 +573,7 @@ Node.prototype.before = Node.prototype.prevNode = function( v ){ return this; }; -Node.prototype.after = Node.prototype.nextNode = function( v ){ +function X_Node_after( v ){ var parent = this.parent, xnodes, i, l, start; // getter @@ -547,7 +608,7 @@ Node.prototype.after = Node.prototype.nextNode = function( v ){ return this; }; -Node.prototype.replace = function( v ){ +function X_Node_replace( v ){ if( !this.parent ) return this; return arguments.length === 1 ? this.before( v ).remove() : this.before.apply( this, arguments ).remove(); }; @@ -555,22 +616,22 @@ Node.prototype.replace = function( v ){ /* -------------------------------------- * Remove */ -Node.prototype.remove = function(){ +function X_Node_remove(){ var parent = this.parent; if( !parent ) return this; parent._xnodes.splice( parent._xnodes.indexOf( this ), 1 ); if( this._root ){ - Node._reserveRemoval[ Node._reserveRemoval.length ] = this; - this._reserveUpdate(); + X_Node_reserveRemoval[ X_Node_reserveRemoval.length ] = this; + X_Node_reserveUpdate(); }; delete this.parent; delete this._root; return this; }; -Node.prototype.empty = function(){ +function X_Node_empty(){ var xnodes = this._xnodes, i; if( xnodes && ( i = xnodes.length ) ){ for( ; i; ){ @@ -584,14 +645,14 @@ Node.prototype.empty = function(){ /* -------------------------------------- * destory */ -Node._destroyChildFlag = false; // TODO +// Node._destroyChildFlag = false; // TODO -Node.prototype.destroy = function( isChild ){ +function X_Node_destroy( isChild ){ var xnodes = this._xnodes, i, elm; if( !this._state ) return; - elm = this._rawObject || this._ie4getRawNode && this._ie4getRawNode(); + elm = this._rawObject || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this ); if( xnodes && ( i = xnodes.length ) ){ //for( ; i; ){ @@ -600,14 +661,14 @@ Node.prototype.destroy = function( isChild ){ }; elm && this._listeners && this.unlisten(); // イベントの退避 - delete Node._chashe[ this._uid ]; + delete X_Node_CHASHE[ this._uid ]; delete this._state; if( this._root ){ !isChild && this.remove(); } else { this.parent && this.parent._xnodes.splice( this.parent._xnodes.indexOf( this ), 1 ); - elm && !isChild && this._actualRemove(); + elm && !isChild && X_Node__actualRemove( this ); this.kill(); }; }; @@ -617,11 +678,11 @@ Node.prototype.destroy = function( isChild ){ /* -------------------------------------- * contains */ -Node.prototype.contains = function( v ){ +function X_Node_contains( v ){ var elm, type, xnodes, i; if( !v || this._xnodeType !== 1 ) return false; // contains ie4+ - if( ( elm = this._rawObject || this._ie4getRawNode && this._ie4getRawNode() ) && document.contains && ( type = X_Node_getType( v ) ) && ( type === X_Node_TYPE.RAW_HTML || type === X_Node_TYPE.RAW_TEXT ) ){ + if( ( elm = this._rawObject || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this ) ) && document.contains && ( type = X_Node_getType( v ) ) && ( type === X_Node_TYPE.RAW_HTML || type === X_Node_TYPE.RAW_TEXT ) ){ return elm.contains( v ); }; //if( document.compareDocumentPosition ){ @@ -640,7 +701,7 @@ Node.prototype.contains = function( v ){ /* -------------------------------------- * getChild */ -Node.prototype.getChildAt = function( i ){ +function X_Node_getChildAt( i ){ var xnodes = this._xnodeType === 1 && this._xnodes; return xnodes && 0 <= i && i < xnodes.length && xnodes[ i ]; }; @@ -649,17 +710,17 @@ Node.prototype.getChildAt = function( i ){ /* -------------------------------------- * firstChild, lastChild */ -Node.prototype.firstChild = function(){ +function X_Node_firstChild(){ return this.getChildAt( 0 ); }; -Node.prototype.lastChild = function(){ +function X_Node_lastChild(){ return this.getChildAt( this._xnodes.length - 1 ); }; /* -------------------------------------- * getOrder */ -Node.prototype.getOrder = function(){ +function X_Node_getOrder(){ var parent = this.parent; if( !parent ) return -1; return parent._xnodes.indexOf( this ); @@ -668,7 +729,7 @@ Node.prototype.getOrder = function(){ /* -------------------------------------- * className, addClass, removeClass, hasClass */ -Node.prototype.className = function( v ){ +function X_Node_className( v ){ var node, _, __; // getter if( v === undefined ) return this._className; @@ -689,10 +750,10 @@ Node.prototype.className = function( v ){ v ? ( this._className = v ) : delete this._className; }; this._dirty |= X_Node_Dirty.CLASSNAME; - this._root && this._reserveUpdate(); + this._root && X_Node_reserveUpdate(); return this; }; -Node.prototype.addClass = function( v ){ +function X_Node_addClass( v ){ var names = v.split( ' ' ), i = names.length, name; @@ -704,7 +765,7 @@ Node.prototype.addClass = function( v ){ }; return v ? this.className( this._className + ( this._className ? ' ' : '' ) + v ) : this; }; -Node.prototype.removeClass = function( v ){ +function X_Node_removeClass( v ){ var _ = ' ', className = this._className, names = v.split( _ ), @@ -723,7 +784,7 @@ Node.prototype.removeClass = function( v ){ }; return f ? this.className( classNames.join( _ ) ) : this; }; -Node.prototype.toggleClass = function( v, opt_toggle ){ +function X_Node_toggleClass( v, opt_toggle ){ var names, i, name; if( opt_toggle !== undefined ){ return !!opt_toggle ? this.addClass( v ) : this.removeClass( v ); @@ -735,7 +796,7 @@ Node.prototype.toggleClass = function( v, opt_toggle ){ }; return this; }; -Node.prototype.hasClass = function( v ){ +function X_Node_hasClass( v ){ var _ = ' ', className = this._className, i, name; @@ -757,9 +818,7 @@ Node.prototype.hasClass = function( v ){ * html, text */ -Node._outerFlag = null; - -Node.prototype.html = function( html ){ +function X_Node_html( html ){ var _ = '', q = '"', xnodes, n, i, l; // setter if( html !== undefined ){ // String 以外に Number や false null なども許可 @@ -772,38 +831,38 @@ Node.prototype.html = function( html ){ return this._text; }; - if( this._dirty & X_Node_Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ + if( this._dirty & X_Node_Dirty.CSS && !( this._cssText = X_Node_CSS_objToCssText( this._css ) ) ){ delete this._cssText; }; - html = !Node._outerFlag ? [] : [ + html = !X_Node_outerXNode ? [] : [ '<', this._tag, this._id ? ' id="' + this._id + q : _, this._className ? ' class="' + this._className + q : _, - this._attrText === false ? ( this._attrText = X_Node_Attr.objToAttrText( this._attrs ) ) : this._attrText, + this._attrText === false ? ( this._attrText = X_Node_Attr_objToAttrText( this._attrs ) ) : this._attrText, this._cssText ? ' style="' + this._cssText + q : _, '>' ]; n = html.length; if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){ - if( !Node._outerFlag ) Node._outerFlag = this; + if( !X_Node_outerXNode ) X_Node_outerXNode = this; for( i = 0; i < l; ++i ){ html[ n ] = xnodes[ i ].html(); ++n; }; - if( Node._outerFlag === this ) Node._outerFlag = null; + if( X_Node_outerXNode === this ) X_Node_outerXNode = null; }; - !Node._outerFlag || X_Dom_DTD_EMPTY[ this._tag ] || ( html[ n ] = '<\/' + this._tag + '>' ); + !X_Node_outerXNode || X_Dom_DTD_EMPTY[ this._tag ] || ( html[ n ] = '<\/' + this._tag + '>' ); return html.join( _ ); }; -Node.prototype.text = function( text ){ +function X_Node_text( text ){ var xnodes, texts, i, l; // setter if( text !== undefined ){ if( this._xnodeType === 3 ){ if( this._text !== text ){ text ? ( this._text = text ) : delete this.text; - this._root && this._reserveUpdate(); + this._root && X_Node_reserveUpdate(); this._dirty |= X_Node_Dirty.CONTENT; }; return this; @@ -832,8 +891,8 @@ Node.prototype.text = function( text ){ /* * HTML要素に対して name の関数を実行しその戻り値を返す。関数に渡す引数も任意に設定できる。 */ -Node.prototype.call = function( name /*, opt_args... */ ){ - var raw = this._rawObject || this._ie4getRawNode && this._ie4getRawNode(), +function X_Node_call( name /*, opt_args... */ ){ + var raw = this._rawObject || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this ), l = arguments.length - 1, func, args, params, i; if( !raw ) return; @@ -871,7 +930,7 @@ Node.prototype.call = function( name /*, opt_args... */ ){ * xnode を this として関数を実行する。 NodeList.each と動作を合わせてあるため関数の戻り値は破棄される。 * 関数に渡す引数も任意に設定できる。 */ -Node.prototype.each = function( func /*, opt_args */ ){ +function X_Node_each( func /*, opt_args */ ){ var args; if( 1 < arguments.length ){ args = X_Object_cloneArray( arguments ); @@ -900,28 +959,28 @@ Node.prototype.each = function( func /*, opt_args */ ){ * root._reserveRemoval にいたら消す, new_parent._xnodes に挿入 steta は not_added にして commitUpdate を待つ */ -Node.prototype._reserveUpdate = function(){ - var root = Node._body; - if( root && !root._updateTimerID ) root._updateTimerID = X.Timer.requestFrame( root, root._startUpdate ); +function X_Node_reserveUpdate(){ + var root = X_Node_body; + if( root && !root._updateTimerID ) root._updateTimerID = X.Timer.requestFrame( X_Node_startUpdate ); }; -Node.prototype._startUpdate = function(){ +function X_Node_startUpdate(){ var removal, i, xnode, tmp; if( X_ViewPort_readyState < X_TEMP.SYSTEM_EVENT_INIT ){ return; }; - if( this._updateTimerID ){ - X.Timer.cancelFrame( this._updateTimerID ); - this._updateTimerID = 0; + if( X_Node_body._updateTimerID ){ + X.Timer.cancelFrame( X_Node_body._updateTimerID ); + X_Node_body._updateTimerID = 0; } else { return; }; // このイベントでサイズを取ると無限ループに // X_ViewPort._listeners && X_ViewPort._listeners[ X.Event.BEFORE_UPDATE ] && X_ViewPort.dispatch( X.Dom.Event.BEFORE_UPDATE ); - removal = Node._reserveRemoval; + removal = X_Node_reserveRemoval; - tmp = this._rawObject.style.visibility; + //tmp = X_Node_body._rawObject.style.visibility; //this._rawObject.style.visibility = 'hidden'; //console.log( '_actualRemove().' ); @@ -929,15 +988,15 @@ Node.prototype._startUpdate = function(){ if( i = removal.length ){ for( ; i; ){ xnode = removal[ --i ]; - xnode._actualRemove(); - !this._state && xnode.kill(); + X_Node__actualRemove( xnode ); + !X_Node_body._state && xnode.kill(); }; removal.length = 0; }; //console.log( 'start _startUpdate().' ); - /* Node._html._dirty ? */ Node._html._commitUpdate() /* : this._commitUpdate() */; + /* X_Node_html._dirty ? */ X_Node__commitUpdate( X_Node_html ); /* : X_Node__commitUpdate( X_Node_body ); */; //console.log( 'end of _startUpdate().' ); @@ -945,150 +1004,150 @@ Node.prototype._startUpdate = function(){ //this._rawObject.style.visibility = tmp; }; -Node.prototype._commitUpdate = +var X_Node__commitUpdate = X_UA_DOM.W3C ? - ( function( parentElement, nextElement ){ - var elm = this._rawObject, + ( function( that, parentElement, nextElement ){ + var elm = that._rawObject, xnodes, l, i, frg, next, k, v; - if( this._state & X_Node_State.IE5_DISPLAY_NONE_FIX ){ - //alert( this._tag + ' ' + !!elm ); + if( that._state & X_Node_State.IE5_DISPLAY_NONE_FIX ){ + //alert( that._tag + ' ' + !!elm ); // filter の効いている要素だけdisplay:none が無視される模様。filter を切ればよい? // 親が、display:none の場合は? - elm && elm.parentNode && this._actualRemove(); + elm && elm.parentNode && X_Node__actualRemove( that ); return nextElement; }; if( !elm || ( parentElement && elm.parentNode !== parentElement ) || ( nextElement && elm.nextSibling !== nextElement ) ){ nextElement ? - parentElement.insertBefore( this._actualCreate(), nextElement ) : - parentElement.appendChild( this._actualCreate() ); - this._afterActualCreate(); + parentElement.insertBefore( X_Node__actualCreate( that ), nextElement ) : + parentElement.appendChild( X_Node__actualCreate( that ) ); + X_Node__afterActualCreate( that ); - return elm || this._rawObject; + return elm || that._rawObject; } else - if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ) { + if( ( xnodes = that._xnodes ) && ( l = xnodes.length ) ) { /*if( elm.childNodes.length !== l && ( frg = X_Node_useDocumentFragment ) ){ for( i = 0; i < l; ++i ){ - frg.appendChild( xnodes[ i ]._actualCreate( true ) ); + frg.appendChild( X_Node__actualCreate( xnodes[ i ], true ) ); }; elm.appendChild( frg ); for( i = 0; i < l; ++i ){ - xnodes[ i ]._afterActualCreate( true ); + X_Node__actualCreate( xnodes[ i ], true ); }; } else {*/ for( ; l; ){ - next = xnodes[ --l ]._commitUpdate( elm, next ); + next = X_Node__commitUpdate( xnodes[ --l ], elm, next ); }; //}; }; - delete this._fontSize; - this._dirty && this._updateRawNode( elm ); - if( this._state & X_Node_State.IE5_DISPLAY_NONE_FIX ){ + delete that._fontSize; + that._dirty && X_Node__updateRawNode( that, elm ); + if( that._state & X_Node_State.IE5_DISPLAY_NONE_FIX ){ return nextElement; }; return elm; }) : X_UA_DOM.IE4 ? - ( function( parentElement, prevElement ){ - var elm = this._rawObject || this._ie4getRawNode(), + ( function( that, parentElement, prevElement ){ + var elm = that._rawObject || X_Node__ie4getRawNode( that ), xnodes, l, i, html, text, prev; if( !elm ){ prevElement ? - prevElement.insertAdjacentHTML( 'AfterEnd', this._actualCreate() ) : - parentElement.insertAdjacentHTML( 'AfterBegin', this._actualCreate() ); - this._afterActualCreate(); - return this._rawObject || this._ie4getRawNode(); + prevElement.insertAdjacentHTML( 'AfterEnd', X_Node__actualCreate( that ) ) : + parentElement.insertAdjacentHTML( 'AfterBegin', X_Node__actualCreate( that ) ); + X_Node__afterActualCreate( that ); + return that._rawObject || X_Node__ie4getRawNode( that ); }; - xnodes = this._xnodes; + xnodes = that._xnodes; l = xnodes ? xnodes.length : 0; - if( this._dirty & X_Node_Dirty.IE4_TEXTNODE_FIX || ( this._state & X_Node_State.IE4_ONLY_TEXT && ( l !== 1 || xnodes[ 0 ]._xnodeType !== 3 ) ) ){ // 1 < l && elm.children.length === 0 + if( that._dirty & X_Node_Dirty.IE4_TEXTNODE_FIX || ( that._state & X_Node_State.IE4_ONLY_TEXT && ( l !== 1 || xnodes[ 0 ]._xnodeType !== 3 ) ) ){ // 1 < l && elm.children.length === 0 html = []; for( i = 0; i < l; ++i ){ - html[ i ] = xnodes[ i ]._actualCreate(); + html[ i ] = X_Node__actualCreate( xnodes[ i ] ); }; elm.innerHTML = html.join( '' ); for( i = 0; i < l; ++i ){ - xnodes[ i ]._afterActualCreate(); + X_Node__afterActualCreate( xnodes[ i ] ); }; - this._state &= ~X_Node_State.IE4_ONLY_TEXT; + that._state &= ~X_Node_State.IE4_ONLY_TEXT; } else - if( this._state & X_Node_State.IE4_ONLY_TEXT ){ // textNode が swap した場合の検出は、_root で行う + if( that._state & X_Node_State.IE4_ONLY_TEXT ){ // textNode が swap した場合の検出は、_root で行う text = xnodes[ 0 ]; if( text._dirty || !text._root ){ elm.innerHTML = text._text; delete text._dirty; - text._root = this._root; + text._root = that._root; }; } else if( l ){ for( i = 0; i < l; ++i ){ - prev = xnodes[ i ]._commitUpdate( elm, prev ); + prev = X_Node__commitUpdate( xnodes[ i ], elm, prev ); }; }; - delete this._fontSize; - this._dirty && this._updateRawNode( elm ); + delete that._fontSize; + that._dirty && X_Node__updateRawNode( that, elm ); return elm; }) : (function(){}); -Node.prototype._updateRawNode = +var X_Node__updateRawNode = X_UA_DOM.W3C ? - ( function( elm ){ + ( function( that, elm ){ var attrs, rename, k, v; // textNode - if( this._dirty & X_Node_Dirty.CONTENT ){ - elm.data = X_String_chrReferanceTo( this._text ); - delete this._dirty; + if( that._dirty & X_Node_Dirty.CONTENT ){ + elm.data = X_String_chrReferanceTo( that._text ); + delete that._dirty; return; }; // id - if( this._dirty & X_Node_Dirty.ID ){ - this._id ? ( elm.id = this._id ) : ( elm.id && elm.removeAttribute( 'id' ) ); + if( that._dirty & X_Node_Dirty.ID ){ + that._id ? ( elm.id = that._id ) : ( elm.id && elm.removeAttribute( 'id' ) ); }; // className - if( this._dirty & X_Node_Dirty.CLASSNAME ){ - this._className ? ( elm.className = this._className ) : ( elm.className && elm.removeAttribute( X.UA.IE5678 ? 'className' : 'class' ) ); // className は ie7-? + if( that._dirty & X_Node_Dirty.CLASSNAME ){ + that._className ? ( elm.className = that._className ) : ( elm.className && elm.removeAttribute( X.UA.IE5678 ? 'className' : 'class' ) ); // className は ie7-? // ie5 only if( X_Node_State.IE5_DISPLAY_NONE_FIX && elm.currentStyle.display === 'none' ){ - this._actualRemove(); - this._state |= X_Node_State.IE5_DISPLAY_NONE_FIX; + X_Node__actualRemove( that ); + that._state |= X_Node_State.IE5_DISPLAY_NONE_FIX; return; }; }; // style // TODO display:none の場合、更新をスキップ - if( this._dirty & X_Node_Dirty.CSS ){ - if( this._cssText !== null || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ + if( that._dirty & X_Node_Dirty.CSS ){ + if( that._cssText !== null || ( that._cssText = X_Node_CSS_objToCssText( that._css ) ) ){ X.UA.Opera78 || X.UA.NN6 ? - elm.setAttribute( 'style', this._cssText ) : // opera8用 - ( elm.style.cssText = this._cssText ); + elm.setAttribute( 'style', that._cssText ) : // opera8用 + ( elm.style.cssText = that._cssText ); } else { elm.style.cssText = ''; // IE5.5以下 Safari3.2 で必要 elm.removeAttribute( 'style' ); - delete this._cssText; + delete that._cssText; }; }; - if( this._dirty & X_Node_Dirty.IE_FILTER ){ - elm.style.filter = X.Dom.Style.SPECIAL_FIX( this._css ); + if( that._dirty & X_Node_Dirty.IE_FILTER ){ + elm.style.filter = X_Node_CSS_SPECIAL_FIX( that._css ); }; // attr // TODO display:none の場合、更新をスキップ - if( this._dirty & X_Node_Dirty.ATTR && ( attrs = this._newAttrs || this._attrs ) ){ - rename = X_Node_Attr.renameForDOM; + if( that._dirty & X_Node_Dirty.ATTR && ( attrs = that._newAttrs || that._attrs ) ){ + rename = X_Node_Attr_renameForDOM; for( k in attrs ){ if( !X.UA.MacIE && ( X.UA.IE5 || X.UA.IE55 ) ){ // IETester 5.5 ではエラーが出なかった.MultipulIE5.5 ではエラーが出たので - if( this._tag === 'TEXTAREA' && k === 'value' ){ + if( that._tag === 'TEXTAREA' && k === 'value' ){ elm.firstChild ? ( elm.firstChild.data = attrs[ k ] ) : elm.appendChild( document.createTextNode( attrs[ k ] ) ); @@ -1098,22 +1157,22 @@ Node.prototype._updateRawNode = // TODO IE では input, なぜか buttonも、type の変更が出来ない、object も 同値で置き換えようとしても不可 ( v = attrs[ k ] ) === undefined ? elm.removeAttribute( rename[ k ] || k ) : - ( elm[ rename[ k ] || k ] = X_Node_Attr.noValue[ k ] ? k : v ); + ( elm[ rename[ k ] || k ] = X_Node_Attr_noValue[ k ] ? k : v ); }; - delete this._newAttrs; + delete that._newAttrs; }; - delete this._dirty; + delete that._dirty; }) : X_UA_DOM.IE4 ? - ( function( elm ){ + ( function( that, elm ){ var attrs, rename, k, v; // fake textNode - if( this._dirty & X_Node_Dirty.CONTENT ){ - elm.innerText = this._text; - delete this._dirty; + if( that._dirty & X_Node_Dirty.CONTENT ){ + elm.innerText = that._text; + delete that._dirty; return; }; @@ -1122,41 +1181,41 @@ Node.prototype._updateRawNode = * title、className、id、lang、language には setAttribute でなく、element.id で直接読み書きできる */ // id - if( this._dirty & X_Node_Dirty.CONTENT ) elm.setAttribute( 'id', this._id || ( 'ie4uid' + xnode._uid ) ); + if( that._dirty & X_Node_Dirty.CONTENT ) elm.setAttribute( 'id', that._id || ( 'ie4uid' + xnode._uid ) ); // className - if( this._dirty & X_Node_Dirty.CLASSNAME ){ - this._className ? ( elm.className = this._className ) : elm.removeAttribute( 'class' ); + if( that._dirty & X_Node_Dirty.CLASSNAME ){ + that._className ? ( elm.className = that._className ) : elm.removeAttribute( 'class' ); }; // style - if( this._dirty & X_Node_Dirty.CSS ){ - if( this._cssText !== null || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ - elm.style.cssText = this._cssText; + if( that._dirty & X_Node_Dirty.CSS ){ + if( that._cssText !== null || ( that._cssText = X_Node_CSS_objToCssText( that._css ) ) ){ + elm.style.cssText = that._cssText; } else { elm.style.cssText = ''; elm.removeAttribute( 'style' ); - delete this._cssText; + delete that._cssText; }; }; - if( this._dirty & X_Node_Dirty.IE_FILTER ){ - this._rawObject.style.filter = X.Dom.Style.SPECIAL_FIX( this._css ); + if( that._dirty & X_Node_Dirty.IE_FILTER ){ + that._rawObject.style.filter = X_Node_CSS_SPECIAL_FIX( that._css ); }; // attr - if( this._dirty & X_Node_Dirty.ATTR && ( attrs = this._newAttrs || this._attrs ) ){ - rename = X_Node_Attr.renameForDOM; + if( that._dirty & X_Node_Dirty.ATTR && ( attrs = that._newAttrs || that._attrs ) ){ + rename = X_Node_Attr_renameForDOM; for( k in attrs ){ ( v = attrs[ k ] ) === undefined ? elm.removeAttribute( rename[ k ] || k ) : - this._tag === 'TEXTAREA' && k === 'value' ? + that._tag === 'TEXTAREA' && k === 'value' ? ( elm.innerText = v ) : - elm.setAttribute( rename[ k ] || k, X_Node_Attr.noValue[ k ] ? k : v ); // TODO X_Node_Attr.noValue[ k ] ? k : v + elm.setAttribute( rename[ k ] || k, X_Node_Attr_noValue[ k ] ? k : v ); // TODO X_Node_Attr_noValue[ k ] ? k : v }; - delete this._newAttrs; + delete that._newAttrs; }; - delete this._dirty; + delete that._dirty; }) : (function(){}); @@ -1177,39 +1236,39 @@ Node.prototype._updateRawNode = * * document.createElement of ie4 is only for OPTION & IMAGE. */ -Node.prototype._actualCreate = - X_UA_DOM.W3C ? (function( isChild ){ - var elm = this._rawObject, +var X_Node__actualCreate = + X_UA_DOM.W3C ? (function( that, isChild ){ + var elm = that._rawObject, xnodes, frg, i, l; - if( this._xnodeType === 3 ){ + if( that._xnodeType === 3 ){ if( elm ) return elm; - delete this._dirty; - return this._rawObject = document.createTextNode( X_String_chrReferanceTo( this._text ) ); + delete that._dirty; + return that._rawObject = document.createTextNode( X_String_chrReferanceTo( that._text ) ); }; if( !elm ){ - if( this._dirty & X_Node_Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ - delete this._cssText; + if( that._dirty & X_Node_Dirty.CSS && !( that._cssText = X_Node_CSS_objToCssText( that._css ) ) ){ + delete that._cssText; }; - this._isNew = true; - this._rawObject = elm = + that._isNew = true; + that._rawObject = elm = X_Node_strictElmCreation ? document.createElement( [ - '<', this._tag, - ' UID="', this._uid, '"', - this._id ? ' id="' + this._id + '"' : '', - this._className ? ' class="' + this._className + '"' : '', - this._attrText === false ? ( this._attrText = X_Node_Attr.objToAttrText( this._attrs ) ) : this._attrText, - this._cssText ? ' style="' + this._cssText + '"' : '', + '<', that._tag, + ' UID="', that._uid, '"', + that._id ? ' id="' + that._id + '"' : '', + that._className ? ' class="' + that._className + '"' : '', + that._attrText === false ? ( that._attrText = X_Node_Attr_objToAttrText( that._attrs ) ) : that._attrText, + that._cssText ? ' style="' + that._cssText + '"' : '', '>' ].join( '' ) ) : - document.createElement( this._tag ); + document.createElement( that._tag ); }; if( X_Node_useDocumentFragment ){ - if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){ + if( ( xnodes = that._xnodes ) && ( l = xnodes.length ) ){ !isChild && ( frg = X_Node_useDocumentFragment ).appendChild( elm ); for( i = 0; i < l; ++i ){ - elm.appendChild( xnodes[ i ]._actualCreate( true ) ); + elm.appendChild( X_Node__actualCreate( xnodes[ i ], true ) ); }; return frg || elm; }; @@ -1217,159 +1276,156 @@ Node.prototype._actualCreate = return elm; }) : - X_UA_DOM.IE4 ? (function( isChild ){ - var uid = this._uid, + X_UA_DOM.IE4 ? (function( that, isChild ){ + var uid = that._uid, html, xnodes, n, i, l; - if( this._xnodeType === 3 ){ - html = [ '', this._text, '' ];// fake textNode - delete this._rawObject; + if( that._xnodeType === 3 ){ + html = [ '', that._text, '' ];// fake textNode + delete that._rawObject; } else { - if( this._rawObject && !isChild ) this._actualRemove( true ); + if( that._rawObject && !isChild ) X_Node__actualRemove( that, true ); - if( this._dirty & X_Node_Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ - delete this._cssText; + if( that._dirty & X_Node_Dirty.CSS && !( that._cssText = X_Node_CSS_objToCssText( that._css ) ) ){ + delete that._cssText; }; html = [ - '<', this._tag, ' id=', ( this._id || ( 'ie4uid' + uid ) ), ' UID="', uid, '"', - this._className ? ' class="' + this._className + '"' : '', - this._attrText === false ? ( this._attrText = X_Node_Attr.objToAttrText( this._attrs ) ) : this._attrText, - this._cssText ? ' style="' + this._cssText + '"' : '', + '<', that._tag, ' id=', ( that._id || ( 'ie4uid' + uid ) ), ' UID="', uid, '"', + that._className ? ' class="' + that._className + '"' : '', + that._attrText === false ? ( that._attrText = X_Node_Attr_objToAttrText( that._attrs ) ) : that._attrText, + that._cssText ? ' style="' + that._cssText + '"' : '', '>' ]; n = html.length; - if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){ + if( ( xnodes = that._xnodes ) && ( l = xnodes.length ) ){ if( l === 1 && xnodes[ 0 ]._xnodeType === 3 ){ // only textnode html[ n ] = xnodes[ 0 ]._text; ++n; - this._state |= X_Node_State.IE4_ONLY_TEXT; + that._state |= X_Node_State.IE4_ONLY_TEXT; } else { for( i = 0; i < l; ++i ){ - html[ n ] = xnodes[ i ]._actualCreate( true ); + html[ n ] = X_Node__actualCreate( xnodes[ i ], true ); ++n; }; }; }; - X_Dom_DTD_EMPTY[ this._tag ] || ( html[ n ] = '<\/' + this._tag + '>' ); + X_Dom_DTD_EMPTY[ that._tag ] || ( html[ n ] = '<\/' + that._tag + '>' ); - delete this._newAttrs; + delete that._newAttrs; }; return html.join( '' ); }) : (function(){}); -Node.prototype._afterActualCreate = - X_UA_DOM.W3C ? (function(){ - var elm = this._rawObject, xnodes, l, attrs, k, i; +var X_Node__afterActualCreate = + X_UA_DOM.W3C ? (function( that ){ + var elm = that._rawObject, xnodes, l, attrs, k, i; - this._root = this.parent._root; + that._root = that.parent._root; - if( this._xnodeType === 3 ){ - this._dirty && this._updateRawNode( elm ); - return this; + if( that._xnodeType === 3 ){ + that._dirty && X_Node__updateRawNode( that, elm ); + return that; }; - xnodes = this._xnodes; + xnodes = that._xnodes; l = xnodes && xnodes.length; - if( this._isNew ){ + if( that._isNew ){ if( !X_Node_useDocumentFragment && l ){// docFrg が使えない場合、doc 追加後に子を追加 for( i = 0; i < l; ++i ){ - elm.appendChild( xnodes[ i ]._actualCreate( true ) ); + elm.appendChild( X_Node__actualCreate( xnodes[ i ], true ) ); }; }; if( X_Node_strictElmCreation ){ - if( this._dirty & X_Node_Dirty.IE_FILTER ){ - elm.style.filter = X.Dom.Style.SPECIAL_FIX( this._css ); + if( that._dirty & X_Node_Dirty.IE_FILTER ){ + elm.style.filter = X_Node_CSS_SPECIAL_FIX( that._css ); }; - delete this._dirty; + delete that._dirty; } else { - elm.UID = this._uid; - this._newAttrs = this._attrs; - this._dirty = X_Node_Dirty.ID | X_Node_Dirty.CLASSNAME | X_Node_Dirty.CSS | X_Node_Dirty.ATTR | X_Node_Dirty.IE_FILTER; - this._updateRawNode( elm ); + elm.UID = that._uid; + that._newAttrs = that._attrs; + that._dirty = X_Node_Dirty.ID | X_Node_Dirty.CLASSNAME | X_Node_Dirty.CSS | X_Node_Dirty.ATTR | X_Node_Dirty.IE_FILTER; + X_Node__updateRawNode( that, elm ); }; - delete this._isNew; + delete that._isNew; } else { - this._dirty && this._updateRawNode( elm ); + that._dirty && X_Node__updateRawNode( that, elm ); }; for( i = 0; i < l; ++i ){ - xnodes[ i ]._afterActualCreate(); + X_Node__afterActualCreate( xnodes[ i ] ); }; // src の onload があるので先ではないか? // ie の str から要素を作る場合、srcだけ イベント設定後ではないか? - X_EventDispatcher_toggleAllEvents( this, true );// イベントの復帰 + X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰 }) : - X_UA_DOM.IE4 ? (function(){ + X_UA_DOM.IE4 ? (function( that ){ var xnodes, i; - this._root = this.parent._root; + that._root = that.parent._root; - if( this._xnodeType !== 1 ) return this; + if( that._xnodeType !== 1 ) return that; - if( ( xnodes = this._xnodes ) && ( i = xnodes.length ) ){ + if( ( xnodes = that._xnodes ) && ( i = xnodes.length ) ){ for( ; i; ){ - xnodes[ --i ]._afterActualCreate(); + X_Node__afterActualCreate( xnodes[ --i ] ); }; }; // textarea への value の適用はここで - if( this._dirty & X_Node_Dirty.IE_FILTER ){ - this._ie4getRawNode().style.filter = X.Dom.Style.SPECIAL_FIX( this._css ); + if( that._dirty & X_Node_Dirty.IE_FILTER ){ + X_Node__ie4getRawNode( that ).style.filter = X_Node_CSS_SPECIAL_FIX( that._css ); }; - delete this._dirty; - X_EventDispatcher_toggleAllEvents( this, true );// イベントの復帰 + delete that._dirty; + X_EventDispatcher_toggleAllEvents( that, true );// イベントの復帰 }) : (function(){}); -Node.prototype._actualRemove = +var X_Node__actualRemove = X_UA_DOM.W3C ? - ( function( isChild ){ - var xnodes = this._xnodes, - elm = this._rawObject, + ( function( that, isChild ){ + var xnodes = that._xnodes, + elm = that._rawObject, child, i, l; if( xnodes && ( l = xnodes.length ) ){ for( i = 0; i < l; ++i ){ child = xnodes[ i ]; - child._xnodeType === 1 && child._actualRemove( true ); + child._xnodeType === 1 && X_Node__actualRemove( child, true ); }; }; if( !elm ) return; - this._xnodeType === 1 && X_EventDispatcher_toggleAllEvents( this, false );// イベントの退避 + that._xnodeType === 1 && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避 // elm.parentNode.tagName for ie7 if( !X.UA.MacIE ){ !isChild && elm.parentNode && elm.parentNode.tagName && elm.parentNode.removeChild( elm ); } else { - !isChild && elm.parentNode && elm.parentNode.tagName && X_TEMP._fixed_remove( elm, this ); + !isChild && elm.parentNode && elm.parentNode.tagName && X_TEMP._fixed_remove( elm, that ); }; }) : X_UA_DOM.IE4 ? - ( function( isChild ){ - var xnodes = this._xnodes, - elm = this._rawObject || this._ie4getRawNode(), + ( function( that, isChild ){ + var xnodes = that._xnodes, + elm = that._rawObject || X_Node__ie4getRawNode( that ), i, l, xnode; if( xnodes && ( l = xnodes.length ) ){ for( i = 0; i < l; ++i ){ - xnodes[ i ]._actualRemove( true ); + X_Node__actualRemove( xnodes[ i ], true ); }; }; if( !elm ) return; - this._xnodeType === 1 && X_EventDispatcher_toggleAllEvents( this, false );// イベントの退避 + that._xnodeType === 1 && X_EventDispatcher_toggleAllEvents( that, false );// イベントの退避 - if( X_Node_Attr.HAS_VALUE[ this._tag ] && ( !this._newAttrs || !X_Object_inObject( 'value', this._newAttrs ) ) ){ - this._attrs.value = elm.value; + if( X_Node_Attr_HAS_VALUE[ that._tag ] && ( !that._newAttrs || !X_Object_inObject( 'value', that._newAttrs ) ) ){ + that._attrs.value = elm.value; }; elm.removeAttribute( 'id' ); // ? - //document.all[ this._id || ( 'ie4uid' + this._uid ) ] = null; // MacIE5 でエラー + //document.all[ that._id || ( 'ie4uid' + that._uid ) ] = null; // MacIE5 でエラー if( !isChild ) elm.outerHTML = ''; - delete this._rawObject; + delete that._rawObject; }) : (function(){}); - -console.log( 'X.Dom.Node' ); - diff --git a/0.6.x/js/02_dom/04_XBoxModel.js b/0.6.x/js/02_dom/04_XBoxModel.js index d6b1cb9..639ed3a 100644 --- a/0.6.x/js/02_dom/04_XBoxModel.js +++ b/0.6.x/js/02_dom/04_XBoxModel.js @@ -1,4 +1,4 @@ -X.Dom.BoxModel = { +var X_Node_BoxModel = { CONTENT_BOX : 1, PADDING_BOX : 2, BORDER_BOX : 3, @@ -7,51 +7,22 @@ X.Dom.BoxModel = { boxSizingEnabled : false, // TODO: offsetLeft, offsetTop の基準位置 - absoluteOffset : 0, - - vScrollbarSize : 0, - hScrollbarSize : 0 + absoluteOffset : 0 }; -X.ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){ - - var node = Node._systemNode, - - // http://jsdo.it/imaya/kTYg - body = document.body, - defaultOverflow = document.body.style.overflow, - width, height; - - body.style.overflow = 'hidden'; - w = body.clientWidth; - h = body.clientHeight; - - body.style.overflow = 'scroll'; - w -= body.clientWidth; - h -= body.clientHeight; - - if( !w ) w = body.offsetWidth - body.clientWidth; - if( !h ) h = body.offsetHeight - body.clientHeight; - body.style.overflow = defaultOverflow; - - X.Dom.BoxModel.vScrollbarSize = w; - X.Dom.BoxModel.hScrollbarSize = h; - if( h <= 0 ){ // ie6, ie11, firefox で 負の値が返る - console.log( 'invalid hScrollbarSize: ' + h ); - X.Dom.BoxModel.hScrollbarSize = w; - }; - // +X_ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){ + var node = X_Node_systemNode; node.cssText( 'width:10px;padding:1px;border:2px solid #0;margin:4px;' ); - X.Dom.BoxModel.defaultBoxModel = node.width() === 10 ? - X.Dom.BoxModel.BORDER_BOX : - X.Dom.BoxModel.CONTENT_BOX; + X_Node_BoxModel.defaultBoxModel = node.width() === 10 ? + X_Node_BoxModel.BORDER_BOX : + X_Node_BoxModel.CONTENT_BOX; - if( X.Dom.BoxModel.defaultBoxModel === X.Dom.BoxModel.CONTENT_BOX ){ - X.Dom.BoxModel.boxSizingEnabled = node.cssText( 'width:10px;padding:1px;border:2px solid #0;margin:4px;' + + if( X_Node_BoxModel.defaultBoxModel === X_Node_BoxModel.CONTENT_BOX ){ + X_Node_BoxModel.boxSizingEnabled = node.cssText( 'width:10px;padding:1px;border:2px solid #0;margin:4px;' + 'box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;-ms-box-sizing:border-box;' ) .width() === 10; }; @@ -60,7 +31,7 @@ X.ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){ // margin // top - X.Dom.BoxModel.absoluteOffset = + X_Node_BoxModel.absoluteOffset = node.cssText( 'position:absolute;top:0;left:0;margin:1px;border:2px solid #000;padding:4px;' ) .append( '
' ) .firstChild().cssText( 'position:absolute;top:8px;left:8px;margin:16px;border:32px solid #666;padding:64px;' ) @@ -82,18 +53,18 @@ Node.prototype.width = function(){ console.log( 'xnode.width() : no parent' ); return 0; }; - Node._body._updateTimerID && Node._body._startUpdate(); + X_Node_body._updateTimerID && X_Node_startUpdate(); if( !this._root ){ console.log( 'xnode.width() : not belong tree.' ); return 0; }; if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ - // this.css( X.Dom.Style.Unit.px, 'width' ); + // this.css( X_Node_CSS_Unit.px, 'width' ); return this._rawObject.offsetWidth; } else if( X_UA_DOM.IE4 ){ - return ( this._rawObject || this._ie4getRawNode() ).offsetWidth; + return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetWidth; } else { }; @@ -104,18 +75,18 @@ Node.prototype.height = function(){ console.log( 'xnode.height() : no parent' ); return 0; }; - Node._body._updateTimerID && Node._body._startUpdate(); + X_Node_body._updateTimerID && X_Node_startUpdate(); if( !this._root ){ console.log( 'xnode.height() : not belong tree.' ); return 0; }; if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ - // this.css( X.Dom.Style.Unit.px, 'height' ); + // this.css( X_Node_CSS_Unit.px, 'height' ); return this._rawObject.offsetHeight; } else if( X_UA_DOM.IE4 ){ - return ( this._rawObject || this._ie4getRawNode() ).offsetHeight; + return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetHeight; } else { }; @@ -126,18 +97,18 @@ Node.prototype.clientWidth = function(){ console.log( 'xnode.width() : no parent' ); return 0; }; - Node._body._updateTimerID && Node._body._startUpdate(); + X_Node_body._updateTimerID && X_Node_startUpdate(); if( !this._root ){ console.log( 'xnode.width() : not belong tree.' ); return 0; }; if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ - // this.css( X.Dom.Style.Unit.px, 'width' ); + // this.css( X_Node_CSS_Unit.px, 'width' ); return this._rawObject.clientWidth; } else if( X_UA_DOM.IE4 ){ - return ( this._rawObject || this._ie4getRawNode() ).clientWidth; + return ( this._rawObject || X_Node__ie4getRawNode( this ) ).clientWidth; } else { }; @@ -148,18 +119,18 @@ Node.prototype.clientHeight = function(){ console.log( 'xnode.height() : no parent' ); return 0; }; - Node._body._updateTimerID && Node._body._startUpdate(); + X_Node_body._updateTimerID && X_Node_startUpdate(); if( !this._root ){ console.log( 'xnode.height() : not belong tree.' ); return 0; }; if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ - // this.css( X.Dom.Style.Unit.px, 'height' ); + // this.css( X_Node_CSS_Unit.px, 'height' ); return this._rawObject.clientHeight; } else if( X_UA_DOM.IE4 ){ - return ( this._rawObject || this._ie4getRawNode() ).clientHeight; + return ( this._rawObject || X_Node__ie4getRawNode( this ) ).clientHeight; } else { }; @@ -170,18 +141,18 @@ Node.prototype.scrollWidth = function(){ console.log( 'xnode.width() : no parent' ); return 0; }; - Node._body._updateTimerID && Node._body._startUpdate(); + X_Node_body._updateTimerID && X_Node_startUpdate(); if( !this._root ){ console.log( 'xnode.width() : not belong tree.' ); return 0; }; if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ - // this.css( X.Dom.Style.Unit.px, 'width' ); + // this.css( X_Node_CSS_Unit.px, 'width' ); return this._rawObject.scrollWidth; } else if( X_UA_DOM.IE4 ){ - return ( this._rawObject || this._ie4getRawNode() ).scrollWidth; + return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollWidth; } else { }; @@ -192,18 +163,18 @@ Node.prototype.scrollHeight = function(){ console.log( 'xnode.height() : no parent' ); return 0; }; - Node._body._updateTimerID && Node._body._startUpdate(); + X_Node_body._updateTimerID && X_Node_startUpdate(); if( !this._root ){ console.log( 'xnode.height() : not belong tree.' ); return 0; }; if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ - // this.css( X.Dom.Style.Unit.px, 'height' ); + // this.css( X_Node_CSS_Unit.px, 'height' ); return this._rawObject.scrollHeight; } else if( X_UA_DOM.IE4 ){ - return ( this._rawObject || this._ie4getRawNode() ).scrollHeight; + return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollHeight; } else { }; @@ -214,18 +185,18 @@ Node.prototype.scrollLeft = function(){ console.log( 'xnode.scrollLeft() : no parent' ); return 0; }; - Node._body._updateTimerID && Node._body._startUpdate(); + X_Node_body._updateTimerID && X_Node_startUpdate(); if( !this._root ){ console.log( 'xnode.scrollLeft() : not belong tree.' ); return 0; }; if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ - // this.css( X.Dom.Style.Unit.px, 'width' ); + // this.css( X_Node_CSS_Unit.px, 'width' ); return this._rawObject.scrollLeft; } else if( X_UA_DOM.IE4 ){ - return ( this._rawObject || this._ie4getRawNode() ).scrollLeft; + return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollLeft; } else { }; @@ -236,18 +207,18 @@ Node.prototype.scrollTop = function(){ console.log( 'xnode.scrollTop() : no parent' ); return 0; }; - Node._body._updateTimerID && Node._body._startUpdate(); + X_Node_body._updateTimerID && X_Node_startUpdate(); if( !this._root ){ console.log( 'xnode.scrollTop() : not belong tree.' ); return 0; }; if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ - // this.css( X.Dom.Style.Unit.px, 'width' ); + // this.css( X_Node_CSS_Unit.px, 'width' ); return this._rawObject.scrollTop; } else if( X_UA_DOM.IE4 ){ - return ( this._rawObject || this._ie4getRawNode() ).scrollTop; + return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollTop; } else { }; @@ -256,29 +227,29 @@ Node.prototype.scrollTop = function(){ /* -------------------------------------- * x, y * position:absolute かつ x か y が設定されていたら、再描画しないで css オブジェクトから計算した値を返す。 float は? - * position:absolute の指定で自動で top,left を補う必要あり? -> X.Dom.Style + * position:absolute の指定で自動で top,left を補う必要あり? -> X.Node.CSS * 親要素 border 外側からの値。 IE, Firefox, Safari, Chrome の offsetLeft/Topでは、border 内側なので補正する。 * transformX, Y は加える? アニメーション中は? */ -// X.Dom.Style.transform, +// X_Node_CSS_transform, Node.prototype.x = function(){ if( !this.parent ){ console.log( 'xnode.x() : no parent' ); return 0; }; - Node._body._updateTimerID && Node._body._startUpdate(); + X_Node_body._updateTimerID && X_Node_startUpdate(); if( !this._root ){ console.log( 'xnode.x() : not belong tree.' ); return 0; }; if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ - // this.css( X.Dom.Style.Unit.px, 'left' ); - // this.css( X.Dom.Style.Unit.px, 'translateX' ); + // this.css( X_Node_CSS_Unit.px, 'left' ); + // this.css( X_Node_CSS_Unit.px, 'translateX' ); return this._rawObject.offsetLeft; } else if( X_UA_DOM.IE4 ){ - return ( this._rawObject || this._ie4getRawNode() ).offsetLeft; + return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetLeft; } else { }; @@ -289,19 +260,19 @@ Node.prototype.y = function(){ console.log( 'xnode.y() : no parent' ); return 0; }; - Node._body._updateTimerID && Node._body._startUpdate(); + X_Node_body._updateTimerID && X_Node_startUpdate(); if( !this._root ){ console.log( 'xnode.y() : not belong tree.' ); return 0; }; if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ - // this.css( X.Dom.Style.Unit.px, 'top' ); - // this.css( X.Dom.Style.Unit.px, 'transisitonY' ); + // this.css( X_Node_CSS_Unit.px, 'top' ); + // this.css( X_Node_CSS_Unit.px, 'transisitonY' ); return this._rawObject.offsetTop; } else if( X_UA_DOM.IE4 ){ - return ( this._rawObject || this._ie4getRawNode() ).offsetTop; + return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetTop; } else { }; @@ -314,14 +285,14 @@ Node.prototype.offset = function( /* xnodeParent */ ){ console.log( 'xnode.offset() : no parent' ); return { x : 0, y : 0 }; }; - Node._body._updateTimerID && Node._body._startUpdate(); + X_Node_body._updateTimerID && X_Node_startUpdate(); if( !this._root ){ console.log( 'xnode.offset() : not belong tree.' ); return { x : 0, y : 0 }; }; if( this._state & X_Node_State.DISPLAY_NONE ) return 0; - if( X.Dom.Node._body === this || X.Dom.Node._html === this ){ + if( X.Doc.body === this || X.Doc.html === this ){ return { x : 0, y : 0 }; }; @@ -329,7 +300,7 @@ Node.prototype.offset = function( /* xnodeParent */ ){ elm = this._rawObject; } else if( X_UA_DOM.IE4 ){ - elm = this._rawObject || this._ie4getRawNode(); + elm = this._rawObject || X_Node__ie4getRawNode( this ); } else { }; diff --git a/0.6.x/js/02_dom/05_XNodeAttr.js b/0.6.x/js/02_dom/05_XNodeAttr.js index 2ff418f..1864969 100644 --- a/0.6.x/js/02_dom/05_XNodeAttr.js +++ b/0.6.x/js/02_dom/05_XNodeAttr.js @@ -1,5 +1,4 @@ -var X_Node_Attr = { - noValue : { +var X_Node_Attr_noValue = { checked : 1, compact : 1, declare : 1, @@ -13,8 +12,8 @@ var X_Node_Attr = { nowrap : 1, readonly : 1, selected : 1 - }, - renameForDOM : { +}, +X_Node_Attr_renameForDOM = { 'class' : 'className', accesskey : 'accessKey', 'accept-charset' : 'acceptCharset', @@ -40,22 +39,22 @@ var X_Node_Attr = { usemap : 'useMap', valuetype : 'valueType', checked : 'defaultChecked' - }, - - HAS_VALUE : { +}, + +X_Node_Attr_HAS_VALUE = { INPUT : true, TEXTAREA : true, SELECT : true, BUTTON : true - }, - - renameForTag : {}, +}, + +X_Node_Attr_renameForTag = {}; // http://nanto.asablo.jp/blog/2005/10/29/123294 // checked -> defaultChecked // 動的に生成した input 要素を文書ツリーに挿入する前に設定した checked 属性は反映されず、defaultChecked だと反映される // 先頭にスペース - objToAttrText : function( obj ){ - var noValue = X_Node_Attr.noValue, +function X_Node_Attr_objToAttrText( obj ){ + var noValue = X_Node_Attr_noValue, attrs = [ '' ], n = 0, p, v; if( !obj ) return ''; // Opera7 for( p in obj ){ @@ -66,7 +65,6 @@ var X_Node_Attr = { attrs[ ++n ] = noValue[ p ] ? p : [ p, '="', v, '"' ].join( '' ); }; return 0 < n ? attrs.join( ' ' ) : ''; - } }; (function( renameForDOM, renameForTag ){ @@ -74,19 +72,19 @@ var X_Node_Attr = { for( name in renameForDOM ){ renameForTag[ renameForDOM[ name ] ] = name; }; -})( X_Node_Attr.renameForDOM, X_Node_Attr.renameForTag ); +})( X_Node_Attr_renameForDOM, X_Node_Attr_renameForTag ); /* -------------------------------------- * attribute - * X_Node_Attr.toIndex に定義されている 属性の場合 + * X_Node_Attr_toIndex に定義されている 属性の場合 * * http://nanto.asablo.jp/blog/2005/10/29/123294 * className, onclick等 はここで設定しない * */ -X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){ +Node.prototype.attr = function( nameOrObj /* v */ ){ var attrs = this._attrs, newAttrs, f, p, elm, v; if( this._xnodeType !== 1 ) return this; @@ -96,21 +94,21 @@ X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){ newAttrs = this._newAttrs || ( this._newAttrs = {} ); for( p in nameOrObj ){ - if( this._setAttr( attrs, newAttrs, p, nameOrObj[ p ] ) === true ) f = true; + if( X_Node_Attr_setAttr( this, attrs, newAttrs, p, nameOrObj[ p ] ) === true ) f = true; }; if( f ){ this._attrText = false; this._dirty |= X_Node_Dirty.ATTR; - this._root && this._reserveUpdate(); + this._root && X_Node_reserveUpdate(); }; return this; } else if( 1 < arguments.length ){ // setter - if( this._setAttr( attrs || ( this._attrs = {} ), this._newAttrs || ( this._newAttrs = {} ), nameOrObj, arguments[ 1 ] ) === true ){ + if( X_Node_Attr_setAttr( this, attrs || ( this._attrs = {} ), this._newAttrs || ( this._newAttrs = {} ), nameOrObj, arguments[ 1 ] ) === true ){ this._attrText = false; this._dirty |= X_Node_Dirty.ATTR; - this._root && this._reserveUpdate(); + this._root && X_Node_reserveUpdate(); }; return this; } else @@ -133,19 +131,19 @@ X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){ case 'selected' : case 'disabled' : case 'selectedIndex' : - if( X_Node_Attr.HAS_VALUE[ this._tag ] ){ + if( X_Node_Attr_HAS_VALUE[ this._tag ] ){ if( this._newAttrs && X_Object_inObject( nameOrObj, this._newAttrs ) ) return this._newAttrs[ nameOrObj ]; - if( elm = X_UA_DOM.IE4 ? this._rawObject || this._ie4getRawNode() : this._rawObject ){ + if( elm = X_UA_DOM.IE4 ? this._rawObject || X_Node__ie4getRawNode( this ) : this._rawObject ){ if( !attrs ) attrs = this._attrs = {}; return attrs[ nameOrObj ] = elm[ nameOrObj ]; // getAttribute( nameOrObj )? }; }; break; }; - return attrs && attrs[ X_Node_Attr.renameForTag[ nameOrObj ] || nameOrObj ]; + return attrs && attrs[ X_Node_Attr_renameForTag[ nameOrObj ] || nameOrObj ]; }; }; -X.Dom.Node.prototype._setAttr = function( attrs, newAttrs, name, v ){ +function X_Node_Attr_setAttr( that, attrs, newAttrs, name, v ){ switch( name ){ // case 'type' : TODO IE は input, button, object に対して type の再設定が出来ない _state が要素生成済なら不可 case 'UID' : @@ -153,19 +151,19 @@ X.Dom.Node.prototype._setAttr = function( attrs, newAttrs, name, v ){ case 'tagName' : return; case 'id' : - v = ( v !== 'ie4uid' + this._uid ) ? v : undefined; - if( v !== this._id ){ - this._id = v; - this._dirty |= X_Node_Dirty.ID; - this._root && this._reserveUpdate(); + v = ( v !== 'ie4uid' + that._uid ) ? v : undefined; + if( v !== that._id ){ + that._id = v; + that._dirty |= X_Node_Dirty.ID; + that._root && X_Node_reserveUpdate(); }; return; case 'class' : case 'className' : - return this.className( v ); + return that.className( v ); case 'style' : case 'cssText' : - return this.cssText( v ); + return that.cssText( v ); }; // debug if( name.indexOf( 'on' ) === 0 ){ @@ -173,7 +171,7 @@ X.Dom.Node.prototype._setAttr = function( attrs, newAttrs, name, v ){ return; }; - name = X_Node_Attr.renameForTag[ name ] || name; + name = X_Node_Attr_renameForTag[ name ] || name; if( attrs[ name ] === v ) return; if( v == null ){ diff --git a/0.6.x/js/02_dom/06_XNodeCSS.js b/0.6.x/js/02_dom/06_XNodeCSS.js index 5fbe5f2..643a8fd 100644 --- a/0.6.x/js/02_dom/06_XNodeCSS.js +++ b/0.6.x/js/02_dom/06_XNodeCSS.js @@ -7,9 +7,8 @@ * * use X.Dom.Event */ -X.Dom.Style = { - - Type : { +var +X_Node_CSS_Type = { LENGTH : 1, PERCENT : 2, COLOR : 2 < 2, @@ -26,7 +25,7 @@ X.Dom.Style = { COMBI : 2 < 13 }, - UNIT : { +X_Node_CSS_UNIT = { 'px' : 0, 'em' : 1, 'cm' : 2, @@ -42,13 +41,12 @@ X.Dom.Style = { }, /* font-size -> fontSize */ - _DICTIONARY_CAMELIZE : {}, +X_Node_CSS__DICTIONARY_CAMELIZE = {}, - camelize : function( cssProp ){ - var me = X.Dom.Style, - parts, l, i, camelized; +X_Node_CSS_camelize = function( cssProp ){ + var parts, l, i, camelized; - if( camelized = me._DICTIONARY_CAMELIZE[ cssProp ] ) return camelized; + if( camelized = X_Node_CSS__DICTIONARY_CAMELIZE[ cssProp ] ) return camelized; parts = cssProp.split( ' ' ).join( '' ).split( '-' ); l = parts.length; if( l === 1 ) return parts[ 0 ]; @@ -60,28 +58,27 @@ X.Dom.Style = { for( i = 1; i < l; ++i ){ camelized += parts[ i ].charAt( 0 ).toUpperCase() + parts[ i ].substring( 1 ); }; - return me._DICTIONARY_CAMELIZE[ cssProp ] = camelized; + return X_Node_CSS__DICTIONARY_CAMELIZE[ cssProp ] = camelized; }, /* fontSize -> font-size */ - CHAR_CODE_A : 'A'.charCodeAt( 0 ), +X_Node_CSS_CHAR_CODE_A = 'A'.charCodeAt( 0 ), - _DICTIONARY_UNCAMELIZE : {}, +X_Node_CSS__DICTIONARY_UNCAMELIZE = {}, - uncamelize : function( str ){ - var me = X.Dom.Style, - A = me.CHAR_CODE_A, - Z = A + 25, - uncamelized, l, chr, code; +X_Node_CSS_uncamelize = function( str ){ + var A = X_Node_CSS_CHAR_CODE_A, + Z = A + 25, + uncamelized, l, chr, code, i; str = str.split( ' ' ).join( '' ); - if( uncamelized = me._DICTIONARY_UNCAMELIZE[ str ] ) return uncamelized; + if( uncamelized = X_Node_CSS__DICTIONARY_UNCAMELIZE[ str ] ) return uncamelized; uncamelized = ''; for( i = 0, l = str.length; i < l; ++i ){ chr = str.charAt( i ); code = chr.charCodeAt( 0 ); uncamelized += ( A <= code && code <= Z ) ? '-' + chr : chr; }; - return me._DICTIONARY_UNCAMELIZE[ str ] = uncamelized.toLowerCase(); + return X_Node_CSS__DICTIONARY_UNCAMELIZE[ str ] = uncamelized.toLowerCase(); }, /* @@ -111,15 +108,14 @@ _ABSOLUTE_BOX _FLOAT_BOX _GRNERAL */ - VENDER_PREFIX : {}, +X_Node_CSS_VENDER_PREFIX = {}, - objToCssText : function( obj ){ +X_Node_CSS_objToCssText = function( obj ){ var css = [], - me = X.Dom.Style, - uncamelize = me.uncamelize, - VENDER_PREFIX = me.VENDER_PREFIX, - FIX_PROP = me.SPECIAL_FIX_PROP, - SPECIAL_FIX = me.SPECIAL_FIX, + uncamelize = X_Node_CSS_uncamelize, + VENDER_PREFIX = X_Node_CSS_VENDER_PREFIX, + FIX_PROP = X_Node_CSS_SPECIAL_FIX_PROP, + SPECIAL_FIX = X_Node_CSS_SPECIAL_FIX, n = -1, p, v, name, sp; if( !obj ) return ''; // Opera7.5 未満? @@ -136,7 +132,7 @@ _GRNERAL return css.join( ';' ); }, - IE_FILTER_FIX : +X_Node_CSS_IE_FILTER_FIX = X.UA.IE && X.UA.IE < 9 && !X.UA.MacIE ? { opacity : 1, @@ -146,8 +142,8 @@ _GRNERAL {} : {}, - _UNIT_RATIO : null, - _FONT_SIZE_RATIO : null, +X_Node_CSS__UNIT_RATIO = {}, +X_Node_CSS__FONT_SIZE_RATIO = {}, // https://developer.mozilla.org/en-US/docs/Web/CSS/transform // Firefox 3.5, ie9, Opera 10.5, Safari 3.1, Chrome @@ -161,7 +157,7 @@ _GRNERAL // ブラウザ毎の getComputedStyle の戻り値 http://d.hatena.ne.jp/uupaa/20080928/1222543331 - COLOR : { +X_Node_CSS_COLOR = { BLACK : 0x0, RED : 0xFF0000, LIME : 0x00FF00, @@ -244,7 +240,7 @@ _GRNERAL LEMONCHIFFON : 0xFFFACD }, - parseColor : function( x ){ +X_Node_CSS_parseColor = function( x ){ var rgb, r, g, b; if( X.Type.isNumber( x ) ){ @@ -252,7 +248,7 @@ _GRNERAL } else if( !X.Type.isString( x ) ) return; - if( X.Type.isNumber( rgb = X.Dom.Style.COLOR[ x.toUpperCase() ] ) && 0x0 <= rgb && rgb <= 0xFFFFFF ){ + if( X.Type.isNumber( rgb = X_Node_CSS_COLOR[ x.toUpperCase() ] ) && 0x0 <= rgb && rgb <= 0xFFFFFF ){ return rgb; } else if( x.charAt( 0 ) === '#' ){ @@ -302,7 +298,7 @@ _GRNERAL return isFinite( r + b + g ) ? ( r << 16 ) + ( g << 8 ) + b : undefined; }, - PARAMS : ( function(){ +X_Node_CSS_PARAMS = ( function(){ var ret = {}; register( ret.percent = {}, 'marginBottom,marginLeft,marginRight,marginTop,paddingBottom,paddingLeft,paddingRight,paddingTop,fontSize,textIndent' @@ -336,12 +332,12 @@ _GRNERAL return ret; })(), - _CLIP_SEPARATOR : X.UA.IE && X.UA.IE < 8 ? ' ' : ',', +X_Node_CSS__CLIP_SEPARATOR = X.UA.IE && X.UA.IE < 8 ? ' ' : ',', /* * */ - Property : X.Class.create( +X_Node_CSS_Property = X.Class.create( 'Property', X.Class.POOL_OBJECT, { @@ -372,7 +368,7 @@ _GRNERAL this.value = u === 'em' ? v / this.xnode._getCharSize() : - v / ( X.Dom.Style._UNIT_RATIO[ u ] || 1 ); + v / ( X_Node_CSS__UNIT_RATIO[ u ] || 1 ); }; }, setValue: function( v ){ @@ -398,10 +394,10 @@ _GRNERAL ( u === 'em' || ( u === '' && this.name === 'lineHeight' ) ) ? v * this.xnode._getCharSize() : // u === '%' - v / ( X.Dom.Style._UNIT_RATIO[ u ] || 1 ); + v / ( X_Node_CSS__UNIT_RATIO[ u ] || 1 ); }, isValid: function(){ - var p = X.Dom.Style.PARAMS, + var p = X_Node_CSS_PARAMS, n = this.name, v = this.value, u = this.unit, @@ -422,7 +418,7 @@ _GRNERAL /** * backgroundPosition, clip */ - PropertyGroup : X.Class.create( +X_Node_CSS_PropertyGroup = X.Class.create( 'PropertyGroup', X.Class.POOL_OBJECT, { @@ -486,7 +482,7 @@ _GRNERAL ret[ ret.length ] = ps[ i ].getValueText(); }; if( this.name === 'clip' ){ - return 'rect(' + ret.join( X.Dom.Style._CLIP_SEPARATOR ) + ')'; + return 'rect(' + ret.join( X_Node_CSS__CLIP_SEPARATOR ) + ')'; }; return ret.join( ' ' ); }, @@ -512,7 +508,7 @@ _GRNERAL * ie67 では rgb() は background-color で反応しない、、、 */ - ColorProperty : X.Class.create( +X_Node_CSS_ColorProperty = X.Class.create( 'ColorProperty', X.Class.POOL_OBJECT, { Constructor : function( name, x ){ @@ -522,7 +518,7 @@ _GRNERAL b = 0, a = 1, rgb; - if( X.Type.isNumber( rgb = x ) || X.Type.isNumber( rgb = X.Dom.Style.COLOR[ x.toUpperCase() ] ) ){ + if( X.Type.isNumber( rgb = x ) || X.Type.isNumber( rgb = X_Node_CSS_COLOR[ x.toUpperCase() ] ) ){ r = ( rgb & 0xff0000 ) >> 16; g = ( rgb & 0xff00 ) >> 8; b = ( rgb & 0xff ); @@ -634,16 +630,15 @@ _GRNERAL return this.r <= 255 && this.g <= 255 && this.b <= 255; } } - ), + ); - _getProperty : function( xnode, css, unit, p ){ +function X_Node_CSS__getProperty( xnode, css, unit, p ){ - var XDomStyle = X.Dom.Style, - me = XDomStyle._getProperty, - PARAMS = XDomStyle.PARAMS, - PropertyGroup = XDomStyle.PropertyGroup, - Property = XDomStyle.Property, - ColorProperty = XDomStyle.ColorProperty, + var me = X_Node_CSS__getProperty, + PARAMS = X_Node_CSS_PARAMS, + PropertyGroup = X_Node_CSS_PropertyGroup, + Property = X_Node_CSS_Property, + ColorProperty = X_Node_CSS_ColorProperty, name, width; if( PARAMS.special[ p ] === true || PARAMS.region[ p ] === true ){ @@ -659,7 +654,7 @@ _GRNERAL all; if( ret.isValid() === true ) return ret; ret.kill(); - all = css[ p ].split( '(' )[ 1 ].split( ')' )[ 0 ].split( XDomStyle._CLIP_SEPARATOR ); + all = css[ p ].split( '(' )[ 1 ].split( ')' )[ 0 ].split( X_Node_CSS__CLIP_SEPARATOR ); return new PropertyGroup( p, @@ -688,7 +683,7 @@ _GRNERAL _1 = all[ 1 ]; _2 = all[ 2 ]; _3 = all[ 3 ]; - vu = XDomStyle._splitValueAndUnit( _0 ); + vu = X_Node_CSS__splitValueAndUnit( _0 ); v = vu[ 0 ]; u = vu[ 1 ]; switch( all.length ){ @@ -701,7 +696,7 @@ _GRNERAL case 2 : top = new Property( props[ 0 ], v, u, xnode ); bottom = new Property( props[ 2 ], v, u, xnode ); - vu = XDomStyle._splitValueAndUnit( _1 ); + vu = X_Node_CSS__splitValueAndUnit( _1 ); v = vu[ 0 ]; u = vu[ 1 ]; right = new Property( props[ 1 ], v, u, xnode ); @@ -709,27 +704,27 @@ _GRNERAL break; case 3 : top = new Property( props[ 0 ], v, u, xnode ); - vu = XDomStyle._splitValueAndUnit( _1 ); + vu = X_Node_CSS__splitValueAndUnit( _1 ); v = vu[ 0 ]; u = vu[ 1 ]; right = new Property( props[ 1 ], v, u, xnode ); left = new Property( props[ 3 ], v, u, xnode ); - vu = XDomStyle._splitValueAndUnit( _2 ); + vu = X_Node_CSS__splitValueAndUnit( _2 ); v = vu[ 0 ]; u = vu[ 1 ]; bottom = new Property( props[ 2 ], v, u, xnode ); break; case 4 : top = new Property( props[ 0 ], v, u, xnode ); - vu = XDomStyle._splitValueAndUnit( _1 ); + vu = X_Node_CSS__splitValueAndUnit( _1 ); v = vu[ 0 ]; u = vu[ 1 ]; right = new Property( props[ 1 ], v, u, xnode ); - vu = XDomStyle._splitValueAndUnit( _2 ); + vu = X_Node_CSS__splitValueAndUnit( _2 ); v = vu[ 0 ]; u = vu[ 1 ]; bottom = new Property( props[ 2 ], v,u, xnode ); - vu = XDomStyle._splitValueAndUnit( _3 ); + vu = X_Node_CSS__splitValueAndUnit( _3 ); v = vu[ 0 ]; u = vu[ 1 ]; left = new Property( props[ 3 ], v, u, xnode ); @@ -786,8 +781,8 @@ _GRNERAL if( ret.isValid() === true ) return ret; ret.kill(); xy = css[ p ].split( ' ' ); - x = XDomStyle._splitValueAndUnit( xy[ 0 ] ); - y = XDomStyle._splitValueAndUnit( xy[ 1 ] ); + x = X_Node_CSS__splitValueAndUnit( xy[ 0 ] ); + y = X_Node_CSS__splitValueAndUnit( xy[ 1 ] ); return new PropertyGroup( p, @@ -796,7 +791,7 @@ _GRNERAL ); }; // opacity, zindex, lineHeight - vu = XDomStyle._splitValueAndUnit( css[ p ] ); + vu = X_Node_CSS__splitValueAndUnit( css[ p ] ); return new Property( p, vu[ 0 ], vu[ 1 ], xnode ); }; var x = css[ p ], e, v, u; @@ -812,73 +807,72 @@ _GRNERAL if( p === 'left' ) v = e.offsetLeft; if( p === 'right' ) v = e.offsetRight; u = _getUnit( x, p ); - // alert( p + XDomStyle._Util.pxTo( v, u ) + u ) - return new Property( p, XDomStyle._Util.pxTo( v, u ), u, xnode ); + // alert( p + X_Node_CSS__Util.pxTo( v, u ) + u ) + return new Property( p, X_Node_CSS__Util.pxTo( v, u ), u, xnode ); }; */ - if( p === 'fontSize' && ( v = XDomStyle._FONT_SIZE_RATIO[ x ] ) ){ // xx-small 等 + if( p === 'fontSize' && ( v = X_Node_CSS__FONT_SIZE_RATIO[ x ] ) ){ // xx-small 等 return new Property( p, v, 'px', xnode ); }; if( PARAMS.offset[ p ] || PARAMS.percent[ p ] || PARAMS.size[ p ] ){ - vu = XDomStyle._splitValueAndUnit( x ); + vu = X_Node_CSS__splitValueAndUnit( x ); return new Property( p, vu[ 0 ], vu[ 1 ], xnode ); }; if( PARAMS.color[ p ] ) return new ColorProperty( p, x ); - }, + }; - _splitValueAndUnit : function( v ){ +function X_Node_CSS__splitValueAndUnit( v ){ var num, _num, u; if( X.Type.isNumber( v ) ) return [ v || 0, '' ]; if( isNaN( num = parseFloat( v ) ) ) return [ 0, '' ]; _num = '' + num; if( _num.indexOf( '0.' ) === 0 ) _num = _num.slice( 1 ); u = v.substr( v.indexOf( _num ) + _num.length ); - return [ num, X.Dom.Style.UNIT[ u ] ? u : 'px' ]; - } -}; + return [ num, X_Node_CSS_UNIT[ u ] ? u : 'px' ]; + }; -X.Dom.Style._GET_VALUE_WITH_UNIT = { - borderWidth : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH, - //borderStyle : X.Dom.Style.Type.QUARTET, - borderRadius : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH, - margin : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT, - padding : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT, - clip : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT, +var X_Node_CSS__GET_VALUE_WITH_UNIT = { + borderWidth : X_Node_CSS_Type.QUARTET | X_Node_CSS_Type.LENGTH, + //borderStyle : X_Node_CSS_Type.QUARTET, + borderRadius : X_Node_CSS_Type.QUARTET | X_Node_CSS_Type.LENGTH, + margin : X_Node_CSS_Type.QUARTET | X_Node_CSS_Type.LENGTH | X_Node_CSS_Type.PERCENT, + padding : X_Node_CSS_Type.QUARTET | X_Node_CSS_Type.LENGTH | X_Node_CSS_Type.PERCENT, + clip : X_Node_CSS_Type.QUARTET | X_Node_CSS_Type.LENGTH | X_Node_CSS_Type.PERCENT, - backgroundColor : X.Dom.Style.Type.COLOR, - backgroundPosition : X.Dom.Style.Type.COMBI, + backgroundColor : X_Node_CSS_Type.COLOR, + backgroundPosition : X_Node_CSS_Type.COMBI, // boxShadow - fontSize : X.Dom.Style.Type.LENGTH, - lineHeight : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT | X.Dom.Style.Type.NUMERICAL, - textIndent : X.Dom.Style.Type.LENGTH, - letterSpacing : X.Dom.Style.Type.LENGTH, - wordSpacing : X.Dom.Style.Type.LENGTH, + fontSize : X_Node_CSS_Type.LENGTH, + lineHeight : X_Node_CSS_Type.LENGTH | X_Node_CSS_Type.PERCENT | X_Node_CSS_Type.NUMERICAL, + textIndent : X_Node_CSS_Type.LENGTH, + letterSpacing : X_Node_CSS_Type.LENGTH, + wordSpacing : X_Node_CSS_Type.LENGTH, /* - textShadowColor : X.Dom.Style.Type.COLOR, - textShadowOffsetX : X.Dom.Style.Type.LENGTH, - textShadowOffsetY : X.Dom.Style.Type.LENGTH, - textShadowBlur : X.Dom.Style.Type.LENGTH, */ + textShadowColor : X_Node_CSS_Type.COLOR, + textShadowOffsetX : X_Node_CSS_Type.LENGTH, + textShadowOffsetY : X_Node_CSS_Type.LENGTH, + textShadowBlur : X_Node_CSS_Type.LENGTH, */ - width : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT, - height : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT, + width : X_Node_CSS_Type.LENGTH | X_Node_CSS_Type.PERCENT, + height : X_Node_CSS_Type.LENGTH | X_Node_CSS_Type.PERCENT, - left : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT, - top : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT, - bottom : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT, - right : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT, + left : X_Node_CSS_Type.LENGTH | X_Node_CSS_Type.PERCENT, + top : X_Node_CSS_Type.LENGTH | X_Node_CSS_Type.PERCENT, + bottom : X_Node_CSS_Type.LENGTH | X_Node_CSS_Type.PERCENT, + right : X_Node_CSS_Type.LENGTH | X_Node_CSS_Type.PERCENT, // table - borderSpacing : X.Dom.Style.Type.LENGTH + borderSpacing : X_Node_CSS_Type.LENGTH }; -X.Dom.Style.SPECIAL_FIX = +var X_Node_CSS_SPECIAL_FIX = // ~IE8 X.UA.IE && X.UA.IE < 9 && !X.UA.MacIE? (function( obj ){ - var test = X.Dom.Style.SPECIAL_FIX_PROP, + var test = X_Node_CSS_SPECIAL_FIX_PROP, filters = [], n = -1, p, id, v, dir; @@ -896,7 +890,7 @@ X.Dom.Style.SPECIAL_FIX = // box-shadow: 10px 10px 10px 10px rgba(0,0,0,0.4) inset; // スペース区切りで、水平方向の距離 垂直方向の距離 ぼかし距離 広がり距離 影の色 insetキーワードを指定する。 ぼかし距離 広がり距離 影の色 insetキーワードは省略可 // shadow(color=#cccccc, strength=10, direction=135); - v = X.Dom.Style._getProperty( this, css, 'px', 'boxShadow' ); + v = X_Node_CSS__getProperty( this, css, 'px', 'boxShadow' ); dir = Math.atan2( v[ 1 ], v[ 0 ] ) * 180 / Math.PI + 90; dir += dir < 0 ? 360 : 0; filters[ ++n ] = 'shadow(color=' + v[ 4 ] + ',strength=' + v[ 3 ] + ',direction=' + dir + ')'; @@ -917,7 +911,7 @@ X.Dom.Style.SPECIAL_FIX = // IE9 textShadow に filter を使用 X.UA.IE && 9 <= X.UA.IE && X.UA.IE < 10 ? (function( obj ){ - var test = X.Dom.Style.SPECIAL_FIX_PROP, + var test = X_Node_CSS_SPECIAL_FIX_PROP, filters = [], p, id, v; for( p in obj ){ if( !( id = test[ p ] ) ) continue; @@ -931,7 +925,7 @@ X.Dom.Style.SPECIAL_FIX = if( filters ) return filters.join( ' ' ); }) : (function( obj ){ - var test = X.Dom.Style.SPECIAL_FIX_PROP, + var test = X_Node_CSS_SPECIAL_FIX_PROP, ret = [], p, id, v, bgpX, bgpY, clipT, clipB, clipL, clipR; for( p in obj ){ if( !( id = test[ p ] ) ) continue; @@ -973,17 +967,16 @@ X.Dom.Style.SPECIAL_FIX = // obj setter // name, value setter -X.Dom.Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ ){ - var XDomStyle = X.Dom.Style, - args = arguments, +Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ ){ + var args = arguments, css = this._css, p, name, v, camelize, unit, ieFix; if( this._xnodeType !== 1 ) return this; // setter:object if( X.Type.isObject( nameOrObj ) ){ if( !css ) css = this._css = {}; - camelize = XDomStyle.camelize; - ieFix = X.Dom.Style.IE_FILTER_FIX; + camelize = X_Node_CSS_camelize; + ieFix = X_Node_CSS_IE_FILTER_FIX; for( p in nameOrObj ){ if( ieFix[ p ] ){ this._dirty |= X_Node_Dirty.IE_FILTER; @@ -996,18 +989,18 @@ X.Dom.Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ }; }; this._dirty |= X_Node_Dirty.CSS; - this.parent && this._reserveUpdate(); + this.parent && X_Node_reserveUpdate(); delete this._cssText; return this; } else if( 1 < args.length ){ - if( !XDomStyle.UNIT[ nameOrObj ] ){ + if( !X_Node_CSS_UNIT[ nameOrObj ] ){ // setter name, value if( !css ) css = this._css = {}; - name = XDomStyle.camelize( nameOrObj ); + name = X_Node_CSS_camelize( nameOrObj ); v = args[ 1 ]; if( css[ name ] === v ) return this; - if( X.Dom.Style.IE_FILTER_FIX[ name ] ){ + if( X_Node_CSS_IE_FILTER_FIX[ name ] ){ this._dirty |= X_Node_Dirty.IE_FILTER; }; if( !v && v !== 0 ){ @@ -1022,14 +1015,14 @@ X.Dom.Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ v === 'none' ? ( this._state |= X_Node_State.DISPLAY_NONE ) : ( this._state &= ~X_Node_State.DISPLAY_NONE ); }; // parent でなく this._root! でなくて this._state & in tree - this.parent && this._reserveUpdate(); + this.parent && X_Node_reserveUpdate(); return this; }; // getter unit // unit 付の値取得は fontSize と 画像サイズが確定していないと正確に取れない。内部のみにする? if( !css ) return; - if( !XDomStyle._GET_VALUE_WITH_UNIT[ name = XDomStyle.camelize( args[ 1 ] ) ] ) return null; - p = XDomStyle._getProperty( this, css, nameOrObj, name ); + if( !X_Node_CSS__GET_VALUE_WITH_UNIT[ name = X_Node_CSS_camelize( args[ 1 ] ) ] ) return null; + p = X_Node_CSS__getProperty( this, css, nameOrObj, name ); v = p.pxTo( nameOrObj ); p.kill(); return v; @@ -1038,16 +1031,16 @@ X.Dom.Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ if( !css ) return; // 集計 border, padding, margin, backgroundPosition, clip // border で正確なデータを返せない時は、null を返す - return css[ XDomStyle.camelize( nameOrObj ) ]; + return css[ X_Node_CSS_camelize( nameOrObj ) ]; }; -X.Dom.Node.prototype.cssText = function( v ){ +Node.prototype.cssText = function( v ){ var obj, i, l, attr, name; if( v === '' ){ delete this._css; this._state &= ~X_Node_State.IE5_DISPLAY_NONE_FIX; this._dirty |= X_Node_Dirty.CSS; - this.parent && this._reserveUpdate(); + this.parent && X_Node_reserveUpdate(); delete this._cssText; return this; } else @@ -1063,7 +1056,7 @@ X.Dom.Node.prototype.cssText = function( v ){ return this.css( obj ); }; // getter - if( this._dirty & X_Node_Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ + if( this._dirty & X_Node_Dirty.CSS && !( this._cssText = X_Node_CSS_objToCssText( this._css ) ) ){ delete this._cssText; }; return this._cssText; @@ -1075,48 +1068,40 @@ X.Dom.Node.prototype.cssText = function( v ){ * body に css attr がセットされた場合には X_ViewPort_baseFontSize をクリア */ -X.Dom.Node.prototype._getCharSize = +Node.prototype._getCharSize = window.getComputedStyle ? (function(){ - Node._body._updateTimerID && Node._body._startUpdate(); - if( this === Node._body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize; + 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 ); }) : document.defaultView && document.defaultView.getComputedStyle ? (function(){ - Node._body._updateTimerID && Node._body._startUpdate(); - if( this === Node._body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize; + 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 ); }) : - - - - - - - - 5.5 <= X.UA.IE ? (function(){ var font, vu, v, u, _v; - Node._body._updateTimerID && Node._body._startUpdate(); - if( this === Node._body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize; + 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; font = this._rawObject.currentStyle.fontSize; //font = this._css && this._css.fontSize || '1em'; - vu = X.Dom.Style._splitValueAndUnit( font ); + vu = X_Node_CSS__splitValueAndUnit( font ); v = vu[ 0 ]; u = vu[ 1 ]; if( v === 0 ){ - if( v = X.Dom.Style._FONT_SIZE_RATIO[ font ] ) return this._fontSize = v; + if( v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return this._fontSize = v; } else { - if( _v = X.Dom.Style._UNIT_RATIO[ u ] ) return this._fontSize = v / _v; + if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return this._fontSize = v / _v; }; switch( u ){ case 'px' : @@ -1134,8 +1119,8 @@ X.Dom.Node.prototype._getCharSize = X_UA_DOM.W3C ? (function(){ var elm, v; - Node._body._updateTimerID && Node._body._startUpdate(); - if( this === Node._body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize; + 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; this._rawObject.appendChild( elm = document.createElement( 'span' ) ); @@ -1148,19 +1133,19 @@ X.Dom.Node.prototype._getCharSize = X_UA_DOM.IE4 ? (function(){ var font, vu, v, u, _v; - Node._body._updateTimerID && Node._body._startUpdate(); - if( this === Node._body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize; + 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; if( this._css && ( font = this._css.fontSize ) ){ - vu = X.Dom.Style._splitValueAndUnit( font ); + vu = X_Node_CSS__splitValueAndUnit( font ); v = vu[ 0 ]; u = vu[ 1 ]; if( v === 0 ){ - if( _v = X.Dom.Style._FONT_SIZE_RATIO[ font ] ) return this._fontSize = _v; + if( _v = X_Node_CSS__FONT_SIZE_RATIO[ font ] ) return this._fontSize = _v; } else { - if( _v = X.Dom.Style._UNIT_RATIO[ u ] ) return this._fontSize = v / _v; + if( _v = X_Node_CSS__UNIT_RATIO[ u ] ) return this._fontSize = v / _v; }; } else { v = 1; @@ -1180,13 +1165,14 @@ X.Dom.Node.prototype._getCharSize = }; return 0; }) : + // ie5? (function(){ var elm, v; - if( this === Node._body && X_ViewPort_baseFontSize ) return X_ViewPort_baseFontSize; - Node._body._updateTimerID && Node._body._startUpdate(); + 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 || this._ie4getRawNode(); + elm = this._rawObject; elm.insertAdjacentHTML( 'BeforeEnd', 'X' ); elm = elm.children[ elm.children.length - 1 ]; v = elm.offsetHeight; @@ -1195,10 +1181,23 @@ X.Dom.Node.prototype._getCharSize = }); +X.CSS = { + + VENDER_PREFIX : X_Node_CSS_VENDER_PREFIX, + + parseColor : X_Node_CSS_parseColor, + + uncamelize : X_Node_CSS_uncamelize +}; + + + +var X_Node_CSS_Support, X_Node_CSS_SPECIAL_FIX_PROP; + ( function(){ var testStyle = X.UA.IE4 ? {} : ( document.documentElement || document.createElement( 'div' ) ).style, temp = testStyle.cssText, - prefix = X.Dom.Style.VENDER_PREFIX, + prefix = X_Node_CSS_VENDER_PREFIX, vendors = 'webkit,Webkit,Moz,moz,Ms,ms,O,o,khtml,Khtml'.split( ',' ), searches = ( 'opacity,boxSizing,' + @@ -1228,13 +1227,13 @@ X.Dom.Node.prototype._getCharSize = testStyle.cssText = 'background:rgba(0,0,0,0.5)'; - X.Dom.Style.Support = { + X.CSS.Support = X_Node_CSS_Support = { rgba : !!testStyle.background }; testStyle.cssText = temp; - X.Dom.Style.SPECIAL_FIX_PROP = + X_Node_CSS_SPECIAL_FIX_PROP = // ~IE8 X.UA.IE < 9 && !X.UA.MacIE ? { @@ -1260,18 +1259,18 @@ X.Dom.Node.prototype._getCharSize = }; } )(); -X.ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){ - var xnode = Node._systemNode, - output = X.Dom.Style._UNIT_RATIO = {}, +X_ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){ + var xnode = X_Node_systemNode, + output = X_Node_CSS__UNIT_RATIO, list = 'cm,mm,in,pt,pc'.split( ',' ), - unit,size, base, i; + unit, size, base, i; for( i = list.length; i; ){ unit = list[ --i ]; output[ unit ] = xnode.css( 'width', 10 + unit ).width() / 10; }; - output = X.Dom.Style._FONT_SIZE_RATIO = {}, + output = X_Node_CSS__FONT_SIZE_RATIO, list = 'xx-large,x-large,large,larger,medium,small,smaller,x-small,xx-small'.split( ',' ); xnode.css( { lineHeight : '100%', height : '1em' } ).text( 'X' ); diff --git a/0.6.x/js/02_dom/07_XNodeList.js b/0.6.x/js/02_dom/07_XNodeList.js index 891bc79..f1a073a 100644 --- a/0.6.x/js/02_dom/07_XNodeList.js +++ b/0.6.x/js/02_dom/07_XNodeList.js @@ -1,5 +1,5 @@ -X.Dom.NodeList = function( v ){ +function X_NodeList( v ){ var args = [], l = arguments.length, i = 0, @@ -9,12 +9,12 @@ X.Dom.NodeList = function( v ){ args.push.apply( args, arguments[ i ] ); }; //alert( arguments[ 0 ].length + ' , ' + args.length ) - if( ( l = args.length ) === 1 ) return new X.Dom.Node( args[ 0 ] ); - if( !this || this.append !== X.Dom.NodeList.prototype.append ) return new X.Dom.NodeList( args ); + if( ( l = args.length ) === 1 ) return new Node( args[ 0 ] ); + if( !this || this.append !== X_NodeList.prototype.append ) return new X_NodeList( args ); for( i = 0; i < l; ++i ){ xnode = args[ i ]; - //xnode = xnode && xnode.constructor === X.Dom.Node ? xnode : new X.Dom.Node( xnode ); + //xnode = xnode && xnode.constructor === Node ? xnode : new Node( xnode ); skip = false; if( xnode._xnodeType === 0 ) continue; for( j = 0; j < n; ++j ){ @@ -29,9 +29,9 @@ X.Dom.NodeList = function( v ){ }; }; }; -X.Dom.NodeList.prototype.length = 0; +X_NodeList.prototype.length = 0; -X.Dom.NodeList.prototype.each = function( func /* opt_args... */ ){ +X_NodeList.prototype.each = function( func /* opt_args... */ ){ var l = this.length, i = 0, args; @@ -52,15 +52,15 @@ X.Dom.NodeList.prototype.each = function( func /* opt_args... */ ){ /* -------------------------------------- * Fuction Base, multi, getter, setter, */ -X.ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_PRE_INIT, function(){ - var target = X.Dom.NodeList.prototype, - src = X.Dom.Node.prototype, +X_ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_PRE_INIT, function(){ + var target = X_NodeList.prototype, + src = Node.prototype, p, v, multi; for( p in src ){ v = src[ p ]; if( X.Type.isFunction( v ) && !target[ p ] ){ target[ p ] = multi = new Function( [ - 'var a=arguments,f=X.Dom.Node.prototype.', p, ',t=this,i,l=t.length;', + 'var a=arguments,f=X.Node.prototype.', p, ',t=this,i,l=t.length;', 'if(l)', 'for(i=0;i' : 2, // 子セレクタ @@ -40,7 +40,7 @@ X.Dom.Query = { ',' : 5, '@' : 6 // XML 用の拡張、属性ノードを辿る http://www.marguerite.jp/Nihongo/WWW/RefDOM/_Attr_interface.html }, - _SELECTOR : { + X_Node_Selector__SELECTOR = { '' : 0, // none tag : 1, '#' : 2, @@ -52,11 +52,10 @@ X.Dom.Query = { root : 8, link : 9 }, - _OPERATORS : { '==' : 1, '!=': 2, '~=': 3, '^=': 4, '$=': 5, '*=': 6, '|=': 7 }, // '':0 は属性が存在するならtrue + X_Node_Selector__OPERATORS = { '==' : 1, '!=': 2, '~=': 3, '^=': 4, '$=': 5, '*=': 6, '|=': 7 }, // '':0 は属性が存在するならtrue // TODO { a : 1, A : 2, _ : 3,,, } - _ALPHABET : 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-0123456789\\', - _NUMBER : '+-0123456789' -}; + X_Node_Selector__ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-0123456789\\', + X_Node_Selector__NUMBER = '+-0123456789'; /* * セレクタ文字列の解析、但し一挙に行わず、ひと塊づつ @@ -64,12 +63,12 @@ X.Dom.Query = { * ' ' 子孫セレクタ, '>' 直下,'+','~' の場合、tagName|* を返す * return [ 今回のパースで解析した終端位置, [ selector, ... ] ] error: return pointer */ -X.Dom.Query._parse = function( query, last ){ - var COMBINATOR = X.Dom.Query._COMBINATOR, - SELECTOR = X.Dom.Query._SELECTOR, - OPERATORS = X.Dom.Query._OPERATORS, - ALPHABET = X.Dom.Query._ALPHABET, - NUMBER = X.Dom.Query._NUMBER, +function X_Node_Selector__parse( query, last ){ + var COMBINATOR = X_Node_Selector__COMBINATOR, + SELECTOR = X_Node_Selector__SELECTOR, + OPERATORS = X_Node_Selector__OPERATORS, + ALPHABET = X_Node_Selector__ALPHABET, + NUMBER = X_Node_Selector__NUMBER, result = [], i = -1, l = query.length, @@ -220,16 +219,16 @@ X.Dom.Query._parse = function( query, last ){ }; // セレクター - X.Dom.find = X._shortcut = Node.prototype.find = X.Dom.NodeList.prototype.find = function( queryString ){ - var HTML = Node._html, - scope = this.constructor === X.Dom.NodeList && this.length ? this : [ this.constructor === Node ? this : Node._body ], + X.Doc.find = X._shortcut = Node.prototype.find = X_NodeList.prototype.find = function( queryString ){ + var HTML = X_Node_html, + scope = this.constructor === X_NodeList && this.length ? this : [ this.constructor === Node ? this : X_Node_body ], parents = scope, // 探索元の親要素 XNodeList の場合あり // TODO { title : true,,, } noLower = 'title id name class for action archive background cite classid codebase data href longdesc profile src usemap',// + X_Dom_DTD_ATTR_VAL_IS_URI.join( ' ' ), ARY_PUSH = Array.prototype.push, ret = [], // 結果要素 - root = X.Dom.Node.getRoot( scope[ 0 ] ), - isXML = !!X.Dom.Node.isXmlDocument( root ), + root = X_Node_getRoot( scope[ 0 ] ), + isXML = !!X_Node_isXmlDocument( root ), isMulti = 1 < scope.length,// 要素をマージする必要がある isStart = true, _ = ' ', @@ -259,7 +258,7 @@ X.Dom.Query._parse = function( query, last ){ // 初期化処理 if( !parsed ){ - parsed = X.Dom.Query._parse( queryString ); + parsed = X_Node_Selector__parse( queryString ); if( typeof parsed === 'number' ){ // error @@ -269,7 +268,7 @@ X.Dom.Query._parse = function( query, last ){ queryString = queryString.substr( parsed[ 0 ] ); parsed = parsed[ 1 ]; - //console.log( 'X.Dom.Query._parse ' + parsed ); + //console.log( 'X_Node_Selector__parse ' + parsed ); if( parsed === 5 ){ isMulti = true; @@ -352,7 +351,7 @@ X.Dom.Query._parse = function( query, last ){ //console.log( l + ' > ' + xnodes.length + ' tag:' + tagName ); for( ; i < l; ++i ){ xnode = parents[ i ]; - xnode._xnodes && xnode._xnodes.length && X.Dom.Query._fetchElements( xnodes, xnode, isAll ? null : tagName ); + xnode._xnodes && xnode._xnodes.length && X_Node_Selector__fetchElements( xnodes, xnode, isAll ? null : tagName ); }; //console.log( l + ' >> ' + xnodes.length + ' tag:' + tagName ); }; @@ -371,7 +370,7 @@ X.Dom.Query._parse = function( query, last ){ filter = [ 'class', 3 /*'~='*/, name ]; break; // :, 擬似クラス case 4 : - if( !( filter = X.Dom.Query._filter[ name ] ) ){ + if( !( filter = X_Node_Selector__filter[ name ] ) ){ return []; }; break; @@ -427,7 +426,7 @@ X.Dom.Query._parse = function( query, last ){ op = filter[ 1 ]; val = filter[ 2 ]; - key = X_Node_Attr.renameForTag[ key ] || key; + key = X_Node_Attr_renameForTag[ key ] || key; // [class~='val'] if( !isXML && key === 'class' && op === 3 ){ @@ -455,7 +454,7 @@ X.Dom.Query._parse = function( query, last ){ //flag_call ? // funcAttr( elem, key ) : //useName ? - // elem[ X_Node_Attr.renameForDOM[ key ] || key ] : + // elem[ X_Node_Attr_renameForDOM[ key ] || key ] : // elem.getAttribute( key, 2 ); flag = attr != null;// && ( !useName || attr !== '' ); if( flag && op ){ @@ -503,7 +502,7 @@ X.Dom.Query._parse = function( query, last ){ if( isMulti ){ xnodes && xnodes.length && ARY_PUSH.apply( ret, xnodes ); l = ret.length; - if( l < 2 ) return ret[ 0 ] || Node.none; + if( l < 2 ) return ret[ 0 ] || X_Node_none; xnodes = []; merge = {}; @@ -515,14 +514,14 @@ X.Dom.Query._parse = function( query, last ){ xnodes[ ++n ] = xnode; }; }; - X.Dom.Query._sortElementOrder( ret = [], xnodes, hasRoot ? [ HTML ] : HTML._xnodes ); + X_Node_Selector__sortElementOrder( ret = [], xnodes, hasRoot ? [ HTML ] : HTML._xnodes ); xnodes = ret; }; - return xnodes.length === 1 ? xnodes[ 0 ] : new X.Dom.NodeList( xnodes ); + return xnodes.length === 1 ? xnodes[ 0 ] : new X_NodeList( xnodes ); }; - X.Dom.Query._sortElementOrder = function( newList, list, xnodes ){ + function X_Node_Selector__sortElementOrder( newList, list, xnodes ){ var l = xnodes.length, i = 0, j, child, _xnodes; @@ -540,13 +539,13 @@ X.Dom.Query._parse = function( query, last ){ }; if( list.length === 0 ) return true; }; - if( ( _xnodes = child._xnodes ) && X.Dom.Query._sortElementOrder( newList, list, _xnodes ) ){ + if( ( _xnodes = child._xnodes ) && X_Node_Selector__sortElementOrder( newList, list, _xnodes ) ){ return true; }; }; }; - X.Dom.Query._fetchElements = function( list, parent, tag ){ + function X_Node_Selector__fetchElements( list, parent, tag ){ var xnodes = parent._xnodes, l = xnodes.length, i = 0, @@ -556,12 +555,12 @@ X.Dom.Query._parse = function( query, last ){ if( child._xnodeType === 1 ){ ( !tag || child._tag === tag ) && ( list[ list.length ] = child ); //console.log( parent._tag + ' > ' + child._tag + ' == ' + tag+ ' l:' + list.length ); - child._xnodes && child._xnodes.length && X.Dom.Query._fetchElements( list, child, tag ); + child._xnodes && child._xnodes.length && X_Node_Selector__fetchElements( list, child, tag ); }; }; }; - X.Dom.Query._funcSelectorChild = function( type, flag_all, flags, xnodes ){ + function X_Node_Selector__funcSelectorChild( type, flag_all, flags, xnodes ){ var res = [], flag_not = flags.not, i = 0, n = -1, xnode, node, @@ -590,7 +589,7 @@ X.Dom.Query._parse = function( query, last ){ }; return res; }; - X.Dom.Query._funcSelectorNth = function( pointer, sibling, flag_all, flags, xnodes, a, b ){ + function X_Node_Selector__funcSelectorNth( pointer, sibling, flag_all, flags, xnodes, a, b ){ var _data = funcData, res = [], checked = {}, @@ -613,7 +612,7 @@ X.Dom.Query._parse = function( query, last ){ }; return res; }; - X.Dom.Query._funcSelectorProp = function( prop, flag, flags, xnodes ){ + function X_Node_Selector__funcSelectorProp( prop, flag, flags, xnodes ){ var res = [], flag_not = flag ? flags.not : !flags.not, i = 0, n = -1, xnode; @@ -623,7 +622,7 @@ X.Dom.Query._parse = function( query, last ){ return res; }; -X.Dom.Query._filter = { +var X_Node_Selector__filter = { root : function( elem ){ return elem === ( elem.ownerDocument || elem.document ).documentElement; }, @@ -640,34 +639,34 @@ X.Dom.Query._filter = { } }, 'first-child' : { - m : function( flags, xnodes ){ return X.Dom.Query._funcSelectorChild( -1, true, flags, xnodes ); } + m : function( flags, xnodes ){ return X_Node_Selector__funcSelectorChild( -1, true, flags, xnodes ); } }, 'last-child' : { - m : function( flags, xnodes ){ return X.Dom.Query._funcSelectorChild( 1, true, flags, xnodes ); } + m : function( flags, xnodes ){ return X_Node_Selector__funcSelectorChild( 1, true, flags, xnodes ); } }, 'only-child' : { - m : function( flags, xnodes ){ return X.Dom.Query._funcSelectorChild( 0, true, flags, xnodes ); } + m : function( flags, xnodes ){ return X_Node_Selector__funcSelectorChild( 0, true, flags, xnodes ); } }, 'first-of-type' : { - m : function( flags, xnodes ){ return X.Dom.Query._funcSelectorChild( -1, false, flags, xnodes ); } + m : function( flags, xnodes ){ return X_Node_Selector__funcSelectorChild( -1, false, flags, xnodes ); } }, 'last-of-type' : { - m : function( flags, xnodes ){ return X.Dom.Query._funcSelectorChild( 1, false, flags, xnodes ); } + m : function( flags, xnodes ){ return X_Node_Selector__funcSelectorChild( 1, false, flags, xnodes ); } }, 'only-of-type' : { - m : function( flags, xnodes ){ return X.Dom.Query._funcSelectorChild( 0, false, flags, xnodes ); } + m : function( flags, xnodes ){ return X_Node_Selector__funcSelectorChild( 0, false, flags, xnodes ); } }, 'nth-child' : { - m : function( flags, xnodes, a, b ){ return X.Dom.Query._funcSelectorNth( 'firstChild', 'nextNode', true, flags, xnodes, a, b ); } + m : function( flags, xnodes, a, b ){ return X_Node_Selector__funcSelectorNth( 'firstChild', 'nextNode', true, flags, xnodes, a, b ); } }, 'nth-last-child' : { - m : function( flags, xnodes, a, b ){ return X.Dom.Query._funcSelectorNth( 'lastChild', 'prevNode', true, flags, xnodes, a, b ); } + m : function( flags, xnodes, a, b ){ return X_Node_Selector__funcSelectorNth( 'lastChild', 'prevNode', true, flags, xnodes, a, b ); } }, 'nth-of-type' : { - m : function( flags, xnodes, a, b ){ return X.Dom.Query._funcSelectorNth( 'firstChild', 'nextNode', false, flags, xnodes, a, b ); } + m : function( flags, xnodes, a, b ){ return X_Node_Selector__funcSelectorNth( 'firstChild', 'nextNode', false, flags, xnodes, a, b ); } }, 'nth-last-of-type' : { - m : function( flags, xnodes, a, b ){ return X.Dom.Query._funcSelectorNth( 'lastChild', 'prevNode', false, flags, xnodes, a, b ); } + m : function( flags, xnodes, a, b ){ return X_Node_Selector__funcSelectorNth( 'lastChild', 'prevNode', false, flags, xnodes, a, b ); } }, empty : { m : function( flags, xnodes ){ @@ -723,13 +722,13 @@ X.Dom.Query._filter = { } }, enabled : { - m : function( flags, xnodes ){ return X.Dom.Query._funcSelectorProp( 'disabled', false, flags, xnodes ); } + m : function( flags, xnodes ){ return X_Node_Selector__funcSelectorProp( 'disabled', false, flags, xnodes ); } }, disabled : { - m : function( flags, xnodes ){ return X.Dom.Query._funcSelectorProp( 'disabled', true, flags, xnodes ); } + m : function( flags, xnodes ){ return X_Node_Selector__funcSelectorProp( 'disabled', true, flags, xnodes ); } }, checked : { - m : function( flags, xnodes ){ return X.Dom.Query._funcSelectorProp( 'checked', true, flags, xnodes ); } + m : function( flags, xnodes ){ return X_Node_Selector__funcSelectorProp( 'checked', true, flags, xnodes ); } }, contains : { m : function( flags, xnodes, arg ){ @@ -743,6 +742,3 @@ X.Dom.Query._filter = { } } }; - - - diff --git a/0.6.x/js/02_dom/09_XHTMLParser.js b/0.6.x/js/02_dom/09_XHTMLParser.js index af11c4b..6804817 100644 --- a/0.6.x/js/02_dom/09_XHTMLParser.js +++ b/0.6.x/js/02_dom/09_XHTMLParser.js @@ -5,31 +5,30 @@ * */ -var X_Dom_Parser = { // HTMLParser - CHARS : { +var X_HTMLParser_CHARS = { A:1,B:1,C:1,D:1,E:1,F:1,G:1,H:1,I:1,J:1,K:1,L:1,M:1,N:1,O:1,P:1,Q:1,R:1,S:1,T:1,U:1,V:1,W:1,X:1,Y:1,Z:1, a:2,b:2,c:2,d:2,e:2,f:2,g:2,h:2,i:2,j:2,k:2,l:2,m:2,n:2,o:2,p:2,q:2,r:2,s:2,t:2,u:2,v:2,w:2,x:2,y:2,z:2, // "0" : 4, "1" : 4, "2" : 4, "3" : 4, "4" : 4, "5" : 4, "6" : 4, "7" : 4, "8" : 4, "9" : 4, closure compiler で minify すると ie4 で error、eval使う '\t' : 16, '\r\n' : 16, '\r' : 16, '\n' : 16, '\f' : 16, '\b' : 16, ' ' : 16 }, - alphabets : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', - whiteSpace : '\t\r\n\f\b ', + X_HTMLParser_alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', + X_HTMLParser_whiteSpace = '\t\r\n\f\b ', // Empty Elements - HTML 4.01 - empty : X_Dom_DTD_EMPTY, + X_HTMLParser_empty = X_Dom_DTD_EMPTY, // Block Elements - HTML 4.01 - block : {ADDRESS:1,APPLET:1,BLOCKQUOTE:1,BUTTON:1,CENTER:1,DD:1,DEL:1,DIR:1,DIV:1,DL:1,DT:1,FIELDSET:1,FORM:1,FRAMESET:1,HR:1,IFRAME:1,INS:1, + X_HTMLParser_block = {ADDRESS:1,APPLET:1,BLOCKQUOTE:1,BUTTON:1,CENTER:1,DD:1,DEL:1,DIR:1,DIV:1,DL:1,DT:1,FIELDSET:1,FORM:1,FRAMESET:1,HR:1,IFRAME:1,INS:1, ISINDEX:1,LI:1,MAP:1,MENU:1,NOFRAMES:1,NOSCRIPT:1,OBJECT:1,OL:1,P:1,PRE:1,SCRIPT:1,TABLE:1,TBODY:1,TD:1,TFOOT:1,TH:1,THEAD:1,TR:1,UL:1 }, // Inline Elements - HTML 4.01 - inline : {A:1,ABBR:1,ACRONYM:1,APPLET:1,B:1,BASEFONT:1,BDO:1,BIG:1,BR:1,BUTTON:1,CITE:1,CODE:1,DEL:1,DFN:1,EM:1,FONT:1,I:1,IFRAME:1,IMG:1, + X_HTMLParser_inline = {A:1,ABBR:1,ACRONYM:1,APPLET:1,B:1,BASEFONT:1,BDO:1,BIG:1,BR:1,BUTTON:1,CITE:1,CODE:1,DEL:1,DFN:1,EM:1,FONT:1,I:1,IFRAME:1,IMG:1, INPUT:1,INS:1,KBD:1,LABEL:1,MAP:1,OBJECT:1,Q:1,S:1,SAMP:1,SCRIPT:1,SELECT:1,SMALL:1,SPAN:1,STRIKE:1,STRONG:1,SUB:1,SUP:1,TEXTAREA:1,TT:1,U:1,VAR:1}, // Elements that you can, intentionally, leave open // (and which close themselves) - closeSelf : {OLGROUP:1,DD:1,DT:1,LI:1,OPTIONS:1,P:1,TBODY:1,TD:1,TFOOT:1,TH:1,THEAD:1,TR:1}, // add tbody + X_HTMLParser_closeSelf = {OLGROUP:1,DD:1,DT:1,LI:1,OPTIONS:1,P:1,TBODY:1,TD:1,TFOOT:1,TH:1,THEAD:1,TR:1}, // add tbody - sisters : { + X_HTMLParser_sisters = { TH : { TD : 1 }, TD : { TH : 1 }, DT : { DD : 1 }, @@ -48,17 +47,17 @@ var X_Dom_Parser = { // HTMLParser */ // Attributes that have their values filled in disabled="disabled" - fillAttrs : X_Node_Attr.noValue, //{checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1}; + X_HTMLParser_fillAttrs = X_Node_Attr_noValue, //{checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1}; // Special Elements (can contain anything) - special : { SCRIPT : 1, STYLE : 1, PLAINTEXT : 1, XMP : 1, TEXTAREA : 1 }, + X_HTMLParser_special = { SCRIPT : 1, STYLE : 1, PLAINTEXT : 1, XMP : 1, TEXTAREA : 1 }; - exec : function( html, handler, async ){ - var special = X_Dom_Parser.special, - //plainText = X_Dom_Parser.plainText, + function X_HTMLParser_exec( html, handler, async ){ + var special = X_HTMLParser_special, + //plainText = X_HTMLParser_plainText, startTime = async && X_Timer_now(), - _parseStartTag = X_Dom_Parser._parseStartTag, - _parseEndTag = X_Dom_Parser._parseEndTag, + _parseStartTag = X_HTMLParser__parseStartTag, + _parseEndTag = X_HTMLParser__parseEndTag, stack = async ? async[ 1 ] : [], lastHtml = html, chars, last, text, index; @@ -126,7 +125,7 @@ var X_Dom_Parser = { // HTMLParser if( async && startTime + 15 <= X_Timer_now() && html ){ handler.progress( 1 - html.length / async[ 0 ] ); - X.Timer.once( 0, X_Dom_Parser.exec, [ html, handler, async ] ); + X.Timer.once( 0, X_HTMLParser_exec, [ html, handler, async ] ); return; }; @@ -134,15 +133,15 @@ var X_Dom_Parser = { // HTMLParser }; // Clean up any remaining tags - X_Dom_Parser.parseEndTag( stack, handler ); + X_HTMLParser_parseEndTag( stack, handler ); async && handler.complete(); - }, + }; - _parseStartTag : function( stack, last, handler, html ){ - var alphabets = X_Dom_Parser.CHARS, - whiteSpace = X_Dom_Parser.CHARS, - saveAttr = X_Dom_Parser.saveAttr, + function X_HTMLParser__parseStartTag( stack, last, handler, html ){ + var alphabets = X_HTMLParser_CHARS, + whiteSpace = X_HTMLParser_CHARS, + saveAttr = X_HTMLParser_saveAttr, uri = X_Dom_DTD_ATTR_VAL_IS_URI, phase = 0, l = html.length, @@ -211,15 +210,15 @@ var X_Dom_Parser = { // HTMLParser }; if( phase === 9 ){ if( empty ) ++i; - if( X_Dom_Parser.parseStartTag( stack, last, handler, tagName.toUpperCase(), attrs, empty, i ) === false ) return false; + if( X_HTMLParser_parseStartTag( stack, last, handler, tagName.toUpperCase(), attrs, empty, i ) === false ) return false; return i; }; return 0; // error - }, + }; - _parseEndTag : function( stack, handler, html ){ - var alphabets = X_Dom_Parser.CHARS, - whiteSpace = X_Dom_Parser.CHARS, + function X_HTMLParser__parseEndTag( stack, handler, html ){ + var alphabets = X_HTMLParser_CHARS, + whiteSpace = X_HTMLParser_CHARS, phase = 0, l = html.length, i = 0, @@ -247,15 +246,15 @@ var X_Dom_Parser = { // HTMLParser ++i; }; if( phase === 9 ){ - X_Dom_Parser.parseEndTag( stack, handler, tagName.toUpperCase() ); + X_HTMLParser_parseEndTag( stack, handler, tagName.toUpperCase() ); return i; }; return 0; // error - }, + }; - saveAttr : function( attrs, name, value ){ + function X_HTMLParser_saveAttr( attrs, name, value ){ name = name.toLowerCase(); - value = X_Dom_Parser.fillAttrs[ name ] === 1 ? name : value; + value = X_HTMLParser_fillAttrs[ name ] === 1 ? name : value; attrs[ attrs.length ] = { name : name, value : value, @@ -264,26 +263,26 @@ var X_Dom_Parser = { // HTMLParser value.split( '"' ).join( '\\"' ).split( '\\\\"' ).join( '\\"' ) : value }; - }, + }; - parseStartTag : function( stack, last, handler, tagName, attrs, empty, index ) { - var inline = X_Dom_Parser.inline, - parseEndTag = X_Dom_Parser.parseEndTag, - sisters = X_Dom_Parser.sisters; - if ( X_Dom_Parser.block[ tagName ] === 1 ) { + function X_HTMLParser_parseStartTag( stack, last, handler, tagName, attrs, empty, index ) { + var inline = X_HTMLParser_inline, + parseEndTag = X_HTMLParser_parseEndTag, + sisters = X_HTMLParser_sisters; + if ( X_HTMLParser_block[ tagName ] === 1 ) { while ( last && inline[ last ] === 1 ) { parseEndTag( stack, handler, last ); last = stack[ stack.length - 1 ]; }; }; - last && X_Dom_Parser.closeSelf[ tagName ] === 1 && ( last === tagName || ( sisters[ tagName ] && sisters[ tagName ][ last ] === 1 ) ) && parseEndTag( stack, handler, last ); - empty = empty || X_Dom_Parser.empty[ tagName ]; + last && X_HTMLParser_closeSelf[ tagName ] === 1 && ( last === tagName || ( sisters[ tagName ] && sisters[ tagName ][ last ] === 1 ) ) && parseEndTag( stack, handler, last ); + empty = empty || X_HTMLParser_empty[ tagName ]; !empty && ( stack[ stack.length ] = tagName ); return handler.start( tagName, attrs, empty, index ); - }, + }; - parseEndTag : function( stack, handler, tagName ) { + function X_HTMLParser_parseEndTag( stack, handler, tagName ) { var pos = 0, i = stack.length; // If no tag name is provided, clean shop @@ -301,16 +300,14 @@ var X_Dom_Parser = { // HTMLParser // Remove the open elements from the stack stack.length = pos; }; - } - -}; + }; var X_HTMLParser_htmlStringToXNode = { flat : null, nest : [], err : function( html ){ X_HTMLParser_htmlStringToXNode.flat.length = 0; - X_HTMLParser_htmlStringToXNode.ignoreError !== true && X.Logger.warn( 'X_Dom_Parser() error ' + html ); + !X_HTMLParser_htmlStringToXNode.ignoreError && X.Logger.warn( 'X_Dom_Parser() error ' + html ); }, start : function( tagName, attrs, noChild, length ){ var xnode, @@ -321,7 +318,7 @@ var X_HTMLParser_htmlStringToXNode = { if( l ){ xnode = nest[ l - 1 ].create( tagName ); } else { - xnode = flat[ flat.length ] = X.Dom.Node.create( tagName ); + xnode = flat[ flat.length ] = X.Node.create( tagName ); }; if( !noChild ) nest[ l ] = xnode; if( i = attrs.length ){ @@ -347,7 +344,7 @@ var X_HTMLParser_htmlStringToXNode = { if( X_HTMLParser_htmlStringToXNode.nest.length ){ X_HTMLParser_htmlStringToXNode.nest[ X_HTMLParser_htmlStringToXNode.nest.length - 1 ].createText( text ); } else { - X_HTMLParser_htmlStringToXNode.flat[ X_HTMLParser_htmlStringToXNode.flat.length ] = X.Dom.Node.createText( text ); + X_HTMLParser_htmlStringToXNode.flat[ X_HTMLParser_htmlStringToXNode.flat.length ] = X.Node.createText( text ); }; }, comment : X.emptyFunction @@ -358,7 +355,7 @@ function X_HtmlParser_parse( html, ignoreError ){ worker.flat = []; worker.nest.length = 0; worker.ignoreError = ignoreError; - X_Dom_Parser.exec( html, worker ); + X_HTMLParser_exec( html, worker ); ret = worker.flat; delete worker.flat; return ret; @@ -385,12 +382,12 @@ var X_HTMLParser_asyncHtmlStringToXNode = { }; function X_HTMLParser_asyncParse( html, ignoreError ){ - var dispatcher = X.Class._override( new X.EventDispatcher(), X_HTMLParser_asyncHtmlStringToXNode ), + var dispatcher = X_Class_override( new X.EventDispatcher(), X_HTMLParser_asyncHtmlStringToXNode ), worker = X_HTMLParser_htmlStringToXNode; dispatcher.listenOnce( X.Event.SUCCESS, dispatcher, dispatcher.kill ); worker.flat = []; worker.nest.length = 0; worker.ignoreError = ignoreError; - X_Dom_Parser.exec( html, dispatcher, [ html.length, [] ] ); + X_HTMLParser_exec( html, dispatcher, [ html.length, [] ] ); return dispatcher; }; diff --git a/0.6.x/js/02_dom/22_XTreeBuilder.js b/0.6.x/js/02_dom/22_XTreeBuilder.js index 86dd109..97df49d 100644 --- a/0.6.x/js/02_dom/22_XTreeBuilder.js +++ b/0.6.x/js/02_dom/22_XTreeBuilder.js @@ -108,7 +108,7 @@ if( X.UA.Opera7 ){ X.ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_PRE_INIT, X_UA_DOM.W3C ? (function(){ - var r = Node._body, + var r = X_Node_body, body = r._rawObject, copy, i, l, node, html, elmProgress; @@ -198,17 +198,17 @@ X.ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_PRE_INIT, } ) .listenOnce( X.Event.SUCCESS, function( e ){ - var xnodes = Node._body._xnodes = [], t; + var xnodes = X_Node_body._xnodes = [], t; xnodes.push.apply( xnodes, e.xnodes ); elmProgress.style.width = '100%'; - X_TEMP.asyncCreateTree( Node._body, body.childNodes, elmProgress ); + X_TEMP.asyncCreateTree( X_Node_body, body.childNodes, elmProgress ); } ); }) : X_UA_DOM.IE4 ? (function(){ - var r = Node._body, + var r = X_Node_body, body = r._rawObject, elmProgress = '_xdom_builder_progress', html; @@ -234,11 +234,11 @@ X_UA_DOM.IE4 ? ) .listenOnce( X.Event.SUCCESS, function( e ){ - var xnodes = Node._body._xnodes = [], t; + var xnodes = X_Node_body._xnodes = [], t; xnodes.push.apply( xnodes, e.xnodes ); elmProgress.style.width = '100%'; - X_TEMP.asyncCreateTree( Node._body, body.childNodes || body.children, elmProgress ); + X_TEMP.asyncCreateTree( X_Node_body, body.childNodes || body.children, elmProgress ); } ); }) : @@ -297,7 +297,7 @@ X_TEMP.asyncCreateTree = function ( parent, elems, elmProgress, async ){ //alert( 'koko?' ); X.Timer.once( 0, X_TEMP.asyncCreateTree, [ null, null, elmProgress, async || { stack : stack, current : i < l && current, done : done } ] ); // progress - elmProgress.style.width = ( ( 1 - done / Node._chashe.length ) * 100 | 0 ) + '%'; + elmProgress.style.width = ( ( 1 - done / X_Node_CHASHE.length ) * 100 | 0 ) + '%'; return; }; }; diff --git a/0.6.x/js/04_util/01_XNinjaIframe.js b/0.6.x/js/04_util/01_XNinjaIframe.js index 7ea88a6..52d98be 100644 --- a/0.6.x/js/04_util/01_XNinjaIframe.js +++ b/0.6.x/js/04_util/01_XNinjaIframe.js @@ -21,7 +21,7 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits( this._name = 'hidden-iframe-' + X_Timer_now(); // https://github.com/polygonplanet/Pot.js/blob/master/src/Worker.js - this.xnodeIframe = X.Dom.Node._body.create( + this.xnodeIframe = X_Node_body.create( 'iframe', { className : 'hidden-iframe', diff --git a/0.6.x/js/04_util/03_XUtilImage.js b/0.6.x/js/04_util/03_XUtilImage.js index 24fdd20..1280c77 100644 --- a/0.6.x/js/04_util/03_XUtilImage.js +++ b/0.6.x/js/04_util/03_XUtilImage.js @@ -18,7 +18,7 @@ function X_Util_Image_getActualDimension( XnodeOrImageElemOrSrc ){ if( X.Type.isString( XnodeOrImageElemOrSrc ) ){ if( ret = X_Util_Image_actualSize[ X_URL_toAbsolutePath( XnodeOrImageElemOrSrc ) ] ) return ret; - xnode = X.Dom.Node._systemNode.create( + xnode = X_Node_systemNode.create( 'img', { src : XnodeOrImageElemOrSrc @@ -27,13 +27,13 @@ function X_Util_Image_getActualDimension( XnodeOrImageElemOrSrc ){ position : 'absolute' } ); - Node._body._startUpdate(); - img = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawObject; + X_Node_startUpdate(); + img = X_UA_DOM.IE4 ? X_Node__ie4getRawNode( xnode ) : xnode._rawObject; remove = true; } else { - if( XnodeOrImageElemOrSrc.constructor === X.Dom.Node ){ + if( XnodeOrImageElemOrSrc.constructor === X.Node ){ xnode = XnodeOrImageElemOrSrc; - img = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawObject; + img = X_UA_DOM.IE4 ? X_Node__ie4getRawNode( xnode )._rawObject : xnode._rawObject; } else if( X.Type.isHTMLElement( XnodeOrImageElemOrSrc ) ){ img = XnodeOrImageElemOrSrc; @@ -50,7 +50,7 @@ function X_Util_Image_getActualDimension( XnodeOrImageElemOrSrc ){ // for Firefox, Safari, Google Chrome if( img.naturalWidth ) return [ img.naturalWidth, img.naturalHeight ]; - if( X.UA.IE && 5 <= X.UA.IE ){// for IE + if( 5 <= X.UA.IE ){// for IE run = img.runtimeStyle; memW = run.width; memH = run.height; diff --git a/0.6.x/js/05_net/01_XNetXHR.js b/0.6.x/js/05_net/01_XNetXHR.js index 8121fe5..1a64bee 100644 --- a/0.6.x/js/05_net/01_XNetXHR.js +++ b/0.6.x/js/05_net/01_XNetXHR.js @@ -73,7 +73,7 @@ X.Net.XHR = { if( X_Net_XHR_W3C || X_Net_XHR_ACTIVE_X ){ - X_NET_XHRWrapper = X.Class._override( + X_NET_XHRWrapper = X_Class_override( new X.EventDispatcher(), { diff --git a/0.6.x/js/05_net/02_XNetJSONP.js b/0.6.x/js/05_net/02_XNetJSONP.js index 9951a78..eb5c24f 100644 --- a/0.6.x/js/05_net/02_XNetJSONP.js +++ b/0.6.x/js/05_net/02_XNetJSONP.js @@ -141,7 +141,7 @@ function X_NET_JSONP_iframeListener( e ){ }; -X_NET_JSONPWrapper = X.Class._override( +X_NET_JSONPWrapper = X_Class_override( new X.EventDispatcher(), { diff --git a/0.6.x/js/05_net/04_XNetImage.js b/0.6.x/js/05_net/04_XNetImage.js index 3573dfa..65c0e8c 100644 --- a/0.6.x/js/05_net/04_XNetImage.js +++ b/0.6.x/js/05_net/04_XNetImage.js @@ -22,12 +22,12 @@ if( X_Net_Image_isElement ){ /* * TODO * new Image() のときに Image オブジェクトを作るもの(IE8-)と、HTMLImageElement を作るものがある。 - * Image は、X.EventDispatcher で、 は X.Dom.Node で。 + * Image は、X.EventDispatcher で、 は X.Node で。 * * Opera7 では毎回 image を作る必要あり、src が異なればOK? */ -X_NET_ImageWrapper = X.Class._override( - !X_Net_Image_isElement ? new X.EventDispatcher( X_Net_Image_image ) : new X.Dom.Node( X_Net_Image_image ), +X_NET_ImageWrapper = X_Class_override( + !X_Net_Image_isElement ? new X.EventDispatcher( X_Net_Image_image ) : new X.Node( X_Net_Image_image ), { _busy : false, @@ -138,4 +138,4 @@ X_NET_ImageWrapper = X.Class._override( X_NET_ImageWrapper.listen( [ 'load', 'error' /*, 'abort'*/, X.Event.KILL_INSTANCE ] ); -// X_Net_Image_isElement && X_NET_ImageWrapper.appendTo( X.Dom.Node._systemNode ); +// X_Net_Image_isElement && X_NET_ImageWrapper.appendTo( X.X_Node_systemNode ); diff --git a/0.6.x/js/06_audio/01_XHTML5Audio.js b/0.6.x/js/06_audio/01_XHTML5Audio.js index e6d9ad6..536e229 100644 --- a/0.6.x/js/06_audio/01_XHTML5Audio.js +++ b/0.6.x/js/06_audio/01_XHTML5Audio.js @@ -17,7 +17,7 @@ if( window.HTMLAudioElement ){ }; }; - X_Audio_HTML5Audio = X.Class._override( + X_Audio_HTML5Audio = X_Class_override( new X.EventDispatcher(), { backendName : 'HTML5 Audio', @@ -155,7 +155,7 @@ if( window.HTMLAudioElement ){ if( option.startTime ) this._startTime = option.startTime; if( option.volume ) this._volume = option.volume; - this._rawObject = X_Audio_rawAudio || new Audio( source );//X.Dom.Node.create( 'audio', { src : source } ).appendToRoot();//( X.Dom.Node._systemNode ); + this._rawObject = X_Audio_rawAudio || new Audio( source );//X.Node.create( 'audio', { src : source } ).appendToRoot();//( X.X_Node_systemNode ); this.listen( [ 'loadstart', 'load', 'progress', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'play', 'pause', 'loadedmetadata', diff --git a/0.6.x/js/06_audio/02_XSilverlightAudio.js b/0.6.x/js/06_audio/02_XSilverlightAudio.js index dfddccb..3eb6538 100644 --- a/0.6.x/js/06_audio/02_XSilverlightAudio.js +++ b/0.6.x/js/06_audio/02_XSilverlightAudio.js @@ -26,7 +26,7 @@ if( X.Pulgin.SilverlightEnabled ){ }; }; - X_Audio_SLAudio = X.Class._override( + X_Audio_SLAudio = X_Class_override( new X.EventDispatcher(), { backendName : 'Silverlight Audio', @@ -117,7 +117,7 @@ if( X.Pulgin.SilverlightEnabled ){ if( !X_Audio_SLAudio_uid ){ // source - //X.Dom.Node._systemNode.create( 'script', { type : 'text/xaml', id : 'silverlightaudio' } ) + //X.X_Node_systemNode.create( 'script', { type : 'text/xaml', id : 'silverlightaudio' } ) // .text( ''); @@ -132,7 +132,7 @@ if( X.Pulgin.SilverlightEnabled ){ this.proxy = proxy; this._onload = 'XAudioSilverlightOnLoad' + ( ++X_Audio_SLAudio_uid ); this._callback = window[ this._onload ] = X_Callback_create( this, this.onSLReady, [ option.autoplay ] ); - this.xnodeObject = X.Dom.Node._body + this.xnodeObject = X_Node_body .create( 'object', { type : 'application/x-silverlight-2', data : 'data:application/x-silverlight-2,', diff --git a/0.6.x/js/20_ui/00_XUI.js b/0.6.x/js/20_ui/00_XUI.js index 12e614f..87a5fdf 100644 --- a/0.6.x/js/20_ui/00_XUI.js +++ b/0.6.x/js/20_ui/00_XUI.js @@ -58,7 +58,7 @@ X.UI = { } ), create : function( props ){ - return X.Class._override( new X.UI.Layout.Base, props, true ); + return X_Class_override( new X.UI.Layout.Base, props, true ); } } }; diff --git a/0.6.x/js/20_ui/06_AbstractUINode.js b/0.6.x/js/20_ui/06_AbstractUINode.js index 8ff8402..cf3765f 100644 --- a/0.6.x/js/20_ui/06_AbstractUINode.js +++ b/0.6.x/js/20_ui/06_AbstractUINode.js @@ -66,7 +66,7 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits( this.rootData = rootData; this.parent = parent; this.parentData = parentData; - //this.xnode = X.Dom.Node.create( 'div' ); + //this.xnode = X.Node.create( 'div' ); this.phase = 1; this.dispatch( X.UI.Event.INIT ); @@ -144,7 +144,7 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits( if( v.indexOf( ' ' ) !== -1 ){ v = v.split( ' ' ); } else - if( color && X.Type.isNumber( _v = X.Dom.Style.parseColor( v ) ) ){ + if( color && X.Type.isNumber( _v = X.CSS.parseColor( v ) ) ){ v = _v; } else { // bad @@ -412,7 +412,7 @@ X.UI._AbstractUINode = X.EventDispatcher.inherits( }, /** - * X.Dom.BoxModel の情報を引きながら top,left,width,height,padding,border の設定 + * X_Node_BoxModel の情報を引きながら top,left,width,height,padding,border の設定 */ updateLayout : function( x, y ){ this.boxX = x; @@ -874,10 +874,10 @@ X.UI.AbstractUINode = X.Class.create( X.Class.ABSTRACT | X.Class.SUPER_ACCESS, { parent : function(){ - return X.Class._getPrivate( this ).parent; + return X_Class_getPrivate( this ).parent; }, root : function(){ - return X.Class._getPrivate( this ).root; + return X_Class_getPrivate( this ).root; }, /* @@ -885,7 +885,7 @@ X.UI.AbstractUINode = X.Class.create( * サポートされていない場合は無視される.親のレイアウトによって変わる */ attr : function( nameOrObject, valueOrUnit ){ - var p = X.Class._getPrivate( this ), + var p = X_Class_getPrivate( this ), layout, k, def, attrs, v; if( nameOrObject && X.Type.isObject( nameOrObject ) ){ // setter @@ -921,22 +921,22 @@ X.UI.AbstractUINode = X.Class.create( }, listen : function( type, arg1, arg2, arg3 ){ - X.Class._getPrivate( this ).listen( type, arg1, arg2, arg3 ); + X_Class_getPrivate( this ).listen( type, arg1, arg2, arg3 ); return this; }, listenOnce : function( type, arg1, arg2, arg3 ){ - X.Class._getPrivate( this ).listenOnce( type, arg1, arg2, arg3 ); + X_Class_getPrivate( this ).listenOnce( type, arg1, arg2, arg3 ); return this; }, listening : function( type, arg1, arg2, arg3 ){ - return X.Class._getPrivate( this ).listening( type, arg1, arg2, arg3 ); + return X_Class_getPrivate( this ).listening( type, arg1, arg2, arg3 ); }, unlisten : function( type, arg1, arg2, arg3 ){ - X.Class._getPrivate( this ).unlisten( type, arg1, arg2, arg3 ); + X_Class_getPrivate( this ).unlisten( type, arg1, arg2, arg3 ); return this; }, dispatch : function( e ){ - return X.Class._getPrivate( this ).dispatch( e ); + return X_Class_getPrivate( this ).dispatch( e ); }, getNextNode : function(){ @@ -946,7 +946,7 @@ X.UI.AbstractUINode = X.Class.create( }, nodeIndex : function( v ){ - var data = X.Class._getPrivate( this ); + var data = X_Class_getPrivate( this ); if( typeof v === 'number' ){ // data.nodeIndex( v ); return this; @@ -958,44 +958,44 @@ X.UI.AbstractUINode = X.Class.create( }, getX : function(){ // dirty の場合、rootData.calculate - return X.Class._getPrivate( this ).boxX; + return X_Class_getPrivate( this ).boxX; }, getY : function(){ // dirty の場合、rootData.calculate - return X.Class._getPrivate( this ).boxY; + return X_Class_getPrivate( this ).boxY; }, getAbsoluteX : function(){ // dirty の場合、rootData.calculate - return X.Class._getPrivate( this ).absoluteX; + return X_Class_getPrivate( this ).absoluteX; }, getAbsoluteY: function(){ // dirty の場合、rootData.calculate - return X.Class._getPrivate( this ).absoluteY; + return X_Class_getPrivate( this ).absoluteY; }, getWidth : function(){ // dirty の場合、rootData.calculate - return X.Class._getPrivate( this ).boxWidth; + return X_Class_getPrivate( this ).boxWidth; }, getHeight : function(){ // dirty の場合、rootData.calculate - return X.Class._getPrivate( this ).boxHeight; + return X_Class_getPrivate( this ).boxHeight; }, scrollTo : function( x, y ){ - X.Class._getPrivate( this ).scrollTo( x, y ); + X_Class_getPrivate( this ).scrollTo( x, y ); }, getScrollX : function( v ){ // dirty の場合、rootData.calculate - return X.Class._getPrivate( this ).scrollX( v ); + return X_Class_getPrivate( this ).scrollX( v ); }, getScrollY : function( v ){ // dirty の場合、rootData.calculate - return X.Class._getPrivate( this ).scrollY( v ); + return X_Class_getPrivate( this ).scrollY( v ); }, disabled : function( v ){ - return X.Class._getPrivate( this ).disabled( v ); + return X_Class_getPrivate( this ).disabled( v ); }, cursor : function( v ){ - return X.Class._getPrivate( this ).cursor( v ); + return X_Class_getPrivate( this ).cursor( v ); } } ); diff --git a/0.6.x/js/20_ui/08_Box.js b/0.6.x/js/20_ui/08_Box.js index 8d07dfb..4e2a112 100644 --- a/0.6.x/js/20_ui/08_Box.js +++ b/0.6.x/js/20_ui/08_Box.js @@ -74,7 +74,7 @@ X.UI._Box = X.UI._AbstractUINode.inherits( //throw new Error( 'Box を継承したインスタンスだけが _Box のオーナーになれます' ); }; - this.xnode = X.Dom.Node.create( 'div' ); + this.xnode = X.Node.create( 'div' ); // すでに定義されていればそちらを採用 // supportAttrs や attrClass が、layout を元に上書きされているため @@ -83,7 +83,7 @@ X.UI._Box = X.UI._AbstractUINode.inherits( for( ; i < l; ++i ){ arg = args[ i ]; if( arg.instanceOf && arg.instanceOf( X.UI.AbstractUINode ) ){ - _data = X.Class._getPrivate( arg ); + _data = X_Class_getPrivate( arg ); if( !uinodes ) this.uinodes = uinodes = []; uinodes[ ++j ] = _data; if( _data.parent ){ @@ -95,7 +95,7 @@ X.UI._Box = X.UI._AbstractUINode.inherits( } else if( X.Type.isObject( arg ) ){ if( attrs ){ - attrs = X.Class._override( attrs, arg ); + attrs = X_Class_override( attrs, arg ); } else { attrs = arg; }; @@ -116,7 +116,7 @@ X.UI._Box = X.UI._AbstractUINode.inherits( this.rootData = rootData; this.parent = parent; this.parentData = parentData; - //this.xnode = X.Dom.Node.create( 'div' ); + //this.xnode = X.Node.create( 'div' ); if( i ){ for( ; i; ){ @@ -205,7 +205,7 @@ X.UI._Box = X.UI._AbstractUINode.inherits( //console.log( '### AddAt ' + this.phase ) for( l = _uinodes.length; i < l; ++i ){ - data = X.Class._getPrivate( _uinodes[ i ] ); + data = X_Class_getPrivate( _uinodes[ i ] ); _p1 = p1 && data.phase < 1; _p2 = p2 && data.phase < 2; _p1 && data.initialize( this.root, this.rootData, this.User, this ); @@ -231,7 +231,7 @@ X.UI._Box = X.UI._AbstractUINode.inherits( //console.log( '### AddAt ' + this.phase ) for( ; i; ){ - data = X.Class._getPrivate( _uinodes[ --i ] ); + data = X_Class_getPrivate( _uinodes[ --i ] ); if( ( n = uinodes.indexOf( data ) ) !== -1 ){ uinodes.splice( n, 1 ); data._remove(); @@ -283,29 +283,29 @@ X.UI.Box = X.UI.AbstractUINode.inherits( X.UI._Box, { Constructor : function(){ - X.Class._newPrivate( this, X.UI.Layout.Canvas, arguments ); + X_Class_newPrivate( this, X.UI.Layout.Canvas, arguments ); }, add : function( node /* , node, node ... */ ){ - X.Class._getPrivate( this ).addAt( this.numNodes() + 1, Array.prototype.slice.call( arguments ) ); + X_Class_getPrivate( this ).addAt( this.numNodes() + 1, Array.prototype.slice.call( arguments ) ); return this; }, addAt : function( index, node /* , node, node ... */ ){ if( index < 0 ) index = 0; - X.Class._getPrivate( this ).addAt( arguments[ 0 ], Array.prototype.slice.call( arguments, 1 ) ); + X_Class_getPrivate( this ).addAt( arguments[ 0 ], Array.prototype.slice.call( arguments, 1 ) ); return this; }, remove : function( node /* , node, node ... */ ){ - X.Class._getPrivate( this ).remove( Array.prototype.slice.call( arguments ) ); + X_Class_getPrivate( this ).remove( Array.prototype.slice.call( arguments ) ); return this; }, removeAt : function( from, length ){ - X.Class._getPrivate( this ).removeAt( from, length ); + X_Class_getPrivate( this ).removeAt( from, length ); return this; }, getNodesByClass : function( klass ){ var ret = [], - uinodes = X.Class._getPrivate( this ).uinodes, + uinodes = X_Class_getPrivate( this ).uinodes, i, l, node; if( !uinodes || uinodes.length === 0 ) return ret; for( i = 0, l = uinodes.length; i < l; ++i ){ @@ -318,16 +318,16 @@ X.UI.Box = X.UI.AbstractUINode.inherits( return this.getNodeAt( 0 ); }, getLastChild : function(){ - var uinodes = X.Class._getPrivate( this ).uinodes; + var uinodes = X_Class_getPrivate( this ).uinodes; return uinodes && uinodes.length && uinodes[ uinodes.length - 1 ].User || null; }, getNodeAt : function( index ){ if( index < 0 ) return null; - var uinodes = X.Class._getPrivate( this ).uinodes; + var uinodes = X_Class_getPrivate( this ).uinodes; return uinodes && uinodes[ index ].User || null; }, numNodes : function(){ - var uinodes = X.Class._getPrivate( this ).uinodes; + var uinodes = X_Class_getPrivate( this ).uinodes; return uinodes && uinodes.length || 0; } } @@ -341,7 +341,7 @@ X.UI.Box.presets = function(){ var args = arguments, i = 0, l = args.length, - shadow = X.Class._getClassDef( this ).privateClass, + shadow = X_Class_getClassDef( this ).privateClass, layout = shadow.prototype.layout, arg, attrs, supports, klass, klassDef, privateKlass, boxName; @@ -352,13 +352,13 @@ X.UI.Box.presets = function(){ if( !shadow.prototype.layout && arg.instanceOf && arg.instanceOf( X.UI.Layout.Base ) ){ layout = arg; } else - if( ( klassDef = X.Class._getClassDef( arg ) ) && klassDef.isPrivate ){ + if( ( klassDef = X_Class_getClassDef( arg ) ) && klassDef.isPrivate ){ privateKlass = arg; layout = privateKlass.prototype.layout; } else if( X.Type.isObject( arg ) ){ if( attrs ){ - X.Class._override( attrs, arg, true ); + X_Class_override( attrs, arg, true ); } else { attrs = arg; }; diff --git a/0.6.x/js/20_ui/14_ChromeBox.js b/0.6.x/js/20_ui/14_ChromeBox.js index 0bc2525..f13d9df 100644 --- a/0.6.x/js/20_ui/14_ChromeBox.js +++ b/0.6.x/js/20_ui/14_ChromeBox.js @@ -39,52 +39,52 @@ X.UI.ChromeBox = X.UI.Box.inherits( X.UI._ChromeBox, { Constructor : function(){ - X.Class._newPrivate( this, X.UI.Layout.Canvas, arguments ); + X_Class_newPrivate( this, X.UI.Layout.Canvas, arguments ); }, add : function( node /* , node, node ... */ ){ - X.Class._getPrivate( this ).containerNode.addAt( this.numNodes(), Array.prototype.slice.call( arguments ) ); + X_Class_getPrivate( this ).containerNode.addAt( this.numNodes(), Array.prototype.slice.call( arguments ) ); return this; }, addAt : function( index, node /* , node, node ... */ ){ - X.Class._getPrivate( this ).containerNode.addAt( index, Array.prototype.slice.call( arguments, 1 ) ); + X_Class_getPrivate( this ).containerNode.addAt( index, Array.prototype.slice.call( arguments, 1 ) ); return this; }, remove : function( node /* , node, node ... */ ){ - X.Class._getPrivate( this ).containerNode.remove( arguments ); + X_Class_getPrivate( this ).containerNode.remove( arguments ); return this; }, removeAt : function( from, length ){ - X.Class._getPrivate( this ).containerNode.removeAt( from, length ); + X_Class_getPrivate( this ).containerNode.removeAt( from, length ); return this; }, getNodesByClass : function( klass ){ - return X.Class._getPrivate( this ).containerNode.User.getNodesByClass( klass ); + return X_Class_getPrivate( this ).containerNode.User.getNodesByClass( klass ); }, getFirstChild : function(){ - return X.Class._getPrivate( this ).containerNode.User.getFirstChild(); + return X_Class_getPrivate( this ).containerNode.User.getFirstChild(); }, getLastChild : function(){ - return X.Class._getPrivate( this ).containerNode.User.getLastChild(); + return X_Class_getPrivate( this ).containerNode.User.getLastChild(); }, getNodeByUID : function( uid ){ - return X.Class._getPrivate( this ).containerNode.User.getNodeByUID(); + return X_Class_getPrivate( this ).containerNode.User.getNodeByUID(); }, getNodeAt : function( index ){ - return X.Class._getPrivate( this ).containerNode.User.getNodeAt( index ); + return X_Class_getPrivate( this ).containerNode.User.getNodeAt( index ); }, numNodes : function(){ - return X.Class._getPrivate( this ).containerNode.User.numNodes(); + return X_Class_getPrivate( this ).containerNode.User.numNodes(); }, getContainerNode : function(){ - return X.Class._getPrivate( this ).containerNode.User; + return X_Class_getPrivate( this ).containerNode.User; }, getChromeNodeAt : function( index ){ if( index < 0 ) return null; - var nodes = X.Class._getPrivate( this ).chromeNodes; + var nodes = X_Class_getPrivate( this ).chromeNodes; return nodes ? nodes[ index ].User || null : null; }, numChromeNodes : function(){ - var nodes = X.Class._getPrivate( this ).chromeNodes; + var nodes = X_Class_getPrivate( this ).chromeNodes; return nodes ? nodes.length : 0; } } diff --git a/0.6.x/js/20_ui/15_ScrollBox.js b/0.6.x/js/20_ui/15_ScrollBox.js index a52c1d7..a819447 100644 --- a/0.6.x/js/20_ui/15_ScrollBox.js +++ b/0.6.x/js/20_ui/15_ScrollBox.js @@ -6,7 +6,7 @@ var m = Math, function Options(){}; - X.Class._override( Options.prototype, { + X_Class_override( Options.prototype, { hScroll : true, vScroll : true, x : 0, @@ -51,7 +51,7 @@ var m = Math, this.transrateXorY = 'translateX('; }; }; - X.Class._override( Scrollbar.prototype, { + X_Class_override( Scrollbar.prototype, { owner : null, dir : null, options : null, @@ -70,7 +70,7 @@ var m = Math, // remove scrollbar if( !this.active ){ if( this.xnodeWrapper ){ - X.Dom.Style.transform && this.xnodeIndicator.css( 'transform', '' ); + X.CSS.transform && this.xnodeIndicator.css( 'transform', '' ); this.xnodeWrapper.css( 'display', 'none' ); }; return; @@ -187,11 +187,11 @@ var m = Math, this.y = this.options.y; // Normalize options - this.options.useTransform = X.Dom.Style.transform && this.options.useTransform; + this.options.useTransform = X.CSS.transform && this.options.useTransform; this.options.hScrollbar = this.options.hScroll && this.options.hScrollbar; this.options.vScrollbar = this.options.vScroll && this.options.vScrollbar; this.options.zoom = this.options.useTransform && this.options.zoom; - this.options.useTransition = X.Dom.Style.transition && this.options.useTransition; + this.options.useTransition = X.CSS.transition && this.options.useTransition; // Helpers FIX ANDROID BUG! // translate3d and scale doesn't work together! @@ -203,16 +203,16 @@ var m = Math, // Set some default styles if (this.options.useTransform){ - this.scroller.style[X.Dom.Style.transform] = 'translate(' + this.x + 'px,' + this.y + 'px)' + translateZ; - this.scroller.style[X.Dom.Style.transformOrigin] = '0 0'; + this.scroller.style[X.CSS.transform] = 'translate(' + this.x + 'px,' + this.y + 'px)' + translateZ; + this.scroller.style[X.CSS.transformOrigin] = '0 0'; } else { this.scroller.style.cssText += ';position:absolute;top:' + this.y + 'px;left:' + this.x + 'px'; }; if (this.options.useTransition){ - this.scroller.style[X.Dom.Style.transition.Property] = this.options.useTransform ? X.Dom.Style.cssVendor + 'transform' : 'top left'; - this.scroller.style[X.Dom.Style.transition.Duration] = '0'; - this.scroller.style[X.Dom.Style.transition.TimingFunction] = 'cubic-bezier(0.33,0.66,0.66,1)'; + this.scroller.style[X.CSS.transition.Property] = this.options.useTransform ? X.CSS.cssVendor + 'transform' : 'top left'; + this.scroller.style[X.CSS.transition.Duration] = '0'; + this.scroller.style[X.CSS.transition.TimingFunction] = 'cubic-bezier(0.33,0.66,0.66,1)'; this.options.fixedScrollbar = true; }; @@ -225,7 +225,7 @@ var m = Math, }; // Prototype -X.Class._override( iScroll.prototype, { +X_Class_override( iScroll.prototype, { uinodeRoot : null, uinodeTarget : null, xnodeTarget : null, @@ -921,7 +921,7 @@ X.UI._ScrollBox = X.UI._ChromeBox.inherits( Constructor : function( layout, args ){ this.SuperConstructor( layout, args ); - this._containerNode = _X.Class._getPrivate( this.containerNode ); + this._containerNode = _X_Class_getPrivate( this.containerNode ); }, creationComplete : function(){ @@ -1015,7 +1015,7 @@ X.UI.ScrollBox = X.UI.ChromeBox.inherits( }; /* this.style = DisplayNodeStyle( this, - X.Class._newPrivate( + X_Class_newPrivate( this, X.UI.Layout.Canvas, [ diff --git a/0.6.x/js/20_ui/17_Text.js b/0.6.x/js/20_ui/17_Text.js index 3e93b97..91a160c 100644 --- a/0.6.x/js/20_ui/17_Text.js +++ b/0.6.x/js/20_ui/17_Text.js @@ -8,7 +8,7 @@ X.UI._Text = X.UI._AbstractUINode.inherits( if( !( this.User.instanceOf( X.UI.Text ) ) ){ alert( 'Text を継承したインスタンスだけが _Text のオーナーになれます' ); }; - this.xnode = X.Dom.Node.create( 'div' ); + this.xnode = X.Node.create( 'div' ); if( X.Type.isString( content ) && content ){ this.content = content; @@ -25,11 +25,11 @@ X.UI.Text = X.UI.AbstractUINode.inherits( X.UI._Text, { Constructor : function( opt_content, opt_cssObj ){ - X.Class._newPrivate( this, opt_content ); + X_Class_newPrivate( this, opt_content ); X.Type.isObject( opt_cssObj = opt_cssObj || opt_content ) && this.attr( opt_cssObj ); }, content : function( v ){ - var data = X.Class._getPrivate( this ); + var data = X_Class_getPrivate( this ); if( data.content !== v ){ data.xnode && data.xnode.text( v ); data.rootData.reserveCalc(); diff --git a/0.6.x/js/20_ui/20_PageRoot.js b/0.6.x/js/20_ui/20_PageRoot.js index a692fbc..c346c0c 100644 --- a/0.6.x/js/20_ui/20_PageRoot.js +++ b/0.6.x/js/20_ui/20_PageRoot.js @@ -106,9 +106,9 @@ X.UI._PageRoot = X.UI._Box.inherits( // this.xnodeInteractiveLayer の前に追加する! - this.addToParent( X.Dom.Node._body ); + this.addToParent( X.Doc.body ); - this.xnodeInteractiveLayer = X.Dom.Node._body.create( 'div', { + this.xnodeInteractiveLayer = X.Doc.body.create( 'div', { 'class' : 'mouse-operation-catcher', unselectable : 'on' } ); -- 2.11.0