Comparing version 3.3.1 to 3.8.0
@@ -5,3 +5,3 @@ { | ||
"main": [ | ||
"dist/notie.js", | ||
"dist/notie.min.js", | ||
"dist/notie.css" | ||
@@ -8,0 +8,0 @@ ], |
@@ -1,1 +0,1 @@ | ||
var notie=function(){function e(e){for(var t in e)k[t]=e[t]}function t(e,t,i){k.colorText.length>0&&(x.style.color=k.colorText),g(),H++,setTimeout(function(){H--},k.animationDelay+10),1===H&&(w?n(function(){o(e,t,i)}):o(e,t,i))}function o(e,t,o){w=!0;var i=0;switch(i="undefined"==typeof o||0===o?864e5:o>0&&1>o?1e3:1e3*o,f(v,"notie-background-success"),f(v,"notie-background-warning"),f(v,"notie-background-error"),f(v,"notie-background-info"),e){case 1:case"success":k.colorSuccess.length>0?v.style.backgroundColor=k.colorSuccess:y(v,"notie-background-success");break;case 2:case"warning":k.colorWarning.length>0?v.style.backgroundColor=k.colorWarning:y(v,"notie-background-warning");break;case 3:case"error":k.colorError.length>0?v.style.backgroundColor=k.colorError:y(v,"notie-background-error");break;case 4:case"info":k.colorInfo.length>0?v.style.backgroundColor=k.colorInfo:y(v,"notie-background-info")}x.innerHTML=t,v.style.top="-10000px",v.style.display="table",v.style.top="-"+v.offsetHeight-5+"px",E=setTimeout(function(){y(v,"notie-transition"),v.style.top=0,D=setTimeout(function(){n(function(){})},i)},20)}function n(e){clearTimeout(E),clearTimeout(D),v.style.top="-"+v.offsetHeight-5+"px",setTimeout(function(){f(v,"notie-transition"),v.style.top="-10000px",w=!1,e&&e()},k.animationDelay+10)}function i(e,t,o,i,l){k.colorInfo.length>0&&(I.style.backgroundColor=k.colorInfo),k.colorSuccess.length>0&&(S.style.backgroundColor=k.colorSuccess),k.colorError.length>0&&(A.style.backgroundColor=k.colorError),k.colorText.length>0&&(M.style.color=k.colorText,N.style.color=k.colorText,W.style.color=k.colorText),g(),w?n(function(){c(e,t,o,i,l)}):c(e,t,o,i,l)}function c(e,t,o,n,i){function c(){M.innerHTML=e,N.innerHTML=t,W.innerHTML=o,L.style.top="-10000px",L.style.display="table",L.style.top="-"+L.offsetHeight-5+"px",V.style.display="block",setTimeout(function(){y(L,"notie-transition"),L.style.top=0,V.style.opacity="0.75",setTimeout(function(){j=!0},k.animationDelay+10)},20)}b(),S.onclick=function(){l(),n&&setTimeout(function(){n()},k.animationDelay+10)},A.onclick=function(){l(),i&&setTimeout(function(){i()},k.animationDelay+10)},j?(l(),setTimeout(function(){c()},k.animationDelay+10)):c()}function l(){L.style.top="-"+L.offsetHeight-5+"px",V.style.opacity="0",setTimeout(function(){f(L,"notie-transition"),L.style.top="-10000px",V.style.display="none",h(),j=!1},k.animationDelay+10)}function r(e,t,o,i,c,l){k.colorInfo.length>0&&(O.style.backgroundColor=k.colorInfo),k.colorSuccess.length>0&&($.style.backgroundColor=k.colorSuccess),k.colorError.length>0&&(q.style.backgroundColor=k.colorError),k.colorText.length>0&&(F.style.color=k.colorText,G.style.color=k.colorText,J.style.color=k.colorText),g(),"undefined"!=typeof e.type&&e.type?R.setAttribute("type",e.type):R.setAttribute("type","text"),"undefined"!=typeof e.placeholder&&e.placeholder&&R.setAttribute("placeholder",e.placeholder),"undefined"!=typeof e.prefilledValue&&e.prefilledValue?R.value=e.prefilledValue:R.value="",w?n(function(){a(t,o,i,c,l)}):a(t,o,i,c,l)}function a(e,t,o,n,i){function c(){F.innerHTML=e,G.innerHTML=t,J.innerHTML=o,B.style.top="-10000px",B.style.display="table",B.style.top="-"+B.offsetHeight-5+"px",z.style.display="block",setTimeout(function(){y(B,"notie-transition"),B.style.top=0,z.style.opacity="0.75",setTimeout(function(){K=!0,R.focus()},k.animationDelay+10)},20)}b(),$.onclick=function(){d(),n&&setTimeout(function(){n(R.value)},k.animationDelay+10)},q.onclick=function(){d(),i&&setTimeout(function(){i(R.value)},k.animationDelay+10)},K?(d(),setTimeout(function(){c()},k.animationDelay+10)):c()}function d(){B.style.top="-"+B.offsetHeight-5+"px",z.style.opacity="0",setTimeout(function(){f(B,"notie-transition"),z.style.display="none",B.style.top="-10000px",h(),K=!1},k.animationDelay+10)}function s(e,t){k.colorInfo.length>0&&(Q.style.backgroundColor=k.colorInfo),k.colorNeutral.length>0&&(Z.style.backgroundColor=k.colorNeutral),k.colorText.length>0&&(U.style.color=k.colorText,Z.style.color=k.colorText);for(var o=[],i=0;i<arguments.length-2;i++)o[i]=arguments[i+2];if(o.length!==t.length)throw new Error("notie.select number of choices must match number of functions");g(),w?n(function(){u(e,t,o)}):u(e,t,o)}function u(e,t,o){function n(e){U.innerHTML=e,P.style.bottom="-10000px",P.style.display="table",P.style.bottom="-"+P.offsetHeight-5+"px",X.style.display="block",setTimeout(function(){y(P,"notie-transition"),P.style.bottom=0,X.style.opacity="0.75",setTimeout(function(){te=!0},k.animationDelay+10)},20)}b(),document.getElementById("notie-select-choices").innerHTML="";for(var i,c=0;c<t.length;c++){var l=document.createElement("div");if(l.innerHTML=t[c].title,y(l,"notie-select-choice"),Y.appendChild(l),l.style.backgroundColor=window.getComputedStyle(l).backgroundColor,k.colorText.length>0&&(l.style.color=k.colorText),t[c].type)switch(t[c].type){case 1:k.colorSuccess.length>0?l.style.backgroundColor=k.colorSuccess:y(l,"notie-background-success");break;case 2:k.colorWarning.length>0?l.style.backgroundColor=k.colorWarning:y(l,"notie-background-warning");break;case 3:k.colorError.length>0?l.style.backgroundColor=k.colorError:y(l,"notie-background-error");break;case 4:k.colorInfo.length>0?l.style.backgroundColor=k.colorInfo:y(l,"notie-background-info")}else t[c].color&&(l.style.backgroundColor=t[c].color);c>0&&l.style.backgroundColor===i.style.backgroundColor&&(i.style.borderBottom="1px solid rgba(255, 255, 255, 0.2)"),l.onclick=function(e){return function(){p(),setTimeout(function(){o[e]()},k.animationDelay+10)}}(c),i=l}te?(p(),setTimeout(function(){n(e)},k.animationDelay+10)):n(e)}function p(){P.style.bottom="-"+P.offsetHeight-5+"px",X.style.opacity="0",setTimeout(function(){f(P,"notie-transition"),P.style.bottom="-10000px",X.style.display="none",h(),te=!1},k.animationDelay+10)}function m(){return w||j||K||te}function y(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function f(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," ")}function g(){document.activeElement&&document.activeElement.blur()}function b(){_=document.body.style.height,ee=document.body.style.overflow,document.body.style.height="100%",document.body.style.overflow="hidden"}function h(){document.body.style.height=_,document.body.style.overflow=ee}var k={colorSuccess:"",colorWarning:"",colorError:"",colorInfo:"",colorNeutral:"",colorText:"",animationDelay:300,backgroundClickDismiss:!0},v=document.createElement("div");v.id="notie-alert-outer",v.onclick=function(){n()},document.body.appendChild(v);var C=document.createElement("div");C.id="notie-alert-inner",v.appendChild(C);var T=document.createElement("div");T.id="notie-alert-content",C.appendChild(T);var x=document.createElement("span");x.id="notie-alert-text",T.appendChild(x);var E,D,w=!1,H=0,L=document.createElement("div");L.id="notie-confirm-outer";var I=document.createElement("div");I.id="notie-confirm-inner",L.appendChild(I);var M=document.createElement("span");M.id="notie-confirm-text",I.appendChild(M);var S=document.createElement("div");S.id="notie-confirm-yes",L.appendChild(S);var A=document.createElement("div");A.id="notie-confirm-no",L.appendChild(A);var N=document.createElement("span");N.id="notie-confirm-text-yes",S.appendChild(N);var W=document.createElement("span");W.id="notie-confirm-text-no",A.appendChild(W);var V=document.createElement("div");V.id="notie-confirm-background",y(V,"notie-transition"),V.onclick=function(){k.backgroundClickDismiss&&l()},document.body.appendChild(L),document.body.appendChild(V);var j=!1,B=document.createElement("div");B.id="notie-input-outer";var z=document.createElement("div");z.id="notie-input-background",y(z,"notie-transition");var O=document.createElement("div");O.id="notie-input-inner",B.appendChild(O);var R=document.createElement("input");R.id="notie-input-field",R.setAttribute("autocomplete","off"),R.setAttribute("autocorrect","off"),R.setAttribute("autocapitalize","off"),R.setAttribute("spellcheck","false"),B.appendChild(R);var $=document.createElement("div");$.id="notie-input-yes",B.appendChild($);var q=document.createElement("div");q.id="notie-input-no",B.appendChild(q);var F=document.createElement("span");F.id="notie-input-text",O.appendChild(F);var G=document.createElement("span");G.id="notie-input-text-yes",$.appendChild(G);var J=document.createElement("span");J.id="notie-input-text-no",q.appendChild(J),document.body.appendChild(B),document.body.appendChild(z),z.onclick=function(){k.backgroundClickDismiss&&d()};var K=!1,P=document.createElement("div");P.id="notie-select-outer";var Q=document.createElement("div");Q.id="notie-select-inner",P.appendChild(Q);var U=document.createElement("span");U.id="notie-select-text",Q.appendChild(U);var X=document.createElement("div");X.id="notie-select-background",y(X,"notie-transition");var Y=document.createElement("div");Y.id="notie-select-choices",P.appendChild(Y);var Z=document.createElement("div");Z.id="notie-select-cancel",Z.innerHTML="Cancel",P.appendChild(Z),document.body.appendChild(P),document.body.appendChild(X),X.onclick=function(){k.backgroundClickDismiss&&p()},Z.onclick=function(){p()};var _,ee,te=!1;return window.addEventListener("keydown",function(e){var t=13===e.which||13===e.keyCode,o=27===e.which||27===e.keyCode;w?(t||o)&&n():j?t?S.click():o&&l():K?t?$.click():o&&d():te&&o&&p()}),{setOptions:e,alert:t,alertHide:n,confirm:i,input:r,select:s,isShowing:m}}();"object"==typeof module&&module.exports&&(module.exports=notie); | ||
var notie=function(){function e(e){for(var t in e)L[t]=e[t]}function t(e,t,i){L.colorText.length>0&&(A.style.color=L.colorText),H(),J++,setTimeout(function(){J--},L.animationDelay+10),1===J&&(Y?n(function(){o(e,t,i)}):o(e,t,i))}function o(e,t,o){Y=!0;var i=0;switch(i="undefined"==typeof o||0===o?864e5:o>0&&1>o?1e3:1e3*o,D(N,"notie-background-success"),D(N,"notie-background-warning"),D(N,"notie-background-error"),D(N,"notie-background-info"),e){case 1:case"success":L.colorSuccess.length>0?N.style.backgroundColor=L.colorSuccess:x(N,"notie-background-success");break;case 2:case"warning":L.colorWarning.length>0?N.style.backgroundColor=L.colorWarning:x(N,"notie-background-warning");break;case 3:case"error":L.colorError.length>0?N.style.backgroundColor=L.colorError:x(N,"notie-background-error");break;case 4:case"info":L.colorInfo.length>0?N.style.backgroundColor=L.colorInfo:x(N,"notie-background-info")}A.innerHTML=t,N.style.top="-10000px",N.style.display="table",N.style.top="-"+N.offsetHeight-5+"px",F=setTimeout(function(){x(N,"notie-transition"),N.style.top=0,W=setTimeout(function(){n(function(){})},i)},20)}function n(e){clearTimeout(F),clearTimeout(W),N.style.top="-"+N.offsetHeight-5+"px",setTimeout(function(){D(N,"notie-transition"),N.style.top="-10000px",Y=!1,e&&e()},L.animationDelay+10)}function i(e,t,o,i,l){L.colorInfo.length>0&&(V.style.backgroundColor=L.colorInfo),L.colorSuccess.length>0&&(B.style.backgroundColor=L.colorSuccess),L.colorError.length>0&&(z.style.backgroundColor=L.colorError),L.colorText.length>0&&(j.style.color=L.colorText,K.style.color=L.colorText,R.style.color=L.colorText),H(),Y?n(function(){c(e,t,o,i,l)}):c(e,t,o,i,l)}function c(e,t,o,n,i){function c(){j.innerHTML=e,K.innerHTML=t,R.innerHTML=o,O.style.top="-10000px",O.style.display="table",O.style.top="-"+O.offsetHeight-5+"px",$.style.display="block",setTimeout(function(){x(O,"notie-transition"),O.style.top=0,$.style.opacity="0.75",setTimeout(function(){q=!0},L.animationDelay+10)},20)}M(),B.onclick=function(){l(),n&&setTimeout(function(){n()},L.animationDelay+10)},z.onclick=function(){l(),i&&setTimeout(function(){i()},L.animationDelay+10)},q?(l(),setTimeout(function(){c()},L.animationDelay+10)):c()}function l(){O.style.top="-"+O.offsetHeight-5+"px",$.style.opacity="0",setTimeout(function(){D(O,"notie-transition"),O.style.top="-10000px",$.style.display="none",w(),q=!1},L.animationDelay+10)}function a(e,t,o,i,c,l){L.colorInfo.length>0&&(Q.style.backgroundColor=L.colorInfo),L.colorSuccess.length>0&&(X.style.backgroundColor=L.colorSuccess),L.colorError.length>0&&(Z.style.backgroundColor=L.colorError),L.colorText.length>0&&(_.style.color=L.colorText,ee.style.color=L.colorText,te.style.color=L.colorText),H(),"undefined"!=typeof e.type&&e.type?U.setAttribute("type",e.type):U.setAttribute("type","text"),"undefined"!=typeof e.placeholder&&e.placeholder&&U.setAttribute("placeholder",e.placeholder),"undefined"!=typeof e.prefilledValue&&e.prefilledValue?U.value=e.prefilledValue:U.value="",Y?n(function(){r(t,o,i,c,l)}):r(t,o,i,c,l)}function r(e,t,o,n,i){function c(){_.innerHTML=e,ee.innerHTML=t,te.innerHTML=o,G.style.top="-10000px",G.style.display="table",G.style.top="-"+G.offsetHeight-5+"px",P.style.display="block",setTimeout(function(){x(G,"notie-transition"),G.style.top=0,P.style.opacity="0.75",setTimeout(function(){oe=!0,U.focus()},L.animationDelay+10)},20)}M(),X.onclick=function(){d(),n&&setTimeout(function(){n(U.value)},L.animationDelay+10)},Z.onclick=function(){d(),i&&setTimeout(function(){i(U.value)},L.animationDelay+10)},oe?(d(),setTimeout(function(){c()},L.animationDelay+10)):c()}function d(){G.style.top="-"+G.offsetHeight-5+"px",P.style.opacity="0",setTimeout(function(){D(G,"notie-transition"),P.style.display="none",G.style.top="-10000px",w(),oe=!1},L.animationDelay+10)}function s(e,t){L.colorInfo.length>0&&(ie.style.backgroundColor=L.colorInfo),L.colorNeutral.length>0&&(re.style.backgroundColor=L.colorNeutral),L.colorText.length>0&&(ce.style.color=L.colorText,re.style.color=L.colorText);for(var o=[],i=0;i<arguments.length-2;i++)o[i]=arguments[i+2];if(o.length!==t.length)throw new Error("notie.select number of choices must match number of functions");H(),Y?n(function(){u(e,t,o)}):u(e,t,o)}function u(e,t,o){function n(e){ce.innerHTML=e,ne.style.bottom="-10000px",ne.style.display="table",ne.style.bottom="-"+ne.offsetHeight-5+"px",le.style.display="block",setTimeout(function(){x(ne,"notie-transition"),ne.style.bottom=0,le.style.opacity="0.75",setTimeout(function(){de=!0},L.animationDelay+10)},20)}M(),document.getElementById("notie-select-choices").innerHTML="";for(var i,c=0;c<t.length;c++){var l=document.createElement("div");if(l.innerHTML=t[c].title,x(l,"notie-select-choice"),ae.appendChild(l),l.style.backgroundColor=window.getComputedStyle(l).backgroundColor,L.colorText.length>0&&(l.style.color=L.colorText),t[c].type)switch(t[c].type){case 1:L.colorSuccess.length>0?l.style.backgroundColor=L.colorSuccess:x(l,"notie-background-success");break;case 2:L.colorWarning.length>0?l.style.backgroundColor=L.colorWarning:x(l,"notie-background-warning");break;case 3:L.colorError.length>0?l.style.backgroundColor=L.colorError:x(l,"notie-background-error");break;case 4:L.colorInfo.length>0?l.style.backgroundColor=L.colorInfo:x(l,"notie-background-info")}else t[c].color&&(l.style.backgroundColor=t[c].color);c>0&&l.style.backgroundColor===i.style.backgroundColor&&(i.style.borderBottom="1px solid rgba(255, 255, 255, 0.2)"),l.onclick=function(e){return function(){m(),setTimeout(function(){o[e]()},L.animationDelay+10)}}(c),i=l}de?(m(),setTimeout(function(){n(e)},L.animationDelay+10)):n(e)}function m(){ne.style.bottom="-"+ne.offsetHeight-5+"px",le.style.opacity="0",setTimeout(function(){D(ne,"notie-transition"),ne.style.bottom="-10000px",le.style.display="none",w(),de=!1},L.animationDelay+10)}function p(){return Y||q||oe||de||Le}function y(e){L.colorInfo.length>0&&(ue.style.backgroundColor=L.colorInfo),L.colorSuccess.length>0&&(Ee.style.backgroundColor=L.colorSuccess),L.colorError.length>0&&(xe.style.backgroundColor=L.colorError),L.colorText.length>0&&(ue.style.color=L.colorText),H(),Y?n(function(){f(e)}):f(e)}function f(e){function t(){He=e.initial||new Date,h(He),Ee.innerHTML=e.yesText||"OK",xe.innerHTML=e.noText||"Cancel",se.style.top="-10000px",se.style.display="table",se.style.top="-"+se.offsetHeight-5+"px",De.style.display="block",setTimeout(function(){x(se,"notie-transition"),se.style.top=0,De.style.opacity="0.75",setTimeout(function(){Le=!0},L.animationDelay+10)},20)}M(),Ee.onclick=function(){E(),e.yesCallback&&setTimeout(function(){e.yesCallback(He)},L.animationDelay+10)},xe.onclick=function(){E(),e.noCallback&&setTimeout(function(){e.noCallback(He)},L.animationDelay+10)},Le?(E(),setTimeout(function(){t()},L.animationDelay+10)):t()}function h(e){var t=L.dateMonths||["January","February","March","April","May","June","July","August","September","October","November","December"];ge.innerHTML=t[e.getMonth()],be.innerHTML=e.getDate(),ve.innerHTML=e.getFullYear()}function g(){He.setMonth(He.getMonth()-1),h(He)}function b(){He.setMonth(He.getMonth()+1),h(He)}function v(){He.setDate(He.getDate()-1),h(He)}function k(){He.setDate(He.getDate()+1),h(He)}function C(){He.setFullYear(He.getFullYear()-1),h(He)}function T(){He.setFullYear(He.getFullYear()+1),h(He)}function E(){se.style.top="-"+se.offsetHeight-5+"px",De.style.opacity="0",setTimeout(function(){D(se,"notie-transition"),se.style.top="-10000px",De.style.display="none",w(),Le=!1},L.animationDelay+10)}function x(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function D(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," ")}function H(){document.activeElement&&document.activeElement.blur()}function M(){Me=document.body.style.height,we=document.body.style.overflow,document.body.style.height="100%",document.body.style.overflow="hidden"}function w(){document.body.style.height=Me,document.body.style.overflow=we}var L={colorSuccess:"",colorWarning:"",colorError:"",colorInfo:"",colorNeutral:"",colorText:"",dateMonths:null,animationDelay:300,backgroundClickDismiss:!0},N=document.createElement("div");N.id="notie-alert-outer",N.onclick=function(){n()},document.body.appendChild(N);var I=document.createElement("div");I.id="notie-alert-inner",N.appendChild(I);var S=document.createElement("div");S.id="notie-alert-content",I.appendChild(S);var A=document.createElement("span");A.id="notie-alert-text",S.appendChild(A);var F,W,Y=!1,J=0,O=document.createElement("div");O.id="notie-confirm-outer";var V=document.createElement("div");V.id="notie-confirm-inner",O.appendChild(V);var j=document.createElement("span");j.id="notie-confirm-text",V.appendChild(j);var B=document.createElement("div");B.id="notie-confirm-yes",O.appendChild(B);var z=document.createElement("div");z.id="notie-confirm-no",O.appendChild(z);var K=document.createElement("span");K.id="notie-confirm-text-yes",B.appendChild(K);var R=document.createElement("span");R.id="notie-confirm-text-no",z.appendChild(R);var $=document.createElement("div");$.id="notie-confirm-background",x($,"notie-transition"),$.onclick=function(){L.backgroundClickDismiss&&l()},document.body.appendChild(O),document.body.appendChild($);var q=!1,G=document.createElement("div");G.id="notie-input-outer";var P=document.createElement("div");P.id="notie-input-background",x(P,"notie-transition");var Q=document.createElement("div");Q.id="notie-input-inner",G.appendChild(Q);var U=document.createElement("input");U.id="notie-input-field",U.setAttribute("autocomplete","off"),U.setAttribute("autocorrect","off"),U.setAttribute("autocapitalize","off"),U.setAttribute("spellcheck","false"),G.appendChild(U);var X=document.createElement("div");X.id="notie-input-yes",G.appendChild(X);var Z=document.createElement("div");Z.id="notie-input-no",G.appendChild(Z);var _=document.createElement("span");_.id="notie-input-text",Q.appendChild(_);var ee=document.createElement("span");ee.id="notie-input-text-yes",X.appendChild(ee);var te=document.createElement("span");te.id="notie-input-text-no",Z.appendChild(te),document.body.appendChild(G),document.body.appendChild(P),P.onclick=function(){L.backgroundClickDismiss&&d()};var oe=!1,ne=document.createElement("div");ne.id="notie-select-outer";var ie=document.createElement("div");ie.id="notie-select-inner",ne.appendChild(ie);var ce=document.createElement("span");ce.id="notie-select-text",ie.appendChild(ce);var le=document.createElement("div");le.id="notie-select-background",x(le,"notie-transition");var ae=document.createElement("div");ae.id="notie-select-choices",ne.appendChild(ae);var re=document.createElement("div");re.id="notie-select-cancel",re.innerHTML="Cancel",ne.appendChild(re),document.body.appendChild(ne),document.body.appendChild(le),le.onclick=function(){L.backgroundClickDismiss&&m()},re.onclick=function(){m()};var de=!1,se=document.createElement("div");se.id="notie-date-outer";var ue=document.createElement("div");ue.id="notie-date-inner",se.appendChild(ue);var me='<div class="notie-date-arrow-up"></div>',pe='<div class="notie-date-arrow-down"></div>',ye=document.createElement("div");ye.className="notie-date-up",ye.innerHTML=me,ue.appendChild(ye),ye.onclick=g;var fe=document.createElement("div");fe.className="notie-date-up",fe.innerHTML=me,ue.appendChild(fe),fe.onclick=v;var he=document.createElement("div");he.className="notie-date-up",he.innerHTML=me,ue.appendChild(he),he.onclick=C;var ge=document.createElement("div");ge.className="notie-date-text",ue.appendChild(ge);var be=document.createElement("div");be.className="notie-date-text",ue.appendChild(be);var ve=document.createElement("div");ve.className="notie-date-text",ue.appendChild(ve);var ke=document.createElement("div");ke.className="notie-date-down",ke.innerHTML=pe,ue.appendChild(ke),ke.onclick=b;var Ce=document.createElement("div");Ce.className="notie-date-down",Ce.innerHTML=pe,ue.appendChild(Ce),Ce.onclick=k;var Te=document.createElement("div");Te.className="notie-date-down",Te.innerHTML=pe,ue.appendChild(Te),Te.onclick=T;var Ee=document.createElement("div");Ee.id="notie-date-yes",ue.appendChild(Ee);var xe=document.createElement("div");xe.id="notie-date-no",ue.appendChild(xe);var De=document.createElement("div");De.id="notie-date-background",x(De,"notie-transition"),De.onclick=function(){L.backgroundClickDismiss&&E()},document.body.appendChild(se),document.body.appendChild(De);var He,Me,we,Le=!1;return window.addEventListener("keydown",function(e){var t=13===e.which||13===e.keyCode,o=27===e.which||27===e.keyCode;Y?(t||o)&&n():q?t?B.click():o&&l():oe?t?X.click():o&&d():de?o&&m():Le&&(t?Ee.click():o&&E())}),{setOptions:e,alert:t,alertHide:n,confirm:i,input:a,select:s,date:y,isShowing:p}}();"object"==typeof module&&module.exports&&(module.exports=notie); |
@@ -5,3 +5,3 @@ { | ||
"author": "Jared Reich", | ||
"version": "3.3.1", | ||
"version": "3.8.0", | ||
"main": "./dist/notie.min.js", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -12,5 +12,5 @@ # notie | ||
* Confirm user choices | ||
* Allow user to input information | ||
* Allow user to select choices | ||
* Do other cool stuff | ||
* Allow users to input information | ||
* Allow users to select choices | ||
* Allow users to select dates | ||
@@ -71,2 +71,8 @@ ![Alt text](/demo.gif?raw=true "Demo") | ||
notie.select(title(String), choices(Array of Objects) /*, callback1(Function), callback2(Function), ... */); | ||
notie.date({ | ||
initial: Date, | ||
yesCallback: Function, | ||
noCallback: Function | ||
}) | ||
``` | ||
@@ -86,26 +92,26 @@ For example: | ||
notie.confirm('Are you sure you want to do that?', 'Yes', 'Cancel', function() { | ||
notie.alert(1, 'Good choice!', 2); | ||
notie.alert(1, 'Good choice!', 2); | ||
}); | ||
notie.confirm('Are you sure?', 'Yes', 'Cancel', function() { | ||
notie.confirm('Are you <b>really</b> sure?', 'Yes', 'Cancel', function() { | ||
notie.confirm('Are you <b>really</b> <i>really</i> sure?', 'Yes', 'Cancel', function() { | ||
notie.alert(1, 'Okay, jeez...', 2); | ||
}); | ||
notie.confirm('Are you <b>really</b> sure?', 'Yes', 'Cancel', function() { | ||
notie.confirm('Are you <b>really</b> <i>really</i> sure?', 'Yes', 'Cancel', function() { | ||
notie.alert(1, 'Okay, jeez...', 2); | ||
}); | ||
}); | ||
}); | ||
notie.input({ | ||
type: 'email' | ||
placeholder: 'name@example.com', | ||
prefilledValue: 'jane@doe.com' | ||
type: 'email' | ||
placeholder: 'name@example.com', | ||
prefilledValue: 'jane@doe.com' | ||
}, 'Please enter your email address:', 'Submit', 'Cancel', 'email', 'name@example.com', function(valueEntered) { | ||
notie.alert(1, 'You entered: ' + valueEntered, 2); | ||
notie.alert(1, 'You entered: ' + valueEntered, 2); | ||
}); | ||
notie.input({ | ||
type: 'password', | ||
placeholder: 'Enter your password' | ||
type: 'password', | ||
placeholder: 'Enter your password' | ||
}, 'Please enter your password:', 'Submit', 'Cancel', function(valueEntered) { | ||
notie.alert(1, 'You entered: ' + valueEntered, 2); | ||
notie.alert(1, 'You entered: ' + valueEntered, 2); | ||
}, function(valueEntered) { | ||
notie.alert(3, 'You cancelled with this value: ' + valueEntered, 2); | ||
notie.alert(3, 'You cancelled with this value: ' + valueEntered, 2); | ||
}); | ||
@@ -115,17 +121,26 @@ | ||
[ | ||
{ title: 'Share' }, | ||
{ title: 'Open', color: '#57BF57' }, | ||
{ title: 'Edit', type: 2 }, | ||
{ title: 'Delete', type: 3 } | ||
{ title: 'Share' }, | ||
{ title: 'Open', color: '#57BF57' }, | ||
{ title: 'Edit', type: 2 }, | ||
{ title: 'Delete', type: 3 } | ||
], | ||
function() { | ||
notie.alert(1, 'Share item!', 3); | ||
notie.alert(1, 'Share item!', 3); | ||
}, function() { | ||
notie.alert(1, 'Open item!', 3); | ||
notie.alert(1, 'Open item!', 3); | ||
}, function() { | ||
notie.alert(2, 'Edit item!', 3); | ||
notie.alert(2, 'Edit item!', 3); | ||
}, function() { | ||
notie.alert(3, 'Delete item!', 3); | ||
notie.alert(3, 'Delete item!', 3); | ||
}); | ||
notie.date({ | ||
initial: new Date(2015, 8, 27), | ||
yesCallback: function (date) { | ||
notie.alert(1, 'You selected: ' + date.toISOString(), 5) | ||
}, | ||
noCallback: function (date) { | ||
notie.alert(3, 'You cancelled: ' + date.toISOString(), 5) | ||
} | ||
}) | ||
``` | ||
@@ -136,10 +151,11 @@ | ||
notie.setOptions({ | ||
colorSuccess: '#57BF57', | ||
colorWarning: '#D6A14D', | ||
colorError: '#E1715B', | ||
colorInfo: '#4D82D6', | ||
colorNeutral: '#A0A0A0', | ||
colorText: '#FFFFFF', | ||
animationDelay: 300, // Be sure to also change "transition: all 0.3s ease" variable in .scss file | ||
backgroundClickDismiss: true | ||
colorSuccess: '#57BF57', | ||
colorWarning: '#D6A14D', | ||
colorError: '#E1715B', | ||
colorInfo: '#4D82D6', | ||
colorNeutral: '#A0A0A0', | ||
colorText: '#FFFFFF', | ||
dateMonths: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'], // For other languages | ||
animationDelay: 300, // Be sure to also change "transition: all 0.3s ease" variable in .scss file | ||
backgroundClickDismiss: true | ||
}); | ||
@@ -146,0 +162,0 @@ ``` |
221
src/notie.js
@@ -26,2 +26,3 @@ /* | ||
colorText: '', | ||
dateMonths: null, | ||
animationDelay: 300, | ||
@@ -665,5 +666,216 @@ backgroundClickDismiss: true | ||
function isShowing () { | ||
return alertIsShowing || confirmIsShowing || inputIsShowing || selectIsShowing | ||
return alertIsShowing || confirmIsShowing || inputIsShowing || selectIsShowing || dateIsShowing | ||
} | ||
// date | ||
// ************** | ||
var dateOuter = document.createElement('div') | ||
dateOuter.id = 'notie-date-outer' | ||
var dateInner = document.createElement('div') | ||
dateInner.id = 'notie-date-inner' | ||
dateOuter.appendChild(dateInner) | ||
var dateUpArrow = '<div class="notie-date-arrow-up"></div>' | ||
var dateDownArrow = '<div class="notie-date-arrow-down"></div>' | ||
var dateUpMonth = document.createElement('div') | ||
dateUpMonth.className = 'notie-date-up' | ||
dateUpMonth.innerHTML = dateUpArrow | ||
dateInner.appendChild(dateUpMonth) | ||
dateUpMonth.onclick = dateUpMonthClick | ||
var dateUpDay = document.createElement('div') | ||
dateUpDay.className = 'notie-date-up' | ||
dateUpDay.innerHTML = dateUpArrow | ||
dateInner.appendChild(dateUpDay) | ||
dateUpDay.onclick = dateUpDayClick | ||
var dateUpYear = document.createElement('div') | ||
dateUpYear.className = 'notie-date-up' | ||
dateUpYear.innerHTML = dateUpArrow | ||
dateInner.appendChild(dateUpYear) | ||
dateUpYear.onclick = dateUpYearClick | ||
var dateMonth = document.createElement('div') | ||
dateMonth.className = 'notie-date-text' | ||
dateInner.appendChild(dateMonth) | ||
var dateDay = document.createElement('div') | ||
dateDay.className = 'notie-date-text' | ||
dateInner.appendChild(dateDay) | ||
var dateYear = document.createElement('div') | ||
dateYear.className = 'notie-date-text' | ||
dateInner.appendChild(dateYear) | ||
var dateDownMonth = document.createElement('div') | ||
dateDownMonth.className = 'notie-date-down' | ||
dateDownMonth.innerHTML = dateDownArrow | ||
dateInner.appendChild(dateDownMonth) | ||
dateDownMonth.onclick = dateDownMonthClick | ||
var dateDownDay = document.createElement('div') | ||
dateDownDay.className = 'notie-date-down' | ||
dateDownDay.innerHTML = dateDownArrow | ||
dateInner.appendChild(dateDownDay) | ||
dateDownDay.onclick = dateDownDayClick | ||
var dateDownYear = document.createElement('div') | ||
dateDownYear.className = 'notie-date-down' | ||
dateDownYear.innerHTML = dateDownArrow | ||
dateInner.appendChild(dateDownYear) | ||
dateDownYear.onclick = dateDownYearClick | ||
var dateYes = document.createElement('div') | ||
dateYes.id = 'notie-date-yes' | ||
dateInner.appendChild(dateYes) | ||
var dateNo = document.createElement('div') | ||
dateNo.id = 'notie-date-no' | ||
dateInner.appendChild(dateNo) | ||
var dateBackground = document.createElement('div') | ||
dateBackground.id = 'notie-date-background' | ||
addClass(dateBackground, 'notie-transition') | ||
// Hide notie.date on no click and background click | ||
dateBackground.onclick = function () { | ||
if (options.backgroundClickDismiss) { | ||
dateHide() | ||
} | ||
} | ||
// Attach date elements to the body element | ||
document.body.appendChild(dateOuter) | ||
document.body.appendChild(dateBackground) | ||
// date helper variables | ||
var dateIsShowing = false | ||
var dateSelected | ||
function date (dateOptions) { | ||
if (options.colorInfo.length > 0) { | ||
dateInner.style.backgroundColor = options.colorInfo | ||
} | ||
if (options.colorSuccess.length > 0) dateYes.style.backgroundColor = options.colorSuccess | ||
if (options.colorError.length > 0) dateNo.style.backgroundColor = options.colorError | ||
if (options.colorText.length > 0) dateInner.style.color = options.colorText | ||
blur() | ||
if (alertIsShowing) { | ||
// Hide notie.alert | ||
alertHide(function () { | ||
dateShow(dateOptions) | ||
}) | ||
} else { | ||
dateShow(dateOptions) | ||
} | ||
} | ||
function dateShow (dateOptions) { | ||
scrollDisable() | ||
// Yes callback function | ||
dateYes.onclick = function () { | ||
dateHide() | ||
if (dateOptions.yesCallback) { | ||
setTimeout(function () { | ||
dateOptions.yesCallback(dateSelected) | ||
}, (options.animationDelay + 10)) | ||
} | ||
} | ||
// No callback function | ||
dateNo.onclick = function () { | ||
dateHide() | ||
if (dateOptions.noCallback) { | ||
setTimeout(function () { | ||
dateOptions.noCallback(dateSelected) | ||
}, (options.animationDelay + 10)) | ||
} | ||
} | ||
function dateShowInner () { | ||
dateSelected = dateOptions.initial || new Date() | ||
dateSet(dateSelected) | ||
dateYes.innerHTML = dateOptions.yesText || 'OK' | ||
dateNo.innerHTML = dateOptions.noText || 'Cancel' | ||
// Get dates's height | ||
dateOuter.style.top = '-10000px' | ||
dateOuter.style.display = 'table' | ||
dateOuter.style.top = '-' + dateOuter.offsetHeight - 5 + 'px' | ||
dateBackground.style.display = 'block' | ||
setTimeout(function () { | ||
addClass(dateOuter, 'notie-transition') | ||
dateOuter.style.top = 0 | ||
dateBackground.style.opacity = '0.75' | ||
setTimeout(function () { | ||
dateIsShowing = true | ||
}, (options.animationDelay + 10)) | ||
}, 20) | ||
} | ||
if (dateIsShowing) { | ||
dateHide() | ||
setTimeout(function () { | ||
dateShowInner() | ||
}, (options.animationDelay + 10)) | ||
} else { | ||
dateShowInner() | ||
} | ||
} | ||
function dateSet (date) { | ||
var dateMonths = options.dateMonths || ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] | ||
dateMonth.innerHTML = dateMonths[date.getMonth()] | ||
dateDay.innerHTML = date.getDate() | ||
dateYear.innerHTML = date.getFullYear() | ||
} | ||
function dateUpMonthClick () { | ||
dateSelected.setMonth(dateSelected.getMonth() - 1) | ||
dateSet(dateSelected) | ||
} | ||
function dateDownMonthClick () { | ||
dateSelected.setMonth(dateSelected.getMonth() + 1) | ||
dateSet(dateSelected) | ||
} | ||
function dateUpDayClick () { | ||
dateSelected.setDate(dateSelected.getDate() - 1) | ||
dateSet(dateSelected) | ||
} | ||
function dateDownDayClick () { | ||
dateSelected.setDate(dateSelected.getDate() + 1) | ||
dateSet(dateSelected) | ||
} | ||
function dateUpYearClick () { | ||
dateSelected.setFullYear(dateSelected.getFullYear() - 1) | ||
dateSet(dateSelected) | ||
} | ||
function dateDownYearClick () { | ||
dateSelected.setFullYear(dateSelected.getFullYear() + 1) | ||
dateSet(dateSelected) | ||
} | ||
function dateHide () { | ||
dateOuter.style.top = '-' + dateOuter.offsetHeight - 5 + 'px' | ||
dateBackground.style.opacity = '0' | ||
setTimeout(function () { | ||
removeClass(dateOuter, 'notie-transition') | ||
dateOuter.style.top = '-10000px' | ||
dateBackground.style.display = 'none' | ||
scrollEnable() | ||
dateIsShowing = false | ||
}, (options.animationDelay + 10)) | ||
} | ||
// Internal helper functions | ||
@@ -727,2 +939,8 @@ // ################# | ||
} | ||
} else if (dateIsShowing) { | ||
if (enterClicked) { | ||
dateYes.click() | ||
} else if (escapeClicked) { | ||
dateHide() | ||
} | ||
} | ||
@@ -738,2 +956,3 @@ }) | ||
select: select, | ||
date: date, | ||
isShowing: isShowing | ||
@@ -740,0 +959,0 @@ } |
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
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
1321183
1002
167