summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-10-15 17:59:59 +0200
committerVincent Petry <pvince81@owncloud.com>2013-10-22 16:44:57 +0200
commit263f8bebfeb6be30a5dc327689dd1c1739f492e5 (patch)
treee6aa6447cb191cc05c2c7f322c98253e8e2e7e2d /apps/files
parentcadd71ec8a02fc5619a9347109f9e588e13b3e3b (diff)
downloadnextcloud-server-263f8bebfeb6be30a5dc327689dd1c1739f492e5.tar.gz
nextcloud-server-263f8bebfeb6be30a5dc327689dd1c1739f492e5.zip
Added FileList.setViewerMode to hide controls
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
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/js/filelist.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 84ff1093253..39b27ec9f3a 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -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();