|
492 | 492 |
|
493 | 493 | currentDataText, |
494 | 494 |
|
| 495 | + currentDataSearch, |
| 496 | + |
495 | 497 | currentText, |
496 | 498 |
|
| 499 | + currentOption, |
| 500 | + |
497 | 501 | parent; |
498 | 502 |
|
499 | 503 | // Checks the `showFirstOption` plugin option to determine if the first dropdown list option should be shown in the options list. |
|
511 | 515 | // into new list item elements of the new dropdown list |
512 | 516 | self.selectItems.each(function(index) { |
513 | 517 |
|
| 518 | + currentOption = $(this); |
| 519 | + |
514 | 520 | optgroupClass = ""; |
515 | 521 |
|
516 | 522 | optgroupElement = ""; |
517 | 523 |
|
518 | | - dataDisabled = $(this).prop("disabled"); |
| 524 | + dataDisabled = currentOption.prop("disabled"); |
519 | 525 |
|
520 | | - iconClass = $(this).attr("data-icon") || ""; |
| 526 | + iconClass = currentOption.attr("data-icon") || ""; |
521 | 527 |
|
522 | | - iconUrl = $(this).attr("data-iconurl") || ""; |
| 528 | + iconUrl = currentOption.attr("data-iconurl") || ""; |
523 | 529 |
|
524 | 530 | iconUrlClass = iconUrl ? "selectboxit-option-icon-url": ""; |
525 | 531 |
|
526 | 532 | iconUrlStyle = iconUrl ? 'style="background-image:url(\'' + iconUrl + '\');"': ""; |
527 | 533 |
|
528 | | - currentDataSelectedText = $(this).attr("data-selectedtext"); |
| 534 | + currentDataSelectedText = currentOption.attr("data-selectedtext"); |
529 | 535 |
|
530 | | - currentDataText = $(this).attr("data-text"); |
| 536 | + currentDataText = currentOption.attr("data-text"); |
531 | 537 |
|
532 | | - currentText = currentDataText ? currentDataText: $(this).text(); |
| 538 | + currentText = currentDataText ? currentDataText: currentOption.text(); |
533 | 539 |
|
534 | | - parent = $(this).parent(); |
| 540 | + parent = currentOption.parent(); |
535 | 541 |
|
536 | 542 | // If the current option being traversed is within an optgroup |
537 | 543 |
|
538 | 544 | if(parent.is("optgroup")) { |
539 | 545 |
|
540 | 546 | optgroupClass = "selectboxit-optgroup-option"; |
541 | 547 |
|
542 | | - if($(this).index() === 0) { |
| 548 | + if(currentOption.index() === 0) { |
543 | 549 |
|
544 | 550 | optgroupElement = '<span class="selectboxit-optgroup-header ' + parent.first().attr("class") + '"data-disabled="true">' + parent.first().attr("label") + '</span>'; |
545 | 551 |
|
|
550 | 556 | // Uses string concatenation for speed (applies HTML attribute encoding) |
551 | 557 | currentItem += optgroupElement + '<li id="' + index + '" data-val="' + this.value + '" data-disabled="' + dataDisabled + '" class="' + optgroupClass + " selectboxit-option " + ($(this).attr("class") || "") + '"><a class="selectboxit-option-anchor"><span class="selectboxit-option-icon-container"><i class="selectboxit-option-icon ' + iconClass + ' ' + (iconUrlClass || self.theme["container"]) + '"' + iconUrlStyle + '></i></span>' + (self.options["html"] ? currentText: self.htmlEscape(currentText)) + '</a></li>'; |
552 | 558 |
|
| 559 | + currentDataSearch = currentOption.attr("data-search"); |
| 560 | + |
553 | 561 | // Stores all of the original select box options text inside of an array |
554 | 562 | // (Used later in the `searchAlgorithm` method) |
555 | | - self.textArray[index] = dataDisabled ? "": currentText; |
| 563 | + self.textArray[index] = dataDisabled ? "": currentDataSearch ? currentDataSearch: currentText; |
556 | 564 |
|
557 | 565 | // Checks the original select box option for the `selected` attribute |
558 | 566 | if (this.selected) { |
@@ -2767,7 +2775,7 @@ selectBoxIt._destroySelectBoxIt = function() { |
2767 | 2775 | // Resets the regular expression with the new value of `self.currentText` |
2768 | 2776 | alphaNumeric = new RegExp(currentText, "gi"); |
2769 | 2777 |
|
2770 | | - // Searches based on the first letter of the dropdown list options text if the currentText < 2 characters |
| 2778 | + // Searches based on the first letter of the dropdown list options text if the currentText < 3 characters |
2771 | 2779 | if (currentText.length < 3) { |
2772 | 2780 |
|
2773 | 2781 | alphaNumeric = new RegExp(currentText.charAt(0), "gi"); |
|
0 commit comments