navigator.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 CONSTANTS, graphQL, siteConfig */
  84. import { mapState } from 'vuex'
  85. export default {
  86. name: 'navigator',
  87. data() {
  88. return {
  89. sdShown: false,
  90. userMenuShown: false
  91. }
  92. },
  93. computed: {
  94. ...mapState('navigator', [
  95. 'subtitleShown',
  96. 'subtitleStyle',
  97. 'subtitleText',
  98. 'subtitleIcon'
  99. ]),
  100. siteTitle() {
  101. return siteConfig.title
  102. },
  103. subtitleClass() {
  104. return {
  105. 'is-active': this.subtitleShown,
  106. 'is-error': this.subtitleStyle === 'error',
  107. 'is-warning': this.subtitleStyle === 'warning',
  108. 'is-success': this.subtitleStyle === 'success',
  109. 'is-info': this.subtitleStyle === 'info'
  110. }
  111. },
  112. subtitleIconClass() { return '#' + this.subtitleIcon }
  113. },
  114. methods: {
  115. toggleMainMenu() {
  116. this.sdShown = !this.sdShown
  117. this.userMenuShown = false
  118. if (this.sdShown) {
  119. this.$nextTick(() => {
  120. this.bindOutsideClick()
  121. this.$refs.iptSearch.focus()
  122. })
  123. } else {
  124. this.unbindOutsideClick()
  125. }
  126. },
  127. toggleUserMenu() {
  128. this.userMenuShown = !this.userMenuShown
  129. this.sdShown = false
  130. if (this.userMenuShown) {
  131. this.bindOutsideClick()
  132. } else {
  133. this.unbindOutsideClick()
  134. }
  135. },
  136. bindOutsideClick() {
  137. document.addEventListener('mousedown', this.handleOutsideClick, false)
  138. },
  139. unbindOutsideClick() {
  140. document.removeEventListener('mousedown', this.handleOutsideClick, false)
  141. },
  142. handleOutsideClick(ev) {
  143. if (!this.$el.contains(ev.target)) {
  144. this.sdShown = false
  145. this.userMenuShown = false
  146. }
  147. },
  148. logout() {
  149. window.location.assign(this.$helpers.resolvePath('logout'))
  150. }
  151. },
  152. mounted() {
  153. }
  154. }
  155. </script>