var nextImage = $('<img />');
var nextImageHolder = $('<div>');
$(document).ready(function () {
loadNextImage();
var options = {
target: '#submit_rawform',
beforeSubmit: loading
};
$('#submit_rawform').ajaxForm(options);
$('#submit_btn').click(function() {
$('.submit_form').fadeIn('medium');
$('.overlay').fadeIn('medium');
});
$('#file_front').click(function() {
$('#file').click();
});
$('#submit_close').click(function() {
$('.submit_form').fadeOut('medium');
$('.overlay').fadeOut('medium');
});
});
$(document).keydown(function(e){
if (e.keyCode == 37) {
window.location.replace("?prev");
} else if(e.keyCode == 39){
forward();
}
});
function loading() {
$('#submit_rawform').innerHTML = "Uploading...";
}
function forward(){
$('body').prepend(nextImageHolder);
$('#background').animate({
left: '2%'
}, 350, function(){
$('#background').animate({
left: '-100%'
}, 1000, function(){
$('#background').remove();
$('#n_background').attr('id', 'background');
$('#n_bg').attr('id', 'c_bg');
});
});
loadNextImage();
return false;
}
function loadNextImage() {
$.get("ajax/next.php", function(data){
nextImage = $('<img />').attr('src', 'walls/' + data);
nextImage.attr('class', 'stretch');
nextImage.attr('id', 'n_bg');
nextImageHolder.attr('class', 'background');
nextImageHolder.attr('id', 'n_background');
nextImageHolder.html(nextImage);
});
}
And here's the body of the page:
<div class="background" id="background"> <img id="c_bg" src="walls/<?php echo $wall; ?>" class="stretch"/> </div> <div class="overlay"></div> <img src="images/loading.gif" class="loading"> <div class="submit_form"> <a href="#" id="submit_close"> <div class="close_btn">X</div> </a> <form action="upload.php" id="submit_rawform" method="post" encoding="multipart/form-data" enctype="multipart/form-data"> <input type="file" id="file" name="wall"> <input type="button" id="file_front" value="Wall"><br> <input type="submit" id="submit_wall" value="Share"> </form> </div> <a href="?prev" class="left"> < </a> <a href="#" class="right" onclick="forward();"> > </a> <div class="report"> <a href="#" id="report_btn">Report</a> </div> <div class="submit"> <a href="#" id="submit_btn">Submit</a> </div>
What happens is the first one works. It slides 2% to the right and then slides -100% (off the screen to the left), but after that the background just stays at 2%. Whenever the right arrow is pushed, the next background is loaded at 2%.

New Topic/Question
Reply




MultiQuote


|