|
46 | 46 | position: {},
|
47 | 47 | appendTo: null,
|
48 | 48 | menuWidth:null,
|
49 |
| - selectedListSeparator: ', ' |
| 49 | + selectedListSeparator: ', ', |
| 50 | + disableInputsOnToggle: true |
50 | 51 | },
|
51 | 52 |
|
52 | 53 | _getAppendEl: function() {
|
|
637 | 638 | _toggleDisabled: function(flag) {
|
638 | 639 | this.button.prop({ 'disabled':flag, 'aria-disabled':flag })[ flag ? 'addClass' : 'removeClass' ]('ui-state-disabled');
|
639 | 640 |
|
640 |
| - var inputs = this.menu.find('input'); |
641 |
| - var key = "ech-multiselect-disabled"; |
642 |
| - |
643 |
| - if(flag) { |
644 |
| - // remember which elements this widget disabled (not pre-disabled) |
645 |
| - // elements, so that they can be restored if the widget is re-enabled. |
646 |
| - inputs = inputs.filter(':enabled').data(key, true); |
647 |
| - } else { |
648 |
| - inputs = inputs.filter(function() { |
649 |
| - return $.data(this, key) === true; |
650 |
| - }).removeData(key); |
| 641 | + if(this.options.disableInputsOnToggle) { |
| 642 | + var checkboxes = this.menu.find(".ui-multiselect-checkboxes").get(0); |
| 643 | + var matchedInputs = []; |
| 644 | + var key = "ech-multiselect-disabled"; |
| 645 | + var i = 0; |
| 646 | + if(flag) { |
| 647 | + // remember which elements this widget disabled (not pre-disabled) |
| 648 | + // elements, so that they can be restored if the widget is re-enabled. |
| 649 | + matchedInputs = checkboxes.querySelectorAll("input:enabled"); |
| 650 | + for(i = 0; i < matchedInputs.length; i++) { |
| 651 | + matchedInputs[i].setAttribute(key, true); |
| 652 | + matchedInputs[i].setAttribute("disabled", "disabled"); |
| 653 | + matchedInputs[i].setAttribute("aria-disabled", "disabled"); |
| 654 | + matchedInputs[i].parentNode.className = matchedInputs[i].parentNode.className + " ui-state-disabled"; |
| 655 | + } |
| 656 | + } else { |
| 657 | + matchedInputs = checkboxes.querySelectorAll("input:disabled"); |
| 658 | + for(i = 0; i < matchedInputs.length; i++) { |
| 659 | + if(matchedInputs[i].hasAttribute(key)) { |
| 660 | + matchedInputs[i].removeAttribute(key); |
| 661 | + matchedInputs[i].removeAttribute("disabled"); |
| 662 | + matchedInputs[i].removeAttribute("aria-disabled"); |
| 663 | + matchedInputs[i].parentNode.className = matchedInputs[i].parentNode.className.replace(" ui-state-disabled", ""); |
| 664 | + } |
| 665 | + } |
| 666 | + } |
651 | 667 | }
|
652 | 668 |
|
653 |
| - inputs |
654 |
| - .prop({ 'disabled':flag, 'arial-disabled':flag }) |
655 |
| - .parent()[ flag ? 'addClass' : 'removeClass' ]('ui-state-disabled'); |
656 |
| - |
657 | 669 | this.element.prop({
|
658 | 670 | 'disabled':flag,
|
659 | 671 | 'aria-disabled':flag
|
|
0 commit comments