From 010f2f01350ca2494a6bde55193ed86c09c9aa47 Mon Sep 17 00:00:00 2001 From: Eduardo Gomez Date: Mon, 22 Jun 2020 22:21:56 +0200 Subject: [PATCH] Make post images zoomable only if the parent is not an anchor --- assets/js/app.js | 2 +- assets/js/helpers.js | 2 +- assets/js/home.js | 2 +- assets/js/page.js | 2 +- assets/js/post.js | 2 +- locales/fa.json | 94 ++++++++++++++++++++++---------------------- package.json | 2 +- src/js/helpers.js | 31 +++++++++++++++ src/js/page.js | 33 +++------------- src/js/post.js | 28 ++----------- 10 files changed, 93 insertions(+), 105 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 3938e39..ef57c39 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{1:function(e,t,n){"use strict";n.r(t),n.d(t,"isRTL",(function(){return a})),n.d(t,"isMobile",(function(){return o})),n.d(t,"isDarkMode",(function(){return i})),n.d(t,"formatDate",(function(){return s})),n.d(t,"getParameterByName",(function(){return c})),n.d(t,"makeImagesZoomable",(function(){return r}));var a=function(){var e=document.querySelector("html");return["ar","he","fa"].includes(e.getAttribute("lang"))},o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},i=function(){var e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return e&&e.matches},s=function(e){return e?new Date(e).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},c=function(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]".concat(e,"(=([^&#]*)|&|#|$)")).exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},r=function(e,t){var n=t(".js-zoomable");n.on("open",(function(t){o()&&e(t.target).parent().hasClass("kg-gallery-image")&&setTimeout((function(){var t=e(".medium-zoom-image--opened"),n=t[0].style.transform,a=n.substr(0,n.indexOf(" ")),o=parseFloat(a.substr(a.indexOf("(")+1).split(")")[0]),i=n.substr(n.indexOf(" ")+1),s=parseFloat(i.split(",")[1]),c="scale(1) translate3d(0, ".concat(s<0?o*s+s:o*s-s,"px, 0)");t.addClass("medium-zoom-image-mobile"),t[0].style.transform=c}),10)})),n.on("close",(function(){o()&&e(event.target).parent().hasClass("kg-gallery-image")&&e(".medium-zoom-image").removeClass("medium-zoom-image-mobile")}))}},16:function(e,t,n){e.exports=n(17)},17:function(e,t,n){"use strict";n.r(t);var a=n(13),o=n(0),i=n.n(o),s=n(8),c=n.n(s),r=n(9),l=n.n(r),d=(n(6),n(7)),u=n(2),m=n(11),h=n.n(m),f=n(12),g=n.n(f),p=n(1);Object(a.a)({}),i()(document).ready((function(){Object(p.isRTL)()&&i()("html").attr("dir","rtl").addClass("rtl");var e=i()("body"),t=i()(".js-header"),n=i()(".js-open-menu"),a=i()(".js-close-menu"),o=i()(".js-menu"),s=i()(".js-toggle-submenu"),r=i()(".js-submenu-option")[0],m=i()(".js-submenu"),f=i()(".js-recent-articles"),b=i()(".js-open-secondary-menu"),v=i()(".js-open-search"),j=i()(".js-close-search"),w=i()(".js-search"),k=i()(".js-input-search"),C=i()(".js-search-results"),y=i()(".js-no-results"),O=i()(".js-toggle-darkmode"),x=i()(".js-notification-close"),M=localStorage.getItem("theme"),S=null,_=!1,L=null;function T(){t.removeClass("submenu-is-active"),s.removeClass("active"),m.removeClass("opened").addClass("closed")}function z(){e.toggleClass("no-scroll-y")}var A,D,I,F,P,R,B,E=function(e){var t=i()('.js-alert[data-notification="'.concat(e,'"]'));t.addClass("opened"),setTimeout((function(){H(t)}),5e3)},H=function(e){e.removeClass("opened");var t=window.location.toString();if(t.indexOf("?")>0){var n=t.substring(0,t.indexOf("?"));window.history.replaceState({},document.title,n)}};(n.click((function(){t.addClass("mobile-menu-opened"),o.addClass("opened"),z()})),a.click((function(){t.removeClass("mobile-menu-opened"),o.removeClass("opened"),z()})),s.click((function(){(_=!_)?(t.addClass("submenu-is-active"),s.addClass("active"),m.removeClass("closed").addClass("opened")):T()})),v.click((function(){w.addClass("opened"),setTimeout((function(){k.focus()}),400),z()})),j.click((function(){k.blur(),w.removeClass("opened"),z()})),k.keyup((function(){if(k.val().length>0&&S){var e=S.search(k.val()),t="";if(e.length>0){for(var n=0,a=e.length;n

').concat(e[n].title,'

').concat(Object(p.formatDate)(e[n].published_at),"
");y.hide(),C.html(t),C.show()}else C.html(""),C.hide(),y.show()}else C.html(""),C.hide(),y.hide()})),O.change((function(){O.is(":checked")?(i()("html").attr("data-theme","dark"),localStorage.setItem("theme","dark")):(i()("html").attr("data-theme","light"),localStorage.setItem("theme","light"))})),x.click((function(){H(i()(this).parent())})),i()(window).click((function(e){_&&r&&!r.contains(e.target)&&(_=!1,T())})),M?(i()("html").attr("data-theme",M),"dark"===M&&O.attr("checked",!0)):Object(p.isDarkMode)()&&O.attr("checked",!0),t.length>0)&&new l.a(t[0],{tolerance:{down:10,up:20},offset:15,onUnpin:function(){if(!Object(p.isMobile)()&&L){var e=L[0];e&&e.state.isVisible&&e.hide()}}}).init();if(f.length>0&&(f.on("init",(function(){Object(u.a)(".js-recent-article-title",50)})),f.slick({adaptiveHeight:!0,arrows:!1,infinite:!1,mobileFirst:!0,variableWidth:!0,rtl:Object(p.isRTL)()})),"undefined"!=typeof disableFadeAnimation&&disableFadeAnimation?i()("[data-aos]").addClass("no-aos-animation"):h.a.init({once:!0,startEvent:"DOMContentLoaded"}),c()(".lozad",{loaded:function(e){e.classList.add("loaded")}}).observe(),b.length>0){var N=document.getElementById("secondary-navigation-template");L=Object(d.a)(".js-open-secondary-menu",{content:N.innerHTML,arrow:!0,trigger:"click",interactive:!0})}Object(d.a)(".js-tooltip"),Object(u.a)(".js-article-card-title",100),Object(u.a)(".js-article-card-title-no-image",250),A=Object(p.getParameterByName)("action"),D=Object(p.getParameterByName)("stripe"),"subscribe"===A&&E("subscribe"),"signup"===A&&(window.location="".concat(ghostHost,"/signup/?action=checkout")),"checkout"===A&&E("signup"),"signin"===A&&E("signin"),"success"===D&&E("checkout"),"undefined"!=typeof ghostSearchApiKey?(I=ghostHost,F=ghostSearchApiKey,P=new GhostContentAPI({url:I,key:F,version:"v2"}),R=[],B={shouldSort:!0,threshold:0,location:0,distance:100,tokenize:!0,matchAllTokens:!1,maxPatternLength:32,minMatchCharLength:1,keys:["title","custom_excerpt","html"]},P.posts.browse({limit:"all",fields:"id, title, url, published_at, custom_excerpt, html"}).then((function(e){for(var t=0,n=e.length;t0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},i=function(){var e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return e&&e.matches},s=function(e){return e?new Date(e).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},c=function(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]".concat(e,"(=([^&#]*)|&|#|$)")).exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},r=function(){for(var e=document.querySelectorAll(".kg-gallery-image img"),t=0,n=e.length;t0){var n=t.substring(0,t.indexOf("?"));window.history.replaceState({},document.title,n)}};(n.click((function(){t.addClass("mobile-menu-opened"),o.addClass("opened"),z()})),a.click((function(){t.removeClass("mobile-menu-opened"),o.removeClass("opened"),z()})),s.click((function(){(_=!_)?(t.addClass("submenu-is-active"),s.addClass("active"),m.removeClass("closed").addClass("opened")):L()})),v.click((function(){k.addClass("opened"),setTimeout((function(){w.focus()}),400),z()})),j.click((function(){w.blur(),k.removeClass("opened"),z()})),w.keyup((function(){if(w.val().length>0&&M){var e=M.search(w.val()),t="";if(e.length>0){for(var n=0,a=e.length;n

').concat(e[n].title,'

').concat(Object(p.formatDate)(e[n].published_at),"
");C.hide(),y.html(t),y.show()}else y.html(""),y.hide(),C.show()}else y.html(""),y.hide(),C.hide()})),O.change((function(){O.is(":checked")?(i()("html").attr("data-theme","dark"),localStorage.setItem("theme","dark")):(i()("html").attr("data-theme","light"),localStorage.setItem("theme","light"))})),x.click((function(){H(i()(this).parent())})),i()(window).click((function(e){_&&r&&!r.contains(e.target)&&(_=!1,L())})),S?(i()("html").attr("data-theme",S),"dark"===S&&O.attr("checked",!0)):Object(p.isDarkMode)()&&O.attr("checked",!0),t.length>0)&&new l.a(t[0],{tolerance:{down:10,up:20},offset:15,onUnpin:function(){if(!Object(p.isMobile)()&&I){var e=I[0];e&&e.state.isVisible&&e.hide()}}}).init();if(g.length>0&&(g.on("init",(function(){Object(u.a)(".js-recent-article-title",50)})),g.slick({adaptiveHeight:!0,arrows:!1,infinite:!1,mobileFirst:!0,variableWidth:!0,rtl:Object(p.isRTL)()})),"undefined"!=typeof disableFadeAnimation&&disableFadeAnimation?i()("[data-aos]").addClass("no-aos-animation"):h.a.init({once:!0,startEvent:"DOMContentLoaded"}),c()(".lozad",{loaded:function(e){e.classList.add("loaded")}}).observe(),b.length>0){var N=document.getElementById("secondary-navigation-template");I=Object(d.a)(".js-open-secondary-menu",{content:N.innerHTML,arrow:!0,trigger:"click",interactive:!0})}Object(d.a)(".js-tooltip"),Object(u.a)(".js-article-card-title",100),Object(u.a)(".js-article-card-title-no-image",250),A=Object(p.getParameterByName)("action"),T=Object(p.getParameterByName)("stripe"),"subscribe"===A&&E("subscribe"),"signup"===A&&(window.location="".concat(ghostHost,"/signup/?action=checkout")),"checkout"===A&&E("signup"),"signin"===A&&E("signin"),"success"===T&&E("checkout"),"undefined"!=typeof ghostSearchApiKey?(D=ghostHost,P=ghostSearchApiKey,F=new GhostContentAPI({url:D,key:P,version:"v2"}),R=[],B={shouldSort:!0,threshold:0,location:0,distance:100,tokenize:!0,matchAllTokens:!1,maxPatternLength:32,minMatchCharLength:1,keys:["title","custom_excerpt","html"]},F.posts.browse({limit:"all",fields:"id, title, url, published_at, custom_excerpt, html"}).then((function(e){for(var t=0,n=e.length;t0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},r=function(){var e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return e&&e.matches},i=function(e){return e?new Date(e).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},c=function(e,n){n||(n=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var t=new RegExp("[?&]".concat(e,"(=([^&#]*)|&|#|$)")).exec(n);return t?t[2]?decodeURIComponent(t[2].replace(/\+/g," ")):"":null},u=function(e,n){var t=n(".js-zoomable");t.on("open",(function(n){a()&&e(n.target).parent().hasClass("kg-gallery-image")&&setTimeout((function(){var n=e(".medium-zoom-image--opened"),t=n[0].style.transform,o=t.substr(0,t.indexOf(" ")),a=parseFloat(o.substr(o.indexOf("(")+1).split(")")[0]),r=t.substr(t.indexOf(" ")+1),i=parseFloat(r.split(",")[1]),c="scale(1) translate3d(0, ".concat(i<0?a*i+i:a*i-i,"px, 0)");n.addClass("medium-zoom-image-mobile"),n[0].style.transform=c}),10)})),t.on("close",(function(){a()&&e(event.target).parent().hasClass("kg-gallery-image")&&e(".medium-zoom-image").removeClass("medium-zoom-image-mobile")}))}},15:function(e,n,t){t(1),e.exports=t(25)},25:function(e,n){}},[[15,0,1]]]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{1:function(e,t,n){"use strict";n.r(t),n.d(t,"isRTL",(function(){return a})),n.d(t,"isMobile",(function(){return o})),n.d(t,"isDarkMode",(function(){return r})),n.d(t,"formatDate",(function(){return i})),n.d(t,"getParameterByName",(function(){return s})),n.d(t,"adjustImageGallery",(function(){return c})),n.d(t,"managePostImages",(function(){return u})),n.d(t,"makeImagesZoomable",(function(){return l}));var a=function(){var e=document.querySelector("html");return["ar","he","fa"].includes(e.getAttribute("lang"))},o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},r=function(){var e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return e&&e.matches},i=function(e){return e?new Date(e).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},s=function(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]".concat(e,"(=([^&#]*)|&|#|$)")).exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},c=function(){for(var e=document.querySelectorAll(".kg-gallery-image img"),t=0,n=e.length;t0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},r=function(){var e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return e&&e.matches},i=function(e){return e?new Date(e).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},s=function(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]".concat(e,"(=([^&#]*)|&|#|$)")).exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},c=function(e,t){var n=t(".js-zoomable");n.on("open",(function(t){o()&&e(t.target).parent().hasClass("kg-gallery-image")&&setTimeout((function(){var t=e(".medium-zoom-image--opened"),n=t[0].style.transform,a=n.substr(0,n.indexOf(" ")),o=parseFloat(a.substr(a.indexOf("(")+1).split(")")[0]),r=n.substr(n.indexOf(" ")+1),i=parseFloat(r.split(",")[1]),s="scale(1) translate3d(0, ".concat(i<0?o*i+i:o*i-i,"px, 0)");t.addClass("medium-zoom-image-mobile"),t[0].style.transform=s}),10)})),n.on("close",(function(){o()&&e(event.target).parent().hasClass("kg-gallery-image")&&e(".medium-zoom-image").removeClass("medium-zoom-image-mobile")}))}},19:function(e,t,n){e.exports=n(20)},20:function(e,t,n){"use strict";n.r(t);var a=n(0),o=n.n(a),r=(n(6),n(2)),i=n(1);o()(document).ready((function(){var e=o()(".js-featured-articles");e.length>0&&(e.on("init",(function(){Object(r.a)(".js-featured-article-title",200)})),e.slick({arrows:!0,infinite:!0,prevArrow:'',nextArrow:'',mobileFirst:!0,rtl:Object(i.isRTL)()}),setTimeout((function(){e.slick("setPosition")}),350))}))}},[[19,0,1]]]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{1:function(t,e,n){"use strict";n.r(e),n.d(e,"isRTL",(function(){return a})),n.d(e,"isMobile",(function(){return r})),n.d(e,"isDarkMode",(function(){return o})),n.d(e,"formatDate",(function(){return i})),n.d(e,"getParameterByName",(function(){return s})),n.d(e,"adjustImageGallery",(function(){return c})),n.d(e,"managePostImages",(function(){return u})),n.d(e,"makeImagesZoomable",(function(){return l}));var a=function(){var t=document.querySelector("html");return["ar","he","fa"].includes(t.getAttribute("lang"))},r=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(t,")")).matches},o=function(){var t=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return t&&t.matches},i=function(t){return t?new Date(t).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},s=function(t,e){e||(e=window.location.href),t=t.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]".concat(t,"(=([^&#]*)|&|#|$)")).exec(e);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},c=function(){for(var t=document.querySelectorAll(".kg-gallery-image img"),e=0,n=t.length;e0&&(t.on("init",(function(){Object(o.a)(".js-featured-article-title",200)})),t.slick({arrows:!0,infinite:!0,prevArrow:'',nextArrow:'',mobileFirst:!0,rtl:Object(i.isRTL)()}),setTimeout((function(){t.slick("setPosition")}),350))}))}},[[19,0,1]]]); \ No newline at end of file diff --git a/assets/js/page.js b/assets/js/page.js index 1eb5c2a..639c443 100644 --- a/assets/js/page.js +++ b/assets/js/page.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{1:function(e,t,n){"use strict";n.r(t),n.d(t,"isRTL",(function(){return a})),n.d(t,"isMobile",(function(){return o})),n.d(t,"isDarkMode",(function(){return r})),n.d(t,"formatDate",(function(){return i})),n.d(t,"getParameterByName",(function(){return s})),n.d(t,"makeImagesZoomable",(function(){return c}));var a=function(){var e=document.querySelector("html");return["ar","he","fa"].includes(e.getAttribute("lang"))},o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},r=function(){var e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return e&&e.matches},i=function(e){return e?new Date(e).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},s=function(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]".concat(e,"(=([^&#]*)|&|#|$)")).exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},c=function(e,t){var n=t(".js-zoomable");n.on("open",(function(t){o()&&e(t.target).parent().hasClass("kg-gallery-image")&&setTimeout((function(){var t=e(".medium-zoom-image--opened"),n=t[0].style.transform,a=n.substr(0,n.indexOf(" ")),o=parseFloat(a.substr(a.indexOf("(")+1).split(")")[0]),r=n.substr(n.indexOf(" ")+1),i=parseFloat(r.split(",")[1]),s="scale(1) translate3d(0, ".concat(i<0?o*i+i:o*i-i,"px, 0)");t.addClass("medium-zoom-image-mobile"),t[0].style.transform=s}),10)})),n.on("close",(function(){o()&&e(event.target).parent().hasClass("kg-gallery-image")&&e(".medium-zoom-image").removeClass("medium-zoom-image-mobile")}))}},23:function(e,t,n){e.exports=n(24)},24:function(e,t,n){"use strict";n.r(t);var a=n(0),o=n.n(a),r=n(4),i=n.n(r),s=n(3),c=n(1);o()(document).ready((function(){i()(".js-post-content"),function(){for(var e=document.querySelectorAll(".kg-gallery-image img"),t=0,n=e.length;t0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},r=function(){var e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return e&&e.matches},i=function(e){return e?new Date(e).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},s=function(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]".concat(e,"(=([^&#]*)|&|#|$)")).exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},c=function(){for(var e=document.querySelectorAll(".kg-gallery-image img"),t=0,n=e.length;t0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(t,")")).matches},i=function(){var t=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return t&&t.matches},s=function(t){return t?new Date(t).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},r=function(t,e){e||(e=window.location.href),t=t.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]".concat(t,"(=([^&#]*)|&|#|$)")).exec(e);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},c=function(t,e){var n=e(".js-zoomable");n.on("open",(function(e){o()&&t(e.target).parent().hasClass("kg-gallery-image")&&setTimeout((function(){var e=t(".medium-zoom-image--opened"),n=e[0].style.transform,a=n.substr(0,n.indexOf(" ")),o=parseFloat(a.substr(a.indexOf("(")+1).split(")")[0]),i=n.substr(n.indexOf(" ")+1),s=parseFloat(i.split(",")[1]),r="scale(1) translate3d(0, ".concat(s<0?o*s+s:o*s-s,"px, 0)");e.addClass("medium-zoom-image-mobile"),e[0].style.transform=r}),10)})),n.on("close",(function(){o()&&t(event.target).parent().hasClass("kg-gallery-image")&&t(".medium-zoom-image").removeClass("medium-zoom-image-mobile")}))}},21:function(t,e,n){t.exports=n(22)},22:function(t,e,n){"use strict";n.r(e);var a=n(0),o=n.n(a),i=(n(6),n(14)),s=n(3),r=n(4),c=n.n(r),l=n(2),u=n(1),d=null,m=null,f=window.pageYOffset,p=0,g=0,h=0,w=!1;function b(){f=window.pageYOffset,y()}function v(t){Object(u.isMobile)("1023px")?(o()("body").addClass("share-menu-displayed"),setTimeout((function(){d.removeAttr("data-aos")}),t)):(Object(i.a)(".js-sticky",{stickyBitStickyOffset:100}),o()("body").removeClass("share-menu-displayed"))}function k(){x(),v(100),setTimeout((function(){O(),y()}),200)}function y(){w||requestAnimationFrame(j),w=!0}function j(){var t=g-p,e=Math.ceil(f/t*100);e<=100&&function(t){if(t<=100){var e=h-t/100*h;m[0].style.strokeDashoffset=e}}(e),w=!1}function x(){p=window.innerHeight,g=o()(document).height()}function O(){var t=m.parent().width(),e=t/2,n=Object(u.isMobile)()?2:3;m.parent().attr("viewBox","0 0 ".concat(t," ").concat(t)),m.attr("stroke-width",n),m.attr("r",e-(n-1)),m.attr("cx",e),m.attr("cy",e),h=2*e*Math.PI,m[0].style.strokeDasharray="".concat(h," ").concat(h),m[0].style.strokeDashoffset=h}function C(){m=o()(".js-progress"),x(),O(),j(),setTimeout((function(){m.parent().css("opacity",1)}),300)}o()(document).ready((function(){d=o()(".js-aos-wrapper");var t=o()(".js-scrolltop"),e=o()(".js-load-comments"),n=o()(".js-comments-iframe"),a=o()(".js-recommended-articles");c()(".js-post-content"),function(){for(var t=document.querySelectorAll(".kg-gallery-image img"),e=0,n=t.length;e0&&(a.on("init",(function(){C(),Object(l.a)(".js-article-card-title",100),Object(l.a)(".js-article-card-title-no-image",250)})),a.slick({arrows:!0,infinite:!0,prevArrow:'',nextArrow:'',mobileFirst:!0,responsive:[{breakpoint:720,settings:{slidesToShow:2}},{breakpoint:1023,settings:{arrows:!1,slidesToShow:3}}],rtl:Object(u.isRTL)()})),t.click((function(){o()("html, body").animate({scrollTop:0},500)})),e.click((function(){e.parent().hide(),n.fadeIn("slow")})),o()(".js-post-content").find("img").each((function(){o()(this).closest("figure").hasClass("kg-bookmark-card")||o()(this).addClass("js-zoomable");var t=o()(this).parent().find("figcaption");t?o()(this).attr("alt",t.text()):o()(this).attr("alt","")})),Object(u.makeImagesZoomable)(o.a,s.a),window.addEventListener("scroll",b,{passive:!0}),window.addEventListener("resize",k,{passive:!0})})),o()(window).on("load",(function(){C()}))}},[[21,0,1]]]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{1:function(t,e,n){"use strict";n.r(e),n.d(e,"isRTL",(function(){return a})),n.d(e,"isMobile",(function(){return o})),n.d(e,"isDarkMode",(function(){return i})),n.d(e,"formatDate",(function(){return s})),n.d(e,"getParameterByName",(function(){return r})),n.d(e,"adjustImageGallery",(function(){return c})),n.d(e,"managePostImages",(function(){return l})),n.d(e,"makeImagesZoomable",(function(){return u}));var a=function(){var t=document.querySelector("html");return["ar","he","fa"].includes(t.getAttribute("lang"))},o=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(t,")")).matches},i=function(){var t=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return t&&t.matches},s=function(t){return t?new Date(t).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},r=function(t,e){e||(e=window.location.href),t=t.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]".concat(t,"(=([^&#]*)|&|#|$)")).exec(e);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},c=function(){for(var t=document.querySelectorAll(".kg-gallery-image img"),e=0,n=t.length;e0&&(a.on("init",(function(){C(),Object(l.a)(".js-article-card-title",100),Object(l.a)(".js-article-card-title-no-image",250)})),a.slick({arrows:!0,infinite:!0,prevArrow:'',nextArrow:'',mobileFirst:!0,responsive:[{breakpoint:720,settings:{slidesToShow:2}},{breakpoint:1023,settings:{arrows:!1,slidesToShow:3}}],rtl:Object(u.isRTL)()})),t.click((function(){o()("html, body").animate({scrollTop:0},500)})),e.click((function(){e.parent().hide(),n.fadeIn("slow")})),Object(u.managePostImages)(o.a),Object(u.makeImagesZoomable)(o.a,s.a),window.addEventListener("scroll",b,{passive:!0}),window.addEventListener("resize",y,{passive:!0})})),o()(window).on("load",(function(){C()}))}},[[21,0,1]]]); \ No newline at end of file diff --git a/locales/fa.json b/locales/fa.json index e863456..2e6d36a 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -1,48 +1,48 @@ { - "% min read": "% دقیقه", - "% posts": "% پست ها", - "1 min read": "۱ دقیقه", - "1 post": "یک پست", - "Among with": "
همراه با ", - "Among with no break line": "همراه با ", - "Apparently there are no posts at the moment, check again later.": "به نظر می رسد در حال حاضر پستی وجود ندارد. دوباره سر بزنید", - "Back to home": "بازگشت به خانه", - "Email cannot be blank.": "ایمیل نمی تواند خالی باشد", - "Featured": "برجسته", - "Get the latest posts delivered right to your inbox.": "جدیدترین پست ها را در ایمیل خود دریافت کنید", - "Go to the home page": "برو به صفحه اصلی", - "Great! Next, complete checkout for full access.": "عالیه! حالا برای دسترسی کامل وارسی رو تکمیل کنید", - "Great! You've successfully subscribed.": "عالیه! با موفقیت عضو شدید", - "JavaScript license information": "اطلاعات لایسنس جاوااسکریپت", - "More": "بیشتر", - "No posts": "پستی نیست", - "No posts found": "پستی پیدا نشد", - "No recent articles found :(": "مقاله تازه ای پیدا نشد :(", - "No results for your search, try something different.": "نتیجه ای برای جست و جوی شما پیدا نشد", - "No tags found :(": "تگی پیدا نشد :(", - "Now check your inbox and click the link to confirm your subscription.": "ایمیل خود را چک کنید و بر روی لینک فعال سازی کلیک کنید", - "Oops! There was an error sending the email, please try later.": "مشکلی در ارسال ایمیل به وجود آمد. دوباره امتحان کنید", - "Page": "صفحه", - "Page not found": "صفحه پیدا نشد", - "Please enter a valid email address": "لطفا یک ایمیل صحیح وارد کنید", - "Posted by": "پست شده توسط", - "Published with": "منتشر شده با", - "Recent articles": "مقالات جدید", - "Recommended for you": "پیشنهاد شده برای شما", - "Stay up to date! Get all the latest & greatest posts delivered straight to your inbox.": "به روز بمانید! جدیدترین و بهترین پست ها را در ایمیل خود دریافت کنید", - "Subscribe": "عضویت", - "Subscribe to": "عضو شدن به ", - "Subscribe to our newsletter": "در خبرنامه ما عضو شوید", - "Subscribed!": "عضو شدید!", - "Success! Your account is fully activated, you now have access to all content.": "موفق! اکانت شما فعال شد", - "Tags": "تگ ها", - "Toggle dark mode": "حالت تاریک", - "Type to search": "برای جست و جو بنویسید", - "Unfortunately the page you were looking for could not be found.": "متاسفانه صفحه ای که به دنبال آن می گردید پیدا نشد", - "Welcome back! You've successfully signed in.": "خوش آمدید! با موفقیت وارد شدید", - "You've successfully subscribed to": "شما با موفقیت عضو شدید به ", - "Your email address": "آدرس ایمیل شما", - "of": "از", - "with the email address": "با آدرس ایمیل", - "with this tag": "با این تگ" - } + "% min read": "% دقیقه", + "% posts": "% پست ها", + "1 min read": "۱ دقیقه", + "1 post": "یک پست", + "Among with": "
همراه با ", + "Among with no break line": "همراه با ", + "Apparently there are no posts at the moment, check again later.": "به نظر می رسد در حال حاضر پستی وجود ندارد. دوباره سر بزنید", + "Back to home": "بازگشت به خانه", + "Email cannot be blank.": "ایمیل نمی تواند خالی باشد", + "Featured": "برجسته", + "Get the latest posts delivered right to your inbox.": "جدیدترین پست ها را در ایمیل خود دریافت کنید", + "Go to the home page": "برو به صفحه اصلی", + "Great! Next, complete checkout for full access.": "عالیه! حالا برای دسترسی کامل وارسی رو تکمیل کنید", + "Great! You've successfully subscribed.": "عالیه! با موفقیت عضو شدید", + "JavaScript license information": "اطلاعات لایسنس جاوااسکریپت", + "More": "بیشتر", + "No posts": "پستی نیست", + "No posts found": "پستی پیدا نشد", + "No recent articles found :(": "مقاله تازه ای پیدا نشد :(", + "No results for your search, try something different.": "نتیجه ای برای جست و جوی شما پیدا نشد", + "No tags found :(": "تگی پیدا نشد :(", + "Now check your inbox and click the link to confirm your subscription.": "ایمیل خود را چک کنید و بر روی لینک فعال سازی کلیک کنید", + "Oops! There was an error sending the email, please try later.": "مشکلی در ارسال ایمیل به وجود آمد. دوباره امتحان کنید", + "Page": "صفحه", + "Page not found": "صفحه پیدا نشد", + "Please enter a valid email address": "لطفا یک ایمیل صحیح وارد کنید", + "Posted by": "پست شده توسط", + "Published with": "منتشر شده با", + "Recent articles": "مقالات جدید", + "Recommended for you": "پیشنهاد شده برای شما", + "Stay up to date! Get all the latest & greatest posts delivered straight to your inbox.": "به روز بمانید! جدیدترین و بهترین پست ها را در ایمیل خود دریافت کنید", + "Subscribe": "عضویت", + "Subscribe to": "عضو شدن به ", + "Subscribe to our newsletter": "در خبرنامه ما عضو شوید", + "Subscribed!": "عضو شدید!", + "Success! Your account is fully activated, you now have access to all content.": "موفق! اکانت شما فعال شد", + "Tags": "تگ ها", + "Toggle dark mode": "حالت تاریک", + "Type to search": "برای جست و جو بنویسید", + "Unfortunately the page you were looking for could not be found.": "متاسفانه صفحه ای که به دنبال آن می گردید پیدا نشد", + "Welcome back! You've successfully signed in.": "خوش آمدید! با موفقیت وارد شدید", + "You've successfully subscribed to": "شما با موفقیت عضو شدید به ", + "Your email address": "آدرس ایمیل شما", + "of": "از", + "with the email address": "با آدرس ایمیل", + "with this tag": "با این تگ" +} \ No newline at end of file diff --git a/package.json b/package.json index 4ed96f7..bf10f38 100644 --- a/package.json +++ b/package.json @@ -54,5 +54,5 @@ "desktop": "assets/screenshot-desktop.jpg", "mobile": "assets/screenshot-mobile.jpg" }, - "version": "0.7.0" + "version": "0.7.2" } diff --git a/src/js/helpers.js b/src/js/helpers.js index 65e68bb..54f2f6d 100644 --- a/src/js/helpers.js +++ b/src/js/helpers.js @@ -43,6 +43,37 @@ export const getParameterByName = (name, url) => { return decodeURIComponent(results[2].replace(/\+/g, ' ')) } +export const adjustImageGallery = () => { + const images = document.querySelectorAll('.kg-gallery-image img') + + for (var i = 0, len = images.length; i < len; i++) { + const container = images[i].closest('.kg-gallery-image') + const width = images[i].attributes.width.value + const height = images[i].attributes.height.value + const ratio = width / height + container.style.flex = `${ratio} 1 0%` + } +} + +export const managePostImages = ($) => { + $('.js-post-content').find('img').each(function () { + if ( + !$(this).closest('figure').hasClass('kg-bookmark-card') && + !$(this).parent().is('a') + ) { + $(this).addClass('js-zoomable') + } + + const $figcaption = $(this).parent().find('figcaption') + + if ($figcaption) { + $(this).attr('alt', $figcaption.text()) + } else { + $(this).attr('alt', '') + } + }) +} + export const makeImagesZoomable = ($, mediumZoom) => { const zoom = mediumZoom('.js-zoomable') diff --git a/src/js/page.js b/src/js/page.js index e014c80..c499ed1 100644 --- a/src/js/page.js +++ b/src/js/page.js @@ -1,37 +1,16 @@ import $ from 'jquery' import fitvids from 'fitvids' import mediumZoom from 'medium-zoom' -import { makeImagesZoomable } from './helpers' +import { + adjustImageGallery, + managePostImages, + makeImagesZoomable +} from './helpers' $(document).ready(() => { fitvids('.js-post-content') - function adjustImageGallery() { - const images = document.querySelectorAll('.kg-gallery-image img') - - for (var i = 0, len = images.length; i < len; i++) { - const container = images[i].closest('.kg-gallery-image') - const width = images[i].attributes.width.value - const height = images[i].attributes.height.value - const ratio = width / height - container.style.flex = `${ratio} 1 0%` - } - } - adjustImageGallery() - - $('.js-post-content').find('figure img').each(function() { - if (!$(this).closest('figure').hasClass('kg-bookmark-card')) { - $(this).addClass('js-zoomable') - } - - const $figcaption = $(this).parent().find('figcaption') - if ($figcaption) { - $(this).attr('alt', $figcaption.text()) - } else { - $(this).attr('alt', '') - } - }) - + managePostImages($) makeImagesZoomable($, mediumZoom) }) diff --git a/src/js/post.js b/src/js/post.js index 7ac00e8..90681ba 100644 --- a/src/js/post.js +++ b/src/js/post.js @@ -7,6 +7,8 @@ import shave from 'shave' import { isRTL, isMobile, + adjustImageGallery, + managePostImages, makeImagesZoomable } from './helpers' @@ -114,18 +116,6 @@ $(document).ready(() => { fitvids('.js-post-content') - function adjustImageGallery() { - const images = document.querySelectorAll('.kg-gallery-image img') - - for (var i = 0, len = images.length; i < len; i++) { - const container = images[i].closest('.kg-gallery-image') - const width = images[i].attributes.width.value - const height = images[i].attributes.height.value - const ratio = width / height - container.style.flex = `${ratio} 1 0%` - } - } - adjustImageGallery() adjustShare(1000) @@ -173,19 +163,7 @@ $(document).ready(() => { $commentsIframe.fadeIn('slow') }) - $('.js-post-content').find('img').each(function() { - if (!$(this).closest('figure').hasClass('kg-bookmark-card')) { - $(this).addClass('js-zoomable') - } - - const $figcaption = $(this).parent().find('figcaption') - if ($figcaption) { - $(this).attr('alt', $figcaption.text()) - } else { - $(this).attr('alt', '') - } - }) - + managePostImages($) makeImagesZoomable($, mediumZoom) window.addEventListener('scroll', onScrolling, { passive: true })