fomantic-ui 2.9.4-beta.30 → 2.9.4-beta.32
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/dist/components/accordion.css +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/accordion.min.css +1 -1
- package/dist/components/accordion.min.js +1 -1
- package/dist/components/ad.css +1 -1
- package/dist/components/ad.min.css +1 -1
- package/dist/components/api.js +1 -1
- package/dist/components/api.min.js +1 -1
- 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 +1 -1
- package/dist/components/calendar.min.css +1 -1
- package/dist/components/calendar.min.js +1 -1
- 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 +1 -1
- package/dist/components/checkbox.min.css +1 -1
- package/dist/components/checkbox.min.js +1 -1
- 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 +1 -1
- package/dist/components/dimmer.min.css +1 -1
- package/dist/components/dimmer.min.js +1 -1
- 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 +42 -11
- 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 +1 -1
- package/dist/components/embed.min.css +1 -1
- package/dist/components/embed.min.js +1 -1
- 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 +1 -1
- package/dist/components/flyout.min.css +1 -1
- package/dist/components/flyout.min.js +1 -1
- package/dist/components/form.css +1 -1
- package/dist/components/form.js +1 -1
- package/dist/components/form.min.css +1 -1
- package/dist/components/form.min.js +1 -1
- 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 +1 -1
- package/dist/components/modal.min.css +1 -1
- package/dist/components/modal.min.js +1 -1
- package/dist/components/nag.css +1 -1
- package/dist/components/nag.js +1 -1
- package/dist/components/nag.min.css +1 -1
- package/dist/components/nag.min.js +1 -1
- 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 +1 -1
- package/dist/components/popup.min.css +1 -1
- package/dist/components/popup.min.js +1 -1
- package/dist/components/progress.css +1 -1
- package/dist/components/progress.js +1 -1
- package/dist/components/progress.min.css +1 -1
- package/dist/components/progress.min.js +1 -1
- 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 +1 -1
- package/dist/components/rating.min.css +1 -1
- package/dist/components/rating.min.js +1 -1
- 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 +58 -10
- 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 +1 -1
- package/dist/components/shape.min.css +1 -1
- package/dist/components/shape.min.js +1 -1
- package/dist/components/sidebar.css +1 -1
- package/dist/components/sidebar.js +1 -1
- package/dist/components/sidebar.min.css +1 -1
- package/dist/components/sidebar.min.js +1 -1
- package/dist/components/site.css +1 -1
- package/dist/components/site.js +1 -1
- package/dist/components/site.min.css +1 -1
- package/dist/components/site.min.js +1 -1
- package/dist/components/slider.css +1 -1
- package/dist/components/slider.js +1 -1
- package/dist/components/slider.min.css +1 -1
- package/dist/components/slider.min.js +1 -1
- package/dist/components/state.js +1 -1
- package/dist/components/state.min.js +1 -1
- 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 +1 -1
- package/dist/components/sticky.min.css +1 -1
- package/dist/components/sticky.min.js +1 -1
- package/dist/components/tab.css +1 -1
- package/dist/components/tab.js +1 -1
- package/dist/components/tab.min.css +1 -1
- package/dist/components/tab.min.js +1 -1
- package/dist/components/table.css +7 -7
- package/dist/components/table.min.css +2 -2
- 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 +1 -1
- package/dist/components/toast.min.css +1 -1
- package/dist/components/toast.min.js +1 -1
- package/dist/components/transition.css +1 -1
- package/dist/components/transition.js +1 -1
- package/dist/components/transition.min.css +1 -1
- package/dist/components/transition.min.js +1 -1
- package/dist/components/visibility.js +1 -1
- package/dist/components/visibility.min.js +1 -1
- package/dist/semantic.css +59 -59
- package/dist/semantic.js +124 -45
- package/dist/semantic.min.css +2 -2
- package/dist/semantic.min.js +2 -2
- package/package.json +1 -1
- package/src/definitions/collections/table.less +6 -6
- package/src/definitions/modules/dropdown.js +41 -10
- package/src/definitions/modules/dropdown.less +7 -0
- package/src/definitions/modules/search.js +57 -9
- package/src/definitions/modules/search.less +9 -2
- package/src/themes/default/globals/site.variables +3 -0
- package/src/themes/default/globals/variation.variables +2 -0
- package/src/themes/default/modules/dropdown.variables +3 -0
- package/src/themes/default/modules/search.variables +3 -0
package/dist/components/menu.css
CHANGED
package/dist/components/modal.js
CHANGED
package/dist/components/nag.css
CHANGED
package/dist/components/nag.js
CHANGED
package/dist/components/popup.js
CHANGED
package/dist/components/rail.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* # Fomantic-UI 2.9.4-beta.
|
2
|
+
* # Fomantic-UI 2.9.4-beta.32+94e4e87 - Search
|
3
3
|
* https://github.com/fomantic/Fomantic-UI/
|
4
4
|
*
|
5
5
|
*
|
@@ -135,7 +135,10 @@
|
|
135
135
|
// this makes sure $.extend does not add specified search fields to default fields
|
136
136
|
// this is the only setting which should not extend defaults
|
137
137
|
if (parameters && parameters.searchFields !== undefined) {
|
138
|
-
settings.searchFields = parameters.searchFields
|
138
|
+
settings.searchFields = Array.isArray(parameters.searchFields)
|
139
|
+
? parameters.searchFields
|
140
|
+
: [parameters.searchFields]
|
141
|
+
;
|
139
142
|
}
|
140
143
|
},
|
141
144
|
},
|
@@ -631,7 +634,7 @@
|
|
631
634
|
exactResults = [],
|
632
635
|
fuzzyResults = [],
|
633
636
|
searchExp = searchTerm.replace(regExp.escape, '\\$&'),
|
634
|
-
matchRegExp
|
637
|
+
matchRegExp = new RegExp(regExp.beginsWith + searchExp, settings.ignoreSearchCase ? 'i' : ''),
|
635
638
|
|
636
639
|
// avoid duplicates when pushing results
|
637
640
|
addResult = function (array, result) {
|
@@ -667,13 +670,14 @@
|
|
667
670
|
var concatenatedContent = [];
|
668
671
|
$.each(searchFields, function (index, field) {
|
669
672
|
var
|
670
|
-
fieldExists =
|
673
|
+
fieldExists = typeof content[field] === 'string' || typeof content[field] === 'number'
|
671
674
|
;
|
672
675
|
if (fieldExists) {
|
673
676
|
var text;
|
674
677
|
text = typeof content[field] === 'string'
|
675
678
|
? module.remove.diacritics(content[field])
|
676
679
|
: content[field].toString();
|
680
|
+
text = $('<div/>', { html: text }).text().trim();
|
677
681
|
if (settings.fullTextSearch === 'all') {
|
678
682
|
concatenatedContent.push(text);
|
679
683
|
if (index < lastSearchFieldIndex) {
|
@@ -704,8 +708,10 @@
|
|
704
708
|
},
|
705
709
|
},
|
706
710
|
exactSearch: function (query, term) {
|
707
|
-
|
708
|
-
|
711
|
+
if (settings.ignoreSearchCase) {
|
712
|
+
query = query.toLowerCase();
|
713
|
+
term = term.toLowerCase();
|
714
|
+
}
|
709
715
|
|
710
716
|
return term.indexOf(query) > -1;
|
711
717
|
},
|
@@ -732,8 +738,10 @@
|
|
732
738
|
if (typeof query !== 'string') {
|
733
739
|
return false;
|
734
740
|
}
|
735
|
-
|
736
|
-
|
741
|
+
if (settings.ignoreSearchCase) {
|
742
|
+
query = query.toLowerCase();
|
743
|
+
term = term.toLowerCase();
|
744
|
+
}
|
737
745
|
if (queryLength > termLength) {
|
738
746
|
return false;
|
739
747
|
}
|
@@ -1088,6 +1096,39 @@
|
|
1088
1096
|
response[fields.results] = response[fields.results].slice(0, settings.maxResults);
|
1089
1097
|
}
|
1090
1098
|
}
|
1099
|
+
if (settings.highlightMatches) {
|
1100
|
+
var results = response[fields.results],
|
1101
|
+
regExpIgnore = settings.ignoreSearchCase ? 'i' : '',
|
1102
|
+
querySplit = module.get.value().split(''),
|
1103
|
+
diacriticReg = settings.ignoreDiacritics ? '[\u0300-\u036F]?' : '',
|
1104
|
+
htmlReg = '(?![^<]*>)',
|
1105
|
+
markedRegExp = new RegExp(htmlReg + '(' + querySplit.join(diacriticReg + ')(.*?)' + htmlReg + '(') + diacriticReg + ')', regExpIgnore),
|
1106
|
+
markedReplacer = function () {
|
1107
|
+
var args = [].slice.call(arguments, 1, querySplit.length * 2).map(function (x, i) {
|
1108
|
+
return i & 1 ? x : '<mark>' + x + '</mark>'; // eslint-disable-line no-bitwise
|
1109
|
+
});
|
1110
|
+
|
1111
|
+
return args.join('');
|
1112
|
+
}
|
1113
|
+
;
|
1114
|
+
$.each(results, function (label, content) {
|
1115
|
+
$.each(settings.searchFields, function (index, field) {
|
1116
|
+
var
|
1117
|
+
fieldExists = typeof content[field] === 'string' || typeof content[field] === 'number'
|
1118
|
+
;
|
1119
|
+
if (fieldExists) {
|
1120
|
+
var markedHTML = typeof content[field] === 'string'
|
1121
|
+
? content[field]
|
1122
|
+
: content[field].toString();
|
1123
|
+
if (settings.ignoreDiacritics) {
|
1124
|
+
markedHTML = markedHTML.normalize('NFD');
|
1125
|
+
}
|
1126
|
+
markedHTML = markedHTML.replace(/<\/?mark>/g, '');
|
1127
|
+
response[fields.results][label][field] = markedHTML.replace(markedRegExp, markedReplacer);
|
1128
|
+
}
|
1129
|
+
});
|
1130
|
+
});
|
1131
|
+
}
|
1091
1132
|
if (isFunction(template)) {
|
1092
1133
|
html = template(response, fields, settings.preserveHTML);
|
1093
1134
|
} else {
|
@@ -1316,9 +1357,15 @@
|
|
1316
1357
|
// search anywhere in value (set to 'exact' to require exact matches
|
1317
1358
|
fullTextSearch: 'exact',
|
1318
1359
|
|
1360
|
+
// Whether search result should highlight matching strings
|
1361
|
+
highlightMatches: false,
|
1362
|
+
|
1319
1363
|
// match results also if they contain diacritics of the same base character (for example searching for "a" will also match "á" or "â" or "à", etc...)
|
1320
1364
|
ignoreDiacritics: false,
|
1321
1365
|
|
1366
|
+
// whether to consider case sensitivity on local searching
|
1367
|
+
ignoreSearchCase: true,
|
1368
|
+
|
1322
1369
|
// whether to add events to prompt automatically
|
1323
1370
|
automatic: true,
|
1324
1371
|
|
@@ -1436,8 +1483,9 @@
|
|
1436
1483
|
};
|
1437
1484
|
if (shouldEscape.test(string)) {
|
1438
1485
|
string = string.replace(/&(?![\d#a-z]{1,12};)/gi, '&');
|
1439
|
-
|
1440
|
-
|
1486
|
+
string = string.replace(badChars, escapedChar);
|
1487
|
+
// FUI controlled HTML is still allowed
|
1488
|
+
string = string.replace(/<(\/)*mark>/g, '<$1mark>');
|
1441
1489
|
}
|
1442
1490
|
|
1443
1491
|
return string;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* # Fomantic UI - 2.9.4-beta.
|
2
|
+
* # Fomantic UI - 2.9.4-beta.32+94e4e87
|
3
3
|
* https://github.com/fomantic/Fomantic-UI
|
4
4
|
* https://fomantic-ui.com/
|
5
5
|
*
|
@@ -8,4 +8,4 @@
|
|
8
8
|
* https://opensource.org/licenses/MIT
|
9
9
|
*
|
10
10
|
*/
|
11
|
-
!function(q,F,k){"use strict";function D(e){return"function"==typeof e&&"number"!=typeof e.nodeType}F=void 0!==F&&F.Math===Math?F:globalThis,q.fn.search=function(R){var S,x=q(this),C=Date.now(),w=[],T=R,A="string"==typeof T,j=[].slice.call(arguments,1);return x.each(function(){var d=q.isPlainObject(R)?q.extend(!0,{},q.fn.search.settings,R):q.extend({},q.fn.search.settings),f=d.className,c=d.metadata,n=d.regExp,i=d.fields,g=d.selector,h=d.error,e=d.namespace,r="."+e,t=e+"-module",v=q(this),p=v.find(g.prompt),s=v.find(g.searchButton),a=v.find(g.results),o=v.find(g.result),u=(v.find(g.category),this),l=v.data(t),m=!1,y=!1,b={initialize:function(){b.verbose("Initializing module"),b.get.settings(),b.determine.searchFields(),b.bind.events(),b.set.type(),b.create.results(),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module",b),l=b,v.data(t,b)},destroy:function(){b.verbose("Destroying instance"),v.off(r).removeData(t)},refresh:function(){b.debug("Refreshing selector cache"),p=v.find(g.prompt),s=v.find(g.searchButton),v.find(g.category),a=v.find(g.results),o=v.find(g.result)},refreshResults:function(){a=v.find(g.results),o=v.find(g.result)},bind:{events:function(){b.verbose("Binding events to search"),d.automatic&&(v.on(b.get.inputEvent()+r,g.prompt,b.event.input),p.attr("autocomplete",b.is.chrome()?"fomantic-search":"off")),v.on("focus"+r,g.prompt,b.event.focus).on("blur"+r,g.prompt,b.event.blur).on("keydown"+r,g.prompt,b.handleKeyboard).on("click"+r,g.searchButton,b.query).on("mousedown"+r,g.results,b.event.result.mousedown).on("mouseup"+r,g.results,b.event.result.mouseup).on("click"+r,g.result,b.event.result.click)}},determine:{searchFields:function(){R&&void 0!==R.searchFields&&(d.searchFields=R.searchFields)}},event:{input:function(){d.searchDelay?(clearTimeout(b.timer),b.timer=setTimeout(function(){b.is.focused()&&b.query()},d.searchDelay)):b.query()},focus:function(){b.set.focus(),d.searchOnFocus&&b.has.minimumCharacters()&&b.query(function(){b.can.show()&&b.showResults()})},blur:function(e){function t(){b.cancel.query(),b.remove.focus(),b.timer=setTimeout(function(){b.hideResults()},d.hideDelay)}var s=k.activeElement===this;s||(y=!1,b.resultsClicked?(b.debug("Determining if user action caused search to close"),v.one("click.close"+r,g.results,function(e){b.is.inMessage(e)||m?p.trigger("focus"):(m=!1,b.is.animating()||b.is.hidden()||t())})):(b.debug("Input blurred without user action, closing results"),t()))},result:{mousedown:function(){b.resultsClicked=!0},mouseup:function(){b.resultsClicked=!1},click:function(e){b.debug("Search result selected");var t=q(this),s=t.find(g.title).eq(0),n=t.is("a[href]")?t:t.find("a[href]").eq(0),r=n.attr("href")||!1,i=n.attr("target")||!1,s=0<s.length&&s.text(),a=b.get.results(),t=t.data(c.result)||b.get.result(s,a),o=b.get.value();if(D(d.onSelect)&&!1===d.onSelect.call(u,t,a))return b.debug("Custom onSelect callback cancelled default select action"),void(m=!0);b.hideResults(),s&&b.get.value()===o&&b.set.value(s),r&&(e.preventDefault(),b.verbose("Opening search link found in result",n),"_blank"===i||e.ctrlKey?F.open(r):F.location.href=r)}}},ensureVisible:function(e){var t,s,n;0!==e.length&&(e=(t=e.position().top)+e.outerHeight(!0),s=a.scrollTop(),n=a.height(),t<0?a.scrollTop(s+t):n<e&&a.scrollTop(s+(e-n)))},handleKeyboard:function(e){var t,s=v.find(g.result),n=v.find(g.category),r=s.filter("."+f.active),i=s.index(r),a=s.length,r=0<r.length,o=e.which,c=13,u=38,l=40;if(o===27&&(b.is.visible()?b.hideResults():(b.verbose("Escape key pressed, blurring search field"),p.trigger("blur")),e.stopPropagation(),y=!0),b.is.visible())if(o===c){if(b.verbose("Enter key pressed, selecting active result"),0<s.filter("."+f.active).length)return b.event.result.click.call(s.filter("."+f.active),e),e.preventDefault(),!1}else o===u&&r?(b.verbose("Up key pressed, changing active result"),t=i-1<0?i:i-1,n.removeClass(f.active),s.removeClass(f.active).eq(t).addClass(f.active).closest(n).addClass(f.active),b.ensureVisible(s.eq(t)),e.preventDefault()):o===l&&(b.verbose("Down key pressed, changing active result"),t=a<=i+1?i:i+1,n.removeClass(f.active),s.removeClass(f.active).eq(t).addClass(f.active).closest(n).addClass(f.active),b.ensureVisible(s.eq(t)),e.preventDefault());else o===c&&(b.verbose("Enter key pressed, executing query"),b.query(),b.set.buttonPressed(),p.one("keyup",b.remove.buttonFocus))},setup:{api:function(n,r){var e={debug:d.debug,on:!1,cache:d.cache,action:"search",urlData:{query:n}};q.extend(!0,e,d.apiSettings,{onSuccess:function(e,t,s){b.parse.response.call(u,e,n),r(),d.apiSettings&&"function"==typeof d.apiSettings.onSuccess&&d.apiSettings.onSuccess.call(this,e,t,s)},onFailure:function(e,t,s){b.displayMessage(h.serverError),r(),d.apiSettings&&"function"==typeof d.apiSettings.onFailure&&d.apiSettings.onFailure.call(this,e,t,s)},onAbort:function(e,t,s){d.apiSettings&&"function"==typeof d.apiSettings.onAbort&&d.apiSettings.onAbort.call(this,e,t,s)},onError:function(e,t,s){b.error(),d.apiSettings&&"function"==typeof d.apiSettings.onError&&d.apiSettings.onError.call(this,e,t,s)}}),b.verbose("Setting up API request",e),v.api(e)}},can:{useAPI:function(){return void 0!==q.fn.api},show:function(){return b.is.focused()&&!b.is.visible()&&!b.is.empty()},transition:function(){return d.transition&&void 0!==q.fn.transition}},is:{animating:function(){return a.hasClass(f.animating)},chrome:function(){return!!F.chrome&&!F.StyleMedia},hidden:function(){return a.hasClass(f.hidden)},inMessage:function(e){var t;if(e.target)return t=q(e.target),q.contains(k.documentElement,e.target)&&0<t.closest(g.message).length},empty:function(){return""===a.html()},visible:function(){return 0<a.filter(":visible").length},focused:function(){return 0<p.filter(":focus").length}},get:{settings:function(){q.isPlainObject(R)&&R.searchFullText&&(d.fullTextSearch=R.searchFullText,b.error(d.error.oldSearchSyntax,u)),d.ignoreDiacritics&&!String.prototype.normalize&&(d.ignoreDiacritics=!1,b.error(h.noNormalize,u))},inputEvent:function(){var e=p[0];return void 0!==e&&void 0!==e.oninput?"input":void 0!==e&&void 0!==e.onpropertychange?"propertychange":"keyup"},value:function(){return p.val()},results:function(){return v.data(c.results)},result:function(s,e){var n=!1;return s=void 0!==s?s:b.get.value(),e=void 0!==e?e:b.get.results(),"category"===d.type?(b.debug("Finding result that matches",s),q.each(e,function(e,t){if(Array.isArray(t.results)&&(n=b.search.object(s,t.results)[0]))return!1})):(b.debug("Finding result in results object",s),n=b.search.object(s,e)[0]),n||!1}},select:{firstResult:function(){b.verbose("Selecting first result"),o.first().addClass(f.active)}},set:{focus:function(){v.addClass(f.focus)},loading:function(){v.addClass(f.loading)},value:function(e){b.verbose("Setting search input value",e),p.val(e)},type:function(e){e=e||d.type,f[e]&&v.addClass(f[e])},buttonPressed:function(){s.addClass(f.pressed)}},remove:{loading:function(){v.removeClass(f.loading)},focus:function(){v.removeClass(f.focus)},buttonPressed:function(){s.removeClass(f.pressed)},diacritics:function(e){return d.ignoreDiacritics?e.normalize("NFD").replace(/[\u0300-\u036F]/g,""):e}},query:function(e){e=D(e)?e:function(){};var t=b.get.value(),s=b.read.cache(t);e=e||function(){},b.has.minimumCharacters()?(s?(b.debug("Reading result from cache",t),b.save.results(s.results),d.onResults.call(u,s.results,!0),b.addResults(s.html),b.inject.id(s.results),e()):(b.debug("Querying for",t),q.isPlainObject(d.source)||Array.isArray(d.source)?(b.search.local(t),e()):b.can.useAPI()?b.search.remote(t,e):(b.error(h.source),e())),d.onSearchQuery.call(u,t)):b.hideResults()},search:{local:function(e){var t,s=b.search.object(e,d.source);b.set.loading(),b.save.results(s),b.debug("Returned full local search results",s),0<d.maxResults&&(b.debug("Using specified max results",s),s=s.slice(0,d.maxResults)),"category"===d.type&&(s=b.create.categoryResults(s)),t=b.generateResults({results:s}),b.remove.loading(),b.addResults(t),b.inject.id(s),b.write.cache(e,{html:t,results:s})},remote:function(e,t){t=D(t)?t:function(){},v.api("is loading")&&v.api("abort"),b.setup.api(e,t),v.api("query")},object:function(r,e,t){r=b.remove.diacritics(String(r));function i(e,t){var s=-1===q.inArray(t,a),n=-1===q.inArray(t,c),r=-1===q.inArray(t,o);s&&n&&r&&e.push(t)}var a=[],o=[],c=[],s=r.replace(n.escape,"\\$&"),u=new RegExp(n.beginsWith+s,"i");if(e=e||d.source,t=void 0!==t?t:d.searchFields,Array.isArray(t)||(t=[t]),void 0===e||!1===e)return b.error(h.source),[];var l=t.length-1;return q.each(e,function(e,s){var n=[];q.each(t,function(e,t){if("string"==typeof s[t]||"number"==typeof s[t]){t="string"==typeof s[t]?b.remove.diacritics(s[t]):s[t].toString();if("all"===d.fullTextSearch){if(n.push(t),e<l)return!0;t=n.join(" ")}"all"!==d.fullTextSearch&&-1!==t.search(u)?i(a,s):"exact"===d.fullTextSearch&&b.exactSearch(r,t)||"some"===d.fullTextSearch&&b.wordSearch(r,t)||"all"===d.fullTextSearch&&b.wordSearch(r,t,!0)?i(o,s):!0===d.fullTextSearch&&b.fuzzySearch(r,t)&&i(c,s)}})}),q.merge(o,c),q.merge(a,o),a}},exactSearch:function(e,t){return e=e.toLowerCase(),-1<(t=t.toLowerCase()).indexOf(e)},wordSearch:function(e,t,s){for(var n=e.split(/\s+/),r=n.length,i=!1,a=0;a<r&&!(!(i=b.exactSearch(n[a],t))&&s||i&&!s);a++);return i},fuzzySearch:function(e,t){var s=t.length,n=e.length;if("string"!=typeof e)return!1;if(e=e.toLowerCase(),t=t.toLowerCase(),s<n)return!1;if(n===s)return e===t;for(var r=0,i=0;r<n;r++){for(var a=!1,o=e.charCodeAt(r);i<s;)if(t.charCodeAt(i++)===o){a=!0;break}if(!a)return!1}return!0},parse:{response:function(e,t){Array.isArray(e)&&((s={})[i.results]=e,e=s);var s=b.generateResults(e);b.verbose("Parsing server response",e),void 0!==e&&void 0!==t&&void 0!==e[i.results]&&(b.addResults(s),b.inject.id(e[i.results]),b.write.cache(t,{html:s,results:e[i.results]}),b.save.results(e[i.results]))}},cancel:{query:function(){b.can.useAPI()&&v.api("abort")}},has:{minimumCharacters:function(){return b.get.value().length>=d.minCharacters},results:function(){return 0!==a.length&&""!==a.html()}},clear:{cache:function(e){var t=v.data(c.cache);e?t&&t[e]&&(b.debug("Removing value from cache",e),delete t[e],v.data(c.cache,t)):(b.debug("Clearing cache",e),v.removeData(c.cache))}},read:{cache:function(e){var t=v.data(c.cache);return!!d.cache&&(b.verbose("Checking cache for generated html for query",e),"object"==typeof t&&void 0!==t[e]&&t[e])}},create:{categoryResults:function(e){var s={};return q.each(e,function(e,t){t.category&&(void 0===s[t.category]?(b.verbose("Creating new category of results",t.category),s[t.category]={name:t.category,results:[t]}):s[t.category].results.push(t))}),s},id:function(e,t){var s,e=e+1;return void 0!==t?(t=String.fromCharCode(97+t),b.verbose("Creating category result id",s=t+e)):b.verbose("Creating result id",s=e),s},results:function(){0===a.length&&(a=q("<div />").addClass(f.results).appendTo(v))}},inject:{result:function(e,t,s){b.verbose("Injecting result into results");s=(void 0!==s?a.children().eq(s).children(g.results).first():a).children(g.result).eq(t);b.verbose("Injecting results metadata",s),s.data(c.result,e)},id:function(e){b.debug("Injecting unique ids into results");var s=0,n=0;return"category"===d.type?q.each(e,function(e,t){0<t.results.length&&(n=0,q.each(t.results,function(e,t){void 0===t.id&&(t.id=b.create.id(n,s)),b.inject.result(t,n,s),n++}),s++)}):q.each(e,function(e,t){void 0===t.id&&(t.id=b.create.id(n)),b.inject.result(t,n),n++}),e}},save:{results:function(e){b.verbose("Saving current search results to metadata",e),v.data(c.results,e)}},write:{cache:function(e,t){var s=void 0!==v.data(c.cache)?v.data(c.cache):{};d.cache&&(b.verbose("Writing generated html to cache",e,t),s[e]=t,v.data(c.cache,s))}},addResults:function(e){if(D(d.onResultsAdd)&&!1===d.onResultsAdd.call(a,e))return b.debug("onResultsAdd callback cancelled default action"),!1;e?(a.html(e),b.refreshResults(),d.selectFirstResult&&b.select.firstResult(),b.showResults()):b.hideResults(function(){a.empty()})},showResults:function(e){e=D(e)?e:function(){},y||!b.is.visible()&&b.has.results()&&(b.can.transition()?(b.debug("Showing results with css animations"),a.transition({animation:d.transition+" in",debug:d.debug,verbose:d.verbose,silent:d.silent,duration:d.duration,onShow:function(){var e=v.find(g.result).eq(0);b.ensureVisible(e)},onComplete:function(){e()},queue:!0})):(b.debug("Showing results with javascript"),a.stop().fadeIn(d.duration,d.easing)),d.onResultsOpen.call(a))},hideResults:function(e){e=D(e)?e:function(){},b.is.visible()&&(b.can.transition()?(b.debug("Hiding results with css animations"),a.transition({animation:d.transition+" out",debug:d.debug,verbose:d.verbose,silent:d.silent,duration:d.duration,onComplete:function(){e()},queue:!0})):(b.debug("Hiding results with javascript"),a.stop().fadeOut(d.duration,d.easing)),d.onResultsClose.call(a))},generateResults:function(e){b.debug("Generating html from response",e);var t=d.templates[d.type],s=q.isPlainObject(e[i.results])&&!q.isEmptyObject(e[i.results]),n=Array.isArray(e[i.results])&&0<e[i.results].length,r="";return s||n?(0<d.maxResults&&(s?"standard"===d.type&&b.error(h.maxResults):e[i.results]=e[i.results].slice(0,d.maxResults)),D(t)?r=t(e,i,d.preserveHTML):b.error(h.noTemplate,!1)):d.showNoResults&&(r=b.displayMessage(h.noResults,"empty",h.noResultsHeader)),d.onResults.call(u,e),r},displayMessage:function(e,t,s){return b.debug("Displaying message",e,t=t||"standard",s),b.addResults(d.templates.message(e,t,s)),d.templates.message(e,t,s)},setting:function(e,t){if(q.isPlainObject(e))q.extend(!0,d,e);else{if(void 0===t)return d[e];d[e]=t}},internal:function(e,t){if(q.isPlainObject(e))q.extend(!0,b,e);else{if(void 0===t)return b[e];b[e]=t}},debug:function(){!d.silent&&d.debug&&(d.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,d.name+":"),b.debug.apply(console,arguments)))},verbose:function(){!d.silent&&d.verbose&&d.debug&&(d.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,d.name+":"),b.verbose.apply(console,arguments)))},error:function(){d.silent||(b.error=Function.prototype.bind.call(console.error,console,d.name+":"),b.error.apply(console,arguments))},performance:{log:function(e){var t,s;d.performance&&(s=(t=Date.now())-(C||t),C=t,w.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:u,"Execution Time":s})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(function(){b.performance.display()},500)},display:function(){var e=d.name+":",s=0;C=!1,clearTimeout(b.performance.timer),q.each(w,function(e,t){s+=t["Execution Time"]}),e+=" "+s+"ms",1<x.length&&(e+=" ("+x.length+")"),0<w.length&&(console.groupCollapsed(e),console.table?console.table(w):q.each(w,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),w=[]}},invoke:function(n,e,t){var r,i,s,a=l;return e=e||j,t=t||u,"string"==typeof n&&void 0!==a&&(n=n.split(/[ .]/),r=n.length-1,q.each(n,function(e,t){var s=e!==r?t+n[e+1].charAt(0).toUpperCase()+n[e+1].slice(1):n;if(q.isPlainObject(a[s])&&e!==r)a=a[s];else{if(void 0!==a[s])return i=a[s],!1;{if(!q.isPlainObject(a[t])||e===r)return void 0!==a[t]?i=a[t]:b.error(h.method,n),!1;a=a[t]}}})),D(i)?s=i.apply(t,e):void 0!==i&&(s=i),Array.isArray(S)?S.push(s):void 0!==S?S=[S,s]:void 0!==s&&(S=s),i}};A?(void 0===l&&b.initialize(),b.invoke(T)):(void 0!==l&&l.invoke("destroy"),b.initialize())}),void 0!==S?S:this},q.fn.search.settings={name:"Search",namespace:"search",silent:!1,debug:!1,verbose:!1,performance:!0,type:"standard",minCharacters:1,selectFirstResult:!1,apiSettings:!1,source:!1,searchOnFocus:!0,searchFields:["id","title","description"],displayField:"",fullTextSearch:"exact",ignoreDiacritics:!1,automatic:!0,hideDelay:0,searchDelay:200,maxResults:7,cache:!0,showNoResults:!0,preserveHTML:!0,transition:"scale",duration:200,easing:"easeOutExpo",onSelect:!1,onResultsAdd:!1,onSearchQuery:function(e){},onResults:function(e,t){},onResultsOpen:function(){},onResultsClose:function(){},className:{animating:"animating",active:"active",category:"category",empty:"empty",focus:"focus",hidden:"hidden",loading:"loading",results:"results",pressed:"down"},error:{source:"Cannot search. No source used, and Fomantic API module was not included",noResultsHeader:"No Results",noResults:"Your search returned no results",noTemplate:"A valid template name was not specified.",oldSearchSyntax:"searchFullText setting has been renamed fullTextSearch for consistency, please adjust your settings.",serverError:"There was an issue querying the server.",maxResults:"Results must be an array to use maxResults setting",method:"The method you called is not defined.",noNormalize:'"ignoreDiacritics" setting will be ignored. Browser does not support String().normalize(). You may consider including <https://cdn.jsdelivr.net/npm/unorm@1.4.1/lib/unorm.min.js> as a polyfill.'},metadata:{cache:"cache",results:"results",result:"result"},regExp:{escape:/[$()*+./?[\\\]^{|}-]/g,beginsWith:"(?:\\s|^)"},fields:{categories:"results",categoryName:"name",categoryResults:"results",description:"description",image:"image",price:"price",results:"results",title:"title",url:"url",action:"action",actionText:"text",actionURL:"url"},selector:{prompt:".prompt",searchButton:".search.button",results:".results",message:".results > .message",category:".category",result:".result",title:".title, .name"},templates:{escape:function(e,t){if(t)return e;var s={"<":"<",">":">",'"':""","'":"'","`":"`"};return/["&'<>`]/.test(e)?(e=e.replace(/&(?![\d#a-z]{1,12};)/gi,"&")).replace(/["'<>`]/g,function(e){return s[e]}):e},message:function(e,t,s){var n="";return void 0!==e&&void 0!==t&&(n+='<div class="message '+t+'">',s&&(n+='<div class="header">'+s+"</div>"),n=n+' <div class="description">'+e+"</div></div>"),n},category:function(e,s,n){var r="",i=q.fn.search.settings.templates.escape;return void 0!==e[s.categoryResults]&&(q.each(e[s.categoryResults],function(e,t){void 0!==t[s.results]&&0<t.results.length&&(r+='<div class="category">',void 0!==t[s.categoryName]&&(r+='<div class="name">'+i(t[s.categoryName],n)+"</div>"),r+='<div class="results">',q.each(t.results,function(e,t){r+=t[s.url]?'<a class="result" href="'+t[s.url].replace(/"/g,"")+'">':'<a class="result">',void 0!==t[s.image]&&(r+='<div class="image"> <img src="'+t[s.image].replace(/"/g,"")+'"></div>'),r+='<div class="content">',void 0!==t[s.price]&&(r+='<div class="price">'+i(t[s.price],n)+"</div>"),void 0!==t[s.title]&&(r+='<div class="title">'+i(t[s.title],n)+"</div>"),void 0!==t[s.description]&&(r+='<div class="description">'+i(t[s.description],n)+"</div>"),r+="</div></a>"}),r+="</div></div>")}),e[s.action]&&(r+=!1===s.actionURL?'<div class="action">'+i(e[s.action][s.actionText],n)+"</div>":'<a href="'+e[s.action][s.actionURL].replace(/"/g,"")+'" class="action">'+i(e[s.action][s.actionText],n)+"</a>"),r)},standard:function(e,s,n){var r="",i=q.fn.search.settings.templates.escape;return void 0!==e[s.results]&&(q.each(e[s.results],function(e,t){r+=t[s.url]?'<a class="result" href="'+t[s.url].replace(/"/g,"")+'">':'<a class="result">',void 0!==t[s.image]&&(r+='<div class="image"> <img src="'+t[s.image].replace(/"/g,"")+'"></div>'),r+='<div class="content">',void 0!==t[s.price]&&(r+='<div class="price">'+i(t[s.price],n)+"</div>"),void 0!==t[s.title]&&(r+='<div class="title">'+i(t[s.title],n)+"</div>"),void 0!==t[s.description]&&(r+='<div class="description">'+i(t[s.description],n)+"</div>"),r+="</div></a>"}),e[s.action]&&(r+=!1===s.actionURL?'<div class="action">'+i(e[s.action][s.actionText],n)+"</div>":'<a href="'+e[s.action][s.actionURL].replace(/"/g,"")+'" class="action">'+i(e[s.action][s.actionText],n)+"</a>"),r)}}},q.extend(q.easing,{easeOutExpo:function(e){return 1===e?1:1-Math.pow(2,-10*e)}})}(jQuery,window,document);
|
11
|
+
!function(k,F,q){"use strict";function D(e){return"function"==typeof e&&"number"!=typeof e.nodeType}F=void 0!==F&&F.Math===Math?F:globalThis,k.fn.search=function(R){var S,x=k(this),C=Date.now(),w=[],T=R,A="string"==typeof T,j=[].slice.call(arguments,1);return x.each(function(){var d=k.isPlainObject(R)?k.extend(!0,{},k.fn.search.settings,R):k.extend({},k.fn.search.settings),f=d.className,c=d.metadata,r=d.regExp,u=d.fields,g=d.selector,h=d.error,e=d.namespace,n="."+e,t=e+"-module",p=k(this),v=p.find(g.prompt),s=p.find(g.searchButton),i=p.find(g.results),a=p.find(g.result),m=(p.find(g.category),this),o=p.data(t),l=!1,y=!1,b={initialize:function(){b.verbose("Initializing module"),b.get.settings(),b.determine.searchFields(),b.bind.events(),b.set.type(),b.create.results(),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module",b),o=b,p.data(t,b)},destroy:function(){b.verbose("Destroying instance"),p.off(n).removeData(t)},refresh:function(){b.debug("Refreshing selector cache"),v=p.find(g.prompt),s=p.find(g.searchButton),p.find(g.category),i=p.find(g.results),a=p.find(g.result)},refreshResults:function(){i=p.find(g.results),a=p.find(g.result)},bind:{events:function(){b.verbose("Binding events to search"),d.automatic&&(p.on(b.get.inputEvent()+n,g.prompt,b.event.input),v.attr("autocomplete",b.is.chrome()?"fomantic-search":"off")),p.on("focus"+n,g.prompt,b.event.focus).on("blur"+n,g.prompt,b.event.blur).on("keydown"+n,g.prompt,b.handleKeyboard).on("click"+n,g.searchButton,b.query).on("mousedown"+n,g.results,b.event.result.mousedown).on("mouseup"+n,g.results,b.event.result.mouseup).on("click"+n,g.result,b.event.result.click)}},determine:{searchFields:function(){R&&void 0!==R.searchFields&&(d.searchFields=Array.isArray(R.searchFields)?R.searchFields:[R.searchFields])}},event:{input:function(){d.searchDelay?(clearTimeout(b.timer),b.timer=setTimeout(function(){b.is.focused()&&b.query()},d.searchDelay)):b.query()},focus:function(){b.set.focus(),d.searchOnFocus&&b.has.minimumCharacters()&&b.query(function(){b.can.show()&&b.showResults()})},blur:function(e){function t(){b.cancel.query(),b.remove.focus(),b.timer=setTimeout(function(){b.hideResults()},d.hideDelay)}var s=q.activeElement===this;s||(y=!1,b.resultsClicked?(b.debug("Determining if user action caused search to close"),p.one("click.close"+n,g.results,function(e){b.is.inMessage(e)||l?v.trigger("focus"):(l=!1,b.is.animating()||b.is.hidden()||t())})):(b.debug("Input blurred without user action, closing results"),t()))},result:{mousedown:function(){b.resultsClicked=!0},mouseup:function(){b.resultsClicked=!1},click:function(e){b.debug("Search result selected");var t=k(this),s=t.find(g.title).eq(0),r=t.is("a[href]")?t:t.find("a[href]").eq(0),n=r.attr("href")||!1,i=r.attr("target")||!1,s=0<s.length&&s.text(),a=b.get.results(),t=t.data(c.result)||b.get.result(s,a),o=b.get.value();if(D(d.onSelect)&&!1===d.onSelect.call(m,t,a))return b.debug("Custom onSelect callback cancelled default select action"),void(l=!0);b.hideResults(),s&&b.get.value()===o&&b.set.value(s),n&&(e.preventDefault(),b.verbose("Opening search link found in result",r),"_blank"===i||e.ctrlKey?F.open(n):F.location.href=n)}}},ensureVisible:function(e){var t,s,r;0!==e.length&&(e=(t=e.position().top)+e.outerHeight(!0),s=i.scrollTop(),r=i.height(),t<0?i.scrollTop(s+t):r<e&&i.scrollTop(s+(e-r)))},handleKeyboard:function(e){var t,s=p.find(g.result),r=p.find(g.category),n=s.filter("."+f.active),i=s.index(n),a=s.length,n=0<n.length,o=e.which,c=13,l=38,u=40;if(o===27&&(b.is.visible()?b.hideResults():(b.verbose("Escape key pressed, blurring search field"),v.trigger("blur")),e.stopPropagation(),y=!0),b.is.visible())if(o===c){if(b.verbose("Enter key pressed, selecting active result"),0<s.filter("."+f.active).length)return b.event.result.click.call(s.filter("."+f.active),e),e.preventDefault(),!1}else o===l&&n?(b.verbose("Up key pressed, changing active result"),t=i-1<0?i:i-1,r.removeClass(f.active),s.removeClass(f.active).eq(t).addClass(f.active).closest(r).addClass(f.active),b.ensureVisible(s.eq(t)),e.preventDefault()):o===u&&(b.verbose("Down key pressed, changing active result"),t=a<=i+1?i:i+1,r.removeClass(f.active),s.removeClass(f.active).eq(t).addClass(f.active).closest(r).addClass(f.active),b.ensureVisible(s.eq(t)),e.preventDefault());else o===c&&(b.verbose("Enter key pressed, executing query"),b.query(),b.set.buttonPressed(),v.one("keyup",b.remove.buttonFocus))},setup:{api:function(r,n){var e={debug:d.debug,on:!1,cache:d.cache,action:"search",urlData:{query:r}};k.extend(!0,e,d.apiSettings,{onSuccess:function(e,t,s){b.parse.response.call(m,e,r),n(),d.apiSettings&&"function"==typeof d.apiSettings.onSuccess&&d.apiSettings.onSuccess.call(this,e,t,s)},onFailure:function(e,t,s){b.displayMessage(h.serverError),n(),d.apiSettings&&"function"==typeof d.apiSettings.onFailure&&d.apiSettings.onFailure.call(this,e,t,s)},onAbort:function(e,t,s){d.apiSettings&&"function"==typeof d.apiSettings.onAbort&&d.apiSettings.onAbort.call(this,e,t,s)},onError:function(e,t,s){b.error(),d.apiSettings&&"function"==typeof d.apiSettings.onError&&d.apiSettings.onError.call(this,e,t,s)}}),b.verbose("Setting up API request",e),p.api(e)}},can:{useAPI:function(){return void 0!==k.fn.api},show:function(){return b.is.focused()&&!b.is.visible()&&!b.is.empty()},transition:function(){return d.transition&&void 0!==k.fn.transition}},is:{animating:function(){return i.hasClass(f.animating)},chrome:function(){return!!F.chrome&&!F.StyleMedia},hidden:function(){return i.hasClass(f.hidden)},inMessage:function(e){var t;if(e.target)return t=k(e.target),k.contains(q.documentElement,e.target)&&0<t.closest(g.message).length},empty:function(){return""===i.html()},visible:function(){return 0<i.filter(":visible").length},focused:function(){return 0<v.filter(":focus").length}},get:{settings:function(){k.isPlainObject(R)&&R.searchFullText&&(d.fullTextSearch=R.searchFullText,b.error(d.error.oldSearchSyntax,m)),d.ignoreDiacritics&&!String.prototype.normalize&&(d.ignoreDiacritics=!1,b.error(h.noNormalize,m))},inputEvent:function(){var e=v[0];return void 0!==e&&void 0!==e.oninput?"input":void 0!==e&&void 0!==e.onpropertychange?"propertychange":"keyup"},value:function(){return v.val()},results:function(){return p.data(c.results)},result:function(s,e){var r=!1;return s=void 0!==s?s:b.get.value(),e=void 0!==e?e:b.get.results(),"category"===d.type?(b.debug("Finding result that matches",s),k.each(e,function(e,t){if(Array.isArray(t.results)&&(r=b.search.object(s,t.results)[0]))return!1})):(b.debug("Finding result in results object",s),r=b.search.object(s,e)[0]),r||!1}},select:{firstResult:function(){b.verbose("Selecting first result"),a.first().addClass(f.active)}},set:{focus:function(){p.addClass(f.focus)},loading:function(){p.addClass(f.loading)},value:function(e){b.verbose("Setting search input value",e),v.val(e)},type:function(e){e=e||d.type,f[e]&&p.addClass(f[e])},buttonPressed:function(){s.addClass(f.pressed)}},remove:{loading:function(){p.removeClass(f.loading)},focus:function(){p.removeClass(f.focus)},buttonPressed:function(){s.removeClass(f.pressed)},diacritics:function(e){return d.ignoreDiacritics?e.normalize("NFD").replace(/[\u0300-\u036F]/g,""):e}},query:function(e){e=D(e)?e:function(){};var t=b.get.value(),s=b.read.cache(t);e=e||function(){},b.has.minimumCharacters()?(s?(b.debug("Reading result from cache",t),b.save.results(s.results),d.onResults.call(m,s.results,!0),b.addResults(s.html),b.inject.id(s.results),e()):(b.debug("Querying for",t),k.isPlainObject(d.source)||Array.isArray(d.source)?(b.search.local(t),e()):b.can.useAPI()?b.search.remote(t,e):(b.error(h.source),e())),d.onSearchQuery.call(m,t)):b.hideResults()},search:{local:function(e){var t,s=b.search.object(e,d.source);b.set.loading(),b.save.results(s),b.debug("Returned full local search results",s),0<d.maxResults&&(b.debug("Using specified max results",s),s=s.slice(0,d.maxResults)),"category"===d.type&&(s=b.create.categoryResults(s)),t=b.generateResults({results:s}),b.remove.loading(),b.addResults(t),b.inject.id(s),b.write.cache(e,{html:t,results:s})},remote:function(e,t){t=D(t)?t:function(){},p.api("is loading")&&p.api("abort"),b.setup.api(e,t),p.api("query")},object:function(n,e,t){n=b.remove.diacritics(String(n));function i(e,t){var s=-1===k.inArray(t,a),r=-1===k.inArray(t,c),n=-1===k.inArray(t,o);s&&r&&n&&e.push(t)}var a=[],o=[],c=[],s=n.replace(r.escape,"\\$&"),l=new RegExp(r.beginsWith+s,d.ignoreSearchCase?"i":"");if(e=e||d.source,t=void 0!==t?t:d.searchFields,Array.isArray(t)||(t=[t]),void 0===e||!1===e)return b.error(h.source),[];var u=t.length-1;return k.each(e,function(e,s){var r=[];k.each(t,function(e,t){if("string"==typeof s[t]||"number"==typeof s[t]){t="string"==typeof s[t]?b.remove.diacritics(s[t]):s[t].toString();if(t=k("<div/>",{html:t}).text().trim(),"all"===d.fullTextSearch){if(r.push(t),e<u)return!0;t=r.join(" ")}"all"!==d.fullTextSearch&&-1!==t.search(l)?i(a,s):"exact"===d.fullTextSearch&&b.exactSearch(n,t)||"some"===d.fullTextSearch&&b.wordSearch(n,t)||"all"===d.fullTextSearch&&b.wordSearch(n,t,!0)?i(o,s):!0===d.fullTextSearch&&b.fuzzySearch(n,t)&&i(c,s)}})}),k.merge(o,c),k.merge(a,o),a}},exactSearch:function(e,t){return d.ignoreSearchCase&&(e=e.toLowerCase(),t=t.toLowerCase()),-1<t.indexOf(e)},wordSearch:function(e,t,s){for(var r=e.split(/\s+/),n=r.length,i=!1,a=0;a<n&&!(!(i=b.exactSearch(r[a],t))&&s||i&&!s);a++);return i},fuzzySearch:function(e,t){var s=t.length,r=e.length;if("string"!=typeof e)return!1;if(d.ignoreSearchCase&&(e=e.toLowerCase(),t=t.toLowerCase()),s<r)return!1;if(r===s)return e===t;for(var n=0,i=0;n<r;n++){for(var a=!1,o=e.charCodeAt(n);i<s;)if(t.charCodeAt(i++)===o){a=!0;break}if(!a)return!1}return!0},parse:{response:function(e,t){Array.isArray(e)&&((s={})[u.results]=e,e=s);var s=b.generateResults(e);b.verbose("Parsing server response",e),void 0!==e&&void 0!==t&&void 0!==e[u.results]&&(b.addResults(s),b.inject.id(e[u.results]),b.write.cache(t,{html:s,results:e[u.results]}),b.save.results(e[u.results]))}},cancel:{query:function(){b.can.useAPI()&&p.api("abort")}},has:{minimumCharacters:function(){return b.get.value().length>=d.minCharacters},results:function(){return 0!==i.length&&""!==i.html()}},clear:{cache:function(e){var t=p.data(c.cache);e?t&&t[e]&&(b.debug("Removing value from cache",e),delete t[e],p.data(c.cache,t)):(b.debug("Clearing cache",e),p.removeData(c.cache))}},read:{cache:function(e){var t=p.data(c.cache);return!!d.cache&&(b.verbose("Checking cache for generated html for query",e),"object"==typeof t&&void 0!==t[e]&&t[e])}},create:{categoryResults:function(e){var s={};return k.each(e,function(e,t){t.category&&(void 0===s[t.category]?(b.verbose("Creating new category of results",t.category),s[t.category]={name:t.category,results:[t]}):s[t.category].results.push(t))}),s},id:function(e,t){var s,e=e+1;return void 0!==t?(t=String.fromCharCode(97+t),b.verbose("Creating category result id",s=t+e)):b.verbose("Creating result id",s=e),s},results:function(){0===i.length&&(i=k("<div />").addClass(f.results).appendTo(p))}},inject:{result:function(e,t,s){b.verbose("Injecting result into results");s=(void 0!==s?i.children().eq(s).children(g.results).first():i).children(g.result).eq(t);b.verbose("Injecting results metadata",s),s.data(c.result,e)},id:function(e){b.debug("Injecting unique ids into results");var s=0,r=0;return"category"===d.type?k.each(e,function(e,t){0<t.results.length&&(r=0,k.each(t.results,function(e,t){void 0===t.id&&(t.id=b.create.id(r,s)),b.inject.result(t,r,s),r++}),s++)}):k.each(e,function(e,t){void 0===t.id&&(t.id=b.create.id(r)),b.inject.result(t,r),r++}),e}},save:{results:function(e){b.verbose("Saving current search results to metadata",e),p.data(c.results,e)}},write:{cache:function(e,t){var s=void 0!==p.data(c.cache)?p.data(c.cache):{};d.cache&&(b.verbose("Writing generated html to cache",e,t),s[e]=t,p.data(c.cache,s))}},addResults:function(e){if(D(d.onResultsAdd)&&!1===d.onResultsAdd.call(i,e))return b.debug("onResultsAdd callback cancelled default action"),!1;e?(i.html(e),b.refreshResults(),d.selectFirstResult&&b.select.firstResult(),b.showResults()):b.hideResults(function(){i.empty()})},showResults:function(e){e=D(e)?e:function(){},y||!b.is.visible()&&b.has.results()&&(b.can.transition()?(b.debug("Showing results with css animations"),i.transition({animation:d.transition+" in",debug:d.debug,verbose:d.verbose,silent:d.silent,duration:d.duration,onShow:function(){var e=p.find(g.result).eq(0);b.ensureVisible(e)},onComplete:function(){e()},queue:!0})):(b.debug("Showing results with javascript"),i.stop().fadeIn(d.duration,d.easing)),d.onResultsOpen.call(i))},hideResults:function(e){e=D(e)?e:function(){},b.is.visible()&&(b.can.transition()?(b.debug("Hiding results with css animations"),i.transition({animation:d.transition+" out",debug:d.debug,verbose:d.verbose,silent:d.silent,duration:d.duration,onComplete:function(){e()},queue:!0})):(b.debug("Hiding results with javascript"),i.stop().fadeOut(d.duration,d.easing)),d.onResultsClose.call(i))},generateResults:function(i){b.debug("Generating html from response",i);var e,t,s,a,o,r=d.templates[d.type],n=k.isPlainObject(i[u.results])&&!k.isEmptyObject(i[u.results]),c=Array.isArray(i[u.results])&&0<i[u.results].length,l="";return n||c?(0<d.maxResults&&(n?"standard"===d.type&&b.error(h.maxResults):i[u.results]=i[u.results].slice(0,d.maxResults)),d.highlightMatches&&(c=i[u.results],n=d.ignoreSearchCase?"i":"",e=b.get.value().split(""),t=d.ignoreDiacritics?"[̀-ͯ]?":"",s="(?![^<]*>)",a=new RegExp(s+"("+e.join(t+")(.*?)"+s+"(")+t+")",n),o=function(){return[].slice.call(arguments,1,2*e.length).map(function(e,t){return 1&t?e:"<mark>"+e+"</mark>"}).join("")},k.each(c,function(r,n){k.each(d.searchFields,function(e,t){var s;"string"!=typeof n[t]&&"number"!=typeof n[t]||(s="string"==typeof n[t]?n[t]:n[t].toString(),s=(s=d.ignoreDiacritics?s.normalize("NFD"):s).replace(/<\/?mark>/g,""),i[u.results][r][t]=s.replace(a,o))})})),D(r)?l=r(i,u,d.preserveHTML):b.error(h.noTemplate,!1)):d.showNoResults&&(l=b.displayMessage(h.noResults,"empty",h.noResultsHeader)),d.onResults.call(m,i),l},displayMessage:function(e,t,s){return b.debug("Displaying message",e,t=t||"standard",s),b.addResults(d.templates.message(e,t,s)),d.templates.message(e,t,s)},setting:function(e,t){if(k.isPlainObject(e))k.extend(!0,d,e);else{if(void 0===t)return d[e];d[e]=t}},internal:function(e,t){if(k.isPlainObject(e))k.extend(!0,b,e);else{if(void 0===t)return b[e];b[e]=t}},debug:function(){!d.silent&&d.debug&&(d.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,d.name+":"),b.debug.apply(console,arguments)))},verbose:function(){!d.silent&&d.verbose&&d.debug&&(d.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,d.name+":"),b.verbose.apply(console,arguments)))},error:function(){d.silent||(b.error=Function.prototype.bind.call(console.error,console,d.name+":"),b.error.apply(console,arguments))},performance:{log:function(e){var t,s;d.performance&&(s=(t=Date.now())-(C||t),C=t,w.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:m,"Execution Time":s})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(function(){b.performance.display()},500)},display:function(){var e=d.name+":",s=0;C=!1,clearTimeout(b.performance.timer),k.each(w,function(e,t){s+=t["Execution Time"]}),e+=" "+s+"ms",1<x.length&&(e+=" ("+x.length+")"),0<w.length&&(console.groupCollapsed(e),console.table?console.table(w):k.each(w,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),w=[]}},invoke:function(r,e,t){var n,i,s,a=o;return e=e||j,t=t||m,"string"==typeof r&&void 0!==a&&(r=r.split(/[ .]/),n=r.length-1,k.each(r,function(e,t){var s=e!==n?t+r[e+1].charAt(0).toUpperCase()+r[e+1].slice(1):r;if(k.isPlainObject(a[s])&&e!==n)a=a[s];else{if(void 0!==a[s])return i=a[s],!1;{if(!k.isPlainObject(a[t])||e===n)return void 0!==a[t]?i=a[t]:b.error(h.method,r),!1;a=a[t]}}})),D(i)?s=i.apply(t,e):void 0!==i&&(s=i),Array.isArray(S)?S.push(s):void 0!==S?S=[S,s]:void 0!==s&&(S=s),i}};A?(void 0===o&&b.initialize(),b.invoke(T)):(void 0!==o&&o.invoke("destroy"),b.initialize())}),void 0!==S?S:this},k.fn.search.settings={name:"Search",namespace:"search",silent:!1,debug:!1,verbose:!1,performance:!0,type:"standard",minCharacters:1,selectFirstResult:!1,apiSettings:!1,source:!1,searchOnFocus:!0,searchFields:["id","title","description"],displayField:"",fullTextSearch:"exact",highlightMatches:!1,ignoreDiacritics:!1,ignoreSearchCase:!0,automatic:!0,hideDelay:0,searchDelay:200,maxResults:7,cache:!0,showNoResults:!0,preserveHTML:!0,transition:"scale",duration:200,easing:"easeOutExpo",onSelect:!1,onResultsAdd:!1,onSearchQuery:function(e){},onResults:function(e,t){},onResultsOpen:function(){},onResultsClose:function(){},className:{animating:"animating",active:"active",category:"category",empty:"empty",focus:"focus",hidden:"hidden",loading:"loading",results:"results",pressed:"down"},error:{source:"Cannot search. No source used, and Fomantic API module was not included",noResultsHeader:"No Results",noResults:"Your search returned no results",noTemplate:"A valid template name was not specified.",oldSearchSyntax:"searchFullText setting has been renamed fullTextSearch for consistency, please adjust your settings.",serverError:"There was an issue querying the server.",maxResults:"Results must be an array to use maxResults setting",method:"The method you called is not defined.",noNormalize:'"ignoreDiacritics" setting will be ignored. Browser does not support String().normalize(). You may consider including <https://cdn.jsdelivr.net/npm/unorm@1.4.1/lib/unorm.min.js> as a polyfill.'},metadata:{cache:"cache",results:"results",result:"result"},regExp:{escape:/[$()*+./?[\\\]^{|}-]/g,beginsWith:"(?:\\s|^)"},fields:{categories:"results",categoryName:"name",categoryResults:"results",description:"description",image:"image",price:"price",results:"results",title:"title",url:"url",action:"action",actionText:"text",actionURL:"url"},selector:{prompt:".prompt",searchButton:".search.button",results:".results",message:".results > .message",category:".category",result:".result",title:".title, .name"},templates:{escape:function(e,t){if(t)return e;var s={"<":"<",">":">",'"':""","'":"'","`":"`"};return e=/["&'<>`]/.test(e)?(e=(e=e.replace(/&(?![\d#a-z]{1,12};)/gi,"&")).replace(/["'<>`]/g,function(e){return s[e]})).replace(/<(\/)*mark>/g,"<$1mark>"):e},message:function(e,t,s){var r="";return void 0!==e&&void 0!==t&&(r+='<div class="message '+t+'">',s&&(r+='<div class="header">'+s+"</div>"),r=r+' <div class="description">'+e+"</div></div>"),r},category:function(e,s,r){var n="",i=k.fn.search.settings.templates.escape;return void 0!==e[s.categoryResults]&&(k.each(e[s.categoryResults],function(e,t){void 0!==t[s.results]&&0<t.results.length&&(n+='<div class="category">',void 0!==t[s.categoryName]&&(n+='<div class="name">'+i(t[s.categoryName],r)+"</div>"),n+='<div class="results">',k.each(t.results,function(e,t){n+=t[s.url]?'<a class="result" href="'+t[s.url].replace(/"/g,"")+'">':'<a class="result">',void 0!==t[s.image]&&(n+='<div class="image"> <img src="'+t[s.image].replace(/"/g,"")+'"></div>'),n+='<div class="content">',void 0!==t[s.price]&&(n+='<div class="price">'+i(t[s.price],r)+"</div>"),void 0!==t[s.title]&&(n+='<div class="title">'+i(t[s.title],r)+"</div>"),void 0!==t[s.description]&&(n+='<div class="description">'+i(t[s.description],r)+"</div>"),n+="</div></a>"}),n+="</div></div>")}),e[s.action]&&(n+=!1===s.actionURL?'<div class="action">'+i(e[s.action][s.actionText],r)+"</div>":'<a href="'+e[s.action][s.actionURL].replace(/"/g,"")+'" class="action">'+i(e[s.action][s.actionText],r)+"</a>"),n)},standard:function(e,s,r){var n="",i=k.fn.search.settings.templates.escape;return void 0!==e[s.results]&&(k.each(e[s.results],function(e,t){n+=t[s.url]?'<a class="result" href="'+t[s.url].replace(/"/g,"")+'">':'<a class="result">',void 0!==t[s.image]&&(n+='<div class="image"> <img src="'+t[s.image].replace(/"/g,"")+'"></div>'),n+='<div class="content">',void 0!==t[s.price]&&(n+='<div class="price">'+i(t[s.price],r)+"</div>"),void 0!==t[s.title]&&(n+='<div class="title">'+i(t[s.title],r)+"</div>"),void 0!==t[s.description]&&(n+='<div class="description">'+i(t[s.description],r)+"</div>"),n+="</div></a>"}),e[s.action]&&(n+=!1===s.actionURL?'<div class="action">'+i(e[s.action][s.actionText],r)+"</div>":'<a href="'+e[s.action][s.actionURL].replace(/"/g,"")+'" class="action">'+i(e[s.action][s.actionText],r)+"</a>"),n)}}},k.extend(k.easing,{easeOutExpo:function(e){return 1===e?1:1-Math.pow(2,-10*e)}})}(jQuery,window,document);
|
package/dist/components/shape.js
CHANGED