/** * Engine Preloader Page * */ (function($, undefined){ if (show_preloader == 'show') { if (show_ajax_load == 'hide') { $('#preloader').show() //start animation bar var t = 0; function ani_step2(){ var step = ~~(0.5,Math.random()*25) step = t>85?1:step t = t+step<100?t+step:100 $('#persent-loader').html(t+'%') $('#progress-line').width(t+'%') if(t<100) { setTimeout(ani_step2, 40) } else { $('#preloader').animate({width: 'hide'}, 200, function() {/*add + 100% and complete*/} ); } } ani_step2() //end animation bar } } jQuery(document).ready(function(){ function ChangeContentNow(a){ $('style[data-type="vc_shortcodes-custom-css"]').html($("", {"html":a}).find('style[data-type="vc_shortcodes-custom-css"]').html()) $("#primary-content").html($("
", {"html":a}).find('#primary-content').html()) } function StartPreloaderNow(a){ //start animation bar var t = 0; function ani_step(){ var step = ~~(0.5,Math.random()*35) step = t>85?1:step t = t+step<100?t+step:100 $('#persent-loader').html(t+'%') $('#progress-line').width(t+'%') if(t<100) { setTimeout(ani_step, 40) } else { $('#preloader').animate({width: 'hide'}, 200, function() {/*add + 100% and complete*/} ); ChangeContentNow(a); } } ani_step() //end animation bar } if (show_ajax_load == 'show') { $(".primary-navigation a").click(function(){ var href = $(this).attr('href'); var title = $(this).html(); history.pushState({}, title, href); var url = $(this).attr("href") + '?ajax=true' $.ajax({ url:url, cache:false, beforeSend:function(){ $('style[data-type="vc_shortcodes-custom-css"]').html("") $('#persent-loader').html('0%') $('#progress-line').width('0%') $('#preloader').show() $("#primary-content").html("") }, success:function(a){ if (show_preloader == 'show') {StartPreloaderNow(a);} else {ChangeContentNow(a);} }, complete:function(){ complete_ajax = true; } }); return false; }); } else { //only preload } }); } )( jQuery );