{"version":3,"sources":["notify.js"],"names":["Notify","this","notifications","defaults","delay","alertIcon","confirmIcon","infoIcon","arguments","options","extendDefaults","document","getElementsByClassName","length","container","docFrag","createDocumentFragment","notifyContainer","createElement","className","appendChild","body","animationEnd","animationEndSelect","source","destination","property","hasOwnProperty","buildNotificationCard","messageText","iconClass","persist","id","onClick","notification","wrapper","iconContainer","icon","message","innerHTML","_this","hideNotification","addEventListener","event","target","parentNode","removeChild","index","indexOf","splice","$","off","setTimeout","one","e","console","error","style","cursor","el","transitions","transition","OTransition","MozTransition","WebkitTransition","t","undefined","prototype","alert","alertMessage","isPersistent","idString","card","call","push","confirm","info"],"mappings":"AAQA,IAAIA,OAAS,WACT,SAASA,IAELC,KAAKC,cAAgB,GAErB,MAAMC,EAAW,CACbC,MAAO,IACPC,UAAW,oBACXC,YAAa,sBACbC,SAAU,oBAUd,GAPIC,UAAU,IAA8B,iBAAjBA,UAAU,GACjCP,KAAKQ,QAAUC,EAAeP,EAAUK,UAAU,IAElDP,KAAKQ,QAAUN,EAIfQ,SAASC,uBAAuB,oBAAoBC,OACpDZ,KAAKa,UAAYH,SAASC,uBAAuB,oBAAoB,OAClE,CACH,MAAMG,EAAUJ,SAASK,yBACnBC,EAAkBN,SAASO,cAAc,OAC/CD,EAAgBE,UAAY,mBAC5BJ,EAAQK,YAAYH,GACpBN,SAASU,KAAKD,YAAYL,GAC1Bd,KAAKa,UAAYG,EAKrBhB,KAAKqB,aAAeC,IAiDxB,SAASb,EAAec,EAAQC,GAC5B,IAAKC,YAAYD,EAETA,EAAYE,eAAeD,YAC3BF,EAAOE,UAAYD,EAAYC,WAGvC,OAAOF,EAOX,SAASI,EAAsBC,EAAaC,EAAWC,EAASC,EAAIC,GAEhE,MAAMC,EAAevB,SAASO,cAAc,OAC5CgB,EAAaf,UAAY,SACzBe,EAAaF,GAAKA,EAElB,MAAMG,EAAUxB,SAASO,cAAc,OACvCiB,EAAQhB,UAAY,iBAEpB,MAAMiB,EAAgBzB,SAASO,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M,YAAYoD,GAC3BvE,KAAKC,cAAcwE,KAAKF,IAO5BxE,EAAOmE,UAAUQ,QAAU,SAAUN,EAActC,EAASC,EAAIC,GAC5D,MAAMqC,EAAevC,IAAW,EAC1BwC,EAAWvC,GAAM,GACjBwC,EAAO5C,EAAsB6C,KAAKxE,KAAMoE,EAAcpE,KAAKQ,QAAQH,YAAagE,EAAcC,EAAUtC,GAC9GuC,EAAKrD,WAAa,WAClBlB,KAAKa,UAAUM,YAAYoD,GAC3BvE,KAAKC,cAAcwE,KAAKF,IAO5BxE,EAAOmE,UAAUS,KAAO,SAAUP,EAActC,EAASC,EAAIC,GACzD,MAAMqC,EAAevC,IAAW,EAC1BwC,EAAWvC,GAAM,GACjBwC,EAAO5C,EAAsB6C,KAAKxE,KAAMoE,EAAcpE,KAAKQ,QAAQF,SAAU+D,EAAcC,EAAUtC,GAC3GuC,EAAKrD,WAAa,QAClBlB,KAAKa,UAAUM,YAAYoD,GAC3BvE,KAAKC,cAAcwE,KAAKF,IAoGrBxE,EA5KE","file":"notify.js","sourcesContent":["\r\n/* =======================================================================\r\n * FD Notify\r\n * Heavily inspired by Notyf, created by Carlos Roso\r\n * https://github.com/caroso1222/notyf\r\n * =======================================================================\r\n */\r\n\r\nvar Notify = (function () { // eslint-disable-line no-unused-vars\r\n function Notify() {\r\n //List of notifications currently active\r\n this.notifications = [];\r\n\r\n const defaults = {\r\n delay: 5000,\r\n alertIcon: 'notify-alert-icon',\r\n confirmIcon: 'notify-confirm-icon',\r\n infoIcon: 'notify-info-icon'\r\n };\r\n\r\n if (arguments[0] && typeof arguments[0] === \"object\") {\r\n this.options = extendDefaults(defaults, arguments[0]);\r\n } else {\r\n this.options = defaults;\r\n }\r\n // Checks to see if a notify container already exists on the page.\r\n // If it doesn't, create one.\r\n if (document.getElementsByClassName('notify-container').length) {\r\n this.container = document.getElementsByClassName('notify-container')[0];\r\n } else {\r\n const docFrag = document.createDocumentFragment();\r\n const notifyContainer = document.createElement('div');\r\n notifyContainer.className = 'notify-container';\r\n docFrag.appendChild(notifyContainer);\r\n document.body.appendChild(docFrag);\r\n this.container = notifyContainer;\r\n }\r\n\r\n\r\n //Stores which transitionEnd event this browser supports\r\n this.animationEnd = animationEndSelect();\r\n }\r\n\r\n //---------- Public methods ---------------\r\n /**\r\n * Shows an alert card\r\n */\r\n\r\n Notify.prototype.alert = function (alertMessage, persist, id, onClick) {\r\n const isPersistent = persist || false;\r\n const idString = id || \"\";\r\n const card = buildNotificationCard.call(this, alertMessage, this.options.alertIcon, isPersistent, idString, onClick);\r\n card.className += ' alert';\r\n this.container.appendChild(card);\r\n this.notifications.push(card);\r\n };\r\n\r\n\r\n /**\r\n * Shows a confirm card\r\n */\r\n Notify.prototype.confirm = function (alertMessage, persist, id, onClick) {\r\n const isPersistent = persist || false;\r\n const idString = id || \"\";\r\n const card = buildNotificationCard.call(this, alertMessage, this.options.confirmIcon, isPersistent, idString, onClick);\r\n card.className += ' confirm';\r\n this.container.appendChild(card);\r\n this.notifications.push(card);\r\n };\r\n\r\n\r\n /**\r\n * Shows a info card\r\n */\r\n Notify.prototype.info = function (alertMessage, persist, id, onClick) {\r\n const isPersistent = persist || false;\r\n const idString = id || \"\";\r\n const card = buildNotificationCard.call(this, alertMessage, this.options.infoIcon, isPersistent, idString, onClick);\r\n card.className += ' info';\r\n this.container.appendChild(card);\r\n this.notifications.push(card);\r\n };\r\n\r\n\r\n //---------- Private methods ---------------\r\n\r\n /**\r\n * Populates the source object with the value from the same keys found in destination\r\n */\r\n function extendDefaults(source, destination) {\r\n for (property in destination) {\r\n //Avoid assigning inherited properties of destination, only assign to source the destination own properties\r\n if (destination.hasOwnProperty(property)) {\r\n source[property] = destination[property];\r\n }\r\n }\r\n return source;\r\n }\r\n\r\n\r\n /**\r\n * Creates a generic card with the param message. Returns a document fragment.\r\n */\r\n function buildNotificationCard(messageText, iconClass, persist, id, onClick) {\r\n //Card wrapper\r\n const notification = document.createElement('div');\r\n notification.className = 'notify';\r\n notification.id = id;\r\n\r\n const wrapper = document.createElement('div');\r\n wrapper.className = 'notify-wrapper';\r\n\r\n const iconContainer = document.createElement('div');\r\n iconContainer.className = 'notify-icon';\r\n\r\n const icon = document.createElement('i');\r\n icon.className = iconClass;\r\n\r\n const message = document.createElement('div');\r\n message.className = 'notify-message';\r\n message.innerHTML = messageText;\r\n\r\n //Build the card\r\n iconContainer.appendChild(icon);\r\n wrapper.appendChild(iconContainer);\r\n wrapper.appendChild(message);\r\n notification.appendChild(wrapper);\r\n\r\n const _this = this;\r\n\r\n const hideNotification = function () {\r\n notification.className += \" disappear\";\r\n notification.addEventListener(_this.animationEnd, function (event) {\r\n event.target === notification && (notification.parentNode !== _this.container || _this.container.removeChild(notification));\r\n });\r\n const index = _this.notifications.indexOf(notification);\r\n _this.notifications.splice(index, 1);\r\n $(notification).off('click');\r\n };\r\n\r\n if (!persist) {\r\n setTimeout(function () {\r\n hideNotification();\r\n }, _this.options.delay);\r\n }\r\n\r\n $(notification).one('click', function () {\r\n if (onClick) {\r\n try {\r\n onClick();\r\n } catch (e) {\r\n console.error(e);\r\n }\r\n }\r\n hideNotification();\r\n });\r\n\r\n notification.style.cursor = \"pointer\";\r\n\r\n return notification;\r\n }\r\n\r\n\r\n // Determine which animationend event is supported\r\n function animationEndSelect() {\r\n const el = document.createElement('fake');\r\n const transitions = {\r\n 'transition': 'animationend',\r\n 'OTransition': 'oAnimationEnd',\r\n 'MozTransition': 'animationend',\r\n 'WebkitTransition': 'webkitAnimationEnd'\r\n };\r\n\r\n for (const t in transitions) {\r\n if (el.style[t] !== undefined) {\r\n return transitions[t];\r\n }\r\n }\r\n }\r\n\r\n return Notify;\r\n})();"]}