@searchstax-inc/searchstudio-ux-js 0.1.5 → 0.3.1
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/README.md +221 -167
- package/README.mustache +154 -167
- package/dist/@searchstax-inc/searchstudio-ux-js.cjs +75 -8
- package/dist/@searchstax-inc/searchstudio-ux-js.d.mts +105 -36
- package/dist/@searchstax-inc/searchstudio-ux-js.d.ts +105 -36
- package/dist/@searchstax-inc/searchstudio-ux-js.iife.js +75 -8
- package/dist/@searchstax-inc/searchstudio-ux-js.mjs +915 -526
- package/dist/styles/mainTheme.css +42 -2
- package/dist/styles/scss/mainTheme.scss +4 -0
- package/dist/styles/scss/widgets/externalPromotions/style.scss +0 -0
- package/dist/styles/scss/widgets/relatedSearches/style.scss +7 -0
- package/dist/styles/scss/widgets/searchFeedback/style.scss +4 -0
- package/dist/styles/scss/widgets/searchInput/style.scss +1 -0
- package/dist/styles/scss/widgets/searchResults/style.scss +2 -2
- package/dist/styles/scss/widgets/sorting/style.scss +35 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -28,35 +28,7 @@ After importing Searchstax class a new instance needs to be created:
|
|
|
28
28
|
```const searchstax = new Searchstax();```
|
|
29
29
|
|
|
30
30
|
## Initialization
|
|
31
|
-
Initialization object
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
`language: string;` - language code. Example: 'en'
|
|
36
|
-
|
|
37
|
-
`searchURL: string;` - SeachStudio select endpoint
|
|
38
|
-
|
|
39
|
-
`suggesterURL: string;` - SeachStudio suggest endpoint
|
|
40
|
-
|
|
41
|
-
`trackApiKey: string;` - Api key used for tracking events
|
|
42
|
-
|
|
43
|
-
`searchAuth: string;` - Authentication value. based on authType it's either a token value or basic auth value
|
|
44
|
-
|
|
45
|
-
`authType: 'token' | 'basic';` - Type of authentication
|
|
46
|
-
|
|
47
|
-
`router: {` - optional object containing router settings
|
|
48
|
-
|
|
49
|
-
'enabled: boolean' - if enabled navigation will history and will keep track of search state
|
|
50
|
-
|
|
51
|
-
'routeName: string' - prefix name for all search properties
|
|
52
|
-
|
|
53
|
-
'title: (result: ISearchObject) => string' - function that will update page title
|
|
54
|
-
|
|
55
|
-
`ignoredKeys: string[]` - array of keys to ignore and not keep track of
|
|
56
|
-
|
|
57
|
-
`}`
|
|
58
|
-
|
|
59
|
-
}
|
|
31
|
+
Initialization object needs to be of type: [ISearchstaxConfig](https://github.com/searchstax/searchstudio-ux-js/blob/main/src/interfaces/connector.interface.ts#L5)
|
|
60
32
|
|
|
61
33
|
Initialization example
|
|
62
34
|
```
|
|
@@ -75,6 +47,16 @@ searchstax.initialize({
|
|
|
75
47
|
return "Search results for: " + result.query;
|
|
76
48
|
},
|
|
77
49
|
ignoredKeys: [],
|
|
50
|
+
},
|
|
51
|
+
hooks: {
|
|
52
|
+
beforeSearch: function (props: ISearchObject) {
|
|
53
|
+
const propsCopy = { ...props };
|
|
54
|
+
return propsCopy;
|
|
55
|
+
},
|
|
56
|
+
afterSearch: function (results: ISearchstaxParsedResult[]) {
|
|
57
|
+
const copy = [...results];
|
|
58
|
+
return copy;
|
|
59
|
+
},
|
|
78
60
|
}
|
|
79
61
|
});
|
|
80
62
|
```
|
|
@@ -105,40 +87,31 @@ Our base theme is designed with this layout in mind but it is optional as all wi
|
|
|
105
87
|
</div>
|
|
106
88
|
```
|
|
107
89
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
a. id of container where widget will be rendered
|
|
90
|
+
### widgets
|
|
91
|
+
Following widgets are available:
|
|
112
92
|
|
|
113
|
-
|
|
93
|
+
[Input Widget](#input-widget)
|
|
114
94
|
|
|
115
|
-
|
|
95
|
+
[Result Widget](#result-widget)
|
|
116
96
|
|
|
117
|
-
|
|
97
|
+
[Facets Widget](#facets-widget)
|
|
118
98
|
|
|
119
|
-
|
|
120
|
-
`template: string;` - main template in Mustache templating language
|
|
121
|
-
`searchInputId: string;` - id of search input within the mainTemplate
|
|
122
|
-
`};`
|
|
99
|
+
[Pagination Widget](#pagination-widget)
|
|
123
100
|
|
|
124
|
-
|
|
125
|
-
`template: string;` - autosuggest template in Mustache templating language
|
|
126
|
-
`};`
|
|
127
|
-
`};`
|
|
101
|
+
[SearchFeedback Widget](#searchfeedback-widget)
|
|
128
102
|
|
|
129
|
-
|
|
103
|
+
[RelatedSearches Widget](#relatedsearches-widget)
|
|
130
104
|
|
|
131
|
-
|
|
105
|
+
[ExternalPromotions Widget](#externalpromotions-widget)
|
|
132
106
|
|
|
133
|
-
|
|
107
|
+
[sorting Widget](#sorting-widget)
|
|
134
108
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
`afterAutosuggest?: (result: ISearchstaxSuggestResponse) => ISearchstaxSuggestResponse;`- this function gets called after autosuggest has values but before rendering. It needs to return same type of data but it can be modified.
|
|
109
|
+
### Input Widget ###
|
|
110
|
+
Initialization properties
|
|
138
111
|
|
|
139
|
-
|
|
112
|
+
a. id of container where widget will be rendered
|
|
140
113
|
|
|
141
|
-
|
|
114
|
+
b. Input widget config object of type: [ISearchstaxSearchInputConfig](https://github.com/searchstax/searchstudio-ux-js/blob/main/src/interfaces/searchInputConfig.interface.ts#L4)
|
|
142
115
|
|
|
143
116
|
|
|
144
117
|
example of input widget initialization with minimum options
|
|
@@ -154,15 +127,6 @@ example of input widget initialization with various options
|
|
|
154
127
|
searchstax.addSearchInputWidget("searchstax-input-container", {
|
|
155
128
|
suggestAfterMinChars: 3,
|
|
156
129
|
hooks: {
|
|
157
|
-
beforeSearch: function (props: ISearchObject) {
|
|
158
|
-
const propsCopy = { ...props };
|
|
159
|
-
return propsCopy;
|
|
160
|
-
},
|
|
161
|
-
afterSearch: function (results: ISearchstaxParsedResult[]) {
|
|
162
|
-
const copy = [...results];
|
|
163
|
-
// copy.splice(0, 1);
|
|
164
|
-
return copy;
|
|
165
|
-
},
|
|
166
130
|
afterAutosuggest: function (result: ISearchstaxSuggestResponse) {
|
|
167
131
|
const copy = { ...result };
|
|
168
132
|
return copy;
|
|
@@ -195,39 +159,12 @@ example of input widget initialization with various options
|
|
|
195
159
|
},
|
|
196
160
|
});
|
|
197
161
|
```
|
|
198
|
-
|
|
162
|
+
### Result Widget ###
|
|
199
163
|
Initialization properties
|
|
200
164
|
|
|
201
165
|
a. id of container where widget will be rendered
|
|
202
166
|
|
|
203
|
-
b.
|
|
204
|
-
|
|
205
|
-
`searchResultUniqueIdAttribute?: string;` - this is needed only if searchResultTemplate is overridden. searchResultTemplate needs to have unique result id property. Default is data-searchstax-unique-result-id="uniqueId". see example below on how it is used
|
|
206
|
-
|
|
207
|
-
`templates?: {` - optional object that defines template override options
|
|
208
|
-
|
|
209
|
-
`mainTemplate?: {`
|
|
210
|
-
template: string; - main template in Mustache templating language.,
|
|
211
|
-
searchResultsContainerId: string;` - this is needed only if mainTemplate is overridden. It points to an element in the template where results need to be rendered
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
`searchResultTemplate?: {`
|
|
215
|
-
template: string - result template using Mustache. ISearchstaxParsedResult is passed to the template and all its properties are available to be used when rendering;
|
|
216
|
-
searchResultUniqueIdAttribute?: string - this is needed only if searchResultTemplate is overridden. searchResultTemplate needs to have unique result id property. Default is data-searchstax-unique-result-id="niqueId". see example below on how it is used
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
`noSearchResultTemplate?: {`
|
|
220
|
-
template: string - Mustache template for no results section override. spellingSuggestion and searchTerm are values available in the template
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
`};`
|
|
224
|
-
|
|
225
|
-
`hooks?: {` - optional object that provides various hook options
|
|
226
|
-
|
|
227
|
-
`afterLinkClick?: (resultClicked: ISearchstaxParsedResult) => ISearchstaxParsedResult | null;` - function is called after user clicks result and passes that result as a property. when result is passed along tracking will execute and user will be navigated if null is returned events are canceled and nothing happens.
|
|
228
|
-
|
|
229
|
-
`};`
|
|
230
|
-
}
|
|
167
|
+
b. Result widget config object of type: [ISearchstaxSearchResultsConfig](https://github.com/searchstax/searchstudio-ux-js/blob/main/src/interfaces/searchResultsConfig.interface.ts#L3)
|
|
231
168
|
|
|
232
169
|
example of results widget initialization with minimum options
|
|
233
170
|
```
|
|
@@ -325,23 +262,12 @@ example of result widget initialization with various options
|
|
|
325
262
|
});
|
|
326
263
|
```
|
|
327
264
|
|
|
328
|
-
|
|
265
|
+
### Pagination Widget ###
|
|
329
266
|
Initialization properties
|
|
330
267
|
|
|
331
268
|
a. id of container where widget will be rendered
|
|
332
269
|
|
|
333
|
-
b.
|
|
334
|
-
|
|
335
|
-
`templates?: {` - optional object that defines template override options
|
|
336
|
-
|
|
337
|
-
`mainTemplate?: {` - optional object for overriding main template
|
|
338
|
-
`template: string;` - main template in Mustache templating language
|
|
339
|
-
`previousButtonClass: string;` - class of previous page link within template,
|
|
340
|
-
`nextButtonClass: string;` - class of next page link within template,
|
|
341
|
-
`};`
|
|
342
|
-
`};`
|
|
343
|
-
|
|
344
|
-
}
|
|
270
|
+
b. Pagination widget config object of type: [ISearchstaxSearchPaginationConfig](https://github.com/searchstax/searchstudio-ux-js/blob/main/src/interfaces/searchPaginationConfig.interface.ts#L1)
|
|
345
271
|
|
|
346
272
|
example of pagination widget initialization with minimum options
|
|
347
273
|
```
|
|
@@ -373,68 +299,12 @@ example of pagination widget initialization with various options
|
|
|
373
299
|
});
|
|
374
300
|
```
|
|
375
301
|
|
|
376
|
-
|
|
302
|
+
### Facets Widget ###
|
|
377
303
|
Initialization properties
|
|
378
304
|
|
|
379
305
|
a. id of container where widget will be rendered
|
|
380
306
|
|
|
381
|
-
b.
|
|
382
|
-
|
|
383
|
-
`facetingType`: "and" | "or" | "showUnavailable" - type that determines how facets will behave,
|
|
384
|
-
|
|
385
|
-
`itemsPerPageDesktop`: number - default expanded facets for desktop,
|
|
386
|
-
|
|
387
|
-
`itemsPerPageMobile`: number - default expanded facets for mobile,
|
|
388
|
-
|
|
389
|
-
`templates?: {` - optional object that defines template override options
|
|
390
|
-
|
|
391
|
-
`mainTemplateDesktop?: {` - optional object for overriding main template
|
|
392
|
-
`template: string;` - main template in Mustache templating language
|
|
393
|
-
`facetsContainerClass: string;` - class of container where facets will be placed
|
|
394
|
-
`},`
|
|
395
|
-
|
|
396
|
-
`mainTemplateMobile?: {` - optional object for overriding main mobile template
|
|
397
|
-
`template: string;` - main template in Mustache templating language
|
|
398
|
-
`facetsContainerId: string;` - id of container where facets will be placed
|
|
399
|
-
`closeOverlayTriggerClasses: string[];` - class list of all elements that should trigger mobile overlay close action
|
|
400
|
-
`filterByContainerId: string` - id of container where "Filter By" button will be rendered
|
|
401
|
-
'selectedFacetsContainerId: string' - id of container where selected facets will be listed
|
|
402
|
-
`},`
|
|
403
|
-
|
|
404
|
-
`showMoreButtonContainerTemplate?: {` - optional object for overriding facet section show more/less template
|
|
405
|
-
`template: string;` - main template in Mustache templating language
|
|
406
|
-
`showMoreButtonClass: string;` - class of container where show more/less button will be placed
|
|
407
|
-
`},`
|
|
408
|
-
|
|
409
|
-
`facetItemContainerTemplate?: {` - optional object for overriding facet container template
|
|
410
|
-
`template: string;` - main template in Mustache templating language
|
|
411
|
-
'facetListTitleContainerClass: string;' - container class where facet category title will be rendered within template
|
|
412
|
-
`facetListContainerClass: string;` - container class where facet items will be listed
|
|
413
|
-
`},`
|
|
414
|
-
|
|
415
|
-
`clearFacetsTemplate?: {` - optional object for overriding clear facets container template
|
|
416
|
-
`template: string;` - main template in Mustache templating language
|
|
417
|
-
'containerId: string;' - container id where clear facets button will be rendered
|
|
418
|
-
`},`
|
|
419
|
-
|
|
420
|
-
`facetItemTemplate?: {` - optional object for overriding clear facet item template
|
|
421
|
-
`template: string;` - main template in Mustache templating language
|
|
422
|
-
'inputCheckboxClass: string;' - class of checkboxes
|
|
423
|
-
'checkTriggerClasses: string[];' - class list of elements that trigger facet select/unselect action
|
|
424
|
-
`},`
|
|
425
|
-
|
|
426
|
-
`filterByTemplate?: {` - optional object for overriding filter by button template
|
|
427
|
-
`template: string;` - main template in Mustache templating language
|
|
428
|
-
'containerId: string;' - id where button will be placed within the template
|
|
429
|
-
`},`
|
|
430
|
-
|
|
431
|
-
`selectedFacetsTemplate?: {` - optional object for overriding selected facets template
|
|
432
|
-
`template: string;` - main template in Mustache templating language
|
|
433
|
-
'containerId: string;' - id where selected facets will be placed within the template
|
|
434
|
-
`},`
|
|
435
|
-
`};`
|
|
436
|
-
|
|
437
|
-
}
|
|
307
|
+
b. Facets widget config object of type: [ISearchstaxSearchFacetsConfig](https://github.com/searchstax/searchstudio-ux-js/blob/main/src/interfaces/searchFacetsConfig.interface.ts#L1)
|
|
438
308
|
|
|
439
309
|
example of facets widget initialization with minimum options
|
|
440
310
|
```
|
|
@@ -478,10 +348,10 @@ example of facets widget initialization with various options
|
|
|
478
348
|
</div>
|
|
479
349
|
</div>
|
|
480
350
|
`,
|
|
481
|
-
|
|
351
|
+
facetsContainerClass: `searchstax-facets-container-mobile`,
|
|
482
352
|
closeOverlayTriggerClasses: ["searchstax-facets-mobile-overlay-done","searchstax-search-close",],
|
|
483
|
-
|
|
484
|
-
|
|
353
|
+
filterByContainerClass: `searchstax-facets-pills-container`,
|
|
354
|
+
selectedFacetsContainerClass: `searchstax-facets-pills-selected`,
|
|
485
355
|
},
|
|
486
356
|
showMoreButtonContainerTemplate: {
|
|
487
357
|
template: `
|
|
@@ -519,7 +389,7 @@ example of facets widget initialization with various options
|
|
|
519
389
|
</div>
|
|
520
390
|
{{/shouldShow}}
|
|
521
391
|
`,
|
|
522
|
-
|
|
392
|
+
containerClass: `searchstax-facets-pill-clear-all`,
|
|
523
393
|
},
|
|
524
394
|
facetItemTemplate: {
|
|
525
395
|
template: `
|
|
@@ -538,7 +408,7 @@ example of facets widget initialization with various options
|
|
|
538
408
|
<div class="searchstax-facets-pill-label">Filter By</div>
|
|
539
409
|
</div>
|
|
540
410
|
`,
|
|
541
|
-
|
|
411
|
+
containerClass: `searchstax-facets-pill-filter-by`,
|
|
542
412
|
},
|
|
543
413
|
selectedFacetsTemplate: {
|
|
544
414
|
template: `
|
|
@@ -547,13 +417,197 @@ example of facets widget initialization with various options
|
|
|
547
417
|
<div class="searchstax-facets-pill-icon-close"></div>
|
|
548
418
|
</div>
|
|
549
419
|
`,
|
|
550
|
-
|
|
420
|
+
containerClass: `searchstax-facets-pill-facets`,
|
|
551
421
|
},
|
|
552
422
|
|
|
553
423
|
},
|
|
554
424
|
});
|
|
555
425
|
```
|
|
556
426
|
|
|
427
|
+
### SearchFeedback Widget ###
|
|
428
|
+
Initialization properties
|
|
429
|
+
|
|
430
|
+
a. id of container where widget will be rendered
|
|
431
|
+
|
|
432
|
+
b. SearchFeedback widget config object of type: [ISearchstaxSearchFeedbackConfig](https://github.com/searchstax/searchstudio-ux-js/blob/main/src/interfaces/searchFeedbackConfig.interface.ts#L1)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
example of search feedback widget initialization with minimum options
|
|
436
|
+
```
|
|
437
|
+
searchstax.addSearchFeedbackWidget("search-feedback-container", {});
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
example of search feedback widget initialization with various options
|
|
442
|
+
```
|
|
443
|
+
searchstax.addSearchFeedbackWidget("search-feedback-container", {
|
|
444
|
+
templates: {
|
|
445
|
+
main: {
|
|
446
|
+
template: `
|
|
447
|
+
{{#searchExecuted}}
|
|
448
|
+
<div class="searchstax-feedback-container">
|
|
449
|
+
Showing <b>{{startResultIndex}} - {{endResultIndex}}</b> of <b>{{totalResults}}</b> results {{#searchTerm}} for "<b>{{searchTerm}}</b>" {{/searchTerm}}
|
|
450
|
+
</div>
|
|
451
|
+
{{/searchExecuted}}
|
|
452
|
+
`,
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
});
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
## RelatedSearches widget
|
|
459
|
+
Initialization properties
|
|
460
|
+
|
|
461
|
+
a. id of container where widget will be rendered
|
|
462
|
+
|
|
463
|
+
b. RelatedSearches widget config object of type: [ISearchstaxRelatedSearchesConfig](https://github.com/searchstax/searchstudio-ux-js/blob/main/src/interfaces/searchRelatedSearchesConfig.interface.ts#L1)
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
example of search feedback widget initialization with minimum options
|
|
467
|
+
```
|
|
468
|
+
searchstax.addRelatedSearchesWidget("searchstax-related-searches-container", {
|
|
469
|
+
relatedSearchesURL: "URL",
|
|
470
|
+
relatedSearchesAPIKey: "KEY"
|
|
471
|
+
})
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
example of search feedback widget initialization with various options
|
|
476
|
+
```
|
|
477
|
+
searchstax.addRelatedSearchesWidget("searchstax-related-searches-container", {
|
|
478
|
+
relatedSearchesURL: "URL",
|
|
479
|
+
relatedSearchesAPIKey: "KEY",
|
|
480
|
+
templates: {
|
|
481
|
+
main: {
|
|
482
|
+
template: `
|
|
483
|
+
{{#hasRelatedSearches}}
|
|
484
|
+
<div class="searchstax-related-searches-container" id="searchstax-related-searches-container">
|
|
485
|
+
Related searches: <span id="searchstax-related-searches"></span>
|
|
486
|
+
{{#relatedSearches}}
|
|
487
|
+
<span class="searchstax-related-search">
|
|
488
|
+
|
|
489
|
+
</span>
|
|
490
|
+
{{/relatedSearches}}
|
|
491
|
+
</div>
|
|
492
|
+
{{/hasRelatedSearches}}
|
|
493
|
+
`,
|
|
494
|
+
relatedSearchesContainerClass: `searchstax-related-search`,
|
|
495
|
+
},
|
|
496
|
+
relatedSearch: {
|
|
497
|
+
template: `
|
|
498
|
+
<span class="searchstax-related-search searchstax-related-search-item">
|
|
499
|
+
{{ related_search }}{{^last}}<span>,</span>{{/last}}
|
|
500
|
+
</span>
|
|
501
|
+
`,
|
|
502
|
+
relatedSearchContainerClass: `searchstax-related-search-item`,
|
|
503
|
+
},
|
|
504
|
+
},
|
|
505
|
+
});
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### ExternalPromotions widget ###
|
|
509
|
+
Initialization properties
|
|
510
|
+
|
|
511
|
+
a. id of container where widget will be rendered
|
|
512
|
+
|
|
513
|
+
b. ExternalPromotions widget config object of type: [ISearchstaxExternalPromotionsConfig](https://github.com/searchstax/searchstudio-ux-js/blob/main/src/interfaces/searchExternalPromotionsConfig.interface.ts#L1)
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
example of search feedback widget initialization with minimum options
|
|
517
|
+
```
|
|
518
|
+
searchstax.addExternalPromotionsWidget("searchstax-external-promotions-layout-container", {})
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
example of search feedback widget initialization with various options
|
|
523
|
+
```
|
|
524
|
+
searchstax.addExternalPromotionsWidget("searchstax-external-promotions-layout-container", {
|
|
525
|
+
templates: {
|
|
526
|
+
mainTemplate: {
|
|
527
|
+
template: `
|
|
528
|
+
{{#hasExternalPromotions}}
|
|
529
|
+
<div class="searchstax-external-promotions-container" id="searchstax-external-promotions-container">
|
|
530
|
+
External promotions go here
|
|
531
|
+
</div>
|
|
532
|
+
{{/hasExternalPromotions}}
|
|
533
|
+
`,
|
|
534
|
+
externalPromotionsContainerId: `searchstax-external-promotions-container`,
|
|
535
|
+
},
|
|
536
|
+
externalPromotion: {
|
|
537
|
+
template: `
|
|
538
|
+
<div class="searchstax-external-promotion searchstax-search-result">
|
|
539
|
+
<div class="icon-elevated"></div>
|
|
540
|
+
{{#url}}
|
|
541
|
+
<a href="{{url}}" data-searchstax-unique-result-id="{{uniqueId}}" class="searchstax-result-item-link"></a>
|
|
542
|
+
{{/url}}
|
|
543
|
+
<div class="searchstax-search-result-title-container">
|
|
544
|
+
<span class="searchstax-search-result-title">{{name}}</span>
|
|
545
|
+
</div>
|
|
546
|
+
{{#description}}
|
|
547
|
+
<p class="searchstax-search-result-description searchstax-search-result-common">
|
|
548
|
+
{{description}}
|
|
549
|
+
</p>
|
|
550
|
+
{{/description}}
|
|
551
|
+
{{#url}}
|
|
552
|
+
<p class="searchstax-search-result-description searchstax-search-result-common">
|
|
553
|
+
{{url}}
|
|
554
|
+
</p>
|
|
555
|
+
{{/url}}
|
|
556
|
+
</div>
|
|
557
|
+
</div>
|
|
558
|
+
`,
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
});
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
### Sorting Widget ###
|
|
566
|
+
Initialization properties
|
|
567
|
+
|
|
568
|
+
a. id of container where widget will be rendered
|
|
569
|
+
|
|
570
|
+
b. Sorting widget config object of type: [ISearchstaxSearchSortingConfig](https://github.com/searchstax/searchstudio-ux-js/blob/main/src/interfaces/searchSortingConfig.interface.ts#L1)
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
example of sorting widget initialization with minimum options
|
|
574
|
+
```
|
|
575
|
+
searchstax.addSearchSortingWidget("search-sorting-container", {});
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
example of sorting widget initialization with various options
|
|
580
|
+
```
|
|
581
|
+
searchstax.addSearchSortingWidget("search-sorting-container", {
|
|
582
|
+
templates: {
|
|
583
|
+
main: {
|
|
584
|
+
template: `
|
|
585
|
+
{{#searchExecuted}}
|
|
586
|
+
{{#hasResultsOrExternalPromotions}}
|
|
587
|
+
<div class="searchstax-sorting-container">
|
|
588
|
+
<label class="searchstax-sorting-label" for="sort-by">Sort By</label>
|
|
589
|
+
<select id="searchstax-search-order-select" class="searchstax-search-order-select">
|
|
590
|
+
<option value="">
|
|
591
|
+
Relevance
|
|
592
|
+
</option>
|
|
593
|
+
<option value="date desc">
|
|
594
|
+
Newest Content
|
|
595
|
+
</option>
|
|
596
|
+
<option value="date asc">
|
|
597
|
+
Oldest Content
|
|
598
|
+
</option>
|
|
599
|
+
</select>
|
|
600
|
+
</div>
|
|
601
|
+
{{/hasResultsOrExternalPromotions}}
|
|
602
|
+
{{/searchExecuted}}
|
|
603
|
+
`,
|
|
604
|
+
selectId: `searchstax-search-order-select`
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
});
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
|
|
557
611
|
## Template overrides
|
|
558
612
|
Templates use mustache templating. For more info see https://github.com/janl/mustache.js
|
|
559
613
|
|