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
|
var StaffView = View.extend({
el: ".page",
events: {
"click #toggle-staff": "toggleStaff",
},
initialize: function() {
this.$toggleStaff = $("#toggle-staff")
if (this.$toggleStaff.length && 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
var verb = state ? "promote this user to staff?" : "remove this user from staff?"
ConfirmModal.confirm("Are you sure you want to " + verb, function(){
$.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)
})
}.bind(this))
},
})
|