PageSourceSearch

https://masoncontractors.org/DXR.axd?r=1_231-V3vLw&order=27

js masoncontractors.org collected 2026-10-02 10:15:42 UTC 16,889 bytes, 442 lines download raw bytes

1ASPx.IS(function(ASPx, dx, DevExpress){
2(function() {
3 var Constants = {
4  ALLOWED_CALC_WIDTH_DIFF: 0.5,
5  ALLOWED_RENDER_WIDTH_DIFF: 0.01,
6  MAX_ITERATION_COUNT: 1000
7 };
8 var GridViewColumnAdjustor = ASPx.CreateClass(null, {
9  constructor: function(grid) {
10   this.grid = grid;
11   this.columnInfos = [];
12   this.hasRestrictions = false;
13   this.hasValidColumnWidths = true;
14  },
15  Initialize: function() {
16   if(!this.IsFixedTableLayout())
17    return;
18   this.columnInfos = this.GetColumnInfos();
19   this.hasRestrictions = this.CheckHasRestrictions(this.columnInfos);
20   this.hasValidColumnWidths = this.IsValidGridLayout(this.columnInfos);
21  },
22  GetColumnInfos: function() {
23   var columnInfos = [];
24   var armRow = this.GetMainTableArmRow();
25   var columns = this.grid.columns;
26   for(var i = 0, column; column = columns[i]; i++) {
27    if(!column.visible)
28     continue;
29    var cellIndex = this.grid.GetDataCellIndex(i);
30    if(cellIndex === -1)
31     continue;
32    var armCell = armRow.cells[cellIndex];
33    if(!armCell || armCell.colSpan > 1)
34     continue;
35    var styleWidth = armCell.style.width;
36    var hasPercentageWidth = false;
37    var hasFixedWidth = false;
38    var width = -1;
39    if(styleWidth) {
40     hasPercentageWidth = ASPx.IsPercentageSize(styleWidth);
41     hasFixedWidth = !hasPercentageWidth;
42     width = hasPercentageWidth ? ASPx.PercentageToFloat(styleWidth) : ASPx.PxToInt(styleWidth);
43    }
44    var info = this.CreateColumnInfoObject(i, column, hasPercentageWidth, hasFixedWidth, width);
45    columnInfos.push(info);
46   }
47   return columnInfos;
48  },
49  CheckHasRestrictions: function(columnInfos) {
50   for(var info, i = 0; info = columnInfos[i]; i++) {
51    if(info.minWidth > 0 || info.maxWidth > 0)
52     return true;
53   }
54   return false;
55  },
56  HasRestrictions: function() {
57   return this.hasRestrictions;
58  },
59  IsValidGridLayout: function(columnInfos) {
60   var hasPercWidths = false,
61    hasAutoWidths = false;
62   for(var info, i = 0; info = columnInfos[i]; i++) {
63    if(info.hasPercentageWidth) {
64     if(hasAutoWidths)
65      return false;
66     hasPercWidths = true;
67    }
68    else if(!info.hasFixedWidth) {
69     if(hasPercWidths)
70      return false;
71     hasAutoWidths = true;
72    }
73   }
74   return true;
75  },
76  HasValidColumnWidths: function() {
77   return this.hasValidColumnWidths;
78  },
79  ShouldAdjustColumns: function() {
80   return this.HasRestrictions() && this.HasValidColumnWidths();
81  },
82  IsColumnAdjustmentAllowed: function() {
83   return !this.grid.AllowResizing() && !this.grid.IsResponsiveAdaptivityMode();
84  },
85  TryAdjustColumns: function() {
86   if(!this.ShouldAdjustColumns() || !this.IsColumnAdjustmentAllowed())
87    return false;
88   var savedStyle = this.CollapseTables();
89   var gridWidth = this.GetGridOffsetWidth(); 
90   if(this.grid.HasHorzScroll()) 
91    gridWidth -= ASPx.GetLeftRightBordersAndPaddingsSummaryValue(this.grid.GetMainElement());
92   this.AdjustColumnsCore(this.columnInfos, gridWidth);
93   this.ExpandTables(savedStyle);
94   return true;
95  },
96  AdjustColumnsCore: function(columnInfos, gridWidth) {
97   this.ResetColumnViolations(columnInfos);
98   var resolvedGridInfo = this.CalculateCompleteResolvedColumnInfos(columnInfos, gridWidth);
99   this.ApplyColumnInfosToRender(resolvedGridInfo.columnInfos, resolvedGridInfo.maxWidth);
100  },
101  ResetColumnViolations: function(columnInfos) {
102   for(var info, i = 0; info = columnInfos[i]; i++)
103    info.violation = null;
104  },
105  GetModifiedColumnInfos: function(newColumnInfos, oldColumnInfos) {
106   var result = [];
107   for(var newInfo, i = 0; newInfo = newColumnInfos[i]; i++) {
108    oldInfo = oldColumnInfos[i];
109    if(!this.AreEqualByWidth(newInfo, oldInfo))
110     result.push(newInfo);
111   }
112   return result;
113  },
114  CalculateCompleteResolvedColumnInfos: function(sourceColumnInfos, gridWidth) {
115   var violation = null;
116   var resolvedGridInfo = null;
117   var counter = 0;
118   do {
119    resolvedGridInfo = this.CalculateResolvedGridInfo(gridWidth, sourceColumnInfos);
120    var resolvedGridWidth = ASPx.IsExists(resolvedGridInfo.resolvedWidth) ? resolvedGridInfo.resolvedWidth : gridWidth;
121    var widthInfos = this.CalculateColumnsCurrentWidths(resolvedGridWidth, resolvedGridInfo.columnInfos);
122    violation = this.GetWidthViolation(widthInfos);
123    if(violation)
124     this.ResolveViolation(violation);
125    if(++counter > Constants.MAX_ITERATION_COUNT)
126     throw "GridView column calculation error.";
127   } while(violation);
128   return resolvedGridInfo;
129  },
130  CollapseTables: function() {
131   var styles = [];
132   var cell = this.GetMainElementCell();
133   var style = cell.style;
134   var savedStyle = { display: style.display, width: style.width, height: style.height, overflow: style.overflow };
135   ASPx.SetStyles(cell, { display: "block", width: "0px", height: "0px", overflow: "hidden", maxWidth: "" });
136   styles.push(savedStyle);
137   if(this.IsGridWidthValueSetInPercentage()) {
138    var mainElement = this.grid.GetMainElement();
139    savedStyle = { width: mainElement.style.width };
140    mainElement.style.width = this.grid.percentSizeConfig.width;
141    styles.push(savedStyle);
142   }
143   return styles;
144  },
145  ExpandTables: function(styles) {
146   var cell = this.GetMainElementCell();
147   ASPx.SetStyles(cell, styles[0]);
148   if(this.IsGridWidthValueSetInPercentage())
149    this.grid.GetMainElement().style.width = styles[1].width;
150  },
151  IsGridWidthValueSetInPercentage: function() { return this.grid.widthValueSetInPercentage; },
152  RestoreTableRenderColumnWidths: function(table) {
153   this.ApplyColumnInfosToTable(table, this.columnInfos);
154  },
155  ApplyColumnInfosToTable: function(table, columnInfos) {
156   var armRow = table.rows[0];
157   for(var info, i = 0; info = columnInfos[i]; i++) {
158    if(!info.column) continue;
159    var widthStr = this.GetColumnInfoWidthString(info);
160    var columnIndex = info.column.index;
161    var cellIndex = this.grid.GetDataCellIndex(columnIndex);
162    var armCell = armRow.cells[cellIndex];
163    armCell.style.width = widthStr;
164   }
165  },
166  ApplyColumnInfosToRender: function(columnInfos, maxGridWidth) {
167   var tables = this.grid.GetLayoutHelper().GetAllTables();
168   for(var table, i = 0; table = tables[i]; i++)
169    this.ApplyColumnInfosToTable(table, columnInfos);
170   if(ASPx.IsExists(maxGridWidth))
171    this.grid.GetMainElement().style.maxWidth = maxGridWidth + "px";
172  },
173  ResolveViolation: function(violation) {
174   violation.columnInfo.violation = violation;
175  },
176  GetWidthViolation: function(widthInfos) {
177   var minViolation = null,
178    maxViolation = null,
179    summaryWidthDiff = 0;
180   for(var info, i = 0; info = widthInfos[i]; i++) {
181    var columnInfo = info.columnInfo.sourceColumnInfo || info.columnInfo;
182    if(columnInfo.minWidth > 0) {
183     var widthDiff = columnInfo.minWidth - info.width;
184     if(widthDiff > Constants.ALLOWED_CALC_WIDTH_DIFF) {
185      summaryWidthDiff += widthDiff;
186      if(!minViolation)
187       minViolation = this.CreateViolationObject(true, columnInfo, widthDiff, columnInfo.minWidth);
188      continue;
189     }
190    }
191    if(columnInfo.maxWidth > 0) {
192     var widthDiff = info.width - columnInfo.maxWidth;
193     if(widthDiff > Constants.ALLOWED_CALC_WIDTH_DIFF) {
194      summaryWidthDiff -= widthDiff;
195      if(!maxViolation)
196       maxViolation = this.CreateViolationObject(false, columnInfo, -widthDiff, columnInfo.maxWidth);
197      continue;
198     }
199    }
200   }
201   return summaryWidthDiff >= 0 ? minViolation : maxViolation;
202  },
203  CreateViolationObject: function(minWidthViolation, columnInfo, widthDiff, violatedWidth) {
204   return {
205    minWidthViolation: minWidthViolation,
206    columnInfo: columnInfo,
207    widthDiff: widthDiff,
208    violatedWidth: violatedWidth
209   };
210  },
211  CalculateResolvedGridInfo: function(gridWidth, columnInfos) {
212   var groupedInfos = this.GroupInfosByWidthType(columnInfos);
213   var autoWidthInfos = groupedInfos.autoWidthInfos,
214    fixedWidthInfos = groupedInfos.fixedWidthInfos,
215    percentageWidthInfos = groupedInfos.percentageWidthInfos;
216   if(autoWidthInfos.length > 0 && percentageWidthInfos.length == 0) {
217    return this.CalculateResolvedAutoWidthColumnsGridInfo(gridWidth, columnInfos);
218   }
219   if(autoWidthInfos.length == 0 && fixedWidthInfos.length > 0 && percentageWidthInfos.length == 0) {
220    return this.CalculateResolvedFixedWidthColumnsGridInfo(gridWidth, columnInfos);
221   }
222   if(autoWidthInfos.length == 0 && percentageWidthInfos.length > 0) {
223    return this.CalculateResolvedPercentageWidthColumnsGridInfo(gridWidth, columnInfos);
224   }
225   return null;
226  },
227  CalculateResolvedPercentageWidthColumnsGridInfo: function(gridWidth, columnInfos) {
228   var result = { columnInfos: [] };
229   var fixedColumnCount = 0;
230   var fixedWidthSummary = 0;
231   var percWidthSummary = 0;
232   for(var info, i = 0; info = columnInfos[i]; i++) {
233    if(info.hasFixedWidth || info.violation) {
234     fixedColumnCount++;
235     fixedWidthSummary += info.hasFixedWidth ? info.width : info.violation.violatedWidth;
236    }
237    else
238     percWidthSummary += info.width;
239   }
240   var percColumnSummaryWidth = gridWidth - fixedWidthSummary;
241   var percColumnCount = columnInfos.length - fixedColumnCount;
242   if(percColumnSummaryWidth > 0 && percColumnCount == 0)
243    result.maxWidth = result.resolvedWidth = fixedWidthSummary;
244   if(percWidthSummary == 0)
245    percWidthSummary = 1;
246   for(var info, i = 0; info = columnInfos[i]; i++) {
247    var hasFixedWidth = true;
248    var width = info.width;
249    if(info.violation)
250     width = info.violation.violatedWidth;
251    else if(!info.hasFixedWidth) {
252     hasFixedWidth = false;
253     width = info.width / percWidthSummary;
254    }
255    var columnInfo = this.CreateColumnInfoObject(info.index, info.column, !hasFixedWidth, hasFixedWidth, width, info);
256    result.columnInfos.push(columnInfo);
257   }
258   return result;
259  },
260  CalculateResolvedFixedWidthColumnsGridInfo: function(gridWidth, columnInfos) {
261   var result = { columnInfos: [] };
262   var violatedWidthSummary = 0;
263   var violatedColumnCount = 0;
264   var normalColumnMinSummaryWidth = 0;
265   for(var info, i = 0; info = columnInfos[i]; i++) {
266    if(info.violation) {
267     violatedWidthSummary += info.violation.violatedWidth;
268     violatedColumnCount++;
269    }
270    else
271     normalColumnMinSummaryWidth += info.width;
272   }
273   var newMinGridWidth = violatedWidthSummary + normalColumnMinSummaryWidth;
274   if(gridWidth <= newMinGridWidth) {
275    for(var info, i = 0; info = columnInfos[i]; i++) {
276     var columnInfo = this.CreateColumnInfoObject(info.index, info.column, false, true, info.width, info);
277     result.columnInfos.push(columnInfo);
278    }
279    return result;
280   }
281   else if(violatedColumnCount == columnInfos.length)
282    result.maxWidth = result.resolvedWidth = gridWidth = violatedWidthSummary;
283   var normalColumnSummaryWidth = gridWidth - violatedWidthSummary;
284   var normalColumnSummaryPart = normalColumnSummaryWidth / gridWidth;
285   var violatedColumnSummaryPart = 1 - normalColumnSummaryPart;
286   for(var info, i = 0; info = columnInfos[i]; i++) {
287    var part = info.violation
288     ? (info.violation.violatedWidth / violatedWidthSummary) * violatedColumnSummaryPart
289     : (info.width / normalColumnMinSummaryWidth) * normalColumnSummaryPart;
290    var width = part * gridWidth;
291    var columnInfo = this.CreateColumnInfoObject(info.index, info.column, false, true, width, info);
292    result.columnInfos.push(columnInfo);
293   }
294   return result;
295  },
296  CalculateResolvedAutoWidthColumnsGridInfo: function(gridWidth, columnInfos) {
297   var result = { columnInfos: [] };
298   var fixedColumnCount = 0;
299   var fixedWidthSummary = 0;
300   for(var info, i = 0; info = columnInfos[i]; i++) {
301    if(info.hasFixedWidth || info.violation) {
302     fixedColumnCount++;
303     fixedWidthSummary += info.hasFixedWidth ? info.width : info.violation.violatedWidth;
304    }
305   }
306   var autoColumnSummaryWidth = gridWidth - fixedWidthSummary;
307   var autoColumnCount = columnInfos.length - fixedColumnCount;
308   var autoWidth = 0;
309   if(autoColumnSummaryWidth > 0) {
310    if(autoColumnCount > 0)
311     autoWidth = autoColumnSummaryWidth / autoColumnCount;
312    else
313     result.maxWidth = result.resolvedWidth = fixedWidthSummary;
314   }
315   for(var info, i = 0; info = columnInfos[i]; i++) {
316    var hasFixedWidth = !!info.violation || info.hasFixedWidth;
317    var width = autoWidth;
318    if(info.hasFixedWidth && !info.violation)
319     width = info.width;
320    else if(info.violation)
321     width = info.violation.violatedWidth;
322    var columnInfo = this.CreateColumnInfoObject(info.index, info.column, false, hasFixedWidth, width, info);
323    result.columnInfos.push(columnInfo);
324   }
325   return result;
326  },
327  CalculateColumnsCurrentWidths: function(gridWidth, columnInfos) {
328   var groupedInfos = this.GroupInfosByWidthType(columnInfos);
329   var autoWidthInfos = groupedInfos.autoWidthInfos,
330    fixedWidthInfos = groupedInfos.fixedWidthInfos,
331    percentageWidthInfos = groupedInfos.percentageWidthInfos;
332   var result = [];
333   if(percentageWidthInfos.length > 0 && autoWidthInfos.length > 0)
334    return null;
335   var fixedWidthSum = 0;
336   for(var info, i = 0; info = fixedWidthInfos[i]; i++)
337    fixedWidthSum += info.width;
338   if(fixedWidthInfos.length == columnInfos.length) {
339    var coefficient = 1;
340    if(fixedWidthSum > 0)
341     coefficient = gridWidth / fixedWidthSum;
342    if(coefficient < 1)
343     coefficient = 1;
344    for(var info, i = 0; info = fixedWidthInfos[i]; i++) {
345     var width = coefficient * info.width;
346     var widthInfo = this.CreateWidthInfoObject(width, info);
347     result.push(widthInfo);
348    }
349   }
350   else {
351    var flexWidthSum = gridWidth - fixedWidthSum;
352    var autoWidthColumnWidth = 0;
353    if(autoWidthInfos.length > 0 && flexWidthSum > 0)
354     autoWidthColumnWidth = flexWidthSum / autoWidthInfos.length;
355    var percWidthColumnSum = 0;
356    for(var info, i = 0; info = percentageWidthInfos[i]; i++)
357     percWidthColumnSum += info.width;
358    if(percWidthColumnSum == 0)
359     percWidthColumnSum = 1;
360    for(var info, i = 0; info = columnInfos[i]; i++) {
361     var width = info.width;
362     if(info.hasPercentageWidth)
363      width = flexWidthSum * info.width / percWidthColumnSum;
364     else if(!info.hasFixedWidth)
365      width = autoWidthColumnWidth;
366     var widthInfo = this.CreateWidthInfoObject(width, info);
367     result.push(widthInfo);
368    }
369   }
370   return result;
371  },
372  GetColumnInfoWidthString: function(columnInfo) {
373   if(columnInfo.hasFixedWidth)
374    return columnInfo.width + "px";
375   else if(columnInfo.hasPercentageWidth)
376    return (columnInfo.width * 100) + "%";
377   else
378    return "";
379  },
380  AreEqualByWidth: function(columnInfo1, columnInfo2) {
381   return columnInfo1.hasFixedWidth === columnInfo2.hasFixedWidth &&
382    columnInfo1.hasPercentageWidth === columnInfo2.hasPercentageWidth &&
383    (!columnInfo1.hasFixedWidth && !columnInfo1.hasPercentageWidth ||
384     Math.abs(columnInfo1.width - columnInfo2.width) < Constants.ALLOWED_RENDER_WIDTH_DIFF);
385  },
386  CreateWidthInfoObject: function(width, columnInfo) {
387   return {
388    width: width,
389    columnInfo: columnInfo
390   };
391  },
392  CreateColumnInfoObject: function(index, column, hasPercentageWidth, hasFixedWidth, width, sourceColumnInfo) {
393   return {
394    index: index,
395    column: column,
396    hasPercentageWidth: hasPercentageWidth,
397    hasFixedWidth: hasFixedWidth,
398    width: width,
399    minWidth: column ? column.minWidth : 0,
400    maxWidth: column ? column.maxWidth : 0,
401    sourceColumnInfo: sourceColumnInfo
402   };
403  },
404  GroupInfosByWidthType: function(infos) {
405   var autoWidthInfos = [],
406    fixedWidthInfos = [],
407    percentageWidthInfos = [],
408    violatedWidthInfos = [];
409   for(var i = 0, info; info = infos[i]; i++) {
410    if(info.hasFixedWidth)
411     fixedWidthInfos.push(info);
412    else if(info.hasPercentageWidth)
413     percentageWidthInfos.push(info);
414    else
415     autoWidthInfos.push(info);
416    if(info.violation)
417     violatedWidthInfos.push(info);
418   }
419   return {
420    autoWidthInfos: autoWidthInfos,
421    fixedWidthInfos: fixedWidthInfos,
422    percentageWidthInfos: percentageWidthInfos,
423    violatedWidthInfos: violatedWidthInfos
424   };
425  },
426  GetGridOffsetWidth: function() {
427   return this.grid.GetMainElement().offsetWidth;
428  },
429  GetMainTableArmRow: function () {
430   return this.grid.GetMainTable().rows[0];
431  },
432  GetMainElementCell: function() {
433   return this.grid.GetLayoutHelper().GetMainElementCell();
434  },
435  IsFixedTableLayout: function() {
436   return this.grid.GetLayoutHelper().IsFixedTableLayout();
437  }
438 });
439 ASPx.GridViewColumnAdjustor = GridViewColumnAdjustor;
440})();
441
442},27);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.