-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcoder_review.js
61 lines (59 loc) · 1.91 KB
/
coder_review.js
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
/**
* Javascript for the Coder_review module.
*/
(function ($) {
jQuery.fn.extend({
check : function() { return this.each(function() { this.checked = true; }); },
uncheck : function() { return this.each(function() { this.checked = false; }); }
});
Backdrop.behaviors.coderReviewFormHandler = {
attach: function (context) {
$("input:checkbox").click(
function() {
core = this.form.elements.namedItem("edit-coder-core");
active = this.form.elements.namedItem("edit-coder-active-modules");
if (this == core || this == active) {
modules = "input[id^=edit-coder-modules-]";
themes = "input[id^=edit-coder-themes-]";
if (core.checked || active.checked) {
$(modules).uncheck();
$(themes).uncheck();
if (core.checked) {
modules += '.coder-core';
themes += '.coder-core';
}
if (active.checked) {
modules += '.coder-active';
themes += '.coder-active';
}
$(modules).check();
$(themes).check();
}
else {
if (this == active) {
modules += ".coder-active";
themes += ".coder-active";
}
else {
modules += ".coder-core";
themes += ".coder-core";
}
$(modules).uncheck();
$(themes).uncheck();
}
}
else if (this.id.substr(0, 19) == "edit-coder-modules-" || this.id.substr(0, 18) == "edit-coder-themes-") {
core.checked = false;
active.checked = false;
}
return true;
}
);
$("img.coder-more").click(
function() {
$('.coder-description', this.parentNode).slideToggle();
}
);
}
};
})(jQuery);