Skip to content
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Commit dbd51fd

Browse files
authored
Merge pull request #23 from Pavel-Teplitsky/master
Improved directory navigation
2 parents d614f93 + 6e7e683 commit dbd51fd

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

src/main/resources/assets/css/quickview.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,9 @@ section {
671671
background: #ddd;
672672
border-color: #aaa;
673673
}
674+
.qv-go-up{
675+
cursor: pointer;
676+
}
674677
/*
675678
******************************************
676679
Document types

src/main/resources/assets/js/quickview.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ NAV BAR CONTROLS
153153
//////////////////////////////////////////////////
154154
// Go to parent directory event from file tree
155155
//////////////////////////////////////////////////
156-
$('.qv-modal-body').on('click', '.qv-filetree-up', function(e){
156+
$('.qv-modal-body').on('click', '.qv-go-up', function(e){
157157
if(currentDirectory.length > 0 && currentDirectory.indexOf('/') == -1){
158158
currentDirectory = '';
159159
}else{
160160
currentDirectory = currentDirectory.replace(/\/[^\/]+\/?$/, '');
161161
}
162162
loadFileTree(currentDirectory);
163-
});
163+
});
164164

165165
//////////////////////////////////////////////////
166166
// Zoom values event
@@ -681,8 +681,8 @@ function loadFileTree(dir) {
681681
// clear tree list from previous data
682682
$('#qv-modal-filebroswer tbody').html(
683683
'<tr>'+
684-
'<td class="text-center"><i class="fa fa-level-up"></i></td>'+
685-
'<td class="qv-filetree-up">...</td>'+
684+
'<td class="text-center qv-go-up"><i class="fa fa-level-up"></i></td>'+
685+
'<td class="qv-filetree-up qv-go-up">...</td>'+
686686
'<td></td>'+
687687
'<td></td>'+
688688
'</tr>');
@@ -702,7 +702,7 @@ function loadFileTree(dir) {
702702
new_size = (Math.round((size / 1024) * 100) / 100) + ' KB';
703703
}
704704
// document format
705-
var docFormat = (getDocumentFormat(name) == undefined)? 'fa-folder' : getDocumentFormat(name);
705+
var docFormat = (getDocumentFormat(name, elem.isDirectory) == undefined)? 'fa-folder' : getDocumentFormat(name, elem.isDirectory);
706706
// append document
707707
$('.qv-modal-table tbody').append(
708708
'<tr>'+
@@ -974,17 +974,22 @@ function appendHtmlContent(pageNumber, documentName, prefix, width, height){
974974
/**
975975
* Get document format (type)
976976
* @param {string} filename - document name
977+
* @param {boolean} isDirectory - define if the current element is directory or file
977978
*/
978-
function getDocumentFormat(filename){
979-
if(typeof map[filename.split('.').pop().toLowerCase()] == "undefined"){
980-
if(filename.split('.').length > 1){
981-
return map["unknown"];
979+
function getDocumentFormat(filename, isDirectory){
980+
if(!isDirectory){
981+
if(typeof map[filename.split('.').pop().toLowerCase()] == "undefined"){
982+
if(filename.split('.').length > 1){
983+
return map["unknown"];
984+
} else {
985+
return map["folder"];
986+
}
982987
} else {
983-
return map["folder"];
988+
return map[filename.split('.').pop().toLowerCase()];
984989
}
985-
} else {
986-
return map[filename.split('.').pop().toLowerCase()];
987-
}
990+
} else {
991+
return map["folder"];
992+
}
988993
}
989994

990995
/**

0 commit comments

Comments
 (0)