| author | ymh <ymh.work@gmail.com> |
| Thu, 02 Aug 2018 16:15:39 +0200 | |
| changeset 593 | f8310b7ddef0 |
| parent 423 | 729e51dd282e |
| permissions | -rw-r--r-- |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
1 |
<template> |
|
410
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
2 |
<div v-on:mouseover="hover = true" v-on:mouseleave="hover = false" class="comment" v-bind:class="commentClass"> |
|
396
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
3 |
<div class="comment-body"> |
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
4 |
<strong class="comment-author">{{ username }}</strong>
|
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
5 |
<div class="comment-content" v-html="commentFormatted"></div> |
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
6 |
</div> |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
7 |
<div class="comment-footer"> |
|
410
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
8 |
<span class="comment-date">{{ dateFormatted }}</span>
|
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
9 |
</div> |
|
410
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
10 |
<comment-form v-show="hover" |
|
423
729e51dd282e
Do not display comment box when not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents:
413
diff
changeset
|
11 |
v-if="allowThread && isAuthenticated" |
|
410
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
12 |
v-bind:annotation="annotation" |
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
13 |
v-bind:reply-to="id"> |
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
14 |
</comment-form> |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
15 |
</div> |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
16 |
</template> |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
17 |
|
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
18 |
<script> |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
19 |
|
|
391
7ab1cc12827e
adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents:
323
diff
changeset
|
20 |
import showdown from 'showdown' |
|
409
3e61d1c8acd3
adds moment and format date for comments
duong tam kien <tk@deveha.com>
parents:
406
diff
changeset
|
21 |
import moment from 'moment' |
|
391
7ab1cc12827e
adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents:
323
diff
changeset
|
22 |
|
|
396
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
23 |
const converter = new showdown.Converter({
|
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
24 |
simpleLineBreaks: true |
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
25 |
}) |
|
391
7ab1cc12827e
adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents:
323
diff
changeset
|
26 |
|
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
27 |
export default {
|
|
396
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
28 |
components: ['comment-form'], |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
29 |
props: [ |
|
396
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
30 |
'id', |
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
31 |
'level', |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
32 |
'comment', |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
33 |
'username', |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
34 |
'email', |
|
396
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
35 |
'date', |
|
423
729e51dd282e
Do not display comment box when not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents:
413
diff
changeset
|
36 |
'allow-thread', |
|
729e51dd282e
Do not display comment box when not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents:
413
diff
changeset
|
37 |
'is-authenticated' |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
38 |
], |
|
396
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
39 |
data() {
|
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
40 |
return {
|
|
405
6b8a1ae18e91
Introduce meta categories widget.
Alexandre Segura <mex.zktk@gmail.com>
parents:
396
diff
changeset
|
41 |
hover: false |
|
396
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
42 |
} |
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
43 |
}, |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
44 |
computed: {
|
|
410
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
45 |
commentClass: function(){
|
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
46 |
var c = []; |
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
47 |
|
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
48 |
if (this.level > 0) {
|
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
49 |
c = [ "comment-thread" ] |
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
50 |
} |
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
51 |
|
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
52 |
return c; |
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
53 |
}, |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
54 |
dateFormatted: function () {
|
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
55 |
|
|
413
9c5f2d97863a
Change MomentJS locale to fr.
Alexandre Segura <mex.zktk@gmail.com>
parents:
411
diff
changeset
|
56 |
var date = moment(this.date).locale('fr');
|
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
57 |
|
|
409
3e61d1c8acd3
adds moment and format date for comments
duong tam kien <tk@deveha.com>
parents:
406
diff
changeset
|
58 |
return date.fromNow(); |
|
391
7ab1cc12827e
adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents:
323
diff
changeset
|
59 |
}, |
|
7ab1cc12827e
adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents:
323
diff
changeset
|
60 |
commentFormatted: function(){
|
|
7ab1cc12827e
adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents:
323
diff
changeset
|
61 |
return converter.makeHtml(this.comment); |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
62 |
} |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
63 |
} |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
64 |
} |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
65 |
|
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
66 |
</script> |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
67 |
|
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
68 |
<style scoped> |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
69 |
.comment {
|
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
70 |
font-size: 12px; |
|
410
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
71 |
padding: 10px 0; |
| 411 | 72 |
border-bottom: 1px solid #ddd; |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
73 |
} |
|
410
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
74 |
|
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
75 |
.comment-thread {
|
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
76 |
border-bottom-width: 0px; |
| 411 | 77 |
border-left: 3px solid #ddd; |
|
410
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
78 |
padding-left: 10px; |
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
79 |
margin-left: 10px; |
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
80 |
} |
|
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
81 |
|
|
396
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
82 |
.comment-author {
|
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
83 |
float: left; |
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
84 |
margin-right: 4px; |
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
85 |
} |
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
86 |
.comment-date {
|
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
87 |
|
|
0a4743126d74
Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents:
391
diff
changeset
|
88 |
} |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
89 |
.comment-footer {
|
|
410
a6db5e626850
sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents:
409
diff
changeset
|
90 |
margin-top: 0px; |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
91 |
color: #ccc; |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
92 |
} |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
93 |
</style> |