OSDN Git Service

Fix the bug of X.NodeAnime.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 14_ChromeBox.js
1 var XUI_ChromeBox = XUI_Box.inherits(\r
2         '_ChromeBox',\r
3         X_Class.NONE,\r
4         {\r
5                 chromeNodes   : null,\r
6                 containerNode : null,\r
7                 \r
8                 Constructor : function( user, layout, args ){\r
9                         var uinodes, i, l, node, after, index = 0;\r
10                         \r
11                         this[ 'Super' ]( user, layout, args );\r
12 \r
13                         uinodes = this.uinodes;\r
14                         l = i   = uinodes.length;\r
15 \r
16                         for( ; i; ){\r
17                                 node = uinodes[ --i ];\r
18                                 if( node.role === 3 ){\r
19                                         if( this.containerNode ){\r
20                                                 //throw new Error( 'ContainerNode が複数設定されています!ContainerNode はクロームボックスにひとつ、生成時に設定できます ' + node );\r
21                                         };\r
22                                         this.containerNode  = node.User;\r
23                                         this._containerNode = node;\r
24                                 } else {\r
25                                         if( !this.chromeNodes ) this.chromeNodes = [];\r
26                                         this.chromeNodes[ this.chromeNodes.length ] = node;\r
27                                 };\r
28                         };\r
29                         if( !this.containerNode ){\r
30                                 //throw new Error( 'ContainerNode が設定されてい\ません!ContainerNode はクロームボックスにひとつ、生成時に設定できます ' );\r
31                         };\r
32                         \r
33                         for( i = 0, l = args.length; i < l; ++i ){\r
34                                 node = args[ i ];\r
35                                 if( node === this.containerNode ){\r
36                                         after = true;\r
37                                         index = 0;\r
38                                 };\r
39                                 if( node[ 'instanceOf' ] && node[ 'instanceOf' ]( Node ) ){\r
40                                         \r
41                                 };\r
42                         };\r
43                 }\r
44         }\r
45 );\r
46 \r
47 X.UI.ChromeBox = X.UI.Box.inherits(\r
48         'ChromeBox',\r
49         X_Class.NONE,\r
50         {\r
51                 Constructor : function(){\r
52                         X_Pair_create( this, XUI_ChromeBox( this, XUI_Layout_Canvas, arguments ) );\r
53                 },\r
54                 add : function( /* node, node, node ... */ ){\r
55                         X_Pair_get( this ).containerNode.addAt( this.numNodes(), X_Array_copy( arguments ) );\r
56                         return this;\r
57                 },\r
58                 addAt : function( index /* , node, node, node ... */ ){\r
59                         var nodes;\r
60                         if( index < 0 ) index = 0;\r
61                         nodes = X_Array_copy( arguments );\r
62                         X_Pair_get( this ).containerNode.addAt( nodes.shift(), nodes );\r
63                         return this;\r
64                 },\r
65                 remove : function( node /* , node, node ... */ ){\r
66                         X_Pair_get( this ).containerNode.remove( arguments );\r
67                         return this;\r
68                 },\r
69                 removeAt : function( from, length ){\r
70                         X_Pair_get( this ).containerNode.removeAt( from, length );\r
71                         return this;\r
72                 },\r
73                 getNodesByClass : function( klass ){\r
74                         return X_Pair_get( this ).containerNode.User.getNodesByClass( klass );\r
75                 },\r
76                 getFirstChild : function(){\r
77                         return X_Pair_get( this ).containerNode.User.getFirstChild();\r
78                 },\r
79                 getLastChild : function(){\r
80                         return X_Pair_get( this ).containerNode.User.getLastChild();\r
81                 },\r
82                 getNodeAt : function( index ){\r
83                         return X_Pair_get( this ).containerNode.User.getNodeAt( index );\r
84                 },\r
85                 numNodes : function(){\r
86                         return X_Pair_get( this ).containerNode.User.numNodes();\r
87                 }\r
88         }\r
89 );