aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/app.js45
-rw-r--r--apps/files/js/breadcrumb.js2
-rw-r--r--apps/files/js/file-upload.js2
-rw-r--r--apps/files/js/fileactions.js12
-rw-r--r--apps/files/js/fileinfomodel.js13
-rw-r--r--apps/files/js/filelist.js41
-rw-r--r--apps/files/js/files.js9
-rw-r--r--apps/files/js/jquery.fileupload.js6
-rw-r--r--apps/files/js/navigation.js11
-rw-r--r--apps/files/js/newfilemenu.js2
10 files changed, 95 insertions, 48 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js
index f7863de09be..fee89cb523d 100644
--- a/apps/files/js/app.js
+++ b/apps/files/js/app.js
@@ -61,6 +61,11 @@
var cropImagePreviews = $('#cropImagePreviews').val() === "1";
this.$cropImagePreviews.prop('checked', cropImagePreviews);
+ // Toggle for grid view
+ this.$showGridView = $('input#showgridview');
+ this.$showGridView.on('change', _.bind(this._onGridviewChange, this));
+ $('#view-toggle').tooltip({placement: 'bottom', trigger: 'hover'});
+
if ($('#fileNotFound').val() === "1") {
OC.Notification.show(t('files', 'File could not be found'), {type: 'error'});
}
@@ -190,7 +195,16 @@
* @param {OCA.Files.FileList} newFileList -
*/
updateCurrentFileList: function(newFileList) {
+ if (this.currentFileList === newFileList) {
+ return
+ }
+
this.currentFileList = newFileList;
+ if (this.currentFileList !== null) {
+ // update grid view to the current value
+ const isGridView = this.$showGridView.is(':checked');
+ this.currentFileList.setGridView(isGridView);
+ }
},
/**
@@ -309,6 +323,7 @@
this._changeUrl(params.view, params.dir);
OC.Apps.hideAppSidebar($('.detailsView'));
this.navigation.getActiveContainer().trigger(new $.Event('urlChanged', params));
+ window._nc_event_bus.emit('files:navigation:changed')
}
},
@@ -360,6 +375,7 @@
this.navigation.getActiveContainer().trigger(new $.Event('show'));
}
this.navigation.getActiveContainer().trigger(new $.Event('urlChanged', params));
+ window._nc_event_bus.emit('files:navigation:changed')
},
/**
@@ -394,7 +410,34 @@
} else {
OC.Util.History.pushState(this._makeUrlParams(params));
}
- }
+ },
+
+ /**
+ * Toggle showing gridview by default or not
+ *
+ * @returns {undefined}
+ */
+ _onGridviewChange: function() {
+ 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: isGridView,
+ });
+ }
+ 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.currentFileList) {
+ this.currentFileList.setGridView(isGridView);
+ }
+ },
+
};
})();
diff --git a/apps/files/js/breadcrumb.js b/apps/files/js/breadcrumb.js
index 5386d6ee4a4..1083be461bb 100644
--- a/apps/files/js/breadcrumb.js
+++ b/apps/files/js/breadcrumb.js
@@ -320,7 +320,7 @@
// depending on whether the menu was previously being shown or not.
this.$el.find('.crumbmenu').addClass('hidden');
- // Show the crumbs to compress the siblings before hidding again the
+ // Show the crumbs to compress the siblings before hiding again the
// crumbs. This is needed when the siblings expand to fill all the
// available width, as in that case their old width would limit the
// available width for the crumbs.
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index dc38f731108..69f9d9d0e63 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -12,7 +12,7 @@
* The file upload code uses several hooks to interact with blueimps jQuery file upload library:
* 1. the core upload handling hooks are added when initializing the plugin,
* 2. if the browser supports progress events they are added in a separate set after the initialization
- * 3. every app can add it's own triggers for fileupload
+ * 3. every app can add its own triggers for fileupload
* - files adds d'n'd handlers and also reacts to done events to add new rows to the filelist
* - TODO pictures upload button
* - TODO music upload button
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 8790eae9c98..f342f21a4fb 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -370,6 +370,7 @@
var menu;
var $trigger = context.$file.closest('tr').find('.fileactions .action-menu');
$trigger.addClass('open');
+ $trigger.attr('aria-expanded', 'true');
menu = new OCA.Files.FileActionsMenu();
@@ -378,6 +379,7 @@
menu.$el.on('afterHide', function() {
context.$file.removeClass('mouseOver');
$trigger.removeClass('open');
+ $trigger.attr('aria-expanded', 'false');
menu.remove();
});
@@ -404,6 +406,7 @@
}, false, context);
$el.addClass('permanent');
+ $el.attr('aria-expanded', 'false');
},
@@ -670,6 +673,9 @@
displayName: function(context) {
var permissions = context.fileInfoModel.attributes.permissions;
if (permissions & OC.PERMISSION_UPDATE) {
+ if (!context.fileInfoModel.canDownload()) {
+ return t('files', 'Move');
+ }
return t('files', 'Move or copy');
}
return t('files', 'Copy');
@@ -682,7 +688,11 @@
var permissions = context.fileInfoModel.attributes.permissions;
var actions = OC.dialogs.FILEPICKER_TYPE_COPY;
if (permissions & OC.PERMISSION_UPDATE) {
- actions = OC.dialogs.FILEPICKER_TYPE_COPY_MOVE;
+ if (!context.fileInfoModel.canDownload()) {
+ actions = OC.dialogs.FILEPICKER_TYPE_MOVE;
+ } else {
+ actions = OC.dialogs.FILEPICKER_TYPE_COPY_MOVE;
+ }
}
var dialogDir = context.dir;
if (typeof context.fileList.dirInfo.dirLastCopiedTo !== 'undefined') {
diff --git a/apps/files/js/fileinfomodel.js b/apps/files/js/fileinfomodel.js
index 83a8c62592b..79575109656 100644
--- a/apps/files/js/fileinfomodel.js
+++ b/apps/files/js/fileinfomodel.js
@@ -126,7 +126,18 @@
});
return deferred.promise();
- }
+ },
+
+ canDownload: function() {
+ for (const i in this.attributes.shareAttributes) {
+ const attr = this.attributes.shareAttributes[i]
+ if (attr.scope === 'permissions' && attr.key === 'download') {
+ return attr.enabled
+ }
+ }
+
+ return true
+ },
});
if (!OCA.Files) {
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 4acefa6902b..ee596dd417e 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -105,7 +105,7 @@
* @return {number} page size
*/
pageSize: function() {
- var isGridView = this.$showGridView.is(':checked');
+ var isGridView = this.$table.hasClass('view-grid');
var columns = 1;
var rows = Math.ceil(this.$container.height() / 50);
if (isGridView) {
@@ -275,7 +275,7 @@
if (options.id) {
this.id = options.id;
}
- this.$container = options.scrollContainer || $(window);
+ this.$container = options.scrollContainer || $('#app-content');
this.$table = $el.find('table:first');
this.$fileList = $el.find('.files-fileList');
this.$header = $el.find('.filelist-header');
@@ -368,12 +368,6 @@
this.$el.find('thead th .columntitle').click(_.bind(this._onClickHeader, this));
- // Toggle for grid view, only register once
- this.$showGridView = $('input#showgridview:not(.registered)');
- this.$showGridView.on('change', _.bind(this._onGridviewChange, this));
- this.$showGridView.addClass('registered');
- $('#view-toggle').tooltip({placement: 'bottom', trigger: 'hover'});
-
this._onResize = _.debounce(_.bind(this._onResize, this), 250);
$('#app-content').on('appresized', this._onResize);
$(window).resize(this._onResize);
@@ -747,27 +741,7 @@
this.breadcrumb._resize();
},
- /**
- * Toggle showing gridview by default or not
- *
- * @returns {undefined}
- */
- _onGridviewChange: function() {
- 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: isGridView,
- });
- }
- 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'),
- )
-
+ setGridView: function(isGridView) {
this.$table.toggleClass('view-grid', isGridView);
if (isGridView) {
// If switching into grid view from list view, too few files might be displayed
@@ -2591,7 +2565,7 @@
* @param fileNames array of file names to move
* @param targetPath absolute target path
* @param callback function to call when movement is finished
- * @param dir the dir path where fileNames are located (optionnal, will take current folder if undefined)
+ * @param dir the dir path where fileNames are located (optional, will take current folder if undefined)
*/
move: function(fileNames, targetPath, callback, dir) {
var self = this;
@@ -2683,7 +2657,7 @@
* @param fileNames array of file names to copy
* @param targetPath absolute target path
* @param callback to call when copy is finished with success
- * @param dir the dir path where fileNames are located (optionnal, will take current folder if undefined)
+ * @param dir the dir path where fileNames are located (optional, will take current folder if undefined)
*/
copy: function(fileNames, targetPath, callback, dir) {
var self = this;
@@ -2712,7 +2686,7 @@
if ( dotIndex > 1) {
var leftPartOfName = targetPathAndName.substr(0, dotIndex);
var fileNumber = leftPartOfName.match(/\d+/);
- // TRANSLATORS name that is appended to copied files with the same name, will be put in parenthesis and appened with a number if it is the second+ copy
+ // TRANSLATORS name that is appended to copied files with the same name, will be put in parenthesis and appended with a number if it is the second+ copy
var copyNameLocalized = t('files', 'copy');
if (isNaN(fileNumber) ) {
fileNumber++;
@@ -3853,7 +3827,7 @@
$actionsContainer.prepend($newButton);
$newButton.tooltip({'placement': 'bottom'});
-
+ $newButton.attr('aria-expanded', 'false');
$newButton.click(_.bind(this._onClickNewButton, this));
this._newButton = $newButton;
},
@@ -3864,6 +3838,7 @@
$target = $target.closest('.button');
}
this._newButton.tooltip('hide');
+ $target.attr('aria-expanded', 'true');
event.preventDefault();
if ($target.hasClass('disabled')) {
return false;
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 1aa39eab523..614186bc86a 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -98,14 +98,15 @@
}
if (response.data !== undefined
&& response.data.quota !== undefined
+ && response.data.total !== undefined
&& response.data.used !== undefined
&& response.data.usedSpacePercent !== undefined) {
var humanUsed = OC.Util.humanFileSize(response.data.used, true);
- var humanQuota = OC.Util.humanFileSize(response.data.quota, true);
+ var humanTotal = OC.Util.humanFileSize(response.data.total, true);
if (response.data.quota > 0) {
- $('#quota').attr('data-original-title', Math.floor(response.data.used/response.data.quota*1000)/10 + '%');
+ $('#quota').attr('data-original-title', t('files', '{used}%', {used: Math.round(response.data.usedSpacePercent)}));
$('#quota progress').val(response.data.usedSpacePercent);
- $('#quotatext').html(t('files', '{used} of {quota} used', {used: humanUsed, quota: humanQuota}));
+ $('#quotatext').html(t('files', '{used} of {quota} used', {used: humanUsed, quota: humanTotal}));
} else {
$('#quotatext').html(t('files', '{used} used', {used: humanUsed}));
}
@@ -483,7 +484,7 @@ var dragOptions={
$('.crumbmenu').removeClass('canDropChildren');
},
drag: function(event, ui) {
- var scrollingArea = window;
+ var scrollingArea = FileList.$container;
var currentScrollTop = $(scrollingArea).scrollTop();
var scrollArea = Math.min(Math.floor($(window).innerHeight() / 2), 100);
diff --git a/apps/files/js/jquery.fileupload.js b/apps/files/js/jquery.fileupload.js
index cc0c97ba3ed..9b382ccae39 100644
--- a/apps/files/js/jquery.fileupload.js
+++ b/apps/files/js/jquery.fileupload.js
@@ -420,7 +420,7 @@
_initProgressListener: function (options) {
var that = this,
xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr();
- // Accesss to the native XHR object is required to add event listeners
+ // Access to the native XHR object is required to add event listeners
// for the upload progress event:
if (xhr.upload) {
$(xhr.upload).bind('progress', function (e) {
@@ -1060,7 +1060,7 @@
data.fileInputClone = inputClone;
$('<form></form>').append(inputClone)[0].reset();
// Detaching allows to insert the fileInput on another form
- // without loosing the file input value:
+ // without losing the file input value:
input.after(inputClone).detach();
// If the fileInput had focus before it was detached,
// restore focus to the inputClone.
@@ -1138,7 +1138,7 @@
dirReader = entry.createReader();
readEntries();
} else {
- // Return an empy list for file system items
+ // Return an empty list for file system items
// other than files or directories:
dfd.resolve([]);
}
diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js
index f8f15394ef0..d7ae7dd7fee 100644
--- a/apps/files/js/navigation.js
+++ b/apps/files/js/navigation.js
@@ -141,13 +141,13 @@
}
return;
}
- this.$el.find('li a').removeClass('active');
+ this.$el.find('li a').removeClass('active').removeAttr('aria-current');
if (this.$currentContent) {
this.$currentContent.addClass('hidden');
this.$currentContent.trigger(jQuery.Event('hide'));
}
this._activeItem = itemId;
- currentItem.children('a').addClass('active');
+ currentItem.children('a').addClass('active').attr('aria-current', 'page');
this.$currentContent = $('#app-content-' + (typeof itemView === 'string' && itemView !== '' ? itemView : itemId));
this.$currentContent.removeClass('hidden');
if (!options || !options.silent) {
@@ -200,6 +200,13 @@
if ($menu.hasClass('collapsible') && $menu.data('expandedstate')) {
$menu.toggleClass('open');
+ var targetAriaExpanded = $target.attr('aria-expanded');
+ if (targetAriaExpanded === 'false') {
+ $target.attr('aria-expanded', 'true');
+ } else if (targetAriaExpanded === 'true') {
+ $target.attr('aria-expanded', 'false');
+ }
+ $menu.toggleAttr('data-expanded', 'true', 'false');
var show = $menu.hasClass('open') ? 1 : 0;
var key = $menu.data('expandedstate');
$.post(OC.generateUrl("/apps/files/api/v1/toggleShowFolder/" + key), {show: show});
diff --git a/apps/files/js/newfilemenu.js b/apps/files/js/newfilemenu.js
index faebc305c6d..67ca8934549 100644
--- a/apps/files/js/newfilemenu.js
+++ b/apps/files/js/newfilemenu.js
@@ -245,7 +245,7 @@
*/
showAt: function($target) {
this.render();
- OC.showMenu(null, this.$el);
+ OC.showMenu($target, this.$el);
}
});