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');
51 this.layoutbase.regions['center'].remove(pan);
62 //this.layoutbase= false;
69 redraw: function(isAuto)
72 // top level is not relivant
73 this.redrawClear(isAuto);
77 //console.log(this.dump(cfg));
84 //console.log(cfg);return;
85 // we draw either a dialog or a tab..
87 if (cfg.xtype == 'LayoutDialog') {
90 //var xy = Pman.Tab.BuilderPanel.panel.el.getXY();
91 //cfg.items[0].x = xy[0];
92 //cfg.items[0].y = xy[1];
93 //cfg.items[0].constraintoviewport = false;
95 this.dialogroot = Roo.get( document.body).createChild({
99 this.dialog = new Roo[cfg.xtype](this.dialogroot, cfg);
100 //this.dialog.el.on('click', this.panelClick, this);
106 // otherwise we are creating a layout area on the document..
110 // contentpanel, nestedlayoutpanel, contentpanel.. etc.
111 // force center region..
112 cfg.region = 'center';
113 cfg.background = false;
114 if (!this.layoutbase) {
116 this.layoutbase = new Ext.BorderLayout(document.body, {
124 alwaysShowTabs: true,
129 this.layoutbase.addxtype( cfg );
136 munge :function (cfg)
139 //cfg.cls = cfg.cls || '';
140 //cfg.cls += ' ' + cfg.id;
144 //console.log(cfg.xtype + ': ' + cfg.id);
150 if (typeof(cfg.background) != 'undefined') {
151 cfg.background = false;
154 var xtype = (cfg['|xns'] || '') + '.' + (cfg.xtype || '');
157 // key is not string?!?!?!!?
158 if (typeof(p) != 'string') {
162 if (typeof(cfg[p]) == 'object') { // listeners!!!
167 if (p.charAt(0) == '|') {
169 if (!cfg[p].length) {
176 var _this = this.renderObj; /// fake '_this' object..
177 /** eval:var:_this **/
178 /** eval:var:_tmp **/
179 // stupid IE can not return objects evaluated..
180 eval('_tmp =(' + cfg[p] + ')');
181 cfg[p.substr(1)] = _tmp;
182 //if (typeof(_tmp) == 'undefined') {
186 } catch(e) { console.log('Error evaluating: ' + cfg[p]); };
193 if ((p.charAt(0) == '*') || (p.charAt(0) == '+')) {
201 // we can overlay some event handlers here..
202 cfg.listeners = cfg.listeners || {};
204 //console.log('xtype' + xtype)
206 case 'Roo.LayoutDialog':
207 cfg.listeners.resize = function(dlg, w,h)
209 console.log('{ "id" : "' + dlg.id + '", "set" : "width", "value": ' + w + '}');
210 console.log('{ "id" : "' + dlg.id + '", "set" : "height", "value": ' + h + '}');
219 // now for all the children.. (items)
220 if (xitems === false) {
224 for (var i = 0; i < xitems.length; i++) {
225 // if +builderhide set !!!! drop it!!
229 if (typeof(xi['*prop']) != 'undefined') {
230 console.log('adding prop:' + xi['*prop']);
232 var pr = xi['*prop'];
234 // if prop is an array - then it's items are really the value..
235 if (pr.match(/\[\]$/)) {
236 console.log('adding array?:' + pr);
237 pr = pr.replace(/\[\]$/, '');
238 cfg[pr] = cfg[pr] || [];
244 if (xi.xtype && xi.xtype == 'Array') {
247 console.log('setting property:' + pr);
258 if (cfg.items.length == 0) {
268 cloneConfig : function(config) {
269 if (!config) { return null; }
271 for (var i in config) {
272 if (typeof config[i] == 'object') {
273 newConfig[i] = this.cloneConfig(config[i]);
274 } else if (typeof config[i] != 'function') {
275 newConfig[i] = config[i];
280 dump : function (arr,level) {
281 var dumped_text = "";
282 if(!level) level = 0;
284 return '... TO DEEP ...';
286 //The padding given at the beginning of the line.
287 var level_padding = "";
288 for(var j=0;j<level+1;j++) level_padding += " ";
290 if(typeof(arr) == 'object') { //Array/Hashes/Objects
291 for(var item in arr) {
293 var value = arr[item];
297 if(typeof(value) == 'function') { //If it is an array,
299 dumped_text += level_padding + "'" + item + "' : function() { ... },\n";
302 if(typeof(value) == 'object') { //If it is an array,
303 dumped_text += level_padding + "'" + item + "': {\n";
304 dumped_text += this.dump(value,level+1);
305 dumped_text += level_padding + "}\n";
308 dumped_text += level_padding + "'" + item + "' : \"" + value + "\"\n";
311 } else { //Stings/Chars/Numbers etc.
312 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
316 findNode : function(ftg , method) {
320 // console.log(ftg.id);
321 if (ftg.id && typeof(ftg.id) == 'string' && ftg.id.match(/builder-/)) {
322 var nid = ftg.id.replace('builder-', '').replace('x-form-el-', '');
327 if (ftg.dom.className.match(/[0-9]+/)) {
328 console.log(ftg.dom.className);
329 var cmat = ftg.dom.className.match(/x-grid-hd-builder-(form-gen-[0-9:]+)/);
331 this[method]( cmat[1] );
342 overPos: function(x,y)
345 var el = document.elementFromPoint(x,y);
346 // //console.log(el.id);
347 // console.log(document.body.innerHTML);
349 getTarget : function () {
352 stopEvent : function() {
359 onclick: function(e) {
360 var tg = Roo.get(e.getTarget());
362 //console.log('no target');
366 if (this.findNode(tg,'logClick')) {
369 var dp = Roo.get(tg.up(''));
370 if (dp && this.findNode(dp,'logClick')) {
374 var ns = Roo.get(tg.getNextSibling());
375 if (ns && this.findNode(ns,'logClick')) {
379 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logClick') ) {
383 for(var i =0; i < 5; i++) {
384 tg = Roo.get(tg.up(''));
386 //console.log('no parent' + i);
389 if (tg && this.findNode(tg,'logClick')) {
393 //console.log('no target in parents');
396 logClick : function(id)
398 var bid = id.length ? 'builder-' + id : '';
399 console.log('{ "id" : "' + bid + '"}');
403 hover : function(e) {
406 var tg = Roo.get(e.getTarget());
408 //console.log('no target');
413 if (this.findNode(tg,'logMove')) {
417 var dp = Roo.get(tg.up(''));
418 if (dp && this.findNode(dp,'logMove')) {
423 var ns = Roo.get(tg.getNextSibling());
424 if (ns && this.findNode(ns,'logMove')) {
428 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logMove' )) {
433 for(var i =0; i < 5; i++) {
434 tg = Roo.get(tg.up(''));
436 //console.log('no parent' + i);
440 if (tg && this.findNode(tg,'logMove')) {
445 //console.log('no target in parents');
448 logMove : function (id) {
449 //console.log("LOGMOVE: " + id);
451 if (this.lastID === id) {
455 var bid = id.length ? 'builder-' + id : '';
456 console.log('{ "hover-node" : "' + bid + '"}');