Ciao,
grazie mille, allego direttamente il javascript. In questo file, come vedrete con window.load viene caricato anche Nivoslider e successivamente con window.ready isotope.
E' un progettino in wordpress.
codice:
jQuery(window).load(function(JQuery) {
jQuery('#slider').nivoSlider({
directionNav: false,
controlNav: false
});
// Apply grayscale functions
JQuery('article header img').each(function() {
JQuery(this).clone().addClass('colors').css('z-index', '10').insertBefore(this);
this.src = grayscale(this.src);
});
// Hover function
JQuery('article header img').hover(
function() {
JQuery(this).stop().animate({"opacity": "0"}, "slow");
},
function() {
JQuery(this).stop().animate({"opacity": "1"}, "slow");
}
);
});
jQuery(document).ready(function(JQuery){
// Start isotope
JQuery('#content').isotope( {
itemSelector : 'article'
});
// Filter items when filter link is clicked
JQuery('#filters a').click(function(){
var selector = JQuery(this).attr('data-filter');
JQuery('#content').isotope({ filter: selector });
return false;
});
});
//Grayscale function
function grayscale(src) {
//check if current browser supports canvas
var supportsCanvas = !!document.createElement('canvas').getContext;
if (supportsCanvas) {
var canvas = document.createElement('canvas'),
context = canvas.getContext('2d'), // use 2d
imageData, px, length, i = 0, gray,
img = new Image();
img.src = src;
canvas.width = img.width;
canvas.height = img.height;
context.drawImage(img, 0, 0); // draw the img image starting top left in the canvas
imageData = context.getImageData(0, 0, canvas.width, canvas.height);
px = imageData.data;
length = px.length;
for (; i < length; i += 4) {
gray = px[i] * .3 + px[i + 1] * .59 + px[i + 2] * .11;
px[i] = px[i + 1] = px[i + 2] = gray;
}
context.putImageData(imageData, 0, 0);
return canvas.toDataURL();
}
else {
return src;
}
}
Grazie mille a tutti
[TrGh]