init
[Pman.Core] / widgets / Ext.bugs.js
1 // <script type="text/javascript">
2  /* this knocks about 3000ms off the startup - total is 13000 originally. */
3  
4  
5   
6  (function(){
7         var propCache = {},
8                 camelRe = /(-[a-z])/gi,
9                 classReCache = {},
10                 view = document.defaultView,
11                 propFloat = Ext.isIE ? 'styleFloat' : 'cssFloat',
12                 opacityRe = /alpha\(opacity=(.*)\)/i;
13     Ext.propCache = propCache; 
14     
15         function camelFn (a) {
16                 return a.charAt(1).toUpperCase();
17         };
18         function chkCache(prop){
19                 return propCache[prop] ||
20                         (propCache[prop] = prop == 'float' ? 
21                 propFloat : prop.replace(camelRe, camelFn));
22         };
23         Ext.override(Ext.Element, {
24                 getStyle : function(){
25                         return view && view.getComputedStyle ?
26                                 function(prop){
27                     // ie!!!.
28                                         var el = this.dom, v, cs;
29                                         if(el == document) return null;
30                                         prop = chkCache(prop);
31                     
32                                         return (v = el.style[prop]) ? v :
33                                                    (cs = view.getComputedStyle(el, '')) ?
34                             cs[prop] : null;
35                                 } :
36                                 function(prop){
37                                         var el = this.dom, m, cs;
38                                         if(el == document) return null;
39                                         if (prop == 'opacity') {
40                                                 if (el.style.filter.match) {
41                                                         if(m = el.style.filter.match(opacityRe)){
42                                                                 var fv = parseFloat(m[1]);
43                                                                 if(!isNaN(fv)){
44                                                                         return fv ? fv / 100 : 0;
45                                                                 }
46                                                         }
47                                                 }
48                                                 return 1;
49                                         }
50                                         prop = chkCache(prop);
51                                         return el.style[prop] || ((cs = el.currentStyle) ? cs[prop] : null);
52                                 };
53                 }(),
54                 setStyle : function(prop, value){
55                         var tmp,
56                                 style,
57                                 camel;
58                         if (typeof(prop) != 'object') {
59                                 tmp = {};
60                                 tmp[prop] = value;
61                                 prop = tmp;
62                         }
63                         for (style in prop) {
64                                 value = prop[style];
65                                 style == 'opacity' ?
66                                         this.setOpacity(value) :
67                                         this.dom.style[chkCache(style)] = value;
68                         }
69                         return this;
70                 }
71         })
72 })();
73
74
75 // added to roo...
76 Ext.override(Ext.dd.StatusProxy, {
77         update : function(html){
78                 if(typeof html == 'string'){
79                         this.ghost.update(html);
80                 }else{
81                         this.ghost.update('');
82                         html.style.margin = '0';
83                         this.ghost.dom.appendChild(html);
84                 }
85                 var el = this.ghost.dom.firstChild;
86                 if(el){
87                         Ext.fly(el).setStyle('float', 'none');
88                 }
89         }
90 });
91
92 // added to roo....
93 Ext.override(Ext.grid.ColumnModel, {
94     
95     
96     getIndexByDataIndex : function(x){ // fixme - find refs and remove them!
97         return this.findColumnIndex(x);
98     }
99 });
100  
101 Ext.override(Ext.grid.GridView, { 
102   
103     updateColumns : function(){ // this was added before I worked out the fix to the cols.
104         this.grid.stopEditing();
105         var cm = this.grid.colModel, colIds = this.getColumnIds();
106         //var totalWidth = cm.getTotalWidth();
107         var pos = 0;
108         var ci = '';
109         var w = 0;
110         for(var i = 0, len = cm.getColumnCount(); i < len; i++){
111             //if(cm.isHidden(i)) continue;
112             w = cm.getColumnWidth(i);
113             ci = Roo.isSafari ? colIds[i].toLowerCase() : colIds[i];
114           //  console.log('UPDATE COLS: " +this.colSelector+colIds[i] + '=>' + (w - this.borderWidth)+ "px");
115             this.css.updateRule(this.colSelector+ci, 'width', (w - this.borderWidth) + 'px');
116             
117             this.css.updateRule(this.hdSelector+ci, 'width', (w - this.borderWidth) + 'px');
118         }
119         this.updateSplitters();
120        // this.forceLayout.defer(100,this);
121     } 
122
123
124
125 });
126  
127  
128  /*
129 String.format =  function(format) {
130     var args = Array.prototype.slice.call(arguments, 1);
131     return format.replace(/\{(\d+)\}/g, function(m, i) {
132        
133         var e = document.createTextNode( args[i]  );
134         var ew = document.createElement('a');
135         ew.appendChild(e);
136         return ew.innerHTML;
137     });
138 };
139 */
140 Ext.grid.ColumnModel.defaultRenderer = function(value){
141     if (typeof value == 'undefined') {
142         return '&#160;';
143     }
144         if (typeof value == 'string' && value.length < 1){
145             return '&#160;';
146         }
147     //console.log(value);
148     return String.format('{0}',value);   
149 };
150  
151 // as 'findbyId in roo...
152 Ext.form.Form.prototype.stackFind = function(id)
153 {
154     return this.findbyId(id);
155      
156 };
157
158 // This is in Roo???
159 Ext.form.Hidden = function(config){
160     Ext.form.Hidden.superclass.constructor.call(this, config);
161 };
162
163 Ext.extend(Ext.form.Hidden, Ext.form.TextField, {
164     fieldLabel: '',
165     inputType: 'hidden',
166     width: 50,
167     allowBlank: true,
168     labelSeparator: '',
169      
170     hidden: true,
171     itemCls : 'x-form-item-display-none'
172
173
174 });
175 Ext.form.DateField.prototype.getValue = function(fmt) {
176     var r = this.parseDate(Ext.form.DateField.superclass.getValue.call(this)) || '';
177     if (typeof(fmt) == 'undefined') {
178         return r;
179     }
180     if (typeof(r) == 'string') {
181         return '';
182     }
183     return r.format(fmt);
184 };
185
186 //<script type="text/Javascript">
187
188 /**
189  * @class Ext.form.FormButton
190  * @extends Ext.Button
191  * Single checkbox field.  Can be used as a direct replacement for traditional checkbox fields.
192  * @constructor
193  * Creates a new Checkbox
194  * @param {Object} config Configuration options
195  */
196  
197 Ext.form.FormButton = function(config){
198     this.config = config;
199     Ext.form.FormButton.superclass.constructor.call(this, config);
200     
201     
202 };
203 Ext.extend(Ext.form.FormButton, Ext.form.Field, {
204     config : false,
205     labelSeparator: '',
206     defaultAutoCreate : { tag: 'input', type: 'hidden'},
207     onRender : function(ct, position){
208         Roo.form.Checkbox.superclass.onRender.call(this, ct, position);
209         // remove label..
210         var p = Ext.get(this.container.findParentNode('div'));
211         var ch = p.child('label');
212         if (ch) {
213             ch.remove();
214         }
215         
216         // add our button..
217         var bc = this.container.createChild({ tag : 'div' });
218           
219         new Ext.Button(bc, this.config);
220         
221     }
222     
223     
224 });
225
226 Roo.Toolbar.prototype.hide = function()
227 {
228     this.el.child('div').setVisibilityMode(Roo.Element.DISPLAY);
229     this.el.child('div').hide();
230 };
231 Roo.Toolbar.prototype.show = function()
232 {
233     this.el.child('div').show();
234 };
235
236 /* what's this for??? - I think to add x-toolbar-td - is it needed???*/
237 Roo.Toolbar.prototype.nextBlock = function(){
238   
239     var td = document.createElement('td');
240     this.tr.appendChild(td);
241     td.className = 'x-toolbar-td';
242     return td;
243     
244 };