]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix grid view button in public page 34292/head
authorVincent Petry <vincent@nextcloud.com>
Tue, 27 Sep 2022 13:51:15 +0000 (15:51 +0200)
committerVincent Petry <vincent@nextcloud.com>
Tue, 27 Sep 2022 13:51:15 +0000 (15:51 +0200)
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
apps/files_sharing/js/public.js

index 6c68490aef58cea876c2037d21842b9901f16bb3..9b0f44213605d69a29ad758ec2e741479187147d 100644 (file)
@@ -62,6 +62,11 @@ OCA.Sharing.PublicApp = {
 
                // file list mode ?
                if ($el.find('.files-filestable').length) {
+                       // Toggle for grid view
+                       this.$showGridView = $('input#showgridview');
+                       this.$showGridView.on('change', _.bind(this._onGridviewChange, this));
+                       $('#view-toggle').tooltip({placement: 'bottom', trigger: 'hover'});
+
                        var filesClient = new OC.Files.Client({
                                host: OC.getHost(),
                                port: OC.getPort(),
@@ -364,6 +369,26 @@ OCA.Sharing.PublicApp = {
                }
        },
 
+       /**
+        * Toggle showing gridview by default or not
+        *
+        * @returns {undefined}
+        */
+       _onGridviewChange: function() {
+               const isGridView = this.$showGridView.is(':checked');
+               this.$showGridView.next('#view-toggle')
+                       .removeClass('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'),
+               )
+
+               if (this.fileList) {
+                       this.fileList.setGridView(isGridView);
+               }
+       },
+
        _onDirectoryChanged: function (e) {
                OC.Util.History.pushState({
                        // arghhhh, why is this not called "dir" !?