shaarli_themes/morgan/js/thumbnails.min.js

2 lines
5.4 KiB
JavaScript
Raw Normal View History

2025-01-26 11:52:28 +01:00
/*! For license information please see thumbnails.min.js.LICENSE.txt */
(()=>{var t={987:function(t,e,o){var n,s;n=function(){"use strict";var t,e,o,n,s="src",r="srcset";return function(s){if(!document.querySelectorAll){var r=document.createStyleSheet();document.querySelectorAll=function(t,e,o,n,s){for(s=document.all,e=[],o=(t=t.replace(/\[for\b/gi,"[htmlFor").split(",")).length;o--;){for(r.addRule(t[o],"k:v"),n=s.length;n--;)s[n].currentStyle.k&&e.push(s[n]);r.removeRule(0)}return e}}var c=this,l=c._util={};l.elements=[],l.destroyed=!0,c.options=s||{},c.options.error=c.options.error||!1,c.options.offset=c.options.offset||100,c.options.root=c.options.root||document,c.options.success=c.options.success||!1,c.options.selector=c.options.selector||".b-lazy",c.options.separator=c.options.separator||"|",c.options.containerClass=c.options.container,c.options.container=!!c.options.containerClass&&document.querySelectorAll(c.options.containerClass),c.options.errorClass=c.options.errorClass||"b-error",c.options.breakpoints=c.options.breakpoints||!1,c.options.loadInvisible=c.options.loadInvisible||!1,c.options.successClass=c.options.successClass||"b-loaded",c.options.validateDelay=c.options.validateDelay||25,c.options.saveViewportOffsetDelay=c.options.saveViewportOffsetDelay||50,c.options.srcset=c.options.srcset||"data-srcset",c.options.src=t=c.options.src||"data-src",n=Element.prototype.closest,o=window.devicePixelRatio>1,(e={}).top=0-c.options.offset,e.left=0-c.options.offset,c.revalidate=function(){i(c)},c.load=function(t,e){var o=this.options;t&&void 0===t.length?u(t,e,o):O(t,(function(t){u(t,e,o)}))},c.destroy=function(){var t=c._util;c.options.container&&O(c.options.container,(function(e){T(e,"scroll",t.validateT)})),T(window,"scroll",t.validateT),T(window,"resize",t.validateT),T(window,"resize",t.saveViewportOffsetT),t.count=0,t.elements.length=0,t.destroyed=!0},l.validateT=x((function(){a(c)}),c.options.validateDelay,c),l.saveViewportOffsetT=x((function(){C(c.options.offset)}),c.options.saveViewportOffsetDelay,c),C(c.options.offset),O(c.options.breakpoints,(function(e){if(e.width>=window.screen.width)return t=e.src,!1})),setTimeout((function(){i(c)}))};function i(t){var e=t._util;e.elements=b(t.options),e.count=e.elements.length,e.destroyed&&(e.destroyed=!1,t.options.container&&O(t.options.container,(function(t){E(t,"scroll",e.validateT)})),E(window,"resize",e.saveViewportOffsetT),E(window,"resize",e.validateT),E(window,"scroll",e.validateT)),a(t)}function a(t){for(var e=t._util,o=0;o<e.count;o++){var n=e.elements[o];(c(n,t.options)||w(n,t.options.successClass))&&(t.load(n),e.elements.splice(o,1),e.count--,o--)}0===e.count&&t.destroy()}function c(t,o){var s=t.getBoundingClientRect();if(o.container&&n){var r=t.closest(o.containerClass);if(r){var i=r.getBoundingClientRect();if(l(i,e)){var a=i.top-o.offset,c=i.right+o.offset,u=i.bottom+o.offset,f=i.left-o.offset;return l(s,{top:a>e.top?a:e.top,right:c<e.right?c:e.right,bottom:u<e.bottom?u:e.bottom,left:f>e.left?f:e.left})}return!1}}return l(s,e)}function l(t,e){return t.right>=e.left&&t.bottom>=e.top&&t.left<=e.right&&t.top<=e.bottom}function u(e,n,i){if(!w(e,i.successClass)&&(n||i.loadInvisible||e.offsetWidth>0&&e.offsetHeight>0)){var a=m(e,t)||m(e,i.src);if(a){var c=a.split(i.separator),l=c[o&&c.length>1?1:0],u=m(e,i.srcset),v=g(e,"img"),h=e.parentNode,b=h&&g(h,"picture");if(v||void 0===e.src){var C=new Image,x=function(){i.error&&i.error(e,"invalid"),y(e,i.errorClass),T(C,"error",x),T(C,"load",k)},k=function(){v?b||d(e,l,u):e.style.backgroundImage='url("'+l+'")',f(e,i),T(C,"load",k),T(C,"error",x)};b&&(C=e,O(h.getElementsByTagName("source"),(function(t){p(t,r,i.srcset)}))),E(C,"error",x),E(C,"load",k),d(C,l,u)}else e.src=l,f(e,i)}else g(e,"video")?(O(e.getElementsByTagName("source"),(function(t){p(t,s,i.src)})),e.load(),f(e,i)):(i.error&&i.error(e,"missing"),y(e,i.errorClass))}}function f(t,e){y(t,e.successClass),e.success&&e.success(t),h(t,e.src),h(t,e.srcset),O(e.breakpoints,(function(e){h(t,e.src)}))}function p(t,e,o){var n=m(t,o);n&&(v(t,e,n),h(t,o))}function d(t,e,o){o&&v(t,r,o),t.src=e}function v(t,e,o){t.setAttribute(e,o)}function m(t,e)