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() {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class OCA.Files.DetailTabView
|
|
|
|
* @classdesc
|
|
|
|
*
|
|
|
|
* Base class for tab views to display file information.
|
|
|
|
*
|
|
|
|
*/
|
2015-08-12 18:30:20 +03:00
|
|
|
var DetailTabView = OC.Backbone.View.extend({
|
|
|
|
tag: 'div',
|
2015-07-15 13:06:13 +03:00
|
|
|
|
2015-08-12 18:30:20 +03:00
|
|
|
className: 'tab',
|
2015-07-15 13:06:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tab label
|
|
|
|
*/
|
|
|
|
_label: null,
|
|
|
|
|
|
|
|
_template: null,
|
|
|
|
|
2015-09-28 13:30:12 +03:00
|
|
|
initialize: function(options) {
|
|
|
|
options = options || {};
|
2015-08-12 18:30:20 +03:00
|
|
|
if (!this.id) {
|
|
|
|
this.id = 'detailTabView' + DetailTabView._TAB_COUNT;
|
|
|
|
DetailTabView._TAB_COUNT++;
|
2015-07-15 13:06:13 +03:00
|
|
|
}
|
2015-09-28 13:30:12 +03:00
|
|
|
if (options.order) {
|
|
|
|
this.order = options.order || 0;
|
|
|
|
}
|
2015-07-15 13:06:13 +03:00
|
|
|
},
|
|
|
|
|
2018-10-04 11:52:33 +03: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 13:06:13 +03:00
|
|
|
/**
|
|
|
|
* Returns the tab label
|
|
|
|
*
|
|
|
|
* @return {String} label
|
|
|
|
*/
|
|
|
|
getLabel: function() {
|
2015-08-12 18:30:20 +03:00
|
|
|
return 'Tab ' + this.id;
|
2015-07-15 13:06:13 +03:00
|
|
|
},
|
|
|
|
|
2018-10-18 16:47:18 +03:00
|
|
|
/**
|
|
|
|
* Returns the tab label
|
|
|
|
*
|
|
|
|
* @return {String}|{null} icon class
|
|
|
|
*/
|
|
|
|
getIcon: function() {
|
|
|
|
return null
|
|
|
|
},
|
|
|
|
|
2015-07-20 15:42:10 +03:00
|
|
|
/**
|
|
|
|
* returns the jQuery object for HTML output
|
|
|
|
*
|
|
|
|
* @returns {jQuery}
|
|
|
|
*/
|
|
|
|
get$: function() {
|
|
|
|
return this.$el;
|
|
|
|
},
|
|
|
|
|
2015-07-15 13:06:13 +03:00
|
|
|
/**
|
|
|
|
* Renders this details view
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
*/
|
|
|
|
render: function() {
|
|
|
|
// to be implemented in subclass
|
2015-07-15 17:09:00 +03:00
|
|
|
// FIXME: code is only for testing
|
2015-08-12 18:30:20 +03:00
|
|
|
this.$el.html('<div>Hello ' + this.id + '</div>');
|
2015-07-15 13:06:13 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the file info to be displayed in the view
|
|
|
|
*
|
2015-08-12 18:30:20 +03:00
|
|
|
* @param {OCA.Files.FileInfoModel} fileInfo file info to set
|
2015-07-15 13:06:13 +03:00
|
|
|
*/
|
|
|
|
setFileInfo: function(fileInfo) {
|
2015-08-14 16:54:27 +03:00
|
|
|
if (this.model !== fileInfo) {
|
|
|
|
this.model = fileInfo;
|
|
|
|
this.render();
|
|
|
|
}
|
2015-07-15 13:06:13 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the file info.
|
|
|
|
*
|
2015-08-12 18:30:20 +03:00
|
|
|
* @return {OCA.Files.FileInfoModel} file info
|
2015-07-15 13:06:13 +03:00
|
|
|
*/
|
|
|
|
getFileInfo: function() {
|
2015-08-12 18:30:20 +03:00
|
|
|
return this.model;
|
2015-09-01 20:29:55 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load the next page of results
|
|
|
|
*/
|
|
|
|
nextPage: function() {
|
|
|
|
// load the next page, if applicable
|
2015-09-25 14:23:39 +03: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 13:06:13 +03:00
|
|
|
}
|
2015-08-12 18:30:20 +03:00
|
|
|
});
|
|
|
|
DetailTabView._TAB_COUNT = 0;
|
2015-07-15 13:06:13 +03:00
|
|
|
|
2015-08-20 18:54:52 +03:00
|
|
|
OCA.Files = OCA.Files || {};
|
|
|
|
|
2015-07-15 13:06:13 +03:00
|
|
|
OCA.Files.DetailTabView = DetailTabView;
|
|
|
|
})();
|
|
|
|
|