layout.js
7.7 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
var Layout = function () {
var isMobileDevice = function() {
return (
navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/BlackBerry/i) ||
navigator.userAgent.match(/iPhone|iPad|iPod/i) ||
navigator.userAgent.match(/Opera Mini/i) ||
navigator.userAgent.match(/IEMobile/i)
);
}
var WindowWidth = $(window).width();
var WindowHeight = $(window).height();
var handleParallax = function () {
$(window).load(function(){
if (isMobileDevice() === false) {
$("#message-block").parallax("50%",0.4);
$("#facts-block").parallax("50%",0.4);
}
});
}
var handleScrolling = function () {
$(".scroll").on("click", function(event) {
event.preventDefault();//the default action of the event will not be triggered
$("html, body").animate({scrollTop:($("#"+this.href.split("#")[1]).offset().top)}, 600);
});
}
/* Smooth scrolling and smart navigation when user scrolls on one-page sites */
var handleNavItemCurrent = function () {
$(".header-navigation").onePageNav({
currentClass: "current",
scrollThreshold: 0
});
}
var handleHeaderPosition = function () {
var CurrentHeaderPosition = $(".header").offset().top;// current header's vertical position
var headerFix = function(){
var CurrentWindowPosition = $(window).scrollTop();// current vertical position
if (CurrentWindowPosition > CurrentHeaderPosition) {
$(".header").addClass("fixNav");
} else {
$(".header").removeClass("fixNav");
}
};
headerFix();// call headerFix() when the page was loaded
if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
$(window).bind("touchend touchcancel touchleave", function(e){
headerFix();
});
} else {
$(window).scroll(function() {
headerFix();
});
}
}
var handleGo2Top = function () {
var Go2TopOperation = function(){
var CurrentWindowPosition = $(window).scrollTop();// current vertical position
if (CurrentWindowPosition > 300) {
$(".go2top").show();
} else {
$(".go2top").hide();
}
};
Go2TopOperation();// call headerFix() when the page was loaded
if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
$(window).bind("touchend touchcancel touchleave", function(e){
Go2TopOperation();
});
} else {
$(window).scroll(function() {
Go2TopOperation();
});
}
}
function handleBootstrap() {
$(".carousel").carousel({
interval: 15000,
pause: "hover"
});
$(".tooltips").tooltip();
$(".popovers").popover();
}
function handleCounter() {
/*$('.counter').counterUp({
delay: 10,
time: 1000
});*/
}
var handlePortfolioSorting = function () {
/*$(".sorting-grid").mixitup();*/
}
var handleFancybox = function () {
if (!jQuery.fancybox) {
return;
}
$(".zoom").fancybox();
}
var handleMobiToggler = function () {
$(".mobi-toggler").on("click", function(event) {
event.preventDefault();//the default action of the event will not be triggered
$(".header").toggleClass("menuOpened");
$(".header").find(".header-navigation").toggle(300);
});
function SlideUpMenu () {
$(".header-navigation a").on("click", function(event) {
if ($(window).width()<1024) {
event.preventDefault();//the default action of the event will not be triggered
$(".header-navigation").slideUp(100);
$(".header").removeClass("menuOpened");
}
});
$(window).scroll(function() {
if (($(window).width()>480)&&($(window).width()<1024)) {
$(".header-navigation").slideUp(100);
$(".header").removeClass("menuOpened");
}
});
}
SlideUpMenu();
$(window).resize(function() {
SlideUpMenu();
});
}
var handleTwitter = function () {
!function(d,s,id){
var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}
}(document,"script","twitter-wjs");
}
function valignCenterMessageFunction () {
MessageCurrentElemHeight = $(".message-block .valign-center-elem").height();
$(".message-block .valign-center-elem").css("position", "absolute")
.css ("top", "50%")
.css ("margin-top", "-"+MessageCurrentElemHeight/2+"px")
.css ("width", "100%")
.css ("height", MessageCurrentElemHeight);
}
function valignCenterPortfolioFunction () {
PortfolioCurrentElemHeight = $(".portfolio-block .valign-center-elem").height();
$(".portfolio-block .valign-center-elem").css("position", "absolute")
.css ("top", "50%")
.css ("margin-top", "-"+PortfolioCurrentElemHeight/2+"px")
.css ("width", "100%")
.css ("height", PortfolioCurrentElemHeight);
}
var valignCenterMessage = function () {
valignCenterMessageFunction();
$(window).resize(function() {
valignCenterMessageFunction();
});
}
var valignCenterPortfolio = function () {
valignCenterPortfolioFunction();
$(window).resize(function() {
valignCenterPortfolioFunction();
});
}
var handleTheme = function () {
var panel = $('.color-panel');
// handle theme colors
var setColor = function (color) {
$('#style-color').attr("href", "../../assets/frontend/onepage/css/themes/" + color + ".css");
$('.site-logo img').attr("src", "../../assets/frontend/onepage/img/logo/" + color + ".png");
}
$('.icon-color', panel).click(function () {
$('.color-mode').show();
$('.icon-color-close').show();
});
$('.icon-color-close', panel).click(function () {
$('.color-mode').hide();
$('.icon-color-close').hide();
});
$('li', panel).click(function () {
var color = $(this).attr("data-style");
setColor(color);
$('.inline li', panel).removeClass("current");
$(this).addClass("current");
});
$('.color-panel .menu-pos').change(function(){
if ($(this).val() == "top") {
$('body').addClass("menu-always-on-top");
} else {
$('body').removeClass("menu-always-on-top");
}
});
}
return {
init: function () {
//handlePromoBlock();
handleParallax();
handleScrolling();
handleNavItemCurrent();
handleHeaderPosition();
handleBootstrap();
handleCounter();
handleGo2Top();
handlePortfolioSorting();
handleFancybox();
handleMobiToggler();
handleTwitter();
valignCenterMessage();
valignCenterPortfolio();
handleTheme();
},
};
}();