-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
251 lines (167 loc) · 5.65 KB
/
script.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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
//javascript for the responsive navigation menu
var menu = document.querySelector(".menu");
var menuBtn = document.querySelector(".menu-btn");
var closeBtn = document.querySelector(".close-btn");
menuBtn.addEventListener("click", () => {
menu.classList.add("active");
});
closeBtn.addEventListener("click", () => {
menu.classList.remove("active");
});
//javascript for the navigation bar effects on scroll
window.addEventListener("scroll", function(){
var header = document.querySelector("header");
header.classList.toggle("sticky", window.scrollY > 0);
});
//javascript for the Slide show
(function($) {
"use strict";
$.fn.sliderResponsive = function(settings) {
var set = $.extend(
{
slidePause: 5000,
fadeSpeed: 800,
autoPlay: "on",
showArrows: "off",
hideDots: "off",
hoverZoom: "on",
titleBarTop: "off"
},
settings
);
var $slider = $(this);
var size = $slider.find("> div").length; //number of slides
var position = 0; // current position of carousal
var sliderIntervalID; // used to clear autoplay
// Add a Dot for each slide
$slider.append("<ul></ul>");
$slider.find("> div").each(function(){
$slider.find("> ul").append('<li></li>');
});
// Put .show on the first Slide
$slider.find("div:first-of-type").addClass("show");
// Put .showLi on the first dot
$slider.find("li:first-of-type").addClass("showli")
//fadeout all items except .show
$slider.find("> div").not(".show").fadeOut();
// If Autoplay is set to 'on' than start it
if (set.autoPlay === "on") {
startSlider();
}
// If showarrows is set to 'on' then don't hide them
if (set.showArrows === "on") {
$slider.addClass('showArrows');
}
// If hideDots is set to 'on' then hide them
if (set.hideDots === "on") {
$slider.addClass('hideDots');
}
// If hoverZoom is set to 'off' then stop it
if (set.hoverZoom === "off") {
$slider.addClass('hoverZoomOff');
}
// If titleBarTop is set to 'on' then move it up
if (set.titleBarTop === "on") {
$slider.addClass('titleBarTop');
}
// function to start auto play
function startSlider() {
sliderIntervalID = setInterval(function() {
nextSlide();
}, set.slidePause);
}
// on mouseover stop the autoplay
$slider.mouseover(function() {
if (set.autoPlay === "on") {
clearInterval(sliderIntervalID);
}
});
// on mouseout starts the autoplay
$slider.mouseout(function() {
if (set.autoPlay === "on") {
startSlider();
}
});
//on right arrow click
$slider.find("> .right").click(nextSlide)
//on left arrow click
$slider.find("> .left").click(prevSlide);
// Go to next slide
function nextSlide() {
position = $slider.find(".show").index() + 1;
if (position > size - 1) position = 0;
changeCarousel(position);
}
// Go to previous slide
function prevSlide() {
position = $slider.find(".show").index() - 1;
if (position < 0) position = size - 1;
changeCarousel(position);
}
//when user clicks slider button
$slider.find(" > ul > li").click(function() {
position = $(this).index();
changeCarousel($(this).index());
});
//this changes the image and button selection
function changeCarousel() {
$slider.find(".show").removeClass("show").fadeOut();
$slider
.find("> div")
.eq(position)
.fadeIn(set.fadeSpeed)
.addClass("show");
// The Dots
$slider.find("> ul").find(".showli").removeClass("showli");
$slider.find("> ul > li").eq(position).addClass("showli");
}
return $slider;
};
})(jQuery);
//////////////////////////////////////////////
// Activate each slider - change options
//////////////////////////////////////////////
$(document).ready(function() {
$("#slider1").sliderResponsive({
// Using default everything
// slidePause: 5000,
// fadeSpeed: 800,
// autoPlay: "on",
// showArrows: "off",
// hideDots: "off",
// hoverZoom: "on",
// titleBarTop: "off"
});
$("#slider2").sliderResponsive({
fadeSpeed: 300,
autoPlay: "off",
showArrows: "on",
hideDots: "on"
});
$("#slider3").sliderResponsive({
hoverZoom: "off",
hideDots: "on"
});
});
// GAllery tab script////////////////////////////////////////////////////////////////
gridGallery({
selector: ".dark",
darkMode: true
});
gridGallery({
selector: "#horizontal",
layout: "horizontal"
});
gridGallery({
selector: "#square",
layout: "square"
});
gridGallery({
selector: "#gap",
gaplength: 10
});
gridGallery({
selector: "#heightWidth",
rowHeight: 180,
columnWidth: 280
});