Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@
<span class="fa fa-cloud-upload upload-icon" aria-hidden="true"></span>
<p>{{ translate('COM_MEDIA_DROP_FILE') }}</p>
</div>
<div v-if="listView === 'table'" class="media-browser-table">
<div class="media-browser-table-head">
<ul>
<li class="type"></li>
<li class="name">{{ translate('COM_MEDIA_MEDIA_NAME') }}</li>
<li class="size">{{ translate('COM_MEDIA_MEDIA_SIZE') }}</li>
<li class="dimension">{{ translate('COM_MEDIA_MEDIA_DIMENSION') }}</li>
<li class="created">{{ translate('COM_MEDIA_MEDIA_DATE_CREATED') }}</li>
<li class="modified">{{ translate('COM_MEDIA_MEDIA_DATE_MODIFIED') }}</li>
</ul>
</div>
<media-browser-item v-for="item in items" :key="item.path" :item="item"></media-browser-item>
</div>
<table v-if="listView === 'table'" class="table media-browser-table">
<caption class="sr-only">{{ sprintf('COM_MEDIA_BROWSER_TABLE_CAPTION', currentDirectory) }}</caption>
<thead class="media-browser-table-head">
<tr>
<th class="type" scope="col"></th>
<th class="name" scope="col">{{ translate('COM_MEDIA_MEDIA_NAME') }}</th>
<th class="size" scope="col">{{ translate('COM_MEDIA_MEDIA_SIZE') }}</th>
<th class="dimension" scope="col">{{ translate('COM_MEDIA_MEDIA_DIMENSION') }}</th>
<th class="created" scope="col">{{ translate('COM_MEDIA_MEDIA_DATE_CREATED') }}</th>
<th class="modified" scope="col">{{ translate('COM_MEDIA_MEDIA_DATE_MODIFIED') }}</th>
</tr>
</thead>
<media-browser-item-row v-for="item in items" :key="item.path" :item="item"></media-browser-item-row>
</table>
<div class="media-browser-grid" v-else-if="listView === 'grid'">
<div class="media-browser-items" :class="mediaBrowserGridItemsClass">
<media-browser-item v-for="item in items" :key="item.path" :item="item"></media-browser-item>
Expand Down Expand Up @@ -74,7 +75,28 @@
},
isModal() {
return Joomla.getOptions('com_media', {}).isModal;
}
},
currentDirectory() {
const parts = this.$store.state.selectedDirectory.split('/').filter(crumb => crumb.length !== 0);

// The first part is the name of the drive, so if we have a folder name display it. Else
// find the filename
if (parts.length !== 1) {
return parts[parts.length - 1];
}

let diskName = '';

this.$store.state.disks.forEach(disk => {
disk.drives.forEach(drive => {
if (drive.root === parts[0] + '/') {
diskName = drive.displayName;
}
});
});

return diskName;
}
},
methods: {
/* Unselect all browser items */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Directory from "./directory.vue";
import File from "./file.vue";
import Image from "./image.vue";
import Video from "./video.vue";
import Row from "./row.vue";
import * as types from "./../../../store/mutation-types";

export default {
Expand All @@ -17,10 +16,6 @@ export default {
* Return the correct item type component
*/
itemType() {
if (this.$store.state.listView === 'table') {
return Row;
}

let imageExtensions = ['jpg', 'jpeg', 'png', 'gif'];
let videoExtensions = ['mp4'];

Expand All @@ -46,10 +41,6 @@ export default {
* @returns {{}}
*/
styles() {
if (this.$store.state.listView === 'table') {
return {};
}

return {
'width': 'calc(' + this.$store.state.gridSize + '% - 20px)',
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<template>
<ul @dblclick.stop.prevent="onDblClick()">
<li class="type" :data-type="item.extension">
</li>
<li class="name">
<tr @dblclick.stop.prevent="onDblClick()" @click="onClick" :class="{selected: this.isSelected()}">
<td class="type" :data-type="item.extension">
</td>
<th scope="row" class="name">
{{ item.name }}
</li>
<li class="size">
</th>
<td class="size">
{{ item.size }}
</li>
<li class="dimension">
</td>
<td class="dimension">
{{ dimension }}
</li>
<li class="created">
</td>
<td class="created">
{{ item.create_date_formatted }}
</li>
<li class="modified">
</td>
<td class="modified">
{{ item.modified_date_formatted }}
</li>
</ul>
</td>
</tr>
</template>

<script>
Expand Down Expand Up @@ -56,7 +56,60 @@
this.$store.commit(types.SHOW_PREVIEW_MODAL);
this.$store.dispatch('getFullContents', this.item);
}
}
},

/**
* Whether or not the item is currently selected
* @returns {boolean}
*/
isSelected() {
return this.$store.state.selectedItems.some(selected => selected.path === this.item.path);
},


/**
* Handle the click event
* @param event
*/
onClick(event) {
let path = false;
const data = {
path: path,
thumb: false,
fileType: this.item.mime_type ? this.item.mime_type : false,
extension: this.item.extension ? this.item.extension : false,
};

if (this.item.type === 'file') {
data.path = this.item.path;
data.thumb = this.item.thumb ? this.item.thumb : false;

const ev = new CustomEvent('onMediaFileSelected', {
"bubbles": true,
"cancelable": false,
"detail": data
});
window.parent.document.dispatchEvent(ev);
}

// Handle clicks when the item was not selected
if (!this.isSelected()) {
// Unselect all other selected items, if the shift key was not pressed during the click event
if (!(event.shiftKey || event.keyCode === 13)) {
this.$store.commit(types.UNSELECT_ALL_BROWSER_ITEMS);
}
this.$store.commit(types.SELECT_BROWSER_ITEM, this.item);
return;
}

// If more than one item was selected and the user clicks again on the selected item,
// he most probably wants to unselect all other items.
if (this.$store.state.selectedItems.length > 1) {
this.$store.commit(types.UNSELECT_ALL_BROWSER_ITEMS);
this.$store.commit(types.SELECT_BROWSER_ITEM, this.item);
}
},

}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Toolbar from "./components/toolbar/toolbar.vue";
import Breadcrumb from "./components/breadcrumb/breadcrumb.vue";
import Browser from "./components/browser/browser.vue";
import BrowserItem from "./components/browser/items/item";
import BrowserItemRow from "./components/browser/items/row.vue";
import Modal from "./components/modals/modal.vue";
import CreateFolderModal from "./components/modals/create-folder-modal.vue";
import PreviewModal from "./components/modals/preview-modal.vue";
Expand All @@ -33,6 +34,7 @@ Vue.component('media-toolbar', Toolbar);
Vue.component('media-breadcrumb', Breadcrumb);
Vue.component('media-browser', Browser);
Vue.component('media-browser-item', BrowserItem);
Vue.component('media-browser-item-row', BrowserItemRow);
Vue.component('media-modal', Modal);
Vue.component('media-create-folder-modal', CreateFolderModal);
Vue.component('media-preview-modal', PreviewModal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let Translate = {};
Translate.translate = function (key) {
// Translate from Joomla text
return Joomla.JText._(key, key);
}
};


Translate.sprintf = function (string, ...args) {
Expand All @@ -25,16 +25,19 @@ Translate.sprintf = function (string, ...args) {
i++;
return val;
});
}
};

Translate.install = function (Vue, options) {
Vue.mixin({
methods: {
translate: function (key) {
return Translate.translate(key);
}
},
sprintf: function (key, ...args) {
return Translate.sprintf(key, args);
},
}
})
}
};

export default Translate;
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@

// Table View
.media-browser-table-head {
font-size: .8rem;
font-weight: bold;
.type {
margin-left: 1px;
&::before {
Expand All @@ -294,30 +292,6 @@
}

.media-browser-table {
overflow-y: auto;
font-size: .9rem;
line-height: $table-item-height;
transition: width .3s cubic-bezier(.4, .0, .2, 1);
.media-browser-item {
width: 100%;
margin: 0;
border: 1px solid rgba(0, 0, 0, .03);
&:hover {
background-color: $table-item-bg-hover;
}
}
ul {
display: flex;
padding: 0;
margin: 0;
list-style: none;
}
li {
padding: 0 10px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.name {
width: calc(30% - 40px);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Text::script('COM_MEDIA_ACTION_RENAME', true);
Text::script('COM_MEDIA_ACTION_SHARE', true);
Text::script('COM_MEDIA_BREADCRUMB_LABEL', true);
Text::script('COM_MEDIA_BROWSER_TABLE_CAPTION', true);
Text::script('COM_MEDIA_CONFIRM_DELETE_MODAL', true);
Text::script('COM_MEDIA_CONFIRM_DELETE_MODAL_HEADING', true);
Text::script('COM_MEDIA_CREATE_NEW_FOLDER', true);
Expand Down
1 change: 1 addition & 0 deletions administrator/language/en-GB/en-GB.com_media.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ COM_MEDIA_ACTION_PREVIEW="Preview item"
COM_MEDIA_ACTION_RENAME="Rename item"
COM_MEDIA_ACTION_SHARE="Get a sharable link"
COM_MEDIA_BREADCRUMB_LABEL="Breadcrumb"
COM_MEDIA_BROWSER_TABLE_CAPTION="Contents of Directory %s"
COM_MEDIA_CONFIGURATION="Media: Options"
COM_MEDIA_CONFIRM_DELETE_MODAL="Delete"
COM_MEDIA_CONFIRM_DELETE_MODAL_HEADING="Confirm Delete"
Expand Down