6a090b7d03efe95a76e0b0e6b160873c5c11270e
[roojs1] / examples / bootstrap4 / dynamic-components.js
1 /*
2  
3 The idea of this is to work out a new way for the builder to generate code
4 That is more component based..
5 -> basically the top level item would be 'extend' something... - like document body, etc..
6 and then it would render the children...
7
8 Changes that might need making?
9
10 ?? can we apply it back to the old Roo library?
11
12 ** builder--- needs updateing
13 ** need test for dialogs... - should be pretty similar to existing.
14 ** 
15  
16  
17  */
18 Roo.debug=1;
19 Roo.namespace('Dynamic');
20
21 Dynamic.Component = function(cfg)
22 {
23     var _this = this;
24     var STRINGS = Dynamic.Component._strings;
25     
26     var config = Roo.apply({
27         // the values specified in the builder for this element go here...
28             '|xns' : 'Roo.bootstrap',
29             cls : 'bg-black',
30             style : 'min-height: 100%;',
31             //xns : Roo.bootstrap,
32             //xtype : 'Body', << not needed...
33             items : [
34              {
35               '|xns' : 'Roo.bootstrap',
36               cls : 'form-box',
37               xns : Roo.bootstrap,
38               xtype : 'Container',
39               items : [
40                {
41                 '|xns' : 'Roo.bootstrap',
42                 cls : 'header',
43                 html : STRINGS['b6d4223e60986fa4c9af77ee5f7149c5'],
44                 xns : Roo.bootstrap,
45                 xtype : 'Container'
46                },
47                {
48                 
49                 // our 'sub component here..
50                 '|xns' : 'Dynamic.Component',
51                 xns : Dynamic.Component,
52                 xtype : 'Form',
53                    
54          
55                },
56                {
57                 '|xns' : 'Roo.bootstrap',
58                 cls : 'footer',
59                 xns : Roo.bootstrap,
60                 xtype : 'Container',
61                 items : [
62                  {
63                   '|xns' : 'Roo.bootstrap',
64                   cls : 'btn-block',
65                   html : STRINGS['3c0445c81a81e7508168c61674497f7d'],
66                   weight : 'primary',
67                   xns : Roo.bootstrap,
68                   xtype : 'Button'
69                  },
70                  {
71                   '|xns' : 'Roo.bootstrap',
72                   tag : 'p',
73                   xns : Roo.bootstrap,
74                   xtype : 'Container',
75                   items : [
76                    {
77                     '|xns' : 'Roo.bootstrap',
78                     href : '#',
79                     html : STRINGS['b05d72142020283dc6812fd3a9bc691c'],
80                     xns : Roo.bootstrap,
81                     xtype : 'Link'
82                    }
83                   ]
84          
85                  },
86                  {
87                   '|xns' : 'Roo.bootstrap',
88                   tag : 'p',
89                   xns : Roo.bootstrap,
90                   xtype : 'Container',
91                   items : [
92                    {
93                     '|xns' : 'Roo.bootstrap',
94                     cls : 'text-center',
95                     href : '#',
96                     html : STRINGS['11268c03b59cc646b0fb7c4cb592130b'],
97                     xns : Roo.bootstrap,
98                     xtype : 'Link'
99                    }
100                   ]
101          
102                  }
103                 ]
104          
105                }
106               ]
107          
108              }
109             ]
110     }, cfg);
111
112     Dynamic.Component.superclass.constructor.call(this, config);
113     
114     // we can add 'events that the extended element creates here..
115     this.addEvents({
116         //eg..
117        // "click" : true,
118        // "toggle" : true
119     });
120     
121     
122     
123 }
124
125 Roo.extend(Dynamic.Component, Roo.bootstrap.Body, {
126
127     // methods in here...
128
129     
130     
131     
132 });
133
134 Roo.apply(Dynamic.Component, {
135  _strings : {
136   '0c83f57c786a0b4a39efab23731c7ebc' :"email",
137   '3c0445c81a81e7508168c61674497f7d' :"Sign me in",
138   'b05d72142020283dc6812fd3a9bc691c' :"I forgot my password",
139   'b6d4223e60986fa4c9af77ee5f7149c5' :"Sign in",
140   '5f4dcc3b5aa765d61d8327deb882cf99' :"password",
141   '11268c03b59cc646b0fb7c4cb592130b' :"Register a new menbership"
142  }
143 });
144
145 /* ------------------------------------------------------------------------------ */
146
147
148 Dynamic.Component.Form = function(cfg)
149 {
150     var _this = this;
151     var STRINGS = Dynamic.Component.Form._strings;
152     
153     // in theory you can use 'cfg.XXX to fill in values...' == eg. cfg.XXX || '10'
154     
155     Roo.apply(this,cfg);
156     
157     cfg.items  = [
158          {
159           '|xns' : 'Roo.bootstrap',
160           cls : 'body bg-gray',
161           xns : Roo.bootstrap,
162           xtype : 'Container',
163           items : [
164            {
165             '|xns' : 'Roo.bootstrap',
166             placeholder : STRINGS['0c83f57c786a0b4a39efab23731c7ebc'],
167             xns : Roo.bootstrap,
168             xtype : 'Input'
169            },
170            {
171             '|xns' : 'Roo.bootstrap',
172             inputType : 'password',
173             placeholder : STRINGS['5f4dcc3b5aa765d61d8327deb882cf99'],
174             xns : Roo.bootstrap,
175             xtype : 'Input'
176            },
177            {
178             '|xns' : 'Roo.bootstrap',
179             boxLabel : 'Remember me',
180             cls : cfg.rememberCls,
181             xns : Roo.bootstrap,
182             xtype : 'CheckBox'
183            }
184           ]
185          }
186         ];
187     
188     
189     
190     
191     Dynamic.Component.Form.superclass.constructor.call(this, cfg);
192     
193     // we can add 'events that the extended element creates here..
194     this.addEvents({
195         //eg..
196        // "click" : true,
197        // "toggle" : true
198     });
199
200 }
201
202 Roo.extend(Dynamic.Component.Form, Roo.bootstrap.Form, {
203
204     // methods in here...
205     
206     // default values here...
207     rememberCls : 'xxxx', // these could be configurable items.. (the UI can pick them up as optional values.)
208     
209     
210     
211 });
212
213 Roo.apply(Dynamic.Component.Form, {
214  _strings : {
215   '0c83f57c786a0b4a39efab23731c7ebc' :"emailx",
216   '5f4dcc3b5aa765d61d8327deb882cf99' :"password",
217  }
218 });