-
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathapplication.js
More file actions
86 lines (76 loc) · 2.75 KB
/
application.js
File metadata and controls
86 lines (76 loc) · 2.75 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require chartkick
//= require Chart.bundle
//= require jquery_ujs
//= require_tree .
$(document).on('ready', function() {
$("a.flag-dialog-link").bind("click", (ev) => {
ev.preventDefault();
const self = $(ev.target);
self.parents(".post--body").find(".js-flag-box").toggleClass("is-active");
});
$('.close-dialog-link').on('click', (ev) => {
ev.preventDefault();
const self = $(ev.target);
console.log(self.parents(".post--body").find(".js-close-box").toggleClass("is-active"));
});
$("a.show-all-flags-dialog-link").bind("click", (ev) => {
ev.preventDefault();
const self = $(ev.target);
self.parents(".post--body").find(".js-flags").toggleClass("is-active");
});
$("a.flag-resolve").bind("click", function(ev) {
ev.preventDefault();
var self = $(this);
var id = self.data("flag-id");
var data = {
'result': self.data("result"),
'message': self.parent().parent().find(".flag-resolve-comment").val()
};
$.ajax({
'type': 'POST',
'url': '/mod/flags/' + id + '/resolve',
'data': data,
'el': self
})
.done(function(response) {
if(response['status'] !== 'success') {
QPixel.createNotification('danger', "<strong>Failed:</strong> " + response['message']);
}
else {
$(this.el).parent().parent().parent().fadeOut(200, function() {
$(this).remove();
});
}
})
.fail(function(jqXHR, textStatus, errorThrown) {
QPixel.createNotification('danger', "<strong>Failed:</strong> " + jqXHR.status);
console.log(jqXHR.responseText);
});
});
$(".is-partial-only:not(.open)").on("click", (evt) => {
if(evt.target.classList.contains("open")) return;
evt.target.classList.add("open");
evt.stopPropagation();
})
if (document.cookie.indexOf('dismiss_fvn') === -1 ) {
$('#fvn-dismiss').on('click', () => {
document.cookie = 'dismiss_fvn=true; path=/; expires=Fri, 31 Dec 9999 23:59:59 GMT';
});
}
});
const cssVar = name => window.getComputedStyle(document.documentElement).getPropertyValue(`--${name}`).trim();
Chartkick.setDefaultOptions({
colors: Array.from(Array(5).keys()).map(idx => cssVar(`data-${idx}`))
});