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));
47 this.layoutbase.remove('center', this.layoutbase.getRegion('center'));
51 this.layoutbase= false;
58 redraw: function(isAuto)
61 // top level is not relivant
62 this.redrawClear(isAuto);
66 //console.log(this.dump(cfg));
73 //console.log(cfg);return;
74 // we draw either a dialog or a tab..
76 if (cfg.xtype == 'LayoutDialog') {
79 //var xy = Pman.Tab.BuilderPanel.panel.el.getXY();
80 //cfg.items[0].x = xy[0];
81 //cfg.items[0].y = xy[1];
82 //cfg.items[0].constraintoviewport = false;
84 this.dialogroot = Roo.get( document.body).createChild({
88 this.dialog = new Roo[cfg.xtype](this.dialogroot, cfg);
89 //this.dialog.el.on('click', this.panelClick, this);
95 // otherwise we are creating a layout area on the document..
99 // contentpanel, nestedlayoutpanel, contentpanel.. etc.
100 // force center region..
101 cfg.region = 'center';
102 cfg.background = false;
103 if (!this.layoutbase) {
105 this.layoutbase = new Ext.BorderLayout(document.body, {
113 alwaysShowTabs: true,
118 this.layoutbase.addxtype( cfg );
125 munge :function (cfg)
128 //cfg.cls = cfg.cls || '';
129 //cfg.cls += ' ' + cfg.id;
133 //console.log(cfg.xtype + ': ' + cfg.id);
139 if (typeof(cfg.background) != 'undefined') {
140 cfg.background = false;
143 var xtype = (cfg['|xns'] || '') + '.' + (cfg.xtype || '');
146 // key is not string?!?!?!!?
147 if (typeof(p) != 'string') {
151 if (typeof(cfg[p]) == 'object') { // listeners!!!
156 if (p.charAt(0) == '|') {
158 if (!cfg[p].length) {
165 var _this = this.renderObj; /// fake '_this' object..
166 /** eval:var:_this **/
167 /** eval:var:_tmp **/
168 // stupid IE can not return objects evaluated..
169 eval('_tmp =(' + cfg[p] + ')');
170 cfg[p.substr(1)] = _tmp;
171 //if (typeof(_tmp) == 'undefined') {
175 } catch(e) { console.log('Error evaluating: ' + cfg[p]); };
182 if ((p.charAt(0) == '*') || (p.charAt(0) == '+')) {
190 // we can overlay some event handlers here..
191 cfg.listeners = cfg.listeners || {};
193 //console.log('xtype' + xtype)
195 case 'Roo.LayoutDialog':
196 cfg.listeners.resize = function(dlg, w,h)
198 console.log('{ "id" : "' + dlg.id + '", "set" : "width", "value": ' + w + '}');
199 console.log('{ "id" : "' + dlg.id + '", "set" : "height", "value": ' + h + '}');
208 // now for all the children.. (items)
209 if (xitems === false) {
213 for (var i = 0; i < xitems.length; i++) {
214 // if +builderhide set !!!! drop it!!
218 if (typeof(xi['*prop']) != 'undefined') {
219 console.log('adding prop:' + xi['*prop']);
221 var pr = xi['*prop'];
223 // if prop is an array - then it's items are really the value..
224 if (pr.match(/\[\]$/)) {
225 console.log('adding array?:' + pr);
226 pr = pr.replace(/\[\]$/, '');
227 cfg[pr] = cfg[pr] || [];
233 if (xi.xtype && xi.xtype == 'Array') {
236 console.log('setting property:' + pr);
247 if (cfg.items.length == 0) {
257 cloneConfig : function(config) {
258 if (!config) { return null; }
260 for (var i in config) {
261 if (typeof config[i] == 'object') {
262 newConfig[i] = this.cloneConfig(config[i]);
263 } else if (typeof config[i] != 'function') {
264 newConfig[i] = config[i];
269 dump : function (arr,level) {
270 var dumped_text = "";
271 if(!level) level = 0;
273 return '... TO DEEP ...';
275 //The padding given at the beginning of the line.
276 var level_padding = "";
277 for(var j=0;j<level+1;j++) level_padding += " ";
279 if(typeof(arr) == 'object') { //Array/Hashes/Objects
280 for(var item in arr) {
282 var value = arr[item];
286 if(typeof(value) == 'function') { //If it is an array,
288 dumped_text += level_padding + "'" + item + "' : function() { ... },\n";
291 if(typeof(value) == 'object') { //If it is an array,
292 dumped_text += level_padding + "'" + item + "': {\n";
293 dumped_text += this.dump(value,level+1);
294 dumped_text += level_padding + "}\n";
297 dumped_text += level_padding + "'" + item + "' : \"" + value + "\"\n";
300 } else { //Stings/Chars/Numbers etc.
301 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
305 findNode : function(ftg , method) {
309 // console.log(ftg.id);
310 if (ftg.id && typeof(ftg.id) == 'string' && ftg.id.match(/builder-/)) {
311 var nid = ftg.id.replace('builder-', '').replace('x-form-el-', '');
316 if (ftg.dom.className.match(/[0-9]+/)) {
317 console.log(ftg.dom.className);
318 var cmat = ftg.dom.className.match(/x-grid-hd-builder-(form-gen-[0-9:]+)/);
320 this[method]( cmat[1] );
331 overPos: function(x,y)
334 var el = document.elementFromPoint(x,y);
335 // //console.log(el.id);
336 // console.log(document.body.innerHTML);
338 getTarget : function () {
341 stopEvent : function() {
348 onclick: function(e) {
349 var tg = Roo.get(e.getTarget());
351 //console.log('no target');
355 if (this.findNode(tg,'logClick')) {
358 var dp = Roo.get(tg.up(''));
359 if (dp && this.findNode(dp,'logClick')) {
363 var ns = Roo.get(tg.getNextSibling());
364 if (ns && this.findNode(ns,'logClick')) {
368 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logClick') ) {
372 for(var i =0; i < 5; i++) {
373 tg = Roo.get(tg.up(''));
375 //console.log('no parent' + i);
378 if (tg && this.findNode(tg,'logClick')) {
382 //console.log('no target in parents');
385 logClick : function(id)
387 var bid = id.length ? 'builder-' + id : '';
388 console.log('{ "id" : "' + bid + '"}');
392 hover : function(e) {
395 var tg = Roo.get(e.getTarget());
397 //console.log('no target');
402 if (this.findNode(tg,'logMove')) {
406 var dp = Roo.get(tg.up(''));
407 if (dp && this.findNode(dp,'logMove')) {
412 var ns = Roo.get(tg.getNextSibling());
413 if (ns && this.findNode(ns,'logMove')) {
417 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logMove' )) {
422 for(var i =0; i < 5; i++) {
423 tg = Roo.get(tg.up(''));
425 //console.log('no parent' + i);
429 if (tg && this.findNode(tg,'logMove')) {
434 //console.log('no target in parents');
437 logMove : function (id) {
438 //console.log("LOGMOVE: " + id);
440 if (this.lastID === id) {
444 var bid = id.length ? 'builder-' + id : '';
445 console.log('{ "hover-node" : "' + bid + '"}');