1 //<script type="text/javascript">
6 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));
48 this.layoutbase.remove('center', this.layoutbase.getRegion('center'));
52 this.layoutbase= false;
58 redraw: function(isAuto)
61 // top level is not relivant
62 this.redrawClear(isAuto);
66 //console.log(this.dump(cfg));
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 var pr = xi['*prop'];
221 // if prop is an array - then it's items are really the value..
222 if (pr.match(/\[\]$/)) {
223 pr = pr.replace(/\[\]$/, '');
224 cfg[pr] = cfg[pr] || [];
230 if (xi.xtype && xi.xtype == 'Array') {
243 if (cfg.items.length == 0) {
253 cloneConfig : function(config) {
254 if (!config) { return null; }
256 for (var i in config) {
257 if (typeof config[i] == 'object') {
258 newConfig[i] = this.cloneConfig(config[i]);
259 } else if (typeof config[i] != 'function') {
260 newConfig[i] = config[i];
265 dump : function (arr,level) {
266 var dumped_text = "";
267 if(!level) level = 0;
269 return '... TO DEEP ...';
271 //The padding given at the beginning of the line.
272 var level_padding = "";
273 for(var j=0;j<level+1;j++) level_padding += " ";
275 if(typeof(arr) == 'object') { //Array/Hashes/Objects
276 for(var item in arr) {
278 var value = arr[item];
282 if(typeof(value) == 'function') { //If it is an array,
284 dumped_text += level_padding + "'" + item + "' : function() { ... },\n";
287 if(typeof(value) == 'object') { //If it is an array,
288 dumped_text += level_padding + "'" + item + "': {\n";
289 dumped_text += this.dump(value,level+1);
290 dumped_text += level_padding + "}\n";
293 dumped_text += level_padding + "'" + item + "' : \"" + value + "\"\n";
296 } else { //Stings/Chars/Numbers etc.
297 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
301 findNode : function(ftg , method) {
305 // console.log(ftg.id);
306 if (ftg.id && typeof(ftg.id) == 'string' && ftg.id.match(/builder-/)) {
307 var nid = ftg.id.replace('builder-', '').replace('x-form-el-', '');
312 console.log(ftg.dom.className);
313 var cmat = ftg.dom.className.match(/x-grid-hd-builder-(form-gen-[0-9:]+)/);
316 this[method]( cmat[1] );
323 overPos: function(x,y)
326 var el = document.elementFromPoint(x,y);
327 // //console.log(el.id);
328 // console.log(document.body.innerHTML);
330 getTarget : function () {
333 stopEvent : function() {
340 onclick: function(e) {
341 var tg = Roo.get(e.getTarget());
343 //console.log('no target');
347 if (this.findNode(tg,'logClick')) {
350 var dp = Roo.get(tg.up(''));
351 if (dp && this.findNode(dp,'logClick')) {
355 var ns = Roo.get(tg.getNextSibling());
356 if (ns && this.findNode(ns,'logClick')) {
360 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logClick') ) {
364 for(var i =0; i < 5; i++) {
365 tg = Roo.get(tg.up(''));
367 //console.log('no parent' + i);
370 if (tg && this.findNode(tg,'logClick')) {
374 //console.log('no target in parents');
377 logClick : function(id)
379 var bid = id.length ? 'builder-' + id : '';
380 console.log('{ "id" : "' + bid + '"}');
384 hover : function(e) {
387 var tg = Roo.get(e.getTarget());
389 //console.log('no target');
394 if (this.findNode(tg,'logMove')) {
398 var dp = Roo.get(tg.up(''));
399 if (dp && this.findNode(dp,'logMove')) {
404 var ns = Roo.get(tg.getNextSibling());
405 if (ns && this.findNode(ns,'logMove')) {
409 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logMove' )) {
414 for(var i =0; i < 5; i++) {
415 tg = Roo.get(tg.up(''));
417 //console.log('no parent' + i);
421 if (tg && this.findNode(tg,'logMove')) {
426 //console.log('no target in parents');
429 logMove : function (id) {
430 //console.log("LOGMOVE: " + id);
432 if (this.lastID === id) {
436 var bid = id.length ? 'builder-' + id : '';
437 console.log('{ "hover-node" : "' + bid + '"}');