-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcustom.js
More file actions
111 lines (72 loc) · 2.63 KB
/
custom.js
File metadata and controls
111 lines (72 loc) · 2.63 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
function parallax() {
var scrollPosition = $(window).scrollTop();
$('#parallax').css('top',(72 - (scrollPosition * 0.3))+'px' ); // bg image moves at 30% of scrolling speed
}
$(document).ready(function() {
/* ========== PARALLAX BACKGROUND ========== */
$(window).on('scroll', function(e) {
parallax();
});
/* ========== FITVIDS PLUGIN ========== */
$('.fitvids').fitVids();
/* ========== BOOTSTRAP CAROUSEL ========== */
$('.carousel').carousel({
interval: 4000
});
/* ========== CONTACT FORM ========== */
$("#contact-form").submit(function() {
$('.form-control', $("#contact-form")).attr('readonly', true);
$('#btnSend').attr('disabled', true).data('orig', $('#btnSend').html()).html('Sending ...');
var str = $(this).serialize();
$.ajax({
type: "POST",
url: "/html/contactus",
data: str,
success: function(msg) {
$('.form-control', $("#contact-form")).attr('readonly', false);
$('#btnSend').attr('disabled', false).html($('#btnSend').data('orig'));
if(msg.success) {
err = $('<div class="alert alert-success">您的邮件已经发送成功了哦~</div>');
$("#contact-form").hide();
setTimeout("location.reload(true);",7000);
} else {
var err = $('<div class="alert alert-error"></div>');
for (var i = 0; i < msg.errors.length; i++) {
var errmsg = '<p>';
if(msg.errors[i].label) {
errmsg += '<strong>' + msg.errors[i].label + '</strong> ';
}
errmsg += msg.errors[i].message;
errmsg += '</p>';
err.append(errmsg);
};
}
$('#contact-error').html('').append(err);
}
});
return false;
});
/* ========== SMOOTH SCROLLING BETWEEN SECTIONS ========== */
$('[href^=#]').not('.carousel a, .panel a, .modal-trigger a').click(function (e) {
e.preventDefault();
var div = $(this).attr('href');
if ($(".navbar").css("position") == "fixed" ) {
$("html, body").animate({
scrollTop: $(div).position().top-$('.navbar').height()
}, 700, 'swing');
} else {
$("html, body").animate({
scrollTop: $(div).position().top
}, 700, 'swing');
}
});
/* =========== CUSTOM STYLE FOR SELECT DROPDOWN ========== */
$("select").selectpicker({style: 'btn-hg btn-primary', menuStyle: 'dropdown'});
// style: select toggle class name (which is .btn)
// menuStyle: dropdown class name
// You can always select by any other attribute, not just tag name.
// Also you can leave selectpicker arguments blank to apply defaults.
/* ========== TOOLTIPS & POPOVERS =========== */
$("[data-toggle=tooltip]").tooltip();
$('.popover-trigger').popover('hide');
});