-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
122 lines (104 loc) · 3.14 KB
/
app.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// for mixitup portfolio
var mixer = mixitup('.portfolio-gallery');
// for contact form
(function($) {
"use strict";
// Form
var contactForm = function() {
if ($('#contactForm').length > 0 ) {
$( "#contactForm" ).validate( {
rules: {
name: "required",
subject: "required",
email: {
required: true,
email: true
},
message: {
required: true,
minlength: 5
}
},
messages: {
name: "Please enter your name",
subject: "Please enter your subject",
email: "Please enter a valid email address",
message: "Please enter a message"
},
/* submit via ajax */
submitHandler: function(form) {
var $submit = $('.submitting'),
waitText = 'Submitting...';
$.ajax({
type: "POST",
url: "php/sendEmail.php",
data: $(form).serialize(),
beforeSend: function() {
$submit.css('display', 'block').text(waitText);
},
success: function(msg) {
if (msg == 'OK') {
$('#form-message-warning').hide();
setTimeout(function(){
$('#contactForm').fadeOut();
}, 1000);
setTimeout(function(){
$('#form-message-success').fadeIn();
}, 1400);
// setTimeout(function(){
// $('#form-message-success').fadeOut();
// }, 8000);
setTimeout(function(){
$submit.css('display', 'none').text(waitText);
}, 1400);
// setTimeout(function(){
// $( '#contactForm' ).each(function(){
// this.reset();
// });
// }, 1400);
} else {
$('#form-message-warning').html(msg);
$('#form-message-warning').fadeIn();
$submit.css('display', 'none');
}
},
error: function() {
$('#form-message-warning').html("Something went wrong. Please try again.");
$('#form-message-warning').fadeIn();
$submit.css('display', 'none');
}
});
} // end submitHandler
});
}
};
contactForm();
})(jQuery);
//for downloading pdf file
function DownloadFile(fileName) {
//Set the File URL.
var url = "resume/" + fileName;
//Create XMLHTTP Request.
var req = new XMLHttpRequest();
req.open("GET", url, true);
req.responseType = "blob";
req.onload = function () {
//Convert the Byte Data to BLOB object.
var blob = new Blob([req.response], { type: "application/octetstream" });
//Check the Browser type and download the File.
var isIE = false || !!document.documentMode;
if (isIE) {
window.navigator.msSaveBlob(blob, fileName);
} else {
var url = window.URL || window.webkitURL;
link = url.createObjectURL(blob);
var a = document.createElement("a");
a.setAttribute("download", fileName);
a.setAttribute("href", link);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
};
req.send();
};