Skip to content

Commit 2e05f33

Browse files
committed
rebuild dist
1 parent ffc8f39 commit 2e05f33

File tree

2 files changed

+82
-73
lines changed

2 files changed

+82
-73
lines changed

dist/js/selectize.js

Lines changed: 80 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,7 @@ var Selectize = function($input, settings) {
11971197
currentResults : null,
11981198
lastValue : '',
11991199
lastValidValue : '',
1200+
lastOpenTarget : false,
12001201
caretPos : 0,
12011202
loading : 0,
12021203
loadedSearches : {},
@@ -1351,7 +1352,11 @@ $.extend(Selectize.prototype, {
13511352
});
13521353

13531354
$control_input.on({
1354-
mousedown : function(e) { e.stopPropagation(); },
1355+
mousedown : function(e) {
1356+
if (self.$control_input.val() !== '' || self.settings.openOnFocus) {
1357+
e.stopPropagation();
1358+
}
1359+
},
13551360
keydown : function() { return self.onKeyDown.apply(self, arguments); },
13561361
keypress : function() { return self.onKeyPress.apply(self, arguments); },
13571362
input : function() { return self.onInput.apply(self, arguments); },
@@ -1557,36 +1562,40 @@ $.extend(Selectize.prototype, {
15571562
var defaultPrevented = e.isDefaultPrevented();
15581563
var $target = $(e.target);
15591564

1560-
if (self.isFocused) {
1561-
// retain focus by preventing native handling. if the
1562-
// event target is the input it should not be modified.
1563-
// otherwise, text selection within the input won't work.
1564-
if (e.target !== self.$control_input[0]) {
1565-
if (self.settings.mode === 'single') {
1566-
// toggle dropdown
1567-
self.isOpen ? self.close() : self.open();
1568-
1569-
// when closing the dropdown, we set a isDropdownClosing
1570-
// varible temporaily to prevent the dropdown from reopening
1571-
// from the onClick event
1572-
self.isDropdownClosing = true;
1573-
setTimeout(function() {
1574-
self.isDropdownClosing = false;
1575-
}, self.settings.closeDropdownThreshold);
1576-
1577-
} else if (!defaultPrevented) {
1578-
self.setActiveItem(null);
1579-
}
1580-
return false;
1581-
}
1582-
} else {
1565+
if (!self.isFocused) {
15831566
// give control focus
15841567
if (!defaultPrevented) {
15851568
window.setTimeout(function() {
15861569
self.focus();
15871570
}, 0);
15881571
}
15891572
}
1573+
// retain focus by preventing native handling. if the
1574+
// event target is the input it should not be modified.
1575+
// otherwise, text selection within the input won't work.
1576+
if (e.target !== self.$control_input[0] || self.$control_input.val() === '') {
1577+
if (self.settings.mode === 'single') {
1578+
// toggle dropdown
1579+
self.isOpen ? self.close() : self.open();
1580+
} else {
1581+
if (!defaultPrevented) {
1582+
self.setActiveItem(null);
1583+
}
1584+
if (!self.settings.openOnFocus) {
1585+
if (self.isOpen && e.target === self.lastOpenTarget) {
1586+
self.close();
1587+
self.lastOpenTarget = false;
1588+
} else if (!self.isOpen) {
1589+
self.refreshOptions();
1590+
self.open();
1591+
self.lastOpenTarget = e.target;
1592+
} else {
1593+
self.lastOpenTarget = e.target;
1594+
}
1595+
}
1596+
}
1597+
return false;
1598+
}
15901599
},
15911600

15921601
/**
@@ -3865,53 +3874,6 @@ $.fn.selectize.support = {
38653874
validity: SUPPORTS_VALIDITY_API
38663875
};
38673876

3868-
/**
3869-
* Plugin: "autofill_disable" (selectize.js)
3870-
* Copyright (c) 2013 Brian Reavis & contributors
3871-
* Copyright (c) 2020-2022 Selectize Team & contributors
3872-
*
3873-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3874-
* file except in compliance with the License. You may obtain a copy of the License at:
3875-
* http://www.apache.org/licenses/LICENSE-2.0
3876-
*
3877-
* Unless required by applicable law or agreed to in writing, software distributed under
3878-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3879-
* ANY KIND, either express or implied. See the License for the specific language
3880-
* governing permissions and limitations under the License.
3881-
*
3882-
* @author Ris Adams <[email protected]>
3883-
*/
3884-
3885-
Selectize.define("autofill_disable", function (options) {
3886-
var self = this;
3887-
3888-
self.setup = (function () {
3889-
var original = self.setup;
3890-
return function () {
3891-
original.apply(self, arguments);
3892-
3893-
// https://stackoverflow.com/questions/30053167/autocomplete-off-vs-false
3894-
self.$control_input.attr({ autocomplete: "new-password", autofill: "no" });
3895-
};
3896-
})();
3897-
});
3898-
3899-
Selectize.define('auto_select_on_type', function(options) {
3900-
var self = this;
3901-
3902-
self.onBlur = (function() {
3903-
var originalBlur = self.onBlur;
3904-
return function(e) {
3905-
var $matchedItem = self.getFirstItemMatchedByTextContent(self.lastValue, true);
3906-
if (typeof $matchedItem.attr('data-value') !== 'undefined' && self.getValue() !== $matchedItem.attr('data-value'))
3907-
{
3908-
self.setValue($matchedItem.attr('data-value'));
3909-
}
3910-
return originalBlur.apply(this, arguments);
3911-
}
3912-
}());
3913-
});
3914-
39153877
Selectize.define("auto_position", function () {
39163878
var self = this;
39173879

@@ -3956,6 +3918,53 @@ Selectize.define("auto_position", function () {
39563918
}());
39573919
});
39583920

3921+
Selectize.define('auto_select_on_type', function(options) {
3922+
var self = this;
3923+
3924+
self.onBlur = (function() {
3925+
var originalBlur = self.onBlur;
3926+
return function(e) {
3927+
var $matchedItem = self.getFirstItemMatchedByTextContent(self.lastValue, true);
3928+
if (typeof $matchedItem.attr('data-value') !== 'undefined' && self.getValue() !== $matchedItem.attr('data-value'))
3929+
{
3930+
self.setValue($matchedItem.attr('data-value'));
3931+
}
3932+
return originalBlur.apply(this, arguments);
3933+
}
3934+
}());
3935+
});
3936+
3937+
/**
3938+
* Plugin: "autofill_disable" (selectize.js)
3939+
* Copyright (c) 2013 Brian Reavis & contributors
3940+
* Copyright (c) 2020-2022 Selectize Team & contributors
3941+
*
3942+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3943+
* file except in compliance with the License. You may obtain a copy of the License at:
3944+
* http://www.apache.org/licenses/LICENSE-2.0
3945+
*
3946+
* Unless required by applicable law or agreed to in writing, software distributed under
3947+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3948+
* ANY KIND, either express or implied. See the License for the specific language
3949+
* governing permissions and limitations under the License.
3950+
*
3951+
* @author Ris Adams <[email protected]>
3952+
*/
3953+
3954+
Selectize.define("autofill_disable", function (options) {
3955+
var self = this;
3956+
3957+
self.setup = (function () {
3958+
var original = self.setup;
3959+
return function () {
3960+
original.apply(self, arguments);
3961+
3962+
// https://stackoverflow.com/questions/30053167/autocomplete-off-vs-false
3963+
self.$control_input.attr({ autocomplete: "new-password", autofill: "no" });
3964+
};
3965+
})();
3966+
});
3967+
39593968
/**
39603969
* Plugin: "clear_button" (selectize.js)
39613970
* Copyright (c) 2013 Brian Reavis & contributors

0 commit comments

Comments
 (0)