Refactor content message class names

This commit is contained in:
lilia 2015-02-17 23:36:20 -08:00
parent 94c94eb7c9
commit 4716754209
4 changed files with 6 additions and 8 deletions

View file

@ -48,7 +48,7 @@
<script type='text/x-tmpl-mustache' id='message'> <script type='text/x-tmpl-mustache' id='message'>
<div class='sender'>{{ sender }}</div> <div class='sender'>{{ sender }}</div>
<img class='avatar' src='{{ contact_avatar }}'> <img class='avatar' src='{{ contact_avatar }}'>
<div class="bubble {{ bubble_class }}"> <div class="bubble">
<p class="content">{{ message }}</p> <p class="content">{{ message }}</p>
<div class='attachments'></div> <div class='attachments'></div>
<p class="timestamp">{{ timestamp }}</p> <p class="timestamp">{{ timestamp }}</p>

View file

@ -39,12 +39,14 @@
this.template = $('#message').html(); this.template = $('#message').html();
Mustache.parse(this.template); Mustache.parse(this.template);
}, },
className: function() {
if (this.model.get('delivered')) { return 'delivered'; }
},
render: function() { render: function() {
this.$el.html( this.$el.html(
Mustache.render(this.template, { Mustache.render(this.template, {
message: this.model.get('body'), message: this.model.get('body'),
timestamp: moment(this.model.get('received_at')).fromNow(), timestamp: moment(this.model.get('received_at')).fromNow(),
bubble_class: this.model.get('type') === 'outgoing' ? 'sent' : 'incoming',
sender: this.model.get('source') sender: this.model.get('source')
}) })
); );
@ -55,10 +57,6 @@
}) })
); );
if (this.model.get('delivered')) {
this.$el.addClass('delivered');
}
var errors = this.model.get('errors'); var errors = this.model.get('errors');
if (errors && errors.length) { if (errors && errors.length) {
this.$el.find('.bubble').append( this.$el.find('.bubble').append(