src_js/iconolab-bundle/src/components/editor/Comment.vue
author duong tam kien <tk@deveha.com>
Wed, 01 Mar 2017 15:46:18 +0100
changeset 409 3e61d1c8acd3
parent 406 733be8cac793
child 410 a6db5e626850
permissions -rw-r--r--
adds moment and format date for comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     1
<template>
405
6b8a1ae18e91 Introduce meta categories widget.
Alexandre Segura <mex.zktk@gmail.com>
parents: 396
diff changeset
     2
    <div v-on:mouseover="hover = true" v-on:mouseleave="hover = false" class="comment" v-bind:style="{ marginLeft: (level * 15) + 'px' }">
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">
405
6b8a1ae18e91 Introduce meta categories widget.
Alexandre Segura <mex.zktk@gmail.com>
parents: 396
diff changeset
     8
            <span v-show="!hover || !allowThread" class="comment-date">{{ dateFormatted }}</span>
6b8a1ae18e91 Introduce meta categories widget.
Alexandre Segura <mex.zktk@gmail.com>
parents: 396
diff changeset
     9
            <comment-form v-show="hover"
6b8a1ae18e91 Introduce meta categories widget.
Alexandre Segura <mex.zktk@gmail.com>
parents: 396
diff changeset
    10
                v-if="allowThread"
6b8a1ae18e91 Introduce meta categories widget.
Alexandre Segura <mex.zktk@gmail.com>
parents: 396
diff changeset
    11
                v-bind:annotation="annotation"
6b8a1ae18e91 Introduce meta categories widget.
Alexandre Segura <mex.zktk@gmail.com>
parents: 396
diff changeset
    12
                v-bind:reply-to="id"></comment-form>
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    13
        </div>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    14
    </div>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    15
</template>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    16
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    17
<script>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    18
391
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    19
    import showdown from 'showdown'
409
3e61d1c8acd3 adds moment and format date for comments
duong tam kien <tk@deveha.com>
parents: 406
diff changeset
    20
    import moment from 'moment'
391
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    21
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    22
    const converter = new showdown.Converter({
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    23
        simpleLineBreaks: true
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    24
    })
391
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    25
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    26
    export default {
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    27
        components: ['comment-form'],
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    28
        props: [
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    29
            'id',
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    30
            'level',
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    31
            'comment',
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    32
            'username',
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    33
            'email',
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    34
            'date',
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    35
            'allowThread'
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    36
        ],
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    37
        data() {
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    38
            return {
405
6b8a1ae18e91 Introduce meta categories widget.
Alexandre Segura <mex.zktk@gmail.com>
parents: 396
diff changeset
    39
                hover: false
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    40
            }
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    41
        },
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    42
        computed: {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    43
            dateFormatted: function () {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    44
409
3e61d1c8acd3 adds moment and format date for comments
duong tam kien <tk@deveha.com>
parents: 406
diff changeset
    45
              var date = moment(this.date); //.format("HH:mm DD/MM/YYYY");
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    46
409
3e61d1c8acd3 adds moment and format date for comments
duong tam kien <tk@deveha.com>
parents: 406
diff changeset
    47
              return date.fromNow();
391
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    48
            },
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    49
            commentFormatted: function(){
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    50
              return converter.makeHtml(this.comment);
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    51
            }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    52
        }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    53
    }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    54
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    55
</script>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    56
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    57
<style scoped>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    58
.comment {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    59
    font-size: 12px;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    60
    padding: 5px 0;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    61
    border-bottom: 1px solid #ccc;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    62
}
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    63
.comment-author {
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    64
    float: left;
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    65
    margin-right: 4px;
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    66
}
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    67
.comment-date {
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    68
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    69
}
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    70
.comment-footer {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    71
    margin-top: 5px;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    72
    color: #ccc;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    73
}
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    74
</style>