diff options
author | Olivier Paroz <github@oparoz.com> | 2015-09-13 14:12:27 +0300 |
---|---|---|
committer | Olivier Paroz <github@oparoz.com> | 2015-09-13 14:12:27 +0300 |
commit | 98acf0015aae13dc2aa92bb3c53ab39f901ad03a (patch) | |
tree | 087d56c4fe67979d1ca180ee42009cf4854baa99 /js | |
parent | b7e8df7bf20caddf7bd53154bfc078d6edfc796a (diff) |
[8.2] Stop sending the path to the media type icons
Thanks @rullzer for the new OC.Mimetype!
Diffstat (limited to 'js')
-rw-r--r-- | js/galleryconfig.js | 19 | ||||
-rw-r--r-- | js/galleryfileaction.js | 11 | ||||
-rw-r--r-- | js/thumbnail.js | 7 |
3 files changed, 16 insertions, 21 deletions
diff --git a/js/galleryconfig.js b/js/galleryconfig.js index b0b8a430..002d1f16 100644 --- a/js/galleryconfig.js +++ b/js/galleryconfig.js @@ -96,15 +96,16 @@ _setMediaTypes: function (mediaTypes) { var supportedMediaTypes = []; var mediaType = null; - var mediaTypesString = ''; - for (var i = 0, keys = Object.keys(mediaTypes); i < keys.length; i++) { - mediaType = keys[i]; - if (this._validateMediaType(mediaType)) { - mediaTypesString += mediaType + ';'; - supportedMediaTypes[mediaType] = mediaTypes[mediaType]; + var i, mediaTypesLength = mediaTypes.length; + if (mediaTypesLength) { + for (i = 0; i < mediaTypesLength; i++) { + mediaType = mediaTypes[i]; + if (this._validateMediaType(mediaType)) { + supportedMediaTypes.push(mediaType); + } } } - this.cachedMediaTypesString = mediaTypesString.slice(0, -1); + this.cachedMediaTypesString = supportedMediaTypes.join(';'); return supportedMediaTypes; }, @@ -114,7 +115,7 @@ * * @param {string} feature * - * @returns {bool} + * @returns {boolean} * @private */ _validateFeature: function (feature) { @@ -131,7 +132,7 @@ * * @param {string} mediaType * - * @returns {bool} + * @returns {boolean} * @private */ _validateMediaType: function (mediaType) { diff --git a/js/galleryfileaction.js b/js/galleryfileaction.js index 1952198c..88a4a7cd 100644 --- a/js/galleryfileaction.js +++ b/js/galleryfileaction.js @@ -39,15 +39,14 @@ if (mediaTypes) { galleryFileAction.mediaTypes = mediaTypes; } - + var i, mediaTypesLength = mediaTypes.length; // We only want to create slideshows for supported media types - for (var i = 0, keys = Object.keys(galleryFileAction.mediaTypes); i < - keys.length; i++) { + for (i = 0; i < mediaTypesLength; i++) { // Each click handler gets the same function and images array and // is responsible to load the slideshow - OCA.Files.fileActions.register(keys[i], 'View', OC.PERMISSION_READ, '', + OCA.Files.fileActions.register(mediaTypes[i], 'View', OC.PERMISSION_READ, '', galleryFileAction.onView); - OCA.Files.fileActions.setDefault(keys[i], 'View'); + OCA.Files.fileActions.setDefault(mediaTypes[i], 'View'); } }, @@ -98,7 +97,7 @@ var file = files[i]; // We only add images to the slideshow if we think we'll be able // to generate previews for this media type - if (galleryFileAction.mediaTypes[file.mimetype]) { + if (galleryFileAction.mediaTypes.indexOf(file.mimetype) > -1) { /* jshint camelcase: false */ var params = { width: longEdge, diff --git a/js/thumbnail.js b/js/thumbnail.js index 2960489d..ccd748f5 100644 --- a/js/thumbnail.js +++ b/js/thumbnail.js @@ -140,12 +140,7 @@ function Thumbnail (fileId, square) { 'data:' + preview.mimetype + ';base64,' + preview.preview; } else { thumb.valid = false; - - // In 8.2, use this directly - //OC.MimeType.getIconUrl(preview.mimetype); - var icon = OC.Util.replaceSVGIcon( - Gallery.config.mediaTypes[preview.mimetype]); - thumb.image.src = icon; + thumb.image.src = OC.MimeType.getIconUrl(preview.mimetype); } } }); |