-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
92 lines (75 loc) · 3.04 KB
/
script.js
File metadata and controls
92 lines (75 loc) · 3.04 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
87
88
89
90
91
92
/*
* jQuery v1.9.1 included
*/
$(document).ready(function() {
// social share popups
$(".share a").click(function(e) {
e.preventDefault();
window.open(this.href, "", "height = 500, width = 500");
});
// toggle the share dropdown in communities
$(".share-label").on("click", function(e) {
e.stopPropagation();
var isSelected = this.getAttribute("aria-selected") == "true";
this.setAttribute("aria-selected", !isSelected);
$(".share-label").not(this).attr("aria-selected", "false");
});
$(document).on("click", function() {
$(".share-label").attr("aria-selected", "false");
});
// show form controls when the textarea receives focus or backbutton is used and value exists
var $commentContainerTextarea = $(".comment-container textarea"),
$commentContainerFormControls = $(".comment-form-controls");
$commentContainerTextarea.one("focus", function() {
$commentContainerFormControls.show();
});
if ($commentContainerTextarea.val() !== "") {
$commentContainerFormControls.show();
}
// Mark as solved button
var $requestMarkAsSolvedButton = $(".request-comment-form .comment-container .mark-as-solved:not([data-disabled])"),
$requestMarkAsSolvedCheckbox = $(".request-comment-form .comment-container input[type=checkbox]"),
$requestCommentSubmitButton = $(".request-comment-form .comment-container input[type=submit]");
$requestMarkAsSolvedButton.on("click", function () {
$requestMarkAsSolvedCheckbox.attr("checked", true);
$requestCommentSubmitButton.prop("disabled", true);
$(this).attr("data-disabled", true).closest("form").submit();
});
// Change Mark as solved text according to whether comment is filled
var $requestCommentTextarea = $(".request-comment-form .comment-container textarea");
$requestCommentTextarea.on("keyup", function() {
if ($requestCommentTextarea.val() !== "") {
$requestMarkAsSolvedButton.text($requestMarkAsSolvedButton.data("solve-and-submit-translation"));
$requestCommentSubmitButton.prop("disabled", false);
} else {
$requestMarkAsSolvedButton.text($requestMarkAsSolvedButton.data("solve-translation"));
$requestCommentSubmitButton.prop("disabled", true);
}
});
// Disable submit button if textarea is empty
if ($requestCommentTextarea.val() === "") {
$requestCommentSubmitButton.prop("disabled", true);
}
// Submit requests filter form in the request list page
$("#request-status-select, #request-organization-select")
.on("change", function() {
search();
});
// Submit requests filter form in the request list page
$("#quick-search").on("keypress", function(e) {
if (e.which === 13) {
search();
}
});
function search() {
window.location.search = $.param({
query: $("#quick-search").val(),
status: $("#request-status-select").val(),
organization_id: $("#request-organization-select").val()
});
}
// Submit organization form in the request page
$("#request-organization select").on("change", function() {
this.form.submit();
});
});