@northdata/fomantic-ui 2.9.413 → 2.9.415
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/semantic-ui/dist/components/accordion.min.js +1 -1
- package/lib/semantic-ui/dist/components/api.min.js +1 -1
- package/lib/semantic-ui/dist/components/calendar.min.js +1 -1
- package/lib/semantic-ui/dist/components/checkbox.min.js +1 -1
- package/lib/semantic-ui/dist/components/dimmer.min.js +1 -1
- package/lib/semantic-ui/dist/components/dropdown.js +835 -1248
- package/lib/semantic-ui/dist/components/form.min.js +1 -1
- package/lib/semantic-ui/dist/components/modal.min.js +1 -1
- package/lib/semantic-ui/dist/components/popup.min.js +1 -1
- package/lib/semantic-ui/dist/components/search.min.js +1 -1
- package/lib/semantic-ui/dist/components/site.min.js +1 -1
- package/lib/semantic-ui/dist/components/statistic.css +308 -0
- package/lib/semantic-ui/dist/components/statistic.min.css +9 -0
- package/lib/semantic-ui/dist/components/tab.min.js +1 -1
- package/lib/semantic-ui/dist/components/transition.min.js +1 -1
- package/lib/semantic-ui/dist/less/site/variation.variables +2 -2
- package/lib/semantic-ui/dist/semantic-packed.css +340 -1
- package/lib/semantic-ui/dist/semantic.css +340 -1
- package/lib/semantic-ui/dist/semantic.full.css +679 -1
- package/lib/semantic-ui/dist/semantic.full.min.css +2 -2
- package/lib/semantic-ui/dist/semantic.js +833 -1246
- package/lib/semantic-ui/dist/semantic.min.css +8 -0
- package/package.json +1 -1
- package/lib/semantic-ui/dist/components/dropdown.min.js +0 -11
- package/lib/semantic-ui/dist/semantic.min.js +0 -11
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* https://github.com/fomantic/Fomantic-UI
|
|
4
4
|
* https://fomantic-ui.com/
|
|
5
5
|
*
|
|
6
|
-
* Copyright
|
|
6
|
+
* Copyright 2026 Contributors
|
|
7
7
|
* Released under the MIT license
|
|
8
8
|
* https://opensource.org/licenses/MIT
|
|
9
9
|
*
|
|
@@ -6949,94 +6949,89 @@
|
|
|
6949
6949
|
? window
|
|
6950
6950
|
: globalThis;
|
|
6951
6951
|
|
|
6952
|
-
$.fn.dropdown = function (
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
$document = $(document),
|
|
6952
|
+
$.fn.dropdown = function (...args) {
|
|
6953
|
+
let $allModules = $(this);
|
|
6954
|
+
const $document = $(document);
|
|
6956
6955
|
|
|
6957
|
-
|
|
6958
|
-
|
|
6956
|
+
let time = Date.now();
|
|
6957
|
+
let performance = [];
|
|
6959
6958
|
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
}
|
|
6959
|
+
const parameters = args[0];
|
|
6960
|
+
const methodInvoked = typeof parameters === 'string';
|
|
6961
|
+
const queryArguments = args.slice(1);
|
|
6962
|
+
const contextCheck = function (context, win) {
|
|
6963
|
+
let $context;
|
|
6964
|
+
if ([window, document].includes(context)) {
|
|
6965
|
+
$context = $(context);
|
|
6966
|
+
} else {
|
|
6967
|
+
$context = $(win.document).find(context);
|
|
6968
|
+
if ($context.length === 0) {
|
|
6969
|
+
$context = win.frameElement ? contextCheck(context, win.parent) : window;
|
|
6972
6970
|
}
|
|
6971
|
+
}
|
|
6973
6972
|
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
;
|
|
6973
|
+
return $context;
|
|
6974
|
+
};
|
|
6975
|
+
let returnedValue;
|
|
6978
6976
|
|
|
6979
6977
|
$allModules.each(function (elementIndex) {
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
$divider
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
;
|
|
7038
|
-
|
|
7039
|
-
module = {
|
|
6978
|
+
const settings = $.isPlainObject(parameters)
|
|
6979
|
+
? $.extend(true, {}, $.fn.dropdown.settings, parameters)
|
|
6980
|
+
: $.extend({}, $.fn.dropdown.settings);
|
|
6981
|
+
|
|
6982
|
+
const className = settings.className;
|
|
6983
|
+
const message = settings.message;
|
|
6984
|
+
const fields = settings.fields;
|
|
6985
|
+
const keys = settings.keys;
|
|
6986
|
+
const metadata = settings.metadata;
|
|
6987
|
+
const namespace = settings.namespace;
|
|
6988
|
+
const regExp = settings.regExp;
|
|
6989
|
+
const selector = settings.selector;
|
|
6990
|
+
const error = settings.error;
|
|
6991
|
+
const templates = settings.templates;
|
|
6992
|
+
|
|
6993
|
+
const eventNamespace = '.' + namespace;
|
|
6994
|
+
const moduleNamespace = 'module-' + namespace;
|
|
6995
|
+
|
|
6996
|
+
let $module = $(this);
|
|
6997
|
+
const $context = contextCheck(settings.context, window);
|
|
6998
|
+
let $text = $module.find(selector.text);
|
|
6999
|
+
let $search = $module.find(selector.search);
|
|
7000
|
+
let $sizer = $module.find(selector.sizer);
|
|
7001
|
+
let $input = $module.find(selector.input);
|
|
7002
|
+
let $icon = $module.find(selector.icon);
|
|
7003
|
+
let $clear = $module.find(selector.clearIcon);
|
|
7004
|
+
|
|
7005
|
+
let $combo = $module.prev().find(selector.text).length > 0
|
|
7006
|
+
? $module.prev().find(selector.text)
|
|
7007
|
+
: $module.prev();
|
|
7008
|
+
|
|
7009
|
+
let $menu = $module.children(selector.menu);
|
|
7010
|
+
let $item = $menu.find(selector.item);
|
|
7011
|
+
let $divider = settings.hideDividers
|
|
7012
|
+
? $item.parent().children(selector.divider)
|
|
7013
|
+
: $();
|
|
7014
|
+
|
|
7015
|
+
let activated = false;
|
|
7016
|
+
let itemActivated = false;
|
|
7017
|
+
let internalChange = false;
|
|
7018
|
+
let iconClicked = false;
|
|
7019
|
+
let element = this;
|
|
7020
|
+
let focused = false;
|
|
7021
|
+
let instance = $module.data(moduleNamespace);
|
|
7022
|
+
|
|
7023
|
+
let selectActionActive;
|
|
7024
|
+
let initialLoad;
|
|
7025
|
+
let pageLostFocus;
|
|
7026
|
+
let willRefocus;
|
|
7027
|
+
let elementNamespace;
|
|
7028
|
+
let id;
|
|
7029
|
+
let selectObserver;
|
|
7030
|
+
let menuObserver;
|
|
7031
|
+
let classObserver;
|
|
7032
|
+
let tempDisableApiCache = false;
|
|
7033
|
+
|
|
7034
|
+
const module = {
|
|
7040
7035
|
|
|
7041
7036
|
initialize: function () {
|
|
7042
7037
|
module.debug('Initializing dropdown', settings);
|
|
@@ -7044,11 +7039,6 @@
|
|
|
7044
7039
|
if (module.is.alreadySetup()) {
|
|
7045
7040
|
module.setup.reference();
|
|
7046
7041
|
} else {
|
|
7047
|
-
if (settings.ignoreDiacritics && !String.prototype.normalize) {
|
|
7048
|
-
settings.ignoreDiacritics = false;
|
|
7049
|
-
module.error(error.noNormalize, element);
|
|
7050
|
-
}
|
|
7051
|
-
|
|
7052
7042
|
module.create.id();
|
|
7053
7043
|
module.setup.layout();
|
|
7054
7044
|
|
|
@@ -7077,8 +7067,7 @@
|
|
|
7077
7067
|
module.verbose('Storing instance of dropdown', module);
|
|
7078
7068
|
instance = module;
|
|
7079
7069
|
$module
|
|
7080
|
-
.data(moduleNamespace, module)
|
|
7081
|
-
;
|
|
7070
|
+
.data(moduleNamespace, module);
|
|
7082
7071
|
},
|
|
7083
7072
|
|
|
7084
7073
|
destroy: function () {
|
|
@@ -7089,29 +7078,24 @@
|
|
|
7089
7078
|
$menu.removeClass(className.visible).addClass(className.hidden);
|
|
7090
7079
|
$module
|
|
7091
7080
|
.off(eventNamespace)
|
|
7092
|
-
.removeData(moduleNamespace)
|
|
7093
|
-
;
|
|
7081
|
+
.removeData(moduleNamespace);
|
|
7094
7082
|
$menu
|
|
7095
|
-
.off(eventNamespace)
|
|
7096
|
-
;
|
|
7083
|
+
.off(eventNamespace);
|
|
7097
7084
|
$document
|
|
7098
|
-
.off(elementNamespace)
|
|
7099
|
-
;
|
|
7085
|
+
.off(elementNamespace);
|
|
7100
7086
|
module.disconnect.menuObserver();
|
|
7101
7087
|
module.disconnect.selectObserver();
|
|
7102
7088
|
module.disconnect.classObserver();
|
|
7103
7089
|
},
|
|
7104
7090
|
|
|
7105
7091
|
observeChanges: function () {
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
module.observe.class();
|
|
7114
|
-
}
|
|
7092
|
+
selectObserver = new MutationObserver(module.event.select.mutation);
|
|
7093
|
+
menuObserver = new MutationObserver(module.event.menu.mutation);
|
|
7094
|
+
classObserver = new MutationObserver(module.event.class.mutation);
|
|
7095
|
+
module.debug('Setting up mutation observer', selectObserver, menuObserver, classObserver);
|
|
7096
|
+
module.observe.select();
|
|
7097
|
+
module.observe.menu();
|
|
7098
|
+
module.observe.class();
|
|
7115
7099
|
},
|
|
7116
7100
|
|
|
7117
7101
|
disconnect: {
|
|
@@ -7164,13 +7148,10 @@
|
|
|
7164
7148
|
elementNamespace = '.' + id;
|
|
7165
7149
|
module.verbose('Creating unique id for element', id);
|
|
7166
7150
|
},
|
|
7167
|
-
userChoice: function (values) {
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
html
|
|
7172
|
-
;
|
|
7173
|
-
values = values || module.get.userValues();
|
|
7151
|
+
userChoice: function (values = module.get.userValues()) {
|
|
7152
|
+
let $userChoices;
|
|
7153
|
+
let $userChoice;
|
|
7154
|
+
let html;
|
|
7174
7155
|
if (!values) {
|
|
7175
7156
|
return false;
|
|
7176
7157
|
}
|
|
@@ -7179,14 +7160,13 @@
|
|
|
7179
7160
|
: [values];
|
|
7180
7161
|
$.each(values, function (index, value) {
|
|
7181
7162
|
if (module.get.item(value) === false) {
|
|
7182
|
-
html = settings.templates.addition(module.add.variables(message.addResult, value));
|
|
7163
|
+
html = settings.templates.addition(module.add.variables(message.addResult, settings.templates.escape(value, settings)));
|
|
7183
7164
|
$userChoice = $('<div />')
|
|
7184
7165
|
.html(html)
|
|
7185
7166
|
.attr('data-' + metadata.value, value)
|
|
7186
7167
|
.attr('data-' + metadata.text, value)
|
|
7187
7168
|
.addClass(className.addition)
|
|
7188
|
-
.addClass(className.item)
|
|
7189
|
-
;
|
|
7169
|
+
.addClass(className.item);
|
|
7190
7170
|
if (settings.hideAdditions) {
|
|
7191
7171
|
$userChoice.addClass(className.hidden);
|
|
7192
7172
|
}
|
|
@@ -7200,9 +7180,7 @@
|
|
|
7200
7180
|
return $userChoices;
|
|
7201
7181
|
},
|
|
7202
7182
|
userLabels: function (value) {
|
|
7203
|
-
|
|
7204
|
-
userValues = module.get.userValues()
|
|
7205
|
-
;
|
|
7183
|
+
const userValues = module.get.userValues();
|
|
7206
7184
|
if (userValues) {
|
|
7207
7185
|
module.debug('Adding user labels', userValues);
|
|
7208
7186
|
$.each(userValues, function (index, value) {
|
|
@@ -7214,21 +7192,16 @@
|
|
|
7214
7192
|
menu: function () {
|
|
7215
7193
|
$menu = $('<div />')
|
|
7216
7194
|
.addClass(className.menu)
|
|
7217
|
-
.appendTo($module)
|
|
7218
|
-
;
|
|
7195
|
+
.appendTo($module);
|
|
7219
7196
|
},
|
|
7220
7197
|
sizer: function () {
|
|
7221
7198
|
$sizer = $('<span />')
|
|
7222
7199
|
.addClass(className.sizer)
|
|
7223
|
-
.insertAfter($search)
|
|
7224
|
-
;
|
|
7200
|
+
.insertAfter($search);
|
|
7225
7201
|
},
|
|
7226
7202
|
},
|
|
7227
7203
|
|
|
7228
|
-
search: function (query) {
|
|
7229
|
-
query = query !== undefined
|
|
7230
|
-
? query
|
|
7231
|
-
: module.get.query();
|
|
7204
|
+
search: function (query = module.get.query()) {
|
|
7232
7205
|
module.verbose('Searching for query', query);
|
|
7233
7206
|
if (settings.fireOnInit === false && module.is.initialLoad()) {
|
|
7234
7207
|
module.verbose('Skipping callback on initial load', settings.onSearch);
|
|
@@ -7247,16 +7220,13 @@
|
|
|
7247
7220
|
.not(selector.unselectable)
|
|
7248
7221
|
.not(selector.addition + selector.hidden)
|
|
7249
7222
|
.eq(0)
|
|
7250
|
-
.addClass(className.selected)
|
|
7251
|
-
;
|
|
7223
|
+
.addClass(className.selected);
|
|
7252
7224
|
},
|
|
7253
7225
|
nextAvailable: function ($selected) {
|
|
7254
7226
|
$selected = $selected.eq(0);
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
hasNext = $nextAvailable.length > 0
|
|
7259
|
-
;
|
|
7227
|
+
const $nextAvailable = $selected.nextAll(selector.item).not(selector.unselectable).eq(0);
|
|
7228
|
+
const $prevAvailable = $selected.prevAll(selector.item).not(selector.unselectable).eq(0);
|
|
7229
|
+
const hasNext = $nextAvailable.length > 0;
|
|
7260
7230
|
if (hasNext) {
|
|
7261
7231
|
module.verbose('Moving selection to', $nextAvailable);
|
|
7262
7232
|
$nextAvailable.addClass(className.selected);
|
|
@@ -7269,20 +7239,17 @@
|
|
|
7269
7239
|
|
|
7270
7240
|
setup: {
|
|
7271
7241
|
api: function () {
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
}
|
|
7281
|
-
;
|
|
7242
|
+
const apiSettings = {
|
|
7243
|
+
debug: settings.debug,
|
|
7244
|
+
urlData: {
|
|
7245
|
+
value: module.get.value(),
|
|
7246
|
+
query: module.get.query(),
|
|
7247
|
+
},
|
|
7248
|
+
on: false,
|
|
7249
|
+
};
|
|
7282
7250
|
module.verbose('First request, initializing API');
|
|
7283
7251
|
$module
|
|
7284
|
-
.api(apiSettings)
|
|
7285
|
-
;
|
|
7252
|
+
.api(apiSettings);
|
|
7286
7253
|
},
|
|
7287
7254
|
layout: function () {
|
|
7288
7255
|
if ($module.is('select')) {
|
|
@@ -7296,18 +7263,14 @@
|
|
|
7296
7263
|
module.verbose('Adding clear icon');
|
|
7297
7264
|
$clear = $('<i />')
|
|
7298
7265
|
.addClass('remove icon')
|
|
7299
|
-
.insertAfter($icon)
|
|
7300
|
-
;
|
|
7266
|
+
.insertAfter($icon);
|
|
7301
7267
|
}
|
|
7302
7268
|
if (module.is.search() && !module.has.search()) {
|
|
7303
7269
|
module.verbose('Adding search input');
|
|
7304
|
-
|
|
7305
|
-
labelNode = $module.prev('label')
|
|
7306
|
-
;
|
|
7270
|
+
const labelNode = $module.prev('label');
|
|
7307
7271
|
$search = $('<input />')
|
|
7308
7272
|
.addClass(className.search)
|
|
7309
|
-
.prop('autocomplete', 'off')
|
|
7310
|
-
;
|
|
7273
|
+
.prop('autocomplete', 'off');
|
|
7311
7274
|
if (labelNode.length > 0) {
|
|
7312
7275
|
if (!labelNode.attr('id')) {
|
|
7313
7276
|
labelNode.attr('id', '_' + module.get.id() + '_formLabel');
|
|
@@ -7324,9 +7287,7 @@
|
|
|
7324
7287
|
}
|
|
7325
7288
|
},
|
|
7326
7289
|
select: function () {
|
|
7327
|
-
|
|
7328
|
-
selectValues = module.get.selectValues()
|
|
7329
|
-
;
|
|
7290
|
+
const selectValues = module.get.selectValues();
|
|
7330
7291
|
module.debug('Dropdown initialized on a select', selectValues);
|
|
7331
7292
|
if ($module.is('select')) {
|
|
7332
7293
|
$input = $module;
|
|
@@ -7346,9 +7307,8 @@
|
|
|
7346
7307
|
.attr('class', $input.attr('class'))
|
|
7347
7308
|
.addClass(className.selection)
|
|
7348
7309
|
.addClass(className.dropdown)
|
|
7349
|
-
.html(templates.dropdown(selectValues,
|
|
7350
|
-
.insertBefore($input)
|
|
7351
|
-
;
|
|
7310
|
+
.html(templates.dropdown(selectValues, settings))
|
|
7311
|
+
.insertBefore($input);
|
|
7352
7312
|
if ($input.hasClass(className.multiple) && $input.prop('multiple') === false) {
|
|
7353
7313
|
module.error(error.missingMultiple);
|
|
7354
7314
|
$input.prop('multiple', true);
|
|
@@ -7370,13 +7330,12 @@
|
|
|
7370
7330
|
.prop('required', false)
|
|
7371
7331
|
.removeAttr('class')
|
|
7372
7332
|
.detach()
|
|
7373
|
-
.prependTo($module)
|
|
7374
|
-
;
|
|
7333
|
+
.prependTo($module);
|
|
7375
7334
|
}
|
|
7376
7335
|
module.refresh();
|
|
7377
7336
|
},
|
|
7378
7337
|
menu: function (values) {
|
|
7379
|
-
$menu.html(templates.menu(values,
|
|
7338
|
+
$menu.html(templates.menu(values, settings));
|
|
7380
7339
|
$item = $menu.find(selector.item);
|
|
7381
7340
|
$divider = settings.hideDividers ? $item.parent().children(selector.divider) : $();
|
|
7382
7341
|
},
|
|
@@ -7390,11 +7349,9 @@
|
|
|
7390
7349
|
module.setup.returnedObject();
|
|
7391
7350
|
},
|
|
7392
7351
|
returnedObject: function () {
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
;
|
|
7397
|
-
// adjust all modules to use correct reference
|
|
7352
|
+
const $firstModules = $allModules.slice(0, elementIndex);
|
|
7353
|
+
const $lastModules = $allModules.slice(elementIndex + 1);
|
|
7354
|
+
// adjust all modules to use the correct reference
|
|
7398
7355
|
$allModules = $firstModules.add($module).add($lastModules);
|
|
7399
7356
|
},
|
|
7400
7357
|
},
|
|
@@ -7427,21 +7384,18 @@
|
|
|
7427
7384
|
module.verbose('Refreshing cached metadata');
|
|
7428
7385
|
$item
|
|
7429
7386
|
.removeData(metadata.text)
|
|
7430
|
-
.removeData(metadata.value)
|
|
7431
|
-
;
|
|
7387
|
+
.removeData(metadata.value);
|
|
7432
7388
|
},
|
|
7433
7389
|
|
|
7434
7390
|
clearData: function () {
|
|
7435
7391
|
module.verbose('Clearing metadata');
|
|
7436
7392
|
$item
|
|
7437
7393
|
.removeData(metadata.text)
|
|
7438
|
-
.removeData(metadata.value)
|
|
7439
|
-
;
|
|
7394
|
+
.removeData(metadata.value);
|
|
7440
7395
|
$module
|
|
7441
7396
|
.removeData(metadata.defaultText)
|
|
7442
7397
|
.removeData(metadata.defaultValue)
|
|
7443
|
-
.removeData(metadata.placeholderText)
|
|
7444
|
-
;
|
|
7398
|
+
.removeData(metadata.placeholderText);
|
|
7445
7399
|
},
|
|
7446
7400
|
|
|
7447
7401
|
clearItems: function () {
|
|
@@ -7508,11 +7462,11 @@
|
|
|
7508
7462
|
});
|
|
7509
7463
|
// Hide submenus explicitly. On some browsers (esp. mobile), they will not automatically receive a
|
|
7510
7464
|
// mouseleave event
|
|
7511
|
-
|
|
7465
|
+
const $subMenu = $module.find(selector.menu);
|
|
7512
7466
|
if ($subMenu.length > 0) {
|
|
7513
7467
|
module.verbose('Hiding sub-menu', $subMenu);
|
|
7514
7468
|
$subMenu.each(function () {
|
|
7515
|
-
|
|
7469
|
+
const $sub = $(this);
|
|
7516
7470
|
if (!module.is.animating($sub)) {
|
|
7517
7471
|
module.animate.hide(false, $sub);
|
|
7518
7472
|
}
|
|
@@ -7531,8 +7485,7 @@
|
|
|
7531
7485
|
$allModules
|
|
7532
7486
|
.not($module)
|
|
7533
7487
|
.has(selector.menu + '.' + className.visible)
|
|
7534
|
-
.dropdown('hide')
|
|
7535
|
-
;
|
|
7488
|
+
.dropdown('hide');
|
|
7536
7489
|
},
|
|
7537
7490
|
|
|
7538
7491
|
hideMenu: function () {
|
|
@@ -7543,9 +7496,7 @@
|
|
|
7543
7496
|
},
|
|
7544
7497
|
|
|
7545
7498
|
hideSubMenus: function () {
|
|
7546
|
-
|
|
7547
|
-
$subMenus = $menu.children(selector.item).find(selector.menu)
|
|
7548
|
-
;
|
|
7499
|
+
const $subMenus = $menu.children(selector.item).find(selector.menu);
|
|
7549
7500
|
module.verbose('Hiding sub menus', $subMenus);
|
|
7550
7501
|
$subMenus.transition('hide');
|
|
7551
7502
|
},
|
|
@@ -7559,28 +7510,23 @@
|
|
|
7559
7510
|
keyboardEvents: function () {
|
|
7560
7511
|
module.verbose('Binding keyboard events');
|
|
7561
7512
|
$module
|
|
7562
|
-
.on('keydown' + eventNamespace, module.event.keydown)
|
|
7563
|
-
;
|
|
7513
|
+
.on('keydown' + eventNamespace, module.event.keydown);
|
|
7564
7514
|
if (module.has.search()) {
|
|
7565
7515
|
$module
|
|
7566
|
-
.on(module.get.inputEvent() + eventNamespace, selector.search, module.event.input)
|
|
7567
|
-
;
|
|
7516
|
+
.on(module.get.inputEvent() + eventNamespace, selector.search, module.event.input);
|
|
7568
7517
|
}
|
|
7569
7518
|
if (module.is.multiple()) {
|
|
7570
7519
|
$document
|
|
7571
|
-
.on('keydown' + elementNamespace, module.event.document.keydown)
|
|
7572
|
-
;
|
|
7520
|
+
.on('keydown' + elementNamespace, module.event.document.keydown);
|
|
7573
7521
|
}
|
|
7574
7522
|
},
|
|
7575
7523
|
inputEvents: function () {
|
|
7576
7524
|
module.verbose('Binding input change events');
|
|
7577
7525
|
$module
|
|
7578
|
-
.on('change' + eventNamespace, selector.input, module.event.change)
|
|
7579
|
-
;
|
|
7526
|
+
.on('change' + eventNamespace, selector.input, module.event.change);
|
|
7580
7527
|
if (module.is.multiple() && module.is.searchSelection()) {
|
|
7581
7528
|
$module
|
|
7582
|
-
.on('paste' + eventNamespace, selector.search, module.event.paste)
|
|
7583
|
-
;
|
|
7529
|
+
.on('paste' + eventNamespace, selector.search, module.event.paste);
|
|
7584
7530
|
}
|
|
7585
7531
|
},
|
|
7586
7532
|
mouseEvents: function () {
|
|
@@ -7588,8 +7534,7 @@
|
|
|
7588
7534
|
if (module.is.multiple()) {
|
|
7589
7535
|
$module
|
|
7590
7536
|
.on('click' + eventNamespace, selector.label, module.event.label.click)
|
|
7591
|
-
.on('click' + eventNamespace, selector.remove, module.event.remove.click)
|
|
7592
|
-
;
|
|
7537
|
+
.on('click' + eventNamespace, selector.remove, module.event.remove.click);
|
|
7593
7538
|
}
|
|
7594
7539
|
if (module.is.searchSelection()) {
|
|
7595
7540
|
$module
|
|
@@ -7602,60 +7547,50 @@
|
|
|
7602
7547
|
.on('focus' + eventNamespace, selector.search, module.event.search.focus)
|
|
7603
7548
|
.on('click' + eventNamespace, selector.search, module.event.search.focus)
|
|
7604
7549
|
.on('blur' + eventNamespace, selector.search, module.event.search.blur)
|
|
7605
|
-
.on('click' + eventNamespace, selector.text, module.event.text.focus)
|
|
7606
|
-
;
|
|
7550
|
+
.on('click' + eventNamespace, selector.text, module.event.text.focus);
|
|
7607
7551
|
if (module.is.multiple()) {
|
|
7608
7552
|
$module
|
|
7609
7553
|
.on('click' + eventNamespace, module.event.click)
|
|
7610
|
-
.on('click' + eventNamespace, module.event.search.focus)
|
|
7611
|
-
;
|
|
7554
|
+
.on('click' + eventNamespace, module.event.search.focus);
|
|
7612
7555
|
}
|
|
7613
7556
|
} else {
|
|
7614
7557
|
if (settings.on === 'click') {
|
|
7615
7558
|
$module
|
|
7616
7559
|
.on('click' + eventNamespace, selector.icon, module.event.icon.click)
|
|
7617
|
-
.on('click' + eventNamespace, module.event.test.toggle)
|
|
7618
|
-
;
|
|
7560
|
+
.on('click' + eventNamespace, module.event.test.toggle);
|
|
7619
7561
|
} else if (settings.on === 'hover') {
|
|
7620
7562
|
$module
|
|
7621
7563
|
.on('mouseenter' + eventNamespace, module.delay.show)
|
|
7622
7564
|
.on('mouseleave' + eventNamespace, module.delay.hide)
|
|
7623
7565
|
.on('touchstart' + eventNamespace, module.event.test.toggle)
|
|
7624
|
-
.on('touchstart' + eventNamespace, selector.icon, module.event.icon.click)
|
|
7625
|
-
;
|
|
7566
|
+
.on('touchstart' + eventNamespace, selector.icon, module.event.icon.click);
|
|
7626
7567
|
} else {
|
|
7627
7568
|
$module
|
|
7628
|
-
.on(settings.on + eventNamespace, module.toggle)
|
|
7629
|
-
;
|
|
7569
|
+
.on(settings.on + eventNamespace, module.toggle);
|
|
7630
7570
|
}
|
|
7631
7571
|
$module
|
|
7632
7572
|
.on('mousedown' + eventNamespace, module.event.mousedown)
|
|
7633
7573
|
.on('mouseup' + eventNamespace, module.event.mouseup)
|
|
7634
7574
|
.on('focus' + eventNamespace, module.event.focus)
|
|
7635
|
-
.on('click' + eventNamespace, selector.clearIcon, module.event.clearIcon.click)
|
|
7636
|
-
;
|
|
7575
|
+
.on('click' + eventNamespace, selector.clearIcon, module.event.clearIcon.click);
|
|
7637
7576
|
if (module.has.menuSearch()) {
|
|
7638
7577
|
$module
|
|
7639
|
-
.on('blur' + eventNamespace, selector.search, module.event.search.blur)
|
|
7640
|
-
;
|
|
7578
|
+
.on('blur' + eventNamespace, selector.search, module.event.search.blur);
|
|
7641
7579
|
} else {
|
|
7642
7580
|
$module
|
|
7643
|
-
.on('blur' + eventNamespace, module.event.blur)
|
|
7644
|
-
;
|
|
7581
|
+
.on('blur' + eventNamespace, module.event.blur);
|
|
7645
7582
|
}
|
|
7646
7583
|
}
|
|
7647
7584
|
$menu
|
|
7648
7585
|
.on('mouseenter' + eventNamespace, selector.item, module.event.item.mouseenter)
|
|
7649
7586
|
.on('touchstart' + eventNamespace, selector.item, module.event.item.mouseenter)
|
|
7650
7587
|
.on('mouseleave' + eventNamespace, selector.item, module.event.item.mouseleave)
|
|
7651
|
-
.on('click' + eventNamespace, selector.item, module.event.item.click)
|
|
7652
|
-
;
|
|
7588
|
+
.on('click' + eventNamespace, selector.item, module.event.item.click);
|
|
7653
7589
|
},
|
|
7654
7590
|
intent: function () {
|
|
7655
7591
|
module.verbose('Binding hide intent event to document');
|
|
7656
7592
|
$document
|
|
7657
|
-
.on('click' + elementNamespace, module.event.test.hide)
|
|
7658
|
-
;
|
|
7593
|
+
.on('click' + elementNamespace, module.event.test.hide);
|
|
7659
7594
|
},
|
|
7660
7595
|
},
|
|
7661
7596
|
|
|
@@ -7663,52 +7598,51 @@
|
|
|
7663
7598
|
intent: function () {
|
|
7664
7599
|
module.verbose('Removing hide intent event from document');
|
|
7665
7600
|
$document
|
|
7666
|
-
.off('click' + elementNamespace)
|
|
7667
|
-
;
|
|
7601
|
+
.off('click' + elementNamespace);
|
|
7668
7602
|
},
|
|
7669
7603
|
},
|
|
7670
7604
|
|
|
7671
7605
|
filter: function (query) {
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
if (
|
|
7684
|
-
if (settings.
|
|
7685
|
-
if (settings.
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
module.hideMenu();
|
|
7690
|
-
}
|
|
7691
|
-
} else {
|
|
7692
|
-
module.verbose('All items filtered, showing message', searchTerm);
|
|
7693
|
-
module.add.message(message.noResults);
|
|
7606
|
+
const searchTerm = query !== undefined
|
|
7607
|
+
? query
|
|
7608
|
+
: module.get.query();
|
|
7609
|
+
const afterFiltered = function () {
|
|
7610
|
+
if (module.is.multiple()) {
|
|
7611
|
+
module.filterActive();
|
|
7612
|
+
}
|
|
7613
|
+
if (query || (!query && module.get.activeItem().length === 0)) {
|
|
7614
|
+
module.select.firstUnfiltered();
|
|
7615
|
+
}
|
|
7616
|
+
if (module.has.allResultsFiltered()) {
|
|
7617
|
+
if (settings.onNoResults.call(element, searchTerm)) {
|
|
7618
|
+
if (settings.allowAdditions) {
|
|
7619
|
+
if (settings.hideAdditions) {
|
|
7620
|
+
module.verbose('User addition with no menu, setting empty style');
|
|
7621
|
+
module.set.empty();
|
|
7622
|
+
module.hideMenu();
|
|
7694
7623
|
}
|
|
7695
7624
|
} else {
|
|
7696
|
-
module.verbose('All items filtered,
|
|
7697
|
-
module.
|
|
7698
|
-
module.hideMenu();
|
|
7625
|
+
module.verbose('All items filtered, showing message', searchTerm);
|
|
7626
|
+
module.add.message(message.noResults);
|
|
7699
7627
|
}
|
|
7700
7628
|
} else {
|
|
7701
|
-
module.
|
|
7702
|
-
module.
|
|
7703
|
-
|
|
7704
|
-
if (settings.allowAdditions) {
|
|
7705
|
-
module.add.userSuggestion(module.escape.htmlEntities(query));
|
|
7706
|
-
}
|
|
7707
|
-
if (module.is.searchSelection() && module.can.show() && module.is.focusedOnSearch() && !module.is.empty()) {
|
|
7708
|
-
module.show();
|
|
7629
|
+
module.verbose('All items filtered, hiding dropdown', searchTerm);
|
|
7630
|
+
module.set.empty();
|
|
7631
|
+
module.hideMenu();
|
|
7709
7632
|
}
|
|
7633
|
+
} else {
|
|
7634
|
+
module.remove.empty();
|
|
7635
|
+
module.remove.message();
|
|
7710
7636
|
}
|
|
7711
|
-
|
|
7637
|
+
if (settings.allowAdditions) {
|
|
7638
|
+
module.add.userSuggestion(settings.preserveHTML
|
|
7639
|
+
? settings.templates.escape(query)
|
|
7640
|
+
: query);
|
|
7641
|
+
}
|
|
7642
|
+
if (module.is.searchSelection() && module.can.show() && module.is.focusedOnSearch() && !module.is.empty()) {
|
|
7643
|
+
module.show();
|
|
7644
|
+
}
|
|
7645
|
+
};
|
|
7712
7646
|
if (settings.useLabels && module.has.maxSelections()) {
|
|
7713
7647
|
module.show();
|
|
7714
7648
|
|
|
@@ -7720,15 +7654,14 @@
|
|
|
7720
7654
|
if (settings.filterRemoteData) {
|
|
7721
7655
|
module.filterItems(searchTerm);
|
|
7722
7656
|
}
|
|
7723
|
-
|
|
7657
|
+
let preSelected = $input.val();
|
|
7724
7658
|
if (!Array.isArray(preSelected)) {
|
|
7725
7659
|
preSelected = preSelected && preSelected !== '' ? preSelected.split(settings.delimiter) : [];
|
|
7726
7660
|
}
|
|
7727
7661
|
if (module.is.multiple()) {
|
|
7728
7662
|
$.each(preSelected, function (index, value) {
|
|
7729
|
-
$item.filter('[data-' + metadata.value + '="' + value + '"]')
|
|
7730
|
-
.addClass(className.filtered)
|
|
7731
|
-
;
|
|
7663
|
+
$item.filter('[data-' + metadata.value + '="' + CSS.escape(value) + '"]')
|
|
7664
|
+
.addClass(className.filtered);
|
|
7732
7665
|
});
|
|
7733
7666
|
}
|
|
7734
7667
|
module.focusSearch(true);
|
|
@@ -7747,88 +7680,81 @@
|
|
|
7747
7680
|
if (!Array.isArray(callbackParameters)) {
|
|
7748
7681
|
callbackParameters = [callbackParameters];
|
|
7749
7682
|
}
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
query: query,
|
|
7757
|
-
},
|
|
7683
|
+
let apiSettings = {
|
|
7684
|
+
errorDuration: false,
|
|
7685
|
+
cache: 'local',
|
|
7686
|
+
throttle: settings.throttle,
|
|
7687
|
+
urlData: {
|
|
7688
|
+
query: query,
|
|
7758
7689
|
},
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
}
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
}
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
module.setup.menu(menuConfig);
|
|
7690
|
+
};
|
|
7691
|
+
const apiCallbacks = {
|
|
7692
|
+
onError: function (errorMessage, $module, xhr) {
|
|
7693
|
+
module.add.message(message.serverError);
|
|
7694
|
+
iconClicked = false;
|
|
7695
|
+
focused = false;
|
|
7696
|
+
callback(...callbackParameters);
|
|
7697
|
+
if (typeof settings.apiSettings.onError === 'function') {
|
|
7698
|
+
settings.apiSettings.onError.call(this, errorMessage, $module, xhr);
|
|
7699
|
+
}
|
|
7700
|
+
},
|
|
7701
|
+
onFailure: function (response, $module, xhr) {
|
|
7702
|
+
module.add.message(message.serverError);
|
|
7703
|
+
iconClicked = false;
|
|
7704
|
+
focused = false;
|
|
7705
|
+
callback(...callbackParameters);
|
|
7706
|
+
if (typeof settings.apiSettings.onFailure === 'function') {
|
|
7707
|
+
settings.apiSettings.onFailure.call(this, response, $module, xhr);
|
|
7708
|
+
}
|
|
7709
|
+
},
|
|
7710
|
+
onSuccess: function (response, $module, xhr) {
|
|
7711
|
+
let values = response[fields.remoteValues];
|
|
7712
|
+
if (!Array.isArray(values)) {
|
|
7713
|
+
values = [];
|
|
7714
|
+
}
|
|
7715
|
+
module.remove.message();
|
|
7716
|
+
const menuConfig = {};
|
|
7717
|
+
menuConfig[fields.values] = values;
|
|
7718
|
+
module.setup.menu(menuConfig);
|
|
7789
7719
|
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
}
|
|
7798
|
-
}
|
|
7799
|
-
iconClicked = false;
|
|
7800
|
-
focused = false;
|
|
7801
|
-
callback.apply(null, callbackParameters);
|
|
7802
|
-
if (typeof settings.apiSettings.onSuccess === 'function') {
|
|
7803
|
-
settings.apiSettings.onSuccess.call(this, response, $module, xhr);
|
|
7720
|
+
if (values.length === 0 && !settings.allowAdditions) {
|
|
7721
|
+
module.add.message(message.noResults);
|
|
7722
|
+
} else {
|
|
7723
|
+
const value = module.is.multiple() ? module.get.values() : module.get.value();
|
|
7724
|
+
if (value !== '') {
|
|
7725
|
+
module.verbose('Value(s) present after click icon, select value(s) in items');
|
|
7726
|
+
module.set.selected(value, null, true, true);
|
|
7804
7727
|
}
|
|
7805
|
-
}
|
|
7806
|
-
|
|
7807
|
-
|
|
7728
|
+
}
|
|
7729
|
+
iconClicked = false;
|
|
7730
|
+
focused = false;
|
|
7731
|
+
callback(...callbackParameters);
|
|
7732
|
+
if (typeof settings.apiSettings.onSuccess === 'function') {
|
|
7733
|
+
settings.apiSettings.onSuccess.call(this, response, $module, xhr);
|
|
7734
|
+
}
|
|
7735
|
+
},
|
|
7736
|
+
};
|
|
7808
7737
|
if (!$module.api('get request')) {
|
|
7809
7738
|
module.setup.api();
|
|
7810
7739
|
}
|
|
7811
7740
|
apiSettings = $.extend(true, {}, apiSettings, settings.apiSettings, apiCallbacks, tempDisableApiCache ? { cache: false } : {});
|
|
7812
7741
|
$module
|
|
7813
7742
|
.api('setting', apiSettings)
|
|
7814
|
-
.api('query')
|
|
7815
|
-
;
|
|
7743
|
+
.api('query');
|
|
7816
7744
|
tempDisableApiCache = false;
|
|
7817
7745
|
},
|
|
7818
7746
|
|
|
7819
7747
|
filterItems: function (query) {
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
query
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
beginsWithRegExp = new RegExp('^' + escapedTerm, regExpFlags)
|
|
7831
|
-
;
|
|
7748
|
+
const searchTerm = module.remove.diacritics(
|
|
7749
|
+
query !== undefined
|
|
7750
|
+
? query
|
|
7751
|
+
: module.get.query()
|
|
7752
|
+
);
|
|
7753
|
+
let results = null;
|
|
7754
|
+
const escapedTerm = module.escape.string(searchTerm);
|
|
7755
|
+
const regExpIgnore = settings.ignoreSearchCase ? 'i' : '';
|
|
7756
|
+
const regExpFlags = regExpIgnore + 'gm';
|
|
7757
|
+
const beginsWithRegExp = new RegExp('^' + escapedTerm, regExpFlags);
|
|
7832
7758
|
module.remove.filteredItem();
|
|
7833
7759
|
// avoid loop if we're matching nothing
|
|
7834
7760
|
if (module.has.query()) {
|
|
@@ -7837,11 +7763,9 @@
|
|
|
7837
7763
|
module.verbose('Searching for matching values', searchTerm);
|
|
7838
7764
|
$item
|
|
7839
7765
|
.each(function () {
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
value
|
|
7844
|
-
;
|
|
7766
|
+
const $choice = $(this);
|
|
7767
|
+
let text;
|
|
7768
|
+
let value;
|
|
7845
7769
|
if ($choice.hasClass(className.unfilterable)) {
|
|
7846
7770
|
results.push(this);
|
|
7847
7771
|
|
|
@@ -7869,32 +7793,28 @@
|
|
|
7869
7793
|
return true;
|
|
7870
7794
|
}
|
|
7871
7795
|
}
|
|
7872
|
-
})
|
|
7873
|
-
;
|
|
7796
|
+
});
|
|
7874
7797
|
}
|
|
7875
7798
|
module.debug('Showing only matched items', searchTerm);
|
|
7876
7799
|
if (results) {
|
|
7877
7800
|
$item
|
|
7878
7801
|
.not(results)
|
|
7879
|
-
.addClass(className.filtered)
|
|
7880
|
-
;
|
|
7802
|
+
.addClass(className.filtered);
|
|
7881
7803
|
if (settings.highlightMatches && (settings.match === 'both' || settings.match === 'text')) {
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7804
|
+
const querySplit = [...query];
|
|
7805
|
+
const diacriticReg = settings.ignoreDiacritics ? '[\u0300-\u036F]?' : '';
|
|
7806
|
+
const htmlReg = '(?![^<]*>)';
|
|
7807
|
+
const markedRegExp = new RegExp(htmlReg + '(' + querySplit.join(diacriticReg + ')(.*?)' + htmlReg + '(') + diacriticReg + ')', regExpIgnore);
|
|
7808
|
+
const markedReplacer = function (...args) {
|
|
7809
|
+
args = args.slice(1, querySplit.length * 2).map(function (x, i) {
|
|
7810
|
+
return i & 1 ? x : '<mark>' + x + '</mark>'; // eslint-disable-line no-bitwise
|
|
7811
|
+
});
|
|
7890
7812
|
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
;
|
|
7813
|
+
return args.join('');
|
|
7814
|
+
};
|
|
7894
7815
|
$.each(results, function (index, result) {
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
;
|
|
7816
|
+
const $result = $(result);
|
|
7817
|
+
let markedHTML = module.get.choiceText($result, true);
|
|
7898
7818
|
if (settings.ignoreDiacritics) {
|
|
7899
7819
|
markedHTML = markedHTML.normalize('NFD');
|
|
7900
7820
|
}
|
|
@@ -7905,19 +7825,17 @@
|
|
|
7905
7825
|
|
|
7906
7826
|
if (!module.has.query()) {
|
|
7907
7827
|
$divider
|
|
7908
|
-
.removeClass(className.hidden)
|
|
7909
|
-
;
|
|
7828
|
+
.removeClass(className.hidden);
|
|
7910
7829
|
} else if (settings.hideDividers === true) {
|
|
7911
7830
|
$divider
|
|
7912
|
-
.addClass(className.hidden)
|
|
7913
|
-
;
|
|
7831
|
+
.addClass(className.hidden);
|
|
7914
7832
|
} else if (settings.hideDividers === 'empty') {
|
|
7915
7833
|
$divider
|
|
7916
7834
|
.removeClass(className.hidden)
|
|
7917
7835
|
.filter(function () {
|
|
7918
7836
|
// First find the last divider in this divider group
|
|
7919
7837
|
// Dividers which are direct siblings are considered a group
|
|
7920
|
-
|
|
7838
|
+
const $lastDivider = $(this).nextUntil(selector.item);
|
|
7921
7839
|
|
|
7922
7840
|
return ($lastDivider.length > 0 ? $lastDivider : $(this))
|
|
7923
7841
|
// Count all non-filtered items until the next divider (or end of the dropdown)
|
|
@@ -7926,16 +7844,13 @@
|
|
|
7926
7844
|
// Hide divider if no items are found
|
|
7927
7845
|
.length === 0;
|
|
7928
7846
|
})
|
|
7929
|
-
.addClass(className.hidden)
|
|
7930
|
-
;
|
|
7847
|
+
.addClass(className.hidden);
|
|
7931
7848
|
}
|
|
7932
7849
|
},
|
|
7933
7850
|
|
|
7934
7851
|
fuzzySearch: function (query, term) {
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
queryLength = query.length
|
|
7938
|
-
;
|
|
7852
|
+
const termLength = term.length;
|
|
7853
|
+
const queryLength = query.length;
|
|
7939
7854
|
if (settings.ignoreSearchCase) {
|
|
7940
7855
|
query = query.toLowerCase();
|
|
7941
7856
|
term = term.toLowerCase();
|
|
@@ -7946,13 +7861,11 @@
|
|
|
7946
7861
|
if (queryLength === termLength) {
|
|
7947
7862
|
return query === term;
|
|
7948
7863
|
}
|
|
7949
|
-
for (
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
queryCharacter = query.charCodeAt(characterIndex)
|
|
7953
|
-
;
|
|
7864
|
+
for (let characterIndex = 0, nextCharacterIndex = 0; characterIndex < queryLength; characterIndex++) {
|
|
7865
|
+
let continueSearch = false;
|
|
7866
|
+
const queryCharacter = query.codePointAt(characterIndex);
|
|
7954
7867
|
while (nextCharacterIndex < termLength) {
|
|
7955
|
-
if (term.
|
|
7868
|
+
if (term.codePointAt(nextCharacterIndex++) === queryCharacter) {
|
|
7956
7869
|
continueSearch = true;
|
|
7957
7870
|
|
|
7958
7871
|
break;
|
|
@@ -7970,13 +7883,12 @@
|
|
|
7970
7883
|
query = settings.ignoreSearchCase ? query.toLowerCase() : query;
|
|
7971
7884
|
term = settings.ignoreSearchCase ? term.toLowerCase() : term;
|
|
7972
7885
|
|
|
7973
|
-
return term.
|
|
7886
|
+
return term.includes(query);
|
|
7974
7887
|
},
|
|
7975
7888
|
filterActive: function () {
|
|
7976
7889
|
if (settings.useLabels) {
|
|
7977
7890
|
$item.filter('.' + className.active)
|
|
7978
|
-
.addClass(className.filtered)
|
|
7979
|
-
;
|
|
7891
|
+
.addClass(className.filtered);
|
|
7980
7892
|
}
|
|
7981
7893
|
},
|
|
7982
7894
|
|
|
@@ -7999,14 +7911,12 @@
|
|
|
7999
7911
|
},
|
|
8000
7912
|
|
|
8001
7913
|
forceSelection: function () {
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
hasSelected = $selectedItem.length > 0
|
|
8009
|
-
;
|
|
7914
|
+
const $currentlySelected = $item.not(className.filtered).filter('.' + className.selected).eq(0);
|
|
7915
|
+
const $activeItem = $item.not(className.filtered).filter('.' + className.active).eq(0);
|
|
7916
|
+
const $selectedItem = $currentlySelected.length > 0
|
|
7917
|
+
? $currentlySelected
|
|
7918
|
+
: $activeItem;
|
|
7919
|
+
const hasSelected = $selectedItem.length > 0;
|
|
8010
7920
|
if (settings.allowAdditions || (hasSelected && !module.is.multiple())) {
|
|
8011
7921
|
module.debug('Forcing partial selection to selected item', $selectedItem);
|
|
8012
7922
|
module.event.item.click.call($selectedItem, {}, true);
|
|
@@ -8021,32 +7931,38 @@
|
|
|
8021
7931
|
module.clear();
|
|
8022
7932
|
}
|
|
8023
7933
|
module.debug('Creating dropdown with specified values', values);
|
|
8024
|
-
|
|
7934
|
+
const menuConfig = {};
|
|
8025
7935
|
menuConfig[fields.values] = values;
|
|
8026
7936
|
module.setup.menu(menuConfig);
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
if (
|
|
8032
|
-
|
|
7937
|
+
const findSelected = function (values) {
|
|
7938
|
+
let hasMultiple = true;
|
|
7939
|
+
$.each(values, function (index, item) {
|
|
7940
|
+
const itemType = item.type || 'item';
|
|
7941
|
+
if (item.selected === true) {
|
|
7942
|
+
module.debug('Setting initial selection to', item[fields.value]);
|
|
7943
|
+
module.set.selected(item[fields.value]);
|
|
7944
|
+
if (!module.is.multiple()) {
|
|
7945
|
+
hasMultiple = false;
|
|
7946
|
+
}
|
|
7947
|
+
} else if (itemType.includes('menu')) {
|
|
7948
|
+
hasMultiple = findSelected(item.values || []);
|
|
8033
7949
|
}
|
|
8034
|
-
|
|
8035
|
-
|
|
7950
|
+
|
|
7951
|
+
return hasMultiple;
|
|
7952
|
+
});
|
|
7953
|
+
|
|
7954
|
+
return hasMultiple;
|
|
7955
|
+
};
|
|
7956
|
+
findSelected(values);
|
|
8036
7957
|
|
|
8037
7958
|
if (module.has.selectInput()) {
|
|
8038
7959
|
module.disconnect.selectObserver();
|
|
8039
7960
|
$input.html('');
|
|
8040
7961
|
$input.append('<option disabled selected value></option>');
|
|
8041
7962
|
$.each(values, function (index, item) {
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
item[fields.name] || '',
|
|
8046
|
-
settings.preserveHTML
|
|
8047
|
-
)
|
|
8048
|
-
;
|
|
8049
|
-
$input.append('<option value="' + value + '"' + (item.selected === true ? ' selected' : '') + '>' + name + '</option>');
|
|
7963
|
+
const value = item[fields.value];
|
|
7964
|
+
const name = item[fields.name] || '';
|
|
7965
|
+
$input.append('<option value="' + settings.templates.escape(value) + '"' + (item.selected === true ? ' selected' : '') + '>' + settings.templates.escape(name, settings) + '</option>');
|
|
8050
7966
|
});
|
|
8051
7967
|
module.observe.select();
|
|
8052
7968
|
}
|
|
@@ -8055,25 +7971,26 @@
|
|
|
8055
7971
|
|
|
8056
7972
|
event: {
|
|
8057
7973
|
paste: function (event) {
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
7974
|
+
const pasteValue = (event.originalEvent.clipboardData || window.clipboardData).getData('text');
|
|
7975
|
+
const tokens = pasteValue.split(settings.delimiter);
|
|
7976
|
+
const notFoundTokens = [];
|
|
7977
|
+
for (let value of tokens) {
|
|
7978
|
+
value = value.trim();
|
|
7979
|
+
const valueTrimmed = settings.preserveHTML
|
|
7980
|
+
? settings.templates.escape(value)
|
|
7981
|
+
: value;
|
|
7982
|
+
if (module.set.selected(valueTrimmed, null, false, true) === false) {
|
|
7983
|
+
notFoundTokens.push(valueTrimmed);
|
|
8066
7984
|
}
|
|
8067
|
-
}
|
|
7985
|
+
}
|
|
8068
7986
|
event.preventDefault();
|
|
8069
7987
|
if (notFoundTokens.length > 0) {
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
;
|
|
7988
|
+
const searchEl = $search[0];
|
|
7989
|
+
const startPos = searchEl.selectionStart;
|
|
7990
|
+
const endPos = searchEl.selectionEnd;
|
|
7991
|
+
const orgText = searchEl.value;
|
|
7992
|
+
const pasteText = notFoundTokens.join(settings.delimiter);
|
|
7993
|
+
const newEndPos = startPos + pasteText.length;
|
|
8077
7994
|
$search.val(orgText.slice(0, startPos) + pasteText + orgText.slice(endPos));
|
|
8078
7995
|
searchEl.selectionStart = newEndPos;
|
|
8079
7996
|
searchEl.selectionEnd = newEndPos;
|
|
@@ -8101,7 +8018,7 @@
|
|
|
8101
8018
|
},
|
|
8102
8019
|
mousedown: function () {
|
|
8103
8020
|
if (module.is.searchSelection(true)) {
|
|
8104
|
-
// prevent menu hiding on immediate re-focus
|
|
8021
|
+
// prevent the menu hiding on immediate re-focus
|
|
8105
8022
|
willRefocus = true;
|
|
8106
8023
|
} else {
|
|
8107
8024
|
// prevents focus callback from occurring on mousedown
|
|
@@ -8110,16 +8027,14 @@
|
|
|
8110
8027
|
},
|
|
8111
8028
|
mouseup: function () {
|
|
8112
8029
|
if (module.is.searchSelection(true)) {
|
|
8113
|
-
// prevent menu hiding on immediate re-focus
|
|
8030
|
+
// prevent the menu hiding on immediate re-focus
|
|
8114
8031
|
willRefocus = false;
|
|
8115
8032
|
} else {
|
|
8116
8033
|
activated = false;
|
|
8117
8034
|
}
|
|
8118
8035
|
},
|
|
8119
8036
|
click: function (event) {
|
|
8120
|
-
|
|
8121
|
-
$target = $(event.target)
|
|
8122
|
-
;
|
|
8037
|
+
const $target = $(event.target);
|
|
8123
8038
|
// focus search
|
|
8124
8039
|
if ($target.is($module)) {
|
|
8125
8040
|
if (!module.is.focusedOnSearch()) {
|
|
@@ -8142,15 +8057,13 @@
|
|
|
8142
8057
|
},
|
|
8143
8058
|
blur: function (event) {
|
|
8144
8059
|
pageLostFocus = document.activeElement === this;
|
|
8145
|
-
if (module.is.searchSelection(true) && !willRefocus) {
|
|
8146
|
-
if (
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
module.remove.searchTerm();
|
|
8151
|
-
}
|
|
8152
|
-
module.hide();
|
|
8060
|
+
if (module.is.searchSelection(true) && !willRefocus && !itemActivated && !pageLostFocus) {
|
|
8061
|
+
if (settings.forceSelection) {
|
|
8062
|
+
module.forceSelection();
|
|
8063
|
+
} else if (!settings.allowAdditions && !settings.keepSearchTerm && !module.has.menuSearch()) {
|
|
8064
|
+
module.remove.searchTerm();
|
|
8153
8065
|
}
|
|
8066
|
+
module.hide();
|
|
8154
8067
|
}
|
|
8155
8068
|
willRefocus = false;
|
|
8156
8069
|
},
|
|
@@ -8203,16 +8116,14 @@
|
|
|
8203
8116
|
},
|
|
8204
8117
|
label: {
|
|
8205
8118
|
click: function (event) {
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
: $label.prevUntil($prevActive).add($activeLabels).add($label)
|
|
8215
|
-
;
|
|
8119
|
+
const $label = $(this);
|
|
8120
|
+
const $labels = $module.find(selector.label);
|
|
8121
|
+
const $activeLabels = $labels.filter('.' + className.active);
|
|
8122
|
+
const $nextActive = $label.nextAll('.' + className.active);
|
|
8123
|
+
const $prevActive = $label.prevAll('.' + className.active);
|
|
8124
|
+
const $range = $nextActive.length > 0
|
|
8125
|
+
? $label.nextUntil($nextActive).add($activeLabels).add($label)
|
|
8126
|
+
: $label.prevUntil($prevActive).add($activeLabels).add($label);
|
|
8216
8127
|
if (event.shiftKey) {
|
|
8217
8128
|
$activeLabels.removeClass(className.active);
|
|
8218
8129
|
$range.addClass(className.active);
|
|
@@ -8222,15 +8133,13 @@
|
|
|
8222
8133
|
$activeLabels.removeClass(className.active);
|
|
8223
8134
|
$label.addClass(className.active);
|
|
8224
8135
|
}
|
|
8225
|
-
settings.onLabelSelect.
|
|
8136
|
+
settings.onLabelSelect.call(this, $labels.filter('.' + className.active));
|
|
8226
8137
|
event.stopPropagation();
|
|
8227
8138
|
},
|
|
8228
8139
|
},
|
|
8229
8140
|
remove: {
|
|
8230
8141
|
click: function (event) {
|
|
8231
|
-
|
|
8232
|
-
$label = $(this).parent()
|
|
8233
|
-
;
|
|
8142
|
+
const $label = $(this).parent();
|
|
8234
8143
|
if ($label.hasClass(className.active)) {
|
|
8235
8144
|
// remove all selected labels
|
|
8236
8145
|
module.remove.activeLabels();
|
|
@@ -8243,11 +8152,9 @@
|
|
|
8243
8152
|
},
|
|
8244
8153
|
test: {
|
|
8245
8154
|
toggle: function (event) {
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
: module.toggle
|
|
8250
|
-
;
|
|
8155
|
+
const toggleBehavior = module.is.multiple()
|
|
8156
|
+
? module.show
|
|
8157
|
+
: module.toggle;
|
|
8251
8158
|
if (module.is.bubbledLabelClick(event) || module.is.bubbledIconClick(event)) {
|
|
8252
8159
|
return;
|
|
8253
8160
|
}
|
|
@@ -8261,20 +8168,18 @@
|
|
|
8261
8168
|
}
|
|
8262
8169
|
},
|
|
8263
8170
|
hide: function (event) {
|
|
8264
|
-
if (module.determine.eventInModule(event, module.hide)) {
|
|
8265
|
-
|
|
8266
|
-
event.preventDefault();
|
|
8267
|
-
}
|
|
8171
|
+
if (module.determine.eventInModule(event, module.hide) && element.id && $(event.target).attr('for') === element.id) {
|
|
8172
|
+
event.preventDefault();
|
|
8268
8173
|
}
|
|
8269
8174
|
},
|
|
8270
8175
|
},
|
|
8271
8176
|
class: {
|
|
8272
8177
|
mutation: function (mutations) {
|
|
8273
|
-
|
|
8178
|
+
for (const mutation of mutations) {
|
|
8274
8179
|
if (mutation.attributeName === 'class') {
|
|
8275
8180
|
module.check.disabled();
|
|
8276
8181
|
}
|
|
8277
|
-
}
|
|
8182
|
+
}
|
|
8278
8183
|
},
|
|
8279
8184
|
},
|
|
8280
8185
|
select: {
|
|
@@ -8291,18 +8196,10 @@
|
|
|
8291
8196
|
},
|
|
8292
8197
|
menu: {
|
|
8293
8198
|
mutation: function (mutations) {
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
: $(false),
|
|
8299
|
-
$removedNode = mutation.removedNodes
|
|
8300
|
-
? $(mutation.removedNodes[0])
|
|
8301
|
-
: $(false),
|
|
8302
|
-
$changedNodes = $addedNode.add($removedNode),
|
|
8303
|
-
isUserAddition = $changedNodes.is(selector.addition) || $changedNodes.closest(selector.addition).length > 0,
|
|
8304
|
-
isMessage = $changedNodes.is(selector.message) || $changedNodes.closest(selector.message).length > 0
|
|
8305
|
-
;
|
|
8199
|
+
const mutation = mutations[0];
|
|
8200
|
+
const $changedNodes = $([...mutation.addedNodes, ...mutation.removedNodes]);
|
|
8201
|
+
const isUserAddition = $changedNodes.is(selector.addition) || $changedNodes.closest(selector.addition).length > 0;
|
|
8202
|
+
const isMessage = $changedNodes.is(selector.message) || $changedNodes.closest(selector.message).length > 0;
|
|
8306
8203
|
if (isUserAddition || isMessage) {
|
|
8307
8204
|
module.debug('Updating item selector cache');
|
|
8308
8205
|
module.refreshItems();
|
|
@@ -8320,14 +8217,12 @@
|
|
|
8320
8217
|
},
|
|
8321
8218
|
item: {
|
|
8322
8219
|
mouseenter: function (event) {
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
isBubbledEvent = $subMenu.find($target).length > 0
|
|
8330
|
-
;
|
|
8220
|
+
const $target = $(event.target);
|
|
8221
|
+
const $item = $(this);
|
|
8222
|
+
const $subMenu = $item.children(selector.menu);
|
|
8223
|
+
const $otherMenus = $item.siblings(selector.item).children(selector.menu);
|
|
8224
|
+
const hasSubMenu = $subMenu.length > 0;
|
|
8225
|
+
const isBubbledEvent = $subMenu.find($target).length > 0;
|
|
8331
8226
|
if (!isBubbledEvent && hasSubMenu) {
|
|
8332
8227
|
clearTimeout(module.itemTimer);
|
|
8333
8228
|
module.itemTimer = setTimeout(function () {
|
|
@@ -8341,9 +8236,7 @@
|
|
|
8341
8236
|
}
|
|
8342
8237
|
},
|
|
8343
8238
|
mouseleave: function (event) {
|
|
8344
|
-
|
|
8345
|
-
$subMenu = $(this).find(selector.menu)
|
|
8346
|
-
;
|
|
8239
|
+
const $subMenu = $(this).find(selector.menu);
|
|
8347
8240
|
if ($subMenu.length > 0) {
|
|
8348
8241
|
clearTimeout(module.itemTimer);
|
|
8349
8242
|
module.itemTimer = setTimeout(function () {
|
|
@@ -8355,18 +8248,15 @@
|
|
|
8355
8248
|
}
|
|
8356
8249
|
},
|
|
8357
8250
|
click: function (event, skipRefocus) {
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
$target
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
isBubbledEvent = $subMenu.find($target).length > 0
|
|
8368
|
-
;
|
|
8369
|
-
// prevents IE11 bug where menu receives focus even though `tabindex=-1`
|
|
8251
|
+
const $choice = $(this);
|
|
8252
|
+
const $target = event
|
|
8253
|
+
? $(event.target || '')
|
|
8254
|
+
: $('');
|
|
8255
|
+
const $subMenu = $choice.find(selector.menu);
|
|
8256
|
+
const text = module.get.choiceText($choice);
|
|
8257
|
+
const value = module.get.choiceValue($choice, text);
|
|
8258
|
+
const hasSubMenu = $subMenu.length > 0;
|
|
8259
|
+
const isBubbledEvent = $subMenu.find($target).length > 0;
|
|
8370
8260
|
if (document.activeElement.tagName.toLowerCase() !== 'input') {
|
|
8371
8261
|
$(document.activeElement).trigger('blur');
|
|
8372
8262
|
}
|
|
@@ -8398,29 +8288,25 @@
|
|
|
8398
8288
|
},
|
|
8399
8289
|
|
|
8400
8290
|
document: {
|
|
8401
|
-
// label selection should occur even when element has no focus
|
|
8291
|
+
// label selection should occur even when the element has no focus
|
|
8402
8292
|
keydown: function (event) {
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
isShortcutKey = module.is.inObject(pressedKey, keys)
|
|
8406
|
-
;
|
|
8293
|
+
const pressedKey = event.which;
|
|
8294
|
+
const isShortcutKey = module.is.inObject(pressedKey, keys);
|
|
8407
8295
|
if (isShortcutKey) {
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
isSelectedSearch = caretAtStart && module.get.caretPosition(true) !== 0
|
|
8423
|
-
;
|
|
8296
|
+
const $label = $module.find(selector.label);
|
|
8297
|
+
let $activeLabel = $label.filter('.' + className.active);
|
|
8298
|
+
const activeValue = $activeLabel.data(metadata.value);
|
|
8299
|
+
const labelIndex = $label.index($activeLabel);
|
|
8300
|
+
const labelCount = $label.length;
|
|
8301
|
+
const hasActiveLabel = $activeLabel.length > 0;
|
|
8302
|
+
const hasMultipleActive = $activeLabel.length > 1;
|
|
8303
|
+
const isFirstLabel = labelIndex === 0;
|
|
8304
|
+
const isLastLabel = labelIndex + 1 === labelCount;
|
|
8305
|
+
const isSearch = module.is.searchSelection();
|
|
8306
|
+
const isFocusedOnSearch = module.is.focusedOnSearch();
|
|
8307
|
+
const isFocused = module.is.focused();
|
|
8308
|
+
const caretAtStart = isFocusedOnSearch && module.get.caretPosition(false) === 0;
|
|
8309
|
+
const isSelectedSearch = caretAtStart && module.get.caretPosition(true) !== 0;
|
|
8424
8310
|
if (isSearch && !hasActiveLabel && !isFocusedOnSearch) {
|
|
8425
8311
|
return;
|
|
8426
8312
|
}
|
|
@@ -8443,8 +8329,7 @@
|
|
|
8443
8329
|
} else {
|
|
8444
8330
|
$activeLabel.prev(selector.siblingLabel)
|
|
8445
8331
|
.addClass(className.active)
|
|
8446
|
-
.end()
|
|
8447
|
-
;
|
|
8332
|
+
.end();
|
|
8448
8333
|
}
|
|
8449
8334
|
event.preventDefault();
|
|
8450
8335
|
}
|
|
@@ -8488,10 +8373,8 @@
|
|
|
8488
8373
|
case keys.backspace: {
|
|
8489
8374
|
if (hasActiveLabel) {
|
|
8490
8375
|
module.verbose('Removing active labels');
|
|
8491
|
-
if (isLastLabel) {
|
|
8492
|
-
|
|
8493
|
-
module.focusSearch();
|
|
8494
|
-
}
|
|
8376
|
+
if (isLastLabel && isSearch && !isFocusedOnSearch) {
|
|
8377
|
+
module.focusSearch();
|
|
8495
8378
|
}
|
|
8496
8379
|
$activeLabel.last().next(selector.siblingLabel).addClass(className.active);
|
|
8497
8380
|
module.remove.activeLabels($activeLabel);
|
|
@@ -8519,32 +8402,28 @@
|
|
|
8519
8402
|
},
|
|
8520
8403
|
|
|
8521
8404
|
keydown: function (event) {
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
isShortcutKey = module.is.inObject(pressedKey, keys) || event.key === settings.delimiter
|
|
8525
|
-
;
|
|
8405
|
+
let pressedKey = event.which;
|
|
8406
|
+
const isShortcutKey = module.is.inObject(pressedKey, keys) || event.key === settings.delimiter;
|
|
8526
8407
|
if (isShortcutKey) {
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
;
|
|
8547
|
-
// allow selection with menu closed
|
|
8408
|
+
const $currentlySelected = $item.not(selector.unselectable).filter('.' + className.selected).eq(0);
|
|
8409
|
+
const $activeItem = $menu.children('.' + className.active).eq(0);
|
|
8410
|
+
const $selectedItem = $currentlySelected.length > 0
|
|
8411
|
+
? $currentlySelected
|
|
8412
|
+
: $activeItem;
|
|
8413
|
+
const $visibleItems = $selectedItem.length > 0
|
|
8414
|
+
? $selectedItem.siblings(':not(.' + className.filtered + ')').addBack()
|
|
8415
|
+
: $menu.children(':not(.' + className.filtered + ')');
|
|
8416
|
+
const $subMenu = $selectedItem.children(selector.menu);
|
|
8417
|
+
const $parentMenu = $selectedItem.closest(selector.menu);
|
|
8418
|
+
const inVisibleMenu = $parentMenu.hasClass(className.visible) || $parentMenu.hasClass(className.animating) || $parentMenu.parent(selector.menu).length > 0;
|
|
8419
|
+
const hasSubMenu = $subMenu.length > 0;
|
|
8420
|
+
const hasSelectedItem = $selectedItem.length > 0;
|
|
8421
|
+
const selectedIsSelectable = $selectedItem.not(selector.unselectable).length > 0;
|
|
8422
|
+
const delimiterPressed = event.key === settings.delimiter && module.is.multiple();
|
|
8423
|
+
const isAdditionWithoutMenu = settings.allowAdditions && (pressedKey === keys.enter || delimiterPressed);
|
|
8424
|
+
let $nextItem;
|
|
8425
|
+
let isSubMenuItem;
|
|
8426
|
+
// allow selection with the menu closed
|
|
8548
8427
|
if (isAdditionWithoutMenu) {
|
|
8549
8428
|
if (selectedIsSelectable && settings.hideAdditions) {
|
|
8550
8429
|
module.verbose('Selecting item from keyboard shortcut', $selectedItem);
|
|
@@ -8560,7 +8439,7 @@
|
|
|
8560
8439
|
|
|
8561
8440
|
// visible menu keyboard shortcuts
|
|
8562
8441
|
if (module.is.visible()) {
|
|
8563
|
-
// enter (select or open
|
|
8442
|
+
// enter (select or open submenu)
|
|
8564
8443
|
if (pressedKey === keys.enter || delimiterPressed) {
|
|
8565
8444
|
if (pressedKey === keys.enter && hasSelectedItem && hasSubMenu && !settings.allowCategorySelection) {
|
|
8566
8445
|
module.verbose('Pressed enter on unselectable category, opening sub menu');
|
|
@@ -8589,30 +8468,24 @@
|
|
|
8589
8468
|
module.verbose('Left key pressed, closing sub-menu');
|
|
8590
8469
|
module.animate.hide(false, $parentMenu);
|
|
8591
8470
|
$selectedItem
|
|
8592
|
-
.removeClass(className.selected)
|
|
8593
|
-
;
|
|
8471
|
+
.removeClass(className.selected);
|
|
8594
8472
|
$parentMenu
|
|
8595
8473
|
.closest(selector.item)
|
|
8596
|
-
.addClass(className.selected)
|
|
8597
|
-
;
|
|
8474
|
+
.addClass(className.selected);
|
|
8598
8475
|
event.preventDefault();
|
|
8599
8476
|
}
|
|
8600
8477
|
}
|
|
8601
8478
|
|
|
8602
|
-
// right arrow (show
|
|
8603
|
-
if (pressedKey === keys.rightArrow) {
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
.addClass(className.selected)
|
|
8613
|
-
;
|
|
8614
|
-
event.preventDefault();
|
|
8615
|
-
}
|
|
8479
|
+
// right arrow (show submenu)
|
|
8480
|
+
if (pressedKey === keys.rightArrow && hasSubMenu) {
|
|
8481
|
+
module.verbose('Right key pressed, opening sub-menu');
|
|
8482
|
+
module.animate.show(false, $subMenu);
|
|
8483
|
+
$selectedItem
|
|
8484
|
+
.removeClass(className.selected);
|
|
8485
|
+
$subMenu
|
|
8486
|
+
.find(selector.item).eq(0)
|
|
8487
|
+
.addClass(className.selected);
|
|
8488
|
+
event.preventDefault();
|
|
8616
8489
|
}
|
|
8617
8490
|
}
|
|
8618
8491
|
|
|
@@ -8630,11 +8503,9 @@
|
|
|
8630
8503
|
|
|
8631
8504
|
module.verbose('Up key pressed, changing active item');
|
|
8632
8505
|
$selectedItem
|
|
8633
|
-
.removeClass(className.selected)
|
|
8634
|
-
;
|
|
8506
|
+
.removeClass(className.selected);
|
|
8635
8507
|
$nextItem
|
|
8636
|
-
.addClass(className.selected)
|
|
8637
|
-
;
|
|
8508
|
+
.addClass(className.selected);
|
|
8638
8509
|
module.set.scrollPosition($nextItem);
|
|
8639
8510
|
if (settings.selectOnKeydown && module.is.single() && !$nextItem.hasClass(className.actionable)) {
|
|
8640
8511
|
module.set.selectedItem($nextItem);
|
|
@@ -8657,11 +8528,9 @@
|
|
|
8657
8528
|
|
|
8658
8529
|
module.verbose('Down key pressed, changing active item');
|
|
8659
8530
|
$item
|
|
8660
|
-
.removeClass(className.selected)
|
|
8661
|
-
;
|
|
8531
|
+
.removeClass(className.selected);
|
|
8662
8532
|
$nextItem
|
|
8663
|
-
.addClass(className.selected)
|
|
8664
|
-
;
|
|
8533
|
+
.addClass(className.selected);
|
|
8665
8534
|
module.set.scrollPosition($nextItem);
|
|
8666
8535
|
if (settings.selectOnKeydown && module.is.single() && !$nextItem.hasClass(className.actionable)) {
|
|
8667
8536
|
module.set.selectedItem($nextItem);
|
|
@@ -8693,29 +8562,25 @@
|
|
|
8693
8562
|
}
|
|
8694
8563
|
// down arrow (open menu)
|
|
8695
8564
|
if (pressedKey === keys.downArrow && !module.is.visible()) {
|
|
8565
|
+
focused = true;
|
|
8696
8566
|
module.verbose('Down key pressed, showing dropdown');
|
|
8697
8567
|
module.show();
|
|
8698
8568
|
event.preventDefault();
|
|
8699
8569
|
}
|
|
8700
8570
|
}
|
|
8701
|
-
} else {
|
|
8702
|
-
|
|
8703
|
-
module.set.selectedLetter(String.fromCharCode(pressedKey));
|
|
8704
|
-
}
|
|
8571
|
+
} else if (!module.has.search()) {
|
|
8572
|
+
module.set.selectedLetter(String.fromCodePoint(pressedKey));
|
|
8705
8573
|
}
|
|
8706
8574
|
},
|
|
8707
8575
|
},
|
|
8708
8576
|
|
|
8709
8577
|
trigger: {
|
|
8710
8578
|
change: function () {
|
|
8711
|
-
|
|
8712
|
-
inputElement = $input[0]
|
|
8713
|
-
;
|
|
8579
|
+
const inputElement = $input[0];
|
|
8714
8580
|
if (inputElement) {
|
|
8715
|
-
|
|
8581
|
+
const event = new Event('change', { bubbles: true });
|
|
8716
8582
|
module.verbose('Triggering native change event');
|
|
8717
|
-
|
|
8718
|
-
inputElement.dispatchEvent(events);
|
|
8583
|
+
inputElement.dispatchEvent(event);
|
|
8719
8584
|
}
|
|
8720
8585
|
},
|
|
8721
8586
|
},
|
|
@@ -8736,11 +8601,9 @@
|
|
|
8736
8601
|
selectActionActive = false;
|
|
8737
8602
|
},
|
|
8738
8603
|
eventInModule: function (event, callback) {
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
inModule = $target.closest($module).length > 0
|
|
8743
|
-
;
|
|
8604
|
+
const $target = $(event.target);
|
|
8605
|
+
const inDocument = $target.closest(document.documentElement).length > 0;
|
|
8606
|
+
const inModule = $target.closest($module).length > 0;
|
|
8744
8607
|
callback = isFunction(callback)
|
|
8745
8608
|
? callback
|
|
8746
8609
|
: function () {};
|
|
@@ -8756,13 +8619,11 @@
|
|
|
8756
8619
|
return false;
|
|
8757
8620
|
},
|
|
8758
8621
|
eventOnElement: function (event, callback) {
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
notInMenu = $target.closest($menu).length === 0
|
|
8765
|
-
;
|
|
8622
|
+
const $target = $(event.target);
|
|
8623
|
+
const $label = $target.closest(selector.siblingLabel);
|
|
8624
|
+
const inVisibleDOM = document.body.contains(event.target);
|
|
8625
|
+
const notOnLabel = $module.find($label).length === 0 || !(module.is.multiple() && settings.useLabels);
|
|
8626
|
+
const notInMenu = $target.closest($menu).length === 0;
|
|
8766
8627
|
callback = isFunction(callback)
|
|
8767
8628
|
? callback
|
|
8768
8629
|
: function () {};
|
|
@@ -8783,10 +8644,7 @@
|
|
|
8783
8644
|
|
|
8784
8645
|
nothing: function () {},
|
|
8785
8646
|
|
|
8786
|
-
activate: function (text, value, element) {
|
|
8787
|
-
value = value !== undefined
|
|
8788
|
-
? value
|
|
8789
|
-
: text;
|
|
8647
|
+
activate: function (text, value = text, element = '') {
|
|
8790
8648
|
if (module.can.activate($(element))) {
|
|
8791
8649
|
module.set.selected(value, $(element), false, settings.keepSearchTerm);
|
|
8792
8650
|
if (!module.is.multiple() && !(!settings.collapseOnActionable && $(element).hasClass(className.actionable))) {
|
|
@@ -8795,10 +8653,7 @@
|
|
|
8795
8653
|
}
|
|
8796
8654
|
},
|
|
8797
8655
|
|
|
8798
|
-
select: function (text, value, element) {
|
|
8799
|
-
value = value !== undefined
|
|
8800
|
-
? value
|
|
8801
|
-
: text;
|
|
8656
|
+
select: function (text, value = text, element = '') {
|
|
8802
8657
|
if (module.can.activate($(element))) {
|
|
8803
8658
|
module.set.value(value, text, $(element));
|
|
8804
8659
|
if (!module.is.multiple() && !(!settings.collapseOnActionable && $(element).hasClass(className.actionable))) {
|
|
@@ -8807,10 +8662,7 @@
|
|
|
8807
8662
|
}
|
|
8808
8663
|
},
|
|
8809
8664
|
|
|
8810
|
-
combo: function (text, value, element) {
|
|
8811
|
-
value = value !== undefined
|
|
8812
|
-
? value
|
|
8813
|
-
: text;
|
|
8665
|
+
combo: function (text, value = text, element = '') {
|
|
8814
8666
|
module.set.selected(value, $(element));
|
|
8815
8667
|
module.hideAndClear();
|
|
8816
8668
|
},
|
|
@@ -8840,30 +8692,25 @@
|
|
|
8840
8692
|
return $module.data(metadata.placeholderText) || '';
|
|
8841
8693
|
},
|
|
8842
8694
|
text: function () {
|
|
8843
|
-
return settings.preserveHTML
|
|
8695
|
+
return settings.preserveHTML
|
|
8696
|
+
? $text.html()
|
|
8697
|
+
: $text.text();
|
|
8844
8698
|
},
|
|
8845
8699
|
query: function () {
|
|
8846
8700
|
return String($search.val()).trim();
|
|
8847
8701
|
},
|
|
8848
|
-
searchWidth: function (value) {
|
|
8849
|
-
value = value !== undefined
|
|
8850
|
-
? value
|
|
8851
|
-
: $search.val();
|
|
8702
|
+
searchWidth: function (value = $search.val()) {
|
|
8852
8703
|
$sizer.text(value);
|
|
8853
8704
|
|
|
8854
8705
|
// prevent rounding issues
|
|
8855
|
-
return Math.ceil($sizer.width() +
|
|
8706
|
+
return Math.ceil($sizer.width() + 1);
|
|
8856
8707
|
},
|
|
8857
8708
|
selectionCount: function () {
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
;
|
|
8862
|
-
count = module.is.multiple()
|
|
8709
|
+
const values = module.get.values();
|
|
8710
|
+
|
|
8711
|
+
return module.is.multiple()
|
|
8863
8712
|
? (Array.isArray(values) ? values.length : 0)
|
|
8864
8713
|
: (module.get.value() !== '' ? 1 : 0);
|
|
8865
|
-
|
|
8866
|
-
return count;
|
|
8867
8714
|
},
|
|
8868
8715
|
transition: function ($subMenu) {
|
|
8869
8716
|
return settings.transition === 'auto'
|
|
@@ -8871,9 +8718,7 @@
|
|
|
8871
8718
|
: settings.transition;
|
|
8872
8719
|
},
|
|
8873
8720
|
userValues: function () {
|
|
8874
|
-
|
|
8875
|
-
values = module.get.values(true)
|
|
8876
|
-
;
|
|
8721
|
+
let values = module.get.values();
|
|
8877
8722
|
if (!values) {
|
|
8878
8723
|
return false;
|
|
8879
8724
|
}
|
|
@@ -8886,16 +8731,12 @@
|
|
|
8886
8731
|
});
|
|
8887
8732
|
},
|
|
8888
8733
|
uniqueArray: function (array) {
|
|
8889
|
-
return
|
|
8890
|
-
return $.inArray(value, array) === index;
|
|
8891
|
-
});
|
|
8734
|
+
return [...new Set(array)];
|
|
8892
8735
|
},
|
|
8893
8736
|
caretPosition: function (returnEndPos) {
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
rangeLength
|
|
8898
|
-
;
|
|
8737
|
+
const input = $search[0];
|
|
8738
|
+
let range;
|
|
8739
|
+
let rangeLength;
|
|
8899
8740
|
if (returnEndPos && 'selectionEnd' in input) {
|
|
8900
8741
|
return input.selectionEnd;
|
|
8901
8742
|
}
|
|
@@ -8915,47 +8756,37 @@
|
|
|
8915
8756
|
}
|
|
8916
8757
|
},
|
|
8917
8758
|
value: function () {
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
isEmptyMultiselect = Array.isArray(value) && value.length === 1 && value[0] === ''
|
|
8923
|
-
;
|
|
8759
|
+
const value = $input.length > 0
|
|
8760
|
+
? $input.val()
|
|
8761
|
+
: $module.data(metadata.value);
|
|
8762
|
+
const isEmptyMultiselect = Array.isArray(value) && value.length === 1 && value[0] === '';
|
|
8924
8763
|
|
|
8925
|
-
// prevents placeholder element from being selected when multiple
|
|
8764
|
+
// prevents the placeholder element from being selected when multiple
|
|
8926
8765
|
return value === undefined || isEmptyMultiselect
|
|
8927
8766
|
? ''
|
|
8928
8767
|
: value;
|
|
8929
8768
|
},
|
|
8930
|
-
values: function (
|
|
8931
|
-
|
|
8932
|
-
value = module.get.value()
|
|
8933
|
-
;
|
|
8769
|
+
values: function () {
|
|
8770
|
+
const value = module.get.value();
|
|
8934
8771
|
if (value === '') {
|
|
8935
8772
|
return '';
|
|
8936
8773
|
}
|
|
8937
8774
|
|
|
8938
8775
|
return !module.has.selectInput() && module.is.multiple()
|
|
8939
8776
|
? (typeof value === 'string' // delimited string
|
|
8940
|
-
? (
|
|
8941
|
-
? value
|
|
8942
|
-
: module.escape.htmlEntities(value)).split(settings.delimiter)
|
|
8777
|
+
? value.split(settings.delimiter)
|
|
8943
8778
|
: '')
|
|
8944
8779
|
: value;
|
|
8945
8780
|
},
|
|
8946
8781
|
remoteValues: function () {
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
remoteValues = false
|
|
8950
|
-
;
|
|
8782
|
+
let values = module.get.values();
|
|
8783
|
+
let remoteValues = false;
|
|
8951
8784
|
if (values) {
|
|
8952
8785
|
if (typeof values === 'string') {
|
|
8953
8786
|
values = [values];
|
|
8954
8787
|
}
|
|
8955
8788
|
$.each(values, function (index, value) {
|
|
8956
|
-
|
|
8957
|
-
name = module.read.remoteData(value)
|
|
8958
|
-
;
|
|
8789
|
+
const name = module.read.remoteData(value);
|
|
8959
8790
|
module.verbose('Restoring value from session data', name, value);
|
|
8960
8791
|
if (name) {
|
|
8961
8792
|
if (!remoteValues) {
|
|
@@ -8968,10 +8799,7 @@
|
|
|
8968
8799
|
|
|
8969
8800
|
return remoteValues;
|
|
8970
8801
|
},
|
|
8971
|
-
choiceText: function ($choice, preserveHTML) {
|
|
8972
|
-
preserveHTML = preserveHTML !== undefined
|
|
8973
|
-
? preserveHTML
|
|
8974
|
-
: settings.preserveHTML;
|
|
8802
|
+
choiceText: function ($choice, preserveHTML = settings.preserveHTML) {
|
|
8975
8803
|
if ($choice) {
|
|
8976
8804
|
if ($choice.find(selector.menu).length > 0) {
|
|
8977
8805
|
module.verbose('Retrieving text of element with sub-menu');
|
|
@@ -8987,8 +8815,7 @@
|
|
|
8987
8815
|
: $choice.text() && $choice.text().trim());
|
|
8988
8816
|
}
|
|
8989
8817
|
},
|
|
8990
|
-
choiceValue: function ($choice, choiceText) {
|
|
8991
|
-
choiceText = choiceText || module.get.choiceText($choice);
|
|
8818
|
+
choiceValue: function ($choice, choiceText = module.get.choiceText($choice)) {
|
|
8992
8819
|
if (!$choice) {
|
|
8993
8820
|
return false;
|
|
8994
8821
|
}
|
|
@@ -9004,9 +8831,7 @@
|
|
|
9004
8831
|
: String(choiceText));
|
|
9005
8832
|
},
|
|
9006
8833
|
inputEvent: function () {
|
|
9007
|
-
|
|
9008
|
-
input = $search[0]
|
|
9009
|
-
;
|
|
8834
|
+
const input = $search[0];
|
|
9010
8835
|
if (input) {
|
|
9011
8836
|
return input.oninput !== undefined
|
|
9012
8837
|
? 'input'
|
|
@@ -9018,26 +8843,22 @@
|
|
|
9018
8843
|
return false;
|
|
9019
8844
|
},
|
|
9020
8845
|
selectValues: function () {
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
values = []
|
|
9025
|
-
;
|
|
8846
|
+
const select = {};
|
|
8847
|
+
let oldGroup = [];
|
|
8848
|
+
const values = [];
|
|
9026
8849
|
$module
|
|
9027
8850
|
.find('option')
|
|
9028
8851
|
.each(function () {
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
group = $option.parent('optgroup')
|
|
9040
|
-
;
|
|
8852
|
+
const $option = $(this);
|
|
8853
|
+
const name = module.escape.assumeUnescapedAmpLtGt($option.html());
|
|
8854
|
+
const disabled = $option.attr('disabled');
|
|
8855
|
+
const value = $option.attr('value') !== undefined
|
|
8856
|
+
? $option.attr('value')
|
|
8857
|
+
: name;
|
|
8858
|
+
const text = $option.data(metadata.text) !== undefined
|
|
8859
|
+
? $option.data(metadata.text)
|
|
8860
|
+
: name;
|
|
8861
|
+
const group = $option.parent('optgroup');
|
|
9041
8862
|
if (settings.placeholder === 'auto' && value === '') {
|
|
9042
8863
|
select.placeholder = name;
|
|
9043
8864
|
} else {
|
|
@@ -9052,12 +8873,11 @@
|
|
|
9052
8873
|
values.push({
|
|
9053
8874
|
name: name,
|
|
9054
8875
|
value: value,
|
|
9055
|
-
text:
|
|
8876
|
+
text: text,
|
|
9056
8877
|
disabled: disabled,
|
|
9057
8878
|
});
|
|
9058
8879
|
}
|
|
9059
|
-
})
|
|
9060
|
-
;
|
|
8880
|
+
});
|
|
9061
8881
|
if (settings.placeholder && settings.placeholder !== 'auto') {
|
|
9062
8882
|
module.debug('Setting placeholder value to', settings.placeholder);
|
|
9063
8883
|
select.placeholder = settings.placeholder;
|
|
@@ -9087,20 +8907,16 @@
|
|
|
9087
8907
|
return $item.filter('.' + className.active);
|
|
9088
8908
|
},
|
|
9089
8909
|
selectedItem: function () {
|
|
9090
|
-
|
|
9091
|
-
$selectedItem = $item.not(selector.unselectable).filter('.' + className.selected)
|
|
9092
|
-
;
|
|
8910
|
+
const $selectedItem = $item.not(selector.unselectable).filter('.' + className.selected);
|
|
9093
8911
|
|
|
9094
8912
|
return $selectedItem.length > 0
|
|
9095
8913
|
? $selectedItem
|
|
9096
8914
|
: $item.eq(0);
|
|
9097
8915
|
},
|
|
9098
8916
|
itemWithAdditions: function (value) {
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
hasUserItems = $userItems && $userItems.length > 0
|
|
9103
|
-
;
|
|
8917
|
+
let $items = module.get.item(value);
|
|
8918
|
+
const $userItems = module.create.userChoice(value);
|
|
8919
|
+
const hasUserItems = $userItems && $userItems.length > 0;
|
|
9104
8920
|
if (hasUserItems) {
|
|
9105
8921
|
$items = $items.length > 0
|
|
9106
8922
|
? $items.add($userItems)
|
|
@@ -9110,18 +8926,14 @@
|
|
|
9110
8926
|
return $items;
|
|
9111
8927
|
},
|
|
9112
8928
|
item: function (value, strict) {
|
|
9113
|
-
|
|
9114
|
-
$selectedItem = false,
|
|
9115
|
-
shouldSearch,
|
|
9116
|
-
isMultiple
|
|
9117
|
-
;
|
|
8929
|
+
let $selectedItem = false;
|
|
9118
8930
|
value = value !== undefined
|
|
9119
8931
|
? value
|
|
9120
8932
|
: (module.get.values() !== undefined
|
|
9121
8933
|
? module.get.values()
|
|
9122
8934
|
: module.get.text());
|
|
9123
|
-
isMultiple = module.is.multiple() && Array.isArray(value);
|
|
9124
|
-
shouldSearch = isMultiple
|
|
8935
|
+
const isMultiple = module.is.multiple() && Array.isArray(value);
|
|
8936
|
+
const shouldSearch = isMultiple
|
|
9125
8937
|
? value.length > 0
|
|
9126
8938
|
: value !== undefined && value !== null;
|
|
9127
8939
|
strict = value === '' || value === false || value === true
|
|
@@ -9130,17 +8942,15 @@
|
|
|
9130
8942
|
if (shouldSearch) {
|
|
9131
8943
|
$item
|
|
9132
8944
|
.each(function () {
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
optionValue = module.get.choiceValue($choice, optionText)
|
|
9137
|
-
;
|
|
8945
|
+
const $choice = $(this);
|
|
8946
|
+
const optionText = module.get.choiceText($choice);
|
|
8947
|
+
let optionValue = module.get.choiceValue($choice, optionText);
|
|
9138
8948
|
// safe early exit
|
|
9139
8949
|
if (optionValue === null || optionValue === undefined) {
|
|
9140
8950
|
return;
|
|
9141
8951
|
}
|
|
9142
8952
|
if (isMultiple) {
|
|
9143
|
-
if (
|
|
8953
|
+
if (value.map(String).includes(String(optionValue))) {
|
|
9144
8954
|
$selectedItem = $selectedItem
|
|
9145
8955
|
? $selectedItem.add($choice)
|
|
9146
8956
|
: $choice;
|
|
@@ -9157,15 +8967,14 @@
|
|
|
9157
8967
|
optionValue = optionValue.toLowerCase();
|
|
9158
8968
|
value = value.toLowerCase();
|
|
9159
8969
|
}
|
|
9160
|
-
if (
|
|
8970
|
+
if (String(optionValue) === String(value)) {
|
|
9161
8971
|
module.verbose('Found select item by value', optionValue, value);
|
|
9162
8972
|
$selectedItem = $choice;
|
|
9163
8973
|
|
|
9164
8974
|
return true;
|
|
9165
8975
|
}
|
|
9166
8976
|
}
|
|
9167
|
-
})
|
|
9168
|
-
;
|
|
8977
|
+
});
|
|
9169
8978
|
}
|
|
9170
8979
|
|
|
9171
8980
|
return $selectedItem;
|
|
@@ -9176,11 +8985,8 @@
|
|
|
9176
8985
|
},
|
|
9177
8986
|
|
|
9178
8987
|
check: {
|
|
9179
|
-
maxSelections: function (selectionCount) {
|
|
8988
|
+
maxSelections: function (selectionCount = module.get.selectionCount()) {
|
|
9180
8989
|
if (settings.maxSelections) {
|
|
9181
|
-
selectionCount = selectionCount !== undefined
|
|
9182
|
-
? selectionCount
|
|
9183
|
-
: module.get.selectionCount();
|
|
9184
8990
|
if (selectionCount >= settings.maxSelections) {
|
|
9185
8991
|
module.debug('Maximum selection count reached');
|
|
9186
8992
|
if (settings.useLabels) {
|
|
@@ -9215,10 +9021,8 @@
|
|
|
9215
9021
|
module.restore.defaultValue();
|
|
9216
9022
|
},
|
|
9217
9023
|
defaultText: function () {
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
placeholderText = module.get.placeholderText
|
|
9221
|
-
;
|
|
9024
|
+
const defaultText = module.get.defaultText();
|
|
9025
|
+
const placeholderText = module.get.placeholderText;
|
|
9222
9026
|
if (defaultText === placeholderText) {
|
|
9223
9027
|
module.debug('Restoring default placeholder text', defaultText);
|
|
9224
9028
|
module.set.placeholderText(defaultText);
|
|
@@ -9231,9 +9035,7 @@
|
|
|
9231
9035
|
module.set.placeholderText();
|
|
9232
9036
|
},
|
|
9233
9037
|
defaultValue: function () {
|
|
9234
|
-
|
|
9235
|
-
defaultValue = module.get.defaultValue()
|
|
9236
|
-
;
|
|
9038
|
+
const defaultValue = module.get.defaultValue();
|
|
9237
9039
|
if (defaultValue !== undefined) {
|
|
9238
9040
|
module.debug('Restoring default value', defaultValue);
|
|
9239
9041
|
if (defaultValue !== '') {
|
|
@@ -9266,14 +9068,14 @@
|
|
|
9266
9068
|
}
|
|
9267
9069
|
},
|
|
9268
9070
|
values: function () {
|
|
9269
|
-
// prevents callbacks from occurring on initial load
|
|
9071
|
+
// prevents callbacks from occurring on the initial load
|
|
9270
9072
|
module.set.initialLoad();
|
|
9271
9073
|
if (settings.apiSettings && settings.saveRemoteData && module.get.remoteValues()) {
|
|
9272
9074
|
module.restore.remoteValues();
|
|
9273
9075
|
} else {
|
|
9274
9076
|
module.set.selected();
|
|
9275
9077
|
}
|
|
9276
|
-
|
|
9078
|
+
const value = module.get.value();
|
|
9277
9079
|
if (value && value !== '' && !(Array.isArray(value) && value.length === 0)) {
|
|
9278
9080
|
$input.removeClass(className.noselection);
|
|
9279
9081
|
} else {
|
|
@@ -9282,9 +9084,7 @@
|
|
|
9282
9084
|
module.remove.initialLoad();
|
|
9283
9085
|
},
|
|
9284
9086
|
remoteValues: function () {
|
|
9285
|
-
|
|
9286
|
-
values = module.get.remoteValues()
|
|
9287
|
-
;
|
|
9087
|
+
const values = module.get.remoteValues();
|
|
9288
9088
|
module.debug('Recreating selected from session data', values);
|
|
9289
9089
|
if (values) {
|
|
9290
9090
|
if (module.is.single()) {
|
|
@@ -9302,15 +9102,7 @@
|
|
|
9302
9102
|
|
|
9303
9103
|
read: {
|
|
9304
9104
|
remoteData: function (value) {
|
|
9305
|
-
|
|
9306
|
-
name
|
|
9307
|
-
;
|
|
9308
|
-
if (window.Storage === undefined) {
|
|
9309
|
-
module.error(error.noStorage);
|
|
9310
|
-
|
|
9311
|
-
return;
|
|
9312
|
-
}
|
|
9313
|
-
name = sessionStorage.getItem(value + elementNamespace);
|
|
9105
|
+
const name = window.sessionStorage.getItem(value + elementNamespace);
|
|
9314
9106
|
|
|
9315
9107
|
return name !== undefined
|
|
9316
9108
|
? name
|
|
@@ -9325,23 +9117,17 @@
|
|
|
9325
9117
|
module.save.defaultValue();
|
|
9326
9118
|
},
|
|
9327
9119
|
defaultValue: function () {
|
|
9328
|
-
|
|
9329
|
-
value = module.get.value()
|
|
9330
|
-
;
|
|
9120
|
+
const value = module.get.value();
|
|
9331
9121
|
module.verbose('Saving default value as', value);
|
|
9332
9122
|
$module.data(metadata.defaultValue, value);
|
|
9333
9123
|
},
|
|
9334
9124
|
defaultText: function () {
|
|
9335
|
-
|
|
9336
|
-
text = module.get.text()
|
|
9337
|
-
;
|
|
9125
|
+
const text = module.get.text();
|
|
9338
9126
|
module.verbose('Saving default text as', text);
|
|
9339
9127
|
$module.data(metadata.defaultText, text);
|
|
9340
9128
|
},
|
|
9341
9129
|
placeholderText: function () {
|
|
9342
|
-
|
|
9343
|
-
text
|
|
9344
|
-
;
|
|
9130
|
+
let text;
|
|
9345
9131
|
if (settings.placeholder !== false && $text.hasClass(className.placeholder)) {
|
|
9346
9132
|
text = module.get.text();
|
|
9347
9133
|
module.verbose('Saving placeholder text as', text);
|
|
@@ -9349,13 +9135,8 @@
|
|
|
9349
9135
|
}
|
|
9350
9136
|
},
|
|
9351
9137
|
remoteData: function (name, value) {
|
|
9352
|
-
if (window.Storage === undefined) {
|
|
9353
|
-
module.error(error.noStorage);
|
|
9354
|
-
|
|
9355
|
-
return;
|
|
9356
|
-
}
|
|
9357
9138
|
module.verbose('Saving remote data to session storage', value, name);
|
|
9358
|
-
sessionStorage.setItem(value + elementNamespace, name);
|
|
9139
|
+
window.sessionStorage.setItem(value + elementNamespace, name);
|
|
9359
9140
|
},
|
|
9360
9141
|
},
|
|
9361
9142
|
|
|
@@ -9381,28 +9162,23 @@
|
|
|
9381
9162
|
},
|
|
9382
9163
|
|
|
9383
9164
|
scrollPage: function (direction, $selectedItem) {
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
isWithinRange,
|
|
9396
|
-
$nextSelectedItem,
|
|
9397
|
-
elementIndex
|
|
9398
|
-
;
|
|
9399
|
-
elementIndex = direction === 'up'
|
|
9165
|
+
const $currentItem = $selectedItem || module.get.selectedItem();
|
|
9166
|
+
const $menu = $currentItem.closest(selector.menu);
|
|
9167
|
+
const menuHeight = $menu.outerHeight();
|
|
9168
|
+
const currentScroll = $menu.scrollTop();
|
|
9169
|
+
const itemHeight = $item.eq(0).outerHeight();
|
|
9170
|
+
const itemsPerPage = Math.floor(menuHeight / itemHeight);
|
|
9171
|
+
const newScroll = direction === 'up'
|
|
9172
|
+
? currentScroll - (itemHeight * itemsPerPage)
|
|
9173
|
+
: currentScroll + (itemHeight * itemsPerPage);
|
|
9174
|
+
const $selectableItem = $item.not(selector.unselectable);
|
|
9175
|
+
const elementIndex = direction === 'up'
|
|
9400
9176
|
? $selectableItem.index($currentItem) - itemsPerPage
|
|
9401
9177
|
: $selectableItem.index($currentItem) + itemsPerPage;
|
|
9402
|
-
isWithinRange = direction === 'up'
|
|
9178
|
+
const isWithinRange = direction === 'up'
|
|
9403
9179
|
? elementIndex >= 0
|
|
9404
9180
|
: elementIndex < $selectableItem.length;
|
|
9405
|
-
$nextSelectedItem = isWithinRange
|
|
9181
|
+
const $nextSelectedItem = isWithinRange
|
|
9406
9182
|
? $selectableItem.eq(elementIndex)
|
|
9407
9183
|
: (direction === 'up'
|
|
9408
9184
|
? $selectableItem.first()
|
|
@@ -9410,33 +9186,28 @@
|
|
|
9410
9186
|
if ($nextSelectedItem.length > 0) {
|
|
9411
9187
|
module.debug('Scrolling page', direction, $nextSelectedItem);
|
|
9412
9188
|
$currentItem
|
|
9413
|
-
.removeClass(className.selected)
|
|
9414
|
-
;
|
|
9189
|
+
.removeClass(className.selected);
|
|
9415
9190
|
$nextSelectedItem
|
|
9416
|
-
.addClass(className.selected)
|
|
9417
|
-
;
|
|
9191
|
+
.addClass(className.selected);
|
|
9418
9192
|
if (settings.selectOnKeydown && module.is.single() && !$nextSelectedItem.hasClass(className.actionable)) {
|
|
9419
9193
|
module.set.selectedItem($nextSelectedItem);
|
|
9420
9194
|
}
|
|
9421
9195
|
$menu
|
|
9422
|
-
.scrollTop(newScroll)
|
|
9423
|
-
;
|
|
9196
|
+
.scrollTop(newScroll);
|
|
9424
9197
|
}
|
|
9425
9198
|
},
|
|
9426
9199
|
|
|
9427
9200
|
set: {
|
|
9428
9201
|
filtered: function () {
|
|
9429
|
-
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
valueIsSet = searchValue !== ''
|
|
9439
|
-
;
|
|
9202
|
+
const isMultiple = module.is.multiple();
|
|
9203
|
+
const isSearch = module.is.searchSelection();
|
|
9204
|
+
const isSearchMultiple = isMultiple && isSearch;
|
|
9205
|
+
const searchValue = isSearch
|
|
9206
|
+
? module.get.query()
|
|
9207
|
+
: '';
|
|
9208
|
+
const hasSearchValue = typeof searchValue === 'string' && searchValue.length > 0;
|
|
9209
|
+
const searchWidth = module.get.searchWidth();
|
|
9210
|
+
const valueIsSet = searchValue !== '';
|
|
9440
9211
|
if (isMultiple && hasSearchValue) {
|
|
9441
9212
|
module.verbose('Adjusting input width', searchWidth);
|
|
9442
9213
|
$search.css('width', searchWidth + 'px');
|
|
@@ -9455,8 +9226,7 @@
|
|
|
9455
9226
|
loading: function () {
|
|
9456
9227
|
$module.addClass(className.loading);
|
|
9457
9228
|
},
|
|
9458
|
-
placeholderText: function (text) {
|
|
9459
|
-
text = text || module.get.placeholderText();
|
|
9229
|
+
placeholderText: function (text = module.get.placeholderText()) {
|
|
9460
9230
|
module.debug('Setting placeholder text', text);
|
|
9461
9231
|
module.set.text(text);
|
|
9462
9232
|
$text.addClass(className.placeholder);
|
|
@@ -9465,21 +9235,17 @@
|
|
|
9465
9235
|
if (module.is.searchSelection()) {
|
|
9466
9236
|
module.debug('Added tabindex to searchable dropdown');
|
|
9467
9237
|
$search
|
|
9468
|
-
.val('')
|
|
9469
|
-
;
|
|
9238
|
+
.val('');
|
|
9470
9239
|
module.check.disabled();
|
|
9471
9240
|
$menu
|
|
9472
|
-
.attr('tabindex', -1)
|
|
9473
|
-
;
|
|
9241
|
+
.attr('tabindex', -1);
|
|
9474
9242
|
} else {
|
|
9475
9243
|
module.debug('Added tabindex to dropdown');
|
|
9476
9244
|
if ($module.attr('tabindex') === undefined) {
|
|
9477
9245
|
$module
|
|
9478
|
-
.attr('tabindex', $input.attr('tabindex') || 0)
|
|
9479
|
-
;
|
|
9246
|
+
.attr('tabindex', $input.attr('tabindex') || 0);
|
|
9480
9247
|
$menu
|
|
9481
|
-
.attr('tabindex', -1)
|
|
9482
|
-
;
|
|
9248
|
+
.attr('tabindex', -1);
|
|
9483
9249
|
}
|
|
9484
9250
|
}
|
|
9485
9251
|
$input.removeAttr('tabindex');
|
|
@@ -9496,31 +9262,22 @@
|
|
|
9496
9262
|
}
|
|
9497
9263
|
},
|
|
9498
9264
|
partialSearch: function (text) {
|
|
9499
|
-
|
|
9500
|
-
length = module.get.query().length
|
|
9501
|
-
;
|
|
9265
|
+
const length = module.get.query().length;
|
|
9502
9266
|
$search.val(text.slice(0, length));
|
|
9503
9267
|
},
|
|
9504
|
-
scrollPosition: function ($item, forceScroll) {
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
menuHeight,
|
|
9514
|
-
abovePage,
|
|
9515
|
-
belowPage
|
|
9516
|
-
;
|
|
9268
|
+
scrollPosition: function ($item, forceScroll = false) {
|
|
9269
|
+
const edgeTolerance = 5;
|
|
9270
|
+
let offset;
|
|
9271
|
+
let itemOffset;
|
|
9272
|
+
let menuOffset;
|
|
9273
|
+
let menuScroll;
|
|
9274
|
+
let menuHeight;
|
|
9275
|
+
let abovePage;
|
|
9276
|
+
let belowPage;
|
|
9517
9277
|
|
|
9518
9278
|
$item = $item || module.get.selectedItem();
|
|
9519
|
-
$menu = $item.closest(selector.menu);
|
|
9520
|
-
hasActive = $item && $item.length > 0;
|
|
9521
|
-
forceScroll = forceScroll !== undefined
|
|
9522
|
-
? forceScroll
|
|
9523
|
-
: false;
|
|
9279
|
+
const $menu = $item.closest(selector.menu);
|
|
9280
|
+
const hasActive = $item && $item.length > 0;
|
|
9524
9281
|
if (module.get.activeItem().length === 0) {
|
|
9525
9282
|
forceScroll = false;
|
|
9526
9283
|
}
|
|
@@ -9558,8 +9315,7 @@
|
|
|
9558
9315
|
}
|
|
9559
9316
|
module.debug('Changing text', text, $text);
|
|
9560
9317
|
$text
|
|
9561
|
-
.removeClass(className.filtered)
|
|
9562
|
-
;
|
|
9318
|
+
.removeClass(className.filtered);
|
|
9563
9319
|
if (settings.preserveHTML) {
|
|
9564
9320
|
$text.html(text);
|
|
9565
9321
|
} else {
|
|
@@ -9568,11 +9324,9 @@
|
|
|
9568
9324
|
}
|
|
9569
9325
|
},
|
|
9570
9326
|
selectedItem: function ($item) {
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
text = module.get.choiceText($item)
|
|
9575
|
-
;
|
|
9327
|
+
const value = module.get.choiceValue($item);
|
|
9328
|
+
const searchText = module.get.choiceText($item, false);
|
|
9329
|
+
const text = module.get.choiceText($item);
|
|
9576
9330
|
module.debug('Setting user selection to item', $item);
|
|
9577
9331
|
module.remove.activeItem();
|
|
9578
9332
|
module.set.partialSearch(searchText);
|
|
@@ -9581,13 +9335,11 @@
|
|
|
9581
9335
|
module.set.text(text);
|
|
9582
9336
|
},
|
|
9583
9337
|
selectedLetter: function (letter) {
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
;
|
|
9590
|
-
// check next of same letter
|
|
9338
|
+
const $selectedItem = $item.filter('.' + className.selected);
|
|
9339
|
+
const alreadySelectedLetter = $selectedItem.length > 0 && module.has.firstLetter($selectedItem, letter);
|
|
9340
|
+
let $nextValue = false;
|
|
9341
|
+
let $nextItem;
|
|
9342
|
+
// check next of the same letter
|
|
9591
9343
|
if (alreadySelectedLetter) {
|
|
9592
9344
|
$nextItem = $selectedItem.nextAll($item).eq(0);
|
|
9593
9345
|
if (module.has.firstLetter($nextItem, letter)) {
|
|
@@ -9603,10 +9355,9 @@
|
|
|
9603
9355
|
|
|
9604
9356
|
return false;
|
|
9605
9357
|
}
|
|
9606
|
-
})
|
|
9607
|
-
;
|
|
9358
|
+
});
|
|
9608
9359
|
}
|
|
9609
|
-
// set next value
|
|
9360
|
+
// set the next value
|
|
9610
9361
|
if ($nextValue) {
|
|
9611
9362
|
module.verbose('Scrolling to next value with letter', letter);
|
|
9612
9363
|
module.set.scrollPosition($nextValue);
|
|
@@ -9623,7 +9374,7 @@
|
|
|
9623
9374
|
if (!$menu) {
|
|
9624
9375
|
module.remove.upward();
|
|
9625
9376
|
} else if (module.is.upward($menu)) {
|
|
9626
|
-
// we need make sure when make assertion openDownward for $menu, $menu does not have upward class
|
|
9377
|
+
// we need to make sure when make assertion openDownward for $menu, $menu does not have upward class
|
|
9627
9378
|
module.remove.upward($menu);
|
|
9628
9379
|
}
|
|
9629
9380
|
|
|
@@ -9640,11 +9391,11 @@
|
|
|
9640
9391
|
}
|
|
9641
9392
|
},
|
|
9642
9393
|
upward: function ($currentMenu) {
|
|
9643
|
-
|
|
9394
|
+
const $element = $currentMenu || $module;
|
|
9644
9395
|
$element.addClass(className.upward);
|
|
9645
9396
|
},
|
|
9646
9397
|
leftward: function ($currentMenu) {
|
|
9647
|
-
|
|
9398
|
+
const $element = $currentMenu || $menu;
|
|
9648
9399
|
$element.addClass(className.leftward);
|
|
9649
9400
|
},
|
|
9650
9401
|
value: function (value, text, $selected, preventChangeTrigger) {
|
|
@@ -9658,14 +9409,11 @@
|
|
|
9658
9409
|
} else {
|
|
9659
9410
|
$input.addClass(className.noselection);
|
|
9660
9411
|
}
|
|
9661
|
-
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
? String(value)
|
|
9667
|
-
: value
|
|
9668
|
-
;
|
|
9412
|
+
const hasInput = $input.length > 0;
|
|
9413
|
+
const currentValue = module.get.values();
|
|
9414
|
+
const stringValue = value !== undefined
|
|
9415
|
+
? String(value)
|
|
9416
|
+
: value;
|
|
9669
9417
|
if (hasInput) {
|
|
9670
9418
|
if (!settings.allowReselection && stringValue == currentValue) {
|
|
9671
9419
|
module.verbose('Skipping value update already same value', value, currentValue);
|
|
@@ -9678,11 +9426,10 @@
|
|
|
9678
9426
|
module.debug('Adding user option', value);
|
|
9679
9427
|
module.add.optionValue(value);
|
|
9680
9428
|
}
|
|
9681
|
-
module.debug('Updating input value',
|
|
9429
|
+
module.debug('Updating input value', value, currentValue);
|
|
9682
9430
|
internalChange = true;
|
|
9683
9431
|
$input
|
|
9684
|
-
.val(
|
|
9685
|
-
;
|
|
9432
|
+
.val(value);
|
|
9686
9433
|
if (settings.fireOnInit === false && module.is.initialLoad()) {
|
|
9687
9434
|
module.debug('Input native change event ignored on initial load');
|
|
9688
9435
|
} else if (preventChangeTrigger !== true) {
|
|
@@ -9690,8 +9437,8 @@
|
|
|
9690
9437
|
}
|
|
9691
9438
|
internalChange = false;
|
|
9692
9439
|
} else {
|
|
9693
|
-
module.verbose('Storing value in metadata',
|
|
9694
|
-
if (
|
|
9440
|
+
module.verbose('Storing value in metadata', value, $input);
|
|
9441
|
+
if (value !== currentValue) {
|
|
9695
9442
|
$module.data(metadata.value, stringValue);
|
|
9696
9443
|
}
|
|
9697
9444
|
}
|
|
@@ -9703,8 +9450,7 @@
|
|
|
9703
9450
|
},
|
|
9704
9451
|
active: function () {
|
|
9705
9452
|
$module
|
|
9706
|
-
.addClass(className.active)
|
|
9707
|
-
;
|
|
9453
|
+
.addClass(className.active);
|
|
9708
9454
|
},
|
|
9709
9455
|
multiple: function () {
|
|
9710
9456
|
$module.addClass(className.multiple);
|
|
@@ -9727,9 +9473,7 @@
|
|
|
9727
9473
|
preventChangeTrigger = $selectedItem;
|
|
9728
9474
|
$selectedItem = undefined;
|
|
9729
9475
|
}
|
|
9730
|
-
|
|
9731
|
-
isMultiple = module.is.multiple()
|
|
9732
|
-
;
|
|
9476
|
+
const isMultiple = module.is.multiple();
|
|
9733
9477
|
$selectedItem = settings.allowAdditions
|
|
9734
9478
|
? $selectedItem || module.get.itemWithAdditions(value)
|
|
9735
9479
|
: $selectedItem || module.get.item(value);
|
|
@@ -9743,7 +9487,11 @@
|
|
|
9743
9487
|
if (settings.useLabels) {
|
|
9744
9488
|
module.remove.selectedItem();
|
|
9745
9489
|
if (value === undefined) {
|
|
9746
|
-
|
|
9490
|
+
const existingLabels = $module.find(selector.label);
|
|
9491
|
+
if (existingLabels.length > 0) {
|
|
9492
|
+
preventChangeTrigger = true;
|
|
9493
|
+
module.remove.labels(existingLabels, true);
|
|
9494
|
+
}
|
|
9747
9495
|
}
|
|
9748
9496
|
}
|
|
9749
9497
|
} else {
|
|
@@ -9757,17 +9505,15 @@
|
|
|
9757
9505
|
// select each item
|
|
9758
9506
|
$selectedItem
|
|
9759
9507
|
.each(function () {
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
shouldAnimate = isMultiple && $selectedItem && $selectedItem.length === 1
|
|
9770
|
-
;
|
|
9508
|
+
const $selected = $(this);
|
|
9509
|
+
const selectedText = module.get.choiceText($selected);
|
|
9510
|
+
const selectedValue = module.get.choiceValue($selected, selectedText);
|
|
9511
|
+
|
|
9512
|
+
const isFiltered = $selected.hasClass(className.filtered);
|
|
9513
|
+
const isActive = $selected.hasClass(className.active);
|
|
9514
|
+
const isActionable = $selected.hasClass(className.actionable);
|
|
9515
|
+
const isUserValue = $selected.hasClass(className.addition);
|
|
9516
|
+
const shouldAnimate = isMultiple && $selectedItem && $selectedItem.length === 1;
|
|
9771
9517
|
if (isActionable) {
|
|
9772
9518
|
if ((!isMultiple || (!isActive || isUserValue)) && settings.apiSettings && settings.saveRemoteData) {
|
|
9773
9519
|
module.save.remoteData(selectedText, selectedValue);
|
|
@@ -9803,11 +9549,9 @@
|
|
|
9803
9549
|
module.set.value(selectedValue, selectedText, $selected, preventChangeTrigger);
|
|
9804
9550
|
$selected
|
|
9805
9551
|
.addClass(className.active)
|
|
9806
|
-
.addClass(className.selected)
|
|
9807
|
-
;
|
|
9552
|
+
.addClass(className.selected);
|
|
9808
9553
|
}
|
|
9809
|
-
})
|
|
9810
|
-
;
|
|
9554
|
+
});
|
|
9811
9555
|
if (!keepSearchTerm) {
|
|
9812
9556
|
module.remove.searchTerm();
|
|
9813
9557
|
}
|
|
@@ -9820,25 +9564,21 @@
|
|
|
9820
9564
|
|
|
9821
9565
|
add: {
|
|
9822
9566
|
label: function (value, text, shouldAnimate) {
|
|
9823
|
-
|
|
9824
|
-
$
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
escapedValue = module.escape.value(value),
|
|
9828
|
-
$label
|
|
9829
|
-
;
|
|
9567
|
+
const $next = module.is.searchSelection()
|
|
9568
|
+
? $search
|
|
9569
|
+
: $text;
|
|
9570
|
+
let $label;
|
|
9830
9571
|
if (settings.ignoreCase) {
|
|
9831
|
-
|
|
9572
|
+
value = value.toLowerCase();
|
|
9832
9573
|
}
|
|
9833
9574
|
$label = $('<a />')
|
|
9834
9575
|
.addClass(className.label)
|
|
9835
|
-
.attr('data-' + metadata.value,
|
|
9836
|
-
.html(templates.label(
|
|
9837
|
-
;
|
|
9838
|
-
$label = settings.onLabelCreate.call($label, escapedValue, text);
|
|
9576
|
+
.attr('data-' + metadata.value, value)
|
|
9577
|
+
.html(templates.label(value, text, settings));
|
|
9578
|
+
$label = settings.onLabelCreate.call($label, value, text);
|
|
9839
9579
|
|
|
9840
9580
|
if (module.has.label(value)) {
|
|
9841
|
-
module.debug('User selection already exists, skipping',
|
|
9581
|
+
module.debug('User selection already exists, skipping', value);
|
|
9842
9582
|
|
|
9843
9583
|
return;
|
|
9844
9584
|
}
|
|
@@ -9856,38 +9596,29 @@
|
|
|
9856
9596
|
verbose: settings.verbose,
|
|
9857
9597
|
silent: settings.silent,
|
|
9858
9598
|
duration: settings.label.duration,
|
|
9859
|
-
})
|
|
9860
|
-
;
|
|
9599
|
+
});
|
|
9861
9600
|
} else {
|
|
9862
9601
|
module.debug('Adding selection label', $label);
|
|
9863
9602
|
$label
|
|
9864
|
-
.insertBefore($next)
|
|
9865
|
-
;
|
|
9603
|
+
.insertBefore($next);
|
|
9866
9604
|
}
|
|
9867
9605
|
},
|
|
9868
9606
|
message: function (message) {
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
html = settings.templates.message(module.add.variables(message))
|
|
9872
|
-
;
|
|
9607
|
+
const $message = $menu.children(selector.message);
|
|
9608
|
+
const html = settings.templates.message(module.add.variables(message));
|
|
9873
9609
|
if ($message.length > 0) {
|
|
9874
9610
|
$message
|
|
9875
|
-
.html(html)
|
|
9876
|
-
;
|
|
9611
|
+
.html(html);
|
|
9877
9612
|
} else {
|
|
9878
9613
|
$('<div/>')
|
|
9879
9614
|
.html(html)
|
|
9880
9615
|
.addClass(className.message)
|
|
9881
|
-
.appendTo($menu)
|
|
9882
|
-
;
|
|
9616
|
+
.appendTo($menu);
|
|
9883
9617
|
}
|
|
9884
9618
|
},
|
|
9885
9619
|
optionValue: function (value) {
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
$option = $input.find('option[value="' + module.escape.string(escapedValue) + '"]'),
|
|
9889
|
-
hasOption = $option.length > 0
|
|
9890
|
-
;
|
|
9620
|
+
const $option = $input.find('option[value="' + CSS.escape(value) + '"]');
|
|
9621
|
+
const hasOption = $option.length > 0;
|
|
9891
9622
|
if (hasOption) {
|
|
9892
9623
|
return;
|
|
9893
9624
|
}
|
|
@@ -9898,22 +9629,19 @@
|
|
|
9898
9629
|
$input.find('option.' + className.addition).remove();
|
|
9899
9630
|
}
|
|
9900
9631
|
$('<option/>')
|
|
9901
|
-
.prop('value',
|
|
9632
|
+
.prop('value', value)
|
|
9902
9633
|
.addClass(className.addition)
|
|
9903
9634
|
.text(value)
|
|
9904
|
-
.appendTo($input)
|
|
9905
|
-
;
|
|
9635
|
+
.appendTo($input);
|
|
9906
9636
|
module.verbose('Adding user addition as an <option>', value);
|
|
9907
9637
|
module.observe.select();
|
|
9908
9638
|
},
|
|
9909
9639
|
userSuggestion: function (value) {
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
|
|
9915
|
-
html
|
|
9916
|
-
;
|
|
9640
|
+
let $addition = $menu.children(selector.addition);
|
|
9641
|
+
const $existingItem = module.get.item(value);
|
|
9642
|
+
const alreadyHasValue = $existingItem && $existingItem.not(selector.addition).length > 0;
|
|
9643
|
+
const hasUserSuggestion = $addition.length > 0;
|
|
9644
|
+
let html;
|
|
9917
9645
|
if (settings.useLabels && module.has.maxSelections()) {
|
|
9918
9646
|
return;
|
|
9919
9647
|
}
|
|
@@ -9928,38 +9656,31 @@
|
|
|
9928
9656
|
.data(metadata.text, value)
|
|
9929
9657
|
.attr('data-' + metadata.value, value)
|
|
9930
9658
|
.attr('data-' + metadata.text, value)
|
|
9931
|
-
.removeClass(className.filtered)
|
|
9932
|
-
;
|
|
9659
|
+
.removeClass(className.filtered);
|
|
9933
9660
|
if (!settings.hideAdditions) {
|
|
9934
|
-
html = settings.templates.addition(module.add.variables(message.addResult, value));
|
|
9661
|
+
html = settings.templates.addition(module.add.variables(message.addResult, settings.templates.escape(value, settings)));
|
|
9935
9662
|
$addition
|
|
9936
|
-
.html(html)
|
|
9937
|
-
;
|
|
9663
|
+
.html(html);
|
|
9938
9664
|
}
|
|
9939
9665
|
module.verbose('Replacing user suggestion with new value', $addition);
|
|
9940
9666
|
} else {
|
|
9941
9667
|
$addition = module.create.userChoice(value);
|
|
9942
9668
|
$addition
|
|
9943
|
-
.prependTo($menu)
|
|
9944
|
-
;
|
|
9669
|
+
.prependTo($menu);
|
|
9945
9670
|
module.verbose('Adding item choice to menu corresponding with user choice addition', $addition);
|
|
9946
9671
|
}
|
|
9947
9672
|
if (!settings.hideAdditions || module.is.allFiltered()) {
|
|
9948
9673
|
$addition
|
|
9949
9674
|
.addClass(className.selected)
|
|
9950
9675
|
.siblings()
|
|
9951
|
-
.removeClass(className.selected)
|
|
9952
|
-
;
|
|
9676
|
+
.removeClass(className.selected);
|
|
9953
9677
|
}
|
|
9954
9678
|
module.refreshItems();
|
|
9955
9679
|
},
|
|
9956
|
-
variables: function (message, term) {
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
hasTerm = message.search('{term}') !== -1,
|
|
9961
|
-
query
|
|
9962
|
-
;
|
|
9680
|
+
variables: function (message = '', term = module.get.query()) {
|
|
9681
|
+
const hasCount = message.search('{count}') !== -1;
|
|
9682
|
+
const hasMaxCount = message.search('{maxCount}') !== -1;
|
|
9683
|
+
const hasTerm = message.search('{term}') !== -1;
|
|
9963
9684
|
module.verbose('Adding templated variables to message', message);
|
|
9964
9685
|
if (hasCount) {
|
|
9965
9686
|
message = message.replace('{count}', module.get.selectionCount());
|
|
@@ -9968,8 +9689,7 @@
|
|
|
9968
9689
|
message = message.replace('{maxCount}', settings.maxSelections);
|
|
9969
9690
|
}
|
|
9970
9691
|
if (hasTerm) {
|
|
9971
|
-
|
|
9972
|
-
message = message.replace('{term}', query);
|
|
9692
|
+
message = message.replace('{term}', term);
|
|
9973
9693
|
}
|
|
9974
9694
|
|
|
9975
9695
|
return message;
|
|
@@ -9980,10 +9700,8 @@
|
|
|
9980
9700
|
$selectedItem = undefined;
|
|
9981
9701
|
addedText = undefined;
|
|
9982
9702
|
}
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
newValue
|
|
9986
|
-
;
|
|
9703
|
+
const currentValue = module.get.values();
|
|
9704
|
+
let newValue;
|
|
9987
9705
|
if (module.has.value(addedValue)) {
|
|
9988
9706
|
module.debug('Value already selected');
|
|
9989
9707
|
|
|
@@ -9996,7 +9714,9 @@
|
|
|
9996
9714
|
}
|
|
9997
9715
|
// extend current array
|
|
9998
9716
|
if (Array.isArray(currentValue)) {
|
|
9999
|
-
newValue = $selectedItem && $selectedItem.hasClass(className.actionable)
|
|
9717
|
+
newValue = $selectedItem && $selectedItem.hasClass(className.actionable)
|
|
9718
|
+
? currentValue
|
|
9719
|
+
: [...currentValue, addedValue];
|
|
10000
9720
|
newValue = module.get.uniqueArray(newValue);
|
|
10001
9721
|
} else {
|
|
10002
9722
|
newValue = [addedValue];
|
|
@@ -10039,11 +9759,11 @@
|
|
|
10039
9759
|
initialLoad = false;
|
|
10040
9760
|
},
|
|
10041
9761
|
upward: function ($currentMenu) {
|
|
10042
|
-
|
|
9762
|
+
const $element = $currentMenu || $module;
|
|
10043
9763
|
$element.removeClass(className.upward);
|
|
10044
9764
|
},
|
|
10045
9765
|
leftward: function ($currentMenu) {
|
|
10046
|
-
|
|
9766
|
+
const $element = $currentMenu || $menu;
|
|
10047
9767
|
$element.removeClass(className.leftward);
|
|
10048
9768
|
},
|
|
10049
9769
|
visible: function () {
|
|
@@ -10055,7 +9775,7 @@
|
|
|
10055
9775
|
filteredItem: function () {
|
|
10056
9776
|
if (settings.highlightMatches) {
|
|
10057
9777
|
$.each($item, function (index, item) {
|
|
10058
|
-
|
|
9778
|
+
const $markItem = $(item);
|
|
10059
9779
|
$markItem.html($markItem.html().replace(/<\/?mark>/g, ''));
|
|
10060
9780
|
});
|
|
10061
9781
|
}
|
|
@@ -10073,18 +9793,15 @@
|
|
|
10073
9793
|
module.remove.empty();
|
|
10074
9794
|
},
|
|
10075
9795
|
optionValue: function (value) {
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
$option = $input.find('option[value="' + module.escape.string(escapedValue) + '"]'),
|
|
10079
|
-
hasOption = $option.length > 0
|
|
10080
|
-
;
|
|
9796
|
+
const $option = $input.find('option[value="' + CSS.escape(value) + '"]');
|
|
9797
|
+
const hasOption = $option.length > 0;
|
|
10081
9798
|
if (!hasOption || !$option.hasClass(className.addition)) {
|
|
10082
9799
|
return;
|
|
10083
9800
|
}
|
|
10084
9801
|
// temporarily disconnect observer
|
|
10085
9802
|
module.disconnect.selectObserver();
|
|
10086
9803
|
$option.remove();
|
|
10087
|
-
module.verbose('Removing user addition as an <option>',
|
|
9804
|
+
module.verbose('Removing user addition as an <option>', value);
|
|
10088
9805
|
module.observe.select();
|
|
10089
9806
|
},
|
|
10090
9807
|
message: function () {
|
|
@@ -10112,11 +9829,9 @@
|
|
|
10112
9829
|
|
|
10113
9830
|
$selectedItem
|
|
10114
9831
|
.each(function () {
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
selectedValue = module.get.choiceValue($selected, selectedText)
|
|
10119
|
-
;
|
|
9832
|
+
const $selected = $(this);
|
|
9833
|
+
const selectedText = module.get.choiceText($selected);
|
|
9834
|
+
const selectedValue = module.get.choiceValue($selected, selectedText);
|
|
10120
9835
|
if (module.is.multiple()) {
|
|
10121
9836
|
if (settings.useLabels) {
|
|
10122
9837
|
module.remove.value(selectedValue, selectedText, $selected, preventChangeTrigger);
|
|
@@ -10134,22 +9849,18 @@
|
|
|
10134
9849
|
}
|
|
10135
9850
|
$selected
|
|
10136
9851
|
.removeClass(className.filtered)
|
|
10137
|
-
.removeClass(className.active)
|
|
10138
|
-
;
|
|
9852
|
+
.removeClass(className.active);
|
|
10139
9853
|
if (settings.useLabels) {
|
|
10140
9854
|
$selected.removeClass(className.selected);
|
|
10141
9855
|
}
|
|
10142
|
-
})
|
|
10143
|
-
;
|
|
9856
|
+
});
|
|
10144
9857
|
},
|
|
10145
9858
|
selectedItem: function () {
|
|
10146
9859
|
$item.removeClass(className.selected);
|
|
10147
9860
|
},
|
|
10148
9861
|
value: function (removedValue, removedText, $removedItem, preventChangeTrigger) {
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
newValue
|
|
10152
|
-
;
|
|
9862
|
+
const values = module.get.values();
|
|
9863
|
+
let newValue;
|
|
10153
9864
|
if (module.has.selectInput()) {
|
|
10154
9865
|
module.verbose('Input is <select> removing selected option', removedValue);
|
|
10155
9866
|
newValue = module.remove.arrayValue(removedValue, values);
|
|
@@ -10179,11 +9890,8 @@
|
|
|
10179
9890
|
return values;
|
|
10180
9891
|
},
|
|
10181
9892
|
label: function (value, shouldAnimate) {
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
$labels = $module.find(selector.label),
|
|
10185
|
-
$removedLabel = $labels.filter('[data-' + metadata.value + '="' + module.escape.string(settings.ignoreCase ? escapedValue.toLowerCase() : escapedValue) + '"]')
|
|
10186
|
-
;
|
|
9893
|
+
const $labels = $module.find(selector.label);
|
|
9894
|
+
const $removedLabel = $labels.filter('[data-' + metadata.value + '="' + CSS.escape(settings.ignoreCase ? value.toLowerCase() : value) + '"]');
|
|
10187
9895
|
module.verbose('Removing label', $removedLabel);
|
|
10188
9896
|
$removedLabel.remove();
|
|
10189
9897
|
},
|
|
@@ -10197,14 +9905,12 @@
|
|
|
10197
9905
|
module.verbose('Removing labels', $labels);
|
|
10198
9906
|
$labels
|
|
10199
9907
|
.each(function () {
|
|
10200
|
-
|
|
10201
|
-
|
|
10202
|
-
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
|
|
10206
|
-
isUserValue = module.is.userValue(stringValue)
|
|
10207
|
-
;
|
|
9908
|
+
const $label = $(this);
|
|
9909
|
+
const value = $label.data(metadata.value);
|
|
9910
|
+
const stringValue = value !== undefined
|
|
9911
|
+
? String(value)
|
|
9912
|
+
: value;
|
|
9913
|
+
const isUserValue = module.is.userValue(stringValue);
|
|
10208
9914
|
if (settings.onLabelRemove.call($label, value) === false) {
|
|
10209
9915
|
module.debug('Label remove callback cancelled removal');
|
|
10210
9916
|
|
|
@@ -10218,26 +9924,21 @@
|
|
|
10218
9924
|
// selected will also remove label
|
|
10219
9925
|
module.remove.selected(stringValue, false, preventChangeTrigger);
|
|
10220
9926
|
}
|
|
10221
|
-
})
|
|
10222
|
-
;
|
|
9927
|
+
});
|
|
10223
9928
|
},
|
|
10224
9929
|
tabbable: function () {
|
|
10225
9930
|
if (module.is.searchSelection()) {
|
|
10226
9931
|
module.debug('Searchable dropdown initialized');
|
|
10227
9932
|
$search
|
|
10228
|
-
.removeAttr('tabindex')
|
|
10229
|
-
;
|
|
9933
|
+
.removeAttr('tabindex');
|
|
10230
9934
|
$menu
|
|
10231
|
-
.removeAttr('tabindex')
|
|
10232
|
-
;
|
|
9935
|
+
.removeAttr('tabindex');
|
|
10233
9936
|
} else {
|
|
10234
9937
|
module.debug('Simple selection dropdown initialized');
|
|
10235
9938
|
$module
|
|
10236
|
-
.removeAttr('tabindex')
|
|
10237
|
-
;
|
|
9939
|
+
.removeAttr('tabindex');
|
|
10238
9940
|
$menu
|
|
10239
|
-
.removeAttr('tabindex')
|
|
10240
|
-
;
|
|
9941
|
+
.removeAttr('tabindex');
|
|
10241
9942
|
}
|
|
10242
9943
|
},
|
|
10243
9944
|
diacritics: function (text) {
|
|
@@ -10261,29 +9962,21 @@
|
|
|
10261
9962
|
selectInput: function () {
|
|
10262
9963
|
return $input.is('select');
|
|
10263
9964
|
},
|
|
10264
|
-
minCharacters: function (searchTerm) {
|
|
9965
|
+
minCharacters: function (searchTerm = module.get.query()) {
|
|
10265
9966
|
if (settings.minCharacters && !iconClicked) {
|
|
10266
|
-
|
|
10267
|
-
? String(searchTerm)
|
|
10268
|
-
: String(module.get.query());
|
|
10269
|
-
|
|
10270
|
-
return searchTerm.length >= settings.minCharacters;
|
|
9967
|
+
return String(searchTerm).length >= settings.minCharacters;
|
|
10271
9968
|
}
|
|
10272
9969
|
iconClicked = false;
|
|
10273
9970
|
|
|
10274
9971
|
return true;
|
|
10275
9972
|
},
|
|
10276
9973
|
firstLetter: function ($item, letter) {
|
|
10277
|
-
var
|
|
10278
|
-
text,
|
|
10279
|
-
firstLetter
|
|
10280
|
-
;
|
|
10281
9974
|
if (!$item || $item.length === 0 || typeof letter !== 'string') {
|
|
10282
9975
|
return false;
|
|
10283
9976
|
}
|
|
10284
|
-
text = module.get.choiceText($item, false);
|
|
9977
|
+
const text = module.get.choiceText($item, false);
|
|
10285
9978
|
letter = letter.toLowerCase();
|
|
10286
|
-
firstLetter = String(text).charAt(0).toLowerCase();
|
|
9979
|
+
const firstLetter = String(text).charAt(0).toLowerCase();
|
|
10287
9980
|
|
|
10288
9981
|
return letter == firstLetter;
|
|
10289
9982
|
},
|
|
@@ -10303,23 +9996,18 @@
|
|
|
10303
9996
|
return $menu.children(selector.message).length > 0;
|
|
10304
9997
|
},
|
|
10305
9998
|
label: function (value) {
|
|
10306
|
-
|
|
10307
|
-
escapedValue = module.escape.value(value),
|
|
10308
|
-
$labels = $module.find(selector.label)
|
|
10309
|
-
;
|
|
9999
|
+
const $labels = $module.find(selector.label);
|
|
10310
10000
|
if (settings.ignoreCase) {
|
|
10311
|
-
|
|
10001
|
+
value = value.toLowerCase();
|
|
10312
10002
|
}
|
|
10313
10003
|
|
|
10314
|
-
return $labels.filter('[data-' + metadata.value + '="' +
|
|
10004
|
+
return $labels.filter('[data-' + metadata.value + '="' + CSS.escape(value) + '"]').length > 0;
|
|
10315
10005
|
},
|
|
10316
10006
|
maxSelections: function () {
|
|
10317
10007
|
return settings.maxSelections && module.get.selectionCount() >= settings.maxSelections;
|
|
10318
10008
|
},
|
|
10319
10009
|
allResultsFiltered: function () {
|
|
10320
|
-
|
|
10321
|
-
$normalResults = $item.not(selector.addition)
|
|
10322
|
-
;
|
|
10010
|
+
const $normalResults = $item.not(selector.addition);
|
|
10323
10011
|
|
|
10324
10012
|
return $normalResults.filter(selector.unselectable).length === $normalResults.length;
|
|
10325
10013
|
},
|
|
@@ -10335,20 +10023,16 @@
|
|
|
10335
10023
|
: module.has.valueMatchingCase(value);
|
|
10336
10024
|
},
|
|
10337
10025
|
valueMatchingCase: function (value) {
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
|
|
10342
|
-
: values == value
|
|
10343
|
-
;
|
|
10026
|
+
const values = module.get.values();
|
|
10027
|
+
const hasValue = Array.isArray(values)
|
|
10028
|
+
? values && values.includes(value)
|
|
10029
|
+
: values == value;
|
|
10344
10030
|
|
|
10345
10031
|
return !!hasValue;
|
|
10346
10032
|
},
|
|
10347
10033
|
valueIgnoringCase: function (value) {
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
hasValue = false
|
|
10351
|
-
;
|
|
10034
|
+
let values = module.get.values();
|
|
10035
|
+
let hasValue = false;
|
|
10352
10036
|
if (!Array.isArray(values)) {
|
|
10353
10037
|
values = [values];
|
|
10354
10038
|
}
|
|
@@ -10380,9 +10064,6 @@
|
|
|
10380
10064
|
bubbledIconClick: function (event) {
|
|
10381
10065
|
return $(event.target).closest($icon).length > 0;
|
|
10382
10066
|
},
|
|
10383
|
-
edge: function () {
|
|
10384
|
-
return !!window.chrome && !!window.StyleMedia;
|
|
10385
|
-
},
|
|
10386
10067
|
empty: function () {
|
|
10387
10068
|
return $module.hasClass(className.empty);
|
|
10388
10069
|
},
|
|
@@ -10398,12 +10079,12 @@
|
|
|
10398
10079
|
: $menu.transition && $menu.transition('is animating');
|
|
10399
10080
|
},
|
|
10400
10081
|
leftward: function ($subMenu) {
|
|
10401
|
-
|
|
10082
|
+
const $selectedMenu = $subMenu || $menu;
|
|
10402
10083
|
|
|
10403
10084
|
return $selectedMenu.hasClass(className.leftward);
|
|
10404
10085
|
},
|
|
10405
10086
|
clearable: function () {
|
|
10406
|
-
|
|
10087
|
+
const hasClearableClass = $module.hasClass(className.clearable);
|
|
10407
10088
|
if (!hasClearableClass && settings.clearable) {
|
|
10408
10089
|
$module.addClass(className.clearable);
|
|
10409
10090
|
}
|
|
@@ -10429,9 +10110,7 @@
|
|
|
10429
10110
|
return initialLoad;
|
|
10430
10111
|
},
|
|
10431
10112
|
inObject: function (needle, object) {
|
|
10432
|
-
|
|
10433
|
-
found = false
|
|
10434
|
-
;
|
|
10113
|
+
let found = false;
|
|
10435
10114
|
$.each(object, function (index, property) {
|
|
10436
10115
|
if (property == needle) {
|
|
10437
10116
|
found = true;
|
|
@@ -10455,9 +10134,7 @@
|
|
|
10455
10134
|
return !module.is.multiple();
|
|
10456
10135
|
},
|
|
10457
10136
|
selectMutation: function (mutations) {
|
|
10458
|
-
|
|
10459
|
-
selectChanged = false
|
|
10460
|
-
;
|
|
10137
|
+
let selectChanged = false;
|
|
10461
10138
|
$.each(mutations, function (index, mutation) {
|
|
10462
10139
|
if ($(mutation.target).is('option, optgroup') || $(mutation.addedNodes).is('select') || ($(mutation.target).is('select') && mutation.type !== 'attributes')) {
|
|
10463
10140
|
selectChanged = true;
|
|
@@ -10478,10 +10155,10 @@
|
|
|
10478
10155
|
return $module.hasClass(className.selection);
|
|
10479
10156
|
},
|
|
10480
10157
|
userValue: function (value) {
|
|
10481
|
-
return
|
|
10158
|
+
return (module.get.userValues() || []).includes(value);
|
|
10482
10159
|
},
|
|
10483
10160
|
upward: function ($menu) {
|
|
10484
|
-
|
|
10161
|
+
const $element = $menu || $module;
|
|
10485
10162
|
|
|
10486
10163
|
return $element.hasClass(className.upward);
|
|
10487
10164
|
},
|
|
@@ -10491,20 +10168,16 @@
|
|
|
10491
10168
|
: $menu.hasClass(className.visible);
|
|
10492
10169
|
},
|
|
10493
10170
|
verticallyScrollableContext: function () {
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
: false
|
|
10498
|
-
;
|
|
10171
|
+
const overflowY = $context[0] !== window
|
|
10172
|
+
? $context.css('overflow-y')
|
|
10173
|
+
: false;
|
|
10499
10174
|
|
|
10500
10175
|
return overflowY === 'auto' || overflowY === 'scroll';
|
|
10501
10176
|
},
|
|
10502
10177
|
horizontallyScrollableContext: function () {
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
: false
|
|
10507
|
-
;
|
|
10178
|
+
const overflowX = $context[0] !== window
|
|
10179
|
+
? $context.css('overflow-X')
|
|
10180
|
+
: false;
|
|
10508
10181
|
|
|
10509
10182
|
return overflowX === 'auto' || overflowX === 'scroll';
|
|
10510
10183
|
},
|
|
@@ -10519,16 +10192,11 @@
|
|
|
10519
10192
|
);
|
|
10520
10193
|
},
|
|
10521
10194
|
openDownward: function ($subMenu) {
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
canOpenDownward,
|
|
10525
|
-
onScreen,
|
|
10526
|
-
calculations
|
|
10527
|
-
;
|
|
10195
|
+
const $currentMenu = $subMenu || $menu;
|
|
10196
|
+
let canOpenDownward;
|
|
10528
10197
|
$currentMenu
|
|
10529
|
-
.addClass(className.loading)
|
|
10530
|
-
|
|
10531
|
-
calculations = {
|
|
10198
|
+
.addClass(className.loading);
|
|
10199
|
+
const calculations = {
|
|
10532
10200
|
context: {
|
|
10533
10201
|
offset: $context[0] === window
|
|
10534
10202
|
? { top: 0, left: 0 }
|
|
@@ -10547,7 +10215,7 @@
|
|
|
10547
10215
|
if (module.has.subMenu($currentMenu)) {
|
|
10548
10216
|
calculations.menu.height += $currentMenu.find(selector.menu).first().outerHeight();
|
|
10549
10217
|
}
|
|
10550
|
-
onScreen = {
|
|
10218
|
+
const onScreen = {
|
|
10551
10219
|
above: calculations.context.scrollTop <= calculations.menu.offset.top - calculations.context.offset.top - calculations.menu.height,
|
|
10552
10220
|
below: (calculations.context.scrollTop + calculations.context.height) >= calculations.menu.offset.top - calculations.context.offset.top + calculations.menu.height,
|
|
10553
10221
|
};
|
|
@@ -10566,16 +10234,12 @@
|
|
|
10566
10234
|
return canOpenDownward;
|
|
10567
10235
|
},
|
|
10568
10236
|
openRightward: function ($subMenu) {
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
isOffscreenRight = false,
|
|
10573
|
-
calculations
|
|
10574
|
-
;
|
|
10237
|
+
const $currentMenu = $subMenu || $menu;
|
|
10238
|
+
let canOpenRightward = true;
|
|
10239
|
+
let isOffscreenRight = false;
|
|
10575
10240
|
$currentMenu
|
|
10576
|
-
.addClass(className.loading)
|
|
10577
|
-
|
|
10578
|
-
calculations = {
|
|
10241
|
+
.addClass(className.loading);
|
|
10242
|
+
const calculations = {
|
|
10579
10243
|
context: {
|
|
10580
10244
|
offset: $context[0] === window
|
|
10581
10245
|
? { top: 0, left: 0 }
|
|
@@ -10621,23 +10285,20 @@
|
|
|
10621
10285
|
|
|
10622
10286
|
animate: {
|
|
10623
10287
|
show: function (callback, $subMenu) {
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
},
|
|
10633
|
-
transition
|
|
10634
|
-
;
|
|
10288
|
+
const $currentMenu = $subMenu || $menu;
|
|
10289
|
+
const start = $subMenu
|
|
10290
|
+
? function () {}
|
|
10291
|
+
: function () {
|
|
10292
|
+
module.hideSubMenus();
|
|
10293
|
+
module.hideOthers();
|
|
10294
|
+
module.set.active();
|
|
10295
|
+
};
|
|
10635
10296
|
callback = isFunction(callback)
|
|
10636
10297
|
? callback
|
|
10637
10298
|
: function () {};
|
|
10638
10299
|
module.verbose('Doing menu show animation', $currentMenu);
|
|
10639
10300
|
module.set.direction($subMenu);
|
|
10640
|
-
transition = settings.transition.showMethod || module.get.transition($subMenu);
|
|
10301
|
+
const transition = settings.transition.showMethod || module.get.transition($subMenu);
|
|
10641
10302
|
if (module.is.selection()) {
|
|
10642
10303
|
module.set.scrollPosition(module.get.selectedItem(), true);
|
|
10643
10304
|
}
|
|
@@ -10662,22 +10323,19 @@
|
|
|
10662
10323
|
onComplete: function () {
|
|
10663
10324
|
callback.call(element);
|
|
10664
10325
|
},
|
|
10665
|
-
})
|
|
10666
|
-
;
|
|
10326
|
+
});
|
|
10667
10327
|
}
|
|
10668
10328
|
}
|
|
10669
10329
|
},
|
|
10670
10330
|
hide: function (callback, $subMenu) {
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
transition = settings.transition.hideMethod || module.get.transition($subMenu)
|
|
10680
|
-
;
|
|
10331
|
+
const $currentMenu = $subMenu || $menu;
|
|
10332
|
+
const start = $subMenu
|
|
10333
|
+
? function () {}
|
|
10334
|
+
: function () {
|
|
10335
|
+
module.unbind.intent();
|
|
10336
|
+
module.remove.active();
|
|
10337
|
+
};
|
|
10338
|
+
const transition = settings.transition.hideMethod || module.get.transition($subMenu);
|
|
10681
10339
|
callback = isFunction(callback)
|
|
10682
10340
|
? callback
|
|
10683
10341
|
: function () {};
|
|
@@ -10704,8 +10362,7 @@
|
|
|
10704
10362
|
onComplete: function () {
|
|
10705
10363
|
callback.call(element);
|
|
10706
10364
|
},
|
|
10707
|
-
})
|
|
10708
|
-
;
|
|
10365
|
+
});
|
|
10709
10366
|
} else {
|
|
10710
10367
|
module.error(error.transition);
|
|
10711
10368
|
}
|
|
@@ -10745,55 +10402,26 @@
|
|
|
10745
10402
|
},
|
|
10746
10403
|
|
|
10747
10404
|
escape: {
|
|
10748
|
-
value: function (value) {
|
|
10749
|
-
var
|
|
10750
|
-
multipleValues = Array.isArray(value),
|
|
10751
|
-
stringValue = typeof value === 'string',
|
|
10752
|
-
isUnparsable = !stringValue && !multipleValues,
|
|
10753
|
-
hasQuotes = stringValue && value.search(regExp.quote) !== -1,
|
|
10754
|
-
values = []
|
|
10755
|
-
;
|
|
10756
|
-
if (isUnparsable || !hasQuotes) {
|
|
10757
|
-
return value;
|
|
10758
|
-
}
|
|
10759
|
-
module.debug('Encoding quote values for use in select', value);
|
|
10760
|
-
if (multipleValues) {
|
|
10761
|
-
$.each(value, function (index, value) {
|
|
10762
|
-
values.push(value.replace(regExp.quote, '"'));
|
|
10763
|
-
});
|
|
10764
|
-
|
|
10765
|
-
return values;
|
|
10766
|
-
}
|
|
10767
|
-
|
|
10768
|
-
return value.replace(regExp.quote, '"');
|
|
10769
|
-
},
|
|
10770
10405
|
string: function (text) {
|
|
10771
10406
|
text = String(text);
|
|
10772
10407
|
|
|
10773
10408
|
return text.replace(regExp.escape, '\\$&');
|
|
10774
10409
|
},
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
'<': '<',
|
|
10782
|
-
'>': '>',
|
|
10783
|
-
'"': '"',
|
|
10784
|
-
"'": ''',
|
|
10785
|
-
'`': '`',
|
|
10786
|
-
},
|
|
10787
|
-
escapedChar = function (chr) {
|
|
10788
|
-
return escape[chr];
|
|
10789
|
-
}
|
|
10790
|
-
;
|
|
10791
|
-
if (shouldEscape.test(string)) {
|
|
10792
|
-
string = string.replace(forceAmpersand ? /&/g : /&(?![\d#a-z]{1,12};)/gi, '&');
|
|
10793
|
-
string = string.replace(badChars, escapedChar);
|
|
10410
|
+
|
|
10411
|
+
// https://github.com/fomantic/Fomantic-UI/issues/2782
|
|
10412
|
+
// https://jsfiddle.net/3efL7jnt/
|
|
10413
|
+
assumeUnescapedAmpLtGt: function (string) {
|
|
10414
|
+
if (settings.preserveHTML) {
|
|
10415
|
+
return string;
|
|
10794
10416
|
}
|
|
10795
10417
|
|
|
10796
|
-
|
|
10418
|
+
const unescapeMap = {
|
|
10419
|
+
'&': '&',
|
|
10420
|
+
'<': '<',
|
|
10421
|
+
'>': '>',
|
|
10422
|
+
};
|
|
10423
|
+
|
|
10424
|
+
return string.replace(/&(?:amp|lt|gt);/g, (v) => unescapeMap[v]);
|
|
10797
10425
|
},
|
|
10798
10426
|
},
|
|
10799
10427
|
|
|
@@ -10820,39 +10448,37 @@
|
|
|
10820
10448
|
return module[name];
|
|
10821
10449
|
}
|
|
10822
10450
|
},
|
|
10823
|
-
debug: function () {
|
|
10451
|
+
debug: function (...args) {
|
|
10824
10452
|
if (!settings.silent && settings.debug) {
|
|
10825
10453
|
if (settings.performance) {
|
|
10826
|
-
module.performance.log(
|
|
10454
|
+
module.performance.log(args);
|
|
10827
10455
|
} else {
|
|
10828
10456
|
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
|
10829
|
-
module.debug.apply(console,
|
|
10457
|
+
module.debug.apply(console, args);
|
|
10830
10458
|
}
|
|
10831
10459
|
}
|
|
10832
10460
|
},
|
|
10833
|
-
verbose: function () {
|
|
10461
|
+
verbose: function (...args) {
|
|
10834
10462
|
if (!settings.silent && settings.verbose && settings.debug) {
|
|
10835
10463
|
if (settings.performance) {
|
|
10836
|
-
module.performance.log(
|
|
10464
|
+
module.performance.log(args);
|
|
10837
10465
|
} else {
|
|
10838
10466
|
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
|
10839
|
-
module.verbose.apply(console,
|
|
10467
|
+
module.verbose.apply(console, args);
|
|
10840
10468
|
}
|
|
10841
10469
|
}
|
|
10842
10470
|
},
|
|
10843
|
-
error: function () {
|
|
10471
|
+
error: function (...args) {
|
|
10844
10472
|
if (!settings.silent) {
|
|
10845
10473
|
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
|
10846
|
-
module.error.apply(console,
|
|
10474
|
+
module.error.apply(console, args);
|
|
10847
10475
|
}
|
|
10848
10476
|
},
|
|
10849
10477
|
performance: {
|
|
10850
10478
|
log: function (message) {
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
previousTime
|
|
10855
|
-
;
|
|
10479
|
+
let currentTime;
|
|
10480
|
+
let executionTime;
|
|
10481
|
+
let previousTime;
|
|
10856
10482
|
if (settings.performance) {
|
|
10857
10483
|
currentTime = Date.now();
|
|
10858
10484
|
previousTime = time || currentTime;
|
|
@@ -10860,7 +10486,7 @@
|
|
|
10860
10486
|
time = currentTime;
|
|
10861
10487
|
performance.push({
|
|
10862
10488
|
Name: message[0],
|
|
10863
|
-
Arguments:
|
|
10489
|
+
Arguments: message.slice(1),
|
|
10864
10490
|
Element: element,
|
|
10865
10491
|
'Execution Time': executionTime,
|
|
10866
10492
|
});
|
|
@@ -10871,10 +10497,8 @@
|
|
|
10871
10497
|
}, 500);
|
|
10872
10498
|
},
|
|
10873
10499
|
display: function () {
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
totalTime = 0
|
|
10877
|
-
;
|
|
10500
|
+
let title = settings.name + ':';
|
|
10501
|
+
let totalTime = 0;
|
|
10878
10502
|
time = false;
|
|
10879
10503
|
clearTimeout(module.performance.timer);
|
|
10880
10504
|
$.each(performance, function (index, data) {
|
|
@@ -10883,35 +10507,24 @@
|
|
|
10883
10507
|
title += ' ' + totalTime + 'ms';
|
|
10884
10508
|
if (performance.length > 0) {
|
|
10885
10509
|
console.groupCollapsed(title);
|
|
10886
|
-
|
|
10887
|
-
console.table(performance);
|
|
10888
|
-
} else {
|
|
10889
|
-
$.each(performance, function (index, data) {
|
|
10890
|
-
console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
|
|
10891
|
-
});
|
|
10892
|
-
}
|
|
10510
|
+
console.table(performance);
|
|
10893
10511
|
console.groupEnd();
|
|
10894
10512
|
}
|
|
10895
10513
|
performance = [];
|
|
10896
10514
|
},
|
|
10897
10515
|
},
|
|
10898
|
-
invoke: function (query, passedArguments, context) {
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
response
|
|
10904
|
-
;
|
|
10905
|
-
passedArguments = passedArguments || queryArguments;
|
|
10906
|
-
context = context || element;
|
|
10516
|
+
invoke: function (query, passedArguments = queryArguments, context = element) {
|
|
10517
|
+
let object = instance;
|
|
10518
|
+
let maxDepth;
|
|
10519
|
+
let found;
|
|
10520
|
+
let response;
|
|
10907
10521
|
if (typeof query === 'string' && object !== undefined) {
|
|
10908
10522
|
query = query.split(/[ .]/);
|
|
10909
10523
|
maxDepth = query.length - 1;
|
|
10910
10524
|
$.each(query, function (depth, value) {
|
|
10911
|
-
|
|
10525
|
+
const camelCaseValue = depth !== maxDepth
|
|
10912
10526
|
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
|
10913
|
-
: query
|
|
10914
|
-
;
|
|
10527
|
+
: query;
|
|
10915
10528
|
if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
|
|
10916
10529
|
object = object[camelCaseValue];
|
|
10917
10530
|
} else if (object[camelCaseValue] !== undefined) {
|
|
@@ -10952,7 +10565,7 @@
|
|
|
10952
10565
|
if (instance === undefined) {
|
|
10953
10566
|
module.initialize();
|
|
10954
10567
|
}
|
|
10955
|
-
module.invoke(
|
|
10568
|
+
module.invoke(parameters);
|
|
10956
10569
|
} else {
|
|
10957
10570
|
if (instance !== undefined) {
|
|
10958
10571
|
instance.invoke('destroy');
|
|
@@ -10996,33 +10609,33 @@
|
|
|
10996
10609
|
match: 'both', // what to match against with search selection (both, text, or label)
|
|
10997
10610
|
fullTextSearch: 'exact', // search anywhere in value (set to 'exact' to require exact matches)
|
|
10998
10611
|
highlightMatches: false, // Whether search result should highlight matching strings
|
|
10999
|
-
ignoreDiacritics: false, // match results also if they contain diacritics of the same base character (for example searching for "a" will also match "á" or "â" or "à", etc...)
|
|
10612
|
+
ignoreDiacritics: false, // match results also if they contain diacritics of the same base character (for example, searching for "a" will also match "á" or "â" or "à", etc...)
|
|
11000
10613
|
hideDividers: false, // Whether to hide any divider elements (specified in selector.divider) that are sibling to any items when searched (set to true will hide all dividers, set to 'empty' will hide them when they are not followed by a visible item)
|
|
11001
10614
|
|
|
11002
|
-
placeholder: 'auto', // whether to convert blank <select> values to placeholder text
|
|
11003
|
-
preserveHTML: true, // preserve
|
|
10615
|
+
placeholder: 'auto', // whether to convert blank <select> values to the placeholder text
|
|
10616
|
+
preserveHTML: true, // preserve HTML when selecting value
|
|
11004
10617
|
sortSelect: false, // sort selection on init
|
|
11005
10618
|
|
|
11006
10619
|
forceSelection: false, // force a choice on blur with search selection
|
|
11007
10620
|
|
|
11008
10621
|
allowAdditions: false, // whether multiple select should allow user added values
|
|
11009
|
-
keepSearchTerm: false, // whether the search value should be kept and menu stays filtered on item selection
|
|
10622
|
+
keepSearchTerm: false, // whether the search value should be kept, and the menu stays filtered on item selection
|
|
11010
10623
|
ignoreCase: false, // whether to consider case sensitivity when creating labels
|
|
11011
10624
|
ignoreSearchCase: true, // whether to consider case sensitivity when filtering items
|
|
11012
|
-
hideAdditions: true, // whether
|
|
10625
|
+
hideAdditions: true, // whether to hide a special message prompting a user, they can enter a value
|
|
11013
10626
|
|
|
11014
|
-
maxSelections: false, // When set to a number limits the number of selections to this count
|
|
10627
|
+
maxSelections: false, // When set to a number, limits the number of selections to this count
|
|
11015
10628
|
useLabels: true, // whether multiple select should filter currently active selections from choices
|
|
11016
|
-
delimiter: ',', // when multiselect uses normal <input
|
|
10629
|
+
delimiter: ',', // when multiselect uses normal <input>, the values will be delimited with this character
|
|
11017
10630
|
|
|
11018
|
-
showOnFocus: false, // show menu on focus
|
|
10631
|
+
showOnFocus: false, // show the menu on focus
|
|
11019
10632
|
allowReselection: false, // whether current value should trigger callbacks when reselected
|
|
11020
|
-
allowTab: true, // add tabindex to element
|
|
11021
|
-
allowCategorySelection: false, // allow elements with
|
|
10633
|
+
allowTab: true, // add tabindex to the element
|
|
10634
|
+
allowCategorySelection: false, // allow elements with submenus to be selected
|
|
11022
10635
|
|
|
11023
10636
|
fireOnInit: false, // Whether callbacks should fire when initializing dropdown values
|
|
11024
10637
|
|
|
11025
|
-
transition: 'auto', // auto transition will slide down or up based on direction
|
|
10638
|
+
transition: 'auto', // auto transition will slide down or up based on the direction
|
|
11026
10639
|
duration: 200, // duration of transition
|
|
11027
10640
|
displayType: false, // displayType of transition
|
|
11028
10641
|
|
|
@@ -11084,14 +10697,11 @@
|
|
|
11084
10697
|
missingMultiple: '<select> requires multiple property to be set to correctly preserve multiple values',
|
|
11085
10698
|
method: 'The method you called is not defined.',
|
|
11086
10699
|
noAPI: 'The API module is required to load resources remotely',
|
|
11087
|
-
noStorage: 'Saving remote data requires session storage',
|
|
11088
10700
|
noElement: 'This module requires ui {element}',
|
|
11089
|
-
noNormalize: '"ignoreDiacritics" setting will be ignored. Browser does not support String().normalize(). You may consider including <https://cdn.jsdelivr.net/npm/unorm@1.4.1/lib/unorm.min.js> as a polyfill.',
|
|
11090
10701
|
},
|
|
11091
10702
|
|
|
11092
10703
|
regExp: {
|
|
11093
10704
|
escape: /[\s#$()*+,.:=?@[\\\]^{|}-]/g,
|
|
11094
|
-
quote: /"/g,
|
|
11095
10705
|
},
|
|
11096
10706
|
|
|
11097
10707
|
metadata: {
|
|
@@ -11102,23 +10712,23 @@
|
|
|
11102
10712
|
value: 'value',
|
|
11103
10713
|
},
|
|
11104
10714
|
|
|
11105
|
-
// property names for remote query
|
|
10715
|
+
// property names for the remote query
|
|
11106
10716
|
fields: {
|
|
11107
10717
|
remoteValues: 'results', // grouping for api results
|
|
11108
10718
|
values: 'values', // grouping for all dropdown values
|
|
11109
10719
|
disabled: 'disabled', // whether value should be disabled
|
|
11110
|
-
name: 'name', // displayed dropdown text
|
|
10720
|
+
name: 'name', // the displayed dropdown text
|
|
11111
10721
|
description: 'description', // displayed dropdown description
|
|
11112
10722
|
descriptionVertical: 'descriptionVertical', // whether description should be vertical
|
|
11113
10723
|
value: 'value', // actual dropdown value
|
|
11114
|
-
text: 'text', // displayed text when selected
|
|
10724
|
+
text: 'text', // the displayed text when selected
|
|
11115
10725
|
data: 'data', // custom data attributes
|
|
11116
10726
|
type: 'type', // type of dropdown element
|
|
11117
10727
|
image: 'image', // optional image path
|
|
11118
10728
|
imageClass: 'imageClass', // optional individual class for image
|
|
11119
10729
|
alt: 'alt', // optional alt text for image
|
|
11120
10730
|
icon: 'icon', // optional icon name
|
|
11121
|
-
iconClass: 'iconClass', // optional individual class for icon (for example to use flag instead)
|
|
10731
|
+
iconClass: 'iconClass', // optional individual class for icon (for example, to use a flag instead)
|
|
11122
10732
|
class: 'class', // optional individual class for item/header
|
|
11123
10733
|
divider: 'divider', // optional divider append for group headers
|
|
11124
10734
|
actionable: 'actionable', // optional actionable item
|
|
@@ -11200,137 +10810,116 @@
|
|
|
11200
10810
|
|
|
11201
10811
|
/* Templates */
|
|
11202
10812
|
$.fn.dropdown.settings.templates = {
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
},
|
|
11206
|
-
escape: function (string, preserveHTML) {
|
|
11207
|
-
if (preserveHTML) {
|
|
10813
|
+
escape: function (string, settings) {
|
|
10814
|
+
if (settings !== undefined && settings.preserveHTML) {
|
|
11208
10815
|
return string;
|
|
11209
10816
|
}
|
|
11210
|
-
var
|
|
11211
|
-
badChars = /["'<>`]/g,
|
|
11212
|
-
shouldEscape = /["&'<>`]/,
|
|
11213
|
-
escape = {
|
|
11214
|
-
'<': '<',
|
|
11215
|
-
'>': '>',
|
|
11216
|
-
'"': '"',
|
|
11217
|
-
"'": ''',
|
|
11218
|
-
'`': '`',
|
|
11219
|
-
},
|
|
11220
|
-
escapedChar = function (chr) {
|
|
11221
|
-
return escape[chr];
|
|
11222
|
-
}
|
|
11223
|
-
;
|
|
11224
|
-
if (shouldEscape.test(string)) {
|
|
11225
|
-
string = string.replace(/&(?![\d#a-z]{1,12};)/gi, '&');
|
|
11226
|
-
string = string.replace(badChars, escapedChar);
|
|
11227
|
-
}
|
|
11228
10817
|
|
|
11229
|
-
|
|
10818
|
+
const escapeMap = {
|
|
10819
|
+
'"': '"',
|
|
10820
|
+
'&': '&',
|
|
10821
|
+
"'": ''',
|
|
10822
|
+
'<': '<',
|
|
10823
|
+
'>': '>',
|
|
10824
|
+
};
|
|
10825
|
+
|
|
10826
|
+
return String(string).replace(/["&'<>]/g, (chr) => escapeMap[chr]);
|
|
11230
10827
|
},
|
|
11231
10828
|
// generates dropdown from select values
|
|
11232
|
-
dropdown: function (select,
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
deQuote = $.fn.dropdown.settings.templates.deQuote
|
|
11238
|
-
;
|
|
10829
|
+
dropdown: function (select, settings) {
|
|
10830
|
+
const placeholder = select.placeholder || false;
|
|
10831
|
+
let html = '';
|
|
10832
|
+
const className = settings.className;
|
|
10833
|
+
const escape = settings.templates.escape;
|
|
11239
10834
|
html += '<i class="dropdown icon"></i>';
|
|
11240
10835
|
html += placeholder
|
|
11241
|
-
? '<div class="default text">' + escape(placeholder,
|
|
10836
|
+
? '<div class="default text">' + escape(placeholder, settings) + '</div>'
|
|
11242
10837
|
: '<div class="text"></div>';
|
|
11243
|
-
html += '<div class="' +
|
|
11244
|
-
html +=
|
|
10838
|
+
html += '<div class="' + escape(className.menu) + '">';
|
|
10839
|
+
html += settings.templates.menu(select, settings);
|
|
11245
10840
|
html += '</div>';
|
|
11246
10841
|
|
|
11247
10842
|
return html;
|
|
11248
10843
|
},
|
|
11249
10844
|
|
|
11250
10845
|
// generates just menu from select
|
|
11251
|
-
menu: function (response,
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
;
|
|
10846
|
+
menu: function (response, settings) {
|
|
10847
|
+
const fields = settings.fields;
|
|
10848
|
+
const values = response[fields.values] || [];
|
|
10849
|
+
let html = '';
|
|
10850
|
+
const className = settings.className;
|
|
10851
|
+
const escape = settings.templates.escape;
|
|
11258
10852
|
$.each(values, function (index, option) {
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
dataObject = option[fields.data]
|
|
11264
|
-
;
|
|
10853
|
+
const itemType = option[fields.type] || 'item';
|
|
10854
|
+
const isMenu = itemType.includes('menu');
|
|
10855
|
+
let maybeData = '';
|
|
10856
|
+
const dataObject = option[fields.data];
|
|
11265
10857
|
if (dataObject) {
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
;
|
|
10858
|
+
let dataKey;
|
|
10859
|
+
let dataKeyEscaped;
|
|
11269
10860
|
for (dataKey in dataObject) {
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
10861
|
+
if (Object.prototype.hasOwnProperty.call(dataObject, dataKey)) {
|
|
10862
|
+
dataKeyEscaped = String(dataKey).replace(/\W/g, '');
|
|
10863
|
+
if (!['text', 'value'].includes(dataKeyEscaped.toLowerCase())) {
|
|
10864
|
+
maybeData += ' data-' + dataKeyEscaped + '="' + escape(String(dataObject[dataKey])) + '"';
|
|
10865
|
+
}
|
|
11273
10866
|
}
|
|
11274
10867
|
}
|
|
11275
10868
|
}
|
|
11276
10869
|
if (itemType === 'item' || isMenu) {
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
;
|
|
11292
|
-
html += '<div class="' + deQuote(maybeActionable + maybeDisabled + maybeDescriptionVertical + (option[fields.class] || className.item)) + '" data-value="' + deQuote(option[fields.value], true) + '"' + maybeText + maybeData + '>';
|
|
10870
|
+
const maybeText = option[fields.text]
|
|
10871
|
+
? ' data-text="' + escape(option[fields.text]) + '"'
|
|
10872
|
+
: '';
|
|
10873
|
+
const maybeActionable = option[fields.actionable]
|
|
10874
|
+
? className.actionable + ' '
|
|
10875
|
+
: '';
|
|
10876
|
+
const maybeDisabled = option[fields.disabled]
|
|
10877
|
+
? className.disabled + ' '
|
|
10878
|
+
: '';
|
|
10879
|
+
const maybeDescriptionVertical = option[fields.descriptionVertical]
|
|
10880
|
+
? className.descriptionVertical + ' '
|
|
10881
|
+
: '';
|
|
10882
|
+
const hasDescription = escape(option[fields.description] || '', settings) !== '';
|
|
10883
|
+
html += '<div class="' + escape(maybeActionable + maybeDisabled + maybeDescriptionVertical + (option[fields.class] || className.item)) + '" data-value="' + escape(option[fields.value]) + '"' + maybeText + maybeData + '>';
|
|
11293
10884
|
if (isMenu) {
|
|
11294
|
-
html += '<i class="' + (itemType.
|
|
10885
|
+
html += '<i class="' + (itemType.includes('left') ? 'left' : '') + ' dropdown icon"></i>';
|
|
11295
10886
|
}
|
|
11296
10887
|
if (option[fields.image]) {
|
|
11297
|
-
html += '<img class="' +
|
|
10888
|
+
html += '<img class="' + escape(option[fields.imageClass] || className.image) + '" src="' + escape(option[fields.image]) + '"' + (option[fields.alt] ? ' alt="' + escape(option[fields.alt]) + '"' : '') + '>';
|
|
11298
10889
|
}
|
|
11299
10890
|
if (option[fields.icon]) {
|
|
11300
|
-
html += '<i class="' +
|
|
10891
|
+
html += '<i class="' + escape(option[fields.icon] + ' ' + (option[fields.iconClass] || className.icon)) + '"></i>';
|
|
11301
10892
|
}
|
|
11302
10893
|
if (hasDescription) {
|
|
11303
|
-
html += '<span class="' +
|
|
11304
|
-
html += !isMenu ? '<span class="' +
|
|
10894
|
+
html += '<span class="' + escape(className.description) + '">' + escape(option[fields.description] || '', settings) + '</span>';
|
|
10895
|
+
html += !isMenu ? '<span class="' + escape(className.text) + '">' : '';
|
|
11305
10896
|
}
|
|
11306
10897
|
if (isMenu) {
|
|
11307
|
-
html += '<span class="' +
|
|
10898
|
+
html += '<span class="' + escape(className.text) + '">';
|
|
11308
10899
|
}
|
|
11309
|
-
html += escape(option[fields.name] || '',
|
|
10900
|
+
html += escape(option[fields.name] || '', settings);
|
|
11310
10901
|
if (isMenu) {
|
|
11311
10902
|
html += '</span>';
|
|
11312
|
-
html += '<div class="' +
|
|
11313
|
-
html +=
|
|
10903
|
+
html += '<div class="' + escape(itemType) + '">';
|
|
10904
|
+
html += settings.templates.menu(option, settings);
|
|
11314
10905
|
html += '</div>';
|
|
11315
10906
|
} else if (hasDescription) {
|
|
11316
10907
|
html += '</span>';
|
|
11317
10908
|
}
|
|
11318
10909
|
html += '</div>';
|
|
11319
10910
|
} else if (itemType === 'header') {
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
groupIcon = deQuote(option[fields.icon] || className.groupIcon)
|
|
11323
|
-
;
|
|
10911
|
+
const groupName = option[fields.name] || '';
|
|
10912
|
+
const groupIcon = option[fields.icon] || className.groupIcon;
|
|
11324
10913
|
if (groupName !== '' || groupIcon !== '') {
|
|
11325
|
-
html += '<div class="' +
|
|
10914
|
+
html += '<div class="' + escape(option[fields.class] || className.header) + '">';
|
|
11326
10915
|
if (groupIcon !== '') {
|
|
11327
|
-
html += '<i class="' +
|
|
10916
|
+
html += '<i class="' + escape(groupIcon + ' ' + (option[fields.iconClass] || className.icon)) + '"></i>';
|
|
11328
10917
|
}
|
|
11329
|
-
html += groupName;
|
|
10918
|
+
html += escape(groupName, settings);
|
|
11330
10919
|
html += '</div>';
|
|
11331
10920
|
}
|
|
11332
10921
|
if (option[fields.divider]) {
|
|
11333
|
-
html += '<div class="' +
|
|
10922
|
+
html += '<div class="' + escape(className.divider) + '"></div>';
|
|
11334
10923
|
}
|
|
11335
10924
|
}
|
|
11336
10925
|
});
|
|
@@ -11339,13 +10928,11 @@
|
|
|
11339
10928
|
},
|
|
11340
10929
|
|
|
11341
10930
|
// generates label for multiselect
|
|
11342
|
-
label: function (value, text,
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
deQuote = $.fn.dropdown.settings.templates.deQuote
|
|
11346
|
-
;
|
|
10931
|
+
label: function (value, text, settings) {
|
|
10932
|
+
const className = settings.className;
|
|
10933
|
+
const escape = settings.templates.escape;
|
|
11347
10934
|
|
|
11348
|
-
return escape(text,
|
|
10935
|
+
return escape(text, settings) + '<i class="' + escape(className.delete) + ' icon"></i>';
|
|
11349
10936
|
},
|
|
11350
10937
|
|
|
11351
10938
|
// generates messages like "No results"
|
|
@@ -11353,7 +10940,7 @@
|
|
|
11353
10940
|
return message;
|
|
11354
10941
|
},
|
|
11355
10942
|
|
|
11356
|
-
// generates user addition to selection menu
|
|
10943
|
+
// generates user addition to the selection menu
|
|
11357
10944
|
addition: function (choice) {
|
|
11358
10945
|
return choice;
|
|
11359
10946
|
},
|