From f5236cde1a2b9ec87794768568155344fa3a4461 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Mon, 4 Jul 2022 19:20:49 +0000 Subject: Change tooltip title of files grid view toggle dynamically Signed-off-by: Christopher Ng --- apps/files/js/filelist.js | 14 +++++++++----- apps/files/templates/index.php | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'apps/files') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 714e66e53ed..19b746ec847 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -748,19 +748,23 @@ * @returns {undefined} */ _onGridviewChange: function() { - var show = this.$showGridView.is(':checked'); + const isGridView = this.$showGridView.is(':checked'); // only save state if user is logged in if (OC.currentUser) { $.post(OC.generateUrl('/apps/files/api/v1/showgridview'), { - show: show + show: isGridView, }); } this.$showGridView.next('#view-toggle') .removeClass('icon-toggle-filelist icon-toggle-pictures') - .addClass(show ? 'icon-toggle-filelist' : 'icon-toggle-pictures') + .addClass(isGridView ? 'icon-toggle-filelist' : 'icon-toggle-pictures') + this.$showGridView.next('#view-toggle').attr( + 'data-original-title', + isGridView ? t('files', 'Show list view') : t('files', 'Show grid view'), + ) - $('.list-container').toggleClass('view-grid', show); - if (show) { + $('.list-container').toggleClass('view-grid', isGridView); + if (isGridView) { // If switching into grid view from list view, too few files might be displayed // Try rendering the next page this._onScroll(); diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 0d95f2694d9..e12d9fafab3 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -6,7 +6,7 @@ aria-label="t('Toggle grid view'))?>" checked="checked" /> + title="t('Show list view') : $l->t('Show grid view'))?>">