/ajax/
$(document).ready(function(){
$('.carousel').carousel(); $('.carousel.carousel-slider').carousel({fullWidth: true});
});
$(document).ready(function () {
var SingleBlogPostHeadingSystem = function () { var title = "", slug = ""; var n = 0; for (var i = 1; i < 7; i++) { $("#postWithLeft h" + i).each(function () { // get title and sting limite title = $(this).text().substring(0, 20); slug = "#" + title.replace(/[^\w ]+/g, '').replace(/ +/g, '-') + "-" + i + n; /* id set header tag */ // $("#postWithLeft h" + i ).attr('id', slug); $(this).attr('id', slug); // append $("#postWithRight ul").append('<li class="collection-item"><a href="' + slug + '">' + title + '</a></li>'); n++; }); n = 0; } }; $previousUrl=""; var blogPostLoadFunction = function (e) { try { var postPermalink = window.location.href; var postPermalink = postPermalink/*.split('#').pop()*/.split('?').pop(); var postPermalink = postPermalink.split('#'); var postPermalink = postPermalink[0].split('='); previousUrl = postPermalink[1]; if (postPermalink[0] == "post") { //var postPermalink = "/{{ page.path | split: '/' | first }}/" + postPermalink[1]; postPermalink= postPermalink[1]; $("#blogArticle").load(postPermalink, function (response, status, xhr) { if (status == "error") { var msg = "Sorry but there was an error: "; $('nav[data-target="blogPosts"]').removeAttr("style"); $("#dianamicContent").hide(); // hide body all selection $("#blogPosts, footer.page-footer").show(); var $toastContent = $('<span>' + xhr.status + " " + xhr.statusText + '</span>') .add($('<a href="" class="btn-flat toast-action">Try Agin</a>')); //error masage if (xhr.status) { $toastContent = $('<span>' + "Post " + " " + xhr.statusText + '</span>'); Materialize.toast($toastContent, 6000); } else { Materialize.toast($toastContent, 10000); } } else { $("#dianamicContent").show(); // hide body all selection $("#blogPosts, footer.page-footer").hide(); // alert( "Load was performed." ); // display post content $("#dianamicContent").show(); // hide body all selection /* $("#blogPosts").addClass("hide"); $("footer.page-footer").addClass("hide");*/ $('#blogArticle pre code').each(function (i, block) { hljs.highlightBlock(block); }); $("body").addClass("view-post"); SingleBlogPostHeadingSystem(); } }); } } catch (e) { Materialize.toast("Problem on loding funtion", 4000); } }; var reload = true; // blogPostLoadFunction furntion run when page load or visite $("body").one("click mouseover", function (event) { blogPostLoadFunction(); reload = false; }); jQuery('body').click(); // blogPostLoadFunction furntion run when url change if (reload) { $(window).on('hashchange', function () { blogPostLoadFunction(); reload = false; }); }
});
$(function () {
$('.mainSlider').each(function () { var $this = $(this); var $target = $('#' + $(this).attr('data-target')); $this.pushpin({ top: $target.offset().top, bottom: $target.offset().top + $target.outerHeight() - $this.height() }); });
});
//initial pushpin metarialze $('nav').pushpin({
top: 0, bottom: 1000, offset: 0
});
$(document).ready(function(){
$('nav[data-target="blogPosts"]').each(function() { var $this = $(this); var $target = $('#' + $(this).attr('data-target')); $this.pushpin({ top: $target.offset().top, bottom: $target.offset().top + $target.outerHeight() - $this.height() }); });
});
//single post's body colapse $(function () {
$("#lPostBtnLarge").on("click", function () { $("#postWithRight").fadeOut("fast"); $("#postWithLeft").removeClass("m9"); $(this).hide(); $("#lPostBtnSamll").show(); }); $("#lPostBtnSamll").on("click", function () { $("#postWithRight").fadeIn("fast"); $("#postWithLeft").addClass("m9"); $(this).hide(); $("#lPostBtnLarge").show() });
});
$(function () {
$("#back2blog").on("click", function (e) { $("#dianamicContent").hide(); // hide body all selection $("#blogPosts, footer.page-footer").show(); jQuery('#blogArticle').html(''); //remove post meta tag $('meta[name="keywords]').remove(); $("body").removeClass("view-post"); $("#spinkit").show().delay(200).fadeOut(); $('nav[data-target="blogPosts"]').each(function () { var $this = $(this); var $target = $('#' + $(this).attr('data-target')); $this.pushpin({ top: $target.offset().top, bottom: $target.offset().top + $target.outerHeight() - $this.height() }); }); window.history.replaceState({}, document.title, "/" ); e.preventDefault(); });
});