-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
62 lines (54 loc) · 2.59 KB
/
script.js
File metadata and controls
62 lines (54 loc) · 2.59 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
//onload event to set margins for feedback
$(document).ready(marginResize);
//on resize event to set margins for feedback
$(window).on('resize', marginResize);
//sets margins for feedback
function marginResize(){
document.getElementById('feedbackBg').style.margin = ($(window).height() / 2) + 'px ' + ($(window).width() / 2) + 'px';
}
//runs on window scroll. For moving things about the page
$(window).scroll(function () {
//opens feedbackSuggest tab when near the bottom of the page
if (($(window).scrollTop() + $(window).height()) > ($(document).height() - 25)) document.getElementById('feedbackSuggest').style.height = '30px';
else document.getElementById('feedbackSuggest').style.height = '0px';
});
//opens feedback form, triggered by popup at bottom
function openFeedback(){
document.getElementById('feedbackScreen').style.display = 'block';
setTimeout(function(){
//ensures that feedback form fits in the smallest screens
if ($(window).height() < 500) {
document.getElementById('feedbackBg').style.height = $(window).height() + 'px';
document.getElementById('feedbackBg').style.margin = '0px ' + (($(window).width() - 500) / 2) + 'px';
}
else document.getElementById('feedbackBg').style.height = '500px';
document.getElementById('feedbackBg').style.width = '500px';
document.getElementById('feedbackBg').style.margin = (($(window).height() - 500) / 2) + 'px ' + (($(window).width() - 500) / 2) + 'px';
}, 100);
}
//closes feedback form, triggered by 'x' button
function closeFeedback(){
document.getElementById('feedbackScreen').style.display = 'none';
document.getElementById('feedbackBg').style.height = '0px';
document.getElementById('feedbackBg').style.width = '0px';
document.getElementById('feedbackBg').style.margin = ($(window).height() / 2) + 'px ' + ($(window).width() / 2) + 'px';
}
//validates the form and notifies user of error before sending feedback
function sendMessage(){
var name = document.getElementsByName('name')[0].value;
var subject = document.getElementsByName('subject')[0].value;
var message = document.getElementsByName('message')[0].value;
if (message=='' || message==null){
alert('You message is looking a little empty there. Why don\'t you fill it before sending?');
}
else if (name=='' || name==null){
alert('Don\'t forget to tell us your name! Otherwise we\'ll be forced to call you "Bushel Britches" behind your back.');
}
else if (subject=='' || subject==null){
alert('Please fill in the subject line with something catchy, so we\'ll see your message.');
}
else {
document.giveFeedback.action = 'feedback.php';
document.giveFeedback.submit();
}
}