var GalleryView = View.extend({ el: "#gallery", template: $("#gallery .template").html(), events: { "click .left": "prev", "click .right": "next", // "touchstart .gallery": "touchstart", // "touchmove .gallery": "touchmove", // "touchend .gallery": "touchend", }, initialize: function(){ this.$(".template").remove() }, reset: function(){ this.gallery && this.gallery.destroy() this.$el.empty() }, populate: function(code, image_ids){ var valid_styles = {} image_ids.forEach(function(id){ if (id.indexOf("_") == -1) return var partz = id.split("_") var size = parseInt(partz[0]), style = partz[1] if (size > 13) return; if (! valid_styles[style] || valid_styles[style] < size) { valid_styles[style] = size } }) Object.keys(valid_styles).forEach(function(style){ var id = valid_styles[style] + "_" + style var t = this.template.replace(/{{image}}/, sdk.image(code, id)) this.$el.append(t) }.bind(this)) this.gallery = new Flickity( "#gallery", { selector: '.item', cellAlign: 'center', autoPlay: false, freeScroll: false, wrapAround: true, imagesLoaded: true, prevNextButtons: false, pageDots: false, contain: true, draggable: true, }) }, prev: function(){ }, next: function(){ }, touchstart: function(e){ }, touchmove: function(e){ }, touchend: function(e){ }, })