-
-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathbasicLightbox.min.js
More file actions
1 lines (1 loc) · 3.56 KB
/
basicLightbox.min.js
File metadata and controls
1 lines (1 loc) · 3.56 KB
1
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).basicLightbox=e()}}((function(){return function e(n,t,o){function r(c,u){if(!t[c]){if(!n[c]){var l="function"==typeof require&&require;if(!u&&l)return l(c,!0);if(i)return i(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var a=t[c]={exports:{}};n[c][0].call(a.exports,(function(e){return r(n[c][1][e]||e)}),a,a.exports,e,n,t,o)}return t[c].exports}for(var i="function"==typeof require&&require,c=0;c<o.length;c++)r(o[c]);return r}({1:[function(e,n,t){"use strict";function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.visible=t.create=void 0;var r=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=document.createElement("div");return t.innerHTML=e.trim(),!0===n?t.children:t.firstChild},i=function(e,n){var t=e.children;return 1===t.length&&t[0].tagName===n},c=t.visible=function(e){return null!=(e=e||document.querySelector(".basicLightbox"))&&!0===e.ownerDocument.body.contains(e)};t.create=function(e,n){e=function(e){var n="string"==typeof e,t=e instanceof HTMLElement==1;if(!1===n&&!1===t)throw new Error("Content must be a DOM element/node or string");return!0===n?Array.from(r(e,!0)):"TEMPLATE"===e.tagName?[e.content.cloneNode(!0)]:Array.from(e.children)}(e),n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(null==(e=Object.assign({},e)).closable&&(e.closable=!0),null==e.className&&(e.className=""),null==e.onShow&&(e.onShow=function(){}),null==e.onClose&&(e.onClose=function(){}),null==e.container&&(e.container=document.body),"boolean"!=typeof e.closable)throw new Error("Property `closable` must be a boolean");if("string"!=typeof e.className)throw new Error("Property `className` must be a string");if("function"!=typeof e.onShow)throw new Error("Property `onShow` must be a function");if("function"!=typeof e.onClose)throw new Error("Property `onClose` must be a function");if("object"!==o(e.container))throw new Error("Property `conteiner` must be a object");return e}(n);var t=function(e,n){var t=r('\n\t\t<div class="basicLightbox '.concat(n.className,'">\n\t\t\t<div class="basicLightbox__placeholder" role="dialog"></div>\n\t\t</div>\n\t')),o=t.querySelector(".basicLightbox__placeholder");e.forEach((function(e){return o.appendChild(e)}));var c=i(o,"IMG"),u=i(o,"VIDEO"),l=i(o,"IFRAME");return!0===c&&t.classList.add("basicLightbox--img"),!0===u&&t.classList.add("basicLightbox--video"),!0===l&&t.classList.add("basicLightbox--iframe"),t}(e,n),u=function(e){return!1!==n.onClose(l)&&function(e,n){return e.classList.remove("basicLightbox--visible"),setTimeout((function(){return!1===c(e)||e.parentElement.removeChild(e),n()}),410),!0}(t,(function(){if("function"==typeof e)return e(l)}))};!0===n.closable&&t.addEventListener("click",(function(e){e.target===t&&u()}));var l={element:function(){return t},visible:function(){return c(t)},show:function(e){return!1!==n.onShow(l)&&function(e,n,t){return t.container.appendChild(e),setTimeout((function(){requestAnimationFrame((function(){return e.classList.add("basicLightbox--visible"),n()}))}),10),!0}(t,(function(){if("function"==typeof e)return e(l)}),n)},close:u};return l}},{}]},{},[1])(1)}));