fomantic-ui 2.10.0-beta.62 → 2.10.0-beta.64
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/.eslintrc.js +0 -1
- package/changelog-setup.js +10 -10
- package/dist/components/accordion.css +1 -1
- package/dist/components/accordion.js +40 -41
- package/dist/components/accordion.min.css +1 -1
- package/dist/components/accordion.min.js +2 -2
- package/dist/components/ad.css +1 -1
- package/dist/components/ad.min.css +1 -1
- package/dist/components/api.js +57 -61
- package/dist/components/api.min.js +2 -2
- package/dist/components/breadcrumb.css +1 -1
- package/dist/components/breadcrumb.min.css +1 -1
- package/dist/components/button.css +1 -1
- package/dist/components/button.min.css +1 -1
- package/dist/components/calendar.css +1 -1
- package/dist/components/calendar.js +186 -187
- package/dist/components/calendar.min.css +1 -1
- package/dist/components/calendar.min.js +2 -2
- package/dist/components/card.css +1 -1
- package/dist/components/card.min.css +1 -1
- package/dist/components/checkbox.css +1 -1
- package/dist/components/checkbox.js +29 -30
- package/dist/components/checkbox.min.css +1 -1
- package/dist/components/checkbox.min.js +2 -2
- package/dist/components/comment.css +1 -1
- package/dist/components/comment.min.css +1 -1
- package/dist/components/container.css +1 -1
- package/dist/components/container.min.css +1 -1
- package/dist/components/dimmer.css +1 -1
- package/dist/components/dimmer.js +22 -23
- package/dist/components/dimmer.min.css +1 -1
- package/dist/components/dimmer.min.js +2 -2
- package/dist/components/divider.css +1 -1
- package/dist/components/divider.min.css +1 -1
- package/dist/components/dropdown.css +1 -1
- package/dist/components/dropdown.js +293 -337
- package/dist/components/dropdown.min.css +1 -1
- package/dist/components/dropdown.min.js +2 -2
- package/dist/components/embed.css +1 -1
- package/dist/components/embed.js +33 -35
- package/dist/components/embed.min.css +1 -1
- package/dist/components/embed.min.js +2 -2
- package/dist/components/emoji.css +1 -1
- package/dist/components/emoji.min.css +1 -1
- package/dist/components/feed.css +1 -1
- package/dist/components/feed.min.css +1 -1
- package/dist/components/flag.css +1 -1
- package/dist/components/flag.min.css +1 -1
- package/dist/components/flyout.css +1 -1
- package/dist/components/flyout.js +74 -81
- package/dist/components/flyout.min.css +1 -1
- package/dist/components/flyout.min.js +2 -2
- package/dist/components/form.css +1 -1
- package/dist/components/form.js +141 -146
- package/dist/components/form.min.css +1 -1
- package/dist/components/form.min.js +2 -2
- package/dist/components/grid.css +1 -1
- package/dist/components/grid.min.css +1 -1
- package/dist/components/header.css +1 -1
- package/dist/components/header.min.css +1 -1
- package/dist/components/icon.css +1 -1
- package/dist/components/icon.min.css +1 -1
- package/dist/components/image.css +1 -1
- package/dist/components/image.min.css +1 -1
- package/dist/components/input.css +1 -1
- package/dist/components/input.min.css +1 -1
- package/dist/components/item.css +1 -1
- package/dist/components/item.min.css +1 -1
- package/dist/components/label.css +1 -1
- package/dist/components/label.min.css +1 -1
- package/dist/components/list.css +1 -1
- package/dist/components/list.min.css +1 -1
- package/dist/components/loader.css +1 -1
- package/dist/components/loader.min.css +1 -1
- package/dist/components/menu.css +1 -1
- package/dist/components/menu.min.css +1 -1
- package/dist/components/message.css +1 -1
- package/dist/components/message.min.css +1 -1
- package/dist/components/modal.css +1 -1
- package/dist/components/modal.js +80 -81
- package/dist/components/modal.min.css +1 -1
- package/dist/components/modal.min.js +2 -2
- package/dist/components/nag.css +1 -1
- package/dist/components/nag.js +27 -28
- package/dist/components/nag.min.css +1 -1
- package/dist/components/nag.min.js +2 -2
- package/dist/components/placeholder.css +1 -1
- package/dist/components/placeholder.min.css +1 -1
- package/dist/components/popup.css +1 -1
- package/dist/components/popup.js +62 -72
- package/dist/components/popup.min.css +1 -1
- package/dist/components/popup.min.js +2 -2
- package/dist/components/progress.css +1 -1
- package/dist/components/progress.js +51 -55
- package/dist/components/progress.min.css +1 -1
- package/dist/components/progress.min.js +2 -2
- package/dist/components/rail.css +1 -1
- package/dist/components/rail.min.css +1 -1
- package/dist/components/rating.css +1 -1
- package/dist/components/rating.js +33 -34
- package/dist/components/rating.min.css +1 -1
- package/dist/components/rating.min.js +2 -2
- package/dist/components/reset.css +1 -1
- package/dist/components/reset.min.css +1 -1
- package/dist/components/reveal.css +1 -1
- package/dist/components/reveal.min.css +1 -1
- package/dist/components/search.css +1 -1
- package/dist/components/search.js +96 -109
- package/dist/components/search.min.css +1 -1
- package/dist/components/search.min.js +2 -2
- package/dist/components/segment.css +1 -1
- package/dist/components/segment.min.css +1 -1
- package/dist/components/shape.css +1 -1
- package/dist/components/shape.js +44 -45
- package/dist/components/shape.min.css +1 -1
- package/dist/components/shape.min.js +2 -2
- package/dist/components/sidebar.css +1 -1
- package/dist/components/sidebar.js +56 -64
- package/dist/components/sidebar.min.css +1 -1
- package/dist/components/sidebar.min.js +2 -2
- package/dist/components/site.css +1 -1
- package/dist/components/site.js +16 -17
- package/dist/components/site.min.css +1 -1
- package/dist/components/site.min.js +2 -2
- package/dist/components/slider.css +1 -1
- package/dist/components/slider.js +143 -148
- package/dist/components/slider.min.css +1 -1
- package/dist/components/slider.min.js +2 -2
- package/dist/components/state.js +24 -25
- package/dist/components/state.min.js +2 -2
- package/dist/components/statistic.css +1 -1
- package/dist/components/statistic.min.css +1 -1
- package/dist/components/step.css +1 -1
- package/dist/components/step.min.css +1 -1
- package/dist/components/sticky.css +1 -1
- package/dist/components/sticky.js +42 -43
- package/dist/components/sticky.min.css +1 -1
- package/dist/components/sticky.min.js +2 -2
- package/dist/components/tab.css +1 -1
- package/dist/components/tab.js +57 -66
- package/dist/components/tab.min.css +1 -1
- package/dist/components/tab.min.js +2 -2
- package/dist/components/table.css +1 -1
- package/dist/components/table.min.css +1 -1
- package/dist/components/text.css +1 -1
- package/dist/components/text.min.css +1 -1
- package/dist/components/toast.css +1 -1
- package/dist/components/toast.js +32 -33
- package/dist/components/toast.min.css +1 -1
- package/dist/components/toast.min.js +2 -2
- package/dist/components/transition.css +1 -1
- package/dist/components/transition.js +38 -45
- package/dist/components/transition.min.css +1 -1
- package/dist/components/transition.min.js +2 -2
- package/dist/components/visibility.js +76 -77
- package/dist/components/visibility.min.js +2 -2
- package/dist/semantic.css +53 -53
- package/dist/semantic.js +1753 -1884
- package/dist/semantic.min.css +1 -1
- package/dist/semantic.min.js +2 -2
- package/package.json +1 -1
- package/scripts/nightly-version.js +3 -3
- package/src/definitions/behaviors/api.js +56 -60
- package/src/definitions/behaviors/form.js +140 -145
- package/src/definitions/behaviors/state.js +23 -24
- package/src/definitions/behaviors/visibility.js +75 -76
- package/src/definitions/globals/site.js +15 -16
- package/src/definitions/modules/accordion.js +39 -40
- package/src/definitions/modules/calendar.js +185 -186
- package/src/definitions/modules/checkbox.js +28 -29
- package/src/definitions/modules/dimmer.js +21 -22
- package/src/definitions/modules/dropdown.js +292 -336
- package/src/definitions/modules/embed.js +32 -34
- package/src/definitions/modules/flyout.js +73 -80
- package/src/definitions/modules/modal.js +79 -80
- package/src/definitions/modules/nag.js +26 -27
- package/src/definitions/modules/popup.js +61 -71
- package/src/definitions/modules/progress.js +50 -54
- package/src/definitions/modules/rating.js +32 -33
- package/src/definitions/modules/search.js +95 -108
- package/src/definitions/modules/shape.js +43 -44
- package/src/definitions/modules/sidebar.js +55 -63
- package/src/definitions/modules/slider.js +142 -147
- package/src/definitions/modules/sticky.js +41 -42
- package/src/definitions/modules/tab.js +56 -65
- package/src/definitions/modules/toast.js +31 -32
- package/src/definitions/modules/transition.js +37 -44
- package/tasks/admin/components/create.js +11 -11
- package/tasks/admin/components/init.js +11 -12
- package/tasks/admin/components/update.js +19 -20
- package/tasks/admin/distributions/create.js +24 -36
- package/tasks/admin/distributions/init.js +11 -12
- package/tasks/admin/distributions/update.js +18 -19
- package/tasks/admin/register.js +7 -7
- package/tasks/build/assets.js +1 -1
- package/tasks/build/css.js +1 -1
- package/tasks/build/javascript.js +1 -1
- package/tasks/config/admin/github.js +1 -1
- package/tasks/config/admin/templates/css-package.js +1 -1
- package/tasks/config/admin/templates/less-package.js +1 -1
- package/tasks/config/project/config.js +6 -6
- package/tasks/config/project/install.js +12 -12
- package/tasks/config/project/release.js +5 -11
- package/tasks/config/tasks.js +5 -5
- package/tasks/config/user.js +1 -4
- package/tasks/docs/metadata.js +11 -12
- package/tasks/install.js +9 -9
- package/test/meteor/assets.js +1 -1
- package/test/modules/module.spec.js +18 -18
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* # Fomantic-UI 2.10.0-beta.
|
|
2
|
+
* # Fomantic-UI 2.10.0-beta.64+bcb9c73 - Dropdown
|
|
3
3
|
* https://github.com/fomantic/Fomantic-UI/
|
|
4
4
|
*
|
|
5
5
|
*
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
|
|
22
22
|
$.fn.dropdown = function (...args) {
|
|
23
23
|
let $allModules = $(this);
|
|
24
|
-
|
|
24
|
+
const $document = $(document);
|
|
25
25
|
|
|
26
26
|
let time = Date.now();
|
|
27
27
|
let performance = [];
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const parameters = args[0];
|
|
30
|
+
const methodInvoked = typeof parameters === 'string';
|
|
31
|
+
const queryArguments = args.slice(1);
|
|
32
|
+
const contextCheck = function (context, win) {
|
|
33
33
|
let $context;
|
|
34
34
|
if ([window, document].includes(context)) {
|
|
35
35
|
$context = $(context);
|
|
@@ -45,26 +45,26 @@
|
|
|
45
45
|
let returnedValue;
|
|
46
46
|
|
|
47
47
|
$allModules.each(function (elementIndex) {
|
|
48
|
-
|
|
48
|
+
const settings = $.isPlainObject(parameters)
|
|
49
49
|
? $.extend(true, {}, $.fn.dropdown.settings, parameters)
|
|
50
50
|
: $.extend({}, $.fn.dropdown.settings);
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
const className = settings.className;
|
|
53
|
+
const message = settings.message;
|
|
54
|
+
const fields = settings.fields;
|
|
55
|
+
const keys = settings.keys;
|
|
56
|
+
const metadata = settings.metadata;
|
|
57
|
+
const namespace = settings.namespace;
|
|
58
|
+
const regExp = settings.regExp;
|
|
59
|
+
const selector = settings.selector;
|
|
60
|
+
const error = settings.error;
|
|
61
|
+
const templates = settings.templates;
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
const eventNamespace = '.' + namespace;
|
|
64
|
+
const moduleNamespace = 'module-' + namespace;
|
|
65
65
|
|
|
66
66
|
let $module = $(this);
|
|
67
|
-
|
|
67
|
+
const $context = contextCheck(settings.context, window);
|
|
68
68
|
let $text = $module.find(selector.text);
|
|
69
69
|
let $search = $module.find(selector.search);
|
|
70
70
|
let $sizer = $module.find(selector.sizer);
|
|
@@ -99,10 +99,9 @@
|
|
|
99
99
|
let selectObserver;
|
|
100
100
|
let menuObserver;
|
|
101
101
|
let classObserver;
|
|
102
|
-
let module;
|
|
103
102
|
let tempDisableApiCache = false;
|
|
104
103
|
|
|
105
|
-
module = {
|
|
104
|
+
const module = {
|
|
106
105
|
|
|
107
106
|
initialize: function () {
|
|
108
107
|
module.debug('Initializing dropdown', settings);
|
|
@@ -251,7 +250,7 @@
|
|
|
251
250
|
return $userChoices;
|
|
252
251
|
},
|
|
253
252
|
userLabels: function (value) {
|
|
254
|
-
|
|
253
|
+
const userValues = module.get.userValues();
|
|
255
254
|
if (userValues) {
|
|
256
255
|
module.debug('Adding user labels', userValues);
|
|
257
256
|
$.each(userValues, function (index, value) {
|
|
@@ -272,10 +271,7 @@
|
|
|
272
271
|
},
|
|
273
272
|
},
|
|
274
273
|
|
|
275
|
-
search: function (query) {
|
|
276
|
-
query = query !== undefined
|
|
277
|
-
? query
|
|
278
|
-
: module.get.query();
|
|
274
|
+
search: function (query = module.get.query()) {
|
|
279
275
|
module.verbose('Searching for query', query);
|
|
280
276
|
if (settings.fireOnInit === false && module.is.initialLoad()) {
|
|
281
277
|
module.verbose('Skipping callback on initial load', settings.onSearch);
|
|
@@ -298,9 +294,9 @@
|
|
|
298
294
|
},
|
|
299
295
|
nextAvailable: function ($selected) {
|
|
300
296
|
$selected = $selected.eq(0);
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
297
|
+
const $nextAvailable = $selected.nextAll(selector.item).not(selector.unselectable).eq(0);
|
|
298
|
+
const $prevAvailable = $selected.prevAll(selector.item).not(selector.unselectable).eq(0);
|
|
299
|
+
const hasNext = $nextAvailable.length > 0;
|
|
304
300
|
if (hasNext) {
|
|
305
301
|
module.verbose('Moving selection to', $nextAvailable);
|
|
306
302
|
$nextAvailable.addClass(className.selected);
|
|
@@ -313,7 +309,7 @@
|
|
|
313
309
|
|
|
314
310
|
setup: {
|
|
315
311
|
api: function () {
|
|
316
|
-
|
|
312
|
+
const apiSettings = {
|
|
317
313
|
debug: settings.debug,
|
|
318
314
|
urlData: {
|
|
319
315
|
value: module.get.value(),
|
|
@@ -341,7 +337,7 @@
|
|
|
341
337
|
}
|
|
342
338
|
if (module.is.search() && !module.has.search()) {
|
|
343
339
|
module.verbose('Adding search input');
|
|
344
|
-
|
|
340
|
+
const labelNode = $module.prev('label');
|
|
345
341
|
$search = $('<input />')
|
|
346
342
|
.addClass(className.search)
|
|
347
343
|
.prop('autocomplete', module.is.chrome() ? 'fomantic-search' : 'off');
|
|
@@ -361,7 +357,7 @@
|
|
|
361
357
|
}
|
|
362
358
|
},
|
|
363
359
|
select: function () {
|
|
364
|
-
|
|
360
|
+
const selectValues = module.get.selectValues();
|
|
365
361
|
module.debug('Dropdown initialized on a select', selectValues);
|
|
366
362
|
if ($module.is('select')) {
|
|
367
363
|
$input = $module;
|
|
@@ -423,8 +419,8 @@
|
|
|
423
419
|
module.setup.returnedObject();
|
|
424
420
|
},
|
|
425
421
|
returnedObject: function () {
|
|
426
|
-
|
|
427
|
-
|
|
422
|
+
const $firstModules = $allModules.slice(0, elementIndex);
|
|
423
|
+
const $lastModules = $allModules.slice(elementIndex + 1);
|
|
428
424
|
// adjust all modules to use the correct reference
|
|
429
425
|
$allModules = $firstModules.add($module).add($lastModules);
|
|
430
426
|
},
|
|
@@ -536,11 +532,11 @@
|
|
|
536
532
|
});
|
|
537
533
|
// Hide submenus explicitly. On some browsers (esp. mobile), they will not automatically receive a
|
|
538
534
|
// mouseleave event
|
|
539
|
-
|
|
535
|
+
const $subMenu = $module.find(selector.menu);
|
|
540
536
|
if ($subMenu.length > 0) {
|
|
541
537
|
module.verbose('Hiding sub-menu', $subMenu);
|
|
542
538
|
$subMenu.each(function () {
|
|
543
|
-
|
|
539
|
+
const $sub = $(this);
|
|
544
540
|
if (!module.is.animating($sub)) {
|
|
545
541
|
module.animate.hide(false, $sub);
|
|
546
542
|
}
|
|
@@ -570,7 +566,7 @@
|
|
|
570
566
|
},
|
|
571
567
|
|
|
572
568
|
hideSubMenus: function () {
|
|
573
|
-
|
|
569
|
+
const $subMenus = $menu.children(selector.item).find(selector.menu);
|
|
574
570
|
module.verbose('Hiding sub menus', $subMenus);
|
|
575
571
|
$subMenus.transition('hide');
|
|
576
572
|
},
|
|
@@ -677,10 +673,10 @@
|
|
|
677
673
|
},
|
|
678
674
|
|
|
679
675
|
filter: function (query) {
|
|
680
|
-
|
|
676
|
+
const searchTerm = query !== undefined
|
|
681
677
|
? query
|
|
682
678
|
: module.get.query();
|
|
683
|
-
|
|
679
|
+
const afterFiltered = function () {
|
|
684
680
|
if (module.is.multiple()) {
|
|
685
681
|
module.filterActive();
|
|
686
682
|
}
|
|
@@ -762,7 +758,7 @@
|
|
|
762
758
|
query: query,
|
|
763
759
|
},
|
|
764
760
|
};
|
|
765
|
-
|
|
761
|
+
const apiCallbacks = {
|
|
766
762
|
onError: function (errorMessage, $module, xhr) {
|
|
767
763
|
module.add.message(message.serverError);
|
|
768
764
|
iconClicked = false;
|
|
@@ -787,14 +783,14 @@
|
|
|
787
783
|
values = [];
|
|
788
784
|
}
|
|
789
785
|
module.remove.message();
|
|
790
|
-
|
|
786
|
+
const menuConfig = {};
|
|
791
787
|
menuConfig[fields.values] = values;
|
|
792
788
|
module.setup.menu(menuConfig);
|
|
793
789
|
|
|
794
790
|
if (values.length === 0 && !settings.allowAdditions) {
|
|
795
791
|
module.add.message(message.noResults);
|
|
796
792
|
} else {
|
|
797
|
-
|
|
793
|
+
const value = module.is.multiple() ? module.get.values() : module.get.value();
|
|
798
794
|
if (value !== '') {
|
|
799
795
|
module.verbose('Value(s) present after click icon, select value(s) in items');
|
|
800
796
|
module.set.selected(value, null, true, true);
|
|
@@ -819,16 +815,16 @@
|
|
|
819
815
|
},
|
|
820
816
|
|
|
821
817
|
filterItems: function (query) {
|
|
822
|
-
|
|
818
|
+
const searchTerm = module.remove.diacritics(
|
|
823
819
|
query !== undefined
|
|
824
820
|
? query
|
|
825
821
|
: module.get.query()
|
|
826
822
|
);
|
|
827
823
|
let results = null;
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
824
|
+
const escapedTerm = module.escape.string(searchTerm);
|
|
825
|
+
const regExpIgnore = settings.ignoreSearchCase ? 'i' : '';
|
|
826
|
+
const regExpFlags = regExpIgnore + 'gm';
|
|
827
|
+
const beginsWithRegExp = new RegExp('^' + escapedTerm, regExpFlags);
|
|
832
828
|
module.remove.filteredItem();
|
|
833
829
|
// avoid loop if we're matching nothing
|
|
834
830
|
if (module.has.query()) {
|
|
@@ -837,7 +833,7 @@
|
|
|
837
833
|
module.verbose('Searching for matching values', searchTerm);
|
|
838
834
|
$item
|
|
839
835
|
.each(function () {
|
|
840
|
-
|
|
836
|
+
const $choice = $(this);
|
|
841
837
|
let text;
|
|
842
838
|
let value;
|
|
843
839
|
if ($choice.hasClass(className.unfilterable)) {
|
|
@@ -875,11 +871,11 @@
|
|
|
875
871
|
.not(results)
|
|
876
872
|
.addClass(className.filtered);
|
|
877
873
|
if (settings.highlightMatches && (settings.match === 'both' || settings.match === 'text')) {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
874
|
+
const querySplit = [...query];
|
|
875
|
+
const diacriticReg = settings.ignoreDiacritics ? '[\u0300-\u036F]?' : '';
|
|
876
|
+
const htmlReg = '(?![^<]*>)';
|
|
877
|
+
const markedRegExp = new RegExp(htmlReg + '(' + querySplit.join(diacriticReg + ')(.*?)' + htmlReg + '(') + diacriticReg + ')', regExpIgnore);
|
|
878
|
+
const markedReplacer = function (...args) {
|
|
883
879
|
args = args.slice(1, querySplit.length * 2).map(function (x, i) {
|
|
884
880
|
return i & 1 ? x : '<mark>' + x + '</mark>'; // eslint-disable-line no-bitwise
|
|
885
881
|
});
|
|
@@ -887,7 +883,7 @@
|
|
|
887
883
|
return args.join('');
|
|
888
884
|
};
|
|
889
885
|
$.each(results, function (index, result) {
|
|
890
|
-
|
|
886
|
+
const $result = $(result);
|
|
891
887
|
let markedHTML = module.get.choiceText($result, true);
|
|
892
888
|
if (settings.ignoreDiacritics) {
|
|
893
889
|
markedHTML = markedHTML.normalize('NFD');
|
|
@@ -909,7 +905,7 @@
|
|
|
909
905
|
.filter(function () {
|
|
910
906
|
// First find the last divider in this divider group
|
|
911
907
|
// Dividers which are direct siblings are considered a group
|
|
912
|
-
|
|
908
|
+
const $lastDivider = $(this).nextUntil(selector.item);
|
|
913
909
|
|
|
914
910
|
return ($lastDivider.length > 0 ? $lastDivider : $(this))
|
|
915
911
|
// Count all non-filtered items until the next divider (or end of the dropdown)
|
|
@@ -923,8 +919,8 @@
|
|
|
923
919
|
},
|
|
924
920
|
|
|
925
921
|
fuzzySearch: function (query, term) {
|
|
926
|
-
|
|
927
|
-
|
|
922
|
+
const termLength = term.length;
|
|
923
|
+
const queryLength = query.length;
|
|
928
924
|
if (settings.ignoreSearchCase) {
|
|
929
925
|
query = query.toLowerCase();
|
|
930
926
|
term = term.toLowerCase();
|
|
@@ -937,7 +933,7 @@
|
|
|
937
933
|
}
|
|
938
934
|
for (let characterIndex = 0, nextCharacterIndex = 0; characterIndex < queryLength; characterIndex++) {
|
|
939
935
|
let continueSearch = false;
|
|
940
|
-
|
|
936
|
+
const queryCharacter = query.codePointAt(characterIndex);
|
|
941
937
|
while (nextCharacterIndex < termLength) {
|
|
942
938
|
if (term.codePointAt(nextCharacterIndex++) === queryCharacter) {
|
|
943
939
|
continueSearch = true;
|
|
@@ -985,12 +981,12 @@
|
|
|
985
981
|
},
|
|
986
982
|
|
|
987
983
|
forceSelection: function () {
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
984
|
+
const $currentlySelected = $item.not(className.filtered).filter('.' + className.selected).eq(0);
|
|
985
|
+
const $activeItem = $item.not(className.filtered).filter('.' + className.active).eq(0);
|
|
986
|
+
const $selectedItem = $currentlySelected.length > 0
|
|
991
987
|
? $currentlySelected
|
|
992
988
|
: $activeItem;
|
|
993
|
-
|
|
989
|
+
const hasSelected = $selectedItem.length > 0;
|
|
994
990
|
if (settings.allowAdditions || (hasSelected && !module.is.multiple())) {
|
|
995
991
|
module.debug('Forcing partial selection to selected item', $selectedItem);
|
|
996
992
|
module.event.item.click.call($selectedItem, {}, true);
|
|
@@ -1005,13 +1001,13 @@
|
|
|
1005
1001
|
module.clear();
|
|
1006
1002
|
}
|
|
1007
1003
|
module.debug('Creating dropdown with specified values', values);
|
|
1008
|
-
|
|
1004
|
+
const menuConfig = {};
|
|
1009
1005
|
menuConfig[fields.values] = values;
|
|
1010
1006
|
module.setup.menu(menuConfig);
|
|
1011
|
-
|
|
1007
|
+
const findSelected = function (values) {
|
|
1012
1008
|
let hasMultiple = true;
|
|
1013
1009
|
$.each(values, function (index, item) {
|
|
1014
|
-
|
|
1010
|
+
const itemType = item.type || 'item';
|
|
1015
1011
|
if (item.selected === true) {
|
|
1016
1012
|
module.debug('Setting initial selection to', item[fields.value]);
|
|
1017
1013
|
module.set.selected(item[fields.value]);
|
|
@@ -1034,8 +1030,8 @@
|
|
|
1034
1030
|
$input.html('');
|
|
1035
1031
|
$input.append('<option disabled selected value></option>');
|
|
1036
1032
|
$.each(values, function (index, item) {
|
|
1037
|
-
|
|
1038
|
-
|
|
1033
|
+
const value = item[fields.value];
|
|
1034
|
+
const name = item[fields.name] || '';
|
|
1039
1035
|
$input.append('<option value="' + settings.templates.escape(value) + '"' + (item.selected === true ? ' selected' : '') + '>' + settings.templates.escape(name, settings) + '</option>');
|
|
1040
1036
|
});
|
|
1041
1037
|
module.observe.select();
|
|
@@ -1045,9 +1041,9 @@
|
|
|
1045
1041
|
|
|
1046
1042
|
event: {
|
|
1047
1043
|
paste: function (event) {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1044
|
+
const pasteValue = (event.originalEvent.clipboardData || window.clipboardData).getData('text');
|
|
1045
|
+
const tokens = pasteValue.split(settings.delimiter);
|
|
1046
|
+
const notFoundTokens = [];
|
|
1051
1047
|
tokens.forEach(function (value) {
|
|
1052
1048
|
value = value.trim();
|
|
1053
1049
|
const valueTrimmed = settings.preserveHTML
|
|
@@ -1059,12 +1055,12 @@
|
|
|
1059
1055
|
});
|
|
1060
1056
|
event.preventDefault();
|
|
1061
1057
|
if (notFoundTokens.length > 0) {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1058
|
+
const searchEl = $search[0];
|
|
1059
|
+
const startPos = searchEl.selectionStart;
|
|
1060
|
+
const endPos = searchEl.selectionEnd;
|
|
1061
|
+
const orgText = searchEl.value;
|
|
1062
|
+
const pasteText = notFoundTokens.join(settings.delimiter);
|
|
1063
|
+
const newEndPos = startPos + pasteText.length;
|
|
1068
1064
|
$search.val(orgText.slice(0, startPos) + pasteText + orgText.slice(endPos));
|
|
1069
1065
|
searchEl.selectionStart = newEndPos;
|
|
1070
1066
|
searchEl.selectionEnd = newEndPos;
|
|
@@ -1108,7 +1104,7 @@
|
|
|
1108
1104
|
}
|
|
1109
1105
|
},
|
|
1110
1106
|
click: function (event) {
|
|
1111
|
-
|
|
1107
|
+
const $target = $(event.target);
|
|
1112
1108
|
// focus search
|
|
1113
1109
|
if ($target.is($module)) {
|
|
1114
1110
|
if (!module.is.focusedOnSearch()) {
|
|
@@ -1190,12 +1186,12 @@
|
|
|
1190
1186
|
},
|
|
1191
1187
|
label: {
|
|
1192
1188
|
click: function (event) {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1189
|
+
const $label = $(this);
|
|
1190
|
+
const $labels = $module.find(selector.label);
|
|
1191
|
+
const $activeLabels = $labels.filter('.' + className.active);
|
|
1192
|
+
const $nextActive = $label.nextAll('.' + className.active);
|
|
1193
|
+
const $prevActive = $label.prevAll('.' + className.active);
|
|
1194
|
+
const $range = $nextActive.length > 0
|
|
1199
1195
|
? $label.nextUntil($nextActive).add($activeLabels).add($label)
|
|
1200
1196
|
: $label.prevUntil($prevActive).add($activeLabels).add($label);
|
|
1201
1197
|
if (event.shiftKey) {
|
|
@@ -1213,7 +1209,7 @@
|
|
|
1213
1209
|
},
|
|
1214
1210
|
remove: {
|
|
1215
1211
|
click: function (event) {
|
|
1216
|
-
|
|
1212
|
+
const $label = $(this).parent();
|
|
1217
1213
|
if ($label.hasClass(className.active)) {
|
|
1218
1214
|
// remove all selected labels
|
|
1219
1215
|
module.remove.activeLabels();
|
|
@@ -1226,7 +1222,7 @@
|
|
|
1226
1222
|
},
|
|
1227
1223
|
test: {
|
|
1228
1224
|
toggle: function (event) {
|
|
1229
|
-
|
|
1225
|
+
const toggleBehavior = module.is.multiple()
|
|
1230
1226
|
? module.show
|
|
1231
1227
|
: module.toggle;
|
|
1232
1228
|
if (module.is.bubbledLabelClick(event) || module.is.bubbledIconClick(event)) {
|
|
@@ -1270,16 +1266,16 @@
|
|
|
1270
1266
|
},
|
|
1271
1267
|
menu: {
|
|
1272
1268
|
mutation: function (mutations) {
|
|
1273
|
-
|
|
1274
|
-
|
|
1269
|
+
const mutation = mutations[0];
|
|
1270
|
+
const $addedNode = mutation.addedNodes
|
|
1275
1271
|
? $(mutation.addedNodes[0])
|
|
1276
1272
|
: $(false);
|
|
1277
|
-
|
|
1273
|
+
const $removedNode = mutation.removedNodes
|
|
1278
1274
|
? $(mutation.removedNodes[0])
|
|
1279
1275
|
: $(false);
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1276
|
+
const $changedNodes = $addedNode.add($removedNode);
|
|
1277
|
+
const isUserAddition = $changedNodes.is(selector.addition) || $changedNodes.closest(selector.addition).length > 0;
|
|
1278
|
+
const isMessage = $changedNodes.is(selector.message) || $changedNodes.closest(selector.message).length > 0;
|
|
1283
1279
|
if (isUserAddition || isMessage) {
|
|
1284
1280
|
module.debug('Updating item selector cache');
|
|
1285
1281
|
module.refreshItems();
|
|
@@ -1297,12 +1293,12 @@
|
|
|
1297
1293
|
},
|
|
1298
1294
|
item: {
|
|
1299
1295
|
mouseenter: function (event) {
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1296
|
+
const $target = $(event.target);
|
|
1297
|
+
const $item = $(this);
|
|
1298
|
+
const $subMenu = $item.children(selector.menu);
|
|
1299
|
+
const $otherMenus = $item.siblings(selector.item).children(selector.menu);
|
|
1300
|
+
const hasSubMenu = $subMenu.length > 0;
|
|
1301
|
+
const isBubbledEvent = $subMenu.find($target).length > 0;
|
|
1306
1302
|
if (!isBubbledEvent && hasSubMenu) {
|
|
1307
1303
|
clearTimeout(module.itemTimer);
|
|
1308
1304
|
module.itemTimer = setTimeout(function () {
|
|
@@ -1316,7 +1312,7 @@
|
|
|
1316
1312
|
}
|
|
1317
1313
|
},
|
|
1318
1314
|
mouseleave: function (event) {
|
|
1319
|
-
|
|
1315
|
+
const $subMenu = $(this).find(selector.menu);
|
|
1320
1316
|
if ($subMenu.length > 0) {
|
|
1321
1317
|
clearTimeout(module.itemTimer);
|
|
1322
1318
|
module.itemTimer = setTimeout(function () {
|
|
@@ -1328,15 +1324,15 @@
|
|
|
1328
1324
|
}
|
|
1329
1325
|
},
|
|
1330
1326
|
click: function (event, skipRefocus) {
|
|
1331
|
-
|
|
1332
|
-
|
|
1327
|
+
const $choice = $(this);
|
|
1328
|
+
const $target = event
|
|
1333
1329
|
? $(event.target || '')
|
|
1334
1330
|
: $('');
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1331
|
+
const $subMenu = $choice.find(selector.menu);
|
|
1332
|
+
const text = module.get.choiceText($choice);
|
|
1333
|
+
const value = module.get.choiceValue($choice, text);
|
|
1334
|
+
const hasSubMenu = $subMenu.length > 0;
|
|
1335
|
+
const isBubbledEvent = $subMenu.find($target).length > 0;
|
|
1340
1336
|
if (document.activeElement.tagName.toLowerCase() !== 'input') {
|
|
1341
1337
|
$(document.activeElement).trigger('blur');
|
|
1342
1338
|
}
|
|
@@ -1370,23 +1366,23 @@
|
|
|
1370
1366
|
document: {
|
|
1371
1367
|
// label selection should occur even when the element has no focus
|
|
1372
1368
|
keydown: function (event) {
|
|
1373
|
-
|
|
1374
|
-
|
|
1369
|
+
const pressedKey = event.which;
|
|
1370
|
+
const isShortcutKey = module.is.inObject(pressedKey, keys);
|
|
1375
1371
|
if (isShortcutKey) {
|
|
1376
|
-
|
|
1372
|
+
const $label = $module.find(selector.label);
|
|
1377
1373
|
let $activeLabel = $label.filter('.' + className.active);
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1374
|
+
const activeValue = $activeLabel.data(metadata.value);
|
|
1375
|
+
const labelIndex = $label.index($activeLabel);
|
|
1376
|
+
const labelCount = $label.length;
|
|
1377
|
+
const hasActiveLabel = $activeLabel.length > 0;
|
|
1378
|
+
const hasMultipleActive = $activeLabel.length > 1;
|
|
1379
|
+
const isFirstLabel = labelIndex === 0;
|
|
1380
|
+
const isLastLabel = labelIndex + 1 === labelCount;
|
|
1381
|
+
const isSearch = module.is.searchSelection();
|
|
1382
|
+
const isFocusedOnSearch = module.is.focusedOnSearch();
|
|
1383
|
+
const isFocused = module.is.focused();
|
|
1384
|
+
const caretAtStart = isFocusedOnSearch && module.get.caretPosition(false) === 0;
|
|
1385
|
+
const isSelectedSearch = caretAtStart && module.get.caretPosition(true) !== 0;
|
|
1390
1386
|
if (isSearch && !hasActiveLabel && !isFocusedOnSearch) {
|
|
1391
1387
|
return;
|
|
1392
1388
|
}
|
|
@@ -1483,24 +1479,24 @@
|
|
|
1483
1479
|
|
|
1484
1480
|
keydown: function (event) {
|
|
1485
1481
|
let pressedKey = event.which;
|
|
1486
|
-
|
|
1482
|
+
const isShortcutKey = module.is.inObject(pressedKey, keys) || event.key === settings.delimiter;
|
|
1487
1483
|
if (isShortcutKey) {
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1484
|
+
const $currentlySelected = $item.not(selector.unselectable).filter('.' + className.selected).eq(0);
|
|
1485
|
+
const $activeItem = $menu.children('.' + className.active).eq(0);
|
|
1486
|
+
const $selectedItem = $currentlySelected.length > 0
|
|
1491
1487
|
? $currentlySelected
|
|
1492
1488
|
: $activeItem;
|
|
1493
|
-
|
|
1489
|
+
const $visibleItems = $selectedItem.length > 0
|
|
1494
1490
|
? $selectedItem.siblings(':not(.' + className.filtered + ')').addBack()
|
|
1495
1491
|
: $menu.children(':not(.' + className.filtered + ')');
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1492
|
+
const $subMenu = $selectedItem.children(selector.menu);
|
|
1493
|
+
const $parentMenu = $selectedItem.closest(selector.menu);
|
|
1494
|
+
const inVisibleMenu = $parentMenu.hasClass(className.visible) || $parentMenu.hasClass(className.animating) || $parentMenu.parent(selector.menu).length > 0;
|
|
1495
|
+
const hasSubMenu = $subMenu.length > 0;
|
|
1496
|
+
const hasSelectedItem = $selectedItem.length > 0;
|
|
1497
|
+
const selectedIsSelectable = $selectedItem.not(selector.unselectable).length > 0;
|
|
1498
|
+
const delimiterPressed = event.key === settings.delimiter && module.is.multiple();
|
|
1499
|
+
const isAdditionWithoutMenu = settings.allowAdditions && (pressedKey === keys.enter || delimiterPressed);
|
|
1504
1500
|
let $nextItem;
|
|
1505
1501
|
let isSubMenuItem;
|
|
1506
1502
|
// allow selection with the menu closed
|
|
@@ -1656,9 +1652,9 @@
|
|
|
1656
1652
|
|
|
1657
1653
|
trigger: {
|
|
1658
1654
|
change: function () {
|
|
1659
|
-
|
|
1655
|
+
const inputElement = $input[0];
|
|
1660
1656
|
if (inputElement) {
|
|
1661
|
-
|
|
1657
|
+
const event = new Event('change', { bubbles: true });
|
|
1662
1658
|
module.verbose('Triggering native change event');
|
|
1663
1659
|
inputElement.dispatchEvent(event);
|
|
1664
1660
|
}
|
|
@@ -1681,9 +1677,9 @@
|
|
|
1681
1677
|
selectActionActive = false;
|
|
1682
1678
|
},
|
|
1683
1679
|
eventInModule: function (event, callback) {
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1680
|
+
const $target = $(event.target);
|
|
1681
|
+
const inDocument = $target.closest(document.documentElement).length > 0;
|
|
1682
|
+
const inModule = $target.closest($module).length > 0;
|
|
1687
1683
|
callback = isFunction(callback)
|
|
1688
1684
|
? callback
|
|
1689
1685
|
: function () {};
|
|
@@ -1699,11 +1695,11 @@
|
|
|
1699
1695
|
return false;
|
|
1700
1696
|
},
|
|
1701
1697
|
eventOnElement: function (event, callback) {
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1698
|
+
const $target = $(event.target);
|
|
1699
|
+
const $label = $target.closest(selector.siblingLabel);
|
|
1700
|
+
const inVisibleDOM = document.body.contains(event.target);
|
|
1701
|
+
const notOnLabel = $module.find($label).length === 0 || !(module.is.multiple() && settings.useLabels);
|
|
1702
|
+
const notInMenu = $target.closest($menu).length === 0;
|
|
1707
1703
|
callback = isFunction(callback)
|
|
1708
1704
|
? callback
|
|
1709
1705
|
: function () {};
|
|
@@ -1724,10 +1720,7 @@
|
|
|
1724
1720
|
|
|
1725
1721
|
nothing: function () {},
|
|
1726
1722
|
|
|
1727
|
-
activate: function (text, value, element) {
|
|
1728
|
-
value = value !== undefined
|
|
1729
|
-
? value
|
|
1730
|
-
: text;
|
|
1723
|
+
activate: function (text, value = text, element = '') {
|
|
1731
1724
|
if (module.can.activate($(element))) {
|
|
1732
1725
|
module.set.selected(value, $(element), false, settings.keepSearchTerm);
|
|
1733
1726
|
if (!module.is.multiple() && !(!settings.collapseOnActionable && $(element).hasClass(className.actionable))) {
|
|
@@ -1736,10 +1729,7 @@
|
|
|
1736
1729
|
}
|
|
1737
1730
|
},
|
|
1738
1731
|
|
|
1739
|
-
select: function (text, value, element) {
|
|
1740
|
-
value = value !== undefined
|
|
1741
|
-
? value
|
|
1742
|
-
: text;
|
|
1732
|
+
select: function (text, value = text, element = '') {
|
|
1743
1733
|
if (module.can.activate($(element))) {
|
|
1744
1734
|
module.set.value(value, text, $(element));
|
|
1745
1735
|
if (!module.is.multiple() && !(!settings.collapseOnActionable && $(element).hasClass(className.actionable))) {
|
|
@@ -1748,10 +1738,7 @@
|
|
|
1748
1738
|
}
|
|
1749
1739
|
},
|
|
1750
1740
|
|
|
1751
|
-
combo: function (text, value, element) {
|
|
1752
|
-
value = value !== undefined
|
|
1753
|
-
? value
|
|
1754
|
-
: text;
|
|
1741
|
+
combo: function (text, value = text, element = '') {
|
|
1755
1742
|
module.set.selected(value, $(element));
|
|
1756
1743
|
module.hideAndClear();
|
|
1757
1744
|
},
|
|
@@ -1788,23 +1775,18 @@
|
|
|
1788
1775
|
query: function () {
|
|
1789
1776
|
return String($search.val()).trim();
|
|
1790
1777
|
},
|
|
1791
|
-
searchWidth: function (value) {
|
|
1792
|
-
value = value !== undefined
|
|
1793
|
-
? value
|
|
1794
|
-
: $search.val();
|
|
1778
|
+
searchWidth: function (value = $search.val()) {
|
|
1795
1779
|
$sizer.text(value);
|
|
1796
1780
|
|
|
1797
1781
|
// prevent rounding issues
|
|
1798
1782
|
return Math.ceil($sizer.width() + 1);
|
|
1799
1783
|
},
|
|
1800
1784
|
selectionCount: function () {
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1785
|
+
const values = module.get.values();
|
|
1786
|
+
|
|
1787
|
+
return module.is.multiple()
|
|
1804
1788
|
? (Array.isArray(values) ? values.length : 0)
|
|
1805
1789
|
: (module.get.value() !== '' ? 1 : 0);
|
|
1806
|
-
|
|
1807
|
-
return count;
|
|
1808
1790
|
},
|
|
1809
1791
|
transition: function ($subMenu) {
|
|
1810
1792
|
return settings.transition === 'auto'
|
|
@@ -1828,7 +1810,7 @@
|
|
|
1828
1810
|
return [...new Set(array)];
|
|
1829
1811
|
},
|
|
1830
1812
|
caretPosition: function (returnEndPos) {
|
|
1831
|
-
|
|
1813
|
+
const input = $search[0];
|
|
1832
1814
|
let range;
|
|
1833
1815
|
let rangeLength;
|
|
1834
1816
|
if (returnEndPos && 'selectionEnd' in input) {
|
|
@@ -1850,10 +1832,10 @@
|
|
|
1850
1832
|
}
|
|
1851
1833
|
},
|
|
1852
1834
|
value: function () {
|
|
1853
|
-
|
|
1835
|
+
const value = $input.length > 0
|
|
1854
1836
|
? $input.val()
|
|
1855
1837
|
: $module.data(metadata.value);
|
|
1856
|
-
|
|
1838
|
+
const isEmptyMultiselect = Array.isArray(value) && value.length === 1 && value[0] === '';
|
|
1857
1839
|
|
|
1858
1840
|
// prevents the placeholder element from being selected when multiple
|
|
1859
1841
|
return value === undefined || isEmptyMultiselect
|
|
@@ -1861,7 +1843,7 @@
|
|
|
1861
1843
|
: value;
|
|
1862
1844
|
},
|
|
1863
1845
|
values: function () {
|
|
1864
|
-
|
|
1846
|
+
const value = module.get.value();
|
|
1865
1847
|
if (value === '') {
|
|
1866
1848
|
return '';
|
|
1867
1849
|
}
|
|
@@ -1880,7 +1862,7 @@
|
|
|
1880
1862
|
values = [values];
|
|
1881
1863
|
}
|
|
1882
1864
|
$.each(values, function (index, value) {
|
|
1883
|
-
|
|
1865
|
+
const name = module.read.remoteData(value);
|
|
1884
1866
|
module.verbose('Restoring value from session data', name, value);
|
|
1885
1867
|
if (name) {
|
|
1886
1868
|
if (!remoteValues) {
|
|
@@ -1893,10 +1875,7 @@
|
|
|
1893
1875
|
|
|
1894
1876
|
return remoteValues;
|
|
1895
1877
|
},
|
|
1896
|
-
choiceText: function ($choice, preserveHTML) {
|
|
1897
|
-
preserveHTML = preserveHTML !== undefined
|
|
1898
|
-
? preserveHTML
|
|
1899
|
-
: settings.preserveHTML;
|
|
1878
|
+
choiceText: function ($choice, preserveHTML = settings.preserveHTML) {
|
|
1900
1879
|
if ($choice) {
|
|
1901
1880
|
if ($choice.find(selector.menu).length > 0) {
|
|
1902
1881
|
module.verbose('Retrieving text of element with sub-menu');
|
|
@@ -1928,7 +1907,7 @@
|
|
|
1928
1907
|
: String(choiceText));
|
|
1929
1908
|
},
|
|
1930
1909
|
inputEvent: function () {
|
|
1931
|
-
|
|
1910
|
+
const input = $search[0];
|
|
1932
1911
|
if (input) {
|
|
1933
1912
|
return input.oninput !== undefined
|
|
1934
1913
|
? 'input'
|
|
@@ -1940,22 +1919,22 @@
|
|
|
1940
1919
|
return false;
|
|
1941
1920
|
},
|
|
1942
1921
|
selectValues: function () {
|
|
1943
|
-
|
|
1922
|
+
const select = {};
|
|
1944
1923
|
let oldGroup = [];
|
|
1945
|
-
|
|
1924
|
+
const values = [];
|
|
1946
1925
|
$module
|
|
1947
1926
|
.find('option')
|
|
1948
1927
|
.each(function () {
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1928
|
+
const $option = $(this);
|
|
1929
|
+
const name = module.escape.assumeUnescapedAmpLtGt($option.html());
|
|
1930
|
+
const disabled = $option.attr('disabled');
|
|
1931
|
+
const value = $option.attr('value') !== undefined
|
|
1953
1932
|
? $option.attr('value')
|
|
1954
1933
|
: name;
|
|
1955
|
-
|
|
1934
|
+
const text = $option.data(metadata.text) !== undefined
|
|
1956
1935
|
? $option.data(metadata.text)
|
|
1957
1936
|
: name;
|
|
1958
|
-
|
|
1937
|
+
const group = $option.parent('optgroup');
|
|
1959
1938
|
if (settings.placeholder === 'auto' && value === '') {
|
|
1960
1939
|
select.placeholder = name;
|
|
1961
1940
|
} else {
|
|
@@ -2004,7 +1983,7 @@
|
|
|
2004
1983
|
return $item.filter('.' + className.active);
|
|
2005
1984
|
},
|
|
2006
1985
|
selectedItem: function () {
|
|
2007
|
-
|
|
1986
|
+
const $selectedItem = $item.not(selector.unselectable).filter('.' + className.selected);
|
|
2008
1987
|
|
|
2009
1988
|
return $selectedItem.length > 0
|
|
2010
1989
|
? $selectedItem
|
|
@@ -2012,8 +1991,8 @@
|
|
|
2012
1991
|
},
|
|
2013
1992
|
itemWithAdditions: function (value) {
|
|
2014
1993
|
let $items = module.get.item(value);
|
|
2015
|
-
|
|
2016
|
-
|
|
1994
|
+
const $userItems = module.create.userChoice(value);
|
|
1995
|
+
const hasUserItems = $userItems && $userItems.length > 0;
|
|
2017
1996
|
if (hasUserItems) {
|
|
2018
1997
|
$items = $items.length > 0
|
|
2019
1998
|
? $items.add($userItems)
|
|
@@ -2024,15 +2003,13 @@
|
|
|
2024
2003
|
},
|
|
2025
2004
|
item: function (value, strict) {
|
|
2026
2005
|
let $selectedItem = false;
|
|
2027
|
-
let shouldSearch;
|
|
2028
|
-
let isMultiple;
|
|
2029
2006
|
value = value !== undefined
|
|
2030
2007
|
? value
|
|
2031
2008
|
: (module.get.values() !== undefined
|
|
2032
2009
|
? module.get.values()
|
|
2033
2010
|
: module.get.text());
|
|
2034
|
-
isMultiple = module.is.multiple() && Array.isArray(value);
|
|
2035
|
-
shouldSearch = isMultiple
|
|
2011
|
+
const isMultiple = module.is.multiple() && Array.isArray(value);
|
|
2012
|
+
const shouldSearch = isMultiple
|
|
2036
2013
|
? value.length > 0
|
|
2037
2014
|
: value !== undefined && value !== null;
|
|
2038
2015
|
strict = value === '' || value === false || value === true
|
|
@@ -2041,8 +2018,8 @@
|
|
|
2041
2018
|
if (shouldSearch) {
|
|
2042
2019
|
$item
|
|
2043
2020
|
.each(function () {
|
|
2044
|
-
|
|
2045
|
-
|
|
2021
|
+
const $choice = $(this);
|
|
2022
|
+
const optionText = module.get.choiceText($choice);
|
|
2046
2023
|
let optionValue = module.get.choiceValue($choice, optionText);
|
|
2047
2024
|
// safe early exit
|
|
2048
2025
|
if (optionValue === null || optionValue === undefined) {
|
|
@@ -2084,11 +2061,8 @@
|
|
|
2084
2061
|
},
|
|
2085
2062
|
|
|
2086
2063
|
check: {
|
|
2087
|
-
maxSelections: function (selectionCount) {
|
|
2064
|
+
maxSelections: function (selectionCount = module.get.selectionCount()) {
|
|
2088
2065
|
if (settings.maxSelections) {
|
|
2089
|
-
selectionCount = selectionCount !== undefined
|
|
2090
|
-
? selectionCount
|
|
2091
|
-
: module.get.selectionCount();
|
|
2092
2066
|
if (selectionCount >= settings.maxSelections) {
|
|
2093
2067
|
module.debug('Maximum selection count reached');
|
|
2094
2068
|
if (settings.useLabels) {
|
|
@@ -2123,8 +2097,8 @@
|
|
|
2123
2097
|
module.restore.defaultValue();
|
|
2124
2098
|
},
|
|
2125
2099
|
defaultText: function () {
|
|
2126
|
-
|
|
2127
|
-
|
|
2100
|
+
const defaultText = module.get.defaultText();
|
|
2101
|
+
const placeholderText = module.get.placeholderText;
|
|
2128
2102
|
if (defaultText === placeholderText) {
|
|
2129
2103
|
module.debug('Restoring default placeholder text', defaultText);
|
|
2130
2104
|
module.set.placeholderText(defaultText);
|
|
@@ -2137,7 +2111,7 @@
|
|
|
2137
2111
|
module.set.placeholderText();
|
|
2138
2112
|
},
|
|
2139
2113
|
defaultValue: function () {
|
|
2140
|
-
|
|
2114
|
+
const defaultValue = module.get.defaultValue();
|
|
2141
2115
|
if (defaultValue !== undefined) {
|
|
2142
2116
|
module.debug('Restoring default value', defaultValue);
|
|
2143
2117
|
if (defaultValue !== '') {
|
|
@@ -2177,7 +2151,7 @@
|
|
|
2177
2151
|
} else {
|
|
2178
2152
|
module.set.selected();
|
|
2179
2153
|
}
|
|
2180
|
-
|
|
2154
|
+
const value = module.get.value();
|
|
2181
2155
|
if (value && value !== '' && !(Array.isArray(value) && value.length === 0)) {
|
|
2182
2156
|
$input.removeClass(className.noselection);
|
|
2183
2157
|
} else {
|
|
@@ -2186,7 +2160,7 @@
|
|
|
2186
2160
|
module.remove.initialLoad();
|
|
2187
2161
|
},
|
|
2188
2162
|
remoteValues: function () {
|
|
2189
|
-
|
|
2163
|
+
const values = module.get.remoteValues();
|
|
2190
2164
|
module.debug('Recreating selected from session data', values);
|
|
2191
2165
|
if (values) {
|
|
2192
2166
|
if (module.is.single()) {
|
|
@@ -2204,7 +2178,7 @@
|
|
|
2204
2178
|
|
|
2205
2179
|
read: {
|
|
2206
2180
|
remoteData: function (value) {
|
|
2207
|
-
|
|
2181
|
+
const name = window.sessionStorage.getItem(value + elementNamespace);
|
|
2208
2182
|
|
|
2209
2183
|
return name !== undefined
|
|
2210
2184
|
? name
|
|
@@ -2219,12 +2193,12 @@
|
|
|
2219
2193
|
module.save.defaultValue();
|
|
2220
2194
|
},
|
|
2221
2195
|
defaultValue: function () {
|
|
2222
|
-
|
|
2196
|
+
const value = module.get.value();
|
|
2223
2197
|
module.verbose('Saving default value as', value);
|
|
2224
2198
|
$module.data(metadata.defaultValue, value);
|
|
2225
2199
|
},
|
|
2226
2200
|
defaultText: function () {
|
|
2227
|
-
|
|
2201
|
+
const text = module.get.text();
|
|
2228
2202
|
module.verbose('Saving default text as', text);
|
|
2229
2203
|
$module.data(metadata.defaultText, text);
|
|
2230
2204
|
},
|
|
@@ -2264,26 +2238,23 @@
|
|
|
2264
2238
|
},
|
|
2265
2239
|
|
|
2266
2240
|
scrollPage: function (direction, $selectedItem) {
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2241
|
+
const $currentItem = $selectedItem || module.get.selectedItem();
|
|
2242
|
+
const $menu = $currentItem.closest(selector.menu);
|
|
2243
|
+
const menuHeight = $menu.outerHeight();
|
|
2244
|
+
const currentScroll = $menu.scrollTop();
|
|
2245
|
+
const itemHeight = $item.eq(0).outerHeight();
|
|
2246
|
+
const itemsPerPage = Math.floor(menuHeight / itemHeight);
|
|
2247
|
+
const newScroll = direction === 'up'
|
|
2274
2248
|
? currentScroll - (itemHeight * itemsPerPage)
|
|
2275
2249
|
: currentScroll + (itemHeight * itemsPerPage);
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
let $nextSelectedItem;
|
|
2279
|
-
let elementIndex;
|
|
2280
|
-
elementIndex = direction === 'up'
|
|
2250
|
+
const $selectableItem = $item.not(selector.unselectable);
|
|
2251
|
+
const elementIndex = direction === 'up'
|
|
2281
2252
|
? $selectableItem.index($currentItem) - itemsPerPage
|
|
2282
2253
|
: $selectableItem.index($currentItem) + itemsPerPage;
|
|
2283
|
-
isWithinRange = direction === 'up'
|
|
2254
|
+
const isWithinRange = direction === 'up'
|
|
2284
2255
|
? elementIndex >= 0
|
|
2285
2256
|
: elementIndex < $selectableItem.length;
|
|
2286
|
-
$nextSelectedItem = isWithinRange
|
|
2257
|
+
const $nextSelectedItem = isWithinRange
|
|
2287
2258
|
? $selectableItem.eq(elementIndex)
|
|
2288
2259
|
: (direction === 'up'
|
|
2289
2260
|
? $selectableItem.first()
|
|
@@ -2304,15 +2275,15 @@
|
|
|
2304
2275
|
|
|
2305
2276
|
set: {
|
|
2306
2277
|
filtered: function () {
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2278
|
+
const isMultiple = module.is.multiple();
|
|
2279
|
+
const isSearch = module.is.searchSelection();
|
|
2280
|
+
const isSearchMultiple = isMultiple && isSearch;
|
|
2281
|
+
const searchValue = isSearch
|
|
2311
2282
|
? module.get.query()
|
|
2312
2283
|
: '';
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2284
|
+
const hasSearchValue = typeof searchValue === 'string' && searchValue.length > 0;
|
|
2285
|
+
const searchWidth = module.get.searchWidth();
|
|
2286
|
+
const valueIsSet = searchValue !== '';
|
|
2316
2287
|
if (isMultiple && hasSearchValue) {
|
|
2317
2288
|
module.verbose('Adjusting input width', searchWidth);
|
|
2318
2289
|
$search.css('width', searchWidth + 'px');
|
|
@@ -2367,13 +2338,11 @@
|
|
|
2367
2338
|
}
|
|
2368
2339
|
},
|
|
2369
2340
|
partialSearch: function (text) {
|
|
2370
|
-
|
|
2341
|
+
const length = module.get.query().length;
|
|
2371
2342
|
$search.val(text.slice(0, length));
|
|
2372
2343
|
},
|
|
2373
|
-
scrollPosition: function ($item, forceScroll) {
|
|
2374
|
-
|
|
2375
|
-
let $menu;
|
|
2376
|
-
let hasActive;
|
|
2344
|
+
scrollPosition: function ($item, forceScroll = false) {
|
|
2345
|
+
const edgeTolerance = 5;
|
|
2377
2346
|
let offset;
|
|
2378
2347
|
let itemOffset;
|
|
2379
2348
|
let menuOffset;
|
|
@@ -2383,11 +2352,8 @@
|
|
|
2383
2352
|
let belowPage;
|
|
2384
2353
|
|
|
2385
2354
|
$item = $item || module.get.selectedItem();
|
|
2386
|
-
$menu = $item.closest(selector.menu);
|
|
2387
|
-
hasActive = $item && $item.length > 0;
|
|
2388
|
-
forceScroll = forceScroll !== undefined
|
|
2389
|
-
? forceScroll
|
|
2390
|
-
: false;
|
|
2355
|
+
const $menu = $item.closest(selector.menu);
|
|
2356
|
+
const hasActive = $item && $item.length > 0;
|
|
2391
2357
|
if (module.get.activeItem().length === 0) {
|
|
2392
2358
|
forceScroll = false;
|
|
2393
2359
|
}
|
|
@@ -2434,9 +2400,9 @@
|
|
|
2434
2400
|
}
|
|
2435
2401
|
},
|
|
2436
2402
|
selectedItem: function ($item) {
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2403
|
+
const value = module.get.choiceValue($item);
|
|
2404
|
+
const searchText = module.get.choiceText($item, false);
|
|
2405
|
+
const text = module.get.choiceText($item);
|
|
2440
2406
|
module.debug('Setting user selection to item', $item);
|
|
2441
2407
|
module.remove.activeItem();
|
|
2442
2408
|
module.set.partialSearch(searchText);
|
|
@@ -2445,8 +2411,8 @@
|
|
|
2445
2411
|
module.set.text(text);
|
|
2446
2412
|
},
|
|
2447
2413
|
selectedLetter: function (letter) {
|
|
2448
|
-
|
|
2449
|
-
|
|
2414
|
+
const $selectedItem = $item.filter('.' + className.selected);
|
|
2415
|
+
const alreadySelectedLetter = $selectedItem.length > 0 && module.has.firstLetter($selectedItem, letter);
|
|
2450
2416
|
let $nextValue = false;
|
|
2451
2417
|
let $nextItem;
|
|
2452
2418
|
// check next of the same letter
|
|
@@ -2501,11 +2467,11 @@
|
|
|
2501
2467
|
}
|
|
2502
2468
|
},
|
|
2503
2469
|
upward: function ($currentMenu) {
|
|
2504
|
-
|
|
2470
|
+
const $element = $currentMenu || $module;
|
|
2505
2471
|
$element.addClass(className.upward);
|
|
2506
2472
|
},
|
|
2507
2473
|
leftward: function ($currentMenu) {
|
|
2508
|
-
|
|
2474
|
+
const $element = $currentMenu || $menu;
|
|
2509
2475
|
$element.addClass(className.leftward);
|
|
2510
2476
|
},
|
|
2511
2477
|
value: function (value, text, $selected, preventChangeTrigger) {
|
|
@@ -2519,9 +2485,9 @@
|
|
|
2519
2485
|
} else {
|
|
2520
2486
|
$input.addClass(className.noselection);
|
|
2521
2487
|
}
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2488
|
+
const hasInput = $input.length > 0;
|
|
2489
|
+
const currentValue = module.get.values();
|
|
2490
|
+
const stringValue = value !== undefined
|
|
2525
2491
|
? String(value)
|
|
2526
2492
|
: value;
|
|
2527
2493
|
if (hasInput) {
|
|
@@ -2583,7 +2549,7 @@
|
|
|
2583
2549
|
preventChangeTrigger = $selectedItem;
|
|
2584
2550
|
$selectedItem = undefined;
|
|
2585
2551
|
}
|
|
2586
|
-
|
|
2552
|
+
const isMultiple = module.is.multiple();
|
|
2587
2553
|
$selectedItem = settings.allowAdditions
|
|
2588
2554
|
? $selectedItem || module.get.itemWithAdditions(value)
|
|
2589
2555
|
: $selectedItem || module.get.item(value);
|
|
@@ -2597,7 +2563,7 @@
|
|
|
2597
2563
|
if (settings.useLabels) {
|
|
2598
2564
|
module.remove.selectedItem();
|
|
2599
2565
|
if (value === undefined) {
|
|
2600
|
-
|
|
2566
|
+
const existingLabels = $module.find(selector.label);
|
|
2601
2567
|
if (existingLabels.length > 0) {
|
|
2602
2568
|
preventChangeTrigger = true;
|
|
2603
2569
|
module.remove.labels(existingLabels, true);
|
|
@@ -2615,15 +2581,15 @@
|
|
|
2615
2581
|
// select each item
|
|
2616
2582
|
$selectedItem
|
|
2617
2583
|
.each(function () {
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2584
|
+
const $selected = $(this);
|
|
2585
|
+
const selectedText = module.get.choiceText($selected);
|
|
2586
|
+
const selectedValue = module.get.choiceValue($selected, selectedText);
|
|
2587
|
+
|
|
2588
|
+
const isFiltered = $selected.hasClass(className.filtered);
|
|
2589
|
+
const isActive = $selected.hasClass(className.active);
|
|
2590
|
+
const isActionable = $selected.hasClass(className.actionable);
|
|
2591
|
+
const isUserValue = $selected.hasClass(className.addition);
|
|
2592
|
+
const shouldAnimate = isMultiple && $selectedItem && $selectedItem.length === 1;
|
|
2627
2593
|
if (isActionable) {
|
|
2628
2594
|
if ((!isMultiple || (!isActive || isUserValue)) && settings.apiSettings && settings.saveRemoteData) {
|
|
2629
2595
|
module.save.remoteData(selectedText, selectedValue);
|
|
@@ -2674,7 +2640,7 @@
|
|
|
2674
2640
|
|
|
2675
2641
|
add: {
|
|
2676
2642
|
label: function (value, text, shouldAnimate) {
|
|
2677
|
-
|
|
2643
|
+
const $next = module.is.searchSelection()
|
|
2678
2644
|
? $search
|
|
2679
2645
|
: $text;
|
|
2680
2646
|
let $label;
|
|
@@ -2714,8 +2680,8 @@
|
|
|
2714
2680
|
}
|
|
2715
2681
|
},
|
|
2716
2682
|
message: function (message) {
|
|
2717
|
-
|
|
2718
|
-
|
|
2683
|
+
const $message = $menu.children(selector.message);
|
|
2684
|
+
const html = settings.templates.message(module.add.variables(message));
|
|
2719
2685
|
if ($message.length > 0) {
|
|
2720
2686
|
$message
|
|
2721
2687
|
.html(html);
|
|
@@ -2727,8 +2693,8 @@
|
|
|
2727
2693
|
}
|
|
2728
2694
|
},
|
|
2729
2695
|
optionValue: function (value) {
|
|
2730
|
-
|
|
2731
|
-
|
|
2696
|
+
const $option = $input.find('option[value="' + CSS.escape(value) + '"]');
|
|
2697
|
+
const hasOption = $option.length > 0;
|
|
2732
2698
|
if (hasOption) {
|
|
2733
2699
|
return;
|
|
2734
2700
|
}
|
|
@@ -2748,9 +2714,9 @@
|
|
|
2748
2714
|
},
|
|
2749
2715
|
userSuggestion: function (value) {
|
|
2750
2716
|
let $addition = $menu.children(selector.addition);
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2717
|
+
const $existingItem = module.get.item(value);
|
|
2718
|
+
const alreadyHasValue = $existingItem && $existingItem.not(selector.addition).length > 0;
|
|
2719
|
+
const hasUserSuggestion = $addition.length > 0;
|
|
2754
2720
|
let html;
|
|
2755
2721
|
if (settings.useLabels && module.has.maxSelections()) {
|
|
2756
2722
|
return;
|
|
@@ -2788,9 +2754,9 @@
|
|
|
2788
2754
|
module.refreshItems();
|
|
2789
2755
|
},
|
|
2790
2756
|
variables: function (message = '', term = module.get.query()) {
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2757
|
+
const hasCount = message.search('{count}') !== -1;
|
|
2758
|
+
const hasMaxCount = message.search('{maxCount}') !== -1;
|
|
2759
|
+
const hasTerm = message.search('{term}') !== -1;
|
|
2794
2760
|
module.verbose('Adding templated variables to message', message);
|
|
2795
2761
|
if (hasCount) {
|
|
2796
2762
|
message = message.replace('{count}', module.get.selectionCount());
|
|
@@ -2810,7 +2776,7 @@
|
|
|
2810
2776
|
$selectedItem = undefined;
|
|
2811
2777
|
addedText = undefined;
|
|
2812
2778
|
}
|
|
2813
|
-
|
|
2779
|
+
const currentValue = module.get.values();
|
|
2814
2780
|
let newValue;
|
|
2815
2781
|
if (module.has.value(addedValue)) {
|
|
2816
2782
|
module.debug('Value already selected');
|
|
@@ -2869,11 +2835,11 @@
|
|
|
2869
2835
|
initialLoad = false;
|
|
2870
2836
|
},
|
|
2871
2837
|
upward: function ($currentMenu) {
|
|
2872
|
-
|
|
2838
|
+
const $element = $currentMenu || $module;
|
|
2873
2839
|
$element.removeClass(className.upward);
|
|
2874
2840
|
},
|
|
2875
2841
|
leftward: function ($currentMenu) {
|
|
2876
|
-
|
|
2842
|
+
const $element = $currentMenu || $menu;
|
|
2877
2843
|
$element.removeClass(className.leftward);
|
|
2878
2844
|
},
|
|
2879
2845
|
visible: function () {
|
|
@@ -2885,7 +2851,7 @@
|
|
|
2885
2851
|
filteredItem: function () {
|
|
2886
2852
|
if (settings.highlightMatches) {
|
|
2887
2853
|
$.each($item, function (index, item) {
|
|
2888
|
-
|
|
2854
|
+
const $markItem = $(item);
|
|
2889
2855
|
$markItem.html($markItem.html().replace(/<\/?mark>/g, ''));
|
|
2890
2856
|
});
|
|
2891
2857
|
}
|
|
@@ -2903,8 +2869,8 @@
|
|
|
2903
2869
|
module.remove.empty();
|
|
2904
2870
|
},
|
|
2905
2871
|
optionValue: function (value) {
|
|
2906
|
-
|
|
2907
|
-
|
|
2872
|
+
const $option = $input.find('option[value="' + CSS.escape(value) + '"]');
|
|
2873
|
+
const hasOption = $option.length > 0;
|
|
2908
2874
|
if (!hasOption || !$option.hasClass(className.addition)) {
|
|
2909
2875
|
return;
|
|
2910
2876
|
}
|
|
@@ -2939,9 +2905,9 @@
|
|
|
2939
2905
|
|
|
2940
2906
|
$selectedItem
|
|
2941
2907
|
.each(function () {
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2908
|
+
const $selected = $(this);
|
|
2909
|
+
const selectedText = module.get.choiceText($selected);
|
|
2910
|
+
const selectedValue = module.get.choiceValue($selected, selectedText);
|
|
2945
2911
|
if (module.is.multiple()) {
|
|
2946
2912
|
if (settings.useLabels) {
|
|
2947
2913
|
module.remove.value(selectedValue, selectedText, $selected, preventChangeTrigger);
|
|
@@ -2969,7 +2935,7 @@
|
|
|
2969
2935
|
$item.removeClass(className.selected);
|
|
2970
2936
|
},
|
|
2971
2937
|
value: function (removedValue, removedText, $removedItem, preventChangeTrigger) {
|
|
2972
|
-
|
|
2938
|
+
const values = module.get.values();
|
|
2973
2939
|
let newValue;
|
|
2974
2940
|
if (module.has.selectInput()) {
|
|
2975
2941
|
module.verbose('Input is <select> removing selected option', removedValue);
|
|
@@ -3000,8 +2966,8 @@
|
|
|
3000
2966
|
return values;
|
|
3001
2967
|
},
|
|
3002
2968
|
label: function (value, shouldAnimate) {
|
|
3003
|
-
|
|
3004
|
-
|
|
2969
|
+
const $labels = $module.find(selector.label);
|
|
2970
|
+
const $removedLabel = $labels.filter('[data-' + metadata.value + '="' + CSS.escape(settings.ignoreCase ? value.toLowerCase() : value) + '"]');
|
|
3005
2971
|
module.verbose('Removing label', $removedLabel);
|
|
3006
2972
|
$removedLabel.remove();
|
|
3007
2973
|
},
|
|
@@ -3015,12 +2981,12 @@
|
|
|
3015
2981
|
module.verbose('Removing labels', $labels);
|
|
3016
2982
|
$labels
|
|
3017
2983
|
.each(function () {
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
2984
|
+
const $label = $(this);
|
|
2985
|
+
const value = $label.data(metadata.value);
|
|
2986
|
+
const stringValue = value !== undefined
|
|
3021
2987
|
? String(value)
|
|
3022
2988
|
: value;
|
|
3023
|
-
|
|
2989
|
+
const isUserValue = module.is.userValue(stringValue);
|
|
3024
2990
|
if (settings.onLabelRemove.call($label, value) === false) {
|
|
3025
2991
|
module.debug('Label remove callback cancelled removal');
|
|
3026
2992
|
|
|
@@ -3072,27 +3038,21 @@
|
|
|
3072
3038
|
selectInput: function () {
|
|
3073
3039
|
return $input.is('select');
|
|
3074
3040
|
},
|
|
3075
|
-
minCharacters: function (searchTerm) {
|
|
3041
|
+
minCharacters: function (searchTerm = module.get.query()) {
|
|
3076
3042
|
if (settings.minCharacters && !iconClicked) {
|
|
3077
|
-
|
|
3078
|
-
? String(searchTerm)
|
|
3079
|
-
: String(module.get.query());
|
|
3080
|
-
|
|
3081
|
-
return searchTerm.length >= settings.minCharacters;
|
|
3043
|
+
return String(searchTerm).length >= settings.minCharacters;
|
|
3082
3044
|
}
|
|
3083
3045
|
iconClicked = false;
|
|
3084
3046
|
|
|
3085
3047
|
return true;
|
|
3086
3048
|
},
|
|
3087
3049
|
firstLetter: function ($item, letter) {
|
|
3088
|
-
let text;
|
|
3089
|
-
let firstLetter;
|
|
3090
3050
|
if (!$item || $item.length === 0 || typeof letter !== 'string') {
|
|
3091
3051
|
return false;
|
|
3092
3052
|
}
|
|
3093
|
-
text = module.get.choiceText($item, false);
|
|
3053
|
+
const text = module.get.choiceText($item, false);
|
|
3094
3054
|
letter = letter.toLowerCase();
|
|
3095
|
-
firstLetter = String(text).charAt(0).toLowerCase();
|
|
3055
|
+
const firstLetter = String(text).charAt(0).toLowerCase();
|
|
3096
3056
|
|
|
3097
3057
|
return letter == firstLetter;
|
|
3098
3058
|
},
|
|
@@ -3112,7 +3072,7 @@
|
|
|
3112
3072
|
return $menu.children(selector.message).length > 0;
|
|
3113
3073
|
},
|
|
3114
3074
|
label: function (value) {
|
|
3115
|
-
|
|
3075
|
+
const $labels = $module.find(selector.label);
|
|
3116
3076
|
if (settings.ignoreCase) {
|
|
3117
3077
|
value = value.toLowerCase();
|
|
3118
3078
|
}
|
|
@@ -3123,7 +3083,7 @@
|
|
|
3123
3083
|
return settings.maxSelections && module.get.selectionCount() >= settings.maxSelections;
|
|
3124
3084
|
},
|
|
3125
3085
|
allResultsFiltered: function () {
|
|
3126
|
-
|
|
3086
|
+
const $normalResults = $item.not(selector.addition);
|
|
3127
3087
|
|
|
3128
3088
|
return $normalResults.filter(selector.unselectable).length === $normalResults.length;
|
|
3129
3089
|
},
|
|
@@ -3139,8 +3099,8 @@
|
|
|
3139
3099
|
: module.has.valueMatchingCase(value);
|
|
3140
3100
|
},
|
|
3141
3101
|
valueMatchingCase: function (value) {
|
|
3142
|
-
|
|
3143
|
-
|
|
3102
|
+
const values = module.get.values();
|
|
3103
|
+
const hasValue = Array.isArray(values)
|
|
3144
3104
|
? values && values.includes(value)
|
|
3145
3105
|
: values == value;
|
|
3146
3106
|
|
|
@@ -3195,12 +3155,12 @@
|
|
|
3195
3155
|
: $menu.transition && $menu.transition('is animating');
|
|
3196
3156
|
},
|
|
3197
3157
|
leftward: function ($subMenu) {
|
|
3198
|
-
|
|
3158
|
+
const $selectedMenu = $subMenu || $menu;
|
|
3199
3159
|
|
|
3200
3160
|
return $selectedMenu.hasClass(className.leftward);
|
|
3201
3161
|
},
|
|
3202
3162
|
clearable: function () {
|
|
3203
|
-
|
|
3163
|
+
const hasClearableClass = $module.hasClass(className.clearable);
|
|
3204
3164
|
if (!hasClearableClass && settings.clearable) {
|
|
3205
3165
|
$module.addClass(className.clearable);
|
|
3206
3166
|
}
|
|
@@ -3274,7 +3234,7 @@
|
|
|
3274
3234
|
return (module.get.userValues() || []).includes(value);
|
|
3275
3235
|
},
|
|
3276
3236
|
upward: function ($menu) {
|
|
3277
|
-
|
|
3237
|
+
const $element = $menu || $module;
|
|
3278
3238
|
|
|
3279
3239
|
return $element.hasClass(className.upward);
|
|
3280
3240
|
},
|
|
@@ -3284,14 +3244,14 @@
|
|
|
3284
3244
|
: $menu.hasClass(className.visible);
|
|
3285
3245
|
},
|
|
3286
3246
|
verticallyScrollableContext: function () {
|
|
3287
|
-
|
|
3247
|
+
const overflowY = $context[0] !== window
|
|
3288
3248
|
? $context.css('overflow-y')
|
|
3289
3249
|
: false;
|
|
3290
3250
|
|
|
3291
3251
|
return overflowY === 'auto' || overflowY === 'scroll';
|
|
3292
3252
|
},
|
|
3293
3253
|
horizontallyScrollableContext: function () {
|
|
3294
|
-
|
|
3254
|
+
const overflowX = $context[0] !== window
|
|
3295
3255
|
? $context.css('overflow-X')
|
|
3296
3256
|
: false;
|
|
3297
3257
|
|
|
@@ -3308,13 +3268,11 @@
|
|
|
3308
3268
|
);
|
|
3309
3269
|
},
|
|
3310
3270
|
openDownward: function ($subMenu) {
|
|
3311
|
-
|
|
3271
|
+
const $currentMenu = $subMenu || $menu;
|
|
3312
3272
|
let canOpenDownward;
|
|
3313
|
-
let onScreen;
|
|
3314
|
-
let calculations;
|
|
3315
3273
|
$currentMenu
|
|
3316
3274
|
.addClass(className.loading);
|
|
3317
|
-
calculations = {
|
|
3275
|
+
const calculations = {
|
|
3318
3276
|
context: {
|
|
3319
3277
|
offset: $context[0] === window
|
|
3320
3278
|
? { top: 0, left: 0 }
|
|
@@ -3333,7 +3291,7 @@
|
|
|
3333
3291
|
if (module.has.subMenu($currentMenu)) {
|
|
3334
3292
|
calculations.menu.height += $currentMenu.find(selector.menu).first().outerHeight();
|
|
3335
3293
|
}
|
|
3336
|
-
onScreen = {
|
|
3294
|
+
const onScreen = {
|
|
3337
3295
|
above: calculations.context.scrollTop <= calculations.menu.offset.top - calculations.context.offset.top - calculations.menu.height,
|
|
3338
3296
|
below: (calculations.context.scrollTop + calculations.context.height) >= calculations.menu.offset.top - calculations.context.offset.top + calculations.menu.height,
|
|
3339
3297
|
};
|
|
@@ -3352,13 +3310,12 @@
|
|
|
3352
3310
|
return canOpenDownward;
|
|
3353
3311
|
},
|
|
3354
3312
|
openRightward: function ($subMenu) {
|
|
3355
|
-
|
|
3313
|
+
const $currentMenu = $subMenu || $menu;
|
|
3356
3314
|
let canOpenRightward = true;
|
|
3357
3315
|
let isOffscreenRight = false;
|
|
3358
|
-
let calculations;
|
|
3359
3316
|
$currentMenu
|
|
3360
3317
|
.addClass(className.loading);
|
|
3361
|
-
calculations = {
|
|
3318
|
+
const calculations = {
|
|
3362
3319
|
context: {
|
|
3363
3320
|
offset: $context[0] === window
|
|
3364
3321
|
? { top: 0, left: 0 }
|
|
@@ -3404,21 +3361,20 @@
|
|
|
3404
3361
|
|
|
3405
3362
|
animate: {
|
|
3406
3363
|
show: function (callback, $subMenu) {
|
|
3407
|
-
|
|
3408
|
-
|
|
3364
|
+
const $currentMenu = $subMenu || $menu;
|
|
3365
|
+
const start = $subMenu
|
|
3409
3366
|
? function () {}
|
|
3410
3367
|
: function () {
|
|
3411
3368
|
module.hideSubMenus();
|
|
3412
3369
|
module.hideOthers();
|
|
3413
3370
|
module.set.active();
|
|
3414
3371
|
};
|
|
3415
|
-
let transition;
|
|
3416
3372
|
callback = isFunction(callback)
|
|
3417
3373
|
? callback
|
|
3418
3374
|
: function () {};
|
|
3419
3375
|
module.verbose('Doing menu show animation', $currentMenu);
|
|
3420
3376
|
module.set.direction($subMenu);
|
|
3421
|
-
transition = settings.transition.showMethod || module.get.transition($subMenu);
|
|
3377
|
+
const transition = settings.transition.showMethod || module.get.transition($subMenu);
|
|
3422
3378
|
if (module.is.selection()) {
|
|
3423
3379
|
module.set.scrollPosition(module.get.selectedItem(), true);
|
|
3424
3380
|
}
|
|
@@ -3448,14 +3404,14 @@
|
|
|
3448
3404
|
}
|
|
3449
3405
|
},
|
|
3450
3406
|
hide: function (callback, $subMenu) {
|
|
3451
|
-
|
|
3452
|
-
|
|
3407
|
+
const $currentMenu = $subMenu || $menu;
|
|
3408
|
+
const start = $subMenu
|
|
3453
3409
|
? function () {}
|
|
3454
3410
|
: function () {
|
|
3455
3411
|
module.unbind.intent();
|
|
3456
3412
|
module.remove.active();
|
|
3457
3413
|
};
|
|
3458
|
-
|
|
3414
|
+
const transition = settings.transition.hideMethod || module.get.transition($subMenu);
|
|
3459
3415
|
callback = isFunction(callback)
|
|
3460
3416
|
? callback
|
|
3461
3417
|
: function () {};
|
|
@@ -3642,7 +3598,7 @@
|
|
|
3642
3598
|
query = query.split(/[ .]/);
|
|
3643
3599
|
maxDepth = query.length - 1;
|
|
3644
3600
|
$.each(query, function (depth, value) {
|
|
3645
|
-
|
|
3601
|
+
const camelCaseValue = depth !== maxDepth
|
|
3646
3602
|
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
|
3647
3603
|
: query;
|
|
3648
3604
|
if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
|
|
@@ -3947,10 +3903,10 @@
|
|
|
3947
3903
|
},
|
|
3948
3904
|
// generates dropdown from select values
|
|
3949
3905
|
dropdown: function (select, settings) {
|
|
3950
|
-
|
|
3906
|
+
const placeholder = select.placeholder || false;
|
|
3951
3907
|
let html = '';
|
|
3952
|
-
|
|
3953
|
-
|
|
3908
|
+
const className = settings.className;
|
|
3909
|
+
const escape = settings.templates.escape;
|
|
3954
3910
|
html += '<i class="dropdown icon"></i>';
|
|
3955
3911
|
html += placeholder
|
|
3956
3912
|
? '<div class="default text">' + escape(placeholder, settings) + '</div>'
|
|
@@ -3964,16 +3920,16 @@
|
|
|
3964
3920
|
|
|
3965
3921
|
// generates just menu from select
|
|
3966
3922
|
menu: function (response, settings) {
|
|
3967
|
-
|
|
3968
|
-
|
|
3923
|
+
const fields = settings.fields;
|
|
3924
|
+
const values = response[fields.values] || [];
|
|
3969
3925
|
let html = '';
|
|
3970
|
-
|
|
3971
|
-
|
|
3926
|
+
const className = settings.className;
|
|
3927
|
+
const escape = settings.templates.escape;
|
|
3972
3928
|
$.each(values, function (index, option) {
|
|
3973
|
-
|
|
3974
|
-
|
|
3929
|
+
const itemType = option[fields.type] || 'item';
|
|
3930
|
+
const isMenu = itemType.includes('menu');
|
|
3975
3931
|
let maybeData = '';
|
|
3976
|
-
|
|
3932
|
+
const dataObject = option[fields.data];
|
|
3977
3933
|
if (dataObject) {
|
|
3978
3934
|
let dataKey;
|
|
3979
3935
|
let dataKeyEscaped;
|
|
@@ -3987,19 +3943,19 @@
|
|
|
3987
3943
|
}
|
|
3988
3944
|
}
|
|
3989
3945
|
if (itemType === 'item' || isMenu) {
|
|
3990
|
-
|
|
3946
|
+
const maybeText = option[fields.text]
|
|
3991
3947
|
? ' data-text="' + escape(option[fields.text]) + '"'
|
|
3992
3948
|
: '';
|
|
3993
|
-
|
|
3949
|
+
const maybeActionable = option[fields.actionable]
|
|
3994
3950
|
? className.actionable + ' '
|
|
3995
3951
|
: '';
|
|
3996
|
-
|
|
3952
|
+
const maybeDisabled = option[fields.disabled]
|
|
3997
3953
|
? className.disabled + ' '
|
|
3998
3954
|
: '';
|
|
3999
|
-
|
|
3955
|
+
const maybeDescriptionVertical = option[fields.descriptionVertical]
|
|
4000
3956
|
? className.descriptionVertical + ' '
|
|
4001
3957
|
: '';
|
|
4002
|
-
|
|
3958
|
+
const hasDescription = escape(option[fields.description] || '', settings) !== '';
|
|
4003
3959
|
html += '<div class="' + escape(maybeActionable + maybeDisabled + maybeDescriptionVertical + (option[fields.class] || className.item)) + '" data-value="' + escape(option[fields.value]) + '"' + maybeText + maybeData + '>';
|
|
4004
3960
|
if (isMenu) {
|
|
4005
3961
|
html += '<i class="' + (itemType.includes('left') ? 'left' : '') + ' dropdown icon"></i>';
|
|
@@ -4028,8 +3984,8 @@
|
|
|
4028
3984
|
}
|
|
4029
3985
|
html += '</div>';
|
|
4030
3986
|
} else if (itemType === 'header') {
|
|
4031
|
-
|
|
4032
|
-
|
|
3987
|
+
const groupName = option[fields.name] || '';
|
|
3988
|
+
const groupIcon = option[fields.icon] || className.groupIcon;
|
|
4033
3989
|
if (groupName !== '' || groupIcon !== '') {
|
|
4034
3990
|
html += '<div class="' + escape(option[fields.class] || className.header) + '">';
|
|
4035
3991
|
if (groupIcon !== '') {
|
|
@@ -4049,8 +4005,8 @@
|
|
|
4049
4005
|
|
|
4050
4006
|
// generates label for multiselect
|
|
4051
4007
|
label: function (value, text, settings) {
|
|
4052
|
-
|
|
4053
|
-
|
|
4008
|
+
const className = settings.className;
|
|
4009
|
+
const escape = settings.templates.escape;
|
|
4054
4010
|
|
|
4055
4011
|
return escape(text, settings) + '<i class="' + escape(className.delete) + ' icon"></i>';
|
|
4056
4012
|
},
|