1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| (function($) {
$.fn.flou = function( options ) {
var defaults = {
taille : '5',
opacity : '0.2'
};
var opts = $.extend( defaults, options );
function createFlou() {
var img = $( this ).find( 'img' );
$( this ).css( 'position', 'relative' );
for ( var i = 1; i <= 4; i++ ) {
$( this ).prepend( '<span class="flou-state-' + i + '"></span>' );
}
$( this ).find( '.jw-flou-state-1, .jw-flou-state-2, .jw-flou-state-3, .jw-flou-state-4' ).css( {
opacity : opts.opacity,
background: 'url(' + img.attr( 'src' ) + ') no-repeat',
width : img.width() + 'px',
height : img.height() + 'px',
position : 'absolute',
top : '0',
left : '0'
} );
$( this ).find( '.jw-flou-state-1' ).css( 'background-position', '-' + opts.taille + 'px -' + opts.taille + 'px' );
$( this ).find( '.jw-flou-state-2' ).css( 'background-position', opts.taille + 'px ' + opts.taille + 'px' );
$( this ).find( '.jw-flou-state-3' ).css( 'background-position', opts.taille + 'px -' + opts.taille + 'px' );
$( this ).find( '.jw-flou-state-4' ).css( 'background-position', '-' + opts.taille + 'px ' + opts.taille + 'px' );
$( this ).find( 'img' ).css( 'opacity', opts.opacity );
}
$( this ).each( createFlou );
return $( this );
};
})(jQuery); |
Partager