|
1 |
| -/*! selectize.js - v0.6.12 | https://github.com/brianreavis/selectize.js | Apache License (v2) */ |
| 1 | +/*! selectize.js - v0.6.13 | https://github.com/brianreavis/selectize.js | Apache License (v2) */ |
2 | 2 |
|
3 | 3 | (function(factory) {
|
4 | 4 | if (typeof exports === 'object') {
|
|
295 | 295 | return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
|
296 | 296 | };
|
297 | 297 |
|
| 298 | + /** |
| 299 | + * Escapes quotation marks with backslashes. Useful |
| 300 | + * for escaping values for use in CSS attribute selectors. |
| 301 | + * |
| 302 | + * @param {string} str |
| 303 | + * @return {string} |
| 304 | + */ |
| 305 | + var escape_quotes = function(str) { |
| 306 | + return str.replace(/(['"])/g, '\\$1'); |
| 307 | + }; |
| 308 | + |
298 | 309 | var hook = {};
|
299 | 310 |
|
300 | 311 | /**
|
|
782 | 793 | });
|
783 | 794 |
|
784 | 795 | $(window).on({
|
785 |
| - resize: function() { |
| 796 | + 'scroll resize': function() { |
786 | 797 | if (self.isOpen) {
|
787 | 798 | self.positionDropdown.apply(self, arguments);
|
788 | 799 | }
|
789 | 800 | },
|
790 |
| - mousemove: function() { |
| 801 | + 'mousemove': function() { |
791 | 802 | self.ignoreHover = false;
|
792 | 803 | }
|
793 | 804 | });
|
|
1707 | 1718 | updateOption: function(value, data) {
|
1708 | 1719 | var self = this;
|
1709 | 1720 | var $item, $item_new;
|
1710 |
| - var value, value_new, index_item, cache_items, cache_options; |
| 1721 | + var value_new, index_item, cache_items, cache_options; |
1711 | 1722 |
|
1712 | 1723 | value = hash_key(value);
|
1713 | 1724 | value_new = hash_key(data[self.settings.valueField]);
|
|
1792 | 1803 | */
|
1793 | 1804 | getOption: function(value) {
|
1794 | 1805 | value = hash_key(value);
|
1795 |
| - return value ? this.$dropdown_content.find('[data-selectable]').filter('[data-value="' + value.replace(/(['"])/g, '\\$1') + '"]:first') : $(); |
| 1806 | + return value ? this.$dropdown_content.find('[data-selectable]').filter('[data-value="' + escape_quotes(value) + '"]:first') : $(); |
1796 | 1807 | },
|
1797 | 1808 |
|
1798 | 1809 | /**
|
|
1818 | 1829 | * @returns {object}
|
1819 | 1830 | */
|
1820 | 1831 | getItem: function(value) {
|
1821 |
| - var i = this.items.indexOf(value); |
1822 |
| - if (i !== -1) { |
1823 |
| - if (i >= this.caretPos) i++; |
1824 |
| - var $el = $(this.$control[0].childNodes[i]); |
1825 |
| - if ($el.attr('data-value') === value) { |
1826 |
| - return $el; |
1827 |
| - } |
1828 |
| - } |
1829 |
| - return $(); |
| 1832 | + return this.$control.children('[data-value="' + escape_quotes(hash_key(value)) + '"]'); |
1830 | 1833 | },
|
1831 | 1834 |
|
1832 | 1835 | /**
|
|
1859 | 1862 | // update menu / remove the option
|
1860 | 1863 | $option = self.getOption(value);
|
1861 | 1864 | value_next = self.getAdjacentOption($option, 1).attr('data-value');
|
1862 |
| - self.refreshOptions(inputMode !== 'single'); |
| 1865 | + self.refreshOptions(self.isFocused && inputMode !== 'single'); |
1863 | 1866 | if (value_next) {
|
1864 | 1867 | self.setActiveOption(self.getOption(value_next));
|
1865 | 1868 | }
|
|
0 commit comments