1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-30 08:53:49 +00:00
seahub/static/scripts/app/views/details.js

66 lines
2.5 KiB
JavaScript
Raw Normal View History

2015-07-24 03:37:57 +00:00
define([
'jquery',
'underscore',
'backbone',
2015-07-28 11:54:57 +00:00
'common'
], function($, _, Backbone, Common) {
2015-07-24 03:37:57 +00:00
'use strict';
var DetailsView = Backbone.View.extend({
id: 'ls-ch',
template: _.template($('#details-popup-tmpl').html()),
2015-07-28 11:54:57 +00:00
detailItemTemplate: _.template($('#detail-item-tmpl').html()),
2015-07-24 03:37:57 +00:00
initialize: function (options) {
this.repo_id = options['repo_id'];
this.cmmt_id = options['cmmt_id'];
this.$el.html(this.template()).modal({autoResize:true});
$('#simplemodal-container').css({'width':'auto', 'height':'auto'});
this.getDetails();
},
getDetails: function () {
2015-07-28 11:54:57 +00:00
var repo_id = this.repo_id, cmmt_id = this.cmmt_id,
details_title, item_data, item_html,
2015-07-24 03:37:57 +00:00
_this = this;
Common.ajaxGet({
get_url: Common.getUrl({ name:'get_history_changes', repo_id: repo_id}),
data: {'commit_id': cmmt_id},
after_op_success: function (data) {
_this.$('.loading-tip').hide();
_this.$('.commit-time').html(data['date_time']);
for (var item in data) {
2015-07-28 11:54:57 +00:00
if (item == "cmt_desc") {
_this.$el.append(data[item]);
} else if (data[item].length > 0 && item != 'date_time') {
2015-07-24 03:37:57 +00:00
if (item == "new") { details_title = gettext("New files") }
if (item == "removed") { details_title = gettext("Deleted files") }
if (item == "renamed") { details_title = gettext("Renamed or Moved files") }
if (item == "modified") { details_title = gettext("Modified files") }
if (item == "newdir") { details_title = gettext("New directories") }
if (item == "deldir") { details_title = gettext("Deleted directories") }
2015-07-28 11:54:57 +00:00
item_data = {"details_title": details_title, "details": data[item]};
item_html = _this.detailItemTemplate(item_data);
_this.$el.append(item_html);
2015-07-24 03:37:57 +00:00
}
}
$(window).resize();
},
2015-07-28 11:54:57 +00:00
after_op_error: function() {
$('#ls-ch').html(gettext("Unknown error"));
setTimeout(function() { $.modal.close(); }, 2500);
2015-07-24 03:37:57 +00:00
}
});
}
});
return DetailsView;
})