1var __aspxLBSerializingSeparator = "|"; 2var __aspxLBSerializingSeparatorLength = __aspxLBSerializingSeparator.length; 3var __aspxLoadRangeItemsCallbackPrefix = "LBCRI"; 4var __aspxLBIPostfixes = ['C', 'I', 'T']; 5var __aspxLBIIdSuffix = "LBI"; 6var __aspxLBSIIdSuffix = __aspxLBIIdSuffix + "-1"; 7var __aspxLBTSIdSuffix = "_TS"; 8var __aspxLBBSIdSuffix = "_BS"; 9var __aspxLBHeaderDivIdSuffix = "_H"; 10var __aspxLTableIdSuffix = "_LBT"; 11var __aspxLEVISuffix = "_VI"; 12var __aspxLBDSuffix = "_D"; 13var __aspxEmptyItemsRange = "0:-1"; 14var __aspxNbsp = " "; 15var __aspxNbspChar = String.fromCharCode(160); 16var ListBoxSelectionMode = { Single : 0, Multiple : 1, CheckColumn : 2 }; 17ASPxClientListEdit = _aspxCreateClass(ASPxClientEdit, { 18 constructor: function(name) { 19 this.constructor.prototype.constructor.call(this, name); 20 this.SelectedIndexChanged = new ASPxClientEvent(); 21 this.savedSelectedIndex = -1; 22 }, 23 FindInputElement: function() { 24 return this.FindStateInputElement(); 25 }, 26 FindStateInputElement: function(){ 27 return document.getElementById(this.name + __aspxLEVISuffix); 28 }, 29 GetItem: function(index) { 30 throw "Not implemented"; 31 }, 32 GetItemValue: function(index) { 33 throw "Not implemented"; 34 }, 35 GetValue: function(){ 36 return this.GetItemValue(this.GetSelectedIndex()); 37 }, 38 GetSelectedIndexInternal: function(){ 39 return this.savedSelectedIndex; 40 }, 41 SetSelectedIndexInternal: function(index){ 42 this.savedSelectedIndex = index; 43 }, 44 FindItemIndexByValue: function(value){ 45 for(var i = 0; i < this.GetItemCount(); i++){ 46 if(this.GetItemValue(i) == value) 47 return i; 48 } 49 return -1; 50 }, 51 RaiseItemClick: function() { 52 var processOnServer = this.autoPostBack; 53 if(!this.ItemClick.IsEmpty()){ 54 var args = new ASPxClientProcessingModeEventArgs(processOnServer); 55 this.ItemClick.FireEvent(this, args); 56 processOnServer = args.processOnServer; 57 } 58 return processOnServer; 59 }, 60 RaiseItemDoubleClick: function() { 61 var processOnServer = this.autoPostBack; 62 if(!this.ItemDoubleClick.IsEmpty()){ 63 var args = new ASPxClientProcessingModeEventArgs(processOnServer); 64 this.ItemDoubleClick.FireEvent(this, args); 65 processOnServer = args.processOnServer; 66 } 67 return processOnServer; 68 }, 69 RaiseValueChangedEvent: function() { 70 if(!this.isInitialized) return false; 71 var processOnServer = ASPxClientEdit.prototype.RaiseValueChangedEvent.call(this); 72 processOnServer = this.RaiseValueChangedAdditionalEvents(processOnServer); 73 return processOnServer; 74 }, 75 RaiseValueChangedAdditionalEvents: function(processOnServer){ 76 return this.RaiseSelectedIndexChanged(processOnServer); 77 }, 78 RaiseSelectedIndexChanged: function(processOnServer) { 79 if(!this.SelectedIndexChanged.IsEmpty()){ 80 var args = new ASPxClientProcessingModeEventArgs(processOnServer); 81 this.SelectedIndexChanged.FireEvent(this, args); 82 processOnServer = args.processOnServer; 83 } 84 return processOnServer; 85 }, 86 UpdateHiddenInputs: function(){ 87 var element = this.FindStateInputElement(); 88 if(_aspxIsExistsElement(element)) { 89 var value = this.GetValue(); 90 if (value == null) 91 value = ""; 92 element.value = value; 93 } 94 }, 95 GetSelectedItem: function(){ 96 var index = this.GetSelectedIndexInternal(); 97 return this.GetItem(index); 98 }, 99 GetSelectedIndex: function(){ 100 return this.GetSelectedIndexInternal(); 101 }, 102 SetSelectedItem: function(item){ 103 var index = (item != null) ? item.index : -1; 104 this.SetSelectedIndex(index); 105 }, 106 SetSelectedIndex: function(index){ 107 this.SelectIndexSilent(index); 108 }, 109 SelectIndexSilent: function(index){ 110 throw "Not implemented"; 111 } 112}); 113ASPxClientListEditItem = _aspxCreateClass(null, { 114 constructor: function(listEditBase, index, text, value, imageUrl){ 115 this.listEditBase = listEditBase; 116 this.index = index; 117 this.imageUrl = imageUrl; 118 this.text = text; 119 this.value = value; 120 } 121}); 122ASPxClientListBoxItem = _aspxCreateClass(ASPxClientListEditItem, { 123 constructor: function(listEditBase, index, texts, value, imageUrl, selected){ 124 this.constructor.prototype.constructor.call(this, listEditBase, index, null, value, imageUrl); 125 this.selected = selected ? selected : false; 126 this.texts = texts; 127 this.text = listEditBase.FormatText(texts); 128 }, 129 GetColumnText: function(columnIndexOrFieldName){ 130 var columnIndex = -1; 131 if(typeof(columnIndexOrFieldName) == "string") 132 columnIndex = _aspxArrayIndexOf(this.listEditBase.columnFieldNames, columnIndexOrFieldName); 133 else if(typeof(columnIndexOrFieldName) == "number") 134 columnIndex = columnIndexOrFieldName; 135 return this.GetColumnTextByIndex(columnIndex); 136 }, 137 GetColumnTextByIndex: function(columnIndex){ 138 if(0 <= columnIndex && columnIndex < this.texts.length) 139 return this.texts[columnIndex]; 140 else 141 return null; 142 } 143}); 144_aspxListBoxScrollCallbackHelperBase = _aspxCreateClass(null, { 145 constructor: function(listBoxControl) { 146 this.listBoxControl = listBoxControl; 147 this.itemsRange = ""; 148 this.defaultItemsRange = "0:" + (this.listBoxControl.callbackPageSize - 1); 149 }, 150 OnScroll: function(){ }, 151 Reset: function(){ }, 152 IsScrolledToTopSpacer: function(){ return false; }, 153 IsScrolledToBottomSpacer: function(){ return false; }, 154 GetIsNeedToHideTopSpacer: function(){ return false; }, 155 GetIsNeedCallback: function(){ return false; }, 156 GetItemsRangeForLoad: function(){ return this.defaultItemsRange; }, 157 SetItemsRangeForLoad: function(){} 158}); 159_aspxListBoxScrollCallbackHelper = _aspxCreateClass(_aspxListBoxScrollCallbackHelperBase, { 160 constructor: function(listBoxControl) { 161 this.constructor.prototype.constructor.call(this, listBoxControl); 162 this.isScrolledToTopSpacer = false; 163 this.isScrolledToBottomSpacer = false; 164 }, 165 OnScroll: function(){ 166 this.DetectScrollDirection(); 167 this.ResetItemsRange(); 168 if(this.GetIsAnySpacerVisible()) 169 this.RecalcItemsRangeForLoad(); 170 }, 171 DetectScrollDirection: function(){ 172 var listBoxControl = this.listBoxControl; 173 var divElement = listBoxControl.GetScrollDivElement(); 174 var listTable = listBoxControl.GetListTable(); 175 var scrollTop = divElement.scrollTop; 176 var scrollBottom = divElement.scrollTop + divElement.clientHeight; 177 var isTopSpacerVisible = listBoxControl.GetScrollSpacerVisibility(true); 178 var isBottomSpacerVisible = listBoxControl.GetScrollSpacerVisibility(false); 179 var topSpacerHeight = listBoxControl.GetScrollSpacerVisibility(true) ? parseInt(listBoxControl.GetScrollSpacerElement(true).clientHeight) : 0; 180 this.isScrolledToTopSpacer = (scrollTop < topSpacerHeight) && isTopSpacerVisible; 181 this.isScrolledToBottomSpacer = (scrollBottom >= topSpacerHeight + listTable.clientHeight) && isBottomSpacerVisible; 182 }, 183 Reset: function(){ 184 this.ResetItemsRange(); 185 this.isScrolledToTopSpacer = false; 186 this.isScrolledToBottomSpacer = false; 187 }, 188 ResetItemsRange: function(){ 189 this.itemsRange = ""; 190 }, 191 RecalcItemsRangeForLoad: function(){ 192 if(this.listBoxControl.isCallbackMode) { 193 if(this.isScrolledToTopSpacer || this.isScrolledToBottomSpacer) 194 this.SetItemsRangeForLoad(this.isScrolledToTopSpacer); 195 } 196 }, 197 IsScrolledToTopSpacer: function(){ 198 return this.isScrolledToTopSpacer; 199 }, 200 IsScrolledToBottomSpacer: function(){ 201 return this.isScrolledToBottomSpacer; 202 }, 203 GetIsAnySpacerVisible: function(){ 204 return this.isScrolledToTopSpacer || this.isScrolledToBottomSpacer; 205 }, 206 GetIsNeedCallback: function(){ 207 return !this.GetIsItemsRangeEmpty(); 208 }, 209 GetIsNeedToHideTopSpacer: function(){ 210 return this.isScrolledToTopSpacer && this.GetIsItemsRangeEmpty(); 211 }, 212 GetItemsRangeForLoad: function(){ 213 return (!this.GetIsItemsRangeEmpty() ? this.itemsRange : this.defaultItemsRange); 214 }, 215 SetItemsRangeForLoad: function(isForTop){ 216 var listbox = this.listBoxControl; 217 var beginIndex = isForTop ? 218 listbox.serverIndexOfFirstItem - listbox.callbackPageSize : 219 listbox.serverIndexOfFirstItem + listbox.GetItemCount(); 220 beginIndex = beginIndex < 0 ? 0 : beginIndex; 221 var endIndex = isForTop ? 222 listbox.serverIndexOfFirstItem - 1 : 223 beginIndex + listbox.callbackPageSize - 1; 224 this.itemsRange = beginIndex + ":" + endIndex; 225 this.isScrolledToTopSpacer = isForTop; 226 this.isScrolledToBottomSpacer = !isForTop; 227 }, 228 GetIsItemsRangeEmpty: function(){ 229 return (this.itemsRange == "" || this.itemsRange == __aspxEmptyItemsRange); 230 } 231}); 232ASPxClientListBoxBase = _aspxCreateClass(ASPxClientListEdit, { 233 constructor: function(name) { 234 this.constructor.prototype.constructor.call(this, name); 235 this.APILockCount = 0; 236 this.enableSyncOnPerfCallback = false; 237 this.scrollOnKBNavigationLockCount = 0; 238 this.isComboBoxList = false; 239 this.isSyncEnabled = true; 240 this.ownerName = ""; 241 this.selectionEventsLockCount = 0; 242 this.syncLockCount = 0; 243 this.encodeHtml = true; 244 this.serializingHelper = null; 245 this.deletedItems = []; 246 this.insertedItems = []; 247 this.itemsValue = []; 248 this.ItemDoubleClick = new ASPxClientEvent();
249 this.ItemClick = new ASPxClientEvent(); 250 }, 251 LockScrollOnKBNavigation: function(){ 252 this.scrollOnKBNavigationLockCount++; 253 }, 254 UnlockScrollOnKBNavigation: function(){ 255 this.scrollOnKBNavigationLockCount--; 256 }, 257 IsScrollOnKBNavigationLocked: function() { 258 return this.scrollOnKBNavigationLockCount > 0; 259 }, 260 LockSelectionEvents: function(){ 261 this.selectionEventsLockCount++; 262 }, 263 UnlockSelectionEvents: function(){ 264 this.selectionEventsLockCount--; 265 }, 266 IsSelectionEventsLocked: function(){ 267 return this.selectionEventsLockCount > 0; 268 }, 269 LockSynchronizationOnInternalCallback: function(){ 270 if(!this.enableSyncOnPerfCallback) 271 this.LockSynchronization(); 272 }, 273 UnlockSynchronizationOnInternalCallback: function (){ 274 if(!this.enableSyncOnPerfCallback) 275 this.UnlockSynchronization(); 276 }, 277 GetItemCount: function(){ 278 return 0; 279 }, 280 GetItemValue: function(index){ 281 if(0 <= index && index < this.GetItemCount()) 282 return this.PrepareItemValue(this.itemsValue[index]); 283 return null; 284 }, 285 GetItemTexts: function(item) { 286 return item.text; 287 }, 288 PrepareItemValue: function(value) { 289 return (typeof(value) == "string" && value == "" && this.convertEmptyStringToNull) ? null : value; 290 }, 291 LoadItemsFromCallback: function(isToTop, itemStrings){ 292 }, 293 SetValue: function(value){ 294 var index = this.FindItemIndexByValue(value); 295 this.SelectIndexSilentAndMakeVisible(index); 296 }, 297 FindItemIndexByText: function(text){ 298 for(var i = 0; i < this.GetItemCount(); i ++){ 299 if(this.GetItem(i).text == text) 300 return i; 301 } 302 return -1; 303 }, 304 SelectIndex: function (index){ 305 if(this.SelectIndexSilentAndMakeVisible(index, false)){ 306 this.RaisePersonalStandardValidation(); 307 this.OnValueChanged(); 308 } 309 }, 310 SelectIndexSilentAndMakeVisible: function(index){ 311 var selectionChanged = this.SelectIndexSilent(index); 312 if(!this.IsScrollOnKBNavigationLocked()) 313 this.MakeItemVisible(index); 314 return selectionChanged; 315 }, 316 MakeItemVisible: function(index){ 317 }, 318 InitOnContainerMadeVisible: function(){ 319 }, 320 AddItem: function(texts, value, imageUrl){ 321 var index = this.GetItemCount(); 322 this.InsertItemInternal(index, texts, value, imageUrl); 323 return index; 324 }, 325 InsertItem: function(index, texts, value, imageUrl){ 326 this.InsertItemInternal(index, texts, value, imageUrl); 327 }, 328 InsertItemInternal: function(index, text, value, imageUrl){ 329 }, 330 BeginUpdate: function(){ 331 this.APILockCount ++; 332 }, 333 EndUpdate: function(){ 334 this.APILockCount --; 335 this.Synchronize(); 336 }, 337 ClearItems: function(){ 338 this.BeginUpdate(); 339 this.UpdateArraysItemsCleared(); 340 this.ClearItemsCore(); 341 this.EndUpdate(); 342 }, 343 ClearItemsCore: function(){ 344 }, 345 ClearItemsForPerformCallback: function(){ 346 this.itemsValue = []; 347 this.ClearItemsCore(); 348 }, 349 RemoveItem: function(index){ 350 }, 351 FindItemByText: function(text){ 352 var index = this.FindItemIndexByText(text); 353 return this.GetItem(index); 354 }, 355 FindItemByValue: function(value){ 356 var index = this.FindItemIndexByValue(value); 357 return this.GetItem(index); 358 }, 359 PerformCallback: function(arg) { 360 }, 361 GetCallbackArguments: function(){ 362 var args = this.GetCustomCallbackArg(); 363 args += this.GetLoadItemsRangeCallbackArg(); 364 return args; 365 }, 366 GetLoadItemsRangeCallbackArg: function(){ 367 return this.FormatCallbackArg(__aspxLoadRangeItemsCallbackPrefix, this.GetItemsRangeForLoad()); 368 }, 369 FormatCallbackArg: function(prefix, arg) { 370 arg = arg.toString(); 371 return (_aspxIsExists(arg) ? prefix + "|" + arg.length + ';' + arg + ';' : ""); 372 }, 373 GetItemsRangeForLoad: function(){ 374 return __aspxEmptyItemsRange; 375 }, 376 GetCallbackOwnerControl: function(){ 377 if(this.ownerName && !this.ownerControl) 378 this.ownerControl = aspxGetControlCollection().Get(this.ownerName); 379 return this.ownerControl; 380 }, 381 GetCustomCallbackArg: function(){ 382 return this.GetSyncHiddenInput("CustomCallback").value; 383 }, 384 SetCustomCallbackArg: function(arg){ 385 this.GetSyncHiddenInput("CustomCallback").value = arg; 386 }, 387 FormatAndSetCustomCallbackArg: function(arg){ 388 arg = _aspxIsExists(arg) ? arg.toString() : "" 389 var formatArg = this.FormatCallbackArg("LECC", arg); 390 this.SetCustomCallbackArg(formatArg); 391 }, 392 SendCallback: function(){ 393 }, 394 LockSynchronization: function(){ 395 this.syncLockCount++; 396 }, 397 UnlockSynchronization: function(){ 398 this.syncLockCount--; 399 }, 400 IsSyncLocked: function(){ 401 return this.syncLockCount > 0; 402 }, 403 IsSyncEnabled: function(){ 404 return this.isSyncEnabled && !this.IsSyncLocked(); 405 }, 406 RegisterInsertedItem: function(index, text, value, imageUrl){ 407 if(this.IsSyncEnabled()){ 408 this.RefreshSynchroArraysIndex(index, true); 409 var item = this.CreateItem(index, text, value, imageUrl); 410 this.insertedItems.push(item); 411 this.Synchronize(); 412 } 413 }, 414 CreateItem: function(index, text, value, imageUrl){ 415 return new ASPxClientListEditItem(this, index, text, value, imageUrl); 416 }, 417 UpdateSyncArraysItemDeleted: function(item, isValueRemovingRequired){ 418 if(isValueRemovingRequired) 419 _aspxArrayRemoveAt(this.itemsValue, item.index); 420 if(this.IsSyncEnabled()){ 421 var index = this.FindItemInArray(this.insertedItems, item); 422 if(index == -1){ 423 this.RefreshSynchroArraysIndex(item.index, false); 424 this.deletedItems.push(item); 425 } else { 426 this.RefreshSynchroArraysIndex(item.index, false); 427 _aspxArrayRemoveAt(this.insertedItems, index); 428 } 429 this.Synchronize(); 430 } 431 }, 432 UpdateArraysItemsCleared: function(){ 433 if(this.IsSyncEnabled()){ 434 for(var i = this.GetItemCount() - 1; i >= 0; i --) 435 this.UpdateSyncArraysItemDeleted(this.GetItem(i), false); 436 } 437 this.itemsValue = []; 438 }, 439 RefreshSynchroArraysIndex: function(startIndex, isIncrease){ 440 this.RefreshSynchroArrayIndexIndex(this.deletedItems, startIndex, isIncrease); 441 this.RefreshSynchroArrayIndexIndex(this.insertedItems, startIndex, isIncrease); 442 }, 443 RefreshSynchroArrayIndexIndex: function(array, startIndex, isIncrease){ 444 var delta = isIncrease ? 1 : -1; 445 for(var i = 0; i < array.length; i ++){ 446 if(array[i].index >= startIndex) 447 array[i].index += delta; 448 } 449 }, 450 FindItemInArray: function(array, item){ 451 for(var i = array.length - 1; i >= 0; i--){ 452 var currentItem = array[i]; 453 if ((!this.encodeHtml || currentItem.text == item.text) && currentItem.value == item.value && 454 currentItem.imageUrl == item.imageUrl) 455 break; 456 } 457 return i; 458 }, 459 GetSyncHiddenInput: function(syncType){ 460 return _aspxGetElementById(this.name + syncType); 461 }, 462 Synchronize: function(){ 463 if(this.APILockCount == 0){ 464 if(this.IsSyncEnabled()){ 465 this.SynchronizeItems(this.deletedItems, "DeletedItems"); 466 this.SynchronizeItems(this.insertedItems, "InsertedItems"); 467 } 468 this.CorrectSizeByTimer(); 469 } 470 }, 471 CorrectSizeByTimer: function(){ 472 }, 473 SynchronizeItems: function(items, syncType){ 474 var inputElement = this.GetSyncHiddenInput(syncType); 475 if(!_aspxIsExistsElement(inputElement)) 476 return; 477 inputElement.value = _aspxEncodeHtml(this.SerializeItems(items)); 478 }, 479 GetSerializingHelper: function(){ 480 if(this.serializingHelper == null)
481 this.serializingHelper = this.CreateSerializingHelper(); 482 return this.serializingHelper; 483 }, 484 CreateSerializingHelper: function(){ 485 return new _aspxListBoxBaseItemsSerializingHelper(this); 486 }, 487 SerializeItems: function(items){ 488 var serialiser = this.GetSerializingHelper(); 489 return serialiser.SerializeItems(items); 490 }, 491 DeserializeItems: function(serializedItems){ 492 var serialiser = this.GetSerializingHelper(); 493 return serialiser.DeserializeItems(serializedItems); 494 } 495}); 496_aspxListBoxBaseItemsSerializingHelper = _aspxCreateClass(null, { 497 constructor: function(listBoxControl) { 498 this.listBoxControl = listBoxControl; 499 this.startPos = 0; 500 }, 501 SerializeItems: function(items){ 502 var sb = [ ]; 503 for(var i = 0; i < items.length; i++) 504 this.SerializeItem(sb, items[i]); 505 return sb.join(""); 506 }, 507 SerializeItem: function(sb, item) { 508 if(!item) 509 return; 510 this.SerializeAtomValue(sb, item.index); 511 this.SerializeAtomValue(sb, item.value); 512 this.SerializeAtomValue(sb, item.imageUrl); 513 var texts = this.listBoxControl.GetItemTexts(item); 514 if(typeof(texts) == "string") 515 this.SerializeAtomValue(sb, texts); 516 else { 517 for(var i = 0; i < texts.length; i++) 518 this.SerializeAtomValue(sb, texts[i]); 519 } 520 }, 521 SerializeAtomValue: function(sb, value) { 522 var valueStr = _aspxIsExists(value) ? value.toString() : ""; 523 sb.push(valueStr.length); 524 sb.push('|'); 525 sb.push(valueStr); 526 }, 527 DeserializeItems: function(serializedItems){ 528 var deserializedItems = []; 529 var item; 530 this.startPos = 0; 531 while(this.startPos < serializedItems.length){ 532 var index = this.ParseItemIndex(serializedItems); 533 var value = this.ParseItemValue(serializedItems); 534 var imageUrl = this.ParseString(serializedItems); 535 if(imageUrl == "") 536 imageUrl = this.listBoxControl.defaultImageUrl; 537 var texts = this.ParseTexts(serializedItems); 538 item = this.listBoxControl.CreateItem(index, texts, value, imageUrl); 539 deserializedItems.push(item); 540 } 541 return deserializedItems; 542 }, 543 ParseItemIndex: function(serializedItem){ 544 return parseInt(this.ParseString(serializedItem)); 545 }, 546 ParseItemValue: function(serializedItem){ 547 return this.ParseString(serializedItem); 548 }, 549 ParseString: function(str){ 550 var indexOfSeparator = str.indexOf(__aspxLBSerializingSeparator, this.startPos); 551 var strLength = parseInt(str.substring(this.startPos, indexOfSeparator)); 552 var strStartPos = indexOfSeparator + __aspxLBSerializingSeparatorLength; 553 this.startPos = strStartPos + strLength; 554 return str.substring(strStartPos, strStartPos + strLength); 555 }, 556 ParseTexts: function(serializedItems){ 557 return this.ParseString(serializedItems); 558 }, 559 DeserializeValues: function(serializedValues){ 560 var deserializedValues = []; 561 this.startPos = 0; 562 while(this.startPos < serializedValues.length){ 563 deserializedValues.push(this.ParseItemValue(serializedValues)); 564 } 565 return deserializedValues; 566 } 567}); 568_aspxListBoxItemsSerializingHelper = _aspxCreateClass(_aspxListBoxBaseItemsSerializingHelper, { 569 constructor: function(listBoxControl) { 570 this.constructor.prototype.constructor.call(this, listBoxControl); 571 }, 572 ParseTexts: function(serializedItems){ 573 var textColumnCount = this.listBoxControl.GetItemTextCellCount(); 574 return (textColumnCount > 1) ? this.DeserializeItemTexts(serializedItems, textColumnCount) 575 : this.constructor.prototype.ParseTexts.call(this, serializedItems); 576 }, 577 DeserializeItemTexts: function(serializedItem, textColumnCount){ 578 var text = ""; 579 var texts = []; 580 for(var i = 0; i < textColumnCount; i++) 581 texts.push(this.ParseString(serializedItem)); 582 return texts; 583 } 584}); 585_aspxListBoxSingleSelectionHelper = _aspxCreateClass(null, { 586 constructor: function(listBoxControl) { 587 this.listBoxControl = listBoxControl; 588 this.savedSelectedIndex = -1; 589 this.updateHiddenInputsLockCount = 0; 590 this.cachedSelectionChangedArgs = []; 591 }, 592 ClearSelection: function(){ 593 this.SetSelectedIndexCore(-1); 594 this.OnSelectionCleared(); 595 }, 596 OnSelectionCleared: function(){ 597 this.cachedSelectionChangedArgs = []; 598 }, 599 GetSelectedIndexInternal: function(){ 600 return this.savedSelectedIndex; 601 }, 602 SetSelectedIndexInternal: function(index){ 603 this.savedSelectedIndex = index; 604 }, 605 SetSelectedIndexCore: function(index){ 606 if(index != this.savedSelectedIndex && -1 <= index && index < this.GetItemCount()){ 607 this.BeginSelectionUpdate(); 608 this.SetSelectedIndexInternal(index); 609 this.EndSelectionUpdate(); 610 return true; 611 } 612 return false; 613 }, 614 GetSelectedIndex: function(){ 615 return this.GetSelectedIndexInternal(); 616 }, 617 SetSelectedIndex: function(index){ 618 this.ChangeSelectedItem(index); 619 this.SetSelectedIndexCore(index); 620 this.OnItemSelectionChanged(index, true); 621 }, 622 GetSelectedIndices: function(){ 623 var selectedIndex = this.GetSelectedIndexInternal(); 624 return selectedIndex != -1 ? [selectedIndex] : []; 625 }, 626 GetSelectedValues: function(){ 627 var selectedValue = this.listBoxControl.GetValue(); 628 return selectedValue != null ? [selectedValue] : []; 629 }, 630 GetSelectedItems: function(){ 631 var selectedItem = this.listBoxControl.GetSelectedItem(); 632 return selectedItem != null? [selectedItem] : []; 633 }, 634 SelectIndices: function(indices){}, 635 SelectItems: function(items){}, 636 SelectValues: function(values){}, 637 UnselectIndices: function(selected){}, 638 UnselectItems: function(items){}, 639 UnselectValues: function(values){}, 640 GetIsItemSelected: function(index){ return index == this.GetSelectedIndexInternal(); }, 641 ResetSelectionCollectionsCache: function(){ }, 642 OnItemClick: function(index, evt){ 643 var selected = true; 644 this.BeginSelectionUpdate(); 645 this.ChangeSelectedItem(index); 646 var selectedIndexChanged = this.SetSelectedIndexCore(index); 647 this.EndSelectionUpdate(); 648 if(selectedIndexChanged) 649 this.OnItemSelectionChanged(index, selected); 650 }, 651 ChangeSelectedItem: function(newSelectedIndex){ 652 var selected = true; 653 var oldSelectedIndex = this.GetSelectedIndexInternal(); 654 this.BeginSelectionUpdate(); 655 this.SetItemSelectionState(oldSelectedIndex, !selected); 656 this.SetItemSelectionState(newSelectedIndex, selected); 657 this.EndSelectionUpdate(); 658 }, 659 SetItemSelectionState: function(itemIndex, selected, controller){ 660 this.BeginSelectionUpdate(); 661 this.listBoxControl.SetItemSelectionAppearance(itemIndex, selected, controller); 662 this.EndSelectionUpdate(); 663 }, 664 GetFocusedIndex: function(){ 665 return this.GetSelectedIndexInternal(); 666 }, 667 BeginSelectionUpdate: function(){
668 this.updateHiddenInputsLockCount++; 669 }, 670 EndSelectionUpdate: function(){ 671 this.updateHiddenInputsLockCount--; 672 if(!this.IsUpdateInternalSelectionStateLocked()){ 673 this.listBoxControl.UpdateInternalState(); 674 this.FlushSelectionChanged(); 675 } 676 }, 677 IsUpdateInternalSelectionStateLocked: function(){ 678 return this.updateHiddenInputsLockCount > 0; 679 }, 680 GetItemCount: function(){ 681 return this.listBoxControl.GetItemCount(); 682 }, 683 OnItemSelectionChanged: function(index, selected){ 684 if(this.IsUpdateInternalSelectionStateLocked()){ 685 var a = {Index: index, Selected: selected}; 686 this.cachedSelectionChangedArgs.push(a); 687 } 688 else 689 this.listBoxControl.OnItemSelectionChanged(index, selected); 690 }, 691 FlushSelectionChanged: function(){ 692 if(this.IsUpdateInternalSelectionStateLocked()) 693 return; 694 for(var i = 0; i < this.cachedSelectionChangedArgs.length; i++) 695 this.listBoxControl.OnItemSelectionChanged(this.cachedSelectionChangedArgs[i].Index, this.cachedSelectionChangedArgs[i].Selected); 696 this.cachedSelectionChangedArgs = []; 697 }, 698 OnItemInserted: function(index){ 699 if(index <= this.savedSelectedIndex && this.savedSelectedIndex != -1) 700 this.SetSelectedIndexInternal(this.savedSelectedIndex + 1); 701 }, 702 OnItemRemoved: function(index){ 703 var selectedIndex = this.GetSelectedIndex(); 704 if(index < this.savedSelectedIndex) 705 this.SetSelectedIndexInternal( this.savedSelectedIndex - 1); 706 else if(index == this.savedSelectedIndex) 707 this.SetSelectedIndexInternal(-1); 708 }, 709 OnItemsCleared: function(){ 710 this.ClearSelection(); 711 } 712}); 713_aspxListBoxMultiSelectionHelper = _aspxCreateClass(_aspxListBoxSingleSelectionHelper, { 714 constructor: function(listBoxControl) { 715 this.constructor.prototype.constructor.call(this, listBoxControl); 716 this.selectedValuesCache = []; 717 this.selectedItemsCache = []; 718 this.savedSelectedIndices = []; 719 this.selectedIndicesSortingRequired = false; 720 this.focusedIndex = -1; 721 this.lastIndexFocusedWithoutShift = -1; 722 }, 723 SetSelectedIndex: function(index){ 724 this.SingleIndexSelection(index); 725 }, 726 ResetSelectionCollectionsCache: function(){ 727 this.selectedIndicesSortingRequired = true; 728 this.selectedItemsCache = []; 729 this.selectedValuesCache = []; 730 }, 731 GetSelectedIndices: function(){ 732 return this.GetSortedSelectedIndices().slice(); 733 }, 734 GetSortedSelectedIndices: function() { 735 if(this.savedSelectedIndices.length > 1 && this.selectedIndicesSortingRequired) 736 this.SortSelectedIndices(); 737 return this.savedSelectedIndices; 738 }, 739 GetSelectedValues: function(){ 740 if(this.savedSelectedIndices.length == 0) 741 return []; 742 if(this.selectedValuesCache.length == 0) 743 this.selectedValuesCache = this.GetSelectedValuesCore(); 744 return this.selectedValuesCache; 745 }, 746 GetSelectedValuesCore: function(){ 747 var selectedValues = []; 748 var selectedIndices = this.GetSortedSelectedIndices(); 749 if(selectedIndices.length == 0) 750 return selectedValues; 751 for(var i = 0; i < selectedIndices.length; i++) 752 selectedValues.push(this.listBoxControl.GetItemValue([selectedIndices[i]])); 753 return selectedValues; 754 }, 755 GetSelectedItems: function(){ 756 if(this.savedSelectedIndices.length == 0) 757 return []; 758 if(this.selectedItemsCache.length == 0) 759 this.selectedItemsCache = this.GetSelectedItemsCore(); 760 return this.selectedItemsCache; 761 }, 762 GetSelectedItemsCore: function(){ 763 var selectedItems = []; 764 for(var i = 0; i < this.savedSelectedIndices.length; i++) 765 selectedItems.push(this.listBoxControl.GetItem(this.savedSelectedIndices[i])); 766 return selectedItems; 767 }, 768 SetIndicesSelectionState: function(indices, selected){ 769 this.BeginSelectionUpdate(); 770 var controller = typeof(aspxGetStateController) != "undefined" ? aspxGetStateController() : null; 771 var itemCount = this.listBoxControl.GetItemCount(); 772 if(indices){ 773 for(var i = 0; i < indices.length; i++){ 774 var index = indices[i]; 775 if(index >= 0 && index < itemCount) 776 this.SetItemSelectionState(indices[i], selected, controller); 777 } 778 } else 779 this.SetAllItemsSelectionState(selected, controller); 780 this.SetSelectedIndexCore(this.GetFirstSelectedIndex()); 781 this.EndSelectionUpdate(); 782 }, 783 SetItemsSelectionState: function(items, selected){ 784 var indices = items ? this.ConvertItemsToIndices(items) : null; 785 this.SetIndicesSelectionState(indices, selected); 786 }, 787 SetValuesSelectionState: function(values, selected){ 788 var indices = values ? this.ConvertValuesToIndices(values) : null; 789 this.SetIndicesSelectionState(indices, selected); 790 }, 791 ConvertValuesToIndices: function(values){ 792 var indices = []; 793 for(var i = 0; i < values.length; i++) 794 indices.push(this.listBoxControl.FindItemIndexByValue(values[i])); 795 return indices; 796 }, 797 ConvertItemsToIndices: function(items){ 798 var indices = []; 799 for(var i = 0; i < items.length; i++) 800 indices.push(items[i].index); 801 return indices; 802 }, 803 SelectIndices: function(indices){ 804 this.SetIndicesSelectionState(indices, true); 805 }, 806 SelectItems: function(items){ 807 this.SetItemsSelectionState(items, true); 808 }, 809 SelectValues: function(values){ 810 this.SetValuesSelectionState(values, true); 811 }, 812 UnselectIndices: function(indices){ 813 this.SetIndicesSelectionState(indices, false); 814 }, 815 UnselectItems: function(items){ 816 this.SetItemsSelectionState(items, false); 817 }, 818 UnselectValues: function(values){ 819 this.SetValuesSelectionState(values, false); 820 }, 821 GetIsItemSelected: function(index){ 822 return _aspxArrayBinarySearch(this.GetSortedSelectedIndices(), index) > -1; 823 }, 824 OnItemClick: function(index, evt){ 825 this.BeginSelectionUpdate(); 826 var ctrlKey = evt.ctrlKey || evt.metaKey; 827 var shift = evt.shiftKey; 828 if(ctrlKey) 829 this.AddSelectedIndex(index); 830 else if(shift){ 831 var startIndex = index > this.lastIndexFocusedWithoutShift ? this.lastIndexFocusedWithoutShift + 1 : index; 832 var endIndex = index > this.lastIndexFocusedWithoutShift ? index : this.lastIndexFocusedWithoutShift - 1; 833 this.SelectRangeIndicesOnly(startIndex, endIndex); 834 this.SetFocusedIndexInternal(index, true); 835 }else 836 this.SingleIndexSelection(index); 837 this.EndSelectionUpdate(); 838 }, 839 OnItemCheckBoxClick: function(index, evt){ 840 this.BeginSelectionUpdate(); 841 this.AddSelectedIndex(index); 842 this.EndSelectionUpdate(); 843 }, 844 AddSelectedIndex: function(index){ 845 this.SetFocusedIndexInternal(index, false); 846 var indexInSelectedIndices = _aspxArrayIndexOf(this.savedSelectedIndices, index); 847 var selectionOperation = indexInSelectedIndices == -1; 848 this.SetItemSelectionState(index, selectionOperation); 849 this.SetSelectedIndexCore(this.GetFirstSelectedIndex()); 850 }, 851 SelectRangeIndicesOnly: function(startIndex, endIndex){ 852 this.BeginSelectionUpdate(); 853 var controller = typeof(aspxGetStateController) != "undefined" ? aspxGetStateController() : null; 854 var itemCount = this.GetItemCount(); 855 for(var i = 0; i < itemCount; i ++) { 856 if(i == this.lastIndexFocusedWithoutShift) 857 continue; 858 this.SetItemSelectionState(i, i >= startIndex && i <= endIndex, controller); 859 } 860 this.SetSelectedIndexCore(this.GetFirstSelectedIndex()); 861 this.EndSelectionUpdate(); 862 }, 863 SingleIndexSelection: function(index){ 864 this.SetFocusedIndexInternal(-1, false); 865 this.SelectRangeIndicesOnly(index, index); 866 this.SetFocusedIndexInternal(index, false); 867 }, 868 SetAllItemsSelectionState: function(selected, controller){ 869 this.BeginSelectionUpdate(); 870 this.savedSelectedIndices = [ ]; 871 var itemCount = this.GetItemCount(); 872 for(var i = 0; i < itemCount; i ++) { 873 this.SetItemSelectionStateCore(i, selected, controller); 874 if(selected) 875 this.PushSelectedIndex(i); 876 this.OnItemSelectionChanged(i, selected); 877 } 878 this.ResetSelectionCollectionsCache(); 879 this.EndSelectionUpdate(); 880 }, 881 SetItemSelectionState: function(itemIndex, selected, controller){ 882 this.SetItemSelectionStateCore(itemIndex, selected, controller); 883 this.ResetSelectionCollectionsCache(); 884 var indexInSelectionArray = _aspxArrayIndexOf(this.savedSelectedIndices, itemIndex); 885 if(selected && indexInSelectionArray == -1){ 886 this.PushSelectedIndex(itemIndex); 887 this.OnItemSelectionChanged(itemIndex, true); 888 } 889 if(!selected && indexInSelectionArray != -1){ 890 this.RemoveSelectedIndexAt(indexInSelectionArray);
891 this.OnItemSelectionChanged(itemIndex, false); 892 } 893 }, 894 GetFirstSelectedIndex: function(){ 895 var selectedIndices = this.GetSelectedIndices(); 896 var selectedIndicesCount = selectedIndices.length; 897 var firstSelectedIndex = -1; 898 if(selectedIndicesCount > 0){ 899 firstSelectedIndex = selectedIndices[0]; 900 for(var i = 1; i < selectedIndices.length; i++){ 901 if(firstSelectedIndex > selectedIndices[i]) 902 firstSelectedIndex = selectedIndices[i]; 903 } 904 } 905 return firstSelectedIndex; 906 }, 907 PushSelectedIndex: function(index){ 908 this.savedSelectedIndices.push(index); 909 }, 910 RemoveSelectedIndex: function(index){ 911 _aspxArrayRemove(this.savedSelectedIndices, index); 912 }, 913 RemoveSelectedIndexAt: function(indexInArray){ 914 _aspxArrayRemoveAt(this.savedSelectedIndices, indexInArray); 915 }, 916 SortSelectedIndices: function(){ 917 _aspxArrayIntegerAscendingSort(this.savedSelectedIndices); 918 this.selectedIndicesSortingRequired = false; 919 }, 920 SetItemSelectionStateCore: function(itemIndex, selected, controller){ 921 _aspxListBoxSingleSelectionHelper.prototype.SetItemSelectionState.call(this, itemIndex, selected, controller); 922 }, 923 GetFocusedIndex: function(){ 924 return this.focusedIndex; 925 }, 926 SetFocusedIndexInternal: function(index, isShiftPressed){ 927 if(!isShiftPressed) 928 this.lastIndexFocusedWithoutShift = index; 929 this.focusedIndex = index; 930 }, 931 OnItemInserted: function(index){ 932 this.ResetSelectionCollectionsCache(); 933 _aspxListBoxSingleSelectionHelper.prototype.OnItemInserted.call(this, index); 934 if(this.focusedIndex >= index) 935 this.focusedIndex ++; 936 for(var i = 0; i < this.savedSelectedIndices.length; i++){ 937 if(this.savedSelectedIndices[i] >= index) 938 this.savedSelectedIndices[i]++; 939 } 940 }, 941 OnItemRemoved: function(index){ 942 this.ResetSelectionCollectionsCache(); 943 _aspxListBoxSingleSelectionHelper.prototype.OnItemRemoved.call(this, index); 944 if(this.focusedIndex == index) 945 this.focusedIndex = -1; 946 else if(this.focusedIndex > index) 947 this.focusedIndex --; 948 if(this.GetIsItemSelected(index)) 949 this.RemoveSelectedIndex(index); 950 for(var i = 0; i < this.savedSelectedIndices.length; i++){ 951 if(this.savedSelectedIndices[i] > index) 952 this.savedSelectedIndices[i]--; 953 } 954 if(this.GetSelectedIndex() == -1) 955 this.SetSelectedIndexCore(this.GetFirstSelectedIndex()); 956 }, 957 ClearSelection: function(){ 958 this.ResetSelectionCollectionsCache(); 959 _aspxArrayClear(this.savedSelectedIndices); 960 this.OnSelectionCleared(); 961 this.SetSelectedIndexCore(-1); 962 } 963}); 964_aspxCheckBoxListMultiSelectionHelper = _aspxCreateClass(_aspxListBoxMultiSelectionHelper, { 965 OnItemClick: function(index){ 966 this.BeginSelectionUpdate(); 967 this.AddSelectedIndex(index); 968 this.EndSelectionUpdate(); 969 }, 970 GetFocusedItemIndex: function(){ 971 return this.lastIndexFocusedWithoutShift; 972 } 973}); 974_aspxListBoxCheckSelectionHelper = _aspxCreateClass(_aspxListBoxMultiSelectionHelper, { 975 OnItemClick: function(index, evt){ 976 this.BeginSelectionUpdate(); 977 if(evt.shiftKey) 978 _aspxListBoxMultiSelectionHelper.prototype.OnItemClick.call(this, index, evt); 979 else 980 this.AddSelectedIndex(index); 981 this.EndSelectionUpdate(); 982 } 983}); 984ASPxClientListBox = _aspxCreateClass(ASPxClientListBoxBase, { 985 constructor: function(name) { 986 this.constructor.prototype.constructor.call(this, name); 987 this.freeUniqIndex = -1; 988 this.isHasFakeRow = false; 989 this.headerDiv = null; 990 this.headerTable = null; 991 this.listTable = null; 992 this.sampleItemFirstTextCell = null; 993 this.width = ""; 994 this.hasSampleItem = false; 995 this.hoverClasses = [""]; 996 this.hoverCssArray = [""]; 997 this.selectedClasses = [""]; 998 this.selectedCssArray = [""]; 999 this.disabledClasses = [""]; 1000 this.disabledCssArray = [""]; 1001 this.imageCellExists = false; 1002 this.scrollHandlerLockCount = 0; 1003 this.columnFieldNames = []; 1004 this.textFormatString = ""; 1005 this.defaultImageUrl = ""; 1006 this.selectionMode = 0; 1007 this.initSelectedIndices = []; 1008 this.itemHorizontalAlign = ""; 1009 this.emptyTextRowCellIndices = null; 1010 this.allowMultipleCallbacks = false; 1011 this.isCallbackMode = false; 1012 this.callbackPageSize = -1; 1013 this.isTopSpacerVisible = false; 1014 this.isBottomSpacerVisible = false; 1015 this.serverIndexOfFirstItem = 0; 1016 this.scrollHelper = null; 1017 this.changeSelectAfterCallback = 0; 1018 this.ownerControl = null; 1019 this.SampleItem = null; 1020 this.scrollDivElement = null; 1021 this.scrollPageSize = 4; 1022 this.itemsValue = []; 1023 this.cachedValue = null; 1024 this.tempCache = new ASPxClientTemporaryCache(); 1025 this.sizingConfig.adjustControl = true; 1026 this.disableScrolling = false; 1027 this.icbFocusedStyle = null; 1028 this.icbImageProperties = null; 1029 this.internalCheckBoxCollection = null; 1030 this.focusableCheckInput = null; 1031 this.nativeCheckOnFocusHandler = null; 1032 }, 1033 Initialize: function() { 1034 this.LockScrollHandler(); 1035 this.InitDXTextAttributes(); 1036 this.InitScrollPos(); 1037 if(__aspxWebKitTouchUI) 1038 ASPxClientTouchUI.MakeScrollable(this.GetScrollDivElement(), {showHorizontalScrollbar: false}); 1039 this.CreateInternalCheckBoxCollection(); 1040 this.InitSelection(); 1041 this.AdjustControl(false);
1042 this.InitializeLoadOnDemand(); 1043 this.UnlockScrollHandler(); 1044 this.freeUniqIndex = this.GetItemCount(); 1045 ASPxClientEdit.prototype.Initialize.call(this); 1046 }, 1047 InitDXTextAttributes: function(){ 1048 if(this.emptyTextRowCellIndices != null){ 1049 var itemWithDXTextCount = this.emptyTextRowCellIndices.length; 1050 for(var i = 0; i < itemWithDXTextCount; i++){ 1051 var itemIndex = this.emptyTextRowCellIndices[i][0]; 1052 var cellIndices = this.emptyTextRowCellIndices[i][1]; 1053 var itemRow = this.GetItemRow(itemIndex); 1054 for(var j = 0; j < cellIndices.length; j++){ 1055 _aspxSetAttribute(itemRow.cells[cellIndices[j]], "DXText", ""); 1056 } 1057 } 1058 } 1059 }, 1060 InitSelection: function(){ 1061 var valueFromLastTime = this.GetValueFromValueInput(); 1062 if(this.MultiSelectionMode()){ 1063 if(valueFromLastTime != ""){ 1064 var serialiser = this.GetSerializingHelper(); 1065 var selectedValuesFromLastTime = serialiser.DeserializeValues(valueFromLastTime); 1066 var selectedIdicesFromLastTime = []; 1067 for(var i = 0; i < selectedValuesFromLastTime.length; i++) 1068 selectedIdicesFromLastTime.push(this.FindItemIndexByValue(selectedValuesFromLastTime[i])); 1069 this.SelectIndices(selectedIdicesFromLastTime); 1070 } else 1071 this.SelectIndices(this.initSelectedIndices); 1072 } else { 1073 var selectedIndex = (valueFromLastTime != "") ? 1074 this.FindItemIndexByValue(valueFromLastTime) : this.GetSelectedIndexInternal(); 1075 this.SetSelectedIndexInternal(selectedIndex); 1076 this.SelectIndexSilent(selectedIndex); 1077 } 1078 this.CacheValue(); 1079 }, 1080 CreateInternalCheckBoxCollection: function() { 1081 if (this.IsNativeCheckBoxes() || this.internalCheckBoxCollection) 1082 return; 1083 this.internalCheckBoxCollection = new ASPxCheckBoxInternalCollection(this.icbImageProperties, false, false, null, true); 1084 for(var i = 0; i < this.GetItemCount(); i++) 1085 this.AddInternalCheckBoxToCollection(i); 1086 }, 1087 AddInternalCheckBoxToCollection: function(index) { 1088 if(!this.internalCheckBoxCollection) 1089 return; 1090 var inputElement = this.GetItemCheckBoxInput(index) 1091 if(inputElement) { 1092 var internalCheckBox = this.internalCheckBoxCollection.Add(this.GetInternalCheckBoxKey(index), inputElement); 1093 internalCheckBox.CreateFocusDecoration(this.icbFocusedStyle); 1094 internalCheckBox.SetEnabled(this.GetEnabled()); 1095 internalCheckBox.autoSwitchEnabled = false; 1096 this.ChangeSpecialInputEnabledAttributes(inputElement, _aspxChangeEventsMethod(this.GetEnabled())); 1097 internalCheckBox.CheckedChanged.AddHandler( 1098 function(s, e) { 1099 if(_aspxGetKeyCode(e) == ASPxKey.Space) { 1100 var element = _aspxGetEventSource(e); 1101 this.GetItemSelectionHelper().OnItemCheckBoxClick(this.FindInternalCheckBoxIndex(element), e); 1102 } 1103 }.aspxBind(this) 1104 ); 1105 internalCheckBox.Focus.AddHandler( 1106 function(s, e) { 1107 var index = this.FindInternalCheckBoxIndex(s.mainElement); 1108 window.setTimeout(function() { this.ScrollToItemVisible(index); }.aspxBind(this), 50); 1109 }.aspxBind(this) 1110 ); 1111 } 1112 }, 1113 ClearInternalCheckBoxCollection: function() { 1114 if(this.internalCheckBoxCollection) 1115 this.internalCheckBoxCollection.Clear(); 1116 }, 1117 RemoveInternalCheckBoxFromCollecntion: function(index) { 1118 if(this.internalCheckBoxCollection) 1119 this.internalCheckBoxCollection.Remove(this.GetItemValue(index)); 1120 }, 1121 GetInternalCheckBoxKey: function(index) { 1122 return this.name + this.GetItemValue(index); 1123 }, 1124 GetInternalCheckBox: function (index) { 1125 if (this.internalCheckBoxCollection == null) 1126 this.CreateInternalCheckBoxCollection() 1127 if(this.internalCheckBoxCollection) 1128 return this.internalCheckBoxCollection.Get(this.GetInternalCheckBoxKey(index)); 1129 return null; 1130 }, 1131 IsNativeCheckBoxes: function() { 1132 return !this.icbImageProperties; 1133 }, 1134 SetCheckBoxChecked: function(index, checked) { 1135 if(this.IsNativeCheckBoxes()) { 1136 var checkBox = this.GetItemCheckBoxInput(index); 1137 checkBox.checked = checked; 1138 } 1139 else { 1140 var internalCheckBox = this.GetInternalCheckBox(index); 1141 internalCheckBox.SetValue(checked ? ASPxClientCheckBoxInputKey.Checked : ASPxClientCheckBoxInputKey.Unchecked); 1142 } 1143 }, 1144 SetCheckBoxEnabled: function(index, enabled) { 1145 var inputElement; 1146 if(this.IsNativeCheckBoxes()) { 1147 var checkbox = this.GetItemCheckBoxInput(index); 1148 checkbox.disabled = !enabled; 1149 this.ChangeNativeCheckEnabledAttributes(checkbox, _aspxChangeEventsMethod(this.GetEnabled())); 1150 inputElement = checkbox; 1151 } 1152 else { 1153 var internalCheckBox = this.GetInternalCheckBox(index); 1154 internalCheckBox.SetEnabled(enabled); 1155 inputElement = internalCheckBox.inputElement; 1156 } 1157 this.ChangeSpecialInputEnabledAttributes(inputElement, _aspxChangeEventsMethod(enabled)); 1158 }, 1159 ClearItems: function() { 1160 ASPxClientListBoxBase.prototype.ClearItems.call(this); 1161 this.ClearInternalCheckBoxCollection(); 1162 }, 1163 OnDelayedSpecialFocusMouseDown: function(evt) { 1164 if(this.GetIsCheckColumnExists()) 1165 this.SetFocusableCheckInput(this.GetCheckBoxInputFromEvent(evt)); 1166 ASPxClientListBoxBase.prototype.OnDelayedSpecialFocusMouseDown.call(this, evt); 1167 }, 1168 GetCheckBoxInputFromEvent: function(evt) { 1169 var element = _aspxGetEventSource(evt); 1170 if(this.IsNativeCheckBoxes()) 1171 return element.type == "checkbox" ? element : null; 1172 var index = this.FindInternalCheckBoxIndex(element); 1173 return index > -1 ? this.GetInternalCheckBox(index).inputElement : null; 1174 }, 1175 FindInternalCheckBoxIndex: function(element) { 1176 var level = 5; 1177 while(level > 0) {
1178 var id = element.id; 1179 if(id && element.tagName == "TD" && id.slice(-1) == __aspxLBIPostfixes[0]) 1180 return element.parentNode.rowIndex; 1181 element = element.parentNode; 1182 level--; 1183 } 1184 return -1; 1185 }, 1186 IsCheckBoxClicked: function(evt) { 1187 return !!this.GetCheckBoxInputFromEvent(evt); 1188 }, 1189 GetFocusableInputElement: function() { 1190 return this.focusableCheckInput || this.GetInputElement(); 1191 }, 1192 SetFocusableCheckInput: function(element) { 1193 this.focusableCheckInput = element; 1194 }, 1195 OnFocusCore: function() { 1196 if(this.UseDelayedSpecialFocus()) 1197 window.clearTimeout(this.specialFocusTimer); 1198 if(this.focused) { 1199 this.UnlockFocusEvents(); 1200 return; 1201 } 1202 ASPxClientListBoxBase.prototype.OnFocusCore.call(this); 1203 }, 1204 OnLostFocusCore: function() { 1205 if(!this.IsFocusEventsLocked()) 1206 this.SetFocusableCheckInput(null); 1207 ASPxClientListBoxBase.prototype.OnLostFocusCore.call(this); 1208 }, 1209 GetValueFromValueInput: function(){ 1210 if(this.ShouldRestoreSelectionAfterBackPressed()){ 1211 var valueInput = this.FindStateInputElement(); 1212 if(_aspxIsExistsElement(valueInput)) 1213 return valueInput.value; 1214 } 1215 return ""; 1216 }, 1217 ShouldRestoreSelectionAfterBackPressed: function(){ 1218 return __aspxIE || __aspxChrome; 1219 }, 1220 GetInitSelectedIndex: function(){ 1221 return this.savedSelectedIndex; 1222 }, 1223 CacheValue: function(){ 1224 this.cachedValue = this.GetValue(); 1225 }, 1226 InitScrollPos: function(){ 1227 if(!this.isComboBoxList && this.isCallbackMode && this.GetInitSelectedIndex() == -1) 1228 this.GetScrollDivElement().scrollTop = 0; 1229 }, 1230 InitializeLoadOnDemand: function(){ 1231 var loadOnDemandRequired = this.isCallbackMode && this.GetEnabledByServer(); 1232 this.scrollHelper = loadOnDemandRequired ? new _aspxListBoxScrollCallbackHelper(this) : new _aspxListBoxScrollCallbackHelperBase(this); 1233 }, 1234 InlineInitialize: function(){ 1235 this.InitializeNativeCheckHandlers(); 1236 this.LockScrollHandler(); 1237 if(!this.disableScrolling) 1238 this.InitSpecialKeyboardHandling(); 1239 this.InitializeItemsAttributes(); 1240 this.GenerateStateItems(); 1241 this.UnlockScrollHandler(); 1242 ASPxClientEdit.prototype.InlineInitialize.call(this); 1243 }, 1244 InitializeNativeCheckHandlers: function() { 1245 this.nativeCheckOnFocusHandler = function(evt) { 1246 this.SetFocusableCheckInput(_aspxGetEventSource(evt)); 1247 }.aspxBind(this); 1248 }, 1249 ChangeNativeCheckEnabledAttributes: function(element, method) { 1250 if(this.nativeCheckOnFocusHandler) 1251 method(element, "focus", this.nativeCheckOnFocusHandler); 1252 }, 1253 InitializeItemsAttributes: function() { 1254 var listTable = this.GetListTable(); 1255 if(this.isHasFakeRow){ 1256 this.LockSynchronization(); 1257 this.ClearItems(); 1258 this.UnlockSynchronization(); 1259 } 1260 listTable.ListBoxId = this.name; 1261 var rows = listTable.rows; 1262 var count = rows.length; 1263 var rowIdConst = this.name + "_"; 1264 if(this.hasSampleItem) 1265 this.InitializeItemAttributes(this.GetSampleItemRow(), rowIdConst + __aspxLBSIIdSuffix); 1266 rowIdConst += __aspxLBIIdSuffix; 1267 for(var i = 0; i < count; i ++) 1268 this.InitializeItemAttributes(rows[i], rowIdConst + i); 1269 }, 1270 InitializeItemAttributes: function(row, rowId) { 1271 var cells = row.cells; 1272 var itemCellsIdSuffixes = this.GetItemCellsIdPostfixes(); 1273 for(var i = 0; i < row.cells.length; i++) { 1274 cells[i].style.textAlign = this.itemHorizontalAlign; 1275 cells[i].id = rowId + itemCellsIdSuffixes[i]; 1276 } 1277 if(this.GetIsCheckColumnExists() && this.IsNativeCheckBoxes() && rowId != this.GetSampleItemRowID()) { 1278 var input = this.GetItemCheckBoxInput(row.rowIndex); 1279 this.ChangeNativeCheckEnabledAttributes(input, _aspxChangeEventsMethod(this.GetEnabled())); 1280 this.ChangeSpecialInputEnabledAttributes(input, _aspxChangeEventsMethod(this.GetEnabled())); 1281 } 1282 }, 1283 InitializePageSize: function(){ 1284 var divElement = this.GetScrollDivElement(); 1285 var listTable = this.GetListTable(); 1286 var rows = listTable.rows; 1287 var count = rows.length; 1288 if(divElement && count > 0) 1289 this.scrollPageSize = Math.round(divElement.clientHeight / rows[0].offsetHeight) - 1; 1290 }, 1291 GenerateStateItems: function() { 1292 if(typeof(aspxGetStateController) == "undefined") return;
1293 var itemCellsIdSuffixes = this.GetItemCellsIdPostfixes(); 1294 var count = this.GetItemCount(); 1295 var constName = this.name + "_" + __aspxLBIIdSuffix; 1296 var name = ""; 1297 var controller = aspxGetStateController(); 1298 var i = this.hasSampleItem ? -1 : 0 ; 1299 for(; i < count; i ++){ 1300 name = constName + i; 1301 if(!__aspxWebKitTouchUI) 1302 controller.AddHoverItem(name, this.hoverClasses, this.hoverCssArray, itemCellsIdSuffixes, null, null, true); 1303 controller.AddSelectedItem(name, this.selectedClasses, this.selectedCssArray, itemCellsIdSuffixes, null, null, true); 1304 controller.AddDisabledItem(name, this.disabledClasses, this.disabledCssArray, itemCellsIdSuffixes, null, null, true); 1305 } 1306 }, 1307 AfterInitialize: function() { 1308 if(this.disableScrolling) { 1309 var scrollDiv = this.GetScrollDivElement(); 1310 var mainElement = this.GetMainElement(); 1311 scrollDiv.style.height = mainElement.style.height = _aspxGetClearClientHeight(this.GetListTable()) + "px"; 1312 } 1313 this.CallbackSpaceInit(true); 1314 this.constructor.prototype.AfterInitialize.call(this); 1315 }, 1316 GetEnabledByServer: function(){ 1317 return this.enabled; 1318 }, 1319 SetEnabled: function(enabled){ 1320 ASPxClientListBoxBase.prototype.SetEnabled.call(this, enabled); 1321 this.CallbackSpaceInit(false); 1322 }, 1323 CallbackSpaceInit: function(isInitialization){ 1324 if(this.isCallbackMode){ 1325 this.SetBottomScrollSpacerVisibility(this.GetScrollSpacerVisibility(false)); 1326 this.SetTopScrollSpacerVisibility(this.GetScrollSpacerVisibility(true)); 1327 if(isInitialization || this.isComboBoxList){ 1328 this.EnsureSelectedItemVisible(); 1329 _aspxAttachEventToElement(this.GetScrollDivElement(), "scroll", aspxLBScroll); 1330 } 1331 } 1332 }, 1333 GetListTable: function() { 1334 return this.tempCache.Get("ListTable", this.GetListTableCore, this); 1335 }, 1336 GetListTableCore: function(){ 1337 if(!_aspxIsExistsElement(this.listTable)) 1338 this.listTable = _aspxGetElementById(this.name + __aspxLTableIdSuffix); 1339 return this.listTable; 1340 }, 1341 GetListTableHeight: function(){ 1342 return this.GetListTable().offsetHeight; 1343 }, 1344 GetHeaderDivElement: function(){ 1345 if(!_aspxIsExistsElement(this.headerDiv)) 1346 this.headerDiv = _aspxGetElementById(this.name + __aspxLBHeaderDivIdSuffix); 1347 return this.headerDiv; 1348 }, 1349 GetHeaderTableElement: function(){ 1350 if(!_aspxIsExistsElement(this.headerTable)){ 1351 var headerDiv = this.GetHeaderDivElement(); 1352 this.headerTable = _aspxGetChildByTagName(headerDiv, "table", 0); 1353 } 1354 return this.headerTable; 1355 }, 1356 GetScrollDivElement: function(){ 1357 if(!_aspxIsExistsElement(this.scrollDivElement)) 1358 this.scrollDivElement = document.getElementById(this.name + __aspxLBDSuffix); 1359 return this.scrollDivElement; 1360 }, 1361 GetItemElement: function(index){ 1362 var itemElement = this.GetItemRow(index); 1363 return __aspxWebKitFamily && itemElement != null ? itemElement.cells[0] : itemElement; 1364 }, 1365 GetItemRow: function(index){ 1366 var listTable = this.GetListTable(); 1367 if(listTable && index >= 0) 1368 return listTable.rows[index] || null; 1369 return null; 1370 }, 1371 GetItemTexts: function(item) { 1372 return item.texts ? item.texts : [ item.text ]; 1373 }, 1374 GetItemCount: function(){ 1375 var lbt = this.GetListTable(); 1376 if(lbt) 1377 return this.GetListTable().rows.length; 1378 return 0; 1379 }, 1380 GetItemCellCount: function(){ 1381 if(this.hasSampleItem) 1382 return this.GetSampleItemRow().cells.length; 1383 else if(this.GetItemCount() > 0){ 1384 var listTable = this.GetListTable(); 1385 return listTable.rows[0].cells.length; 1386 } 1387 return 0; 1388 }, 1389 GetItemTextCellCount: function(){ 1390 return this.GetItemCellCount() - this.GetItemFirstTextCellIndex(); 1391 }, 1392 GetItemFirstTextCellIndex: function(){ 1393 var itemFirstTextCellIndex = 0; 1394 if(this.GetIsCheckColumnExists()) 1395 itemFirstTextCellIndex++; 1396 if(this.imageCellExists) 1397 itemFirstTextCellIndex++; 1398 return itemFirstTextCellIndex; 1399 }, 1400 GetItemFirstTextCell: function(index){ 1401 var rowElement = this.GetItemRow(index); 1402 if(rowElement == null) 1403 return null; 1404 return rowElement.cells[this.GetItemFirstTextCellIndex()]; 1405 }, 1406 GetItemTopOffset: function(index){ 1407 var itemElement = this.GetItemElement(index); 1408 return (itemElement != null) ? itemElement.offsetTop + this.GetTopScrollSpacerHeight() : 0; 1409 }, 1410 GetItemHeight: function(index){ 1411 var itemElement = this.GetItemElement(index); 1412 return (itemElement != null) ? itemElement.offsetHeight : 0; 1413 }, 1414 GetItemCheckBoxInput: function(index){ 1415 var itemRow = this.GetItemRow(index); 1416 var checkBoxCell = itemRow.cells[this.GetCheckBoxCellIndex()];
1417 return _aspxGetElementsByTagName(checkBoxCell, "input")[0]; 1418 }, 1419 GetIsCheckColumnExists: function(){ 1420 if(!this.checkCellExists) 1421 this.checkCellExists = this.CheckColumnSelectionMode(); 1422 return this.checkCellExists; 1423 }, 1424 GetCheckBoxCellIndex: function(){ 1425 return 0; 1426 }, 1427 GetImageCellIndex: function(){ 1428 return this.GetIsCheckColumnExists() ? 1 : 0; 1429 }, 1430 GetItemCellsIdPostfixes: function(){ 1431 if(this.itemCellsIdPostfixes == null){ 1432 this.itemCellsIdPostfixes = []; 1433 var i = 0; 1434 if(this.GetIsCheckColumnExists()) { 1435 this.itemCellsIdPostfixes.push(__aspxLBIPostfixes[0]); 1436 i++; 1437 } 1438 if(this.imageCellExists){ 1439 this.itemCellsIdPostfixes.push(__aspxLBIPostfixes[1]); 1440 i++; 1441 } 1442 var cellCount = this.GetItemCellCount(); 1443 for(; i < cellCount; i++) 1444 this.itemCellsIdPostfixes.push(__aspxLBIPostfixes[2] + i); 1445 } 1446 return this.itemCellsIdPostfixes; 1447 }, 1448 AdjustControl: function (checkSizeCorrectedFlag, nestedCall) { 1449 if (!checkSizeCorrectedFlag) 1450 this.heightCorrected = false; 1451 ASPxClientEdit.prototype.AdjustControl.call(this, checkSizeCorrectedFlag, nestedCall); 1452 }, 1453 AdjustControlCore: function(){ 1454 if(this.disableScrolling) 1455 return; 1456 ASPxClientEdit.prototype.AdjustControlCore.call(this); 1457 this.CorrectSize(); 1458 this.EnsureSelectedItemVisible(); 1459 if(!this.isComboBoxList && __aspxIE && __aspxBrowserVersion >= 7) 1460 this.CorrectWidth(); 1461 }, 1462 CorrectSize: function() { 1463 if(this.isComboBoxList || this.disableScrolling) 1464 return; 1465 this.LockScrollHandler(); 1466 this.CorrectHeight(); 1467 this.CorrectWidth(); 1468 this.InitializePageSize(); 1469 this.UnlockScrollHandler(); 1470 }, 1471 OnCorrectSizeByTimer: function() { 1472 if(this.IsVisible()) 1473 this.CorrectSize(); 1474 }, 1475 SetProtectionFromFlick_inFF: function(changeVisibility, changeDisplay){ 1476 if(!__aspxFirefox) return; 1477 var listTable = this.GetListTable(); 1478 if(changeVisibility) 1479 listTable.style.visibility = "hidden"; 1480 if(changeDisplay) 1481 listTable.style.display = "none"; 1482 }, 1483 ResetProtectionFromFlick_inFF: function(){ 1484 if(!__aspxFirefox) return; 1485 var listTable = this.GetListTable(); 1486 listTable.style.visibility = ""; 1487 listTable.style.display = ""; 1488 }, 1489 CorrectHeight: function(){ 1490 if(__aspxFirefox && this.heightCorrected) return; 1491 this.heightCorrected = true; 1492 var mainElement = this.GetMainElement(); 1493 var divElement = this.GetScrollDivElement(); 1494 if(__aspxIE && __aspxBrowserVersion == 5.5) 1495 divElement.style.display = "none"; 1496 divElement.style.height = "0px"; 1497 var height = mainElement.offsetHeight; 1498 if(__aspxIE && __aspxBrowserVersion == 5.5) 1499 divElement.style.display = ""; 1500 divElement.style.height = height + "px"; 1501 var extrudedHeight = mainElement.offsetHeight; 1502 var heightCorrection = extrudedHeight - height; 1503 if(heightCorrection > 0){ 1504 var divHeight = divElement.offsetHeight; 1505 this.SetProtectionFromFlick_inFF(true, false); 1506 divElement.style.height = (divHeight - heightCorrection) + "px"; 1507 this.ResetProtectionFromFlick_inFF(); 1508 extrudedHeight = mainElement.offsetHeight; 1509 var paddingsHeightCorrection = extrudedHeight - height; 1510 if(paddingsHeightCorrection > 0) 1511 divElement.style.height = (divHeight - heightCorrection - paddingsHeightCorrection) + "px"; 1512 } 1513 }, 1514 IsMultiColumn: function(){ 1515 return this.columnFieldNames.length > 0; 1516 }, 1517 CorrectWidth: function(){ 1518 if(this.IsMultiColumn()) 1519 this.CorrectMultiColumnWidth(); 1520 else 1521 this.CorrectNonMultiColumnWidth(); 1522 }, 1523 CorrectMultiColumnWidth: function(){ 1524 var scrollDivElement = this.GetScrollDivElement(); 1525 var scrollBarWidth = this.GetVerticalScrollBarWidth(); 1526 var browserPutsScrollBarOnContent = __aspxIE && __aspxBrowserVersion > 5.5 && __aspxBrowserVersion < 8; 1527 if(browserPutsScrollBarOnContent) 1528 scrollDivElement.style.paddingRight = scrollBarWidth + "px"; 1529 if(__aspxIE && (__aspxBrowserVersion == 6 || __aspxBrowserVersion == 7)){ 1530 this.CollapseMultiColumnHeaderWidth(); 1531 var listTable = this.GetListTable(); 1532 var mainElement = this.GetMainElement(); 1533 listTable.style.width = ""; 1534 scrollDivElement.style.width = (mainElement.clientWidth - scrollBarWidth) + "px"; 1535 listTable.style.width = "100%"; 1536 } 1537 this.CorrectMultiColumnHeaderWidth(scrollBarWidth);
1538 if(this.rtl && __aspxIE && __aspxBrowserVersion < 8) 1539 this.FixIE7MultiColumnRtl(); 1540 }, 1541 CollapseMultiColumnHeaderWidth:function(){ 1542 var headerDivElement = this.GetHeaderDivElement(); 1543 headerDivElement.style.width = "0px"; 1544 }, 1545 CorrectMultiColumnHeaderWidth: function(scrollBarWidth){ 1546 var scrollDivElement = this.GetScrollDivElement(); 1547 var headerDivElement = this.GetHeaderDivElement(); 1548 if(_aspxIsExistsElement(headerDivElement)){ 1549 var headerTable; 1550 if(__aspxWebKitFamily){ 1551 headerTable = this.GetHeaderTableElement(); 1552 if(!_aspxIsExistsElement(headerTable)) 1553 headerTable = null; 1554 } 1555 if(headerTable) 1556 headerTable.style.width = "0"; 1557 if(__aspxIE && __aspxBrowserVersion < 8) 1558 headerDivElement.style.width = scrollDivElement.style.width; 1559 headerDivElement.style.paddingRight = scrollBarWidth + "px"; 1560 if(headerTable) 1561 window.setTimeout(function() { headerTable.style.width = "100%"; }, 0); 1562 } 1563 }, 1564 FixIE7MultiColumnRtl: function() { 1565 var tables = [ this.GetHeaderTableElement(), this.GetListTable() ]; 1566 for(var i = 0; i < tables.length; i++) { 1567 var table = tables[i]; 1568 if(!table) continue; 1569 var backup = table.style.tableLayout; 1570 table.style.tableLayout = "auto"; 1571 table.offsetWidth; 1572 table.style.tableLayout = backup; 1573 } 1574 }, 1575 CorrectNonMultiColumnWidth: function(){ 1576 var divElement = this.GetScrollDivElement(); 1577 if(__aspxIE && __aspxBrowserMajorVersion < 8) { 1578 var mainElement = this.GetMainElement(); 1579 var scrollBarWidth = this.GetVerticalScrollBarWidth(); 1580 mainElement.style.width = ""; 1581 divElement.style.width = "100%"; 1582 if(__aspxIE && __aspxBrowserVersion > 5.5) 1583 divElement.style.paddingRight = "0px"; 1584 if(this.width != ""){ 1585 mainElement.style.width = this.width; 1586 divElement.style.width = "0px"; 1587 var widthCorrectrion = (__aspxIE && __aspxBrowserVersion == 5.5) ? 0 : scrollBarWidth; 1588 var correctedWidth = mainElement.clientWidth - widthCorrectrion; 1589 if(correctedWidth >= 0) 1590 divElement.style.width = correctedWidth + "px"; 1591 } else { 1592 var widthCorrectrion = (__aspxIE && __aspxBrowserVersion == 5.5) ? scrollBarWidth : 0; 1593 if(this.IsListBoxWidthLessThenList()) 1594 widthCorrectrion -= scrollBarWidth; 1595 divElement.style.width = (mainElement.clientWidth + widthCorrectrion) + "px"; 1596 } 1597 if(__aspxIE && __aspxBrowserVersion > 5.5) 1598 divElement.style.paddingRight = scrollBarWidth + "px"; 1599 } else { 1600 if(this.width == ""){ 1601 var listTable = this.GetListTable(); 1602 var mainElement = this.GetMainElement(); 1603 if(listTable.offsetWidth != 0 || !__aspxNetscapeFamily){ 1604 divElement.style.width = (listTable.offsetWidth + this.GetVerticalScrollBarWidth()) + "px"; 1605 if(__aspxFirefox) 1606 mainElement.style.width = divElement.offsetWidth + "px"; 1607 } 1608 } else { 1609 var mainElement = this.GetMainElement(); 1610 mainElement.style.width = this.width; 1611 divElement.style.width = __aspxWebKitFamily ? "1px" : "0px"; 1612 divElement.style.width = mainElement.clientWidth + "px"; 1613 } 1614 } 1615 }, 1616 UpdateWidthCorrectionRequired: function() { 1617 this.widthValueSetInPercentage = _aspxIsWidthSetInPercentage(this.width); 1618 }, 1619 EnsureSelectedItemVisible: function(){ 1620 var index = this.GetSelectedIndex(); 1621 if(index != -1) 1622 this.MakeItemVisible(index); 1623 }, 1624 MakeItemVisible: function(index){ 1625 if(!this.IsItemVisible(index)) 1626 this.ScrollItemToTop(index); 1627 }, 1628 IsItemVisible: function(index){ 1629 var scrollDiv = this.GetScrollDivElement(); 1630 var itemElement = this.GetItemElement(index); 1631 var topVisible = false; 1632 var bottomVisible = false; 1633 if(itemElement != null){ 1634 var itemOffsetTop = itemElement.offsetTop + this.GetTopScrollSpacerHeight(); 1635 topVisible = itemOffsetTop >= scrollDiv.scrollTop; 1636 bottomVisible = itemOffsetTop + itemElement.offsetHeight < scrollDiv.scrollTop + scrollDiv.clientHeight; 1637 } 1638 return (topVisible && bottomVisible); 1639 }, 1640 ScrollItemToTop: function(index){ 1641 this.LockScrollHandler(); 1642 this.SetScrollTop(this.GetItemTopOffset(index)); 1643 this.UnlockScrollHandler(); 1644 }, 1645 ScrollToItemVisible: function(index){ 1646 if(!this.IsItemVisible(index)){ 1647 var scrollDiv = this.GetScrollDivElement(); 1648 var scrollTop = scrollDiv.scrollTop; 1649 var scrollDivHeight = scrollDiv.clientHeight; 1650 var itemOffsetTop = this.GetItemTopOffset(index); 1651 var itemHeight = this.GetItemHeight(index); 1652 var itemAbove = scrollTop > itemOffsetTop; 1653 var itemBelow = scrollTop + scrollDivHeight < itemOffsetTop + itemHeight; 1654 if(itemAbove) 1655 scrollDiv.scrollTop = itemOffsetTop; 1656 else if(itemBelow){ 1657 var scrollPaddings = scrollDiv.scrollHeight - this.GetListTable().offsetHeight - 1658 this.GetTopScrollSpacerHeight() - this.GetBottomScrollSpacerHeight(); 1659 scrollDiv.scrollTop = itemOffsetTop + itemHeight - scrollDivHeight + scrollPaddings; 1660 } 1661 } 1662 }, 1663 SetScrollTop: function(scrollTop){ 1664 var scrollDiv = this.GetScrollDivElement(); 1665 if(scrollDiv){ 1666 scrollDiv.scrollTop = scrollTop; 1667 if(__aspxOpera) 1668 this.CachedScrollTop(); 1669 } 1670 }, 1671 CachedScrollTop: function(){ 1672 var scrollDiv = this.GetScrollDivElement(); 1673 scrollDiv.cachedScrollTop = scrollDiv.scrollTop; 1674 }, 1675 RestoreScrollTopFromCache: function(){ 1676 var scrollDiv = this.GetScrollDivElement(); 1677 if(scrollDiv && _aspxIsExists(scrollDiv.cachedScrollTop)) 1678 scrollDiv.scrollTop = scrollDiv.cachedScrollTop; 1679 }, 1680 IsListBoxWidthLessThenList: function(){ 1681 var divElement = this.GetScrollDivElement(); 1682 var listTable = this.GetListTable(); 1683 var listTabelWidth = listTable.style.width; 1684 var isLess = false; 1685 listTable.style.width = ""; 1686 isLess = listTable.offsetWidth < divElement.offsetWidth; 1687 listTable.style.width = listTabelWidth; 1688 return isLess; 1689 }, 1690 GetVerticalScrollBarWidth: function(){ 1691 var divElement = this.GetScrollDivElement(); 1692 if(!this.verticalScrollBarWidth || this.verticalScrollBarWidth <= 0){ 1693 this.verticalScrollBarWidth = this.GetVerticalScrollBarWidthCore(divElement); 1694 return this.verticalScrollBarWidth; 1695 } else 1696 return this.GetIsVerticalScrollBarVisible(divElement) ? this.verticalScrollBarWidth : 0; 1697 }, 1698 GetIsVerticalScrollBarVisible: function(divElement){ 1699 var verticalOverflow = this.GetVerticalOverflow(divElement); 1700 if(verticalOverflow != "auto"){ 1701 var listTable = this.GetListTable(); 1702 return divElement.clientHeight < listTable.offsetHeight; 1703 } else { 1704 var borderWidthWithScroll = divElement.offsetWidth - divElement.clientWidth; 1705 return borderWidthWithScroll == this.scrollDivBordersWidthWithScroll; 1706 } 1707 }, 1708 GetVerticalScrollBarWidthCore: function(divElement){ 1709 var overflowYReserv = this.GetVerticalOverflow(divElement); 1710 this.SetVerticalOverflow(divElement, "auto"); 1711 this.scrollDivBordersWidthWithScroll = divElement.offsetWidth - divElement.clientWidth; 1712 if(__aspxIE && __aspxBrowserVersion >= 7) 1713 return this.scrollDivBordersWidthWithScroll; 1714 this.SetProtectionFromFlick_inFF(false, true); 1715 this.SetVerticalOverflow(divElement, "hidden"); 1716 var bordersWidthWithoutScroll = divElement.offsetWidth - divElement.clientWidth; 1717 this.SetVerticalOverflow(divElement, overflowYReserv); 1718 this.ResetProtectionFromFlick_inFF(); 1719 return this.scrollDivBordersWidthWithScroll - bordersWidthWithoutScroll; 1720 }, 1721 GetVerticalOverflow: function(element){ 1722 if(__aspxIE || __aspxSafari && __aspxBrowserVersion >= 3 || __aspxChrome) 1723 return element.style.overflowY; 1724 return element.style.overflow; 1725 }, 1726 SetVerticalOverflow: function(element, value){ 1727 if(__aspxIE || __aspxSafari && __aspxBrowserVersion >= 3 || __aspxChrome) 1728 element.style.overflowY = value; 1729 else 1730 element.style.overflow = value; 1731 }, 1732 MultiSelectionMode: function(){ 1733 return this.selectionMode != ListBoxSelectionMode.Single; 1734 }, 1735 CheckColumnSelectionMode: function(){ 1736 return this.selectionMode == ListBoxSelectionMode.CheckColumn; 1737 }, 1738 OnItemClick: function(index, evt){ 1739 if(!this.isInitialized) 1740 return; 1741 if(this.readOnly) 1742 return this.OnItemClickOrDblClickReadOnly(); 1743 if(this.CheckColumnSelectionMode() && this.IsCheckBoxClicked(evt))
1744 this.GetItemSelectionHelper().OnItemCheckBoxClick(index, evt); 1745 else 1746 this.GetItemSelectionHelper().OnItemClick(index, evt); 1747 this.SetFocus(); 1748 this.RaiseItemClick(); 1749 }, 1750 OnItemClickOrDblClickReadOnly: function(){ 1751 return false; 1752 }, 1753 OnItemDblClick: function(){ 1754 if(this.readOnly) 1755 return this.OnItemClickOrDblClickReadOnly(); 1756 return this.RaiseItemDoubleClick(); 1757 }, 1758 CanChangeSelection: function(){ 1759 return !this.readOnly || !this.isInitialized; 1760 }, 1761 SelectIndexSilent: function(index){ 1762 return this.SetItemSelectionStateSilent(index); 1763 }, 1764 SetItemSelectionStateSilent: function(index){ 1765 if(!this.CanChangeSelection()) 1766 return; 1767 var oldSelectionIndex = this.GetSelectedIndex(); 1768 this.LockSelectionEvents(); 1769 this.SetSelectedIndexCore(index); 1770 this.UnlockSelectionEvents(); 1771 return index != oldSelectionIndex; 1772 }, 1773 SetItemSelectionAppearance: function(index, selected, controller){ 1774 if(!this.CanChangeSelection()) 1775 return; 1776 if(!controller) 1777 controller = aspxGetStateController(); 1778 if(!this.isInitialized) 1779 this.SetHoverElement(null); 1780 var itemFirstTextCell = this.GetItemFirstTextCell(index); 1781 if(selected) 1782 controller.SelectElementBySrcElement(itemFirstTextCell); 1783 else 1784 controller.DeselectElementBySrcElement(itemFirstTextCell); 1785 if(!this.isInitialized) 1786 this.SetHoverElement(itemFirstTextCell); 1787 }, 1788 GetItemSelectionHelper: function(){ 1789 if(!this.itemSelectionHelper) 1790 this.itemSelectionHelper = this.CreateItemSelectionHelper(); 1791 return this.itemSelectionHelper; 1792 }, 1793 CreateItemSelectionHelper: function(){ 1794 if(this.selectionMode == ListBoxSelectionMode.Single) 1795 return new _aspxListBoxSingleSelectionHelper(this); 1796 else if(this.selectionMode == ListBoxSelectionMode.Multiple) 1797 return new _aspxListBoxMultiSelectionHelper(this); 1798 else if(this.selectionMode == ListBoxSelectionMode.CheckColumn) 1799 return new _aspxListBoxCheckSelectionHelper(this); 1800 }, 1801 GetValue: function(){ 1802 var index = this.GetSelectedIndex(); 1803 if(0 <= index && index < this.itemsValue.length) 1804 return this.itemsValue[index]; 1805 return null; 1806 }, 1807 SetValue: function(value){ 1808 var index = this.FindItemIndexByValue(value); 1809 this.SetSelectedIndex(index); 1810 }, 1811 GetSelectedItem: function(){ 1812 var index = this.GetSelectedIndex(); 1813 return this.GetItem(index); 1814 }, 1815 GetSelectedIndex: function(){ 1816 if(!this.isInitialized) 1817 return this.GetSelectedIndexInternal(); 1818 return this.GetItemSelectionHelper().GetSelectedIndex(); 1819 }, 1820 SetSelectedIndex: function(index){ 1821 this.LockSelectionEvents(); 1822 this.SetSelectedIndexCore(index); 1823 this.EnsureSelectedItemVisible(index); 1824 this.UnlockSelectionEvents(); 1825 }, 1826 SetSelectedIndexCore: function(index){ 1827 this.GetItemSelectionHelper().SetSelectedIndex(index); 1828 }, 1829 GetSelectedIndices: function(){ 1830 return this.GetItemSelectionHelper().GetSelectedIndices(); 1831 }, 1832 GetSelectedValues: function(){ 1833 return this.GetItemSelectionHelper().GetSelectedValues(); 1834 }, 1835 GetSelectedItems: function(){ 1836 return this.GetItemSelectionHelper().GetSelectedItems(); 1837 }, 1838 SelectAll: function(){ 1839 this.SelectIndices(); 1840 }, 1841 UnselectAll: function(){ 1842 this.UnselectIndices(); 1843 }, 1844 SelectIndices: function(indices){ 1845 this.LockSelectionEvents(); 1846 this.GetItemSelectionHelper().SelectIndices(indices); 1847 this.UnlockSelectionEvents(); 1848 }, 1849 SelectItems: function(items){ 1850 this.LockSelectionEvents(); 1851 this.GetItemSelectionHelper().SelectItems(items); 1852 this.UnlockSelectionEvents(); 1853 }, 1854 SelectValues: function(values){ 1855 this.LockSelectionEvents(); 1856 this.GetItemSelectionHelper().SelectValues(values); 1857 this.UnlockSelectionEvents(); 1858 }, 1859 UnselectIndices: function(indices){ 1860 this.LockSelectionEvents(); 1861 this.GetItemSelectionHelper().UnselectIndices(indices); 1862 this.UnlockSelectionEvents(); 1863 }, 1864 UnselectItems: function(items){ 1865 this.LockSelectionEvents(); 1866 this.GetItemSelectionHelper().UnselectItems(items); 1867 this.UnlockSelectionEvents(); 1868 }, 1869 UnselectValues: function(values){ 1870 this.LockSelectionEvents(); 1871 this.GetItemSelectionHelper().UnselectValues(values); 1872 this.UnlockSelectionEvents(); 1873 }, 1874 GetIsItemSelected: function(index){ 1875 return this.GetItemSelectionHelper().GetIsItemSelected(index); 1876 }, 1877 GetFocusedIndex: function(){ 1878 return this.GetItemSelectionHelper().GetFocusedIndex(); 1879 }, 1880 UpdateInternalState: function(){
1881 this.UpdateHiddenInputs(); 1882 }, 1883 IsUpdateHiddenInputsLocked: function(){ 1884 return this.GetItemSelectionHelper().IsUpdateInternalSelectionStateLocked(); 1885 }, 1886 UpdateHiddenInputs: function(){ 1887 if(this.IsUpdateHiddenInputsLocked()) 1888 return; 1889 if(this.MultiSelectionMode()){ 1890 var element = this.FindStateInputElement(); 1891 if(_aspxIsExistsElement(element)) { 1892 var sb = [ ]; 1893 var serialiser = this.GetSerializingHelper(); 1894 var selectedIndices = this.GetSelectedIndices(); 1895 for(var i = 0; i < selectedIndices.length; i++) 1896 serialiser.SerializeAtomValue(sb, this.GetItemValue(selectedIndices[i])); 1897 element.value = sb.join(""); 1898 } 1899 } else 1900 ASPxClientListBoxBase.prototype.UpdateHiddenInputs.call(this); 1901 }, 1902 UseDelayedSpecialFocus: function() { 1903 return true; 1904 }, 1905 ShowLoadingPanel: function() { 1906 if(!this.isComboBoxList){ 1907 var loadingParentElement = this.GetScrollDivElement().parentNode; 1908 this.CreateLoadingPanelWithAbsolutePosition(loadingParentElement); 1909 } 1910 }, 1911 ShowLoadingDiv: function () { 1912 if(!this.isComboBoxList){ 1913 var loadingParentElement = this.GetScrollDivElement().parentNode; 1914 this.CreateLoadingDiv(loadingParentElement); 1915 } 1916 }, 1917 ParseCallbackResult: function(result){ 1918 var gottenEgdeOfCollection = false; 1919 var nothingToLoad = result == ""; 1920 var isLoadindToTopByScroll = this.scrollHelper.IsScrolledToTopSpacer(); 1921 if(!nothingToLoad){ 1922 var deserializedItems = this.DeserializeItems(result); 1923 this.LoadItemsFromCallback(isLoadindToTopByScroll, deserializedItems); 1924 gottenEgdeOfCollection = deserializedItems.length != this.callbackPageSize; 1925 } 1926 var noMoreItemsForLoadThisDirection = nothingToLoad || gottenEgdeOfCollection; 1927 this.SetScrollSpacerVisibility(isLoadindToTopByScroll, !noMoreItemsForLoadThisDirection); 1928 this.scrollHelper.Reset(); 1929 }, 1930 LoadItemsFromCallback: function(isToTop, deserializedItems){ 1931 this.LockSynchronizationOnInternalCallback(); 1932 this.BeginUpdate(); 1933 if(isToTop){ 1934 var scrollHeightCorrection = 0; 1935 for(var i = deserializedItems.length - 1; i >= 0; i --){ 1936 this.InsertItem(0, deserializedItems[i].texts, deserializedItems[i].value, deserializedItems[i].imageUrl); 1937 scrollHeightCorrection += this.GetItemHeight(0); 1938 } 1939 this.GetScrollDivElement().scrollTop += scrollHeightCorrection; 1940 this.serverIndexOfFirstItem -= deserializedItems.length; 1941 if(this.serverIndexOfFirstItem < 0) this.serverIndexOfFirstItem = 0; 1942 } else { 1943 for(var i = 0; i < deserializedItems.length; i ++){ 1944 this.AddItem(deserializedItems[i].texts, deserializedItems[i].value, deserializedItems[i].imageUrl); 1945 } 1946 } 1947 if(this.changeSelectAfterCallback != 0) { 1948 var newIndex = this.GetSelectedIndex() + this.changeSelectAfterCallback; 1949 newIndex = this.GetAdjustedIndex(newIndex); 1950 this.SelectIndexSilent(newIndex); 1951 if(this.scrollHelper.isScrolledToTopSpacer) 1952 this.ScrollItemToTop(newIndex); 1953 else 1954 this.ScrollToItemVisible(newIndex); 1955 } 1956 this.EndUpdate(); 1957 this.UnlockSynchronizationOnInternalCallback(); 1958 }, 1959 CreateSerializingHelper: function(){ 1960 return new _aspxListBoxItemsSerializingHelper(this); 1961 }, 1962 InCallback: function(){ 1963 var callbackOwner = this.GetCallbackOwnerControl(); 1964 if(callbackOwner != null) 1965 return callbackOwner.InCallback(); 1966 return ASPxClientListEdit.prototype.InCallback.call(this); 1967 }, 1968 GetItemsRangeForLoad: function(){ 1969 return this.scrollHelper.GetItemsRangeForLoad(); 1970 }, 1971 GetScrollSpacerElement: function(isTop){ 1972 return document.getElementById(this.name + (isTop ? __aspxLBTSIdSuffix : __aspxLBBSIdSuffix)); 1973 }, 1974 GetScrollSpacerVisibility: function(isTop){ 1975 if(!this.clientEnabled) 1976 return false; 1977 return isTop ? this.isTopSpacerVisible : this.isBottomSpacerVisible; 1978 }, 1979 SetScrollSpacerVisibility: function(isTop, visibility){ 1980 this.LockScrollHandler(); 1981 var spacer = this.GetScrollSpacerElement(isTop); 1982 if(spacer){ 1983 if(visibility) 1984 spacer.style.height = this.GetScrollDivElement().clientHeight + "px"; 1985 if(this.clientEnabled){ 1986 if(isTop) 1987 this.isTopSpacerVisible = visibility; 1988 else 1989 this.isBottomSpacerVisible = visibility; 1990 } 1991 if(_aspxGetElementDisplay(spacer) != visibility){ 1992 _aspxSetElementDisplay(spacer, visibility); 1993 _aspxGetElementVisibility(spacer, visibility); 1994 } 1995 } 1996 this.UnlockScrollHandler(); 1997 }, 1998 SetTopScrollSpacerVisibility: function(visibility){ 1999 this.SetScrollSpacerVisibility(true, visibility); 2000 }, 2001 SetBottomScrollSpacerVisibility: function(visibility){ 2002 this.SetScrollSpacerVisibility(false, visibility); 2003 }, 2004 GetTopScrollSpacerHeight: function(){ 2005 return this.GetScrollSpacerVisibility(true) ? this.GetScrollSpacerElement(true).clientHeight : 0; 2006 }, 2007 GetBottomScrollSpacerHeight: function(){ 2008 return this.GetScrollSpacerVisibility(false) ? this.GetScrollSpacerElement(false).clientHeight : 0; 2009 }, 2010 SendCallback: function(){ 2011 if(!this.InCallback()){ 2012 this.ShowLoadingElements(); 2013 var callbackOwner = this.GetCallbackOwnerControl(); 2014 if(callbackOwner != null) 2015 callbackOwner.SendCallback(); 2016 else { 2017 var argument = this.GetCallbackArguments(); 2018 this.CreateCallback(argument); 2019 } 2020 } 2021 }, 2022 OnCallback: function(result) { 2023 this.ParseCallbackResult(result); 2024 this.OnCallbackFinally(); 2025 }, 2026 OnCallbackError: function(result){ 2027 ASPxClientListBoxBase.prototype.OnCallbackError.call(this, result); 2028 this.OnCallbackFinally(); 2029 }, 2030 OnCallbackFinally: function(){ 2031 this.HideLoadingPanel(); 2032 this.changeSelectAfterCallback = 0; 2033 }, 2034 LockScrollHandler: function(){ 2035 this.scrollHandlerLockCount ++; 2036 }, 2037 UnlockScrollHandler: function(){ 2038 this.scrollHandlerLockCount --; 2039 }, 2040 IsScrollHandlerLocked: function(){ 2041 return this.scrollHandlerLockCount > 0; 2042 }, 2043 OnScroll: function(){ 2044 if(this.IsScrollHandlerLocked()) return; 2045 if(this.IsVisible() && !this.InCallback() && ( this.GetScrollSpacerVisibility(true) || this.GetScrollSpacerVisibility(false))) { 2046 this.scrollHelper.OnScroll(); 2047 if(this.scrollHelper.GetIsNeedToHideTopSpacer()) 2048 this.SetTopScrollSpacerVisibility(false); 2049 if(this.scrollHelper.GetIsNeedCallback()) 2050 this.SendCallback(); 2051 } 2052 }, 2053 OnBrowserWindowResize: function(evt) { 2054 if (this.IsVisible()) 2055 this.CorrectSize(); 2056 }, 2057 KeyboardSupportAllowed: function(){ 2058 return !this.CheckColumnSelectionMode(); 2059 }, 2060 InitializeKeyHandlers: function() { 2061 if(this.KeyboardSupportAllowed()){ 2062 this.AddKeyDownHandler(ASPxKey.PageUp, "OnPageUp"); 2063 this.AddKeyDownHandler(ASPxKey.PageDown, "OnPageDown"); 2064 this.AddKeyDownHandler(ASPxKey.End, "OnEndKeyDown"); 2065 this.AddKeyDownHandler(ASPxKey.Home, "OnHomeKeyDown"); 2066 this.AddKeyDownHandler(ASPxKey.Up, "OnArrowUp"); 2067 this.AddKeyDownHandler(ASPxKey.Down, "OnArrowDown"); 2068 } 2069 }, 2070 OnArrowUp: function(evt){ 2071 if(this.isInitialized) 2072 this.SelectNeighbour(-1); 2073 return true; 2074 }, 2075 OnArrowDown: function(evt){ 2076 if(this.isInitialized) 2077 this.SelectNeighbour(1); 2078 return true; 2079 }, 2080 OnPageUp: function(evt){ 2081 if(this.isInitialized) 2082 this.SelectNeighbour(-this.scrollPageSize); 2083 return true; 2084 }, 2085 OnPageDown: function(evt){ 2086 if(this.isInitialized) 2087 this.SelectNeighbour(this.scrollPageSize); 2088 return true; 2089 }, 2090 OnHomeKeyDown: function(evt){ 2091 if(this.isInitialized) 2092 this.SelectNeighbour(-this.GetItemCount()); 2093 return true; 2094 }, 2095 OnEndKeyDown: function(evt){ 2096 if(this.isInitialized) 2097 this.SelectNeighbour(this.GetItemCount()); 2098 return true; 2099 }, 2100 GetAdjustedIndex: function(index){ 2101 if(index < 0) index = 0; 2102 else{ 2103 var itemCount = this.GetItemCount(); 2104 if(index >= itemCount) index = itemCount - 1; 2105 } 2106 return index; 2107 }, 2108 SelectNeighbour: function (step) { 2109 var itemCount = this.GetItemCount(); 2110 if (itemCount > 0) { 2111 this.changeSelectAfterCallback = 0; 2112 var selectedIndex = this.GetFocusedIndex(); 2113 var pageDownSize = step == 1 ? this.scrollPageSize + 1 : this.scrollPageSize; 2114 var isFirstPageDown = selectedIndex == -1 && step == pageDownSize && step > 1; 2115 var newSelectedIndex = isFirstPageDown ? step : selectedIndex + step; 2116 newSelectedIndex = this.GetAdjustedIndex(newSelectedIndex); 2117 if (selectedIndex != newSelectedIndex) { 2118 this.LockScrollOnKBNavigation(); 2119 this.SetSelectedIndexCore(newSelectedIndex); 2120 this.UnlockScrollOnKBNavigation(); 2121 } 2122 if (this.GetIsNeedToCallbackLoadItemsToTop(newSelectedIndex, step, itemCount)) { 2123 this.LoadItemsOnCallback(true, newSelectedIndex); 2124 } else if (this.GetIsNeedToCallbackLoadItemsToBottom(newSelectedIndex, step, itemCount)) { 2125 this.LoadItemsOnCallback(false, newSelectedIndex); 2126 } 2127 this.ScrollToItemVisible(newSelectedIndex); 2128 } 2129 }, 2130 GetIsNeedToCallbackLoadItemsToTop: function(selectedIndex, step, itemCount){ 2131 return this.isCallbackMode && this.GetScrollSpacerVisibility(true) && 2132 this.serverIndexOfFirstItem > 0 && ((step < 0 && selectedIndex <= 0) || step <= -itemCount); 2133 }, 2134 GetIsNeedToCallbackLoadItemsToBottom: function(selectedIndex, step, itemCount){ 2135 return this.isCallbackMode && this.GetScrollSpacerVisibility(false) && 2136 ((step > 0 && selectedIndex >= itemCount - 1) || step >= itemCount); 2137 }, 2138 LoadItemsOnCallback: function(isToTop, index){ 2139 this.changeSelectAfterCallback = index - this.GetSelectedIndex(); 2140 this.scrollHelper.SetItemsRangeForLoad(isToTop); 2141 this.SendCallback(); 2142 }, 2143 FindInputElement: function(){ 2144 return document.getElementById(this.name + "_KBS"); 2145 }, 2146 SetHoverElement: function(element){ 2147 aspxGetStateController().SetCurrentHoverElementBySrcElement(element); 2148 }, 2149 InitOnContainerMadeVisible: function(){ 2150 this.AdjustControl(false); 2151 }, 2152 ClearItemsCore: function(){ 2153 this.ClearListTableContent(); 2154 this.OnItemsCleared(); 2155 this.SetValue(null); 2156 }, 2157 OnItemsCleared: function(){
2158 this.GetItemSelectionHelper().OnItemsCleared(); 2159 }, 2160 CopyCellWidths: function(sourceRowIndex, destinationRowIndex){ 2161 var cellCount = this.GetItemCellCount(); 2162 var sourceRow = this.GetItemRow(sourceRowIndex); 2163 var destRow = this.GetItemRow(destinationRowIndex); 2164 for(var i = 0; i < cellCount; i++) 2165 destRow.cells[i].style.width = sourceRow.cells[i].style.width; 2166 }, 2167 RemoveItem: function(index){ 2168 if(index == 0 && this.GetItemCount() > 1) 2169 this.CopyCellWidths(0, 1); 2170 if(0 <= index && index < this.GetItemCount()){ 2171 if(this.GetIsCheckColumnExists() && !this.IsNativeCheckBoxes()) 2172 this.RemoveInternalCheckBoxFromCollecntion(index); 2173 this.UpdateSyncArraysItemDeleted(this.GetItem(index), true); 2174 var row = this.GetItemRow(index); 2175 if(_aspxIsExistsElement(row)) 2176 row.parentNode.removeChild(row); 2177 this.OnItemRemoved(index); 2178 } 2179 }, 2180 GetItem: function(index){ 2181 var listTable = this.GetListTable(); 2182 if(!listTable || index < 0 || index >= listTable.rows.length) 2183 return null; 2184 var row = listTable.rows[index]; 2185 var image = this.imageCellExists ? _aspxGetChildByTagName(row.cells[this.GetImageCellIndex()], "IMG", 0) : null; 2186 var src = image == null ? "" : ASPxImageUtils.GetImageSrc(image); 2187 var i = this.GetItemFirstTextCellIndex(); 2188 var texts = []; 2189 for(;i < row.cells.length; i ++){ 2190 var textCell = row.cells[i]; 2191 if(typeof(textCell.attributes["DXText"]) != "undefined") 2192 texts.push(_aspxGetAttribute(textCell, "DXText")); 2193 else { 2194 var text = _aspxGetInnerText(textCell); 2195 if(__aspxIE && __aspxBrowserVersion >= 9 && !this.encodeHtml) 2196 text = this.PrepareItemTextForIE(text); 2197 text = text.replace(new RegExp(__aspxNbspChar, "g"), " "); 2198 texts.push(text); 2199 } 2200 } 2201 return new ASPxClientListBoxItem(this, index, texts, this.itemsValue[index], src, this.GetIsItemSelected(index)); 2202 }, 2203 PrepareItemTextForIE: function(text, index) { 2204 if (!index && index !== 0) 2205 return this.PrepareItemTextForIE(text, 0); 2206 if (text[index] === '\r' && text[index + 1] === '\n') 2207 return this.PrepareItemTextForIE(text, index + 2); 2208 return text.substr(index); 2209 }, 2210 PerformCallback: function(arg) { 2211 this.SetScrollSpacerVisibility(true, false); 2212 this.SetScrollSpacerVisibility(false, false); 2213 this.ClearItemsForPerformCallback(); 2214 this.serverIndexOfFirstItem = 0; 2215 this.SetScrollSpacerVisibility(true, false); 2216 this.SetScrollSpacerVisibility(false, false); 2217 this.FormatAndSetCustomCallbackArg(arg); 2218 this.SendCallback(); 2219 }, 2220 GetTableRowParent: function(table){ 2221 if(table.tBodies.length > 0) 2222 return table.tBodies[0]; 2223 return table; 2224 }, 2225 ProtectWhitespaceSerieses: function(text){ 2226 if(text == "") 2227 text = __aspxNbsp; 2228 else { 2229 if(text.charAt(0) == ' ') 2230 text = __aspxNbsp + text.slice(1); 2231 if(text.charAt(text.length - 1) == ' ') 2232 text = text.slice(0, -1) + __aspxNbsp; 2233 text = text.replace(new RegExp(" ", "g"), " "); 2234 } 2235 return text; 2236 }, 2237 CreateItem: function(index, texts, value, imageUrl){ 2238 return new ASPxClientListBoxItem(this, index, texts, value, imageUrl); 2239 }, 2240 InsertItemInternal: function(index, texts, value, imageUrl){ 2241 if(!texts || texts.length == 0) 2242 texts = [""]; 2243 else if(typeof(texts) == "string") 2244 texts = [ texts ]; 2245 if(!_aspxIsExists(value)) 2246 value = texts[0]; 2247 if(!_aspxIsExists(imageUrl)) 2248 imageUrl = ""; 2249 var newItemRow = this.CreateNewItem(); 2250 _aspxRemoveAttribute(newItemRow, "id"); 2251 var listTable = this.GetListTable(); 2252 var tbody = this.GetTableRowParent(listTable); 2253 var isAdd = listTable.rows.length <= index; 2254 if(isAdd) 2255 tbody.appendChild(newItemRow); 2256 else 2257 tbody.insertBefore(newItemRow, this.GetItemRow(index)); 2258 var newIndex = this.FindFreeIndex(); 2259 var newId = this.CreateItemId(newIndex); 2260 var newClientId = this.CreateItemClientId(newIndex); 2261 this.InitializeItemAttributes(newItemRow, newClientId, true); 2262 var sampleItemFirstTextCell = this.GetSampleItemFirstTextCell(); 2263 var itemCellsIdPostfixes = this.GetItemCellsIdPostfixes(); 2264 var styleController = aspxGetStateController(); 2265 aspxAddHoverItems(this.name, this.CreateStyleClasses(newId, itemCells
2265IdPostfixes, 2266 styleController.GetHoverElement(sampleItemFirstTextCell), __aspxHoverItemKind), true); 2267 aspxAddSelectedItems(this.name, this.CreateStyleClasses(newId, itemCellsIdPostfixes, 2268 styleController.GetSelectedElement(sampleItemFirstTextCell), __aspxSelectedItemKind), true); 2269 aspxAddDisabledItems(this.name, this.CreateStyleClasses(newId, itemCellsIdPostfixes, 2270 styleController.GetDisabledElement(sampleItemFirstTextCell), __aspxDisabledItemKind), true); 2271 _aspxRemoveAttribute(sampleItemFirstTextCell, __aspxCachedStatePrefix + __aspxHoverItemKind); 2272 _aspxRemoveAttribute(sampleItemFirstTextCell, __aspxCachedStatePrefix + __aspxSelectedItemKind); 2273 _aspxRemoveAttribute(sampleItemFirstTextCell, __aspxCachedStatePrefix + __aspxDisabledItemKind); 2274 this.PrepareItem(newItemRow, texts, imageUrl); 2275 _aspxArrayInsert(this.itemsValue, value, index); 2276 this.RegisterInsertedItem(index, texts, value, imageUrl); 2277 if(this.GetIsCheckColumnExists() && !this.IsNativeCheckBoxes()) 2278 this.AddInternalCheckBoxToCollection(index); 2279 this.OnItemInserted(index); 2280 }, 2281 PrepareItem: function(newItemRow, texts, imageUrl){ 2282 var i = 0; 2283 if(this.GetIsCheckColumnExists()) 2284 i ++; 2285 if(this.imageCellExists) { 2286 this.PrepareItemImage(newItemRow, i, imageUrl); 2287 i ++; 2288 } 2289 var cellCount = this.GetItemCellCount(); 2290 for(var j = 0; i < cellCount; i++, j++) 2291 this.PrepareItemTextCell(newItemRow.cells[i], texts[j]) 2292 }, 2293 PrepareItemImage: function(newItemRow, imageCellIndex, imageUrl){ 2294 var imageCell = newItemRow.cells[imageCellIndex]; 2295 var image = _aspxGetChildByTagName(imageCell, "IMG", 0); 2296 if(!image){ 2297 image = document.createElement("IMG"); 2298 imageCell.innerHTML = ""; 2299 imageCell.appendChild(image); 2300 } 2301 ASPxImageUtils.SetImageSrc(image, imageUrl); 2302 }, 2303 PrepareItemTextCell: function(cell, text){ 2304 if(!_aspxIsExists(text)) 2305 text = ""; 2306 if(this.encodeHtml) 2307 text = _aspxEncodeHtml(text); 2308 cell.innerHTML = this.ProtectWhitespaceSerieses(text); 2309 if(text == "") 2310 _aspxSetAttribute(cell, "DXText", text); 2311 }, 2312 ClearListTableContent: function(){ 2313 var tBody = this.GetTableRowParent(this.GetListTable()); 2314 if(__aspxIE) 2315 tBody.innerText = ""; 2316 else 2317 tBody.innerHTML = ""; 2318 }, 2319 FormatText: function(texts){ 2320 if(typeof(texts) == "string") 2321 return texts; 2322 else if(!this.IsMultiColumn()) 2323 return texts[0]; 2324 else 2325 return this.FormatTextCore(texts); 2326 }, 2327 FormatTextCore: function(texts){ 2328 if(this.isComboBoxList) 2329 return ASPxFormatter.Format(this.textFormatString, texts); 2330 else 2331 return texts.join("; "); 2332 }, 2333 OnItemInserted: function(index){ 2334 this.GetItemSelectionHelper().OnItemInserted(index); 2335 }, 2336 OnItemRemoved: function(index){ 2337 this.GetItemSelectionHelper().OnItemRemoved(index); 2338 }, 2339 CreateItemId: function(index){ 2340 return __aspxLBIIdSuffix + index; 2341 }, 2342 CreateItemClientId: function(index){ 2343 return this.name + "_" + __aspxLBIIdSuffix + index; 2344 }, 2345 CreateNewItem: function(){ 2346 var newItemRow = this.GetSampleItemRow(); 2347 if (_aspxIsExistsElement(newItemRow)) 2348 newItemRow = newItemRow.cloneNode(true); 2349 return newItemRow; 2350 }, 2351 CreateStyleClasses: function(id, postfixes, item, kind){ 2352 var classes = []; 2353 if(item && item[kind]){ 2354 classes[0] = []; 2355 classes[0][0] = item[kind].classNames; 2356 classes[0][1] = item[kind].cssTexts; 2357 classes[0][2] = []; 2358 classes[0][2][0] = id; 2359 classes[0][3] = postfixes; 2360 } 2361 return classes; 2362 }, 2363 CorrectSizeByTimer: function(){ 2364 if(this.APILockCount == 0 && this.IsDisplayed()) 2365 _aspxSetTimeout("aspxLBCorrectSizeByTimer(\""+this.name+"\");", 0); 2366 }, 2367 FindFreeIndex: function(){ 2368 return this.freeUniqIndex ++; 2369 }, 2370 GetSampleItemRowID: function(){ 2371 return this.name + "_" + __aspxLBSIIdSuffix; 2372 }, 2373 GetSampleItemRow: function(){ 2374 if(this.SampleItem == null) 2375 this.SampleItem = _aspxGetElementById(this.GetSampleItemRowID()); 2376 return this.SampleItem; 2377 }, 2378 GetSampleItemFirstTextCell: function(){ 2379 if(!_aspxIsExistsElement(this.sampleItemFirstTextCell)){ 2380 var sampleItemRow = this.GetSampleItemRow(); 2381 if(_aspxIsExistsElement(sampleItemRow)) 2382 this.sampleItemFirstTextCell = sampleItemRow.cells[this.imageCellExists ? 1 : 0]; 2383 } 2384 return this.sampleItemFirstTextCell; 2385 }, 2386 ChangeEnabledAttributes: function(enabled){ 2387 this.ChangeListTableEvents(this.GetListTable(), _aspxChangeEventsMethod(enabled)); 2388 var inputElement = this.GetInputElement(); 2389 if(inputElement) 2390 this.ChangeSpecialInputEnabledAttributes(inputElement, _aspxChangeEventsMethod(enabled)); 2391 }, 2392 ChangeEnabledStateItems: function(enabled){ 2393 var controller = aspxGetStateController(); 2394 controller.SetElementEnabled(this.GetMainElement(), enabled); 2395 var count = this.GetItemCount(); 2396 var i = this.hasSampleItem ? -1 : 0 ; 2397 var checkColumnExists = this.GetIsCheckColumnExists();
2398 for(; i < count; i ++){ 2399 var element = this.GetItemFirstTextCell(i); 2400 if(element) 2401 controller.SetElementEnabled(element, enabled); 2402 if(checkColumnExists && i >= 0) 2403 this.SetCheckBoxEnabled(i, enabled); 2404 } 2405 }, 2406 ChangeListTableEvents: function(listTable, method){ 2407 if(this.isComboBoxList){ 2408 method(listTable, "mouseup", aspxLBIClick); 2409 if(__aspxFirefox) 2410 method(listTable, "mousedown", _aspxPreventEvent); 2411 } 2412 else{ 2413 method(listTable, "click", aspxLBIClick); 2414 method(listTable, "dblclick", aspxLBIClick); 2415 if(this.MultiSelectionMode()) 2416 _aspxAttachEventToElement(listTable, "selectstart", aspxLBTSelectStart); 2417 } 2418 }, 2419 IsValueChanged: function(){ 2420 return this.cachedValue != this.GetValue(); 2421 }, 2422 OnItemSelectionChanged: function(index, selected){ 2423 if(this.CheckColumnSelectionMode()) 2424 this.SetCheckBoxChecked(index, selected); 2425 if (!this.IsSelectionEventsLocked()) { 2426 this.SetRaiseSelectedIndexChangedArguments(this.autoPostBack, index, selected); 2427 var valueChanged = this.IsValueChanged(); 2428 if (valueChanged) { 2429 this.RaisePersonalStandardValidation(); 2430 this.OnValueChanged(); 2431 } else { 2432 if(this.RaiseSelectedIndexChanged()) 2433 this.SendPostBackInternal(""); 2434 } 2435 } 2436 this.CacheValue(); 2437 }, 2438 SetRaiseSelectedIndexChangedArguments: function(processOnServer, index, selected){ 2439 this.selectedIndexChangedArguments = { 2440 processOnServer: processOnServer, 2441 index: index, 2442 selected: selected 2443 }; 2444 }, 2445 GetRaiseSelectedIndexChangedArguments: function(){ 2446 if(!this.selectedIndexChangedArguments) 2447 this.SetRaiseSelectedIndexChangedArguments(false, this.GetSelectedIndex(), true); 2448 return this.selectedIndexChangedArguments; 2449 }, 2450 RaiseSelectedIndexChanged: function(processOnServer){ 2451 var savedArgs = this.GetRaiseSelectedIndexChangedArguments(); 2452 processOnServer = savedArgs.processOnServer || processOnServer; 2453 if(!this.SelectedIndexChanged.IsEmpty()){ 2454 var args = new ASPxClientListEditItemSelectedChangedEventArgs(savedArgs.index, savedArgs.selected, processOnServer); 2455 this.SelectedIndexChanged.FireEvent(this, args); 2456 processOnServer = args.processOnServer; 2457 } 2458 return processOnServer; 2459 }, 2460 SetWidth: function(width) { 2461 this.width = width + "px"; 2462 this.GetScrollDivElement().style.width = "100%"; 2463 this.constructor.prototype.SetWidth.call(this, width); 2464 }, 2465 SetHeight: function(height) { 2466 this.heightCorrected = false; 2467 this.constructor.prototype.SetHeight.call(this, height); 2468 } 2469}); 2470ASPxClientNativeListBox = _aspxCreateClass(ASPxClientListBoxBase, { 2471 constructor: function(name) { 2472 this.constructor.prototype.constructor.call(this, name); 2473 }, 2474 SetMainElement: function(mainElement){ 2475 this.mainElement = mainElement; 2476 }, 2477 FindInputElement: function(){ 2478 return this.GetMainElement(); 2479 }, 2480 GetOptionCount: function(){ 2481 return this.GetMainElement().options.length; 2482 }, 2483 GetOption: function(index){ 2484 return this.GetMainElement().options[index]; 2485 }, 2486 GetItemCount: function(){ 2487 return this.GetOptionCount(); 2488 }, 2489 SelectIndexSilent: function(index){ 2490 var selectedIndex = this.GetSelectedIndexInternal(); 2491 var isValidIndex = (-1 <= index && index < this.GetItemCount()); 2492 if((selectedIndex != index && isValidIndex) || !this.isInitialized){ 2493 this.SetSelectedIndexInternal(index); 2494 return true; 2495 } 2496 return false; 2497 }, 2498 GetSelectedIndexInternal: function(){ 2499 return this.GetMainElement().selectedIndex; 2500 }, 2501 SetSelectedIndexInternal: function(index){ 2502 this.GetMainElement().selectedIndex = index; 2503 }, 2504 ClearItemsCore: function(){ 2505 this.GetMainElement().innerHTML = ""; 2506 }, 2507 RemoveItem: function(index){ 2508 if(0 <= index && index < this.GetItemCount()){ 2509 var oldSelectedIndex = this.GetSelectedIndexInternal(); 2510 this.UpdateSyncArraysItemDeleted(this.GetItem(index), true); 2511 var option = this.GetOption(index); 2512 this.GetMainElement().removeChild(option); 2513 this.UpdateOptionValues(); 2514 this.OnItemRemoved(oldSelectedIndex, index); 2515 } 2516 }, 2517 OnItemRemoved: function(oldSelectedIndex, newSelectedIndex){ 2518 if(newSelectedIndex == oldSelectedIndex && !this.MultiSelectionMode()) 2519 this.SetSelectedIndexInternal(-1); 2520 }, 2521 MultiSelectionMode: function(){ 2522 return this.GetMainElement().multiple; 2523 }, 2524 GetItem: function(index){ 2525 if(0 <= index && index < this.GetOptionCount()) { 2526 var text = this.GetOption(index).text; 2527 if(_aspxIsExists(text)) 2528 return new ASPxClientListEditItem(this, index, text, this.itemsValue[index], ""); 2529 } 2530 return null; 2531 }, 2532 PerformCallback: function(arg) { 2533 this.ClearItemsForPerformCallback(); 2534 this.FormatAndSetCustomCallbackArg(arg); 2535 this.SendCallback(); 2536 }, 2537 SendCallback: function(){ 2538 if(!this.InCallback()){ 2539 var callbackOwner = this.GetCallbackOwnerControl(); 2540 if(callbackOwner != null) 2541 callbackOwner.SendCallback(); 2542 else { 2543 var argument = this.GetCallbackArguments(); 2544 this.CreateCallback(argument); 2545 } 2546 } 2547 }, 2548 ParseCallbackResult: function(result){ 2549 var deserializedItems = this.DeserializeItems(result); 2550 this.LoadItemsFromCallback(true, deserializedItems); 2551 }, 2552 InsertItemInternal: function(index, text, value, imageUrl){ 2553 if(!_aspxIsExists(value)) 2554 value = text; 2555 var oldSelectedIndex = this.GetSelectedIndexInternal(); 2556 var isAdd = this.GetOptionCount() <= index; 2557 var newOption = document.createElement("OPTION"); 2558 if(isAdd) 2559 this.GetMainElement().appendChild(newOption); 2560 else 2561 this.GetMainElement().insertBefore(newOption, this.GetOption(index)); 2562 newOption.innerHTML = text; 2563 this.UpdateOptionValues();
2564 _aspxArrayInsert(this.itemsValue, value, index); 2565 this.RegisterInsertedItem(index, text, value, imageUrl); 2566 if(index == oldSelectedIndex && index != -1) 2567 this.SetSelectedIndex(index + 1); 2568 }, 2569 UpdateOptionValues: function() { 2570 if(this.APILockCount == 0){ 2571 for(var i = 0; i < this.GetOptionCount(); i++) 2572 this.GetOption(i).value = i; 2573 } 2574 }, 2575 ChangeEnabledAttributes: function(enabled){ 2576 if(!this.isComboBoxList) 2577 this.GetMainElement().disabled = !enabled; 2578 }, 2579 OnCallback: function(result) { 2580 this.ParseCallbackResult(result); 2581 }, 2582 OnItemDblClick: function(){ 2583 this.RaiseItemDoubleClick(); 2584 }, 2585 LoadItemsFromCallback: function(isToTop, deserializedItems){ 2586 this.BeginUpdate(); 2587 this.LockSynchronizationOnInternalCallback(); 2588 for(var i = deserializedItems.length - 1; i >= 0; i --) 2589 this.InsertItemInternal(0, deserializedItems[i].text, deserializedItems[i].value, deserializedItems[i].imageUrl); 2590 this.UnlockSynchronizationOnInternalCallback(); 2591 this.EndUpdate(); 2592 }, 2593 EndUpdate: function(){ 2594 ASPxClientListBoxBase.prototype.EndUpdate.call(this); 2595 this.UpdateOptionValues(); 2596 }, 2597 GetSelectedIndices: function(){ 2598 var selectedIndices = []; 2599 var mainElement = this.GetMainElement(); 2600 for(var i = 0; i < mainElement.options.length; i++){ 2601 if(mainElement.options[i].selected) 2602 selectedIndices.push(i); 2603 } 2604 return selectedIndices; 2605 }, 2606 GetSelectedValues: function(){ 2607 var selectedValues = []; 2608 var selectedIndices = this.GetSelectedIndices(); 2609 for(var i = 0; i < selectedIndices.length; i++) 2610 selectedValues.push(this.GetItemValue(selectedIndices[i])); 2611 return selectedValues; 2612 }, 2613 GetSelectedItems: function(){ 2614 var selectedItems = []; 2615 var selectedIndices = this.GetSelectedIndices(); 2616 for(var i = 0; i < selectedIndices.length; i++) 2617 selectedItems.push(this.GetItem(selectedIndices[i])); 2618 return selectedItems; 2619 }, 2620 SelectAll: function(){ 2621 this.SetAllItemsSelectedValue(true); 2622 }, 2623 UnselectAll: function(){ 2624 this.SetAllItemsSelectedValue(false); 2625 }, 2626 SetAllItemsSelectedValue: function(selected){ 2627 var mainElement = this.GetMainElement(); 2628 for(var i = 0; i < mainElement.options.length; i++) 2629 mainElement.options[i].selected = selected; 2630 }, 2631 SelectIndices: function(indices){ 2632 this.SetIndicesSelectionState(indices, true); 2633 }, 2634 UnselectIndices: function(indices){ 2635 this.SetIndicesSelectionState(indices, false); 2636 }, 2637 SetIndicesSelectionState: function(indices, selected){ 2638 var mainElement = this.GetMainElement(); 2639 for(var i = 0; i < indices.length; i++){ 2640 mainElement.options[indices[i]].selected = selected; 2641 } 2642 }, 2643 SelectItems: function(items){ 2644 if(_aspxIsExists(items)) 2645 this.SetItemsSelectionState(items, true); 2646 else 2647 this.SelectAll(); 2648 }, 2649 UnselectItems: function(items){ 2650 if(_aspxIsExists(items)) 2651 this.SetItemsSelectionState(items, false); 2652 else 2653 this.UnselectAll(); 2654 }, 2655 SetItemsSelectionState: function(items, selected){ 2656 var mainElement = this.GetMainElement(); 2657 for(var i = 0; i < items.length; i++){ 2658 mainElement.options[items[i].index].selected = selected; 2659 } 2660 }, 2661 SelectValues: function(values){ 2662 this.SetValuesSelectedState(values, true); 2663 }, 2664 UnselectValues: function(values){ 2665 this.SetValuesSelectedState(values, false); 2666 }, 2667 SetValuesSelectedState: function(values, selected){ 2668 var mainElement = this.GetMainElement(); 2669 var index; 2670 for(var i = 0; i < values.length; i++){ 2671 index = this.FindItemIndexByValue(values[i]); 2672 mainElement.options[index].selected = selected; 2673 } 2674 } 2675}); 2676ASPxClientListBox.Cast = ASPxClientControl.Cast; 2677ASPxClientCheckListBase = _aspxCreateClass(ASPxClientListEdit, { 2678 constructor: function(name) { 2679 this.constructor.prototype.constructor.call(this, name); 2680 this.imageProperties = null; 2681 this.internalButtonCollection = null; 2682 this.icbFocusedStyle = []; 2683 this.items = []; 2684 }, 2685 Initialize: function() { 2686 ASPxClientListEdit.prototype.Initialize.call(this); 2687 this.UpdateInternalSelectedIndex(); 2688 }, 2689 UpdateInternalSelectedIndex: function() { 2690 var selectedIndexFromServer = this.GetSelectedIndex(); 2691 if(__aspxIE) { 2692 var stateInput = this.FindStateInputElement(); 2693 if(stateInput) { 2694 var restoredSelectedIndex = stateInput.value; 2695 if(restoredSelectedIndex != '' && restoredSelectedIndex != selectedIndexFromServer) 2696 this.SetSelectedIndex(restoredSelectedIndex); 2697 } 2698 } 2699 }, 2700 CreateButtonInternalCollection: function() { 2701 this.internalButtonCollection = new ASPxCheckBoxInternalCollection(this.imageProperties, false, true, ASPxCheckEditElementHelper.Instance); 2702 var instance = this; 2703 for(var i = 0; i < this.GetItemCount(); i++) { 2704 var icbInputElement = this.GetItemInput(i); 2705 var internalButton = this.internalButtonCollection.Add(icbInputElement.id, icbInputElement, this.GetItemElement(i)); 2706 internalButton.CreateFocusDecoration(this.icbFocusedStyle); 2707 internalButton.SetEnabled(this.GetEnabled()); 2708 internalButton.readOnly = this.readOnly; 2709 internalButton.CheckedChanged.AddHandler(function(s, e) { instance.OnItemClick(instance.GetItemIndexByElement(_aspxGetEventSource(e))); }); 2710 internalButton.Focus.AddHandler(function(s, e) { instance.OnFocus(); }); 2711 internalButton.LostFocus.AddHandler(function(s, e) { instance.OnLostFocus(); }); 2712 this.attachToCellsClick(i);
2713 this.PrepareInternalButton(internalButton, i); 2714 } 2715 }, 2716 CheckableElementsExist: function() { 2717 return !!this.imageProperties; 2718 }, 2719 SetFocus: function() { 2720 this.UpdateFocus(); 2721 }, 2722 UpdateFocus: function() { 2723 }, 2724 IsElementBelongToInputElement: function(element) { 2725 return this.GetItemIndexByElement(element) != -1; 2726 }, 2727 attachToCellsClick: function(index) { 2728 var element = this.GetItemElement(index); 2729 _aspxAttachEventToElement(element, "click", function(evt) { 2730 var src = _aspxGetEventSource(evt); 2731 var label = ASPxCheckEditElementHelper.Instance.GetLabelElement(element); 2732 var button = this.internalButtonCollection.Get(this.GetItemInput(index).id); 2733 if (!_aspxGetIsParent(button.mainElement, src) && src !== label) { 2734 ASPxCheckEditElementHelper.Instance.InvokeClick(button, evt); 2735 } 2736 }.aspxBind(this)); 2737 }, 2738 GetItemIndexByElement: function(element) { 2739 for (var i = 0; i < this.GetItemCount(); i++) { 2740 var itemElement = this.GetItemElement(i); 2741 if (_aspxGetIsParent(itemElement, element)) 2742 return i; 2743 } 2744 return -1; 2745 }, 2746 GetItemInput: function(index) { 2747 return this.GetChild("_RB" + index + "_I"); 2748 }, 2749 GetItemElement: function(index) { 2750 return this.GetChild("_RB" + index); 2751 }, 2752 GetItemCount: function() { 2753 return this.items.length; 2754 }, 2755 OnItemClick: function(index) { 2756 }, 2757 OnItemClickReadonly: function() { 2758 var index = this.GetSelectedIndexInternal(); 2759 this.SelectIndexSilent(index); 2760 }, 2761 UpdateHiddenInputs: function(index) { 2762 var stateInput = this.FindStateInputElement(); 2763 if(_aspxIsExistsElement(stateInput)) 2764 stateInput.value = index; 2765 var valueInput = this.GetValueInputElement(); 2766 if(_aspxIsExistsElement(valueInput)) { 2767 var value = this.GetValue(); 2768 valueInput.value = _aspxIsExists(value) ? value : " "; 2769 } 2770 }, 2771 GetItemValue: function(index){ 2772 if (index > -1 && index < this.items.length) { 2773 if (typeof(this.items[index].value) == "string" && this.items[index].value == "" && this.convertEmptyStringToNull) 2774 return null; 2775 else 2776 return this.items[index].value; 2777 } 2778 return null; 2779 }, 2780 SetValue: function(value) { 2781 for (var i = 0; i < this.items.length; i++) { 2782 if(this.GetItemValue(i) == value) { 2783 this.SelectIndexSilent(i); 2784 return; 2785 } 2786 } 2787 this.SelectIndexSilent(-1); 2788 }, 2789 CreateItems: function(itemsProperties){ 2790 for(var i = 0; i < itemsProperties.length; i ++) 2791 this.CreateItem(i, itemsProperties[i][0], itemsProperties[i][1], itemsProperties[i][2]); 2792 }, 2793 CreateItem: function(index, text, value, imageUrl){ 2794 var item = new ASPxClientListEditItem(this, index, text, value, imageUrl); 2795 this.items.push(item); 2796 }, 2797 GetItem: function(index){ 2798 return (0 <= index && index < this.items.length) ? this.items[index] : null; 2799 }, 2800 ChangeEnabledAttributes: function(enabled){ 2801 if(!this.CheckableElementsExist()) { 2802 for(var i = 0; i < this.GetItemCount(); i++){ 2803 var element = this.GetItemInput(i); 2804 if(element){ 2805 this.ChangeItemEnabledAttributes(element, _aspxChangeAttributesMethod(enabled)); 2806 element.disabled = !enabled; 2807 } 2808 } 2809 } else { 2810 var selectedIndex = this.GetSelectedIndexInternal(); 2811 this.UpdateCheckableElementDecorations(selectedIndex, enabled); 2812 } 2813 }, 2814 ChangeEnabledStateItems: function(enabled){ 2815 aspxGetStateController().SetElementEnabled(this.GetMainElement(), enabled); 2816 if(this.isNative){ 2817 for(var i = 0; i < this.GetItemCount(); i++){ 2818 var element = this.GetItemInput(i); 2819 if(element) 2820 aspxGetStateController().SetElementEnabled(element, enabled); 2821 } 2822 } 2823 }, 2824 ChangeItemEnabledAttributes: function(element, method){ 2825 method(element, "onclick"); 2826 } 2827}); 2828ASPxClientRadioButtonList = _aspxCreateClass(ASPxClientCheckListBase, { 2829 constructor: function(name) { 2830 this.constructor.prototype.constructor.call(this, name); 2831 this.isASPxClientRadioButtonList = true; 2832 }, 2833 InlineInitialize: function() { 2834 var selectedIndex = this.GetSelectedIndex(); 2835 this.UpdateHiddenInputs(selectedIndex);
2836 if(this.CheckableElementsExist()) 2837 this.CreateButtonInternalCollection(); 2838 this.SetSelectedIndex(this.GetSelectedIndex()); 2839 ASPxClientCheckListBase.prototype.InlineInitialize.call(this); 2840 }, 2841 Initialize: function() { 2842 ASPxClientCheckListBase.prototype.Initialize.call(this); 2843 }, 2844 PrepareInternalButton: function(internalRadioButton){ 2845 internalRadioButton.autoSwitchEnabled = false; 2846 }, 2847 GetInputElement: function() { 2848 if(this.isNative) { 2849 var index = this.GetSelectedIndexInternal(); 2850 return this.GetItemInput(index); 2851 } else 2852 return this.GetValueInputElement(); 2853 }, 2854 GetValueInputElement: function() { 2855 if(this.valueInput == null) { 2856 this.valueInput = _aspxCreateHiddenField(null, this.name + "_ValueInput"); 2857 var stateInput = this.FindStateInputElement(); 2858 stateInput.parentNode.insertBefore(this.valueInput, stateInput); 2859 } 2860 return this.valueInput; 2861 }, 2862 GetValueInputToValidate: function() { 2863 return this.GetValueInputElement(); 2864 }, 2865 SelectIndexSilent: function(index) { 2866 var itemCount = this.GetItemCount(); 2867 var isValidIndex = (-1 <= index && index < itemCount); 2868 if(isValidIndex) { 2869 if(this.CheckableElementsExist()) 2870 this.UpdateCheckableElementDecorations(index, this.GetEnabled()); 2871 else { 2872 for(var i = 0; i < itemCount; i++) { 2873 var element = this.GetItemInput(i); 2874 if(element) 2875 element.checked = (i == index); 2876 } 2877 } 2878 this.SetSelectedIndexInternal(index); 2879 this.UpdateHiddenInputs(index); 2880 } 2881 }, 2882 UpdateCheckableElementDecorations: function(selectedIndex, enabled) { 2883 if(this.CheckableElementsExist()) { 2884 for(var i = 0; i < this.items.length; i++) { 2885 var inputElement = this.GetItemInput(i); 2886 var internalButton = this.internalButtonCollection.Get(inputElement.id); 2887 internalButton.SetEnabled(enabled); 2888 internalButton.SetValue(i == selectedIndex ? ASPxClientCheckBoxInputKey.Checked : ASPxClientCheckBoxInputKey.Unchecked); 2889 } 2890 } 2891 }, 2892 UpdateFocus: function() { 2893 var index = this.GetSelectedIndexInternal(); 2894 if(index == -1) 2895 index = 0; 2896 var itemElement = this.GetItemInput(index); 2897 if (itemElement != null && _aspxGetActiveElement() != itemElement && _aspxIsEditorFocusable(itemElement)) 2898 _aspxSetFocus(itemElement); 2899 }, 2900 OnItemClick: function(index) { 2901 if(this.GetSelectedIndexInternal() != index) { 2902 this.SelectIndexSilent(index); 2903 this.RaisePersonalStandardValidation(); 2904 this.OnValueChanged(); 2905 } 2906 this.UpdateFocus(); 2907 } 2908}); 2909ASPxClientRadioButtonList.Cast = ASPxClientControl.Cast; 2910ASPxClientCheckBoxList = _aspxCreateClass(ASPxClientCheckListBase, { 2911 constructor: function(name) { 2912 this.constructor.prototype.constructor.call(this, name); 2913 this.selectionEventsLockCount = 0; 2914 }, 2915 InlineInitialize: function() { 2916 if(this.CheckableElementsExist()) 2917 this.CreateButtonInternalCollection(); 2918 ASPxClientCheckListBase.prototype.InlineInitialize.call(this); 2919 }, 2920 Initialize: function() { 2921 ASPxClientCheckListBase.prototype.Initialize.call(this); 2922 this.InitSelection(); 2923 }, 2924 InitSelection: function() { 2925 this.SelectIndices(this.initSelectedIndices); 2926 this.CacheValue(); 2927 }, 2928 PrepareInternalButton: function(internalCheckBox, index){ 2929 internalCheckBox.autoSwitchEnabled = true; 2930 internalCheckBox.SetChecked(this.GetItemSelectionHelper().GetIsItemSelected(index)); 2931 }, 2932 SelectIndexSilent: function(index) { 2933 var itemCount = this.GetItemCount(); 2934 var isValidIndex = (-1 <= index && index < itemCount); 2935 if(isValidIndex) { 2936 this.UpdateHiddenInputs(index); 2937 } 2938 }, 2939 UpdateCheckableElementDecorations: function(selectedIndex, enabled) { 2940 if(this.CheckableElementsExist()) { 2941 for(var i = 0; i < this.items.length; i++) { 2942 var inputElement = this.GetItemInput(i); 2943 var internalButton = this.internalButtonCollection.Get(inputElement.id); 2944 internalButton.SetEnabled(enabled); 2945 } 2946 } 2947 }, 2948 SetSelectionDecoration: function(index, selected){ 2949 if(this.CheckableElementsExist()){ 2950 var inputElement = this.GetItemInput(index); 2951 var internalButton = this.internalButtonCollection.Get(inputElement.id); 2952 internalButton.SetValue(selected ? ASPxClientCheckBoxInputKey.Checked : ASPxClientCheckBoxInputKey.Unchecked); 2953 } else { 2954 var element = this.GetItemInput(index); 2955 if(element) 2956 element.checked = (selected); 2957 } 2958 }, 2959 OnItemClick: function(index) {
2960 this.GetItemSelectionHelper().OnItemClick(index); 2961 }, 2962 UpdateFocus: function() { 2963 var index = this.GetItemSelectionHelper().GetFocusedItemIndex(); 2964 if(index == -1) 2965 index = this.GetSelectedIndexInternal(); 2966 if(index == -1) 2967 index = 0; 2968 var itemElement = this.GetItemInput(index); 2969 if (itemElement != null && _aspxGetActiveElement() != itemElement && _aspxIsEditorFocusable(itemElement)) 2970 _aspxSetFocus(itemElement); 2971 }, 2972 UpdateInternalState: function(){ 2973 this.UpdateHiddenInputs(); 2974 }, 2975 IsUpdateHiddenInputsLocked: function(){ 2976 return this.GetItemSelectionHelper().IsUpdateInternalSelectionStateLocked(); 2977 }, 2978 UpdateHiddenInputs: function(){ 2979 if(this.IsUpdateHiddenInputsLocked()) 2980 return; 2981 var element = this.FindStateInputElement(); 2982 if(_aspxIsExistsElement(element)) { 2983 var sb = [ ]; 2984 var serialiser = this.GetSerializingHelper(); 2985 var selectedIndices = this.GetSelectedIndices(); 2986 for(var i = 0; i < selectedIndices.length; i++) 2987 serialiser.SerializeAtomValue(sb, selectedIndices[i]); 2988 element.value = sb.join(""); 2989 } 2990 }, 2991 GetSerializingHelper: function(){ 2992 if(this.serializingHelper == null) 2993 this.serializingHelper = new _aspxListBoxBaseItemsSerializingHelper(this); 2994 return this.serializingHelper; 2995 }, 2996 SetItemSelectionAppearance: function(index, selected, controller){ 2997 }, 2998 LockSelectionEvents: function(){ 2999 this.selectionEventsLockCount++; 3000 }, 3001 UnlockSelectionEvents: function(){ 3002 this.selectionEventsLockCount--; 3003 }, 3004 IsSelectionEventsLocked: function(){ 3005 return this.selectionEventsLockCount > 0; 3006 }, 3007 CacheValue: function(){ 3008 this.cachedValue = this.GetValue(); 3009 }, 3010 IsValueChanged: function(){ 3011 return this.cachedValue != this.GetValue(); 3012 }, 3013 OnItemSelectionChanged: function(index, selected){ 3014 this.SetSelectionDecoration(index, selected); 3015 if (!this.IsSelectionEventsLocked()) { 3016 this.SetRaiseSelectedIndexChangedArguments(this.autoPostBack, index, selected); 3017 var valueChanged = this.IsValueChanged(); 3018 if (valueChanged) { 3019 this.RaisePersonalStandardValidation(); 3020 this.OnValueChanged(); 3021 } else { 3022 if(this.RaiseSelectedIndexChanged()) 3023 this.SendPostBackInternal(""); 3024 } 3025 } 3026 this.CacheValue(); 3027 }, 3028 SetRaiseSelectedIndexChangedArguments: function(processOnServer, index, selected){ 3029 this.selectedIndexChangedArguments = { 3030 processOnServer: processOnServer, 3031 index: index, 3032 selected: selected 3033 }; 3034 }, 3035 GetRaiseSelectedIndexChangedArguments: function(){ 3036 if(!this.selectedIndexChangedArguments) 3037 this.SetRaiseSelectedIndexChangedArguments(false, this.GetSelectedIndex(), true); 3038 return this.selectedIndexChangedArguments; 3039 }, 3040 RaiseSelectedIndexChanged: function(processOnServer){ 3041 var savedArgs = this.GetRaiseSelectedIndexChangedArguments(); 3042 processOnServer = savedArgs.processOnServer || processOnServer; 3043 if(!this.SelectedIndexChanged.IsEmpty()){ 3044 var args = new ASPxClientListEditItemSelectedChangedEventArgs(savedArgs.index, savedArgs.selected, processOnServer); 3045 this.SelectedIndexChanged.FireEvent(this, args); 3046 processOnServer = args.processOnServer; 3047 } 3048 return processOnServer; 3049 }, 3050 GetItemSelectionHelper: function(){ 3051 if(!this.itemSelectionHelper) 3052 this.itemSelectionHelper = this.CreateItemSelectionHelper(); 3053 return this.itemSelectionHelper; 3054 }, 3055 CreateItemSelectionHelper: function(){ 3056 return new _aspxCheckBoxListMultiSelectionHelper(this); 3057 }, 3058 GetItem: function(index){ 3059 var item = ASPxClientCheckListBase.prototype.GetItem.call(this, index); 3060 item.selected = this.GetItemSelectionHelper().GetIsItemSelected(index); 3061 return item; 3062 }, 3063 SetValue: function(value){ 3064 var index = this.FindItemIndexByValue(value); 3065 this.SetSelectedIndex(index); 3066 }, 3067 GetSelectedIndexInternal: function(){ 3068 if(!this.isInitialized) 3069 return ASPxClientCheckListBase.prototype.GetSelectedIndexInternal.call(this); 3070 return this.GetItemSelectionHelper().GetSelectedIndex(); 3071 }, 3072 SetSelectedIndex: function(index){ 3073 this.LockSelectionEvents(); 3074 this.GetItemSelectionHelper().SetSelectedIndex(index); 3075 this.UnlockSelectionEvents(); 3076 }, 3077 GetSelectedIndices: function(){ 3078 return this.GetItemSelectionHelper().GetSelectedIndices(); 3079 }, 3080 GetSelectedValues: function(){ 3081 return this.GetItemSelectionHelper().GetSelectedValues();
3082 }, 3083 GetSelectedItems: function(){ 3084 return this.GetItemSelectionHelper().GetSelectedItems(); 3085 }, 3086 SelectAll: function(){ 3087 this.SelectIndices(); 3088 }, 3089 UnselectAll: function(){ 3090 this.UnselectIndices(); 3091 }, 3092 SelectIndices: function(indices){ 3093 this.LockSelectionEvents(); 3094 this.GetItemSelectionHelper().SelectIndices(indices); 3095 this.UnlockSelectionEvents(); 3096 }, 3097 SelectItems: function(items){ 3098 this.LockSelectionEvents(); 3099 this.GetItemSelectionHelper().SelectItems(items); 3100 this.UnlockSelectionEvents(); 3101 }, 3102 SelectValues: function(values){ 3103 this.LockSelectionEvents(); 3104 this.GetItemSelectionHelper().SelectValues(values); 3105 this.UnlockSelectionEvents(); 3106 }, 3107 UnselectIndices: function(indices){ 3108 this.LockSelectionEvents(); 3109 this.GetItemSelectionHelper().UnselectIndices(indices); 3110 this.UnlockSelectionEvents(); 3111 }, 3112 UnselectItems: function(items){ 3113 this.LockSelectionEvents(); 3114 this.GetItemSelectionHelper().UnselectItems(items); 3115 this.UnlockSelectionEvents(); 3116 }, 3117 UnselectValues: function(values){ 3118 this.LockSelectionEvents(); 3119 this.GetItemSelectionHelper().UnselectValues(values); 3120 this.UnlockSelectionEvents(); 3121 } 3122}); 3123ASPxClientCheckBoxList.Cast = ASPxClientControl.Cast; 3124ASPxClientListEditItemSelectedChangedEventArgs = _aspxCreateClass(ASPxClientProcessingModeEventArgs, { 3125 constructor: function(index, isSelected, processOnServer){ 3126 this.constructor.prototype.constructor.call(this, processOnServer); 3127 this.index = index; 3128 this.isSelected = isSelected; 3129 } 3130}); 3131function aspxLBTSelectStart(evt){ 3132 var element = _aspxGetEventSource(evt); 3133 var shiftPressed = evt.shiftKey; 3134 var ctrlKey = evt.ctrlKey || evt.metaKey; 3135 if(shiftPressed || ctrlKey){ 3136 _aspxClearSelection(); 3137 _aspxPreventEventAndBubble(evt); 3138 } 3139} 3140function aspxLBIClick(evt){ 3141 if(ASPxClientTouchUI.isMouseEventFromScrolling) return; 3142 var element = _aspxGetEventSource(evt); 3143 while(element != null && element.tagName != "BODY"){ 3144 if(element.tagName == "TR"){ 3145 var table = element.offsetParent; 3146 if(table && table.ListBoxId){ 3147 var lb = aspxGetControlCollection().Get(table.ListBoxId); 3148 if(lb != null) { 3149 var retValue; 3150 if(evt.type == "dblclick") 3151 retValue =lb.OnItemDblClick(); 3152 else if(!lb.isComboBoxList || _aspxGetIsLeftButtonPressed(evt)) 3153 retValue = lb.OnItemClick(element.rowIndex, evt); 3154 if(typeof(retValue) != "undefined") 3155 return retValue; 3156 } 3157 break; 3158 } 3159 } 3160 element = element.parentNode; 3161 } 3162} 3163function aspxNLBIDClick(evt){ 3164 var element = _aspxGetEventSource(evt); 3165 if(element != null && element.tagName == "SELECT"){ 3166 var lb = aspxGetControlCollection().Get(element.id); 3167 if(lb != null) 3168 lb.OnItemDblClick(); 3169 } 3170} 3171function aspxLBScroll(evt){ 3172 var sourceId = _aspxGetEventSource(evt).id; 3173 if(sourceId.slice(-__aspxLBDSuffix.length) == __aspxLBDSuffix){ 3174 var name = sourceId.slice(0, -2); 3175 var lb = aspxGetControlCollection().Get(name); 3176 if(lb != null && lb.isInitialized) 3177 lb.OnScroll(); 3178 } 3179} 3180function aspxLBCorrectSizeByTimer(name){ 3181 var lb = aspxGetControlCollection().Get(name); 3182 if(lb != null) 3183 lb.OnCorrectSizeByTimer(); 3184} 3185function aspxERBLIClick(name, index) { 3186 var list = aspxGetControlCollection().Get(name); 3187 if(list != null) 3188 list.OnItemClick(index); 3189} 3190function aspxERBLICancel(name) { 3191 var list = aspxGetControlCollection().Get(name); 3192 if(list != null) 3193 list.OnItemClickReadonly(); 3194} 3195
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.