2017-06-26 08:08:54 +00:00
|
|
|
define([
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
|
|
|
'common'
|
|
|
|
], function($, _, Backbone, Common) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var View = Backbone.View.extend({
|
|
|
|
id: 'repo-details',
|
2017-12-05 09:53:45 +00:00
|
|
|
className: 'details-panel',
|
2017-06-26 08:08:54 +00:00
|
|
|
|
|
|
|
template: _.template($('#repo-details-tmpl').html()),
|
|
|
|
|
2018-05-17 09:42:27 +00:00
|
|
|
initialize: function(options) {
|
2017-06-26 08:08:54 +00:00
|
|
|
var _this = this;
|
2018-05-17 09:42:27 +00:00
|
|
|
|
|
|
|
this.parentView = options.parentView;
|
2018-02-05 08:47:56 +00:00
|
|
|
$(document).on('keydown', function(e) {
|
2017-06-26 08:08:54 +00:00
|
|
|
// ESCAPE key pressed
|
|
|
|
if (e.which == 27) {
|
|
|
|
_this.hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
|
|
|
'click .js-close': 'close'
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
this.$el.html(this.template(this.data));
|
|
|
|
},
|
|
|
|
|
2017-06-27 10:58:08 +00:00
|
|
|
update: function(part_data) {
|
|
|
|
if (part_data.error) {
|
|
|
|
this.$('#file-count').html('<span class="error">' + gettext("Error") + '</span>');
|
|
|
|
} else {
|
|
|
|
this.$('#file-count').html(part_data.file_count);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-06-26 08:08:54 +00:00
|
|
|
hide: function() {
|
2017-12-05 09:53:45 +00:00
|
|
|
this.$el.hide();
|
2017-06-26 08:08:54 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
close: function() {
|
|
|
|
this.hide();
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
show: function(options) {
|
|
|
|
this.data = options;
|
|
|
|
this.render();
|
2017-12-05 09:53:45 +00:00
|
|
|
|
|
|
|
if (!$('#' + this.id).length) {
|
2018-05-17 09:42:27 +00:00
|
|
|
this.parentView.$('.main-panel-main-with-side').append(this.$el);
|
2017-12-05 09:53:45 +00:00
|
|
|
if (!this.$el.is(':visible')) {
|
|
|
|
this.$el.show();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.$el.show();
|
|
|
|
}
|
2017-06-26 08:08:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return View;
|
|
|
|
});
|