@ -35,9 +35,16 @@
var ContentMessageView = Whisper . View . extend ( {
var ContentMessageView = Whisper . View . extend ( {
tagName : 'div' ,
tagName : 'div' ,
template : $ ( '#message' ) . html ( ) ,
template : $ ( '#message' ) . html ( ) ,
initialize : function ( ) {
this . listenTo ( this . model , 'change:body' , this . render ) ;
this . listenTo ( this . model , 'change:delivered' , this . renderDelivered ) ;
} ,
className : function ( ) {
className : function ( ) {
if ( this . model . get ( 'delivered' ) ) { return 'delivered' ; }
if ( this . model . get ( 'delivered' ) ) { return 'delivered' ; }
} ,
} ,
renderDelivered : function ( ) {
if ( this . model . get ( 'delivered' ) ) { this . $el . addClass ( 'delivered' ) ; }
} ,
render : function ( ) {
render : function ( ) {
this . $el . html (
this . $el . html (
Mustache . render ( this . template , {
Mustache . render ( this . template , {
@ -47,7 +54,7 @@
} )
} )
) ;
) ;
if ( this . model . get ( 'delivered' ) ) { this . $el . addClass ( 'delivered' ) ; }
this. renderDelivered ( ) ;
this . $el . find ( '.attachments' ) . append (
this . $el . find ( '.attachments' ) . append (
this . model . get ( 'attachments' ) . map ( function ( attachment ) {
this . model . get ( 'attachments' ) . map ( function ( attachment ) {
@ -85,7 +92,6 @@
}
}
this . $el . append ( this . view . el ) ;
this . $el . append ( this . view . el ) ;
this . listenTo ( this . model , 'change' , this . render ) ; // auto update
this . listenTo ( this . model , 'destroy' , this . remove ) ; // auto update
this . listenTo ( this . model , 'destroy' , this . remove ) ; // auto update
} ,
} ,
events : {
events : {