73bcce88
luigser
COMPONENTS
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
<head>
|
a53fbbed
Renato De Donato
select-dataset ne...
|
15
|
<title>Select contacts</title>
|
73bcce88
luigser
COMPONENTS
|
16
17
18
19
20
21
22
23
24
25
|
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
|
73bcce88
luigser
COMPONENTS
|
26
|
<link rel="import" href="../../iron-ajax/iron-ajax.html">
|
e619a3b0
Luigi Serra
Controllet cross ...
|
27
|
<link rel="import" href="../../paper-icon-button/paper-icon-button.html">
|
73bcce88
luigser
COMPONENTS
|
28
29
|
<link rel="import" href="../../iron-icon/iron-icon.html">
<link rel="import" href="../../iron-icons/iron-icons.html">
|
a53fbbed
Renato De Donato
select-dataset ne...
|
30
31
32
|
<link rel="import" href="../../paper-styles/color.html">
<link rel="import" href="../../paper-styles/typography.html">
<link rel="import" href="../../app-layout/app-toolbar/app-toolbar.html">
|
e619a3b0
Luigi Serra
Controllet cross ...
|
33
34
35
|
<link rel="import" href="../../paper-menu/paper-menu.html">
<link rel="import" href="../../paper-item/paper-item.html">
<link rel="import" href="../../paper-badge/paper-badge.html">
|
eb240478
Luigi Serra
public room cards...
|
36
|
<link rel="import" href="../iron-list.html">
|
73bcce88
luigser
COMPONENTS
|
37
38
39
40
|
<dom-module id="x-app">
<style>
|
73bcce88
luigser
COMPONENTS
|
41
42
43
|
:host {
@apply(--layout-fit);
@apply(--layout-vertical);
|
e619a3b0
Luigi Serra
Controllet cross ...
|
44
|
@apply(--paper-font-common-base);
|
73bcce88
luigser
COMPONENTS
|
45
46
47
|
font-family: sans-serif;
}
|
a53fbbed
Renato De Donato
select-dataset ne...
|
48
|
app-toolbar {
|
e619a3b0
Luigi Serra
Controllet cross ...
|
49
|
background: var(--paper-pink-500);
|
a53fbbed
Renato De Donato
select-dataset ne...
|
50
51
52
53
54
55
56
57
58
59
|
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.3);
color: white;
z-index: 1;
color: white;
--paper-toolbar-title: {
font-size: 16px;
line-height: 16px;
font-weight: bold;
margin-left: 0;
};
|
73bcce88
luigser
COMPONENTS
|
60
61
|
}
|
a53fbbed
Renato De Donato
select-dataset ne...
|
62
|
app-toolbar paper-icon-button {
|
e619a3b0
Luigi Serra
Controllet cross ...
|
63
64
65
|
--paper-icon-button-ink-color: white;
}
|
a53fbbed
Renato De Donato
select-dataset ne...
|
66
|
#itemsList,
|
e619a3b0
Luigi Serra
Controllet cross ...
|
67
|
#selectedItemsList {
|
73bcce88
luigser
COMPONENTS
|
68
69
70
71
|
@apply(--layout-flex);
}
.item {
|
73bcce88
luigser
COMPONENTS
|
72
|
@apply(--layout-horizontal);
|
e619a3b0
Luigi Serra
Controllet cross ...
|
73
74
75
76
77
|
cursor: pointer;
padding: 16px 22px;
border-bottom: 1px solid #DDD;
}
|
eb240478
Luigi Serra
public room cards...
|
78
79
|
.item:focus,
.item.selected:focus {
|
e619a3b0
Luigi Serra
Controllet cross ...
|
80
|
outline: 0;
|
c5169e0e
Renato De Donato
a new hope
|
81
|
background-color: #ddd;
|
e619a3b0
Luigi Serra
Controllet cross ...
|
82
83
84
85
86
87
|
}
.item.selected .star {
color: var(--paper-blue-600);
}
|
a53fbbed
Renato De Donato
select-dataset ne...
|
88
89
90
|
.item.selected {
background-color: var(--google-grey-300);
border-bottom: 1px solid #ccc;
|
73bcce88
luigser
COMPONENTS
|
91
92
93
94
95
96
97
|
}
.avatar {
height: 40px;
width: 40px;
border-radius: 20px;
box-sizing: border-box;
|
a53fbbed
Renato De Donato
select-dataset ne...
|
98
|
background-color: #ddd;
|
73bcce88
luigser
COMPONENTS
|
99
100
101
|
}
.pad {
|
73bcce88
luigser
COMPONENTS
|
102
103
|
@apply(--layout-flex);
@apply(--layout-vertical);
|
e619a3b0
Luigi Serra
Controllet cross ...
|
104
|
padding: 0 16px;
|
73bcce88
luigser
COMPONENTS
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
}
.primary {
font-size: 16px;
}
.secondary {
font-size: 14px;
}
.dim {
color: gray;
}
|
e619a3b0
Luigi Serra
Controllet cross ...
|
119
|
.star {
|
73bcce88
luigser
COMPONENTS
|
120
121
122
123
|
width: 24px;
height: 24px;
}
|
e619a3b0
Luigi Serra
Controllet cross ...
|
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
paper-badge {
-webkit-transition: all 0.1s;
transition: all 0.1s;
opacity: 1;
margin-top: 5px;
}
paper-badge[label="0"] {
opacity: 0;
}
#starredView {
width: 200px;
border-left: 1px solid #ddd;
}
paper-item {
white-space: nowrap;
cursor: pointer;
position: relative;
}
|
eb240478
Luigi Serra
public room cards...
|
146
|
paper-item:hover::after {
|
e619a3b0
Luigi Serra
Controllet cross ...
|
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
content: "-";
width: 16px;
height: 16px;
display: block;
border-radius: 50% 50%;
background-color: var(--google-red-300);
margin-left: 10px;
line-height: 16px;
text-align: center;
color: white;
font-weight: bold;
text-decoration: none;
position: absolute;
right: 15px;
top: calc(50% - 8px);
}
.noSelection {
color: #999;
margin-left: 10px;
line-height: 50px;
}
|
a53fbbed
Renato De Donato
select-dataset ne...
|
170
171
172
173
174
175
176
177
178
179
|
.twoColumns {
@apply(--layout-flex);
@apply(--layout-horizontal);
overflow: hidden;
}
#starredView {
@apply(--layout-vertical);
}
|
73bcce88
luigser
COMPONENTS
|
180
181
182
|
</style>
<template>
|
73bcce88
luigser
COMPONENTS
|
183
184
|
<iron-ajax url="data/contacts.json" last-response="{{data}}" auto></iron-ajax>
|
a53fbbed
Renato De Donato
select-dataset ne...
|
185
186
187
|
<app-toolbar>
<div title>Selection using iron-list</div>
<div>
|
e619a3b0
Luigi Serra
Controllet cross ...
|
188
189
190
|
<paper-icon-button icon="icons:star" alt="Starred" on-tap="_toggleStarredView"></paper-icon-button>
<paper-badge label$="[[selectedItems.length]]"></paper-badge>
</div>
|
a53fbbed
Renato De Donato
select-dataset ne...
|
191
192
193
194
195
196
197
198
199
200
201
202
|
</app-toolbar>
<div class="twoColumns">
<!-- Main List for the items -->
<iron-list id="itemsList" items="[[data]]" selected-items="{{selectedItems}}" selection-enabled multi-selection>
<template>
<div>
<div tabindex$="[[tabIndex]]" aria-label$="Select/Deselect [[item.name]]" class$="[[_computedClass(selected)]]">
<img class="avatar" src="[[item.image]]">
<div class="pad">
<div class="primary">
[[item.name]]
|
e619a3b0
Luigi Serra
Controllet cross ...
|
203
|
</div>
|
a53fbbed
Renato De Donato
select-dataset ne...
|
204
|
<div class="secondary dim">[[item.shortText]]</div>
|
73bcce88
luigser
COMPONENTS
|
205
|
</div>
|
a53fbbed
Renato De Donato
select-dataset ne...
|
206
|
<iron-icon icon$="[[iconForItem(selected)]]" class="star"></iron-icon>
|
73bcce88
luigser
COMPONENTS
|
207
|
</div>
|
a53fbbed
Renato De Donato
select-dataset ne...
|
208
209
210
211
212
|
<div class="border"></div>
</div>
</template>
</iron-list>
<div id="starredView" hidden$="[[!showSelection]]">
|
e619a3b0
Luigi Serra
Controllet cross ...
|
213
214
215
216
217
218
|
<template is="dom-if" if="[[!selectedItems.length]]">
<div class="noSelection">Select a contact</div>
</template>
<!-- List for the selected items -->
<iron-list id="selectedItemsList" items="[[selectedItems]]" hidden$="[[!selectedItems.length]]">
<template>
|
a53fbbed
Renato De Donato
select-dataset ne...
|
219
|
<paper-item tabindex$="[[tabIndex]]" on-tap="_unselect" aria-label$="Deselect [[item.name]]">[[item.name]]</paper-item>
|
e619a3b0
Luigi Serra
Controllet cross ...
|
220
221
222
223
|
</template>
</iron-list>
</div>
</div>
|
73bcce88
luigser
COMPONENTS
|
224
225
226
227
228
229
230
231
232
233
234
|
</template>
</dom-module>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-app',
|
e619a3b0
Luigi Serra
Controllet cross ...
|
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
properties: {
selectedItems: {
type: Object
},
showSelection: {
type: Boolean,
value: true,
observer: '_showSelectionChanged'
}
},
iconForItem: function(isSelected) {
return isSelected ? 'star' : 'star-border';
},
_computedClass: function(isSelected) {
var classes = 'item';
if (isSelected) {
classes += ' selected';
}
return classes;
},
_unselect: function(e) {
this.$.itemsList.deselectItem(e.model.item);
},
_toggleStarredView: function() {
this.showSelection = !this.showSelection;
},
_showSelectionChanged: function() {
this.$.selectedItemsList.fire('resize');
|
73bcce88
luigser
COMPONENTS
|
269
|
}
|
73bcce88
luigser
COMPONENTS
|
270
271
272
273
274
275
276
|
});
});
</script>
</head>
|
a53fbbed
Renato De Donato
select-dataset ne...
|
277
278
279
280
281
|
<style is="custom-style">
body {
@apply(--layout-fullbleed);
}
</style>
|
73bcce88
luigser
COMPONENTS
|
282
283
284
285
286
287
|
<body unresolved>
<x-app></x-app>
</body>
</html>
|