OSDN Git Service

Version 0.6.51, add logger.html, fix for NF3.4.
[pettanr/clientJs.git] / 0.6.x / js / _old / xdoc.js
1 var BoxModel;\r
2 \r
3 var DOM = ( function( window, document ){\r
4         var DIV_LIST  = [],\r
5                 SPAN_LIST = [],\r
6                 TEXT_LIST = [];\r
7         \r
8         var elmTextSize;\r
9         \r
10         function correctNodes( node ){\r
11                 var child;\r
12                 if( node && node.parentNode ){\r
13                         while( node.lastChild ) correctNodes( node.lastChild );\r
14                         node.parentNode.removeChild( node );\r
15                         if( node.nodeType === 1 ){\r
16                                 switch( node.tagName ){\r
17                                         case 'DIV':\r
18                                                 DIV_LIST.push( node );\r
19                                                 break;\r
20                                         case 'SPAN':\r
21                                                 SPAN_LIST.push( node );\r
22                                                 break;\r
23                                         \r
24                                 };\r
25                                 node.removeAttribute( 'className' );\r
26                                 node.removeAttribute( 'style' );\r
27                                 node.removeAttribute( 'id' );\r
28                         } else\r
29                         if( node.nodeType === 3 ){\r
30                                 node.data = '';\r
31                                 TEXT_LIST.push( node );\r
32                         };\r
33                 };\r
34         };\r
35         \r
36         return {\r
37                 createDiv : function(){\r
38                         return 0 < DIV_LIST.length ? DIV_LIST.shift() : document.createElement( 'div' );\r
39                 },\r
40                 createSpan : function(){\r
41                         \r
42                 },\r
43                 createText : function(){\r
44                         \r
45                 },\r
46                 getTextSize : function( elm, content ){\r
47                         var span = DOM.createSpan(),\r
48                                 text = DOM.createText(),\r
49                                 w, h;\r
50                         elm.appendChild( span );\r
51                         span.style.cssText = 'visibility:hidden;position:absolute;';\r
52                         span.appendChild( text );\r
53                         text.data = content;\r
54                         w = span.offsetWidth;\r
55                         h = span.offsetHeight;\r
56                         DOM.correctNodes( span );\r
57                         return [ w, h ];\r
58                 },\r
59                 getTextHeight : function( elm, w, content ){\r
60                         var div  = DOM.createSpan(),\r
61                                 text = DOM.createText(),\r
62                                 w, h;\r
63                         elm.appendChild( div );\r
64                         div.style.cssText = 'visibility:hidden;position:absolute;width:' + w + 'px;';\r
65                         div.appendChild( text );\r
66                         text.data = content;\r
67                         w = div.offsetWidth;\r
68                         h = div.offsetHeight;\r
69                         DOM.correctNodes( div );\r
70                         return h;\r
71                 },\r
72                 correctNodes : function( node ){\r
73                         var child;\r
74                         if( node && node.parentNode ){\r
75                                 while( node.lastChild ) DOM.correctNodes( node.lastChild );\r
76                                 node.parentNode.removeChild( node );\r
77                                 if( node.nodeType === 1 ){\r
78                                         switch( node.tagName ){\r
79                                                 case 'DIV':\r
80                                                         DIV_LIST.push( node );\r
81                                                         break;\r
82                                                 case 'SPAN':\r
83                                                         SPAN_LIST.push( node );\r
84                                                         break;\r
85                                                 \r
86                                         };\r
87                                         node.removeAttribute( 'className' );\r
88                                         node.removeAttribute( 'style' );\r
89                                         node.removeAttribute( 'id' );\r
90                                 } else\r
91                                 if( node.nodeType === 3 ){\r
92                                         node.data = '';\r
93                                         TEXT_LIST.push( node );\r
94                                 };\r
95                         };\r
96                 }\r
97         }\r
98 })( window, document );\r
99 \r
100 var XBrowserStyle = ( function(){\r
101         var     EMPTY          = '',\r
102                 CORON          = ':',\r
103                 SEMICORON      = ';',\r
104                 SPACE          = ' ',\r
105                 UNITS          = 'px,cm,mm,in,pt,pc,em,%'.split( ',' ),\r
106                 CLIP_SEPARATOR = UA.isIE === true && UA.ieVersion < 8 ? ' ' : ',';\r
107 \r
108         var SPECIAL = ( function(){\r
109                 var special = {};\r
110                 if( UA.isIE === true && UA.ieVersion < 9 ){\r
111                         if( UA.ACTIVEX === true ){\r
112                                 // special.opacity    = 'ActiveXOpacity';\r
113                                 special.setFilters = function( style ){\r
114                                         var filters = ( style.filter || '' ).split( ') ' ),\r
115                                                 data    = {},\r
116                                                 i       = filters.length,\r
117                                                 filter, names, props, prop, j, l, key, v;\r
118                                         for( ; i; ){\r
119                                                 filter   = filters[ --i ].split( ' ' ).join( '' ).split( '(' );\r
120                                                 if( filter.length !== 2 ) continue;\r
121                                                 names    = filter[ 0 ].split( '.' ); // progid:DXImageTransform.Microsoft.Shadow(color=#666666,direction=120,strength=9)\r
122                                                 props    = filter[ 1 ].split( ',' ); // \r
123                                                 filter   = {};\r
124                                                 for( j = 0, l = props.length; j < l; ++j ){\r
125                                                         prop = props[ j ].split( '=' );\r
126                                                         key  = prop[ 0 ].toLowerCase();\r
127                                                         v    = prop[ 1 ];\r
128                                                         filter[ key ] = v; //v.charAt( 0 ) === '#' ? v : parseInt( v );\r
129                                                 };\r
130                                                 data[ names[ names.length - 1 ] ] = filter;\r
131                                         };\r
132                                         \r
133                                         style.filter  = data;\r
134                                         style.opacity = data.alpha && data.alpha.opacity ? data.alpha.opacity / 100 : 1;\r
135                                 };\r
136                                 special.hasLayout = function( elm ){\r
137                                         return elm.currentStyle.hasLayout;\r
138                                 };\r
139                         } else {\r
140                                 special.opacity = null;\r
141                         };\r
142                 } else {\r
143                         var style = document.documentElement.style;\r
144                         special.opacity = style.opacity           !== undefined ? 'opacity' : \r
145                                                         style.MozOpacity          !== undefined ? 'MozOpacity' :\r
146                                                         style.KhtmlOpacity        !== undefined ? 'KhtmlOpacity' :\r
147                                                         style[ '-khtml-opacity' ] !== undefined ? 'KhtmlOpacity' : null;\r
148 \r
149                         // if( style.backgroundPositionX === undefined ){\r
150                                 special.setBackgroundPositionXY = function( style ){\r
151                                         var bgp = ( style.backgroundPosition || '' ).split( ' ' );\r
152                                         style.backgroundPositionX = bgp[ 0 ] || 0;\r
153                                         style.backgroundPositionY = bgp[ 1 ] || 0;\r
154                                 };\r
155                         // };\r
156                         if( style.clipTop === undefined && style[ 'clip-top' ] === undefined ){\r
157                                 special.setClipTopRightBottomLeft = function( style ){\r
158                                         var clip = style.clip;\r
159                                         if( !cliop || clip.indexOf( 'rect(' ) === -1 ){\r
160                                                 style.clipTop    = 0;\r
161                                                 style.clipRight  = 0;\r
162                                                 style.clipBottom = 0;\r
163                                                 style.clipLeft   = 0;\r
164                                                 return;\r
165                                         };\r
166                                         clip = clip.split( '(' )[ 1 ].split( ')' )[ 0 ].split( clip.indexOf( ',' ) !== -1 ? ',' : ' ' );\r
167                                         ret.clipTop    = clip[ 0 ];\r
168                                         ret.clipRight  = clip[ 1 ];\r
169                                         ret.clipBottom = clip[ 2 ];\r
170                                         ret.clipLeft   = clip[ 3 ];\r
171                                 };\r
172                         };\r
173                 };\r
174                 return special;\r
175         })();\r
176         \r
177         function cssToObject( css ){\r
178                 var ret      = {}, i, nv, n, v,\r
179                         parse    = Util.parse,\r
180                         isNumber = Type.isNumber,\r
181                         camelize = Util.camelize;\r
182                 if( Type.isString( css ) === true ){\r
183                         css = css.split( SEMICORON );\r
184                         for( i = css.length; i; ){\r
185                                 nv = css[ --i ].split( CORON ); // filter の場合, progid: がくる\r
186                                 n  = nv.shift();\r
187                                 if( isNumber( parse( n ) ) === true ) continue;\r
188                                 v  = nv.join( EMPTY );\r
189                                 while( v.charAt( 0 ) === ' ' ) v = v.substr( 1 );\r
190                                 ret[ camelize( n ) ] = parse( v );\r
191                         };\r
192                 } else {\r
193                         for( n in css ){\r
194                                 if( Type.isNumber( parse( n ) ) === false ) ret[ n ] = parse( css[ n ] );\r
195                         };\r
196                 };\r
197 \r
198                 if( SPECIAL.setFilters ){\r
199                         SPECIAL.setFilters( ret );\r
200                 } else {\r
201                         ret.opacity = SPECIAL.opacity !== null ? ret[ SPECIAL.opacity ] : 1;\r
202                 };\r
203                 \r
204                 SPECIAL.setBackgroundPositionXY && SPECIAL.setBackgroundPositionXY( ret );\r
205                 SPECIAL.setClipTopRightBottomLeft && SPECIAL.setClipTopRightBottomLeft( ret );\r
206                 \r
207                 return ret;\r
208         };\r
209 \r
210         var COLOR = ( function(){\r
211                 var ret = {}, v, name,\r
212                         list = [\r
213                                 '0', 'BLACK',\r
214                                 'FF0000', 'RED',\r
215                                 '00FF00', 'LIME',\r
216                                 '0000FF', 'BLUE',\r
217                                 'FFFF00', 'YELLOW',\r
218                                 '00FFFF', 'AQUA',\r
219                                 '00FFFF', 'CYAN',\r
220                                 'FF00FF', 'MAGENTA',\r
221                                 'FF00FF', 'FUCHSIA',\r
222                                 'FFFFFF', 'WHITE',\r
223                                 '008000', 'GREEN',\r
224                                 '800080', 'PURPLE',\r
225                                 '800000', 'MAROON',\r
226                                 '000080', 'NAVY',\r
227                                 '808000', 'OLIVE',\r
228                                 '008080', 'TEAL',\r
229                                 '808080', 'GRAY',\r
230                                 'C0C0C0', 'SILVER',\r
231                                 '696969', 'DIMGRAY',\r
232                                 '708090', 'SLATEGRAY',\r
233                                 'A9A9A9', 'DARKGRAY',\r
234                                 'DCDCDC', 'GAINSBORO',\r
235                                 '191970', 'MIDNIGHTBLUE',\r
236                                 '6A5ACD', 'SLATEBLUE',\r
237                                 '0000CD', 'MEDIUMBLUE',\r
238                                 '4169E1', 'ROYALBLUE',\r
239                                 '1E90FF', 'DODGERBLUE',\r
240                                 '87CEEB', 'SKYBLUE',\r
241                                 '4682B4', 'STEELBLUE',\r
242                                 'ADD8E6', 'LIGHTBLUE',\r
243                                 'AFEEEE', 'PALETURQUOISE',\r
244                                 '40E0D0', 'TURQUOISE',\r
245                                 'E0FFFF', 'LIGHTCYAN',\r
246                                 '7FFFD4', 'AQUAMARINE',\r
247                                 '006400', 'DARKGREEN',\r
248                                 '2E8B57', 'SEAGREEN',\r
249                                 '90EE90', 'LIGHTGREEN',\r
250                                 '7FFF00', 'CHARTREUSE',\r
251                                 'ADFF2F', 'GREENYELLOW',\r
252                                 '32CD32', 'LIMEGREEN',\r
253                                 '9ACD32', 'YELLOWGREEN',\r
254                                 '6B8E23', 'OLIVEDRAB',\r
255                                 'BCB76B', 'DARKKHAKI',\r
256                                 'EEE8AA', 'PALEGOLDENROD',\r
257                                 'FFFFE0', 'LIGHTYELLOW',\r
258                                 'FFD700', 'GOLD',\r
259                                 'DAA520', 'GOLDENROD',\r
260                                 'B8860B', 'DARKGOLDENROD',\r
261                                 'BC8F8F', 'ROSYBROWN',\r
262                                 'CD5C5C', 'INDIANRED',\r
263                                 '8B4513', 'SADDLEBROWN',\r
264                                 'A0522D', 'SIENNA',\r
265                                 'CD853F', 'PERU',\r
266                                 'DEB887', 'BURLYWOOD',\r
267                                 'F5F5DC', 'BEIGE',\r
268                                 'F5DEB3', 'WHEAT',\r
269                                 'F4A460', 'SANDYBROWN',\r
270                                 'D2B48C', 'TAN',\r
271                                 'D2691E', 'CHOCOLATE',\r
272                                 'B22222', 'FIREBRICK',\r
273                                 'A52A2A', 'BROWN',\r
274                                 'FA8072', 'SALMON',\r
275                                 'FFA500', 'ORANGE',\r
276                                 'FF7F50', 'CORAL',\r
277                                 'FF6347', 'TOMATO',\r
278                                 'FF69B4', 'HOTPINK',\r
279                                 'FFC0CB', 'PINK',\r
280                                 'FF1493', 'DEEPPINK',\r
281                                 'DB7093', 'PALEVIOLETRED',\r
282                                 'EE82EE', 'VIOLET',\r
283                                 'DDA0DD', 'PLUM',\r
284                                 'DA70D6', 'ORCHILD',\r
285                                 '9400D3', 'DARKVIOLET',\r
286                                 '8A2BE2', 'BLUEVIOLET',\r
287                                 '9370DB', 'MEDIUMPURPLE',\r
288                                 'D8BFD8', 'THISTLE',\r
289                                 'E6E6FA', 'LAVENDER',\r
290                                 'FFE4E1', 'MISTYROSE',\r
291                                 'FFFFF0', 'IVORY',\r
292                                 'FFFACD', 'LEMONCHIFFON'\r
293                         ];\r
294                 for( i = list.length; i; ){\r
295                         v    = list[ --i ];\r
296                         name = list[ --i ];\r
297                         ret[ name ] = parseInt( v, 16 );\r
298                 };\r
299                 return ret;\r
300         })();\r
301         \r
302         var PARAMS = ( function(){\r
303                 var ret = {};\r
304                 register( ret.percent = {},\r
305                         'marginBottom,marginLeft,marginRight,marginTop,paddingBottom,paddingLeft,paddingRight,paddingTop,fontSize,textIndent'\r
306                 );\r
307                 register( ret.offset = {},\r
308                         'height,width,bottom,left,right,top'\r
309                 );              \r
310                 register( ret.size = {},\r
311                         'borderBottomWidth,borderLeftWidth,borderRightWidth,borderTopWidth,letterSpacing'\r
312                 );\r
313                 register( ret.color = {},\r
314                         'backgroundColor,borderBottomColor,borderLeftColor,borderRightColor,borderTopColor,color'\r
315                 );\r
316                 register( ret.region = {},\r
317                         'margin,padding,borderWidth,borderColor'\r
318                 );              \r
319                 register( ret.special = {},\r
320                         'clip,backgroundPosition,opacity,lineHeight,zIndex'\r
321                 );\r
322                 register( ret.unit = {}, 'px,cm,mm,in,pt,pc,em,%' );\r
323                 \r
324                 register( ret.margin = {}, 'marginBottom,marginLeft,marginRight,marginTop,paddingBottom' );\r
325                 register( ret.padding = {}, 'paddingBottom,paddingLeft,paddingRight,paddingTop' );\r
326                 register( ret.borderWidth = {}, 'borderBottomWidth,borderLeftWidth,borderRightWidth,borderTopWidth' );\r
327                 register( ret.borderColor = {}, 'borderBottomColor,borderLeftColor,borderRightColor,borderTopColor' );\r
328                 \r
329                 function register( obj, params ){\r
330                         params = params.split( ',' );\r
331                         for( var i=params.length; i; ) obj[ params[ --i ] ] = true;\r
332                 };\r
333                 return ret;\r
334         })();\r
335         \r
336         /*\r
337          * \r
338          */\r
339         var Property = Class.create(\r
340                 'Property',\r
341                 Class.POOL_OBJECT,\r
342                 {\r
343                         Constructor : function( name, value, unit, pxPerEm ){\r
344                                 this.name    = name;\r
345                                 this.value   = value;\r
346                                 this.unit    = unit;\r
347                                 this.pxPerEm = pxPerEm; // XXpx = 1em;\r
348                         },\r
349                         name    : '',\r
350                         value   : 0,\r
351                         pxPerEm : 12, // 1em === ??px\r
352                         unit    : '',\r
353                         equal : function( prop ){\r
354                                 if( this.unit === prop.unit ){\r
355                                         return this.value === prop.value;\r
356                                 };\r
357                                 return Math.abs( this.toPx() - prop.toPx() ) < 1;\r
358                         },\r
359                         convert: function( prop ){\r
360                                 var u = prop.unit, v;\r
361                                 if( this.unit === u ) return;\r
362                                 this.value = v = this.toPx();\r
363                                 this.unit  = u;\r
364                                 if( u !== px ){\r
365                                         this.value = u === 'em' ? v / this.pxPerEm : Util.pxTo( v, u );\r
366                                 };\r
367                         },\r
368                         setValue: function( v ){\r
369                                 this.value = v;\r
370                         },\r
371                         getValue: function(){\r
372                                 return this.value;\r
373                         },\r
374                         getOffset: function( prop ){\r
375                                 return prop.value - this.value;\r
376                         },\r
377                         getUnit: function(){\r
378                                 return this.unit;\r
379                         },\r
380                         getValueText: function(){\r
381                                 return this.value === 0 ? '0' : this.value + this.unit;\r
382                         },\r
383                         toPx: function(){\r
384                                 var v = this.value, u = this.unit;\r
385                                 if( u === px )   return v;\r
386                                 if( u === 'em' ) return v * this.pxPerEm;\r
387                                 if( u === '' && this.name === 'lineHeight' ) return v * this.pxPerEm;\r
388                                 return Util.toPx( v, u );\r
389                         },\r
390                         isValid: function( t ){\r
391                                 t = t || this;\r
392                                 var n = t.name,\r
393                                         v = t.value,\r
394                                         u = t.unit,\r
395                                         z = u !== '' ? true : v === 0;\r
396                                 if( PARAMS.percent[ n ] === true ) return z;\r
397                                 if( PARAMS.offset[ n ] === true  ) return z;\r
398                                 if( PARAMS.size[ n ] === true  )   return z && u !== '%';\r
399                                 if( PARAMS.special[ n ] === true  ){\r
400                                         if( n === 'lineHeight' ) return true;\r
401                                         if( n === 'opacity' )    return 0 <= v && v <= 1 && u === '';\r
402                                         if( n === 'zIndex'  )    return u === '';\r
403                                 };\r
404                                 return false;\r
405                         }\r
406                 }\r
407         );\r
408         \r
409         /**\r
410          * backgroundPosition, clip\r
411          */\r
412         var PropertyGroup = Class.create(\r
413                 'PropertyGroup',\r
414                 Class.POOL_OBJECT,\r
415                 {\r
416                         Constructor : function( name ){\r
417                                 this.name  = name;\r
418                                 this.props = [];\r
419                                 for( var i = 1, l = arguments.length; i<l; ++i ){\r
420                                         this.props.push( arguments[ i ] );\r
421                                 };\r
422                         },\r
423                         name  : '',\r
424                         equal : function( prop ){\r
425                                 var ps = this.props, i = ps.length;\r
426                                 for( ; i; ){\r
427                                         --i;\r
428                                         if( ps[ i ].equal( prop[ i ] ) === false ) return false;\r
429                                 };\r
430                                 return true;\r
431                         },\r
432                         convert : function( prop ){\r
433                                 var ps = this.props, i = ps.length;\r
434                                 for( ; i; ){\r
435                                         --i;\r
436                                         ps[ i ].convert( prop[ i ] );\r
437                                 };\r
438                         },\r
439                         setValue : function( ary ){\r
440                                 var ps = this.props, i = 0, l = ps.length;\r
441                                 for( ; i<l; ++i ){\r
442                                         ps[ i ].setValue( ary[ i ] );\r
443                                 };\r
444                         },\r
445                         getValue : function(){\r
446                                 var ret = [], ps = this.props, i = 0, l = ps.length;\r
447                                 for( ; i<l; ++i ){\r
448                                         ret.push( ps[ i ].getValue() );\r
449                                 };\r
450                                 return ret;\r
451                         },\r
452                         getOffset : function( prop ){\r
453                                 var ret = [],\r
454                                         ps  = this.props,\r
455                                         _ps = prop.props,\r
456                                         i   = 0,\r
457                                         l = ps.length;\r
458                                 for( ; i<l; ++i ){\r
459                                         ret.push( ps[ i ].getOffset( _ps[ i ] ) );\r
460                                 };\r
461                                 return ret;\r
462                         },\r
463                         getUnit : function(){\r
464                                 var ret = [], ps = this.props, i = 0, l = ps.length;\r
465                                 for( ; i<l; ++i ){\r
466                                         ret.push( ps[ i ].getUnit() );\r
467                                 };\r
468                                 return ret;\r
469                         },\r
470                         getValueText : function(){\r
471                                 var ret = [], ps = this.props, i = 0, l = ps.length;\r
472                                 for( ; i<l; ++i ){\r
473                                         ret.push( ps[ i ].getValueText() );\r
474                                 };                      \r
475                                 if( this.name === 'clip' ){\r
476                                         return 'rect(' + ret.join( CLIP_SEPARATOR ) + ')';\r
477                                 };\r
478                                 return ret.join( ' ' );\r
479                         },\r
480                         onKill : function(){\r
481                                 var ps = this.props, i = ps.length;\r
482                                 for( ; i; ){\r
483                                         ps[ --i ].kill();\r
484                                 };\r
485                         },\r
486                         isValid : function( t ){\r
487                                 t = t || this;\r
488                                 var ps = t.props, i = ps.length;\r
489                                 for( ; i; ){\r
490                                         if( ps[ --i ].isValid() === false ) return false;\r
491                                 };\r
492                                 return true;\r
493                         }\r
494                 }\r
495         );\r
496         \r
497         /**\r
498          * margin, padding, borderWidth, borderColor\r
499          */\r
500         var FrexibleProperty = PropertyGroup.inherits(\r
501                 'FrexibleProperty',\r
502                 Class.POOL_OBJECT, {\r
503                         Constructor : function( name ){\r
504                                 this.name  = name;\r
505                                 this.props = [];\r
506                                 for( var i = 1, l = arguments.length; i<l; ++i ){\r
507                                         this.props.push( arguments[ i ] );\r
508                                 };\r
509                                 // top, bottom, left, right, topbottom, leftright, all                          \r
510                         }\r
511                 }\r
512         );\r
513 \r
514         var ColorProperty = Class.create(\r
515                 'ColorProperty',\r
516                 Class.POOL_OBJECT, {\r
517                         Constructor : function( name, r, g, b, pct ){\r
518                                 this.name = name;\r
519                                 this.r    = r;\r
520                                 this.g    = g;\r
521                                 this.b    = b;\r
522                                 this.pct  = pct;\r
523                         },\r
524                         name  : '',\r
525                         equal : function( prop ){\r
526                                 if( this.pct === prop.pct ){\r
527                                         return this.r === prop.r && this.g === prop.g && this.b === prop.b;\r
528                                 };\r
529                                 var rgb  = this._toPct(),\r
530                                         _rgb = prop._toPct(),\r
531                                         i    = rgb.length;\r
532                                 for( ; i; ){\r
533                                         --i;\r
534                                         if( Math.abs( rgb[ i ] - _rgb[ i ] ) > 1 ) return false;\r
535                                 };\r
536                                 return true;\r
537                         },\r
538                         convert : function( prop ){\r
539                                 var u = prop.pct, x;\r
540                                 if( this.pct === u ) return;\r
541                                 x = u === true ? 100 / 255 : 2.55;\r
542                                 this.r  *= x;\r
543                                 this.g  *= x;\r
544                                 this.b  *= x;\r
545                                 this.pct = u;\r
546                         },\r
547                         setValue : function( rgb ){\r
548                                 this.r = rgb[ 0 ];\r
549                                 this.g = rgb[ 1 ];\r
550                                 this.b = rgb[ 2 ];\r
551                         },\r
552                         getValue : function(){\r
553                                 return [ this.r, this.g, this.b ];\r
554                         },\r
555                         getOffset : function( prop ){\r
556                                 return [ prop.r - this.r, prop.g - this.g, prop.b - this.b ];\r
557                         },\r
558                         getUnit : function(){\r
559                                 return this.pct === true ? '%' : '';\r
560                         },\r
561                         getValueText : function(){\r
562                                 if( this.pct === true ){\r
563                                         return [ 'rgb(', this.r, '%,', this.g, '%,', this.b, '%)' ].join( '' );\r
564                                 };\r
565                                 var round = Math.round;\r
566                                 //return [ 'rgb(', round( this.r ), ',', round( this.g ), ',', round( this.b ), ')' ].join( '' );\r
567                                 \r
568                                 var rgb   = '00000' + ( ( round( this.r ) << 16 ) + ( round( this.g ) << 8 ) + round( this.b ) ).toString( 16 );\r
569                                 return '#' + rgb.substr( rgb.length - 6 );\r
570                         },\r
571                         _toPct : function(){\r
572                                 if( this.pct === true ) return [ this.r, this.g, this.b ];\r
573                                 return [ this.r / 2.55, this.g / 2.55, this.b / 2.55 ];\r
574                         },\r
575                         isValid : function( t ){\r
576                                 var isFinite = window.isFinite;\r
577                                 if( !isFinite( this.r ) || !isFinite( this.g ) || !isFinite( this.b ) ) return false;\r
578                                 if( 0 > this.r || 0 > this.g || 0 > this.b ) return false;\r
579                                 if( this.pct === true ) return this.r <= 100 && this.g <= 100 && this.b <= 100;\r
580                                 return this.r <= 255 && this.g <= 255 && this.b <= 255;\r
581                         }\r
582                 }\r
583         );\r
584         \r
585         var isString       = Type.isString,\r
586                 isNumber       = Type.isNumber;\r
587         var REG_UINIT      = /.*\d(\w{1,2})?/,\r
588                 $1             = '$1',\r
589                 px             = 'px',\r
590                 REG_XXXXXX     = /^#[\da-fA-F]{6}?/,\r
591                 REG_XXX        = /^#[\da-fA-F]{3}?/;\r
592         \r
593         var WrappedStyle = Class.create(\r
594                 'WrappedStyle',\r
595                 Class.POOL_OBJECT,\r
596                 {\r
597                         Constructor : function( style ){\r
598                                 this.style   = style;\r
599                                 var fontsize = this.get( 'fontSize' );\r
600                                 this.pxPerEm = fontsize.toPx();\r
601                                 fonstsize.kill();\r
602                         },\r
603                         get: function( p ){\r
604                                 if( PARAMS.special[ p ] === true || PARAMS.region[ p ] === true ){\r
605                                         if( p === 'clip' )        return this.getClip();\r
606                                         if( p === 'margin' )      return this.getMarginPaddingBorder( p, '' );\r
607                                         if( p === 'padding' )     return this.getMarginPaddingBorder( p, '' );\r
608                                         if( p === 'borderWidth' ) return this.getMarginPaddingBorder( 'border', 'Width' );\r
609                                         if( p === 'borderColor' ) return this.getBorderColor( 'borderColor' );\r
610                                         if( p === 'backgroundPosition' ) return this.getBackgroundPosition( p );\r
611                                         // opacity, zindex, lineHeight\r
612                                         return new Property( p, this.getValue( x ), this.getUnit( x ), this.pxPerEm );\r
613                                 };\r
614                                 var x = this.style[ p ], e, v, u;\r
615                                 if( PARAMS.offset[ p ] === true ){\r
616                                         return new Property( p, this.getValue( x ), this.getUnit( x, p ), this.pxPerEm );\r
617                                         /*\r
618                                         e = this.elm;\r
619                                         if( p === 'width'  ) v = e.offsetWidth;\r
620                                         if( p === 'height' ) v = e.offsetHeight;\r
621                                         if( p === 'top'    ) v = e.offsetTop;\r
622                                         if( p === 'bottom' ) v = e.offsetBottom;\r
623                                         if( p === 'left'   ) v = e.offsetLeft;\r
624                                         if( p === 'right'  ) v = e.offsetRight;\r
625                                         u = this.getUnit( x, p );\r
626                                         // alert( p + this.pxTo( v, u ) + u )\r
627                                         return new Property( p, this.pxTo( v, u ), u, this.pxPerEm ); */\r
628                                 };\r
629                                 if( p === 'fontSize' ){ // xx-small 等\r
630                                         v = Util.absoluteFontSizeToPx( x );\r
631                                         if( v !== 0 ){\r
632                                                 return new Property( p, v, px, this.pxPerEm );\r
633                                         };\r
634                                 };                      \r
635                                 if( PARAMS.percent[ p ] === true ){\r
636                                         // alert( p + ' , ' + x + ' , ' + this.getUnit( x, p ) )\r
637                                         return new Property( p, this.getValue( x ), this.getUnit( x, p ), this.pxPerEm );\r
638                                 };\r
639                                 if( PARAMS.size[ p ] === true ){\r
640                                         return new Property( p, this.getValue( x ), this.getUnit( x, p ), this.pxPerEm );\r
641                                 };\r
642                                 if( PARAMS.color[ p ] === true ){\r
643                                         return this.getColor( x, p );\r
644                                 };\r
645                         },\r
646                         pxTo: function( px, unit ){\r
647                                 if( unit === 'em' ) return px / this.pxPerEm;\r
648                                 return Util.pxTo( px, unit );\r
649                         },\r
650                         getValue: function( x ){\r
651                                 return isString( x ) === true ? parseInt( x ) :\r
652                                        isNumber( x ) === true ? x : 0;\r
653                         },\r
654                         getUnit: function( x, p ){\r
655                                 var u;\r
656                                 if( isString( x ) === true ){\r
657                                         u = x.replace( REG_UINIT, $1 );\r
658                                         if( p === 'lineHeight' ) return u;\r
659                                         if( PARAMS.unit[ u ] !== true ) return px;\r
660                                         return u;\r
661                                 };\r
662                                 return px;\r
663                         },\r
664                         getColor: function( x, p ){\r
665                                 var rgb = COLOR[ x.toUpperCase() ],\r
666                                         pct = false,\r
667                                         r   = 0,\r
668                                         g   = 0,\r
669                                         b   = 0;\r
670                                 if( isNumber( rgb ) === true ){\r
671                                         r = ( rgb & 0xff0000 ) >> 16;\r
672                                         g = ( rgb & 0xff00 ) >> 8;\r
673                                         b = ( rgb & 0xff );\r
674                                 } else\r
675                                 if( x.match( REG_XXXXXX ) ){\r
676                                         r = parseInt( x.charAt( 1 ) + x.charAt( 2 ), 16 );\r
677                                         g = parseInt( x.charAt( 3 ) + x.charAt( 4 ), 16 );\r
678                                         b = parseInt( x.charAt( 5 ) + x.charAt( 6 ), 16 );\r
679                                         //alert( x + ' g: ' + g )\r
680                                 } else                  \r
681                                 if( x.match( REG_XXX ) ){\r
682                                         r = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );\r
683                                         g = parseInt( x.charAt( 2 ) + x.charAt( 2 ), 16 );\r
684                                         b = parseInt( x.charAt( 3 ) + x.charAt( 3 ), 16 );\r
685                                 } else\r
686                                 if( x.indexOf( 'rgb(' ) === 0 ){\r
687                                         rgb = x.substr( 4 ).split( ',' );\r
688                                         r = parseFloat( rgb[ 0 ] );\r
689                                         g = parseFloat( rgb[ 1 ] );\r
690                                         b = parseFloat( rgb[ 2 ] );\r
691                                         if( x.indexOf( '%' ) !== -1 ) pct = true;\r
692                                 } else {\r
693                                         r = 255;\r
694                                         g = 255;\r
695                                         b = 255;\r
696                                 };\r
697                                 return new ColorProperty( p, r, g, b, pct );\r
698                         },\r
699                         getClip: function( name ){\r
700                                 // rect(...)    クリップします。<top>, <bottom> は上端からの、 <right>, <left> は左端からのオフセットで指定します。Internet Explorer 4~7 では、カンマの代わりにスペースで区切る必要があります。\r
701                                 // position:absolute または position:fixed を適用した要素に対してのみ有効です。\r
702                                 var top    = this.get( name + 'Top' ),\r
703                                         right  = this.get( name + 'Right' ),\r
704                                         bottom = this.get( name + 'Bottom' ),\r
705                                         left   = this.get( name + 'Left' ),\r
706                                         ret    = new PropertyGroup( name, top, right, bottom, left),\r
707                     all;\r
708                                 if( ret.isValid() === true ) return ret;\r
709                                 ret.kill();\r
710                                 all    = this.style[ name ].split( '(' )[ 1 ].split( ')' )[ 0 ].split( CLIP_SEPARATOR );\r
711                                 return new PropertyGroup( name,\r
712                                         new Property( name + 'Top',    all[ 0 ], px, this.pxPerEm ),\r
713                                         new Property( name + 'Right',  all[ 1 ], px, this.pxPerEm ),\r
714                                         new Property( name + 'Bottom', all[ 2 ], px, this.pxPerEm ),\r
715                                         new Property( name + 'Left',   all[ 3 ], px, this.pxPerEm )\r
716                                 );\r
717                         },\r
718                         getBackgroundPosition: function( name ){\r
719                                 var x   = this.get( name + 'X' ),\r
720                                         y   = this.get( name + 'Y' ),\r
721                                         ret = new PropertyGroup( name, x, y ),\r
722                                         xy;\r
723                                 if( ret.isValid() === true ) return ret;\r
724                                 ret.kill();\r
725                                 xy  = this.style[ name ].split( ' ' );\r
726                                 return new PropertyGroup( name,\r
727                                         new Property( name + 'X', this.getValue( xy[ 0 ] ), this.getUnit( xy[ 0 ] ), this.pxPerEm ),\r
728                                         new Property( name + 'Y', this.getValue( xy[ 1 ] ), this.getUnit( xy[ 1 ] ), this.pxPerEm )\r
729                                 );\r
730                         },\r
731                         getMarginPaddingBorder: function( name, width ){\r
732                                 var props  = [ name + 'Top'    + width,\r
733                                                    name + 'Right'  + width,\r
734                                                    name + 'Bottom' + width,\r
735                                                    name + 'Left'   + width ],\r
736                                         top    = this.get( props[ 0 ] ),\r
737                                         right  = this.get( props[ 1 ] ),\r
738                                         bottom = this.get( props[ 2 ] ),\r
739                                         left   = this.get( props[ 3 ] ),\r
740                                         ret    = new FrexibleProperty( name, top, right, bottom, left ),\r
741                                         klass, pxPerEm, getValue, getUnit,\r
742                                         all, _0, _1, _2, _3, v, u;\r
743                                 if( ret.isValid() === true ) return ret;\r
744                                 ret.kill();\r
745                                 klass    = Property;\r
746                                 pxPerEm  = this.pxPerEm;\r
747                                 getValue = this.getValue;\r
748                                 getUnit  = this.getUnit;\r
749                                 all = this.style[ name + width ].split( ' ' );\r
750                                 _0 = all[ 0 ];\r
751                                 _1 = all[ 1 ];\r
752                                 _2 = all[ 2 ];\r
753                                 _3 = all[ 3 ];\r
754                                 v  = getValue( _0 );\r
755                                 u  = getUnit( _0 );\r
756                                 switch( all.length ){\r
757                                         case 1 :\r
758                                                 top    = new klass( props[ 0 ], v, u, pxPerEm );\r
759                                                 right  = new klass( props[ 1 ], v, u, pxPerEm );\r
760                                                 bottom = new klass( props[ 2 ], v, u, pxPerEm );\r
761                                                 left   = new klass( props[ 3 ], v, u, pxPerEm );\r
762                                                 break;\r
763                                         case 2 :\r
764                                                 top    = new klass( props[ 0 ], v, u, pxPerEm );\r
765                                                 bottom = new klass( props[ 2 ], v, u, pxPerEm );\r
766                                                 v  = getValue( _1 );\r
767                                                 u  = getUnit( _1 );\r
768                                                 right  = new klass( props[ 1 ], v, u, pxPerEm );\r
769                                                 left   = new klass( props[ 3 ], v, u, pxPerEm );\r
770                                                 break;\r
771                                         case 3 :\r
772                                                 top    = new klass( props[ 0 ], v, u, pxPerEm );\r
773                                                 v  = getValue( _1 );\r
774                                                 u  = getUnit( _1 );\r
775                                                 right  = new klass( props[ 1 ], v, u, pxPerEm );\r
776                                                 left   = new klass( props[ 3 ], v, u, pxPerEm );\r
777                                                 bottom = new klass( props[ 2 ], getValue( _2 ), getUnit( _2 ), pxPerEm );\r
778                                                 break;\r
779                                         case 4 :\r
780                                                 top    = new klass( props[ 0 ], v, u, pxPerEm );\r
781                                                 right  = new klass( props[ 1 ], getValue( _1 ), getUnit( _1 ), pxPerEm );\r
782                                                 bottom = new klass( props[ 2 ], getValue( _2 ), getUnit( _2 ), pxPerEm );\r
783                                                 left   = new klass( props[ 3 ], getValue( _3 ), getUnit( _3 ), pxPerEm );\r
784                                                 break;\r
785                                 };\r
786                                 return new FrexibleProperty( name, top, right, bottom, left );\r
787                         },\r
788                         getBorderColor: function( name ){\r
789                                 var props    = 'borderTopColor,borderRightColor,borderBottomColor,borderLeftColor'.split( ',' ),\r
790                                         top      = this.get( props[ 0 ] ),\r
791                                         right    = this.get( props[ 1 ] ),\r
792                                         bottom   = this.get( props[ 2 ] ),\r
793                                         left     = this.get( props[ 3 ] ),\r
794                                         ret      = new FrexibleProperty( name, top, right, bottom, left ),\r
795                                         all, _0, _1, getColor;\r
796                                 if( ret.isValid() === true ) return ret;\r
797                                 ret.kill();\r
798                                 getColor = this.getColor;\r
799                                 all = this.style[ name ].split( ' ' );\r
800                                 _0  = all[ 0 ];\r
801                                 _1  = all[ 1 ];\r
802                                 switch( all.length ){\r
803                                         case 1 :\r
804                                                 top    = getColor( _0, props[ 0 ] );\r
805                                                 right  = getColor( _0, props[ 1 ] );\r
806                                                 bottom = getColor( _0, props[ 2 ] );\r
807                                                 left   = getColor( _0, props[ 3 ] );\r
808                                                 break;\r
809                                         case 2 :\r
810                                                 top    = getColor( _0, props[ 0 ] );\r
811                                                 right  = getColor( _1, props[ 1 ] );\r
812                                                 bottom = getColor( _0, props[ 2 ] );\r
813                                                 left   = getColor( _1, props[ 3 ] );\r
814                                                 break;\r
815                                         case 3 :\r
816                                                 top    = getColor( _0,       props[ 0 ] );\r
817                                                 right  = getColor( _1,       props[ 1 ] );\r
818                                                 bottom = getColor( all[ 2 ], props[ 2 ] );\r
819                                                 left   = getColor( _1,       props[ 3 ] );\r
820                                                 break;\r
821                                         case 4 :\r
822                                                 top    = getColor( _0,       props[ 0 ] );\r
823                                                 right  = getColor( _1,       props[ 1 ] );\r
824                                                 bottom = getColor( all[ 2 ], props[ 2 ] );\r
825                                                 left   = getColor( all[ 3 ], props[ 3 ] );\r
826                                                 break;\r
827                                 };\r
828                                 return new FrexibleProperty( name, top, right, bottom, left );\r
829                         }\r
830                 }\r
831         );\r
832         function camelizeHash( obj ){\r
833                 var p, _p, came = Util.camelize;\r
834                 for( p in obj ){\r
835                         _p = came( p );\r
836                         if( _p === p ) continue;\r
837                         obj[ _p ] = obj[ _p ] || obj[ p ];\r
838                         delete obj[ p ];\r
839                 };\r
840         };      \r
841         return {\r
842                 create: function( css ){\r
843                         return new WrappedStyle( camelizeHash( p ) );\r
844                 }\r
845         };\r
846 })();\r
847 \r
848 var XDocument = ( function( window, document ){\r
849         \r
850         var ROOT_LIST = [];\r
851         var AUTO      = Number.POSITIVE_INFINITY;\r
852         var FULL      = X.Css.Attr; // something unigue value;\r
853         var FLOOR     = Math.floor;\r
854         \r
855         var RootNode = Node.inherits(\r
856                 'RootNode',\r
857                 Class.POOL_OBJECT,\r
858                 LayoutBoxPrivate,\r
859                 {\r
860                         Constructor : function(){\r
861                                 RootNode.newPrivateData( this, BasicLayoutManager );\r
862                         }\r
863                 }\r
864         );\r
865         \r
866 })( window, document );