diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-05 20:09:28 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-05 20:15:37 -0500 |
| commit | 7045fe96bc33fe92ba54a837e637145fe9bbbd23 (patch) | |
| tree | 48597698d868e20642e6cbb997384c7ddfa39e97 /StoneIsland/www/js/lib/blogs | |
| parent | 07f85e3ed76d3760afb4ea4e984579fb70cab99e (diff) | |
plotting hub
Diffstat (limited to 'StoneIsland/www/js/lib/blogs')
| -rw-r--r-- | StoneIsland/www/js/lib/blogs/HubView.js | 44 |
1 files changed, 42 insertions, 2 deletions
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, "<br>")) 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 |
