Skip to content

Commit

Permalink
v1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ctf0 committed Oct 11, 2017
1 parent b48efa2 commit 1dac356
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 112 deletions.
7 changes: 0 additions & 7 deletions logs/v1.3.3.txt

This file was deleted.

3 changes: 3 additions & 0 deletions logs/v1.3.4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- fix pressing enter not working correctly because “selectedFile” is not cleared after last dir
- more optimization for keyboard events so now it fires only when needed.
- you can now use “left/right/home/end” when image lightBox is active
191 changes: 102 additions & 89 deletions src/resources/assets/js/components/media-bulma.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,44 @@ export default {
}
},
methods: {
navigation(e, curSelectedIndex) {
e.preventDefault()
let cur = ''
let newSelected = ''
// go to prev image
if ((keycode(e) == 'left' || keycode(e) == 'up') && curSelectedIndex !== 0) {
newSelected = curSelectedIndex - 1
cur = $('div[data-index="' + newSelected + '"]')
this.scrollToFile(cur)
}
// go to next image
if ((keycode(e) == 'right' || keycode(e) == 'down') && curSelectedIndex < this.allItemsCount - 1) {
newSelected = curSelectedIndex + 1
cur = $('div[data-index="' + newSelected + '"]')
this.scrollToFile(cur)
}
// go to last item
if (keycode(e) == 'end') {
newSelected = this.allItemsCount - 1
cur = $('div[data-index="' + newSelected + '"]')
this.scrollToFile(cur)
}
// go to first item
if (keycode(e) == 'home') {
this.scrollToFile()
}
if (!this.selectedFileIs('image')) {
this.noScroll()
}
},
// init
initManager() {
let manager = this
Expand Down Expand Up @@ -129,78 +167,42 @@ export default {
let curSelected = $('#files li .selected')
let curSelectedIndex = parseInt(curSelected.data('index'))
let newSelected = ''
// when modal isnt visible
if (!$('.modal').hasClass('is-active')) {
// when search is not focused
if (!$('.input').is(':focus')) {
// lightbox is not active
if (!this.lightBoxIsActive()) {
// when no bulk selecting
if (!this.isBulkSelecting()) {
let cur = ''
let newSelected = ''
let index = ''
if ((keycode(e) == 'left' || keycode(e) == 'up') && curSelectedIndex !== 0) {
e.preventDefault()
newSelected = curSelectedIndex - 1
cur = $('div[data-index="' + newSelected + '"]')
this.scrollToFile(cur)
}
if ((keycode(e) == 'right' || keycode(e) == 'down') && curSelectedIndex < this.allItemsCount - 1) {
e.preventDefault()
newSelected = curSelectedIndex + 1
cur = $('div[data-index="' + newSelected + '"]')
this.scrollToFile(cur)
}
// when no bulk selecting
if (!this.isBulkSelecting()) {
// open folder
if (keycode(e) == 'enter') {
this.openFolder(this.selectedFile)
}
// go up a dir
if (keycode(e) == 'backspace') {
index = parseInt(this.folders.length) - 1
// open folder
if (keycode(e) == 'enter' && this.selectedFile) {
this.openFolder(this.selectedFile)
}
if (index < 0) {
return false
}
// go up a dir
if (keycode(e) == 'backspace' && this.folders.length) {
newSelected = parseInt(this.folders.length) - 1
this.goToFolder(index)
if (newSelected < 0) {
return false
}
// go to first / last item
if (this.allItemsCount) {
if (keycode(e) == 'home') {
e.preventDefault()
this.scrollToFile()
}
if (keycode(e) == 'end') {
e.preventDefault()
index = this.allItemsCount - 1
cur = $('div[data-index="' + index + '"]')
this.scrollToFile(cur)
}
}
this.goToFolder(newSelected)
}
// file upload
if (keycode(e) == 'u') {
$('#upload').trigger('click')
}
// when there are files
if (this.allItemsCount) {
this.navigation(e, curSelectedIndex)
// play-pause for media
if (keycode(e) == 'space' && e.target == document.body) {
if (
keycode(e) == 'space' && e.target == document.body &&
(this.selectedFileIs('video') || this.selectedFileIs('audio') || this.selectedFileIs('image'))
) {
e.preventDefault()
// play-pause media
if (this.selectedFileIs('video') || this.selectedFileIs('audio')) {
return $('.player')[0].paused
? $('.player')[0].play()
Expand All @@ -213,44 +215,49 @@ export default {
this.toggleModal('#img_modal')
}
}
}
/* end of no bulk selection */
// when there are files
if (this.allItemsCount) {
// bulk select
if (keycode(e) == 'b') {
$('#blk_slct').trigger('click')
}
// add all to bulk list
if (this.isBulkSelecting() && keycode(e) == 'a') {
$('#blk_slct_all').trigger('click')
}
// delete file
if (keycode(e) == 'delete' || keycode(e) == 'd') {
$('#delete').trigger('click')
}
// refresh
if (keycode(e) == 'r') {
$('#refresh').trigger('click')
}
}
// end of when there are files
// move file
if (this.checkForFolders() && keycode(e) == 'm') {
$('#move').trigger('click')
}
// file upload
if (keycode(e) == 'u') {
$('#upload').trigger('click')
}
}
/* end of no bulk selection */
// with or without bulk selection
if (this.allItemsCount) {
// bulk select
if (keycode(e) == 'b') {
$('#blk_slct').trigger('click')
}
// add all to bulk list
if (this.isBulkSelecting() && keycode(e) == 'a') {
$('#blk_slct_all').trigger('click')
}
/* end of there are files */
// toggle file details sidebar
if (keycode(e) == 't') {
$('.toggle').trigger('click')
// delete file
if (keycode(e) == 'delete' || keycode(e) == 'd') {
$('#delete').trigger('click')
}
// move file
if (this.checkForFolders() && keycode(e) == 'm') {
$('#move').trigger('click')
}
}
/* end of with or without bulk selection */
// toggle file details sidebar
if (keycode(e) == 't') {
$('.toggle').trigger('click')
}
/* end of no lightbox is active */
}
/* end of search is not focused */
}
Expand All @@ -263,11 +270,17 @@ export default {
$('.modal.is-active').find('button[type="submit"]').trigger('click')
}
if (this.lightBoxIsActive() && keycode(e) == 'space') {
e.preventDefault()
this.toggleModal()
if (this.lightBoxIsActive()) {
// hide lb
if (keycode(e) == 'space') {
e.preventDefault()
this.toggleModal()
}
this.navigation(e, curSelectedIndex)
}
// hide lb
if (keycode(e) == 'esc') {
this.toggleModal()
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/assets/js/components/mixins/methods/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export default {
return 'N/A'
}

let k = 1000,
dm = 2,
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k))
let k = 1000
let dm = 2
let sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
let i = Math.floor(Math.log(bytes) / Math.log(k))

return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
},
Expand Down
1 change: 1 addition & 0 deletions src/resources/assets/js/components/mixins/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default {
watch: {
allFiles(val) {
if (val.length < 1) {
this.resetInput('selectedFile')
return this.noFiles('show')
}

Expand Down
8 changes: 2 additions & 6 deletions src/resources/assets/sass/shared/manager.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ $blue_2: #276cda;
// toolbar
#toolbar {
flex-wrap: wrap;
margin: 0;
padding: 1rem;
border: 1px solid $gray_2;
border-bottom: 0;
margin: 0;
border-radius: 4px 4px 0 0;
background: $white_gray;
}
Expand Down Expand Up @@ -62,11 +62,11 @@ $blue_2: #276cda;

// breadcrump
.breadcrumb-container {
margin: 0 !important;
padding: 0.5rem 1rem;
border: 1px solid $gray_2;
border-top: 0;
background: $gray_3;
margin: 0 !important;

.breadcrumb {
margin-bottom: 0 !important;
Expand Down Expand Up @@ -369,7 +369,3 @@ $blue_2: #276cda;
.m-l-50 {
margin-left: 50px !important;
}

.m-0 {
margin: 0 !important;
}
12 changes: 6 additions & 6 deletions src/resources/views/media-bulma.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class="button"
{{-- ====================================================================== --}}

{{-- upload --}}
<div class="field m-0">
<div class="field is-marginless">
<div id="dz">
<form class="dz" id="new-upload" action="{{ route('media.upload') }}">
<div class="dz-message title is-4">
Expand Down Expand Up @@ -352,7 +352,7 @@ class="button"
<img :src="selectedFile.path">
</p>
</div>
<button class="modal-close is-large" aria-label="close" @click="toggleModal()"></button>
<button class="modal-close is-large" @click="toggleModal()"></button>
</div>
<img :src="selectedFile.path"
v-tippy="{position: 'right', arrow: true}"
Expand Down Expand Up @@ -424,7 +424,7 @@ class="button"
<span class="icon"><i class="fa fa-folder"></i></span>
<span>{{ trans('MediaManager::messages.add_new_folder') }}</span>
</p>
<button type="button" class="delete" aria-label="close" @click="toggleModal()"></button>
<button type="button" class="delete" @click="toggleModal()"></button>
</header>
<section class="modal-card-body">
<input class="input" type="text"
Expand Down Expand Up @@ -452,7 +452,7 @@ class="button"
<span class="icon"><i class="fa fa-i-cursor"></i></span>
<span>{{ trans('MediaManager::messages.rename_file_folder') }}</span>
</p>
<button type="button" class="delete" aria-label="close" @click="toggleModal()"></button>
<button type="button" class="delete" @click="toggleModal()"></button>
</header>
<section class="modal-card-body">
<h4 class="title">{{ trans('MediaManager::messages.new_file_folder') }}</h4>
Expand Down Expand Up @@ -482,7 +482,7 @@ class="button"
<span class="icon"><i class="fa fa-share"></i></span>
<span>{{ trans('MediaManager::messages.move_file_folder') }}</span>
</p>
<button type="button" class="delete" aria-label="close" @click="toggleModal()"></button>
<button type="button" class="delete" @click="toggleModal()"></button>
</header>
<section class="modal-card-body">
<h4 class="title">{{ trans('MediaManager::messages.destination_folder') }}</h4>
Expand Down Expand Up @@ -523,7 +523,7 @@ class="button"
<span class="icon"><i class="fa fa-warning"></i></span>
<span>{{ trans('MediaManager::messages.are_you_sure') }}</span>
</p>
<button type="button" class="delete" aria-label="close" @click="toggleModal()"></button>
<button type="button" class="delete" @click="toggleModal()"></button>
</header>
<section class="modal-card-body">
<h4 class="title">{{ trans('MediaManager::messages.are_you_sure_delete') }}</h4>
Expand Down

0 comments on commit 1dac356

Please sign in to comment.