|
28 | 28 |
|
29 | 29 | var pluginName = 'selectric';
|
30 | 30 | var classList = 'Input Items Open Disabled TempShow HideSelect Wrapper Focus Hover Responsive Above Scroll Group GroupLabel';
|
31 |
| - var bindSufix = '.sl'; |
| 31 | + var eventNamespaceSuffix = '.sl'; |
32 | 32 |
|
33 | 33 | var chars = ['a', 'e', 'i', 'o', 'u', 'n', 'c', 'y'];
|
34 | 34 | var diacritics = [
|
|
534 | 534 | .add(_this.$element)
|
535 | 535 | .add(_this.elements.outerWrapper)
|
536 | 536 | .add(_this.elements.input)
|
537 |
| - .off(bindSufix); |
| 537 | + .off(eventNamespaceSuffix); |
538 | 538 |
|
539 |
| - _this.elements.outerWrapper.on('mouseenter' + bindSufix + ' mouseleave' + bindSufix, function(e) { |
| 539 | + _this.elements.outerWrapper.on('mouseenter' + eventNamespaceSuffix + ' mouseleave' + eventNamespaceSuffix, function(e) { |
540 | 540 | $(this).toggleClass(_this.classes.hover, e.type === 'mouseenter');
|
541 | 541 |
|
542 | 542 | // Delay close effect when openOnHover is true
|
|
552 | 552 | });
|
553 | 553 |
|
554 | 554 | // Toggle open/close
|
555 |
| - _this.elements.wrapper.on('click' + bindSufix, function(e) { |
| 555 | + _this.elements.wrapper.on('click' + eventNamespaceSuffix, function(e) { |
556 | 556 | _this.state.opened ? _this.close() : _this.open(e);
|
557 | 557 | });
|
558 | 558 |
|
559 | 559 | // Translate original element focus event to dummy input
|
560 |
| - _this.$element.on('focus' + bindSufix, function() { |
| 560 | + _this.$element.on('focus' + eventNamespaceSuffix, function() { |
561 | 561 | _this.elements.input.focus();
|
562 | 562 | });
|
563 | 563 |
|
564 | 564 | _this.elements.input
|
565 | 565 | .prop({ tabindex: _this.originalTabindex, disabled: false })
|
566 |
| - .on('keydown' + bindSufix, $.proxy(_this.handleKeys, _this)) |
567 |
| - .on('focusin' + bindSufix, function(e) { |
| 566 | + .on('keydown' + eventNamespaceSuffix, $.proxy(_this.handleKeys, _this)) |
| 567 | + .on('focusin' + eventNamespaceSuffix, function(e) { |
568 | 568 | _this.elements.outerWrapper.addClass(_this.classes.focus);
|
569 | 569 |
|
570 | 570 | // Prevent the flicker when focusing out and back again in the browser window
|
|
576 | 576 | _this.open(e);
|
577 | 577 | }
|
578 | 578 | })
|
579 |
| - .on('focusout' + bindSufix, function() { |
| 579 | + .on('focusout' + eventNamespaceSuffix, function() { |
580 | 580 | _this.elements.outerWrapper.removeClass(_this.classes.focus);
|
581 | 581 | })
|
582 | 582 | .on('input propertychange', function() {
|
|
802 | 802 | // Delayed binds events on Document to make label clicks work
|
803 | 803 | setTimeout(function() {
|
804 | 804 | $doc
|
805 |
| - .on('click' + bindSufix, $.proxy(_this.close, _this)) |
806 |
| - .on('scroll' + bindSufix, $.proxy(_this.isInViewport, _this)); |
| 805 | + .on('click' + eventNamespaceSuffix, $.proxy(_this.close, _this)) |
| 806 | + .on('scroll' + eventNamespaceSuffix, $.proxy(_this.isInViewport, _this)); |
807 | 807 | }, 1);
|
808 | 808 |
|
809 | 809 | _this.isInViewport();
|
810 | 810 |
|
811 | 811 | // Prevent window scroll when using mouse wheel inside items box
|
812 | 812 | if ( _this.options.preventWindowScroll ) {
|
813 | 813 | /* istanbul ignore next */
|
814 |
| - $doc.on('mousewheel' + bindSufix + ' DOMMouseScroll' + bindSufix, '.' + _this.classes.scroll, function(e) { |
| 814 | + $doc.on('mousewheel' + eventNamespaceSuffix + ' DOMMouseScroll' + eventNamespaceSuffix, '.' + _this.classes.scroll, function(e) { |
815 | 815 | var orgEvent = e.originalEvent;
|
816 | 816 | var scrollTop = $(this).scrollTop();
|
817 | 817 | var deltaY = 0;
|
|
842 | 842 | _this.utils.triggerCallback('BeforeClose', _this);
|
843 | 843 |
|
844 | 844 | // Remove custom events on document
|
845 |
| - $doc.off(bindSufix); |
| 845 | + $doc.off(eventNamespaceSuffix); |
846 | 846 |
|
847 | 847 | // Remove visible class to hide options box
|
848 | 848 | _this.elements.outerWrapper.removeClass(_this.classes.open);
|
|
966 | 966 | _this.$element.removeData(pluginName).removeData('value');
|
967 | 967 | }
|
968 | 968 |
|
969 |
| - _this.$element.prop('tabindex', _this.originalTabindex).off(bindSufix).off(_this.eventTriggers).unwrap().unwrap(); |
| 969 | + _this.$element.prop('tabindex', _this.originalTabindex).off(eventNamespaceSuffix).off(_this.eventTriggers).unwrap().unwrap(); |
970 | 970 |
|
971 | 971 | _this.state.enabled = false;
|
972 | 972 | }
|
|
0 commit comments