Make post images zoomable only if the parent is not an anchor

This commit is contained in:
Eduardo Gomez 2020-06-22 22:21:56 +02:00
parent f097a490c9
commit 010f2f0135
10 changed files with 93 additions and 105 deletions

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{1:function(e,n,t){"use strict";t.r(n),t.d(n,"isRTL",(function(){return o})),t.d(n,"isMobile",(function(){return a})),t.d(n,"isDarkMode",(function(){return r})),t.d(n,"formatDate",(function(){return i})),t.d(n,"getParameterByName",(function(){return c})),t.d(n,"makeImagesZoomable",(function(){return u}));var o=function(){var e=document.querySelector("html");return["ar","he","fa"].includes(e.getAttribute("lang"))},a=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"}):""},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]]]);
(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;t<n;t++){var a=e[t].closest(".kg-gallery-image"),o=e[t].attributes.width.value/e[t].attributes.height.value;a.style.flex="".concat(o," 1 0%")}},u=function(e){e(".js-post-content").find("img").each((function(){e(this).closest("figure").hasClass("kg-bookmark-card")||e(this).parent().is("a")||e(this).addClass("js-zoomable");var t=e(this).parent().find("figcaption");t?e(this).attr("alt",t.text()):e(this).attr("alt","")}))},l=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")}))}},15:function(e,t,n){n(1),e.exports=n(25)},25:function(e,t){}},[[15,0,1]]]);

View file

@ -1 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{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")}))}},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:'<button class="m-icon-button in-featured-articles slick-prev" aria-label="Previous"><span class="icon-arrow-left"></span></button>',nextArrow:'<button class="m-icon-button in-featured-articles slick-next" aria-label="Next"><span class="icon-arrow-right"></span></button>',mobileFirst:!0,rtl:Object(i.isRTL)()}),setTimeout((function(){e.slick("setPosition")}),350))}))}},[[19,0,1]]]);
(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;e<n;e++){var a=t[e].closest(".kg-gallery-image"),r=t[e].attributes.width.value/t[e].attributes.height.value;a.style.flex="".concat(r," 1 0%")}},u=function(t){t(".js-post-content").find("img").each((function(){t(this).closest("figure").hasClass("kg-bookmark-card")||t(this).parent().is("a")||t(this).addClass("js-zoomable");var e=t(this).parent().find("figcaption");e?t(this).attr("alt",e.text()):t(this).attr("alt","")}))},l=function(t,e){var n=e(".js-zoomable");n.on("open",(function(e){r()&&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(" ")),r=parseFloat(a.substr(a.indexOf("(")+1).split(")")[0]),o=n.substr(n.indexOf(" ")+1),i=parseFloat(o.split(",")[1]),s="scale(1) translate3d(0, ".concat(i<0?r*i+i:r*i-i,"px, 0)");e.addClass("medium-zoom-image-mobile"),e[0].style.transform=s}),10)})),n.on("close",(function(){r()&&t(event.target).parent().hasClass("kg-gallery-image")&&t(".medium-zoom-image").removeClass("medium-zoom-image-mobile")}))}},19:function(t,e,n){t.exports=n(20)},20:function(t,e,n){"use strict";n.r(e);var a=n(0),r=n.n(a),o=(n(6),n(2)),i=n(1);r()(document).ready((function(){var t=r()(".js-featured-articles");t.length>0&&(t.on("init",(function(){Object(o.a)(".js-featured-article-title",200)})),t.slick({arrows:!0,infinite:!0,prevArrow:'<button class="m-icon-button in-featured-articles slick-prev" aria-label="Previous"><span class="icon-arrow-left"></span></button>',nextArrow:'<button class="m-icon-button in-featured-articles slick-next" aria-label="Next"><span class="icon-arrow-right"></span></button>',mobileFirst:!0,rtl:Object(i.isRTL)()}),setTimeout((function(){t.slick("setPosition")}),350))}))}},[[19,0,1]]]);

View file

@ -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;t<n;t++){var a=e[t].closest(".kg-gallery-image"),o=e[t].attributes.width.value/e[t].attributes.height.value;a.style.flex="".concat(o," 1 0%")}}(),o()(".js-post-content").find("figure img").each((function(){o()(this).closest("figure").hasClass("kg-bookmark-card")||o()(this).addClass("js-zoomable");var e=o()(this).parent().find("figcaption");e?o()(this).attr("alt",e.text()):o()(this).attr("alt","")})),Object(c.makeImagesZoomable)(o.a,s.a)}))}},[[23,0,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,"adjustImageGallery",(function(){return c})),n.d(t,"managePostImages",(function(){return u})),n.d(t,"makeImagesZoomable",(function(){return m}));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;t<n;t++){var a=e[t].closest(".kg-gallery-image"),o=e[t].attributes.width.value/e[t].attributes.height.value;a.style.flex="".concat(o," 1 0%")}},u=function(e){e(".js-post-content").find("img").each((function(){e(this).closest("figure").hasClass("kg-bookmark-card")||e(this).parent().is("a")||e(this).addClass("js-zoomable");var t=e(this).parent().find("figcaption");t?e(this).attr("alt",t.text()):e(this).attr("alt","")}))},m=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"),Object(c.adjustImageGallery)(),Object(c.managePostImages)(o.a),Object(c.makeImagesZoomable)(o.a,s.a)}))}},[[23,0,1]]]);

View file

@ -1 +1 @@
(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,"makeImagesZoomable",(function(){return c}));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(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;e<n;e++){var a=t[e].closest(".kg-gallery-image"),o=t[e].attributes.width.value/t[e].attributes.height.value;a.style.flex="".concat(o," 1 0%")}}(),v(1e3),a.length>0&&(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:'<button class="m-icon-button filled in-recommended-articles slick-prev" aria-label="Previous"><span class="icon-arrow-left"></span></button>',nextArrow:'<button class="m-icon-button filled in-recommended-articles slick-next" aria-label="Next"><span class="icon-arrow-right"></span></button>',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]]]);
(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;e<n;e++){var a=t[e].closest(".kg-gallery-image"),o=t[e].attributes.width.value/t[e].attributes.height.value;a.style.flex="".concat(o," 1 0%")}},l=function(t){t(".js-post-content").find("img").each((function(){t(this).closest("figure").hasClass("kg-bookmark-card")||t(this).parent().is("a")||t(this).addClass("js-zoomable");var e=t(this).parent().find("figcaption");e?t(this).attr("alt",e.text()):t(this).attr("alt","")}))},u=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),m=null,d=null,f=window.pageYOffset,g=0,p=0,h=0,w=!1;function b(){f=window.pageYOffset,k()}function v(t){Object(u.isMobile)("1023px")?(o()("body").addClass("share-menu-displayed"),setTimeout((function(){m.removeAttr("data-aos")}),t)):(Object(i.a)(".js-sticky",{stickyBitStickyOffset:100}),o()("body").removeClass("share-menu-displayed"))}function y(){x(),v(100),setTimeout((function(){O(),k()}),200)}function k(){w||requestAnimationFrame(j),w=!0}function j(){var t=p-g,e=Math.ceil(f/t*100);e<=100&&function(t){if(t<=100){var e=h-t/100*h;d[0].style.strokeDashoffset=e}}(e),w=!1}function x(){g=window.innerHeight,p=o()(document).height()}function O(){var t=d.parent().width(),e=t/2,n=Object(u.isMobile)()?2:3;d.parent().attr("viewBox","0 0 ".concat(t," ").concat(t)),d.attr("stroke-width",n),d.attr("r",e-(n-1)),d.attr("cx",e),d.attr("cy",e),h=2*e*Math.PI,d[0].style.strokeDasharray="".concat(h," ").concat(h),d[0].style.strokeDashoffset=h}function C(){d=o()(".js-progress"),x(),O(),j(),setTimeout((function(){d.parent().css("opacity",1)}),300)}o()(document).ready((function(){m=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"),Object(u.adjustImageGallery)(),v(1e3),a.length>0&&(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:'<button class="m-icon-button filled in-recommended-articles slick-prev" aria-label="Previous"><span class="icon-arrow-left"></span></button>',nextArrow:'<button class="m-icon-button filled in-recommended-articles slick-next" aria-label="Next"><span class="icon-arrow-right"></span></button>',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]]]);

View file

@ -1,48 +1,48 @@
{
"% min read": "% دقیقه",
"% posts": "% پست ها",
"1 min read": "۱ دقیقه",
"1 post": "یک پست",
"Among with": "<br>همراه با ",
"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": "<br>همراه با ",
"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": "با این تگ"
}

View file

@ -54,5 +54,5 @@
"desktop": "assets/screenshot-desktop.jpg",
"mobile": "assets/screenshot-mobile.jpg"
},
"version": "0.7.0"
"version": "0.7.2"
}

View file

@ -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')

View file

@ -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)
})

View file

@ -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 })