summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/ProjectView.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-04-04 12:14:18 -0400
committerJules Laplace <jules@okfoc.us>2016-04-04 12:14:18 -0400
commit7c073e83edf335fe611864c00a14abca0d718b11 (patch)
treed4cd6a2986039cdf60cc7ae68bb098deb1986630 /public/assets/js/lib/ProjectView.js
parentfde2bc89e2b78cbe53b985e7e99c1797e1c99bb2 (diff)
preload images, inject iframes
Diffstat (limited to 'public/assets/js/lib/ProjectView.js')
-rw-r--r--public/assets/js/lib/ProjectView.js52
1 files changed, 51 insertions, 1 deletions
diff --git a/public/assets/js/lib/ProjectView.js b/public/assets/js/lib/ProjectView.js
index b119b65..97a7e1c 100644
--- a/public/assets/js/lib/ProjectView.js
+++ b/public/assets/js/lib/ProjectView.js
@@ -12,7 +12,24 @@ var ProjectView = View.extend({
this.project_id = this.$el.data("id")
this.page_number = opt.page_number
this.slide_count = this.$(".cell").length
- console.log("INIT", this.project_id)
+
+ this.$iframes = this.$(".cell.iframe")
+ this.$images = this.$(".cell.image")
+ this.$videos = this.$(".cell.video")
+
+ this.images = this.$images.toArray().map(function(img){ return $(img).data("uri") })
+
+ if (is_mobile) {
+ $iframes.remove()
+ $videos.remove()
+ }
+
+ if (this.$(".cell").length > 1) {
+ this.$(".top").flickity(app.flickity_options).on( 'cellSelect', function(e) {
+ var gallery = $(e.target).data('flickity')
+ app.header.updateSlideNumber( gallery.selectedIndex )
+ })
+ }
var $viewport = this.$(".flickity-viewport")
if (! $viewport.length) {
@@ -30,6 +47,14 @@ var ProjectView = View.extend({
this.$el.append( $("<figure>").addClass("page-up") )
this.$el.append( $("<figure>").addClass("page-down") )
}
+
+ this.$el.addClass('hidden')
+ },
+
+ preload: function(){
+ if (this.images.length) {
+ app.loader.preloadImage( this.images[0] )
+ }
},
show: function(){
@@ -46,6 +71,24 @@ var ProjectView = View.extend({
app.router.pushState("/project/" + this.project_id)
}
+ this.$images.each(function(){
+ var uri = $(this).data("uri")
+ $(this).css("background-image", "url(" + uri + ")")
+ })
+
+ if (is_mobile) {
+ this.$images.each(function(){
+ var uri = $(this).data("uri")
+ $(this).css("background-image", "url(" + uri + ")")
+ })
+ }
+ else {
+ this.$iframes.each(function(){
+ var uri = $(this).data("uri")
+ $(this).html("<iframe src='" + uri + "'>")
+ })
+ }
+
app.nav.setActive( this.project_id )
this.showing = true
@@ -58,6 +101,13 @@ var ProjectView = View.extend({
addClassForPeriod( this.el, "hiding", app.navigation_delay, function(){
this.$el.addClass("hidden")
this.$el.removeClass("active")
+
+ this.$images.each(function(){
+ $(this).css("background-image", "")
+ })
+ this.$iframes.html("")
+ this.$videos.html("")
+
}.bind(this) )
},