Pman.Tab.BuilderView.js
[Pman.Builder] / Pman.Tab.BuilderView.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5
6
7 // register the module first
8 Pman.on('beforeload', function()
9 {
10     Pman.register({
11         modKey : '001-Pman.Tab.BuilderView',
12         module : Pman.Tab.BuilderView,
13         region : 'center',
14         parent : Pman.Tab.BuilderTab,
15         name : "Pman.Tab.BuilderView",
16         disabled : false, 
17         permname: '' 
18     });
19 });
20
21 Pman.Tab.BuilderView = new Roo.util.Observable({
22
23     panel : false,
24     disabled : false,
25     parentLayout:  false,
26
27     add : function(parentLayout, region)
28     {
29
30         var _this = this;
31         this.parentLayout = parentLayout;
32
33         this.panel = parentLayout.addxtype({
34             xtype: 'ContentPanel',
35             xns: Roo,
36             listeners : {
37                 activate : function (_self)
38                 {
39                     _this.panel = _self;
40                 }
41             },
42             region : 'center',
43             title : "View",
44             munge : function() {
45                 var xitems = false;
46                 if (cfg.items) {
47                     xitems = cfg.items;
48                     delete cfg.items;
49                 }
50                 
51                 if (typeof(cfg.background) != 'undefined') {
52                     cfg.background = false;
53                 }
54                 
55                 
56                 for(var p in cfg){
57                     // key is not string?!?!?!!?
58                     if (typeof(p) != 'string') {
59                         continue;
60                     }
61                     
62                     if (typeof(cfg[p]) == 'object') { // listeners!!!
63                         this.munge(cfg[p]);
64                         continue;
65                     }
66                     // SPECIAL - PIPE
67                     if (p.charAt(0) == '|') {
68                         
69                         if (!cfg[p].length) {
70                             delete cfg[p];
71                             continue;
72                         }
73                         try {
74                             var _tmp = false;
75                             var _this = this.renderObj; /// fake '_this' object..
76                             // stupid IE can not return objects evaluated..
77                             /**
78                              eval:var:_this  
79                              eval:var:_tmp 
80                             **/
81                             eval('_tmp =(' + cfg[p] + ')');
82                             cfg[p.substr(1)] = _tmp;
83                             //if (typeof(_tmp) == 'undefined') {
84                             //    alert(cfg[p]);
85                            // }
86                            
87                         } catch(e) {  console.log('Error evaluating: '  + cfg[p]); };
88                         delete cfg[p];
89                             
90                         
91                         continue;
92                     }
93                     // skip '*'
94                     if ((p.charAt(0) == '*') || (p.charAt(0) == '+')) {
95                         delete cfg[p];
96                         continue;
97                     }
98                     // normal..
99                       
100                 }
101                 // now for all the children.. (items)
102                 if (xitems === false) {
103                     return;
104                 }
105                 cfg.items = [];
106                 for (var i = 0; i < xitems.length; i++) {
107                     // if +builderhide set !!!! drop it!!
108                     
109                     
110                     var xi = xitems[i];
111                     if (typeof(xi['*prop']) != 'undefined') {
112                         var pr = xi['*prop'];
113                         this.munge(xi);
114                         // if prop is an array - then it's items are really the value..
115                         
116                         if (xi.xtype && xi.xtype  == 'Array') {
117                             cfg[pr] = xi.items;
118                         } else {
119                             cfg[pr] = xi;
120                         }
121                         
122                         
123                         continue;
124                     }
125                     this.munge(xi);
126                     cfg.items.push(xi);
127                 }
128                 
129                 if (cfg.items.length == 0) {
130                     delete cfg.items;
131                 }
132                     
133                     
134             },
135             clearAll : function(isAuto) {
136             //        this.renderObj = { isBuilder : true };
137             
138                     
139                     if (this.panelroot) {
140                         this.scroll = this.panelroot.el.getScroll();
141                         this.layout.remove('center', this.panelroot);
142                         this.panelroot = false;
143                     }
144                     if (this.dialogroot) {
145                         this.dialogroot.remove();
146                         this.dialogroot = false;
147                     }
148             },
149             redraw : function(isAuto)
150                 {
151                     
152                     // top level is not relivant
153             
154             //          var btop =  Pman.Tab.BuilderTop2;
155               //      if (isAuto && btop.redrawBtn  && !btop.redrawBtn.auto) {
156                 //        return; /// auto redraw is turned off..
157                   //  }
158                     
159                     this.clearAll(isAuto);
160                     
161                     var cfg =  this.toJS();
162                     if (!cfg.items[0]) {
163                         return;
164                     }
165                     
166                     
167                     this.munge(cfg.items[0]);
168                     
169                     // we draw either a dialog or a tab..
170                     
171                     if (cfg.items[0].xtype == 'LayoutDialog') {
172                         
173                         cfg.items[0].modal = false;
174                         var xy  = this.panel.el.getXY();
175                         cfg.items[0].x = xy[0];
176                         cfg.items[0].y = xy[1];
177                         cfg.items[0].constraintoviewport = false;
178                     
179                         this.dialogroot = Roo.get( document.body).createChild();
180                          
181                         this.dialog = new Roo[cfg.items[0].xtype](this.dialogroot, cfg.items[0]);
182                         this.dialog.el.on('click', this.panelClick, this);
183                         this.dialog.show();
184                         return;
185                         
186                     }
187                     
188                          // force center region..
189                     cfg.items[0].region = 'center';
190                     cfg.items[0].background = false;
191                     
192                     this.panelroot = this.layout.addxtype(cfg.items[0]);
193                     
194                      
195                     //this.highlightElement(Pman.Tab.BuilderTree.currentNode);
196                     
197                     if (this.panelroot.el) {
198                             this.panelroot.el.scrollTo('top', this.scroll.top);
199                             this.panelroot.el.scrollTo('left', this.scroll.left);
200                         
201                     }
202                 },
203             toJS : function(n) {
204                 var bt = Pman.Tab.BuilderTree;
205                 if (!n) {
206                     return this.toJS(bt.tree.root);
207                 }
208             
209                 var _this = this;
210                 var ret = bt.cloneConfig(n.elConfig);
211                 
212                 // flag to prevent rendering..
213                 if ((typeof(ret['+buildershow']) != 'undefined') && !ret['+buildershow']) {
214                     return false;
215                 }
216             
217                 ret.id = typeof(ret.id) == 'undefined' ? 'builder-' + n.id : ret.id;
218             
219                 if (n.childNodes.length) {
220                     ret.items = [];
221                     n.eachChild(function(cn) {
222                         var add = _this.toJS(cn);
223                         if (add === false) {
224                             return;
225                         }
226                         
227                         
228                         ret.items.push(add);
229                     });
230                         
231                 }
232                 return ret;
233             }
234         });
235         this.layout = this.panel.layout;
236
237     }
238 });