diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-09-10 09:26:36 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-09-10 09:26:36 -0400 |
| commit | fcc74fbe841d542da252d5688e7b90b1e2799224 (patch) | |
| tree | 5a6cee797637fa4cf3ca2dd57e5cbb0669cecd57 /public/assets/javascripts/ui/site/StaffView.js | |
| parent | 6663ede5b27c2d4aa0caa1072463b97af8de8b57 (diff) | |
| parent | 6d2746ad8a24f1ac3da5e9cb2ed452b73da20b71 (diff) | |
merge
Diffstat (limited to 'public/assets/javascripts/ui/site/StaffView.js')
| -rw-r--r-- | public/assets/javascripts/ui/site/StaffView.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/public/assets/javascripts/ui/site/StaffView.js b/public/assets/javascripts/ui/site/StaffView.js new file mode 100644 index 0000000..fdf39d2 --- /dev/null +++ b/public/assets/javascripts/ui/site/StaffView.js @@ -0,0 +1,49 @@ +var StaffView = View.extend({ + el: ".page", + + events: { + "click #toggle-staff": "toggleStaff", + }, + + initialize: function() { + this.$toggleStaff = $("#toggle-staff") + this.$mediaEmbed = $("#media-embed") + if (this.$toggleStaff.length && this.$toggleStaff.data().isstaff) { + this.$toggleStaff.html("Is Staff") + } + 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)) + }, + +}) |
