-
Notifications
You must be signed in to change notification settings - Fork 0
/
paper-checklist.html
60 lines (48 loc) · 1.89 KB
/
paper-checklist.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
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/paper-input/paper-input.html">
<link rel="import" href="bower_components/paper-checkbox/paper-checkbox.html">
<link rel="import" href="bower_components/paper-menu/paper-menu.html">
<link rel="import" href="bower_components/paper-item/paper-item.html">
<dom-module id="paper-checklist">
<template>
<paper-input id="checklist-input" on-keyup="filterList" label="Type to search"></paper-input>
<paper-menu id="checklist-menu">
<template is="dom-repeat" items="{{checklistData}}">
<paper-item role="menuitemcheckbox"><paper-checkbox></paper-checkbox><paper-item-body>{{item}}</paper-item-body></paper-item>
</template>
</paper-menu>
</template>
<script>
var importDoc = document.currentScript.ownerDocument;
if(!importDoc) {
importDoc = document.currentScript._ownerDocument;
}
Polymer({
is: "paper-checklist",
properties: {
checklistData : {
type: Array,
value: []
}
},
filterList: function(e) {
var inputStr = this.$['checklist-input'].value;
var menuItems = this.$['checklist-menu'].querySelectorAll('paper-item');
for(var i = 0; i < menuItems.length; i++) {
menuItems[i].style.display = 'none';
if(menuItems[i].querySelector('paper-item-body').innerHTML.toLowerCase().indexOf(inputStr.toLowerCase()) !== -1) {
menuItems[i].style.display = '';
}
}
},
ready: function() {
var userList = Polymer.dom(this).querySelectorAll('ul > li');
var checklistData = [];
for(var i = 0; i < userList.length; i++) {
checklistData.push(userList[i].innerHTML);
}
this.checklistData = checklistData;
}
});
</script>
</dom-module>