Dodano obsługę WebP oraz poprawiono formatowanie kodu w plikach PHP i JS
This commit is contained in:
27
libraries/functions-front.js
Normal file
27
libraries/functions-front.js
Normal file
@@ -0,0 +1,27 @@
|
||||
var user_agent = navigator.userAgent.toLowerCase();
|
||||
var click_event = user_agent.match(/(iphone|ipod|ipad)/) ? "touchend" : "click";
|
||||
var windowsize = $(window).width();
|
||||
|
||||
$( function()
|
||||
{
|
||||
function hasWebP() {
|
||||
var rv = $.Deferred(), img = new Image();
|
||||
img.onload = function() { rv.resolve(); };
|
||||
img.onerror = function() { rv.reject(); };
|
||||
img.src = "/libraries/webp.webp";
|
||||
return rv.promise();
|
||||
}
|
||||
|
||||
hasWebP().then(function() {
|
||||
}, function() {
|
||||
$('body').addClass('nowebp');
|
||||
$( 'img' ).each( function()
|
||||
{
|
||||
if ( $( this ).attr( 'src-nowebp' ) )
|
||||
{
|
||||
$( this ).attr( 'src', $( this ).attr( 'src-nowebp' ) );
|
||||
$( this ).attr( 'data-src', $( this ).attr( 'src-nowebp' ) );
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user