,
sidebar = document.getElementById("sidebar");
sidebarButton.addEventListener("click", function (event) {
event.stopPropagation();
document.body.setAttribute("data-scr", window.scrollY);
document.body.style.top = "-" + window.scrollY + "px";
document.body.classList.add("menu-open");
sidebar.classList.add("reveal");
})
sidebar.addEventListener("click", function (event) {
event.stopPropagation();
})
document.body.addEventListener("click", function () {
if (document.body.classList.contains("menu-open")) {
document.body.classList.remove("menu-open");
window.scrollTo(0, document.body.getAttribute("data-scr"));
sidebar.classList.remove("reveal");
}
})
blogsky.ajax.onPollVoteBegin = function (data) {
document.getElementById("submit-vote-button-" + data.id).setAttribute("disabled", "disabled");
document.getElementById("submit-vote-button-" + data.id).classList.add("loading");
}
blogsky.ajax.onPollVoteSuccess = function (data) {
document.getElementById("poll-vote-" + data.id).innerHTML = data.data;
}
blogsky.ajax.onPollVoteFailure = function (data) {
document.getElementById("submit-vote-button-" + data.id).removeAttribute("disabled");
document.getElementById("submit-vote-button-" + data.id).classList.remove("loading");
var pollVoteErrorMessage = document.getElementById("poll-vote-error-message-" + data.id);
pollVoteErrorMessage.innerHTML = data.error;
pollVoteErrorMessage.style.display = "block";
setTimeout(function () {
pollVoteErrorMessage.style.display = "none";
}, 5000);
}
blogsky.ajax.onPollResultBegin = function (data) {
document.getElementById("poll-results-button-" + data.id).setAttribute("disabled", "disabled");
document.getElementById("poll-results-button-" + data.id).classList.add("loading");
}
blogsky.ajax.onPollResultSuccess = function (data) {
document.getElementById("poll-vote-" + data.id).style.display = "none";
document.getElementById("poll-result-" + data.id).innerHTML = data.data;
}
blogsky.ajax.onPollResultFailure = function (data) {
var pollVoteErrorMessage = document.getElementById("poll-vote-error-message-" + data.id);
pollVoteErrorMessage.innerHTML = data.error;
pollVoteErrorMessage.style.display = "block";
setTimeout(function () {
pollVoteErrorMessage.style.display = "none";
}, 5000);
}
blogsky.ajax.onPollResultComplete = function (data) {
document.getElementById("poll-results-button-" + data.id).removeAttribute("disabled");
document.getElementById("poll-results-button-" + data.id).classList.remove("loading");
}
if (window.location.href.indexOf("/post-") > -1) {
window.onscroll = function () {
var articleElement = document.querySelector(".post-box");
var currentState = document.body.scrollTop || document.documentElement.scrollTop;
var pageHeight = articleElement.scrollHeight;
// var pageHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrollStatePercentage = (currentState / pageHeight) * 100;
document.querySelector(".reading-progress").setAttribute("value", scrollStatePercentage);
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
document.querySelector(".reading-progress").setAttribute("value", 100);
}
}
}
if (document.getElementById("total-label")) {
if (/^\/\d{4}\/\d{2}\/\d{2}\/post-\d+.*/i.test(window.location.pathname)) {
document.getElementById("total-label").innerHTML = "نظر";
} else if (window.location.pathname.indexOf("/dailylink") == 0) {
document.getElementById("total-label").innerHTML = "لینک";
} else if (window.location.search.indexOf("?q=") > -1) {
document.getElementById("total-label").innerHTML = "نتیجه";
} else if (window.location.pathname == "" || window.location.pathname == "/" || window.location.pathname.indexOf("/page/") == 0 || window.location.pathname.indexOf("/posts") == 0 || window.location.pathname.indexOf("/category/") == 0 || window.location.pathname.indexOf("/tag/") == 0 || window.location.pathname.indexOf("/author/") == 0 || /^\/\d{4}(\/\d{2})?(\/\d{2})?/i.test(window.location.pathname)) {
document.getElementById("total-label").innerHTML = "یادداشت";
} else {
document.getElementById("total-label").innerHTML = "نظر";
}
}
//more
(function (global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() :
typeof define === "function" && define.amd ? define(factory) :
(global = global || self, global.shave = factory());
}(this, function () {
"use strict";
function shave(target, maxHeight) {
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (!maxHeight) throw Error("maxHeight is required");
var els = typeof target === "string" ? document.querySelectorAll(target) : target;
if (!els) return;
var character = opts.character || "…";
var classname = opts.classname || "js-shave";
var spaces = typeof opts.spaces === "boolean" ? opts.spaces : true;
var charHtml = "<span class=\"js-shave-char\">".concat(character, "</span>");
if (!("length" in els)) els = [els];
for (var i = 0; i < els.length; i += 1) {
var el = els[i];
var styles = el.style;
var span = el.querySelector(".".concat(classname));
var textProp = el.textContent === undefined ? "innerText" :
"textContent"; // If element text has already been shaved
if (span) {
el.removeChild(el.querySelector(".js-shave-char"));
el[textProp] = el[textProp];
}
var fullText = el[textProp];
var words = spaces ? fullText.split(" ") : fullText;
if (words.length < 2) continue;
var heightStyle = styles.height;
styles.height = "auto";
var maxHeightStyle = styles.maxHeight;
styles.maxHeight = "none";
if (el.offsetHeight <= maxHeight) {
styles.height = heightStyle;
styles.maxHeight = maxHeightStyle;
continue;
}
var max = words.length - 1;
var min = 0;
var pivot = void 0;
while (min < max) {
pivot = min + max + 1 >> 1;
el[textProp] = spaces ? words.slice(0, pivot).join(" ") : words.slice(0, pivot);
el.insertAdjacentHTML("beforeend", charHtml);
if (el.offsetHeight > maxHeight) max = spaces ? pivot - 1 : pivot - 2;
else min = pivot;
}
el[textProp] = spaces ? words.slice(0, max).join(" ") : words.slice(0, max);
el.insertAdjacentHTML("beforeend", charHtml);
var diff = spaces ? " ".concat(words.slice(max).join(" ")) : words.slice(max);
var shavedText = document.createTextNode(diff);
var elWithShavedText = document.createElement("span");
elWithShavedText.classList.add(classname);
elWithShavedText.style.display = "none";
elWithShavedText.appendChild(shavedText);
el.insertAdjacentElement("beforeend", elWithShavedText);
styles.height = heightStyle;
styles.maxHeight = maxHeightStyle;
}
}
return shave;
}));
shave(".collapsable", 25, { character: "<button class=\"btn btn-sm btn-link p-0 mr-1 d-inline\" style=\"cursor:pointer\"><small>ادامه...<small></button>" });
document.querySelector(".collapsable").addEventListener("click", function () {
if (this.querySelector(".js-shave")) {
this.querySelector(".js-shave-char").remove();
this.textContent += this.querySelector(".js-shave").textContent;
}
});
//Parallax
(function (n, h) { "function" === typeof define && define.amd ? define([], h) : "object" === typeof module && module.exports ? module.exports = h() : n.Rellax = h() })("undefined" !== typeof window ? window : global, function () {
var n = function (h, p) {
var a = Object.create(n.prototype), l = 0, r = 0, k = 0, t = 0, c = [], u = !0, B = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || window.oRequestAnimationFrame || function (a) { return setTimeout(a, 1E3 / 60) }, q = null, C = window.cancelAnimationFrame ||
window.mozCancelAnimationFrame || clearTimeout, D = window.transformProp || function () { var a = document.createElement("div"); if (null === a.style.transform) { var b = ["Webkit", "Moz", "ms"], e; for (e in b) if (void 0 !== a.style[b[e] + "Transform"]) return b[e] + "Transform" } return "transform" }(); a.options = { speed: -2, center: !1, wrapper: null, relativeToWrapper: !1, round: !0, vertical: !0, horizontal: !1, callback: function () { } }; p && Object.keys(p).forEach(function (d) { a.options[d] = p[d] }); h || (h = ".rellax"); var m = "string" === typeof h ? document.querySelectorAll(h) :
[h]; if (0 < m.length) {
a.elems = m; if (a.options.wrapper && !a.options.wrapper.nodeType) if (m = document.querySelector(a.options.wrapper)) a.options.wrapper = m; else { console.warn("Rellax: The wrapper you)
= c[b].max ? c[b].max : e), a.options.horizontal && !a.options.vertical && (g = g >= c[b].max ? c[b].max : g)); a.elems[b].style[D] = "translate3d(" + (a.options.horizontal ? g : "0") + "px," + (a.options.vertical ? e : "0") + "px," + c[b].zindex +
"px) " + c[b].transform
} a.options.callback(d)
}; a.destroy = function () { for (var d = 0; d < a.elems.length; d++)a.elems[d].style.cssText = c[d].style; u || (window.removeEventListener("resize", w), u = !0); C(q); q = null }; w(); A(); a.refresh = w; return a
} console.warn("Rellax: The elements you're trying to select don't exist.")
}; return n
});
new Rellax(".rellax");