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.

155 lines
4.8 KiB

  1. <template lang="pug">
  2. .navigator
  3. .navigator-bar
  4. .navigator-fab
  5. .navigator-fab-button(@click='toggleMainMenu')
  6. svg.icons.is-24(role='img')
  7. title Navigation
  8. use(xlink:href='#gg-apps-grid')
  9. .navigator-title
  10. h1 {{ siteTitle }}
  11. .navigator-subtitle(:class='subtitleClass')
  12. transition(name='navigator-subtitle-icon')
  13. svg.icons.is-24.navigator-subtitle-icon(role='img', v-if='subtitleIcon')
  14. title {{subtitleText}}
  15. use(:xlink:href='subtitleIconClass')
  16. h2 {{subtitleText}}
  17. .navigator-action
  18. .navigator-action-item(:class='{"is-active": userMenuShown}', @click='toggleUserMenu')
  19. svg.icons.is-32(role='img')
  20. title User
  21. use(xlink:href='#nc-user-circle')
  22. transition(name='navigator-action-item-dropdown')
  23. ul.navigator-action-item-dropdown(v-show='userMenuShown', v-cloak)
  24. li
  25. label Account
  26. svg.icons.is-24(role='img')
  27. title Account
  28. use(xlink:href='#nc-man-green')
  29. li(@click='logout')
  30. label Sign out
  31. svg.icons.is-24(role='img')
  32. title Sign Out
  33. use(xlink:href='#nc-exit')
  34. transition(name='navigator-sd')
  35. .navigator-sd(v-show='sdShown', v-cloak)
  36. .navigator-sd-actions
  37. a.is-active(href='', title='Search')
  38. svg.icons.is-24(role='img')
  39. title Search
  40. use(xlink:href='#gg-search')
  41. a(href='', title='New Document')
  42. svg.icons.is-24(role='img')
  43. title New Document
  44. use(xlink:href='#nc-plus-circle')
  45. a(href='', title='Edit Document')
  46. svg.icons.is-24(role='img')
  47. title Edit Document
  48. use(xlink:href='#nc-pen-red')
  49. a(href='', title='History')
  50. svg.icons.is-24(role='img')
  51. title History
  52. use(xlink:href='#nc-restore')
  53. a(href='', title='View Source')
  54. svg.icons.is-24(role='img')
  55. title View Source
  56. use(xlink:href='#nc-code-editor')
  57. a(href='', title='Move Document')
  58. svg.icons.is-24(role='img')
  59. title Move Document
  60. use(xlink:href='#nc-move')
  61. a(href='', title='Delete Document')
  62. svg.icons.is-24(role='img')
  63. title Delete Document
  64. use(xlink:href='#nc-trash')
  65. .navigator-sd-search
  66. input(type='text', ref='iptSearch', placeholder='Search')
  67. .navigator-sd-results
  68. .navigator-sd-footer
  69. a(href='', title='Settings')
  70. svg.icons.is-24(role='img')
  71. title Settings
  72. use(xlink:href='#nc-gear')
  73. a(href='', title='Users')
  74. svg.icons.is-24(role='img')
  75. title Users
  76. use(xlink:href='#nc-users')
  77. a(href='', title='Assets')
  78. svg.icons.is-24(role='img')
  79. title Assets
  80. use(xlink:href='#nc-image')
  81. </template>
  82. <script>
  83. /* global siteConfig */
  84. import { mapState } from 'vuex'
  85. export default {
  86. data() {
  87. return {
  88. sdShown: false,
  89. userMenuShown: false
  90. }
  91. },
  92. computed: {
  93. ...mapState('navigator', [
  94. 'subtitleShown',
  95. 'subtitleStyle',
  96. 'subtitleText',
  97. 'subtitleIcon'
  98. ]),
  99. siteTitle() {
  100. return siteConfig.title
  101. },
  102. subtitleClass() {
  103. return {
  104. 'is-active': this.subtitleShown,
  105. 'is-error': this.subtitleStyle === 'error',
  106. 'is-warning': this.subtitleStyle === 'warning',
  107. 'is-success': this.subtitleStyle === 'success',
  108. 'is-info': this.subtitleStyle === 'info'
  109. }
  110. },
  111. subtitleIconClass() { return '#' + this.subtitleIcon }
  112. },
  113. methods: {
  114. toggleMainMenu() {
  115. this.sdShown = !this.sdShown
  116. this.userMenuShown = false
  117. if (this.sdShown) {
  118. this.$nextTick(() => {
  119. this.bindOutsideClick()
  120. this.$refs.iptSearch.focus()
  121. })
  122. } else {
  123. this.unbindOutsideClick()
  124. }
  125. },
  126. toggleUserMenu() {
  127. this.userMenuShown = !this.userMenuShown
  128. this.sdShown = false
  129. if (this.userMenuShown) {
  130. this.bindOutsideClick()
  131. } else {
  132. this.unbindOutsideClick()
  133. }
  134. },
  135. bindOutsideClick() {
  136. document.addEventListener('mousedown', this.handleOutsideClick, false)
  137. },
  138. unbindOutsideClick() {
  139. document.removeEventListener('mousedown', this.handleOutsideClick, false)
  140. },
  141. handleOutsideClick(ev) {
  142. if (!this.$el.contains(ev.target)) {
  143. this.sdShown = false
  144. this.userMenuShown = false
  145. }
  146. },
  147. logout() {
  148. window.location.assign(this.$helpers.resolvePath('logout'))
  149. }
  150. }
  151. }
  152. </script>