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;
132 // key is not string?!?!?!!?
133 if (typeof(p) != 'string') {
137 if (typeof(cfg[p]) == 'object') { // listeners!!!
142 if (p.charAt(0) == '|') {
144 if (!cfg[p].length) {
151 var _this = this.renderObj; /// fake '_this' object..
152 /** eval:var:_this **/
153 /** eval:var:_tmp **/
154 // stupid IE can not return objects evaluated..
155 eval('_tmp =(' + cfg[p] + ')');
156 cfg[p.substr(1)] = _tmp;
157 //if (typeof(_tmp) == 'undefined') {
161 } catch(e) { console.log('Error evaluating: ' + cfg[p]); };
168 if ((p.charAt(0) == '*') || (p.charAt(0) == '+')) {
175 // now for all the children.. (items)
176 if (xitems === false) {
180 for (var i = 0; i < xitems.length; i++) {
181 // if +builderhide set !!!! drop it!!
185 if (typeof(xi['*prop']) != 'undefined') {
186 var pr = xi['*prop'];
188 // if prop is an array - then it's items are really the value..
190 if (xi.xtype && xi.xtype == 'Array') {
203 if (cfg.items.length == 0) {
210 cloneConfig : function(config) {
211 if (!config) { return null; }
213 for (var i in config) {
214 if (typeof config[i] == 'object') {
215 newConfig[i] = this.cloneConfig(config[i]);
216 } else if (typeof config[i] != 'function') {
217 newConfig[i] = config[i];
222 dump : function (arr,level) {
223 var dumped_text = "";
224 if(!level) level = 0;
226 //The padding given at the beginning of the line.
227 var level_padding = "";
228 for(var j=0;j<level+1;j++) level_padding += " ";
230 if(typeof(arr) == 'object') { //Array/Hashes/Objects
231 for(var item in arr) {
232 var value = arr[item];
234 if(typeof(value) == 'object') { //If it is an array,
235 dumped_text += level_padding + "'" + item + "' ...\n";
236 dumped_text += this.dump(value,level+1);
238 dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
241 } else { //Stings/Chars/Numbers etc.
242 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
246 findNode : function(ftg) {
250 // console.log(ftg.id);
251 if (ftg.id && typeof(ftg.id) == 'string' && ftg.id.match(/builder-/)) {
252 var nid = ftg.id.replace('builder-', '').replace('x-form-el-', '');
257 //console.log(ftg.dom.className);
258 var cmat = ftg.dom.className.match(/x-grid-hd-builder-(form-gen-[0-9]+)/);
261 this.logMove( cmat[1] );
268 overPos: function(x,y)
271 var el = document.elementFromPoint(x,y);
273 console.log(document.body.innerHTML);
275 getTarget : function () {
278 stopEvent : function() {
287 hover : function(e) {
290 var tg = Roo.get(e.getTarget());
292 //console.log('no target');
297 if (this.findNode(tg)) {
301 var dp = Roo.get(tg.up(''));
302 if (dp && this.findNode(dp)) {
307 var ns = Roo.get(tg.getNextSibling());
308 if (ns && this.findNode(ns)) {
312 if (ns && ns.down('') && this.findNode(Roo.get(ns.down('')))) {
317 for(var i =0; i < 5; i++) {
318 tg = Roo.get(tg.up(''));
320 //console.log('no parent' + i);
324 if (tg && this.findNode(tg)) {
329 //console.log('no target in parents');
332 logMove : function (id) {
333 //console.log("LOGMOVE: " + id);
335 if (this.lastID === id) {
339 var bid = id.length ? 'builder-' + id : '';
340 console.log('{ "hover-node" : "' + bid + '"}');