summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/products/ClosedStoreView.js
blob: 5f8c1e84fa8517f8b180fc66466ed148ea455ee8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var ClosedStoreView = View.extend({

  el: "#closed",
  
  storeIsClosed: false,

  events: {
    "click .website_link": "website_link",
  },
  
  delay: 8000,
  
  timeout: -1,
  images: null,
  
  initialize: function(){
    this.loader = new Loader ()
  },
  
  show: function(){
    document.body.className = "closed"
    this.animate()
    app.footer.hide()
    console.log(this)
    if (this.storeOpenDate) {
      var date = moment(this.storeOpenDate).format("MM/DD")
      console.log(date)
      $(".closed_store_msg h3").html("THIS STORE WILL OPEN ON " + date)
    }
    else {
      $(".closed_store_msg h3").html("THIS STORE IS CURRENTLY CLOSED")
    }
  },
  
  hide: function(){
    clearTimeout(this.timeout)
  },
  
  animate: function(){
    this.timeout = setTimeout(this.animate.bind(this), this.delay)
    if (! this.images) return
    var url = choice(this.images)
    this.loader.preloadImage(url, function(img){
      this.el.style.backgroundImage = 'url(' + img.src + ')'
    }.bind(this))
  },
  
  populate: function(data){
    this.images = data.map(function(img){ return img.uri })
  },

  website_link: function(){
    window.open("http://www.stoneisland.com/", '_system')
  },

})