aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/files.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r--apps/files/js/files.js50
1 files changed, 35 insertions, 15 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 44868e78bd0..19cc3b26e44 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -61,7 +61,7 @@
if (response.data !== undefined && response.data.uploadMaxFilesize !== undefined) {
$('#max_upload').val(response.data.uploadMaxFilesize);
$('#free_space').val(response.data.freeSpace);
- $('#upload.button').attr('original-title', response.data.maxHumanFilesize);
+ $('#upload.button').attr('data-original-title', response.data.maxHumanFilesize);
$('#usedSpacePercent').val(response.data.usedSpacePercent);
$('#owner').val(response.data.owner);
$('#ownerDisplayName').val(response.data.ownerDisplayName);
@@ -72,7 +72,7 @@
}
if (response[0].uploadMaxFilesize !== undefined) {
$('#max_upload').val(response[0].uploadMaxFilesize);
- $('#upload.button').attr('original-title', response[0].maxHumanFilesize);
+ $('#upload.button').attr('data-original-title', response[0].maxHumanFilesize);
$('#usedSpacePercent').val(response[0].usedSpacePercent);
Files.displayStorageWarnings();
}
@@ -163,18 +163,14 @@
return OC.filePath('files', 'ajax', action + '.php') + q;
},
+ /**
+ * Fetch the icon url for the mimetype
+ * @param {string} mime The mimetype
+ * @param {Files~mimeicon} ready Function to call when mimetype is retrieved
+ * @deprecated use OC.MimeType.getIconUrl(mime)
+ */
getMimeIcon: function(mime, ready) {
- if (Files.getMimeIcon.cache[mime]) {
- ready(Files.getMimeIcon.cache[mime]);
- } else {
- $.get( OC.filePath('files','ajax','mimeicon.php'), {mime: mime}, function(path) {
- if(OC.Util.hasSVGSupport()){
- path = path.substr(0, path.length-4) + '.svg';
- }
- Files.getMimeIcon.cache[mime]=path;
- ready(Files.getMimeIcon.cache[mime]);
- });
- }
+ ready(OC.MimeType.getIconUrl(mime));
},
/**
@@ -211,7 +207,6 @@
* Initialize the files view
*/
initialize: function() {
- Files.getMimeIcon.cache = {};
Files.bindKeyboardShortcuts(document, $);
// TODO: move file list related code (upload) to OCA.Files.FileList
@@ -276,8 +271,33 @@
FileList.scrollTo(getURLParameter('scrollto'));
}
*/
+ },
+
+ /**
+ * Handles the download and calls the callback function once the download has started
+ * - browser sends download request and adds parameter with a token
+ * - server notices this token and adds a set cookie to the download response
+ * - browser now adds this cookie for the domain
+ * - JS periodically checks for this cookie and then knows when the download has started to call the callback
+ *
+ * @param {string} url download URL
+ * @param {function} callback function to call once the download has started
+ */
+ handleDownload: function(url, callback) {
+ var randomToken = Math.random().toString(36).substring(2),
+ checkForDownloadCookie = function() {
+ if (!OC.Util.isCookieSetToValue('ocDownloadStarted', randomToken)){
+ return false;
+ } else {
+ callback();
+ return true;
+ }
+ };
+
+ OC.redirect(url + '&downloadStartSecret=' + randomToken);
+ OC.Util.waitFor(checkForDownloadCookie, 500);
}
- }
+ };
Files._updateStorageStatisticsDebounced = _.debounce(Files._updateStorageStatistics, 250);
OCA.Files.Files = Files;