Skip to content

Commit d9c07af

Browse files
authored
Merge pull request #34294 from nextcloud/backport/34292/stable25
[stable25] Fix grid view button in public page
2 parents e85870a + a85d1ca commit d9c07af

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

apps/files_sharing/js/public.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ OCA.Sharing.PublicApp = {
6262

6363
// file list mode ?
6464
if ($el.find('.files-filestable').length) {
65+
// Toggle for grid view
66+
this.$showGridView = $('input#showgridview');
67+
this.$showGridView.on('change', _.bind(this._onGridviewChange, this));
68+
$('#view-toggle').tooltip({placement: 'bottom', trigger: 'hover'});
69+
6570
var filesClient = new OC.Files.Client({
6671
host: OC.getHost(),
6772
port: OC.getPort(),
@@ -364,6 +369,26 @@ OCA.Sharing.PublicApp = {
364369
}
365370
},
366371

372+
/**
373+
* Toggle showing gridview by default or not
374+
*
375+
* @returns {undefined}
376+
*/
377+
_onGridviewChange: function() {
378+
const isGridView = this.$showGridView.is(':checked');
379+
this.$showGridView.next('#view-toggle')
380+
.removeClass('icon-toggle-filelist icon-toggle-pictures')
381+
.addClass(isGridView ? 'icon-toggle-filelist' : 'icon-toggle-pictures')
382+
this.$showGridView.next('#view-toggle').attr(
383+
'data-original-title',
384+
isGridView ? t('files', 'Show list view') : t('files', 'Show grid view'),
385+
)
386+
387+
if (this.fileList) {
388+
this.fileList.setGridView(isGridView);
389+
}
390+
},
391+
367392
_onDirectoryChanged: function (e) {
368393
OC.Util.History.pushState({
369394
// arghhhh, why is this not called "dir" !?

0 commit comments

Comments
 (0)