2 lines
1.6 KiB
JavaScript
2 lines
1.6 KiB
JavaScript
!function(l,i,n){"use strict";var o=n,d="blazybox",s=d,c="."+d,r=c+"__content",h="is-"+d+"--open",u="visually-hidden",b="aria-hidden";function a(e){var a=i.blazyBox,t=l(e);a.el=e,(a.$el=t).on("click."+d,c+"__close",a.close,!0)}i.blazyBox={el:null,$el:null,options:{hideCloseBtn:!1},open:function(e){var a=i.blazyBox,t=a.$el,e=i.theme("blazyBoxMedia",{data:e});i.attachBehaviors(t[0]),t.removeClass(u).attr(b,!1).find(r).innerHTML=e,l.addClass(n.body,h),a.check()},close:function(e){var a=i.blazyBox.$el;l.isUnd(e)||e.preventDefault(),a.addClass(u).attr(b,!0).find(r).innerHTML="",l.removeClass(n.body,h),i.detachBehaviors(a[0])},check:function(){var e;this.options.hideCloseBtn&&(e=this.$el.find(c+"__close"),l.isElm(e)&&l.addClass(e,u))},attach:function(){l.isElm(l.find(n.body,c))||l.append(n.body,i.theme("blazyBox"))},isOpened:function(){return!i.blazyBox.$el.hasClass(u)}},i.theme.blazyBox=function(){return l.template('<div id="$id" class="$id visually-hidden" tabindex="-1" role="dialog" aria-hidden="true" aria-label="$id"><div class="$id__content"></div><button class="$id__close" data-role="none">×</button></div>',{id:d})},i.theme.blazyBoxMedia=function(e){var a=e.data,t=a,i="",i='<div class="media media--fullscreen">';return l.isObj(a)&&(a=(e=l(a.el||a.element)).attr("href"),t=e.attr("data-oembed-url",a,!0)),l.isStr(t)&&(i+='<iframe src="'+t+'" width="100%" height="100%" allowfullscreen></iframe>'),i+="</div>"},i.behaviors.blazyBox={attach:function(e){o=l.context(e),i.blazyBox.attach(),l.once(a,s,c,o)},detach:function(e,a,t){"unload"===t&&l.once.removeSafely(s,c,o)}}}(dBlazy,Drupal,this.document);
|