-
Notifications
You must be signed in to change notification settings - Fork 0
/
contacts-view.html
66 lines (57 loc) · 2.4 KB
/
contacts-view.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
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/core-icons/core-icons.html">
<link rel="import" href="bower_components/core-list/core-list.html">
<link rel="import" href="bower_components/core-item/core-item.html">
<link rel="import" href="bower_components/paper-shadow/paper-shadow.html">
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="bower_components/paper-ripple/paper-ripple.html">
<link rel="import" href="message-overlay.html">
<!--
##### Example
<contacts-view></contacts-view>
@element contacts-view
@blurb Element providing solution to [...].
@status [...]
-->
<polymer-element name="contacts-view" attributes="data" label="Contacts">
<template>
<link rel="stylesheet" href="contacts-view.css">
<message-overlay id="messageOverlay"></message-overlay>
<section layout vertical center-center>
<paper-shadow id="listContainer" z="1">
<core-list data="{{data.contacts}}" class="contact-list" height="81" slide-from-right>
<template>
<core-item layout horizontal center>
<div class="avatar">{{model.name[0]}}</div>
<div flex class="contact-name">{{model.name}}</div>
<paper-ripple fit></paper-ripple>
<paper-icon-button icon="send" on-tap="{{openThread}}"></paper-icon-button>
<paper-icon-button icon="delete" on-tap="{{deleteContact}}"></paper-icon-button>
</core-item>
</template>
</core-list>
</paper-shadow>
</section>
</template>
<script>
Polymer('contacts-view', {
ready: function() {
},
openThread: function(event) {
var contact = event.target.templateInstance.model.model;
this.$.messageOverlay.thread = this.data.threads.filter(
function(t) {return t.from == contact.name})[0];
if (this.$.messageOverlay.thread === undefined) {
var thread = {from: contact.name, messages: []};
this.data.threads.push(thread);
this.$.messageOverlay.thread = thread;
}
this.$.messageOverlay.open();
},
deleteContact: function(event) {
var toDelete = event.target.templateInstance.model.model;
this.data.contacts = this.data.contacts.filter(function(c) {return c.name != toDelete.name});
}
});
</script>
</polymer-element>