From 0cca9e26c41a1957b3a574d33b3835ea76c63e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 2 Jan 2015 12:50:21 +0100 Subject: [PATCH] show no files found message --- apps/files/css/files.css | 23 +++++++++++++++++++++++ apps/files/js/filelist.js | 5 +++++ apps/files/js/search.js | 8 ++++++++ apps/files/templates/list.php | 6 ++++++ search/js/search.js | 27 +++++++++------------------ 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/apps/files/css/files.css b/apps/files/css/files.css index a75ad57c83..a6a28b594a 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -599,3 +599,26 @@ table.dragshadow td.size { .mask.transparent{ opacity: 0; } + +#nofilterresults { + font-size: 16px; + color: #888; + position: absolute; + text-align: center; + top: 30%; + width: 100%; +} +#nofilterresults h2 { + font-size: 22px; + margin-bottom: 10px; +} +#nofilterresults [class^="icon-"], +#nofilterresults [class*=" icon-"] { + background-size: 64px; + height: 64px; + width: 64px; + margin: 0 auto 15px; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; + filter: alpha(opacity=50); + opacity: .5; +} \ No newline at end of file diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index e01a029bc9..48c990872d 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1685,9 +1685,14 @@ if (this._filter && this.fileSummary.summary.totalDirs + this.fileSummary.summary.totalFiles === 0) { this.$el.find('#filestable thead th').addClass('hidden'); this.$el.find('#emptycontent').addClass('hidden'); + if ( $('#searchresults').length === 0 || $('#searchresults').hasClass('hidden')) { + this.$el.find('#nofilterresults').removeClass('hidden'). + find('p').text(t('files', 'No entries in this folder match \'{filter}\'', {filter:this._filter})); + } } else { this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty); this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty); + this.$el.find('#nofilterresults').addClass('hidden'); } }, /** diff --git a/apps/files/js/search.js b/apps/files/js/search.js index 73eccd06dc..ec93b93769 100644 --- a/apps/files/js/search.js +++ b/apps/files/js/search.js @@ -40,11 +40,18 @@ result.mime = result.mime_type; } } + function hideNoFilterResults (){ + var $nofilterresults = $('#nofilterresults'); + if ( ! $nofilterresults.hasClass('hidden') ) { + $nofilterresults.addClass('hidden'); + } + } this.renderFolderResult = function($row, result) { if (inFileList($row, result)) { return null; } + hideNoFilterResults(); /*render folder icon, show path beneath filename, show size and last modified date on the right */ this.updateLegacyMimetype(result); @@ -61,6 +68,7 @@ if (inFileList($row, result)) { return null; } + hideNoFilterResults(); /*render preview icon, show path beneath filename, show size and last modified date on the right */ this.updateLegacyMimetype(result); diff --git a/apps/files/templates/list.php b/apps/files/templates/list.php index 4224d9bc10..5b90e629dd 100644 --- a/apps/files/templates/list.php +++ b/apps/files/templates/list.php @@ -60,6 +60,12 @@

t('Upload some content or sync with your devices!')); ?>

+ + diff --git a/search/js/search.js b/search/js/search.js index b090a4ec4a..8e576e6e8f 100644 --- a/search/js/search.js +++ b/search/js/search.js @@ -109,7 +109,7 @@ } } // prevent double pages - if ($searchResults && query === lastQuery && page === lastPage&& size === lastSize) { + if ($searchResults && query === lastQuery && page === lastPage && size === lastSize) { return; } lastQuery = query; @@ -153,9 +153,6 @@ } } function showResults(results) { - if (results.length === 0) { - return; - } if (!$searchResults) { $wrapper = $('
'); $('#app-content') @@ -190,9 +187,7 @@ }); $('#app-content').on('scroll', _.bind(onScroll, this)); lastResults = results; - $status = $searchResults.find('#status') - .data('count', results.length) - .text(t('search', '{count} search results in other folders', {count:results.length}, results.length)); + $status = $searchResults.find('#status'); placeStatus(); showResults(results); }); @@ -231,16 +226,11 @@ } if ($row) { $searchResults.find('tbody').append($row); - } else { - // not showing result, decrease counter - var count = $status.data('count') - 1; - if (count < 0) { - count = 0; - } - $status.data('count', count) - .text(t('search', '{count} search results in other places', {count:count}, count)); } }); + var count = $searchResults.find('tr.result').length; + $status.data('count', count) + .text(t('search', '{count} search results in other places', {count:count}, count)); } function renderCurrent() { var result = $searchResults.find('tr.result')[currentResult]; @@ -263,6 +253,7 @@ $wrapper.remove(); $searchResults = false; $wrapper = false; + lastQuery = false; } }; @@ -292,14 +283,14 @@ var query = $searchBox.val(); if (lastQuery !== query) { currentResult = -1; - if(self.hasFilter(getCurrentApp())) { - self.getFilter(getCurrentApp())(query); - } if (query.length > 2) { self.search(query); } else { self.hideResults(); } + if(self.hasFilter(getCurrentApp())) { + self.getFilter(getCurrentApp())(query); + } } } });