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 this.layoutbase.remove('center', this.layoutbase.getRegion('center'));
57 //this.layoutbase= false;
64 redraw: function(isAuto)
67 // top level is not relivant
68 this.redrawClear(isAuto);
72 //console.log(this.dump(cfg));
79 //console.log(cfg);return;
80 // we draw either a dialog or a tab..
82 if (cfg.xtype == 'LayoutDialog') {
85 //var xy = Pman.Tab.BuilderPanel.panel.el.getXY();
86 //cfg.items[0].x = xy[0];
87 //cfg.items[0].y = xy[1];
88 //cfg.items[0].constraintoviewport = false;
90 this.dialogroot = Roo.get( document.body).createChild({
94 this.dialog = new Roo[cfg.xtype](this.dialogroot, cfg);
95 //this.dialog.el.on('click', this.panelClick, this);
101 // otherwise we are creating a layout area on the document..
105 // contentpanel, nestedlayoutpanel, contentpanel.. etc.
106 // force center region..
107 cfg.region = 'center';
108 cfg.background = false;
109 if (!this.layoutbase) {
111 this.layoutbase = new Ext.BorderLayout(document.body, {
119 alwaysShowTabs: true,
124 this.layoutbase.addxtype( cfg );
131 munge :function (cfg)
134 //cfg.cls = cfg.cls || '';
135 //cfg.cls += ' ' + cfg.id;
139 //console.log(cfg.xtype + ': ' + cfg.id);
145 if (typeof(cfg.background) != 'undefined') {
146 cfg.background = false;
149 var xtype = (cfg['|xns'] || '') + '.' + (cfg.xtype || '');
152 // key is not string?!?!?!!?
153 if (typeof(p) != 'string') {
157 if (typeof(cfg[p]) == 'object') { // listeners!!!
162 if (p.charAt(0) == '|') {
164 if (!cfg[p].length) {
171 var _this = this.renderObj; /// fake '_this' object..
172 /** eval:var:_this **/
173 /** eval:var:_tmp **/
174 // stupid IE can not return objects evaluated..
175 eval('_tmp =(' + cfg[p] + ')');
176 cfg[p.substr(1)] = _tmp;
177 //if (typeof(_tmp) == 'undefined') {
181 } catch(e) { console.log('Error evaluating: ' + cfg[p]); };
188 if ((p.charAt(0) == '*') || (p.charAt(0) == '+')) {
196 // we can overlay some event handlers here..
197 cfg.listeners = cfg.listeners || {};
199 //console.log('xtype' + xtype)
201 case 'Roo.LayoutDialog':
202 cfg.listeners.resize = function(dlg, w,h)
204 console.log('{ "id" : "' + dlg.id + '", "set" : "width", "value": ' + w + '}');
205 console.log('{ "id" : "' + dlg.id + '", "set" : "height", "value": ' + h + '}');
214 // now for all the children.. (items)
215 if (xitems === false) {
219 for (var i = 0; i < xitems.length; i++) {
220 // if +builderhide set !!!! drop it!!
224 if (typeof(xi['*prop']) != 'undefined') {
225 console.log('adding prop:' + xi['*prop']);
227 var pr = xi['*prop'];
229 // if prop is an array - then it's items are really the value..
230 if (pr.match(/\[\]$/)) {
231 console.log('adding array?:' + pr);
232 pr = pr.replace(/\[\]$/, '');
233 cfg[pr] = cfg[pr] || [];
239 if (xi.xtype && xi.xtype == 'Array') {
242 console.log('setting property:' + pr);
253 if (cfg.items.length == 0) {
263 cloneConfig : function(config) {
264 if (!config) { return null; }
266 for (var i in config) {
267 if (typeof config[i] == 'object') {
268 newConfig[i] = this.cloneConfig(config[i]);
269 } else if (typeof config[i] != 'function') {
270 newConfig[i] = config[i];
275 dump : function (arr,level) {
276 var dumped_text = "";
277 if(!level) level = 0;
279 return '... TO DEEP ...';
281 //The padding given at the beginning of the line.
282 var level_padding = "";
283 for(var j=0;j<level+1;j++) level_padding += " ";
285 if(typeof(arr) == 'object') { //Array/Hashes/Objects
286 for(var item in arr) {
288 var value = arr[item];
292 if(typeof(value) == 'function') { //If it is an array,
294 dumped_text += level_padding + "'" + item + "' : function() { ... },\n";
297 if(typeof(value) == 'object') { //If it is an array,
298 dumped_text += level_padding + "'" + item + "': {\n";
299 dumped_text += this.dump(value,level+1);
300 dumped_text += level_padding + "}\n";
303 dumped_text += level_padding + "'" + item + "' : \"" + value + "\"\n";
306 } else { //Stings/Chars/Numbers etc.
307 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
311 findNode : function(ftg , method) {
315 // console.log(ftg.id);
316 if (ftg.id && typeof(ftg.id) == 'string' && ftg.id.match(/builder-/)) {
317 var nid = ftg.id.replace('builder-', '').replace('x-form-el-', '');
322 if (ftg.dom.className.match(/[0-9]+/)) {
323 console.log(ftg.dom.className);
324 var cmat = ftg.dom.className.match(/x-grid-hd-builder-(form-gen-[0-9:]+)/);
326 this[method]( cmat[1] );
337 overPos: function(x,y)
340 var el = document.elementFromPoint(x,y);
341 // //console.log(el.id);
342 // console.log(document.body.innerHTML);
344 getTarget : function () {
347 stopEvent : function() {
354 onclick: function(e) {
355 var tg = Roo.get(e.getTarget());
357 //console.log('no target');
361 if (this.findNode(tg,'logClick')) {
364 var dp = Roo.get(tg.up(''));
365 if (dp && this.findNode(dp,'logClick')) {
369 var ns = Roo.get(tg.getNextSibling());
370 if (ns && this.findNode(ns,'logClick')) {
374 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logClick') ) {
378 for(var i =0; i < 5; i++) {
379 tg = Roo.get(tg.up(''));
381 //console.log('no parent' + i);
384 if (tg && this.findNode(tg,'logClick')) {
388 //console.log('no target in parents');
391 logClick : function(id)
393 var bid = id.length ? 'builder-' + id : '';
394 console.log('{ "id" : "' + bid + '"}');
398 hover : function(e) {
401 var tg = Roo.get(e.getTarget());
403 //console.log('no target');
408 if (this.findNode(tg,'logMove')) {
412 var dp = Roo.get(tg.up(''));
413 if (dp && this.findNode(dp,'logMove')) {
418 var ns = Roo.get(tg.getNextSibling());
419 if (ns && this.findNode(ns,'logMove')) {
423 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logMove' )) {
428 for(var i =0; i < 5; i++) {
429 tg = Roo.get(tg.up(''));
431 //console.log('no parent' + i);
435 if (tg && this.findNode(tg,'logMove')) {
440 //console.log('no target in parents');
443 logMove : function (id) {
444 //console.log("LOGMOVE: " + id);
446 if (this.lastID === id) {
450 var bid = id.length ? 'builder-' + id : '';
451 console.log('{ "hover-node" : "' + bid + '"}');