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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
var StaffView = View.extend({
el: ".page",
events: {
"click #toggle-staff": "toggleStaff",
"click #toggle-featured": "toggleFeatured",
},
initialize: function() {
this.$toggleStaff = $("#toggle-staff")
this.$toggleFeatured = $("#toggle-featured")
this.$mediaEmbed = $("#media-embed")
if (this.$toggleStaff.length && this.$toggleStaff.data().isstaff) {
this.$toggleStaff.html("Is Staff")
}
if (this.$toggleFeatured.length && this.$toggleFeatured.data().featured) {
this.$toggleFeatured.html("Featured Project")
}
if (this.$mediaEmbed.length) {
var media = this.$mediaEmbed.data()
this.$mediaEmbed.html( Parser.tag( media ) )
}
},
load: function() {
$(".json").each(function(){
$(this).JSONView( this.innerText )
}).show()
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))
},
toggleFeatured: function(){
var state = ! this.$toggleFeatured.data().featured
$.ajax({
type: "put",
dataType: "json",
url: window.location.href + "/feature",
data: {
state: state,
_csrf: $("#_csrf").val(),
},
success: function(data){
this.$toggleFeatured.data("featured", data.state)
this.$toggleFeatured.html(data.state ? "Featured Project" : "Feature this project")
$("#isFeaturedProject").html(data.state ? "yes" : "no")
}.bind(this)
})
},
})
|