Comparing version 4.1.0 to 4.2.0
@@ -183,3 +183,5 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var transitionFull = options.transitionSelector + ' ' + options.transitionDuration + 's ' + options.transitionCurve; | ||
var getTransition = function getTransition() { | ||
return options.transitionSelector + ' ' + options.transitionDuration + 's ' + options.transitionCurve; | ||
}; | ||
@@ -204,3 +206,3 @@ var enterClicked = function enterClicked(event) { | ||
tick().then(function () { | ||
element.style.transition = transitionFull; | ||
element.style.transition = getTransition(); | ||
element.style[from] = 0; | ||
@@ -240,3 +242,3 @@ }); | ||
tick().then(function () { | ||
element.style.transition = transitionFull; | ||
element.style.transition = getTransition(); | ||
element.style.opacity = options.overlayOpacity; | ||
@@ -622,10 +624,29 @@ }); | ||
var handleDayInput = function handleDayInput(event) { | ||
var daysInMonth = new Date(value.getFullYear(), value.getMonth() + 1, 0).getDate(); | ||
var day = event.target.textContent.replace(/^0+/, '').replace(/[^\d]/g, '').slice(0, 2); | ||
if (Number(day) > daysInMonth) day = daysInMonth.toString(); | ||
event.target.textContent = day; | ||
if (Number(day) < 1) day = '1'; | ||
value.setDate(Number(day)); | ||
}; | ||
var elementDateDay = document.createElement('div'); | ||
elementDateDay.classList.add(options.classes.element); | ||
elementDateDay.classList.add(options.classes.elementThird); | ||
elementDateDay.setAttribute('contentEditable', true); | ||
elementDateDay.addEventListener('input', handleDayInput); | ||
elementDateDay.innerHTML = value.getDate(); | ||
var handleYearInput = function handleYearInput(event) { | ||
var year = event.target.textContent.replace(/^0+/, '').replace(/[^\d]/g, '').slice(0, 4); | ||
event.target.textContent = year; | ||
value.setFullYear(Number(year)); | ||
}; | ||
var elementDateYear = document.createElement('div'); | ||
elementDateYear.classList.add(options.classes.element); | ||
elementDateYear.classList.add(options.classes.elementThird); | ||
elementDateYear.setAttribute('contentEditable', true); | ||
elementDateYear.addEventListener('input', handleYearInput); | ||
elementDateYear.innerHTML = value.getFullYear(); | ||
@@ -654,30 +675,37 @@ | ||
elementDateUpMonth.onclick = function () { | ||
value.setMonth(value.getMonth() - 1); | ||
var updateMonth = function updateMonth(amount) { | ||
var daysInNextMonth = new Date(value.getFullYear(), value.getMonth() + amount + 1, 0).getDate(); | ||
if (value.getDate() > daysInNextMonth) value.setDate(daysInNextMonth); | ||
value.setMonth(value.getMonth() + amount); | ||
setValueHTML(value); | ||
}; | ||
elementDateUpDay.onclick = function () { | ||
value.setDate(value.getDate() - 1); | ||
var updateDay = function updateDay(amount) { | ||
value.setDate(value.getDate() + amount); | ||
setValueHTML(value); | ||
}; | ||
elementDateUpYear.onclick = function () { | ||
value.setFullYear(value.getFullYear() - 1); | ||
var updateYear = function updateYear(amount) { | ||
var nextYear = value.getFullYear() + amount; | ||
if (nextYear < 0) value.setFullYear(0);else value.setFullYear(value.getFullYear() + amount); | ||
setValueHTML(value); | ||
}; | ||
elementDateUpMonth.onclick = function () { | ||
return updateMonth(1); | ||
}; | ||
elementDateUpDay.onclick = function () { | ||
return updateDay(1); | ||
}; | ||
elementDateUpYear.onclick = function () { | ||
return updateYear(1); | ||
}; | ||
elementDateDownMonth.onclick = function () { | ||
value.setMonth(value.getMonth() + 1); | ||
setValueHTML(value); | ||
return updateMonth(-1); | ||
}; | ||
elementDateDownDay.onclick = function () { | ||
value.setDate(value.getDate() + 1); | ||
setValueHTML(value); | ||
return updateDay(-1); | ||
}; | ||
elementDateDownYear.onclick = function () { | ||
value.setFullYear(value.getFullYear() + 1); | ||
setValueHTML(value); | ||
return updateYear(-1); | ||
}; | ||
@@ -684,0 +712,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.notie=t():e.notie=t()}(this,function(){return function(e){function t(s){if(n[s])return n[s].exports;var a=n[s]={i:s,l:!1,exports:{}};return e[s].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,s){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:s})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";(function(e){var n,s,a,c="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};!function(i,l){"object"===c(t)&&"object"===c(e)?e.exports=l():(s=[],n=l,a="function"==typeof n?n.apply(t,s):n,!(void 0!==a&&(e.exports=a)))}(void 0,function(){return function(e){function t(s){if(n[s])return n[s].exports;var a=n[s]={i:s,l:!1,exports:{}};return e[s].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,s){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:s})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){function s(e,t){var n={};for(var s in e)t.indexOf(s)>=0||Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s]);return n}Object.defineProperty(t,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"===c(Symbol.iterator)?function(e){return"undefined"==typeof e?"undefined":c(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":"undefined"==typeof e?"undefined":c(e)},i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},l={alertTime:3,dateMonths:["January","February","March","April","May","June","July","August","September","October","November","December"],overlayClickDismiss:!0,overlayOpacity:.75,transitionCurve:"ease",transitionDuration:.3,transitionSelector:"all",classes:{container:"notie-container",textbox:"notie-textbox",textboxInner:"notie-textbox-inner",button:"notie-button",element:"notie-element",elementHalf:"notie-element-half",elementThird:"notie-element-third",overlay:"notie-overlay",backgroundSuccess:"notie-background-success",backgroundWarning:"notie-background-warning",backgroundError:"notie-background-error",backgroundInfo:"notie-background-info",backgroundNeutral:"notie-background-neutral",backgroundOverlay:"notie-background-overlay",alert:"notie-alert",inputField:"notie-input-field",selectChoiceRepeated:"notie-select-choice-repeated",dateSelectorInner:"notie-date-selector-inner",dateSelectorUp:"notie-date-selector-up"},ids:{overlay:"notie-overlay"}},o=t.setOptions=function(e){l=i({},l,e,{classes:i({},l.classes,e.classes),ids:i({},l.ids,e.ids)})},r=function(){return new Promise(function(e){return setTimeout(e,0)})},d=function(e){return new Promise(function(t){return setTimeout(t,1e3*e)})},u=function(){document.activeElement&&document.activeElement.blur()},f=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)});return"notie-"+e},p={1:l.classes.backgroundSuccess,success:l.classes.backgroundSuccess,2:l.classes.backgroundWarning,warning:l.classes.backgroundWarning,3:l.classes.backgroundError,error:l.classes.backgroundError,4:l.classes.backgroundInfo,info:l.classes.backgroundInfo,5:l.classes.backgroundNeutral,neutral:l.classes.backgroundNeutral},m=l.transitionSelector+" "+l.transitionDuration+"s "+l.transitionCurve,v=function(e){return 13===e.keyCode},b=function(e){return 27===e.keyCode},x=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top";e.classList.add(l.classes.container),e.style[t]="-10000px",document.body.appendChild(e),e.style[t]="-"+e.offsetHeight+"px",e.listener&&window.addEventListener("keydown",e.listener),r().then(function(){e.style.transition=m,e.style[t]=0})},y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top",n=document.getElementById(e);n&&(n.style[t]="-"+n.offsetHeight+"px",n.listener&&window.removeEventListener("keydown",n.listener),d(l.transitionDuration).then(function(){n.parentNode&&n.parentNode.removeChild(n)}))},L=function(e,t){var n=document.createElement("div");n.id=l.ids.overlay,n.classList.add(l.classes.overlay),n.classList.add(l.classes.backgroundOverlay),n.style.opacity=0,e&&l.overlayClickDismiss&&(n.onclick=function(){y(e.id,t),h()}),document.body.appendChild(n),r().then(function(){n.style.transition=m,n.style.opacity=l.overlayOpacity})},h=function(){var e=document.getElementById(l.ids.overlay);e.style.opacity=0,d(l.transitionDuration).then(function(){e.parentNode&&e.parentNode.removeChild(e)})},k=t.hideAlerts=function(e){var t=document.getElementsByClassName(l.classes.alert);if(t.length){for(var n=0;n<t.length;n++){var s=t[n];y(s.id)}e&&d(l.transitionDuration).then(function(){return e()})}},g=t.alert=function(e){var t=e.type,n=void 0===t?4:t,s=e.text,a=e.time,c=void 0===a?l.alertTime:a,i=e.stay,o=void 0!==i&&i;u(),k();var r=document.createElement("div"),m=f();r.id=m,r.classList.add(l.classes.textbox),r.classList.add(p[n]),r.classList.add(l.classes.alert),r.innerHTML='<div class="'+l.classes.textboxInner+'">'+s+"</div>",r.onclick=function(){return y(m)},r.listener=function(e){(v(e)||b(e))&&k()},x(r),c&&c<1&&(c=1),!o&&c&&d(c).then(function(){return y(m)})},C=t.force=function(e,t){var n=e.type,s=void 0===n?5:n,a=e.text,c=e.buttonText,i=void 0===c?"OK":c,o=e.callback;u(),k();var r=document.createElement("div"),d=f();r.id=d;var m=document.createElement("div");m.classList.add(l.classes.textbox),m.classList.add(l.classes.backgroundInfo),m.innerHTML='<div class="'+l.classes.textboxInner+'">'+a+"</div>";var b=document.createElement("div");b.classList.add(l.classes.button),b.classList.add(p[s]),b.innerHTML=i,b.onclick=function(){y(d),h(),o?o():t&&t()},r.appendChild(m),r.appendChild(b),r.listener=function(e){v(e)&&b.click()},x(r),L()},T=t.confirm=function(e,t,n){var s=e.text,a=e.submitText,c=void 0===a?"Yes":a,i=e.cancelText,o=void 0===i?"Cancel":i,r=e.submitCallback,d=e.cancelCallback;u(),k();var p=document.createElement("div"),m=f();p.id=m;var g=document.createElement("div");g.classList.add(l.classes.textbox),g.classList.add(l.classes.backgroundInfo),g.innerHTML='<div class="'+l.classes.textboxInner+'">'+s+"</div>";var C=document.createElement("div");C.classList.add(l.classes.button),C.classList.add(l.classes.elementHalf),C.classList.add(l.classes.backgroundSuccess),C.innerHTML=c,C.onclick=function(){y(m),h(),r?r():t&&t()};var T=document.createElement("div");T.classList.add(l.classes.button),T.classList.add(l.classes.elementHalf),T.classList.add(l.classes.backgroundError),T.innerHTML=o,T.onclick=function(){y(m),h(),d?d():n&&n()},p.appendChild(g),p.appendChild(C),p.appendChild(T),p.listener=function(e){v(e)?C.click():b(e)&&T.click()},x(p),L(p)},E=function(e,t,n){var c=e.text,i=e.submitText,o=void 0===i?"Submit":i,r=e.cancelText,d=void 0===r?"Cancel":r,p=e.submitCallback,m=e.cancelCallback,g=s(e,["text","submitText","cancelText","submitCallback","cancelCallback"]);u(),k();var C=document.createElement("div"),T=f();C.id=T;var E=document.createElement("div");E.classList.add(l.classes.textbox),E.classList.add(l.classes.backgroundInfo),E.innerHTML='<div class="'+l.classes.textboxInner+'">'+c+"</div>";var M=document.createElement("input");M.classList.add(l.classes.inputField),M.setAttribute("autocapitalize",g.autocapitalize||"none"),M.setAttribute("autocomplete",g.autocomplete||"off"),M.setAttribute("autocorrect",g.autocorrect||"off"),M.setAttribute("autofocus",g.autofocus||"true"),M.setAttribute("inputmode",g.inputmode||"verbatim"),M.setAttribute("max",g.max||""),M.setAttribute("maxlength",g.maxlength||""),M.setAttribute("min",g.min||""),M.setAttribute("minlength",g.minlength||""),M.setAttribute("placeholder",g.placeholder||""),M.setAttribute("spellcheck",g.spellcheck||"default"),M.setAttribute("step",g.step||"any"),M.setAttribute("type",g.type||"text"),M.value=g.value||"",g.allowed&&(M.oninput=function(){var e=void 0;if(Array.isArray(g.allowed)){for(var t="",n=g.allowed,s=0;s<n.length;s++)"an"===n[s]?t+="0-9a-zA-Z":"a"===n[s]?t+="a-zA-Z":"n"===n[s]&&(t+="0-9"),"s"===n[s]&&(t+=" ");e=new RegExp("[^"+t+"]","g")}else"object"===a(g.allowed)&&(e=g.allowed);M.value=M.value.replace(e,"")});var H=document.createElement("div");H.classList.add(l.classes.button),H.classList.add(l.classes.elementHalf),H.classList.add(l.classes.backgroundSuccess),H.innerHTML=o,H.onclick=function(){y(T),h(),p?p(M.value):t&&t(M.value)};var S=document.createElement("div");S.classList.add(l.classes.button),S.classList.add(l.classes.elementHalf),S.classList.add(l.classes.backgroundError),S.innerHTML=d,S.onclick=function(){y(T),h(),m?m(M.value):n&&n(M.value)},C.appendChild(E),C.appendChild(M),C.appendChild(H),C.appendChild(S),C.listener=function(e){v(e)?H.click():b(e)&&S.click()},x(C),M.focus(),L(C)};t.input=E;var M=t.select=function(e,t){var n=e.text,s=e.cancelText,a=void 0===s?"Cancel":s,c=e.cancelCallback,i=e.choices;u(),k();var o="bottom",r=document.createElement("div"),d=f();r.id=d;var m=document.createElement("div");m.classList.add(l.classes.textbox),m.classList.add(l.classes.backgroundInfo),m.innerHTML='<div class="'+l.classes.textboxInner+'">'+n+"</div>",r.appendChild(m),i.forEach(function(e,t){var n=e.type,s=void 0===n?1:n,a=e.text,c=e.handler,u=document.createElement("div");u.classList.add(p[s]),u.classList.add(l.classes.button),u.classList.add(l.classes.selectChoice);var f=i[t+1];f&&!f.type&&(f.type=1),f&&f.type===s&&u.classList.add(l.classes.selectChoiceRepeated),u.innerHTML=a,u.onclick=function(){y(d,o),h(),c()},r.appendChild(u)});var v=document.createElement("div");v.classList.add(l.classes.backgroundNeutral),v.classList.add(l.classes.button),v.innerHTML=a,v.onclick=function(){y(d,o),h(),c?c():t&&t()},r.appendChild(v),r.listener=function(e){b(e)&&v.click()},x(r,o),L(r,o)},H=t.date=function(e,t,n){var s=e.value,a=void 0===s?new Date:s,c=e.submitText,i=void 0===c?"OK":c,o=e.cancelText,r=void 0===o?"Cancel":o,d=e.submitCallback,p=e.cancelCallback;u(),k();var m="▾",g=document.createElement("div"),C=f();g.id=C;var T=document.createElement("div");T.classList.add(l.classes.backgroundInfo);var E=document.createElement("div");E.classList.add(l.classes.dateSelectorInner);var M=document.createElement("div");M.classList.add(l.classes.button),M.classList.add(l.classes.elementThird),M.classList.add(l.classes.dateSelectorUp),M.innerHTML=m;var H=document.createElement("div");H.classList.add(l.classes.button),H.classList.add(l.classes.elementThird),H.classList.add(l.classes.dateSelectorUp),H.innerHTML=m;var S=document.createElement("div");S.classList.add(l.classes.button),S.classList.add(l.classes.elementThird),S.classList.add(l.classes.dateSelectorUp),S.innerHTML=m;var O=document.createElement("div");O.classList.add(l.classes.element),O.classList.add(l.classes.elementThird),O.innerHTML=l.dateMonths[a.getMonth()];var w=document.createElement("div");w.classList.add(l.classes.element),w.classList.add(l.classes.elementThird),w.innerHTML=a.getDate();var A=document.createElement("div");A.classList.add(l.classes.element),A.classList.add(l.classes.elementThird),A.innerHTML=a.getFullYear();var I=document.createElement("div");I.classList.add(l.classes.button),I.classList.add(l.classes.elementThird),I.innerHTML=m;var j=document.createElement("div");j.classList.add(l.classes.button),j.classList.add(l.classes.elementThird),j.innerHTML=m;var D=document.createElement("div");D.classList.add(l.classes.button),D.classList.add(l.classes.elementThird),D.innerHTML=m;var P=function(e){O.innerHTML=l.dateMonths[e.getMonth()],w.innerHTML=e.getDate(),A.innerHTML=e.getFullYear()};M.onclick=function(){a.setMonth(a.getMonth()-1),P(a)},H.onclick=function(){a.setDate(a.getDate()-1),P(a)},S.onclick=function(){a.setFullYear(a.getFullYear()-1),P(a)},I.onclick=function(){a.setMonth(a.getMonth()+1),P(a)},j.onclick=function(){a.setDate(a.getDate()+1),P(a)},D.onclick=function(){a.setFullYear(a.getFullYear()+1),P(a)};var N=document.createElement("div");N.classList.add(l.classes.button),N.classList.add(l.classes.elementHalf),N.classList.add(l.classes.backgroundSuccess),N.innerHTML=i,N.onclick=function(){y(C),h(),d?d(a):t&&t(a)};var F=document.createElement("div");F.classList.add(l.classes.button),F.classList.add(l.classes.elementHalf),F.classList.add(l.classes.backgroundError),F.innerHTML=r,F.onclick=function(){y(C),h(),p?p(a):n&&n(a)},E.appendChild(M),E.appendChild(H),E.appendChild(S),E.appendChild(O),E.appendChild(w),E.appendChild(A),E.appendChild(I),E.appendChild(j),E.appendChild(D),T.appendChild(E),g.appendChild(T),g.appendChild(N),g.appendChild(F),g.listener=function(e){v(e)?N.click():b(e)&&F.click()},x(g),L(g)};t.default={alert:g,force:C,confirm:T,input:E,select:M,date:H,setOptions:o,hideAlerts:k}}])})}).call(t,n(0)(e))}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.notie=t():e.notie=t()}(this,function(){return function(e){function t(a){if(n[a])return n[a].exports;var s=n[a]={i:a,l:!1,exports:{}};return e[a].call(s.exports,s,s.exports,t),s.l=!0,s.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,a){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:a})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";(function(e){var n,a,s,c="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};!function(i,r){"object"===c(t)&&"object"===c(e)?e.exports=r():(a=[],n=r,s="function"==typeof n?n.apply(t,a):n,!(void 0!==s&&(e.exports=s)))}(void 0,function(){return function(e){function t(a){if(n[a])return n[a].exports;var s=n[a]={i:a,l:!1,exports:{}};return e[a].call(s.exports,s,s.exports,t),s.l=!0,s.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,a){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:a})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){function a(e,t){var n={};for(var a in e)t.indexOf(a)>=0||Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);return n}Object.defineProperty(t,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"===c(Symbol.iterator)?function(e){return"undefined"==typeof e?"undefined":c(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":"undefined"==typeof e?"undefined":c(e)},i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},r={alertTime:3,dateMonths:["January","February","March","April","May","June","July","August","September","October","November","December"],overlayClickDismiss:!0,overlayOpacity:.75,transitionCurve:"ease",transitionDuration:.3,transitionSelector:"all",classes:{container:"notie-container",textbox:"notie-textbox",textboxInner:"notie-textbox-inner",button:"notie-button",element:"notie-element",elementHalf:"notie-element-half",elementThird:"notie-element-third",overlay:"notie-overlay",backgroundSuccess:"notie-background-success",backgroundWarning:"notie-background-warning",backgroundError:"notie-background-error",backgroundInfo:"notie-background-info",backgroundNeutral:"notie-background-neutral",backgroundOverlay:"notie-background-overlay",alert:"notie-alert",inputField:"notie-input-field",selectChoiceRepeated:"notie-select-choice-repeated",dateSelectorInner:"notie-date-selector-inner",dateSelectorUp:"notie-date-selector-up"},ids:{overlay:"notie-overlay"}},l=t.setOptions=function(e){r=i({},r,e,{classes:i({},r.classes,e.classes),ids:i({},r.ids,e.ids)})},o=function(){return new Promise(function(e){return setTimeout(e,0)})},d=function(e){return new Promise(function(t){return setTimeout(t,1e3*e)})},u=function(){document.activeElement&&document.activeElement.blur()},f=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)});return"notie-"+e},p={1:r.classes.backgroundSuccess,success:r.classes.backgroundSuccess,2:r.classes.backgroundWarning,warning:r.classes.backgroundWarning,3:r.classes.backgroundError,error:r.classes.backgroundError,4:r.classes.backgroundInfo,info:r.classes.backgroundInfo,5:r.classes.backgroundNeutral,neutral:r.classes.backgroundNeutral},m=function(){return r.transitionSelector+" "+r.transitionDuration+"s "+r.transitionCurve},v=function(e){return 13===e.keyCode},b=function(e){return 27===e.keyCode},x=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top";e.classList.add(r.classes.container),e.style[t]="-10000px",document.body.appendChild(e),e.style[t]="-"+e.offsetHeight+"px",e.listener&&window.addEventListener("keydown",e.listener),o().then(function(){e.style.transition=m(),e.style[t]=0})},y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top",n=document.getElementById(e);n&&(n.style[t]="-"+n.offsetHeight+"px",n.listener&&window.removeEventListener("keydown",n.listener),d(r.transitionDuration).then(function(){n.parentNode&&n.parentNode.removeChild(n)}))},L=function(e,t){var n=document.createElement("div");n.id=r.ids.overlay,n.classList.add(r.classes.overlay),n.classList.add(r.classes.backgroundOverlay),n.style.opacity=0,e&&r.overlayClickDismiss&&(n.onclick=function(){y(e.id,t),g()}),document.body.appendChild(n),o().then(function(){n.style.transition=m(),n.style.opacity=r.overlayOpacity})},g=function(){var e=document.getElementById(r.ids.overlay);e.style.opacity=0,d(r.transitionDuration).then(function(){e.parentNode&&e.parentNode.removeChild(e)})},h=t.hideAlerts=function(e){var t=document.getElementsByClassName(r.classes.alert);if(t.length){for(var n=0;n<t.length;n++){var a=t[n];y(a.id)}e&&d(r.transitionDuration).then(function(){return e()})}},k=t.alert=function(e){var t=e.type,n=void 0===t?4:t,a=e.text,s=e.time,c=void 0===s?r.alertTime:s,i=e.stay,l=void 0!==i&&i;u(),h();var o=document.createElement("div"),m=f();o.id=m,o.classList.add(r.classes.textbox),o.classList.add(p[n]),o.classList.add(r.classes.alert),o.innerHTML='<div class="'+r.classes.textboxInner+'">'+a+"</div>",o.onclick=function(){return y(m)},o.listener=function(e){(v(e)||b(e))&&h()},x(o),c&&c<1&&(c=1),!l&&c&&d(c).then(function(){return y(m)})},C=t.force=function(e,t){var n=e.type,a=void 0===n?5:n,s=e.text,c=e.buttonText,i=void 0===c?"OK":c,l=e.callback;u(),h();var o=document.createElement("div"),d=f();o.id=d;var m=document.createElement("div");m.classList.add(r.classes.textbox),m.classList.add(r.classes.backgroundInfo),m.innerHTML='<div class="'+r.classes.textboxInner+'">'+s+"</div>";var b=document.createElement("div");b.classList.add(r.classes.button),b.classList.add(p[a]),b.innerHTML=i,b.onclick=function(){y(d),g(),l?l():t&&t()},o.appendChild(m),o.appendChild(b),o.listener=function(e){v(e)&&b.click()},x(o),L()},E=t.confirm=function(e,t,n){var a=e.text,s=e.submitText,c=void 0===s?"Yes":s,i=e.cancelText,l=void 0===i?"Cancel":i,o=e.submitCallback,d=e.cancelCallback;u(),h();var p=document.createElement("div"),m=f();p.id=m;var k=document.createElement("div");k.classList.add(r.classes.textbox),k.classList.add(r.classes.backgroundInfo),k.innerHTML='<div class="'+r.classes.textboxInner+'">'+a+"</div>";var C=document.createElement("div");C.classList.add(r.classes.button),C.classList.add(r.classes.elementHalf),C.classList.add(r.classes.backgroundSuccess),C.innerHTML=c,C.onclick=function(){y(m),g(),o?o():t&&t()};var E=document.createElement("div");E.classList.add(r.classes.button),E.classList.add(r.classes.elementHalf),E.classList.add(r.classes.backgroundError),E.innerHTML=l,E.onclick=function(){y(m),g(),d?d():n&&n()},p.appendChild(k),p.appendChild(C),p.appendChild(E),p.listener=function(e){v(e)?C.click():b(e)&&E.click()},x(p),L(p)},T=function(e,t,n){var c=e.text,i=e.submitText,l=void 0===i?"Submit":i,o=e.cancelText,d=void 0===o?"Cancel":o,p=e.submitCallback,m=e.cancelCallback,k=a(e,["text","submitText","cancelText","submitCallback","cancelCallback"]);u(),h();var C=document.createElement("div"),E=f();C.id=E;var T=document.createElement("div");T.classList.add(r.classes.textbox),T.classList.add(r.classes.backgroundInfo),T.innerHTML='<div class="'+r.classes.textboxInner+'">'+c+"</div>";var M=document.createElement("input");M.classList.add(r.classes.inputField),M.setAttribute("autocapitalize",k.autocapitalize||"none"),M.setAttribute("autocomplete",k.autocomplete||"off"),M.setAttribute("autocorrect",k.autocorrect||"off"),M.setAttribute("autofocus",k.autofocus||"true"),M.setAttribute("inputmode",k.inputmode||"verbatim"),M.setAttribute("max",k.max||""),M.setAttribute("maxlength",k.maxlength||""),M.setAttribute("min",k.min||""),M.setAttribute("minlength",k.minlength||""),M.setAttribute("placeholder",k.placeholder||""),M.setAttribute("spellcheck",k.spellcheck||"default"),M.setAttribute("step",k.step||"any"),M.setAttribute("type",k.type||"text"),M.value=k.value||"",k.allowed&&(M.oninput=function(){var e=void 0;if(Array.isArray(k.allowed)){for(var t="",n=k.allowed,a=0;a<n.length;a++)"an"===n[a]?t+="0-9a-zA-Z":"a"===n[a]?t+="a-zA-Z":"n"===n[a]&&(t+="0-9"),"s"===n[a]&&(t+=" ");e=new RegExp("[^"+t+"]","g")}else"object"===s(k.allowed)&&(e=k.allowed);M.value=M.value.replace(e,"")});var H=document.createElement("div");H.classList.add(r.classes.button),H.classList.add(r.classes.elementHalf),H.classList.add(r.classes.backgroundSuccess),H.innerHTML=l,H.onclick=function(){y(E),g(),p?p(M.value):t&&t(M.value)};var S=document.createElement("div");S.classList.add(r.classes.button),S.classList.add(r.classes.elementHalf),S.classList.add(r.classes.backgroundError),S.innerHTML=d,S.onclick=function(){y(E),g(),m?m(M.value):n&&n(M.value)},C.appendChild(T),C.appendChild(M),C.appendChild(H),C.appendChild(S),C.listener=function(e){v(e)?H.click():b(e)&&S.click()},x(C),M.focus(),L(C)};t.input=T;var M=t.select=function(e,t){var n=e.text,a=e.cancelText,s=void 0===a?"Cancel":a,c=e.cancelCallback,i=e.choices;u(),h();var l="bottom",o=document.createElement("div"),d=f();o.id=d;var m=document.createElement("div");m.classList.add(r.classes.textbox),m.classList.add(r.classes.backgroundInfo),m.innerHTML='<div class="'+r.classes.textboxInner+'">'+n+"</div>",o.appendChild(m),i.forEach(function(e,t){var n=e.type,a=void 0===n?1:n,s=e.text,c=e.handler,u=document.createElement("div");u.classList.add(p[a]),u.classList.add(r.classes.button),u.classList.add(r.classes.selectChoice);var f=i[t+1];f&&!f.type&&(f.type=1),f&&f.type===a&&u.classList.add(r.classes.selectChoiceRepeated),u.innerHTML=s,u.onclick=function(){y(d,l),g(),c()},o.appendChild(u)});var v=document.createElement("div");v.classList.add(r.classes.backgroundNeutral),v.classList.add(r.classes.button),v.innerHTML=s,v.onclick=function(){y(d,l),g(),c?c():t&&t()},o.appendChild(v),o.listener=function(e){b(e)&&v.click()},x(o,l),L(o,l)},H=t.date=function(e,t,n){var a=e.value,s=void 0===a?new Date:a,c=e.submitText,i=void 0===c?"OK":c,l=e.cancelText,o=void 0===l?"Cancel":l,d=e.submitCallback,p=e.cancelCallback;u(),h();var m="▾",k=document.createElement("div"),C=f();k.id=C;var E=document.createElement("div");E.classList.add(r.classes.backgroundInfo);var T=document.createElement("div");T.classList.add(r.classes.dateSelectorInner);var M=document.createElement("div");M.classList.add(r.classes.button),M.classList.add(r.classes.elementThird),M.classList.add(r.classes.dateSelectorUp),M.innerHTML=m;var H=document.createElement("div");H.classList.add(r.classes.button),H.classList.add(r.classes.elementThird),H.classList.add(r.classes.dateSelectorUp),H.innerHTML=m;var S=document.createElement("div");S.classList.add(r.classes.button),S.classList.add(r.classes.elementThird),S.classList.add(r.classes.dateSelectorUp),S.innerHTML=m;var w=document.createElement("div");w.classList.add(r.classes.element),w.classList.add(r.classes.elementThird),w.innerHTML=r.dateMonths[s.getMonth()];var O=function(e){var t=new Date(s.getFullYear(),s.getMonth()+1,0).getDate(),n=e.target.textContent.replace(/^0+/,"").replace(/[^\d]/g,"").slice(0,2);Number(n)>t&&(n=t.toString()),e.target.textContent=n,Number(n)<1&&(n="1"),s.setDate(Number(n))},A=document.createElement("div");A.classList.add(r.classes.element),A.classList.add(r.classes.elementThird),A.setAttribute("contentEditable",!0),A.addEventListener("input",O),A.innerHTML=s.getDate();var D=function(e){var t=e.target.textContent.replace(/^0+/,"").replace(/[^\d]/g,"").slice(0,4);e.target.textContent=t,s.setFullYear(Number(t))},I=document.createElement("div");I.classList.add(r.classes.element),I.classList.add(r.classes.elementThird),I.setAttribute("contentEditable",!0),I.addEventListener("input",D),I.innerHTML=s.getFullYear();var j=document.createElement("div");j.classList.add(r.classes.button),j.classList.add(r.classes.elementThird),j.innerHTML=m;var N=document.createElement("div");N.classList.add(r.classes.button),N.classList.add(r.classes.elementThird),N.innerHTML=m;var P=document.createElement("div");P.classList.add(r.classes.button),P.classList.add(r.classes.elementThird),P.innerHTML=m;var F=function(e){w.innerHTML=r.dateMonths[e.getMonth()],A.innerHTML=e.getDate(),I.innerHTML=e.getFullYear()},Y=function(e){var t=new Date(s.getFullYear(),s.getMonth()+e+1,0).getDate();s.getDate()>t&&s.setDate(t),s.setMonth(s.getMonth()+e),F(s)},_=function(e){s.setDate(s.getDate()+e),F(s)},z=function(e){var t=s.getFullYear()+e;t<0?s.setFullYear(0):s.setFullYear(s.getFullYear()+e),F(s)};M.onclick=function(){return Y(1)},H.onclick=function(){return _(1)},S.onclick=function(){return z(1)},j.onclick=function(){return Y(-1)},N.onclick=function(){return _(-1)},P.onclick=function(){return z(-1)};var U=document.createElement("div");U.classList.add(r.classes.button),U.classList.add(r.classes.elementHalf),U.classList.add(r.classes.backgroundSuccess),U.innerHTML=i,U.onclick=function(){y(C),g(),d?d(s):t&&t(s)};var B=document.createElement("div");B.classList.add(r.classes.button),B.classList.add(r.classes.elementHalf),B.classList.add(r.classes.backgroundError),B.innerHTML=o,B.onclick=function(){y(C),g(),p?p(s):n&&n(s)},T.appendChild(M),T.appendChild(H),T.appendChild(S),T.appendChild(w),T.appendChild(A),T.appendChild(I),T.appendChild(j),T.appendChild(N),T.appendChild(P),E.appendChild(T),k.appendChild(E),k.appendChild(U),k.appendChild(B),k.listener=function(e){v(e)?U.click():b(e)&&B.click()},x(k),L(k)};t.default={alert:k,force:C,confirm:E,input:T,select:M,date:H,setOptions:l,hideAlerts:h}}])})}).call(t,n(0)(e))}])}); |
@@ -5,3 +5,3 @@ { | ||
"author": "Jared Reich", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"main": "./dist/notie.min.js", | ||
@@ -8,0 +8,0 @@ "files": [ |
@@ -147,4 +147,4 @@ # notie | ||
```javascript | ||
notie.alert({ text: 'Info!') | ||
notie.alert({ type: 1, text: 'Success!', stay: true) // Never hides unless clicked, or escape or enter is pressed | ||
notie.alert({ text: 'Info!' }) | ||
notie.alert({ type: 1, text: 'Success!', stay: true }) // Never hides unless clicked, or escape or enter is pressed | ||
notie.alert({ type: 'success', text: 'Success!', time: 2 }) // Hides after 2 seconds | ||
@@ -151,0 +151,0 @@ notie.alert({ type: 2, text: 'Warning<br><b>with</b><br><i>HTML</i><br><u>included.</u>' }) |
@@ -83,3 +83,5 @@ // ==================== | ||
const transitionFull = `${options.transitionSelector} ${options.transitionDuration}s ${options.transitionCurve}` | ||
const getTransition = () => ( | ||
`${options.transitionSelector} ${options.transitionDuration}s ${options.transitionCurve}` | ||
) | ||
@@ -98,3 +100,3 @@ const enterClicked = event => event.keyCode === 13 | ||
tick().then(() => { | ||
element.style.transition = transitionFull | ||
element.style.transition = getTransition() | ||
element.style[from] = 0 | ||
@@ -132,3 +134,3 @@ }) | ||
tick().then(() => { | ||
element.style.transition = transitionFull | ||
element.style.transition = getTransition() | ||
element.style.opacity = options.overlayOpacity | ||
@@ -499,10 +501,39 @@ }) | ||
const handleDayInput = event => { | ||
const daysInMonth = new Date( | ||
value.getFullYear(), | ||
value.getMonth() + 1, | ||
0 | ||
).getDate() | ||
let day = event.target.textContent | ||
.replace(/^0+/, '') | ||
.replace(/[^\d]/g, '') | ||
.slice(0, 2) | ||
if (Number(day) > daysInMonth) day = daysInMonth.toString() | ||
event.target.textContent = day | ||
if (Number(day) < 1) day = '1' | ||
value.setDate(Number(day)) | ||
} | ||
const elementDateDay = document.createElement('div') | ||
elementDateDay.classList.add(options.classes.element) | ||
elementDateDay.classList.add(options.classes.elementThird) | ||
elementDateDay.setAttribute('contentEditable', true) | ||
elementDateDay.addEventListener('input', handleDayInput) | ||
elementDateDay.innerHTML = value.getDate() | ||
const handleYearInput = event => { | ||
const year = event.target.textContent | ||
.replace(/^0+/, '') | ||
.replace(/[^\d]/g, '') | ||
.slice(0, 4) | ||
event.target.textContent = year | ||
value.setFullYear(Number(year)) | ||
} | ||
const elementDateYear = document.createElement('div') | ||
elementDateYear.classList.add(options.classes.element) | ||
elementDateYear.classList.add(options.classes.elementThird) | ||
elementDateYear.setAttribute('contentEditable', true) | ||
elementDateYear.addEventListener('input', handleYearInput) | ||
elementDateYear.innerHTML = value.getFullYear() | ||
@@ -531,32 +562,32 @@ | ||
elementDateUpMonth.onclick = () => { | ||
value.setMonth(value.getMonth() - 1) | ||
const updateMonth = amount => { | ||
const daysInNextMonth = new Date( | ||
value.getFullYear(), | ||
value.getMonth() + amount + 1, | ||
0 | ||
).getDate() | ||
if (value.getDate() > daysInNextMonth) value.setDate(daysInNextMonth) | ||
value.setMonth(value.getMonth() + amount) | ||
setValueHTML(value) | ||
} | ||
elementDateUpDay.onclick = () => { | ||
value.setDate(value.getDate() - 1) | ||
const updateDay = amount => { | ||
value.setDate(value.getDate() + amount) | ||
setValueHTML(value) | ||
} | ||
elementDateUpYear.onclick = () => { | ||
value.setFullYear(value.getFullYear() - 1) | ||
const updateYear = amount => { | ||
const nextYear = value.getFullYear() + amount | ||
if (nextYear < 0) value.setFullYear(0) | ||
else value.setFullYear(value.getFullYear() + amount) | ||
setValueHTML(value) | ||
} | ||
elementDateDownMonth.onclick = () => { | ||
value.setMonth(value.getMonth() + 1) | ||
setValueHTML(value) | ||
} | ||
elementDateUpMonth.onclick = () => updateMonth(1) | ||
elementDateUpDay.onclick = () => updateDay(1) | ||
elementDateUpYear.onclick = () => updateYear(1) | ||
elementDateDownMonth.onclick = () => updateMonth(-1) | ||
elementDateDownDay.onclick = () => updateDay(-1) | ||
elementDateDownYear.onclick = () => updateYear(-1) | ||
elementDateDownDay.onclick = () => { | ||
value.setDate(value.getDate() + 1) | ||
setValueHTML(value) | ||
} | ||
elementDateDownYear.onclick = () => { | ||
value.setFullYear(value.getFullYear() + 1) | ||
setValueHTML(value) | ||
} | ||
const elementButtonLeft = document.createElement('div') | ||
@@ -563,0 +594,0 @@ elementButtonLeft.classList.add(options.classes.button) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82342
1271