-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
133 lines (119 loc) · 4.53 KB
/
main.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
123
124
125
126
127
128
129
130
131
132
133
/**
* @author : abhishek goswami (hiro)
* @github : abhishekg785
*
* main.js
*/
(function($, d, w) {
var WindowInnerHeight,
WindowInnerWidth,
demoCanvas = $("#demo-canvas"),
aboutUsLaptopWrap = $('.wrap'),
aboutUsAppDevelopSectionWrapper = $('#app-develop-section .wrapper'),
currentSelectedLink = $('#home_link'),
menuColors = {
'selectedItem' : 'rgb(255, 87, 34)',
'deSelectedItem' : 'white'
},
currentSelectedSectionIndex = 0,
currentSelectedSection = '#home-section';
var _MainFunctions = {
init : function() {
_MainFunctions.scrollBodyTop(0);
_MainFunctions.SelectMenuItem(currentSelectedLink);
},
/**
* function resizes the background of the home page
* according to the window height and width
*/
ResizeHomeBackgroundCanvas : function() {
WindowInnerHeight = w.innerHeight;
WindowInnerWidth = w.innerWidth;
demoCanvas.css({
'width' : WindowInnerWidth
});
},
ResizeAboutUsSection : function() {
if(w.innerWidth >= 960) {
aboutUsLaptopWrap.css('transform', 'scale(1)');
}
if(w.innerWidth < 960 && w.innerWidth > 823) {
aboutUsLaptopWrap.css('transform', 'scale(0.8)');
}
},
ResizeAboutAppSection : function() {
if(w.innerWidth >= 1330) {
aboutUsAppDevelopSectionWrapper.css('transform', 'scale(0.6)');
}
else if(w.innerWidth < 1330 && w.innerWidth >= 1320) {
aboutUsAppDevelopSectionWrapper.css('transform', 'scale(0.5)');
}
else if(w.innerWidth < 1320 && w.innerWidth > 1134 ) {
aboutUsAppDevelopSectionWrapper.css('transform', 'scale(0.4)');
}
},
SelectMenuItem : function(element) {
$(element).css({
'color' : menuColors.selectedItem
});
},
DeSelectMenuItem : function(element) {
$(element).css({
'color' : menuColors.deSelectedItem
});
},
scrollBodyTop : function(val) {
$('html, body').animate({
scrollTop : val
}, 500);
}
}
$(w).on('resize', function(d) {
_MainFunctions.ResizeHomeBackgroundCanvas();
_MainFunctions.ResizeAboutUsSection();
_MainFunctions.ResizeAboutAppSection();
$(w).scroll(); // to fix the problem occurs in the link selection due to scrolling
});
// for slow scrolling and selected menu item
$(d).ready(function() {
_MainFunctions.init();
$('.nav-list a').click(function() {
var clickedLinkSection = $(this).attr('href');
if(!(currentSelectedSection == clickedLinkSection)) {
_MainFunctions.DeSelectMenuItem(currentSelectedLink);
_MainFunctions.SelectMenuItem($(this));
_MainFunctions.scrollBodyTop($( $(this).attr('href') ).offset().top);
currentSelectedSection = clickedLinkSection;
currentSelectedLink = $(this);
}
return false;
});
// take user to the apply form
$('#apply-button').on('click', function() {
w.open('apply.html', '_blank');
});
// controlling the links according to the view the user is on
$(w).scroll(function() {
var index = $(w).scrollTop() / $(w).height(),
errorFactor = 0.1,
linkIndex = Math.floor(index + errorFactor);
if(linkIndex == 2) {
return;
}
else if(linkIndex > 2){
linkIndex -= 1;
}
if(!(linkIndex == currentSelectedSectionIndex)) {
var currentLink = $('.nav-list nav').children()[currentSelectedSectionIndex],
nextSectionLink = $('.nav-list nav').children()[linkIndex];
$(currentLink).addClass('deactive-link');
$(currentLink).removeClass('active-link');
$(nextSectionLink).addClass('active-link');
$(nextSectionLink).removeClass('deactive-link');
currentSelectedSectionIndex = linkIndex;
currentSelectedSection = $(nextSectionLink).attr('href');
currentSelectedLink = nextSectionLink;
}
});
});
})(jQuery, document, window);