-
Notifications
You must be signed in to change notification settings - Fork 0
/
evite.js
92 lines (66 loc) · 2.39 KB
/
evite.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
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
//helps keep the form from holding the page up if you try to leave
window.onbeforeunload = null;
$(document).ready(function(){
openEvite();
});
// $(window).load(function() {function(){
// openEvite();
// }
function specialFadeIn($element) {
var opacity = 0.1;
var fadeInterval;
fadeInterval = setInterval(function() {
console.log(opacity);
opacity += 0.05;
$element.css('opacity', opacity);
if(opacity >= 1) clearInterval(fadeInterval);
}, 90);
}
function openEvite() {
//hide everything bring in the background and bring it all back
$('#hidden-body').hide().fadeIn(3000);
var audio = new Audio('fireplace.mp3');
audio.loop = true;
audio.volume = 0.04;
audio.play();
$('#rsvp-btn').click(function() {
$('.formal-letter').hide();
$('.main-title').removeClass('hidden').css('opacity', '0.05');
$('.rsvp-area').removeClass('hidden').css('opacity', '0.05');
specialFadeIn($('.main-title'));
specialFadeIn($('.rsvp-area'));
});
//when form has completed sending clear the form
$('form').bind('ajax:complete', function() {
var $theForm = $(this);
$theForm.find(
'input[type=text], ' +
'input[type=radio], ' +
'input[type=email] '
).val("");
});
// capture submit
$('form').submit(function() {
var $theForm = $(this);
var data = $theForm.serializeArray();
var response = data[2].value;
//hide the form
$('.rsvp-area').addClass('hidden');
//unhide the responses
//hiding and unhiding used here due to mixed use of
//hide attribute with jquery and bootstrap hidden class
$('.response').hide().removeClass('hidden');
if (response === 'Yes!') {
$('.response-yes').removeClass('hidden');
} else {
$('.response-no').removeClass('hidden');
}
$('.response').fadeIn('slow');
});
}
//preload images in a very not DRY way
// $images.push( $('<img>').attr('src', './slideshow/2.jpg').addClass('img-responsive img-rounded') );
// $images.push( $('<img>').attr('src', './slideshow/3.jpg').addClass('img-responsive img-rounded') );
// $images.push( $('<img>').attr('src', './slideshow/4.jpg').addClass('img-responsive img-rounded') );
// $images.push( $('<img>').attr('src', './slideshow/5.jpg').addClass('img-responsive img-rounded') );
// $images.push( $('<img>').attr('src', './slideshow/6.jpg').addClass('img-responsive img-rounded') );