1ASPx.IS(function(ASPx, dx, DevExpress){ 2(function() { 3var currentSelectedItemCallbackPrefix = "CBSI"; 4var loadDropDownOnDemandCallbackPrefix = "CBLD"; 5var listBoxNameSuffix = "_L"; 6var comboBoxValueInputSuffix = "VI"; 7var ASPxClientComboBoxBase = ASPx.CreateClass(ASPxClientDropDownEditBase, { 8 constructor: function(name) { 9 this.constructor.prototype.constructor.call(this, name); 10 this.lbEventLockCount = 0; 11 this.receiveGlobalMouseWheel = false; 12 this.collectCallbackIDs = false; 13 this.callbackIDs = { }; 14 this.callbackIDsToReset = { }; 15 this.listBox = null; 16 this.lastSuccessValue = ""; 17 this.islastSuccessValueInit = false; 18 this.SelectedIndexChanged = new ASPxClientEvent(); 19 }, 20 Initialize: function(){ 21 this.InitializeListBoxOwnerName(); 22 ASPxClientDropDownEditBase.prototype.Initialize.call(this); 23 this.InitLastSuccessValue(); 24 }, 25 InitializeListBoxOwnerName: function(){ 26 var lb = this.GetListBoxControl(); 27 if(lb) 28 lb.ownerName = this.name; 29 }, 30 InitLastSuccessValue: function(){ 31 this.SetLastSuccessValue(this.GetValue()); 32 }, 33 SetLastSuccessValue: function (value) { 34 if(this.convertEmptyStringToNull && value === "") 35 value = null; 36 this.lastSuccessValue = value; 37 this.islastSuccessValueInit = true; 38 }, 39 GetDropDownInnerControlName: function(suffix){ 40 return ""; 41 }, 42 CreateAccessibilityHelper: function() { 43 return new AccessibilityHelperComboBox(this); 44 }, 45 GetListBoxControl: function(){ 46 if(!ASPx.IsExists(this.listBox)){ 47 var name = this.GetDropDownInnerControlName(listBoxNameSuffix); 48 this.listBox = ASPx.GetControlCollection().Get(name); 49 } 50 if(this.isNative || (this.listBox && !!this.listBox.GetMainElement())) 51 return this.listBox; 52 return null; 53 }, 54 GetCallbackArguments: function(){ 55 return this.GetListBoxCallbackArguments(); 56 }, 57 GetListBoxCallbackArguments: function(){ 58 var lb = this.GetListBoxControl(); 59 return lb.GetCallbackArguments(); 60 }, 61 SendCallback: function(onSuccess) { 62 var callbackID = this.CreateCallback(this.GetCallbackArguments(), null, onSuccess); 63 this.OnCreateCallback(callbackID); 64 }, 65 SendSpecialCallback: function(args, handler) { 66 var callbackID = this.CreateCallback(args, null, handler); 67 this.OnCreateCallback(callbackID); 68 }, 69 OnCreateCallback: function(callbackID) { 70 if(this.collectCallbackIDs) 71 this.callbackIDs[callbackID] = true; 72 this.UnlockDoEndCallback(); 73 }, 74 CanProcessCallbackResult: function(callbackID) { 75 var result = !this.collectCallbackIDs || !this.callbackIDsToReset[callbackID]; 76 delete this.callbackIDs[callbackID]; 77 delete this.callbackIDsToReset[callbackID]; 78 if(!result) 79 this.LockDoEndCallback(); 80 return result; 81 }, 82 LockDoEndCallback: function() { 83 this.lockDoEndCallback = true; 84 this.lockDoEndCallbackTimerId = window.setTimeout(function() { this.lockDoEndCallback = false; }.bind(this), 200); 85 }, 86 UnlockDoEndCallback: function() { 87 this.lockDoEndCallback = false; 88 ASPx.Timer.ClearTimer(this.lockDoEndCallbackTimerId); 89 }, 90 IsDoEndCallbackLocked: function() { 91 return !!this.lockDoEndCallback; 92 }, 93 ResetWaitingCallbacks: function() { 94 var ids = Object.keys(this.callbackIDs); 95 if(ids.length === 0) return; 96 ids.forEach(function(id) { this.callbackIDsToReset[id] = true; }.bind(this)); 97 this.callbackIDs = { }; 98 this.requestCount = 0; 99 ASPx.GetControlCollection().ResetRequestCount(); 100 this.CancelCallbackInternal(); 101 }, 102 SetReadOnlyInternal: function(readOnly) { 103 ASPxClientDropDownEditBase.prototype.SetReadOnlyInternal.call(this, readOnly); 104 var lb = this.GetListBoxControl(); 105 if(lb) 106 lb.SetReadOnly(readOnly); 107 }, 108 SetText: function(text){ 109 var lb = this.GetListBoxControl(); 110 var index = this.GetAdjustedSelectedIndexByText(lb, text); 111 var isAllowNullValue = !this.isDropDownListStyle || this.allowNull; 112 var isChangingTextInEmpty = index < 0 && !text && this.lastSuccessText !== text; 113 if(isAllowNullValue || !isChangingTextInEmpty) { 114 this.SelectIndex(index, false); 115 this.SetTextBase(text); 116 this.SetLastSuccessText(text); 117 this.SetLastSuccessValue(index >= 0 ? lb.GetValue() : text); 118 } 119 }, 120 GetValue: function(){ 121 var value = this.islastSuccessValueInit ? this.lastSuccessValue : this.GetValueInternal(); 122 if(this.convertEmptyStringToNull && value === "") 123 value = null; 124 return value; 125 }, 126 GetValueInternal: function(){ 127 var text = this.GetTextInternal(); 128 var textChanges = text != this.lastSuccessText; 129 if(textChanges){ 130 var lb = this.GetListBoxControl(); 131 if(lb){ 132 var index = this.GetAdjustedSelectedIndexByText(lb, text); 133 this.SelectIndexSilent(lb, index); 134 if(index != -1) 135 return lb.GetValue(); 136 } 137 } 138 return ASPxClientDropDownEditBase.prototype.GetValue.call(this); 139 }, 140 GetLastSuccesfullValue: function() { 141 return this.GetValue(); 142 }, 143 GetSetValueOptimizeHelper: function () { 144 this.setValueOptimizeHelper = this.setValueOptimizeHelper || new setValueOptimizeHelper(); 145 return this.setValueOptimizeHelper; 146 }, 147 SetValue: function (value) { 148 this.GetSetValueOptimizeHelper().setValue(this, value); 149 if(this.accessibilityCompliant) 150 this.GetAccessibilityHelper().SetLabelAttribute(null, null); 151 }, 152 SetValueInternal: function(value) { 153 var lb = this.GetListBoxControl(); 154 if (lb) { 155 lb.SetValue(value); 156 var item = lb.GetSelectedItem(); 157 var text = item ? item.text : value; 158 this.OnSelectionChangedCore(text, item, false); 159 this.UpdateValueInput(); 160 } 161 }, 162 Clear: function() { 163 ASPxClientDropDownEditBase.prototype.Clear.call(this); 164 if(!this.GetListBoxControl()) 165 this.islastSuccessValueInit = false; 166 }, 167 GetFormattedText: function() { 168 return this.GetText(); 169 }, 170 GetAdjustedSelectedIndexByText: function(lb, text){ 171 if(!lb) 172 return -1; 173 var lbSelectedItem = lb.GetSelectedItem(); 174 if(lbSelectedItem != null && (lbSelectedItem.text == text || !this.isInitialized)) 175 return lbSelectedItem.index; 176 return this.FindItemIndexByText(lb, text); 177 }, 178 FindItemIndexByText: function(lb, text){ 179 if(lb) 180 return lb.FindItemIndexByText(text); 181 }, 182 CollectionChanged: function(){ 183 }, 184 HasChanges: function(){ 185 return false; 186 }, 187 SelectIndex: function(index, initialize){ 188 var lb = this.GetListBoxControl(); 189 if(!lb) 190 return false; 191 var isSelectionChanged = lb.SelectIndexSilentAndMakeVisible(index, initialize); 192 var item = lb.GetSelectedItem(); 193 var text = item != null ? item.text : ""; 194 if(isSelectionChanged || this.HasChanges()) 195 this.OnSelectionChangedCore(text, item, false); 196 this.UpdateValueInput(); 197 return isSelectionChanged; 198 }, 199 OnSelectChanged: function(){ 200 if(this.lbEventLockCount > 0) return; 201 var lb = this.GetListBoxControl(); 202 var item = lb.GetSelectedItem(); 203 var text = item != null ? item.text : ""; 204 this.OnSelectionChangedCore(text, item, false); 205 this.OnChange(); 206 }, 207 OnSelectionChangedCore: function(text, item, canBeRolledBack){ 208 this.SetTextBase(text); 209 this.ShowItemImage(item); 210 if(!canBeRolledBack){ 211 this.SetLastSuccessText(text); 212 this.SetLastSuccessValue(item != null ? item.value : text); 213 } 214 }, 215 ShowItemImageByIndex: function(index){ 216 var item = this.GetItem(index); 217 this.ShowItemImage(item); 218 }, 219 ShowCurrentItemImage: function() { 220 var selectedItem = this.GetSelectedItem(); 221 this.ShowItemImage(selectedItem); 222 }, 223 ShowItemImage: function(item){ 224 var imageUrl = item != null ? item.imageUrl : ""; 225 this.SetSelectedImage(imageUrl); 226 }, 227 GetDropDownImageElement: function(){ 228 var itemImageCell = this.GetDropDownItemImageCell(); 229 if(itemImageCell != null) 230 return ASPx.GetNodeByTagName(itemImageCell, "IMG", 0); 231 return null; 232 }, 233 SetSelectedImage: function(imageUrl) { 234 var imgElement = this.GetDropDownImageElement(); 235 if(imgElement != null) { 236 var imageExists = imageUrl != ""; 237 imageUrl = imageExists ? imageUrl : ASPx.EmptyImageUrl; 238 imgElement.src = imageUrl; 239 var itemImageCell = this.GetDropDownItemImageCell(); 240 if(ASPx.GetElementDisplay(itemImageCell) != imageExists) 241 ASPx.SetElementDisplay(itemImageCell, imageExists); 242 } 243 }, 244 OnCallback: function(result) { 245 }, 246 OnChange: function(){ 247 this.UpdateValueInput(); 248 this.RaisePersonalStandardValidation(); 249 this.OnValueChanged(); 250 }, 251 UpdateValueInput: function() { 252 }, 253 RaiseValueChangedEvent: function() { 254 if(!this.isInitialized) return; 255 var processOnServer = ASPxClientTextEdit.prototype.RaiseValueChangedEvent.call(this); 256 processOnServer = this.RaiseSelectedIndexChanged(processOnServer); 257 return processOnServer; 258 }, 259 RaiseSelectedIndexChanged: function(processOnServer) { 260 if(!this.SelectedIndexChanged.IsEmpty()){ 261 var args = new ASPxClientProcessingModeEventArgs(processOnServer); 262 this.SelectedIndexChanged.FireEvent(this, args); 263 processOnServer = args.processOnServer; 264 } 265 return processOnServer; 266 }, 267 GetItemHtmlContent: function(index) { 268 var lb = this.GetListBoxControl(); 269 return lb && lb.GetItemHtmlContent(index); 270 }, 271 AddItem: function(texts, value, imageUrl, htmlContent, cssClass, tooltip) { 272 var index = this.GetListBoxControl().AddItem(texts, value, imageUrl, htmlContent, cssClass, tooltip); 273 this.CollectionChanged(); 274 return index; 275 }, 276 InsertItem: function(index, texts, value, imageUrl, htmlContent, cssClass, tooltip){ 277 this.GetListBoxControl().InsertItem(index, texts, value, imageUrl, htmlContent, cssClass, tooltip); 278 this.CollectionChanged(); 279 }, 280 RemoveItem: function(index){ 281 this.GetListBoxControl().RemoveItem(index); 282 this.CollectionChanged(); 283 }, 284 ClearItems: function(){ 285 this.GetListBoxControl().ClearItems();
286 this.ClearItemsInternal(); 287 }, 288 BeginUpdate: function(){ 289 this.GetListBoxControl().BeginUpdate(); 290 }, 291 EndUpdate: function(){ 292 this.GetListBoxControl().EndUpdate(); 293 this.CollectionChanged(); 294 }, 295 MakeItemVisible: function(index){ 296 }, 297 GetItem: function(index){ 298 var lb = this.GetListBoxControl(); 299 if(lb) 300 return this.GetItemCore(index); 301 else 302 return null; 303 }, 304 GetItemCore: function(index) { 305 return this.GetListBoxControl().GetItem(index); 306 }, 307 FindItemByText: function(text) { 308 var lb = this.GetListBoxControl(); 309 if(lb) 310 return lb.FindItemByText(text); 311 return null; 312 }, 313 FindItemByValue: function(value){ 314 var lb = this.GetListBoxControl(); 315 if(lb) 316 return lb.FindItemByValue(value); 317 return null; 318 }, 319 GetItemCount: function(){ 320 var lb = this.GetListBoxControl(); 321 if(lb) 322 return lb.GetItemCount(); 323 return 0; 324 }, 325 GetSelectedIndex: function(){ 326 var lb = this.GetListBoxControl(); 327 if(lb) 328 return lb.GetSelectedIndex(); 329 else 330 return -1; 331 }, 332 SetSelectedIndex: function(index){ 333 this.SelectIndex(index, false); 334 }, 335 GetSelectedItem: function(){ 336 var lb = this.GetListBoxControl(); 337 var index = lb.GetSelectedIndex(); 338 return lb.GetItem(index); 339 }, 340 SetSelectedItem: function(item){ 341 var index = (item != null) ? item.index : -1; 342 this.SelectIndex(index, false); 343 }, 344 GetText: function(){ 345 return this.lastSuccessText; 346 }, 347 PerformCallback: function(arg) { 348 }, 349 ClearItemsInternal: function(){ 350 this.SetValue(null); 351 this.CollectionChanged(); 352 }, 353 GetModifyEvent: function() { 354 if(this.isNative) 355 return this.SelectedIndexChanged; 356 else 357 return ASPxClientDropDownEditBase.prototype.GetModifyEvent.call(this); 358 } 359}); 360var ASPxClientComboBox = ASPx.CreateClass(ASPxClientComboBoxBase, { 361 constructor: function(name) { 362 this.constructor.prototype.constructor.call(this, name); 363 this.allowMultipleCallbacks = false; 364 this.allowNull = false; 365 this.isCallbackMode = false; 366 this.loadDropDownOnDemand = false; 367 this.needToLoadDropDown = false; 368 this.isPerformCallback = false; 369 this.changeSelectAfterCallback = 0; 370 this.incrementalFilteringMode = "Contains"; 371 this.filterStrategy = null; 372 this.filterTimer = ASPx.Browser.WebKitTouchUI ? 300 : 100; 373 this.filterMinLength = 0; 374 this.customFiltering = false; 375 this.initTextCorrectionRequired = false; 376 this.isDropDownListStyle = true; 377 this.defaultDropDownHeight = ""; 378 this.dropDownHeight = ""; 379 this.dropDownWidth = ""; 380 this.dropDownRows = 7; 381 this.enterKeyPressed = false; 382 this.onLoadDropDownOnDemandCallbackFinalizedEventHandler = null; 383 this.callBackCoreComplete = false; 384 this.adroidSamsungBugTimeout = 0; 385 this.isNeedToForceFirstShowLoadingPanel = true; 386 this.forceLoadCustomRangeOnDropDown = false; 387 this.needToInitPopupWindowOnShow = false; 388 this.ItemFiltering = new ASPxClientEvent(); 389 this.CustomHighlighting = new ASPxClientEvent(); 390 }, 391 Initialize: function(){ 392 this.needToLoadDropDown = this.loadDropDownOnDemand; 393 var lb = this.GetListBoxControl(); 394 this.InitializeListBoxOwnerName(); 395 this.InitScrollSpacerVisibility(); 396 this.InitializeFilterStrategy(); 397 var mainElement = this.GetMainElement(); 398 var input = this.GetInputElement(); 399 var ddbutton = this.GetDropDownButton(); 400 ASPx.Evt.AttachEventToElement(input, "paste", this.SyncRawValueIfHasTextDecorators.bind(this, true)); 401 if(this.isDropDownListStyle && ASPx.Browser.WindowsPlatform && ASPx.Browser.Safari) { 402 ASPx.Evt.AttachEventToElement(this.GetInputElement(), "blur", function() { 403 var inputElementValue = this.GetInputElement().value; 404 if(!this.focusEventsLocked && !inputElementValue && !!this.GetText()) 405 this.OnTextChanged(); 406 }.aspxBind(this)); 407 } 408 if(this.isToolbarItem) { 409 mainElement.unselectable="on"; 410 input.unselectable="on"; 411 if(input.offsetParent) 412 input.offsetParent.unselectable="on"; 413 if(ddbutton) 414 ddbutton.unselectable="on"; 415 if(lb) 416 lb.SetItemRowsUnselectable(); 417 } 418 this.RemoveRaisePSValidationFromListBox(); 419 this.RedirectStandardValidators(); 420 if(lb && lb.GetItemCount() > 0) 421 this.EnsureListBoxSelectionSynchronized(lb); 422 ASPxClientComboBoxBase.prototype.Initialize.call(this); 423 }, 424 InitScrollSpacerVisibility: function() { 425 var lb = this.GetListBoxControl(); 426 if(!lb || lb.GetItemCount() >= lb.callbackPageSize) 427 return; 428 lb.SetScrollSpacerVisibility(true, false); 429 lb.SetScrollSpacerVisibility(false, false); 430 }, 431 InitializeFilterStrategy: function() { 432 var fs = this.filterStrategy;
433 ASPx.Evt.AttachEventToElement(this.GetInputElement(), "keydown", fs.OnKeyDown.bind(fs)); 434 }, 435 CreateFilterStrategy: function() { 436 if(this.incrementalFilteringMode == "Contains") 437 return new ComboBoxContainsFilterStrategy(this); 438 else if(this.incrementalFilteringMode == "StartsWith") 439 return new ComboBoxStartsWithFilterStrategy(this); 440 else if(this.incrementalFilteringMode == "None") 441 return new ComboBoxDisabledFilterStrategy(this); 442 }, 443 shouldStartUserInputTimer: function() { 444 return true; 445 }, 446 onInputChangedOnUserInputTimer: function(onRestart) { 447 ASPxClientDropDownEditBase.prototype.onInputChangedOnUserInputTimer.call(this); 448 if (!onRestart) { 449 this.SyncRawValueIfHasTextDecorators(); 450 this.filterStrategy.OnInput(); 451 } 452 }, 453 RaiseItemFiltering: function(item, filter, isFit) { 454 if(!this.ItemFiltering.IsEmpty()) { 455 var args = new ASPxClientListEditItemFilteringEventArgs(item, filter, isFit); 456 this.ItemFiltering.FireEvent(this, args); 457 isFit = args.isFit; 458 } 459 return isFit; 460 }, 461 RaiseCustomHighlighting: function(filter, callbackHighlighting) { 462 if(!this.CustomHighlighting.IsEmpty()) { 463 var args = new ASPxClientListEditCustomHighlightingEventArgs(filter); 464 args.highlighting = callbackHighlighting; 465 this.CustomHighlighting.FireEvent(this, args); 466 return args.highlighting; 467 } 468 return callbackHighlighting; 469 }, 470 InlineInitialize: function() { 471 this.BeforeInlineInitialize(); 472 this.filterStrategy = this.CreateFilterStrategy(); 473 ASPxClientComboBoxBase.prototype.InlineInitialize.call(this); 474 }, 475 UseSpecialKeyboardHandling: function() { 476 return true; 477 }, 478 IsClearButtonVisibleAuto: function() { 479 return this.allowNull && ASPxClientComboBoxBase.prototype.IsClearButtonVisibleAuto.call(this); 480 }, 481 BeforeInlineInitialize: function() { 482 this.lastSuccessValue = this.GetDecodeValue(this.lastSuccessValue); 483 this.InsureInputValueCorrect(); 484 }, 485 InsureInputValueCorrect: function(){ 486 if(this.initTextCorrectionRequired){ 487 var lb = this.GetListBoxControl(); 488 if(lb){ 489 var initSelectedIndex = lb.GetSelectedIndexInternal(); 490 if(initSelectedIndex >= 0){ 491 var initSelectedText = lb.GetItem(initSelectedIndex).text; 492 var input = this.GetInputElement(); 493 if(ASPx.IsExists(this.GetRawValue()) && this.GetRawValue() != initSelectedText){ 494 this.SetRawValue(initSelectedText); 495 this.SetInputValue(this.GetDecoratedText(initSelectedText)); 496 } 497 else if(input.value != initSelectedText) 498 this.SetInputValue(initSelectedText); 499 } 500 } 501 } 502 }, 503 ChangeEnabledAttributes: function(enabled){ 504 ASPxClientComboBoxBase.prototype.ChangeEnabledAttributes.call(this, enabled); 505 var changeEventsMethod = ASPx.Attr.ChangeEventsMethod(enabled); 506 var mainElement = this.GetMainElement(); 507 if(mainElement) 508 changeEventsMethod(mainElement, ASPx.Evt.GetMouseWheelEventName(), aspxCBMouseWheel); 509 var btnElement = this.GetDropDownButton(); 510 if(btnElement) 511 changeEventsMethod(btnElement, "onmousemove", ASPx.CBDDButtonMMove); 512 }, 513 GetDropDownInnerControlName: function(suffix){ 514 return ASPxClientDropDownEditBase.prototype.GetDropDownInnerControlName.call(this, suffix); 515 }, 516 AdjustControlCore: function() { 517 ASPxClientEdit.prototype.AdjustControlCore.call(this); 518 this.ResetDropDownSizeCache(); 519 }, 520 RemoveRaisePSValidationFromListBox: function() { 521 var listBox = this.GetListBoxControl(); 522 if(listBox) 523 listBox.RaisePersonalStandardValidation = function() { }; 524 }, 525 RedirectStandardValidators: function() { 526 var valueInput = this.GetValueInput(); 527 if(ASPx.IsExistsElement(valueInput) && valueInput.Validators) { 528 for(var i = 0; i < valueInput.Validators.length; i++) 529 valueInput.Validators[i].controltovalidate = valueInput.id; 530 } 531 }, 532 GetValueInputToValidate: function(){ 533 return this.GetValueInput(); 534 }, 535 SetText: function(text, applyFilter) { 536 ASPxClientComboBoxBase.prototype.SetText.call(this, text); 537 if(applyFilter) 538 this.filterStrategy.Filtering(true); 539 }, 540 SetTextBase: function(text) { 541 ASPxClientComboBoxBase.prototype.SetTextBase.call(this, text); 542 this.restartCurrentUserInputTimer(); 543 }, 544 SetReadOnly: function(readOnly) { 545 if(this.isDropDownListStyle && this.incrementalFilteringMode === "None") 546 return; 547 ASPxClientComboBoxBase.prototype.SetReadOnly.call(this, readOnly); 548 }, 549 GetValueInput: function(){ 550 return document.getElementById(this.name + "_" + comboBoxValueInputSuffix); 551 }, 552 GetListBoxScrollDivElement: function(){ 553 return this.GetListBoxControl().GetScrollDivElement(); 554 }, 555 RollbackValueInputValue: function(){ 556 var inputElement = this.GetValueInput(); 557 if(inputElement) 558 inputElement.value = this.lastSuccessValue; 559 }, 560 UpdateValueInput: function() { 561 var inputElement = this.GetValueInput(); 562 if(inputElement) { 563 var value = this.GetValue(); 564 if(ASPx.Ident.IsDate(value)) 565 value = value.toISOString(); 566 inputElement.value = value != null ? value : ""; 567 } 568 }, 569 SetInputValue: function(value) { 570 var inputElement = this.GetInputElement(); 571 if(inputElement) { 572 inputElement.value = value; 573 this.restartCurrentUserInputTimer(); 574 } 575 },
576 CollectionChanged: function(filtering){ 577 this.GetSetValueOptimizeHelper().onItemCollectionChanged(); 578 var listBox = this.GetListBoxControl(); 579 listBox.CollectionChanged(filtering); 580 var needUpdateDropDownPositionAndSize = listBox.APILockCount == 0 && (this.isShownAtFirst || this.pcIsShowingNow); 581 if(needUpdateDropDownPositionAndSize) 582 this.UpdateDropDownPositionAndSize(); 583 }, 584 UpdateDropDownPositionAndSize: function(){ 585 this.InitDropDownSize(); 586 if(this.droppedDown){ 587 var pc = this.GetPopupControl(); 588 if(pc) 589 pc.UpdatePositionAtElement(this.GetMainElement()); 590 } 591 if(!this.clientVisible) 592 this.ResetControlAdjustment(); 593 }, 594 GetDropDownHeight: function(){ 595 if(this.ddHeightCache != ASPx.InvalidDimension) 596 return this.ddHeightCache; 597 this.EnsureDropDownWidth(); 598 return this.AdjustListBoxHeight(); 599 }, 600 GetDropDownWidth: function(){ 601 return (this.ddWidthCache != ASPx.InvalidDimension && !this.GetIsControlWidthWasChanged()) ? this.ddWidthCache : this.AdjustListBoxWidth(); 602 }, 603 EnsureDropDownWidth: function() { 604 this.GetDropDownWidth(); 605 }, 606 InitDropDownSize: function() { 607 if(!this.enabled || this.GetItemCount() == 0) return; 608 var pc = this.GetPopupControl(); 609 if(pc && this.IsDisplayed() && !this.IsHidden()) { 610 var pcwElement = pc.GetCurrentWindowElement(); 611 if(ASPx.IsExistsElement(pcwElement)){ 612 var isPcwDisplayed = ASPx.GetElementDisplay(pcwElement); 613 if(!isPcwDisplayed) 614 pc.SetWindowDisplay(-1, true); 615 var listBoxHeight = this.AdjustListBoxHeight(); 616 var listBoxWidth = this.AdjustListBoxWidth(); 617 if(listBoxHeight != this.ddHeightCache || listBoxWidth != this.ddWidthCache){ 618 this.ddHeightCache = listBoxHeight; 619 this.ddWidthCache = listBoxWidth; 620 pc.SetSize(this.ddWidthCache, this.ddHeightCache); 621 pc.SetIsDragged(-1, false); 622 pc.ShowAtElement(this.GetMainElement(), true); 623 } 624 if(!isPcwDisplayed) { 625 pc.SetWindowDisplay(-1, false); 626 pc.DoHideWindowModalElement(pcwElement); 627 } 628 } 629 } else { 630 this.needToInitPopupWindowOnShow = true; 631 } 632 }, 633 InitMainElementCache: function(){ 634 this.mainElementWidthCache = this.GetMainElement().clientWidth; 635 }, 636 GetDefaultDropDownHeight: function(listHeight, count){ 637 if(this.defaultDropDownHeight == ""){ 638 this.defaultDropDownHeight = ((listHeight / count) * this.dropDownRows) + "px"; 639 } 640 return this.defaultDropDownHeight; 641 }, 642 AdjustListBoxHeight: function () { 643 return this.GetListBoxControl().AdjustHeightInDropDown(this.dropDownHeight, this.dropDownRows); 644 }, 645 AdjustListBoxWidth: function () { 646 this.InitMainElementCache(); 647 return this.GetListBoxControl().AdjustWidthInDropDown(this.GetMainElement(), this.isCallbackMode, this.dropDownWidth); 648 }, 649 SelectIndexSilent: function(lb, index, lockScrollingToItem){ 650 this.lbEventLockCount ++; 651 lb.SelectIndexSilentAndMakeVisible(index, lockScrollingToItem); 652 this.ShowItemImageByIndex(index); 653 this.lbEventLockCount --; 654 }, 655 GetDecoratedText: function(text) { 656 var result; 657 var lb = this.GetListBoxControl(); 658 var hasMultiColumnFormattedSelectedItem = this.displayFormat != null && 659 lb && lb.IsMultiColumn() && 660 this.GetSelectedItem() != null; 661 if(hasMultiColumnFormattedSelectedItem) 662 result = this.GetMultiColumnFormattedSelectedItemText(lb); 663 else 664 result = ASPxClientComboBoxBase.prototype.GetDecoratedText.call(this, text); 665 return result; 666 }, 667 GetMultiColumnFormattedSelectedItemText: function(lb) { 668 var selectedItem = this.GetSelectedItem(); 669 var textColumnCount = this.GetTextColumnCountForTextDecoration(lb, selectedItem); 670 var texts = [textColumnCount]; 671 for(var i = 0; i < textColumnCount; i++) 672 texts[i] = selectedItem.GetColumnTextByIndex(i); 673 return ASPx.Formatter.Format(this.displayFormat, texts); 674 }, 675 GetTextColumnCountForTextDecoration: function(lb, item) { 676 return lb.GetItemTextCellCount(); 677 }, 678 CanApplyNullTextDecoration: function() { 679 var result; 680 if(this.GetListBoxControl() || !this.loadDropDownOnDemand) { 681 var value = this.isInitialized ? this.GetRawValue() : this.GetValue(); 682 var isValueNull = this.convertEmptyStringToNull && value === "" ? true : value === null; 683 result = this.GetSelectedIndex() == -1 && isValueNull; 684 } else 685 result = this.GetCurrentText() === ""; 686 return result; 687 }, 688 ForceTextChanged: function() { 689 if(this.isCallbackMode && this.filterStrategy) 690 this.filterStrategy.ClearFilterApplied(); 691 ASPxClientComboBoxBase.prototype.ForceTextChanged.call(this); 692 }, 693 ShowDropDownArea: function(isRaiseEvent){ 694 if(this.needToLoadDropDown) { 695 this.EnsureDropDownLoaded(); 696 return; 697 } 698 if(this.RequireLoadCustomRangeOnDropDown()){ 699 this.LoadCustomItemsRange(); 700 return; 701 } 702 var lb = this.GetListBoxControl(); 703 if(!lb || (!this.isDropDownModal() && !lb.GetItemCount())) 704 return; 705 if(!this.filterStrategy.IsFilterMeetRequirementForMinLength() && !this.isDropDownModal()) { 706 this.DropDownButtonPop(true); 707 return; 708 } 709 if(this.needToInitPopupWindowOnShow) { 710 this.needToInitPopupWindowOnShow = false; 711 this.InitDropDownSize(); 712 } 713 ASPxClientDropDownEditBase.prototype.ShowDropDownArea.call(this, isRaiseEvent); 714 this.EnsureListBoxSelectionSynchronized(lb); 715 this.EnsureSelectedItemVisibleOnShow(lb); 716 lb.CallbackSpaceInit(); 717 if(this.accessibilityCompliant) 718 this.GetAccessibilityHelper().SetExpandedState(true); 719 if(!lb.GetItemCount()) 720 this.onNoResultsFiltering(); 721 if(!this.filterStrategy.IsFilterMeetRequirementForMinLength()) 722 this.onProcessFilterLessMinLength(); 723 }, 724 ForceShowLoadingPanel: function() { 725 if(this.GetItemCount() == 0 && !this.needToLoadDropDown) { 726 var lb = this.GetListBoxControl(); 727 if(lb) { 728 var sizes = { width: this.GetWidth(), height: 100 }; 729 ASPxClientDropDownEditBase.prototype.ShowDropDownArea.call(this, false, sizes); 730 lb.SetHeight(sizes.height); 731 lb.SetWidth(sizes.width); 732 } 733 } 734 }, 735 FireFoxRequiresCacheScrollBar: function(){ 736 return ASPx.Browser.Firefox && ASPx.Browser.Version >= 3.6; 737 }, 738 BrowserRequiresCacheScrollBar: function(){ 739 return ASPx.Browser.WebKitFamily || ASPx.Browser.Opera || this.FireFoxRequiresCacheScrollBar(); 740 }, 741 HideDropDownArea: function(isRaiseEvent){ 742 if(this.filterStrategy) 743 this.filterStrategy.OnDropDownHideArea(); 744 if(this.BrowserRequiresCacheScrollBar()) 745 this.CachedScrollTop(); 746 ASPxClientDropDownEditBase.prototype.HideDropDownArea.call(this, isRaiseEvent); 747 if(this.accessibilityCompliant) 748 this.GetAccessibilityHelper().SetExpandedState(false); 749 }, 750 EnsureSelectedItemTextSynchronized: function(){ 751 var selectedItem = this.GetSelectedItem(); 752 if(!this.CanSynchronizeSelectedItemText(selectedItem)) 753 return; 754 var textUnsynchronized = this.GetText() !== selectedItem.text; 755 var textDecorationUnsynchronized = this.HasTextDecorators() && this.CanApplyTextDecorators() && 756 this.GetDecoratedText(selectedItem.text) !== this.GetInputElement().value; 757 if(textUnsynchronized || textDecorationUnsynchronized || !this.IsImageSynchronized(selectedItem)) { 758 this.SetTextBase(selectedItem.text); 759 this.ShowItemImage(selectedItem); 760 this.SetLastSuccessText(selectedItem.text); 761 this.UpdateValueInput(); 762 } 763 }, 764 IsImageSynchronized: function(selectedItem) { 765 var ddImageElement = this.GetDropDownImageElement(); 766 var imageUrl = selectedItem.imageUrl != "" ? selectedItem.imageUrl : ASPx.Url.GetAbsoluteUrl(ASPx.EmptyImageUrl); 767 return !ddImageElement || ASPx.ImageUtils.GetImageSrc(ddImageElement) === imageUrl; 768 }, 769 CanSynchronizeSelectedItemText: function(selectedItem) { 770 return !!selectedItem; 771 }, 772 EnsureListBoxSelectionSynchronized: function(listBox){ 773 var rawText = this.GetTextInternal(); 774 var lbItem = listBox.GetSelectedItem(); 775 var lbText = lbItem != null ? lbItem.text : ""; 776 var isTextsExist = rawText != null && lbText != ""; 777 var needSynchronize = rawText != lbText || !this.isInitialized; 778 if(needSynchronize && isTextsExist) { 779 this.SynchronizeListBoxSelection(listBox, rawText); 780 if(!this.isInitialized && this.IsValueRestoredByBrowser()) 781 this.SynchronizeListBoxInitSelection(); 782 } 783 }, 784 SynchronizeListBoxSelection: function(listBox, rawText) { 785 var newSelectedIndex = this.GetAdjustedSelectedIndexByText(listBox, rawText); 786 listBox.SelectIndexSilent(newSelectedIndex, false); 787 }, 788 SynchronizeListBoxInitSelection: function() { 789 setTimeout(function () { 790 var inputText = this.GetInputElement().value; 791 var selectedItem = this.FindItemByText(inputText); 792 if(selectedItem) 793 this.SelectIndex(selectedItem.index, true); 794 }.aspxBind(this), 0); 795 }, 796 EnsureSelectedItemVisibleOnShow: function(listBox){ 797 if(this.BrowserRequiresCacheScrollBar()) 798 listBox.RestoreScrollTopFromCache(); 799 listBox.EnsureSelectedItemVisible(); 800 }, 801 CachedScrollTop: function(){ 802 this.GetListBoxControl().CachedScrollTop(); 803 if(this.BrowserRequiresCacheScrollBar()){ 804 var scrollDiv = this.GetListBoxScrollDivElement(); 805 if(scrollDiv != null) 806 scrollDiv.scrollTop = 0; 807 } 808 }, 809 IsFilterEnabled: function() { 810 return this.incrementalFilteringMode != "None"; 811 }, 812 ChangeInputEnabled: function(element, enabled, readOnly){ 813 ASPxClientTextEdit.prototype.ChangeInputEnabled.call(this, element, enabled, readOnly || (this.isDropDownListStyle && !this.IsFilterEnabled())); 814 }, 815 GetCallbackArguments: function(){ 816 var args = ASPxClientComboBoxBase.prototype.GetCallbackArguments.call(this); 817 args += this.filterStrategy.GetCallbackArguments(); 818 return args; 819 }, 820 ClearEditorValueByClearButtonCore: function() { 821 this.enterKeyPressed = false; 822 ASPxClientDropDownEditBase.prototype.ClearEditorValueByClearButtonCore.call(this); 823 if(!this.IsFilterEnabled() && this.isDropDownListStyle) 824 this.HideDropDownArea(); 825 else 826 this.filterStrategy.OnClearButtonClick(); 827 }, 828 ResetEditorState: function() { 829 ASPxClientComboBoxBase.prototype.ResetEditorState.call(this); 830 this.isNeedToForceFirstShowLoadingPanel = true; 831 this.filterStrategy.ResetCallbackState(); 832 }, 833 IsFilterRollbackRequiredAfterApply: function() { 834 var filterRollbackRequired = !this.GetSelectedItem() && !this.focused && this.InCallback(); 835 return filterRollbackRequired; 836 }, 837 IsNullState: function() { 838 return this.GetSelectedIndex() === -1 && ASPxClientComboBoxBase.prototype.IsNullState.call(this); 839 }, 840 OnPost: function(args) { 841 if(!args.isCallback && this.isDropDownListStyle && ASPx.GetFocusedElement() == this.GetInputElement()) 842 this.OnTextChangedInternal(); 843 ASPxClientComboBoxBase.prototype.OnPost.call(this, args); 844 }, 845 GetLoadingParentElement: function(listBox) {
846 return listBox.GetLoadingParentElement(); 847 }, 848 ShowLoadingPanel: function() { 849 var lb = this.GetListBoxControl(); 850 var loadingParentElement = this.GetLoadingParentElement(lb); 851 if(!this.loadingPanelElement) { 852 var loadingPanel = this.CreateLoadingPanelWithAbsolutePosition(loadingParentElement, loadingParentElement); 853 lb.PreventMouseWheelOnElement(loadingPanel); 854 } 855 }, 856 ShowLoadingDiv: function () { 857 var lb = this.GetListBoxControl(); 858 var loadingParentElement = this.GetLoadingParentElement(lb); 859 if(!this.loadingDivElement) { 860 var loadingDiv = this.CreateLoadingDiv(loadingParentElement); 861 lb.PreventMouseWheelOnElement(loadingDiv); 862 } 863 }, 864 HideLoadingPanelOnCallback: function(){ 865 return false; 866 }, 867 OnCallback: function(result, callbackID) { 868 if(!this.CanProcessCallbackResult(callbackID) || !this.GetMainElement()) 869 return; 870 this.defaultDropDownHeight = ""; 871 if(ASPx.Browser.WebKitTouchUI) { 872 if(this.needToLoadDropDown) 873 this.OnLoadDropDownOnDemandCallback(result.c); 874 window.setTimeout(function() { 875 this.OnCallbackCore(result); 876 this.DoEndCallback(); 877 }.aspxBind(this), 300); 878 } else 879 this.OnCallbackCore(result); 880 }, 881 OnCallbackCore: function(result) { 882 if(result.serverMode) 883 this.UpdateStateObjectWithObject({serverMode: true}); 884 if(this.needToLoadDropDown) { 885 if(!ASPx.Browser.WebKitTouchUI) 886 this.OnLoadDropDownOnDemandCallback(result.c); 887 } else if(!this.filterStrategy.ShouldDiscardCallbackResult()) { 888 this.OnCallbackBeforeListBox(); 889 this.OnListBoxCallback(result); 890 this.OnCallbackInternal(result); 891 this.OnCallbackFinally(true); 892 } 893 this.callBackCoreComplete = true; 894 }, 895 OnListBoxCallback: function(result) { 896 var selectedValue = this.GetValue(); 897 var selectedText = this.GetText(); 898 function shouldSelectSilent(value, text) { 899 return value === selectedValue || text === selectedText; 900 } 901 this.GetListBoxControl().OnCallback(result, shouldSelectSilent); 902 this.EnsureSelectedItemTextSynchronized(); 903 }, 904 OnLoadDropDownOnDemandCallbackFinalized: function() { 905 this.DoReInitializeAfterLoadDropDownOnDemand(); 906 this.HideLoadingPanel(); 907 this.HideLoadingDiv(); 908 var isCallbackForShowDropDownArea = !this.onLoadDropDownOnDemandCallbackFinalizedEventHandler; 909 if(isCallbackForShowDropDownArea) { 910 this.ShowDropDown(); 911 if(this.isDropDownModal()) 912 this.onDropDownModalChanged(true); 913 } 914 else 915 this.onLoadDropDownOnDemandCallbackFinalizedEventHandler(); 916 this.FixButtonState(); 917 this.initializeDropDown(); 918 }, 919 OnCallbackFinalized: function() { 920 if(this.needToLoadDropDown) 921 this.OnLoadDropDownOnDemandCallbackFinalized(); 922 }, 923 OnLoadDropDownOnDemandCallback: function(html) { 924 var node = this.GetLoadedDropDownPrevSibling(); 925 var tempDiv = node.ownerDocument.createElement('div'); 926 tempDiv.innerHTML = html; 927 var len = tempDiv.childNodes.length; 928 for(var ind = len - 1; ind >= 0; ind--) { 929 ASPx.InsertElementAfter(tempDiv.childNodes.item(ind), node); 930 } 931 }, 932 GetLoadedDropDownPrevSibling: function() { 933 return this.GetMainElement(); 934 }, 935 ProcessCallbackError: function(errorObj, callbackID) { 936 if(!this.CanProcessCallbackResult(callbackID)) 937 return; 938 this.callBackCoreComplete = true; 939 ASPxClientDropDownEditBase.prototype.ProcessCallbackError.call(this, errorObj); 940 }, 941 DoEndCallback: function(){ 942 if(!this.callBackCoreComplete && ASPx.Browser.WebKitTouchUI || this.IsDoEndCallbackLocked()) { 943 this.UnlockDoEndCallback(); 944 return; 945 } 946 this.filterStrategy.OnBeforeDoEndCallback(); 947 ASPxClientDropDownEditBase.prototype.DoEndCallback.call(this); 948 this.filterStrategy.OnAfterDoEndCallback(); 949 this.callBackCoreComplete = false; 950 }, 951 RaiseEndCallback: function(){ 952 if(this.preventEndCallbackRising) { 953 this.preventEndCallbackRising = false; 954 ASPx.GetControlCollection().DecrementRequestCount(); 955 } else { 956 ASPxClientDropDownEditBase.prototype.RaiseEndCallback.call(this); 957 } 958 }, 959 OnCallbackError: function(result, data) { 960 var lb = this.GetListBoxControl(); 961 if(lb) 962 lb.OnCallbackError(result); 963 else 964 ASPxClientComboBoxBase.prototype.OnCallbackError.call(this, result, data); 965 this.OnCallbackFinally(false); 966 }, 967 OnCallbackFinally: function(isSuccessful){ 968 this.filterStrategy.OnBeforeCallbackFinally(); 969 var listBox = this.GetListBoxControl(); 970 var scrollDiv = this.listBox.GetScrollDivElement(); 971 var oldScrollTop = scrollDiv.scrollTop; 972 this.CollectionChanged(); 973 if(ASPx.Browser.Firefox && scrollDiv.scrollTop != oldScrollTop) 974 scrollDiv.scrollTop = oldScrollTop; 975 this.HideLoadingElements(); 976 var listBoxHasItems = listBox && listBox.GetItemCount(); 977 if(this.isNeedToForceFirstShowLoadingPanel && listBoxHasItems) 978 this.isNeedToForceFirstShowLoadingPanel = false; 979 this.isPerformCallback = false; 980 this.changeSelectAfterCallback = 0; 981 if(isSuccessful) 982 this.filterStrategy.OnAfterCallbackFinally(); 983 }, 984 OnCallbackBeforeListBox: function(){ 985 var lb = this.GetListBoxControl(); 986 this.changeSelectAfterCallback = lb.changeSelectAfterCallback; 987 }, 988 OnCallbackCorrectSelectedIndex: function(){ 989 var lb = this.GetListBoxControl(); 990 if(this.changeSelectAfterCallback != 0) 991 this.SetTextInternal(lb.GetSelectedItem().text); 992 }, 993 OnCallbackInternal: function(result){ 994 this.OnCallbackCorrectSelectedIndex(); 995 if(this.isPerformCallback) { 996 var lb = this.GetListBoxControl(); 997 if(!lb.GetItemCount()) { 998 this.onNoResultsFiltering(); 999 if(!this.isDropDownModal()) 1000 this.HideDropDownArea(true); 1001 } 1002 } 1003 this.filterStrategy.OnCallback(result); 1004 }, 1005 DoReInitializeAfterLoadDropDownOnDemand: function() { 1006 this.InitializeListBoxOwnerName(); 1007 this.needToLoadDropDown = false; 1008 }, 1009 CancelLoadCustomRangeOnDropDown: function() { 1010 delete this.customItemsRangeInfo; 1011 },
1012 ForceLoadCustomItemsRangeOnDropDown: function(startIndex, valueToSelect) { 1013 var count = this.GetListBoxControl().callbackPageSize; 1014 this.customItemsRangeInfo = { startIndex: startIndex, endIndex: startIndex + count - 1, valueToSelect: valueToSelect }; 1015 }, 1016 RequireLoadCustomRangeOnDropDown: function() { return !!this.customItemsRangeInfo; }, 1017 LoadCustomItemsRange: function() { 1018 if(this.InCallback()) return; 1019 this.ClearItems(); 1020 this.ShowInputLoadingPanel(); 1021 var startIndex = this.customItemsRangeInfo.startIndex; 1022 var endIndex = this.customItemsRangeInfo.endIndex; 1023 var value = this.customItemsRangeInfo.valueToSelect; 1024 var callbackArgs = this.GetListBoxControl().GetLoadCustomItemsRangeCallbackArguments(startIndex, endIndex, value); 1025 this.SendSpecialCallback(callbackArgs, function() { this.OnSuccessCustomItemsRangeLoad(); }.aspxBind(this)); 1026 }, 1027 OnSuccessCustomItemsRangeLoad: function() { 1028 var info = this.customItemsRangeInfo; 1029 if(!info) return; 1030 var listBox = this.GetListBoxControl(); 1031 var startIndex = info.startIndex; 1032 listBox.serverIndexOfFirstItem = startIndex; 1033 listBox.SetScrollSpacerVisibility(true, startIndex > 0); 1034 if(ASPx.IsExists(info.valueToSelect)) 1035 this.SetValue(info.valueToSelect); 1036 this.CancelLoadCustomRangeOnDropDown(); 1037 this.ShowDropDown(); 1038 }, 1039 EnsureDropDownLoaded: function(callbackFunction) { 1040 if(this.needToLoadDropDown) { 1041 this.onLoadDropDownOnDemandCallbackFinalizedEventHandler = callbackFunction ? function() { 1042 callbackFunction(); 1043 } : null; 1044 var args = this.FormatLoadDropDownOnDemandCallbackArguments(); 1045 this.SendLoadDropDownOnDemandCallback(args); 1046 } 1047 }, 1048 IsDropDownButtonClick: function(evt) { 1049 return ASPx.GetIsParent(this.GetDropDownButton(), ASPx.Evt.GetEventSource(evt)); 1050 }, 1051 OnDropDown: function(evt) { 1052 var returnValue = ASPxClientDropDownEditBase.prototype.OnDropDown.call(this, evt); 1053 if(this.IsDropDownButtonClick(evt) && this.IsCanToDropDown()) { 1054 this.OnDropDownButtonClick(evt); 1055 return returnValue; 1056 } 1057 return true; 1058 }, 1059 OnDropDownButtonClick: function(evt) { 1060 if(this.filterStrategy != null) 1061 this.filterStrategy.OnDropDownButtonClick(); 1062 this.ForceRefocusEditor(evt); 1063 }, 1064 SendCallback: function(onSuccess){ 1065 if(!this.pcIsShowingNow) 1066 this.ShowLoadingElements(); 1067 ASPxClientComboBoxBase.prototype.SendCallback.call(this, onSuccess); 1068 }, 1069 IsAndroidKeyEventsLocked: function() { 1070 return ASPx.Browser.AndroidMobilePlatform && this.androidKeyEventsLocked; 1071 }, 1072 LockAndroidKeyEvents: function() { 1073 this.androidKeyEventsLocked = true; 1074 }, 1075 UnlockAndroidKeyEvents: function() { 1076 this.androidKeyEventsLocked = false; 1077 }, 1078 CancelChangesOnUndo: function() { 1079 if(this.isCallbackMode) 1080 this.SetTextInternal(this.lastSuccessText); 1081 else 1082 this.OnCancelChanges(); 1083 this.filterStrategy.OnUndo(); 1084 }, 1085 OnKeyDown: function(evt) { 1086 if(this.IsCtrlZ(evt)) { 1087 this.CancelChangesOnUndo(); 1088 return ASPx.Evt.PreventEvent(evt); 1089 } 1090 var isClearKey = ASPx.Data.ArrayIndexOf([ASPx.Key.Delete, ASPx.Key.Backspace], evt.keyCode) >= 0; 1091 if(isClearKey && this.allowNull && (this.IsAllTextSelected() || this.isDropDownListStyle && !this.IsFilterEnabled())) 1092 this.ClearEditorValueAndForceOnChange(); 1093 else if(this.IsAndroidKeyEventsLocked()) 1094 return ASPx.Evt.PreventEventAndBubble(evt); 1095 else 1096 ASPxClientComboBoxBase.prototype.OnKeyDown.call(this, evt); 1097 }, 1098 OnKeyUp: function(evt) { 1099 if(this.IsAndroidKeyEventsLocked()) 1100 return ASPx.Evt.PreventEventAndBubble(evt); 1101 return ASPxClientComboBoxBase.prototype.OnKeyUp.call(this, evt); 1102 }, 1103 IsAllTextSelected: function() { 1104 var input = this.GetInputElement(); 1105 var textLength = input.value.length; 1106 if(textLength === 0) 1107 return false; 1108 var selectionInfo = ASPx.Selection.GetExtInfo(input); 1109 var selectionLength = selectionInfo.endPos - selectionInfo.startPos; 1110 return selectionLength === textLength; 1111 }, 1112 SelectNeighbour: function (step){ 1113 if((this.isToolBarItem && !this.droppedDown) || this.GetReadOnly()) return; 1114 this.SelectNeighbourInternal(step); 1115 }, 1116 SelectNeighbourInternal: function(step){ 1117 var lb = this.GetListBoxControl(); 1118 if(this.droppedDown) 1119 this.lbEventLockCount ++; 1120 lb.SelectNeighbour(step); 1121 if(this.droppedDown) { 1122 var selectedItem = lb.GetSelectedItem(); 1123 if (selectedItem) { 1124 this.OnSelectionChangedCore(selectedItem.text, selectedItem, true); 1125 } 1126 this.lbEventLockCount --; 1127 } 1128 if(this.accessibilityCompliant) 1129 this.GetAccessibilityHelper().SetLabelAttribute(null, null); 1130 }, 1131 GetFocusSelectAction: function() { 1132 return this.isToolbarItem ? null : "all"; 1133 }, 1134 OnArrowUp: function(evt){ 1135 if(!this.isInitialized) return true; 1136 if(this.RequireLoadCustomRangeOnDropDown() && !this.droppedDown) { 1137 this.LoadCustomItemsRange(); 1138 return; 1139 } 1140 var isProcessed = ASPxClientDropDownEditBase.prototype.OnArrowUp.call(this, evt); 1141 if(!isProcessed && this.filterStrategy.CanNavigateByKbd()) 1142 this.SelectNeighbour(-1); 1143 return true; 1144 }, 1145 OnTextChanged: function () { 1146 if(!this.IsFocusEventsLocked()) 1147 ASPxClientComboBoxBase.prototype.OnTextChanged.call(this); 1148 }, 1149 OnTextChangedInternal: function() { 1150 if(!this.forceValueChanged) { 1151 var preserveFilterInInput = this.InCallback() && this.filterStrategy.currentCallbackIsFiltration; 1152 if(preserveFilterInInput) return; 1153 } 1154 ASPxClientComboBoxBase.prototype.OnTextChangedInternal.call(this); 1155 if(this.filterStrategy) 1156 this.filterStrategy.OnTextChanged(); 1157 }, 1158 OnArrowDown: function(evt){ 1159 if(!this.isInitialized) return true; 1160 if(this.RequireLoadCustomRangeOnDropDown() && !this.droppedDown) { 1161 this.LoadCustomItemsRange(); 1162 return; 1163 } 1164 var isProcessed = ASPxClientDropDownEditBase.prototype.OnArrowDown.call(this, evt); 1165 if(!isProcessed && this.filterStrategy.CanNavigateByKbd()) 1166 this.SelectNeighbour(1); 1167 return true; 1168 }, 1169 OnPageUp: function(){ 1170 if(!this.isInitialized || !this.filterStrategy.CanNavigateByKbd()) return true; 1171 return this.OnPageButtonDown(false); 1172 }, 1173 OnPageDown: function(){ 1174 if(!this.isInitialized || !this.filterStrategy.CanNavigateByKbd()) return true; 1175 return this.OnPageButtonDown(true); 1176 }, 1177 OnPageButtonDown: function(isDown){ 1178 if(!this.isInitialized) return true; 1179 var lb = this.GetListBoxControl(); 1180 if(lb){ 1181 var direction = isDown ? 1 : -1; 1182 this.SelectNeighbour(lb.scrollPageSize * direction); 1183 } 1184 return true; 1185 }, 1186 OnHomeKeyDown: function(evt){ 1187 if(!this.isInitialized) return true; 1188 return this.OnHomeEndKeyDown(evt, true); 1189 }, 1190 OnEndKeyDown: function(evt){ 1191 if(!this.isInitialized) return true; 1192 return this.OnHomeEndKeyDown(evt, false); 1193 }, 1194 OnHomeEndKeyDown: function(evt, isHome){ 1195 if(!this.isInitialized) return true; 1196 var input = this.GetValueInput(); 1197 if((input && input.readOnly) || evt.ctrlKey){ 1198 var lb = this.GetListBoxControl(); 1199 var count = lb.GetItemCount(); 1200 this.SelectNeighbour(isHome ? -count : count); 1201 return true; 1202 } 1203 return false; 1204 }, 1205 OnEscape: function() { 1206 this.filterStrategy.OnEscape(); 1207 return ASPxClientComboBoxBase.prototype.OnEscape.call(this); 1208 }, 1209 OnEnter: function(){ 1210 if(!this.isInitialized) return true; 1211 if(this.isDropDownListStyle) this.enterKeyPressed = true; 1212 if(this.filterStrategy.IsCloseByEnterLocked()) return; 1213 this.enterProcessed = this.droppedDown; 1214 if(!this.isEnterLocked) { 1215 this.OnApplyChangesAndCloseWithEvents(); 1216 this.filterStrategy.OnAfterEnter(); 1217 } 1218 return this.enterProcessed; 1219 }, 1220 OnTab: function(evt){ 1221 if(!this.isInitialized) 1222 return true; 1223 if(this.InCallback()) 1224 this.filterStrategy.callbackProcessingStateManager.SetApply(); 1225 else 1226 this.OnApplyChangesAndCloseWithEvents(); 1227 }, 1228 OnApplyChanges: function(){ 1229 if(!this.focused || (this.isDropDownListStyle && !this.IsFilterEnabled())) return; 1230 this.OnApplyChangesInternal(); 1231 }, 1232 OnApplyChangesAndCloseWithEvents: function() { 1233 this.OnApplyChangesInternal(); 1234 this.HideDropDownArea(true); 1235 }, 1236 OnApplyChangesInternal: function(){ 1237 var inCallback = this.InCallback(); 1238 var lb = this.GetListBoxControl(); 1239 var isChanged = this.HasChanges(); 1240 var isRollback = false; 1241 if(isChanged || this.filterStrategy.isTotallyMismatchedFilter) { 1242 this.filterStrategy.isTotallyMismatchedFilter = false; 1243 this.filterStrategy.needEmptyFilterBeforeFiltering = false; 1244 var text = this.GetCurrentText(); 1245 if(this.filterStrategy.OnApplyChanges()) 1246 return; 1247 var adjustedSelectedIndex = this.GetAdjustedSelectedIndexByText(lb, text); 1248 var isNullState = this.allowNull && !text; 1249 var rollbackRequired = this.isDropDownListStyle && adjustedSelectedIndex < 0 && !isNullState; 1250 if(rollbackRequired) { 1251 var rollbackToItem = lb.GetSelectedItem(); 1252 isRollback = rollbackToItem == null && this.isCallbackMode; 1253 if(isRollback) { 1254 this.RollbackValueInputValue(); 1255 this.RollbackTextInputValue(); 1256 } 1257 text = rollbackToItem != null ? rollbackToItem.text : this.lastSuccessText; 1258 } 1259 if(!isRollback) { 1260 var adjustedSelectedItem = this.GetItem(adjustedSelectedIndex); 1261 var adjustedSelectedItemText = adjustedSelectedItem && adjustedSelectedItem.text; 1262 text = adjustedSelectedItemText || text; 1263 var hasChanges = this.HasChanges(text); 1264 this.SetText(text); 1265 if(hasChanges) 1266 this.OnChange(); 1267 } 1268 else if(!inCallback) { 1269 this.filterStrategy.OnFilterRollback(); 1270 } 1271 } 1272 }, 1273 GetCurrentText: function(){ 1274 var textDecorated = !this.focused && this.GetRawValue() != null; 1275 return textDecorated ? this.GetRawValue() : this.GetInputElement().value; 1276 }, 1277 GetCurrentValue: function(){ 1278 var value = null; 1279 var selectedItem = this.listBox.GetSelectedItem(); 1280 if(selectedItem && (selectedItem.value !== "" || !this.convertEmptyStringToNull)) 1281 value = selectedItem.value; 1282 return selectedItem ? value : this.GetValue(); 1283 }, 1284 HasChanges: function(currentText){ 1285 currentText = currentText === undefined ? this.GetCurrentText() : currentText; 1286 return this.lastSuccessText != currentText || this.lastSuccessValue != this.GetCurrentValue(); 1287 }, 1288 OnButtonClick: function(number){
1289 if(number != this.dropDownButtonIndex) { 1290 if(this.droppedDown) 1291 this.OnApplyChangesAndCloseWithEvents(false); 1292 else 1293 ASPxClientComboBoxBase.prototype.OnTextChanged.call(this); 1294 } 1295 ASPxClientButtonEditBase.prototype.OnButtonClick.call(this, number); 1296 }, 1297 OnCancelChanges: function(){ 1298 var isCancelProcessed = ASPxClientDropDownEditBase.prototype.OnCancelChanges.call(this); 1299 this.filterStrategy.OnCancelChanges(); 1300 var lb = this.GetListBoxControl(); 1301 if(ASPx.IsExists(lb)) { 1302 var index = this.GetAdjustedSelectedIndexByText(lb, this.lastSuccessText); 1303 this.SelectIndexSilent(lb, index); 1304 } 1305 return isCancelProcessed; 1306 }, 1307 ShouldCloseOnMCMouseDown: function () { 1308 return this.GetInputElement().readOnly; 1309 }, 1310 OnCloseUp: function(evt){ 1311 var evt = ASPx.Evt.GetEvent(evt); 1312 if(ASPx.Browser.Firefox && evt.type == "mouseup" && ASPx.Evt.GetEventSource(evt).tagName == "DIV") { 1313 var scrollDiv = this.GetListBoxControl().GetScrollDivElement(); 1314 var scrollDivID = scrollDiv ? scrollDiv.id : ""; 1315 if(scrollDivID == ASPx.Evt.GetEventSource(evt).id) 1316 return; 1317 } 1318 ASPxClientDropDownEditBase.prototype.OnCloseUp.call(this, evt); 1319 }, 1320 OnDDButtonMouseMove: function(evt){ 1321 return (this.droppedDown ? ASPx.Evt.CancelBubble(evt) : true); 1322 }, 1323 CloseDropDownByDocumentOrWindowEvent: function(causedByWindowResizing) { 1324 if(!this.InCallback()) { 1325 this.OnApplyChangesInternal(); 1326 ASPxClientDropDownEditBase.prototype.CloseDropDownByDocumentOrWindowEvent.call(this, causedByWindowResizing); 1327 } 1328 this.filterStrategy.OnDropDownCloseByDocumentOrWindowEvent(); 1329 }, 1330 IsCanToDropDown: function() { 1331 if(this.loadDropDownOnDemand) { 1332 var lb = this.GetListBoxControl(); 1333 return (!this.needToLoadDropDown && (lb.GetItemCount() || this.isDropDownModal())); 1334 } 1335 return ASPxClientDropDownEditBase.prototype.IsCanToDropDown.call(this); 1336 }, 1337 OnPopupControlShown: function(){ 1338 if(!this.isInitialized) return; 1339 if(ASPx.Browser.Opera) 1340 this.GetListBoxControl().RestoreScrollTopFromCache(); 1341 if(this.lockListBoxClick) 1342 this.RemoveLockListBoxClick(); 1343 if(this.InCallback()) 1344 this.ShowLoadingDivAndPanel(); 1345 ASPxClientDropDownEditBase.prototype.OnPopupControlShown.call(this); 1346 if(!this.isShownAtFirst) { 1347 this.InitDropDownSize(); 1348 this.isShownAtFirst = true; 1349 } 1350 }, 1351 OnLBSelectedIndexChanged: function(){ 1352 if(!this.lockListBoxClick) { 1353 this.OnSelectChanged(); 1354 this.filterStrategy.OnSelectedIndexChanged(); 1355 if(this.IsNavigationOnKeyPress()){ 1356 if(!this.droppedDown) { 1357 ASPx.Selection.Set(this.GetInputElement()); 1358 } 1359 } else if(this.focused) { 1360 if(ASPx.IsElementVisible(this.GetInputElement())) 1361 this.ForceRefocusEditor(); 1362 else { 1363 this.UnlockFocusEvents(); 1364 this.OnLostFocus(); 1365 } 1366 } 1367 } 1368 }, 1369 IsNavigationOnKeyPress: function() { 1370 var lb = this.GetListBoxControl(); 1371 return lb.IsScrollOnKBNavigationLocked(); 1372 }, 1373 OnListBoxItemMouseUp: function(evt){ 1374 if(!this.lockListBoxClick && !this.InCallback()){ 1375 this.OnApplyChangesInternal(); 1376 this.OnCloseUp(evt); 1377 } 1378 }, 1379 OnMouseWheel: function(evt){ 1380 if(this.allowMouseWheel && !this.droppedDown && this.filterStrategy.CanNavigateByKbd()) { 1381 var wheelDelta = ASPx.Evt.GetWheelDelta(evt); 1382 if(wheelDelta > 0) 1383 this.SelectNeighbour(-1); 1384 else if(wheelDelta < 0) 1385 this.SelectNeighbour(1); 1386 return ASPx.Evt.PreventEvent(evt); 1387 } 1388 }, 1389 OnOpenAnotherDropDown: function(){ 1390 this.OnApplyChangesAndCloseWithEvents(); 1391 }, 1392 ParseValue: function() { 1393 var forceValueChanged = !this.IsValueChanging() && this.IsValueChangeForced(); 1394 var newText = this.GetInputElement().value; 1395 var oldText = this.GetText(); 1396 var isNeedToParseValue = oldText != newText; 1397 if(isNeedToParseValue || forceValueChanged) { 1398 this.StartValueChanging(); 1399 if(this.CanTextBeAccepted(newText, oldText) || forceValueChanged){ 1400 if(isNeedToParseValue || newText) 1401 this.SetText(newText); 1402 this.OnChange(); 1403 } else 1404 this.SetTextInternal(oldText); 1405 this.EndValueChanging(); 1406 } 1407 }, 1408 CanTextBeAccepted: function(newText, oldText){ 1409 var notAnyTextCanBeAccepted = this.isDropDownListStyle; 1410 if(notAnyTextCanBeAccepted){ 1411 var lb = this.GetListBoxControl(); 1412 var newTextPresentInItemCollection = this.GetAdjustedSelectedIndexByText(lb, newText) != -1; 1413 return newTextPresentInItemCollection; 1414 } 1415 var wasTextErased = !newText && oldText; 1416 if((!wasTextErased) && this.nullText && this.CanApplyNullTextDecoration()) { 1417 return false; 1418 } 1419 return true; 1420 }, 1421 MakeItemVisible: function(index){ 1422 var lb = this.GetListBoxControl(); 1423 lb.MakeItemVisible(index); 1424 }, 1425 PerformCallback: function(arg, onSuccess) { 1426 this.isPerformCallback = true; 1427 this.CancelLoadCustomRangeOnDropDown(); 1428 this.filterStrategy.OnPerformCallback(); 1429 if(this.needToLoadDropDown) { 1430 var formatCallbackArg = function(prefix, arg) { 1431 arg = arg.toString(); 1432 return (ASPx.IsExists(arg) ? prefix + "|" + arg.length + ';' + arg + ';' : ""); 1433 }; 1434 if(arg === undefined || arg == null) 1435 arg = "";
1436 var performArgs = formatCallbackArg(ASPxClientListEdit.CONSTANTS.CALLBACK_PREFIXES.CUSTOM, arg); 1437 this.onLoadDropDownOnDemandCallbackFinalizedEventHandler = function() { 1438 var selectedItem = this.listBox.GetSelectedItem(); 1439 if(selectedItem != null) 1440 this.SetTextInternal(selectedItem.text); 1441 var lb = this.GetListBoxControl(); 1442 if(lb) 1443 lb.SetCustomCallbackArg(performArgs); 1444 }; 1445 var loadItemsRangeArgs = formatCallbackArg(ASPxClientListEdit.CONSTANTS.CALLBACK_PREFIXES.LOAD_RANGE_ITEMS, "0:-2"); 1446 var args = this.FormatLoadDropDownOnDemandCallbackArguments(performArgs + loadItemsRangeArgs); 1447 this.SendLoadDropDownOnDemandCallback(args, onSuccess); 1448 } else { 1449 this.ClearItemsInternal(); 1450 this.GetListBoxControl().PerformCallback(arg, onSuccess); 1451 } 1452 }, 1453 ClearItemsInternal: function(){ 1454 ASPxClientComboBoxBase.prototype.ClearItemsInternal.call(this); 1455 var lbScrollDiv = this.GetListBoxScrollDivElement(); 1456 if(lbScrollDiv) 1457 lbScrollDiv.scrollTop = "0px"; 1458 }, 1459 SendLoadDropDownOnDemandCallback: function(args, handler) { 1460 this.ShowInputLoadingPanel(); 1461 this.SendSpecialCallback(args, handler); 1462 }, 1463 ShowInputLoadingPanel: function() { 1464 var inputElement = this.GetInputElement(); 1465 var inputParentElement = inputElement.parentNode; 1466 this.CreateLoadingDiv(inputParentElement, inputElement); 1467 this.CreateLoadingPanelWithAbsolutePosition(inputParentElement, inputElement); 1468 }, 1469 FormatLoadDropDownOnDemandCallbackArguments: function(args) { 1470 var internalArgs = ASPx.IsExists(args) ? args.toString() : ""; 1471 var resultArgs = loadDropDownOnDemandCallbackPrefix + "|0;;"; 1472 return resultArgs + internalArgs; 1473 }, 1474 CorrectCaretPositionInChrome: function() { 1475 if(!ASPx.Browser.Chrome) return; 1476 var currentSelection = ASPx.Selection.GetInfo(this.GetInputElement()); 1477 if(currentSelection.startPos === currentSelection.endPos) 1478 ASPx.Selection.SetCaretPosition(this.GetInputElement(), 0); 1479 }, 1480 ForceRefocusEditor: function(evt, isNativeFocus) { 1481 this.CorrectCaretPositionInChrome(); 1482 this.refocusWhenInputClicked = this.IsElementBelongToInputElement(ASPx.Evt.GetEventSource(evt)); 1483 ASPxClientButtonEditBase.prototype.ForceRefocusEditor.call(this, evt, isNativeFocus); 1484 }, 1485 OnFocusCore: function () { 1486 if(this.needToLoadDropDown) { 1487 var args = this.FormatLoadDropDownOnDemandCallbackArguments(); 1488 this.SendLoadDropDownOnDemandCallback(args); 1489 } else 1490 this.FixButtonState(); 1491 ASPxClientDropDownEditBase.prototype.OnFocusCore.call(this); 1492 }, 1493 FixButtonState: function() { 1494 var lb = this.GetListBoxControl(); 1495 if(lb && this.ddButtonPushed) { 1496 this.DropDownButtonPop(true); 1497 } 1498 }, 1499 getDropDownEventTargets: function() { 1500 return ASPxClientComboBoxBase.prototype.getDropDownEventTargets.call(this).concat([ 1501 this.isDropDownListStyle ? this.getInputCell() : null, 1502 ]); 1503 }, 1504 onDropDownModalChanged: function(enabled) { 1505 ASPxClientComboBoxBase.prototype.onDropDownModalChanged.call(this, enabled); 1506 if(!enabled) { 1507 if(!this.GetItemCount() || !this.filterStrategy.IsFilterMeetRequirementForMinLength()) 1508 setTimeout(this.HideDropDownArea.bind(this, true), 0); 1509 this.showDropDownModalMessageElement(false); 1510 } 1511 this.GetListBoxControl().onDropDownModalChanged(enabled); 1512 this.UpdateDropDownPositionAndSize(); 1513 }, 1514 onProcessFilterLessMinLength: function() { 1515 if(this.isDropDownModal() && this.droppedDown) 1516 this.showDropDownModalMessageElement(true, this.isDropDownListStyle ? this.msgFilterMinLength : (this.msgFilterMinLength + "<br />" + this.msgFilterNoResults)); 1517 if(!this.isDropDownModal()) 1518 this.HideDropDownArea(true); 1519 }, 1520 onNoResultsFiltering: function() { 1521 if(this.isDropDownModal() && this.droppedDown) 1522 this.showDropDownModalMessageElement(true, this.msgFilterNoResults); 1523 this.isNeedToForceFirstShowLoadingPanel = true; 1524 }, 1525 onBeforeFiltering: function() { 1526 if(this.isDropDownModal() && this.droppedDown) 1527 this.showDropDownModalMessageElement(false); 1528 }, 1529 showDropDownModalMessageElement: function(visible, message) { 1530 var listBox = this.GetListBoxControl(); 1531 if(!listBox) 1532 return; 1533 if(visible && !this.dropDownModalMessageElement) { 1534 this.dropDownModalMessageElement = document.createElement("div"); 1535 this.dropDownModalMessageElement.className = "dxdd-info"; 1536 listBox.GetMainElement().parentNode.insertBefore(this.dropDownModalMessageElement, listBox.GetMainElement()); 1537 } 1538 else if(visible) 1539 this.dropDownModalMessageElement.style.display = ""; 1540 else if(!visible && this.dropDownModalMessageElement) 1541 this.dropDownModalMessageElement.style.display = "none"; 1542 if(visible && message) 1543 this.dropDownModalMessageElement.innerHTML = message; 1544 if(this.dropDownModalMessageElement) 1545 ASPx.SetElementDisplay(listBox.GetMainElement(), !visible); 1546 }, 1547 onDropDownApplyCommandClick: function() { 1548 this.OnApplyChangesAndCloseWithEvents(); 1549 }, 1550 onDropDownCloseCommandClick: function() { 1551 this.OnEscape(); 1552 }, 1553 SetItemHtml: function(index, html) { 1554 this.GetListBoxControl().SetItemHtml(index, html); 1555 }, 1556 SetItemTooltip: function(index, tooltip) { this.GetListBoxControl().SetItemTooltip(index, tooltip); }, 1557 SetItemAttribute: function(index, attributeName, attributeValue) { this.GetListBoxControl().SetItemAttribute(index, attributeName, attributeValue); }, 1558 AddItemCssClass: function(index, className) { this.GetListBoxControl().AddItemCssClass(index, className); }, 1559 RemoveItemCssClass: function(index, className) { this.GetListBoxControl().RemoveItemCssClass(index, className); }, 1560 SetItemTextCellHtml: function(itemIndex, textCellIndex, html) { this.GetListBoxControl().SetItemTextCellHtml(itemIndex, textCellIndex, html); }, 1561 SetItemTextCellTooltip: function(itemIndex, textCellIndex, tooltip) { this.GetListBoxControl().SetItemTextCellTooltip(itemIndex, textCellIndex, tooltip); }, 1562 SetItemTextCellAttribute: function(itemIndex, textCellIndex, attributeName, attributeValue) { this.GetListBoxControl().SetItemTextCellAttribute(itemIndex, textCellIndex, attributeName, attributeValue); }, 1563 AddItemTextCellCssClass: function(itemIndex, textCellIndex, className) { this.GetListBoxControl().AddItemTextCellCssClass(itemIndex, textCellIndex, className); }, 1564 RemoveItemTextCellCssClass: function(itemIndex, textCellIndex, className) { this.GetListBoxControl().RemoveItemTextCellCssClass(itemIndex, textCellIndex, className); }, 1565 GetAccessibilityText: function() { 1566 var helper = this.GetAccessibilityHelper(); 1567 return helper && helper.getListSelectedItemText() || this.GetCurrentText(); 1568 } 1569}); 1570ASPx.Ident.scripts.ASPxClientComboBox = true; 1571ASPxClientComboBox.Cast = ASPxClientControl.Cast; 1572var CallbackProcessingStateManager = function(){ 1573 var states = { 1574 Default: 0, 1575 Rollback: 1, 1576 Apply: 2, 1577 ApplyAfterRollback: 3 1578 }; 1579 var state = states.Default; 1580 return { 1581 ResetState: function() { 1582 state = states.Default; 1583 }, 1584 IsApply: function() { 1585 return state == states.Apply; 1586 }, 1587 IsRollback: function() { 1588 return state == states.Rollback; 1589 }, 1590 IsApplyAfterRollback: function() { 1591 return state == states.ApplyAfterRollback; 1592 }, 1593 NoFilterPostProcessing: function() { 1594 return !this.IsApply() && !this.IsApplyAfterRollback() && !this.IsRollback(); 1595 }, 1596 SetRollback: function() { 1597 if(state == states.Default) 1598 state = states.Rollback; 1599 }, 1600 SetApply: function() { 1601 if(state == states.Default) 1602 state = states.Apply; 1603 }, 1604 SetApplyAfterRollback: function() { 1605 if(state == states.Default || state == states.Apply) 1606 state = states.ApplyAfterRollback; 1607 }, 1608 OnCallbackResult: function(filterRollbackRequired) { 1609 if(state == states.Apply) { 1610 state = filterRollbackRequired ? states.ApplyAfterRollback : states.Default; 1611 return; 1612 } 1613 if(state == states.Rollback) { 1614 state = states.ApplyAfterRollback; 1615 return; 1616 } 1617 if(state == states.ApplyAfterRollback) { 1618 state = states.Default; 1619 return; 1620 } 1621 } 1622 }; 1623}; 1624var ASPxClientNativeComboBox = ASPx.CreateClass(ASPxClientComboBoxBase, { 1625 constructor: function(name) { 1626 this.constructor.prototype.constructor.call(this, name); 1627 this.initSelectedIndex = -1; 1628 this.raiseValueChangedOnEnter = false; 1629 }, 1630 InlineInitialize: function () { 1631 ASPxClientComboBoxBase.prototype.InlineInitialize.call(this); 1632 var lb = this.GetListBoxControl(); 1633 if(lb != null) lb.SetMainElement(this.GetMainElement()); 1634 if(this.initSelectedIndex == -1) { 1635 this.SelectIndex(this.initSelectedIndex, true); 1636 } 1637 }, 1638 FindInputElement: function(){ 1639 return this.GetMainElement(); 1640 }, 1641 GetDropDownInnerControlName: function(suffix){ 1642 return this.name + suffix; 1643 }, 1644 PerformCallback: function(arg) { 1645 this.GetListBoxControl().PerformCallback(arg); 1646 }, 1647 GetTextInternal: function(){ 1648 var selectedItem = this.GetSelectedItem(); 1649 return (selectedItem != null) ? selectedItem.text : ""; 1650 }, 1651 HasTextDecorators: function() { 1652 return false; 1653 }, 1654 SetText: function (text){ 1655 var lb = this.GetListBoxControl(); 1656 var index = this.FindItemIndexByText(lb, text); 1657 this.SelectIndex(index, false); 1658 this.SetLastSuccessText((index > -1) ? text : ""); 1659 this.SetLastSuccessValue((index > -1) ? lb.GetValue() : null); 1660 }, 1661 GetValue: function(){ 1662 var selectedItem = this.GetSelectedItem(); 1663 return (selectedItem != null) ? selectedItem.value : null; 1664 }, 1665 SetValue: function(value){ 1666 var lb = this.GetListBoxControl(); 1667 if(lb){ 1668 lb.SetValue(value); 1669 var item = lb.GetSelectedItem(); 1670 var text = item ? item.text : value; 1671 this.SetLastSuccessText(item != null ? text : ""); 1672 this.SetLastSuccessValue(item != null ? item.value : null); 1673 } 1674 }, 1675 ForceRefocusEditor: function(){ 1676 }, 1677 OnCallback: function(result) { 1678 this.GetListBoxControl().OnCallback(result); 1679 if(this.GetItemCount() > 0) 1680 this.SetSelectedIndex(0); 1681 }, 1682 OnTextChanged: function() { 1683 this.OnChange(); 1684 }, 1685 SetTextInternal: function(text){ 1686 }, 1687 SetTextBase: function(text){ 1688 }, 1689 ChangeEnabledAttributes: function(enabled){ 1690 this.GetMainElement().disabled = !enabled; 1691 this.ChangeSpecialInputEnabledAttributes(this.GetMainElement(), ASPx.Attr.ChangeEventsMethod(enabled), true); 1692 } 1693}); 1694var AccessibilityHelperComboBox = ASPx.CreateClass(ASPx.AccessibilityHelperBase, { 1695 constructor: function(comboBox) { 1696 this.constructor.prototype.constructor.call(this, comboBox); 1697 this.currentValue = null; 1698 }, 1699 SetLabelAttribute: function(text, isItemSelected) { 1700 this.currentValue = this.control.GetValue(); 1701 var message = text !== null ? this.getLabelText(text, isItemSelected) : this.getListSelectedItemText(); 1702 this.PronounceMessage(message); 1703 }, 1704 SetExpandedState: function(expanded) { 1705 this.SetLabelAttribute(null, null); 1706 var input = this.getInputElement(); 1707 var expandArg = { "aria-expanded": expanded }; 1708 this.changeActivityAttributes(input, expandArg); 1709 }, 1710 GetPronounceElement: function() { 1711 return this.getInputElement(); 1712 }, 1713 getLabelText: function(text, isItemSelected) { 1714 var blankText = ASPx.AccessibilitySR.BlankEditorText; 1715 if(!text) 1716 text = blankText; 1717 var itemsCount = this.getListBoxControl().GetVisibleItemCount(); 1718 var formatString = ASPx.AccessibilitySR.ComboBoxFilteringResultFormatString; 1719 if(!isItemSelected || itemsCount == 1) 1720 formatString += ASPx.AccessibilitySR.ComboBoxCurrentTextFormatString; 1721 return ASPx.Str.ApplyReplacement(formatString, [["{0}", itemsCount], 1722 ["{1}", (isItemSelected || !this.control.lastSuccessText) ? text : this.control.lastSuccessText], 1723 ["{2}", this.getInputElement().value || blankText]]); 1724 }, 1725 getListBoxControl: function() { return this.control.GetListBoxControl(); }, 1726 getListSelectedItemText: function() { 1727 var lb = this.getListBoxControl(); 1728 var selectedItem = lb.GetSelectedItem(); 1729 var itemText = ""; 1730 if(!!selectedItem) { 1731 var formatString = ASPx.AccessibilitySR.ItemPositionFormatString; 1732 var visibleIndex = this.control.isCallbackMode ? selectedItem.index + 1 : lb.GetIndexVisibleItem(selectedItem); 1733 var itemPositionText = ASPx.Str.ApplyReplacement(formatString, [["{0}", visibleIndex], ["{1}", lb.GetVisibleItemCount()]]); 1734 itemText = selectedItem.text + itemPositionText; 1735 } else { 1736 var input = this.getInputElement(); 1737 itemText = !!input.value ? input.value : ASPx.AccessibilitySR.BlankEditorText; 1738 } 1739 return itemText; 1740 } 1741}); 1742function setValueOptimizeHelper() { 1743 var itemCollectionWasChangedSinceLastSetValue = false; 1744 function canReSetValue() { 1745 return itemCollectionWasChangedSinceLastSetValue; 1746 } 1747 function onSetValue() { 1748 itemCollectionWasChangedSinceLastSetValue = false; 1749 } 1750 return { 1751 onItemCollectionChanged: function () { 1752 itemCollectionWasChangedSinceLastSetValue = true; 1753 }, 1754 setValue: function (comboBox, newValue, methodName) { 1755 var item = comboBox.FindItemByValue(newValue); 1756 var reSetValue = comboBox.GetValue() === newValue; 1757 if (reSetValue && !canReSetValue() && (!item || item.selected)) return; 1758 comboBox.SetValueInternal(newValue); 1759 onSetValue(); 1760 } 1761 }; 1762} 1763ASPx.CBDDButtonMMove = function(evt){ 1764 return ASPx.GetDropDownCollection().OnDDButtonMouseMove(evt); 1765};
1766function aspxCBMouseWheel(evt){ 1767 var srcElement = ASPx.Evt.GetEventSource(evt); 1768 var focusedCB = ASPx.GetDropDownCollection().GetFocusedDropDown(); 1769 if(focusedCB != null && ASPx.GetIsParent(focusedCB.GetMainElement(), srcElement)) 1770 return focusedCB.OnMouseWheel(evt); 1771} 1772var ComboBoxDisabledFilterStrategy = ASPx.CreateClass(ASPx.ListEditFilterStrategyBase, { 1773 constructor: function(comboBox) { 1774 this.constructor.prototype.constructor.call(this, comboBox.filterTimer, comboBox.filterMinLength, comboBox.isCallbackMode); 1775 this.comboBox = comboBox; 1776 this.callbackProcessingStateManager = new CallbackProcessingStateManager(); 1777 }, 1778 OnDropDownCloseByDocumentOrWindowEvent: function() { 1779 if(this.comboBox.InCallback()) 1780 this.callbackProcessingStateManager.SetApply(); 1781 }, 1782 OnAfterCallbackFinally: function() { 1783 if(this.callbackProcessingStateManager.IsApply() || this.callbackProcessingStateManager.IsApplyAfterRollback()) { 1784 this.comboBox.OnApplyChangesAndCloseWithEvents(); 1785 this.callbackProcessingStateManager.ResetState(); 1786 } 1787 }, 1788 IsCloseByEnterLocked: function() { return false; }, 1789}); 1790var ComboBoxIncrementalFilterStrategyBase = ASPx.CreateClass(ASPx.ListEditIncrementalFilterStrategyBase, { 1791 constructor: function(comboBox) { 1792 this.constructor.prototype.constructor.call(this, comboBox.filterTimer, comboBox.filterMinLength, comboBox.isCallbackMode); 1793 this.comboBox = comboBox; 1794 this.isDropDownListStyle = comboBox.isDropDownListStyle; 1795 this.callbackProcessingStateManager = new CallbackProcessingStateManager(); 1796 this.isTotallyMismatchedFilter = false; 1797 }, 1798 OnInput: function() { 1799 if (!this.comboBox.allowNull && !this.GetInputFilterValue()) 1800 this.ClearFilterApplied(); 1801 ASPx.ListEditIncrementalFilterStrategyBase.prototype.OnInput.call(this); 1802 }, 1803 OnKeyDown: function(evt) { 1804 var cbInputElement = this.comboBox.GetInputElement(); 1805 var selInfo = ASPx.Selection.GetInfo(cbInputElement); 1806 if(selInfo.startPos != selInfo.endPos && evt.keyCode == ASPx.Key.Backspace) { 1807 var currentText = cbInputElement.value; 1808 var cutText = currentText.slice(0, selInfo.startPos) + currentText.slice(selInfo.endPos); 1809 var newFilter = ASPx.Str.PrepareStringForFilter(cutText); 1810 if(cutText != currentText && this.comboBox.filterStrategy.FilterCompareLower(newFilter)) { 1811 cbInputElement.value = cutText; 1812 ASPx.Selection.SetCaretPosition(cbInputElement, selInfo.startPos); 1813 } 1814 } 1815 }, 1816 OnEscape: function() { 1817 this.FilterStopTimer(); 1818 if(this.InCallback()) 1819 this.callbackProcessingStateManager.SetRollback(); 1820 }, 1821 OnUndo: function() { 1822 if(this.isCallbackMode) 1823 this.Filtering(); 1824 else { 1825 this.FilteringStopClient(); 1826 this.GetListBoxControl().EnsureSelectedItemVisible(); 1827 } 1828 }, 1829 OnApplyChanges: function () { 1830 if (this.IsFilterTimerActive()) { 1831 this.FilterNowAndApply(); 1832 return true; 1833 } 1834 return false; 1835 }, 1836 OnCancelChanges: function () { 1837 this.OnFilterRollback(); 1838 }, 1839 OnClearButtonClick: function () { 1840 if (!this.InCallback()) { 1841 this.FilteringStop(); 1842 if (this.isCallbackMode) 1843 this.Filtering(); 1844 } 1845 }, 1846 OnDropDownCloseByDocumentOrWindowEvent: function() { 1847 if(this.InCallback()) 1848 this.callbackProcessingStateManager.SetApply(); 1849 }, 1850 PreventEndCallbackRising: function() { 1851 this.comboBox.preventEndCallbackRising = true; 1852 }, 1853 OnBeforeCallbackFinally: function() { 1854 this.currentCallbackIsFiltration = false; 1855 }, 1856 OnAfterCallbackFinally: function() { 1857 var filterRollbackRequired = false; 1858 if(this.callbackProcessingStateManager.IsApply() || this.callbackProcessingStateManager.IsApplyAfterRollback()) { 1859 this.ApplyAfterFinalFiltrationCallback(); 1860 filterRollbackRequired = this.comboBox.IsFilterRollbackRequiredAfterApply(); 1861 } 1862 if(this.callbackProcessingStateManager.IsRollback()) 1863 filterRollbackRequired = true; 1864 this.callbackProcessingStateManager.OnCallbackResult(filterRollbackRequired); 1865 if(filterRollbackRequired) 1866 window.setTimeout(this.OnFilterRollback.bind(this), 0); 1867 }, 1868 OnPerformCallback: function() { 1869 this.ClearFilter(); 1870 }, 1871 CanNavigateByKbd: function() { 1872 return this.IsFilterMeetRequirementForMinLength(); 1873 }, 1874 ApplyAfterFinalFiltrationCallback: function() { 1875 var itemIsSelected = this.TrySelectItemAfterFilter(); 1876 this.comboBox.HideDropDownArea(); 1877 var requiredApplyFailed = this.comboBox.isDropDownListStyle && !itemIsSelected && this.comboBox.focused && this.callbackProcessingStateManager.IsApply(); 1878 if(requiredApplyFailed) 1879 this.comboBox.ShowDropDownArea(true); 1880 var needApplyChanges = itemIsSelected || !this.comboBox.focused; 1881 if(needApplyChanges) 1882 this.comboBox.OnApplyChangesInternal(); 1883 }, 1884 TrySelectItemAfterFilter: function() { 1885 var lb = this.GetListBoxControl(); 1886 if(!lb) return false; 1887 var selectedItem; 1888 if(this.isDropDownListStyle) 1889 selectedItem = lb.GetVisibleItemCount() == 1 ? lb.GetItem(0) : null; 1890 else 1891 selectedItem = lb.FindItemByText(this.filter); 1892 if(selectedItem) { 1893 lb.SelectIndexSilent(selectedItem.index); 1894 this.comboBox.SetTextInternal(selectedItem.text); 1895 } 1896 return !!selectedItem; 1897 }, 1898 IsEnabled: function() { 1899 return this.comboBox.GetEnabled(); 1900 }, 1901 Filtering: function(fromApi) { 1902 ASPx.ListEditIncrementalFilterStrategyBase.prototype.Filtering.call(this, fromApi); 1903 this.comboBox.EnsureClearButtonVisibility(); 1904 }, 1905 ShouldClearFilterBeforeFiltering: function(filter) { 1906 return this.TryRollbackLastSuccessText(this.GetInputFilterValue()); 1907 }, 1908 OnBeforeFiltering: function() { 1909 this.comboBox.onBeforeFiltering(); 1910 this.EnsureDropDownAreaStateBeforeFiltering(); 1911 if(this.isCallbackMode && !this.comboBox.droppedDown && this.comboBox.isNeedToForceFirstShowLoadingPanel) 1912 this.comboBox.ForceShowLoadingPanel(); 1913 }, 1914 OnAfterFiltering: function() { 1915 if(!this.isCallbackMode) 1916 this.ResetCallbackState(); 1917 },
1918 OnFilteringCancelled: function(filteringFromApi) { 1919 if(this.comboBox.isCallbackMode) { 1920 var firstItem = this.GetListBoxControl().GetItem(0); 1921 if(firstItem && firstItem.selected) { 1922 this.HighlightTextAfterCallback(firstItem.text); 1923 this.EnsureDropDownAreaStateBeforeFiltering(); 1924 } 1925 else if(filteringFromApi) 1926 this.EnsureDropDownAreaStateBeforeFiltering(); 1927 } 1928 this.ResetCallbackState(); 1929 }, 1930 OnFilterRollback: function() { 1931 if(this.InCallback() && this.currentCallbackIsFiltration) 1932 return; 1933 if(this.isCallbackMode && this.filterInitialized) { 1934 var listBox = this.GetListBoxControl(); 1935 this.callbackProcessingStateManager.SetApplyAfterRollback(); 1936 if(this.comboBox.GetText() != "" && this.comboBox.isDropDownListStyle) { 1937 listBox.ClearItems(); 1938 this.needEmptyFilterBeforeFiltering = false; 1939 var currentSelectedItemCbArgs = ASPx.FilteringUtils.FormatCallbackArg(currentSelectedItemCallbackPrefix, ""); 1940 this.comboBox.SendSpecialCallback(currentSelectedItemCbArgs); 1941 } else 1942 this.Filtering(); 1943 this.SetFilter(this.comboBox.GetText()); 1944 this.SetHighlighting(this.filter); 1945 this.ClearFilterApplied(); 1946 } 1947 }, 1948 NotifyCollectionChanged: function() { 1949 this.comboBox.CollectionChanged(true); 1950 }, 1951 TryProcessFilterLessMinLength: function(oldFilter) { 1952 this.comboBox.onProcessFilterLessMinLength(); 1953 this.ResetCallbackState(); 1954 this.GetListBoxControl().SelectIndexSilent(-1, false); 1955 return true; 1956 }, 1957 GetSelectedIndex: function() { 1958 return this.comboBox.GetSelectedIndex(); 1959 }, 1960 ResetCallbackState: function() { 1961 this.callbackProcessingStateManager.ResetState(); 1962 }, 1963 HighlightTextAfterCallback: function() { }, 1964 IsCloseByEnterLocked: function() { return false; }, 1965 TryRollbackLastSuccessText: function(filter) { 1966 if(this.comboBox.allowNull || filter) return false; 1967 var inpValue = this.comboBox.lastSuccessText; 1968 var inputElement = this.comboBox.GetInputElement(); 1969 if(this.comboBox.HasTextDecorators()) { 1970 this.comboBox.SetRawValue(inpValue); 1971 if(this.comboBox.CanApplyTextDecorators()) 1972 this.comboBox.SetInputValue(this.comboBox.GetDecoratedText(inpValue)); 1973 else 1974 this.comboBox.SetInputValue(inpValue); 1975 } 1976 else if(inputElement.value != inpValue) 1977 this.comboBox.SetInputValue(inpValue); 1978 if(this.comboBox.focused) 1979 ASPx.Selection.Set(inputElement, 0, inputElement.value.length); 1980 var lb = this.comboBox.GetListBoxControl(); 1981 if(lb) { 1982 if(this.comboBox.lastSuccessValue != null) 1983 lb.SetValue(this.comboBox.lastSuccessValue); 1984 else { 1985 var index = lb.FindItemIndexByText(this.comboBox.lastSuccessText); 1986 lb.SelectIndexSilent(index); 1987 } 1988 } 1989 this.comboBox.ShowCurrentItemImage(); 1990 return true; 1991 }, 1992 EnsureDropDownAreaStateBeforeFiltering: function() { 1993 var showDropDown = this.CanShowDropDownOnFocus(this.filter); 1994 if(this.callbackProcessingStateManager.NoFilterPostProcessing() && showDropDown) { 1995 var lb = this.GetListBoxControl(); 1996 if(lb) 1997 lb.LockScrollHandler(); 1998 this.EnsureShowDropDownArea(); 1999 if(lb) 2000 lb.UnlockScrollHandler(); 2001 } else if(!showDropDown) 2002 this.comboBox.HideDropDownArea(); 2003 }, 2004 EnsureShowDropDownArea: function() { 2005 if(!this.comboBox.droppedDown && this.comboBox.focused) { 2006 this.comboBox.CancelLoadCustomRangeOnDropDown(); 2007 this.comboBox.ShowDropDownArea(true); 2008 } 2009 }, 2010 CanShowDropDownOnFocus: function(filter) { 2011 if(filter != "") 2012 return true; 2013 return !!this.comboBox.showDropDownOnFocus ? this.comboBox.showDropDownOnFocus !== "Never" : true; 2014 }, 2015 AllowEmptyFilterResults: function() { 2016 return !this.comboBox.isDropDownListStyle; 2017 }, 2018 GetInputFilterValue: function() { 2019 var rawValue = this.comboBox.GetRawValue(); 2020 return rawValue !== null && rawValue !== undefined ? rawValue : this.comboBox.GetInputElement().value; 2021 }, 2022 GetListBoxControl: function() { 2023 return this.comboBox.GetListBoxControl(); 2024 }, 2025 OnBeforeFilteringOnClient: function(filter) { 2026 var comboBox = this.comboBox; 2027 if(comboBox.isDropDownListStyle) { 2028 if(this.GetInputFilterValue() != filter) 2029 comboBox.SetInputValue(filter); 2030 if(ASPx.IsExists(comboBox.GetRawValue())) 2031 comboBox.SetRawValue(filter); 2032 this.SetFilter(filter); 2033 } 2034 this.TryRollbackLastSuccessText(filter); 2035 }, 2036 OnAfterFilteringOnClientCore: function (filter, firstSatisfyItemIndex) { 2037 if(firstSatisfyItemIndex !== -1 && this.CanShowDropDownOnFocus(filter)) 2038 this.GetListBoxControl().CorrectCellWidthsOnFirstRowItemReplacement(0, firstSatisfyItemIndex); 2039 else { 2040 this.comboBox.onNoResultsFiltering(); 2041 if(!this.comboBox.isDropDownModal()) 2042 this.comboBox.HideDropDownArea(true); 2043 } 2044 this.needEmptyFilterBeforeFiltering = false; 2045 }, 2046 FilteringStop: function() { 2047 if(!this.isCallbackMode) 2048 this.FilteringStopClient(); 2049 }, 2050 FilteringStopClient: function() { 2051 this.MakeAllItemsVisible(); 2052 this.ClearFilter();
2053 this.DiscardHighlighting(); 2054 }, 2055 MakeAllItemsVisible: function() { 2056 ASPx.ListEditIncrementalFilterStrategyBase.prototype.MakeAllItemsVisible.call(this); 2057 this.NotifyCollectionChanged(); 2058 }, 2059 FilterNowAndApply: function() { 2060 this.callbackProcessingStateManager.SetApply(); 2061 this.Filtering(); 2062 if(!this.comboBox.isCallbackMode) 2063 this.comboBox.OnApplyChangesInternal(); 2064 }, 2065 InCallback: function() { 2066 return this.comboBox.InCallback(); 2067 }, 2068 OnCallbackCore: function(highlighting, newFilterLength) { 2069 if(this.currentCallbackIsFiltration) { 2070 var lb = this.GetListBoxControl(); 2071 if(!lb.GetItemCount() || !this.CanShowDropDownOnFocus(this.filter)) { 2072 this.comboBox.onNoResultsFiltering(); 2073 if(!this.comboBox.isDropDownModal()) 2074 this.comboBox.HideDropDownArea(true); 2075 } 2076 else { 2077 this.OnFilterCallbackHighlightAndSelect(highlighting, newFilterLength); 2078 var isNeedToKeepDropDownVisible = !this.comboBox.isPerformCallback && this.callbackProcessingStateManager.NoFilterPostProcessing(); 2079 if(!this.CanShowDropDownOnFocus(this.filter)) 2080 this.comboBox.HideDropDownArea(); 2081 else if(isNeedToKeepDropDownVisible) 2082 this.EnsureShowDropDownArea(); 2083 this.OnEndFiltering(); 2084 } 2085 } 2086 else 2087 this.RefreshHighlighting(); 2088 }, 2089 OnFilterCallbackHighlightAndSelect: function(highlighting, newFilterLength) { 2090 var listBox = this.GetListBoxControl(); 2091 var firstItemText = listBox.GetItem(0).text; 2092 var isTextClearing = !this.comboBox.allowNull && this.IsEmptyFilter() && firstItemText; 2093 if(!isTextClearing) { 2094 var isFilterRollBack = this.CheckForFilterRollback(newFilterLength); 2095 var isNonFilterChangingCallback = (listBox.GetSelectedItem() == null); 2096 this.isTotallyMismatchedFilter = this.TryRollbackLastSuccessText(this.filter); 2097 var isNullState = this.comboBox.allowNull && !this.filter && !listBox.FindItemByText(this.filter); 2098 if(!this.isTotallyMismatchedFilter && !isNullState) 2099 this.SetHighlighting(this.filter, highlighting); 2100 if(!this.isTotallyMismatchedFilter && !isNullState && (isFilterRollBack || isNonFilterChangingCallback)) 2101 this.HighlightTextAfterCallback(firstItemText); 2102 else 2103 this.DiscardHighlighting(); 2104 } 2105 else 2106 this.TryRollbackLastSuccessText(this.filter); 2107 }, 2108 CheckForFilterRollback: function(newFilterLength) { 2109 var filter = ASPx.Str.PrepareStringForFilter(this.filter); 2110 if(typeof(newFilterLength) === "number" && filter.length > newFilterLength) { 2111 var inputText = this.GetCutInputText(this.filter, newFilterLength); 2112 this.SetFilter(filter.substring(0, newFilterLength)); 2113 this.comboBox.SetInputValue(inputText); 2114 return true; 2115 } 2116 return false; 2117 }, 2118 GetCutInputText: function(text, textLength) { 2119 var saveCaseSensitive = true; 2120 var result = ASPx.Str.PrepareStringForFilter(text, saveCaseSensitive); 2121 return result.substring(0, textLength); 2122 }, 2123 SendCallbackCore: function() { 2124 this.comboBox.SendCallback(); 2125 }, 2126 SupportsFilterCorrection: function() { 2127 return this.isDropDownListStyle; 2128 }, 2129 SetListBoxSuggestionSelection: function() { 2130 var lb = this.GetListBoxControl(); 2131 var singleItem = lb && lb.GetVisibleItemCount() == 1; 2132 var canSuggest = this.comboBox.isDropDownListStyle && this.comboBox.droppedDown && singleItem; 2133 var itemIndex = -1; 2134 if(canSuggest) { 2135 itemIndex = lb.GetFirstFilteredItemIndex(); 2136 this.comboBox.SelectIndexSilent(lb, itemIndex); 2137 } 2138 if(this.comboBox.accessibilityCompliant) 2139 this.comboBox.GetAccessibilityHelper().SetLabelAttribute(canSuggest ? lb.GetItem(itemIndex).text : this.GetInputFilterValue(), canSuggest); 2140 }, 2141 FilteringBackspace: function() { 2142 var currentText = this.GetInputFilterValue(); 2143 if(currentText.length) 2144 this.comboBox.SetInputValue(currentText.slice(0, -1)); 2145 this.FilterStartTimer(); 2146 }, 2147 RaiseItemFilteringEvent: function(item, filter, isFit) { 2148 return this.comboBox.RaiseItemFiltering(item, filter, isFit); 2149 }, 2150 RaiseCustomHighlightingEvent: function(filter, callbackHighlighting) { 2151 return this.comboBox.RaiseCustomHighlighting(filter, callbackHighlighting); 2152 } 2153}); 2154var ComboBoxContainsFilterStrategy = ASPx.CreateClass(ComboBoxIncrementalFilterStrategyBase, { 2155 IsSatisfy: function(text, filter) { 2156 return ASPx.Str.PrepareStringForFilter(text).indexOf(filter) != -1; 2157 }, 2158 OnDropDownHideArea: function() { 2159 if(!this.isCallbackMode) 2160 this.FilteringStopClient(); 2161 }, 2162 OnDropDownButtonClick: function() { 2163 var lb = this.GetListBoxControl(); 2164 if(lb && lb.GetVisibleItemCount() == 0 && this.isDropDownListStyle) 2165 this.comboBox.OnCancelChanges(); 2166 }, 2167 OnTextChanged: function() { 2168 if(!this.comboBox.IsFocusEventsLocked()) 2169 if(!this.comboBox.ChangedByEnterKeyPress()) 2170 this.OnFilterRollback(); 2171 }, 2172 OnBeforeCallbackFinally: function () {
2173 this.RefreshHighlighting(); 2174 this.SetListBoxSuggestionSelection(); 2175 ComboBoxIncrementalFilterStrategyBase.prototype.OnBeforeCallbackFinally.call(this); 2176 }, 2177 OnEndFiltering: function(visibleCollectionChanged) { 2178 ComboBoxIncrementalFilterStrategyBase.prototype.OnEndFiltering.call(this, visibleCollectionChanged); 2179 this.SetListBoxSuggestionSelection(); 2180 }, 2181 IsCloseByEnterLocked: function() { 2182 if(this.comboBox.isDropDownListStyle) { 2183 if(this.IsFilterTimerActive()) return false; 2184 var lb = this.GetListBoxControl(); 2185 if(lb && lb.GetVisibleItemCount() == 1) return false; 2186 var selectedItem = this.comboBox.GetSelectedItem(); 2187 if(selectedItem) 2188 if(this.GetInputFilterValue() == selectedItem.text) 2189 return false; 2190 return true; 2191 } 2192 return false; 2193 }, 2194}); 2195var ComboBoxStartsWithFilterStrategy = ASPx.CreateClass(ComboBoxIncrementalFilterStrategyBase, { 2196 HighlightTextAfterCallback: function(firstItemText) { 2197 var lb = this.GetListBoxControl(); 2198 this.FilteringHighlightCompletedText(firstItemText); 2199 if(this.comboBox.accessibilityCompliant) 2200 this.comboBox.GetAccessibilityHelper().SetLabelAttribute(firstItemText, true); 2201 if(!this.comboBox.isPerformCallback) 2202 this.comboBox.SelectIndexSilent(lb, 0); 2203 }, 2204 OnFirstSatisfiedItemFound: function(index, text, isTextClearing) { 2205 if(this.needEmptyFilterBeforeFiltering && isTextClearing) return; 2206 var lb = this.GetListBoxControl(); 2207 if(!isTextClearing) 2208 this.FilteringHighlightCompletedText(text); 2209 this.comboBox.SelectIndexSilent(lb, isTextClearing ? -1 : index, true); 2210 }, 2211 FilteringHighlightCompletedText: function(filterItemText) { 2212 var input = this.comboBox.GetInputElement(); 2213 ASPx.StartWithFilteringUtils.HighlightSuggestedText(input, filterItemText, this.comboBox, 2214 this.comboBox.restartCurrentUserInputTimer.bind(this.comboBox)); 2215 if(ASPx.IsExists(this.comboBox.GetRawValue())) 2216 this.comboBox.SyncRawValueIfHasTextDecorators(false); 2217 }, 2218 IsSatisfy: function(text, filter) { 2219 return ASPx.Str.PrepareStringForFilter(text).indexOf(filter) == 0; 2220 }, 2221 OnDropDownHideArea: function() { 2222 this.FilteringStop(); 2223 }, 2224 OnEndFiltering: function(visibleCollectionChanged) { 2225 ComboBoxIncrementalFilterStrategyBase.prototype.OnEndFiltering.call(this, visibleCollectionChanged); 2226 var selectedItem = this.GetListBoxControl().GetSelectedItem(); 2227 if (selectedItem) 2228 this.GetListBoxControl().MakeItemVisible(selectedItem.index); 2229 if(this.comboBox.accessibilityCompliant) { 2230 this.comboBox.GetAccessibilityHelper().SetLabelAttribute(!!selectedItem ? selectedItem.text : this.GetInputFilterValue(), !!selectedItem); 2231 } 2232 }, 2233 OnAfterEnter: function() { 2234 var inputElement = this.comboBox.GetInputElement(); 2235 ASPx.Selection.SetCaretPosition(inputElement); 2236 }, 2237 TrySelectItemAfterFilter: function() { 2238 var lb = this.GetListBoxControl(); 2239 var selectedItem = lb.GetItem(0); 2240 return !!selectedItem; 2241 } 2242}); 2243ASPx.ComboBoxDisabledFilterStrategy = ComboBoxDisabledFilterStrategy; 2244ASPx.ComboBoxContainsFilterStrategy = ComboBoxContainsFilterStrategy; 2245ASPx.ComboBoxStartsWithFilterStrategy = ComboBoxStartsWithFilterStrategy; 2246window.ASPxClientComboBoxBase = ASPxClientComboBoxBase; 2247window.ASPxClientComboBox = ASPxClientComboBox; 2248window.ASPxClientNativeComboBox = ASPxClientNativeComboBox; 2249})(); 2250 2251},12);
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.