1 //<script type="text/javascript">
3 _this = { } ; // a fake self for rendering.
7 render : function(data)
13 Builder.click= Roo.get(document.body).on('click', this.onclick, this);
22 renderObj : { isBuilder : true },
25 redrawClear : function(isAuto)
27 this.renderObj = { isBuilder : true };
36 //if (this.panelroot) {
37 // this.scroll = this.panelroot.el.getScroll();
38 // this.layout.remove('center', this.panelroot);
39 // this.panelroot = false;
41 if (this.dialogroot) {
42 this.dialogroot.remove();
43 this.dialogroot = false;
45 if (this.layoutbase) {
46 //console.log(Builder.dump(this.layoutbase.el));
50 var pan = this.layoutbase.getRegion('center').getPanel(0);
52 this.layoutbase.remove('center', pan);
58 console.log(JSON.stringify(e));
64 //this.layoutbase= false;
71 redraw: function(isAuto)
74 // top level is not relivant
75 this.redrawClear(isAuto);
79 //console.log(this.dump(cfg));
86 //console.log(this.dump(cfg));
87 // we draw either a dialog or a tab..
89 if (cfg.xtype == 'LayoutDialog') {
92 //var xy = Pman.Tab.BuilderPanel.panel.el.getXY();
93 //cfg.items[0].x = xy[0];
94 //cfg.items[0].y = xy[1];
95 //cfg.items[0].constraintoviewport = false;
97 this.dialogroot = Roo.get( document.body).createChild({
101 this.dialog = new Roo[cfg.xtype](this.dialogroot, cfg);
102 //this.dialog.el.on('click', this.panelClick, this);
108 // otherwise we are creating a layout area on the document..
112 // contentpanel, nestedlayoutpanel, contentpanel.. etc.
113 // force center region..
114 cfg.region = 'center';
115 cfg.background = false;
116 if (!this.layoutbase) {
118 this.layoutbase = new Ext.BorderLayout(document.body, {
126 alwaysShowTabs: true,
132 console.log("ADDING CFG");
133 this.layoutbase.addxtype( cfg );
135 console.log("GOT ERROR?");
137 console.log(typeof(e));
139 console.log(this.dump(e));
146 munge :function (cfg)
149 //cfg.cls = cfg.cls || '';
150 //cfg.cls += ' ' + cfg.id;
154 //console.log(cfg.xtype + ': ' + cfg.id);
160 if (typeof(cfg.background) != 'undefined') {
161 cfg.background = false;
164 var xtype = (cfg['|xns'] || '') + '.' + (cfg.xtype || '');
167 // key is not string?!?!?!!?
168 if (typeof(p) != 'string') {
172 if (typeof(cfg[p]) == 'object') { // listeners!!!
177 if (p.charAt(0) == '|') {
179 if (!cfg[p].length) {
186 var _this = this.renderObj; /// fake '_this' object..
187 /** eval:var:_this **/
188 /** eval:var:_tmp **/
189 // stupid IE can not return objects evaluated..
190 eval('_tmp =(' + cfg[p] + ')');
191 cfg[p.substr(1)] = _tmp;
192 //if (typeof(_tmp) == 'undefined') {
197 console.log('Error evaluating: ' + cfg[p] + "\r\n" + JSON.stringify(e));
205 if ((p.charAt(0) == '*') || (p.charAt(0) == '+')) {
213 if (cfg.xtype && cfg.xtype.match(/^Roo\./) && !cfg.xns) {
214 // xtype contains full path..
215 var bits = cfg.xtype.split('.');
216 bits.shift(); // remove roo..
217 cfg.xtype = bits.pop(); // get the last bit..
219 while (bits.length) {
220 cfg.xns = cfg.xns[bits.shift()];
225 if (!cfg.xns || typeof(cfg.xns[cfg.xtype]) == 'undefined') {
226 throw "Invalid Xtype " + cfg.xtype + ' on ' + cfg.xtreepath;
230 // we can overlay some event handlers here..
231 cfg.listeners = cfg.listeners || {};
233 //console.log('xtype' + xtype)
235 case 'Roo.LayoutDialog':
236 cfg.listeners.resize = function(dlg, w,h)
238 console.log('{ "id" : "' + dlg.id + '", "set" : "width", "value": ' + w + '}');
239 console.log('{ "id" : "' + dlg.id + '", "set" : "height", "value": ' + h + '}');
248 // now for all the children.. (items)
249 if (xitems === false) {
253 for (var i = 0; i < xitems.length; i++) {
254 // if +builderhide set !!!! drop it!!
258 if (typeof(xi['*prop']) != 'undefined') {
259 console.log('adding prop:' + xi['*prop']);
261 var pr = xi['*prop'];
263 // if prop is an array - then it's items are really the value..
264 if (pr.match(/\[\]$/)) {
265 console.log('adding array?:' + pr);
266 pr = pr.replace(/\[\]$/, '');
267 cfg[pr] = cfg[pr] || [];
273 if (xi.xtype && xi.xtype == 'Array') {
276 console.log('setting property:' + pr);
287 if (cfg.items.length == 0) {
297 cloneConfig : function(config) {
298 if (!config) { return null; }
300 for (var i in config) {
301 if (typeof config[i] == 'object') {
302 newConfig[i] = this.cloneConfig(config[i]);
303 } else if (typeof config[i] != 'function') {
304 newConfig[i] = config[i];
309 dump : function (arr,level) {
310 var dumped_text = "";
311 if(!level) level = 0;
313 return '... TO DEEP ...';
315 //The padding given at the beginning of the line.
316 var level_padding = "";
317 for(var j=0;j<level+1;j++) level_padding += " ";
319 if(typeof(arr) == 'object') { //Array/Hashes/Objects
320 for(var item in arr) {
322 var value = arr[item];
326 if(typeof(value) == 'function') { //If it is an array,
328 dumped_text += level_padding + "'" + item + "' : function() { ... },\n";
331 if(typeof(value) == 'object') { //If it is an array,
332 dumped_text += level_padding + "'" + item + "': {\n";
333 dumped_text += this.dump(value,level+1);
334 dumped_text += level_padding + "}\n";
337 dumped_text += level_padding + "'" + item + "' : \"" + value + "\"\n";
340 } else { //Stings/Chars/Numbers etc.
341 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
345 findNode : function(ftg , method) {
349 // console.log(ftg.id);
350 if (ftg.id && typeof(ftg.id) == 'string' && ftg.id.match(/builder-/)) {
351 var nid = ftg.id.replace('builder-', '').replace('x-form-el-', '');
356 if (ftg.dom.className.match(/[0-9]+/)) {
357 console.log(ftg.dom.className);
358 var cmat = ftg.dom.className.match(/x-grid-hd-builder-(form-gen-[0-9:]+)/);
360 this[method]( cmat[1] );
371 overPos: function(x,y)
374 var el = document.elementFromPoint(x,y);
375 // //console.log(el.id);
376 // console.log(document.body.innerHTML);
378 getTarget : function () {
381 stopEvent : function() {
388 onclick: function(e) {
389 var tg = Roo.get(e.getTarget());
391 //console.log('no target');
395 if (this.findNode(tg,'logClick')) {
398 var dp = Roo.get(tg.up(''));
399 if (dp && this.findNode(dp,'logClick')) {
403 var ns = Roo.get(tg.getNextSibling());
404 if (ns && this.findNode(ns,'logClick')) {
408 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logClick') ) {
412 for(var i =0; i < 5; i++) {
413 tg = Roo.get(tg.up(''));
415 //console.log('no parent' + i);
418 if (tg && this.findNode(tg,'logClick')) {
422 //console.log('no target in parents');
425 logClick : function(id)
427 var bid = id.length ? 'builder-' + id : '';
428 console.log('{ "id" : "' + bid + '"}');
432 hover : function(e) {
435 var tg = Roo.get(e.getTarget());
437 //console.log('no target');
442 if (this.findNode(tg,'logMove')) {
446 var dp = Roo.get(tg.up(''));
447 if (dp && this.findNode(dp,'logMove')) {
452 var ns = Roo.get(tg.getNextSibling());
453 if (ns && this.findNode(ns,'logMove')) {
457 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logMove' )) {
462 for(var i =0; i < 5; i++) {
463 tg = Roo.get(tg.up(''));
465 //console.log('no parent' + i);
469 if (tg && this.findNode(tg,'logMove')) {
474 //console.log('no target in parents');
477 logMove : function (id) {
478 //console.log("LOGMOVE: " + id);
480 if (this.lastID === id) {
484 var bid = id.length ? 'builder-' + id : '';
485 console.log('{ "hover-node" : "' + bid + '"}');