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']);
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 + '"}');