]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added FileList.setViewerMode to hide controls
authorVincent Petry <pvince81@owncloud.com>
Tue, 15 Oct 2013 15:59:59 +0000 (17:59 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 22 Oct 2013 14:44:57 +0000 (16:44 +0200)
Some files app embed themselves under the controls (like the text
editor). The new method FileList.setViewerMode() makes it possible to
properly show/hide the control buttons using the correct permissions.

Apps using this approach must call setViewerMode(true) when starting and
setViewerMode(false) upon closing to restore the controls.

This is needed for #5284

apps/files/js/filelist.js

index 84ff1093253caf8aed02c40a4e18c2882fd5c141..39b27ec9f3a78e49a487bdbb1627668eefa1ae08 100644 (file)
@@ -251,6 +251,31 @@ var FileList={
                $('.creatable').toggleClass('hidden', !isCreatable);
                $('.notCreatable').toggleClass('hidden', isCreatable);
        },
+       /**
+        * Shows/hides action buttons
+        *
+        * @param show true for enabling, false for disabling
+        */
+       showActions: function(show){
+               $('.actions,#file_action_panel').toggleClass('hidden', !show);
+               if (show){
+                       // make sure to display according to permissions
+                       var permissions =  $('#permissions').val();
+                       var isCreatable = (permissions & OC.PERMISSION_CREATE) !== 0;
+                       $('.creatable').toggleClass('hidden', !isCreatable);
+                       $('.notCreatable').toggleClass('hidden', isCreatable);
+               }
+       },
+       /**
+        * Enables/disables viewer mode.
+        * In viewer mode, apps can embed themselves under the controls bar.
+        * In viewer mode, the actions of the file list will be hidden.
+        * @param show true for enabling, false for disabling
+        */
+       setViewerMode: function(show){
+               this.showActions(!show);
+               $('#filestable').toggleClass('hidden', show);
+       },
        remove:function(name){
                $('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy');
                $('tr').filterAttr('data-file',name).remove();