1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-30 17:02:15 +00:00
seahub/static/scripts/app/views/repo-details.js

74 lines
1.9 KiB
JavaScript
Raw Normal View History

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',
className: 'details-panel right-side-panel hide', // `hide` is for 'clickItem' in `views/myhome-repos.js`
template: _.template($('#repo-details-tmpl').html()),
initialize: function() {
$("#main").append(this.$el);
var _this = this;
$(document).keydown(function(e) {
// ESCAPE key pressed
if (e.which == 27) {
_this.hide();
}
});
$(window).resize(function() {
_this.setConMaxHeight();
});
},
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
setConMaxHeight: function() {
this.$('.right-side-panel-con').css({
'height': $(window).height() - // this.$el `position:fixed; top:0;`
this.$('.right-side-panel-hd').outerHeight(true)
});
},
hide: function() {
this.$el.css({'right': '-400px'}).hide();
},
close: function() {
this.hide();
return false;
},
show: function(options) {
this.data = options;
this.render();
this.$el.css({'right': '0px'}).show();
this.setConMaxHeight();
}
});
return View;
});