123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406 |
- /* global $this: true */
- /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "animationsSlider" }] */
- if ($.cookie('themeCSSpath')) {
- $('link#theme-stylesheet').attr('href', $.cookie('themeCSSpath'))
- }
- if ($.cookie('themeLayout')) {
- $('body').addClass($.cookie('themeLayout'))
- }
- // test
- $(function () {
- sliderHomepage()
- sliders()
- fullScreenContainer()
- productDetailGallery(4000)
- menuSliding()
- productDetailSizes()
- utils()
- animations()
- counters()
- demo()
- contactFormAjax()
- getVtuber()
- })
- // Ajax contact
- function contactFormAjax () {
- var form = $('.contact-form-ajax')
- if (typeof form === 'undefined') return false
- form.submit(function () {
- $this = $(this)
- $.post($(this).attr('action'),
- $this.serialize(),
- function () {
- $this[0].reset() // clear form
- $('#contact-message')
- .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>')
- .fadeIn()
- }
- , 'json')
- return false
- })
- }
- /* for demo purpose only - can be deleted */
- function demo () {
- if ($.cookie('themeCSSpath')) {
- $('link#theme-stylesheet').attr('href', $.cookie('themeCSSpath'))
- }
- $('#colour').change(function () {
- if ($(this).val() !== '') {
- var themeCSSpath = 'css/style.' + $(this).val() + '.css'
- $('link#theme-stylesheet').attr('href', themeCSSpath)
- $.cookie('themeCSSpath', themeCSSpath, {expires: 365, path: '/'})
- }
- return false
- })
- $('#layout').change(function () {
- if ($(this).val() !== '') {
- var themeLayout = $(this).val()
- $('body').removeClass('wide')
- $('body').removeClass('boxed')
- $('body').addClass(themeLayout)
- $.cookie('themeLayout', themeLayout, {expires: 365, path: '/'})
- }
- return false
- })
- }
- /* slider homepage */
- function sliderHomepage () {
- if ($('#slider').length) {
- // var owl = $('#slider')
- $('#slider').owlCarousel({
- autoPlay: 3000,
- items: 4,
- itemsDesktopSmall: [900, 3],
- itemsTablet: [600, 3],
- itemsMobile: [500, 2]
- })
- }
- }
- /* sliders */
- function sliders () {
- if ($('.owl-carousel').length) {
- console.log("pass");
- $('.customers').owlCarousel({
- items: 6,
- itemsDesktopSmall: [990, 4],
- itemsTablet: [768, 2],
- itemsMobile: [480, 1]
- })
- $('.testimonials').owlCarousel({
- items: 4,
- itemsDesktopSmall: [990, 3],
- itemsTablet: [768, 2],
- itemsMobile: [480, 1]
- })
- $('.project').owlCarousel({
- navigation: true, // Show next and prev buttons
- navigationText: ['<i class="fas fa-angle-left"></i>', '<i class="fas fa-angle-right"></i>'],
- dots: false,
- slideSpeed: 300,
- paginationSpeed: 400,
- autoPlay: true,
- stopOnHover: true,
- singleItem: true,
- afterInit: '',
- lazyLoad: true
- })
- $(".eu-vtuber").owlCarousel({
- navigation: true, // Show next and prev buttons
- navigationText: ['<i class="fas fa-angle-left"></i>', '<i class="fas fa-angle-right"></i>'],
- dots: false,
- slideSpeed: 300,
- paginationSpeed: 400,
- autoPlay: true,
- stopOnHover: true,
- singleItem: true,
- afterInit: '',
- lazyLoad: true
- })
- $('.homepage').owlCarousel({
- navigation: false, // Show next and prev buttons
- margin: 10,
- navigationText: ['<i class="fas fa-angle-left"></i>', '<i class="fas fa-angle-right"></i>'],
- slideSpeed: 2000,
- paginationSpeed: 1000,
- autoPlay: true,
- stopOnHover: true,
- singleItem: true,
- lazyLoad: false,
- addClassActive: true,
- afterInit: function () {
- // animationsSlider()
- },
- afterMove: function () {
- // animationsSlider()
- }
- })
- }
- }
- /* menu sliding */
- function menuSliding () {
- $('.dropdown').on('show.bs.dropdown', function () {
- if ($(window).width() > 750) {
- $(this).find('.dropdown-menu').first().stop(true, true).slideDown()
- } else {
- $(this).find('.dropdown-menu').first().stop(true, true).show()
- }
- })
- $('.dropdown').on('hide.bs.dropdown', function () {
- if ($(window).width() > 750) {
- $(this).find('.dropdown-menu').first().stop(true, true).slideUp()
- } else {
- $(this).find('.dropdown-menu').first().stop(true, true).hide()
- }
- })
- }
- /* animations */
- function animations () {
- var delayTime = 0
- $('[data-animate]').css({opacity: '0'})
- $('[data-animate]').waypoint(function () {
- delayTime += 150
- $(this).delay(delayTime).queue(function (next) {
- $(this).toggleClass('animated')
- $(this).toggleClass($(this).data('animate'))
- delayTime = 0
- next()
- // $(this).removeClass('animated')
- // $(this).toggleClass($(this).data('animate'))
- })
- }, {
- offset: '90%',
- triggerOnce: true
- })
- $('[data-animate-hover]').hover(function () {
- $(this).css({opacity: 1})
- $(this).addClass('animated')
- $(this).removeClass($(this).data('animate'))
- $(this).addClass($(this).data('animate-hover'))
- }, function () {
- $(this).removeClass('animated')
- $(this).removeClass($(this).data('animate-hover'))
- })
- }
- function animationsSlider () {
- var delayTimeSlider = 400
- $('.owl-item:not(.active) [data-animate-always]').each(function () {
- $(this).removeClass('animated')
- $(this).removeClass($(this).data('animate-always'))
- $(this).stop(true, true, true).css({opacity: 0})
- })
- $('.owl-item.active [data-animate-always]').each(function () {
- delayTimeSlider += 500
- $(this).delay(delayTimeSlider).queue(function () {
- $(this).addClass('animated')
- $(this).addClass($(this).data('animate-always'))
- console.log($(this).data('animate-always'))
- })
- })
- }
- /* counters */
- function counters () {
- $('.counter').counterUp({
- delay: 10,
- time: 1000
- })
- }
- /* picture zoom */
- function pictureZoom () {
- $('.product .image, .post .image, .photostream div').each(function () {
- var imgHeight = $(this).find('img').height()
- if (imgHeight) {
- $(this).height(imgHeight)
- }
- })
- }
- /* full screen intro */
- function fullScreenContainer () {
- var screenWidth = $(window).width() + 'px'
- var screenHeight = '500px'
- if ($(window).height() > 500) {
- screenHeight = $(window).height() + 'px'
- }
- $('#intro, #intro .item').css({
- width: screenWidth,
- height: screenHeight
- })
- }
- function utils () {
- /* tooltips */
- $('[data-toggle="tooltip"]').tooltip()
- /* click on the box activates the radio */
- $('#checkout').on('click', '.box.shipping-method, .box.payment-method', function () {
- var radio = $(this).find(':radio')
- radio.prop('checked', true)
- })
- /* click on the box activates the link in it */
- $('.box.clickable').on('click', function () {
- window.location = $(this).find('a').attr('href')
- })
- /* external links in new window */
- $('.external').on('click', function (e) {
- e.preventDefault()
- window.open($(this).attr('href'))
- })
- /* animated scrolling */
- $('.scroll-to, .scroll-to-top').click(function (event) {
- var fullUrl = this.href
- var parts = fullUrl.split('#')
- if (parts.length > 1) {
- scrollTo(fullUrl)
- event.preventDefault()
- }
- })
- function scrollTo (fullUrl) {
- var parts = fullUrl.split('#')
- var trgt = parts[1]
- var targetOffset = $('#' + trgt).offset()
- var targetTop = targetOffset.top - 100
- if (targetTop < 0) {
- targetTop = 0
- }
- $('html, body').animate({
- scrollTop: targetTop
- }, 1000)
- }
- }
- /* product detail gallery */
- function productDetailGallery (confDetailSwitch) {
- $('.thumb:first').addClass('active')
- var timer = setInterval(autoSwitch, confDetailSwitch)
- $('.thumb').click(function (e) {
- switchImage($(this))
- clearInterval(timer)
- timer = setInterval(autoSwitch, confDetailSwitch)
- e.preventDefault()
- })
- $('#mainImage').hover(function () {
- clearInterval(timer)
- }, function () {
- timer = setInterval(autoSwitch, confDetailSwitch)
- })
- function autoSwitch () {
- var nextThumb = $('.thumb.active').closest('div').next('div').find('.thumb')
- if (nextThumb.length === 0) {
- nextThumb = $('.thumb:first')
- }
- switchImage(nextThumb)
- }
- function switchImage (thumb) {
- $('.thumb').removeClass('active')
- var bigUrl = thumb.attr('href')
- thumb.addClass('active')
- $('#mainImage img').attr('src', bigUrl)
- }
- }
- /* product detail sizes */
- function productDetailSizes () {
- $('.sizes a').click(function (e) {
- e.preventDefault()
- $('.sizes a').removeClass('active')
- $('.size-input').prop('checked', false)
- $(this).addClass('active')
- $(this).next('input').prop('checked', true)
- })
- }
- $.fn.alignElementsSameHeight = function () {
- $('.same-height-row').each(function () {
- var maxHeight = 0
- var children = $(this).find('.same-height')
- children.height('auto')
- if ($(window).width() > 768) {
- children.each(function () {
- if ($(this).innerHeight() > maxHeight) {
- maxHeight = $(this).innerHeight()
- }
- })
- children.innerHeight(maxHeight)
- }
- maxHeight = 0
- children = $(this).find('.same-height-always')
- children.height('auto')
- children.each(function () {
- if ($(this).height() > maxHeight) {
- maxHeight = $(this).innerHeight()
- }
- })
- children.innerHeight(maxHeight)
- })
- }
- var windowWidth
- $(function () {
- windowWidth = $(window).width()
- $(this).alignElementsSameHeight()
- pictureZoom()
- })
- $(window).resize(function () {
- var newWindowWidth = $(window).width()
- if (windowWidth !== newWindowWidth) {
- setTimeout(function () {
- $(this).alignElementsSameHeight()
- fullScreenContainer()
- pictureZoom()
- }, 205)
- windowWidth = newWindowWidth
- }
- });
|