Last active
May 25, 2016 12:40
-
-
Save justinwyllie/0456803d637f7f2f503083dd2e738633 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
function getAlbums2() { | |
"use strict"; | |
var t = "" | |
, i = "" | |
, a = ""; | |
$.getJSON("/assets/js/images.json", function(n) { | |
var s = n.albums; | |
$.each(s, function(n, s) { | |
t = s.name, | |
a = s.id, | |
i = s.photos, | |
displayAlbums2(t, a, i) | |
}) | |
}) | |
} | |
function displayAlbums2(name, id, photos) { | |
$(".img-container").show(); | |
console.log(name, photos[0], id); | |
var thumb = $(".templates .albums .thumb").clone(!0) | |
, s = thumb.find(".thumbnail") | |
, e = thumb.find(".thumbnail .image") | |
, u = thumb.find(".thumbnail .caption h4"); | |
u.html(name); | |
s.attr("id", id); | |
e.attr("src", photos[0].href); | |
e.attr("alt", photos[0].href); | |
thumb.click(function() {displayGallery2(photos)}) | |
$(".img-container .row").append(thumb); | |
} | |
function displayGallery2(photos) { | |
"use strict"; | |
$(".img-container").hide(); | |
$("body").append('<div id="gallery"/>'); | |
$.each(photos, function(idx, photo) { | |
console.log(idx, photo); | |
$('#gallery').append('<img width="300px" src="'+photo.href+'"/>'); | |
}) | |
} | |
$(function() { | |
"use strict"; | |
getAlbums2() | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment