1 //<script type="text/javascript">
6 render : function(data)
10 if (!Builder.docMove) {
11 // Builder.docMove = Roo.get(document.body).on('mousemove', this.hover, this);
12 // Builder.docMove = Roo.get(document.body).on('dragover', this.hover, this);
20 renderObj : { isBuilder : true },
23 redrawClear : function(isAuto)
25 this.renderObj = { isBuilder : true };
34 //if (this.panelroot) {
35 // this.scroll = this.panelroot.el.getScroll();
36 // this.layout.remove('center', this.panelroot);
37 // this.panelroot = false;
39 if (this.dialogroot) {
40 this.dialogroot.remove();
41 this.dialogroot = false;
48 redraw: function(isAuto)
51 // top level is not relivant
52 this.redrawClear(isAuto);
56 //console.log(this.dump(cfg));
64 // we draw either a dialog or a tab..
66 if (cfg.xtype == 'LayoutDialog') {
69 //var xy = Pman.Tab.BuilderPanel.panel.el.getXY();
70 //cfg.items[0].x = xy[0];
71 //cfg.items[0].y = xy[1];
72 //cfg.items[0].constraintoviewport = false;
74 this.dialogroot = Roo.get( document.body).createChild({
78 this.dialog = new Roo[cfg.xtype](this.dialogroot, cfg);
79 //this.dialog.el.on('click', this.panelClick, this);
87 // force center region..
88 cfg.items[0].region = 'center';
89 cfg.items[0].background = false;
91 this.panelroot = this.layout.addxtype(cfg.items[0]);
94 this.highlightElement(Pman.Tab.BuilderTree.currentNode);
96 if (this.panelroot.el) {
98 this.panelroot.el.scrollTo('top', this.scroll.top);
99 this.panelroot.el.scrollTo('left', this.scroll.left);
112 munge :function (cfg)
115 //cfg.cls = cfg.cls || '';
116 //cfg.cls += ' ' + cfg.id;
120 //console.log(cfg.xtype + ': ' + cfg.id);
126 if (typeof(cfg.background) != 'undefined') {
127 cfg.background = false;
130 var xtype = (cfg['|xns'] || '') + '.' + (cfg.xtype || '');
133 // key is not string?!?!?!!?
134 if (typeof(p) != 'string') {
138 if (typeof(cfg[p]) == 'object') { // listeners!!!
143 if (p.charAt(0) == '|') {
145 if (!cfg[p].length) {
152 var _this = this.renderObj; /// fake '_this' object..
153 /** eval:var:_this **/
154 /** eval:var:_tmp **/
155 // stupid IE can not return objects evaluated..
156 eval('_tmp =(' + cfg[p] + ')');
157 cfg[p.substr(1)] = _tmp;
158 //if (typeof(_tmp) == 'undefined') {
162 } catch(e) { console.log('Error evaluating: ' + cfg[p]); };
169 if ((p.charAt(0) == '*') || (p.charAt(0) == '+')) {
177 // we can overlay some event handlers here..
179 console.log('xtype' + xtype)
181 case 'Roo.LayoutDialog':
182 cfg.listeners.resize = function(dlg, w,h)
184 console.log('{ "id" : "' + dlg.id + '", "set" : "width", "value": ' + w + '}');
185 console.log('{ "id" : "' + dlg.id + '", "set" : "height", "value": ' + h + '}');
194 // now for all the children.. (items)
195 if (xitems === false) {
199 for (var i = 0; i < xitems.length; i++) {
200 // if +builderhide set !!!! drop it!!
204 if (typeof(xi['*prop']) != 'undefined') {
205 var pr = xi['*prop'];
207 // if prop is an array - then it's items are really the value..
209 if (xi.xtype && xi.xtype == 'Array') {
222 if (cfg.items.length == 0) {
229 cloneConfig : function(config) {
230 if (!config) { return null; }
232 for (var i in config) {
233 if (typeof config[i] == 'object') {
234 newConfig[i] = this.cloneConfig(config[i]);
235 } else if (typeof config[i] != 'function') {
236 newConfig[i] = config[i];
241 dump : function (arr,level) {
242 var dumped_text = "";
243 if(!level) level = 0;
245 //The padding given at the beginning of the line.
246 var level_padding = "";
247 for(var j=0;j<level+1;j++) level_padding += " ";
249 if(typeof(arr) == 'object') { //Array/Hashes/Objects
250 for(var item in arr) {
251 var value = arr[item];
253 if(typeof(value) == 'object') { //If it is an array,
254 dumped_text += level_padding + "'" + item + "' ...\n";
255 dumped_text += this.dump(value,level+1);
257 dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
260 } else { //Stings/Chars/Numbers etc.
261 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
265 findNode : function(ftg) {
269 // console.log(ftg.id);
270 if (ftg.id && typeof(ftg.id) == 'string' && ftg.id.match(/builder-/)) {
271 var nid = ftg.id.replace('builder-', '').replace('x-form-el-', '');
276 //console.log(ftg.dom.className);
277 var cmat = ftg.dom.className.match(/x-grid-hd-builder-(form-gen-[0-9]+)/);
280 this.logMove( cmat[1] );
287 overPos: function(x,y)
290 var el = document.elementFromPoint(x,y);
291 // //console.log(el.id);
292 // console.log(document.body.innerHTML);
294 getTarget : function () {
297 stopEvent : function() {
306 hover : function(e) {
309 var tg = Roo.get(e.getTarget());
311 //console.log('no target');
316 if (this.findNode(tg)) {
320 var dp = Roo.get(tg.up(''));
321 if (dp && this.findNode(dp)) {
326 var ns = Roo.get(tg.getNextSibling());
327 if (ns && this.findNode(ns)) {
331 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')))) {
336 for(var i =0; i < 5; i++) {
337 tg = Roo.get(tg.up(''));
339 //console.log('no parent' + i);
343 if (tg && this.findNode(tg)) {
348 //console.log('no target in parents');
351 logMove : function (id) {
352 //console.log("LOGMOVE: " + id);
354 if (this.lastID === id) {
358 var bid = id.length ? 'builder-' + id : '';
359 console.log('{ "hover-node" : "' + bid + '"}');