%PDF- %PDF-
| Direktori : /home/lightco1/www/lightingrepublic.com.au/templates/shaper_macro/js/ |
| Current File : /home/lightco1/www/lightingrepublic.com.au/templates/shaper_macro/js/main.js |
/**
* @package Helix3 Framework
* @author JoomShaper http://www.joomshaper.com
* @copyright Copyright (c) 2010 - 2016 JoomShaper
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
*/
// makes sure the whole site is loaded
jQuery(window).load(function() {
if (sp_preloader) {
// will first fade out the loading animation
jQuery("#preloader .load").delay(700).fadeOut();
// will fade out the whole DIV that covers the website.
jQuery("#preloader").delay(1000).fadeOut("slow");
}
})
jQuery(function($) {
$('#offcanvas-toggler').on('click', function(event){
event.preventDefault();
$('body').addClass('offcanvas');
});
$( '<div class="offcanvas-overlay"></div>' ).insertBefore( '.body-innerwrapper > .offcanvas-menu' );
//$('.offcanvas-menu').append( '<div class="offcanvas-overlay"></div>' );
$('.close-offcanvas, .offcanvas-overlay').on('click', function(event){
event.preventDefault();
$('body').removeClass('offcanvas');
});
//Mega Menu
$('.sp-megamenu-wrapper').parent().parent().css('position','static').parent().css('position', 'relative');
$('.sp-menu-full').each(function(){
$(this).parent().addClass('menu-justify');
});
//wrap bottom and footer in a div
// $("section#sp-bottom, footer#sp-footer").wrapAll('<div class="sp-bottom-footer"></div>');
// has slideshow and sub header
$(document).ready(function(){
var spHeader = $("#sp-header");
if ($('body.com-sppagebuilder #sp-page-builder .sppb-slider-wrapper').length) {
$('body').addClass('has-slideshow');
}
//has subheader
if ($('body #sp-page-title .sp-page-title.bg-image').length) {
$('body').addClass('has-sub-image');
}
// class in header
spHeader.addClass('menu-fixed-out');
});
//Slideshow height
var slideHeight = $(window).height();
$('.sppb-slider-wrapper.sppb-slider-fullwidth-wrapper .sppb-slideshow-fullwidth-item-bg').css('height',slideHeight);
$('.sppb-addon-animated-headlines .sppb-addon-animated-headlines-bg').css('height',slideHeight);
// Menu Fixed
var windowSize = $(window);
if ($('.sppb-slider-wrapper.sppb-slider-fullwidth-wrapper').length) {
console.log($(window).scrollTop());
if(windowSize.scrollTop() + windowSize.height() >= windowSize[0].outerHeight) {
var stickyNavTop = $('.sppb-slider-wrapper.sppb-slider-fullwidth-wrapper').offset().top;
}
//alert($('.sppb-slider-wrapper.sppb-slider-fullwidth-wrapper').length);
} else {
//var stickyNavTop = $('#sp-header').offset().top;
}
// $(window).scroll(function() {
// if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].outerHeight) {
// alert('test');
// } else {
// //$("span").hide();
// }
// });
var stickyNavTop = $('#sp-header').offset().top;
var stickyNav = function(){
var scrollTop = $(window).scrollTop();
if (scrollTop > stickyNavTop) {
//alert('top');
$('#sp-header').removeClass('menu-fixed-out')
.addClass('menu-fixed');
}
else
{
if($('#sp-header').hasClass('menu-fixed'))
{
$('#sp-header').removeClass('menu-fixed').addClass('menu-fixed-out');
}
}
};
stickyNav();
$(window).scroll(function() {
stickyNav();
});
//Search
$(".icon-search.search-icon").on('click', function(){
$(".searchwrapper").fadeIn(200);
$(".remove-search").delay(200).fadeIn(200);
$(".search-icon").fadeOut(200);
});
$("#search_close").on('click', function(){
$(".searchwrapper").fadeOut(200);
$(".remove-search").fadeOut(200);
$(".search-icon").delay(200).fadeIn(200);
});
// press esc to hide search
$(document).keyup(function(e) {
if (e.keyCode == 27) { // esc keycode
$(".searchwrapper").fadeOut(200);
$(".remove-search").fadeOut(200);
$(".search-icon").delay(200).fadeIn(200);
}
});
if (sp_gotop) {
// go to top
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('.scrollup').fadeIn();
} else {
$('.scrollup').fadeOut(400);
}
});
$('.scrollup').click(function () {
$("html, body").animate({
scrollTop: 0
}, 600);
return false;
});
}
//scroll animation
var lastScrollTop = 0;
$(window).scroll(function(event){
var st = $(this).scrollTop();
if (st > lastScrollTop){
$('.footer-animation').removeClass('scroll-down');
$('.footer-animation').addClass('scroll-top');
} else {
$('.footer-animation').removeClass('scroll-top');
$('.footer-animation').addClass('scroll-down');
}
lastScrollTop = st;
});
//Tooltip
$('[data-toggle="tooltip"]').tooltip();
$(document).on('click', '.sp-rating .star', function(event) {
event.preventDefault();
var data = {
'action':'voting',
'user_rating' : $(this).data('number'),
'id' : $(this).closest('.post_rating').attr('id')
};
var request = {
'option' : 'com_ajax',
'plugin' : 'helix3',
'data' : data,
'format' : 'json'
};
$.ajax({
type : 'POST',
data : request,
beforeSend: function(){
$('.post_rating .ajax-loader').show();
},
success: function (response) {
var data = $.parseJSON(response.data);
$('.post_rating .ajax-loader').hide();
if (data.status == 'invalid') {
$('.post_rating .voting-result').text('You have already rated this entry!').fadeIn('fast');
}else if(data.status == 'false'){
$('.post_rating .voting-result').text('Somethings wrong here, try again!').fadeIn('fast');
}else if(data.status == 'true'){
var rate = data.action;
$('.voting-symbol').find('.star').each(function(i) {
if (i < rate) {
$( ".star" ).eq( -(i+1) ).addClass('active');
}
});
$('.post_rating .voting-result').text('Thank You!').fadeIn('fast');
}
},
error: function(){
$('.post_rating .ajax-loader').hide();
$('.post_rating .voting-result').text('Failed to rate, try again!').fadeIn('fast');
}
});
});
});