2015-07-15 13:06:13 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
var TEMPLATE =
|
2015-07-15 17:09:00 +03:00
|
|
|
'<div class="thumbnail"></div><div class="fileName">{{name}}</div>' +
|
2015-07-15 18:05:25 +03:00
|
|
|
'<div>' +
|
|
|
|
' <a href="#" ' +
|
|
|
|
' alt="{{starAltText}}"' +
|
|
|
|
' class="action action-favorite {{#isFavorite}}permanent{{/isFavorite}}">' +
|
|
|
|
' <img class="svg" src="{{starIcon}}" />' +
|
|
|
|
' </a>' +
|
|
|
|
' <span title="{{altSize}}">{{size}}</span>, <span title="{{altDate}}">{{date}}</span>' +
|
|
|
|
'</div>';
|
2015-07-15 13:06:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @class OCA.Files.MainFileInfoDetailView
|
|
|
|
* @classdesc
|
|
|
|
*
|
|
|
|
* Displays main details about a file
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
var MainFileInfoDetailView = function() {
|
|
|
|
this.initialize();
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @memberof OCA.Files
|
|
|
|
*/
|
|
|
|
MainFileInfoDetailView.prototype = _.extend({}, OCA.Files.DetailFileInfoView.prototype,
|
|
|
|
/** @lends OCA.Files.MainFileInfoDetailView.prototype */ {
|
|
|
|
_template: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the details view
|
|
|
|
*/
|
|
|
|
initialize: function() {
|
|
|
|
this.$el = $('<div class="mainFileInfoView"></div>');
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders this details view
|
|
|
|
*/
|
|
|
|
render: function() {
|
|
|
|
this.$el.empty();
|
|
|
|
|
|
|
|
if (!this._template) {
|
|
|
|
this._template = Handlebars.compile(TEMPLATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._fileInfo) {
|
2015-07-15 18:05:25 +03:00
|
|
|
var isFavorite = (this._fileInfo.tags || []).indexOf(OC.TAG_FAVORITE) >= 0
|
2015-07-15 17:09:00 +03:00
|
|
|
this.$el.append(this._template({
|
|
|
|
nameLabel: t('files', 'Name'),
|
|
|
|
name: this._fileInfo.name,
|
|
|
|
pathLabel: t('files', 'Path'),
|
|
|
|
path: this._fileInfo.path,
|
|
|
|
sizeLabel: t('files', 'Size'),
|
|
|
|
// TODO: refactor and use size formatter
|
|
|
|
size: OC.Util.humanFileSize(this._fileInfo.size, true),
|
2015-07-15 18:05:25 +03:00
|
|
|
altSize: n('files', '%n byte', '%n bytes', this._fileInfo.size),
|
2015-07-15 17:09:00 +03:00
|
|
|
dateLabel: t('files', 'Modified'),
|
|
|
|
altDate: OC.Util.formatDate(this._fileInfo.mtime),
|
2015-07-15 18:05:25 +03:00
|
|
|
date: OC.Util.relativeModifiedDate(this._fileInfo.mtime),
|
|
|
|
isFavorite: isFavorite,
|
|
|
|
starAltText: isFavorite ? t('files', 'Favorited') : t('files', 'Favorite'),
|
|
|
|
starIcon: OC.imagePath('core', isFavorite ? 'actions/starred' : 'actions/star')
|
2015-07-15 17:09:00 +03:00
|
|
|
}));
|
|
|
|
|
2015-07-15 13:06:13 +03:00
|
|
|
var $iconDiv = this.$el.find('.thumbnail');
|
2015-07-15 17:09:00 +03:00
|
|
|
// TODO: we really need OC.Previews
|
|
|
|
if (this._fileInfo.mimetype !== 'httpd/unix-directory') {
|
|
|
|
// FIXME: use proper way, this is only for demo purposes
|
|
|
|
var previewUrl = FileList.generatePreviewUrl({
|
|
|
|
file: this._fileInfo.path + '/' + this._fileInfo.name,
|
|
|
|
c: this._fileInfo.etag,
|
|
|
|
x: 50,
|
|
|
|
y: 50
|
|
|
|
});
|
|
|
|
previewUrl = previewUrl.replace('(', '%28').replace(')', '%29');
|
|
|
|
$iconDiv.css('background-image', 'url("' + previewUrl + '")');
|
|
|
|
} else {
|
|
|
|
// TODO: special icons / shared / external
|
|
|
|
$iconDiv.css('background-image', 'url("' + OC.MimeType.getIconUrl('dir') + '")');
|
|
|
|
}
|
2015-07-15 18:05:25 +03:00
|
|
|
this.$el.find('[title]').tipsy();
|
2015-07-15 13:06:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
OCA.Files.MainFileInfoDetailView = MainFileInfoDetailView;
|
|
|
|
})();
|
|
|
|
|