-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathx-chat-list.html
177 lines (171 loc) · 3.7 KB
/
x-chat-list.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<script src="bower_components/time-elements/time-elements.js"></script>
<polymer-element name="x-chat-list" attributes="uri webid audio video img avatar viewer color like username text status timestamp">
<template>
<style>
:host {
display: block;
position: relative;
width: 100%;
border-bottom: 1px solid #e0e0e0;
font-size: 16px;
min-height: 72px;
z-index: 0;
}
.user-list {
padding: 16px;
}
.avatar {
border-radius: 50%;
width: 40px;
height: 40px;
margin: 0 16px 0 0;
background: #9e9e9e url(lion.png) center center no-repeat;
background-size: contain;
position: relative;
}
.status {
position: absolute;
bottom: -3px;
right: -3px;
border-radius: 50%;
width: 14px;
height: 14px;
background-color: #7EDF25;
display: none;
}
.status.online {
display: block;
}
.status.away {
display: block;
background-color: orange;
}
.username {
line-height: 1.2em;
max-width: 90%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
color: #919191;
text-decoration: none;
}
.like{
color: #6D84B4;
font-size: 0.75em;
}
.media {
max-height: 800px;
max-width: 100%;
}
.timestamp {
font-size: 0.75em;
color: #919191;
text-decoration: none;
}
.avatar {
border: solid 3px silver;
}
.avatar.navy {
border-color: #393b79;
}
.avatar.slate {
border-color: #6b6ecf;
}
.avatar.olive {
border-color: #637939;
}
.avatar.moss {
border-color: #b5cf6b;
}
.avatar.chocolate {
border-color: #8c6d31;
}
.avatar.buttercup {
border-color: #e7ba52;
}
.avatar.maroon {
border-color: #843c39;
}
.avatar.cerise {
border-color: #d6616b;
}
.avatar.plum {
border-color: #7b4173;
}
.avatar.orchid {
border-color: #ce6dbd;
}
core-icon-button {
position: absolute;
top: 32px;
right: 3px;
color: #636363;
}
:host([like]) core-icon-button {
color: #da4336;
}
</style>
<section class="user-list" layout horizontal>
<div class="avatar {{color}}" style="background-image: url({{avatar}})">
<div class="status {{status}}"></div>
</div>
<div flex>
<div flex class="username"><a class="username" target="_blank" href="{{webid}}">{{username}}</a></div>
<div class="text">{{text}}</div>
<core-icon-button
id="favicon"
icon="favorite"
on-tap="{{handleLike}}">
</core-icon-button>
<template if="{{img}}">
<img class="media" src="{{img}}"/>
</template>
<template if="{{video}}">
<video class="media" controls src="{{video}}"></video>
</template>
<template if="{{audio}}">
<audio class="media" controls src="{{audio}}"></audio>
</template>
</div>
<div><a class="timestamp" target="_blank" href="{{uri}}"><time class="timestamp" is="relative-time" datetime="{{timestamp}}"></time></a></div>
</section>
</template>
<script>
Polymer('x-chat-list', {
publish: {
like: {
value: false,
reflect: true
},
},
avatar: '',
uri: '',
webid: '',
status: 'offline',
viewer: '',
ready: function() {
},
handleLike: function() {
if (!this.viewer) return;
console.log(' like : ' + this.like);
var verb;
if (this.like) {
this.like = false;
verb = 'DELETE';
} else {
this.like = true;
verb = 'INSERT';
}
console.log(this.uri);
$.ajax({
url: this.uri.split('#')[0],
contentType: "application/sparql-update",
type: 'PATCH',
data: verb+' DATA { <'+this.viewer+'> <http://ontologi.es/like#likes> <'+this.uri+'> . } ',
success: function(result) {
}
});
}
});
</script>
</polymer-element>