Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 18615
1
/* global $this: true */
2
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "animationsSlider" }] */
3
4
if ($.cookie('themeCSSpath')) {
5
$('link#theme-stylesheet').attr('href', $.cookie('themeCSSpath'))
6
}
7
if ($.cookie('themeLayout')) {
8
$('body').addClass($.cookie('themeLayout'))
9
}
10
11
$(function () {
12
sliderHomepage()
13
sliders()
14
//fullScreenContainer()
15
// productDetailGallery(4000)
16
// menuSliding()
17
// productDetailSizes()
18
// utils()
19
//animations()
20
// counters()
21
//demo()
22
//contactForm()
23
})
24
25
// Ajax contact
26
function contactForm () {
27
var form = $('.contact-form')
28
form.submit(function () {
29
$this = $(this)
30
$.post($(this).attr('action'),
31
$this.serialize(),
32
function () {
33
$this[0].reset() // clear form
34
35
$('#contact-message')
36
.html('<div class="alert alert-success" role="alert"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>Thank you for getting in touch. We will get back to you soon!</div>')
37
.fadeIn()
38
}
39
, 'json')
40
return false
41
})
42
}
43
44
/* for demo purpose only - can be deleted */
45
function demo () {
46
if ($.cookie('themeCSSpath')) {
47
$('link#theme-stylesheet').attr('href', $.cookie('themeCSSpath'))
48
}
49
50
$('#colour').change(function () {
51
if ($(this).val() !== '') {
52
var themeCSSpath = 'css/style.' + $(this).val() + '.css'
53
54
$('link#theme-stylesheet').attr('href', themeCSSpath)
55
56
$.cookie('themeCSSpath', themeCSSpath, {expires: 365, path: '/'})
57
}
58
59
return false
60
})
61
62
$('#layout').change(function () {
63
if ($(this).val() !== '') {
64
var themeLayout = $(this).val()
65
66
$('body').removeClass('wide')
67
$('body').removeClass('boxed')
68
69
$('body').addClass(themeLayout)
70
71
$.cookie('themeLayout', themeLayout, {expires: 365, path: '/'})
72
}
73
74
return false
75
})
76
}
77
78
/* slider homepage */
79
function sliderHomepage () {
80
if ($('#slider').length) {
81
// var owl = $('#slider')
82
83
$('#slider').owlCarousel({
84
autoPlay: 3000,
85
items: 4,
86
itemsDesktopSmall: [900, 3],
87
itemsTablet: [600, 3],
88
itemsMobile: [500, 2]
89
})
90
}
91
}
92
93
/* sliders */
94
function sliders () {
95
if ($('.owl-carousel').length) {
96
$('.customers').owlCarousel({
97
items: 3,
98
itemsDesktopSmall: [990, 3],
99
itemsTablet: [768, 2],
100
itemsMobile: [480, 1]
101
})
102
103
$('.testimonials').owlCarousel({
104
items: 4,
105
itemsDesktopSmall: [990, 3],
106
itemsTablet: [768, 2],
107
itemsMobile: [480, 1]
108
})
109
110
$('.project').owlCarousel({
111
navigation: true, // Show next and prev buttons
112
navigationText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
113
slideSpeed: 300,
114
paginationSpeed: 400,
115
autoPlay: true,
116
stopOnHover: true,
117
singleItem: true,
118
afterInit: '',
119
lazyLoad: true
120
})
121
122
$('.homepage').owlCarousel({
123
navigation: false, // Show next and prev buttons
124
navigationText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
125
slideSpeed: 2000,
126
paginationSpeed: 1000,
127
autoPlay: true,
128
stopOnHover: true,
129
singleItem: true,
130
lazyLoad: false,
131
addClassActive: true,
132
afterInit: function () {
133
// animationsSlider()
134
},
135
afterMove: function () {
136
// animationsSlider()
137
}
138
})
139
}
140
}
141
142
/* menu sliding */
143
function menuSliding () {
144
$('.dropdown').on('show.bs.dropdown', function () {
145
if ($(window).width() > 750) {
146
$(this).find('.dropdown-menu').first().stop(true, true).slideDown()
147
} else {
148
$(this).find('.dropdown-menu').first().stop(true, true).show()
149
}
150
})
151
152
$('.dropdown').on('hide.bs.dropdown', function () {
153
if ($(window).width() > 750) {
154
$(this).find('.dropdown-menu').first().stop(true, true).slideUp()
155
} else {
156
$(this).find('.dropdown-menu').first().stop(true, true).hide()
157
}
158
})
159
}
160
161
/* animations */
162
function animations () {
163
var delayTime = 0
164
$('[data-animate]').css({opacity: '0'})
165
$('[data-animate]').waypoint(function () {
166
delayTime += 150
167
$(this).delay(delayTime).queue(function (next) {
168
$(this).toggleClass('animated')
169
$(this).toggleClass($(this).data('animate'))
170
delayTime = 0
171
next()
172
// $(this).removeClass('animated')
173
// $(this).toggleClass($(this).data('animate'))
174
})
175
}, {
176
offset: '90%',
177
triggerOnce: true
178
})
179
180
$('[data-animate-hover]').hover(function () {
181
$(this).css({opacity: 1})
182
$(this).addClass('animated')
183
$(this).removeClass($(this).data('animate'))
184
$(this).addClass($(this).data('animate-hover'))
185
}, function () {
186
$(this).removeClass('animated')
187
$(this).removeClass($(this).data('animate-hover'))
188
})
189
}
190
191
function animationsSlider () {
192
var delayTimeSlider = 400
193
194
$('.owl-item:not(.active) [data-animate-always]').each(function () {
195
$(this).removeClass('animated')
196
$(this).removeClass($(this).data('animate-always'))
197
$(this).stop(true, true, true).css({opacity: 0})
198
})
199
200
$('.owl-item.active [data-animate-always]').each(function () {
201
delayTimeSlider += 500
202
203
$(this).delay(delayTimeSlider).queue(function () {
204
$(this).addClass('animated')
205
$(this).addClass($(this).data('animate-always'))
206
207
console.log($(this).data('animate-always'))
208
})
209
})
210
}
211
212
/* counters */
213
function counters () {
214
$('.counter').counterUp({
215
delay: 10,
216
time: 1000
217
})
218
}
219
220
/* picture zoom */
221
function pictureZoom () {
222
$('.product .image, .post .image, .photostream div').each(function () {
223
var imgHeight = $(this).find('img').height()
224
$(this).height(imgHeight)
225
})
226
}
227
228
/* full screen intro */
229
function fullScreenContainer () {
230
var screenWidth = $(window).width() + 'px'
231
var screenHeight = '500px'
232
233
if ($(window).height() > 500) {
234
screenHeight = $(window).height() + 'px'
235
}
236
237
$('#intro, #intro .item').css({
238
width: screenWidth,
239
height: screenHeight
240
})
241
}
242
243
function utils () {
244
/* tooltips */
245
$('[data-toggle="tooltip"]').tooltip()
246
247
/* click on the box activates the radio */
248
$('#checkout').on('click', '.box.shipping-method, .box.payment-method', function () {
249
var radio = $(this).find(':radio')
250
radio.prop('checked', true)
251
})
252
253
/* click on the box activates the link in it */
254
$('.box.clickable').on('click', function () {
255
window.location = $(this).find('a').attr('href')
256
})
257
258
/* external links in new window */
259
$('.external').on('click', function (e) {
260
e.preventDefault()
261
window.open($(this).attr('href'))
262
})
263
264
/* animated scrolling */
265
$('.scroll-to, .scroll-to-top').click(function (event) {
266
var fullUrl = this.href
267
var parts = fullUrl.split('#')
268
269
if (parts.length > 1) {
270
scrollTo(fullUrl)
271
event.preventDefault()
272
}
273
})
274
275
function scrollTo (fullUrl) {
276
var parts = fullUrl.split('#')
277
var trgt = parts[1]
278
var targetOffset = $('#' + trgt).offset()
279
var targetTop = targetOffset.top - 100
280
281
if (targetTop < 0) {
282
targetTop = 0
283
}
284
285
$('html, body').animate({
286
scrollTop: targetTop
287
}, 1000)
288
}
289
}
290
291
/* product detail gallery */
292
function productDetailGallery (confDetailSwitch) {
293
$('.thumb:first').addClass('active')
294
var timer = setInterval(autoSwitch, confDetailSwitch)
295
296
$('.thumb').click(function (e) {
297
switchImage($(this))
298
clearInterval(timer)
299
timer = setInterval(autoSwitch, confDetailSwitch)
300
e.preventDefault()
301
})
302
303
$('#mainImage').hover(function () {
304
clearInterval(timer)
305
}, function () {
306
timer = setInterval(autoSwitch, confDetailSwitch)
307
})
308
309
function autoSwitch () {
310
var nextThumb = $('.thumb.active').closest('div').next('div').find('.thumb')
311
if (nextThumb.length === 0) {
312
nextThumb = $('.thumb:first')
313
}
314
switchImage(nextThumb)
315
}
316
317
function switchImage (thumb) {
318
$('.thumb').removeClass('active')
319
var bigUrl = thumb.attr('href')
320
thumb.addClass('active')
321
$('#mainImage img').attr('src', bigUrl)
322
}
323
}
324
325
/* product detail sizes */
326
function productDetailSizes () {
327
$('.sizes a').click(function (e) {
328
e.preventDefault()
329
$('.sizes a').removeClass('active')
330
$('.size-input').prop('checked', false)
331
$(this).addClass('active')
332
$(this).next('input').prop('checked', true)
333
})
334
}
335
336
$.fn.alignElementsSameHeight = function () {
337
$('.same-height-row').each(function () {
338
var maxHeight = 0
339
var children = $(this).find('.same-height')
340
children.height('auto')
341
342
if ($(window).width() > 768) {
343
children.each(function () {
344
if ($(this).innerHeight() > maxHeight) {
345
maxHeight = $(this).innerHeight()
346
}
347
})
348
children.innerHeight(maxHeight)
349
}
350
351
maxHeight = 0
352
children = $(this).find('.same-height-always')
353
children.height('auto')
354
children.each(function () {
355
if ($(this).height() > maxHeight) {
356
maxHeight = $(this).innerHeight()
357
}
358
})
359
children.innerHeight(maxHeight)
360
})
361
}
362
363
var windowWidth
364
$(function () {
365
windowWidth = $(window).width()
366
367
$(this).alignElementsSameHeight()
368
pictureZoom()
369
})
370
371
$(window).resize(function () {
372
var newWindowWidth = $(window).width()
373
374
if (windowWidth !== newWindowWidth) {
375
setTimeout(function () {
376
$(this).alignElementsSameHeight()
377
fullScreenContainer()
378
pictureZoom()
379
}, 205)
380
windowWidth = newWindowWidth
381
}
382
})
383
384