You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sharebreadcrumbview.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * @copyright 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
  3. *
  4. * @author 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. (function() {
  23. 'use strict'
  24. var BreadCrumbView = OC.Backbone.View.extend({
  25. tagName: 'span',
  26. events: {
  27. click: '_onClick'
  28. },
  29. _dirInfo: undefined,
  30. /** @type OCA.Sharing.ShareTabView */
  31. _shareTab: undefined,
  32. initialize: function(options) {
  33. this._shareTab = options.shareTab
  34. },
  35. render: function(data) {
  36. this._dirInfo = data.dirInfo || null
  37. if (this._dirInfo !== null && (this._dirInfo.path !== '/' || this._dirInfo.name !== '')) {
  38. var isShared = data.dirInfo && data.dirInfo.shareTypes && data.dirInfo.shareTypes.length > 0
  39. this.$el.removeClass('shared icon-public icon-shared')
  40. if (isShared) {
  41. this.$el.addClass('shared')
  42. if (data.dirInfo.shareTypes.indexOf(OC.Share.SHARE_TYPE_LINK) !== -1) {
  43. this.$el.addClass('icon-public')
  44. } else {
  45. this.$el.addClass('icon-shared')
  46. }
  47. } else {
  48. this.$el.addClass('icon-shared')
  49. }
  50. this.$el.show()
  51. this.delegateEvents()
  52. } else {
  53. this.$el.removeClass('shared icon-public icon-shared')
  54. this.$el.hide()
  55. }
  56. return this
  57. },
  58. _onClick: function(e) {
  59. e.preventDefault()
  60. var fileInfoModel = new OCA.Files.FileInfoModel(this._dirInfo)
  61. var self = this
  62. fileInfoModel.on('change', function() {
  63. self.render({
  64. dirInfo: self._dirInfo
  65. })
  66. })
  67. this._shareTab.on('sharesChanged', function(shareModel) {
  68. var shareTypes = []
  69. var shares = shareModel.getSharesWithCurrentItem()
  70. for (var i = 0; i < shares.length; i++) {
  71. if (shareTypes.indexOf(shares[i].share_type) === -1) {
  72. shareTypes.push(shares[i].share_type)
  73. }
  74. }
  75. if (shareModel.hasLinkShares()) {
  76. shareTypes.push(OC.Share.SHARE_TYPE_LINK)
  77. }
  78. // Since the dirInfo isn't updated we need to do this dark hackery
  79. self._dirInfo.shareTypes = shareTypes
  80. self.render({
  81. dirInfo: self._dirInfo
  82. })
  83. })
  84. OCA.Files.App.fileList.showDetailsView(fileInfoModel, 'shareTabView')
  85. }
  86. })
  87. OCA.Sharing.ShareBreadCrumbView = BreadCrumbView
  88. })()