summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/lib/account/SettingsView.js
blob: f6eae13cac9bab5fe55481a5a0c3a3c2d2d2edf6 (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
var SettingsView = FormView.extend({
  
  el: "#settings",
  
  events: {
    "change [name=store]": "changeStore",
    "change [name=hub]": "changeHub",
  },
  
  initialize: function(){
    this.$form = this.$("form")
    this.$msg = this.$(".msg")
    this.$store = this.$("[name=store]")
    this.$hub = this.$("[name=hub]")
    this.scroller = new IScroll('#settings', app.iscroll_options)
  },

  show: function(){
    if (! auth.logged_in()) { return app.router.go("intro") }
    if (! navigator.onLine) {
      app.closed.showElement()
      app.closed.setMessage("PLEASE GO ONLINE TO CHANGE<br>YOUR NOTIFICATION SETTINGS.", "")
      return
    }
    document.body.className = "settings"
    this.deferScrollToTop()
    
    this.$store.prop("checked", !! push.settings.store)
    this.$hub.prop("checked", !! push.settings.hub)
    // push.subscribe("store")
    // push.subscribe("hub")
  },
  
  changeStore: function(){
    var state = app.settings.$store.prop("checked")
    if (state) { push.subscribe("store") }
    else { push.unsubscribe('store') }
  },
  changeHub: function(){
    var state = app.settings.$hub.prop("checked")
    if (state) { push.subscribe("hub") }
    else { push.unsubscribe('hub') }
  },

})