313 lines
9.8 KiB
JavaScript
313 lines
9.8 KiB
JavaScript
|
$(function () {
|
||
|
|
||
|
utils();
|
||
|
|
||
|
|
||
|
$("ul.dropdown-menu [data-toggle='dropdown']").on("click", function (event) {
|
||
|
event.preventDefault();
|
||
|
event.stopPropagation();
|
||
|
|
||
|
$(this).siblings().toggleClass("show");
|
||
|
|
||
|
|
||
|
if (!$(this).next().hasClass('show')) {
|
||
|
$(this).parents('.dropdown-menu').first().find('.show').removeClass("show");
|
||
|
}
|
||
|
$(this).parents('li.nav-item.dropdown.show').on('hidden.bs.dropdown', function (e) {
|
||
|
$('.dropdown-submenu .show').removeClass("show");
|
||
|
});
|
||
|
|
||
|
});
|
||
|
|
||
|
|
||
|
$('i.delete').on('click', function () {
|
||
|
$(this).parents('.item').fadeOut();
|
||
|
});
|
||
|
|
||
|
|
||
|
// ------------------------------------------------------- //
|
||
|
// Open & Close Search Panel
|
||
|
// ------------------------------------------------------ //
|
||
|
$('.search').on('click', function () {
|
||
|
$('.search-area').fadeIn();
|
||
|
});
|
||
|
|
||
|
$('.search-area .close-btn').on('click', function () {
|
||
|
$('.search-area').fadeOut();
|
||
|
});
|
||
|
|
||
|
|
||
|
// ------------------------------------------------------- //
|
||
|
// Items Carousel
|
||
|
// ------------------------------------------------------ //
|
||
|
$('.items-slider').owlCarousel({
|
||
|
loop: true,
|
||
|
items: 1,
|
||
|
thumbs: true,
|
||
|
thumbsPrerendered: true,
|
||
|
dots: false,
|
||
|
responsiveClass: false
|
||
|
});
|
||
|
|
||
|
|
||
|
// ------------------------------------------------------- //
|
||
|
// Increase/Reduce product amount
|
||
|
// ------------------------------------------------------ //
|
||
|
$('.dec-btn').click(function () {
|
||
|
// var siblings = $(this).siblings('input.quantity-no');
|
||
|
// if (parseInt(siblings.val(), 10) >= 1) {
|
||
|
// siblings.val(parseInt(siblings.val(), 10) - 1);
|
||
|
// }
|
||
|
});
|
||
|
|
||
|
$('.inc-btn').click(function () {
|
||
|
// var siblings = $(this).siblings('input.quantity-no');
|
||
|
// siblings.val(parseInt(siblings.val(), 10) + 1);
|
||
|
});
|
||
|
|
||
|
// ------------------------------------------------------- //
|
||
|
// Scroll to top button
|
||
|
// ------------------------------------------------------ //
|
||
|
// Scroll to top button
|
||
|
$(window).on('scroll', function () {
|
||
|
if ($(window).scrollTop() >= 1500) {
|
||
|
$('#scrollTop').fadeIn();
|
||
|
} else {
|
||
|
$('#scrollTop').fadeOut();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
|
||
|
$('#scrollTop').on('click', function () {
|
||
|
$('html, body').animate({ scrollTop: 0 }, 1000);
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
// ------------------------------------------------------- //
|
||
|
// Bootstrap select
|
||
|
// ------------------------------------------------------ //
|
||
|
$('.bs-select').selectpicker({
|
||
|
size: 4
|
||
|
});
|
||
|
|
||
|
|
||
|
// ------------------------------------------------------- //
|
||
|
// Hero Slider
|
||
|
// ------------------------------------------------------ //
|
||
|
var owl = $('.hero-slider');
|
||
|
owl.owlCarousel({
|
||
|
loop: true,
|
||
|
margin: 0,
|
||
|
smartSpeed: 500,
|
||
|
responsiveClass: true,
|
||
|
autoplay: true,
|
||
|
autoplayHoverPause: true,
|
||
|
navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
|
||
|
responsive: {
|
||
|
0: {
|
||
|
items: 1,
|
||
|
nav: false,
|
||
|
dots: true
|
||
|
},
|
||
|
600: {
|
||
|
items: 1,
|
||
|
nav: false,
|
||
|
dots: true
|
||
|
},
|
||
|
1120: {
|
||
|
items: 1,
|
||
|
dots: false,
|
||
|
nav: true
|
||
|
}
|
||
|
},
|
||
|
onRefresh: function () {
|
||
|
owl.find('.item').height('');
|
||
|
},
|
||
|
onRefreshed: function () {
|
||
|
var maxHeight = 0;
|
||
|
var items = owl.find('.item');
|
||
|
items.each(function () {
|
||
|
var itemHeight = $(this).height();
|
||
|
if (itemHeight > maxHeight) {
|
||
|
maxHeight = itemHeight;
|
||
|
}
|
||
|
});
|
||
|
items.height(maxHeight);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// ------------------------------------------------------- //
|
||
|
// Products Slider
|
||
|
// ------------------------------------------------------ //
|
||
|
$('.products-slider').owlCarousel({
|
||
|
loop: false,
|
||
|
margin: 20,
|
||
|
dots: true,
|
||
|
nav: false,
|
||
|
smartSpeed: 400,
|
||
|
responsiveClass: true,
|
||
|
navText: ['<i class="fa fa-long-arrow-left"></i>', '<i class="fa fa-long-arrow-right"></i>'],
|
||
|
responsive: {
|
||
|
0: {
|
||
|
items: 1
|
||
|
},
|
||
|
600: {
|
||
|
items: 2
|
||
|
},
|
||
|
1000: {
|
||
|
items: 4
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// ------------------------------------------------------- //
|
||
|
// Brands Slider
|
||
|
// ------------------------------------------------------ //
|
||
|
$('.brands-slider').owlCarousel({
|
||
|
loop: true,
|
||
|
margin: 20,
|
||
|
dots: true,
|
||
|
nav: false,
|
||
|
smartSpeed: 400,
|
||
|
responsiveClass: true,
|
||
|
responsive: {
|
||
|
0: {
|
||
|
items: 2
|
||
|
},
|
||
|
600: {
|
||
|
items: 3
|
||
|
},
|
||
|
1000: {
|
||
|
items: 6,
|
||
|
loop: false
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// ------------------------------------------------------- //
|
||
|
// Google Maps
|
||
|
// ------------------------------------------------------ //
|
||
|
if ($('#map').length > 0) {
|
||
|
|
||
|
|
||
|
function initMap() {
|
||
|
|
||
|
var location = new google.maps.LatLng(50.0875726, 14.4189987);
|
||
|
|
||
|
var mapCanvas = document.getElementById('map');
|
||
|
var mapOptions = {
|
||
|
center: location,
|
||
|
zoom: 16,
|
||
|
panControl: false,
|
||
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||
|
}
|
||
|
var map = new google.maps.Map(mapCanvas, mapOptions);
|
||
|
|
||
|
var markerImage = 'img/marker.png';
|
||
|
|
||
|
var marker = new google.maps.Marker({
|
||
|
position: location,
|
||
|
map: map,
|
||
|
icon: markerImage
|
||
|
});
|
||
|
|
||
|
var contentString = '<div class="info-window">' +
|
||
|
'<h3>Info Window Content</h3>' +
|
||
|
'<div class="info-content">' +
|
||
|
'<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>' +
|
||
|
'</div>' +
|
||
|
'</div>';
|
||
|
|
||
|
var infowindow = new google.maps.InfoWindow({
|
||
|
content: contentString,
|
||
|
maxWidth: 400
|
||
|
});
|
||
|
|
||
|
marker.addListener('click', function () {
|
||
|
infowindow.open(map, marker);
|
||
|
});
|
||
|
|
||
|
var styles = [{ "featureType": "landscape", "stylers": [{ "saturation": -100 }, { "lightness": 65 }, { "visibility": "on" }] }, { "featureType": "poi", "stylers": [{ "saturation": -100 }, { "lightness": 51 }, { "visibility": "simplified" }] }, { "featureType": "road.highway", "stylers": [{ "saturation": -100 }, { "visibility": "simplified" }] }, { "featureType": "road.arterial", "stylers": [{ "saturation": -100 }, { "lightness": 30 }, { "visibility": "on" }] }, { "featureType": "road.local", "stylers": [{ "saturation": -100 }, { "lightness": 40 }, { "visibility": "on" }] }, { "featureType": "transit", "stylers": [{ "saturation": -100 }, { "visibility": "simplified" }] }, { "featureType": "administrative.province", "stylers": [{ "visibility": "off" }] }, { "featureType": "water", "elementType": "labels", "stylers": [{ "visibility": "on" }, { "lightness": -25 }, { "saturation": -100 }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "hue": "#ffff00" }, { "lightness": -25 }, { "saturation": -97 }] }];
|
||
|
|
||
|
map.set('styles', styles);
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
google.maps.event.addDomListener(window, 'load', initMap);
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
// ------------------------------------------------------ //
|
||
|
// For demo purposes, can be deleted
|
||
|
// ------------------------------------------------------ //
|
||
|
|
||
|
var stylesheet = $('link#theme-stylesheet');
|
||
|
$("<link id='new-stylesheet' rel='stylesheet'>").insertAfter(stylesheet);
|
||
|
var alternateColour = $('link#new-stylesheet');
|
||
|
|
||
|
if ($.cookie("theme_csspath")) {
|
||
|
alternateColour.attr("href", $.cookie("theme_csspath"));
|
||
|
}
|
||
|
|
||
|
$("#colour").change(function () {
|
||
|
|
||
|
if ($(this).val() !== '') {
|
||
|
|
||
|
var theme_csspath = 'css/style.' + $(this).val() + '.css';
|
||
|
|
||
|
alternateColour.attr("href", theme_csspath);
|
||
|
|
||
|
$.cookie("theme_csspath", theme_csspath, { expires: 365, path: document.URL.substr(0, document.URL.lastIndexOf('/')) });
|
||
|
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
});
|
||
|
|
||
|
function utils() {
|
||
|
|
||
|
/* click on the box activates the link in it */
|
||
|
|
||
|
$('.box.clickable').on('click', function (e) {
|
||
|
|
||
|
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 full_url = this.href;
|
||
|
var parts = full_url.split("#");
|
||
|
if (parts.length > 1) {
|
||
|
|
||
|
scrollTo(full_url);
|
||
|
event.preventDefault();
|
||
|
}
|
||
|
});
|
||
|
function scrollTo(full_url) {
|
||
|
var parts = full_url.split("#");
|
||
|
var trgt = parts[1];
|
||
|
var target_offset = $("#" + trgt).offset();
|
||
|
var target_top = target_offset.top - 100;
|
||
|
if (target_top < 0) {
|
||
|
target_top = 0;
|
||
|
}
|
||
|
|
||
|
$('html, body').animate({
|
||
|
scrollTop: target_top
|
||
|
}, 1000);
|
||
|
}
|
||
|
}
|