This repository has been archived by the owner on Nov 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpoll.js.php
88 lines (77 loc) · 3.88 KB
/
poll.js.php
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
<script type="text/javascript">
$(document).ready(function() {
// show poll url
var pollUrl = window.location.protocol + "//" +
window.location.hostname +
window.location.pathname +
"?poll=<?php echo $poll->getId() ?>";
$("#public-url-field").val(pollUrl);
$("#admin-url-field").val(pollUrl + "&adm=<?php echo $adminId ?>");
// url clipboard copy feature
var clipboard = new ClipboardJS(".copy-trigger");
clipboard.on("success", function(e) {
$(e.trigger).addClass("copy-success").addClass("copy-success").delay(600).queue(function(){
$(this).removeClass("copy-success").dequeue();
});
});
clipboard.on("error", function(e) {
alert("<?php echo SPR_URL_COPY_ERROR ?>");
$(e.trigger).addClass("copy-fail").delay(2000).queue(function(){
$(this).removeClass("copy-fail").dequeue();
});
});
// delete entry button functionality
$(".schedule-delete").click(function(){
if (confirm("<?php echo SPR_REMOVE_CONFIRM ?> '" + $(this).attr("data-name") + "' ?")){
$.post( "entry.delete.php", { pollId: $(this).attr("data-poll"), name: $(this).attr("data-name"), adm: $(this).attr("data-adminid") } ).done( function() {
location.href = location.href;
});
}
});
// delete date/option button functionality
$(".date-delete").click(function(){
if (confirm("<?php echo SPR_REMOVE_CONFIRM ?> '" + $(this).attr("data-date") + "' ?")){
$.post( "date.delete.php", { pollId: $(this).attr("data-poll"), date: $(this).attr("data-date"), adm: $(this).attr("data-adminid") } ).done( function() {
location.href = location.href;
});
}
});
// delete poll button functionality
$("#ctrl-delete-poll").click(function(){
if (confirm("<?php echo SPR_DELETE_POLL_CONFIRM ?>")){
$.post( "poll.delete.php", { pollId: $(this).attr("data-poll"), adm: $(this).attr("data-adminid") } ).done( function() {
location.href = "index.php";
});
}
});
// iterate options on click (ugly, but works for now)
$(".new-entry-box").click(function(){
console.log("yes")
if ($(this).hasClass("new-entry-choice-maybe")){
$(this).removeClass("new-entry-choice-maybe");
$(this).addClass("new-entry-choice-yes");
$(this).children(".entry-value").attr("value", "1");
} else if ($(this).hasClass("new-entry-choice-yes")){
$(this).removeClass("new-entry-choice-yes");
$(this).addClass("new-entry-choice-no");
$(this).children(".entry-value").attr("value", "0");
} else if ($(this).hasClass("new-entry-choice-no")) {
$(this).removeClass("new-entry-choice-no");
$(this).addClass("new-entry-choice-maybe");
$(this).children(".entry-value").attr("value", "2");
}
});
// mini-view toggler
$("#ctrl-mini-view").click(function(){
if ($("#ctrl-mini-view").attr("data-miniview") == "off"){
$("table.schedule").addClass("mini");
$("#ctrl-mini-view").attr("data-miniview", "on");
$("#ctrl-mini-view").text("<?php echo SPR_POLL_CONTROL_NORMAL_VIEW ?>");
} else {
$("table.schedule").removeClass("mini");
$("#ctrl-mini-view").attr("data-miniview", "off");
$("#ctrl-mini-view").text("<?php echo SPR_POLL_CONTROL_MINI_VIEW ?>");
}
});
});
</script>