aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/breadcrumb.js2
-rw-r--r--apps/files/js/favoritesfilelist.js6
-rw-r--r--apps/files/js/file-upload.js6
-rw-r--r--apps/files/js/fileinfomodel.js9
-rw-r--r--apps/files/js/filelist.js113
-rw-r--r--apps/files/js/files.js13
-rw-r--r--apps/files/js/keyboardshortcuts.js20
-rw-r--r--apps/files/js/recentfilelist.js6
8 files changed, 100 insertions, 75 deletions
diff --git a/apps/files/js/breadcrumb.js b/apps/files/js/breadcrumb.js
index 383d3debd09..5386d6ee4a4 100644
--- a/apps/files/js/breadcrumb.js
+++ b/apps/files/js/breadcrumb.js
@@ -220,7 +220,7 @@
});
// root part
crumbs.push({
- name: t('core', 'Home'),
+ name: t('files', 'Home'),
dir: '/',
class: 'crumbhome',
linkclass: rootIcon || 'icon-home'
diff --git a/apps/files/js/favoritesfilelist.js b/apps/files/js/favoritesfilelist.js
index 737f2fd6e96..7ea41da8143 100644
--- a/apps/files/js/favoritesfilelist.js
+++ b/apps/files/js/favoritesfilelist.js
@@ -18,7 +18,7 @@ window.addEventListener('DOMContentLoaded', function() {
* @classdesc Favorites file list.
* Displays the list of files marked as favorites
*
- * @param $el container element with existing markup for the #controls
+ * @param $el container element with existing markup for the .files-controls
* and a table
* @param [options] map of options, see other parameters
*/
@@ -48,8 +48,8 @@ window.addEventListener('DOMContentLoaded', function() {
var dir = this.getCurrentDirectory();
if (dir === '/') {
// root has special permissions
- this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty);
- this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty);
+ this.$el.find('.emptyfilelist.emptycontent').toggleClass('hidden', !this.isEmpty);
+ this.$el.find('.files-filestable thead th').toggleClass('hidden', this.isEmpty);
}
else {
OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments);
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 793c9672c3f..dc38f731108 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -1030,7 +1030,7 @@ OC.Uploader.prototype = _.extend({
// check free space
if (!self.fileList || upload.getTargetFolder() === self.fileList.getCurrentDirectory()) {
// Use global free space if there is no file list to check or the current directory is the target
- freeSpace = $('#free_space').val()
+ freeSpace = $('input[name=free_space]').val()
} else if (upload.getTargetFolder().indexOf(self.fileList.getCurrentDirectory()) === 0) {
// Check subdirectory free space if file is uploaded there
// Retrieve the folder destination name
@@ -1134,7 +1134,7 @@ OC.Uploader.prototype = _.extend({
}
}
console.error(e, data, response)
- OC.Notification.show(message || data.errorThrown, {type: 'error'});
+ OC.Notification.show(message || data.errorThrown || t('files', 'File could not be uploaded'), {type: 'error'});
}
if (upload) {
@@ -1266,7 +1266,7 @@ OC.Uploader.prototype = _.extend({
});
fileupload.on('fileuploaddragover', function(e){
$('#app-content').addClass('file-drag');
- $('#emptycontent .icon-folder').addClass('icon-filetype-folder-drag-accept');
+ $('.emptyfilelist.emptycontent .icon-folder').addClass('icon-filetype-folder-drag-accept');
var filerow = $(e.delegatedEvent.target).closest('tr');
diff --git a/apps/files/js/fileinfomodel.js b/apps/files/js/fileinfomodel.js
index 8e7b399544c..83a8c62592b 100644
--- a/apps/files/js/fileinfomodel.js
+++ b/apps/files/js/fileinfomodel.js
@@ -84,6 +84,15 @@
},
/**
+ * Returns the mimetype of the file
+ *
+ * @return {string} mimetype
+ */
+ getMimeType: function() {
+ return this.get('mimetype');
+ },
+
+ /**
* Reloads missing properties from server and set them in the model.
* @param properties array of properties to be reloaded
* @return ajax call object
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 701b635fac3..4acefa6902b 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -18,7 +18,7 @@
* A file list view consists of a controls bar and
* a file list table.
*
- * @param $el container element with existing markup for the #controls
+ * @param $el container element with existing markup for the .files-controls
* and a table
* @param {Object} [options] map of options, see other parameters
* @param {Object} [options.scrollContainer] scrollable container, defaults to $(window)
@@ -224,13 +224,14 @@
/**
* Initialize the file list and its components
*
- * @param $el container element with existing markup for the #controls
+ * @param $el container element with existing markup for the .files-controls
* and a table
* @param options map of options, see other parameters
* @param options.scrollContainer scrollable container, defaults to $(window)
* @param options.dragOptions drag options, disabled by default
* @param options.folderDropOptions folder drop options, disabled by default
* @param options.scrollTo name of file to scroll to after the first load
+ * @param [options.dir='/'] current directory
* @param {OC.Files.Client} [options.filesClient] files API client
* @param {OC.Backbone.Model} [options.filesConfig] files app configuration
* @private
@@ -276,9 +277,9 @@
}
this.$container = options.scrollContainer || $(window);
this.$table = $el.find('table:first');
- this.$fileList = $el.find('#fileList');
- this.$header = $el.find('#filelist-header');
- this.$footer = $el.find('#filelist-footer');
+ this.$fileList = $el.find('.files-fileList');
+ this.$header = $el.find('.filelist-header');
+ this.$footer = $el.find('.filelist-footer');
if (!_.isUndefined(this._filesConfig)) {
this._filesConfig.on('change:showhidden', function() {
@@ -357,7 +358,7 @@
}
this.breadcrumb = new OCA.Files.BreadCrumb(breadcrumbOptions);
- var $controls = this.$el.find('#controls');
+ var $controls = this.$el.find('.files-controls');
if ($controls.length > 0) {
$controls.prepend(this.breadcrumb.$el);
this.$table.addClass('has-controls');
@@ -414,6 +415,10 @@
});
}
+ if (!_.isUndefined(options.dir)) {
+ this._setCurrentDir(options.dir || '/', false);
+ }
+
if(options.openFile) {
// Wait for some initialisation process to be over before triggering the default action.
_.defer(() => {
@@ -735,7 +740,7 @@
_onResize: function() {
var containerWidth = this.$el.width();
var actionsWidth = 0;
- $.each(this.$el.find('#controls .actions'), function(index, action) {
+ $.each(this.$el.find('.files-controls .actions'), function(index, action) {
actionsWidth += $(action).outerWidth();
});
@@ -748,19 +753,23 @@
* @returns {undefined}
*/
_onGridviewChange: function() {
- var show = this.$showGridView.is(':checked');
+ 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: show
+ show: isGridView,
});
}
this.$showGridView.next('#view-toggle')
.removeClass('icon-toggle-filelist icon-toggle-pictures')
- .addClass(show ? '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'),
+ )
- $('.list-container').toggleClass('view-grid', show);
- if (show) {
+ this.$table.toggleClass('view-grid', isGridView);
+ if (isGridView) {
// If switching into grid view from list view, too few files might be displayed
// Try rendering the next page
this._onScroll();
@@ -1685,7 +1694,7 @@
td.append(
'<input id="select-' + this.id + '-' + fileData.id +
- '" type="checkbox" class="selectCheckBox checkbox"/><label for="select-' + this.id + '-' + fileData.id + '">' +
+ '" type="checkbox" class="selectCheckBox checkbox" aria-describedby="innernametext_' + fileData.id + '" /><label for="select-' + this.id + '-' + fileData.id + '">' +
'<span class="hidden-visually">' + (fileData.type === 'dir' ?
t('files', 'Select directory "{dirName}"', {dirName: name}) :
t('files', 'Select file "{fileName}"', {fileName: name})) + '</span>' +
@@ -1735,8 +1744,9 @@
basename = name;
extension = false;
}
- var nameSpan=$('<span></span>').addClass('nametext');
- var innernameSpan = $('<span></span>').addClass('innernametext').text(basename);
+ var nameSpan=$('<span></span>').addClass('nametext')
+
+ var innernameSpan = $('<span></span>').addClass('innernametext').text(basename).prop('title', basename).prop('id', `innernametext_${fileData.id}`);
var conflictingItems = this.$fileList.find('tr[data-file="' + this._jqSelEscape(name) + '"]');
@@ -1783,8 +1793,11 @@
td.append(linkElem);
tr.append(td);
- var enabledThemes = window.OCA?.Theming?.enabledThemes || []
- var isDarkTheme = enabledThemes.join('').indexOf('dark') !== -1
+ const enabledThemes = window.OCA?.Theming?.enabledThemes || []
+ // Check enabled themes, if system default is selected check the browser
+ const isDarkTheme = (enabledThemes.length === 0 || enabledThemes[0] === 'default')
+ ? window.matchMedia('(prefers-color-scheme: dark)').matches
+ : enabledThemes.join('').indexOf('dark') !== -1
try {
var maxContrastHex = window.getComputedStyle(document.documentElement)
@@ -1894,6 +1907,7 @@
* @return new tr element (not appended to the table)
*/
add: function(fileData, options) {
+ var self = this;
var index;
var $tr;
var $rows;
@@ -1936,7 +1950,7 @@
$tr.addClass('appear transparent');
window.setTimeout(function() {
$tr.removeClass('transparent');
- $("#fileList tr").removeClass('mouseOver');
+ self.$fileList.find('tr').removeClass('mouseOver');
$tr.addClass('mouseOver');
});
}
@@ -2044,7 +2058,7 @@
* @return current directory
*/
getCurrentDirectory: function(){
- return this._currentDirectory || this.$el.find('#dir').val() || '/';
+ return this._currentDirectory || '/';
},
/**
* Returns the directory permissions
@@ -2126,9 +2140,6 @@
}
this._currentDirectory = targetDir;
- // legacy stuff
- this.$el.find('#dir').val(targetDir);
-
if (changeUrl !== false) {
var params = {
dir: targetDir,
@@ -2468,7 +2479,7 @@
* @param show true for enabling, false for disabling
*/
showActions: function(show){
- this.$el.find('.actions,#file_action_panel').toggleClass('hidden', !show);
+ this.$el.find('.actions').toggleClass('hidden', !show);
if (show){
// make sure to display according to permissions
var permissions = this.getDirectoryPermissions();
@@ -2476,7 +2487,7 @@
this.$el.find('.creatable').toggleClass('hidden', !isCreatable);
this.$el.find('.notCreatable').toggleClass('hidden', isCreatable);
// remove old style breadcrumbs (some apps might create them)
- this.$el.find('#controls .crumb').remove();
+ this.$el.find('.files-controls .crumb').remove();
// refresh breadcrumbs in case it was replaced by an app
this.breadcrumb.render();
}
@@ -2492,7 +2503,7 @@
*/
setViewerMode: function(show){
this.showActions(!show);
- this.$el.find('#filestable').toggleClass('hidden', show);
+ this.$el.find('.files-filestable').toggleClass('hidden', show);
this.$el.trigger(new $.Event('changeViewerMode', {viewerModeEnabled: show}));
},
/**
@@ -2633,7 +2644,10 @@
self.showFileBusyState($tr, false);
});
};
- return this.reportOperationProgress(fileNames, moveFileFunction, callback);
+ return this.reportOperationProgress(fileNames, moveFileFunction, callback).then(function() {
+ self.updateStorageStatistics();
+ self.updateStorageQuotas();
+ });
},
_reflect: function (promise){
@@ -2813,7 +2827,10 @@
}
});
};
- return this.reportOperationProgress(fileNames, copyFileFunction, callback);
+ return this.reportOperationProgress(fileNames, copyFileFunction, callback).then(function() {
+ self.updateStorageStatistics();
+ self.updateStorageQuotas();
+ });
},
/**
@@ -3294,11 +3311,11 @@
updateEmptyContent: function() {
var permissions = this.getDirectoryPermissions();
var isCreatable = (permissions & OC.PERMISSION_CREATE) !== 0;
- this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty);
- this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty);
- this.$el.find('#emptycontent .uploadmessage').toggleClass('hidden', !isCreatable || !this.isEmpty);
- this.$el.find('#filestable').toggleClass('hidden', this.isEmpty);
- this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty);
+ this.$el.find('.emptyfilelist.emptycontent').toggleClass('hidden', !this.isEmpty);
+ this.$el.find('.emptyfilelist.emptycontent').toggleClass('hidden', !this.isEmpty);
+ this.$el.find('.emptyfilelist.emptycontent .uploadmessage').toggleClass('hidden', !isCreatable || !this.isEmpty);
+ this.$el.find('.files-filestable').toggleClass('hidden', this.isEmpty);
+ this.$el.find('.files-filestable thead th').toggleClass('hidden', this.isEmpty);
},
/**
* Shows the loading mask.
@@ -3313,7 +3330,7 @@
}
this.$table.addClass('hidden');
- this.$el.find('#emptycontent').addClass('hidden');
+ this.$el.find('.emptyfilelist.emptycontent').addClass('hidden');
$mask = $('<div class="mask transparent icon-loading"></div>');
@@ -3398,8 +3415,8 @@
},
hideIrrelevantUIWhenNoFilesMatch:function() {
if (this._filter && this.fileSummary.summary.totalDirs + this.fileSummary.summary.totalFiles === 0) {
- this.$el.find('#filestable thead th').addClass('hidden');
- this.$el.find('#emptycontent').addClass('hidden');
+ this.$el.find('.files-filestable thead th').addClass('hidden');
+ this.$el.find('.emptyfilelist.emptycontent').addClass('hidden');
$('#searchresults').addClass('filter-empty');
$('#searchresults .emptycontent').addClass('emptycontent-search');
if ( $('#searchresults').length === 0 || $('#searchresults').hasClass('hidden') ) {
@@ -3415,9 +3432,9 @@
} else {
$('#searchresults').removeClass('filter-empty');
$('#searchresults .emptycontent').removeClass('emptycontent-search');
- this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty);
+ this.$el.find('.files-filestable thead th').toggleClass('hidden', this.isEmpty);
if (!this.$el.find('.mask').exists()) {
- this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty);
+ this.$el.find('.emptyfilelist.emptycontent').toggleClass('hidden', !this.isEmpty);
}
this.$el.find('.nofilterresults').addClass('hidden');
}
@@ -3439,15 +3456,15 @@
var showHidden = !!this._filesConfig.get('showhidden');
if (summary.totalFiles === 0 && summary.totalDirs === 0) {
- this.$el.find('#headerName a.name>span:first').text(t('files','Name'));
- this.$el.find('#headerSize a>span:first').text(t('files','Size'));
- this.$el.find('#modified a>span:first').text(t('files','Modified'));
+ this.$el.find('.column-name a.name>span:first').text(t('files','Name'));
+ this.$el.find('.column-size a>span:first').text(t('files','Size'));
+ this.$el.find('.column-mtime a>span:first').text(t('files','Modified'));
this.$el.find('table').removeClass('multiselect');
this.$el.find('.selectedActions').addClass('hidden');
}
else {
this.$el.find('.selectedActions').removeClass('hidden');
- this.$el.find('#headerSize a>span:first').text(OC.Util.humanFileSize(summary.totalSize));
+ this.$el.find('.column-size a>span:first').text(OC.Util.humanFileSize(summary.totalSize));
var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs);
var fileInfo = n('files', '%n file', '%n files', summary.totalFiles);
@@ -3469,8 +3486,8 @@
selection += ' (' + hiddenInfo + ')';
}
- this.$el.find('#headerName a.name>span:first').text(selection);
- this.$el.find('#modified a>span:first').text('');
+ this.$el.find('.column-name a.name>span:first').text(selection);
+ this.$el.find('.column-mtime a>span:first').text('');
this.$el.find('table').addClass('multiselect');
if (this.fileMultiSelectMenu) {
@@ -3579,7 +3596,7 @@
* Shows a "permission denied" notification
*/
_showPermissionDeniedNotification: function() {
- var message = t('files', 'You don’t have permission to upload or create files here');
+ var message = t('files', 'You do not have permission to upload or create files here');
OC.Notification.show(message, {type: 'error'});
},
@@ -3782,7 +3799,7 @@
}
var currentOffset = this.$container.scrollTop();
- var additionalOffset = this.$el.find("#controls").height()+this.$el.find("#controls").offset().top;
+ var additionalOffset = this.$el.find(".files-controls").height()+this.$el.find(".files-controls").offset().top;
// Animation
var _this = this;
@@ -3825,13 +3842,13 @@
_renderNewButton: function() {
// if an upload button (legacy) already exists or no actions container exist, skip
- var $actionsContainer = this.$el.find('#controls .actions');
+ var $actionsContainer = this.$el.find('.files-controls .actions');
if (!$actionsContainer.length || this.$el.find('.button.upload').length) {
return;
}
var $newButton = $(OCA.Files.Templates['template_addbutton']({
- addText: t('files', 'New'),
- iconClass: 'icon-add'
+ addText: t('files', 'New file/folder menu'),
+ iconClass: 'icon-add',
}));
$actionsContainer.prepend($newButton);
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index ae247584682..1aa39eab523 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -25,7 +25,9 @@
state.call.abort();
}
state.dir = currentDir;
- state.call = $.getJSON(OC.filePath('files','ajax','getstoragestats.php') + '?dir=' + encodeURIComponent(currentDir),function(response) {
+ state.call = $.getJSON(OC.generateUrl('apps/files/ajax/getstoragestats?dir={dir}', {
+ dir: currentDir,
+ }), function(response) {
state.dir = null;
state.call = null;
Files.updateMaxUploadFilesize(response);
@@ -37,7 +39,7 @@
},
_updateStorageQuotas: function() {
var state = Files.updateStorageQuotas;
- state.call = $.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) {
+ state.call = $.getJSON(OC.generateUrl('apps/files/ajax/getstoragestats'), function(response) {
Files.updateQuota(response);
});
},
@@ -103,9 +105,9 @@
if (response.data.quota > 0) {
$('#quota').attr('data-original-title', Math.floor(response.data.used/response.data.quota*1000)/10 + '%');
$('#quota progress').val(response.data.usedSpacePercent);
- $('#quotatext').text(t('files', '{used} of {quota} used', {used: humanUsed, quota: humanQuota}));
+ $('#quotatext').html(t('files', '{used} of {quota} used', {used: humanUsed, quota: humanQuota}));
} else {
- $('#quotatext').text(t('files', '{used} used', {used: humanUsed}));
+ $('#quotatext').html(t('files', '{used} used', {used: humanUsed}));
}
if (response.data.usedSpacePercent > 80) {
$('#quota progress').addClass('warn');
@@ -304,9 +306,6 @@
initialize: function() {
Files.bindKeyboardShortcuts(document, $);
- // TODO: move file list related code (upload) to OCA.Files.FileList
- $('#file_action_panel').attr('activeAction', false);
-
// drag&drop support using jquery.fileupload
// TODO use OC.dialogs
$(document).bind('drop dragover', function (e) {
diff --git a/apps/files/js/keyboardshortcuts.js b/apps/files/js/keyboardshortcuts.js
index b2f2cd0e582..0e716fc6d37 100644
--- a/apps/files/js/keyboardshortcuts.js
+++ b/apps/files/js/keyboardshortcuts.js
@@ -57,21 +57,21 @@
}
function esc() {
- $("#controls").trigger('click');
+ $(".files-controls").trigger('click');
}
function down() {
var select = -1;
- $("#fileList tr").each(function(index) {
+ $(".files-fileList tr").each(function(index) {
if ($(this).hasClass("mouseOver")) {
select = index + 1;
$(this).removeClass("mouseOver");
}
});
if (select === -1) {
- $("#fileList tr:first").addClass("mouseOver");
+ $(".files-fileList tr:first").addClass("mouseOver");
} else {
- $("#fileList tr").each(function(index) {
+ $(".files-fileList tr").each(function(index) {
if (index === select) {
$(this).addClass("mouseOver");
}
@@ -81,16 +81,16 @@
function up() {
var select = -1;
- $("#fileList tr").each(function(index) {
+ $(".files-fileList tr").each(function(index) {
if ($(this).hasClass("mouseOver")) {
select = index - 1;
$(this).removeClass("mouseOver");
}
});
if (select === -1) {
- $("#fileList tr:last").addClass("mouseOver");
+ $(".files-fileList tr:last").addClass("mouseOver");
} else {
- $("#fileList tr").each(function(index) {
+ $(".files-fileList tr").each(function(index) {
if (index === select) {
$(this).addClass("mouseOver");
}
@@ -99,7 +99,7 @@
}
function enter() {
- $("#fileList tr").each(function(index) {
+ $(".files-fileList tr").each(function(index) {
if ($(this).hasClass("mouseOver")) {
$(this).removeClass("mouseOver");
$(this).find("span.nametext").trigger('click');
@@ -108,7 +108,7 @@
}
function del() {
- $("#fileList tr").each(function(index) {
+ $(".files-fileList tr").each(function(index) {
if ($(this).hasClass("mouseOver")) {
$(this).removeClass("mouseOver");
$(this).find("a.action.delete").trigger('click');
@@ -117,7 +117,7 @@
}
function rename() {
- $("#fileList tr").each(function(index) {
+ $(".files-fileList tr").each(function(index) {
if ($(this).hasClass("mouseOver")) {
$(this).removeClass("mouseOver");
$(this).find("a[data-action='Rename']").trigger('click');
diff --git a/apps/files/js/recentfilelist.js b/apps/files/js/recentfilelist.js
index 78eaa0b6858..3b7cd035f2a 100644
--- a/apps/files/js/recentfilelist.js
+++ b/apps/files/js/recentfilelist.js
@@ -18,7 +18,7 @@ window.addEventListener('DOMContentLoaded', function () {
* @classdesc Recent file list.
* Displays the list of recently modified files
*
- * @param $el container element with existing markup for the #controls
+ * @param $el container element with existing markup for the .files-controls
* and a table
* @param [options] map of options, see other parameters
*/
@@ -53,8 +53,8 @@ window.addEventListener('DOMContentLoaded', function () {
var dir = this.getCurrentDirectory();
if (dir === '/') {
// root has special permissions
- this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty);
- this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty);
+ this.$el.find('.emptyfilelist.emptycontent').toggleClass('hidden', !this.isEmpty);
+ this.$el.find('.files-filestable thead th').toggleClass('hidden', this.isEmpty);
}
else {
OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments);