fs-danaus
2023-03-30 665b0603d09890014f982fdfbd6ec47938f504b0
提交 | 用户 | age
25ab64 1 MS.Color;
F 2 var CColors = {"transparent":"#FFFFFF","black":"#000001","silver":"#C0C0C0","gray":"#808080","white":"#FFFFFE","maroon":"#800000","red":"#FF0000",
3                "purple":"#800080","fuchsia":"#FF00FF","green":"#008000","lime":"#00FF00","olive":"#808000","yellow":"#FFFF00","navy":"#000080",
4                "blue":"#0000FF","teal":"#008080","aqua":"#00FFFF","orange":"#FFA500",
5                "aliceblue":"f0f8ff","antiquewhite":"faebd7","aquamarine":"7fffd4","azure":"f0ffff","beige":"f5f5dc","bisque":"ffe4c4","blanchedalmond":"ffebcd","blueviolet":"8a2be2","brown":"a52a2a","burlywood":"deb887",
6                "cadetblue":"5f9ea0","chartreuse":"7fff00","chocolate":"d2691e","coral":"ff7f50","cornflowerblue":"6495ed","cornsilk":"fff8dc","crimson":"dc143c","cyan":"00ffff",
7                "darkblue":"00008b","darkcyan":"008b8b","darkgoldenrod":"b8860b","darkgray":"a9a9a9","darkgreen":"006400","darkkhaki":"bdb76b","darkmagenta":"8b008b","darkolivegreen":"556b2f","darkorange":"ff8c00",
8                "darkorchid":"9932cc","darkred":"8b0000","darksalmon":"e9967a","darkseagreen":"8fbc8f","darkslateblue":"483d8b","darkslategray":"2f4f4f","darkturquoise":"00ced1","darkviolet":"9400d3",
9                "deeppink":"ff1493","deepskyblue":"00bfff","dimgray":"696969","dodgerblue":"1e90ff","feldspar":"d19275","firebrick":"b22222","floralwhite":"fffaf0","forestgreen":"228b22",
10                "gainsboro":"dcdcdc","ghostwhite":"f8f8ff","gold":"ffd700","goldenrod":"daa520","greenyellow":"adff2f","honeydew":"f0fff0","hotpink":"ff69b4","indianred":"cd5c5c","indigo":"4b0082","ivory":"fffff0",
11                "khaki":"f0e68c","lavender":"e6e6fa","lavenderblush":"fff0f5","lawngreen":"7cfc00","lemonchiffon":"fffacd","lightblue":"add8e6","lightcoral":"f08080","lightcyan":"e0ffff","lightgoldenrodyellow":"fafad2",
12                "lightgrey":"d3d3d3","lightgreen":"90ee90","lightpink":"ffb6c1","lightsalmon":"ffa07a","lightseagreen":"20b2aa","lightskyblue":"87cefa","lightslateblue":"8470ff","lightslategray":"778899",
13                "lightsteelblue":"b0c4de","lightyellow":"ffffe0","limegreen":"32cd32","linen":"faf0e6","magenta":"ff00ff","mediumaquamarine":"66cdaa","mediumblue":"0000cd","mediumorchid":"ba55d3","mediumpurple":"9370d8",
14                "mediumseagreen":"3cb371","mediumslateblue":"7b68ee","mediumspringgreen":"00fa9a","mediumturquoise":"48d1cc","mediumvioletred":"c71585","midnightblue":"191970","mintcream":"f5fffa","mistyrose":"ffe4e1",
15                "moccasin":"ffe4b5","navajowhite":"ffdead","oldlace":"fdf5e6","olivedrab":"6b8e23","orangered":"ff4500","orchid":"da70d6","palegoldenrod":"eee8aa","palegreen":"98fb98","paleturquoise":"afeeee",
16                "palevioletred":"d87093","papayawhip":"ffefd5","peachpuff":"ffdab9","peru":"cd853f","pink":"ffc0cb","plum":"dda0dd","powderblue":"b0e0e6","rosybrown":"bc8f8f","royalblue":"4169e1",
17                "saddlebrown":"8b4513","salmon":"fa8072","sandybrown":"f4a460","seagreen":"2e8b57","seashell":"fff5ee","sienna":"a0522d","skyblue":"87ceeb","slateblue":"6a5acd","slategray":"708090",
18                "snow":"fffafa","springgreen":"00ff7f","steelblue":"4682b4","tan":"d2b48c","thistle":"d8bfd8","tomato":"ff6347","turquoise":"40e0d0","violet":"ee82ee","violetred":"d02090",
19                "wheat":"f5deb3","whitesmoke":"f5f5f5","yellowgreen":"9acd32" };
20 ME.Color;
21
22 // -----------------------------------------------------------------------------------------------------------
23 MS.Color;
24 TGP.ConvertColor = function(clr){
25 var rgb = this.Formats[clr];
26 if(rgb!=null) return rgb;
27 clr += "";
28 var cclr = CColors[clr.toLowerCase()]; if(cclr) clr = cclr;
29
30 if(clr.charAt(0)=='#') {
31    if(clr.length==4) rgb = ("0x"+clr.charAt(1)<<24) + ("0x"+clr.charAt(2)<<14) + ("0x"+clr.charAt(3)<<4);
32    
33    else rgb = ("0x"+clr.slice(1,3)<<20) + ("0x"+clr.slice(3,5)<<10) + (("0x"+clr.slice(5,7))-0);
34    if(rgb===0) rgb++;
35    }
36    
37 else if(clr.indexOf("-")>=0){
38    rgb = clr.replace(/[^\d\,\-\.]/g,"");
39    rgb = rgb.split(","); 
40    rgb = (255+(rgb[0]-0)<<20)+(255+(rgb[1]-0)<<10)+(255+(rgb[2]-0)); 
41    }   
42
43 else if(clr.slice(0,4)=="rgba"){
44    rgb = clr.replace(/[^\d\,\-\.]/g,"");
45    MS.Debug;
46    if(!rgb && clr) this.Debug(2,"Invalid color: ",clr);
47    ME.Debug;
48    rgb = rgb.split(","); 
49    var n = Math.round(rgb[3]*10); if(n>7) n = 7;
50    rgb = (rgb[0]<255?rgb[0]<<20:0xFF00000)+(rgb[1]<255?rgb[1]<<10:0x3FC00)+(rgb[2]<255?rgb[2]-0:255);
51    if(n&1) rgb += 0xFF00000;
52    if(n&2) rgb += 0x3FC00;
53    if(n&4) rgb += 255;
54    }
55
56 else { 
57    rgb = clr.replace(/[^\d\,\-\.]/g,"");
58    MS.Debug;
59    if(!rgb && clr) this.Debug(2,"Invalid color: ",clr);
60    ME.Debug;
61    rgb = rgb.split(","); 
62    rgb = (rgb[0]<255?rgb[0]<<20:0xFF00000)+(rgb[1]<255?rgb[1]<<10:0x3FC00)+(rgb[2]<255?rgb[2]-0:255);
63    }
64 if(rgb) rgb -= 0xFF3FCFF; else rgb = 0;   
65 this.Formats[clr] = rgb;
66 return rgb;
67 }
68 ME.Color;
69 // -----------------------------------------------------------------------------------------------------------
70 TGP.ColorCell = function(row,col){
71 MS.Color;
72 var cell = this.GetCell(row,col); if(!cell) return;
73 var A = []; this.GetRowHTML(row,A,5,col);
74 var cur = this.CursorToSet;
75
76 cell.style.backgroundColor = A[1];
77
78
79
80 if(cell.className.indexOf("NoRight")>=0) cell.nextSibling.style.backgroundColor = A[1];
81
82 MS.Tree; if(col==this.MainCol && !this.HideTree && cell.className.indexOf("NoLeft")>=0) cell.previousSibling.style.backgroundColor = A[1]; ME.Tree;   
83 ME.Color;
84 }
85 // -----------------------------------------------------------------------------------------------------------
86 TGP.ColorRow = function(row){
87 MS.Color;
88 if(!row || !row.r1) return;
89 MS.Space;
90 if(row.Space){
91    var cell = row.SpaceWrap ? row.r1.firstChild.firstChild : row.r1.firstChild.rows[0].cells[BIEA?1:0];
92    var A = []; this.GetRowHTML(row,A,5);
93    for(var pos=1;cell;cell=cell.nextSibling,pos+=2) cell.style.backgroundColor = A[pos];
94    return;   
95    }
96 ME.Space;
97 var SS = this.GetSS();
98 this.GetRowHTML(row,SS,5);
99 var rcls = this.Img.Style+row.Kind+"Row "+(this.DynamicBorder&&!row.NoDynBorder?" "+this.Img.Style+"DB ":"")+this.GetRowHTML(row,null,16);
100 var right = "NoRight"; 
101 for(var i=this.FirstSec;i<=this.LastSec;i++){
102    var r = row["r"+i]; if(!r) continue;
103    r.className = rcls;
104    if(BIEA) r.style.paddingLeft = "0px"; 
105    var A = SS[i], cell = r.firstChild, pos = 1; if(!A) continue; 
106    if((this.LeftTD||i==1)&&cell) cell = cell.nextSibling;
107    while(cell){
108       var cls = cell.className;
109
110 //      cls = A[pos-1] + cls.replace(/[\s^]Color\S*/g,"");
111 //      cell.className = cls;
112       cell.style.backgroundColor = A[pos];
113       if(cls.indexOf(right)<0) pos+=2;
114       cell = cell.nextSibling;
115       }
116    }
117 ME.Color;   
118 }
119 // -----------------------------------------------------------------------------------------------------------
120 TGP.ColorCol = function(col,row){
121 if(!row){
122    this.ColorCol(col,this.XH);
123    this.ColorCol(col,this.XF);
124    for(var p=this.XB.firstChild;p;p=p.nextSibling) if(p.r1) this.ColorCol(col,p);
125    return;
126    }
127 for(var r=row.firstChild;r;r=r.nextSibling){
128    if(r.firstChild && r.Hasch) this.ColorCol(col,r);
129    this.ColorCell(r,col);
130    }
131 }
132
133 // -----------------------------------------------------------------------------------------------------------
134 MS.SideButton;
135 TGP.SetCellIcon = function(row,col,cell){
136 if(row.Space) {
137    var src = this.GetAttr(row,col,"Button"); 
138    if(src) cell.style.backgroundImage = "url("+(this.EscapeImages?'"'+this.Lang.Format.Escape(src)+'"':src)+")";
139    }
140 else if(!this.SpannedTree || col!=this.MainCol || this.HideTree || !this.Cols[col].Visible&&!this.Cols[col].Hidden || row.Fixed){   
141    var src = this.GetAttr(row,col,"Icon"), src2;
142    var val = Get(row,col); 
143    if(val&&val!="0") { src2 = this.GetAttr(row,col,"IconChecked"); if(src2) src = src2; }
144    
145    if(src==null && this.GetType(row,col)=="Icon") src = Get(row,col);
146    if(src==null && this.GetType(row,col)=="Button") { src = this.GetAttr(row,col,"ButtonText"); if(src==null) src = Get(row,col); }
147    if(src) cell.style.backgroundImage = "url("+(this.EscapeImages?'"'+this.Lang.Format.Escape(src)+'"':src)+")";
148    var w = this.GetAttr(row,col,"IconWidth"); 
149    if(w) cell.style["padding-"+(CAlignTypes[this.GetAttr(row,col,"IconAlign")]=="Right"?"right":"left")] = w+"px";
150    }
151 }
152 ME.SideButton;
153 // -----------------------------------------------------------------------------------------------------------
154 TGP.RefreshCell = function(row,col,clsonly,noundo){
155 if(this.Rendering==2) return; 
156 MS.Animate; if((row.Animating||row.AnimatingCells&&row.AnimatingCells[col])&&!clsonly) this.AnimCell(row,col); ME.Animate;
157 var cell = this.GetCell(row,col); if(!cell) return;
158 MS.Nested;
159 if(row.DetailCol && row.DetailGrid && row.DetailCol==(row.Spanned ? this.GetSpanCol(row,col) : col)) return;
160 ME.Nested;
161 var A = [], W = null, WW = null, h = null;
162 if(this.Cols[col]&&this.Cols[col].Type=="Img"&&row[col]&&row[col]!=""&&row[col].indexOf("http")<0){//*****处理图片,把不是以http开头的转成http,https开头
163     row[col]=this.createPicPath(row[col]);
164 }
165 this.GetRowHTML(row,A,4,col);
166 if(!clsonly){
167    var typ = this.GetType(row,col), refh = this.GetAttr(row,col,"RefreshHeight",null,1); 
168    h = refh==1 || refh==null&&(row.Space||CEditMulti[typ]) ? cell.offsetHeight : null;
169    if(row.Space && row.RelWidth){
170       var cf = row[col+"RelWidth"] ? cell.lastChild : null;
171       while(cf && cf.firstChild && cf.className && cf.className.indexOf("Inner")>=0 && cf.className.indexOf("WidthInner")<0 && cf.firstChild.nodeType==1) cf = cf.firstChild;
172       if(cf) W = cf.style.width;
173       else WW = cell.offsetWidth;
174       }
175    if(Grids.OnClearRow) Grids.OnClearRow(this,row,col);
176    if(BSafari && cell.style.overflow=="visible" && A[0]!=CNBSP) cell.style.overflow = "";
177    cell.innerHTML = A[0];
178    if(BIEA&&cell.lastChild&&cell.lastChild.nodeType==3&&!cell.lastChild.data) cell.removeChild(cell.lastChild); 
179    }
180
181 if(!this.GanttPaging || !this.Cols[col] || !this.Cols[col].GanttPageW){
182
183    MS.SideButton;
184    if(A[3]==" "){ cell.style.backgroundImage = ""; cell.style.paddingLeft = ""; }
185    else if(A[3]) this.SetCellIcon(row,col,cell); 
186    
187    var bcell = cell.className.indexOf("NoRight")>=0 ? cell.nextSibling : null;
188    
189    if(A[5]) { 
190       if(!bcell){
191          bcell = cell.parentNode.insertCell(cell.cellIndex+1);
192          cell.colSpan = cell.colSpan-1;
193          bcell.rowSpan = cell.rowSpan;
194          bcell.innerHTML = CNBSP;
195          }
196       bcell.className = A[5];
197       bcell.style.backgroundColor = A[2];
198       if(!clsonly && A[4]) bcell.innerHTML = A[4];
199       if(A[6]) {
200          var but = this.GetAttr(row,col,"Button"); if(this.EscapeImages) but = '"'+this.Lang.Format.Escape(but)+'"';
201          bcell.style.backgroundImage = "url("+but+")"; 
202          }
203       else if(bcell.style.backgroundImage) bcell.style.backgroundImage = "";
204       }
205    else if(bcell){
206       bcell.parentNode.removeChild(bcell);
207       cell.colSpan = cell.colSpan+1;
208       }
209    ME.SideButton;   
210
211    MS.Tree;
212    if(A[8] && (this.Cols[col].Visible||this.Cols[col].Hidden)){ 
213       var tcell = cell.previousSibling;
214       tcell.innerHTML = A[8];
215       tcell.className = A[9];
216       tcell.style.backgroundColor = A[2];
217       }
218    ME.Tree; 
219    }
220
221 //[1] = A[1].replace(/ToolUndo/,"");
222 cell.className = A[1];
223 cell.style.backgroundColor = A[2]; 
224
225 MS.Overlay; 
226 if(this.Overlay>=2&&!row.Space) { 
227    this.UpdateOverlay(row,this.Cols[col].Sec); 
228    MS.RowSpan; if(this.Overlay&4 && row.RowSpan && row[col+"RowSpan"]>1) for(var r=row.nextSibling,lr=this.GetLastSpanRow(row,col);r!=lr.nextSibling;r=r.nextSibling) this.UpdateOverlay(r,this.Cols[col].Sec); ME.RowSpan; 
229    } 
230 ME.Overlay;
231 if(W){
232    var cf = cell.lastChild;
233    while(cf && cf.firstChild && cf.className && cf.className.indexOf("Inner")>=0 && cf.className.indexOf("WidthInner")<0 && cf.firstChild.nodeType==1) cf = cf.firstChild;
234    if(cf) cf.style.width = W;
235    }
236 else if(WW && WW!=cell.offsetWidth) this.UpdateSpaceRelWidth(row);
237 if(h && h!=cell.offsetHeight && cell.offsetHeight) { if(row.Space) this.Update(); else this.UpdateRowHeight(row,1,null,noundo); }
238 if(row==this.ARow && col==this.ACol) this.GridMouseOver();
239 if(this.ScrollAlign && this.ScrollAlign[4][row.id]) this.DoScrollAlign(null,row.id);
240 if(Grids.OnRenderRow && !clsonly) Grids.OnRenderRow(this,row,col);
241 }
242 // -----------------------------------------------------------------------------------------------------------
243 TGP.RefreshRow = function(row,sec){
244 if(!row || !row.r1) return;
245 MS.Animate; if(row.Animating||row.AnimatingCells) this.AnimRow(row); ME.Animate;
246 if(Grids.OnClearRow) Grids.OnClearRow(this,row);
247 var SS, fr, lr, s, d, h = null, upd = 0;
248 if(row.Space){
249    if(row==this.ERow && this.EndEdit(1)==-1) return;
250    var h = row.r1.offsetHeight;
251    row.r1.innerHTML = this.GetSpaceHTML(row);
252    if(row.RelWidth) this.UpdateSpaceRelWidth(row);
253    if(h!=row.r1.offsetHeight) this.Update();
254    }   
255 else {   
256    if(sec==null) { SS = this.GetSS(); fr = this.FirstSec; lr = this.LastSec; }
257    else { 
258       SS = []; SS[sec] = []; fr = sec; lr = sec; 
259       if(!row["r"+sec]) return;
260       var oh = row["r"+sec].offsetHeight; 
261       }
262    this.GetRowHTML(row,SS,0);
263    MS.FFOnly; MX.FFOnly;
264    if(BIEA||BSafari){ 
265       s = this.GetRowTagHTML(row); 
266       d = document.createElement("div");
267       }
268    ME.FFOnly; 
269    for(var i=fr;i<=lr;i++){
270       var r = row["r"+i]; if(!r || !SS[i]) continue; 
271       if(BIEA||BSafari){ 
272          d.innerHTML = CTableCSP0 + CTfoot + s + (i==1&&!this.LeftTD?"<td style='width:0px;'></td>":"") + SS[i].join("") + "</tr>" + CTableEnd;
273          var n = d.firstChild.rows[0];
274          r.parentNode.replaceChild(n,r);
275          row["r"+i] = n;
276          if(BTablet) { n.ontouchstart = r.ontouchstart; r.ontouchstart = null; }
277          else if(BTouch) { n.setAttribute("ontouchstart",r.getAttribute("ontouchstart")); r.setAttribute("ontouchstart",null); }
278          if(BMouse) { n.onmousemove = r.onmousemove; r.onmousemove = null; }
279          n.row = row;
280          r.row = null;
281          n.style.height = r.style.height;
282          r = n;
283          }
284       else {
285          r.innerHTML = (this.LeftTD||i==1?"<td style='width:0px;height:0px'></td>":"")+SS[i].join("");   
286          }
287       if(h==null) h = r.offsetHeight;
288       else if(!upd && h!=r.offsetHeight) upd = 1;
289       }
290    if(upd || sec!=null&&oh!=h) this.UpdateRowHeight(row,1);
291    }      
292 if(row==this.ARow) this.GridMouseOver();
293 if(this.ScrollAlign && this.ScrollAlign[4][row.id]) this.DoScrollAlign(null,row.id);
294 if(Grids.OnRenderRow) Grids.OnRenderRow(this,row);
295 }
296 // -----------------------------------------------------------------------------------------------------------
297 TGP.ReColor = function(noshow){ 
298 MS.Color;
299 var a = this.Alternate; if(!a) return;
300 var b = this.AlternateCount; if(!(b>0)) b = 1;
301 var t = this.AlternateType, t2 = this.Paging!=3||t&2;
302 for(var p=this.XB.firstChild,c=null;p;p=p.nextSibling) if(p.firstChild) c = this.ReColorPage(p,noshow,a,b,t2?c:null,t&1);
303 ME.Color;
304 }
305 // -----------------------------------------------------------------------------------------------------------
306 MS.Color;
307 TGP.ReColorPage = function(p,noshow,a,b,c,t){ 
308 if(c==null) c = (this.AlternateStart!=null?b-1+this.AlternateStart:a-1);
309 for(var r=p.firstChild;r;r=r.nextSibling){ 
310    if(!r.Visible) continue;
311    if(r.ColorPos != c<b){ 
312       r.ColorPos = c<b; 
313       if(!noshow) {
314          this.ColorRow(r); 
315          if(this.RowIndex) this.RefreshCell(r,this.RowIndex);
316          }
317       }
318    if(!c--) c = a-1; 
319    if(r.firstChild && (!t||r.Expanded)) { var cc = this.ReColorPage(r,noshow,a,b,t?c:null,t); if(t) c = cc; }
320    }
321 return c;
322 }
323 ME.Color;
324 // -----------------------------------------------------------------------------------------------------------
325 // Refreshes row' panel
326 TGP.UpdatePanel = function(row,anim){ 
327 MS.Panel;
328 if(!row) return;   
329 if(!anim) anim = "";
330 var CN = this.ColNames;
331 if(!this.FirstSec) for(var i=0,N=CN[0];i<N.length;i++) if(this.GetType(row,N[i])=="Panel") this.RefreshCellAnimate(row,N[i],anim);
332 if(this.SecCount==3) for(var i=0,N=CN[this.LastSec];i<N.length;i++) if(this.GetType(row,N[i])=="Panel") this.RefreshCellAnimate(row,N[i],anim);
333 for(var i=0,N=CN[1];i<N.length&&i<10;i++) if(this.GetType(row,N[i])=="Panel") this.RefreshCellAnimate(row,N[i],anim); 
334 ME.Panel;   
335 }
336 // -----------------------------------------------------------------------------------------------------------
337 // Refreshes row' panel
338 TGP.UpdateColPanel = function(col){ 
339 MS.Panel;
340 if(!col) return;   
341 for(var r=this.XH.firstChild;r;r=r.nextSibling) if(this.GetType(r,col)=="Panel") this.RefreshCell(r,col);
342 for(var r=this.XF.firstChild;r;r=r.nextSibling) if(this.GetType(r,col)=="Panel") this.RefreshCell(r,col);
343 ME.Panel;   
344 }
345
346 // -----------------------------------------------------------------------------------------------------------
347 // Refreshes Related Enum after change
348 MS.Edit;
349 MS.Enum;
350 TGP.RefreshEnum = function(row,col,anim,updh){
351 if(!anim) anim = "";
352 var ref = this.GetAttr(row,col,"Refresh"); 
353 if(ref){
354    ref = ref.split(',');
355    for(var i=0;i<ref.length;i++) this.RefreshCellAnimate(row,ref[i],anim,updh);
356    }
357 var ref = this.GetAttr(row,col,"Clear");
358 if(ref){
359    ref = ref.split(',');
360    for(var i=0;i<ref.length;i++) {
361       if(row[ref[i]] || row[ref[i]]=='0') {
362          if(this.GetAttr(row,ref[i],"CanEmpty")==1) this.SetValue(row,ref[i],""); 
363          else {
364             var rp = this.GetRelatedPrefix(row,ref[i]), ena = this.GetEnum(row,ref[i],"Enum",rp), eka = this.GetEnum(row,ref[i],"EnumKeys",rp);
365             if(ena){
366                if(!eka && this.IsIndexEnum(Get(row,col),this.IsRange(row,ref[i]),ena)) this.SetValue(row,ref[i],0);
367                else this.SetValue(row,ref[i],(eka?eka:ena).split((eka?eka:ena).charAt(0))[1]);
368                }
369             }
370          }
371       this.RefreshCellAnimate(row,ref[i],anim,updh);
372       }
373    }
374 }
375 ME.Enum;
376 ME.Edit;
377 // -----------------------------------------------------------------------------------------------------------
378 // Obnovi grid, ale neprekresluje ho, kvuli zmenam IE, obcas je opravdu nutne
379
380 TGP.Refresh = function(){
381 MS.FFOnly; MX.FFOnly;
382 if(BIEA && !BIEA10 && !this.Rendering){
383    
384    try { this.BodyMain[1].scrollTop = this.BodyMain[1].scrollTop; } catch(e) { }
385    }
386 ME.FFOnly;
387 }
388 // -----------------------------------------------------------------------------------------------------------
389
390 // -----------------------------------------------------------------------------------------------------------