1
0

detailtabview.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (c) 2015
  3. *
  4. * This file is licensed under the Affero General Public License version 3
  5. * or later.
  6. *
  7. * See the COPYING-README file.
  8. *
  9. */
  10. (function() {
  11. /**
  12. * @class OCA.Files.DetailTabView
  13. * @classdesc
  14. *
  15. * Base class for tab views to display file information.
  16. *
  17. */
  18. var DetailTabView = OC.Backbone.View.extend({
  19. tag: 'div',
  20. className: 'tab',
  21. /**
  22. * Tab label
  23. */
  24. _label: null,
  25. _template: null,
  26. initialize: function(options) {
  27. options = options || {};
  28. if (!this.id) {
  29. this.id = 'detailTabView' + DetailTabView._TAB_COUNT;
  30. DetailTabView._TAB_COUNT++;
  31. }
  32. if (options.order) {
  33. this.order = options.order || 0;
  34. }
  35. },
  36. /**
  37. * Returns the extra CSS classes used by the tabs container when this
  38. * tab is the selected one.
  39. *
  40. * In general you should not extend this method, as tabs should not
  41. * modify the classes of its container; this is reserved as a last
  42. * resort for very specific cases in which there is no other way to get
  43. * the proper style or behaviour.
  44. *
  45. * @return {String} space-separated CSS classes
  46. */
  47. getTabsContainerExtraClasses: function() {
  48. return '';
  49. },
  50. /**
  51. * Returns the tab label
  52. *
  53. * @return {String} label
  54. */
  55. getLabel: function() {
  56. return 'Tab ' + this.id;
  57. },
  58. /**
  59. * Returns the tab label
  60. *
  61. * @return {String}|{null} icon class
  62. */
  63. getIcon: function() {
  64. return null
  65. },
  66. /**
  67. * returns the jQuery object for HTML output
  68. *
  69. * @returns {jQuery}
  70. */
  71. get$: function() {
  72. return this.$el;
  73. },
  74. /**
  75. * Renders this details view
  76. *
  77. * @abstract
  78. */
  79. render: function() {
  80. // to be implemented in subclass
  81. // FIXME: code is only for testing
  82. this.$el.html('<div>Hello ' + this.id + '</div>');
  83. },
  84. /**
  85. * Sets the file info to be displayed in the view
  86. *
  87. * @param {OCA.Files.FileInfoModel} fileInfo file info to set
  88. */
  89. setFileInfo: function(fileInfo) {
  90. if (this.model !== fileInfo) {
  91. this.model = fileInfo;
  92. this.render();
  93. }
  94. },
  95. /**
  96. * Returns the file info.
  97. *
  98. * @return {OCA.Files.FileInfoModel} file info
  99. */
  100. getFileInfo: function() {
  101. return this.model;
  102. },
  103. /**
  104. * Load the next page of results
  105. */
  106. nextPage: function() {
  107. // load the next page, if applicable
  108. },
  109. /**
  110. * Returns whether the current tab is able to display
  111. * the given file info, for example based on mime type.
  112. *
  113. * @param {OCA.Files.FileInfoModel} fileInfo file info model
  114. * @return {boolean} whether to display this tab
  115. */
  116. canDisplay: function(fileInfo) {
  117. return true;
  118. }
  119. });
  120. DetailTabView._TAB_COUNT = 0;
  121. OCA.Files = OCA.Files || {};
  122. OCA.Files.DetailTabView = DetailTabView;
  123. })();