summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/site/StaffView.js
blob: 8f677cbf23e7dc7330912243c01a8ca94525b18f (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
var StaffView = View.extend({
  el: ".page",
  
  events: {
    "click #toggle-staff": "toggleStaff",
  },

	initialize: function() {
		this.$toggleStaff = $("#toggle-staff")
    if (this.$toggleStaff.data().isstaff) {
      this.$toggleStaff.html("Is Staff")
    }
	},

	load: function() {
		$(".json").each(function(){
      $(this).JSONView( this.innerText )
    })

		this.projectList = new ProjectList ()
	},
	
  toggleStaff: function(){
    var state = ! this.$toggleStaff.data().isstaff
    $.ajax({
      type: "put",
      dataType: "json",
      url: window.location.href + "/bless",
      data: {
        state: state,
        _csrf: $("#_csrf").val(),
      },
      success: function(data){
        this.$toggleStaff.data("isstaff", data.state)
        this.$toggleStaff.html(data.state ? "Is Staff" : "Make Staff")
        $("#is-staff").html(data.state ? "yes" : "no")
      }.bind(this)
    })
  },	

})