2017-05-18 03:46:43 +00:00
|
|
|
define([
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
|
|
|
'common'
|
|
|
|
], function($, _, Backbone, Common) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var View = Backbone.View.extend({
|
|
|
|
id: 'dirent-details',
|
2017-07-04 09:49:36 +00:00
|
|
|
className: 'details-panel right-side-panel',
|
2017-05-18 03:46:43 +00:00
|
|
|
|
|
|
|
template: _.template($('#dirent-details-tmpl').html()),
|
|
|
|
|
2017-07-04 09:49:36 +00:00
|
|
|
initialize: function() {
|
2017-05-18 03:46:43 +00:00
|
|
|
$("#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));
|
|
|
|
|
|
|
|
var _this = this;
|
2017-07-04 09:49:36 +00:00
|
|
|
this.$('.details-panel-img-container img').load(function() {
|
2017-05-18 03:46:43 +00:00
|
|
|
_this.showImg();
|
|
|
|
});
|
|
|
|
this.$('.thumbnail').on('error', function() {
|
|
|
|
_this.getBigIcon();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-07-04 09:49:36 +00:00
|
|
|
update: function(part_data) {
|
|
|
|
if (part_data.error) {
|
|
|
|
this.$('.dir-folder-counts, .dir-file-counts, .dir-size')
|
|
|
|
.html('<span class="error">' + gettext("Error") + '</span>');
|
|
|
|
} else {
|
|
|
|
this.$('.dir-folder-counts').html(part_data.dir_count);
|
|
|
|
this.$('.dir-file-counts').html(part_data.file_count);
|
|
|
|
this.$('.dir-size').html(part_data.size);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-05-18 03:46:43 +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() {
|
2017-07-04 09:49:36 +00:00
|
|
|
this.$el.css({'right': '-320px'});
|
2017-05-18 03:46:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
close: function() {
|
|
|
|
this.hide();
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
show: function(options) {
|
|
|
|
this.data = options;
|
|
|
|
this.render();
|
2017-07-04 09:49:36 +00:00
|
|
|
this.$el.css({'right': '0px'});
|
2017-05-18 03:46:43 +00:00
|
|
|
this.setConMaxHeight();
|
|
|
|
},
|
|
|
|
|
|
|
|
showImg: function() {
|
2017-07-04 09:49:36 +00:00
|
|
|
var $container = this.$('.details-panel-img-container');
|
2017-05-18 03:46:43 +00:00
|
|
|
$('.loading-icon', $container).hide();
|
|
|
|
$('img', $container).show();
|
|
|
|
},
|
|
|
|
|
|
|
|
getBigIcon: function() {
|
|
|
|
this.$('.thumbnail').attr({
|
|
|
|
'src': this.data.big_icon_url,
|
|
|
|
'width': 96
|
|
|
|
}).removeClass('thumbnail');
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return View;
|
|
|
|
});
|