From 7045fe96bc33fe92ba54a837e637145fe9bbbd23 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 5 Nov 2015 20:09:28 -0500 Subject: plotting hub --- StoneIsland/www/js/lib/blogs/HubView.js | 44 +++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'StoneIsland/www/js/lib/blogs/HubView.js') diff --git a/StoneIsland/www/js/lib/blogs/HubView.js b/StoneIsland/www/js/lib/blogs/HubView.js index d44ce7c8..2f04c5cb 100644 --- a/StoneIsland/www/js/lib/blogs/HubView.js +++ b/StoneIsland/www/js/lib/blogs/HubView.js @@ -1,4 +1,4 @@ -var HubView = View.extend({ +var HubView = ScrollableView.extend({ el: "#hub", template: $("#hub .template").html(), @@ -23,14 +23,54 @@ var HubView = View.extend({ // id date subtitle body link image[uri caption] this.data.forEach(function(row){ console.log(row) - var t = this.template.replace(/{{image}}/, row.image[0].uri) + var t = this.template.replace(/{{id}}/, row.id) .replace(/{{date}}/, row.date) .replace(/{{title}}/, row.title) .replace(/{{subtitle}}/, row.subtitle) .replace(/{{link}}/, row.link) .replace(/{{body}}/, row.body.replace(/\n/g, "
")) this.$content.append(t) + + if (row.image.length > 1) { + // image gallery + var $gallery = $(".gallery-" + row.id) + row.image.forEach(function(img){ + var el = document.createElement("div") + el.style.backgroundImage = "url(" + img.uri + ")" + el.className = "item" + $gallery.append(el) + }) + new Flickity( ".gallery-" + row.id, { + selector: '.item', + cellAlign: 'center', + autoPlay: false, + freeScroll: false, + wrapAround: true, + imagesLoaded: true, + prevNextButtons: false, + pageDots: false, + contain: true, + draggable: true, + }) + } + else { + // single image + var el = document.createElement("div") + el.style.backgroundImage = "url(" + img.uri + ")" + el.className = "item" + $(".gallery-" + row.id).append(el) + + // video, append play button + if (row.link.match(/youtube|youtu.be|vimeo/)) { + var play = document.createElement("div") + play.className = "play" + $(".gallery-" + row.id).append(play) + } + } + }.bind(this)) + + this.deferScrollToTop() }, }) \ No newline at end of file -- cgit v1.2.3-70-g09d2