|
1 |
| -/*! selectize.js - v0.6.6 | https://github.com/brianreavis/selectize.js | Apache License (v2) */ |
| 1 | +/*! selectize.js - v0.6.7 | https://github.com/brianreavis/selectize.js | Apache License (v2) */ |
2 | 2 |
|
3 | 3 | (function(factory) {
|
4 | 4 | if (typeof exports === 'object') {
|
|
1030 | 1030 | * @returns {boolean}
|
1031 | 1031 | */
|
1032 | 1032 | onOptionSelect: function(e) {
|
| 1033 | + var value, $target, $option, self = this; |
| 1034 | + |
1033 | 1035 | e.preventDefault && e.preventDefault();
|
1034 | 1036 | e.stopPropagation && e.stopPropagation();
|
1035 |
| - this.focus(false); |
| 1037 | + self.focus(false); |
1036 | 1038 |
|
1037 |
| - var $target = $(e.currentTarget); |
| 1039 | + $target = $(e.currentTarget); |
1038 | 1040 | if ($target.hasClass('create')) {
|
1039 |
| - this.createItem(); |
| 1041 | + self.createItem(); |
1040 | 1042 | } else {
|
1041 |
| - var value = $target.attr('data-value'); |
| 1043 | + value = $target.attr('data-value'); |
1042 | 1044 | if (value) {
|
1043 |
| - this.setTextboxValue(''); |
1044 |
| - this.addItem(value); |
| 1045 | + self.setTextboxValue(''); |
| 1046 | + self.addItem(value); |
| 1047 | + if (!self.settings.hideSelected && e.type && /mouse/.test(e.type)) { |
| 1048 | + self.setActiveOption(self.getOption(value)); |
| 1049 | + } |
1045 | 1050 | }
|
1046 | 1051 | }
|
1047 | 1052 | },
|
|
1799 | 1804 | self.refreshClasses();
|
1800 | 1805 |
|
1801 | 1806 | if (self.isSetup) {
|
1802 |
| - // remove the option from the menu |
1803 | 1807 | options = self.$dropdown_content.find('[data-selectable]');
|
| 1808 | + |
| 1809 | + // update menu / remove the option |
1804 | 1810 | $option = self.getOption(value);
|
1805 | 1811 | value_next = self.getAdjacentOption($option, 1).attr('data-value');
|
1806 | 1812 | self.refreshOptions(true);
|
|
2088 | 2094 | * @returns {boolean}
|
2089 | 2095 | */
|
2090 | 2096 | deleteSelection: function(e) {
|
2091 |
| - var i, n, direction, selection, values, caret, $tail; |
| 2097 | + var i, n, direction, selection, values, caret, option_select, $option_select, $tail; |
2092 | 2098 | var self = this;
|
2093 | 2099 |
|
2094 | 2100 | direction = (e && e.keyCode === KEY_BACKSPACE) ? -1 : 1;
|
2095 | 2101 | selection = getSelection(self.$control_input[0]);
|
2096 | 2102 |
|
| 2103 | + if (self.$activeOption && !self.settings.hideSelected) { |
| 2104 | + option_select = self.getAdjacentOption(self.$activeOption, -1).attr('data-value'); |
| 2105 | + } |
| 2106 | + |
2097 | 2107 | // determine items that will be removed
|
2098 | 2108 | values = [];
|
2099 | 2109 |
|
|
2132 | 2142 |
|
2133 | 2143 | self.showInput();
|
2134 | 2144 | self.refreshOptions(true);
|
| 2145 | + |
| 2146 | + // select previous option |
| 2147 | + if (option_select) { |
| 2148 | + $option_select = self.getOption(option_select); |
| 2149 | + if ($option_select.length) { |
| 2150 | + self.setActiveOption($option_select); |
| 2151 | + } |
| 2152 | + } |
| 2153 | + |
2135 | 2154 | return true;
|
2136 | 2155 | },
|
2137 | 2156 |
|
|
0 commit comments