1 //<script type="text/javascript">
6 render : function(data)
12 Builder.click= Roo.get(document.body).on('click', this.onclick, this);
21 renderObj : { isBuilder : true },
24 redrawClear : function(isAuto)
26 this.renderObj = { isBuilder : true };
35 //if (this.panelroot) {
36 // this.scroll = this.panelroot.el.getScroll();
37 // this.layout.remove('center', this.panelroot);
38 // this.panelroot = false;
40 if (this.dialogroot) {
41 this.dialogroot.remove();
42 this.dialogroot = false;
44 if (this.layoutbase) {
45 //console.log(Builder.dump(this.layoutbase.el));
49 var pan = this.layoutbase.getRegion('center').getPanel(0);
51 this.layoutbase.remove('center', pan);
57 console.log(JSON.stringify(e));
63 //this.layoutbase= false;
70 redraw: function(isAuto)
73 // top level is not relivant
74 this.redrawClear(isAuto);
78 //console.log(this.dump(cfg));
85 //console.log(this.dump(cfg));
86 // we draw either a dialog or a tab..
88 if (cfg.xtype == 'LayoutDialog') {
91 //var xy = Pman.Tab.BuilderPanel.panel.el.getXY();
92 //cfg.items[0].x = xy[0];
93 //cfg.items[0].y = xy[1];
94 //cfg.items[0].constraintoviewport = false;
96 this.dialogroot = Roo.get( document.body).createChild({
100 this.dialog = new Roo[cfg.xtype](this.dialogroot, cfg);
101 //this.dialog.el.on('click', this.panelClick, this);
107 // otherwise we are creating a layout area on the document..
111 // contentpanel, nestedlayoutpanel, contentpanel.. etc.
112 // force center region..
113 cfg.region = 'center';
114 cfg.background = false;
115 if (!this.layoutbase) {
117 this.layoutbase = new Ext.BorderLayout(document.body, {
125 alwaysShowTabs: true,
131 console.log("ADDING CFG");
132 this.layoutbase.addxtype( cfg );
134 console.log("GOT ERROR?");
136 console.log(typeof(e));
138 console.log(this.dump(e));
145 munge :function (cfg)
148 //cfg.cls = cfg.cls || '';
149 //cfg.cls += ' ' + cfg.id;
153 //console.log(cfg.xtype + ': ' + cfg.id);
159 if (typeof(cfg.background) != 'undefined') {
160 cfg.background = false;
163 var xtype = (cfg['|xns'] || '') + '.' + (cfg.xtype || '');
166 // key is not string?!?!?!!?
167 if (typeof(p) != 'string') {
171 if (typeof(cfg[p]) == 'object') { // listeners!!!
176 if (p.charAt(0) == '|') {
178 if (!cfg[p].length) {
185 var _this = this.renderObj; /// fake '_this' object..
186 /** eval:var:_this **/
187 /** eval:var:_tmp **/
188 // stupid IE can not return objects evaluated..
189 eval('_tmp =(' + cfg[p] + ')');
190 cfg[p.substr(1)] = _tmp;
191 //if (typeof(_tmp) == 'undefined') {
196 console.log('Error evaluating: ' + cfg[p] + "\r\n" + JSON.stringify(e));
204 if ((p.charAt(0) == '*') || (p.charAt(0) == '+')) {
212 if (cfg.xtype && cfg.xtype.match(/^Roo\./) && !cfg.xns) {
213 // xtype contains full path..
214 var bits = cfg.xtype.split('.');
215 bits.shift(); // remove roo..
216 cfg.xtype = bits.pop(); // get the last bit..
218 while (bits.length) {
219 cfg.xns = cfg.xns[bits.shift()];
224 if (!cfg.xns || typeof(cfg.xns[cfg.xtype]) == 'undefined') {
225 throw "Invalid Xtype " + cfg.xtype + ' on ' + cfg.xtreepath;
229 // we can overlay some event handlers here..
230 cfg.listeners = cfg.listeners || {};
232 //console.log('xtype' + xtype)
234 case 'Roo.LayoutDialog':
235 cfg.listeners.resize = function(dlg, w,h)
237 console.log('{ "id" : "' + dlg.id + '", "set" : "width", "value": ' + w + '}');
238 console.log('{ "id" : "' + dlg.id + '", "set" : "height", "value": ' + h + '}');
247 // now for all the children.. (items)
248 if (xitems === false) {
252 for (var i = 0; i < xitems.length; i++) {
253 // if +builderhide set !!!! drop it!!
257 if (typeof(xi['*prop']) != 'undefined') {
258 console.log('adding prop:' + xi['*prop']);
260 var pr = xi['*prop'];
262 // if prop is an array - then it's items are really the value..
263 if (pr.match(/\[\]$/)) {
264 console.log('adding array?:' + pr);
265 pr = pr.replace(/\[\]$/, '');
266 cfg[pr] = cfg[pr] || [];
272 if (xi.xtype && xi.xtype == 'Array') {
275 console.log('setting property:' + pr);
286 if (cfg.items.length == 0) {
296 cloneConfig : function(config) {
297 if (!config) { return null; }
299 for (var i in config) {
300 if (typeof config[i] == 'object') {
301 newConfig[i] = this.cloneConfig(config[i]);
302 } else if (typeof config[i] != 'function') {
303 newConfig[i] = config[i];
308 dump : function (arr,level) {
309 var dumped_text = "";
310 if(!level) level = 0;
312 return '... TO DEEP ...';
314 //The padding given at the beginning of the line.
315 var level_padding = "";
316 for(var j=0;j<level+1;j++) level_padding += " ";
318 if(typeof(arr) == 'object') { //Array/Hashes/Objects
319 for(var item in arr) {
321 var value = arr[item];
325 if(typeof(value) == 'function') { //If it is an array,
327 dumped_text += level_padding + "'" + item + "' : function() { ... },\n";
330 if(typeof(value) == 'object') { //If it is an array,
331 dumped_text += level_padding + "'" + item + "': {\n";
332 dumped_text += this.dump(value,level+1);
333 dumped_text += level_padding + "}\n";
336 dumped_text += level_padding + "'" + item + "' : \"" + value + "\"\n";
339 } else { //Stings/Chars/Numbers etc.
340 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
344 findNode : function(ftg , method) {
348 // console.log(ftg.id);
349 if (ftg.id && typeof(ftg.id) == 'string' && ftg.id.match(/builder-/)) {
350 var nid = ftg.id.replace('builder-', '').replace('x-form-el-', '');
355 if (ftg.dom.className.match(/[0-9]+/)) {
356 console.log(ftg.dom.className);
357 var cmat = ftg.dom.className.match(/x-grid-hd-builder-(form-gen-[0-9:]+)/);
359 this[method]( cmat[1] );
370 overPos: function(x,y)
373 var el = document.elementFromPoint(x,y);
374 // //console.log(el.id);
375 // console.log(document.body.innerHTML);
377 getTarget : function () {
380 stopEvent : function() {
387 onclick: function(e) {
388 var tg = Roo.get(e.getTarget());
390 //console.log('no target');
394 if (this.findNode(tg,'logClick')) {
397 var dp = Roo.get(tg.up(''));
398 if (dp && this.findNode(dp,'logClick')) {
402 var ns = Roo.get(tg.getNextSibling());
403 if (ns && this.findNode(ns,'logClick')) {
407 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logClick') ) {
411 for(var i =0; i < 5; i++) {
412 tg = Roo.get(tg.up(''));
414 //console.log('no parent' + i);
417 if (tg && this.findNode(tg,'logClick')) {
421 //console.log('no target in parents');
424 logClick : function(id)
426 var bid = id.length ? 'builder-' + id : '';
427 console.log('{ "id" : "' + bid + '"}');
431 hover : function(e) {
434 var tg = Roo.get(e.getTarget());
436 //console.log('no target');
441 if (this.findNode(tg,'logMove')) {
445 var dp = Roo.get(tg.up(''));
446 if (dp && this.findNode(dp,'logMove')) {
451 var ns = Roo.get(tg.getNextSibling());
452 if (ns && this.findNode(ns,'logMove')) {
456 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logMove' )) {
461 for(var i =0; i < 5; i++) {
462 tg = Roo.get(tg.up(''));
464 //console.log('no parent' + i);
468 if (tg && this.findNode(tg,'logMove')) {
473 //console.log('no target in parents');
476 logMove : function (id) {
477 //console.log("LOGMOVE: " + id);
479 if (this.lastID === id) {
483 var bid = id.length ? 'builder-' + id : '';
484 console.log('{ "hover-node" : "' + bid + '"}');