Skip to content

Commit

Permalink
simplified slideBackgroundPhoto
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryman committed Apr 5, 2013
1 parent ecee1e0 commit df7e52f
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ $(function () {
}

isAnimating = true;

animateNavigationBox(imageIndex);
slideBackgroundPhoto(imageIndex);

Expand Down Expand Up @@ -385,22 +386,25 @@ $(function () {
var photo = photos[imageIndex];

// Create a new div and apply the CSS
var cssMap = Object();
cssMap['display'] = "none";
cssMap['background-image'] = "url(" + photo.image + ")";
cssMap['background-repeat'] = "no-repeat";
cssMap['background-size'] = "contain";
cssMap['background-position'] = "center";

var divNode = $("<div />").css(cssMap).addClass(photo.cssclass);
divNode.prependTo("#pictureSlider");

$("#pictureSlider div").fadeIn(animationSpeed);
var oldDiv = $("#pictureSlider div:not(:first)");
oldDiv.fadeOut(animationSpeed, function () {
oldDiv.remove();
var cssMap = {
'display': "none",
'background-image': "url(" + photo.image + ")",
'background-repeat': "no-repeat",
'background-size': "contain",
'background-position': "center"
}

// Fade out old div
$("#pictureSlider div").fadeOut(animationSpeed, function () {
$(this).remove();
isAnimating = false;
});

// Fade in new one
$("<div />").css(cssMap)
.addClass(photo.cssclass)
.prependTo("#pictureSlider")
.fadeIn(animationSpeed);
};

var verifyNsfwMakesSense = function() {
Expand All @@ -421,14 +425,12 @@ $(function () {
}

var tryConvertUrl = function (url) {
if (url.indexOf('imgur.com') >= 0) {
if (url.indexOf('/a/') >= 0) {
// albums aren't supported yet
return '';
}
// imgur is really nice and serves the image with whatever extension
// you give it. '.jpg' is arbitrary
return url + '.jpg';
if (url.indexOf('imgur.com') >= 0
// albums aren't supported yet
&& url.indexOf('/a/') < 0) {
// imgur is really nice and serves the image with whatever extension
// you give it. '.jpg' is arbitrary
return url + '.jpg';
}

return '';
Expand Down

0 comments on commit df7e52f

Please sign in to comment.