-
Notifications
You must be signed in to change notification settings - Fork 6
/
category-results-materialize.html
134 lines (119 loc) · 4.47 KB
/
category-results-materialize.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html ng-app="demoApp">
<head>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, width=device-width">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.8/css/materialize.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<style>
ngc-omnibox {
position: relative;
display: block;
}
.collection {
position: absolute;
top: 100%;
left: 0;
right: 0;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
max-height: 500px;
background: white;
}
dl, dt, dd {
margin: 0;
}
.collection-item strong {
color: #fdd835;
}
.omniboxField [readonly] {
opacity: 0.5;
}
/* Small work around Materialize so input field takes up the remainder of the space from chips */
.chips {
display: flex;
flex-wrap: wrap;
align-items: center;
}
.chips .input {
width: 100% !important;
font-size: 16px; /* stops iOS Safari from zooming in */
}
.omniboxField {
flex-grow: 1;
flex-basis: 200px;
}
</style>
</head>
<body>
<main class="container" ng-controller="OmniboxExampleController as demo">
<h3>Categorized Results Example - Materialize CSS Framework</h3>
<h4>Search For a U.S. Senator by State</h4>
<ngc-omnibox
ng-model="demo.model"
is-selectable="demo.isSelectable(suggestion)"
multiple="true"
source="demo.sourceFn(query)"
require-match="true">
<div class="chips" ng-class="{'focus': demoCtrl.fieldHasFocus}">
<div ngc-omnibox-choices>
<div class="chip"
ng-class="{
'selected': omnibox.isChoiceHighlighted(choice),
'red lighten-3': choice.party === 'Republican',
'blue lighten-3': choice.party === 'Democrat'
}">
{{choice.person.name}}
<i class="close material-icons" ng-click="omnibox.unchoose(choice)">
close
</i>
</div>
</div>
<div class="omniboxField" ngc-omnibox-field ng-focus="demoCtrl.fieldHasFocus = true"
ng-blur="demoCtrl.fieldHasFocus = false">
<input class="input" type="text" autofocus="true"
placeholder="Search for a US Senator by Name or Party">
</div>
</div>
<div ngc-omnibox-suggestions class="collection with-header">
<dl ngc-omnibox-suggestions-category>
<dt class="collection-header">
<h5 ngc-omnibox-suggestions-header
ng-class="{'active': omnibox.isHighlighted(suggestion)}">
{{suggestion.state}}
</h5>
</dt>
<dd>
<div ngc-omnibox-suggestions-item class="collection-item"
ng-class="{'active': omnibox.isHighlighted(suggestion)}">
<h6>
<span ng-bind-html="suggestion.person.firstname | ngcOmniboxHighlightMatch:omnibox.query">
</span>
<span ng-bind-html="suggestion.person.lastname | ngcOmniboxHighlightMatch:omnibox.query:'<strong class=\'orange-text lighten-4\'>$&</strong>'">
</span>
</h6>
<em>
{{suggestion.description}} —
<span ng-bind-html="suggestion.party | ngcOmniboxHighlightMatch:omnibox.query:'<strong class=\'deep-purple-text lighten-4\'>$&</strong>'"></span>
</em>
</div>
</dd>
</dl>
<div ngc-omnibox-suggestions-loading class="progress">
<div class="indeterminate"></div>
</div>
<div ngc-omnibox-suggestions-empty class="center-align">
<span class="blue-grey-text text-lighten-3">No results...</span>
</div>
</div>
</ngc-omnibox>
<p>
Model value:
<pre><code style="white-space: pre-line">{{demo.model}}</code></pre>
</p>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.6/angular.js"></script>
<script src="https://rawgit.com/wouter2203/fuzzy-search/master/dist/FuzzySearch.js"></script>
<script src="../dist/ngc-omnibox.js"></script>
<script src="./category-results.js"></script>
</body>
</html>