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;
57 redraw: function(isAuto)
60 // top level is not relivant
61 this.redrawClear(isAuto);
65 //console.log(this.dump(cfg));
73 // we draw either a dialog or a tab..
75 if (cfg.xtype == 'LayoutDialog') {
78 //var xy = Pman.Tab.BuilderPanel.panel.el.getXY();
79 //cfg.items[0].x = xy[0];
80 //cfg.items[0].y = xy[1];
81 //cfg.items[0].constraintoviewport = false;
83 this.dialogroot = Roo.get( document.body).createChild({
87 this.dialog = new Roo[cfg.xtype](this.dialogroot, cfg);
88 //this.dialog.el.on('click', this.panelClick, this);
94 // otherwise we are creating a layout area on the document..
98 // contentpanel, nestedlayoutpanel, contentpanel.. etc.
99 // force center region..
100 cfg.region = 'center';
101 cfg.background = false;
102 if (!this.layoutbase) {
104 this.layoutbase = new Ext.BorderLayout(document.body, {
112 alwaysShowTabs: true,
117 this.layoutbase.addxtype( cfg );
124 munge :function (cfg)
127 //cfg.cls = cfg.cls || '';
128 //cfg.cls += ' ' + cfg.id;
132 //console.log(cfg.xtype + ': ' + cfg.id);
138 if (typeof(cfg.background) != 'undefined') {
139 cfg.background = false;
142 var xtype = (cfg['|xns'] || '') + '.' + (cfg.xtype || '');
145 // key is not string?!?!?!!?
146 if (typeof(p) != 'string') {
150 if (typeof(cfg[p]) == 'object') { // listeners!!!
155 if (p.charAt(0) == '|') {
157 if (!cfg[p].length) {
164 var _this = this.renderObj; /// fake '_this' object..
165 /** eval:var:_this **/
166 /** eval:var:_tmp **/
167 // stupid IE can not return objects evaluated..
168 eval('_tmp =(' + cfg[p] + ')');
169 cfg[p.substr(1)] = _tmp;
170 //if (typeof(_tmp) == 'undefined') {
174 } catch(e) { console.log('Error evaluating: ' + cfg[p]); };
181 if ((p.charAt(0) == '*') || (p.charAt(0) == '+')) {
189 // we can overlay some event handlers here..
190 cfg.listeners = cfg.listeners || {};
192 console.log('xtype' + xtype)
194 case 'Roo.LayoutDialog':
195 cfg.listeners.resize = function(dlg, w,h)
197 console.log('{ "id" : "' + dlg.id + '", "set" : "width", "value": ' + w + '}');
198 console.log('{ "id" : "' + dlg.id + '", "set" : "height", "value": ' + h + '}');
207 // now for all the children.. (items)
208 if (xitems === false) {
212 for (var i = 0; i < xitems.length; i++) {
213 // if +builderhide set !!!! drop it!!
217 if (typeof(xi['*prop']) != 'undefined') {
218 console.log('adding prop' + xi['*prop']);
220 var pr = xi['*prop'];
222 // if prop is an array - then it's items are really the value..
223 if (pr.match(/\[\]$/)) {
224 console.log('adding array?' + pr);
225 pr = pr.replace(/\[\]$/, '');
226 cfg[pr] = cfg[pr] || [];
232 if (xi.xtype && xi.xtype == 'Array') {
245 if (cfg.items.length == 0) {
255 cloneConfig : function(config) {
256 if (!config) { return null; }
258 for (var i in config) {
259 if (typeof config[i] == 'object') {
260 newConfig[i] = this.cloneConfig(config[i]);
261 } else if (typeof config[i] != 'function') {
262 newConfig[i] = config[i];
267 dump : function (arr,level) {
268 var dumped_text = "";
269 if(!level) level = 0;
271 return '... TO DEEP ...';
273 //The padding given at the beginning of the line.
274 var level_padding = "";
275 for(var j=0;j<level+1;j++) level_padding += " ";
277 if(typeof(arr) == 'object') { //Array/Hashes/Objects
278 for(var item in arr) {
280 var value = arr[item];
284 if(typeof(value) == 'function') { //If it is an array,
286 dumped_text += level_padding + "'" + item + "' : function() { ... },\n";
289 if(typeof(value) == 'object') { //If it is an array,
290 dumped_text += level_padding + "'" + item + "': {\n";
291 dumped_text += this.dump(value,level+1);
292 dumped_text += level_padding + "}\n";
295 dumped_text += level_padding + "'" + item + "' : \"" + value + "\"\n";
298 } else { //Stings/Chars/Numbers etc.
299 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
303 findNode : function(ftg , method) {
307 // console.log(ftg.id);
308 if (ftg.id && typeof(ftg.id) == 'string' && ftg.id.match(/builder-/)) {
309 var nid = ftg.id.replace('builder-', '').replace('x-form-el-', '');
314 console.log(ftg.dom.className);
315 var cmat = ftg.dom.className.match(/x-grid-hd-builder-(form-gen-[0-9:]+)/);
318 this[method]( cmat[1] );
325 overPos: function(x,y)
328 var el = document.elementFromPoint(x,y);
329 // //console.log(el.id);
330 // console.log(document.body.innerHTML);
332 getTarget : function () {
335 stopEvent : function() {
342 onclick: function(e) {
343 var tg = Roo.get(e.getTarget());
345 //console.log('no target');
349 if (this.findNode(tg,'logClick')) {
352 var dp = Roo.get(tg.up(''));
353 if (dp && this.findNode(dp,'logClick')) {
357 var ns = Roo.get(tg.getNextSibling());
358 if (ns && this.findNode(ns,'logClick')) {
362 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logClick') ) {
366 for(var i =0; i < 5; i++) {
367 tg = Roo.get(tg.up(''));
369 //console.log('no parent' + i);
372 if (tg && this.findNode(tg,'logClick')) {
376 //console.log('no target in parents');
379 logClick : function(id)
381 var bid = id.length ? 'builder-' + id : '';
382 console.log('{ "id" : "' + bid + '"}');
386 hover : function(e) {
389 var tg = Roo.get(e.getTarget());
391 //console.log('no target');
396 if (this.findNode(tg,'logMove')) {
400 var dp = Roo.get(tg.up(''));
401 if (dp && this.findNode(dp,'logMove')) {
406 var ns = Roo.get(tg.getNextSibling());
407 if (ns && this.findNode(ns,'logMove')) {
411 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')) ,'logMove' )) {
416 for(var i =0; i < 5; i++) {
417 tg = Roo.get(tg.up(''));
419 //console.log('no parent' + i);
423 if (tg && this.findNode(tg,'logMove')) {
428 //console.log('no target in parents');
431 logMove : function (id) {
432 //console.log("LOGMOVE: " + id);
434 if (this.lastID === id) {
438 var bid = id.length ? 'builder-' + id : '';
439 console.log('{ "hover-node" : "' + bid + '"}');