X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_dom%2F14_XDomAttr.js;fp=0.6.x%2Fjs%2F01_dom%2F14_XDomAttr.js;h=0000000000000000000000000000000000000000;hb=51e22031f9629d4bc32444a0228930642144ee9e;hp=3fd0ed2fef3d95427e83464a03aba464c2cd73de;hpb=05ae2ffbbca8b1bdb4c3fcbfdd4e1708c0485360;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/01_dom/14_XDomAttr.js b/0.6.x/js/01_dom/14_XDomAttr.js deleted file mode 100644 index 3fd0ed2..0000000 --- a/0.6.x/js/01_dom/14_XDomAttr.js +++ /dev/null @@ -1,187 +0,0 @@ -X.Dom.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 - }, - renameForDOM : { - 'class' : 'className', - accesskey : 'accessKey', - 'accept-charset' : 'acceptCharset', - bgcolor : 'bgColor', - cellpadding : 'cellPadding', - cellspacing : 'cellSpacing', - 'char' : 'ch', - charoff : 'chOff', - codebase : 'codeBase', - codetype : 'codeType', - colspan : 'colSpan', - datetime : 'dateTime', - 'for' : 'htmlFor', - frameborder : 'frameBorder', - 'http-equiv' : 'httpEquiv', - ismap : 'isMap', - longdesc : 'longDesc', - maxlength : 'maxLength', - nohref : 'noHref', - readonly : 'readOnly', - rowspan : 'rowSpan', - tabindex : 'tabIndex', - usemap : 'useMap', - valuetype : 'valueType', - checked : 'defaultChecked' - }, - - HAS_VALUE : { - INPUT : true, - TEXTAREA : true, - SELECT : true, - BUTTON : true - }, - - renameForTag : {}, - // http://nanto.asablo.jp/blog/2005/10/29/123294 - // checked -> defaultChecked - // 動的に生成した input 要素を文書ツリーに挿入する前に設定した checked 属性は反映されず、defaultChecked だと反映される - // 先頭にスペース - objToAttrText : function( obj ){ - var noValue = X.Dom.Attr.noValue, - attrs = [ '' ], n = 0, p, v; - if( !obj ) return ''; // Opera7 - for( p in obj ){ - v = obj[ p ]; - if( p === 'value' ){ - v = v.split( '"' ).join( '"' ).split( '>' ).join( '>' ).split( '<' ).join( '<' ); - }; - attrs[ ++n ] = noValue[ p ] ? p : [ p, '="', v, '"' ].join( '' ); - }; - return 0 < n ? attrs.join( ' ' ) : ''; - } -}; - -(function( renameForDOM, renameForTag ){ - var name, i; - for( name in renameForDOM ){ - renameForTag[ renameForDOM[ name ] ] = name; - }; -})( X.Dom.Attr.renameForDOM, X.Dom.Attr.renameForTag ); - - - -/* -------------------------------------- - * attribute - * X.Dom.Attr.toIndex に定義されている 属性の場合 - * - * http://nanto.asablo.jp/blog/2005/10/29/123294 - * className, onclick等 はここで設定しない - * - */ -X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){ - var attrs = this._attrs, newAttrs, f, p, elm, v; - - if( this._xnodeType !== 1 ) return this; - - if( nameOrObj && X.Type.isObject( nameOrObj ) ){ - attrs || ( attrs = this._attrs = {} ); - newAttrs = this._newAttrs || ( this._newAttrs = {} ); - - for( p in nameOrObj ){ - if( this._setAttr( attrs, newAttrs, p, nameOrObj[ p ] ) === true ) f = true; - }; - if( f ){ - this._attrText = false; - this._dirty |= X.Dom.Dirty.ATTR; - this._root && this._reserveUpdate(); - }; - return this; - } else - if( 1 < arguments.length ){ - // setter - if( this._setAttr( attrs || ( this._attrs = {} ), this._newAttrs || ( this._newAttrs = {} ), nameOrObj, arguments[ 1 ] ) === true ){ - this._attrText = false; - this._dirty |= X.Dom.Dirty.ATTR; - this._root && this._reserveUpdate(); - }; - return this; - } else - if( typeof nameOrObj === 'string' ){ - // getter - switch( nameOrObj ){ - case 'id' : - return this._id; - case 'class' : - case 'className' : - return this._className; - case 'tag' : - case 'tagName' : - return this._tag; - case 'style' : - case 'cssText' : - return this.cssText(); - case 'value' : - case 'checked' : - case 'selected' : - case 'disabled' : - case 'selectedIndex' : - if( X.Dom.Attr.HAS_VALUE[ this._tag ] ){ - if( this._newAttrs && X.inObject( nameOrObj, this._newAttrs ) ) return this._newAttrs[ nameOrObj ]; - if( elm = X.Dom.DOM_IE4 ? this._rawObject || this._ie4getRawNode() : this._rawObject ){ - if( !attrs ) attrs = this._attrs = {}; - return attrs[ nameOrObj ] = elm[ nameOrObj ]; // getAttribute( nameOrObj )? - }; - }; - break; - }; - return attrs && attrs[ X.Dom.Attr.renameForTag[ nameOrObj ] || nameOrObj ]; - }; -}; -X.Dom.Node.prototype._setAttr = function( attrs, newAttrs, name, v ){ - switch( name ){ - // case 'type' : TODO IE は input, button に対して type の再設定が出来ない _state が要素生成済なら不可 - case 'UID' : - case 'tag' : - case 'tagName' : - return; - case 'id' : - v = ( v !== 'ie4uid' + this._uid ) ? v : undefined; - if( v !== this._id ){ - this._id = v; - this._dirty |= X.Dom.Dirty.ID; - this._root && this._reserveUpdate(); - }; - return; - case 'class' : - case 'className' : - return this.className( v ); - case 'style' : - case 'cssText' : - return this.cssText( v ); - }; - // debug - if( name.indexOf( 'on' ) === 0 ){ - X.Notification.warn( 'xnode.attr("' + name + '") is wrong, xnode.listen() & xnode.unlisten().' ); - return; - }; - - name = X.Dom.Attr.renameForTag[ name ] || name; - if( attrs[ name ] === v ) return; - - if( v == null ){ - newAttrs[ name ] = undefined; - if( attrs.hasOwnProperty( name ) ) delete attrs[ name ]; - } else { - newAttrs[ name ] = attrs[ name ] = v; - }; - return true; -}; -