-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.html
90 lines (74 loc) · 2.76 KB
/
results.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!-- results needs to have its own controller; used model paths:
* results
* options.multiple
* message
* loading
-->
<index:>
{{if options.multiple == false}}
<view is="dropdown:search" as="search" />
{{/}}
<span class="select2-results">
<ul as="results" id="{{@id}}" class="select2-results__options" role="listbox"
aria-multiselectable="{{options.multiple ? 'true' : 'false'}}" aria-expanded="true">
{{if message}}
<view is="results-message" message="{{message}}" />
{{else}}
{{each results as #data}}
<view is="results-option" data="{{#data}}" />
{{else}}
<view is="results-message" message="noResults" />
{{/each}}
{{/}}
{{if loading}}
<li role="treeitem" class="select2-results__option" aria-disabled="true">
{{loading}}
</li>
{{/}}
</ul>
</span>
<results-message:>
<li role="alert" aria-live="assertive" class="select2-results__option select2-results__message">
{{@message}}
</li>
<!-- attributes: item; it can be anything, but if it is an object, those attributes are used and should be
supplied to select2 as input:
* id
* title
* children
* disabled
* selected
data: {
item: item,
id: item.id,
title: item.title,
children: item.children,
disabled: item.disabled,
selected: true/false
}
-->
<results-option:>
<li id="{{@data.id}}" class="select2-results__option{{if highlighted.item === @data.item}} select2-results__option--highlighted{{/}}"
title="{{@data.title}}"
role="{{@data.children ? 'group' : 'option'}}"
on-mouseenter="highlight(@data, $event)"
on-mouseup="select(@data, $event)"
aria-label="{{if @data.children}}{{@data.text}}{{/}}"
aria-selected="{{[email protected] && [email protected] && @data.selected ? 'true' : 'false'}}"
aria-disabled="{{@data.disabled}}">
{{if @data.children}}
<strong class="select2-results__group">
<view is="results-template" data="{{@data}}" />
</strong>
<ul class="select2-results__options select2-results__options--nested">
{{each @data.children as #child}}
<view is="results-option" data="{{#child}}" />
{{/}}
</ul>
{{else}}
<view is="{{options.resultsTemplate}}" item="{{@data.item}}" />
{{/}}
</li>
<!-- plain item display; users have to provide a different view to change/"normalize" display of an item -->
<results-template:>
{{@item.text}}