diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-04-04 11:32:07 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-04-04 11:34:26 +0200 |
commit | a4eafca77f86ab2630bec698c3302c93daddb991 (patch) | |
tree | d19954cea3761efe945e1cee0816c69fc555e94b /apps | |
parent | 8a10c44eb33d45e2deba7d72b30e509fa332fb24 (diff) | |
download | nextcloud-server-a4eafca77f86ab2630bec698c3302c93daddb991.tar.gz nextcloud-server-a4eafca77f86ab2630bec698c3302c93daddb991.zip |
Moved code to replace svg with png to OC.Util
- Moved code that replaces the "svg" extension for the given file to
core as OC.Util.replaceSVGIcon.
- Added unit test for OC.Util.replaceSVGIcon
- Moved "replaceSVG" to OC.Util.replaceSVG and deprecated the global
"replaceSVG" function.
- Added alias for SVGSupport() as OC.Util.hasSVGSupport() (for now)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/js/breadcrumb.js | 5 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 26 | ||||
-rw-r--r-- | apps/files/js/files.js | 2 |
3 files changed, 10 insertions, 23 deletions
diff --git a/apps/files/js/breadcrumb.js b/apps/files/js/breadcrumb.js index ff017a22bb5..5bc2fac1369 100644 --- a/apps/files/js/breadcrumb.js +++ b/apps/files/js/breadcrumb.js @@ -20,7 +20,6 @@ */ /* global OC */ -/* global SVGSupport, replaceSVG */ (function() { /** * Creates an breadcrumb element in the given container @@ -104,8 +103,8 @@ $crumb.addClass('last'); // in case svg is not supported by the browser we need to execute the fallback mechanism - if (!SVGSupport()) { - replaceSVG(); + if (!OC.Util.hasSVGSupport()) { + OC.Util.replaceSVG(this.$el); } // setup drag and drop diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 509929d0e55..506741eb6ea 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -9,7 +9,7 @@ */ /* global OC, t, n, FileList, FileActions, Files, BreadCrumb */ -/* global procesSelection, dragOptions, SVGSupport */ +/* global procesSelection, dragOptions */ window.FileList = { appName: t('files', 'Files'), isEmpty: true, @@ -160,22 +160,6 @@ window.FileList = { this.$fileList.trigger(jQuery.Event("updated")); }, /** - * If SVG is not supported, replaces the given images's extension - * from ".svg" to ".png". - * If SVG is supported, return the image path as is. - * @param icon image path - * @return fixed image path - */ - _replaceSVG: function(icon) { - if (!SVGSupport()) { - var i = icon.lastIndexOf('.svg'); - if (i >= 0) { - icon = icon.substr(0, i) + '.png' + icon.substr(i+4); - } - } - return icon; - }, - /** * Creates a new table row element using the given file data. * @param fileData map of file attributes * @param options map of attribute "loading" whether the entry is currently loading @@ -183,7 +167,7 @@ window.FileList = { */ _createRow: function(fileData, options) { var td, simpleSize, basename, extension, sizeColor, - icon = FileList._replaceSVG(fileData.icon), + icon = OC.Util.replaceSVGIcon(fileData.icon), name = fileData.name, type = fileData.type || 'file', mtime = parseInt(fileData.mtime, 10) || new Date().getTime(), @@ -659,7 +643,11 @@ window.FileList = { }, null, null, result.data.etag); } else { - tr.find('td.filename').removeClass('preview').attr('style','background-image:url('+FileList._replaceSVG(fileInfo.icon)+')'); + tr.find('td.filename') + .removeClass('preview') + .attr('style','background-image:url(' + + OC.Util.replaceSVGIcon(fileInfo.icon) + + ')'); } } // reinsert row diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 4c2d87d808c..668faf723c8 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -635,7 +635,7 @@ Files.getMimeIcon = function(mime, ready) { ready(Files.getMimeIcon.cache[mime]); } else { $.get( OC.filePath('files','ajax','mimeicon.php'), {mime: mime}, function(path) { - if(SVGSupport()){ + if(OC.Util.hasSVGSupport()){ path = path.substr(0, path.length-4) + '.svg'; } Files.getMimeIcon.cache[mime]=path; |