more quote identeiifers fixessss
[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 /*
160 Ext.form.Hidden = function(config){
161     Ext.form.Hidden.superclass.constructor.call(this, config);
162 };
163
164 Ext.extend(Ext.form.Hidden, Ext.form.TextField, {
165     fieldLabel: '',
166     inputType: 'hidden',
167     width: 50,
168     allowBlank: true,
169     labelSeparator: '',
170      
171     hidden: true,
172     itemCls : 'x-form-item-display-none'
173
174
175 });
176
177
178  Why is this here.. it does not work very well...
179 Ext.form.DateField.prototype.getValue = function(fmt) {
180     var r = this.parseDate(Ext.form.DateField.superclass.getValue.call(this)) || '';
181     if (typeof(fmt) == 'undefined') {
182         return r;
183     }
184     if (typeof(r) == 'string') {
185         return '';
186     }
187     return r.format(fmt);
188 };
189 */
190 //<script type="text/Javascript">
191
192 /**
193  * @class Ext.form.FormButton
194  * @extends Ext.Button
195  * Single checkbox field.  Can be used as a direct replacement for traditional checkbox fields.
196  * @constructor
197  * Creates a new Checkbox
198  * @param {Object} config Configuration options
199  */
200  
201 Ext.form.FormButton = function(config){
202     this.config = config;
203     Ext.form.FormButton.superclass.constructor.call(this, config);
204     
205     
206 };
207 Ext.extend(Ext.form.FormButton, Ext.form.Field, {
208     config : false,
209     labelSeparator: '',
210     defaultAutoCreate : { tag: 'input', type: 'hidden'},
211     onRender : function(ct, position){
212         Roo.form.Checkbox.superclass.onRender.call(this, ct, position);
213         // remove label..
214         var p = Ext.get(this.container.findParentNode('div'));
215         var ch = p.child('label');
216         if (ch) {
217             ch.remove();
218         }
219         
220         // add our button..
221         var bc = this.container.createChild({ tag : 'div' });
222           
223         new Ext.Button(bc, this.config);
224         
225     }
226     
227     
228 });
229
230 Roo.Toolbar.prototype.hide = function()
231 {
232     this.el.child('div').setVisibilityMode(Roo.Element.DISPLAY);
233     this.el.child('div').hide();
234 };
235 Roo.Toolbar.prototype.show = function()
236 {
237     this.el.child('div').show();
238 };
239
240 /* what's this for??? - I think to add x-toolbar-td - is it needed???*/
241 Roo.Toolbar.prototype.nextBlock = function(){
242   
243     var td = document.createElement('td');
244     this.tr.appendChild(td);
245     td.className = 'x-toolbar-td';
246     return td;
247     
248 };