@ -498,7 +498,7 @@ var OC={
} ) ;
}
if ( ! SVGSupport ( ) ) {
replaceSVG ( ) ;
OC . Util . replaceSVG ( ) ;
}
} ) . show ( ) ;
} , 'html' ) ;
@ -785,7 +785,7 @@ SVGSupport.checkMimeType=function(){
}
} ) ;
if ( headers [ "content-type" ] !== 'image/svg+xml' ) {
replaceSVG ( ) ;
OC . Util . replaceSVG ( ) ;
SVGSupport . checkMimeType . correct = false ;
}
}
@ -793,35 +793,10 @@ SVGSupport.checkMimeType=function(){
} ;
SVGSupport . checkMimeType . correct = true ;
//replace all svg images with png for browser compatibility
function replaceSVG ( ) {
$ ( 'img.svg' ) . each ( function ( index , element ) {
element = $ ( element ) ;
var src = element . attr ( 'src' ) ;
element . attr ( 'src' , src . substr ( 0 , src . length - 3 ) + 'png' ) ;
} ) ;
$ ( '.svg' ) . each ( function ( index , element ) {
element = $ ( element ) ;
var background = element . css ( 'background-image' ) ;
if ( background ) {
var i = background . lastIndexOf ( '.svg' ) ;
if ( i >= 0 ) {
background = background . substr ( 0 , i ) + '.png' + background . substr ( i + 4 ) ;
element . css ( 'background-image' , background ) ;
}
}
element . find ( '*' ) . each ( function ( index , element ) {
element = $ ( element ) ;
var background = element . css ( 'background-image' ) ;
if ( background ) {
var i = background . lastIndexOf ( '.svg' ) ;
if ( i >= 0 ) {
background = background . substr ( 0 , i ) + '.png' + background . substr ( i + 4 ) ;
element . css ( 'background-image' , background ) ;
}
}
} ) ;
} ) ;
// replace all svg images with png for browser compatibility
// @deprecated use OC.Util.replaceSVG instead
function replaceSVG ( $el ) {
return OC . Util . replaceSVG ( $el ) ;
}
/ * *
@ -900,7 +875,7 @@ function initCore() {
}
if ( ! SVGSupport ( ) ) { //replace all svg images with png images for browser that dont support svg
replaceSVG ( ) ;
OC . Util . replaceSVG ( ) ;
} else {
SVGSupport . checkMimeType ( ) ;
}
@ -1134,6 +1109,72 @@ function relative_modified_date(timestamp) {
else { return t ( 'core' , 'years ago' ) ; }
}
OC . Util = {
/ * *
* Returns whether the browser supports SVG
*
* @ return true if the browser supports SVG , false otherwise
* /
// TODO: replace with original function
hasSVGSupport : SVGSupport ,
/ * *
* If SVG is not supported , replaces the given icon ' s extension
* from ".svg" to ".png" .
* If SVG is supported , return the image path as is .
*
* @ param file image path with svg extension
* @ return fixed image path with png extension if SVG is not
* supported
* /
replaceSVGIcon : function ( file ) {
if ( ! OC . Util . hasSVGSupport ( ) ) {
var i = file . lastIndexOf ( '.svg' ) ;
if ( i >= 0 ) {
file = file . substr ( 0 , i ) + '.png' + file . substr ( i + 4 ) ;
}
}
return file ;
} ,
/ * *
* Replace SVG images in all elements that have the "svg" class set
* with PNG images .
*
* @ param $el root element from which to search , defaults to $ ( 'body' )
* /
replaceSVG : function ( $el ) {
if ( ! $el ) {
$el = $ ( 'body' ) ;
}
$el . find ( 'img.svg' ) . each ( function ( index , element ) {
element = $ ( element ) ;
var src = element . attr ( 'src' ) ;
element . attr ( 'src' , src . substr ( 0 , src . length - 3 ) + 'png' ) ;
} ) ;
$el . find ( '.svg' ) . each ( function ( index , element ) {
element = $ ( element ) ;
var background = element . css ( 'background-image' ) ;
if ( background ) {
var i = background . lastIndexOf ( '.svg' ) ;
if ( i >= 0 ) {
background = background . substr ( 0 , i ) + '.png' + background . substr ( i + 4 ) ;
element . css ( 'background-image' , background ) ;
}
}
element . find ( '*' ) . each ( function ( index , element ) {
element = $ ( element ) ;
var background = element . css ( 'background-image' ) ;
if ( background ) {
var i = background . lastIndexOf ( '.svg' ) ;
if ( i >= 0 ) {
background = background . substr ( 0 , i ) + '.png' + background . substr ( i + 4 ) ;
element . css ( 'background-image' , background ) ;
}
}
} ) ;
} ) ;
}
} ;
/ * *
* get a variable by name
* @ param string name