diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-24 20:57:41 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-24 20:57:41 -0500 |
| commit | 612561818f907f0f9988247c82ec158ba4494986 (patch) | |
| tree | 8bbc773dad7a6364cbdb8aed2ef4cab04854f49a /StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js | |
| parent | d548a7d02ce6349ca9a820b6824e4374b759812b (diff) | |
build
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js')
| -rw-r--r-- | StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js | 67 |
1 files changed, 59 insertions, 8 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js index ea9b3048..3b2900ad 100644 --- a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js @@ -1,18 +1,21 @@ -var HubView = View.extend({ +var HubView = ScrollableView.extend({ el: "#hub", template: $("#hub .template").html(), events: { + "click .store": "store_link", }, initialize: function(){ this.$content = this.$(".content") this.$loader = this.$(".loader") - this.scroller = new IScroll('#hub .scroll') + this.scroller = new IScroll('#hub', app.iscroll_optionsx) }, show: function(){ + this.deferScrollToTop() + app.footer.hide() document.body.className = "hub" }, @@ -20,17 +23,65 @@ var HubView = View.extend({ this.data = data this.$loader.hide() this.$content.empty() + // id date subtitle body link store image[uri caption] this.data.forEach(function(row){ - var t = this.template.replace(/{{image}}/, row.image.url) - .replace(/{{date}}/, row.date) - .replace(/{{code}}/, row.code) + // console.log(row) + var t = this.template.replace(/{{id}}/, row.id) + .replace(/{{date}}/, moment(row.date).format("MM.DD.YYYY")) .replace(/{{title}}/, row.title) .replace(/{{subtitle}}/, row.subtitle) .replace(/{{link}}/, row.link) - .replace(/{{body}}/, row.body) - this.$content.append(t) + .replace(/{{body}}/, row.body.replace(/\n/g, "<br>")) + var $t = $(t) + if (row.store != "true") { + $t.find(".store").remove() + } + 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(" + row.image[0].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() + }, + + store_link: function(){ + app.router.go("store") }, - })
\ No newline at end of file |
