diff options
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js')
| -rw-r--r-- | StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js index a6ae958e..49c05ff6 100644 --- a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js @@ -4,15 +4,17 @@ var HubView = ScrollableView.extend({ template: $("#hub .template").html(), events: { + "click .share": "content-share", "click .store": "store_link", "click .gallery-left": "gallery_left", "click .gallery-right": "gallery_right", + "click .play": "play_video", }, initialize: function(){ this.$content = this.$(".content") this.$loader = this.$(".loader") - this.scroller = new IScroll('#hub', app.iscroll_optionsx) + this.scroller = new IScroll('#hub', app.iscroll_options) }, show: function(){ @@ -21,14 +23,16 @@ var HubView = ScrollableView.extend({ document.body.className = "hub" }, + galleries: {}, populate: function(data){ this.data = data this.$loader.hide() this.$content.empty() + this.galleries = {} // id date subtitle body link store image[uri caption] this.data.forEach(function(row){ // console.log(row) - var t = this.template.replace(/{{id}}/, row.id) + var t = this.template.replace(/{{id}}/g, row.id) .replace(/{{date}}/, moment(row.date).format("MM.DD.YYYY")) .replace(/{{title}}/, row.title) .replace(/{{subtitle}}/, row.subtitle) @@ -49,7 +53,7 @@ var HubView = ScrollableView.extend({ el.className = "item" $gallery.append(el) }) - new Flickity( ".gallery-" + row.id, { + this.galleries[row.id] = new Flickity( ".gallery-" + row.id, { selector: '.item', cellAlign: 'center', autoPlay: false, @@ -68,6 +72,7 @@ var HubView = ScrollableView.extend({ el.style.backgroundImage = "url(" + row.image[0].uri + ")" el.className = "item" $(".gallery-" + row.id).append(el) + $(".gallery-" + row.id).data("row", row) // video, append play button if (row.link.match(/youtube|youtu.be|vimeo/)) { @@ -75,8 +80,8 @@ var HubView = ScrollableView.extend({ play.className = "play" $(".gallery-" + row.id).append(play) } - $t.find("gallery-left").remove() - $t.find("gallery-right").remove() + $t.find(".gallery-left").remove() + $t.find(".gallery-right").remove() } }.bind(this)) @@ -87,12 +92,22 @@ var HubView = ScrollableView.extend({ store_link: function(){ app.router.go("store") }, + play_video: function(e){ + var row = $(e.currentTarget).closest('.gallery-video-post').data("row") + window.open(row.link, '_system') + }, - gallery_prev: function(e){ - $(e.currentTarget).closest("hub_item").flickity('prev') + gallery_left: function(e){ + var id = $(e.currentTarget).closest(".hub_item").data('id') + this.galleries[id].previous() + }, + gallery_right: function(e){ + var id = $(e.currentTarget).closest(".hub_item").data('id') + this.galleries[id].next() }, - gallery_next: function(e){ - $(e.currentTarget).closest("hub_item").flickity('next') + + share: function(){ + window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://stoneisland.com/") }, })
\ No newline at end of file |
