aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/favoritesfilelist.js9
-rw-r--r--apps/files/js/file-upload.js44
-rw-r--r--apps/files/js/fileactions.js2
-rw-r--r--apps/files/js/filelist.js36
-rw-r--r--apps/files/js/files.js7
-rw-r--r--apps/files/js/mainfileinfodetailview.js4
-rw-r--r--apps/files/js/newfilemenu.js77
7 files changed, 120 insertions, 59 deletions
diff --git a/apps/files/js/favoritesfilelist.js b/apps/files/js/favoritesfilelist.js
index 4e7db9f17ba..e6532ab188c 100644
--- a/apps/files/js/favoritesfilelist.js
+++ b/apps/files/js/favoritesfilelist.js
@@ -71,6 +71,10 @@ $(document).ready(function() {
if (this._reloadCall) {
this._reloadCall.abort();
}
+
+ // there is only root
+ this._setCurrentDir('/', false);
+
this._reloadCall = $.ajax({
url: OC.generateUrl('/apps/files/api/v1/tags/{tagName}/files', {tagName: tagName}),
type: 'GET',
@@ -86,10 +90,9 @@ $(document).ready(function() {
if (result.files) {
this.setFiles(result.files.sort(this._sortComparator));
+ return true;
}
- else {
- // TODO: error handling
- }
+ return false;
}
});
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 77b85ecd7da..d419cb3a2c0 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -18,7 +18,7 @@
* - TODO music upload button
*/
-/* global jQuery, oc_requesttoken, humanFileSize */
+/* global jQuery, oc_requesttoken, humanFileSize, FileList */
/**
* Function that will allow us to know if Ajax uploads are supported
@@ -48,6 +48,26 @@ function supportAjaxUploadWithProgress() {
}
/**
+ * Add form data into the given form data
+ *
+ * @param {Array|Object} formData form data which can either be an array or an object
+ * @param {Object} newData key-values to add to the form data
+ *
+ * @return updated form data
+ */
+function addFormData(formData, newData) {
+ // in IE8, formData is an array instead of object
+ if (_.isArray(formData)) {
+ _.each(newData, function(value, key) {
+ formData.push({name: key, value: value});
+ });
+ } else {
+ formData = _.extend(formData, newData);
+ }
+ return formData;
+}
+
+/**
* keeps track of uploads in progress and implements callbacks for the conflicts dialog
* @namespace
*/
@@ -143,9 +163,9 @@ OC.Upload = {
data.data.append('resolution', 'replace');
} else {
if (!data.formData) {
- data.formData = [];
+ data.formData = {};
}
- data.formData.push({name:'resolution', value:'replace'}); //hack for ie8
+ addFormData(data.formData, {resolution: 'replace'});
}
data.submit();
},
@@ -159,9 +179,9 @@ OC.Upload = {
data.data.append('resolution', 'autorename');
} else {
if (!data.formData) {
- data.formData = [];
+ data.formData = {};
}
- data.formData.push({name:'resolution', value:'autorename'}); //hack for ie8
+ addFormData(data.formData, {resolution: 'autorename'});
}
data.submit();
},
@@ -185,7 +205,7 @@ OC.Upload = {
* @param {function} callbacks.onCancel
*/
checkExistingFiles: function (selection, callbacks) {
- var fileList = OCA.Files.App.fileList;
+ var fileList = FileList;
var conflicts = [];
// only keep non-conflicting uploads
selection.uploads = _.filter(selection.uploads, function(upload) {
@@ -402,17 +422,19 @@ OC.Upload = {
submit: function(e, data) {
OC.Upload.rememberUpload(data);
if (!data.formData) {
- data.formData = [];
+ data.formData = {};
}
var fileDirectory = '';
if(typeof data.files[0].relativePath !== 'undefined') {
fileDirectory = data.files[0].relativePath;
}
- // FIXME: prevent re-adding the same
- data.formData.push({name: 'requesttoken', value: oc_requesttoken});
- data.formData.push({name: 'dir', value: data.targetDir || FileList.getCurrentDirectory()});
- data.formData.push({name: 'file_directory', value: fileDirectory});
+
+ addFormData(data.formData, {
+ requesttoken: oc_requesttoken,
+ dir: data.targetDir || FileList.getCurrentDirectory(),
+ file_directory: fileDirectory
+ });
},
fail: function(e, data) {
OC.Upload.log('fail', e, data);
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 079c5330ec2..6a767d48a28 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -589,7 +589,7 @@
context.fileList.showFileBusyState(filename, false);
};
- context.fileList.showFileBusyState(downloadFileaction, true);
+ context.fileList.showFileBusyState(filename, true);
OCA.Files.Files.handleDownload(url, disableLoadingState);
}
}
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 4f5fdf242d9..d1f68d98eab 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -390,12 +390,15 @@
* Update the details view to display the given file
*
* @param {string} fileName file name from the current list
+ * @param {boolean} [show=true] whether to open the sidebar if it was closed
*/
- _updateDetailsView: function(fileName) {
+ _updateDetailsView: function(fileName, show) {
if (!this._detailsView) {
return;
}
+ // show defaults to true
+ show = _.isUndefined(show) || !!show;
var oldFileInfo = this._detailsView.getFileInfo();
if (oldFileInfo) {
// TODO: use more efficient way, maybe track the highlight
@@ -413,7 +416,7 @@
return;
}
- if (this._detailsView.$el.hasClass('disappear')) {
+ if (show && this._detailsView.$el.hasClass('disappear')) {
OC.Apps.showAppSidebar(this._detailsView.$el);
}
@@ -764,7 +767,7 @@
*/
elementToFile: function($el){
$el = $($el);
- return {
+ var data = {
id: parseInt($el.attr('data-id'), 10),
name: $el.attr('data-file'),
mimetype: $el.attr('data-mime'),
@@ -774,6 +777,15 @@
etag: $el.attr('data-etag'),
permissions: parseInt($el.attr('data-permissions'), 10)
};
+ var icon = $el.attr('data-icon');
+ if (icon) {
+ data.icon = icon;
+ }
+ var mountType = $el.attr('data-mounttype');
+ if (mountType) {
+ data.mountType = mountType;
+ }
+ return data;
},
/**
@@ -896,11 +908,12 @@
mtime = parseInt(fileData.mtime, 10),
mime = fileData.mimetype,
path = fileData.path,
+ dataIcon = null,
linkUrl;
options = options || {};
if (isNaN(mtime)) {
- mtime = new Date().getTime()
+ mtime = new Date().getTime();
}
if (type === 'dir') {
@@ -908,6 +921,7 @@
if (fileData.mountType && fileData.mountType.indexOf('external') === 0) {
icon = OC.MimeType.getIconUrl('dir-external');
+ dataIcon = icon;
}
}
@@ -923,6 +937,11 @@
"data-permissions": fileData.permissions || this.getDirectoryPermissions()
});
+ if (dataIcon) {
+ // icon override
+ tr.attr('data-icon', dataIcon);
+ }
+
if (fileData.mountType) {
tr.attr('data-mounttype', fileData.mountType);
}
@@ -1174,7 +1193,7 @@
// display actions
this.fileActions.display(filenameTd, !options.silent, this);
- if (fileData.isPreviewAvailable) {
+ if (fileData.isPreviewAvailable && mime !== 'httpd/unix-directory') {
var iconDiv = filenameTd.find('.thumbnail');
// lazy load / newly inserted td ?
// the typeof check ensures that the default value of animate is true
@@ -1771,7 +1790,7 @@
tr.remove();
tr = self.add(fileInfo, {updateSummary: false, silent: true});
self.$fileList.trigger($.Event('fileActionsReady', {fileList: self, $files: $(tr)}));
- self._updateDetailsView(fileInfo.name);
+ self._updateDetailsView(fileInfo.name, false);
}
});
} else {
@@ -2114,15 +2133,16 @@
this.hideIrrelevantUIWhenNoFilesMatch();
}
var that = this;
+ filter = filter.toLowerCase();
this.$fileList.find('tr').each(function(i,e) {
var $e = $(e);
- if ($e.data('file').toString().toLowerCase().indexOf(filter.toLowerCase()) === -1) {
+ if ($e.data('file').toString().toLowerCase().indexOf(filter) === -1) {
$e.addClass('hidden');
- that.$container.trigger('scroll');
} else {
$e.removeClass('hidden');
}
});
+ that.$container.trigger('scroll');
},
hideIrrelevantUIWhenNoFilesMatch:function() {
if (this._filter && this.fileSummary.summary.totalDirs + this.fileSummary.summary.totalFiles === 0) {
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 9ab7609cc40..ae38511ec05 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -295,7 +295,12 @@
}
};
- OC.redirect(url + '&downloadStartSecret=' + randomToken);
+ if (url.indexOf('?') >= 0) {
+ url += '&';
+ } else {
+ url += '?';
+ }
+ OC.redirect(url + 'downloadStartSecret=' + randomToken);
OC.Util.waitFor(checkForDownloadCookie, 500);
}
};
diff --git a/apps/files/js/mainfileinfodetailview.js b/apps/files/js/mainfileinfodetailview.js
index abf7da52ff4..69c796e492f 100644
--- a/apps/files/js/mainfileinfodetailview.js
+++ b/apps/files/js/mainfileinfodetailview.js
@@ -128,8 +128,8 @@
$iconDiv.addClass('icon-loading icon-32');
this.loadPreview(this.model.getFullPath(), this.model.get('mimetype'), this.model.get('etag'), $iconDiv, $container, this.model.isImage());
} else {
- // TODO: special icons / shared / external
- $iconDiv.css('background-image', 'url("' + OC.MimeType.getIconUrl('dir') + '")');
+ var iconUrl = this.model.get('icon') || OC.MimeType.getIconUrl('dir');
+ $iconDiv.css('background-image', 'url("' + iconUrl + '")');
OC.Util.scaleFixForIE8($iconDiv);
}
this.$el.find('[title]').tooltip({placement: 'bottom'});
diff --git a/apps/files/js/newfilemenu.js b/apps/files/js/newfilemenu.js
index 0a67aba202b..be7dcc40b6e 100644
--- a/apps/files/js/newfilemenu.js
+++ b/apps/files/js/newfilemenu.js
@@ -44,6 +44,11 @@
'click .menuitem': '_onClickAction'
},
+ /**
+ * @type OCA.Files.FileList
+ */
+ fileList: null,
+
initialize: function(options) {
var self = this;
var $uploadEl = $('#file_upload_start');
@@ -55,7 +60,20 @@
console.warn('Missing upload element "file_upload_start"');
}
- this._fileList = options && options.fileList;
+ this.fileList = options && options.fileList;
+
+ this._menuItems = [{
+ id: 'folder',
+ displayName: t('files', 'Folder'),
+ templateName: t('files', 'New folder'),
+ iconClass: 'icon-folder',
+ fileType: 'folder',
+ actionHandler: function(name) {
+ self.fileList.createDirectory(name);
+ }
+ }];
+
+ OC.Plugins.attach('OCA.Files.NewFileMenu', this);
},
template: function(data) {
@@ -127,7 +145,7 @@
try {
if (!Files.isFileNameValid(filename)) {
// Files.isFileNameValid(filename) throws an exception itself
- } else if (self._fileList.inList(filename)) {
+ } else if (self.fileList.inList(filename)) {
throw t('files', '{newname} already exists', {newname: filename});
} else {
return true;
@@ -163,7 +181,14 @@
if (checkInput()) {
var newname = $input.val();
- self._createFile(fileType, newname);
+
+ /* Find the right actionHandler that should be called.
+ * Actions is retrieved by using `actionSpec.id` */
+ action = _.filter(self._menuItems, function(item) {
+ return item.id == $target.attr('data-action');
+ }).pop();
+ action.actionHandler(newname);
+
$form.remove();
$target.find('.displayname').removeClass('hidden');
OC.hideMenus();
@@ -172,23 +197,21 @@
},
/**
- * Creates a file with the given type and name.
- * This calls the matching methods on the attached file list.
- *
- * @param {string} fileType file type
- * @param {string} name file name
- */
- _createFile: function(fileType, name) {
- switch(fileType) {
- case 'file':
- this._fileList.createFile(name);
- break;
- case 'folder':
- this._fileList.createDirectory(name);
- break;
- default:
- console.warn('Unknown file type "' + fileType + '"');
- }
+ * Add a new item menu entry in the “New” file menu (in
+ * last position). By clicking on the item, the
+ * `actionHandler` function is called.
+ *
+ * @param {Object} actionSpec item’s properties
+ */
+ addMenuEntry: function(actionSpec) {
+ this._menuItems.push({
+ id: actionSpec.id,
+ displayName: actionSpec.displayName,
+ templateName: actionSpec.templateName,
+ iconClass: actionSpec.iconClass,
+ fileType: actionSpec.fileType,
+ actionHandler: actionSpec.actionHandler,
+ });
},
/**
@@ -198,19 +221,7 @@
this.$el.html(this.template({
uploadMaxHumanFileSize: 'TODO',
uploadLabel: t('files', 'Upload'),
- items: [{
- id: 'file',
- displayName: t('files', 'Text file'),
- templateName: t('files', 'New text file.txt'),
- iconClass: 'icon-filetype-text',
- fileType: 'file'
- }, {
- id: 'folder',
- displayName: t('files', 'Folder'),
- templateName: t('files', 'New folder'),
- iconClass: 'icon-folder',
- fileType: 'folder'
- }]
+ items: this._menuItems
}));
OC.Util.scaleFixForIE8(this.$('.svg'));
},