Created
December 6, 2011 00:24
-
-
Save codler/1436072 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var queue = 0; | |
var last_index = 0; | |
jQuery(function ($) { | |
$(document).on('click', '#splash .left a', function () { | |
show_splash(--last_index); | |
return false; | |
}); | |
$(document).on('click', '#splash .right a', function () { | |
show_splash(++last_index); | |
return false; | |
}); | |
splash_list = get_splash_list(); | |
rotate(); | |
}); | |
function rotate() { | |
setTimeout(function () { | |
show_splash(++last_index); | |
rotate(); | |
}, 5000); | |
} | |
function get_splash_list() { | |
var list = []; | |
$('.album:first img').each(function() { | |
list.push({ | |
'bild_url' : $(this).attr('src'), | |
'title' : $(this).attr('alt') | |
}); | |
}); | |
return list; | |
} | |
function show_splash(index) { | |
if (queue > 0) return; | |
queue += 2; | |
if (index < 1) index = 1; | |
if (index > splash_list.length) index = 1; | |
last_index = index; | |
index--; | |
var old = $('#splash'); | |
var clone = $('#splash').clone(); | |
clone.css({ | |
'position' : 'absolute', | |
'top' : '115px', | |
'opacity' : 0 | |
}); | |
clone.find('#splash-inner').css({ | |
'background-image' : "url('" + splash_list[index].bild_url + "')" | |
}); | |
clone.find('.text h1').text(splash_list[index].title); | |
clone.find('.star:first').text(++index); | |
clone.insertAfter(old); | |
old.animate({opacity:0}, { | |
complete : function () { | |
$(this).remove(); | |
queue--; | |
} | |
}); | |
clone.animate({opacity:1}, { | |
complete : function () { | |
$(this).css({ | |
'position' : '', | |
'top' : '' | |
}); | |
queue--; | |
} | |
}) | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment