1// Name: ComboBox.ComboBox.debug.js 2// Assembly: AjaxControlToolkit 3// Version: 3.5.7.1213 4// FileVersion: 3.5.7.1213 5/// <reference name="MicrosoftAjax.js"/> 6 7 8Type.registerNamespace('Sys.Extended.UI'); 9 10Sys.Extended.UI.ComboBoxAutoCompleteMode = function () { }; 11Sys.Extended.UI.ComboBoxAutoCompleteMode.prototype = 12{ 13 None: 0, 14 Append: 1, 15 Suggest: 2, 16 SuggestAppend: 3 17}; 18Sys.Extended.UI.ComboBoxAutoCompleteMode.registerEnum( 19 'Sys.Extended.UI.ComboBoxAutoCompleteMode', false); 20 21Sys.Extended.UI.ComboBoxStyle = function () { }; 22Sys.Extended.UI.ComboBoxStyle.prototype = 23{ 24 DropDownList: 0, 25 DropDown: 1, 26 Simple: 2 27}; 28Sys.Extended.UI.ComboBoxStyle.registerEnum( 29 'Sys.Extended.UI.ComboBoxStyle', false); 30 31Sys.Extended.UI.ComboBoxTextSelectionStrategy = function () { }; 32Sys.Extended.UI.ComboBoxTextSelectionStrategy.prototype = 33{ 34 Unknown: 0, 35 Microsoft: 1, 36 W3C: 2 37}; 38Sys.Extended.UI.ComboBoxTextSelectionStrategy.registerEnum( 39 "Sys.Extended.UI.ComboBoxTextSelectionStrategy", false); 40 41 42Sys.Extended.UI.ComboBox = function (element) { 43 44 Sys.Extended.UI.ComboBox.initializeBase(this, [element]); 45 46 this._comboTableControl = null; 47 this._textBoxControl = null; 48 this._optionListControl = null; 49 this._buttonControl = null; 50 this._hiddenFieldControl = null; 51 this._autoPostBack = false; 52 this._autoCompleteMode = null; 53 this._dropDownStyle = null; 54 this._caseSensitive = false; 55 this._originalSelectedIndex = null; 56 this._listItemHoverCssClass = null; 57 58 this._popupBehavior = null; 59 this._supressFocusHide = true; 60 this._doingPostBack = false; 61 this._textSelectionStrategy = null; 62 this._highlightSuggestedItem = false; 63 this._highlightedIndex = null; 64 65 this._optionListItems = null; 66 this._optionListItemHeight = null; 67 this._optionListHeight = null; 68 this._optionListWidth = null; 69 70 this.clearDelegates(); 71 72}; 73Sys.Extended.UI.ComboBox.prototype = { 74 75 initialize: function () { 76 77 Sys.Extended.UI.ComboBox.callBaseMethod(this, 'initialize'); 78 ComboBox_Elements[ComboBox_Elements.length] = this; 79 var hiddenParent = this._findHiddenParent(this.get_comboTableControl()); 80 var hiddenParentDisplay; 81 var hiddenParentVisibility; 82 if (hiddenParent != null) { 83 hiddenParentDisplay = hiddenParent.style.display; 84 hiddenParentVisibility = hiddenParent.style.visibility; 85 hiddenParent.style.visibility = "visible"; 86 hiddenParent.style.display = "block"; 87 } 88 this.createDelegates(); 89 this.initializeTextBox(); 90 this.initializeButton(); 91 this.initializeOptionList(); 92 this.addHandlers(); 93 if (hiddenParent != null) { 94 hiddenParent.style.visibility = hiddenParentVisibility; 95 hiddenParent.style.display = hiddenParentDisplay; 96 } 97 }, 98 dispose: function () { 99 100 if (this._popupBehavior) { 101 this._popupBehavior.remove_showing(this._popupShowingHandler); 102 this._popupBehavior.remove_shown(this._popupShownHandler); 103 this._popupBehavior.remove_hiding(this._popupHidingHandler); 104 this._popupBehavior.dispose(); 105 this._popupBehavior = null; 106 } 107 108 this.clearHandlers(); 109 this.clearDelegates(); 110 111 Sys.Extended.UI.ComboBox.callBaseMethod(this, 'dispose'); 112 113 }, 114 115 _findHiddenParent: function (element) { 116 var parent = element.parentElement; 117 if (parent == null || parent.style.visibility == "hidden" || parent.style.display == 'none') { 118 return parent; 119 } 120 121 return this._findHiddenParent(parent); 122 }, 123 124 createDelegates: function () { 125 126 this._listMouseOverHandler = Function.createDelegate(this, this._onListMouseOver); 127 this._listMouseOutHandler = Function.createDelegate(this, this._onListMouseOut); 128 this._listMouseDownHandler = Function.createDelegate(this, this._onListMouseDown);
129 this._listClickHandler = Function.createDelegate(this, this._onListClick); 130 this._listDragHandler = Function.createDelegate(this, this._onListDrag); 131 this._listSelectStartHandler = Function.createDelegate(this, this._onListSelectStart); 132 this._listMouseWheelHandler = Function.createDelegate(this, this._onListMouseWheel); 133 this._textBoxClickHandler = Function.createDelegate(this, this._onTextBoxClick); 134 this._textBoxFocusHandler = Function.createDelegate(this, this._onTextBoxFocus); 135 this._textBoxBlurHandler = Function.createDelegate(this, this._onTextBoxBlur); 136 this._textBoxKeyPressHandler = Function.createDelegate(this, this._onTextBoxKeyPress); 137 this._textBoxKeyDownHandler = Function.createDelegate(this, this._onTextBoxKeyDown); 138 this._buttonClickHandler = Function.createDelegate(this, this._onButtonClick); 139 this._buttonBlurHandler = Function.createDelegate(this, this._onButtonBlur); 140 this._buttonKeyDownHandler = Function.createDelegate(this, this._onButtonKeyDown); 141 this._buttonKeyPressHandler = Function.createDelegate(this, this._onButtonKeyPress); 142 this._documentClickHandler = Function.createDelegate(this, this._onDocumentClick); 143 this._documentMouseWheelHandler = Function.createDelegate(this, this._onDocumentMouseWheel); 144 this._popupShowingHandler = Function.createDelegate(this, this._popupShowing); 145 this._popupShownHandler = Function.createDelegate(this, this._popupShown); 146 this._popupHidingHandler = Function.createDelegate(this, this._popupHiding); 147 148 }, 149 clearDelegates: function () { 150 151 this._listMouseOverHandler = null; 152 this._listMouseOutHandler = null; 153 this._listMouseDownHandler = null; 154 this._listClickHandler = null; 155 this._listDragHandler = null; 156 this._listSelectStartHandler = null; 157 this._listMouseWheelHandler = null; 158 this._textBoxClickHandler = null; 159 this._textBoxFocusHandler = null; 160 this._textBoxBlurHandler = null; 161 this._textBoxKeyPressHandler = null; 162 this._textBoxKeyDownHandler = null; 163 this._buttonClickHandler = null; 164 this._buttonBlurHandler = null;
165 this._buttonKeyDownHandler = null; 166 this._buttonKeyPressHandler = null; 167 this._documentClickHandler = null; 168 this._documentMouseWheelHandler = null; 169 this._popupShowingHandler = null; 170 this._popupShownHandler = null; 171 this._popupHidingHandler = null; 172 173 }, 174 addHandlers: function () { 175 176 var optionListControl = this.get_optionListControl(); 177 178 $addHandlers(optionListControl, 179 { 180 'mouseover': this._listMouseOverHandler, 181 'mouseout': this._listMouseOutHandler, 182 'mousedown': this._listMouseDownHandler, 183 'click': this._listClickHandler, 184 'drag': this._listDragHandler, 185 'selectstart': this._listSelectStartHandler 186 }, this); 187 188 $addHandlers(this.get_textBoxControl(), 189 { 190 "click": this._textBoxClickHandler, 191 "focus": this._textBoxFocusHandler, 192 "blur": this._textBoxBlurHandler, 193 "keypress": this._textBoxKeyPressHandler 194 }, this); 195 196 if (Sys.Browser.agent == Sys.Browser.InternetExplorer || Sys.Browser.agent === Sys.Browser.Safari 197 || Sys.Browser.agent === Sys.Browser.WebKit) { 198 $addHandler(this.get_textBoxControl(), "keydown", this._textBoxKeyDownHandler); 199 } 200 201 $addHandlers(this.get_buttonControl(), 202 { 203 'click': this._buttonClickHandler, 204 'blur': this._buttonBlurHandler,
205 'keydown': this._buttonKeyDownHandler, 206 'keypress': this._buttonKeyPressHandler 207 }, this); 208 209 $addHandler(document, 'click', this._documentClickHandler); 210 211 if (typeof (optionListControl.onmousewheel) === 'undefined') { 212 $addHandler(optionListControl, 'DOMMouseScroll', this._listMouseWheelHandler); 213 $addHandler(document, 'DOMMouseScroll', this._documentMouseWheelHandler); 214 } 215 else { 216 $addHandler(optionListControl, 'mousewheel', this._listMouseWheelHandler); 217 $addHandler(document, 'mousewheel', this._documentMouseWheelHandler); 218 } 219 }, 220 clearHandlers: function () { 221 222 $clearHandlers(this.get_optionListControl()); 223 $clearHandlers(this.get_textBoxControl()); 224 $clearHandlers(this.get_buttonControl()); 225 $clearHandlers(document); 226 }, 227 initializeTextBox: function () { 228 229 var style = this.get_textBoxControl().style; 230 231 if (style.margin == '') 232 style.margin = '0px'; 233 234 }, 235 initializeButton: function () { 236 237 var style = this.get_buttonControl().style; 238 239 if (style.height == '' && this.get_textBoxControl().offsetHeight >= 0) 240 style.height = this.get_textBoxControl().offsetHeight + 'px'; 241 if (style.width == '') 242 style.width = style.height; 243 244 if (style.margin == '') 245 style.margin = '0px'; 246 if (style.padding == '') 247 style.padding = '0px'; 248 249 this._buttonControl.style.visibility = 'visible'; 250 251 }, 252 initializeOptionList: function () { 253 254 if (this.get_optionListControl() == null) { 255 var optionList = document.createElement('ul'); 256 this.get_element().appendChild(optionList); 257 this.set_optionListControl(optionList); 258 } 259 var optionListControl = this.get_optionListControl(); 260 261 if (Sys.Browser.agent === Sys.Browser.Safari || Sys.Browser.agent === Sys.Browser.WebKit) { 262 var parentOfOptionList = optionListControl.parentNode; 263 if (parentOfOptionList != null) 264 parentOfOptionList.removeChild(optionListControl); 265 266 var parent = this.get_element().parentNode; 267 while (typeof (parent) != typeof (document.forms[0])) { 268 parent = parent.parentNode; 269 } 270 var safariListContainer = document.createElement('div'); 271 safariListContainer.className = this.get_element().className; 272 safariListContainer.appendChild(optionListControl); 273 parent.appendChild(safariListContainer); 274 } 275 276 var style = optionListControl.style; 277 278 style.display = 'block'; 279 style.zIndex = '10000'; 280 281 this._optionListItems = new Array(); 282 var children = optionListControl.childNodes; 283 for (var i = 0; i < children.length; i++) { 284 285 var child = children[i]; 286 287 if (child.tagName == undefined || child.tagName.toUpperCase() != 'LI') { 288 optionListControl.removeChild(child); 289 i--; 290 continue; 291 } 292 293 var item = new Object(); 294 var text = child.innerHTML.trim(); 295 296 var indexOfCarriageReturn = text.indexOf('\r'); 297 while (indexOfCarriageReturn >= 0) { 298 text = text.substring(0, indexOfCarriageReturn).trim() 299 + ' ' + text.substring(indexOfCarriageReturn + 1, text.length).trim(); 300 indexOfCarriageReturn = text.indexOf('\r'); 301 } 302 303 var indexOfNewline = text.indexOf('\n'); 304 while (indexOfNewline >= 0) { 305 text = text.substring(0, indexOfNewline).trim() 306 + ' ' + text.substring(indexOfNewline + 1, text.length).trim(); 307 indexOfNewline = text.indexOf('\n'); 308 } 309 310 text = text.replace(/\&/g, '&') 311 .replace(/\"/g, '"') 312 .replace(/\>/g, '>') 313 .replace(/\</g, '<'); 314 315 item.text = text.trim(); 316 Array.add(this._optionListItems, item); 317 318 this.initializeOptionListItem(child); 319 } 320 321 style.width = this._getOptionListBounds().width + 'px'; 322 style.width = '0px'; 323 324 this._popupBehavior = $create(Sys.Extended.UI.PopupBehavior, 325 { 326 'id': this.get_id() + '_PopupBehavior' 327 , 'parentElement': this.get_textBoxControl() 328 , "positioningMode": Sys.Extended.UI.PositioningMode.BottomLeft 329 }, null, null, optionListControl); 330 this._popupBehavior.add_showing(this._popupShowingHandler); 331 this._popupBehavior.add_shown(this._popupShownHandler); 332 this._popupBehavior.add_hiding(this._popupHidingHandler); 333 334 if (this.get_selectedIndex() >= 0) { 335 this._highlightListItem(this.get_selectedIndex()); 336 this.get_textBoxControl().value = this._optionListItems[this.get_selectedIndex()].text; 337 } 338 else { 339 this.get_textBoxControl().value = ''; 340 } 341 342 this._popupShowing(); 343 optionListControl.style.display = "none"; 344 345 }, 346 initializeOptionListItem: function (liElement) { 347 348 liElement._textIsEmpty = false; 349 if (liElement.innerHTML.length < 1) { 350 liElement.innerHTML = ' '; 351 liElement._textIsEmpty = true; 352 } 353 354 }, 355 _popupShowing: function () { 356 357 var windowBounds = this._getWindowBounds(); 358 var tableBounds = Sys.UI.DomElement.getBounds(this.get_comboTableControl()); 359 var optionListBounds = this._getOptionListBounds(); 360 var safetyDimension = 30; 361 362 var yThreshold = windowBounds.y + (windowBounds.height / 2); 363 var yFlopPoint = tableBounds.y + tableBounds.height; 364 var xThreshold = windowBounds.x + (windowBounds.width / 2); 365 var xFlopPoint = tableBounds.x + (tableBounds.width / 2); 366 367 var maxHeight = tableBounds.y - windowBounds.y; 368 var yAlign = 'Top'; 369 if (yFlopPoint <= yThreshold) { 370 yAlign = 'Bottom'; 371 maxHeight = windowBounds.height - tableBounds.height - maxHeight; 372 } 373 374 var itemHeight = this._getOptionListItemHeight(); 375 if (maxHeight >= optionListBounds.height) { 376 maxHeight = optionListBounds.height; 377 } 378 else { 379 maxHeight = itemHeight * ((Math.floor(maxHeight / itemHeight)) - 2); 380 } 381 var visibleItems = maxHeight / itemHeight; 382 var yScrollbar = (visibleItems < this._optionListItems.length); 383 var scrollbarWidth = 20; 384 385 if (yAlign == "Top" && maxHeight < (windowBounds.height - tableBounds.y)) { 386 yAlign = "Bottom"; 387 } 388 389 var maxWidth = tableBounds.x - windowBounds.x; 390 var xAlign = 'Left'; 391 if (xFlopPoint <= xThreshold) { 392 maxWidth = windowBounds.width - maxWidth; 393 } 394 else { 395 xAlign = 'Right'; 396 maxWidth = tableBounds.width + maxWidth; 397 } 398 399 maxWidth -= safetyDimension; 400 401 var bestWidth = optionListBounds.width; 402 if (yScrollbar) { 403 bestWidth += scrollbarWidth; 404 if (maxWidth >= bestWidth) { 405 maxWidth = bestWidth; 406 } 407 } 408 else if (maxWidth >= bestWidth) { 409 maxWidth = bestWidth; 410 } 411 412 if (xAlign == "Right" && maxWidth < (windowBounds.width - tableBounds.x)) { 413 xAlign = "Left"; 414 } 415 416 if (maxHeight < 0) { 417 maxHeight = 0; 418 } 419 if (maxWidth < 0) { 420 maxWidth = 0; 421 } 422 423 var style = this.get_optionListControl().style; 424 style.height = maxHeight + 'px'; 425 style.width = maxWidth + 'px'; 426 427 if (yScrollbar) { 428 style.overflow = 'auto'; 429 style.overflowX = 'hidden'; 430 } 431 else { 432 style.overflow = 'hidden'; 433 } 434 435 var compositeAlign = yAlign + xAlign; 436 if (compositeAlign == 'BottomLeft') 437 this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.BottomLeft); 438 else if (compositeAlign == 'BottomRight') 439 this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.BottomRight); 440 else if (compositeAlign == 'TopLeft') 441 this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.TopLeft); 442 else if (compositeAlign == 'TopRight') 443 this._popupBehavior.set_positioningMode(Sys.Extended.UI.PositioningMode.TopRight); 444 445 style.visibility = 'hidden'; 446 447 }, 448 _popupShown: function () { 449 450 var optionListControl = this.get_optionListControl(); 451 optionListControl.style.display = 'block'; 452 453 var tableBounds = Sys.UI.DomElement.getBounds(this.get_comboTableControl()); 454 var listBounds = Sys.UI.DomElement.getBounds(optionListControl); 455 var textBoxBounds = Sys.UI.DomElement.getBounds(this.get_textBoxControl()); 456 var y = listBounds.y; 457 var x; 458 459 if (this._popupBehavior.get_positioningMode() === Sys.Extended.UI.PositioningMode.BottomLeft 460 || this._popupBehavior.get_positioningMode() === Sys.Extended.UI.PositioningMode.TopLeft) { 461 x = textBoxBounds.x; 462 } 463 else if (this._popupBehavior.get_positioningMode() === Sys.Extended.UI.PositioningMode.BottomRight 464 || this._popupBehavior.get_positioningMode() === Sys.Extended.UI.PositioningMode.TopRight) { 465 x = textBoxBounds.x - (listBounds.width - textBoxBounds.width); 466 } 467 468 Sys.UI.DomElement.setLocation(optionListControl, x, y); 469 470 this._ensureHighlightedIndex(); 471 this._ensureScrollTop(); 472 473 optionListControl.style.visibility = 'visible'; 474 475 }, 476 _popupHiding: function () { 477 478 this._highlightSuggestedItem = false; 479 480 var style = this.get_optionListControl().style; 481 style.display = 'none'; 482 style.visibility = 'hidden'; 483 484 }, 485 _onButtonClick: function (e) { 486 Sys.Extended.UI.ComboBox.IsOpen(this); 487 if (this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.Simple) { 488 this._popupBehavior.show(); 489 } 490 491 else if (this._popupBehavior._visible) { 492 this._popupBehavior.hide(); 493 } 494 else { 495 this._popupBehavior.show(); 496 } 497 498 e.preventDefault(); 499 e.stopPropagation(); 500 return false; 501 502 }, 503 _onButtonBlur: function (e) { 504 505 if (this.get_autoPostBack() == true && !this._doingPostBack && this._originalSelectedIndex != this.get_selectedIndex()) { 506 this._doingPostBack = true;
507 __doPostBack(this.get_element().id, ''); 508 } 509 510 }, 511 _onButtonKeyDown: function (e) { 512 513 if (e.keyCode == Sys.UI.Key.tab || e.keyCode == 16) { // 16==SHIFT key 514 return true; 515 } 516 517 if (!this._popupBehavior._visible && (e.keyCode == Sys.UI.Key.enter || e.keyCode == Sys.UI.Key.down)) { 518 this._popupBehavior.show(); 519 } 520 else if (this._popupBehavior._visible && (e.keyCode == Sys.UI.Key.enter || e.keyCode == Sys.UI.Key.up)) { 521 this._popupBehavior.hide(); 522 } 523 524 e.stopPropagation(); 525 e.preventDefault(); 526 527 var textBoxID = this.get_textBoxControl().id; 528 setTimeout(function () { document.getElementById(textBoxID).focus(); }, 0); 529 return false; 530 531 }, 532 _onButtonKeyPress: function (e) { 533 534 if (e.charCode == Sys.UI.Key.tab || e.charCode == 16) { // 16==SHIFT key 535 return true; 536 } 537 e.stopPropagation(); 538 e.preventDefault(); 539 return false; 540 541 }, 542 _onListMouseWheel: function (e) { 543 544 var direction; 545 546 if (typeof (e.rawEvent.wheelDelta) === 'undefined') { 547 direction = (e.rawEvent.detail >= 1) ? 1 : -1; 548 } 549 else { 550 direction = (e.rawEvent.wheelDelta > 1) ? -1 : 1; 551 } 552 553 this.get_optionListControl().scrollTop += this._getOptionListItemHeight() * direction; 554 555 e.stopPropagation(); 556 e.preventDefault(); 557 return false; 558 559 }, 560 _onListMouseOver: function (e) { 561 var optionListControl = this.get_optionListControl(); 562 if (e.target !== optionListControl) { 563 var target = e.target; 564 var children = optionListControl.childNodes; 565 566 for (var i = 0; i < children.length; ++i) { 567 if (target === children[i]) { 568 this._highlightListItem(i, true); 569 break; 570 } 571 } 572 } 573 574 }, 575 _onListMouseOut: function (e) { 576 577 if (this._popupBehavior._visible 578 && this.get_autoCompleteMode() == Sys.Extended.UI.ComboBoxAutoCompleteMode.SuggestAppend) { 579 this._highlightListItem(this._highlightedIndex, false); 580 } 581 582 }, 583 _onListMouseDown: function (e) { 584 var optionListControl = this.get_optionListControl(); 585 586 if (e.target == optionListControl || e.target.tagName == 'scrollbar') { 587 return true; 588 } 589 590 if (e.target !== optionListControl) { 591 var highlightedItem = optionListControl.childNodes[this._highlightedIndex], 592 text = this._optionListItems[this._highlightedIndex].text; 593 this.get_textBoxControl().value = text; 594 this.set_selectedIndex(this._highlightedIndex); 595 596 this._supressFocusHide = false; 597 this._handleTextBoxFocus(null); 598 599 } 600 else { 601 return true; 602 } 603 e.preventDefault(); 604 e.stopPropagation(); 605 return false; 606 607 }, 608 _onListClick: function (e) { 609 610 if (e.target == this.get_optionListControl()) { 611 return true; 612 } 613 614 e.preventDefault(); 615 e.stopPropagation(); 616 return false; 617 618 }, 619 _onListDrag: function (e) { 620 621 e.preventDefault(); 622 e.stopPropagation(); 623 return false; 624 625 }, 626 _onListSelectStart: function (e) { 627 628 e.preventDefault(); 629 e.stopPropagation(); 630 return false; 631 632 }, 633 _onTextBoxClick: function (e) { 634 635 if (this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.Simple) { 636 this._popupBehavior.show(); 637 } 638 639 e.preventDefault(); 640 e.stopPropagation(); 641 return false; 642 643 }, 644 _onTextBoxFocus: function (e) { 645 Sys.Extended.UI.ComboBox.IsOpen(this); 646 this._handleTextBoxFocus(e); 647 648 }, 649 _onTextBoxBlur: function (e) { 650 651 var textBoxValue = this.get_textBoxControl().value.trim(); 652 var matchedIndex = -3; 653 654 for (var i = 0; i < this._optionListItems.length; i++) { 655 var item = this._optionListItems[i]; 656 if (this._isExactMatch(item.text, textBoxValue)) { 657 matchedIndex = i; 658 break; 659 } 660 } 661 662 if (this._highlightSuggestedItem == true && this._highlightedIndex != null && this._highlightedIndex >= 0) { 663 this.set_selectedIndex(this._highlightedIndex); 664 this.get_textBoxControl().value = this._optionListItems[this.get_selectedIndex()].text; 665 } 666 667 else if (matchedIndex == -3 && textBoxValue.length > 0 668 && this.get_dropDownStyle() != Sys.Extended.UI.ComboBoxStyle.DropDownList) { 669 this.set_selectedIndex(-2); 670 } 671 672 else if (this._optionListItems.length < 1 && (textBoxValue == '' 673 || this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.DropDownList)) { 674 this.set_selectedIndex(-1); 675 this.get_textBoxControl().value = ''; 676 } 677 678 else if (this._optionListItems.length >= 0 && matchedIndex == -3 679 && this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.DropDownList) { 680 this.set_selectedIndex(0); 681 this.get_textBoxControl().value = this._optionListItems[0].text; 682 } 683 684 else if (matchedIndex >= 0) { 685 this.set_selectedIndex(matchedIndex); 686 this.get_textBoxControl().value = this._optionListItems[matchedIndex].text; 687 } 688 689 this._popupBehavior.hide(); 690 if (this.get_autoPostBack() == true && !this._doingPostBack && this._originalSelectedIndex != this.get_selectedIndex()) { 691 this._doingPostBack = true;
692 __doPostBack(this.get_element().id, ''); 693 } 694 695 }, 696 _onTextBoxKeyDown: function (e) { 697 698 699 var enterResult = this._handleEnterKey(e); 700 if (enterResult != null) { 701 return enterResult; 702 } 703 704 this._handleArrowKey(e); 705 706 var erasureKeyResult = this._handleErasureKeys(e); 707 if (erasureKeyResult != null) { 708 return erasureKeyResult; 709 } 710 711 return true; 712 713 }, 714 _onTextBoxKeyPress: function (e) { 715 716 var enterResult = this._handleEnterKey(e); 717 if (enterResult != null) { 718 return enterResult; 719 } 720 721 var arrowResult = this._handleArrowKey(e); 722 if (arrowResult != null) { 723 return arrowResult; 724 } 725 726 var nonCharacterKeyResult = this._handleNonCharacterKey(e); 727 if (nonCharacterKeyResult != null) { 728 return nonCharacterKeyResult; 729 } 730 731 if (this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.Simple && !this._popupBehavior._visible) { 732 this._popupBehavior.show(); 733 } 734 735 if (this.get_selectedIndex() == -1 && this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.DropDownList) { 736 this.get_textBoxControl().value = ''; 737 e.preventDefault(); 738 e.stopPropagation(); 739 return false; 740 } 741 742 var info = this._getTextSelectionInfo(this.get_textBoxControl(), e); 743 var newSelectionStart = info.selectionStart; 744 var newSelectionEnd = info.selectionEnd; 745 var allText = info.selectionPrefix + info.typedCharacter 746 + info.selectionText.substring(1) + info.selectionSuffix; 747 var userText = info.selectionPrefix + info.typedCharacter; 748 if (userText.length > this.get_textBoxControl().maxLength) { 749 userText = userText.substring(0, this.get_textBoxControl().maxLength); 750 } 751 var suggestedIndex = this._suggestIndex(allText, userText); 752 753 if (this.get_autoCompleteMode() == Sys.Extended.UI.ComboBoxAutoCompleteMode.Suggest 754 || this.get_autoCompleteMode() == Sys.Extended.UI.ComboBoxAutoCompleteMode.SuggestAppend) { 755 this._highlightSuggestedItem = true; 756 if (!this._popupBehavior._visible) { 757 this._popupBehavior.show(); 758 } 759 } 760 761 if (suggestedIndex >= 0) { 762 763 if (this.get_autoCompleteMode() == Sys.Extended.UI.ComboBoxAutoCompleteMode.Append 764 || this.get_autoCompleteMode() == Sys.Extended.UI.ComboBoxAutoCompleteMode.SuggestAppend) { 765 this.get_textBoxControl().value = this._optionListItems[suggestedIndex].text; 766 newSelectionStart = info.selectionStart + 1; 767 newSelectionEnd = this.get_textBoxControl().value.length; 768 } 769 else { 770 this.get_textBoxControl().value = this._optionListItems[suggestedIndex].text.substring(0, userText.length); 771 newSelectionStart = this.get_textBoxControl().value.length; 772 newSelectionEnd = this.get_textBoxControl().value.length; 773 } 774 } 775 else if (this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.Simple 776 || this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.DropDown) { 777 this.get_textBoxControl().value = userText; 778 newSelectionStart = userText.length; 779 newSelectionEnd = userText.length; 780 } 781 782 var erasureKeyResult = this._handleErasureKeys(e); 783 if (erasureKeyResult != null) { 784 return erasureKeyResult; 785 } 786 787 this._ensureHighlightedIndex(); 788 this._ensureScrollTop(); 789 this._setTextSelectionRange(this.get_textBoxControl(), newSelectionStart, newSelectionEnd); 790 791 e.preventDefault(); 792 e.stopPropagation(); 793 return false; 794 795 }, 796 _onDocumentClick: function (e) { 797 798 if (this._popupBehavior._visible) { 799 this._popupBehavior.hide(); 800 } 801 802 }, 803 _onDocumentMouseWheel: function (e) { 804 805 if (this._popupBehavior) { 806 this._popupBehavior.hide(); 807 } 808 return true; 809 810 }, 811 _handleTextBoxFocus: function (e) { 812 813 if (!this._supressFocusHide && this._popupBehavior._visible) { 814 this._popupBehavior.hide(); 815 this._supressFocusHide = true; 816 if (this.get_autoPostBack() && !this._doingPostBack && this._originalSelectedIndex != this.get_selectedIndex()) { 817 this._doingPostBack = true;
818 __doPostBack(this.get_element().id, ''); 819 } 820 } 821 822 if (this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.Simple) { 823 this._popupBehavior.show(); 824 } 825 826 this._setTextSelectionRange( 827 this.get_textBoxControl(), 828 0, 829 this.get_textBoxControl().value.length); 830 831 if (e != null) { 832 e.preventDefault(); 833 e.stopPropagation(); 834 } 835 836 }, 837 _highlightListItem: function (index, isHighlighted) { 838 839 if (index == undefined || index < 0) { 840 if (this._highlightedIndex != undefined && this._highlightedIndex >= 0) { 841 this._highlightListItem(this._highlightedIndex, false); 842 } 843 return; 844 } 845 846 var children = this.get_optionListControl().childNodes; 847 var liElement = children[index]; 848 849 if (isHighlighted == true) { 850 851 if (this._highlightedIndex == index) 852 return; 853 854 if (index >= 0) { 855 if (this.get_listItemHoverCssClass() == undefined || this.get_listItemHoverCssClass() == '') { 856 liElement.style.backgroundColor = 'Highlight'; 857 liElement.style.color = 'HighlightText'; 858 } 859 else { 860 liElement.className = this.get_listItemHoverCssClass; 861 } 862 } 863 864 if (this._highlightedIndex != null && this._highlightedIndex != index && this._highlightedIndex >= 0) { 865 this._highlightListItem(this._highlightedIndex, false); 866 } 867 868 this._highlightedIndex = index; 869 } 870 871 else { 872 if (this.get_listItemHoverCssClass() == undefined || this.get_listItemHoverCssClass() == '') { 873 liElement.style.backgroundColor = ''; 874 liElement.style.color = ''; 875 } 876 else { 877 liElement.className = ''; 878 } 879 880 if (index == this._highlightedIndex) { 881 this._highlightedIndex = -1; 882 } 883 } 884 885 }, 886 _suggestIndex: function (allText, userText) { 887 888 var suggestedIndex = -1; 889 var firstMatch = false; 890 var exactMatch = false; 891 892 for (var i = 0; i < this._optionListItems.length; i++) { 893 itemText = this._optionListItems[i].text; 894 895 if (itemText.length < 1) 896 continue; 897 898 if (itemText.substring(0, 1).toLowerCase() != userText.substring(0, 1).toLowerCase()) 899 continue; 900 901 var allCandidate = itemText.substring(0, allText.length); 902 exactMatch = (allCandidate == allText); 903 if (!exactMatch && !this.get_caseSensitive()) { 904 exactMatch = (allCandidate.toLowerCase() == allText.toLowerCase()); 905 } 906 907 if (exactMatch) { 908 suggestedIndex = i; 909 break; 910 } 911 912 else if (!firstMatch) { 913 var userCandidate = itemText.substring(0, userText.length); 914 firstMatch = (userCandidate == userText); 915 if (!firstMatch && !this.get_caseSensitive()) 916 firstMatch = (userCandidate.toLowerCase() == userText.toLowerCase()); 917 if (firstMatch) 918 suggestedIndex = i; 919 } 920 } 921 return suggestedIndex; 922 923 }, 924 _getKeyboardCode: function (e) { 925 926 if (e.type == 'keypress') { 927 return e.charCode; 928 } else if (e.type == 'keydown') { 929 return e.keyCode; 930 } 931 return undefined; 932 933 }, 934 _handleArrowKey: function (e) { 935 936 if (e.shiftKey == true) { 937 return null; 938 } 939 940 var code = this._getKeyboardCode(e); 941 942 if (code == Sys.UI.Key.up || code == Sys.UI.Key.down) { 943 if (this._popupBehavior._visible) { 944 var vector = code - 39; 945 if ((vector == -1 && this._highlightedIndex > 0) || (vector == 1 && this._highlightedIndex < this._optionListItems.length - 1)) { 946 var newIndex = (this._highlightedIndex + vector); 947 this.get_textBoxControl().value = this._optionListItems[newIndex].text; 948 this._highlightListItem(newIndex, true); 949 this.set_selectedIndex(newIndex); 950 this._ensureScrollTop(); 951 } 952 } 953 else { 954 this._popupBehavior.show(); 955 } 956 957 if (e.type == 'keypress') { 958 e.preventDefault(); 959 e.stopPropagation(); 960 return false; 961 } 962 return true; 963 } 964 return null; 965 966 }, 967 _handleEnterKey: function (e) { 968 969 var code = this._getKeyboardCode(e); 970 971 if (code == Sys.UI.Key.enter) { 972 if (this._popupBehavior._visible) { 973 if (this._highlightedIndex >= 0) { 974 this.get_textBoxControl().value = this._optionListItems[this._highlightedIndex].text; 975 this.set_selectedIndex(this._highlightedIndex);
976 __doPostBack(this.get_element().id, ''); 977 } 978 this._popupBehavior.hide(); 979 e.preventDefault(); 980 e.stopPropagation(); 981 return false; 982 } 983 984 else if (this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.Simple 985 || this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.DropDown) { 986 return true; 987 } 988 989 else if (this._highlightedIndex == this.get_selectedIndex()) { 990 return true; 991 } 992 993 e.preventDefault(); 994 e.stopPropagation(); 995 return false; 996 } 997 return null; 998 999 }, 1000 _handleErasureKeys: function (e) { 1001 1002 var code = this._getKeyboardCode(e); 1003 1004 var isBackspaceKey = (code == Sys.UI.Key.backspace); 1005 var isDeleteKey = (code == Sys.UI.Key.del); 1006 if (typeof (window.event) === 'undefined' && e.type == 'keypress') { 1007 isDeleteKey = (e.rawEvent.keyCode == 46); 1008 } 1009 1010 if (isBackspaceKey || isDeleteKey) { 1011 1012 var info = this._getTextSelectionInfo(this.get_textBoxControl(), e); 1013 var newSelectionStart, newSelectionEnd; 1014 1015 if (info.selectionStart < info.selectionEnd) { 1016 this.get_textBoxControl().value = info.selectionPrefix + info.selectionSuffix; 1017 newSelectionStart = info.selectionStart; 1018 newSelectionEnd = info.selectionStart; 1019 } 1020 1021 else if (info.selectionStart == info.selectionEnd) { 1022 var newValue; 1023 if (isBackspaceKey && info.selectionStart > 0) { 1024 var trimSize = 1; 1025 if (info.selectionPrefix.charCodeAt(info.selectionPrefix.length - 1) == 8) { 1026 trimSize = 2; 1027 } 1028 newValue = info.selectionPrefix.substr(0, info.selectionPrefix.length - trimSize); 1029 newValue += info.selectionSuffix; 1030 this.get_textBoxControl().value = newValue; 1031 newSelectionStart = info.selectionStart - 1; 1032 newSelectionEnd = info.selectionStart - 1; 1033 } 1034 else if (isDeleteKey && info.selectionStart < info.textBoxValue.length) { 1035 newValue = info.selectionSuffix; 1036 newValue = info.selectionPrefix + newValue.substr(1, info.selectionSuffix.length - 1); 1037 this.get_textBoxControl().value = newValue; 1038 newSelectionStart = info.selectionStart; 1039 newSelectionEnd = info.selectionStart; 1040 this._setTextSelectionRange(this.get_textBoxControl(), info.selectionStart, info.selectionStart); 1041 } 1042 } 1043 1044 this._ensureHighlightedIndex(); 1045 this._ensureScrollTop(); 1046 this._setTextSelectionRange(this.get_textBoxControl(), newSelectionStart, newSelectionEnd); 1047 1048 if ((this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.Simple 1049 || this.get_dropDownStyle() == Sys.Extended.UI.ComboBoxStyle.DropDown) 1050 && (this.get_autoCompleteMode() == Sys.Extended.UI.ComboBoxAutoCompleteMode.Suggest 1051 || this.get_autoCompleteMode() == Sys.Extended.UI.ComboBoxAutoCompleteMode.SuggestAppend) 1052 && (this._highlightedIndex != null && this._highlightedIndex >= 0)) { 1053 var _isExactMatch = this._isExactMatch(this._optionListItems[this._highlightedIndex].text, this.get_textBoxControl().value); 1054 if (!_isExactMatch) { 1055 this._highlightListItem(this._highlightedIndex, false); 1056 } 1057 } 1058 1059 e.preventDefault(); 1060 e.stopPropagation(); 1061 return false; 1062 } 1063 return null; 1064 1065 }, 1066 _handleNonCharacterKey: function (e) { 1067 1068 var code = this._getKeyboardCode(e); 1069 1070 var isBackspaceKey = (code == Sys.UI.Key.backspace); 1071 var isDeleteKey = (code == Sys.UI.Key.del); 1072 if (e.type == 'keypress') { 1073 isDeleteKey = (e.rawEvent.code == 46); 1074 } 1075 1076 if (isBackspaceKey || isDeleteKey) { 1077 return null; 1078 } 1079 1080 if (this._isNonCharacterKey(e)) { 1081 if (code == Sys.UI.Key.esc) { 1082 this._popupBehavior.hide(); 1083 this.get_textBoxControl().blur(); 1084 e.preventDefault(); 1085 e.stopPropagation(); 1086 return false; 1087 } 1088 return true; 1089 } 1090 return null; 1091 }, 1092 _isNonCharacterKey: function (e) { 1093 1094 var code = this._getKeyboardCode(e); 1095 1096 if (code == Sys.UI.Key.enter || code == Sys.UI.Key.esc) { // allow RETURN/ENTER and ESC keys for all browsers 1097 return true; 1098 } 1099 else if (Sys.Browser.agent == Sys.Browser.Safari && Sys.Browser.version < 500) { 1100 1101 if (code == 8 // BACKSPACE in Safari 2 1102 || code == 9 // TAB in Safari 2
1103 || code == 63272 // DELETE in Safari 2 1104 || code == 63276 // PAGEUP in Safari 2 1105 || code == 63277 // PAGEDOWN in Safari 2 1106 || code == 63275 // END in Safari 2 1107 || code == 63273 // HOME in Safari 2 1108 || code == 63234 // ARROWLEFT in Safari 2 1109 || code == 63235 // ARROWRIGHT in Safari 2 1110 || (code >= 63236 && code <= 63243) // FUNCTION keys in Safari 2 1111 || code == 63248 // F13 key in Safari 2 1112 ) { 1113 return true; 1114 } 1115 } 1116 else if (Sys.Browser.agent == Sys.Browser.WebKit) { 1117 1118 if (code == 8 // BACKSPACE in Safari 3 1119 || code == 9 // TAB in Safari 3 1120 || code == 19 // PAUSE BREAK Safari 3 1121 || code == 33 // PAGEUP in Safari 3 1122 || code == 34 // PAGEDOWN in Safari 3 1123 || code == 35 // END in Safari 3 1124 || code == 36 // HOME in Safari 3 1125 || code == 37 // ARROWLEFT in Safari 3 1126 || code == 39 // ARROWRIGHT in Safari 3 1127 || code == 45 // INSERT in Safari 3 1128 || code == 46 // DELETE in Safari 3 1129 || code == 91 // WINDOWS LEFT Safari 3 1130 || code == 92 // WINDOWS RIGHT Safari 3 1131 || code == 93 // MENU Safari 3 1132 || code == 113 // F2 Safari 3 1133 || code == 115 // F4 Safari 3 1134 || code == 118 // F7 Safari 3 1135 || code == 119 // F8 Safari 3 1136 || code == 120 // F9 Safari 3 1137 || code == 122 // F11 Safari 3 1138 || code == 145 // SCROLL LOCK Safari 3 1139 ) 1140 return true; 1141 } 1142 else if (Sys.Browser.agent != Sys.Browser.InternetExplorer) { 1143 1144 if (code == 8 // BACKSPACE in non-microsoft browsers 1145 || code == 9 // TAB in non-microsoft browsers 1146 || code == 33 // PAGEUP in non-microsoft browsers 1147 || code == 34 // PAGEDOWN in non-microsoft browsers 1148 || code == 35 // END in non-microsoft browsers 1149 || code == 36 // HOME in non-microsoft browsers 1150 || code == 37 // ARROWLEFT in non-microsoft browsers 1151 || code == 39 // ARROWRIGHT in non-microsoft browsers 1152 || code == 45 // INSERT in non-microsoft browsers 1153 || code == 46 // DELETE in non-microsoft browsers 1154 ) { 1155 if (!e.shiftKey) 1156 return true; 1157 } 1158 else if (code == 145) { 1159 1160 return true; 1161 1162 } 1163 else if (code == 19) { 1164 1165 return true; 1166 } 1167 else if (Sys.Browser.agent == Sys.Browser.Opera) { 1168 1169 if (code == 0 // MENU key in Opera 1170 || code == 16 // SHIFT key in Opera 1171 || code == 17 // CONTROL key in Opera 1172 ) { 1173 return true; 1174 } 1175 } 1176 else if (Sys.Browser.agent == Sys.Browser.Firefox) { 1177 1178 if (code == 91 // WINDOWS LEFT key in Firefox 1179 || code == 92 // WINDOWS RIGHT key in Firefox 1180 || code == 93 // MENU key in Firefox 1181 ) { 1182 return true; 1183 } 1184 } 1185 } 1186 else if (Sys.Browser.agent == Sys.Browser.InternetExplorer) { 1187 if (code == 46) 1188 return true; 1189 } 1190 return false; 1191 1192 }, 1193 _ensureScrollTop: function () { 1194 1195 var optionListControl = this.get_optionListControl(); 1196 1197 if (this._highlightedIndex >= 0) { 1198 var itemHeight = this._getOptionListItemHeight(), 1199 itemTop = itemHeight * this._highlightedIndex, 1200 scrollBottom = optionListControl.scrollTop + optionListControl.clientHeight; 1201 1202 if (itemTop <= optionListControl.scrollTop || itemTop >= scrollBottom) 1203 optionListControl.scrollTop = this._highlightedIndex * itemHeight; 1204 } 1205 1206 }, 1207 _ensureSelectedIndex: function () { 1208 1209 var selectedIndex = this.get_hiddenFieldControl().value; 1210 if (selectedIndex == '') { 1211 selectedIndex = (this._optionListItems.length > 0) ? 0 : -1; 1212 this.get_hiddenFieldControl().value = selectedIndex.toString(); 1213 } 1214 if (this._originalSelectedIndex == null) { 1215 this._originalSelectedIndex = parseInt(selectedIndex); 1216 } 1217 1218 1219 }, 1220 _ensureHighlightedIndex: function () { 1221 1222 var textBoxValue = this.get_textBoxControl().value; 1223 1224 if (this._highlightedIndex != null && this._highlightedIndex >= 0 1225 && this._isExactMatch(this._optionListItems[this._highlightedIndex].text, textBoxValue)) { 1226 return; 1227 } 1228 1229 var firstMatch = -1; 1230 var ensured = false; 1231 for (var i = 0; i < this._optionListItems.length; i++) { 1232 var itemText = this._optionListItems[i].text; 1233 if (this._isExactMatch(itemText, textBoxValue)) { 1234 this._highlightListItem(i, true); 1235 ensured = true; 1236 break; 1237 } 1238 1239 else if (firstMatch < 0 && this._highlightSuggestedItem) { 1240 if (this._isPrefixMatch(itemText, textBoxValue)) { 1241 firstMatch = i; 1242 } 1243 } 1244 } 1245 1246 if (!ensured) { 1247 this._highlightListItem(firstMatch, true); 1248 } 1249 1250 }, 1251 _isExactMatch: function (itemText, userText) { 1252 1253 var exactMatch = (itemText == userText); 1254 if (!exactMatch && !this.get_caseSensitive()) 1255 exactMatch = (itemText.toLowerCase() == userText.toLowerCase()); 1256 return exactMatch; 1257 1258 }, 1259 _isPrefixMatch: function (itemText, userText) { 1260 1261 return this._isExactMatch(itemText.substring(0, userText.length), userText); 1262 1263 }, 1264 _setTextSelectionRange: function (textBox, selectionStart, selectionEnd) { 1265 1266 var strategy = this._getTextSelectionStrategy(); 1267 if (strategy == Sys.Extended.UI.ComboBoxTextSelectionStrategy.Microsoft) { 1268 var range = textBox.createTextRange(); 1269 range.collapse(true); 1270 range.moveEnd('character', selectionEnd); 1271 range.moveStart('character', selectionStart); 1272 range.select(); 1273 1274 if (Sys.Browser.agent == Sys.Browser.Opera) { 1275 textBox.setSelectionRange(selectionStart, selectionEnd); 1276 } 1277 } 1278 else if (strategy == Sys.Extended.UI.ComboBoxTextSelectionStrategy.W3C) { 1279 textBox.setSelectionRange(selectionStart, selectionEnd); 1280 } 1281 1282 }, 1283 _getTextSelectionStrategy: function () { 1284 1285 if (this._textSelectionStrategy == null) { 1286 if (this.get_textBoxControl().createTextRange) { 1287 this._textSelectionStrategy = 1288 Sys.Extended.UI.ComboBoxTextSelectionStrategy.Microsoft; 1289 } 1290 else if (this.get_textBoxControl().setSelectionRange) { 1291 this._textSelectionStrategy = 1292 Sys.Extended.UI.ComboBoxTextSelectionStrategy.W3C; 1293 } 1294 else { 1295 this._textSelectionStrategy = 1296 Sys.Extended.UI.ComboBoxTextSelectionStrategy.Unknown; 1297 } 1298 } 1299 1300 return this._textSelectionStrategy; 1301 1302 }, 1303 _getTextSelectionInfo: function (textBox, e) { 1304 1305 var info = new Object(); 1306 1307 info.strategy = this._getTextSelectionStrategy(); 1308 1309 if (info.strategy == Sys.Extended.UI.ComboBoxTextSelectionStrategy.Microsoft) { 1310 var userRange = document.selection.createRange(); 1311 info.selectionStart = 0; 1312 info.selectionEnd = textBox.value.length; 1313 while (userRange.moveStart('character', -1) != 0) { 1314 info.selectionStart++; 1315 } 1316 while (userRange.moveEnd('character', 1) != 0) { 1317 info.selectionEnd--; 1318 } 1319 } 1320 else if (info.strategy == Sys.Extended.UI.ComboBoxTextSelectionStrategy.W3C) { 1321 info.selectionStart = textBox.selectionStart; 1322 info.selectionEnd = textBox.selectionEnd; 1323 } 1324 1325 info.typedCharacter = String.fromCharCode(e.charCode); 1326 info.textBoxValue = textBox.value; 1327 info.selectionPrefix = (info.textBoxValue.length >= info.selectionStart) 1328 ? info.textBoxValue.substring(0, info.selectionStart) 1329 : ''; 1330 info.selectionText = (info.textBoxValue.length >= info.selectionEnd) 1331 ? info.textBoxValue.substring(info.selectionStart, info.selectionEnd) 1332 : ''; 1333 info.selectionSuffix = (info.textBoxValue.length >= info.selectionEnd) 1334 ? info.textBoxValue.substring(info.selectionEnd, info.textBoxValue.length) 1335 : ''; 1336 info.selectionTextFirst = info.selectionText.substring(0, 1); 1337 1338 return info; 1339 1340 }, 1341 _getOptionListItemHeight: function () { 1342 1343 var optionListControl = this.get_optionListControl(); 1344 1345 if (this._optionListItemHeight == null && optionListControl.scrollHeight > 0) { 1346 this._optionListItemHeight = Math.round(optionListControl.scrollHeight / this._optionListItems.length); 1347 } 1348 else if (Sys.Browser.agent === Sys.Browser.InternetExplorer && Sys.Browser.version < 7 1349 && Math.round(optionListControl.scrollHeight / this._optionListItems.length) < this._optionListItemHeight) { 1350 this._optionListItemHeight = Math.round(optionListControl.scrollHeight / this._optionListItems.length); 1351 } 1352 return this._optionListItemHeight; 1353 1354 }, 1355 _getOptionListBounds: function () { 1356 1357 var bounds = { 1358 width: this._getOptionListWidth(), 1359 height: this._getOptionListHeight() 1360 }; 1361 return bounds; 1362 1363 }, 1364 _getOptionListHeight: function () { 1365 1366 if (this._optionListHeight == null || (this._getOptionListItemHeight() * this._optionListItems.length) < this._optionListHeight) { 1367 this._optionListHeight = this._getOptionListItemHeight() * this._optionListItems.length; 1368 } 1369 1370 if (this._optionListHeight < 0) { 1371 this._optionListHeight = 0; 1372 } 1373 1374 return this._optionListHeight; 1375 1376 }, 1377 _getOptionListWidth: function () { 1378 1379 var optionListControl = this.get_optionListControl(); 1380 1381 if (this._optionListWidth == null) { 1382 var leftBorder = 1; 1383 var rightBorder = 1; 1384 var leftPadding = 0; 1385 var rightPadding = 0; 1386 var style = optionListControl.style; 1387 1388 1389 style.overflow = 'auto'; 1390 1391 var bestWidth = this.get_comboTableControl().offsetWidth; 1392 1393 bestWidth -= (leftBorder + rightBorder); 1394 if (bestWidth < 0) { 1395 bestWidth = 0; 1396 } 1397 1398 var originalWidth = style.width; 1399 style.width = bestWidth + 'px'; 1400 1401 if (this.get_comboTableControl().offsetWidth < optionListControl.scrollWidth) { 1402 bestWidth = optionListControl.scrollWidth + rightPadding + leftPadding; 1403 } 1404 1405 style.overflow = 'hidden'; 1406 1407 style.width = originalWidth; 1408 1409 this._optionListWidth = bestWidth; 1410 } 1411 1412 if (this._optionListWidth < 0) { 1413 this._optionListWidth = 0; 1414 } 1415 1416 return this._optionListWidth; 1417 1418 }, 1419 _getWindowBounds: function () { 1420 1421 var bounds = { 1422 x: this._getScrollLeft(), 1423 y: this._getScrollTop(), 1424 width: this._getWindowWidth(), 1425 height: this._getWindowHeight() 1426 }; 1427 return bounds; 1428 1429 }, 1430 _getWindowHeight: function () { 1431 1432 var windowHeight = 0; 1433 if (typeof (window.innerHeight) == 'number') { 1434 windowHeight = window.innerHeight; 1435 } 1436 else if (document.documentElement && document.documentElement.clientHeight) { 1437 windowHeight = document.documentElement.clientHeight; 1438 } 1439 else if (document.body && document.body.clientHeight) { 1440 windowHeight = document.body.clientHeight; 1441 } 1442 return windowHeight; 1443 1444 }, 1445 _getWindowWidth: function () { 1446 1447 var windowWidth = 0; 1448 if (typeof (window.innerWidth) == 'number') { 1449 windowWidth = window.innerWidth; 1450 } 1451 else if (document.documentElement && document.documentElement.clientWidth) { 1452 windowWidth = document.documentElement.clientWidth; 1453 } 1454 else if (document.body && document.body.clientWidth) { 1455 windowWidth = document.body.clientWidth; 1456 } 1457 return windowWidth; 1458 1459 }, 1460 _getScrollTop: function () { 1461 1462 var scrollTop = 0; 1463 if (typeof (window.pageYOffset) == 'number') { 1464 scrollTop = window.pageYOffset; 1465 } 1466 if (document.body && document.body.scrollTop) { 1467 scrollTop = document.body.scrollTop; 1468 } 1469 else if (document.documentElement && document.documentElement.scrollTop) { 1470 scrollTop = document.documentElement.scrollTop; 1471 } 1472 return scrollTop; 1473 1474 }, 1475 _getScrollLeft: function () { 1476 1477 var scrollLeft = 0; 1478 if (typeof (window.pageXOffset) == 'number') { 1479 scrollLeft = window.pageXOffset; 1480 } 1481 else if (document.body && document.body.scrollLeft) { 1482 scrollLeft = document.body.scrollLeft; 1483 } 1484 else if (document.documentElement && document.documentElement.scrollLeft) { 1485 scrollLeft = document.documentElement.scrollLeft; 1486 } 1487 return scrollLeft; 1488 1489 }, 1490 set_comboTableControl: function (value) { 1491 1492 if (this._comboTableControl !== value) { 1493 this._comboTableControl = value; 1494 this.raisePropertyChanged('comboTableControl'); 1495 } 1496 1497 }, 1498 get_comboTableControl: function () { 1499 1500 return this._comboTableControl; 1501 1502 }, 1503 set_textBoxControl: function (value) { 1504 1505 if (this._textBoxControl !== value) { 1506 this._textBoxControl = value; 1507 this.raisePropertyChanged('textBoxControl'); 1508 } 1509 1510 }, 1511 get_textBoxControl: function () { 1512 1513 return this._textBoxControl; 1514 1515 }, 1516 set_buttonControl: function (value) { 1517 1518 if (this._buttonControl !== value) { 1519 this._buttonControl = value; 1520 this.raisePropertyChanged('buttonControl'); 1521 } 1522 1523 }, 1524 get_buttonControl: function () { 1525 return this._buttonControl; 1526 }, 1527 set_optionListControl: function (value) { 1528 1529 if (this._optionListControl !== value) { 1530 this._optionListControl = value; 1531 this.raisePropertyChanged('optionListControl'); 1532 } 1533 1534 }, 1535 get_optionListControl: function () { 1536 1537 return this._optionListControl; 1538 1539 }, 1540 set_hiddenFieldControl: function (value) { 1541 1542 if (this._hiddenFieldControl !== value) { 1543 this._hiddenFieldControl = value; 1544 this.raisePropertyChanged('hiddenFieldControl'); 1545 } 1546 1547 }, 1548 get_hiddenFieldControl: function () { 1549 1550 return this._hiddenFieldControl; 1551 1552 }, 1553 set_selectedIndex: function (value) { 1554 1555 if (this.get_hiddenFieldControl().value !== value.toString()) { 1556 this.get_hiddenFieldControl().value = value.toString(); 1557 this._ensureSelectedIndex(); 1558 this.raisePropertyChanged('selectedIndex'); 1559 } 1560 1561 }, 1562 get_selectedIndex: function () { 1563 1564 this._ensureSelectedIndex(); 1565 var selectedIndex = this.get_hiddenFieldControl().va
1565lue; 1566 return parseInt(selectedIndex); 1567 1568 }, 1569 set_autoPostBack: function (value) { 1570 1571 if (this._autoPostBack !== value) { 1572 this._autoPostBack = value; 1573 this.raisePropertyChanged('autoPostBack'); 1574 } 1575 1576 }, 1577 get_autoPostBack: function () { 1578 1579 return this._autoPostBack; 1580 1581 }, 1582 set_autoCompleteMode: function (value) { 1583 1584 if (this._autoCompleteMode !== value) { 1585 this._autoCompleteMode = value; 1586 this.raisePropertyChanged('autoCompleteMode'); 1587 } 1588 1589 }, 1590 get_autoCompleteMode: function () { 1591 1592 return this._autoCompleteMode; 1593 1594 }, 1595 set_dropDownStyle: function (value) { 1596 1597 if (this._dropDownStyle !== value) { 1598 this._dropDownStyle = value; 1599 this.raisePropertyChanged('dropDownStyle'); 1600 } 1601 1602 }, 1603 get_dropDownStyle: function () { 1604 1605 return this._dropDownStyle; 1606 1607 }, 1608 set_caseSensitive: function (value) { 1609 1610 if (this._caseSensitive !== value) { 1611 this._caseSensitive = value; 1612 this.raisePropertyChanged('caseSensitive'); 1613 } 1614 1615 }, 1616 get_caseSensitive: function () { 1617 1618 return this._caseSensitive; 1619 1620 }, 1621 set_listItemHoverCssClass: function (value) { 1622 1623 if (this._listItemHoverCssClass !== value) { 1624 this._listItemHoverCssClass = value; 1625 this.raisePropertyChanged('listItemHoverCssClass'); 1626 } 1627 1628 }, 1629 get_listItemHoverCssClass: function () { 1630 1631 return this._listItemHoverCssClass; 1632 1633 } 1634 1635}; 1636Sys.Extended.UI.ComboBox.registerClass('Sys.Extended.UI.ComboBox', Sys.UI.Control); 1637 1638 1639var ComboBox_Elements = new Array(); 1640 1641Sys.Extended.UI.ComboBox.IsOpen = function (currentInstance) { 1642 var components = Sys.Application.getComponents(); 1643 for (var i = 0; i < components.length; i++) { 1644 var component = components[i]; 1645 if (Sys.Extended.UI.ComboBox.isInstanceOfType(component)) { 1646 if (component != currentInstance && component._popupBehavior._visible) { 1647 component._popupBehavior.hide(); 1648 } 1649 } 1650 } 1651};
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.