PageSourceSearch

https://www.netokuskolinn.is/DXR.axd?r=1_186-en7Np

js netokuskolinn.is collected 2026-10-02 22:41:40 UTC 258,656 bytes, 6,524 lines download raw bytes

1(function() {
2var serializingSeparator = "|";
3var serializingSeparatorLength = serializingSeparator.length;
4var lbIPostfixes = ['C', 'I', 'T'];
5var lbIIdSuffix = "LBI";
6var lbSIIdSuffix = lbIIdSuffix + "-1";
7var lbAIRIdSuffix = "AIR";
8var lbAIRTIdSuffix = lbAIRIdSuffix + "-1";
9var lbTSIdSuffix = "_TS";
10var lbBSIdSuffix = "_BS";
11var lbHeaderDivIdSuffix = "_H";
12var lTableIdSuffix = "_LBT";
13var leVISuffix = "_VI";
14var lbDSuffix = "_D";
15var emptyItemsRange = "0:-1";
16var nbsp = " ";
17var nameSeparator = "_";
18var nbspChar = String.fromCharCode(160);
19var NullSizeCellClassName = "dxlbNullSizeCell";
20var itemCellTextAttributeName = "data-item-cell-text";
21var itemSerializedTextsAttributeName = "data-item-serialized-texts";
22var FIRST_CELL_MARKER_CSS_CLASS_NAME = "dxeFTM";
23var LAST_CELL_MARKER_CSS_CLASS_NAME = "dxeLTM";
24var selectAllMainElementID = "LBSAME";
25var selectAllCheckBoxID = "LBSACB";
26var filterMainElementID = "LBF";
27var filteringTextBoxID = "LBFE";
28var showFilterButtonID = "LBSFEB";
29var inactiveFilterElementClassName = "dxeLBInactiveFilterPanelSys";
30var listTableCollapsedClassName = "dxeLBTCollapsed";
31var ListBoxSelectionMode = { Single : 0, Multiple : 1, CheckColumn : 2 };
32var ListBoxVirtualScrollTableContainerIDPostfix = "LBVSTC";
33var CONSTANTS = {
34 CALLBACK_PREFIXES: {
35  CUSTOM: "LECC",
36  CUSTOMPERFORM: "LECCP",
37  LOAD_RANGE_ITEMS: "LBCRI",
38  FILTERING: "CBLF",
39  FILTERING_CORRECT: "CBCF"
40 },
41 CALLBACK_RESULTS: {
42  ITEMS: "i",
43  FILTER_CUSTOMHIGHLIGHTING: "fCH",
44  FILTER_LENGTH: "fL"
45 }
46};
47var ListBoxStateControllerManagerBase = ASPx.CreateClass(null, {
48 constructor: function(listBox) {
49  this.listBox = listBox;
50 },
51 Initialize: function() {
52  this.AddStateItems(false, false);
53 },
54 AddStateItems: function(clearCache, hoverItemOnly) {
55  if(typeof (ASPx.GetStateController) !== "undefined") {
56   var itemCellsIdSuffixes = this.listBox.GetItemCellsIdPostfixes();
57   this.AddStateItemsCore(ASPx.GetStateController(), clearCache, itemCellsIdSuffixes, hoverItemOnly);
58  }
59 },
60 AddStateItemsCore: function(controller, clearCache, itemCellsIdSuffixes, hoverItemOnly) {
61  if(this.HasSampleItemStateItems())
62   this.AddItemStateItems(controller, clearCache, itemCellsIdSuffixes, hoverItemOnly,-1);
63 },
64 AddItemStateItems: function(controller, clearCache, itemCellsIdSuffixes, hoverItemOnly, index) {
65  var name = this.listBox.name + "_" + lbIIdSuffix + index;
66  if(clearCache)
67   this.listBox.ClearStateItemCache(controller, name, itemCellsIdSuffixes);
68  if(!ASPx.Browser.WebKitTouchUI)
69   controller.AddHoverItem(name, this.listBox.hoverClasses, this.listBox.hoverCssArray, itemCellsIdSuffixes, null, null, true);
70  if(!hoverItemOnly) {
71   controller.AddSelectedItem(name, this.listBox.selectedClasses, this.listBox.selectedCssArray, itemCellsIdSuffixes, null, null, true);
72   controller.AddDisabledItem(name, this.listBox.disabledClasses, this.listBox.disabledCssArray, itemCellsIdSuffixes, null, null, true);
73  }
74 },
75 RemoveHoverStateItem: function() {
76  if(typeof (ASPx.GetStateController) !== "undefined") {
77   var itemCellsIdSuffixes = this.listBox.GetItemCellsIdPostfixes();
78   this.RemoveHoverStateItemCore(ASPx.GetStateController(), itemCellsIdSuffixes);
79  }
80 },
81 RemoveHoverStateItemCore: function(controller, itemCellsIdSuffixes) {
82  if(this.HasSampleItemStateItems())
83   this.RemoveItemStateHoverItem(controller, itemCellsIdSuffixes, -1);
84 },
85 RemoveItemStateHoverItem: function(controller, itemCellsIdSuffixes, index) {
86  var name = this.listBox.name + "_" + lbIIdSuffix + index;
87  this.listBox.ClearStateItemCache(controller, name, itemCellsIdSuffixes);
88  if(!ASPx.Browser.WebKitTouchUI)
89   controller.RemoveHoverItem(name, itemCellsIdSuffixes);
90 },
91 HasSampleItemStateItems: function() {
92  return this.listBox.hasSampleItem;
93 },
94});
95var VirtualRenderListBoxStateControllerManager = ASPx.CreateClass(ListBoxStateControllerManagerBase, {
96 constructor: function(listBox, virtualRenderItemsManager) {
97  this.constructor.prototype.constructor.call(this, listBox);
98  this.virtualRenderItemsManager = virtualRenderItemsManager;
99 },
100 AddStateItemsCore: function(controller, clearCache, itemCellsIdSuffixes, hoverItemOnly) {
101  ListBoxStateControllerManagerBase.prototype.AddStateItemsCore.call(this, controller, clearCache, itemCellsIdSuffixes, hoverItemOnly);
102  var range = this.virtualRenderItemsManager.GetRenderedItemRange();
103  for(var i = range.startIndex;i <= range.endIndex;i++) {
104   if(i >= 0)
105    this.AddItemStateItems(controller, clearCache, itemCellsIdSuffixes, hoverItemOnly, i);
106  }
107 },
108 RemoveHoverStateItemCore: function(controller, itemCellsIdSuffixes) {
109  ListBoxStateControllerManagerBase.prototype.RemoveHoverStateItemCore.call(this, controller, itemCellsIdSuffixes);
110  var range = this.virtualRenderItemsManager.GetRenderedItemRange();
111  for(var i = range.startIndex; i <= range.endIndex; i++) {
112   if(i >= 0)
113    this.RemoveItemStateHoverItem(controller, itemCellsIdSuffixes, i);
114  }
115 },
116});
117var DefaultListBoxStateControllerManager = ASPx.CreateClass(ListBoxStateControllerManagerBase, {
118 constructor: function(listBox) {
119  this.constructor.prototype.constructor.call(this, listBox);
120 },
121 AddStateItemsCore: function(controller, clearCache, itemCellsIdSuffixes, hoverItemOnly) {
122  ListBoxStateControllerManagerBase.prototype.AddStateItemsCore.call(this, controller, clearCache, itemCellsIdSuffixes, hoverItemOnly);
123  var count = this.listBox.GetItemCount();
124  for(var i = 0;i < count;i++)
125   this.AddItemStateItems(controller, clearCache, itemCellsIdSuffixes, hoverItemOnly, i);
126 },
127 RemoveHoverStateItemCore: function(controller, itemCellsIdSuffixes) {
128  ListBoxStateControllerManagerBase.prototype.RemoveHoverStateItemCore.call(this, controller, itemCellsIdSuffixes);
129  var count = this.GetItemCount();
130  for(var i = 0; i < count; i++)
131   this.RemoveItemStateHoverItem(controller, itemCellsIdSuffixes, i);
132 },
133});
134var ListBoxItemsManagerBase = ASPx.CreateClass(null, {
135 constructor: function(listBox) {
136  this.listBox = listBox;
137  this.listTable = listBox.GetListTable();
138 },
139 Initialize: function() {
140 },
141 GetListTableRows: function() {
142  return this.listTable ? this.listTable.rows : [];
143 },
144 GetItemHtmlContent: function(index) { return null; },
145 GetItem: function () { return null; },
146 GetItemIndexByRow: function (itemRow) { return null; },
147 GetItemCount: function () { return 0; },
148 GetItemRow: function (index) {
149  if (this.listTable && index >= 0) {
150   var rowIndex = this.ConvertItemIndexToRowIndex(index);
151   var itemRow = this.listTable.rows[rowIndex];
152   if (itemRow && ASPx.ElementContainsCssClass(itemRow, "dxeListBoxItemRow"))
153    return itemRow;
154  }
155  return null;
156 },
157 GetItemElement: function (index) {
158  var result = null;
159  var itemRow = this.GetItemRow(index);
160  if (itemRow)
161   result = this.GetFirstVisibleCell(itemRow) || itemRow.cells[0];
162  return result;
163 },
164 GetFirstVisibleCell: function (itemRow) {
165  for (var i = 0; i < itemRow.cells.length; i++)
166   if (ASPx.GetElementDisplay(itemRow.cells[i]))
167    return itemRow.cells[i];
168  return null;
169 },
170 GetItemHeight: function(index) {
171  throw new Error("this method is abstract");
172 },
173 GetTotalItemsHeight: function(firstItemIndex, lastItemIndex) {
174  throw new Error("this method is abstract");
175 },
176 GetItemsHeight: function() { return 0; },
177 GetItemsWidth: function() { return 0; },
178 GetVisibleItemCount: function () { return 0; },
179 GetTopSpacersHeight: function() {
180  return this.listBox.GetTopScrollSpacerHeight();
181 },
182 GetItemTopOffset: function(index) {
183  return this.GetItemTopOffsetCore(index);
184 },
185 GetItemTopOffsetCore: function(index) {
186  var itemElement = this.GetItemElement(index);
187  return itemElement ? itemElement.offsetTop + this.GetTopSpacersHeight() : 0;
188 },
189 IsItemVisible: function(index) {
190  return this.IsItemEdgeVisible(index, true, true);
191 },
192 IsItemEdgeVisible: function(index, checkTop, checkBottom) {
193  var result = false;
194  var itemElement = this.GetItemElement(index);
195  if(itemElement != null) {
196   var scrollDiv = this.listBox.GetScrollDivElement();
197   var topScrollDivEdge = scrollDiv.scrollTop;
198   var bottomScrollDivEdge = scrollDiv.scrollTop + scrollDiv.clientHeight;
199   var topItemElementEdge = this.GetItemTopOffset(index);
200   var bottomItemElementEdge = topItemElementEdge + itemElement.getBoundingClientRect().height;
201   var checkTopVisibleResult = !checkTop || this.IsVisibleOffset(topItemElementEdge, topScrollDivEdge, bottomScrollDivEdge);
202   var checkBottomVisibleResult = !checkBottom || this.IsVisibleOffset(bottomItemElementEdge, topScrollDivEdge, bottomScrollDivEdge);
203   result = checkTopVisibleResult && checkBottomVisibleResult;
204  }
205  return result;
206 },
207 IsVisibleOffset: function(offset, topScrollDivEdge, bottomScrollDivEdge) {
208  return offset >= topScrollDivEdge && offset <= bottomScrollDivEdge;
209 },
210 GetFirstVisibleItem: function () { return null; },
211 GetFirstVisibleItemRow: function() {
212  var firstVisibleItemIndex = this.GetFirstVisibleItem();
213  return this.listTable.rows[this.ConvertItemIndexToRowIndex(firstVisibleItemIndex)];
214 },
215 GetFirstRenderedItem: function () { },
216 GetLastRenderedItem: function () { },
217 InitializeInternalCheckBoxCollection: function () { },
218 GetScrollDivChildElementHeight: function () { return null; },
219 RemoveItem: function(index) { this.RemoveItemCore(index); },
220 RemoveItemCore: function(index) {
221  this.listBox.RemoveItemRow(index);
222 },
223 InsertItem: function () { },
224 CreateNewItemRow: function (index) {
225  var newItemRow = this.listBox.GetSampleItemRow();
226  if (ASPx.IsExistsElement(newItemRow))
227   newItemRow = newItemRow.cloneNode(true);
228  return newItemRow;
229 },
230 ClearItems: function () {
231  this.ClearItemsCore();
232 },
233 ClearItemsCore: function() {
234  var tBody = this.listBox.GetListTableRowParent();
235  tBody.innerHTML = "";
236 },
237 IsItemFiltered: function (index) { return false; },
238 ConvertItemIndexToRowIndex: function () { return null; },
239 Adjust: function () { },
240 BeforeClientFiltering: function () { },
241 ApplyFilterToItem: function (index, isSatisfy, savePrevState, isFilterReset) { },
242 RestorePrevFilteredState: function (index) { },
243 OnEndItemsFiltering: function () { },
244 ChangeItemsFilteredState: function(action) {
245  var count = this.GetItemCount();
246  for (var i = 0; i < count; i++) {
247   action(i);
248   this.AfterChangeItemFilteredStateAction(i);
249  }
250 },
251 AfterChangeItemFilteredStateAction: function() { },
252 MakeAllItemsVisible: function () {
253  this.ChangeItemsFilteredState(function (index) {
254   this.ApplyFilterToItem(index, true, false, true);
255  }.aspxBind(this));
256 },
257 MakeItemVisibleAtTop: function(index) {
258  var scrollDiv = this.listBox.GetScrollDivElement();
259  scrollDiv.scrollTop = this.GetItemTopOffset(index);
260 },
261 MakeItemVisible: function(index) { 
262  if(!this.IsItemVisible(index)) {
263   var scrollDiv = this.listBox.GetScrollDivElement();
264   var scrollTop = scrollDiv.scrollTop;
265   var scrollDivHeight = scrollDiv.clientHeight;
266   var itemOffsetTop = this.GetItemTopOffset(index);
267   var itemHeight = this.GetItemHeight(index);
268   var itemAbove = scrollTop > itemOffsetTop;
269   var itemBelow = scrollTop + scrollDivHeight < itemOffsetTop + itemHeight;
270   if(itemAbove) {
271    this.MakeItemVisibleAtTop(index);
272   }
273   else if(itemBelow) {
274    var scrollDivChildElementHeight = this.listBox.GetScrollDivChildElementHeight();
275    var scrollPaddings = scrollDiv.scrollHeight - scrollDivChildElementHeight;
276    scrollDiv.scrollTop = itemOffsetTop + itemHeight - scrollDivHeight + scrollPaddings;
277   }
278  }
279 },
280 RewriteFilteredItemIndices: function(newFilteredItemIndices) { },
281 OnScrollSpacerVisibilityChanged: function () { },
282 SetItemHtml: function (index, html) { },
283 SetItemTooltip: function(index, tooltip) { },
284 SetItemAttribute: function(index, attrName, attrValue) { },
285 AddItemCssClass: function (index, className) { },
286 RemoveItemCssClass: function (index, className) { },
287 SetItemTextCellHtml: function (itemIndex, textCellIndex, html) { },
288 SetItemTextCellTooltip: function(itemIndex, textCellIndex, tooltip) { },
289 SetItemTextCellAttribute: function(itemIndex, textCellIndex, attrName, attrValue) { },
290 AddItemTextCellCssClass: function (itemIndex, textCellIndex, className) { },
291 RemoveItemTextCellCssClass: function (itemIndex, textCellIndex, className) { },
292 OnDecoratedItemsRendering: function () { },
293 DeactivateScrollHandler: function() { },
294 ActivateScrollHandler: function() { },
295 IsScrollActivated: function() { return true; },
296 BeginUpdate: function() { },
297 EndUpdate: function() { }
298});
299var ListBoxItemsDefaultManager = ASPx.CreateClass(ListBoxItemsManagerBase, {
300 constructor: function (listBox) {
301  this.constructor.prototype.constructor.call(this, listBox);
302 },
303 GetItemIndexByRow: function (itemRow) {
304  var result = itemRow.rowIndex;
305  if (this.listBox.ContainsFixWidthRow())
306   result--;
307  return result;
308 },
309 GetItemCount: function () {
310  if (this.listTable) {
311   var rowLength = this.listTable.rows.length;
312   if (!!this.listBox.GetAccessibilityHeaderRow())
313    rowLength--;
314   if (this.listBox.ContainsFixWidthRow())
315    rowLength--;
316   return rowLength;
317  }
318  return 0;
319 },
320 GetItem: function (index) {
321  var rowLength = this.GetItemCount();
322  if (!this.listTable || index < 0 || index >= rowLength)
323   return null;
324  var row = this.listBox.GetItemRow(index);
325  var image = this.listBox.imageCellExists ? ASPx.GetNodeByTagName(row.cells[this.listBox.GetImageCellIndex()], "IMG", 0) : null;
326  var src = image == null ? "" : ASPx.ImageUtils.GetImageSrc(image);
327  var itemValue = this.listBox.itemsValue[index] !== undefined ? this.listBox.itemsValue[index] : null;
328  return new ASPxClientListBoxItem(this.listBox, index, this.listBox.GetItemRowTexts(row), itemValue, src, this.listBox.GetIsItemSelected(index));
329 },
330 GetVisibleItemCount: function () {
331  var count = this.GetItemCount();
332  var visibleItemCount = 0;
333  for (var i = 0; i < count; i++) {
334   if (ASPx.GetElementDisplay(this.GetItemRow(i)))
335    visibleItemCount++;
336  }
337  return visibleItemCount;
338 },
339 GetFirstVisibleItem: function () {
340  var itemCount = this.GetItemCount();
341  for (var i = 0; i < itemCount; i++)
342   if (this.GetItemRow(i) && this.IsItemFiltered(i))
343    return i;
344  return -1;
345 },
346 GetFirstFilteredItemIndex: function () {
347  return this.GetFirstVisibleItem();
348 },
349 GetLastFilteredItemIndex: function() {
350  var itemCount = this.GetItemCount();
351  for(var i = itemCount - 1; i >= 0; i--)
352   if(this.GetItemRow(i) && this.IsItemFiltered(i))
353    return i;
354  return -1;
355 },
356 GetNextFilteredItemIndex: function(currentIndex) {
357  var itemCount = this.GetItemCount();
358  for(var i = currentIndex + 1; i < itemCount; i++)
359   if(this.GetItemRow(i) && this.IsItemFiltered(i))
360    return i;
361  return -1;
362 },
363 GetPrevFilteredItemIndex: function(currentIndex) {
364  for(var i = currentIndex - 1; i >= 0; i--)
365   if(this.GetItemRow(i) && this.IsItemFiltered(i))
366    return i;
367  return -1;
368 },
369 GetFirstRenderedItem: function () {
370  return this.GetItemCount() > 0 ? this.GetItem(0) : null;
371 },
372 GetLastRenderedItem: function () {
373  return this.GetItemCount() > 0 ? this.GetItem(this.GetItemCount() - 1) : null;
374 },
375 ConvertItemIndexToRowIndex: function (itemIndex) {
376  return this.listBox.ContainsFixWidthRow() ? itemIndex + 1 : itemIndex;
377 },
378 GetScrollDivChildElementHeight: function () {
379  return this.listBox.GetListTableHeight() + this.listBox.GetTopScrollSpacerHeight() + this.listBox.GetBottomScrollSpacerHeight();
380 },
381 IsItemFiltered: function (index) {
382  return ASPx.GetElementDisplay(this.GetItemRow(index));
383 },
384 InsertItem: function (index, itemProperties) {
385  this.listBox.InsertItemRow(index, itemProperties);
386 },
387 InitializeInternalCheckBoxCollection: function () {
388  var count = this.GetItemCount();
389  var enabled = this.listBox.GetEnabled();
390  var changeEventMethod = ASPx.Attr.ChangeEventsMethod(enabled);
391  for (var i = 0; i < count; i++)
392   this.listBox.AddInternalCheckBoxToCollectionCore(i, enabled, changeEventMethod);
393 },
394 ApplyFilterToItem: function (index, isSatisfy, savePrevState, isFilterReset) {
395  var itemRow = this.GetItemRow(index);
396  if (savePrevState) {
397   var newDisplayValue = isSatisfy ? "" : "none";
398   ASPx.Attr.ChangeStyleAttribute(itemRow, "display", newDisplayValue);
399  }
400  else
401   ASPx.SetElementDisplay(itemRow, isSatisfy);
402 },
403 RestorePrevFilteredState: function (index) {
404  ASPx.Attr.RestoreStyleAttribute(this.GetItemRow(index), "display");
405 },
406 GetItemsHeight: function () {
407  return this.listBox.GetListTableHeight();
408 },
409 GetTotalItemsHeight: function(firstItemIndex, lastItemIndex) {
410  var result = 0;
411  var rows = Array.prototype.slice.call(this.listTable.rows);
412  var visibleRowsIndexes = [];
413  rows.forEach(function(row, index) {
414   if(ASPx.GetElementDisplay(row))
415    visibleRowsIndexes.push(index);
416  });
417  if(firstItemIndex > visibleRowsIndexes.length)
418   lastItemIndex = visibleRowsIndexes.length - 1;
419  if(lastItemIndex > visibleRowsIndexes.length)
420   lastItemIndex = visibleRowsIndexes.length - 1;
421  for(var i = firstItemIndex;i <= lastItemIndex;i++)
422   result += this.GetItemHeight(visibleRowsIndexes[i]);
423  return result;
424 },
425 GetItemHeight: function(index) {
426  if((isNaN(index))) throw new Error("index must be a number");
427  var itemElement = this.GetItemElement(index);
428  return itemElement != null ? itemElement.getBoundingClientRect().height : 0;
429 },
430 GetItemsWidth: function() {
431  return this.listTable.offsetWidth;
432 },
433 GetNewItemIndexInFilteredRange: function(selectedIndex, step) {
434  var rows = Array.prototype.slice.call(this.listTable.rows);
435  var filteredRows = rows.filter(function(row) { 
436   return ASPx.GetElementDisplay(row);
437  });
438  var selectedRow = this.GetItemRow(selectedIndex);
439  var itemIndexInFilteredRange = ASPx.Data.ArrayIndexOf(filteredRows, selectedRow);
440  var newItemIndexInFilteredRange = itemIndexInFilteredRange + step;
441  if(newItemIndexInFilteredRange >= filteredRows.length)
442   newItemIndexInFilteredRange = filteredRows.length - 1;
443  else if(newItemIndexInFilteredRange < 0)
444   newItemIndexInFilteredRange = 0;
445  var newSelectedRow = filteredRows[newItemIndexInFilteredRange];
446  return this.GetItemIndexByRow(newSelectedRow);
447 }
448});
449var ListBoxItemsVirtualManager = ASPx.CreateClass(ListBoxItemsManagerBase, {
450 constructor: function(listBox) {
451  this.constructor.prototype.constructor.call(this, listBox);
452  this.smallestItemHeight = 0;
453  this.smallestItemWidth = 0;
454  this.previousScrollPosition = 0;
455 },
456 Initialize: function () {
457  ListBoxItemsManagerBase.prototype.Initialize.call(this);
458  this.virtualScrollTopInvisibleItemsCount = 1;
459  this.virtualScrollBottomInvisibleItemsCount = 1;
460  this.showFilterButtonWidthCounted = false;
461  this.isScrollProcessingActivated = true;
462  this.InitializeItemRows();
463  this.virtualScrollVisibleItemIndices = [];
464  this.updateSmallestItemSize();
465  this.UpdateScrollTableContainerHeight();
466 },
467 GetItemIndexByRow: function (itemRow) {
468  return itemRow.itemIndex;
469 },
470 GetItemCount: function () {
471  return this.deserializedItems.length;
472 },
473 GetItem: function(index, preventEncodeText) {
474  if (index < 0 || index >= this.GetItemCount())
475   return null;
476  var deserializedItem = this.deserializedItems[index];
477  var itemTexts = this.AdjustItemTexts(deserializedItem, preventEncodeText);
478  var result = new ASPxClientListBoxItem(this.listBox, index, itemTexts, deserializedItem.value,
479   deserializedItem.imageUrl, this.listBox.GetIsItemSelected(index));
480  result.insertOrderIndex = deserializedItem.insertOrderIndex;
481  return result;
482 },
483 GetItemHtmlContent: function(index) {
484  return this.deserializedItems[index] && this.deserializedItems[index].htmlContent;
485 },
486 AdjustItemTexts: function (item, preventEncodeText) {
487  var itemInnerTexts = this.GetItemInnerTexts(item, preventEncodeText);
488  if (this.listBox.IsMultiColumn()) {
489   for (var i = itemInnerTexts.length; i < this.listBox.columnFieldNames.length; i++)
490    itemInnerTexts.push("");
491  }
492  return itemInnerTexts;
493 },
494 GetItemInnerTexts: function(item, preventEncodeText) {
495  if(!item.texts)
496   return item.texts;
497  var adjustedItemTexts = [];
498  for(var i = 0; i < item.texts.length; i++) {
499   var itemText = item.texts[i] || "";
500   if(!this.listBox.encodeHtml && !preventEncodeText)
501    itemText = this.GetEncodedItemInnerText(itemText);
502   adjustedItemTexts[i] = itemText;
503  }
504  return adjustedItemTexts;
505 },
506 GetEncodedItemInnerText: function(itemText) {
507  var result = itemText;
508  var encodedItemText = ASPx.Str.EncodeHtml(itemText);
509  if(itemText !== encodedItemText) {
510   var div = document.createElement("DIV");
511   ASPx.SetInnerHtml(div, itemText);
512   result = ASPx.GetInnerText(div);
513  }
514  return result;
515 },
516 GetVisibleItemCount: function () {
517  return this.filteredItemIndices.length;
518 },
519 GetItemsHeight: function () {
520  var result = 0;
521  ASPx.Data.ForEach(this.filteredItemIndices, function(itemIndex) {
522   result += this.GetItemHeight(itemIndex);
523  }.bind(this));
524  return result;
525 },
526 GetTotalItemsHeight: function(firstItemIndex, lastItemIndex) {
527  var result = 0;
528  if(lastItemIndex >= this.filteredItemIndices.length)
529   lastItemIndex = this.filteredItemIndices.length - 1;
530  for(var i = firstItemIndex;i <= lastItemIndex;i++) {
531   result += this.GetItemHeight(this.filteredItemIndices[i]);
532  }
533  return result;
534 },
535 GetItemHeight: function(index) {
536  return this.deserializedItems[index].calculatedHeight ? this.deserializedItems[index].calculatedHeight : this.smallestItemHeight;
537 },
538 GetItemsWidth: function() {
539  var listTableOffsetWidth = this.listTable.offsetWidth;
540  var showFilterButton = this.listBox.GetShowFilterButton();
541  if(showFilterButton && !this.showFilterButtonWidthCounted) {
542   listTableOffsetWidth += showFilterButton.GetMainElement().offsetWidth;
543   this.showFilterButtonWidthCounted = true;
544  } 
545  var itemsWidth = this.UseVirtualItemWidth() ?
546   Math.max(this.visibleItemTextMaxWidth + this.smallestItemWidth, listTableOffsetWidth)
547   : listTableOffsetWidth;
548  return itemsWidth;
549 },
550 UseVirtualItemWidth: function() {
551  return !this.IsFixedWidth() && !this.listBox.hasDecoratedItems && !this.IsItemTextWrapEnabled();
552 },
553 IsFixedWidth: function() {
554  return this.listBox.IsMultiColumn() || this.IsStandaloneListBoxWithFixedWidth();
555 },
556 IsStandaloneListBoxWithFixedWidth: function() {
557  return !this.listBox.isComboBoxList && this.listBox.width !== "";
558 },
559 GetFirstRenderedItem: function () {
560  for (var i = 0; i < this.listTable.rows.length; i++)
561   if (this.listTable.rows[i].itemIndex !== undefined)
562    return this.GetItem(this.listTable.rows[i].itemIndex);
563  return null;
564 },
565 GetLastRenderedItem: function () {
566  for (var i = this.listTable.rows.length - 1; i >= 0; i--)
567   if (this.listTable.rows[i].itemIndex !== undefined)
568    return this.GetItem(this.listTable.rows[i].itemIndex);
569  return null;
570 },
571 GetTopSpacersHeight: function () {
572  return ListBoxItemsManagerBase.prototype.GetTopSpacersHeight.call(this) + this.GetVirtualScrollTopSpacer().clientHeight;
573 },
574 GetItemTopOffset: function (index) {
575  var result = this.GetItemTopOffsetCore(index);
576  if(result === 0) {
577   var renderedItemRange = this.GetRenderedItemRange();
578   if((renderedItemRange.startIndex >= 0 && renderedItemRange.endIndex >= 0) && (index < renderedItemRange.startIndex || index > renderedItemRange.endIndex)) {
579    itemIndexInFilteredRange = ASPx.Data.ArrayIndexOf(this.filteredItemIndices, index);
580    if(itemIndexInFilteredRange !== -1) {
581     result = this.GetTotalItemsHeight(0, itemIndexInFilteredRange) - this.GetItemHeight(itemIndexInFilteredRange);
582    }
583   }
584  }
585  return result;
586 },
587 IsItemVisible: function (index) {
588  return this.IsItemRendered(index) ? ListBoxItemsManagerBase.prototype.IsItemVisible.call(this, index) : false;
589 },
590 AreAllItemsVisible: function() {
591  return this.filteredItemIndices.length === this.GetItemCount();
592 },
593 IsLastItemBottomEdgeVisible: function() {
594  return this.IsItemEdgeVisible(this.GetLastFilteredItemIndex(), false, true);
595 },
596 ConvertItemIndexToRowIndex: function (itemIndex) {
597  if(this.listTable.rows.length < 1)
598   return -1;
599  if(this.AreAllItemsVisible() && this.listBox.syncLockCount < 1 && !this.listBox.hasItemTemplate) { 
600   var rawIndex = itemIndex - this.listTable.rows[0].itemIndex;
601   return rawIndex >= 0 && rawIndex < this.listTable.rows.length
602    ? rawIndex
603    : ASPx.Data.ArrayIndexOf(this.listTable.rows, itemIndex, function(element) {return element.itemIndex === itemIndex;});
604  }
605  return ASPx.Data.ArrayIndexOf(this.listTable.rows, itemIndex, function (element) { return element.itemIndex === itemIndex; });
606 },
607 GetScrollDivChildElementHeight: function () {
608  return this.GetVirtualScrollTableContainer().getBoundingClientRect().height;
609 },
610 IsItemFiltered: function (index) {
611  return this.deserializedItems[index] && this.deserializedItems[index].filtered;
612 },
613 GetFirstVisibleItem: function () { 
614  for(var i = 0; i < this.listTable.rows.length; i++)
615   if (this.listTable.rows[i] && ASPx.ElementContainsCssClass(this.listTable.rows[i], "dxeListBoxItemRow"))
616    return this.listTable.rows[i].itemIndex;
617  return -1;
618 },
619 GetFirstFilteredItemIndex: function() {
620  return this.filteredItemIndices.length > 0 ? this.filteredItemIndices[0] : -1;
621 },
622 GetLastFilteredItemIndex: function() {
623  return this.filteredItemIndices.length > 0 ? this.filteredItemIndices[this.filteredItemIndices.length - 1] : 
623-1;
624 },
625 GetNextFilteredItemIndex: function(currentFilteredItemIndex) {
626  return this.filteredItemIndices.length > 0 ? this.filteredItemIndices[ASPx.Data.ArrayIndexOf(this.filteredItemIndices, currentFilteredItemIndex) + 1] : -1;
627 },
628 GetPrevFilteredItemIndex: function(currentFilteredItemIndex) {
629  return this.filteredItemIndices.length > 0 ? this.filteredItemIndices[ASPx.Data.ArrayIndexOf(this.filteredItemIndices, currentFilteredItemIndex) - 1] : -1;
630 },
631 GetNewItemIndexInFilteredRange: function(selectedIndex, step) {
632  var itemIndexInFilteredRange = ASPx.Data.ArrayIndexOf(this.filteredItemIndices, selectedIndex);
633  var newItemIndexInFilteredRange = itemIndexInFilteredRange + step;
634  if(newItemIndexInFilteredRange >= this.filteredItemIndices.length)
635   newItemIndexInFilteredRange = this.filteredItemIndices.length - 1;
636  else if(newItemIndexInFilteredRange < 0)
637   newItemIndexInFilteredRange = 0;
638  return this.filteredItemIndices[newItemIndexInFilteredRange];
639 },
640 ShouldRenderItemOnInsert: function(index) {
641  if (!this.listBox.IsDisplayed())
642   return false;
643  if (this.GetFirstVisibleItemRow() == null)
644   return true;
645  if (this.IsIndexInRenderedItemRange(index))
646   return true;
647  if (this.filteredItemIndices.length > 0) {
648   var startFilteredItemIndex = this.filteredItemIndices[0];
649   var endFilteredItemIndex = this.filteredItemIndices[this.filteredItemIndices.length - 1];
650   return index < startFilteredItemIndex && this.IsItemVisible(startFilteredItemIndex)
651    || index > endFilteredItemIndex && this.IsItemVisible(endFilteredItemIndex);
652  }
653  return false;
654 },
655 InsertItem: function(index, itemProperties) {
656  var isInsertToEnd = index === this.GetItemCount();
657  var isInsertToEndWithLock = isInsertToEnd && this.updateLock;
658  var shouldRenderItemOnInsert = !isInsertToEndWithLock && this.ShouldRenderItemOnInsert(index);
659  var isItemInsertedToTop = this.virtualScrollVisibleItemIndices.length > 0 && index < this.virtualScrollVisibleItemIndices[0];
660  ASPx.Data.ArrayInsert(this.deserializedItems, this.listBox.CreateItem(index, itemProperties), index);
661  this.deserializedItems[index].filtered = true;
662  this.deserializedItems[index].insertOrderIndex = this.listBox.FindFreeIndex();
663  if(!isInsertToEnd) {
664   for(var i = 0; i < this.deserializedItems.length; i++)
665    this.deserializedItems[i].index = i;
666   var requiredItemIndexInFilteredRange = -1;
667   for(var i = 0; i < this.filteredItemIndices.length; i++)
668    if(this.filteredItemIndices[i] >= index) {
669     this.filteredItemIndices[i]++;
670     if(requiredItemIndexInFilteredRange == -1)
671      requiredItemIndexInFilteredRange = i;
672    }
673   ASPx.Data.ArrayInsert(this.filteredItemIndices, index, requiredItemIndexInFilteredRange);
674  }
675  else
676   this.filteredItemIndices.push(index);
677  if(shouldRenderItemOnInsert) {
678   this.updateSmallestItemSize();
679  }
680  if(!isInsertToEndWithLock) {
681   this.virtualScrollVisibleItemIndices = [];
682   var rows = this.GetListTableRows();
683   for(var i = 0; i < rows.length; i++) {
684    var row = rows[i];
685    if(row.itemIndex !== undefined) {
686     if(row.itemIndex >= index)
687      row.itemIndex++;
688     this.virtualScrollVisibleItemIndices.push(row.itemIndex);
689    }
690   }
691   if(shouldRenderItemOnInsert) {
692    ASPx.Data.ArrayInsert(this.virtualScrollVisibleItemIndices, index,
693     ASPx.Data.ArrayIndexOf(this.virtualScrollVisibleItemIndices, index,
694     function(element) { return element > index; }));
695    this.listBox.InsertItemRow(index, itemProperties);
696    this.RecreateItemRowsCompletelly(this.getScrollPosition());
697   }
698   this.UpdateScrollTableContainerHeight();
699   if(isItemInsertedToTop)
700    this.UpdateVirtualScrollSpacerHeight(this.virtualScrollVisibleItemIndices, 0);
701   if(!this.listBox.IsDisplayed())
702    this.listBox.ResetControlAdjustment();
703  }
704  this.UpdateItemTextMaxWidth(this.GetItem(index).text);
705 },
706 BeginUpdate: function() {
707  this.updateLock = true;
708 },
709 EndUpdate: function() {
710  this.updateLock = false;
711  this.updateSmallestItemSize();
712  this.RecreateItemRowsCompletelly(this.getScrollPosition());
713  this.UpdateScrollTableContainerHeight();
714  if(!this.listBox.IsDisplayed())
715   this.listBox.ResetControlAdjustment();
716 },
717 RemoveItem: function(index) {
718  var shouldRecreateItemRows = this.listBox.IsDisplayed() && this.IsIndexInRenderedItemRange(index);
719  var shouldRemoveFromRender = this.GetItemRow(index);
720  var isItemRemovedFromTop = this.virtualScrollVisibleItemIndices.length > 0 && index < this.virtualScrollVisibleItemIndices[0];
721  var needUpdateItemTextMaxWidth = this.NeedUpdateItemTextMaxWidthOnRemoveItem(index);
722  ASPx.Data.ArrayRemoveAt(this.deserializedItems, index);
723  ASPx.Data.ArrayRemove(this.filteredItemIndices, index);
724  for (var i = 0; i < this.deserializedItems.length; i++)
725   this.deserializedItems[i].index = i;
726  for (var i = 0; i < this.filteredItemIndices.length; i++)
727   if (this.filteredItemIndices[i] > index)
728    this.filteredItemIndices[i]--;
729  this.virtualScrollVisibleItemIndices = [];
730  if (shouldRemoveFromRender)
731   this.RemoveItemCore(index);
732  var rows = this.GetListTableRows();
733  for (var i = 0; i < rows.length; i++) {
734   var row = rows[i];
735   if (row.itemIndex !== undefined) {
736    if(row.itemIndex > index)
737     row.itemIndex--;
738    this.virtualScrollVisibleItemIndices.push(row.itemIndex);
739   }
740  }
741  if (shouldRecreateItemRows)
742   this.RecreateItemRowsCompletelly(this.getScrollPosition());
743  this.UpdateScrollTableContainerHeight();
744  if (isItemRemovedFromTop)
745   this.UpdateVirtualScrollSpacerHeight(this.virtualScrollVisibleItemIndices, 0
745);
746  if (needUpdateItemTextMaxWidth) {
747   this.itemTextMaxWidth = 0;
748   this.visibleItemTextMaxWidth = 0;
749   for (var i = 0; i < this.GetItemCount() ; i++)
750    this.UpdateItemTextMaxWidth(this.GetItem(i).text);
751  }
752  if (!this.listBox.IsDisplayed())
753   this.listBox.ResetControlAdjustment();
754 },
755 ClearItems: function () {
756  this.ClearItemsCore();
757  this.deserializedItems = [];
758  this.filteredItemIndices = [];
759  this.virtualScrollVisibleItemIndices = [];
760  if (this.listBox.isComboBoxList) {
761   this.itemTextMaxWidth = 0;
762   this.visibleItemTextMaxWidth = 0;
763  }
764  this.UpdateScrollTableContainerHeight();
765  if (!this.listBox.IsDisplayed())
766   this.listBox.ResetControlAdjustment();
767 },
768 CreateNewItemRow: function (index) {
769  var newItemRow = ListBoxItemsManagerBase.prototype.CreateNewItemRow.call(this, index);
770  newItemRow.itemIndex = index;
771  return newItemRow;
772 },
773 Adjust: function() {
774  if (this.GetItemCount() == 0 || !this.listBox.IsDisplayed())
775   return;
776  if(this.smallestItemHeight === 0) {
777   this.updateSmallestItemSize();
778   this.UpdateScrollTableContainerHeight();
779  }
780  if(this.smallestItemHeight !== 0) {
781   this.RecreateItemRowsCompletelly(this.getScrollPosition());
782   this.listBox.InitializePageSize();
783   if(!this.listBox.isComboBoxList)
784    this.listBox.CorrectWidth();
785  }
786 },
787 UpdateItemTextMaxWidth: function (itemText, isFiltering) {
788  if (!this.UseVirtualItemWidth())
789   return;
790  if (!ASPx.IsExists(this.visibleItemTextMaxWidth))
791   this.visibleItemTextMaxWidth = 0;
792  this.visibleItemTextMaxWidth = Math.max(this.GetItemTextWidth(itemText), this.visibleItemTextMaxWidth);
793  if (!isFiltering)
794   this.itemTextMaxWidth = this.visibleItemTextMaxWidth;
795 },
796 GetItemTextWidth: function (itemText) {
797  return Math.round(this.GetItemTextMeasureContext().measureText(itemText).width);
798 },
799 GetItemTextMeasureContext: function() {
800  if (!this.itemTextMeasureContext) {
801   var itemTextMeasureCanvas = document.createElement("canvas");
802   this.itemTextMeasureContext = itemTextMeasureCanvas.getContext("2d");
803   var mainElementStyle = ASPx.GetCurrentStyle(this.listBox.GetMainElement());
804   var mainElementFont = mainElementStyle.font ? mainElementStyle.font :
805    mainElementStyle.fontStyle + " " + mainElementStyle.fontVariant + " " + mainElementStyle.fontWeight + " "
806     + mainElementStyle.fontSize + " / " + mainElementStyle.lineHeight + " " + mainElementStyle.fontFamily;
807   this.itemTextMeasureContext.font = mainElementFont;
808  }
809  return this.itemTextMeasureContext;
810 },
811 NeedUpdateItemTextMaxWidthOnRemoveItem: function(index) {
812  return this.UseVirtualItemWidth() && this.listBox.isComboBoxList && this.IsItemWithMaxText(this.GetItem(index).text);
813 },
814 BeforeClientFiltering: function () {
815  if (this.listBox.isComboBoxList)
816   this.visibleItemTextMaxWidth = 0;
817 },
818 IsItemWithMaxText: function(itemText) {
819  return this.GetItemTextWidth(itemText) === this.itemTextMaxWidth;
820 },
821 ApplyFilterToItem: function (index, isSatisfy, savePrevState, isFilterReset) {
822  if (savePrevState && !ASPx.IsExists(this.deserializedItems[index].savedFiltered))
823   this.deserializedItems[index].savedFiltered = this.deserializedItems[index].filtered;
824  this.ChangeItemFilteredFlag(index, isSatisfy, isFilterReset);
825 },
826 RestorePrevFilteredState: function (index) {
827  var savedFilteredState = this.deserializedItems[index].savedFiltered;
828  if (ASPx.IsExists(savedFilteredState)) {
829   this.ChangeItemFilteredFlag(index, savedFilteredState);
830   delete this.deserializedItems[index].savedFiltered;
831  }
832 },
833 ChangeItemFilteredFlag: function (index, newValue, isFilterReset) {
834  var item = this.deserializedItems[index];
835  item.filtered = newValue;
836  if (!isFilterReset && this.listBox.isComboBoxList && newValue)
837   this.UpdateItemTextMaxWidth(item.text);
838 },
839 OnEndItemsFiltering: function() {
840  if(this.listBox.IsDisplayed()) {
841   this.RecreateItemRowsCompletelly(0);
842  }
843 },
844 ChangeItemsFilteredState: function (action) {
845  this.filteredItemIndices = [];
846  ListBoxItemsManagerBase.prototype.ChangeItemsFilteredState.call(this, action);
847 },
848 AfterChangeItemFilteredStateAction: function (index) {
849  if (this.IsItemFiltered(index))
850   this.filteredItemIndices.push(index);
851 },
852 RewriteFilteredItemIndices: function (newFilteredItemIndices) {
853  this.filteredItemIndices = newFilteredItemIndices;
854 },
855 MakeAllItemsVisible: function () {
856  ListBoxItemsManagerBase.prototype.MakeAllItemsVisible.call(this);
857  this.visibleItemTextMaxWidth = this.itemTextMaxWidth;
858 },
859 MakeItemVisible: function(index) { 
860  if(index < 0) {
861   index = 0;
862  }
863  ListBoxItemsManagerBase.prototype.MakeItemVisible.call(this, index);
864 },
865 InsertTempFirstItemRow: function() {
866  try {
867   this.listBox.LockRunStartupSciptsInItemRow();
868   if(this.deserializedItems.length > 0)
869    this.listBox.InsertItemRow(0, this.deserializedItems[0]);
870  }
871  finally {
872   this.listBox.UnlockRunStartupSciptsInItemRow();
873  }
874 },
875 RemoveFirstTempRow: function () {
876  if (this.deserializedItems.length > 0)
877   this.listBox.RemoveItemRow(0);
878 },
879 GetVirtualScrollItemHeight: function(virtualScrollItemRow) {
880  return virtualScrollItemRow.getBoundingClientRect().height;
881 },
882 updateSmallestItemSize: function() {
883  if(this.smallestItemHeight == 0 && this.GetItemCount() !== 0) {
884   this.InsertTempFirstItemRow();
885   var firstItemRow = this.GetFirstVisibleItemRow();
886   var itemTextCell = this.listBox.GetItemFirstTextCell(0);
887   var cellDisplay = itemTextCell.style.display; 
888   itemTextCell.style.display = "";
889   ASPx.SetInnerHtml(itemTextCell,".");
890   ASPx.AddClassNameToElement(this.listTable, listTableCollapsedClassName);
891   this.smallestItemHeight = firstItemRow.offsetHeight;
892   ASPx.SetInnerHtml(itemTextCell,"");
893   if(this.UseVirtualItemWidth() && this.smallestItemWidth === 0) {
894    this.smallestItemWidth = firstItemRow.offsetWidth;
895   }
896   itemTextCell.style.display = cellDisplay;
897   ASPx.RemoveClassNameFromElement(this.listTable, listTableCollapsedClassName);
898   this.RemoveFirstTempRow();
899  }
900 },
901 UpdateScrollTableContainerHeight: function () {
902  var virtualScrollTableContainer = this.GetVirtualScrollTableContainer();
903  if (virtualScrollTableContainer)
904   ASPx.SetStyles(virtualScrollTableContainer, {
905    height: this.GetItemsHeight()
906     + this.listBox.GetTopScrollSpacerHeight()
907     + this.listBox.GetBottomScrollSpacerHeight()
908   });
909 },
910 UpdateVirtualScrollSpacerHeight: function(visibleIndices, scrollableContainerHeightDelta) {
911  var firstVisibleIndex = visibleIndices.length > 0 && this.filteredItemIndices.length > 0 ? ASPx.Data.ArrayIndexOf(this.filteredItemIndices, visibleIndices[0]) : 0;
912  var topSpacerHeight = 0;
913  if(firstVisibleIndex > 0) {
914   topSpacerHeight = this.GetTotalItemsHeight(0, firstVisibleIndex - 1);
915  }
916  if(!scrollableContainerHeightDelta)
917   scrollableContainerHeightDelta = 0;
918  ASPx.SetStyles(this.GetVirtualScrollTopSpacer(), { height: topSpacerHeight - scrollableContainerHeightDelta });
919 },
920 OnScrollSpacerVisibilityChanged: function() {
921  this.UpdateScrollTableContainerHeight();
922 },
923 SetItemHtml: function(index, html) {
924  this.deserializedItems[index].htmlContent = html;
925 },
926 SetItemTooltip: function (index, tooltip) {
927  this.deserializedItems[index].tooltip = tooltip;
928 },
929 SetItemAttribute: function(index, attrName, attrValue) {
930  if(!this.deserializedItems[index].attributes)
931   this.deserializedItems[index].attributes = {};
932  this.deserializedItems[index].attributes[attrName] = attrValue;
933 },
934 AddClassNameToCssClass: function(cssClass, className) {
935  return (cssClass == "" || cssClass == undefined) ? className : cssClass + " " + className;
936 },
937 RemoveClassNameFromCssClass: function (cssClass, className) {
938  var updClassName = " " + cssClass + " ";
939  var newClassName = updClassName.replace(" " + className + " ", " ");
940  return updClassName.length != newClassName.length ? ASPx.Str.Trim(newClassName) : cssClass;
941 },
942 AddItemCssClass: function (index, className) {
943  this.deserializedItems[index].cssClass = this.AddClassNameToCssClass(this.deserializedItems[index].cssClass, className);
944 },
945 RemoveItemCssClass: function (index, className) {
946  this.deserializedItems[index].cssClass = this.RemoveClassNameFromCssClass(this.deserializedItems[index].cssClass, className);
947 },
948 SetItemTextCellHtml: function (itemIndex, textCellIndex, html) {
949  if (!this.deserializedItems[itemIndex].htmlContents)
950   this.deserializedItems[itemIndex].htmlContents = [];
951  this.SetItemTextCellInfoValue(this.deserializedItems[itemIndex].htmlContents, textCellIndex, html);
952 },
953 SetItemTextCellTooltip: function (itemIndex, textCellIndex, tooltip) {
954  if (!this.deserializedItems[itemIndex].cellTooltips)
955   this.deserializedItems[itemIndex].cellTooltips = [];
956  this.SetItemTextCellInfoValue(this.deserializedItems[itemIndex].cellTooltips, textCellIndex, tooltip);
957 },
958 SetItemTextCellAttribute: function(itemIndex, textCellIndex, attrName, attrValue) {
959  if(!this.deserializedItems[itemIndex].cellAttributes)
960   this.deserializedItems[itemIndex].cellAttributes = [];
961  var setValueAction = function(itemInfo, value) {
962   if(!itemInfo.value)
963    itemInfo.value = {};
964   itemInfo.value[value.attrName] = value.attrValue;
965  };
966  this.SetItemTextCellInfoValue(this.deserializedItems[itemIndex].cellAttributes, textCellIndex,
967   { attrName: attrName, attrValue: attrValue }, setValueAction);
968 },
969 AddItemTextCellCssClass: function (itemIndex, textCellIndex, className) {
970  if (!this.deserializedItems[itemIndex].cellCssClasses)
971   this.deserializedItems[itemIndex].cellCssClasses = [];
972  var newCssClass = this.AddClassNameToCssClass(this.deserializedItems[itemIndex].cellCssClasses[textCellIndex], className);
973  this.SetItemTextCellInfoValue(this.deserializedItems[itemIndex].cellCssClasses, textCellIndex, newCssClass);
974 },
975 RemoveItemTextCellCssClass: function (itemIndex, textCellIndex, className) {
976  if (!this.deserializedItems[itemIndex].cellCssClasses)
977   this.deserializedItems[itemIndex].cellCssClasses = [];
978  var newCssClass = this.RemoveClassNameFromCssClass(this.deserializedItems[itemIndex].cellCssClasses[textCellIndex], className);
979  this.SetItemTextCellInfoValue(this.deserializedItems[itemIndex].cellCssClasses, textCellIndex, newCssClass);
980 },
981 SetItemTextCellInfoValue: function (infoArray, textCellIndex, value, setValueAction) {
982  var itemInfo = null;
983  var filteredArray = infoArray.filter(function (info) { return info.index === textCellIndex; });
984  if (filteredArray.length == 0) {
985   itemInfo = { index: textCellIndex };
986   infoArray.push(itemInfo);
987  }
988  else
989   itemInfo = filteredArray[0];
990  if(setValueAction)
991   setValueAction(itemInfo, value);
992  else
993   itemInfo.value = value;
994 },
995 InitializeItems: function(items, itemsValue) {
996  this.deserializedItems = this.listBox.DeserializeItems(items);
997  this.filteredItemIndices = [];
998  this.visibleItemTextMaxWidth = 0;
999  this.itemTextMaxWidth = 0;
1000  for (var i = 0; i < this.deserializedItems.length; i++) {
1001   this.listBox.AdjustItemProperties(this.deserializedItems[i]);
1002   itemsValue[i] = this.deserializedItems[i].value;
1003   this.filteredItemIndices[i] = this.deserializedItems[i].index;
1004   this.deserializedItems[i].filtered = true;
1005   this.deserializedItems[i].insertOrderIndex = this.listBox.FindFreeIndex();
1006   this.UpdateItemTextMaxWidth(this.deserializedItems[i].text);
1007  }
1008 },
1009 InitializeItemRows: function () {
1010  var topSpacer = ASPx.CreateHtmlElement("DIV");
1011  topSpacer.id = this.listBox.name + "VirtualScrollTopSpacer";
1012  var tableContainer = ASPx.CreateHtmlElement("DIV");
1013  tableContainer.id = this.listBox.name + ListBoxVirtualScrollTableContainerIDPostfix;
1014  tableContainer.appendChild(topSpacer);
1015  var scrollDiv = this.listBox.GetScrollDivElement();
1016  ASPx.MoveChildrenToElement(scrollDiv, tableContainer);
1017  scrollDiv.appendChild(tableContainer);
1018  ASPx.SetStyles(tableContainer, { overflow: "hidden", width: "100%" });
1019  ASPx.Evt.AttachEventToElement(scrollDiv, "scroll", this.onScroll.bind(this));
1020 },
1021 getScrollPosition: function() {
1022  var scrollDiv = this.listBox.GetScrollDivElement();
1023  var scrollTop = scrollDiv.scrollTop - this.listBox.GetTopScrollSpacerHeight();
1024  if(scrollTop < 0)
1025   scrollTop = 0;
1026  return scrollTop;
1027 },
1028 onScroll: function() {
1029  var scrollTop = this.getScrollPosition();
1030  if(this.IsScrollActivated()) {
1031   var scrollDiv = this.listBox.GetScrollDivElement();
1032   if(!scrollDiv) return;
1033   var scrollDivHeight = scrollDiv.clientHeight;
1034   var scrollContainerHeight = this.GetScrollDivChildElementHeight();
1035   var scrollToBottom = scrollContainerHeight <= scrollDivHeight ? false : scrollTop >= scrollContainerHeight - scrollDivHeight;
1036   var isSmallScroll = Math.abs(scrollTop - this.previousScrollPosition) < scrollDivHeight;
1037   if(isSmallScroll)
1038    this.RecreateItemRowsPartially(scrollTop);
1039   else
1040    this.RecreateItemRowsCompletelly(scrollTop);
1041   if(scrollToBottom) {
1042    this.DeactivateScrollHandler();
1043    scrollDiv.scrollTop = this.GetScrollDivChildElementHeight() - scrollDivHeight;
1044   }
1045  }
1046  else {
1047   this.ActivateScrollHandler();
1048  }
1049  this.previousScrollPosition = scrollTop;
1050 },
1051 RecreateItemRowsCompletelly: function(scrollTop) {
1052  this.RecreateItemRows(scrollTop, false);
1053 },
1054 RecreateItemRowsPartially: function(scrollTop) {
1055  this.RecreateItemRows(scrollTop, true);
1056 },
1057 RecreateItemRows: function(scrollTop, recreateItemsPartially) {
1058  if(recreateItemsPartially == "undefined") throw new Error("recreateItemsPartially");
1059  if(this.listBox.IsDisplayed()) {
1060   var firstVisibleItemIndex = this.getFirstVisibleItemIndex(scrollTop);
1061   var lastVisibleItemIndex = this.getLastVisibleItemIndex(scrollTop);
1062   this.RecreateItemRowsCore(firstVisibleItemIndex, lastVisibleItemIndex, recreateItemsPartially);
1063   if(typeof (ASPxClientHint) != "undefined")
1064    this.UpdateHintControl();
1065   this.listBox.AssignEllipsisTooltips();
1066  }
1067 },
1068 RecreateItemRowsCore: function(topRenderedItemIndex, bottomRenderedItemIndex, recreateItemsPartially) {
1069  if(topRenderedItemIndex > bottomRenderedItemIndex && this.filteredItemIndices.length > 0)
1070   return;
1071  var newVisibleIndices = this.filteredItemIndices.slice(topRenderedItemIndex, bottomRenderedItemIndex + 1);
1072  this.RecreateItemRowsByVisibleIndices(newVisibleIndices, false, recreateItemsPartially);
1073  this.OnDecoratedItemsRendering();
1074  if(this.listBox.NeedToHandleCellWidth())
1075   this.listBox.CorrectCellNullWidthStyle(this.GetFirstVisibleItemRow());
1076 },
1077 getFirstVisibleItemIndex: function(scrollTop) {
1078  var result = -1;
1079  var scrollDiv = this.listBox.GetScrollDivElement();
1080  var scrollDivHeight = scrollDiv.clientHeight;
1081  var scrollContainerHeight = this.GetScrollDivChildElementHeight();
1082  var scrollToBottom = scrollContainerHeight <= scrollDivHeight ? false : scrollTop >= scrollContainerHeight - scrollDivHeight;
1083  var height = 0;
1084  if(scrollToBottom) {
1085   for(var i = this.filteredItemIndices.length - 1;i >= 0;i--) {
1086    height += this.GetItemHeight(this.filteredItemIndices[i]);
1087    if(height > scrollDivHeight) {
1088     result = i;
1089     break;
1090    }
1091   }
1092  }
1093  else {
1094   for(var i = 0;i < this.filteredItemIndices.length;i++) {
1095    height += this.GetItemHeight(this.filteredItemIndices[i]);
1096    if(height > scrollTop) {
1097     result = i > 1 ? i - 1 : 0;
1098     break;
1099    }
1100   }
1101  }
1102  return result;
1103 },
1104 getLastVisibleItemIndex: function(scrollTop) {
1105  var result = -1;
1106  var scrollDiv = this.listBox.GetScrollDivElement();
1107  var scrollDivHeight = scrollDiv.clientHeight;
1108  var scrollContainerHeight = this.GetScrollDivChildElementHeight();
1109  var scrollToBottom = scrollContainerHeight <= scrollDivHeight ? false : scrollTop >= scrollContainerHeight - scrollDivHeight;
1110  if(scrollToBottom) {
1111   result = this.filteredItemIndices[this.filteredItemIndices.length - 1];
1112  }
1113  else {
1114   var height = 0;
1115   result = this.filteredItemIndices.length - 1;
1116   if(this.filteredItemIndices) {
1117    for(var i = 0;i < this.filteredItemIndices.length;i++) {
1118     height += this.GetItemHeight(this.filteredItemIndices[i]);
1119     if(height >= (scrollTop + scrollDivHeight)) {
1120      result = i;
1121      break;
1122     }
1123    }
1124   }
1125  }
1126  return result == this.filteredItemIndices.length - 1 ? result : result + 1;
1127 },
1128 UpdateHintControl: function() {
1129  ASPxClientHint.hideByTargetsContainerElement(this.listTable, true);
1130  ASPxClientHint.Update();
1131 },
1132 GetScrollContentHeight: function() {
1133  return this.GetVirtualScrollTopSpacer().getBoundingClientRect().height
1134   + this.listBox.GetTopScrollSpacerHeight() + this.listBox.GetBottomScrollSpacerHeight()
1135   + this.listTable.getBoundingClientRect().height;
1136 },
1137 removeItems: function(indicesToRemove) {
1138  var renderedItemIndexesBeforeModification = this.virtualScrollVisibleItemIndices;
1139  var removedFromTopItemsHeight = 0;
1140  for(var i = 0;i < indicesToRemove.length;i++) {
1141   var itemIndex = indicesToRemove[i];
1142   if(renderedItemIndexesBeforeModification.indexOf(itemIndex) === 0) {
1143    removedFromTopItemsHeight += this.GetItemHeight(itemIndex);
1144    renderedItemIndexesBeforeModification = renderedItemIndexesBeforeModification.slice(1);
1145   }
1146   this.listBox.RemoveItemRow(itemIndex);
1147  }
1148  return removedFromTopItemsHeight;
1149 },
1150 insertItems: function(indicesToInsert) {
1151  var firstVisibleItemIndexBeforeInsert = this.GetFirstVisibleItem();
1152  var scrollableContainerHeightDelta = 0;
1153  var insertedToTopItemsHeight = 0;
1154  for(var i = 0;i < indicesToInsert.length;i++) {
1155   var itemIndex = indicesToInsert[i];
1156   if(itemIndex < firstVisibleItemIndexBeforeInsert) {
1157    insertedToTopItemsHeight += this.GetItemHeight(itemIndex);
1158   }
1159   this.listBox.InsertItemRow(itemIndex, this.deserializedItems[itemIndex]);
1160   if(!this.deserializedItems[itemIndex].calculatedHeight) {
1161    var itemRowElement = this.GetItemRow(itemIndex);
1162    var imageElements = itemRowElement.querySelectorAll("img");
1163    var updateCalculatedHeightFunction = function(itemIndex, itemRowElement) {
1164     this.deserializedItems[itemIndex].calculatedHeight = this.GetVirtualScrollItemHeight(itemRowElement);
1165     this.RecreateItemRows(this.getScrollPosition(),true);
1166    };
1167    for(var j = 0;j < imageElements.length;j++) {
1168     var img = imageElements[j];
1169     if(!img.complete) {
1170      ASPx.Evt.AttachEventToElement(img, "load", updateCalculatedHeightFunction.bind(this, itemIndex, itemRowElement));
1171      ASPx.Evt.AttachEventToElement(img, "error", updateCalculatedHeightFunction.bind(this, itemIndex, itemRowElement));
1172     }
1173    }
1174    this.deserializedItems[itemIndex].calculatedHeight = this.GetVirtualScrollItemHeight(itemRowElement);
1175    if(itemIndex < firstVisibleItemIndexBeforeInsert) {
1176     scrollableContainerHeightDelta += this.deserializedItems[itemIndex].calculatedHeight - this.smallestItemHeight;
1177    }
1178   }
1179   var isItemSelected = this.listBox.GetIsItemSelected(itemIndex);
1180   var stateController = typeof (ASPx.GetStateController) != "undefined" ? ASPx.GetStateController() : null;
1181   this.listBox.SetItemSelectionAppearance(itemIndex, isItemSelected, stateController, false);
1182   if (this.listBox.GetIsCheckColumnExists())
1183    this.listBox.SetCheckBoxChecked(itemIndex, isItemSelected);
1184   this.listBox.ChangeEnabledStateItem(itemIndex, this.listBox.GetEnabled(), stateController);
1185  }
1186  return {
1187   scrollableContainerHeightDelta: scrollableContainerHeightDelta,
1188   insertedToTopItemsHeight: insertedToTopItemsHeight
1189  };
1190 },
1191 RecreateItemRowsByVisibleIndices: function(newVisibleIndices, keepTopSpacerHeight, recreateItemsPartially) {
1192  if(recreateItemsPartially == "undefined") throw new Error("recreateItemsPartially");
1193  if(keepTopSpacerHeight == "undefined") throw new Error("keepTopSpacerHeight");
1194  newVisibleIndices = newVisibleIndices || [];
1195  var indicesToRemove = this.virtualScrollVisibleItemIndices.filter(function(index) {
1196   return newVisibleIndices.indexOf(index) === -1;
1197  });
1198  var indicesToInsert = newVisibleIndices.filter(function(index) {
1199   return this.virtualScrollVisibleItemIndices.indexOf(index) === -1;
1200  }.bind(this));
1201  this.listBox.LockSynchronization();
1202  var removedFromTopItemsHeight = this.removeItems(indicesToRemove);
1203  var insertionInfo = this.insertItems(indicesToInsert);
1204  var scrollableContainerHeightDelta = insertionInfo.scrollableContainerHeightDelta;
1205  var insertedToTopItemsHeight = insertionInfo.insertedToTopItemsHeight;
1206  this.virtualScrollVisibleItemIndices = newVisibleIndices;
1207  this.UpdateScrollTableContainerHeight();
1208  this.listBox.TryApplyHighlighting();
1209  this.listBox.UnlockSynchronization();
1210  if(recreateItemsPartially) {
1211   var virtualScrollTopSpacer = this.GetVirtualScrollTopSpacer();
1212   var newHeight = virtualScrollTopSpacer.getBoundingClientRect().height - insertedToTopItemsHeight + removedFromTopItemsHeight;
1213   newHeight = newHeight >= 0 ? newHeight : 0;
1214   ASPx.SetStyles(virtualScrollTopSpacer, { height: newHeight });
1215   if(scrollableContainerHeightDelta !== 0) {
1216    this.DeactivateScrollHandler();
1217    this.listBox.GetScrollDivElement().scrollTop += scrollableContainerHeightDelta;
1218   }
1219  }
1220  else if(!keepTopSpacerHeight)
1221   this.UpdateVirtualScrollSpacerHeight(newVisibleIndices);
1222  this.listBox.InitDXTextAttributes();
1223 },
1224 GetVirtualScrollTableContainer: function () {
1225  return this.listBox.tempCache.Get("virtualScrollTableContainer", this.GetVirtualScrollTableContainerCore.aspxBind(this), this.listBox);
1226 },
1227 GetVirtualScrollTableContainerCore: function () {
1228  if (!ASPx.IsExistsElement(this.listBox.virtualScrollTableContainer))
1229   this.listBox.virtualScrollTableContainer = ASPx.GetElementById(this.listBox.name + ListBoxVirtualScrollTableContainerIDPostfix);
1230  return this.listBox.virtualScrollTableContainer;
1231 },
1232 GetVirtualScrollTopSpacer: function () {
1233  return this.listBox.tempCache.Get("virtualScrollTopSpacer", this.GetVirtualScrollTopSpacerCore.aspxBind(this), this.listBox);
1234 },
1235 GetVirtualScrollTopSpacerCore: function () {
1236  if (!ASPx.IsExistsElement(this.listBox.virtualScrollTopSpacer))
1237   this.listBox.virtualScrollTopSpacer = ASPx.GetElementById(this.listBox.name + "VirtualScrollTopSpacer");
1238  return this.listBox.virtualScrollTopSpacer;
1239 },
1240 GetRenderedItemRange: function () {
1241  var firstRenderedItem = this.GetFirstRenderedItem();
1242  var lastRenderedItem = this.GetLastRenderedItem();
1243  return {
1244   startIndex: firstRenderedItem ? firstRenderedItem.index : -1,
1245   endIndex: lastRenderedItem ? lastRenderedItem.index : -1
1246  };
1247 },
1248 IsIndexInRenderedItemRange: function(index) {
1249  var renderedItemRange = this.GetRenderedItemRange();
1250  return index >= renderedItemRange.startIndex && index <= renderedItemRange.endIndex;
1251 },
1252 IsItemRendered: function (itemIndex) {
1253  return this.GetItemRow(itemIndex) !== null;
1254 },
1255 IsItemTextWrapEnabled: function() {
1256  if(!ASPx.IsExists(this.enableItemTextWrap)) {
1257   var sampleItemFirstTextCell = this.listBox.GetSampleItemFirstTextCell();
1258   this.enableItemTextWrap = sampleItemFirstTextCell && ASPx.GetCurrentStyle(sampleItemFirstTextCell).whiteSpace !== "nowrap";
1259  }
1260  return this.enableItemTextWrap;
1261 },
1262 OnDecoratedItemsRendering: function () {
1263  if(this.listBox.hasDecoratedItems && !this.IsFixedWidth() && this.listBox.IsDisplayed() && !this.IsItemTextWrapEnabled())
1264   this.listBox.CorrectWidth();
1265 },
1266 DeactivateScrollHandler: function() { 
1267  this.isScrollProcessingActivated = false;
1268 },
1269 ActivateScrollHandler: function() { 
1270  this.isScrollProcessingActivated = true;
1271 },
1272 IsScrollActivated: function() {
1273  return this.isScrollProcessingActivated;
1274 }
1275});
1276var ASPxClientListEdit = ASPx.CreateClass(ASPxClientEdit, {
1277 constructor: function(name) {
1278  this.constructor.prototype.constructor.call(this, name);
1279  this.SelectedIndexChanged = new ASPxClientEvent();
1280  this.savedSelectedIndex = -1;
1281 },
1282 FindInputElement: function() {
1283  return this.FindStateInputElement();
1284 },
1285 FindStateInputElement: function(){
1286  return document.getElementById(this.name + leVISuffix);
1287 },
1288 GetItem: function(index) {
1289  throw "Not implemented";
1290 },
1291 GetItemValue: function(index) {
1292  throw "Not implemented";
1293 },
1294 GetValue: function(){
1295  return this.GetItemValue(this.GetSelectedIndex());
1296 }, 
1297 GetSelectedIndexInternal: function(){
1298  return this.savedSelectedIndex;
1299 },
1300 SetSelectedIndexInternal: function(index){
1301  this.savedSelectedIndex = index;
1302 },
1303 FindItemIndexByValue: function(value){
1304  for(var i = 0; i < this.GetItemCount(); i++){
1305   if(this.GetItemValue(i) == value)
1306    return i;
1307  }
1308  return -1;
1309 },
1310 RaiseItemClick: function() {
1311  var processOnServer = this.autoPostBack;
1312  if(!this.ItemClick.IsEmpty()){
1313   var args = new ASPxClientProcessingModeEventArgs(processOnServer);
1314   this.ItemClick.FireEvent(this, args);
1315   processOnServer = args.processOnServer;
1316  }
1317  return processOnServer;
1318 },
1319 RaiseItemDoubleClick: function() {
1320  var processOnServer = this.autoPostBack;
1321  if(!this.ItemDoubleClick.IsEmpty()){
1322   var args = new ASPxClientProcessingModeEventArgs(processOnServer);
1323   this.ItemDoubleClick.FireEvent(this, args);
1324   processOnServer = args.processOnServer;
1325  }
1326  return processOnServer;
1327 },
1328 RaiseValueChangedEvent: function() {
1329  if(!this.isInitialized) return false;
1330  var processOnServer = ASPxClientEdit.prototype.RaiseValueChangedEvent.call(this);
1331  processOnServer = this.RaiseValueChangedAdditionalEvents(processOnServer);
1332  return processOnServer;
1333 },
1334 RaiseValueChangedAdditionalEvents: function(processOnServer){
1335  return this.RaiseSelectedIndexChanged(processOnServer);
1336 },
1337 RaiseSelectedIndexChanged: function (processOnServer) {
1338  this.RaiseValidationInternal();
1339  if(!this.SelectedIndexChanged.IsEmpty()){
1340   var args = new ASPxClientProcessingModeEventArgs(processOnServer);
1341   this.SelectedIndexChanged.FireEvent(this, args);
1342   processOnServer = args.processOnServer;
1343  }
1344  return processOnServer;
1345 },
1346 UpdateHiddenInputs: function(){
1347  var element = this.FindStateInputElement();
1348  if(ASPx.IsExistsElement(element)) {
1349   var value = this.GetValue();
1350   if(value == null)
1351    value = "";
1352   element.value = value;
1353  }
1354 },
1355 GetModifyEvent: function () {
1356  return this.SelectedIndexChanged;
1357 },
1358 GetSelectedItem: function(){
1359  var index = this.GetSelectedIndexInternal();
1360  return this.GetItem(index);
1361 },
1362 GetSelectedIndex: function(){
1363  return this.GetSelectedIndexInternal();
1364 },
1365 SetSelectedItem: function(item){
1366  var index = (item != null) ? item.index : -1;
1367  this.SetSelectedIndex(index);
1368 },
1369 SetSelectedIndex: function(index){
1370  this.SelectIndexSilent(index);
1371 },
1372 SelectIndexSilent: function(index){
1373  throw "Not implemented";
1374 },
1375 OnValueChanged: function () {
1376  var processOnServer = this.RaiseValueChangedEvent() && this.GetIsValid();
1377  if(processOnServer)
1378   this.SendPostBackInternal("");
1379 },
1380 getElementToObserveVisibilityChange: function () {
1381  return this.GetMainElement();
1382 },
1383 processVisibilityChanged: function (visible) {
1384  var focusHandlingInputForKeyboardSupport = this.GetMainElement().querySelector(".dxKBSI");
1385  ASPx.ToggleClassNameToElement(focusHandlingInputForKeyboardSupport, "dx-position-fixed", visible);
1386 }
1387});
1388var ASPxClientListEditItem = ASPx.CreateClass(null, {
1389 constructor: function(listEditBase, index, text, value, imageUrl){
1390  this.listEditBase = listEditBase;
1391  this.index = index;
1392  this.imageUrl = imageUrl;
1393  this.text = text;
1394  this.value = value;
1395 }
1396});
1397var ASPxClientListBoxItem = ASPx.CreateClass(ASPxClientListEditItem, {
1398 constructor: function(listEditBase, index, texts, value, imageUrl, selected, cellStyles, cellCssClasses, cellTooltips, cellAttributes, htmlContents, style, cssClass, tooltip, attributes, htmlContent) {
1399  this.constructor.prototype.constructor.call(this, listEditBase, index, null, value, imageUrl);
1400  this.selected = !!selected;
1401  this.texts = texts;
1402  this.text = listEditBase.FormatText(texts, value);
1403  this.cellStyles = cellStyles;
1404  this.cellCssClasses = cellCssClasses;
1405  this.cellTooltips = cellTooltips;
1406  this.cellAttributes = cellAttributes;
1407  this.htmlContents = htmlContents;
1408  this.style = style;
1409  this.cssClass = cssClass;
1410  this.tooltip = tooltip;
1411  this.attributes = attributes;
1412  this.htmlContent = htmlContent;
1413 },
1414 GetColumnText: function(columnIndexOrFieldName){
1415  var columnIndex = -1;
1416  if(typeof(columnIndexOrFieldName) == "string")
1417   columnIndex = ASPx.Data.ArrayIndexOf(this.listEditBase.columnFieldNames, columnIndexOrFieldName);
1418  else if(typeof(columnIndexOrFieldName) == "number")
1419   columnIndex = columnIndexOrFieldName;
1420  return this.GetColumnTextByIndex(columnIndex);
1421 },
1422 GetColumnTextByIndex: function(columnIndex){
1423  if(0 <= columnIndex && columnIndex < this.texts.length)
1424   return this.texts[columnIndex];
1425  else
1426   return null;
1427 }
1428});
1429var ListBoxScrollCallbackHelperBase = ASPx.CreateClass(null, {
1430 constructor: function(listBoxControl) {
1431  this.listBoxControl = listBoxControl;
1432  this.itemsRange = "";
1433  this.defaultItemsRange = "0:" + (this.listBoxControl.callbackPageSize - 1);
1434 },
1435 OnScroll: function(){ },
1436 Reset: function(){ },
1437 IsScrolledToTopSpacer: function(){ return false; },
1438 IsScrolledToBottomSpacer: function(){ return false; },
1439 GetIsNeedToHideTopSpacer: function(){ return false; },
1440 GetIsNeedCallback: function(){ return false; },
1441 GetIsAnySpacerVisible: function() { return false; },
1442 GetItemsRangeForLoad: function(){ return this.defaultItemsRange; },
1443 SetItemsRangeForLoad: function(){}
1444});
1445var ListBoxScrollCallbackHelper = ASPx.CreateClass(ListBoxScrollCallbackHelperBase, {
1446 constructor: function(listBoxControl) {
1447  this.constructor.prototype.constructor.call(this, listBoxControl);
1448  this.isScrolledToTopSpacer = false;
1449  this.isScrolledToBottomSpacer = false;
1450 },
1451 OnScroll: function(){
1452  this.DetectScrollDirection();
1453  this.ResetItemsRange();
1454  if(this.GetIsAnySpacerVisible())
1455   this.RecalcItemsRangeForLoad();
1456 },
1457 DetectScrollDirection: function(){
1458  var listBoxControl = this.listBoxControl;
1459  var divElement = listBoxControl.GetScrollDivElement();
1460  var scrollTop = divElement.scrollTop;
1461  var scrollBottom = divElement.scrollTop + divElement.clientHeight;
1462  var isTopSpacerVisible = listBoxControl.GetScrollSpacerVisibility(true);
1463  var isBottomSpacerVisible = listBoxControl.GetScrollSpacerVisibility(false);
1464  this.isScrolledToTopSpacer = (scrollTop < parseInt(listBoxControl.GetTopSpacersHeight())) && isTopSpacerVisible;
1465  var listHeight = this.GetListHeight();
1466  this.isScrolledToBottomSpacer = (scrollBottom >= listBoxControl.GetTopSpacersHeight() + listHeight) && isBottomSpacerVisible;
1467 },
1468 GetListHeight: function () {
1469  var listTable = this.listBoxControl.GetListTable();
1470  return listTable.clientHeight;
1471 },
1472 Reset: function(){
1473  this.ResetItemsRange();
1474  this.isScrolledToTopSpacer = false;
1475  this.isScrolledToBottomSpacer = false;
1476 },
1477 ResetItemsRange: function(){
1478  this.itemsRange = "";
1479 },
1480 RecalcItemsRangeForLoad: function(){
1481  if(this.listBoxControl.isCallbackMode) {
1482   if(this.isScrolledToTopSpacer || this.isScrolledToBottomSpacer)
1483    this.SetItemsRangeForLoad(this.isScrolledToTopSpacer);
1484  }
1485 },
1486 IsScrolledToTopSpacer: function(){
1487  return this.isScrolledToTopSpacer;
1488 },
1489 IsScrolledToBottomSpacer: function(){
1490  return this.isScrolledToBottomSpacer;
1491 },
1492 GetIsAnySpacerVisible: function(){
1493  return this.isScrolledToTopSpacer || this.isScrolledToBottomSpacer;
1494 },
1495 GetIsNeedCallback: function(){
1496  return !this.GetIsItemsRangeEmpty();
1497 },
1498 GetIsNeedToHideTopSpacer: function(){
1499  return this.isScrolledToTopSpacer && this.GetIsItemsRangeEmpty();
1500 },
1501 GetItemsRangeForLoad: function(){
1502  return (!this.GetIsItemsRangeEmpty() ? this.itemsRange : this.defaultItemsRange);
1503 },
1504 SetItemsRangeForLoad: function(isForTop){
1505  var listbox = this.listBoxControl;
1506  var beginIndex = isForTop ? 
1507   listbox.serverIndexOfFirstItem - listbox.callbackPageSize : 
1508   listbox.serverIndexOfFirstItem + listbox.GetItemCount();
1509  beginIndex = beginIndex < 0 ? 0 : beginIndex;
1510  var endIndex = isForTop ? 
1511   listbox.serverIndexOfFirstItem - 1 : 
1512   beginIndex + listbox.callbackPageSize - 1;
1513  this.itemsRange = beginIndex + ":" + endIndex;
1514  this.isScrolledToTopSpacer = isForTop;
1515  this.isScrolledToBottomSpacer = !isForTop;
1516 },
1517 GetIsItemsRangeEmpty: function(){
1518  return (this.itemsRange == "" || this.itemsRange == emptyItemsRange);
1519 }
1520});
1521var ASPxClientListBoxBase = ASPx.CreateClass(ASPxClientListEdit, {
1522 constructor: function(name) {
1523  this.constructor.prototype.constructor.call(this, name);
1524  this.APILockCount = 0;
1525  this.updateSelectAllElementsLockCount = 0;
1526  this.enableSyncOnPerfCallback = false;
1527  this.scrollOnKBNavigationLockCount = 0;
1528  this.isComboBoxList = false;
1529  this.isSyncEnabled = true;
1530  this.ownerName = "";
1531  this.selectionEventsLockCount = 0;
1532  this.syncLockCount = 0;
1533  this.encodeHtml = true;
1534  this.useCaseInsensitiveSearch = true;
1535  this.serializingHelper = null;
1536  this.deletedItems = [];
1537  this.insertedItems = [];
1538  this.itemsValue = [];
1539  this.ItemDoubleClick = new ASPxClientEvent();
1540  this.ItemClick = new ASPxClientEvent();
1541 },
1542 InlineInitialize: function () {
1543  ASPxClientListEdit.prototype.InlineInitialize.call(this);
1544  for(var i = 0; i < this.itemsValue.length; i++)
1545   this.itemsValue[i] = this.GetDecodeValue(this.itemsValue[i]);
1546 },
1547 LockScrollOnKBNavigation: function(){
1548  this.scrollOnKBNavigationLockCount++;
1549 },
1550 UnlockScrollOnKBNavigation: function(){
1551  this.scrollOnKBNavigationLockCount--;
1552 },
1553 IsScrollOnKBNavigationLocked: function() {
1554  return this.scrollOnKBNavigationLockCount > 0;
1555 },
1556 LockSelectionEvents: function(){
1557  this.selectionEventsLockCount++;
1558 },
1559 UnlockSelectionEvents: function(){
1560  this.selectionEventsLockCount--;
1561 },
1562 IsSelectionEventsLocked: function(){
1563  return this.selectionEventsLockCount > 0;
1564 },
1565 LockSynchronizationOnInternalCallback: function(){
1566  if(!this.enableSyncOnPerfCallback)
1567   this.LockSynchronization();
1568 },
1569 UnlockSynchronizationOnInternalCallback: function (){
1570  if(!this.enableSyncOnPerfCallback)
1571   this.UnlockSynchronization();
1572 },
1573 GetItemCount: function(){
1574  return 0;
1575 },
1576 GetItemValue: function(index){
1577  if(0 <= index && index < this.GetItemCount())
1578   return this.PrepareItemValue(this.itemsValue[index]);
1579  return null;
1580 },
1581 GetItemTexts: function(item) {
1582  return item.text;
1583 },
1584 PrepareItemValue: function(value) {
1585  return (typeof(value) == "string" && value == "" && this.convertEmptyStringToNull) ? null : value;
1586 },
1587 LoadItemsFromCallback: function(isToTop, itemStrings){
1588 },
1589 SetValue: function(value){
1590  var index = this.FindItemIndexByValue(value);
1591  this.SelectIndexSilentAndMakeVisible(index);
1592 },
1593 FindItemIndexByText: function(text){
1594  var transformText = function(text) { return text; };
1595  var textIsString = typeof(text) === "string";
1596  if(this.useCaseInsensitiveSearch && textIsString)
1597   transformText = function(text) { return text.toUpperCase(); };
1598  text = transformText(text);
1599  for(var i = 0; i < this.GetItemCount(); i ++){
1600   if(transformText(this.GetItem(i).text) == text)
1601    return i;
1602  }
1603  return -1;
1604 },
1605 SelectIndex: function (index){ 
1606  if(this.SelectIndexSilentAndMakeVisible(index, false)){
1607   this.RaisePersonalStandardValidation();
1608   this.OnValueChanged();
1609  }
1610 },
1611 SelectIndexSilentAndMakeVisible: function(index, lockScrollingToItem){
1612  var selectionChanged = this.SelectIndexSilent(index);
1613  if(!this.IsScrollOnKBNavigationLocked() && !lockScrollingToItem && selectionChanged)
1614   this.MakeItemVisible(index);
1615  return selectionChanged;
1616 },
1617 FormatText: function (texts) {
1618  return texts;
1619 },
1620 MakeItemVisible: function(index){
1621 },
1622 InitOnContainerMadeVisible: function(){
1623 },
1624 AddItem: function(texts, value, imageUrl) {
1625  return this.AddItemInternal(this.CreateItemProperties(texts, value, imageUrl));
1626 },
1627 AddItemInternal: function(itemProperties) {
1628  var index = this.GetItemCount();
1629  this.InsertItemInternal(index, itemProperties);
1630  if(!ASPx.IsExists(this.GetItem(index)))
1631   index = -1;
1632  return index;
1633 },
1634 InsertItem: function(index, texts, value, imageUrl) {
1635  this.InsertItemInternal(index, this.CreateItemProperties(texts, value, imageUrl));
1636 },
1637 CreateItemProperties: function(texts, value, imageUrl, htmlContent, cssClass, tooltip) {
1638  return {
1639   texts: texts,
1640   value: value,
1641   imageUrl: imageUrl,
1642   htmlContent: htmlContent,
1643   cssClass: cssClass,
1644   tooltip: tooltip
1645  };
1646 },
1647 InsertItemInternal: function(index, itemProperties) {
1648 },
1649 BeginUpdate: function(){
1650  this.APILockCount ++;
1651 },
1652 EndUpdate: function(){
1653  this.APILockCount --;
1654  this.Synchronize();
1655 },
1656 LockUpdateSelectAllElements: function() {
1657  this.updateSelectAllElementsLockCount++;
1658 },
1659 UnlockUpdateSelectAllElements: function () {
1660  this.updateSelectAllElementsLockCount--;
1661 },
1662 IsUpdateSelectAllElementsLocked: function() {
1663  return this.updateSelectAllElementsLockCount > 0;
1664 },
1665 ClearItems: function(){
1666  this.BeginUpdate();
1667  this.UpdateArraysItemsCleared();
1668  this.ClearItemsCore();
1669  this.EndUpdate();
1670 },
1671 ClearItemsCore: function(){
1672 },
1673 ClearItemsForPerformCallback: function(){
1674  this.itemsValue = [];
1675  this.ClearItemsCore();
1676 },
1677 RemoveItem: function(index){
1678 },
1679 FindItemByText: function(text){
1680  var index = this.FindItemIndexByText(text);
1681  return this.GetItem(index);
1682 },
1683 FindItemByValue: function(value){
1684  var index = this.FindItemIndexByValue(value);
1685  return this.GetItem(index);
1686 },
1687 PerformCallback: function(arg) {
1688 },
1689 GetCallbackArguments: function(){
1690  var args = this.GetCustomCallbackArg();
1691  args += this.GetLoadItemsRangeCallbackArg();
1692  if(this.filterStrategy)
1693   args += this.filterStrategy.GetCallbackArguments();
1694  return args;
1695 },
1696 GetLoadItemsRangeCallbackArg: function(){
1697  return this.GetLoadItemsRangeCallbackArgCore(this.GetItemsRangeForLoad());
1698 },
1699 GetLoadCustomItemsRangeCallbackArguments: function(beginIndex, endIndex, value) {
1700  var itemsRange = beginIndex + ":" + endIndex;
1701  if(ASPx.IsExists(value))
1702   itemsRange = itemsRange + ":" + ASPx.Json.ToJson(value);
1703  var args = this.GetCustomCallbackArg();
1704  args += this.GetLoadItemsRangeCallbackArgCore(itemsRange);
1705  return args;
1706 },
1707 GetLoadItemsRangeCallbackArgCore: function(itemsRange) {
1708  return this.FormatCallbackArg(CONSTANTS.CALLBACK_PREFIXES.LOAD_RANGE_ITEMS, itemsRange);
1709 },
1710 FormatCallbackArg: function(prefix, arg) { 
1711  arg = arg.toString();
1712  return (ASPx.IsExists(arg) ? prefix + "|" + arg.length + ';' + arg + ';' : "");
1713 },
1714 GetItemsRangeForLoad: function(){
1715  return emptyItemsRange;
1716 },
1717 GetCallbackOwnerControl: function(){
1718  if(this.ownerName && !this.ownerControl)
1719   this.ownerControl = ASPx.GetControlCollection().Get(this.ownerName);
1720  return this.ownerControl;
1721 },
1722 GetCustomCallbackArg: function(){
1723  return this.stateObject["CustomCallback"];
1724 },
1725 SetCustomCallbackArg: function(arg){
1726  this.UpdateStateObjectWithObject({ CustomCallback: arg });
1727 },
1728 FormatAndSetCustomCallbackArg: function(arg, onPerformCallback){
1729  arg = ASPx.IsExists(arg) ? arg.toString() : "";
1730  var formatArg = this.FormatCallbackArg(onPerformCallback ? CONSTANTS.CALLBACK_PREFIXES.CUSTOMPERFORM : CONSTANTS.CALLBACK_PREFIXES.CUSTOM, arg);
1731  this.SetCustomCallbackArg(formatArg);
1732 },
1733 SendCallback: function(){
1734 },
1735 LockSynchronization: function(){
1736  this.syncLockCount++;
1737 },
1738 UnlockSynchronization: function(){
1739  this.syncLockCount--;
1740 },
1741 IsSyncLocked: function(){
1742  return this.syncLockCount > 0;
1743 },
1744 IsSyncEnabled: function(){
1745  return this.isSyncEnabled && !this.IsSyncLocked();
1746 },
1747 RegisterInsertedItem: function(index, itemProperties){
1748  if(this.IsSyncEnabled()){
1749   this.RefreshSynchroArraysIndex(index, true);
1750   var item = this.CreateItem(index, itemProperties);
1751   this.insertedItems.push(item);
1752   this.Synchronize();
1753  }
1754 },
1755 CreateItem: function(index, itemProperties) {
1756  return new ASPxClientListBoxItem(this, index, itemProperties.texts || [itemProperties.text], itemProperties.value, itemProperties.imageUrl,
1757   itemProperties.selected, itemProperties.cellStyles, itemProperties.cellCssClasse
1757s, itemProperties.cellTooltips, itemProperties.cellAttributes, itemProperties.htmlContents,
1758   itemProperties.style, itemProperties.cssClass, itemProperties.tooltip, itemProperties.attributes, itemProperties.htmlContent);
1759 },
1760 UpdateSyncArraysItemDeleted: function(item, isValueRemovingRequired){
1761  if(isValueRemovingRequired)
1762   ASPx.Data.ArrayRemoveAt(this.itemsValue, item.index);
1763  if(this.IsSyncEnabled()){
1764   var index = this.FindItemInArray(this.insertedItems, item);
1765   if(index == -1){
1766    this.RefreshSynchroArraysIndex(item.index, false);
1767    this.deletedItems.push(item);
1768   } else {
1769    this.RefreshSynchroArraysIndex(item.index, false);
1770    ASPx.Data.ArrayRemoveAt(this.insertedItems, index);
1771   }
1772   this.Synchronize();
1773  }
1774 },
1775 UpdateArraysItemsCleared: function(){
1776  if(this.IsSyncEnabled()){
1777   for(var i = this.GetItemCount() - 1; i >= 0; i --)
1778    this.UpdateSyncArraysItemDeleted(this.GetItem(i), false);
1779  } 
1780  this.itemsValue = [];
1781 },
1782 RefreshSynchroArraysIndex: function(startIndex, isIncrease){
1783  this.RefreshSynchroArrayIndexIndex(this.deletedItems, startIndex, isIncrease);
1784  this.RefreshSynchroArrayIndexIndex(this.insertedItems, startIndex, isIncrease);
1785 },
1786 RefreshSynchroArrayIndexIndex: function(array, startIndex, isIncrease){
1787  var delta = isIncrease ? 1 : -1;
1788  for(var i = 0; i < array.length; i ++){
1789   if(array[i].index >= startIndex)
1790    array[i].index += delta;
1791  }   
1792 },
1793 FindItemInArray: function(array, item){
1794  for(var i = array.length - 1; i >= 0; i--){
1795   var currentItem = array[i];
1796   if((!this.encodeHtml || currentItem.text == item.text) && currentItem.value == item.value &&
1797    currentItem.imageUrl == item.imageUrl)
1798    break;
1799  }
1800  return i;
1801 },
1802 Synchronize: function(){
1803  if(this.APILockCount == 0){
1804   if(this.IsSyncEnabled()){
1805    this.SynchronizeItems(this.deletedItems, "DeletedItems");
1806    this.SynchronizeItems(this.insertedItems, "InsertedItems");
1807   }
1808   this.CorrectSizeByTimer();
1809  }
1810 },
1811 CorrectSizeByTimer: function(){
1812 },
1813 SynchronizeItems: function(items, syncType){
1814  var itemsObj = { };
1815  itemsObj[syncType] = this.SerializeItems(items);
1816  this.UpdateStateObjectWithObject(itemsObj);
1817 },
1818 GetSerializingHelper: function(){ 
1819  if(this.serializingHelper == null)
1820   this.serializingHelper = this.CreateSerializingHelper();
1821  return this.serializingHelper;
1822 },
1823 CreateSerializingHelper: function(){
1824  return new ListBoxBaseItemsSerializingHelper(this);
1825 },
1826 SerializeItems: function(items){
1827  var serialiser = this.GetSerializingHelper();
1828  return serialiser.SerializeItems(items);
1829 },
1830 DeserializeItems: function(items) {
1831  return items.map(function(itemProperties, index) {
1832   return this.CreateItem(index, itemProperties);
1833  }.bind(this));
1834 }
1835});
1836var ListBoxBaseItemsSerializingHelper = ASPx.CreateClass(null, {
1837 constructor: function(listBoxControl) {
1838  this.listBoxControl = listBoxControl;
1839  this.startPos = 0;
1840 },
1841 SerializeItems: function(items){
1842  var sb = [ ];
1843  for(var i = 0; i < items.length; i++)
1844   this.SerializeItem(sb, items[i]);
1845  return sb.join("");
1846 },
1847 SerializeItem: function(sb, item) {
1848  if(!item)
1849   return;
1850  this.SerializeAtomValue(sb, item.index);
1851  this.SerializeAtomValue(sb, item.value);
1852  this.SerializeAtomValue(sb, item.imageUrl);
1853  var texts = this.listBoxControl.GetItemTexts(item);
1854  if(typeof(texts) == "string")
1855   this.SerializeAtomValue(sb, texts);
1856  else {
1857   for(var i = 0; i < texts.length; i++)
1858    this.SerializeAtomValue(sb, texts[i]);
1859  }
1860 },
1861 SerializeAtomValue: function(sb, value) {
1862  var valueStr = ASPx.IsExists(value) ? value.toString() : "";
1863  sb.push(valueStr.length);
1864  sb.push('|');
1865  sb.push(valueStr);
1866 },
1867 ParseItemIndex: function(serializedItem){
1868  return parseInt(this.ParseString(serializedItem));
1869 },
1870 ParseItemValue: function(serializedItem){
1871  return this.ParseString(serializedItem);
1872 },
1873 ParseString: function(str){
1874  var indexOfSeparator = str.indexOf(serializingSeparator, this.startPos);
1875  var strLength = parseInt(str.substring(this.startPos, indexOfSeparator));
1876  var strStartPos = indexOfSeparator + serializingSeparatorLength;
1877  this.startPos = strStartPos + strLength;
1878  return str.substring(strStartPos, strStartPos + strLength);
1879 },
1880 ParseTexts: function(serializedItems){
1881  return this.ParseString(serializedItems);
1882 },
1883 DeserializeValues: function(serializedValues){
1884  var deserializedValues = [];
1885  this.startPos = 0;
1886  while(this.startPos < serializedValues.length){
1887   deserializedValues.push(this.ParseItemValue(serializedValues));
1888  }
1889  return deserializedValues;
1890 }
1891});
1892var ListBoxItemsSerializingHelper = ASPx.CreateClass(ListBoxBaseItemsSerializingHelper, {
1893 constructor: function(listBoxControl) {
1894  this.constructor.prototype.constructor.call(this, listBoxControl);
1895 },
1896 ParseTexts: function(serializedItems){
1897  var textColumnCount = this.listBoxControl.GetItemTextCellCount();
1898  return (textColumnCount > 1) ? this.DeserializeItemTexts(serializedItems, textColumnCount) 
1899   : ListBoxBaseItemsSerializingHelper.prototype.ParseTexts.call(this, serializedItems);
1900 },
1901 DeserializeItemTexts: function(serializedItem, textColumnCount){
1902  var texts = [];
1903  for(var i = 0; i < textColumnCount; i++)
1904   texts.push(this.ParseString(serializedItem));
1905  return texts;
1906 }
1907});
1908var ListBoxSingleSelectionHelper = ASPx.CreateClass(null, {
1909 constructor: function(listBoxControl) {
1910  this.listBoxControl = listBoxControl;
1911  this.savedSelectedIndex = listBoxControl.savedSelectedIndex;
1912  this.updateHiddenInputsLockCount = 0;
1913  this.cachedSelectionChangedArgs = [];
1914 },
1915 ClearSelection: function(){
1916  this.SetSelectedIndexCore(-1);
1917  this.OnSelectionCleared();
1918 },
1919 OnSelectionCleared: function(){
1920  this.cachedSelectionChangedArgs = [];
1921 },
1922 GetSelectedIndexInternal: function(){
1923  return this.savedSelectedIndex;
1924 }, 
1925 SetSelectedIndexInternal: function(index){
1926  this.savedSelectedIndex = index;
1927 }, 
1928 SetSelectedIndexCore: function(index){
1929  if(index != this.savedSelectedIndex && -1 <= index && index < this.GetItemCount()){
1930   this.BeginSelectionUpdate();
1931   this.SetSelectedIndexInternal(index);
1932   this.EndSelectionUpdate();
1933   return true;
1934  }
1935  return false;
1936 },
1937 GetSelectedIndex: function(){
1938  return this.GetSelectedIndexInternal();
1939 },
1940 SetSelectedIndex: function(index){
1941  this.ChangeSelectedItem(index);
1942  this.SetSelectedIndexCore(index);
1943  this.OnItemSelectionChanged(index, true);
1944 },
1945 GetSelectedIndices: function(){ 
1946  var selectedIndex = this.GetSelectedIndexInternal();
1947  return selectedIndex != -1 ? [selectedIndex] : [];
1948 },
1949 GetSelectedValues: function(){ 
1950  var selectedValue =  this.listBoxControl.GetValue();
1951  return selectedValue != null ? [selectedValue] : [];
1952 },
1953 GetSelectedItems: function(){ 
1954  var selectedItem = this.listBoxControl.GetSelectedItem();
1955  return selectedItem != null? [selectedItem] : [];
1956 },
1957 SelectIndices: function(indices){},
1958 SelectItems: function(items){},
1959 SelectValues: function(values){},
1960 UnselectIndices: function (selected) { this.SetSelectedIndex(-1); },
1961 UnselectItems: function(items){},
1962 UnselectValues: function(values){},
1963 GetIsItemSelected: function(index){ return index == this.GetSelectedIndexInternal(); },
1964 ResetSelectionCollectionsCache: function(){ },
1965 OnItemClick: function(index, evt){
1966  var selected = true;
1967  this.BeginSelectionUpdate();
1968  this.ChangeSelectedItem(index);
1969  var selectedIndexChanged = this.SetSelectedIndexCore(index);
1970  this.EndSelectionUpdate();
1971  if(selectedIndexChanged)
1972   this.OnItemSelectionChanged(index, selected);
1973 },
1974 ChangeSelectedItem: function(newSelectedIndex){
1975  var selected = true;
1976  var oldSelectedIndex = this.GetSelectedIndexInternal();
1977  this.BeginSelectionUpdate();
1978  this.SetItemSelectionState(oldSelectedIndex, !selected);
1979  this.SetItemSelectionState(newSelectedIndex, selected);
1980  this.EndSelectionUpdate();
1981 },
1982 SetItemSelectionState: function (itemIndex, selected, controller) {
1983  this.BeginSelectionUpdate();
1984  this.listBoxControl.SetItemSelectionAppearance(itemIndex, selected, controller, true);
1985  this.EndSelectionUpdate();
1986 },
1987 GetFocusedIndex: function(){
1988  return this.GetSelectedIndexInternal();
1989 },
1990 BeginSelectionUpdate: function(){
1991  this.updateHiddenInputsLockCount++;
1992 },
1993 EndSelectionUpdate: function(){
1994  this.updateHiddenInputsLockCount--;
1995  if(!this.IsUpdateInternalSelectionStateLocked()){
1996   this.listBoxControl.UpdateInternalState();
1997   this.FlushSelectionChanged();
1998  }
1999 },
2000 IsUpdateInternalSelectionStateLocked: function(){
2001  return this.updateHiddenInputsLockCount > 0;
2002 },
2003 GetItemCount: function(){
2004  return this.listBoxControl.GetItemCount();
2005 },
2006 OnItemSelectionChanged: function(index, selected){
2007  if(this.IsUpdateInternalSelectionStateLocked()){
2008   var a = {Index: index, Selected: selected};
2009   this.cachedSelectionChangedArgs.push(a);
2010  }
2011  else 
2012   this.listBoxControl.OnItemSelectionChanged(index, selected);
2013 },
2014 FlushSelectionChanged: function(){
2015  if(this.IsUpdateInternalSelectionStateLocked()) 
2016   return;
2017  for(var i = 0; i < this.cachedSelectionChangedArgs.length; i++)
2018   this.listBoxControl.OnItemSelectionChanged(this.cachedSelectionChangedArgs[i].Index, this.cachedSelectionChangedArgs[i].Selected);
2019  this.cachedSelectionChangedArgs = [];
2020 },
2021 OnItemInserted: function(index){
2022  if(index <= this.savedSelectedIndex && this.savedSelectedIndex != -1)
2023   this.SetSelectedIndexInternal(this.savedSelectedIndex + 1);
2024 },
2025 OnItemRemoved: function(index){
2026  if(index < this.savedSelectedIndex)
2027   this.SetSelectedIndexInternal( this.savedSelectedIndex - 1);
2028  else if(index == this.savedSelectedIndex)
2029   this.SetSelectedIndexInternal(-1);
2030 },
2031 OnItemsCleared: function(){
2032  this.ClearSelection();
2033 }
2034});
2035var ListBoxMultiSelectionHelper = ASPx.CreateClass(ListBoxSingleSelectionHelper, {
2036 constructor: function(listBoxControl) {
2037  this.constructor.prototype.constructor.call(this, listBoxControl);
2038  this.selectedValuesCache = [];
2039  this.selectedItemsCache = [];
2040  this.savedSelectedIndices = [];
2041  this.selectedIndicesSortingRequired = false;
2042  this.focusedIndex = -1;
2043  this.lastIndexFocusedWithoutShift = -1;
2044 },
2045 SetSelectedIndex: function(index){
2046  this.SingleIndexSelection(index);
2047 },
2048 SetSelectedIndexCore: function(index){
2049  ListBoxSingleSelectionHelper.prototype.SetSelectedIndexCore.call(this, index);
2050  this.updateSelectAllElementsState();
2051 },
2052 updateSelectAllElementsState: function() {
2053  this.listBoxControl.updateSelectAllElementsState();
2054 },
2055 ResetSelectionCollectionsCache: function(){
2056  this.selectedIndicesSortingRequired = true;
2057  this.selectedItemsCache = [];
2058  this.selectedValuesCache = [];
2059 },
2060 GetSelectedIndices: function(){
2061  return this.GetSortedSelectedIndices().slice();
2062 },
2063 GetSortedSelectedIndices: function() {
2064  if(this.savedSelectedIndices.length > 1 && this.selectedIndicesSortingRequired)
2065   this.SortSelectedIndices();
2066  return this.savedSelectedIndices;
2067 },
2068 GetSelectedValues: function(){ 
2069  if(this.savedSelectedIndices.length == 0)
2070   return [];
2071  if(this.selectedValuesCache.length == 0)
2072   this.selectedValuesCache = this.GetSelectedValuesCore();
2073  return this.selectedValuesCache;
2074 },
2075 GetSelectedValuesCore: function(){
2076  var selectedValues = [];
2077  var selectedIndices = this.GetSortedSelectedIndices();
2078  if(selectedIndices.length == 0)
2079   return selectedValues;
2080  for(var i = 0; i < selectedIndices.length; i++)
2081   selectedValues.push(this.listBoxControl.GetItemValue([selectedIndices[i]]));
2082  return selectedValues;
2083 },
2084 GetSelectedItems: function(){
2085  if(this.savedSelectedIndices.length == 0)
2086   return [];
2087  if(this.selectedItemsCache.length == 0)
2088   this.selectedItemsCache = this.GetSelectedItemsCore();
2089  return this.selectedItemsCache;
2090 },
2091 GetSelectedItemsCore: function(){
2092  var selectedItems = [];
2093  for(var i = 0; i < this.savedSelectedIndices.length; i++)
2094   selectedItems.push(this.listBoxControl.GetItem(this.savedSelectedIndices[i]));
2095  return selectedItems;
2096 },
2097 SetIndicesSelectionState: function(indices, selected){
2098  this.BeginSelectionUpdate();
2099  var controller = typeof(ASPx.GetStateController) != "undefined" ? ASPx.GetStateController() : null;
2100  if(indices){
2101   var itemCount = this.listBoxControl.GetItemCount();
2102   for(var i = 0; i < indices.length; i++) {
2103    var index = indices[i];
2104    if(index >= 0 && index < itemCount)
2105     this.SetItemSelectionState(indices[i], selected, controller);
2106   }
2107  } else if(this.IsClientFilterApplied())
2108   this.SetAllFilteredItemsSelectionState(selected, controller);
2109  else
2110   this.SetAllItemsSelectionState(selected, controller);
2111  this.SetSelectedIndexCore(this.GetFirstSelectedIndex());
2112  this.EndSelectionUpdate();
2113 },
2114 IsClientFilterApplied: function() {
2115  return this.listBoxControl.IsClientFilterApplied();
2116 },
2117 SetAllFilteredItemsSelectionState: function (selected, controller) {
2118  for (var i = 0; i < this.listBoxControl.GetItemCount() ; i++) {
2119   if (this.listBoxControl.IsItemFiltered && !this.listBoxControl.IsItemFiltered(i))
2120    continue;
2121   this.SetItemSelectionState(i, selected, controller);
2122  }
2123 },
2124 SetItemsSelectionState: function(items, selected){
2125  var indices = items ? this.ConvertItemsToIndices(items) : null;
2126  this.SetIndicesSelectionState(indices, selected);
2127 },
2128 SetValuesSelectionState: function(values, selected){
2129  var indices = values ? this.ConvertValuesToIndices(values)  : null;
2130  this.SetIndicesSelectionState(indices, selected);
2131 },
2132 ConvertValuesToIndices: function(values){
2133  var indices = [];
2134  for(var i = 0; i < values.length; i++)
2135   indices.push(this.listBoxControl.FindItemIndexByValue(values[i]));
2136  return indices;
2137 },
2138 ConvertItemsToIndices: function(items){
2139  var indices = [];
2140  for(var i = 0; i < items.length; i++)
2141   indices.push(items[i].index);
2142  return indices;
2143 },
2144 SelectIndices: function(indices){
2145  this.SetIndicesSelectionState(indices, true);
2146 },
2147 SelectItems: function(items){
2148  this.SetItemsSelectionState(items, true);
2149 },
2150 SelectValues: function(values){
2151  this.SetValuesSelectionState(values, true);
2152 },
2153 UnselectIndices: function(indices){
2154  this.SetIndicesSelectionState(indices, false);
2155 },
2156 UnselectItems: function(items){
2157  this.SetItemsSelectionState(items, false);
2158 },
2159 UnselectValues: function(values){
2160  this.SetValuesSelectionState(values, false);  
2161 },
2162 GetIsItemSelected: function(index){ 
2163  return ASPx.Data.ArrayBinarySearch(this.GetSortedSelectedIndices(), index) > -1;
2164 },
2165 OnItemClick: function(index, evt){
2166  this.BeginSelectionUpdate();
2167  var ctrlKey = evt.ctrlKey || evt.metaKey;
2168  var shift = evt.shiftKey;
2169  if(ctrlKey)
2170   this.AddSelectedIndex(index);
2171  else if(shift){
2172   var startIndex = index > this.lastIndexFocusedWithoutShift ? this.lastIndexFocusedWithoutShift + 1 : index;
2173   var endIndex = index > this.lastIndexFocusedWithoutShift ? index : this.lastIndexFocusedWithoutShift - 1;
2174   this.SelectRangeIndicesOnly(startIndex, endIndex);
2175   this.SetFocusedIndexInternal(index, true);
2176  }else 
2177   this.SingleIndexSelection(index);
2178  this.EndSelectionUpdate();
2179 },
2180 OnItemCheckBoxClick: function(index, evt){
2181  this.BeginSelectionUpdate();
2182  this.AddSelectedIndex(index);
2183  this.EndSelectionUpdate();
2184 },
2185 AddSelectedIndex: function(index){
2186  this.SetFocusedIndexInternal(index, false);
2187  var indexInSelectedIndices = ASPx.Data.ArrayIndexOf(this.savedSelectedIndices, index);
2188  var selectionOperation = indexInSelectedIndices == -1;
2189  this.SetItemSelectionState(index, selectionOperation);
2190  this.SetSelectedIndexCore(this.GetFirstSelectedIndex());
2191 },
2192 SelectRangeIndicesOnly: function(startIndex, endIndex){
2193  this.BeginSelectionUpdate();
2194  var controller = typeof(ASPx.GetStateController) != "undefined" ? ASPx.GetStateController() : null;
2195  var itemCount = this.GetItemCount();
2196  for(var i = 0; i < itemCount; i ++) {
2197   if(i == this.lastIndexFocusedWithoutShift) 
2198    continue;
2199   if(startIndex !== endIndex && this.listBoxControl.IsItemFiltered && !this.listBoxControl.IsItemFiltered(i))
2200    continue;
2201   this.SetItemSelectionState(i, i >= startIndex && i <= endIndex, controller);
2202  }
2203  this.SetSelectedIndexCore(this.GetFirstSelectedIndex());
2204  this.EndSelectionUpdate();
2205 },
2206 SingleIndexSelection: function(index){
2207  this.SetFocusedIndexInternal(-1, false);
2208  this.SelectRangeIndicesOnly(index, index);
2209  this.SetFocusedIndexInternal(index, false);
2210 },
2211 SetAllItemsSelectionState: function(selected, controller){
2212  this.BeginSelectionUpdate();
2213  this.savedSelectedIndices = [ ];
2214  var itemCount = this.GetItemCount();
2215  for (var i = 0; i < itemCount; i++) {
2216   this.SetItemSelectionStateCore(i, selected, controller);
2217   if(selected)
2218    this.PushSelectedIndex(i);
2219   this.OnItemSelectionChanged(i, selected);
2220  }
2221  this.ResetSelectionCollectionsCache();
2222  this.EndSelectionUpdate();
2223 },
2224 SetItemSelectionState: function(itemIndex, selected, controller){
2225  this.SetItemSelectionStateCore(itemIndex, selected, controller);
2226  this.ResetSelectionCollectionsCache();
2227  var indexInSelectionArray = this.savedSelectedIndices.indexOf(itemIndex);
2228  if(selected && indexInSelectionArray == -1){
2229   this.PushSelectedIndex(itemIndex);
2230   this.OnItemSelectionChanged(itemIndex, true);
2231  }
2232  if(!selected && indexInSelectionArray != -1){
2233   this.RemoveSelectedIndexAt(indexInSelectionArray);
2234   this.OnItemSelectionChanged(itemIndex, false);
2235  }
2236 },
2237 GetFirstSelectedIndex: function(){
2238  var selectedIndices = this.GetSelectedIndices();
2239  var selectedIndicesCount = selectedIndices.length;
2240  var firstSelectedIndex = -1;
2241  if(selectedIndicesCount > 0){
2242   firstSelectedIndex = selectedIndices[0];
2243   for(var i = 1; i < selectedIndices.length; i++){
2244    if(firstSelectedIndex > selectedIndices[i])
2245     firstSelectedIndex = selectedIndices[i];
2246   }
2247  }
2248  return firstSelectedIndex;
2249 },
2250 PushSelectedIndex: function(index){
2251  this.savedSelectedIndices.push(index);
2252 },
2253 RemoveSelectedIndex: function(index){
2254  ASPx.Data.ArrayRemove(this.savedSelectedIndices, index);
2255 },
2256 RemoveSelectedIndexAt: function(indexInArray){
2257  ASPx.Data.ArrayRemoveAt(this.savedSelectedIndices, indexInArray);
2258 },
2259 SortSelectedIndices: function(){
2260  ASPx.Data.ArrayIntegerAscendingSort(this.savedSelectedIndices);
2261  this.selectedIndicesSortingRequired = false;
2262 },
2263 SetItemSelectionStateCore: function(itemIndex, selected, controller){
2264  ListBoxSingleSelectionHelper.prototype.SetItemSelectionState.call(this, itemIndex, selected, controller);
2265 },
2266 GetFocusedIndex: function(){
2267  return this.focusedIndex;
2268 },
2269 SetFocusedIndexInternal: function(index, isShiftPressed){
2270  if(!isShiftPressed)
2271   this.lastIndexFocusedWithoutShift = index;
2272  this.focusedIndex = index;
2273 },
2274 OnItemInserted: function(index){
2275  this.ResetSelectionCollectionsCache();
2276  ListBoxSingleSelectionHelper.prototype.OnItemInserted.call(this, index);
2277  if(this.focusedIndex >= index)
2278   this.focusedIndex ++;
2279  for(var i = 0; i < this.savedSelectedIndices.length; i++){
2280   if(this.savedSelectedIndices[i] >= index)
2281    this.savedSelectedIndices[i]++;
2282  }
2283  this.updateSelectAllElementsState();
2284 },
2285 OnItemRemoved: function(index){
2286  this.ResetSelectionCollectionsCache();
2287  ListBoxSingleSelectionHelper.prototype.OnItemRemoved.call(this, index);
2288  if(this.focusedIndex == index)
2289   this.focusedIndex = -1;
2290  else if(this.focusedIndex > index)
2291   this.focusedIndex --;
2292  if(this.GetIsItemSelected(index))
2293   this.RemoveSelectedIndex(index);
2294  for(var i = 0; i < this.savedSelectedIndices.length; i++){
2295   if(this.savedSelectedIndices[i] > index)
2296    this.savedSelectedIndices[i]--;
2297  }
2298  if(this.GetSelectedIndex() == -1)
2299   this.SetSelectedIndexCore(this.GetFirstSelectedIndex());
2300  this.updateSelectAllElementsState();
2301 },
2302 ClearSelection: function(){
2303  this.ResetSelectionCollectionsCache();
2304  ASPx.Data.ArrayClear(this.savedSelectedIndices);
2305  this.OnSelectionCleared();
2306  this.SetSelectedIndexCore(-1);
2307 }
2308});
2309var CheckBoxListMultiSelectionHelper = ASPx.CreateClass(ListBoxMultiSelectionHelper, {
2310 OnItemClick: function(index){
2311  this.BeginSelectionUpdate();
2312  this.AddSelectedIndex(index);
2313  this.EndSelectionUpdate();
2314 },
2315 GetFocusedItemIndex: function(){
2316  return this.lastIndexFocusedWithoutShift;
2317 },
2318 updateSelectAllElementsState: function () { },
2319 IsClientFilterApplied: function() { return false; }
2320});
2321var ListBoxCheckSelectionHelper = ASPx.CreateClass(ListBoxMultiSelectionHelper, {
2322 OnItemClick: function(index, evt){
2323  this.BeginSelectionUpdate();
2324  if(evt.shiftKey)
2325   ListBoxMultiSelectionHelper.prototype.OnItemClick.call(this, index, evt);
2326  else
2327   this.AddSelectedIndex(index);
2328  this.EndSelectionUpdate();
2329 }
2330});
2331var ASPxClientListBox = ASPx.CreateClass(ASPxClientListBoxBase, {
2332 constructor: function(name) {
2333  this.constructor.prototype.constructor.call(this, name);
2334  this.freeUniqIndex = -1;
2335  this.isHasFakeRow = false;
2336  this.headerDiv = null;
2337  this.headerTable = null;
2338  this.listTable = null;
2339  this.sampleItemFirstTextCell = null;
2340  this.width = "";
2341  this.defaultHeight = "";
2342  this.hasSampleItem = false;
2343  this.hoverClasses = [""];
2344  this.hoverCssArray = [""];
2345  this.selectAllHoverClasses = [""];
2346  this.selectAllHoverCssArray = [""];
2347  this.selectAllDisabledClasses = [""];
2348  this.selectAllDisabledCssArray = [""];
2349  this.selectedClasses = [""];
2350  this.selectedCssArray = [""];
2351  this.disabledClasses = [""];
2352  this.disabledCssArray = [""];
2353  this.imageCellExists = false;
2354  this.scrollHandlerLockCount = 0;
2355  this.columnFieldNames = [];
2356  this.textFormatString = "";
2357  this.nullValueItemDisplayText = null;
2358  this.defaultImageUrl = "";
2359  this.selectionMode = 0;
2360  this.initSelectedIndices = [];
2361  this.itemHorizontalAlign = "";
2362  this.emptyTextRowCellIndices = null;
2363  this.accessibilityHelper = null;
2364  this.accessibilityHelperID = "";
2365  this.allowMultipleCallbacks = false;
2366  this.isCallbackMode = false;
2367  this.callbackPageSize = -1;
2368  this.isTopSpacerVisible = false;
2369  this.isBottomSpacerVisible = false;
2370  this.serverIndexOfFirstItem = 0;
2371  this.scrollHelper = null;
2372  this.changeSelectAfterCallback = 0;
2373  this.ownerControl = null;
2374  this.SampleItem = null;
2375  this.sampleHeaderRow = null;
2376  this.scrollDivElement = null;
2377  this.scrollPageSize = 4;
2378  this.itemsValue = [];
2379  this.cachedValue = null;
2380  this.tempCache = new ListBoxTemporaryCache();
2381  this.sizingConfig.adjustControl = true;
2382  this.disableScrolling = false;
2383  this.icbFocusedStyle = null;
2384  this.icbImageProperties = null;
2385  this.internalCheckBoxCollection = null;
2386  this.focusableCheckInput = null;
2387  this.nativeCheckOnFocusHandler = null;
2388  this.enableSelectAll = false;
2389  this.enableFiltering = false;
2390  this.filteringDelay = 100;
2391  this.filterMinLength = 1;
2392  this.filterTimerID = -1;
2393  this.customFilteringEditorID = "";
2394  this.filteringTextBox = null;
2395  this.filteringTextBoxInput = null;
2396  this.showFilterButtonInput = null;
2397  this.highlighting = this.CreateHighlightingHelper();
2398  this.hasDecoratedItems = false;
2399  this.scrollDivMinWidth = 0;
2400  this.ItemFiltering = new ASPxClientEvent();
2401  this.CustomHighlighting = new ASPxClientEvent();
2402 },
2403 Initialize: function() {   
2404  this.LockScrollHandler();
2405  this.InitScrollPos();
2406  if(ASPx.Browser.WebKitTouchUI && !this.disableScrolling)
2407   ASPx.TouchUIHelper.MakeScrollable(this.GetScrollDivElement(), {showHorizontalScrollbar: false});
2408  this.CreateInternalCheckBoxCollection();
2409  this.InitSelection();
2410  if(!this.isComboBoxList)
2411   this.AdjustControlCore();
2412  this.InitializeLoadOnDemand();
2413  this.UnlockScrollHandler();
2414  if(!this.HasVirtualScrolling())
2415   this.freeUniqIndex = this.GetItemCount();
2416  ASPxClientEdit.prototype.Initialize.call(this);
2417  if(this.NeedUnfocusableScrollDivElement())
2418   ASPx.Attr.SetAttribute(this.GetScrollDivElement(), "tabIndex", "-1");
2419  this.EnsureFilteringElements();
2420 },
2421 InitDXTextAttributes: function(){
2422  if(this.emptyTextRowCellIndices != null){
2423   var itemWithDXTextCount = this.emptyTextRowCellIndices.length;
2424   for(var i = 0; i < itemWithDXTextCount; i++){
2425    var itemIndex = this.emptyTextRowCellIndices[i][0];
2426    var cellIndices = this.emptyTextRowCellIndices[i][1];
2427    var itemRow = this.GetItemRow(itemIndex);
2428    if(!itemRow) continue;
2429    for(var j = 0; j < cellIndices.length; j++){
2430     ASPx.Attr.SetAttribute(itemRow.cells[cellIndices[j]], "DXText", "");
2431    }
2432   }
2433  }
2434 },
2435 InitSelection: function(){
2436  var valueFromLastTime = this.GetValueFromValueInput();
2437  if(this.MultiSelectionMode()){
2438   if(valueFromLastTime != ""){
2439    var serialiser = this.GetSerializingHelper();
2440    var selectedValuesFromLastTime = serialiser.DeserializeValues(valueFromLastTime);
2441    var selectedIdicesFromLastTime = [];
2442    for(var i = 0; i < selectedValuesFromLastTime.length; i++)
2443     selectedIdicesFromLastTime.push(this.FindItemIndexByValue(selectedValuesFromLastTime[i]));
2444    this.SelectIndices(selectedIdicesFromLastTime);
2445   } else
2446    this.SelectIndices(this.initSelectedIndices);
2447  } else {
2448   var selectedIndex = (valueFromLastTime != "") ? 
2449    this.FindItemIndexByValue(valueFromLastTime) : this.GetSelectedIndexInternal();
2450   this.SetSelectedIndexInternal(selectedIndex);
2451   this.SelectIndexSilent(selectedIndex);
2452   this.GetItemSelectionHelper().SetSelectedIndexInternal(selectedIndex);
2453  }
2454  this.CacheValue();
2455 },
2456 BeginUpdate: function() {
2457  ASPxClientListBoxBase.prototype.BeginUpdate.call(this);
2458  if(this.isInitialized)
2459   this.itemsManager.BeginUpdate();
2460 },
2461 EndUpdate: function() {
2462  ASPxClientListBoxBase.prototype.EndUpdate.call(this);
2463  if(this.isInitialized)
2464   this.itemsManager.EndUpdate();
2465 },
2466 GetShowFilterButton: function() {
2467  return ASPx.GetControlCollection().Get(this.name + "_" + showFilterButtonID);
2468 },
2469 GetAccessibilityHelper: function() {
2470  var result = null;
2471  if(this.accessibilityCompliant) {
2472   if(!this.accessibilityHelper) {
2473    this.accessibilityHelper = new AccessibilityHelperListBox(this);
2474   }
2475   result = this.accessibilityHelper;
2476  }
2477  return result;
2478 },
2479 CreateHighlightingHelper: function() {
2480  return new ASPx.ListBoxHighlightingHelper(this, "em");
2481 },
2482 CreateInternalCheckBoxCollection: function() {
2483  if(this.IsNativeCheckBoxes() || this.internalCheckBoxCollection)
2484   return;
2485  this.internalCheckBoxCollection = new ASPx.CheckBoxInternalCollection(this.icbImageProperties, false, false, null, true, this.accessibilityCompliant);
2486  this.itemsManager.InitializeInternalCheckBoxCollection();
2487 },
2488 AddInternalCheckBoxToCollection: function(index) {
2489  if(!this.internalCheckBoxCollection)
2490   return;
2491  var enabled = this.GetEnabled();
2492  var changeEventMethod = ASPx.Attr.ChangeEventsMethod(enabled);
2493  this.AddInternalCheckBoxToCollectionCore(index, enabled, changeEventMethod);
2494 },
2495 AddInternalCheckBoxToCollectionCore: function(index, enabled, changeEventMethod) {
2496  var inputElement = this.GetItemCheckBoxInput(index);
2497  if(inputElement) {
2498   var internalCheckBox = this.internalCheckBoxCollection.Add(this.GetInternalCheckBoxKey(index), inputElement);
2499   internalCheckBox.CreateFocusDecoration(this.icbFocusedStyle);
2500   internalCheckBox.SetEnabled(enabled);
2501   internalCheckBox.autoSwitchEnabled = false;
2502   var checkBoxFocusableElement = this.GetCheckBoxFocusableElement(index);
2503   this.ChangeSpecialInputEnabledAttributes(checkBoxFocusableElement, changeEventMethod, true);
2504   if(this.accessibilityCompliant) {
2505    this.SetupCheckBoxAccessibilityAttributes(checkBoxFocusableElement, index);
2506   }
2507   internalCheckBox.CheckedChanged.AddHandler(
2508    function(s, e) {
2509     if(ASPx.Evt.GetKeyCode(e) == ASPx.Key.Space) {
2510      var element = ASPx.Evt.GetEventSource(e);
2511      this.GetItemSelectionHelper().OnItemCheckBoxClick(this.FindInternalCheckBoxIndex(element), e);
2512     }
2513    }.aspxBind(this)
2514   );
2515   internalCheckBox.Focus.AddHandler(
2516    function(s, e) {
2517     var index = this.FindInternalCheckBoxIndex(s.mainElement);
2518     window.setTimeout(function() { this.MakeItemVisible(index); }.aspxBind(this),50);
2519    }.aspxBind(this)
2520   );
2521  }
2522 },
2523 SetupCheckBoxAccessibilityAttributes: function(checkBox, index) {
2524  if(index !== -1) { 
2525   ASPx.Attr.SetAttribute(checkBox, "aria-label", this.GetAccessibilityHelper().getTextForScreenReader(this.GetItem(index)));
2526  }
2527 },
2528 ClearInternalCheckBoxCollection: function() {
2529  if(this.internalCheckBoxCollection)
2530   this.internalCheckBoxCollection.Clear();
2531 },
2532 RemoveInternalCheckBoxFromCollecntion: function(index) {
2533  if(this.internalCheckBoxCollection)
2534   this.internalCheckBoxCollection.Remove(this.GetInternalCheckBoxKey(index));
2535 },
2536 GetInternalCheckBoxKey: function(index) {
2537  return this.name + nameSeparator + this.GetItemValue(index);
2538 },
2539 GetInternalCheckBox: function (index) {
2540  if(this.internalCheckBoxCollection == null)
2541   this.CreateInternalCheckBoxCollection();
2542  if(this.internalCheckBoxCollection)
2543   return this.internalCheckBoxCollection.Get(this.GetInternalCheckBoxKey(index));
2544  return null;
2545 },
2546 IsNativeCheckBoxes: function() {
2547  return !this.icbImageProperties;
2548 },
2549 SetCheckBoxChecked: function(index, checked) {
2550  var checkBox = this.IsNativeCheckBoxes() ? this.GetItemCheckBoxInput(index) : this.GetInternalCheckBox(index);
2551  if(checkBox)
2552   this.SetCheckBoxCheckedCore(checkBox, checked);
2553  if(this.accessibilityCompliant) {
2554   setTimeout(function() { this.GetAccessibilityHelper().SetCheckBoxesValidationAttributes(); }.bind(this), 0);
2555  }
2556 },
2557 SetCheckBoxCheckedCore: function (checkBox, checked) {
2558  if(this.IsNativeCheckBoxes())
2559   checkBox.checked = checked;
2560  else
2561   checkBox.SetValue(checked ? ASPx.CheckBoxInputKey.Checked : ASPx.CheckBoxInputKey.Unchecked);
2562 },
2563 SetCheckBoxEnabled: function (index, enabled) {
2564  var checkBox = this.IsNativeCheckBoxes() ? this.GetItemCheckBoxInput(index) : this.GetInternalCheckBox(index);
2565  if (checkBox)
2566   this.SetCheckBoxEnabledCore(checkBox, enabled);
2567 },
2568 SetCheckBoxEnabledCore: function (checkbox, enabled) {
2569  if (this.IsNativeCheckBoxes()) {
2570   checkbox.disabled = !enabled;
2571   this.ChangeNativeCheckEnabledAttributes(checkbox, ASPx.Attr.ChangeEventsMethod(this.GetEnabled()));
2572  }
2573  else
2574   checkbox.SetEnabled(enabled);
2575  this.ChangeSpecialInputEnabledAttributes(this.IsNativeCheckBoxes() ?
2576   checkbox : checkbox.inputElement, ASPx.Attr.ChangeEventsMethod(enabled));
2577 },
2578 ClearItems: function() {
2579  ASPxClientListBoxBase.prototype.ClearItems.call(this);
2580  this.ClearInternalCheckBoxCollection();
2581  this.freeUniqIndex = this.GetItemCount();
2582 },
2583 OnDelayedSpecialFocusMouseDown: function (evt) {
2584  if(this.filteringTextBox) {
2585   var isEventFromFilteringTextBox = ASPx.Evt.GetEventSource(evt) == this.filteringTextBox.GetInputElement();
2586   this.filteringTextBoxInput = isEventFromFilteringTextBox ? this.filteringTextBox.GetInputElement() : null;
2587  }
2588  if(this.showFilterButton) {
2589   var isEventFromShowFilterButton = ASPx.GetIsParent(this.showFilterButton.GetMainElement(), ASPx.Evt.GetEventSource(evt));
2590   this.showFilterButtonInput = isEventFromShowFilterButton ? this.showFilterButton.GetInternalButton() : null;
2591   this.isFilterEditorShowing = isEventFromShowFilterButton;
2592  }
2593  if(this.GetIsCheckColumnExists())
2594   this.SetFocusableCheckInput(this.GetCheckBoxInputFromEvent(evt));
2595  ASPxClientListBoxBase.prototype.OnDelayedSpecialFocusMouseDown.call(this, evt);
2596  var shiftPressed = evt.shiftKey;
2597  var ctrlKey = evt.ctrlKey || evt.metaKey;
2598  if(shiftPressed || ctrlKey)
2599   ASPx.Selection.Clear();
2600 },
2601 GetCheckBoxInputFromEvent: function(evt) {
2602  var element = ASPx.Evt.GetEventSource(evt);
2603  if(this.IsNativeCheckBoxes())
2604   return element.type == "checkbox" ? element : null;
2605  var index = this.FindInternalCheckBoxIndex(element);
2606  if(index > -1)
2607   return this.GetCheckBoxFocusableElement(index);
2608  else if(this.IsSelectAllCheckBoxClicked(element))
2609   return this.GetSelectAllCheckBoxFocusableElement();
2610  return null;
2611 },
2612 IsSelectAllCheckBoxClicked: function(eventSource) {
2613  return this.selectAllCheckBox && ASPx.GetIsParent(this.selectAllCheckBox.container, eventSource)
2614   && (eventSource == this.selectAllCheckBox.mainElement || eventSource.tagName == "LABEL");
2615 },
2616 IsNativeSelectAllCheckBoxClicked: function (eventSource) {
2617  return this.nativeSelectAllCheckBox && ASPx.GetIsParent(this.nativeSelectAllCheckBox, eventSource);
2618 },
2619 GetSelectAllClickableElement: function() {
2620  return this.IsMultiColumn() ? this.selectAllMainElement.parentNode : this.selectAllMainElement;
2621 },
2622 GetSelectAllCheckBoxFocusableElement: function() {
2623  return this.accessibilityCompliant ? this.selectAllCheckBox.mainElement : this.selectAllCheckBox.inputElement;
2624 },
2625 GetCheckBoxFocusableElement: function(index) {
2626  var internalCheckBox = this.GetInternalCheckBox(index);
2627  if(!internalCheckBox)
2628   return null;
2629  return this.accessibilityCompliant ? internalCheckBox.mainElement : internalCheckBox.inputElement;
2630 },
2631 FindInternalCheckBoxIndex: function(element) {
2632  var level = 5;
2633  while(level > 0) {
2634   var id = element.id;
2635   if(id && element.tagName == "TD" && id.slice(-1) == lbIPostfixes[0])
2636    return this.GetItemIndexByRow(element.parentNode);
2637   element = element.parentNode;
2638   level--;
2639  }
2640  return -1;
2641 },
2642 IsCheckBoxClicked: function(evt) {
2643  return !!this.GetCheckBoxInputFromEvent(evt);
2644 },
2645 GetFocusableInputElement: function() {
2646  return this.showFilterButtonInput || this.filteringTextBoxInput || this.focusableCheckInput || this.GetInputElement();
2647 },
2648 IsElementBelongToInputElement: function (element) {
2649  return ASPxClientEdit.prototype.IsElementBelongToInputElement.call(this, element)
2650  || this.filteringTextBox && this.filteringTextBox.ownerListBox == this && this.filteringTextBox.IsElementBelongToInputElement(element);
2651 },
2652 SetFocusableCheckInput: function(element) {
2653  this.focusableCheckInput = element;
2654 },
2655 OnFocusCore: function() {
2656  if(this.UseDelayedSpecialFocus())
2657   this.specialFocusTimer = ASPx.Timer.ClearTimer(this.specialFocusTimer);
2658  if(this.focused)
2659   this.UnlockFocusEvents();
2660  else
2661   ASPxClientListBoxBase.prototype.OnFocusCore.call(this);
2662 },
2663 OnLostFocusCore: function() {
2664  if(!this.IsFocusEventsLocked()) { 
2665   this.SetFocusableCheckInput(null);
2666   this.filteringTextBoxInput = null;
2667   this.showFilterButtonInput = null;
2668  }
2669  ASPxClientListBoxBase.prototype.OnLostFocusCore.call(this);
2670 },
2671 IsFocusEventsLocked: function() {
2672  var result = ASPxClientEdit.prototype.IsFocusEventsLocked.call(this) ||
2673      this.IsInternalFilteringTextBoxFocusEventsLocked() ||
2674      this.isFilterEditorShowing;
2675  if(this.accessibilityCompliant)
2676   result = this.focused && (result || this.HasInternalFilteringTextBoxFocus());
2677  return result;
2678 },
2679 HasInternalFilteringTextBoxFocus: function() {
2680  return !this.customFilteringEditorID && this.filteringTextBox && ASPx.GetIsParent(this.filteringTextBox.GetMainElement(), ASPx.GetActiveElement());
2681 },
2682 IsInternalFilteringTextBoxFocusEventsLocked: function() {
2683  return !this.customFilteringEditorID && this.filteringTextBox && this.filteringTextBox.IsFocusEventsLocked();
2684 },
2685 ForceLockFocusEvents: function() {
2686  this.focusEventsLocked = true;
2687 },
2688 GetValueFromValueInput: function(){
2689  var valueInput = this.FindStateInputElement();
2690  if(ASPx.IsExistsElement(valueInput))
2691   return valueInput.value;
2692  return "";
2693 },
2694 NeedUnfocusableScrollDivElement: function() {
2695  return ASPx.Browser.Firefox;
2696 },
2697 GetInitSelectedIndex: function(){
2698  return this.savedSelectedIndex;
2699 },
2700 CacheValue: function(){
2701  this.cachedValue = this.GetValue();
2702 },
2703 InitScrollPos: function(){ 
2704  if(!this.isComboBoxList && this.isCallbackMode && this.GetInitSelectedIndex() == -1)
2705   this.GetScrollDivElement().scrollTop = 0;
2706 },
2707 InitializeLoadOnDemand: function(){
2708  var loadOnDemandRequired = this.isCallbackMode && this.GetEnabledByServer();
2709  this.scrollHelper = this.CreateScrollHelper(loadOnDemandRequired);
2710 },
2711 CreateScrollHelper: function (loadOnDemandRequired) {
2712  if (loadOnDemandRequired)
2713   return new ListBoxScrollCallbackHelper(this);
2714  return new ListBoxScrollCallbackHelperBase(this);
2715 },
2716 HasVirtualScrolling: function() { return !!this.itemsInfo || this.itemsManager instanceof ListBoxItemsVirtualManager; },
2717 CreateItemsManager: function() {
2718  if (this.HasVirtualScrolling()) {
2719   var manager = new ListBoxItemsVirtualManager(this);
2720   manager.InitializeItems(this.itemsInfo, this.itemsValue);
2721   delete this.itemsInfo;
2722   return manager;
2723  }
2724  return new ListBoxItemsDefaultManager(this);
2725 },
2726 CreateStateControllerManager: function() {
2727  var result = null;
2728  if(this.HasVirtualScrolling()) {
2729   result = this.CreateVirtualRenderStateControllerManager();
2730  }
2731  else {
2732   result = this.CreateDefaultRenderStateControllerManager();
2733  }
2734  return result;
2735 },
2736 CreateVirtualRenderStateControllerManager: function() {
2737  return new VirtualRenderListBoxStateControllerManager(this, this.itemsManager);
2738 },
2739 CreateDefaultRenderStateControllerManager: function() {
2740  return new DefaultListBoxStateControllerManager(this);
2741 },
2742 InlineInitialize: function(){
2743  if(this.HasVirtualScrolling())
2744   this.freeUniqIndex = 0;
2745  this.itemsManager = this.CreateItemsManager();
2746  this.stateControllerManager = this.CreateStateControllerManager();
2747  this.filterStrategy = this.isComboBoxList ? null : this.CreateFilterStrategy();
2748  this.EnsureFixWidthRow();
2749  this.InitializeNativeCheckHandlers();
2750  this.LockScrollHandler();
2751  this.InitializeItemsAttributes();
2752  this.InitDXTextAttributes();
2753  this.stateControllerManager.Initialize();
2754  this.itemsManager.Initialize();
2755  this.AddSelectAllStateItems(true);
2756  this.UnlockScrollHandler();
2757  if(this.NeedToHandleCellWidth()) {
2758   var headerTable = this.GetHeaderTableElement();
2759   var firstHeaderRow = !!headerTable && headerTable.rows[0];
2760   this.CorrectCellNullWidthStyle(firstHeaderRow);
2761   this.CorrectCellNullWidthStyle(this.itemsManager.GetFirstVisibleItemRow());
2762  }
2763  ASPxClientListBoxBase.prototype.InlineInitialize.call(this);
2764  this.EnsureSelectAllElements();
2765 },
2766 IsItemVisible: function(index) {
2767  return this.itemsManager.IsItemVisible(index);
2768 },
2769 UseSpecialKeyboardHandling: function() {
2770  return true;
2771 },
2772 GetItemIndexByInsertionOrder: function (itemIndex) { 
2773  return this.HasVirtualScrolling() ? this.GetItem(itemIndex).insertOrderIndex : this.FindFreeIndex();
2774 },
2775 InsertItemRow: function (index, itemProperties) {
2776  var newItemRow = this.itemsManager.CreateNewItemRow(index);
2777  ASPx.Attr.RemoveAttribute(newItemRow, "id");
2778  var listTable = this.GetListTable();
2779  var tbody = this.GetTableRowParent(listTable);
2780  var rowBeforeNewItemRow = this.GetListTableRowBeforeNewItemRow(index, listTable);
2781  var scrollDiv = this.GetScrollDivElement();
2782  var oldScrollTop = scrollDiv.scrollTop;
2783  if(rowBeforeNewItemRow)
2784   tbody.insertBefore(newItemRow, rowBeforeNewItemRow);
2785  else
2786   tbody.appendChild(newItemRow);  
2787  if(ASPx.Browser.Firefox && scrollDiv.scrollTop != oldScrollTop)
2788   scrollDiv.scrollTop = oldScrollTop;
2789  var newIndex = this.GetItemIndexByInsertionOrder(index);
2790  var newId = this.CreateItemId(newIndex);
2791  var newClientId = this.CreateItemClientId(newIndex);
2792  this.InitializeItemAttributes(newItemRow, newClientId, true);
2793  this.AddStateControllerClasses(newId);
2794  this.PrepareItem(newItemRow, itemProperties);
2795  if (this.needUnselectableItemRows)
2796   this.SetItemRowUnselectable(newItemRow);
2797  if (this.GetIsCheckColumnExists() && !this.IsNativeCheckBoxes()) {
2798   if (!this.internalCheckBoxCollection)
2799    this.CreateInternalCheckBoxCollection();
2800   this.AddInternalCheckBoxToCollection(index);
2801  }
2802 },
2803 RemoveItemRow: function (index) {
2804  if (this.GetIsCheckColumnExists() && !this.IsNativeCheckBoxes())
2805   this.RemoveInternalCheckBoxFromCollecntion(index);
2806  var row = this.GetItemRow(index);
2807  if (ASPx.IsExistsElement(row)) {
2808   var firstCellId = this.GetItemElement(index).id;
2809   var itemId = firstCellId.match(/LBI\d+/)[0];
2810   this.RemoveStateControllerClasses(itemId);
2811   row.parentNode.removeChild(row);
2812  }
2813 },
2814 SetItemRowsUnselectable: function() {
2815  var count = this.GetItemCount();
2816  for (var i = 0; i < count; i++) {
2817   var itemRow = this.GetItemRow(i);
2818   if (itemRow)
2819    this.SetItemRowUnselectable(itemRow);
2820  }
2821  this.needUnselectableItemRows = true;
2822 },
2823 SetItemRowUnselectable: function (itemRow) {
2824  for (var j = 0; j < itemRow.cells.length; j++)
2825   ASPx.Selection.SetElementAsUnselectable(itemRow.cells[j], true);
2826 },
2827 GetInactiveFilterElementClassName: function() {
2828  return inactiveFilterElementClassName;
2829 },
2830 GetAnimatedFilterElementClassName: function() {
2831  return "dxeLBAnimatedFilterPanelSys";
2832 },
2833 GetCompactViewFilterAdjacentScrollDivSelector: function() {
2834  return "*[class*=\"dxeListBoxFilter\"]:not(.dxeLBInactiveFilterPanelSys) + *[class*=\"dxeListBoxSelectAll\"] + .dxlbd";
2835 },
2836 GetCompactViewInactiveFilterAdjacentScrollDivSelector: function() {
2837  return ".dxeLBInactiveFilterPanelSys + *[class*=\"dxeListBoxSelectAll\"] + .dxlbd";
2838 },
2839 EnsureFilteringElements: function () {
2840  if(this.enableFiltering) {
2841   this.EnsureFilteringTextBox();
2842   if(!this.customFilteringEditorID) {
2843    this.filterMainElement = this.GetChildElement(filterMainElementID);
2844    this.showFilterButton = this.GetShowFilterButton();
2845    if(this.showFilterButton) {
2846     this.showFilterButton.ownerListBox = this;
2847     var changeEventMethod = ASPx.Attr.ChangeEventsMethod(this.GetEnabled());
2848     var showFilterButtonInternalButton = this.showFilterButton.GetInternalButton();
2849     if(showFilterButtonInternalButton)
2850      this.ChangeSpecialInputEnabledAttributes(showFilterButtonInternalButton, changeEventMethod, true);
2851     this.showFilterButton.SetEnabled(this.GetEnabled());
2852     this.UpdateFilterButtonHeight();
2853     this.UpdateShowHideFilterElementCssRules();
2854    }
2855   }
2856  }
2857 },
2858 CreateFilterStrategy: function() {
2859  if(this.enableFiltering)
2860   return new ListBoxFilterStrategy(this);
2861  return new ListEditFilterStrategyBase();
2862 },
2863 UpdateShowHideFilterElementCssRules: function() {
2864  var scrollDiv = this.GetScrollDivElement();
2865  var scrollDivClientHeight = scrollDiv.offsetHeight - ASPx.GetTopBottomBordersAndPaddingsSummaryValue(scrollDiv);
2866  var filterMainElementOffsetHeight = this.GetFilterMainElementHeight();
2867  if (ASPx.GetElementVisibility(this.filteringTextBox.GetMainElement(), true))
2868   scrollDivClientHeight += filterMainElementOffsetHeight;
2869  var showHideFilterStyle = this.EnsureShowHideFilterStyle();
2870  var mainElementSelector = "#" + this.name;
2871  var styleContent = [
2872   mainElementSelector + " " + this.GetCompactViewFilterAdjacentScrollDivSelector()
2873    + " { max-height: " + (scrollDivClientHeight - filterMainElementOffsetHeight) + "px; }",
2874   mainElementSelector + " " + this.GetCompactViewInactiveFilterAdjacentScrollDivSelector()
2875    + " { max-height: " + scrollDivClientHeight + "px; }"
2876  ];
2877  showHideFilterStyle.innerHTML = styleContent.join('\n');
2878 },
2879 EnsureShowHideFilterStyle: function() {
2880  if(!this.showHideFilterStyle) {
2881   this.showHideFilterStyle = this.FindShowHideFilterStyle();
2882   if(!this.showHideFilterStyle) {
2883    this.showHideFilterStyle = document.createElement('style');
2884    this.showHideFilterStyle.id = this.GetShowHideFilterStyleID();
2885    ASPx.Attr.AppendStyleType(this.showHideFilterStyle);
2886    document.getElementsByTagName('head')[0].appendChild(this.showHideFilterStyle);
2887   }
2888  }
2889  return this.showHideFilterStyle;
2890 },
2891 FindShowHideFilterStyle: function() {
2892  return ASPx.GetChildById(document.getElementsByTagName('head')[0], this.GetShowHideFilterStyleID());
2893 },
2894 GetShowHideFilterStyleID: function() {
2895  return this.name + "ShowHideFilterStyle";
2896 },
2897 GetFilterMainElementHeight: function() {
2898  if(!this.filterMainElementHeight) {
2899   var filteringTextBoxClone = this.filteringTextBox.GetMainElement().cloneNode(true);
2900   filteringTextBoxClone.style.position = "absolute";
2901   filteringTextBoxClone.style.visibility = "hidden";
2902   document.body.appendChild(filteringTextBoxClone);
2903   this.filterMainElementHeight = filteringTextBoxClone.offsetHeight;
2904   document.body.removeChild(filteringTextBoxClone);
2905   var filterMainElementClone = this.filterMainElement.cloneNode(false);
2906   filterMainElementClone.style.position = "absolute";
2907   filterMainElementClone.style.visibility = "hidden";
2908   ASPx.RemoveClassNameFromElement(filterMainElementClone, this.GetInactiveFilterElementClassName());
2909   ASPx.RemoveClassNameFromElement(filterMainElementClone, this.GetAnimatedFilterElementClassName());
2910   document.body.appendChild(filterMainElementClone);
2911   this.filterMainElementHeight += ASPx.GetTopBottomBordersAndPaddingsSummaryValue(filterMainElementClone);
2912   document.body.removeChild(filterMainElementClone);
2913  }
2914  return this.filterMainElementHeight;
2915 },
2916 RemoveShowHideFilterCssRules: function () {
2917  var showHideFilterStyle = this.FindShowHideFilterStyle();
2918  if(showHideFilterStyle)
2919   showHideFilterStyle.innerHTML = "";
2920 },
2921 UpdateFilterButtonHeight: function() {
2922  setTimeout(function () {
2923   this.showFilterButton.SetHeight(this.selectAllMainElement.offsetHeight - ASPx.GetVerticalBordersWidth(this.selectAllMainElement));
2924  }.aspxBind(this), 0);
2925 },
2926 EnsureFilteringTextBox: function() {
2927  this.filteringTextBox = this.FindFilteringTextBox();
2928  if(this.filteringTextBox) {
2929   this.filteringTextBox.UserInput.AddHandler(this.filterStrategy.OnInput.bind(this.filterStrategy));
2930   if(!this.customFilteringEditorID) {
2931    this.filteringTextBox.ownerListBox = this;
2932    var changeEventMethod = ASPx.Attr.ChangeEventsMethod(this.GetEnabled());
2933    this.ChangeSpecialInputEnabledAttributes(this.filteringTextBox.GetInputElement(), changeEventMethod, true);
2934    this.filteringTextBox.SetEnabled(this.GetEnabled());
2935    this.filteringTextBox.KeyDown.AddHandler(function(sender, args) {
2936     if(ASPx.Evt.GetKeyCode(args.htmlEvent) === ASPx.Key.Esc)
2937      sender.GetInputElement().value = "";
2938    });
2939   }
2940  }
2941 },
2942 FindFilteringTextBox: function() {
2943  var actualFilteringTextBoxID = this.customFilteringEditorID ? this.customFilteringEditorID : this.name + "_" + filteringTextBoxID;
2944  return ASPx.GetControlCollection().Get(actualFilteringTextBoxID);
2945 },
2946 CollectionChanged: function(isFiltering) {
2947  if(isFiltering)
2948   this.itemsManager.OnEndItemsFiltering();
2949 },
2950 ChangeItemsFilteredState: function(action) {
2951  this.itemsManager.ChangeItemsFilteredState(action);
2952 },
2953 RewriteFilteredItemIndices: function (newFilteredItemIndices) {
2954  this.itemsManager.RewriteFilteredItemIndices(newFilteredItemIndices);
2955 },
2956 BeforeClientFiltering: function () {
2957  this.itemsManager.BeforeClientFiltering();
2958 },
2959 ApplyFilterToItem: function (index, isSatisfy, savePrevState, isFilterReset) {
2960  this.itemsManager.ApplyFilterToItem(index, isSatisfy, savePrevState, isFilterReset);
2961 },
2962 RestorePrevFilteredState: function (index) {
2963  this.itemsManager.RestorePrevFilteredState(index);
2964 },
2965 IsItemFiltered: function (index) {
2966  return this.itemsManager.IsItemFiltered(index);
2967 },
2968 IsClientFilterApplied: function() {
2969  return !this.isComboBoxList && this.filterStrategy.filter != "" && !this.isCallbackMode;
2970 },
2971 MakeAllItemsVisible: function () {
2972  this.itemsManager.MakeAllItemsVisible();
2973 },
2974 ShowFilterElement: function() {
2975  ASPx.RemoveClassNameFromElement(this.filterMainElement, this.GetInactiveFilterElementClassName());
2976  this.showFilterButton.SetVisible(false);
2977  if(ASPx.Browser.VirtualKeyboardSupported) {
2978   this.ReplaceFilteringTextBoxShowNullTextOnFocusFunction();
2979   this.isFilterEditorShowing = false;
2980   this.filteringTextBox.GetInputElement().focus();
2981  }
2982  else
2983   setTimeout(function () {
2984    this.isFilterEditorShowing = false;
2985    this.filteringTextBox.GetInputElement().focus();
2986   }.aspxBind(this), 200);
2987 },
2988 HideFilterElement: function () {
2989  ASPx.AddClassNameToElement(this.filterMainElement, this.GetInactiveFilterElementClassName());
2990  this.showFilterButton.SetVisible(true);
2991  this.UpdateFilterButtonHeight();
2992  this.CorrectHeight(true);
2993  setTimeout(function () {
2994   this.filteringTextBox.UnlockFocusEvents();
2995   this.showFilterButton.GetInternalButton().focus();
2996  }.aspxBind(this), 0);
2997 },
2998 ReplaceFilteringTextBoxShowNullTextOnFocusFunction: function () {
2999  if(this.filteringTextBox.nullTextDisplayMode === ASPx.NullTextDisplayMode.UnfocusedAndFocused) {
3000   var origin = this.filteringTextBox.ensureActivateFocusedNullTextMechanism;
3001   var filteringTextBox = this.filteringTextBox;
3002   this.filteringTextBox.ensureActivateFocusedNullTextMechanism = function() {
3003    setTimeout(function() {
3004     origin.call(filteringTextBox);
3005     filteringTextBox.ensureActivateFocusedNullTextMechanism = origin;
3006     setTimeout(function () {
3007      if(filteringTextBox.isFocusedNullTextElementDisplayed())
3008       filteringTextBox.adjustFocusedNullTextElement();
3009     }, 300);
3010    }, 400);
3011   };
3012  }
3013 },
3014 EnsureSelectAllElements: function () {
3015  if(this.enableSelectAll && !this.selectAllMainElement) {
3016   this.EnsureSelectAllCheckElement();
3017   this.selectAllMainElement = this.GetChildElement(selectAllMainElementID);
3018   var selectAllClickableElement = this.GetSelectAllClickableElement();
3019   ASPx.Evt.AttachEventToElement(selectAllClickableElement, "click", this.onSelectAllClickableElementClick.bind(this));
3020  }
3021 },
3022 EnsureSelectAllCheckElement: function () {
3023  var selectAllCheckBoxInput = null;
3024  if(!this.IsNativeCheckBoxes()) {
3025   this.CreateSelectAllCheckBox();
3026   selectAllCheckBoxInput = this.GetSelectAllCheckBoxFocusableElement();
3027  }
3028  else {
3029   this.nativeSelectAllCheckBox = this.GetChildElement(selectAllCheckBoxID + "_I");
3030   this.nativeSelectAllCheckBox.disabled = !this.GetEnabled();
3031   selectAllCheckBoxInput = this.nativeSelectAllCheckBox;
3032  }
3033  var changeEventMethod = ASPx.Attr.ChangeEventsMethod(this.GetEnabled());
3034  this.ChangeSpecialInputEnabledAttributes(selectAllCheckBoxInput, changeEventMethod, true);
3035 },
3036 CreateSelectAllCheckBox: function () {
3037  var selectAllCheckBoxElement = this.GetChildElement(selectAllCheckBoxID);
3038  var selectAllCheckBoxInputElement = this.GetChildElement(selectAllCheckBoxID + "_S");
3039  var selectAllStateController = ASPx.CheckableElementStateController.Create(this.icbImageProperties, CheckBoxInputKey.Checked, CheckBoxInputKey.Unchecked, CheckBoxInputKey.Indeterminate, true);  
3040  this.selectAllCheckBox = new ASPx.CheckBoxInternal(selectAllCheckBoxInputElement, selectAllStateController, true, false,
3041   ASPx.CheckEditElementHelper.Instance, selectAllCheckBoxElement, true, undefined, undefined, this.accessibilityCompliant);
3042  this.selectAllCheckBox.CreateFocusDecoration(this.icbFocusedStyle);
3043  this.selectAllCheckBox.SetEnabled(this.GetEnabled());
3044  this.selectAllCheckBox.GetReadOnly = this.GetReadOnly.bind(this);
3045  this.selectAllCheckBox.CheckedChanged.AddHandler(this.onSelectAll.as
3045pxBind(this));
3046  if(ASPx.Browser.WebKitFamily)
3047   ASPx.Evt.AttachEventToElement(this.selectAllCheckBox.mainElement.parentNode, "selectstart", ASPx.Evt.PreventEventAndBubble);
3048 },
3049 onSelectAllClickableElementClick: function (evt) {
3050  if (!this.GetEnabled() || this.GetReadOnly()) {
3051   if (this.IsNativeCheckBoxes() || this.isNative)
3052    ASPx.Evt.PreventEvent(evt);
3053   return false;
3054  }
3055  if(this.IsSelectAllCheckBoxClicked(ASPx.Evt.GetEventSource(evt)))
3056   return;
3057  if(!this.IsNativeSelectAllCheckBoxClicked(ASPx.Evt.GetEventSource(evt))) {
3058   var currentCheckState = this.getSelectAllCheckElementState();
3059   var newCheckState = currentCheckState != ASPx.CheckBoxCheckState.Checked ?
3060    ASPx.CheckBoxCheckState.Checked : ASPx.CheckBoxCheckState.Unchecked;
3061   this.updateSelectAllCheckElementState(newCheckState);
3062  }
3063  this.onSelectAll();
3064 },
3065 onSelectAll: function () {
3066  this.LockUpdateSelectAllElements();
3067  var selectAllCheckState = this.getSelectAllCheckElementState();
3068  this.onSelectAllCore(selectAllCheckState);
3069  this.UnlockUpdateSelectAllElements();
3070 },
3071 onSelectAllCore: function (currentCheckState) {
3072  var toSelect = currentCheckState == ASPx.CheckBoxCheckState.Checked;
3073  var valueBeforeSelectAll = this.GetValue();
3074  var selectionBeforeSelectAll = this.GetValueFromValueInput();
3075  if (toSelect)
3076   this.SelectAll();
3077  else
3078   this.UnselectAll();
3079  if(selectionBeforeSelectAll !== this.GetValueFromValueInput())
3080   this.OnItemSelectionChanged(-1, toSelect, true, valueBeforeSelectAll !== this.GetValue());
3081 },
3082 getSelectAllCheckElementState: function () {
3083  if(this.selectAllCheckBox)
3084   return this.selectAllCheckBox.GetCurrentCheckState();
3085  if(this.nativeSelectAllCheckBox)
3086   return this.nativeSelectAllCheckBox.checked ? ASPx.CheckBoxCheckState.Checked : ASPx.CheckBoxCheckState.Unchecked;
3087  return null;
3088 },
3089 updateSelectAllCheckElementState: function (checkState) {
3090  if(this.selectAllCheckBox) {
3091   var checkValue = this.selectAllCheckBox.stateController.GetValueByCheckState(checkState);
3092   this.selectAllCheckBox.SetValue(checkValue, !this.isInitialized);
3093  } else if(this.nativeSelectAllCheckBox)
3094   this.nativeSelectAllCheckBox.checked = checkState === ASPx.CheckBoxCheckState.Checked;
3095 },
3096 updateSelectAllElementsState: function() {
3097  if(!this.IsUpdateSelectAllElementsLocked() && this.enableSelectAll) {
3098   this.EnsureSelectAllElements();
3099   this.updateSelectAllElementsStateCore();
3100  }
3101 },
3102 updateSelectAllElementsStateCore: function() {
3103  var selectAllCheckState = ASPx.CheckBoxCheckState.Unchecked;
3104  var isFilteredSelectedItemFound = false;
3105  var isFilteredUnselectedItemFound = false;
3106  var itemCount = this.GetItemCount();
3107  for(var i = 0; i < itemCount; i++) {
3108   if(this.IsItemFiltered(i)) {
3109    if(this.GetIsItemSelected(i))
3110     isFilteredSelectedItemFound = true;
3111    else
3112     isFilteredUnselectedItemFound = true;
3113   }
3114   if (isFilteredSelectedItemFound && isFilteredUnselectedItemFound) {
3115    selectAllCheckState = ASPx.CheckBoxCheckState.Indeterminate;
3116    break;
3117   }
3118   if(i == itemCount - 1 && isFilteredSelectedItemFound && !isFilteredUnselectedItemFound)
3119    selectAllCheckState = ASPx.CheckBoxCheckState.Checked;
3120  }
3121  this.updateSelectAllCheckElementState(selectAllCheckState);
3122 },
3123 changeSelectAllElementsEnabledState: function(enabled) {
3124  var selectAllCheckBoxInput = null;
3125  if(this.selectAllCheckBox) {
3126   this.selectAllCheckBox.SetEnabled(enabled);
3127   selectAllCheckBoxInput = this.GetSelectAllCheckBoxFocusableElement();
3128  }
3129  else if(this.nativeSelectAllCheckBox) {
3130   this.nativeSelectAllCheckBox.disabled = !enabled;
3131   selectAllCheckBoxInput = this.nativeSelectAllCheckBox;
3132  }
3133  if(selectAllCheckBoxInput) {
3134   var changeEventMethod = ASPx.Attr.ChangeEventsMethod(enabled);
3135   this.ChangeSpecialInputEnabledAttributes(selectAllCheckBoxInput, changeEventMethod, true);
3136  }
3137  ASPx.GetStateController().SetElementEnabled(this.selectAllMainElement, enabled);
3138 },
3139 NeedToHandleCellWidth: function() {
3140  return this.IsMultiColumn() && (ASPx.Browser.Firefox || ASPx.Browser.Edge);
3141 },
3142 CorrectCellNullWidthStyle: function(row) {
3143  if(!row) return;
3144  var cellCount = row.cells.length;
3145  for(var i = 0; i < cellCount; i++) {
3146   var cellStyle = !!window.getComputedStyle ? window.getComputedStyle(row.cells[i]) : ASPx.GetCurrentStyle(row.cells[i]);
3147   var originalWidth = parseInt(cellStyle.width);
3148   var needToApply = originalWidth === 0 || originalWidth <= ASPx.PxToInt(cellStyle.paddingLeft) || originalWidth <= ASPx.PxToInt(cellStyle.paddingRight);
3149   var action = needToApply ? ASPx.AddClassNameToElement : ASPx.RemoveClassNameFromElement;
3150   action(row.cells[i], NullSizeCellClassName);
3151  }
3152 },
3153 InitializeNativeCheckHandlers: function() {
3154  this.nativeCheckOnFocusHandler = function(evt) {
3155   this.SetFocusableCheckInput(ASPx.Evt.GetEventSource(evt));
3156  }.aspxBind(this);
3157 },
3158 ChangeNativeCheckEnabledAttributes: function(element, method) {
3159  if(this.nativeCheckOnFocusHandler)
3160   method(element, "focus", this.nativeCheckOnFocusHandler);
3161 },
3162 InitializeItemsAttributes: function() { 
3163  var listTable = this.GetListTable();
3164  if(this.isHasFakeRow){
3165   this.LockSynchronization();
3166   this.ClearItems();
3167   this.UnlockSynchronization();
3168  }
3169  listTable.ListBoxId = this.name;
3170  var rowIdConst = this.name + "_";
3171  if(this.hasSampleItem)
3172   this.InitializeItemAttributes(this.GetSampleItemRow(), rowIdConst + lbSIIdSuffix);
3173  if(!this.HasVirtualScrolling()) {
3174   rowIdConst += lbIIdSuffix;
3175   var count = this.GetItemCount();
3176   if(this.HasAccessibilityHeaderRow())
3177    count--;
3178   for (var i = 0; i < count; i++)
3179    this.InitializeItemAttributes(this.GetItemRow(i), rowIdConst + i);
3180  }
3181  var rows = listTable.rows;
3182  if(this.HasAccessibilityHeaderRow() && rows[rows.length - 1])
3183   rows[rows.length - 1].id = this.GetAccessibilityHeaderRowID();
3184 },
3185 InitializeItemAttributes: function(row, rowId) {
3186  var cells = row.cells;
3187  var itemCellsIdSuffixes = this.GetItemCellsIdPostfixes();
3188  for(var i = 0; i < row.cells.length; i++) {
3189   cells[i].style.textAlign = this.itemHorizontalAlign;
3190   cells[i].id = rowId + itemCellsIdSuffixes[i];
3191  }
3192  if(this.GetIsCheckColumnExists() && this.IsNativeCheckBoxes() && rowId != this.GetSampleItemRowID()) {
3193   var input = this.GetItemCheckBoxInput(this.GetItemIndexByRow(row));
3194   this.ChangeNativeCheckEnabledAttributes(input, ASPx.Attr.ChangeEventsMethod(this.GetEnabled()));
3195   this.ChangeSpecialInputEnabledAttributes(input, ASPx.Attr.ChangeEventsMethod(this.GetEnabled()));
3196  }
3197 },
3198 InitializePageSize: function(){
3199  var divElement = this.GetScrollDivElement();
3200  var count = this.GetItemCount();
3201  if (divElement && count > 0) {
3202   var firstVisibleRow = this.itemsManager.GetFirstVisibleItemRow();
3203   if(firstVisibleRow)
3204    this.scrollPageSize = Math.round(divElement.clientHeight / firstVisibleRow.offsetHeight) - 1;
3205  }
3206 },
3207 AddSelectAllStateItems: function(isInitialization) {
3208  if (this.enableSelectAll && typeof (ASPx.GetStateController) !== "undefined") {
3209   var stateController = ASPx.GetStateController();
3210   var name = this.name + "_" + selectAllMainElementID;
3211   if (!isInitialization)
3212    this.ClearStateItemCache(stateController, name, [""]);
3213   stateController.AddHoverItem(name, this.selectAllHoverClasses, this.selectAllHoverCssArray, "", null, null, true);
3214   stateController.AddDisabledItem(name, this.selectAllDisabledClasses, this.selectAllDisabledCssArray, "", null, null, true);
3215  }
3216 },
3217 RemoveSelectAllStateItems: function() {
3218  if (this.enableSelectAll && typeof (ASPx.GetStateController) !== "undefined") {
3219   var stateController = ASPx.GetStateController();
3220   var name = this.name + "_" + selectAllMainElementID;
3221   this.ClearStateItemCache(stateController, name, [""]);
3222   stateController.RemoveHoverItem(name, "");
3223   stateController.RemoveDisabledItem(name, "");
3224  }
3225 },
3226 ClearStateItemCache: function(stateController, name, suffixes) {
3227  for (var i = 0; i < suffixes.length; i++) {
3228   var element = document.getElementById(name + suffixes[i]);
3229   var elements = ASPx.GetNodes(element);
3230   elements.push(element);
3231   ASPx.Data.ForEach(elements, stateController.ClearElementCache.bind(stateController));
3232  }
3233 },
3234 AfterInitialize: function() {
3235  if(this.disableScrolling) {
3236   var scrollDiv = this.GetScrollDivElement();
3237   var mainElement = this.GetMainElement();
3238   var listTable = this.GetListTable();
3239   scrollDiv.style.height = mainElement.style.height = (listTable 
3240    ? ASPx.GetClearClientHeight(listTable)
3241    : this.GetListTableHeight() - ASPx.GetTopBottomBordersAndPaddingsSummaryValue(mainElement)) + "px";
3242  }
3243  this.CallbackSpaceInit(true);
3244  ASPxClientListBoxBase.prototype.AfterInitialize.call(this);
3245 },
3246 GetEnabledByServer: function(){
3247  return this.enabled;
3248 },
3249 SetEnabled: function(enabled){  
3250  ASPxClientListBoxBase.prototype.SetEnabled.call(this, enabled);
3251  this.CallbackSpaceInit(false);
3252 },
3253 SetReadOnlyInternal: function(readOnly) {
3254  ASPxClientListBoxBase.prototype.SetReadOnlyInternal.call(this, readOnly);
3255  if (readOnly) {
3256   this.RemoveSelectAllStateItems();
3257   this.stateControllerManager.RemoveHoverStateItem();
3258  }
3259  else {
3260   this.AddSelectAllStateItems(false);
3261   this.stateControllerManager.AddStateItems(true, true);
3262  }
3263 }, 
3264 CallbackSpaceInit: function(isInitialization){
3265  if(this.isCallbackMode){
3266   this.SetBottomScrollSpacerVisibility(this.GetScrollSpacerVisibility(false));
3267   this.SetTopScrollSpacerVisibility(this.GetScrollSpacerVisibility(true));
3268   if(isInitialization || this.isComboBoxList){
3269    this.EnsureSelectedItemVisible();
3270    ASPx.Evt.AttachEventToElement(this.GetScrollDivElement(), "scroll", aspxLBScroll);
3271   }
3272  }
3273 },
3274 GetListTable: function() {
3275  return this.tempCache.Get("ListTable", this.GetListTableCore, this);
3276 },
3277 GetListTableCore: function(){
3278  if(!ASPx.IsExistsElement(this.listTable))
3279   this.listTable = ASPx.GetElementById(this.name + lTableIdSuffix);
3280  return this.listTable;
3281 },
3282 GetItemElements: function() {
3283  return this.GetListTable().rows;
3284 },
3285 GetListTableHeight: function(){
3286  return this.GetListTable().offsetHeight;
3287 },
3288 GetHeaderDivElement: function(){
3289  if(!ASPx.IsExistsElement(this.headerDiv))
3290   this.headerDiv = ASPx.GetElementById(this.name + lbHeaderDivIdSuffix);
3291  return this.headerDiv;
3292 },
3293 GetHeaderTableElement: function(){
3294  if(!ASPx.IsExistsElement(this.headerTable)){
3295   var headerDiv = this.GetHeaderDivElement();
3296   this.headerTable = ASPx.GetNodeByTagName(headerDiv, "table", 0);
3297  }
3298  return this.headerTable;
3299 },
3300 GetScrollDivElement: function(){
3301  if(!ASPx.IsExistsElement(this.scrollDivElement))
3302   this.scrollDivElement = document.getElementById(this.name + lbDSuffix);
3303  return this.scrollDivElement;
3304 },
3305 GetItemElement: function(index) {
3306  return this.itemsManager.GetItemElement(index);
3307 },
3308 GetItemRow: function(index){
3309  return this.itemsManager.GetItemRow(index);
3310 },
3311 GetItemIndexByRow: function (itemRow) {
3312  return this.itemsManager.GetItemIndexByRow(itemRow);
3313 },
3314 GetItemSelectableElementsByRow: function(row) {
3315  return row.cells;
3316 },
3317 GetItemTexts: function(item) {
3318  return item.texts ? item.texts : [ item.text ];
3319 },
3320 GetItemHtmlContent: function(index) {
3321  return this.itemsManager.GetItemHtmlContent(index);
3322 },
3323 GetItemCount: function(){
3324  return this.itemsManager.GetItemCount();
3325 },
3326 GetListTableRowParent: function() {
3327  var listTable = this.GetListTable();
3328  return this.GetTableRowParent(listTable);
3329 },
3330 EnsureFixWidthRow: function (isSetItemHtmlProcessing) {
3331  var needfixWidthRow = !this.ContainsFixWidthRow() && this.IsMultiColumn() && (isSetItemHtmlProcessing || this.hasItemTemplate);
3332  if (needfixWidthRow)
3333   this.CreateFixWidthRow();
3334 },
3335 CreateFixWidthRow: function() {
3336  this.fixWidthRow = document.createElement("TR");
3337  var etalonRow = this.GetSampleItemRow();
3338  for(var i = 0; i < etalonRow.cells.length; i++) {
3339   var fixWidthCell = document.createElement("TD");
3340   var etalonCell = etalonRow.cells[i];
3341   var etalonCellStyle = ASPx.GetCurrentStyle(etalonCell);
3342   fixWidthCell.style.width = etalonCell.style.width || etalonCellStyle.width;
3343   fixWidthCell.style.borderLeftWidth = etalonCellStyle.borderLeftWidth;
3344   fixWidthCell.style.borderRightWidth = etalonCellStyle.borderRightWidth;
3345   fixWidthCell.style.borderLeftStyle = etalonCellStyle.borderLeftStyle;
3346   fixWidthCell.style.borderRightStyle = etalonCellStyle.borderRightStyle;
3347   fixWidthCell.style.paddingLeft = etalonCellStyle.paddingLeft;
3348   fixWidthCell.style.paddingRight = etalonCellStyle.paddingRight;
3349   fixWidthCell.style.boxSizing = etalonCellStyle.boxSizing;
3350   fixWidthCell.style.display = etalonCellStyle.display;
3351   this.fixWidthRow.appendChild(fixWidthCell);
3352  }
3353  ASPx.SetElementVisibility(this.fixWidthRow, "hidden");
3354  this.fixWidthRow.style.height = "0px";
3355  var listTableBody = this.GetListTableRowParent();
3356  listTableBody.insertBefore(this.fixWidthRow, listTableBody.childNodes[0]);
3357 },
3358 ContainsFixWidthRow: function() {
3359  return this.fixWidthRow && this.fixWidthRow.parentNode === this.GetListTableRowParent();
3360 },
3361 GetVisibleItemCount: function () {
3362  return this.itemsManager.GetVisibleItemCount();
3363 },
3364 GetIndexVisibleItem: function(item) {
3365  var count = this.GetItemCount();
3366  var visibleItemCount = 0;
3367  for(var i = 0; i < count; i ++){
3368   if(this.IsItemFiltered(i))
3369    visibleItemCount++;
3370   var curItem = this.GetItem(i);
3371   if(item.value === curItem.value && item.text === curItem.text)
3372    break;
3373  }
3374  return visibleItemCount;
3375 },
3376 GetItemCellCount: function(){
3377  if(this.hasSampleItem)
3378   return this.GetSampleItemRow().cells.length;
3379  if(this.GetItemCount() > 0)
3380   return this.itemsManager.GetFirstVisibleItemRow().cells.length;
3381  return 0;
3382 },
3383 GetItemTextCellCount: function(){
3384  return this.GetItemCellCount() - this.GetItemFirstTextCellIndex();
3385 },
3386 GetItemFirstTextCellIndex: function(){
3387  var itemFirstTextCellIndex  = 0;
3388  if(this.GetIsCheckColumnExists())
3389   itemFirstTextCellIndex++;
3390  if(this.imageCellExists)
3391   itemFirstTextCellIndex++;
3392  return itemFirstTextCellIndex;
3393 },
3394 GetItemFirstTextCell: function(index){
3395  return this.GetItemTextCell(index, 0);
3396 },
3397 GetItemTextCell: function(itemIndex, textCellIndex) {
3398  var rowElement = this.GetItemRow(itemIndex);
3399  if(rowElement == null) 
3400   return null;
3401  return rowElement.cells[this.GetItemFirstTextCellIndex() + textCellIndex];
3402 },
3403 GetItemTextCells: function(item) {
3404  var firstTextCellIndex = this.GetItemFirstTextCellIndex();
3405  return Array.prototype.slice.call(this.GetItemSelectableElementsByRow(item), firstTextCellIndex);
3406 },
3407 GetItemTopOffset: function(index){
3408  return this.itemsManager.GetItemTopOffset(index);
3409 },
3410 GetItemHeight: function(index){
3411  return this.itemsManager.GetItemHeight(index);
3412 },
3413 GetItemsHeight: function(){
3414  return this.itemsManager.GetItemsHeight();
3415 },
3416 GetItemsWidth: function () {
3417  return this.itemsManager.GetItemsWidth();
3418 },
3419 GetItemCheckBoxInput: function(index){
3420  var itemRow = this.GetItemRow(index);
3421  var checkBoxCell = itemRow ? itemRow.cells[this.GetCheckBoxCellIndex()] : null;
3422  return checkBoxCell ? ASPx.GetNodesByTagName(checkBoxCell, "input")[0] : null;
3423 },
3424 GetIsCheckColumnExists: function(){
3425  if(!this.checkCellExists)
3426   this.checkCellExists = this.CheckColumnSelectionMode();
3427  return this.checkCellExists;
3428 },
3429 GetCheckBoxCellIndex: function(){
3430  return 0;
3431 },
3432 GetImageCellIndex: function(){
3433  return this.GetIsCheckColumnExists() ? 1 : 0;
3434 },
3435 GetItemCellsIdPostfixes: function(){
3436  if(this.itemCellsIdPostfixes == null){
3437   this.itemCellsIdPostfixes = [];
3438   var i = 0;
3439   if(this.GetIsCheckColumnExists()) {
3440    this.itemCellsIdPostfixes.push(lbIPostfixes[0]);
3441    i++;
3442   }
3443   if(this.imageCellExists){
3444    this.itemCellsIdPostfixes.push(lbIPostfixes[1]);
3445    i++;
3446   }
3447   var cellCount = this.GetItemCellCount();
3448   for(; i < cellCount; i++) 
3449    this.itemCellsIdPostfixes.push(lbIPostfixes[2] + i);
3450  }
3451  return this.itemCellsIdPostfixes;
3452 },
3453 AdjustControl: function (nestedCall) {
3454  if(this.IsAdjustmentRequired()) 
3455   this.heightCorrected = false;
3456  ASPxClientEdit.prototype.AdjustControl.call(this, nestedCall);
3457 },
3458 AdjustControlCore: function(){
3459  this.RemoveShowHideFilterCssRules();
3460  if(this.disableScrolling)
3461   return;
3462  ASPxClientEdit.prototype.AdjustControlCore.call(this);
3463  this.CorrectSize();
3464  this.itemsManager.Adjust();
3465  this.EnsureSelectedItemVisible();
3466  if(this.showFilterButton) {
3467   this.UpdateFilterButtonHeight();
3468   this.UpdateShowHideFilterElementCssRules();
3469  }
3470 },
3471 CorrectSize: function() {
3472  if(this.isComboBoxList || this.disableScrolling || this.filterStrategy.currentCallbackIsFiltration)
3473   return;
3474  this.LockScrollHandler();
3475  this.CorrectHeight();
3476  this.CorrectWidth();
3477  this.InitializePageSize();
3478  this.UnlockScrollHandler();
3479 },
3480 OnCorrectSizeByTimer: function() {
3481  if(this.IsVisible())
3482   this.CorrectSize();
3483 }, 
3484 SetProtectionFromFlick_inFF: function(changeVisibility, changeDisplay){
3485  if(!ASPx.Browser.Firefox) return;
3486  var listTable = this.GetListTable();
3487  if(changeVisibility)
3488   listTable.style.visibility = "hidden";
3489  if(changeDisplay)
3490   listTable.style.display = "none";
3491 },
3492 ResetProtectionFromFlick_inFF: function(){
3493  if(!ASPx.Browser.Firefox) return;
3494  var listTable = this.GetListTable();
3495  listTable.style.visibility = "";
3496  listTable.style.display = "";
3497 },
3498 CorrectHeight: function(force){
3499  if(ASPx.Browser.Firefox && this.heightCorrected && !force) return; 
3500  this.heightCorrected = true;
3501  var mainElement = this.GetMainElement();
3502  var divElement = this.GetScrollDivElement();
3503  divElement.style.height = "0px";
3504  var height = mainElement.offsetHeight;
3505  divElement.style.height = height + "px";
3506  var extrudedHeight = mainElement.offsetHeight;
3507  var heightCorrection = extrudedHeight - height;
3508  if(heightCorrection > 0){
3509   var divHeight = divElement.offsetHeight;
3510   this.SetProtectionFromFlick_inFF(true, false);
3511   divElement.style.height = (divHeight - heightCorrection) + "px";
3512   this.ResetProtectionFromFlick_inFF(); 
3513   extrudedHeight = mainElement.offsetHeight;
3514   var paddingsHeightCorrection = extrudedHeight - height;
3515   if(paddingsHeightCorrection > 0)
3516    divElement.style.height = (divHeight - heightCorrection - paddingsHeightCorrection) + "px";
3517  } 
3518 },
3519 IsMultiColumn: function(){
3520  return this.columnFieldNames.length > 0;
3521 },
3522 IsCorrectWidthRequired: function(){
3523  return true;
3524 },
3525 GetVisibleColumnCount: function() {
3526  if (!this.visibleColumnCount) {
3527   this.visibleColumnCount = this.IsMultiColumn() ?
3528    ASPx.Data.CollectionToArray(this.GetSampleItemRow().cells)
3529     .slice(this.GetItemFirstTextCellIndex())
3530     .filter(function (cell) { return ASPx.GetElementDisplay(cell); }).length
3531    : -1;
3532  }
3533  return this.visibleColumnCount;
3534 },
3535 CorrectWidth: function () {
3536  if(!this.IsCorrectWidthRequired()) return;
3537  if(this.IsMultiColumn())
3538   this.CorrectMultiColumnWidth();
3539  else
3540   this.CorrectNonMultiColumnWidth();
3541 },
3542 CorrectMultiColumnWidth: function(){
3543  var scrollBarWidth = this.GetVerticalScrollBarWidth(); 
3544  this.CorrectMultiColumnHeaderWidth(scrollBarWidth);
3545 },
3546 CollapseMultiColumnHeaderWidth:function(){
3547  var headerDivElement = this.GetHeaderDivElement();
3548  headerDivElement.style.width = "0px";
3549 },
3550 CorrectMultiColumnHeaderWidth: function(scrollBarWidth){
3551  var headerDivElement = this.GetHeaderDivElement();
3552  if(ASPx.IsExistsElement(headerDivElement)){
3553   var headerTable;
3554   if(ASPx.Browser.WebKitFamily){
3555    headerTable = this.GetHeaderTableElement();
3556    if(!ASPx.IsExistsElement(headerTable))
3557     headerTable = null;
3558   }
3559   if(this.rtl)
3560    headerDivElement.style.paddingLeft = scrollBarWidth + "px";
3561   else
3562    headerDivElement.style.paddingRight = scrollBarWidth + "px";
3563   if(headerTable)
3564    window.setTimeout(function() { headerTable.style.width = "100%"; }, 0);
3565  }
3566 },
3567 CorrectNonMultiColumnWidth: function(){
3568  var mainElement = this.GetMainElement(),
3569   divElement = this.GetScrollDivElement();
3570  if(this.width == ""){
3571   var itemsWidth = this.GetItemsWidth();
3572   if (itemsWidth != 0 || !ASPx.Browser.NetscapeFamily) { 
3573    divElement.style.width = Math.max((itemsWidth + this.GetVerticalScrollBarWidth()), this.scrollDivMinWidth) + "px";
3574    if(ASPx.Browser.Firefox) 
3575     mainElement.style.width = divElement.offsetWidth + "px";
3576   }
3577  } else {  
3578   mainElement.style.width = this.width;
3579   if(this.width !== "100%") {
3580    var scrollDivWidth = ASPx.Browser.WebKitFamily ? 1 : 0;
3581    var oldScrollTop = divElement.scrollTop;
3582    divElement.style.width = scrollDivWidth + "px";
3583    scrollDivWidth = ASPx.Browser.Edge ? mainElement.clientWidth - ASPx.GetHorizontalBordersWidth(mainElement) : mainElement.clientWidth;
3584    divElement.style.width = scrollDivWidth + "px";
3585    var isScrollEventWillRaised = divElement.scrollTop != oldScrollTop;
3586    if(isScrollEventWillRaised)
3587     this.itemsManager.DeactivateScrollHandler();
3588    divElement.scrollTop = oldScrollTop;
3589   }
3590  }
3591 },
3592 UpdateAdjustmentFlags: function() {
3593  var mainElement = this.GetMainElement();
3594  if(mainElement) {
3595   var mainElementStyle = ASPx.GetCurrentStyle(mainElement);
3596   this.UpdatePercentSizeConfig([this.width], [mainElementStyle.height, mainElement.style.height]);
3597  }
3598 },
3599 EnsureSelectedItemVisible: function() {
3600  var index = this.GetSelectedIndex();
3601  if(index != -1)
3602   this.itemsManager.MakeItemVisibleAtTop(index);
3603 },
3604 MakeItemVisible: function(index) { 
3605  if(!this.itemsManager.IsItemVisible(index))
3606   this.itemsManager.MakeItemVisibleAtTop(index);
3607 },
3608 ScrollItemToTop: function(index) {
3609  this.LockScrollHandler();
3610  this.SetScrollTop(this.GetItemTopOffset(index));
3611  this.UnlockScrollHandler();
3612 },
3613 GetScrollDivChildElementHeight: function() {
3614  return this.itemsManager.GetScrollDivChildElementHeight();
3615 },
3616 SetScrollTop: function(scrollTop){
3617  var scrollDiv = this.GetScrollDivElement();
3618  if(scrollDiv){ 
3619   scrollDiv.scrollTop = scrollTop;
3620   if(ASPx.Browser.Opera) 
3621    this.CachedScrollTop();
3622  }   
3623 },
3624 CachedScrollTop: function(){
3625  var scrollDiv = this.GetScrollDivElement();
3626  scrollDiv.cachedScrollTop = scrollDiv.scrollTop;
3627 },
3628 RestoreScrollTopFromCache: function(){
3629  var scrollDiv = this.GetScrollDivElement();
3630  if(scrollDiv && ASPx.IsExists(scrollDiv.cachedScrollTop))
3631   scrollDiv.scrollTop = scrollDiv.cachedScrollTop;
3632 },
3633 IsListBoxWidthLessThenList: function(){
3634  var divElement = this.GetScrollDivElement();
3635  var listTable = this.GetListTable();
3636  var listTabelWidth = listTable.style.width;
3637  var isLess = false;
3638  listTable.style.width = "";
3639  isLess = listTable.offsetWidth < divElement.offsetWidth;
3640  listTable.style.width = listTabelWidth;
3641  return isLess;
3642 },
3643 GetVerticalScrollBarWidth: function(){
3644  var divElement = this.GetScrollDivElement(); 
3645  if(!this.verticalScrollBarWidth || this.verticalScrollBarWidth <= 0){
3646   this.verticalScrollBarWidth = this.GetVerticalScrollBarWidthCore(divElement);
3647   return this.verticalScrollBarWidth;
3648  } else
3649   return this.GetIsVerticalScrollBarVisible(divElement) ? this.verticalScrollBarWidth : 0;
3650 },
3651 GetIsVerticalScrollBarVisible: function(divElement){
3652  var verticalOverflow = this.GetVerticalOverflow(divElement);
3653  if(verticalOverflow != "auto"){
3654   return divElement.clientHeight < this.GetListTableHeight();
3655  } else {
3656   var borderWidthWithScroll = divElement.offsetWidth - divElement.clientWidth;
3657   return borderWidthWithScroll == this.scrollDivBordersWidthWithScroll;
3658  }
3659 },
3660 GetVerticalScrollBarWidthCore: function(divElement){
3661  var overflowYReserv = this.GetVerticalOverflow(divElement);
3662  this.SetVerticalOverflow(divElement, "auto");
3663  this.scrollDivBordersWidthWithScroll = divElement.offsetWidth - divElement.clientWidth;
3664  this.SetProtectionFromFlick_inFF(false, true);
3665  this.SetVerticalOverflow(divElement, "hidden");
3666  var bordersWidthWithoutScroll = divElement.offsetWidth - divElement.clientWidth;
3667  this.SetVerticalOverflow(divElement, overflowYReserv);
3668  this.ResetProtectionFromFlick_inFF();
3669  return this.scrollDivBordersWidthWithScroll - bordersWidthWithoutScroll;
3670 },
3671 GetVerticalOverflowPropertyName: function() {
3672  if(ASPx.Browser.WebKitFamily || ASPx.Browser.AndroidDefaultBrowser || ASPx.Browser.Firefox && ASPx.Browser.Version >= 3)
3673   return "overflowY";
3674  return "overflow";
3675 },
3676 GetVerticalOverflow: function(element){
3677  return element.style[this.GetVerticalOverflowPropertyName()];
3678 },
3679 SetVerticalOverflow: function(element, value) {
3680  element.style[this.GetVerticalOverflowPropertyName()] = value;
3681 },
3682 MultiSelectionMode: function(){
3683  return this.selectionMode != ListBoxSelectionMode.Single;
3684 },
3685 CheckColumnSelectionMode: function(){
3686  return this.selectionMode == ListBoxSelectionMode.CheckColumn;
3687 },
3688 OnItemClick: function(index, evt){
3689  if(!this.isInitialized) 
3690   return;
3691  if (this.GetReadOnly()) {
3692   ASPx.Evt.PreventEvent(evt);
3693   return this.OnItemClickOrDblClickReadOnly();
3694  }
3695  if(this.CheckColumnSelectionMode() && this.IsCheckBoxClicked(evt))
3696   this.GetItemSelectionHelper().OnItemCheckBoxClick(index, evt);
3697  else
3698   this.GetItemSelectionHelper().OnItemClick(index, evt);
3699  this.SetFocus();
3700  this.RaiseItemClick();
3701 },
3702 OnItemClickOrDblClickReadOnly: function(){
3703  return false;
3704 },
3705 OnItemDblClick: function(){
3706  if (this.GetReadOnly())
3707   return this.OnItemClickOrDblClickReadOnly();
3708  return this.RaiseItemDoubleClick();
3709 },
3710 CanChangeSelection: function(){
3711  return !this.GetReadOnly() || !this.isInitialized;
3712 },
3713 SelectIndexSilent: function(index){ 
3714  return this.SetItemSelectionStateSilent(index);
3715 },
3716 SetItemSelectionStateSilent: function(index) {
3717  if(!this.CanChangeSelection())
3718   return;
3719  var oldSelectionIndex = this.GetSelectedIndex();
3720  this.LockSelectionEvents();
3721  this.SetSelectedIndexCore(index);
3722  this.UnlockSelectionEvents();
3723  return index !== oldSelectionIndex;
3724 },
3725 SetItemSelectionAppearance: function (index, selected, controller, checkCanChangeSelection) {
3726  if (checkCanChangeSelection && !this.CanChangeSelection())
3727   return;
3728  if(!controller)
3729   controller = ASPx.GetStateController();
3730  var itemFirstTextCell = this.GetItemFirstTextCell(index);
3731  if(selected)
3732   controller.SelectElementBySrcElement(itemFirstTextCell);
3733  else
3734   controller.DeselectElementBySrcElement(itemFirstTextCell);
3735 },
3736 GetItemSelectionHelper: function(){
3737  if(!this.itemSelectionHelper)
3738   this.itemSelectionHelper = this.CreateItemSelectionHelper();
3739  return this.itemSelectionHelper;
3740 },
3741 CreateItemSelectionHelper: function(){
3742  if(this.selectionMode == ListBoxSelectionMode.Single)
3743   return new ListBoxSingleSelectionHelper(this);
3744  else if(this.selectionMode == ListBoxSelectionMode.Multiple)
3745   return new ListBoxMultiSelectionHelper(this);
3746  else if(this.selectionMode == ListBoxSelectionMode.CheckColumn)
3747   return new ListBoxCheckSelectionHelper(this);
3748 },
3749 GetValue: function(){
3750  var index = this.GetSelectedIndex();
3751  if(0 <= index && index < this.itemsValue.length)
3752   return this.itemsValue[index];
3753  return null;
3754 },
3755 SetValue: function(value){
3756  var index = this.FindItemIndexByValue(value);
3757  this.SetSelectedIndex(index);
3758 },
3759 GetSelectedItem: function(){
3760  var index = this.GetSelectedIndex();
3761  return this.GetItem(index);
3762 },
3763 GetSelectedIndex: function(){
3764  if(!this.itemSelectionHelper)
3765   return this.GetSelectedIndexInternal();
3766  return this.GetItemSelectionHelper().GetSelectedIndex();
3767 },
3768 SetSelectedIndex: function(index){
3769  this.LockSelectionEvents();
3770  this.SetSelectedIndexCore(index);
3771  this.EnsureSelectedItemVisible(index);
3772  this.UnlockSelectionEvents();
3773 },
3774 SetSelectedIndexCore: function(index){
3775  this.GetItemSelectionHelper().SetSelectedIndex(index);
3776 },
3777 GetSelectedIndices: function(){
3778  return this.GetItemSelectionHelper().GetSelectedIndices();
3779 },
3780 GetSelectedValues: function(){ 
3781  return this.GetItemSelectionHelper().GetSelectedValues();
3782 },
3783 GetSelectedItems: function(){
3784  return this.GetItemSelectionHelper().GetSelectedItems();
3785 },
3786 SelectAll: function(){
3787  this.SelectIndices();
3788 },
3789 UnselectAll: function(){
3790  this.UnselectIndices();
3791 },
3792 SelectIndices: function(indices){
3793  this.LockSelectionEvents();
3794  this.GetItemSelectionHelper().SelectIndices(indices);
3795  this.UnlockSelectionEvents();
3796 },
3797 SelectItems: function(items){
3798  this.LockSelectionEvents();
3799  this.GetItemSelectionHelper().SelectItems(items);
3800  this.UnlockSelectionEvents();
3801 },
3802 SelectValues: function(values){
3803  this.LockSelectionEvents();
3804  this.GetItemSelectionHelper().SelectValues(values);
3805  this.UnlockSelectionEvents();
3806 },
3807 UnselectIndices: function(indices){
3808  this.LockSelectionEvents();
3809  this.GetItemSelectionHelper().UnselectIndices(indices);
3810  this.UnlockSelectionEvents();
3811 },
3812 UnselectItems: function(items){
3813  this.LockSelectionEvents();
3814  this.GetItemSelectionHelper().UnselectItems(items);
3815  this.UnlockSelectionEvents();
3816 },
3817 UnselectValues: function(values){
3818  this.LockSelectionEvents();
3819  this.GetItemSelectionHelper().UnselectValues(values);
3820  this.UnlockSelectionEvents();
3821 },
3822 GetIsItemSelected: function(index){
3823  return this.GetItemSelectionHelper().GetIsItemSelected(index);
3824 },
3825 GetFocusedIndex: function(){
3826  return this.GetItemSelectionHelper().GetFocusedIndex();
3827 },
3828 UpdateInternalState: function(){
3829  this.UpdateHiddenInputs();
3830 },
3831 IsUpdateHiddenInputsLocked: function(){
3832  return this.GetItemSelectionHelper().IsUpdateInternalSelectionStateLocked();
3833 },
3834 UpdateHiddenInputs: function(){
3835  if(this.IsUpdateHiddenInputsLocked())
3836   return;
3837  if(this.MultiSelectionMode()){ 
3838   var element = this.FindStateInputElement();
3839   if(ASPx.IsExistsElement(element)) {
3840    var sb = [ ];
3841    var serialiser = this.GetSerializingHelper();
3842    var selectedIndices = this.GetSelectedIndices();
3843    for(var i = 0; i < selectedIndices.length; i++)
3844     serialiser.SerializeAtomValue(sb, this.GetItemValue(selectedIndices[i]));
3845    element.value = sb.join("");
3846   }
3847  } else 
3848   ASPxClientListBoxBase.prototype.UpdateHiddenInputs.call(this);
3849 },
3850 UseDelayedSpecialFocus: function() { 
3851  return true;
3852 },
3853 GetInnerEditors: function() {
3854  var result = ASPxClientListBoxBase.prototype.GetInnerEditors();
3855  if(this.filteringTextBox) {
3856   result.push(this.filteringTextBox);
3857  }
3858  return result;
3859 },
3860 AdjustWidthInDropDown: function(parentComboBoxMainElement, isCallbackMode, customWidth) {
3861  var lbScrollDiv = this.GetScrollDivElement();
3862  var lbMainElement = this.GetMainElement();
3863  var scrollWidth = 0;
3864  if (this.IsMultiColumn() && isCallbackMode && this.GetScrollSpacerVisibility(false) && this.GetBottomScrollSpacerHeight() == 0)
3865   this.SetBottomScrollSpacerVisibility(true);
3866  var keepCurrentWidth = this.HasVirtualScrolling() && this.hasDecoratedItems && this.isComboBoxScrollingCallbackProcessing;
3867  if(!keepCurrentWidth) {
3868   lbMainElement.style.width = "";
3869   lbScrollDiv.style.paddingRight = "0px";
3870   lbScrollDiv.style.width = "100%";
3871  }
3872  else
3873   this.isComboBoxScrollingCallbackProcessing = false;
3874  if (customWidth != "") {
3875   lbMainElement.style.width = customWidth;
3876   var width = lbMainElement.clientWidth;
3877   var scrollInfo = this.SetScrollDivAndCorrectionForScroll(width, false);
3878   width = scrollInfo.scrollDivWidth;
3879   scrollWidth = scrollInfo.scrollWidth;
3880   if(!this.enableEllipsis) {
3881    var difference = this.GetItemsWidth() - lbScrollDiv.clientWidth;
3882    if (difference > 0) {
3883     lbMainElement.style.width = (lbMainElement.offsetWidth + difference) + "px";
3884     lbScrollDiv.style.width = (lbMainElement.clientWidth) + "px";
3885    }
3886   }
3887  } else {
3888   var width = this.GetItemsWidth();
3889   var scrollInfo = this.SetScrollDivAndCorrectionForScroll(width, true);
3890   width = scrollInfo.scrollDivWidth;
3891   scrollWidth = scrollInfo.scrollWidth;
3892   if (ASPx.Browser.Firefox && lbMainElement.offsetWidth < lbScrollDiv.offsetWidth)
3893    lbMainElement.style.width = "0%"; 
3894   if (parentComboBoxMainElement) {
3895    var widthDifference = parentComboBoxMainElement.offsetWidth - lbMainElement.offsetWidth;
3896    if (widthDifference > 0) {
3897     this.scrollDivMinWidth = width + widthDifference;
3898     lbScrollDiv.style.width = this.scrollDivMinWidth + "px";
3899     var twoBorderSize = (lbMainElement.offsetWidth - lbMainElement.clientWidth);
3900     lbMainElement.style.width = (width + widthDifference + twoBorderSize) + "px"; 
3901    }
3902   }
3903  }
3904  if (this.IsMultiColumn())
3905   this.CorrectMultiColumnHeaderWidth(scrollWidth);
3906  if (this.NeedToHandleCellWidth())
3907   this.CorrectCellNullWidthStyle(this.itemsManager.GetFirstVisibleItemRow());
3908  if (this.ContainsFixWidthRow()) {
3909   var lbHeaderDiv = this.GetHeaderDivElement();
3910   if (lbHeaderDiv)
3911    lbScrollDiv.style.width = lbHeaderDiv.offsetWidth - ASPx.GetLeftRightBordersAndPaddingsSummaryValue(lbScrollDiv) + "px";
3912  }
3913  return lbScrollDiv.offsetWidth;
3914 },
3915 SetScrollDivAndCorrectionForScroll: function(width, widthByContent) {
3916  var lbScrollDiv = this.GetScrollDivElement();
3917  var scrollWidth = this.GetVerticalScrollBarWidth();
3918  var browserCanHaveScroll = this.GetVerticalOverflow(lbScrollDiv) == "auto";
3919  if (widthByContent && browserCanHaveScroll)
3920   width += scrollWidth;
3921  lbScrollDiv.style.width = width + "px";
3922  return { scrollDivWidth: width, scrollWidth: scrollWidth };
3923 },
3924 BeforeAdjustHeightInDropDown: function() {
3925  this.GetMainElement().style.height = "0px";
3926 },
3927 AdjustHeightInDropDown: function(customHeight, visibleRowCount) {
3928  this.BeforeAdjustHeightInDropDown();
3929  if(this.itemsManager.smallestItemHeight === 0)
3930   this.itemsManager.updateSmallestItemSize();
3931  var lbHeight = 0;
3932  if (customHeight == "")
3933   lbHeight = this.GetHeightByContent(visibleRowCount);
3934  else
3935   lbHeight = this.GetHeightByServerValue(customHeight);
3936  this.itemsManager.Adjust(); 
3937  this.InitializePageSize();
3938  return lbHeight;
3939 },
3940 GetHeightByContent: function(visibleRowCount) {
3941  var lbScrollDiv = this.GetScrollDivElement(),
3942   itemCount = this.GetVisibleItemCount(),
3943   hasVerticalScrollbar = itemCount > visibleRowCount;
3944  lbScrollDiv.style.height = "";
3945  var height = 0;
3946  if (hasVerticalScrollbar)
3947   height = this.itemsManager.GetTotalItemsHeight(0, visibleRowCount - 1);
3948  else {
3949   if(itemCount !== 0) {
3950    height = this.GetItemsHeight();
3951   }
3952  }
3953  height += "px";
3954  lbScrollDiv.style.height = height;
3955  height = lbScrollDiv.offsetHeight;
3956  height += ASPx.GetTopBottomBordersAndPaddingsSummaryValue(this.GetMainElement());
3957  var lbHeaderDiv = this.GetHeaderDivElement();
3958  if (ASPx.IsExists(lbHeaderDiv))
3959   height += lbHeaderDiv.offsetHeight;
3960  return height;
3961 },
3962 GetHeightByServerValue: function(customHeight) {
3963  var lbMainElement = this.GetMainElement();
3964  var lbScrollDiv = this.GetScrollDivElement();
3965  var height = customHeight;
3966  lbMainElement.style.height = "0px";
3967  lbScrollDiv.style.height = "0px";
3968  lbMainElement.style.height = height;
3969  var trueLbOffsetHeight = lbMainElement.offsetHeight;
3970  var trueLbClientHeight = lbMainElement.clientHeight;
3971  lbScrollDiv.style.height = lbMainElement.clientHeight + "px";
3972  var lbHeightCorrection = lbMainElement.offsetHeight - trueLbOffsetHeight;
3973  lbScrollDiv.style.height = (trueLbClientHeight - lbHeightCorrection) + "px";
3974  height = lbMainElement.offsetHeight;
3975  return height;
3976 },
3977 GetLoadingParentElement: function() {
3978  return this.GetScrollDivElement().parentNode;
3979 },
3980 ShowLoadingPanel: function() { 
3981  if(!this.isComboBoxList){
3982   var loadingParentElement = this.GetLoadingParentElement();
3983   var lp = this.CreateLoadingPanelWithAbsolutePosition(loadingParentElement);
3984   this.PreventMouseWheelOnElement(lp);
3985  }
3986 },
3987 ShowLoadingDiv: function () {
3988  if(!this.isComboBoxList){
3989   var loadingParentElement = this.GetLoadingParentElement();
3990   var ld = this.CreateLoadingDiv(loadingParentElement);
3991   this.PreventMouseWheelOnElement(ld);
3992  }
3993 },
3994 PreventMouseWheelOnElement: function(element) {
3995  if(!element) return;
3996  var wheelEventName = ASPx.Evt.GetMouseWheelEventName();
3997  ASPx.Evt.AttachEventToElement(element, wheelEventName, function(evt) {
3998   if(this.scrollHelper.GetIsAnySpacerVisible())
3999    ASPx.Evt.PreventEvent(evt);
4000  }.aspxBind(this));
4001 },
4002 ParseCallbackResult: function(result, shouldSelectSilentDelegate){
4003  var gottenEgdeOfCollection = false;
4004  var isLoadindToTopByScroll = this.scrollHelper.IsScrolledToTopSpacer();
4005  if(result[CONSTANTS.CALLBACK_RESULTS.ITEMS].length) {
4006   var deserializedItems = this.DeserializeItems(result[CONSTANTS.CALLBACK_RESULTS.ITEMS]);
4007   this.LoadItemsFromCallback(isLoadindToTopByScroll, deserializedItems, shouldSelectSilentDelegate);
4008   gottenEgdeOfCollection = deserializedItems.length < this.callbackPageSize;
4009  }
4010  var noMoreItemsForLoadThisDirection = !result[CONSTANTS.CALLBACK_RESULTS.ITEMS].length || gottenEgdeOfCollection;
4011  this.SetScrollSpacerVisibility(isLoadindToTopByScroll, !noMoreItemsForLoadThisDirection);
4012  this.scrollHelper.Reset();
4013 },
4014 LoadItemsFromCallback: function(isToTop, deserializedItems, shouldSelectSilentDelegate){
4015  this.LockSynchronizationOnInternalCallback();
4016  this.BeginUpdate();
4017  var isMultiSelect = this.MultiSelectionMode();
4018  this.RemoveAccessibilityHeaderRow();
4019  if(isToTop){
4020   var scrollHeightCorrection = 0;
4021   for(var i = deserializedItems.length - 1; i >= 0; i--) {
4022    this.InsertItemInternal(0, deserializedItems[i]);
4023    scrollHeightCorrection += this.GetItemHeight(0);
4024   } 
4025   this.GetScrollDivElement().scrollTop += scrollHeightCorrection;
4026   this.serverIndexOfFirstItem -= deserializedItems.length;
4027   if(this.serverIndexOfFirstItem < 0) this.serverIndexOfFirstItem = 0;
4028  } else {
4029   for(var i = 0; i < deserializedItems.length; i++) {
4030    var itemIndex = this.AddItemInternal(deserializedItems[i]);
4031    var shouldSelectSilent = shouldSelectSilentDelegate && shouldSelectSilentDelegate(deserializedItems[i].value, deserializedItems[i].text);
4032    this.SelectValueOnLoad(itemIndex, deserializedItems[i].selected, shouldSelectSilent, isMultiSelect);
4033   } 
4034  }
4035  if(this.changeSelectAfterCallback != 0) {
4036   var newIndex = this.GetSelectedIndex() + this.changeSelectAfterCallback;
4037   newIndex = this.GetAdjustedIndex(newIndex);
4038   this.SelectIndexSilent(newIndex);
4039   if(this.scrollHelper.isScrolledToTopSpacer)
4040    this.ScrollItemToTop(newIndex);
4041   else
4042    this.MakeItemVisible(newIndex);
4043  }
4044  this.AddAccessibilityHeaderRow();
4045  this.EndUpdate();
4046  this.UnlockSynchronizationOnInternalCallback();
4047 },
4048 SelectValueOnLoad: function (index, selected, shouldSelectSilent, isMultiSelect) {
4049  if(selected && this.changeSelectAfterCallback == 0) {
4050   if(isMultiSelect) {
4051    this.SelectIndices([index]);
4052   } else {
4053    if(shouldSelectSilent)
4054     this.SelectIndexSilent(index);
4055    else
4056     this.SelectIndex(index);
4057   }
4058  }
4059 },
4060 CreateSerializingHelper: function(){
4061  return new ListBoxItemsSerializingHelper(this);
4062 },
4063 InCallback: function(){
4064  var callbackOwner = this.GetCallbackOwnerControl();
4065  if(callbackOwner != null)
4066   return callbackOwner.InCallback();
4067  return ASPxClientListEdit.prototype.InCallback.call(this);
4068 },
4069 GetItemsRangeForLoad: function(){
4070  return this.scrollHelper.GetItemsRangeForLoad();
4071 },
4072 GetScrollSpacerElement: function(isTop){
4073  return document.getElementById(this.name + (isTop ? lbTSIdSuffix : lbBSIdSuffix));
4074 },
4075 GetScrollSpacerVisibility: function(isTop){
4076  if(!this.clientEnabled)
4077   return false;
4078  return isTop ? this.isTopSpacerVisible : this.isBottomSpacerVisible;
4079 },
4080 SetScrollSpacerVisibility: function(isTop, visibility){
4081  this.LockScrollHandler();
4082  var spacer = this.GetScrollSpacerElement(isTop);
4083  if(spacer){
4084   if(visibility)
4085    spacer.style.height = this.GetRequiredScrollSpacerHeight() + "px";
4086   if(this.clientEnabled){
4087    if(isTop)
4088     this.isTopSpacerVisible = visibility;
4089    else
4090     this.isBottomSpacerVisible = visibility;
4091   }
4092   if(ASPx.GetElementDisplay(spacer) != visibility){
4093    ASPx.SetElementDisplay(spacer, visibility);
4094    ASPx.GetElementVisibility(spacer, visibility);
4095   }
4096  }
4097  this.itemsManager.OnScrollSpacerVisibilityChanged();
4098  this.UnlockScrollHandler();
4099 },
4100 GetRequiredScrollSpacerHeight: function() {
4101  return this.GetScrollDivElement().clientHeight;
4102 },
4103 SetTopScrollSpacerVisibility: function(visibility){
4104  this.SetScrollSpacerVisibility(true, visibility);
4105 },
4106 SetBottomScrollSpacerVisibility: function(visibility){
4107  this.SetScrollSpacerVisibility(false, visibility);
4108 },
4109 GetTopScrollSpacerHeight: function(){
4110  return this.GetScrollSpacerVisibility(true) ? this.GetScrollSpacerElement(true).clientHeight : 0;
4111 },
4112 GetBottomScrollSpacerHeight: function(){
4113  return this.GetScrollSpacerVisibility(false) ? this.GetScrollSpacerElement(false).clientHeight : 0;
4114 },
4115 GetTopSpacersHeight: function() {
4116  return this.itemsManager.GetTopSpacersHeight();
4117 },
4118 SendCallback: function(onSuccess) {
4119  if(!this.InCallback()){
4120   this.ShowLoadingElements();
4121   var callbackOwner = this.GetCallbackOwnerControl();
4122   if(callbackOwner != null)
4123    callbackOwner.SendCallback(onSuccess);
4124   else {
4125    var argument = this.GetCallbackArguments();
4126    this.CreateCallback(argument, null, onSuccess);
4127   }
4128  }
4129 },
4130 OnCallback: function(result, shouldSelectSilentDelegate) {
4131  if(result.serverMode)
4132   this.UpdateStateObjectWithObject({serverMode: true});
4133  if(!this.filterStrategy || !this.filterStrategy.ShouldDiscardCallbackResult()) {
4134   this.ParseCallbackResult(result, shouldSelectSilentDelegate);
4135   if(!this.isComboBoxList)
4136    this.filterStrategy.OnCallback(result);
4137   this.OnCallbackFinally();
4138  }
4139 },
4140 OnCallbackError: function(result){
4141  ASPxClientListBoxBase.prototype.OnCallbackError.call(this, result);
4142  this.OnCallbackFinally();
4143 },
4144 OnCallbackFinally: function () {
4145  this.HideLoadingPanel();
4146  this.changeSelectAfterCallback = 0;
4147 },
4148 DoEndCallback: function() {
4149  this.filterStrategy.OnBeforeDoEndCallback();
4150  ASPxClientListBoxBase.prototype.DoEndCallback.call(this);
4151  this.filterStrategy.OnAfterDoEndCallback();
4152 },
4153 RaiseEndCallback: function() {
4154  if(this.preventEndCallbackRising)
4155   this.preventEndCallbackRising = false;
4156  else
4157   ASPxClientListBoxBase.prototype.RaiseEndCallback.call(this);
4158 },
4159 LockScrollHandler: function(){
4160  this.scrollHandlerLockCount ++;
4161 },
4162 UnlockScrollHandler: function(){
4163  this.scrollHandlerLockCount --;
4164 },
4165 IsScrollHandlerLocked: function(){
4166  return this.scrollHandlerLockCount > 0;
4167 },
4168 OnScroll: function(){
4169  if(this.IsScrollHandlerLocked()) return;
4170  if(this.IsVisible() && !this.InCallback() && ( this.GetScrollSpacerVisibility(true) || this.GetScrollSpacerVisibility(false))) {
4171   this.scrollHelper.OnScroll();
4172   if(this.scrollHelper.GetIsNeedToHideTopSpacer())
4173    this.SetTopScrollSpacerVisibility(false);
4174   if(this.scrollHelper.GetIsNeedCallback()) {
4175    this.isComboBoxScrollingCallbackProcessing = this.isComboBoxList;
4176    this.SendCallback();
4177   }
4178  }
4179 },
4180 OnBrowserWindowResize: function(e) {
4181  if(this.IsVisible())
4182   this.CorrectSize();
4183 },
4184 KeyboardSupportAllowed: function(){
4185  return !this.CheckColumnSelectionMode();
4186 },
4187 InitializeKeyHandlers: function() {
4188  if(this.KeyboardSupportAllowed()){
4189   this.AddKeyDownHandler(ASPx.Key.PageUp, "OnPageUp");
4190   this.AddKeyDownHandler(ASPx.Key.PageDown, "OnPageDown");
4191   this.AddKeyDownHandler(ASPx.Key.End, "OnEndKeyDown");
4192   this.AddKeyDownHandler(ASPx.Key.Home, "OnHomeKeyDown");
4193   this.AddKeyDownHandler(ASPx.Key.Up, "OnArrowUp");
4194   this.AddKeyDownHandler(ASPx.Key.Down, "OnArrowDown");
4195  } else if(this.accessibilityCompliant && !this.IsNativeCheckBoxes()) {
4196   this.AddKeyDownHandler(ASPx.Key.Up, "OnAccessArrowUp");
4197   this.AddKeyDownHandler(ASPx.Key.Down, "OnAccessArrowDown");
4198  }
4199 },
4200 OnArrowUp: function(evt){
4201  if(this.isInitialized)
4202   this.SelectNeighbour(-1);
4203  return true;
4204 },
4205 OnArrowDown: function(evt){
4206  if(this.isInitialized)
4207   this.SelectNeighbour(1);
4208  return true;
4209 },
4210 OnAccessArrowUp: function(evt){
4211  if(!this.isInitialized) return true;
4212  var index = this.GetFocusedIndex();
4213  var isItemCheckBoxFocused = this.GetInternalCheckBox(index) && this.GetInternalCheckBox(index).focused;
4214  var isSelectAllCheckBoxFocused = this.selectAllCheckBox && this.selectAllCheckBox.focused;
4215  if(index > this.GetFirstFilteredItemIndex() && isItemCheckBoxFocused)
4216   this.SetFocusedIndex(this.GetPrevFilteredItemIndex(index));
4217  else if(index == this.GetFirstFilteredItemIndex() && this.selectAllCheckBox && !isSelectAllCheckBoxFocused) {
4218   this.selectAllCheckBox.mainElement.focus();
4219   this.GetItemSelectionHelper().SetFocusedIndexInternal(index, false);
4220  }
4221  else
4222   this.SetFocusedIndex(this.GetLastFilteredItemIndex());
4223  return true;
4224 },
4225 OnAccessArrowDown: function(evt){
4226  if(!this.isInitialized) return true;
4227  var index = this.GetFocusedIndex();
4228  var isItemCheckBoxFocused = this.GetInternalCheckBox(index) && this.GetInternalCheckBox(index).focused;
4229  var isSelectAllCheckBoxFocused = this.selectAllCheckBox && this.selectAllCheckBox.focused;
4230  if(index < this.GetLastFilteredItemIndex() && isItemCheckBoxFocused)
4231   this.SetFocusedIndex(this.GetNextFilteredItemIndex(index));
4232  else if(index == this.GetLastFilteredItemIndex() && this.selectAllCheckBox && !isSelectAllCheckBoxFocused) {
4233   this.selectAllCheckBox.mainElement.focus();
4234   this.GetItemSelectionHelper().SetFocusedIndexInternal(index, false);
4235  }
4236  else
4237   this.SetFocusedIndex(this.GetFirstFilteredItemIndex());
4238  return true;
4239 },
4240 SetFocusedIndex: function(index) {
4241  if(this.GetIsCheckColumnExists()) {
4242   this.MakeItemVisible(index);
4243   setTimeout(function () { this.GetInternalCheckBox(index).mainElement.focus(); }.aspxBind(this), 0);
4244  }
4245  this.GetItemSelectionHelper().SetFocusedIndexInternal(index, false);
4246 },
4247 OnPageUp: function(evt){
4248  if(this.isInitialized)
4249   this.SelectNeighbour(-this.scrollPageSize);
4250  return true;
4251 },
4252 OnPageDown: function(evt){
4253  if(this.isInitialized)
4254   this.SelectNeighbour(this.scrollPageSize);
4255  return true;
4256 },
4257 OnHomeKeyDown: function(evt){
4258  if(this.isInitialized)
4259   this.SelectNeighbour(-this.GetItemCount());
4260  return true;
4261 },
4262 OnEndKeyDown: function(evt){
4263  if(this.isInitialized)
4264   this.SelectNeighbour(this.GetItemCount());
4265  return true;
4266 },
4267 GetAdjustedIndex: function(index){
4268  if(index < 0) index = 0;
4269  else{
4270   var itemCount = this.GetItemCount();
4271   if(index >= itemCount) index = itemCount - 1;
4272  }
4273  return index;
4274 },
4275 SelectNeighbour: function (step) {
4276  var itemCount = this.GetItemCount();
4277  if(itemCount > 0) {
4278   this.changeSelectAfterCallback = 0;
4279   var selectedIndex = this.GetFocusedIndex();
4280   var newSelectedIndex = this.GetNewSelectedIndex(selectedIndex, step);
4281   newSelectedIndex = this.GetAdjustedIndex(newSelectedIndex);
4282   if(selectedIndex != newSelectedIndex && this.IsItemFiltered(newSelectedIndex)) {
4283    this.LockScrollOnKBNavigation();
4284    this.SetSelectedIndexCore(newSelectedIndex);
4285    this.UnlockScrollOnKBNavigation();
4286   }
4287   if(this.GetIsNeedToCallbackLoadItemsToTop(newSelectedIndex, step, itemCount)) {
4288    this.LoadItemsOnCallback(true, newSelectedIndex);
4289   } else if(this.GetIsNeedToCallbackLoadItemsToBottom(newSelectedIndex, step, itemCount)) {
4290    this.LoadItemsOnCallback(false, newSelectedIndex);
4291   }
4292   this.itemsManager.MakeItemVisible(newSelectedIndex);
4293  }
4294 },
4295 GetNewSelectedIndex: function(selectedIndex, step) {
4296  var pageDownSize = step == 1 ? this.scrollPageSize + 1 : this.scrollPageSize; 
4297  var isFirstPageDown = selectedIndex == -1 && step == pageDownSize && step > 1;
4298  if(isFirstPageDown)
4299   step++;
4300  var newSelectedIndex = 0;
4301  var areThereUnfilteredItems = this.GetVisibleItemCount() < this.GetItemCount();
4302  if(areThereUnfilteredItems)
4303   newSelectedIndex = this.itemsManager.GetNewItemIndexInFilteredRange(selectedIndex, step);
4304  else
4305   newSelectedIndex = selectedIndex + step;
4306  return newSelectedIndex;
4307 },
4308 GetIsNeedToCallbackLoadItemsToTop: function(selectedIndex, step, itemCount){
4309  return this.isCallbackMode && this.GetScrollSpacerVisibility(true) && 
4310   this.serverIndexOfFirstItem > 0 && ((step < 0 && selectedIndex <= 0) || step <= -itemCount);
4311 },
4312 GetIsNeedToCallbackLoadItemsToBottom: function(selectedIndex, step, itemCount){
4313  return this.isCallbackMode && this.GetScrollSpacerVisibility(false) && 
4314   ((step > 0 && selectedIndex >= itemCount - 1) || step >= itemCount);
4315 },
4316 LoadItemsOnCallback: function(isToTop, index){
4317  this.changeSelectAfterCallback = index - this.GetSelectedIndex();
4318  this.scrollHelper.SetItemsRangeForLoad(isToTop);
4319  this.isComboBoxScrollingCallbackProcessing = this.isComboBoxList;
4320  this.SendCallback();
4321 },
4322 FindInputElement: function(){
4323  if(this.accessibilityCompliant)
4324   return this.isComboBoxList ? null : this.GetAccessibilityAssistantElement();
4325  return this.GetKBSInput();
4326 },
4327 GetKBSInput: function() {
4328  return this.GetChildElement("KBS");
4329 },
4330 GetAccessibilityActiveElements: function() {
4331  var accessibilityElements = [];
4332  if(this.CheckColumnSelectionMode()) {
4333   for(var i = 0; i < this.GetItemCount() ; i++) {
4334    var checkBoxFocusableElement = this.GetCheckBoxFocusableElement(i);
4335    if(checkBoxFocusableElement)
4336     accessibilityElements.push(checkBoxFocusableElement);
4337   }
4338  }
4339  accessibilityElements.push(this.accessibilityCompliant ? this.GetAccessibilityHelper().GetActiveElement() : this.GetInputElement());
4340  return accessibilityElements;
4341 },
4342 SetHoverElement: function(element){
4343  ASPx.GetStateController().SetCurrentHoverElementBySrcElement(element);
4344 },
4345 InitOnContainerMadeVisible: function(){
4346  this.AdjustControl();
4347 },
4348 ClearItemsCore: function(){
4349  this.itemsManager.ClearItems();
4350  this.EnsureFixWidthRow();
4351  this.AddAccessibilityHeaderRow();
4352  this.OnItemsCleared();
4353  this.SetValue(null);
4354 },
4355 OnItemsCleared: function(){
4356  this.GetItemSelectionHelper().OnItemsCleared();
4357 },
4358 CorrectCellWidthsOnFirstRowItemReplacement: function(oldFirstRowItemIndex, newFirstRowItemIndex) {
4359  if (!this.ContainsFixWidthRow() && !this.HasVirtualScrolling()) {
4360   var oldFirstRowItemHasTemplate = this.ItemRowHasTemplate(oldFirstRowItemIndex);
4361   var newFirstRowItemHasTemplate = this.ItemRowHasTemplate(newFirstRowItemIndex);
4362   if(!oldFirstRowItemHasTemplate && !newFirstRowItemHasTemplate)
4363    this.CopyCellWidths(oldFirstRowItemIndex, newFirstRowItemIndex);
4364  }
4365 },
4366 CopyCellWidths: function(sourceRowIndex, destinationRowIndex){
4367  var cellCount = this.GetItemCellCount();
4368  var sourceRow = this.GetItemRow(sourceRowIndex);
4369  var destRow = this.GetItemRow(destinationRowIndex);
4370  if (!sourceRow || !destRow) return; 
4371  var lastDestCellIndex = destRow.cells.length - 1;
4372  for(var i = 0; i < lastDestCellIndex; i++) {
4373   destRow.cells[i].style.width = sourceRow.cells[i].style.width;
4374  }
4375  if(destRow.cells.length === cellCount) {
4376   destRow.cells[lastDestCellIndex].style.width = sourceRow.cells[lastDestCellIndex].style.width;
4377  } else {
4378   var cellWidths = ASPx.Data.CollectionToArray(sourceRow.cells)
4379    .slice(lastDestCellIndex)
4380    .map(function(cell) { return ASPx.PxToInt(cell.style.width); })
4381    .reduce(function(accumulator, current) { return accumulator + current; }, 0);
4382   destRow.cells[lastDestCellIndex].style.width = cellWidths + "px";
4383  }
4384  if(this.NeedToHandleCellWidth())
4385   this.CorrectCellNullWidthStyle(destRow);
4386 },
4387 RemoveItem: function (index) {
4388  var firstRenderedItem = this.itemsManager.GetFirstRenderedItem();
4389  if (firstRenderedItem && index == firstRenderedItem.index && this.GetItemRow(firstRenderedItem.index + 1) !== null)
4390   this.CorrectCellWidthsOnFirstRowItemReplacement(firstRenderedItem.index, firstRenderedItem.index + 1);
4391  if (0 <= index && index < this.GetItemCount()) {
4392   this.UpdateSyncArraysItemDeleted(this.GetItem(index), true);
4393   this.itemsManager.RemoveItem(index);
4394   this.OnItemRemoved(index);
4395  }
4396 },
4397 GetItem: function(index, preventEncodeText) {
4398  return this.itemsManager.GetItem(index, preventEncodeText);
4399 },
4400 GetItemRowTexts: function(row) {
4401  var serializedTexts = this.GetTextsDataAttribute(row);
4402  if(ASPx.IsExists(serializedTexts))
4403   return JSON.parse(serializedTexts);
4404  var texts = [];
4405  var i = this.GetItemFirstTextCellIndex();
4406  var cellsLength = this.IsMultiColumn() ? row.cells.length : i + 1;
4407  for(; i < cellsLength; i++) {
4408   var textCell = row.cells[i];
4409   texts.push(ASPxClientListBox.GetItemCellInnerText(textCell));
4410  }
4411  return texts;
4412 },
4413 ItemRowHasTemplate: function(itemIndex) {
4414  var itemRow = this.GetItemRow(itemIndex);
4415  return itemRow ? this.ItemRowHasTemplateCore(itemRow) : false;
4416 },
4417 ItemRowHasTemplateCore: function(itemRow) {
4418  return this.ItemRowHasSerializedTextsAttr(itemRow);
4419 },
4420 ItemRowHasSerializedTextsAttr: function(itemRow) {
4421  return ASPx.Attr.IsExistsAttribute(itemRow, itemSerializedTextsAttributeName);
4422 },
4423 ItemCellHasTextAttr: function(itemTextCell) {
4424  return ASPx.Attr.IsExistsAttribute(itemTextCell, itemCellTextAttributeName);
4425 },
4426 GetFirstVisibleItem: function() {
4427  return this.itemsManager.GetFirstVisibleItem();
4428 },
4429 GetFirstFilteredItemIndex: function () {
4430  return this.itemsManager.GetFirstFilteredItemIndex();
4431 },
4432 GetLastFilteredItemIndex: function() {
4433  return this.itemsManager.GetLastFilteredItemIndex();
4434 },
4435 GetNextFilteredItemIndex: function(currentFilteredItemIndex) {
4436  return this.itemsManager.GetNextFilteredItemIndex(currentFilteredItemIndex);
4437 },
4438 GetPrevFilteredItemIndex: function(currentFilteredItemIndex) {
4439  return this.itemsManager.GetPrevFilteredItemIndex(currentFilteredItemIndex);
4440 },
4441 PerformCallback: function(arg, onSuccess) {
4442  this.SetScrollSpacerVisibility(true, false);
4443  this.SetScrollSpacerVisibility(false, false);
4444  this.ClearItemsForPerformCallback();
4445  this.serverIndexOfFirstItem = 0;
4446  this.SetScrollSpacerVisibility(true, false);
4447  this.SetScrollSpacerVisibility(false, false);
4448  this.FormatAndSetCustomCallbackArg(arg, true);
4449  this.SendCallback(onSuccess);
4450  this.FormatAndSetCustomCallbackArg(arg, false);
4451 },
4452 GetTableRowParent: function(table){
4453  if(table.tBodies.length > 0)
4454   return table.tBodies[0];
4455  return table;
4456 },
4457 ProtectWhitespaceSerieses: function(text){
4458  if(text == "") 
4459   text = nbsp;
4460  else {
4461   if(text.charAt(0) == ' ')
4462    text = nbsp + text.slice(1);
4463   if(text.charAt(text.length - 1) == ' ')
4464    text = text.slice(0, -1) + nbsp;
4465   text = text.replace(new RegExp("  ", "g"), " &nbsp;");
4466  }
4467  return text;
4468 }, 
4469 InsertItemInternal: function(index, itemProperties) {
4470  if(!this.hasSampleItem) 
4471   return;
4472  this.AdjustItemProperties(itemProperties);
4473  ASPx.Data.ArrayInsert(this.itemsValue, itemProperties.value, index);
4474  this.itemsManager.InsertItem(index, itemProperties);
4475  this.RegisterInsertedItem(index, itemProperties);
4476  this.OnItemInserted(index);
4477 },
4478 GetListTableRowBeforeNewItemRow: function (newItemIndex, listTable) {
4479  var lastRenderedItem = this.itemsManager.GetLastRenderedItem();
4480  if (!lastRenderedItem || lastRenderedItem.index < newItemIndex) {
4481   var lastItemRow = lastRenderedItem ? this.GetItemRow(lastRenderedItem.index) : null;
4482   var lastListTableRow = listTable.rows[listTable.rows.length - 1];
4483   if (lastItemRow)
4484    return lastItemRow === lastListTableRow ? null : lastItemRow.nextSibling;
4485   if (!!this.GetAccessibilityHeaderRow())
4486    return this.ContainsFixWidthRow() ? listTable.rows[1] : listTable.rows[0];
4487   return null;
4488  }
4489  for (var i = 0; i < listTable.rows.length; i++)
4490   if (this.GetItemIndexByRow(listTable.rows[i]) >= newItemIndex)
4491    return listTable.rows[i];
4492  return null;
4493 },
4494 AdjustItemProperties: function(itemProperties) {
4495  if(!itemProperties.texts || itemProperties.texts.length == 0)
4496   itemProperties.texts = [""];
4497  else if(typeof (itemProperties.texts) === "string")
4498   itemProperties.texts = [itemProperties.texts];
4499  if(typeof (itemProperties.value) === "undefined")
4500   itemProperties.value = itemProperties.texts[0];
4501  if(!ASPx.IsExists(itemProperties.imageUrl) || itemProperties.imageUrl === "")
4502   itemProperties.imageUrl = this.defaultImageUrl;
4503 },
4504 AddStateControllerClasses: function(itemId){
4505  var itemCellsIdPostfixes = this.GetItemCellsIdPostfixes();
4506  var sampleItemFirstTextCell = this.GetSampleItemFirstTextCell();
4507  var styleController = ASPx.GetStateController();
4508  var hoverStyleClasses = this.CreateStyleClasses(itemId, itemCellsIdPostfixes, 
4509      styleController.GetHoverElement(sampleItemFirstTextCell), ASPx.HoverItemKind);
4510  var selectedStyleClasses = this.CreateStyleClasses(itemId, itemCellsIdPostfixes, 
4511      styleController.GetSelectedElement(sampleItemFirstTextCell), ASPx.SelectedItemKind);
4512  var disabledStyleClasses = this.CreateStyleClasses(itemId, itemCellsIdPostfixes, 
4513      styleController.GetDisabledElement(sampleItemFirstTextCell), ASPx.DisabledItemKind);
4514    ASPx.AddHoverItems(this.name, hoverStyleClasses, true);
4515    ASPx.AddSelectedItems(this.name, selectedStyleClasses, true);
4516    ASPx.AddDisabledItems(this.name, disabledStyleClasses, true);
4517  ASPx.Attr.RemoveAttribute(sampleItemFirstTextCell, ASPx.CachedStatePrefix + ASPx.HoverItemKind);
4518  ASPx.Attr.RemoveAttribute(sampleItemFirstTextCell, ASPx.CachedStatePrefix + ASPx.SelectedItemKind);
4519  ASPx.Attr.RemoveAttribute(sampleItemFirstTextCell, ASPx.CachedStatePrefix + ASPx.DisabledItemKind);
4520 },
4521 RemoveStateControllerClasses: function(itemId){
4522  var itemCellsIdPostfixes = this.GetItemCellsIdPostfixes();
4523  var classes = [];
4524  classes[0] = [];
4525  classes[0][0] = [itemId];
4526  classes[0][1] = itemCellsIdPostfixes;
4527    ASPx.RemoveHoverItems(this.name, classes);
4528    ASPx.RemoveSelectedItems(this.name, classes);
4529    ASPx.RemoveDisabledItems(this.name, classes);
4530 },
4531 GetCellInfo: function(index, infoArray) {
4532  if(!infoArray) return null;
4533  var filteredArray = infoArray.filter(function(info) { return info.index === index; });
4534  return filteredArray.length ? filteredArray[0].value : null;
4535 },
4536 PrepareItem: function(newItemRow, itemProperties) {
4537  var i = 0;
4538  if(this.GetIsCheckColumnExists())
4539   i++;
4540  if(this.imageCellExists) {
4541   this.PrepareItemImage(newItemRow, i, itemProperties.imageUrl);
4542   i++;
4543  }
4544  if(itemProperties.htmlContent) {
4545   this.SetItemHtmlContent(newItemRow, itemProperties.htmlContent);
4546   this.SetTextsDataAttribute(newItemRow, itemProperties.texts);
4547  } else {
4548   this.SetItemTextContent(i, newItemRow, itemProperties);
4549  }
4550  this.AssignDecorationSettingsToElement(newItemRow, itemProperties.style, itemProperties.cssClass, itemProperties.tooltip, itemProperties.attributes);
4551 },
4552 LockRunStartupSciptsInItemRow: function() {
4553  this.lockRunStartupScipts = true;
4554 },
4555 UnlockRunStartupSciptsInItemRow: function() {
4556  this.lockRunStartupScipts = false;
4557 },
4558 IsRunStartupSciptsInItemRowLocked: function() {
4559  return this.lockRunStartupScipts;
4560 },
4561 EnsureStartupScriptsInContainer: function(container) {
4562  if(!this.InCallback() && !this.IsRunStartupSciptsInItemRowLocked())
4563   ASPx.RunStartupScripts(false, container);
4564 },
4565 SetItemHtml: function(index, html) {
4566  this.hasDecoratedItems = true;
4567  this.hasItemTemplate = true;
4568  this.EnsureFixWidthRow(true);
4569  this.itemsManager.SetItemHtml(index, html);
4570  this.ProcessItemRow(index, function(itemRow) {
4571   if(!this.ItemRowHasSerializedTextsAttr(itemRow))
4572    this.SetTextsDataAttribute(itemRow, this.GetItem(index).texts);
4573   this.SetItemHtmlContent(itemRow, html);
4574   this.itemsManager.OnDecoratedItemsRendering();
4575  }.bind(this));
4576 },
4577 SetTextsDataAttribute: function(itemRow, texts) { ASPx.Attr.SetAttribute(itemRow, itemSerializedTextsAttributeName, JSON.stringify(texts)); },
4578 GetTextsDataAttribute: function(itemRow) { return ASPx.Attr.GetAttribute(itemRow, itemSerializedTextsAttributeName); },
4579 SetItemTooltip: function(index, tooltip) {
4580  this.itemsManager.SetItemTooltip(index, tooltip);
4581  this.ProcessItemRow(index, function(itemRow) { this.SetElementTooltip(itemRow, tooltip); }.aspxBind(this));
4582 },
4583 SetItemAttribute: function(index, attributeName, attributeValue) {
4584  this.itemsManager.SetItemAttribute(index, attributeName, attributeValue);
4585  this.ProcessItemRow(index, function(itemRow) { ASPx.Attr.SetAttribute(itemRow, attributeName, attributeValue); }.aspxBind(this));
4586 },
4587 AddItemCssClass: function(index, className) {
4588  this.hasDecoratedItems = true;
4589  this.itemsManager.AddItemCssClass(index, className);
4590  this.ProcessItemRow(index, function(itemRow) {
4591   ASPx.AddClassNameToElement(itemRow, className);
4592   this.itemsManager.OnDecoratedItemsRendering();
4593  }.bind(this));
4594 },
4595 RemoveItemCssClass: function(index, className) {
4596  this.hasDecoratedItems = true;
4597  this.itemsManager.RemoveItemCssClass(index, className);
4598  this.ProcessItemRow(index, function(itemRow) {
4599   ASPx.RemoveClassNameFromElement(itemRow, className);
4600   this.itemsManager.OnDecoratedItemsRendering();
4601  }.bind(this));
4602 },
4603 SetItemTextCellHtml: function(itemIndex, textCellIndex, html) {
4604  this.hasDecoratedItems = true;
4605  this.itemsManager.SetItemTextCellHtml(itemIndex, textCellIndex, html);
4606  this.ProcessItemTextCell(itemIndex, textCellIndex, function(textCell) {
4607   if(!this.ItemCellHasTextAttr(textCell))
4608    this.SetItemCellTextDataAttribute(textCell, this.GetItem(itemIndex).texts[textCellIndex]);
4609   this.SetItemTextCellHtmlContent(textCell, html);
4610   this.itemsManager.OnDecoratedItemsRendering();
4611  }.aspxBind(this));
4612 },
4613 SetItemCellTextDataAttribute: function(textCell, text) {
4614  ASPx.Attr.SetAttribute(textCell, itemCellTextAttributeName, text);
4615 },
4616 SetItemTextCellTooltip: function(itemIndex, textCellIndex, tooltip) {
4617  this.itemsManager.SetItemTextCellTooltip(itemIndex, textCellIndex, tooltip);
4618  this.ProcessItemTextCell(itemIndex, textCellIndex, function(textCell) { this.SetElementTooltip(textCell, tooltip); }.aspxBind(this));
4619 },
4620 SetItemTextCellAttribute: function(itemIndex, textCellIndex, attributeName, attributeValue) {
4621  this.itemsManager.SetItemTextCellAttribute(itemIndex, textCellIndex, attributeName, attributeValue);
4622  this.ProcessItemTextCell(itemIndex, textCellIndex, function(textCell) { ASPx.Attr.SetAttribute(textCell, attributeName, attributeValue); }.aspxBind(this));
4623 },
4624 AddItemTextCellCssClass: function(itemIndex, textCellIndex, className) {
4625  this.hasDecoratedItems = true;
4626  this.itemsManager.AddItemTextCellCssClass(itemIndex, textCellIndex, className);
4627  this.ProcessItemTextCell(itemIndex, textCellIndex, function(textCell) {
4628   ASPx.AddClassNameToElement(textCell, className);
4629   this.itemsManager.OnDecoratedItemsRendering();
4630  }.bind(this));
4631 },
4632 RemoveItemTextCellCssClass: function(itemIndex, textCellIndex, className) {
4633  this.hasDecoratedItems = true;
4634  this.itemsManager.RemoveItemTextCellCssClass(itemIndex, textCellIndex, className);
4635  this.ProcessItemTextCell(itemIndex, textCellIndex, function(textCell) {
4636   ASPx.RemoveClassNameFromElement(textCell, className);
4637   this.itemsManager.OnDecoratedItemsRendering();
4638  }.bind(this));
4639 },
4640 ProcessItemRow: function(index, action) {
4641  var itemRow = this.GetItemRow(index);
4642  if(itemRow)
4643   action(itemRow);
4644 },
4645 ProcessItemTextCell: function(itemIndex, textCellIndex, action) {
4646  var itemTextCell = this.GetItemTextCell(itemIndex, textCellIndex);
4647  if(itemTextCell && !this.ItemRowHasTemplateCore(itemTextCell.parentNode))
4648   action(itemTextCell);
4649 },
4650 SetItemHtmlContent: function(itemRow, html) {
4651  var redundantCells = ASPx.Data.CollectionToArray(itemRow.cells)
4652   .slice(this.GetItemFirstTextCellIndex(), itemRow.cells.length - 1);
4653  redundantCells.forEach(function(cell) { itemRow.removeChild(cell); });
4654  var itemHtmlContainerCell = itemRow.cells[itemRow.cells.length - 1];
4655  ASPx.SetElementDisplay(itemHtmlContainerCell, this.GetVisibleColumnCount() !== 0);
4656  itemHtmlContainerCell.colSpan = Math.max(itemHtmlContainerCell.colSpan, this.GetVisibleColumnCount());
4657  if(this.IsMultiColumn()) {
4658   if(this.GetItemFirstTextCellIndex() === 0)
4659    ASPx.AddClassNameToElement(itemHtmlContainerCell, FIRST_CELL_MARKER_CSS_CLASS_NAME);
4660   ASPx.AddClassNameToElement(itemHtmlContainerCell, LAST_CELL_MARKER_CSS_CLASS_NAME);
4661  }
4662  itemHtmlContainerCell.style.width = "";
4663  itemHtmlContainerCell.innerHTML = html;
4664  this.RemoveEllipsisFromNode(itemHtmlContainerCell);
4665  this.EnsureStartupScriptsInContainer(itemHtmlContainerCell);
4666 },
4667 SetItemTextContent: function(textCellIndex, newItemRow, itemProperties) {
4668  var cellCount = this.GetItemCellCount();
4669  for(var j = 0; textCellIndex < cellCount; textCellIndex++, j++) {
4670   var cellStyle = this.GetCellInfo(j, itemProperties.cellStyles);
4671   var cellCssClass = this.GetCellInfo(j, itemProperties.cellCssClasses);
4672   var cellTooltip = this.GetCellInfo(j, itemProperties.cellTooltips);
4673   var cellAttributes = this.GetCellInfo(j, itemProperties.cellAttributes);
4674   var htmlContent = this.GetCellInfo(j, itemProperties.htmlContents);
4675   this.PrepareItemTextCell(newItemRow.cells[textCellIndex], itemProperties.texts[j], cellStyle, cellCssClass, cellTooltip, cellAttributes, htmlContent);
4676  }
4677 },
4678 SetItemTextCellHtmlContent: function(cell, html) {
4679  cell.innerHTML = html;
4680  this.RemoveEllipsisFromNode(cell);
4681  this.EnsureStartupScriptsInContainer(cell);
4682 },
4683 PrepareItemImage: function(newItemRow, imageCellIndex, imageUrl){
4684  var imageCell = newItemRow.cells[imageCellIndex];
4685  var image = ASPx.GetNodeByTagName(imageCell, "IMG", 0);
4686  if(!imageUrl) {
4687   if(image)
4688    ASPx.RemoveElement(image);
4689   imageCell.innerHTML = "&nbsp;";
4690  } else {
4691   if(!image) {
4692    image = document.createElement("IMG");
4693    imageCell.innerHTML = "";
4694    imageCell.appendChild(image);
4695   }
4696   ASPx.ImageUtils.SetImageSrc(image, imageUrl);
4697  }
4698 }, 
4699 PrepareItemTextCell: function(cell, text, style, cssClass, tooltip, attributes, htmlContent) {
4700  if(!ASPx.IsExists(text)) 
4701   text = "";
4702  if(this.encodeHtml)
4703   text = ASPx.Str.EncodeHtml(text);
4704  if(htmlContent) {
4705   this.SetItemTextCellHtmlContent(cell, htmlContent);
4706   this.SetItemCellTextDataAttribute(cell, this.ProtectWhitespaceSerieses(text));
4707  }
4708  else {
4709   cell.innerHTML = this.ProtectWhitespaceSerieses(text);
4710   if(this.enableEllipsis)
4711    ASPx.AddClassNameToElement(cell, ASPx.ELLIPSIS_MARKER_CLASS);
4712  }
4713  this.AssignDecorationSettingsToElement(cell, style, cssClass, tooltip, attributes);
4714  if(text == "")
4715   ASPx.Attr.SetAttribute(cell, "DXText", text);
4716 },
4717 AssignDecorationSettingsToElement: function(element, style, cssClass, tooltip, attributes) {
4718  if(cssClass)
4719   ASPx.AddClassNameToElement(element, cssClass);
4720  if(style) {
4721   var styleSheet = ASPx.GetCurrentStyleSheet();
4722   ASPx.AddClassNameToElement(element, ASPx.CreateImportantStyleRule(styleSheet, style));
4723  }
4724  if(tooltip)
4725   this.SetElementTooltip(element, tooltip);
4726  if(attributes)
4727   for(var key in attributes)
4728    if(attributes.hasOwnProperty(key))
4729     ASPx.Attr.SetAttribute(element, key, attributes[key]);
4730 },
4731 SetElementTooltip: function(element, tooltip) {
4732  this.RemoveEllipsisTooltip(element);
4733  ASPx.Attr.SetAttribute(element, "title", tooltip);
4734 },
4735 FormatText: function(texts, value) {
4736  if(typeof(texts) === "string")
4737   return texts;
4738  else if(!this.IsMultiColumn())
4739   return texts[0];
4740  else
4741   return this.FormatTextCore(texts, value);
4742 },
4743 FormatTextCore: function(texts, value) {
4744  var result = "";
4745  if(this.isComboBoxList) {
4746   if(this.nullValueItemDisplayText !== null && value === null)
4747    result = this.nullValueItemDisplayText;
4748   else
4749    result = ASPx.Formatter.Format(this.textFormatString, texts);
4750  } else
4751   result = texts.join("; ");
4752  return result;
4753 },
4754 OnItemInserted: function(index){
4755  this.GetItemSelectionHelper().OnItemInserted(index);
4756 },
4757 OnItemRemoved: function(index){
4758  this.GetItemSelectionHelper().OnItemRemoved(index);
4759 },
4760 CreateItemId: function(index){
4761  return lbIIdSuffix + index;
4762 },
4763 CreateItemClientId: function(index){
4764  return this.name + "_" + lbIIdSuffix + index;
4765 },
4766 CreateStyleClasses: function(id, postfixes, item, kind){
4767  var classes = [];
4768  if(item && item[kind]){
4769   classes[0] = [];
4770   classes[0][0] = item[kind].classNames;
4771   classes[0][1] = item[kind].cssTexts;
4772   classes[0][2] = [];
4773   classes[0][2][0] = id;
4774   classes[0][3] = postfixes;
4775  }
4776  return classes;
4777 },
4778 CorrectSizeByTimer: function(){
4779  if(this.APILockCount == 0 && this.IsDisplayed())
4780   window.setTimeout(function() { this.OnCorrectSizeByTimer(); }.aspxBind(this), 0);
4781 },
4782 FindFreeIndex: function(){
4783  return this.freeUniqIndex ++;
4784 },
4785 GetSampleItemRowID: function(){
4786  return this.name + "_" + lbSIIdSuffix;
4787 },
4788 GetAccessibilitySampleHeaderRowID: function() {
4789  return this.name + "_" + lbAIRTIdSuffix;
4790 },
4791 GetSampleItemRow: function(){
4792  if(this.SampleItem == null)
4793   this.SampleItem = ASPx.GetElementById(this.GetSampleItemRowID());
4794  return this.SampleItem;
4795 },
4796 GetAccessibilitySampleHeaderRow: function() {
4797  if(this.sampleHeaderRow == null)
4798   this.sampleHeaderRow = ASPx.GetElementById(this.GetAccessibilitySampleHeaderRowID());
4799  return this.sampleHeaderRow;
4800 },
4801 AddAccessibilityHeaderRow: function() {
4802  if(!this.HasAccessibilityHeaderRow()) return;
4803  var listTableBody = ASPx.GetChildByTagName(this.GetListTable(), "TBODY", 0);
4804  var headerRow = this.GetAccessibilitySampleHeaderRow().cloneNode(true);
4805  headerRow.id = this.GetAccessibilityHeaderRowID();
4806  listTableBody.appendChild(headerRow);
4807 },
4808 HasAccessibilityHeaderRow: function() {
4809  return this.accessibilityCompliant && this.IsMultiColumn();
4810 },
4811 GetAccessibilityHeaderRow: function() {
4812  return this.GetChildElement(lbAIRIdSuffix);
4813 },
4814 RemoveAccessibilityHeaderRow: function() {
4815  var headerRow = this.GetAccessibilityHeaderRow();
4816  if(headerRow)
4817   ASPx.RemoveElement(headerRow);
4818 },
4819 GetAccessibilityHeaderRowID: function() {
4820  return this.name + "_" + lbAIRIdSuffix;
4821 },
4822 GetSampleItemFirstTextCell: function(){
4823  if(!ASPx.IsExistsElement(this.sampleItemFirstTextCell)){
4824   var sampleItemRow = this.GetSampleItemRow();
4825   if(ASPx.IsExistsElement(sampleItemRow))
4826    this.sampleItemFirstTextCell = sampleItemRow.cells[this.imageCellExists ? 1 : 0];
4827  }
4828  return this.sampleItemFirstTextCell;
4829 },
4830 ChangeEnabledAttributes: function(enabled){
4831  this.ChangeListTableEvents(this.GetListTable(), ASPx.Attr.ChangeEventsMethod(enabled));
4832  var focusableElement = this.GetInputElement();
4833  if(focusableElement) {
4834   this.ChangeSpecialInputEnabledAttributes(focusableElement, ASPx.Attr.ChangeEventsMethod(enabled));
4835   if(this.accessibilityCompliant)
4836    this.ChangeFocusableElementTabIndex(focusableElement, enabled);
4837   else if(!this.isComboBoxList) {
4838    var changeMethod = enabled ? ASPx.Attr.RestoreTabIndexAttribute : ASPx.Attr.SaveTabIndexAttributeAndReset;
4839    changeMethod(focusableElement);
4840   }
4841  }
4842 },
4843 ChangeFocusableElementTabIndex: function(focusableElement, enabled) {
4844  if(!this.isComboBoxList) {
4845   if(enabled)
4846    ASPx.Attr.SetAttribute(focusableElement, "tabindex", "0");
4847   else
4848    focusableElement.removeAttribute("tabindex");
4849  }
4850 },
4851 ChangeEnabledStateItems: function(enabled){
4852  var controller = ASPx.GetStateController();
4853  controller.SetElementEnabled(this.GetMainElement(), enabled);
4854  var count = this.GetItemCount();
4855  var i = this.hasSampleItem ? -1 : 0 ;
4856  for(; i < count; i ++){
4857   this.ChangeEnabledStateItem(i, enabled, controller);
4858  }
4859  this.changeSelectAllElementsEnabledState(enabled);
4860  var changeEventMethod = ASPx.Attr.ChangeEventsMethod(enabled);
4861  if(this.filteringTextBox && !this.customFilteringEditorID) {
4862   this.filteringTextBox.SetEnabled(enabled);
4863   this.ChangeSpecialInputEnabledAttributes(this.filteringTextBox.GetInputElement(), changeEventMethod, true);
4864  }
4865  if(this.showFilterButton) {
4866   this.showFilterButton.SetEnabled(enabled);
4867   this.ChangeSpecialInputEnabledAttributes(this.showFilterButton.GetInternalButton(), changeEventMethod, true);
4868  }
4869 },
4870 ChangeEnabledStateItem: function (index, enabled, controller) {
4871  var element = this.GetItemFirstTextCell(index);
4872  if (element)
4873   controller.SetElementEnabled(element, enabled);
4874  if (this.GetIsCheckColumnExists() && index >= 0)
4875   this.SetCheckBoxEnabled(index, enabled);
4876 },
4877 ChangeListTableEvents: function(listTable, method){
4878  if(this.isComboBoxList){
4879   method(listTable, "mouseup", aspxLBIClick);
4880   if(ASPx.Browser.Firefox)
4881    method(listTable, "mousedown", ASPx.Evt.PreventEvent); 
4882  }
4883  else{
4884   method(listTable, "click", aspxLBIClick);   
4885   method(listTable, "dblclick", aspxLBIClick); 
4886   if(this.MultiSelectionMode())
4887    this.AttachSelectStartHandlerToElement(listTable);
4888  }
4889 },
4890 AttachSelectStartHandlerToElement: function(element) {
4891  ASPx.Evt.AttachEventToElement(element, "selectstart", aspxLBTSelectStart);
4892 },
4893 IsValueChanged: function(){
4894  return this.cachedValue != this.GetValue();
4895 },
4896 OnItemSelectionChanged: function(index, selected, fromSelectAllClick, forceValueChanged){
4897  if(this.CheckColumnSelectionMode() && !fromSelectAllClick)
4898   this.SetCheckBoxChecked(index, selected);
4899  if(!this.IsSelectionEventsLocked()) {
4900   this.SetRaiseSelectedIndexChangedArguments(this.autoPostBack, index, selected);
4901   var valueChanged = this.IsValueChanged() || forceValueChanged;
4902   if(valueChanged) {
4903    this.RaisePersonalStandardValidation();
4904    this.OnValueChanged();
4905   } else {
4906    if(this.RaiseSelectedIndexChanged())
4907     this.SendPostBackInternal("");
4908   }
4909  }
4910  this.CacheValue();
4911  if(this.accessibilityCompliant && !fromSelectAllClick)
4912   this.GetAccessibilityHelper().OnSelectedIndexChanged(index);
4913 },
4914 SetRaiseSelectedIndexChangedArguments: function(processOnServer, index, selected){
4915  this.selectedIndexChangedArguments = {
4916   processOnServer: processOnServer,
4917   index: index,
4918   selected: selected
4919  };
4920 },
4921 GetRaiseSelectedIndexChangedArguments: function(){
4922  if(!this.selectedIndexChangedArguments)
4923   this.SetRaiseSelectedIndexChangedArguments(false, this.GetSelectedIndex(), true);
4924  return this.selectedIndexChangedArguments;
4925 },
4926 RaiseSelectedIndexChanged: function (processOnServer) {
4927  this.RaiseValidationInternal();
4928  var savedArgs = this.GetRaiseSelectedIndexChangedArguments();
4929  processOnServer = savedArgs.processOnServer || processOnServer;
4930  if(!this.SelectedIndexChanged.IsEmpty()){
4931   var args = new ASPxClientListEditItemSelectedChangedEventArgs(savedArgs.index, savedArgs.selected, processOnServer);
4932   this.SelectedIndexChanged.FireEvent(this, args);
4933   processOnServer = args.processOnServer;
4934  }
4935  return processOnServer;
4936 },
4937 RaiseItemFiltering: function(item, filter, isFit) {
4938  if(!this.ItemFiltering.IsEmpty()) {
4939   var args = new ASPxClientListEditItemFilteringEventArgs(item, filter, isFit);
4940   this.ItemFiltering.FireEvent(this, args);
4941   isFit = args.isFit;
4942  }
4943  return isFit;
4944 },
4945 RaiseCustomHighlighting: function(filter, callbackHighlighting) {
4946  if(!this.CustomHighlighting.IsEmpty()) {
4947   var args = new ASPxClientListEditCustomHighlightingEventArgs(filter);
4948   args.highlighting = callbackHighlighting;
4949   this.CustomHighlighting.FireEvent(this, args);
4950   return args.highlighting;
4951  }
4952  return callbackHighlighting;
4953 },
4954 SetWidth: function(width) {
4955  this.width = width + "px";
4956  this.GetScrollDivElement().style.width = "100%";
4957  ASPxClientListBoxBase.prototype.SetWidth.call(this, width);
4958 },
4959 SetHeight: function(height) {
4960  this.heightCorrected = false;
4961  ASPxClientListBoxBase.prototype.SetHeight.call(this, height);
4962  this.CorrectHeight();
4963 },
4964 OnAssociatedLabelClick: function(focusableElement) {
4965  var isValidElement = focusableElement && ASPx.IsActionElement(focusableElement) && ASPx.GetIsParent(this.GetMainElement(), focusableElement);
4966  if(isValidElement)
4967   focusableElement.focus();
4968  else
4969   ASPxClientListBoxBase.prototype.OnDelayedSpecialFocusMouseDown.call(this, null);
4970 },
4971 TryApplyHighlighting: function() {
4972  var ownerControl = this.GetCallbackOwnerControl();
4973  var filterStrategy = ownerControl && ownerControl.filterStrategy ? ownerControl.filterStrategy : this.filterStrategy;
4974  if(filterStrategy && filterStrategy.ApplyHighlighting)
4975   filterStrategy.ApplyHighlighting();
4976 },
4977 onDropDownModalChanged: function(enabled) {
4978  if(!this.IsMultiColumn())
4979   return;
4980  if(enabled && !this.itemsManager.GetFirstVisibleItemRow())
4981   return;
4982  this.updateCellWidthsOnDropDownChanged(enabled);
4983 },
4984 updateCellWidthsOnDropDownChanged: function(enabled) {
4985  var applyFunction = this.getUpdateCellWidthsFunctionOnDropDownChanged(enabled);
4986  var sampleRow = this.GetSampleItemRow();
4987  var headerRow = this.GetHeaderTableElement().rows[0];
4988  var dataRows = this.itemsManager.GetListTableRows();
4989  for(var i = this.columnFieldNames.length - 1; i >= 0; i--) {
4990   applyFunction(sampleRow, i);
4991   applyFunction(headerRow, i);
4992   for(var row, j = 0; row = dataRows[j]; j++)
4993    applyFunction(row, i);
4994  }
4995 },
4996 getUpdateCellWidthsFunctionOnDropDownChanged: function(enabled) {
4997  if(enabled) {
4998   var row = this.itemsManager.GetFirstVisibleItemRow();
4999   var widths = Array.prototype.slice.call(row.cells, 0).map(function(cell) { return cell.offsetWidth; });
5000   var commonWidth = widths.reduce(function(a, b) { return a + b; }, 0);
5001   widths = widths.map(function(w) { return (w * 100) / commonWidth; });
5002   return function(row, cellIndex) {
5003    ASPx.Attr.ChangeStyleAttribute(row.cells[cellIndex], "width", widths[cellIndex] + "%");
5004   };
5005  }
5006  return function(row, cellIndex) {
5007   ASPx.Attr.RestoreStyleAttribute(row.cells[cellIndex], "width");
5008  };
5009 }
5010});
5011ASPxClientListBox.GetItemCellInnerText = function(itemTextCell) {
5012 var text;
5013 if(typeof(itemTextCell.attributes["DXText"]) != "undefined")
5014  text = ASPx.Attr.GetAttribute(itemTextCell, "DXText");
5015 else {
5016  var itemCellTextAttribute = ASPx.Attr.GetAttribute(itemTextCell, itemCellTextAttributeName);    
5017  text = ASPx.IsExists(itemCellTextAttribute) ? itemCellTextAttribute : ASPx.GetInnerText(itemTextCell);
5018 }
5019 text = text.replace(new RegExp(nbspChar, "g"), " ");
5020 return text;
5021};
5022var ASPxClientNativeListBox = ASPx.CreateClass(ASPxClientListBoxBase, {
5023 constructor: function(name) {
5024  this.constructor.prototype.constructor.call(this, name);
5025 },
5026 InitializeEvents: function() {
5027  ASPxClientListBoxBase.prototype.InitializeEvents.call(this);
5028  if(!!this.GetMainElement()) {
5029   ASPx.Evt.AttachEventToElement(this.GetMainElement(), "keydown", this.OnKeyDown.aspxBind(this));
5030   ASPx.Evt.AttachEventToElement(this.GetMainElement(), "keyup", this.OnKeyUp.aspxBind(this));
5031   ASPx.Evt.AttachEventToElement(this.GetMainElement(), "keypress", this.OnKeyPress.aspxBind(this));
5032  }
5033 },
5034 SetReadOnlyInternal: function(readOnly) {
5035  ASPxClientListBoxBase.prototype.SetReadOnlyInternal.call(this, readOnly);
5036  var options = this.GetMainElement().querySelectorAll("option");
5037  for (var i = 0, option; option = options[i]; i++) {
5038   if (readOnly)
5039    ASPx.Attr.SetAttribute(option, "disabled", "disabled");
5040   else
5041    ASPx.Attr.RemoveAttribute(option, "disabled");
5042  }
5043 }, 
5044 SetMainElement: function(mainElement){
5045  this.mainElement = mainElement;
5046 },
5047 FindInputElement: function(){
5048  return this.GetMainElement();
5049 }, 
5050 GetOptionCount: function(){
5051  return this.GetMainElement().options.length;
5052 },
5053 GetOption: function(index){
5054  return this.GetMainElement().options[index];
5055 },
5056 GetItemCount: function(){
5057  return this.GetOptionCount();
5058 },
5059 SelectIndexSilent: function(index){
5060  var selectedIndex = this.GetSelectedIndexInternal();
5061  var isValidIndex = (-1 <= index && index < this.GetItemCount());
5062  if((selectedIndex != index && isValidIndex) || !this.isInitialized){
5063   this.SetSelectedIndexInternal(index);
5064   return true;
5065  }
5066  return false;
5067 },
5068 GetSelectedIndexInternal: function(){
5069  return this.GetMainElement().selectedIndex; 
5070 },
5071 SetSelectedIndexInternal: function(index){
5072  this.GetMainElement().selectedIndex = index; 
5073 },
5074 ClearItemsCore: function(){
5075  this.GetMainElement().innerHTML = "";
5076 },
5077 RemoveItem: function(index){
5078  if(0 <= index && index < this.GetItemCount()){
5079   var oldSelectedIndex = this.GetSelectedIndexInternal();
5080   this.UpdateSyncArraysItemDeleted(this.GetItem(index), true);
5081   var option = this.GetOption(index);
5082   this.GetMainElement().removeChild(option);
5083   this.UpdateOptionValues();
5084   this.OnItemRemoved(oldSelectedIndex, index);
5085  }
5086 },
5087 OnItemRemoved: function(oldSelectedIndex, newSelectedIndex){
5088  if(newSelectedIndex == oldSelectedIndex && !this.MultiSelectionMode())
5089   this.SetSelectedIndexInternal(-1);
5090 },
5091 MultiSelectionMode: function(){
5092  return this.GetMainElement().multiple;
5093 },
5094 GetItem: function(index){
5095  if(0 <= index && index < this.GetOptionCount()) {
5096   var text = this.GetOption(index).text;
5097   var selected = this.GetMainElement().options[index].selected;
5098   var itemValue = this.itemsValue[index] !== undefined ? this.itemsValue[index] : null;
5099   if(ASPx.IsExists(text))
5100    return new ASPxClientListBoxItem(this, index, text, itemValue, "", selected);
5101  }
5102  return null;
5103 },
5104 PerformCallback: function(arg) {
5105  this.ClearItemsForPerformCallback();
5106  this.FormatAndSetCustomCallbackArg(arg, true);
5107  this.SendCallback();
5108  this.FormatAndSetCustomCallbackArg(arg, false);
5109 },
5110 SendCallback: function(){
5111  if(!this.InCallback()){
5112   var callbackOwner = this.GetCallbackOwnerControl();
5113   if(callbackOwner != null)
5114    callbackOwner.SendCallback();
5115    else {
5116    var argument = this.GetCallbackArguments();
5117    this.CreateCallback(argument);
5118   }
5119  }
5120 },
5121 ParseCallbackResult: function(result){
5122  var deserializedItems = this.DeserializeItems(result[CONSTANTS.CALLBACK_RESULTS.ITEMS]);
5123  this.LoadItemsFromCallback(true, deserializedItems);
5124 },
5125 InsertItemInternal: function(index, itemProperties) {
5126  if(typeof (itemProperties.value) == "undefined")
5127   itemProperties.value = itemProperties.texts;
5128  var oldSelectedIndex = this.GetSelectedIndexInternal();
5129  var isAdd = this.GetOptionCount() <= index;
5130  var newOption = document.createElement("OPTION");
5131  if(isAdd)
5132   this.GetMainElement().appendChild(newOption);
5133  else
5134   this.GetMainElement().insertBefore(newOption, this.GetOption(index));
5135  newOption.innerHTML = itemProperties.texts;
5136  this.UpdateOptionValues();
5137  ASPx.Data.ArrayInsert(this.itemsValue, itemProperties.value, index);
5138  this.RegisterInsertedItem(index, itemProperties); 
5139  if(index == oldSelectedIndex && index != -1)
5140   this.SetSelectedIndex(index + 1);
5141 },
5142 UpdateOptionValues: function() {
5143  if(this.APILockCount == 0){
5144   for(var i = 0; i < this.GetOptionCount(); i++)
5145    this.GetOption(i).value = i;
5146  }
5147 },
5148 ChangeEnabledAttributes: function(enabled){
5149  if(!this.isComboBoxList) {
5150   this.GetMainElement().disabled = !enabled;
5151   this.ChangeSpecialInputEnabledAttributes(this.GetMainElement(), ASPx.Attr.ChangeEventsMethod(enabled), true);
5152  }
5153 },
5154 OnCallback: function(result) {
5155  this.ParseCallbackResult(result);
5156 },
5157 OnItemDblClick: function(){
5158  this.RaiseItemDoubleClick();
5159 },
5160 LoadItemsFromCallback: function(isToTop, deserializedItems){
5161  this.BeginUpdate();
5162  this.LockSynchronizationOnInternalCallback();
5163  var mainElement = this.GetMainElement();
5164  for(var i = deserializedItems.length - 1; i >= 0; i--) {
5165   this.InsertItemInternal(0, deserializedItems[i]);
5166   if(deserializedItems[i].selected)
5167    mainElement.options[0].selected = true;
5168  }
5169  this.UnlockSynchronizationOnInternalCallback();
5170  this.EndUpdate();
5171 },
5172 EndUpdate: function(){
5173  ASPxClientListBoxBase.prototype.EndUpdate.call(this);
5174  this.UpdateOptionValues();
5175 },
5176 GetSelectedIndices: function(){
5177  var selectedIndices = [];
5178  var mainElement = this.GetMainElement();
5179  for(var i = 0; i < mainElement.options.length; i++){
5180   if(mainElement.options[i].selected)
5181    selectedIndices.push(i);
5182  }
5183  return selectedIndices;
5184 },
5185 GetSelectedValues: function(){ 
5186  var selectedValues = [];
5187  var selectedIndices = this.GetSelectedIndices();
5188  for(var i = 0; i < selectedIndices.length; i++)
5189   selectedValues.push(this.GetItemValue(selectedIndices[i]));
5190  return selectedValues;
5191 },
5192 GetSelectedItems: function(){
5193  var selectedItems = [];
5194  var selectedIndices = this.GetSelectedIndices();
5195  for(var i = 0; i < selectedIndices.length; i++)
5196   selectedItems.push(this.GetItem(selectedIndices[i]));
5197  return selectedItems;
5198 },
5199 SelectAll: function(){
5200  this.SetAllItemsSelectedValue(true);
5201 },
5202 UnselectAll: function(){
5203  this.SetAllItemsSelectedValue(false);
5204 },
5205 SetAllItemsSelectedValue: function(selected){
5206  var mainElement = this.GetMainElement();
5207  for(var i = 0; i < mainElement.options.length; i++)
5208   mainElement.options[i].selected = selected;
5209 },
5210 SelectIndices: function(indices){
5211  this.SetIndicesSelectionState(indices, true);
5212 },
5213 UnselectIndices: function(indices){
5214  this.SetIndicesSelectionState(indices, false);
5215 },
5216 SetIndicesSelectionState: function(indices, selected){
5217  var mainElement = this.GetMainElement();
5218  for(var i = 0; i < indices.length; i++){
5219   mainElement.options[indices[i]].selected = selected;
5220  }
5221 },
5222 SelectItems: function(items){
5223  if(ASPx.IsExists(items))
5224   this.SetItemsSelectionState(items, true);
5225  else
5226   this.SelectAll();
5227 },
5228 UnselectItems: function(items){
5229  if(ASPx.IsExists(items))
5230   this.SetItemsSelectionState(items, false);
5231  else
5232   this.UnselectAll();
5233 },
5234 SetItemsSelectionState: function(items, selected){
5235  var mainElement = this.GetMainElement();
5236  for(var i = 0; i < items.length; i++){
5237   mainElement.options[items[i].index].selected = selected;
5238  }
5239 },
5240 SelectValues: function(values){
5241  this.SetValuesSelectedState(values, true);
5242 },
5243 UnselectValues: function(values){
5244  this.SetValuesSelectedState(values, false);
5245 },
5246 SetValuesSelectedState: function(values, selected){
5247  var mainElement = this.GetMainElement();
5248  var index;
5249  for(var i = 0; i < values.length; i++){
5250   index = this.FindItemIndexByValue(values[i]);
5251   mainElement.options[index].selected = selected;
5252  }
5253 },
5254 EnsureRequiredNativeAttributesExists: function() {
5255  var input = this.GetInputElement();
5256  if(!input.onchange)
5257   ASPx.Evt.AttachEventToElement(input, "change", function() { ASPx.EValueChanged(this.name); }.aspxBind(this));
5258 }
5259});
5260var AccessibilityHelperListBox = ASPx.CreateClass(ASPx.AccessibilityHelperBase, {
5261 constructor: function(listBox) {
5262  this.constructor.prototype.constructor.call(this, listBox);
5263  this.checkBoxRefocusTimeout = 1000;
5264  this.firstReadingColumnIndex = this.control.CheckColumnSelectionMode() ? 1 : 0;
5265  this.Initialize();
5266 },
5267 Initialize: function() {
5268  if(this.control.CheckColumnSelectionMode() && !this.control.IsNativeCheckBoxes())
5269   this.control.GotFocus.AddHandler(function() { this.SetActionElementFocus(); }.aspxBind(this));
5270  this.control.GotFocus.AddHandler(function() { this.OnSelectedIndexChanged(this.control.GetSelectedIndex()); }.aspxBind(this));
5271  this.control.LostFocus.AddHandler(function() { 
5272   setTimeout(function() { 
5273    this.changeActivityAttributes(this.getMainElement(), { "aria-activedescendant": "" }); 
5274   }.aspxBind(this), 200); 
5275  }.aspxBind(this));
5276 },
5277 OnSelectedIndexChanged: function(index) {
5278  var stateSelected = index != -1 && this.control.GetItem(index) && this.control.GetItem(index).selected;
5279  var selectedIndex = this.control.GetSelectedIndex();
5280  if(this.control.CheckColumnSelectionMode() || stateSelected || selectedIndex == -1)
5281   this.setSelectionAttributes(index, stateSelected);
5282 },
5283 getPronounceTimeout: function() {
5284  if(ASPx.Browser.WebKitFamily && this.control.CheckColumnSelectionMode())
5285   return 1000;
5286  return ASPx.AccessibilityHelperBase.prototype.getPronounceTimeout.call(this);
5287 },
5288 getHeaderCellCaptionText: function(index) {
5289  var headerDiv = this.control.GetHeaderDivElement();
5290  if(!headerDiv) return "";
5291  var headerTable = headerDiv.firstElementChild;
5292  return headerTable.rows[0].cells[this.firstReadingColumnIndex + index].textContent;
5293 },
5294 isItemCheckBoxFocused: function() {
5295  for(var i = 0; i < this.control.GetItemCount() ; i++) {
5296   var internalCheckBox = this.control.GetInternalCheckBox(i);
5297   if(internalCheckBox && internalCheckBox.focused)
5298    return true;
5299  }
5300  return false;
5301 },
5302 isSelectAllCheckBoxFocused: function() {
5303  return this.control.selectAllCheckBox && this.control.selectAllCheckBox.focused;
5304 },
5305 SetActionElementFocus: function() {
5306  if(this.control.enableFiltering) {
5307   if(!this.control.HasInternalFilteringTextBoxFocus())
5308    this.SetFilterPanelFocus();
5309  }
5310  else
5311   this.SetCheckBoxFocus();
5312 },
5313 SetCheckBoxFocus: function () {
5314  var isCheckBoxFocused = this.isItemCheckBoxFocused() || this.isSelectAllCheckBoxFocused();
5315  if(!isCheckBoxFocused)
5316   this.ProcessRefocusHandler(function() {
5317    this.control.SetFocusedIndex(0);
5318   }.aspxBind(this));
5319 },
5320 SetFilterPanelFocus: function() {
5321  if(this.control.customFilteringEditorID || ASPx.ElementHasCssClass(this.control.filterMainElement, this.control.GetInactiveFilterElementClassName())) {
5322   if(this.control.showFilterButton)
5323    this.ProcessRefocusHandler(function() {
5324     this.control.showFilterButton.Focus(); 
5325    }.aspxBind(this));
5326  } else 
5327    this.ProcessRefocusHandler(function() {
5328     ASPx.FindFirstChildActionElement(this.control.filterMainElement).focus(); 
5329    }.aspxBind(this));
5330 },
5331 ProcessRefocusHandler: function(handler) {
5332   setTimeout(function() {
5333   if(!this.control.focused) return;
5334   handler();
5335  }.aspxBind(this), this.checkBoxRefocusTimeout);
5336 },
5337 getTextForScreenReader: function(item) {
5338  var result = "";
5339  if(!this.control.IsMultiColumn()) {
5340   result= item.text;
5341  } else {
5342   var columnsCount = this.control.columnFieldNames.length;
5343   var formatString = ASPx.AccessibilitySR.TableItemFormatString;
5344   for(var i = 0; i < columnsCount; i++)
5345    result += ASPx.Str.ApplyReplacement(formatString, [["{0}", this.getHeaderCellCaptionText(i)], ["{1}", item.texts[i]]]);
5346  }
5347  return result;
5348 },
5349 setSelectionAttributes: function(index, stateSelected) {
5350  if(index == -1) index = 0;
5351  var item = this.control.GetItem(index);
5352  if(!item) return;
5353  var assistText = this.getTextForScreenReader(item);
5354  var activeItemArgs = {
5355   "role"    : "option",
5356   "aria-posinset" : index + 1,
5357   "aria-setsize"  : this.control.itemTotalCount,
5358   "aria-selected" : stateSelected
5359  };
5360  var inactiveItemArgs = {
5361   "role"    : "",
5362   "aria-posinset" : "",
5363   "aria-setsize"  : "",
5364   "aria-selected" : ""
5365  };
5366  this.PronounceMessage(assistText, activeItemArgs, inactiveItemArgs);
5367 },
5368 SetCheckBoxesValidationAttributes: function() {
5369  if(!this.control.CheckColumnSelectionMode() || !this.control.GetErrorCell()) return;
5370  var errorTextElement = this.control.ariaExplanatoryTextManager.GetErrorTextElement();
5371  for (var i = 0; i < this.control.GetItemCount() ; i++) {
5372   var checkBoxFocusableElement = this.control.GetCheckBoxFocusableElement(i);
5373   if(checkBoxFocusableElement) {
5374    ASPx.Attr.SetOrRemoveAttribute(checkBoxFocusableElement, "aria-describedby", !this.control.isValid ? errorTextElement.id : null);
5375    ASPx.Attr.SetOrRemoveAttribute(checkBoxFocusableElement, "aria-invalid", !this.control.isValid);
5376   }
5377  }
5378 }
5379});
5380ASPxClientListBox.Cast = ASPxClientControl.Cast;
5381var ASPxClientCheckListBase = ASPx.CreateClass(ASPxClientListEdit, {
5382 constructor: function(name) {
5383  this.constructor.prototype.constructor.call(this, name);          
5384  this.imageProperties = null;
5385  this.internalButtonCollection = null; 
5386  this.icbFocusedStyle = [];
5387  this.items = [];
5388 },
5389 SetData: function(data){
5390  ASPxClientEdit.prototype.SetData.call(this, data);
5391  if(data.items)
5392   this.CreateItems(data.items);
5393 },
5394 Initialize: function() {
5395  ASPxClientListEdit.prototype.Initialize.call(this);
5396  this.UpdateInternalSelectedIndex(); 
5397 },
5398 UpdateInternalSelectedIndex: function() {
5399  var selectedIndexFromServer = this.GetSelectedIndex();
5400  var stateInput = this.FindStateInputElement();
5401  if(stateInput) {
5402   var restoredSelectedIndex = stateInput.value;
5403   if(restoredSelectedIndex != '' && restoredSelectedIndex != selectedIndexFromServer) {
5404    this.SetSelectedIndex(selectedIndexFromServer);
5405    this.SetSelectedIndex(restoredSelectedIndex);
5406   }
5407  }
5408 },
5409 CreateButtonInternalCollection: function() { 
5410  this.internalButtonCollection = this.CreateCheckBoxInternalCollection();
5411  for(var i = 0; i < this.GetItemCount(); i++) {
5412   var icbInputElement = this.GetItemInput(i);
5413   var internalButton = this.internalButtonCollection.Add(icbInputElement.id, icbInputElement, this.GetItemElement(i));
5414   internalButton.CreateFocusDecoration(this.icbFocusedStyle);
5415   internalButton.SetEnabled(this.GetEnabled());
5416   internalButton.GetReadOnly = this.GetReadOnly.bind(this);
5417   internalButton.CheckedChanged.AddHandler(function(s, e) {
5418    this.OnItemClick(this.GetItemIndexByElement(ASPx.Evt.GetEventSource(e)));
5419   }.aspxBind(this));
5420   internalButton.Focus.AddHandler(function(s, e) {
5421    if(!this.focused)
5422     this.OnFocus();
5423   }.bind(this));
5424   internalButton.LostFocus.AddHandler(function(s, e) { this.OnLostFocus(); }.aspxBind(this));
5425   this.attachToCellsClick(i);
5426   this.PrepareInternalButton(internalButton, i);
5427  }
5428  this.attachToMainElementMouseDown();
5429 },
5430 CreateCheckBoxInternalCollection: function () {
5431  return new ASPx.CheckBoxInternalCollection(this.imageProperties, false, true, ASPx.CheckEditElementHelper.Instance, undefined,
5432   this.accessibilityCompliant);
5433 },
5434 CheckableElementsExist: function() {
5435  return !!this.imageProperties;
5436 },
5437 SetEnabled: function(enabled){
5438  ASPxClientListEdit.prototype.SetEnabled.call(this, enabled);
5439  var stateInput = this.FindStateInputElement();
5440  if(enabled)
5441   ASPx.Attr.RemoveAttribute(stateInput, "disabled");
5442  else
5443   ASPx.Attr.SetAttribute(stateInput, "disabled", "disabled");
5444 },
5445 SetFocus: function() {
5446  this.UpdateFocus(); 
5447 },
5448 UpdateFocus: function() {
5449 },
5450 IsElementBelongToInputElement: function(element) {
5451  return this.GetItemIndexByElement(element) != -1;
5452 },
5453 attachToCellsClick: function(index) {
5454  var element = this.GetItemElement(index);
5455  ASPx.Evt.AttachEventToElement(element, "click", function(evt) {
5456   var src = ASPx.Evt.GetEventSource(evt);
5457   var label = ASPx.CheckEditElementHelper.Instance.GetLabelElement(element);
5458   var button = this.internalButtonCollection.Get(this.GetItemInput(index).id);
5459   if(!ASPx.GetIsParent(button.mainElement, src) && src !== label && src.parentElement !== label) {
5460    ASPx.CheckEditElementHelper.Instance.InvokeClick(button, evt);
5461   }
5462  }.aspxBind(this));
5463 },
5464 attachToMainElementMouseDown: function() {
5465  var mainElement = this.GetMainElement();
5466  ASPx.Evt.AttachEventToElement(mainElement, "mousedown", function() {
5467   if(!this.enabled || this.readOnly)
5468    return;
5469   this.LockFocusEvents();
5470   setTimeout(function() { this.UnlockFocusEvents(); }.aspxBind(this), 0);
5471  }.aspxBind(this));
5472 },
5473 GetItemIndexByElement: function(element) {
5474  for(var i = 0; i < this.GetItemCount(); i++) {
5475   var itemElement = this.GetItemElement(i);
5476   if(ASPx.GetIsParent(itemElement, element))
5477    return i;
5478  }
5479  return -1;  
5480 },
5481 GetItemInput: function(index) {
5482  return this.GetChildElement("RB" + index + "_I");
5483 },
5484 GetItemElement: function(index) {
5485  return this.GetChildElement("RB" + index);
5486 },
5487 GetItemFocusableElement: function(index) {
5488  return this.accessibilityCompliant ? this.GetChildElement("RB" + index + "_I_D") : this.GetItemInput(index);
5489 },
5490 GetAccessibilityActiveElements: function() {
5491  var accessibilityElements = [];
5492  for(var i = 0; i < this.GetItemCount(); i++) 
5493   accessibilityElements.push(this.GetItemFocusableElement(i));
5494  return accessibilityElements;
5495 },
5496 GetItemCount: function() {
5497  return this.items.length;
5498 },
5499 OnItemClick: function(index) {
5500 },
5501 OnItemClickReadonly: function() {
5502  var index = this.GetSelectedIndexInternal();
5503  this.SelectIndexSilent(index);
5504 },
5505 UpdateHiddenInputs: function(index) {
5506  var stateInput = this.FindStateInputElement();
5507  if(ASPx.IsExistsElement(stateInput))
5508   stateInput.value = index;
5509  var valueInput = this.GetValueInputElement();
5510  if(ASPx.IsExistsElement(valueInput)) {
5511   var value = this.GetValue();
5512   valueInput.value = ASPx.IsExists(value) ? value : " ";
5513  }
5514 },
5515 GetItemValue: function(index){
5516  if(index > -1 && index < this.items.length) {
5517   if(typeof(this.items[index].value) == "string" && this.items[index].value == "" && this.convertEmptyStringToNull)
5518    return null;
5519   else
5520    return this.items[index].value;
5521  }
5522  return null;
5523 },
5524 SetValue: function(value) {
5525  for(var i = 0; i < this.items.length; i++) {
5526   if(this.GetItemValue(i) == value) {   
5527    this.SelectIndexSilent(i);
5528    return;
5529   }
5530  } 
5531  this.SelectIndexSilent(-1);    
5532 },
5533 CreateItems: function(itemsProperties){
5534  for(var i = 0; i < itemsProperties.length; i++)
5535   this.CreateItem(i, {
5536    texts: itemsProperties[i][0],
5537    value: this.GetDecodeValue(itemsProperties[i][1]),
5538    imageUrl: itemsProperties[i][2]
5539   });
5540 },
5541 CreateItem: function(index, itemProperties){
5542  var item = new ASPxClientListEditItem(this, index, itemProperties.texts, itemProperties.value, itemProperties.imageUrl);
5543  this.items.push(item);
5544 },
5545 GetItem: function(index){
5546  return (0 <= index && index < this.items.length) ? this.items[index] : null;
5547 },
5548 ChangeEnabledAttributes: function(enabled){
5549  if(!this.CheckableElementsExist()) {
5550   for(var i = 0; i < this.GetItemCount(); i++){
5551    var element = this.GetItemInput(i);
5552    if(element){
5553     this.ChangeItemEnabledAttributes(element, ASPx.Attr.ChangeAttributesMethod(enabled));
5554     this.ChangeSpecialInputEnabledAttributes(element, ASPx.Attr.ChangeEventsMethod(enabled), true);
5555     element.disabled = !enabled;
5556    }
5557   }
5558  } else {
5559   var selectedIndex = this.GetSelectedIndexInternal();
5560   this.UpdateCheckableElementDecorations(selectedIndex, enabled);
5561  }
5562 },
5563 ChangeEnabledStateItems: function(enabled){
5564  ASPx.GetStateController().SetElementEnabled(this.GetMainElement(), enabled);
5565  if(this.isNative){
5566   for(var i = 0; i < this.GetItemCount(); i++){
5567    var element = this.GetItemInput(i);
5568    if(element)
5569     ASPx.GetStateController().SetElementEnabled(element, enabled);
5570   }
5571  }
5572 },
5573 ChangeItemEnabledAttributes: function(element, method){
5574  method(element, "onclick");
5575 }
5576});
5577var ASPxClientRadioButtonList = ASPx.CreateClass(ASPxClientCheckListBase, {
5578 constructor: function(name) {
5579  this.constructor.prototype.constructor.call(this, name);          
5580 },
5581 InlineInitialize: function() {
5582  if(this.CheckableElementsExist()) 
5583   this.CreateButtonInternalCollection();
5584  ASPxClientCheckListBase.prototype.InlineInitialize.call(this);
5585 },
5586 Initialize: function() {
5587  ASPxClientCheckListBase.prototype.Initialize.call(this);
5588  this.UpdateHiddenInputs(this.GetSelectedIndex());
5589  this.SetSelectedIndex(this.GetSelectedIndex()); 
5590 },
5591 PrepareInternalButton: function(internalRadioButton){
5592  internalRadioButton.autoSwitchEnabled = false;
5593 },
5594 GetInputElement: function() {
5595  if(this.isNative) {
5596   var index = this.GetSelectedIndexInternal();
5597   return this.GetItemInput(index);
5598  } else 
5599   return this.GetValueInputElement();
5600 },
5601 GetValueInputElement: function() {
5602  if(this.valueInput == null) {
5603   var stateInput = this.FindStateInputElement();
5604   this.valueInput = this.GetHiddenField(null, this.name + "_ValueInput", stateInput.parentNode, stateInput);
5605  }
5606  return this.valueInput;
5607 },
5608 GetValueInputToValidate: function() {
5609  return this.GetValueInputElement();
5610 },
5611 SelectIndexSilent: function(index) {
5612  var itemCount = this.GetItemCount();
5613  var isValidIndex = (-1 <= index && index < itemCount);
5614  if(isValidIndex) {
5615   if(this.CheckableElementsExist()) 
5616    this.UpdateCheckableElementDecorations(index, this.GetEnabled());
5617   else {
5618    for(var i = 0; i < itemCount; i++) {
5619     var element = this.GetItemInput(i);
5620     if(element)
5621      element.checked = (i == index);
5622    }
5623   }
5624   this.SetSelectedIndexInternal(index);
5625   this.UpdateHiddenInputs(index);
5626  }
5627 },
5628 UpdateCheckableElementDecorations: function(selectedIndex, enabled) {
5629  if(this.CheckableElementsExist()) {
5630   for(var i = 0; i < this.items.length; i++) {
5631    var inputElement = this.GetItemInput(i);
5632    var internalButton = this.internalButtonCollection.Get(inputElement.id);
5633    internalButton.SetEnabled(enabled);
5634    internalButton.SetValue(i == selectedIndex ? ASPx.CheckBoxInputKey.Checked : ASPx.CheckBoxInputKey.Unchecked);
5635   }
5636  }
5637 },
5638 UpdateFocus: function() {
5639  var index = this.GetSelectedIndexInternal();
5640  if(index == -1)
5641   index = 0;
5642  var itemElement = this.GetItemFocusableElement(index);
5643  if(itemElement != null && ASPx.GetActiveElement() != itemElement && ASPx.IsEditorFocusable(itemElement)) 
5644   ASPx.SetFocus(itemElement);
5645 },
5646 OnItemClick: function(index) {
5647  if(this.GetSelectedIndexInternal() != index) {
5648   this.SelectIndexSilent(index);
5649   this.RaisePersonalStandardValidation();
5650   this.OnValueChanged();
5651  }
5652  this.UpdateFocus();
5653 },
5654 RequireInputElementToValidate: function() {
5655  return false;
5656 },
5657 GetItem: function(index){
5658  var item = ASPxClientCheckListBase.prototype.GetItem.call(this, index);
5659  if(item)
5660   item.selected = index == this.GetSelectedIndexInternal();
5661  return item;
5662 }
5663});
5664ASPxClientRadioButtonList.Cast = ASPxClientControl.Cast;
5665var ASPxClientCheckBoxList = ASPx.CreateClass(ASPxClientCheckListBase, {
5666 constructor: function(name) {
5667  this.constructor.prototype.constructor.call(this, name);          
5668  this.selectionEventsLockCount = 0;
5669  this.initializeInputValue = null;
5670  this.restoredSelectedIndices = null;
5671 },
5672 InlineInitialize: function() {
5673  if(this.CheckableElementsExist()) 
5674   this.CreateButtonInternalCollection();
5675  ASPxClientCheckListBase.prototype.InlineInitialize.call(this);
5676 },
5677 Initialize: function() {
5678  this.initializeInputValue = this.GetInputElement().value;
5679  ASPxClientCheckListBase.prototype.Initialize.call(this);
5680  this.SaveRestoredIndices();
5681  this.InitSelection();
5682 },
5683 SaveRestoredIndices: function() {
5684  var value = this.initializeInputValue;
5685  if(!ASPx.IsExists(value) || value === "")
5686   return;
5687  var serializer = this.GetSerializingHelper();
5688  var itemStringIndices = serializer.DeserializeValues(value);
5689  var itemIndices = [];
5690  for(var i = 0; i < itemStringIndices.length; i++) {
5691   var itemIndex = parseInt(itemStringIndices[i]);
5692   itemIndices.push(itemIndex);
5693  }
5694  this.restoredSelectedIndices = itemIndices;
5695 },
5696 InitSelection: function() {
5697  if(this.restoredSelectedIndices)
5698   this.UnselectAll();
5699  var selectedIndices = this.restoredSelectedIndices || this.initSelectedIndices;
5700  this.SelectIndices(selectedIndices);
5701  this.CacheValue();
5702 },
5703 PrepareInternalButton: function(internalCheckBox, index){
5704  internalCheckBox.autoSwitchEnabled = true;
5705  internalCheckBox.SetChecked(this.GetItemSelectionHelper().GetIsItemSelected(index));
5706 },
5707 SelectIndexSilent: function(index) {
5708  var itemCount = this.GetItemCount();
5709  var isValidIndex = (-1 <= index && index < itemCount);
5710  if(isValidIndex)
5711   this.SelectIndices([index]);
5712 },
5713 UpdateCheckableElementDecorations: function(selectedIndex, enabled) {
5714  if(this.CheckableElementsExist()) {
5715   for(var i = 0; i < this.items.length; i++) {
5716    var inputElement = this.GetItemInput(i);
5717    var internalButton = this.internalButtonCollection.Get(inputElement.id);
5718    internalButton.SetEnabled(enabled);
5719   }
5720  }
5721 },
5722 SetSelectionDecoration: function(index, selected){ 
5723  if(this.CheckableElementsExist()){
5724   var inputElement = this.GetItemInput(index);
5725   var internalButton = this.internalButtonCollection.Get(inputElement.id);
5726   internalButton.SetValue(selected ? ASPx.CheckBoxInputKey.Checked : ASPx.CheckBoxInputKey.Unchecked);
5727  } else {
5728   var element = this.GetItemInput(index);
5729   if(element)
5730    element.checked = (selected); 
5731  }
5732 },
5733 OnItemClick: function(index) {
5734  this.GetItemSelectionHelper().OnItemClick(index);
5735 },
5736 UpdateFocus: function() {
5737  var index = this.GetItemSelectionHelper().GetFocusedItemIndex();
5738  if(index == -1)
5739   index = this.GetSelectedIndexInternal();
5740  if(index == -1)
5741   index = 0;
5742  var itemElement = this.GetItemFocusableElement(index);
5743  if(itemElement != null && ASPx.GetActiveElement() != itemElement && ASPx.IsEditorFocusable(itemElement)) 
5744   ASPx.SetFocus(itemElement);
5745 },
5746 UpdateInternalState: function(){
5747  this.UpdateHiddenInputs();
5748 },
5749 IsUpdateHiddenInputsLocked: function(){
5750  return this.GetItemSelectionHelper().IsUpdateInternalSelectionStateLocked();
5751 },
5752 UpdateHiddenInputs: function(){
5753  if(this.IsUpdateHiddenInputsLocked()) 
5754   return;
5755  var element = this.FindStateInputElement();
5756  if(ASPx.IsExistsElement(element)) { 
5757   var sb = [ ];
5758   var serialiser = this.GetSerializingHelper();
5759   var selectedIndices = this.GetSelectedIndices();
5760   for(var i = 0; i < selectedIndices.length; i++)
5761    serialiser.SerializeAtomValue(sb, selectedIndices[i]);
5762   element.value = sb.join("");
5763  }
5764 },
5765 GetSerializingHelper: function(){ 
5766  if(this.serializingHelper == null)
5767   this.serializingHelper = new ListBoxBaseItemsSerializingHelper(this);
5768  return this.serializingHelper;
5769 },
5770 SetItemSelectionAppearance: function(index, selected, controller, checkCanChangeSelection){
5771 },
5772 LockSelectionEvents: function(){
5773  this.selectionEventsLockCount++;
5774 },
5775 UnlockSelectionEvents: function(){
5776  this.selectionEventsLockCount--;
5777 },
5778 IsSelectionEventsLocked: function(){
5779  return this.selectionEventsLockCount > 0;
5780 },
5781 CacheValue: function(){
5782  this.cachedValue = this.GetValue();
5783 },
5784 IsValueChanged: function(){
5785  return this.cachedValue != this.GetValue();
5786 },
5787 OnItemSelectionChanged: function(index, selected){
5788  this.SetSelectionDecoration(index, selected);
5789  if(!this.IsSelectionEventsLocked()) {
5790   this.SetRaiseSelectedIndexChangedArguments(this.autoPostBack, index, selected);
5791   var valueChanged = this.IsValueChanged();
5792   if(valueChanged) {
5793    this.RaisePersonalStandardValidation();
5794    this.OnValueChanged();
5795   } else {
5796    if(this.RaiseSelectedIndexChanged())
5797     this.SendPostBackInternal("");
5798   }
5799  }
5800  this.CacheValue();
5801 },
5802 SetRaiseSelectedIndexChangedArguments: function(processOnServer, index, selected){
5803  this.selectedIndexChangedArguments = {
5804   processOnServer: processOnServer,
5805   index: index,
5806   selected: selected
5807  };
5808 },
5809 GetRaiseSelectedIndexChangedArguments: function(){
5810  if(!this.selectedIndexChangedArguments)
5811   this.SetRaiseSelectedIndexChangedArguments(false, this.GetSelectedIndex(), true);
5812  return this.selectedIndexChangedArguments;
5813 },
5814 RaiseSelectedIndexChanged: function (processOnServer) {
5815  this.RaiseValidationInternal();
5816  var savedArgs = this.GetRaiseSelectedIndexChangedArguments();
5817  processOnServer = savedArgs.processOnServer || processOnServer;
5818  if(!this.SelectedIndexChanged.IsEmpty()){
5819   var args = new ASPxClientListEditItemSelectedChangedEventArgs(savedArgs.index, savedArgs.selected, processOnServer);
5820   this.SelectedIndexChanged.FireEvent(this, args);
5821   processOnServer = args.processOnServer;
5822  }
5823  return processOnServer;
5824 },
5825 GetItemSelectionHelper: function(){
5826  if(!this.itemSelectionHelper)
5827   this.itemSelectionHelper = this.CreateItemSelectionHelper();
5828  return this.itemSelectionHelper;
5829 },
5830 CreateItemSelectionHelper: function(){
5831  return new CheckBoxListMultiSelectionHelper(this);
5832 },
5833 GetItem: function(index){
5834  var item = ASPxClientCheckListBase.prototype.GetItem.call(this, index);
5835  item.selected = this.GetItemSelectionHelper().GetIsItemSelected(index);
5836  return item;
5837 },
5838 SetValue: function(value){
5839  var index = this.FindItemIndexByValue(value);
5840  this.SetSelectedIndex(index);
5841 },
5842 GetSelectedIndexInternal: function(){
5843  if(!this.isInitialized)
5844   return ASPxClientCheckListBase.prototype.GetSelectedIndexInternal.call(this);
5845  return this.GetItemSelectionHelper().GetSelectedIndex();
5846 },
5847 SetSelectedIndex: function(index){
5848  this.LockSelectionEvents();
5849  this.GetItemSelectionHelper().SetSelectedIndex(index);
5850  this.UnlockSelectionEvents();
5851 },
5852 GetSelectedIndices: function(){
5853  return this.GetItemSelectionHelper().GetSelectedIndices();
5854 },
5855 GetSelectedValues: function(){ 
5856  return this.GetItemSelectionHelper().GetSelectedValues();
5857 },
5858 GetSelectedItems: function(){
5859  return this.GetItemSelectionHelper().GetSelectedItems();
5860 },
5861 SelectAll: function(){
5862  this.SelectIndices();
5863 },
5864 UnselectAll: function(){
5865  this.UnselectIndices();
5866 },
5867 SelectIndices: function(indices){
5868  this.LockSelectionEvents();
5869  this.GetItemSelectionHelper().SelectIndices(indices);
5870  this.UnlockSelectionEvents();
5871 },
5872 SelectItems: function(items){
5873  this.LockSelectionEvents();
5874  this.GetItemSelectionHelper().SelectItems(items);
5875  this.UnlockSelectionEvents();
5876 },
5877 SelectValues: function(values){
5878  this.LockSelectionEvents();
5879  this.GetItemSelectionHelper().SelectValues(values);
5880  this.UnlockSelectionEvents();
5881 },
5882 UnselectIndices: function(indices){
5883  this.LockSelectionEvents();
5884  this.GetItemSelectionHelper().UnselectIndices(indices);
5885  this.UnlockSelectionEvents();
5886 },
5887 UnselectItems: function(items){
5888  this.LockSelectionEvents();
5889  this.GetItemSelectionHelper().UnselectItems(items);
5890  this.UnlockSelectionEvents();
5891 },
5892 UnselectValues: function(values){
5893  this.LockSelectionEvents();
5894  this.GetItemSelectionHelper().UnselectValues(values);
5895  this.UnlockSelectionEvents();
5896 }
5897});
5898ASPxClientCheckBoxList.Cast = ASPxClientControl.Cast;
5899var ASPxClientListEditItemSelectedChangedEventArgs = ASPx.CreateClass(ASPxClientProcessingModeEventArgs, {
5900 constructor: function(index, isSelected, processOnServer){
5901  this.constructor.prototype.constructor.call(this, processOnServer);
5902  this.index = index;
5903  this.isSelected = isSelected;
5904 }
5905});
5906function aspxLBTSelectStart(evt){
5907 var shiftPressed = evt.shiftKey;
5908 var ctrlKey = evt.ctrlKey || evt.metaKey;
5909 if(shiftPressed || ctrlKey){
5910  ASPx.Selection.Clear();
5911  ASPx.Evt.PreventEventAndBubble(evt);
5912 }
5913}
5914function aspxLBIClick(evt){
5915 if(ASPx.TouchUIHelper.isMouseEventFromScrolling) return;
5916 var element = ASPx.Evt.GetEventSource(evt);
5917 while(element != null && element.tagName != "BODY"){
5918  if(element.tagName == "TR"){
5919   var table = element.offsetParent;
5920   if(table && table.ListBoxId){
5921    var lb = ASPx.GetControlCollection().Get(table.ListBoxId);
5922    if(lb != null) {
5923     var retValue;
5924     if(evt.type == "dblclick") 
5925      retValue =lb.OnItemDblClick();
5926     else if(!lb.isComboBoxList || ASPx.Evt.IsLeftButtonPressed(evt)) {
5927      var itemIndex = lb.GetItemIndexByRow(element);
5928      retValue = lb.OnItemClick(itemIndex, evt);
5929     }
5930     if(typeof(retValue) != "undefined")
5931      return retValue;
5932    }
5933    break;
5934   }
5935  }
5936  element = element.parentNode;
5937 }
5938}
5939function aspxLBScroll(evt){
5940 var sourceId = ASPx.Evt.GetEventSource(evt).id;
5941 if(sourceId.slice(-lbDSuffix.length) == lbDSuffix){
5942  var name = sourceId.slice(0, -2);
5943  var lb = ASPx.GetControlCollection().Get(name);
5944  if(lb != null && lb.isInitialized) 
5945   lb.OnScroll();
5946 }
5947}
5948ASPx.NLBIDClick = function(evt) {
5949 var element = ASPx.Evt.GetEventSource(evt);
5950 if(element != null && element.tagName == "SELECT"){
5951  var lb = ASPx.GetControlCollection().Get(element.id);
5952  if(lb != null)
5953   lb.OnItemDblClick();
5954 }
5955};
5956ASPx.ERBLIClick = function(name, index) {
5957 var list = ASPx.GetControlCollection().Get(name);
5958 if(list != null) {
5959  if(list.GetReadOnly())
5960   return false;
5961  list.OnItemClick(index);
5962 }
5963};
5964ASPx.ERBLICancel = function(name) {
5965 var list = ASPx.GetControlCollection().Get(name);
5966 if(list != null)
5967  list.OnItemClickReadonly();
5968};
5969ASPx.ShowListBoxFilter = function(name) {
5970 var list = ASPx.GetControlCollection().Get(name);
5971 if(list != null)
5972  list.ShowFilterElement();
5973};
5974ASPx.HideListBoxFilter = function(name) {
5975 var list = ASPx.GetControlCollection().Get(name);
5976 if (list != null)
5977  list.HideFilterElement();
5978};
5979var highlightingOpeningGuid = "680fb6b5-de5f-4af1-b444-2617b6dc5aab";
5980var highlightingClosingGuid = "ee51e3d2-fb72-45fc-b737-6d3432008053";
5981ASPx.ListBoxHighlightingHelper = ASPx.CreateClass(null, {
5982 constructor: function(listBox, tagName) {
5983  this.listBox = listBox;
5984  this.tagName = tagName;
5985  this.highlightingOpeningTag = "<" + tagName + ">";
5986  this.highlightingClosingTag = "</" + tagName + ">";
5987  this.highlightingOpeningTagPlaceholder = new RegExp(highlightingOpeningGuid, "g");
5988  this.highlightingClosingTagPlaceholder = new RegExp(highlightingClosingGuid, "g");
5989  this.customReplacer = highlightingOpeningGuid + "$&" + highlightingClosingGuid;
5990 },
5991 Apply: function(text, isCustom) {
5992  if(text == "" || !this.listBox.encodeHtml) return;
5993  if(isCustom)
5994   this.applyCustom(text);
5995  else
5996   this.apply(text, ASPx.ContainsFilteringUtils.SelectContainsTextInElement, false);
5997 },
5998 Remove: function(text, isCustom) {
5999  if(isCustom)
6000   this.removeCustom(text);
6001  else
6002   this.apply(text, ASPx.ContainsFilteringUtils.UnselectContainsTextInElement, true);
6003 },
6004 Refresh: function(text, isCustom) {
6005  if(text == "") return;
6006  if(isCustom)
6007   this.applyCustom(text, true);
6008  else
6009   this.apply(text, ASPx.ContainsFilteringUtils.ReselectContainsTextInElement, false);
6010 },
6011 applyCustom: function(highlighting, refreshing) { 
6012  var count = this.listBox.GetItemCount();
6013  var highlightingRegExpxByColumns = this.getCustomHighlightingRegExpsByColumns(highlighting);
6014  for(var i = 0; i < count; i++) {
6015   var item = this.listBox.GetItemRow(i);
6016   if(!item || this.listBox.ItemRowHasTemplate(i)) continue;
6017   this.applyCustomCore(item, highlightingRegExpxByColumns, refreshing);
6018  }
6019 },
6020 applyCustomCore: function(item, highlightingRegExpxByColumns, refreshing) {
6021  var elements = this.getTextCellElements(item);
6022  for(var i = 0, el; el = elements[i]; i++) {
6023   if(refreshing)
6024    this.removeCustomFromItem(el);
6025   this.applyCustomToItem(el, highlightingRegExpxByColumns[i]);
6026  }
6027 },
6028 applyCustomToItem: function(element, regexp) {
6029  if(!regexp)
6030   return;
6031  var currentText = ASPx.Attr.GetAttribute(element, "DXText");
6032  if(!ASPx.IsExists(currentText)) ASPx.Attr.SetAttribute(element, "DXText", ASPx.GetInnerText(element));
6033  var oldInnerText = ASPx.GetInnerText(element);
6034  var newInnerText = oldInnerText.replace(regexp, this.customReplacer);
6035  newInnerText = ASPx.ContainsFilteringUtils.PrepareElementText(newInnerText)
6036   .replace(this.highlightingOpeningTagPlaceholder, this.highlightingOpeningTag)
6037   .replace(this.highlightingClosingTagPlaceholder, this.highlightingClosingTag);
6038  if(newInnerText !== oldInnerText)
6039   ASPx.SetInnerHtml(element, newInnerText);
6040 },
6041 removeCustomFromItem: function(element) {
6042  var currentText = ASPx.Attr.GetAttribute(element, "DXText");
6043  if(ASPx.IsExists(currentText)) {
6044   currentText = ASPx.ContainsFilteringUtils.PrepareElementText(currentText);
6045   ASPx.SetInnerHtml(element, currentText === "" ? "&nbsp;" : currentText);
6046  }
6047 },
6048 removeCustom: function() {
6049  var count = this.listBox.GetItemCount();
6050  for(var i = 0; i < count; i++) {
6051   var item = this.listBox.GetItemRow(i);
6052   if(!item || this.listBox.ItemRowHasTemplate(i)) continue;
6053   this.removeCustomCore(item);
6054  }
6055 },
6056 removeCustomCore: function(item) {
6057  var elements = this.getTextCellElements(item);
6058  for(var i = 0, el; el = elements[i]; i++)
6059   this.removeCustomFromItem(el);
6060 },
6061 getCustomHighlightingRegExpsByColumns: function(highlighting) {
6062  var columns = this.listBox.IsMultiColumn() ? this.listBox.columnFieldNames : [""];
6063  return columns.map(function(fieldName) {
6064   if(typeof (highlighting) === "string" || Array.isArray(highlighting) || highlighting instanceof RegExp)
6065    return this.arrayToRegEx(highlighting);
6066   if(typeof (highlighting) === "object")
6067    return this.arrayToRegEx(highlighting[fieldName]);
6068   return null;
6069  }.bind(this));
6070 },
6071 arrayToRegEx: function(texts) {
6072  if(texts instanceof RegExp)
6073   return texts;
6074  if(typeof (texts) === "string")
6075   return this.arrayToRegEx([texts]);
6076  if(Array.isArray(texts)) {
6077   texts = texts
6078    .filter(function(t) { return typeof (t) === "string" && t.length; })
6079    .sort(function(a, b) { return b.length - a.length; })
6080    .map(ASPx.Str.EscapeForRegEx);
6081   if(texts.length)
6082    return new RegExp("(" + texts.join("|") + ")", "gi");
6083  }
6084  return null;
6085 },
6086 apply: function(text, func, allColumns) {
6087  var count = this.listBox.GetItemCount();
6088  for (var i = 0; i < count; i++) {
6089   var item = this.listBox.GetItemRow(i);
6090   if (item && (allColumns || ASPx.GetElementDisplay(item)) && this.canApply(item)) {
6091    var elements = this.listBox.GetItemSelectableElementsByRow(item);
6092    this.applyToItem(text, elements, func, allColumns);
6093   }
6094  }
6095 },
6096 applyToItem: function(text, elements, func, allColumns) {
6097  var itemValues = this.getItemValues(elements);
6098  var itemSelection = this.getItemSelection(itemValues, this.listBox.textFormatString, text);
6099  var firstTextCellIndex = this.getFirstTextCellIndex();
6100  if (allColumns) {
6101   for (var i = 0; i < elements.length; i++)
6102    this.applyToItemCore(func, elements[i], itemSelection[i]);
6103  } else
6104   this.applyToTextCells(func, firstTextCellIndex, elements, itemSelection);
6105 },
6106 getItemSelection: function (itemValues, textFormatString, text) {
6107  return ASPx.ContainsFilteringUtils.GetColumnSelectionsForItem(itemValues, textFormatString, text);
6108 },
6109 applyToTextCells: function(func, firstTextCellIndex, elements, itemSelection) {
6110  for(var i = 0; i < itemSelection.length; i++)
6111   this.applyToItemCore(func, elements[itemSelection[i].index + firstTextCellIndex], itemSelection[i]);
6112 },
6113 applyToItemCore: function (func, itemElement, itemSelection) {
6114  if (!this.listBox.ItemCellHasTextAttr(itemElement))
6115   func(itemElement, itemSelection, this.tagName);
6116 },
6117 getItemValues: function (elements) {
6118  var result = [];
6119  for (var i = this.getFirstTextCellIndex() ; i < elements.length; i++)
6120   result.push(ASPxClientListBox.GetItemCellInnerText(elements[i]));
6121  return result;
6122 },
6123 canApply: function (item) {
6124  return !this.listBox.ItemRowHasTemplateCore(item);
6125 },
6126 getFirstTextCellIndex: function () {
6127  return this.listBox.GetItemFirstTextCellIndex();
6128 },
6129 getTextCellElements: function(item) {
6130  return this.listBox.GetItemTextCells(item);
6131 }
6132});
6133var ListEditFilterStrategyBase = ASPx.CreateClass(null, {
6134 OnPaste: function(evt) { },
6135 OnInput: function() { },
6136 OnClearButtonClick: function() { },
6137 OnTextChanged: function() { },
6138 OnEscape: function() { },
6139 OnKeyDown: function(evt) { },
6140 OnAfterEnter: function() { },
6141 OnSelectedIndexChanged: function() { },
6142 OnLostFocus: function() { },
6143 OnCallback: function(result) { },
6144 OnBeforeDoEndCallback: function() { },
6145 OnAfterDoEndCallback: function() { },
6146 OnBeforeCallbackFinally: function() { },
6147 OnAfterCallbackFinally: function() { },
6148 OnPerformCallback: function() { },
6149 Filtering: function() { },
6150 CancelFiltering: function() { },
6151 ShouldDiscardCallbackResult: function() { },
6152 GetCallbackArguments: function() { return ""; },
6153 CanNavigateByKbd: function() { return true; },
6154 IsFilterMeetRequirementForMinLength: function (filter) { return true; },
6155 ResetCallbackState: function() { },
6156 ClearFilterApplied: function() { },
6157 OnDropDownHideArea: function() { },
6158 OnDropDownButtonClick: function() { },
6159 OnDropDownCloseByDocumentOrWindowEvent: function() { },
6160 OnApplyChanges: function() { },
6161 OnCancelChanges: function() { },
6162 OnUndo: function() { }
6163});
6164var ListEditIncrementalFilterStrategyBase = ASPx.CreateClass(ListEditFilterStrategyBase, {
6165 constructor: function(filterDelay, filterMinLength, isCallbackMode) {
6166  this.filterTimeoutId = -1;
6167  this.filterDelay = filterDelay;
6168  this.filterMinLength = filterMinLength;
6169  this.isCallbackMode = isCallbackMode;
6170  this.filter = "";
6171  this.highlighting = "";
6172  this.filterInitialized = false;
6173  this.needEmptyFilterBeforeFiltering = false;
6174  this.currentCallbackIsFiltration = false;
6175  this.refiltrationRequired = false;
6176 },
6177 GetInputFilterValue: function() { throw "Not Implemented"; },
6178 GetListBoxControl: function() { throw "Not Implemented"; },
6179 IsSatisfy: function(text, filter) { throw "Not Implemented"; },
6180 InCallback: function() { throw "Not Implemented"; },
6181 IsEnabled: function() { throw "Not Implemented"; },
6182 SendCallbackCore: function() { throw "Not Implemented"; },
6183 PreventEndCallbackRising: function() { throw "Not Implemented"; },
6184 GetSelectedIndex: function() { throw "Not Implemented"; },
6185 NotifyCollectionChanged: function() { throw "Not Implemented"; },
6186 OnCallbackCore: function(highlighting, newFilterLength) { throw "Not Implemented"; },
6187 RaiseItemFilteringEvent: function(item, filter, isFit) { throw "Not Implemented"; },
6188 RaiseCustomHighlightingEvent: function(filter, highlighting) { throw "Not Implemented"; },
6189 OnBeforeFilteringOnClient: function(filter) { }, 
6190 OnAfterFilteringOnClientCore: function (filter, firstSatisfyItemIndex) { throw "Not Implemented"; },
6191 SupportsFilterCorrection: function() { throw "Not Implemented"; },
6192 OnFirstSatisfiedItemFound: function(index, text, isTextClearing) { },
6193 TryProcessFilterLessMinLength: function() { return true; },
6194 AllowEmptyFilterResults: function() { return true; },
6195 OnBeforeFiltering: function() { },
6196 OnAfterFiltering: function() { },
6197 OnFilteringCancelled: function() { },
6198 OnTextChanged: function() { },
6199 OnFilterRollback: function() { },
6200 CanStartFilterOnInput: function() {
6201  return this.IsEnabled() && !this.InCallback();
6202 },
6203 OnAfterFilteringOnClient: function (filter, satisfyItemIndices) {
6204  this.GetListBoxControl().RewriteFilteredItemIndices(satisfyItemIndices);
6205  var firstSatisfyItemIndex = satisfyItemIndices.length > 0 ? satisfyItemIndices[0] : -1;
6206  this.OnAfterFilteringOnClientCore(filter, firstSatisfyItemIndex);
6207 },
6208 ShouldClearFilterBeforeFiltering: function(filter) { return false; },
6209 OnInput: function() {
6210  if(this.CanStartFilterOnInput()) {
6211   this.FilterStopTimer();
6212   this.FilterStartTimer();
6213  }
6214 },
6215 OnCallback: function(result) {
6216  this.OnCallbackCore(result[CONSTANTS.CALLBACK_RESULTS.FILTER_CUSTOMHIGHLIGHTING], result[CONSTANTS.CALLBACK_RESULTS.FILTER_LENGTH]);
6217  this.currentCallbackIsFiltration = false;
6218 },
6219 CancelFiltering: function() {
6220  this.FilterStopTimer();
6221 },
6222 Filtering: function(fromApi) {
6223  this.FilterStopTimer();
6224  var inputValue = this.GetInputFilterValue();
6225  this.needEmptyFilterBeforeFiltering = this.ShouldClearFilterBeforeFiltering(inputValue);
6226  var newFilter = this.needEmptyFilterBeforeFiltering ? "" : inputValue;
6227  var oldFilter = this.filter;
6228  if(!this.FilterCompare(newFilter)) {
6229   this.SetFilter(newFilter);
6230   if(!this.IsFilterMeetRequirementForMinLength() && this.TryProcessFilterLessMinLength(oldFilter))
6231    return;
6232   else {
6233    this.OnBeforeFiltering();
6234    if(this.isCallbackMode)
6235     this.FilteringOnServer();
6236    else
6237     this.FilteringOnClient();
6238    this.OnAfterFiltering();
6239   }
6240  }
6241  else
6242   this.OnFilteringCancelled(fromApi);
6243 },
6244 FilteringOnClient: function() {
6245  var listBox = this.GetListBoxControl(),
6246   count = listBox.GetItemCount(),
6247   filter = this.filter,
6248   visibleItems = [],
6249   visibleItemFound = false;
6250  this.DiscardHighlighting();
6251  while(true) {
6252   var preparedFilter = ASPx.Str.PrepareStringForFilter(filter);
6253   listBox.BeforeClientFiltering();
6254   for(var i = 0; i < count; i++) {
6255    var item = listBox.GetItem(i);
6256    var isFit = this.IsSatisfy(item.text, preparedFilter);
6257    isFit = this.RaiseItemFilteringEvent(item, filter, isFit);
6258    if(isFit) {
6259     if(!visibleItemFound) {
6260      this.OnBeforeFilteringOnClient(filter);
6261      for(var j = 0; j < i; j++)
6262       listBox.ApplyFilterToItem(j, false);
6263      var isTextClearing = filter == "" && this.filter != item.text;
6264      this.OnFirstSatisfiedItemFound(i, item.text, isTextClearing);
6265      visibleItemFound = true;
6266     }
6267     visibleItems.push(i);
6268    }
6269    if(visibleItemFound)
6270     listBox.ApplyFilterToItem(i, isFit);
6271   }
6272   if(visibleItemFound || this.AllowEmptyFilterResults() || !filter)
6273    break;
6274   filter = filter.substr(0, filter.length - 1);
6275  }
6276  if(!visibleItemFound) {
6277   this.OnBeforeFilteringOnClient(filter); 
6278   if(this.AllowEmptyFilterResults()) {
6279    for(var i = 0; i < count; i++)
6280     listBox.ApplyFilterToItem(i, false);
6281   }
6282  }
6283  this.OnAfterFilteringOnClient(filter, visibleItems);
6284  this.SetHighlighting(filter);
6285  this.OnEndFiltering(visibleItemFound || this.AllowEmptyFilterResults());
6286 },
6287 FilteringOnServer: function() {
6288  if(!this.InCallback()) {
6289   var listBox = this.GetListBoxControl();
6290   listBox.ClearItems(); 
6291   listBox.serverIndexOfFirstItem = 0;
6292   listBox.SetScrollSpacerVisibility(true, false);
6293   listBox.SetScrollSpacerVisibility(false, false);
6294  }
6295  this.SendFilteringCallback();
6296 },
6297 SendFilteringCallback: function(owner) {
6298  this.currentCallbackIsFiltration = true;
6299  this.SendCallbackCore();
6300 },
6301 OnEndFiltering: function(visibleCollectionChanged) {
6302  if(visibleCollectionChanged)
6303   this.NotifyCollectionChanged();
6304  this.ApplyHighlighting();
6305 },
6306 IsFilterTimerActive: function() {
6307  return this.filterTimeoutId !== -1;
6308 },
6309 FilterStopTimer: function() {
6310  this.filterTimeoutId = ASPx.Timer.ClearTimer(this.filterTimeoutId);
6311 },
6312 FilterStartTimer: function() {
6313  this.filterTimeoutId = ASPx.Timer.SetControlBoundTimeout(function() {
6314   this.filterTimeoutId = -1;
6315   this.Filtering();
6316  }.bind(this), this.GetListBoxControl(), this.filterDelay);
6317 },
6318 IsFilterMeetRequirementForMinLength: function(filter) {
6319  if(typeof (filter) !== "string")
6320   filter = this.GetInputFilterValue();
6321  return typeof (filter) === "string" ? filter.length >= this.filterMinLength : true;
6322 },
6323 GetCallbackArguments: function() {
6324  if(this.filter) {
6325   var callbackPrefix = this.SupportsFilterCorrection() ? CONSTANTS.CALLBACK_PREFIXES.FILTERING_CORRECT : CONSTANTS.CALLBACK_PREFIXES.FILTERING;
6326   return ASPx.FilteringUtils.FormatCallbackArg(callbackPrefix, this.filter);
6327  }
6328  return "";
6329 },
6330 OnAfterDoEndCallback: function() {
6331  if(this.refiltrationRequired) {
6332   this.refiltrationRequired = false;
6333   window.setTimeout(this.Filtering.bind(this), 0);
6334  }
6335 },
6336 OnBeforeDoEndCallback: function() {
6337  if(this.refiltrationRequired)
6338   this.PreventEndCallbackRising();
6339 },
6340 OnSelectedIndexChanged: function() {
6341  this.ClearFilterApplied();
6342 },
6343 SetHighlighting: function(filter, callbackHighlighting) {
6344  callbackHighlighting = this.ProcessCallbackHighlighting(callbackHighlighting);
6345  var customHighlighting = this.RaiseCustomHighlightingEvent(filter, callbackHighlighting);
6346  this.isCustomHighlighting = customHighlighting !== null && customHighlighting !== undefined;
6347  this.highlighting = this.isCustomHighlighting ? customHighlighting : filter;
6348 },
6349 ProcessCallbackHighlighting: function(obj) {
6350  if(obj === undefined || obj === null)
6351   return undefined;
6352  var val = obj.val;
6353  var regEx = !!obj.regEx;
6354  if(regEx) {
6355   if(typeof (val) === "string")
6356    val = new RegExp(val, "gi");
6357   if(!Array.isArray(val) && typeof (val) === "object") {
6358    for(var col in val) {
6359     if(!val.hasOwnProperty(col)) continue;
6360     if(typeof (val[col]) === "string")
6361      val[col] = new RegExp(val[col], "gi");
6362    }
6363   }
6364  }
6365  return val;
6366 },
6367 IsEmptyFilter: function() {
6368  return !this.filterInitialized || this.filter === "";
6369 },
6370 ShouldDiscardCallbackResult: function() {
6371  var discardCallbackResult = !this.needEmptyFilterBeforeFiltering && !this.IsFilterEqualInputValue() && this.currentCallbackIsFiltration;
6372  if(discardCallbackResult)
6373   this.refiltrationRequired = true;
6374  return discardCallbackResult;
6375 },
6376 IsFilterEqualInputValue: function() {
6377  var currentFilter = this.GetInputFilterValue();
6378  return this.FilterCompareLower(ASPx.Str.PrepareStringForFilter(currentFilter));
6379 },
6380 FilterCompare: function(value) {
6381  return this.filterInitialized && this.filter === value;
6382 },
6383 FilterCompareLower: function(value) {
6384  if(!this.filterInitialized)
6385   return false;
6386  return ASPx.Str.PrepareStringForFilter(this.filter) == value;
6387 },
6388 DiscardHighlighting: function() {
6389  this.GetListBoxControl().highlighting.Remove(this.highlighting, this.isCustomHighlighting);
6390 },
6391 ApplyHighlighting: function() {
6392  this.GetListBoxControl().highlighting.Apply(this.highlighting, this.isCustomHighlighting);
6393 },
6394 RefreshHighlighting: function() {
6395  this.GetListBoxControl().highlighting.Refresh(this.highlighting, this.isCustomHighlighting);
6396 },
6397 MakeAllItemsVisible: function() {
6398  this.GetListBoxControl().MakeAllItemsVisible();
6399 },
6400 SetFilter: function(newFilter) {
6401  this.filter = newFilter;
6402  this.highlighting = "";
6403  this.isCustomHighlighting = undefined;
6404  this.filterInitialized = true;
6405 },
6406 ClearFilter: function() {
6407  this.filter = "";
6408  this.highlighting = "";
6409  this.isCustomHighlighting = undefined;
6410  this.filterInitialized = false;
6411 },
6412 ClearFilterApplied: function() {
6413  this.filterInitialized = false;
6414 },
6415 FilteringBackspace: function() {
6416  throw "Not Implemented";
6417 },
6418});
6419var ListBoxFilterStrategy = ASPx.CreateClass(ListEditIncrementalFilterStrategyBase, {
6420 constructor: function(listBox) {
6421  this.constructor.prototype.constructor.call(this, listBox.filteringDelay, listBox.filterMinLength, listBox.isCallbackMode);
6422  this.listBox = listBox;
6423 },
6424 SupportsFilterCorrection: function() {
6425  return false;
6426 },
6427 IsEnabled: function() {
6428  return this.listBox.GetEnabled();
6429 },
6430 GetInputFilterValue: function() {
6431  return this.listBox.filteringTextBox.GetInputElement().value;
6432 },
6433 NotifyCollectionChanged: function() {
6434  this.listBox.CollectionChanged(true);
6435 },
6436 TryProcessFilterLessMinLength: function(oldFilter) {
6437  this.SetFilter("");
6438  return !oldFilter;
6439 },
6440 IsSatisfy: function(text, filter) {
6441  return ASPx.Str.PrepareStringForFilter(text).indexOf(filter) !== -1;
6442 },
6443 GetListBoxControl: function() {
6444  return this.listBox;
6445 },
6446 OnAfterFilteringOnClientCore: function (filter, firstSatisfyItemIndex) {
6447  if(firstSatisfyItemIndex !== -1)
6448   this.listBox.CorrectCellWidthsOnFirstRowItemReplacement(0, firstSatisfyItemIndex);
6449 },
6450 OnEndFiltering: function(visibleCollectionChanged) {
6451  ListEditIncrementalFilterStrategyBase.prototype.OnEndFiltering.call(this, visibleCollectionChanged);
6452  if(this.listBox.IsMultiColumn())
6453   this.listBox.CorrectWidth();
6454  this.listBox.updateSelectAllElementsState();
6455 },
6456 SendCallbackCore: function() {
6457  this.listBox.SendCallback();
6458 },
6459 InCallback: function() {
6460  return this.listBox.InCallback();
6461 },
6462 PreventEndCallbackRising: function() {
6463  this.listBox.preventEndCallbackRising = true;
6464 },
6465 GetSelectedIndex: function() {
6466  return this.listBox.GetSelectedIndex();
6467 },
6468 OnCallbackCore: function(highlighting, newFilterLength) {
6469  if(this.currentCallbackIsFiltration)
6470   this.SetHighlighting(this.filter, highlighting);
6471  if(this.filter)
6472   this.OnEndFiltering();
6473 },
6474 FilteringBackspace: function() {
6475  var textBox = this.listBox.filteringTextBox;
6476  if(textBox)
6477   ASPx.StartWithFilteringUtils.RollbackOneSuggestedChar(textBox.GetInputElement());
6478  this.FilterStartTimer();
6479 },
6480 RaiseItemFilteringEvent: function(item, filter, isFit) {
6481  return this.listBox.RaiseItemFiltering(item, filter, isFit);
6482 },
6483 RaiseCustomHighlightingEvent: function(filter, callbackHighlighting) {
6484  return this.listBox.RaiseCustomHighlighting(filter, callbackHighlighting);
6485 }
6486});
6487ASPx.ListBoxItemsDefaultManager = ListBoxItemsDefaultManager;
6488ASPx.ListBoxItemsVirtualManager = ListBoxItemsVirtualManager;
6489ASPx.VirtualRenderListBoxStateControllerManager = VirtualRenderListBoxStateControllerManager;
6490ASPx.DefaultListBoxStateControllerManager = DefaultListBoxStateControllerManager;
6491ASPx.ListEditIncrementalFilterStrategyBase = ListEditIncrementalFilterStrategyBase;
6492ASPx.ListBoxFilterStrategy = ListBoxFilterStrategy;
6493ASPx.ListEditFilterStrategyBase = ListEditFilterStrategyBase;
6494var ASPxClientListEditItemFilteringEventArgs = ASPx.CreateClass(ASPxClientEventArgs, {
6495 constructor: function(item, filter, isFit) {
6496  this.constructor.prototype.constructor.call(this);
6497  this.item = item;
6498  this.isFit = isFit;
6499  this.filter = filter;
6500 }
6501});
6502var ASPxClientListEditCustomHighlightingEventArgs = ASPx.CreateClass(ASPxClientEventArgs, {
6503 constructor: function(filter) {
6504  this.constructor.prototype.constructor.call(this);
6505  this.highlighting = null;
6506  this.filter = filter;
6507 }
6508});
6509ASPx.ListBoxScrollCallbackHelper = ListBoxScrollCallbackHelper;
6510window.ASPxClientListEdit = ASPxClientListEdit;
6511window.ASPxClientListEdit.CONSTANTS = CONSTANTS;
6512window.ASPxClientListEditItem = ASPxClientListEditItem;
6513window.ASPxClientListBoxItem = ASPxClientListBoxItem;
6514window.ASPxClientListBoxBase = ASPxClientListBoxBase;
6515window.ASPxClientListBox = ASPxClientListBox;
6516window.ASPxClientNativeListBox = ASPxClientNativeListBox;
6517window.ASPxClientCheckListBase = ASPxClientCheckListBase;
6518window.ASPxClientRadioButtonList = ASPxClientRadioButtonList;
6519window.ASPxClientCheckBoxList = ASPxClientCheckBoxList;
6520window.ASPxClientListEditItemSelectedChangedEventArgs = ASPxClientListEditItemSelectedChangedEventArgs;
6521window.ASPxClientListEditItemFilteringEventArgs = ASPxClientListEditItemFilteringEventArgs;
6522window.ASPxClientListEditCustomHighlightingEventArgs = ASPxClientListEditCustomHighlightingEventArgs;
6523})();
6524

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.