1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-29 08:27:55 +00:00
seahub/static/scripts/app/views/group-discussion.js

55 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-03-08 05:36:58 +00:00
define([
'jquery',
'underscore',
'backbone',
'common',
2016-03-17 07:43:05 +00:00
'marked',
'moment'
], function($, _, Backbone, Common, Marked, Moment) {
2016-03-08 05:36:58 +00:00
'use strict';
var View = Backbone.View.extend({
tagName: 'li',
2016-03-17 07:43:05 +00:00
className: 'msg cspt ovhd',
2016-03-08 05:36:58 +00:00
template: _.template($('#group-discussion-tmpl').html()),
events: {
'mouseenter': 'highlight',
'mouseleave': 'rmHighlight'
},
initialize: function() {
},
render: function() {
var obj = this.model.attributes;
2016-03-17 07:43:05 +00:00
var m = Moment(obj['created_at']);
var user_profile_url = Common.getUrl({
'name': 'user_profile',
'username': encodeURIComponent(obj.user_email)
});
2016-03-08 05:36:58 +00:00
_.extend(obj, {
2016-03-17 07:43:05 +00:00
'content_marked': Marked(obj.content, { breaks: true }),
'time': m.format('LLLL'),
'time_from_now': Common.getRelativeTimeStr(m),
'user_profile_url': user_profile_url
2016-03-08 05:36:58 +00:00
});
this.$el.html(this.template(obj));
return this;
},
highlight: function() {
this.$el.addClass('hl');
},
rmHighlight: function() {
this.$el.removeClass('hl');
}
});
return View;
});