sidebar.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
  3. *
  4. * @author John Molakvoæ <skjnldsv@protonmail.com>
  5. *
  6. * @license AGPL-3.0-or-later
  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. import Vue from 'vue'
  23. import { translate as t } from '@nextcloud/l10n'
  24. import SidebarView from './views/Sidebar.vue'
  25. import Sidebar from './services/Sidebar.js'
  26. import Tab from './models/Tab.js'
  27. Vue.prototype.t = t
  28. // Init Sidebar Service
  29. if (!window.OCA.Files) {
  30. window.OCA.Files = {}
  31. }
  32. Object.assign(window.OCA.Files, { Sidebar: new Sidebar() })
  33. Object.assign(window.OCA.Files.Sidebar, { Tab })
  34. console.debug('OCA.Files.Sidebar initialized')
  35. window.addEventListener('DOMContentLoaded', function() {
  36. const contentElement = document.querySelector('body > .content')
  37. || document.querySelector('body > #content')
  38. // Make sure we have a proper layout
  39. if (contentElement) {
  40. // Make sure we have a mountpoint
  41. if (!document.getElementById('app-sidebar')) {
  42. const sidebarElement = document.createElement('div')
  43. sidebarElement.id = 'app-sidebar'
  44. contentElement.appendChild(sidebarElement)
  45. }
  46. }
  47. // Init vue app
  48. const View = Vue.extend(SidebarView)
  49. const AppSidebar = new View({
  50. name: 'SidebarRoot',
  51. })
  52. AppSidebar.$mount('#app-sidebar')
  53. window.OCA.Files.Sidebar.open = AppSidebar.open
  54. window.OCA.Files.Sidebar.close = AppSidebar.close
  55. window.OCA.Files.Sidebar.setFullScreenMode = AppSidebar.setFullScreenMode
  56. })