Attribute changed old-javascript
[app.Builder.js] / old-javascript / Palete / Roo.js
1 //<Script type="text/javascript">
2  
3 Gio       = imports.gi.Gio;
4
5 console   = imports.console;
6 XObject   = imports.XObject.XObject;
7
8 Base      = imports.Palete.Base.Base;
9 File      = imports.File.File;
10 //----------------------- our roo verison
11
12
13 // single instance controlled by projectmanager.
14
15 Roo = XObject.define(
16     function(cfg) {
17         
18        
19         // various loader methods..
20          this.map = [];
21         this.load();
22        
23         // no parent...
24         
25        
26     },
27     Base,
28     {
29     
30         name : 'Roo',
31         
32         load: function ( o ) {
33             
34              
35             var data = File.read(__script_path__ +'/RooUsage.txt');
36             //print(data);
37             data  = data.split(/\n/g);
38             var state = 0;
39             var cfg = [];
40             var left = [];
41             var right = [];
42             
43             data.forEach( function(d) {
44                 if (!d.length || d.match(/^\s+$/) || d.match(/^\//)) { //empty
45                     return;
46                 }
47                 if (d.match(/^left:/)) { 
48                     state = 1;
49                     if (left.length ){
50                         
51                         cfg.push({
52                             left : left,
53                             right: right
54                         });
55                         }
56                     left = [];
57                     right = [];
58                     return;
59                 }
60                 if (d.match(/^right:/)) { 
61                     state = 2;
62                     return;
63                 }
64                 if (state == 1) {
65                     left.push(d.replace(/\s+/g, ''));
66                     return;
67                 }
68                 right.push(d.replace(/\s+/g, ''));
69                 //Seed.quit();
70                
71             }); 
72             if (left.length ){
73                         
74                 cfg.push({
75                     left : left,
76                     right: right
77                 });
78             }
79             this.map = cfg;
80             
81         },
82         loadProps: function()
83         {
84              
85
86             if (this.proplist) {
87                 return;
88             }
89             
90            
91             
92             var data =  File.read(__script_path__ +'/rooprops.json');
93             this.proplist = JSON.parse(data).data;
94         },
95         getPropertiesFor: function(ename, type)
96         {
97             this.loadProps();
98             if (typeof(this.proplist[ename]) == 'undefined' || 
99                 typeof(this.proplist[ename][type]) == 'undefined' ) {
100                     return [];
101             }
102             return this.proplist[ename][type];
103         },
104         guessName: function(ar)
105         {
106             var name = ar;
107             if (typeof(name) !== 'string') {
108                 name = Base.prototype.guessName(ar);
109             }
110             
111             this.loadProps();
112             if (typeof(this.proplist[name]) != 'undefined') {
113                 return name;
114             }
115             // roo toolbar is not in our DB!
116             if (name.match(/^Roo\.Toolbar\..*/)) {
117                 return name;
118             }
119             
120             var match = name.split('.').pop();
121             for (var i in this.proplist) {
122                 var last = i.split('.').pop();
123                 if (last == match) {
124                     return i;
125                 }
126                 
127             }
128             return name;
129             
130             
131         }
132         
133         
134         
135     }
136 );
137
138