2015-07-15 10:06:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class OCA.Files.DetailTabView
|
|
|
|
* @classdesc
|
|
|
|
*
|
|
|
|
* Base class for tab views to display file information.
|
|
|
|
*
|
|
|
|
*/
|
2015-08-12 15:30:20 +00:00
|
|
|
var DetailTabView = OC.Backbone.View.extend({
|
|
|
|
tag: 'div',
|
2015-07-15 10:06:13 +00:00
|
|
|
|
2015-08-12 15:30:20 +00:00
|
|
|
className: 'tab',
|
2015-07-15 10:06:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tab label
|
|
|
|
*/
|
|
|
|
_label: null,
|
|
|
|
|
|
|
|
_template: null,
|
|
|
|
|
2015-09-28 10:30:12 +00:00
|
|
|
initialize: function(options) {
|
|
|
|
options = options || {};
|
2015-08-12 15:30:20 +00:00
|
|
|
if (!this.id) {
|
|
|
|
this.id = 'detailTabView' + DetailTabView._TAB_COUNT;
|
|
|
|
DetailTabView._TAB_COUNT++;
|
2015-07-15 10:06:13 +00:00
|
|
|
}
|
2015-09-28 10:30:12 +00:00
|
|
|
if (options.order) {
|
|
|
|
this.order = options.order || 0;
|
|
|
|
}
|
2015-07-15 10:06:13 +00:00
|
|
|
},
|
|
|
|
|
2018-10-04 08:52:33 +00:00
|
|
|
/**
|
|
|
|
* Returns the extra CSS classes used by the tabs container when this
|
|
|
|
* tab is the selected one.
|
|
|
|
*
|
|
|
|
* In general you should not extend this method, as tabs should not
|
|
|
|
* modify the classes of its container; this is reserved as a last
|
|
|
|
* resort for very specific cases in which there is no other way to get
|
|
|
|
* the proper style or behaviour.
|
|
|
|
*
|
|
|
|
* @return {String} space-separated CSS classes
|
|
|
|
*/
|
|
|
|
getTabsContainerExtraClasses: function() {
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
|
2015-07-15 10:06:13 +00:00
|
|
|
/**
|
|
|
|
* Returns the tab label
|
|
|
|
*
|
|
|
|
* @return {String} label
|
|
|
|
*/
|
|
|
|
getLabel: function() {
|
2015-08-12 15:30:20 +00:00
|
|
|
return 'Tab ' + this.id;
|
2015-07-15 10:06:13 +00:00
|
|
|
},
|
|
|
|
|
2018-10-18 13:47:18 +00:00
|
|
|
/**
|
|
|
|
* Returns the tab label
|
|
|
|
*
|
|
|
|
* @return {String}|{null} icon class
|
|
|
|
*/
|
|
|
|
getIcon: function() {
|
|
|
|
return null
|
|
|
|
},
|
|
|
|
|
2015-07-20 12:42:10 +00:00
|
|
|
/**
|
|
|
|
* returns the jQuery object for HTML output
|
|
|
|
*
|
|
|
|
* @returns {jQuery}
|
|
|
|
*/
|
|
|
|
get$: function() {
|
|
|
|
return this.$el;
|
|
|
|
},
|
|
|
|
|
2015-07-15 10:06:13 +00:00
|
|
|
/**
|
|
|
|
* Renders this details view
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
*/
|
|
|
|
render: function() {
|
|
|
|
// to be implemented in subclass
|
2015-07-15 14:09:00 +00:00
|
|
|
// FIXME: code is only for testing
|
2015-08-12 15:30:20 +00:00
|
|
|
this.$el.html('<div>Hello ' + this.id + '</div>');
|
2015-07-15 10:06:13 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the file info to be displayed in the view
|
|
|
|
*
|
2015-08-12 15:30:20 +00:00
|
|
|
* @param {OCA.Files.FileInfoModel} fileInfo file info to set
|
2015-07-15 10:06:13 +00:00
|
|
|
*/
|
|
|
|
setFileInfo: function(fileInfo) {
|
2015-08-14 13:54:27 +00:00
|
|
|
if (this.model !== fileInfo) {
|
|
|
|
this.model = fileInfo;
|
|
|
|
this.render();
|
|
|
|
}
|
2015-07-15 10:06:13 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the file info.
|
|
|
|
*
|
2015-08-12 15:30:20 +00:00
|
|
|
* @return {OCA.Files.FileInfoModel} file info
|
2015-07-15 10:06:13 +00:00
|
|
|
*/
|
|
|
|
getFileInfo: function() {
|
2015-08-12 15:30:20 +00:00
|
|
|
return this.model;
|
2015-09-01 17:29:55 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load the next page of results
|
|
|
|
*/
|
|
|
|
nextPage: function() {
|
|
|
|
// load the next page, if applicable
|
2015-09-25 11:23:39 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the current tab is able to display
|
|
|
|
* the given file info, for example based on mime type.
|
|
|
|
*
|
|
|
|
* @param {OCA.Files.FileInfoModel} fileInfo file info model
|
|
|
|
* @return {bool} whether to display this tab
|
|
|
|
*/
|
|
|
|
canDisplay: function(fileInfo) {
|
|
|
|
return true;
|
2015-07-15 10:06:13 +00:00
|
|
|
}
|
2015-08-12 15:30:20 +00:00
|
|
|
});
|
|
|
|
DetailTabView._TAB_COUNT = 0;
|
2015-07-15 10:06:13 +00:00
|
|
|
|
2015-08-20 15:54:52 +00:00
|
|
|
OCA.Files = OCA.Files || {};
|
|
|
|
|
2015-07-15 10:06:13 +00:00
|
|
|
OCA.Files.DetailTabView = DetailTabView;
|
|
|
|
})();
|
|
|
|
|