summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js
diff options
context:
space:
mode:
authorRene Ae <aehtyb@gmail.com>2015-12-04 20:32:44 -0600
committerRene Ae <aehtyb@gmail.com>2015-12-04 20:32:44 -0600
commit10efb0f7b426426057fed757fe3c851a249358dd (patch)
treeb80e285251d30fbca36220c932ef180c29c55dcf /StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js
parent015b58ff6845b5cb79b13fec109a37b4c10c7813 (diff)
android build
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js')
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js113
1 files changed, 113 insertions, 0 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js
new file mode 100755
index 00000000..49c05ff6
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js
@@ -0,0 +1,113 @@
+var HubView = ScrollableView.extend({
+
+ el: "#hub",
+ 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_options)
+ },
+
+ show: function(){
+ this.deferScrollToTop()
+ app.footer.hide()
+ 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}}/g, 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.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)
+ })
+ this.galleries[row.id] = 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)
+ $(".gallery-" + row.id).data("row", row)
+
+ // 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)
+ }
+ $t.find(".gallery-left").remove()
+ $t.find(".gallery-right").remove()
+ }
+
+ }.bind(this))
+
+ this.deferScrollToTop()
+ },
+
+ 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_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()
+ },
+
+ share: function(){
+ window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://stoneisland.com/")
+ },
+
+}) \ No newline at end of file