src_js/iconolab-bundle/src/components/editor/Comment.vue
author duong tam kien <tk@deveha.com>
Wed, 01 Mar 2017 17:18:53 +0100
changeset 410 a6db5e626850
parent 409 3e61d1c8acd3
child 411 74b01659ee40
permissions -rw-r--r--
sizes up panels and get closer to the mockup
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>
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
a6db5e626850 sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents: 409
diff changeset
    11
        <comment-form v-show="hover"
a6db5e626850 sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents: 409
diff changeset
    12
            v-if="allowThread"
a6db5e626850 sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents: 409
diff changeset
    13
            v-bind:annotation="annotation"
a6db5e626850 sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents: 409
diff changeset
    14
            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
    15
        </comment-form>
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    16
    </div>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    17
</template>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    18
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    19
<script>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    20
391
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    21
    import showdown from 'showdown'
409
3e61d1c8acd3 adds moment and format date for comments
duong tam kien <tk@deveha.com>
parents: 406
diff changeset
    22
    import moment from 'moment'
391
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    23
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    24
    const converter = new showdown.Converter({
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    25
        simpleLineBreaks: true
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    26
    })
391
7ab1cc12827e adds handling of rich text (markdown)
duong tam kien <tk@deveha.com>
parents: 323
diff changeset
    27
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    28
    export default {
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    29
        components: ['comment-form'],
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    30
        props: [
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    31
            'id',
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    32
            'level',
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    33
            'comment',
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    34
            'username',
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    35
            'email',
396
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    36
            'date',
0a4743126d74 Implement replying to comments.
Alexandre Segura <mex.zktk@gmail.com>
parents: 391
diff changeset
    37
            'allowThread'
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
409
3e61d1c8acd3 adds moment and format date for comments
duong tam kien <tk@deveha.com>
parents: 406
diff changeset
    56
              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
    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;
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    72
    border-bottom: 1px solid #ccc;
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;
a6db5e626850 sizes up panels and get closer to the mockup
duong tam kien <tk@deveha.com>
parents: 409
diff changeset
    77
  border-left: 3px solid #ccc;
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>