|
| 1 | +<template> |
| 2 | + <div |
| 3 | + class="media-browser-audio" |
| 4 | + @dblclick="openPreview()" |
| 5 | + @mouseleave="hideActions()" |
| 6 | + > |
| 7 | + <div class="media-browser-item-preview"> |
| 8 | + <div class="file-background"> |
| 9 | + <div class="file-icon"> |
| 10 | + <span class="fas fa-file-audio" /> |
| 11 | + </div> |
| 12 | + </div> |
| 13 | + </div> |
| 14 | + <div class="media-browser-item-info"> |
| 15 | + {{ item.name }} {{ item.filetype }} |
| 16 | + </div> |
| 17 | + <span |
| 18 | + class="media-browser-select" |
| 19 | + :aria-label="translate('COM_MEDIA_TOGGLE_SELECT_ITEM')" |
| 20 | + :title="translate('COM_MEDIA_TOGGLE_SELECT_ITEM')" |
| 21 | + /> |
| 22 | + <div |
| 23 | + class="media-browser-actions" |
| 24 | + :class="{'active': showActions}" |
| 25 | + > |
| 26 | + <button |
| 27 | + ref="actionToggle" |
| 28 | + type="button" |
| 29 | + class="action-toggle" |
| 30 | + :aria-label="translate('COM_MEDIA_OPEN_ITEM_ACTIONS')" |
| 31 | + :title="translate('COM_MEDIA_OPEN_ITEM_ACTIONS')" |
| 32 | + @keyup.enter="openActions()" |
| 33 | + @focus="focused(true)" |
| 34 | + @blur="focused(false)" |
| 35 | + @keyup.space="openActions()" |
| 36 | + @keyup.down="openActions()" |
| 37 | + @keyup.up="openLastActions()" |
| 38 | + > |
| 39 | + <span |
| 40 | + class="image-browser-action icon-ellipsis-h" |
| 41 | + aria-hidden="true" |
| 42 | + @click.stop="openActions()" |
| 43 | + /> |
| 44 | + </button> |
| 45 | + <div |
| 46 | + v-if="showActions" |
| 47 | + class="media-browser-actions-list" |
| 48 | + > |
| 49 | + <ul> |
| 50 | + <li> |
| 51 | + <button |
| 52 | + ref="actionPreview" |
| 53 | + type="button" |
| 54 | + class="action-preview" |
| 55 | + :aria-label="translate('COM_MEDIA_ACTION_PREVIEW')" |
| 56 | + :title="translate('COM_MEDIA_ACTION_PREVIEW')" |
| 57 | + @keyup.enter="openPreview()" |
| 58 | + @keyup.space="openPreview()" |
| 59 | + @focus="focused(true)" |
| 60 | + @blur="focused(false)" |
| 61 | + @keyup.esc="hideActions()" |
| 62 | + @keyup.up="$refs.actionDelete.focus()" |
| 63 | + @keyup.down="$refs.actionDownload.focus()" |
| 64 | + > |
| 65 | + <span |
| 66 | + class="image-browser-action icon-search-plus" |
| 67 | + aria-hidden="true" |
| 68 | + @click.stop="openPreview()" |
| 69 | + /> |
| 70 | + </button> |
| 71 | + </li> |
| 72 | + <li> |
| 73 | + <button |
| 74 | + ref="actionDownload" |
| 75 | + type="button" |
| 76 | + class="action-download" |
| 77 | + :aria-label="translate('COM_MEDIA_ACTION_DOWNLOAD')" |
| 78 | + :title="translate('COM_MEDIA_ACTION_DOWNLOAD')" |
| 79 | + @keyup.enter="download()" |
| 80 | + @keyup.space="download()" |
| 81 | + @focus="focused(true)" |
| 82 | + @blur="focused(false)" |
| 83 | + @keyup.esc="hideActions()" |
| 84 | + @keyup.up="$refs.actionPreview.focus()" |
| 85 | + @keyup.down="$refs.actionRename.focus()" |
| 86 | + > |
| 87 | + <span |
| 88 | + class="image-browser-action icon-download" |
| 89 | + aria-hidden="true" |
| 90 | + @click.stop="download()" |
| 91 | + /> |
| 92 | + </button> |
| 93 | + </li> |
| 94 | + <li> |
| 95 | + <button |
| 96 | + ref="actionRename" |
| 97 | + type="button" |
| 98 | + class="action-rename" |
| 99 | + :aria-label="translate('COM_MEDIA_ACTION_RENAME')" |
| 100 | + :title="translate('COM_MEDIA_ACTION_RENAME')" |
| 101 | + @keyup.enter="openRenameModal()" |
| 102 | + @keyup.space="openRenameModal()" |
| 103 | + @focus="focused(true)" |
| 104 | + @blur="focused(false)" |
| 105 | + @keyup.esc="hideActions()" |
| 106 | + @keyup.up="$refs.actionDownload.focus()" |
| 107 | + @keyup.down="$refs.actionShare.focus()" |
| 108 | + > |
| 109 | + <span |
| 110 | + class="image-browser-action icon-text-width" |
| 111 | + aria-hidden="true" |
| 112 | + @click.stop="openRenameModal()" |
| 113 | + /> |
| 114 | + </button> |
| 115 | + </li> |
| 116 | + <li> |
| 117 | + <button |
| 118 | + ref="actionShare" |
| 119 | + type="button" |
| 120 | + class="action-url" |
| 121 | + :aria-label="translate('COM_MEDIA_ACTION_SHARE')" |
| 122 | + :title="translate('COM_MEDIA_ACTION_SHARE')" |
| 123 | + @keyup.enter="openShareUrlModal()" |
| 124 | + @keyup.space="openShareUrlModal()" |
| 125 | + @focus="focused(true)" |
| 126 | + @blur="focused(false)" |
| 127 | + @keyup.esc="hideActions()" |
| 128 | + @keyup.up="$refs.actionRename.focus()" |
| 129 | + @keyup.down="$refs.actionDelete.focus()" |
| 130 | + > |
| 131 | + <span |
| 132 | + class="image-browser-action icon-link" |
| 133 | + aria-hidden="true" |
| 134 | + @click.stop="openShareUrlModal()" |
| 135 | + /> |
| 136 | + </button> |
| 137 | + </li> |
| 138 | + <li> |
| 139 | + <button |
| 140 | + ref="actionDelete" |
| 141 | + type="button" |
| 142 | + class="action-delete" |
| 143 | + :aria-label="translate('COM_MEDIA_ACTION_DELETE')" |
| 144 | + :title="translate('COM_MEDIA_ACTION_DELETE')" |
| 145 | + @keyup.enter="openConfirmDeleteModal()" |
| 146 | + @keyup.space="openConfirmDeleteModal()" |
| 147 | + @focus="focused(true)" |
| 148 | + @blur="focused(false)" |
| 149 | + @keyup.esc="hideActions()" |
| 150 | + @keyup.up="$refs.actionShare.focus()" |
| 151 | + @keyup.down="$refs.actionPreview.focus()" |
| 152 | + > |
| 153 | + <span |
| 154 | + class="image-browser-action icon-trash" |
| 155 | + aria-hidden="true" |
| 156 | + @click.stop="openConfirmDeleteModal()" |
| 157 | + /> |
| 158 | + </button> |
| 159 | + </li> |
| 160 | + </ul> |
| 161 | + </div> |
| 162 | + </div> |
| 163 | + </div> |
| 164 | +</template> |
| 165 | + |
| 166 | +<script> |
| 167 | +import * as types from '../../../store/mutation-types.es6'; |
| 168 | +
|
| 169 | +export default { |
| 170 | + name: 'MediaBrowserItemAudio', |
| 171 | + // eslint-disable-next-line vue/require-prop-types |
| 172 | + props: ['item', 'focused'], |
| 173 | + data() { |
| 174 | + return { |
| 175 | + showActions: false, |
| 176 | + }; |
| 177 | + }, |
| 178 | + methods: { |
| 179 | + /* Preview an item */ |
| 180 | + openPreview() { |
| 181 | + this.$store.commit(types.SHOW_PREVIEW_MODAL); |
| 182 | + this.$store.dispatch('getFullContents', this.item); |
| 183 | + }, |
| 184 | + /* Preview an item */ |
| 185 | + download() { |
| 186 | + this.$store.dispatch('download', this.item); |
| 187 | + }, |
| 188 | + /* Opening confirm delete modal */ |
| 189 | + openConfirmDeleteModal() { |
| 190 | + this.$store.commit(types.UNSELECT_ALL_BROWSER_ITEMS); |
| 191 | + this.$store.commit(types.SELECT_BROWSER_ITEM, this.item); |
| 192 | + this.$store.commit(types.SHOW_CONFIRM_DELETE_MODAL); |
| 193 | + }, |
| 194 | + /* Rename an item */ |
| 195 | + openRenameModal() { |
| 196 | + this.$store.commit(types.SELECT_BROWSER_ITEM, this.item); |
| 197 | + this.$store.commit(types.SHOW_RENAME_MODAL); |
| 198 | + }, |
| 199 | + /* Open modal for share url */ |
| 200 | + openShareUrlModal() { |
| 201 | + this.$store.commit(types.SELECT_BROWSER_ITEM, this.item); |
| 202 | + this.$store.commit(types.SHOW_SHARE_MODAL); |
| 203 | + }, |
| 204 | + /* Open actions dropdown */ |
| 205 | + openActions() { |
| 206 | + this.showActions = true; |
| 207 | + this.$nextTick(() => this.$refs.actionPreview.focus()); |
| 208 | + }, |
| 209 | + /* Open actions dropdown and focus on last element */ |
| 210 | + openLastActions() { |
| 211 | + this.showActions = true; |
| 212 | + this.$nextTick(() => this.$refs.actionDelete.focus()); |
| 213 | + }, |
| 214 | + /* Hide actions dropdown */ |
| 215 | + hideActions() { |
| 216 | + this.showActions = false; |
| 217 | + this.$nextTick(() => this.$refs.actionToggle.focus()); |
| 218 | + }, |
| 219 | + }, |
| 220 | +}; |
| 221 | +</script> |
0 commit comments