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
|
@@ -20,40 +20,39 @@
|
|
|
20
20
|
: globalThis;
|
|
21
21
|
|
|
22
22
|
$.fn.rating = function (...args) {
|
|
23
|
-
|
|
23
|
+
const $allModules = $(this);
|
|
24
24
|
|
|
25
25
|
let time = Date.now();
|
|
26
26
|
let performance = [];
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const parameters = args[0];
|
|
29
|
+
const methodInvoked = typeof parameters === 'string';
|
|
30
|
+
const queryArguments = args.slice(1);
|
|
31
31
|
let returnedValue;
|
|
32
32
|
$allModules.each(function () {
|
|
33
|
-
|
|
33
|
+
const settings = $.isPlainObject(parameters)
|
|
34
34
|
? $.extend(true, {}, $.fn.rating.settings, parameters)
|
|
35
35
|
: $.extend({}, $.fn.rating.settings);
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
const namespace = settings.namespace;
|
|
38
|
+
const className = settings.className;
|
|
39
|
+
const error = settings.error;
|
|
40
|
+
const metadata = settings.metadata;
|
|
41
|
+
const selector = settings.selector;
|
|
42
|
+
const cssVars = settings.cssVars;
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const eventNamespace = '.' + namespace;
|
|
45
|
+
const moduleNamespace = 'module-' + namespace;
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const element = this;
|
|
48
48
|
let instance = $(this).data(moduleNamespace);
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
const $module = $(this);
|
|
51
51
|
let $icon = $module.find(selector.icon);
|
|
52
52
|
|
|
53
53
|
let initialLoad;
|
|
54
|
-
let module;
|
|
55
54
|
|
|
56
|
-
module = {
|
|
55
|
+
const module = {
|
|
57
56
|
|
|
58
57
|
initialize: function () {
|
|
59
58
|
module.verbose('Initializing rating module', settings);
|
|
@@ -93,9 +92,9 @@
|
|
|
93
92
|
|
|
94
93
|
setup: {
|
|
95
94
|
layout: function () {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
const maxRating = module.get.maxRating();
|
|
96
|
+
const icon = module.get.icon();
|
|
97
|
+
const html = $.fn.rating.settings.templates.icon(maxRating, icon);
|
|
99
98
|
module.debug('Generating icon html dynamically');
|
|
100
99
|
$module
|
|
101
100
|
.html(html);
|
|
@@ -105,7 +104,7 @@
|
|
|
105
104
|
|
|
106
105
|
event: {
|
|
107
106
|
mouseenter: function () {
|
|
108
|
-
|
|
107
|
+
const $activeIcon = $(this);
|
|
109
108
|
$activeIcon
|
|
110
109
|
.nextAll()
|
|
111
110
|
.removeClass(className.selected);
|
|
@@ -123,10 +122,10 @@
|
|
|
123
122
|
.removeClass(className.selected);
|
|
124
123
|
},
|
|
125
124
|
click: function () {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
const $activeIcon = $(this);
|
|
126
|
+
const currentRating = module.get.rating();
|
|
127
|
+
const rating = $icon.index($activeIcon) + 1;
|
|
128
|
+
const canClear = settings.clearable === 'auto'
|
|
130
129
|
? $icon.length === 1
|
|
131
130
|
: settings.clearable;
|
|
132
131
|
if (canClear && currentRating === rating) {
|
|
@@ -188,7 +187,7 @@
|
|
|
188
187
|
|
|
189
188
|
get: {
|
|
190
189
|
icon: function () {
|
|
191
|
-
|
|
190
|
+
const icon = $module.data(metadata.icon);
|
|
192
191
|
if (icon) {
|
|
193
192
|
$module.removeData(metadata.icon);
|
|
194
193
|
}
|
|
@@ -214,7 +213,7 @@
|
|
|
214
213
|
return settings.maxRating;
|
|
215
214
|
},
|
|
216
215
|
rating: function () {
|
|
217
|
-
|
|
216
|
+
const currentRating = $icon.filter('.' + className.active).length;
|
|
218
217
|
module.verbose('Current rating retrieved', currentRating);
|
|
219
218
|
|
|
220
219
|
return currentRating;
|
|
@@ -223,14 +222,14 @@
|
|
|
223
222
|
|
|
224
223
|
set: {
|
|
225
224
|
rating: function (rating) {
|
|
226
|
-
|
|
225
|
+
const ratingIndex = Math.floor(
|
|
227
226
|
Math.max(rating - 1, 0)
|
|
228
227
|
);
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
const $activeIcon = $icon.eq(ratingIndex);
|
|
229
|
+
const $partialActiveIcon = rating <= 1
|
|
231
230
|
? $activeIcon
|
|
232
231
|
: $activeIcon.next();
|
|
233
|
-
|
|
232
|
+
const filledPercentage = (rating % 1) * 100;
|
|
234
233
|
$module
|
|
235
234
|
.removeClass(className.selected);
|
|
236
235
|
$icon
|
|
@@ -365,7 +364,7 @@
|
|
|
365
364
|
query = query.split(/[ .]/);
|
|
366
365
|
maxDepth = query.length - 1;
|
|
367
366
|
$.each(query, function (depth, value) {
|
|
368
|
-
|
|
367
|
+
const camelCaseValue = depth !== maxDepth
|
|
369
368
|
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
|
370
369
|
: query;
|
|
371
370
|
if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
|
|
@@ -483,7 +482,7 @@
|
|
|
483
482
|
icon: function (maxRating, iconClass) {
|
|
484
483
|
let icon = 1;
|
|
485
484
|
let html = '';
|
|
486
|
-
|
|
485
|
+
const escape = $.fn.rating.settings.templates.escape;
|
|
487
486
|
while (icon <= maxRating) {
|
|
488
487
|
html += '<i class="' + escape(iconClass) + ' icon"></i>';
|
|
489
488
|
icon++;
|
|
@@ -20,47 +20,45 @@
|
|
|
20
20
|
: globalThis;
|
|
21
21
|
|
|
22
22
|
$.fn.search = function (...args) {
|
|
23
|
-
|
|
23
|
+
const $allModules = $(this);
|
|
24
24
|
|
|
25
25
|
let time = Date.now();
|
|
26
26
|
let performance = [];
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const parameters = args[0];
|
|
29
|
+
const methodInvoked = typeof parameters === 'string';
|
|
30
|
+
const queryArguments = args.slice(1);
|
|
31
31
|
let returnedValue;
|
|
32
32
|
$allModules.each(function () {
|
|
33
|
-
|
|
33
|
+
const settings = $.isPlainObject(parameters)
|
|
34
34
|
? $.extend(true, {}, $.fn.search.settings, parameters)
|
|
35
35
|
: $.extend({}, $.fn.search.settings);
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
const className = settings.className;
|
|
38
|
+
const metadata = settings.metadata;
|
|
39
|
+
const regExp = settings.regExp;
|
|
40
|
+
const fields = settings.fields;
|
|
41
|
+
const selector = settings.selector;
|
|
42
|
+
const error = settings.error;
|
|
43
|
+
const namespace = settings.namespace;
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const eventNamespace = '.' + namespace;
|
|
46
|
+
const moduleNamespace = namespace + '-module';
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
const $module = $(this);
|
|
49
49
|
let $prompt = $module.find(selector.prompt);
|
|
50
50
|
let $searchButton = $module.find(selector.searchButton);
|
|
51
51
|
let $results = $module.find(selector.results);
|
|
52
52
|
let $result = $module.find(selector.result);
|
|
53
53
|
let $category = $module.find(selector.category);
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
const element = this;
|
|
56
56
|
let instance = $module.data(moduleNamespace);
|
|
57
57
|
|
|
58
58
|
let disabledBubbled = false;
|
|
59
59
|
let resultsDismissed = false;
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
module = {
|
|
61
|
+
const module = {
|
|
64
62
|
|
|
65
63
|
initialize: function () {
|
|
66
64
|
module.verbose('Initializing module');
|
|
@@ -158,8 +156,8 @@
|
|
|
158
156
|
}
|
|
159
157
|
},
|
|
160
158
|
blur: function (event) {
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
const pageLostFocus = document.activeElement === this;
|
|
160
|
+
const callback = function () {
|
|
163
161
|
module.cancel.query();
|
|
164
162
|
module.remove.focus();
|
|
165
163
|
module.timer = setTimeout(function () {
|
|
@@ -204,18 +202,18 @@
|
|
|
204
202
|
},
|
|
205
203
|
click: function (event) {
|
|
206
204
|
module.debug('Search result selected');
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
205
|
+
const $result = $(this);
|
|
206
|
+
const $title = $result.find(selector.title).eq(0);
|
|
207
|
+
const $link = $result.is('a[href]') ? $result : $();
|
|
208
|
+
const href = $link.attr('href') || false;
|
|
209
|
+
const target = $link.attr('target') || false;
|
|
212
210
|
// title is used for result lookup
|
|
213
|
-
|
|
211
|
+
const value = $title.length > 0
|
|
214
212
|
? $title.text()
|
|
215
213
|
: false;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
214
|
+
const results = module.get.results();
|
|
215
|
+
const result = $result.data(metadata.result) || module.get.result(value, results);
|
|
216
|
+
const oldValue = module.get.value();
|
|
219
217
|
if (isFunction(settings.onSelect) && settings.onSelect.call(element, result, results) === false) {
|
|
220
218
|
module.debug('Custom onSelect callback cancelled default select action');
|
|
221
219
|
disabledBubbled = true;
|
|
@@ -239,18 +237,14 @@
|
|
|
239
237
|
},
|
|
240
238
|
},
|
|
241
239
|
ensureVisible: function ($el) {
|
|
242
|
-
let elTop;
|
|
243
|
-
let elBottom;
|
|
244
|
-
let resultsScrollTop;
|
|
245
|
-
let resultsHeight;
|
|
246
240
|
if ($el.length === 0) {
|
|
247
241
|
return;
|
|
248
242
|
}
|
|
249
|
-
elTop = $el.position().top;
|
|
250
|
-
elBottom = elTop + $el.outerHeight(true);
|
|
243
|
+
const elTop = $el.position().top;
|
|
244
|
+
const elBottom = elTop + $el.outerHeight(true);
|
|
251
245
|
|
|
252
|
-
resultsScrollTop = $results.scrollTop();
|
|
253
|
-
resultsHeight = $results.height();
|
|
246
|
+
const resultsScrollTop = $results.scrollTop();
|
|
247
|
+
const resultsHeight = $results.height();
|
|
254
248
|
|
|
255
249
|
if (elTop < 0) {
|
|
256
250
|
$results.scrollTop(resultsScrollTop + elTop);
|
|
@@ -260,15 +254,15 @@
|
|
|
260
254
|
},
|
|
261
255
|
handleKeyboard: function (event) {
|
|
262
256
|
// force selector refresh
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
257
|
+
const $result = $module.find(selector.result);
|
|
258
|
+
const $category = $module.find(selector.category);
|
|
259
|
+
const $activeResult = $result.filter('.' + className.active);
|
|
260
|
+
const currentIndex = $result.index($activeResult);
|
|
261
|
+
const resultSize = $result.length;
|
|
262
|
+
const hasActiveResult = $activeResult.length > 0;
|
|
263
|
+
|
|
264
|
+
const keyCode = event.which;
|
|
265
|
+
const keys = {
|
|
272
266
|
backspace: 8,
|
|
273
267
|
enter: 13,
|
|
274
268
|
escape: 27,
|
|
@@ -337,7 +331,7 @@
|
|
|
337
331
|
|
|
338
332
|
setup: {
|
|
339
333
|
api: function (searchTerm, callback) {
|
|
340
|
-
|
|
334
|
+
const apiSettings = {
|
|
341
335
|
debug: settings.debug,
|
|
342
336
|
on: false,
|
|
343
337
|
cache: settings.cache,
|
|
@@ -346,7 +340,7 @@
|
|
|
346
340
|
query: searchTerm,
|
|
347
341
|
},
|
|
348
342
|
};
|
|
349
|
-
|
|
343
|
+
const apiCallbacks = {
|
|
350
344
|
onSuccess: function (response, $module, xhr) {
|
|
351
345
|
module.parse.response.call(element, response, searchTerm);
|
|
352
346
|
callback();
|
|
@@ -405,8 +399,8 @@
|
|
|
405
399
|
if (!event.target) {
|
|
406
400
|
return;
|
|
407
401
|
}
|
|
408
|
-
|
|
409
|
-
|
|
402
|
+
const $target = $(event.target);
|
|
403
|
+
const isInDOM = document.documentElement.contains(event.target);
|
|
410
404
|
|
|
411
405
|
return isInDOM && $target.closest(selector.message).length > 0;
|
|
412
406
|
},
|
|
@@ -429,8 +423,8 @@
|
|
|
429
423
|
}
|
|
430
424
|
},
|
|
431
425
|
inputEvent: function () {
|
|
432
|
-
|
|
433
|
-
|
|
426
|
+
const prompt = $prompt[0];
|
|
427
|
+
const inputEvent = prompt !== undefined && prompt.oninput !== undefined
|
|
434
428
|
? 'input'
|
|
435
429
|
: (prompt !== undefined && prompt.onpropertychange !== undefined
|
|
436
430
|
? 'propertychange'
|
|
@@ -444,14 +438,8 @@
|
|
|
444
438
|
results: function () {
|
|
445
439
|
return $module.data(metadata.results);
|
|
446
440
|
},
|
|
447
|
-
result: function (value, results) {
|
|
441
|
+
result: function (value = module.get.value(), results = module.get.results()) {
|
|
448
442
|
let result = false;
|
|
449
|
-
value = value !== undefined
|
|
450
|
-
? value
|
|
451
|
-
: module.get.value();
|
|
452
|
-
results = results !== undefined
|
|
453
|
-
? results
|
|
454
|
-
: module.get.results();
|
|
455
443
|
if (settings.type === 'category') {
|
|
456
444
|
module.debug('Finding result that matches', value);
|
|
457
445
|
$.each(results, function (index, category) {
|
|
@@ -520,8 +508,8 @@
|
|
|
520
508
|
callback = isFunction(callback)
|
|
521
509
|
? callback
|
|
522
510
|
: function () {};
|
|
523
|
-
|
|
524
|
-
|
|
511
|
+
const searchTerm = module.get.value();
|
|
512
|
+
const cache = module.read.cache(searchTerm);
|
|
525
513
|
if (module.has.minimumCharacters()) {
|
|
526
514
|
if (cache) {
|
|
527
515
|
module.debug('Reading result from cache', searchTerm);
|
|
@@ -551,7 +539,6 @@
|
|
|
551
539
|
search: {
|
|
552
540
|
local: function (searchTerm) {
|
|
553
541
|
let results = module.search.object(searchTerm, settings.source);
|
|
554
|
-
let searchHTML;
|
|
555
542
|
module.set.loading();
|
|
556
543
|
module.save.results(results);
|
|
557
544
|
module.debug('Returned full local search results', results);
|
|
@@ -562,7 +549,7 @@
|
|
|
562
549
|
if (settings.type === 'category') {
|
|
563
550
|
results = module.create.categoryResults(results);
|
|
564
551
|
}
|
|
565
|
-
searchHTML = module.generateResults({
|
|
552
|
+
const searchHTML = module.generateResults({
|
|
566
553
|
results: results,
|
|
567
554
|
});
|
|
568
555
|
module.remove.loading();
|
|
@@ -586,17 +573,17 @@
|
|
|
586
573
|
},
|
|
587
574
|
object: function (searchTerm, source = settings.source, searchFields = settings.searchFields) {
|
|
588
575
|
searchTerm = module.remove.diacritics(String(searchTerm));
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
576
|
+
const results = [];
|
|
577
|
+
const exactResults = [];
|
|
578
|
+
const fuzzyResults = [];
|
|
579
|
+
const searchExp = searchTerm.replace(regExp.escape, '\\$&');
|
|
580
|
+
const matchRegExp = new RegExp(regExp.beginsWith + searchExp, settings.ignoreSearchCase ? 'i' : '');
|
|
594
581
|
|
|
595
582
|
// avoid duplicates when pushing results
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
583
|
+
const addResult = function (array, result) {
|
|
584
|
+
const notResult = !results.includes(result);
|
|
585
|
+
const notFuzzyResult = !fuzzyResults.includes(result);
|
|
586
|
+
const notExactResults = !exactResults.includes(result);
|
|
600
587
|
if (notResult && notFuzzyResult && notExactResults) {
|
|
601
588
|
array.push(result);
|
|
602
589
|
}
|
|
@@ -614,11 +601,11 @@
|
|
|
614
601
|
return [];
|
|
615
602
|
}
|
|
616
603
|
// iterate through search fields looking for matches
|
|
617
|
-
|
|
604
|
+
const lastSearchFieldIndex = searchFields.length - 1;
|
|
618
605
|
$.each(source, function (label, content) {
|
|
619
|
-
|
|
606
|
+
const concatenatedContent = [];
|
|
620
607
|
$.each(searchFields, function (index, field) {
|
|
621
|
-
|
|
608
|
+
const fieldExists = typeof content[field] === 'string' || typeof content[field] === 'number';
|
|
622
609
|
if (fieldExists) {
|
|
623
610
|
let text;
|
|
624
611
|
text = typeof content[field] === 'string'
|
|
@@ -661,7 +648,7 @@
|
|
|
661
648
|
return term.includes(query);
|
|
662
649
|
},
|
|
663
650
|
wordSearch: function (query, term, matchAll) {
|
|
664
|
-
|
|
651
|
+
const allWords = query.split(/\s+/);
|
|
665
652
|
let found = false;
|
|
666
653
|
for (const w of allWords) {
|
|
667
654
|
found = module.exactSearch(w, term);
|
|
@@ -673,8 +660,8 @@
|
|
|
673
660
|
return found;
|
|
674
661
|
},
|
|
675
662
|
fuzzySearch: function (query, term) {
|
|
676
|
-
|
|
677
|
-
|
|
663
|
+
const termLength = term.length;
|
|
664
|
+
const queryLength = query.length;
|
|
678
665
|
if (typeof query !== 'string') {
|
|
679
666
|
return false;
|
|
680
667
|
}
|
|
@@ -690,7 +677,7 @@
|
|
|
690
677
|
}
|
|
691
678
|
for (let characterIndex = 0, nextCharacterIndex = 0; characterIndex < queryLength; characterIndex++) {
|
|
692
679
|
let continueSearch = false;
|
|
693
|
-
|
|
680
|
+
const queryCharacter = query.codePointAt(characterIndex);
|
|
694
681
|
while (nextCharacterIndex < termLength) {
|
|
695
682
|
if (term.codePointAt(nextCharacterIndex++) === queryCharacter) {
|
|
696
683
|
continueSearch = true;
|
|
@@ -710,11 +697,11 @@
|
|
|
710
697
|
parse: {
|
|
711
698
|
response: function (response, searchTerm) {
|
|
712
699
|
if (Array.isArray(response)) {
|
|
713
|
-
|
|
700
|
+
const o = {};
|
|
714
701
|
o[fields.results] = response;
|
|
715
702
|
response = o;
|
|
716
703
|
}
|
|
717
|
-
|
|
704
|
+
const searchHTML = module.generateResults(response);
|
|
718
705
|
module.verbose('Parsing server response', response);
|
|
719
706
|
if (response !== undefined && searchTerm !== undefined && response[fields.results] !== undefined) {
|
|
720
707
|
module.addResults(searchHTML);
|
|
@@ -738,8 +725,8 @@
|
|
|
738
725
|
|
|
739
726
|
has: {
|
|
740
727
|
minimumCharacters: function () {
|
|
741
|
-
|
|
742
|
-
|
|
728
|
+
const searchTerm = module.get.value();
|
|
729
|
+
const numCharacters = searchTerm.length;
|
|
743
730
|
|
|
744
731
|
return numCharacters >= settings.minCharacters;
|
|
745
732
|
},
|
|
@@ -747,7 +734,7 @@
|
|
|
747
734
|
if ($results.length === 0) {
|
|
748
735
|
return false;
|
|
749
736
|
}
|
|
750
|
-
|
|
737
|
+
const html = $results.html();
|
|
751
738
|
|
|
752
739
|
return html !== '';
|
|
753
740
|
},
|
|
@@ -755,7 +742,7 @@
|
|
|
755
742
|
|
|
756
743
|
clear: {
|
|
757
744
|
cache: function (value) {
|
|
758
|
-
|
|
745
|
+
const cache = $module.data(metadata.cache);
|
|
759
746
|
if (!value) {
|
|
760
747
|
module.debug('Clearing cache', value);
|
|
761
748
|
$module.removeData(metadata.cache);
|
|
@@ -772,7 +759,7 @@
|
|
|
772
759
|
|
|
773
760
|
read: {
|
|
774
761
|
cache: function (name) {
|
|
775
|
-
|
|
762
|
+
const cache = $module.data(metadata.cache);
|
|
776
763
|
if (settings.cache) {
|
|
777
764
|
module.verbose('Checking cache for generated html for query', name);
|
|
778
765
|
|
|
@@ -787,7 +774,7 @@
|
|
|
787
774
|
|
|
788
775
|
create: {
|
|
789
776
|
categoryResults: function (results) {
|
|
790
|
-
|
|
777
|
+
const categoryResults = {};
|
|
791
778
|
$.each(results, function (index, result) {
|
|
792
779
|
if (!result.category) {
|
|
793
780
|
return;
|
|
@@ -806,7 +793,7 @@
|
|
|
806
793
|
return categoryResults;
|
|
807
794
|
},
|
|
808
795
|
id: function (resultIndex, categoryIndex) {
|
|
809
|
-
|
|
796
|
+
const resultID = resultIndex + 1; // not zero indexed
|
|
810
797
|
let letterID;
|
|
811
798
|
let id;
|
|
812
799
|
if (categoryIndex !== undefined) {
|
|
@@ -833,7 +820,7 @@
|
|
|
833
820
|
inject: {
|
|
834
821
|
result: function (result, resultIndex, categoryIndex) {
|
|
835
822
|
module.verbose('Injecting result into results');
|
|
836
|
-
|
|
823
|
+
const $selectedResult = categoryIndex !== undefined
|
|
837
824
|
? $results
|
|
838
825
|
.children().eq(categoryIndex)
|
|
839
826
|
.children(selector.results)
|
|
@@ -890,7 +877,7 @@
|
|
|
890
877
|
|
|
891
878
|
write: {
|
|
892
879
|
cache: function (name, value) {
|
|
893
|
-
|
|
880
|
+
const cache = $module.data(metadata.cache) !== undefined
|
|
894
881
|
? $module.data(metadata.cache)
|
|
895
882
|
: {};
|
|
896
883
|
if (settings.cache) {
|
|
@@ -941,7 +928,7 @@
|
|
|
941
928
|
silent: settings.silent,
|
|
942
929
|
duration: settings.duration,
|
|
943
930
|
onShow: function () {
|
|
944
|
-
|
|
931
|
+
const $firstResult = $module.find(selector.result).eq(0);
|
|
945
932
|
module.ensureVisible($firstResult);
|
|
946
933
|
},
|
|
947
934
|
onComplete: function () {
|
|
@@ -989,9 +976,9 @@
|
|
|
989
976
|
|
|
990
977
|
generateResults: function (response) {
|
|
991
978
|
module.debug('Generating html from response', response);
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
979
|
+
const template = settings.templates[settings.type];
|
|
980
|
+
const isProperObject = $.isPlainObject(response[fields.results]) && !$.isEmptyObject(response[fields.results]);
|
|
981
|
+
const isProperArray = Array.isArray(response[fields.results]) && response[fields.results].length > 0;
|
|
995
982
|
let html = '';
|
|
996
983
|
if (isProperObject || isProperArray) {
|
|
997
984
|
if (settings.maxResults > 0) {
|
|
@@ -1004,13 +991,13 @@
|
|
|
1004
991
|
}
|
|
1005
992
|
}
|
|
1006
993
|
if (settings.highlightMatches) {
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
994
|
+
const results = response[fields.results];
|
|
995
|
+
const regExpIgnore = settings.ignoreSearchCase ? 'i' : '';
|
|
996
|
+
const querySplit = [...module.get.value()];
|
|
997
|
+
const diacriticReg = settings.ignoreDiacritics ? '[\u0300-\u036F]?' : '';
|
|
998
|
+
const htmlReg = '(?![^<]*>)';
|
|
999
|
+
const markedRegExp = new RegExp(htmlReg + '(' + querySplit.join(diacriticReg + ')(.*?)' + htmlReg + '(') + diacriticReg + ')', regExpIgnore);
|
|
1000
|
+
const markedReplacer = function (...args) {
|
|
1014
1001
|
args = args.slice(1, querySplit.length * 2).map(function (x, i) {
|
|
1015
1002
|
return i & 1 ? x : '<mark>' + x + '</mark>'; // eslint-disable-line no-bitwise
|
|
1016
1003
|
});
|
|
@@ -1019,7 +1006,7 @@
|
|
|
1019
1006
|
};
|
|
1020
1007
|
$.each(results, function (label, content) {
|
|
1021
1008
|
$.each(settings.searchFields, function (index, field) {
|
|
1022
|
-
|
|
1009
|
+
const fieldExists = typeof content[field] === 'string' || typeof content[field] === 'number';
|
|
1023
1010
|
if (fieldExists) {
|
|
1024
1011
|
let markedHTML = typeof content[field] === 'string'
|
|
1025
1012
|
? content[field]
|
|
@@ -1148,7 +1135,7 @@
|
|
|
1148
1135
|
query = query.split(/[ .]/);
|
|
1149
1136
|
maxDepth = query.length - 1;
|
|
1150
1137
|
$.each(query, function (depth, value) {
|
|
1151
|
-
|
|
1138
|
+
const camelCaseValue = depth !== maxDepth
|
|
1152
1139
|
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
|
1153
1140
|
: query;
|
|
1154
1141
|
if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
|
|
@@ -1392,8 +1379,8 @@
|
|
|
1392
1379
|
},
|
|
1393
1380
|
category: function (response, settings) {
|
|
1394
1381
|
let html = '';
|
|
1395
|
-
|
|
1396
|
-
|
|
1382
|
+
const fields = settings.fields;
|
|
1383
|
+
const escape = settings.templates.escape;
|
|
1397
1384
|
if (response[fields.categoryResults] !== undefined) {
|
|
1398
1385
|
// each category
|
|
1399
1386
|
$.each(response[fields.categoryResults], function (index, category) {
|
|
@@ -1465,8 +1452,8 @@
|
|
|
1465
1452
|
},
|
|
1466
1453
|
standard: function (response, settings) {
|
|
1467
1454
|
let html = '';
|
|
1468
|
-
|
|
1469
|
-
|
|
1455
|
+
const fields = settings.fields;
|
|
1456
|
+
const escape = settings.templates.escape;
|
|
1470
1457
|
if (response[fields.results] !== undefined) {
|
|
1471
1458
|
// each result
|
|
1472
1459
|
$.each(response[fields.results], function (index, result) {
|