Browse Source

Merge pull request #8129 from owncloud/core-svgsupport

Moved SVGSupport call to use OC.Util.SVGSupport()
tags/v7.0.0alpha2
Thomas Tanghus 10 years ago
parent
commit
5b8c7a01e9
2 changed files with 6 additions and 6 deletions
  1. 3
    3
      core/js/js.js
  2. 3
    3
      core/js/tests/specs/coreSpec.js

+ 3
- 3
core/js/js.js View File

*/ */
imagePath:function(app,file){ imagePath:function(app,file){
if(file.indexOf('.')==-1){//if no extension is given, use png or svg depending on browser support if(file.indexOf('.')==-1){//if no extension is given, use png or svg depending on browser support
file+=(SVGSupport())?'.svg':'.png';
file+=(OC.Util.hasSVGSupport())?'.svg':'.png';
} }
return OC.filePath(app,'img',file); return OC.filePath(app,'img',file);
}, },
throw e; throw e;
}); });
} }
if(!SVGSupport()) {
if(!OC.Util.hasSVGSupport()) {
OC.Util.replaceSVG(); OC.Util.replaceSVG();
} }
}).show(); }).show();
initSessionHeartBeat(); initSessionHeartBeat();
} }


if(!SVGSupport()){ //replace all svg images with png images for browser that dont support svg
if(!OC.Util.hasSVGSupport()){ //replace all svg images with png images for browser that dont support svg
OC.Util.replaceSVG(); OC.Util.replaceSVG();
}else{ }else{
SVGSupport.checkMimeType(); SVGSupport.checkMimeType();

+ 3
- 3
core/js/tests/specs/coreSpec.js View File

}); });
describe('Images', function() { describe('Images', function() {
it('Generates image path with given extension', function() { it('Generates image path with given extension', function() {
var svgSupportStub = sinon.stub(window, 'SVGSupport', function() { return true; });
var svgSupportStub = sinon.stub(OC.Util, 'hasSVGSupport', function() { return true; });
expect(OC.imagePath('core', 'somefile.jpg')).toEqual(OC.webroot + '/core/img/somefile.jpg'); expect(OC.imagePath('core', 'somefile.jpg')).toEqual(OC.webroot + '/core/img/somefile.jpg');
expect(OC.imagePath(TESTAPP, 'somefile.jpg')).toEqual(TESTAPP_ROOT + '/img/somefile.jpg'); expect(OC.imagePath(TESTAPP, 'somefile.jpg')).toEqual(TESTAPP_ROOT + '/img/somefile.jpg');
svgSupportStub.restore(); svgSupportStub.restore();
}); });
it('Generates image path with svg extension when svg support exists', function() { it('Generates image path with svg extension when svg support exists', function() {
var svgSupportStub = sinon.stub(window, 'SVGSupport', function() { return true; });
var svgSupportStub = sinon.stub(OC.Util, 'hasSVGSupport', function() { return true; });
expect(OC.imagePath('core', 'somefile')).toEqual(OC.webroot + '/core/img/somefile.svg'); expect(OC.imagePath('core', 'somefile')).toEqual(OC.webroot + '/core/img/somefile.svg');
expect(OC.imagePath(TESTAPP, 'somefile')).toEqual(TESTAPP_ROOT + '/img/somefile.svg'); expect(OC.imagePath(TESTAPP, 'somefile')).toEqual(TESTAPP_ROOT + '/img/somefile.svg');
svgSupportStub.restore(); svgSupportStub.restore();
}); });
it('Generates image path with png ext when svg support is not available', function() { it('Generates image path with png ext when svg support is not available', function() {
var svgSupportStub = sinon.stub(window, 'SVGSupport', function() { return false; });
var svgSupportStub = sinon.stub(OC.Util, 'hasSVGSupport', function() { return false; });
expect(OC.imagePath('core', 'somefile')).toEqual(OC.webroot + '/core/img/somefile.png'); expect(OC.imagePath('core', 'somefile')).toEqual(OC.webroot + '/core/img/somefile.png');
expect(OC.imagePath(TESTAPP, 'somefile')).toEqual(TESTAPP_ROOT + '/img/somefile.png'); expect(OC.imagePath(TESTAPP, 'somefile')).toEqual(TESTAPP_ROOT + '/img/somefile.png');
svgSupportStub.restore(); svgSupportStub.restore();

Loading…
Cancel
Save