diff --git a/noticer.js b/noticer.js index d15d265..49eaab2 100644 --- a/noticer.js +++ b/noticer.js @@ -1,10 +1,8 @@ -/*! noticer - v0.1.0 - 2023-05-31 +/*! noticer - v0.1.1 - 2023-06-02 * https://git.zhirov.kz/alexander/noticer * Copyright Alexander Zhirov; Licensed GPL-2.0 */ class Noticer { - timer; - constructor() { this.div = $('
'); this.div.css({ @@ -85,17 +83,17 @@ class Noticer { newNotice.fadeIn(500).mouseenter(() => { clearTimeout(opacityTimeout); - this.timer.pause(); + timer.pause(); }).mouseleave(() => { - this.timer.resume(); + timer.resume(); }).click(() => { - this.timer.dead(); + timer.dead(); newNotice.fadeOut(0, function(){ this.remove(); }); }); - this.timer = new Timer(() => { + let timer = new Timer(() => { newNotice.fadeOut(500, function(){ this.remove(); }); diff --git a/noticer.min.js b/noticer.min.js index e9e9957..e7604a1 100644 --- a/noticer.min.js +++ b/noticer.min.js @@ -1,4 +1,4 @@ -/*! noticer - v0.1.0 - 2023-05-31 +/*! noticer - v0.1.1 - 2023-06-02 * https://git.zhirov.kz/alexander/noticer * Copyright Alexander Zhirov; Licensed GPL-2.0 */ -class Noticer{timer;constructor(){this.div=$('
'),this.div.css({position:"absolute",top:"10px",right:"20px","z-index":"1000"}),$("body").append(this.div)}success(e,t=6e3){this.print(e,t,"#52b818","#bffdc0")}warning(e,t=6e3){this.print(e,t,"#b8ae18","#f8fdbf")}error(e,t=6e3){this.print(e,t,"#b96161","#fddede")}print=function(e,t,n,s){t<6e3&&(t=6e3);let i=function(e,t){let n,s,o=t;this.pause=function(){clearTimeout(n),o-=new Date-s},this.resume=function(){s=new Date,clearTimeout(n),n=setTimeout(e,o)},this.dead=function(){clearTimeout(n)},this.resume()},o=$(`
${e}
`);o.css({border:`1px solid ${n}`,"background-color":`${s}`,color:"#333",padding:"10px 30px","text-align":"center",display:"none",margin:"10px 0 0 0",width:"350px",opacity:"1",cursor:"pointer"}),o.hover(function(){$(this).css({opacity:"1"})},function(){$(this).css({opacity:"0.3"})}),this.div.append(o);let a=setTimeout(function(){o.fadeTo(1e3,.3)},2500);o.fadeIn(500).mouseenter(()=>{clearTimeout(a),this.timer.pause()}).mouseleave(()=>{this.timer.resume()}).click(()=>{this.timer.dead(),o.fadeOut(0,function(){this.remove()})}),this.timer=new i(()=>{o.fadeOut(500,function(){this.remove()})},t)}} +class Noticer{constructor(){this.div=$('
'),this.div.css({position:"absolute",top:"10px",right:"20px","z-index":"1000"}),$("body").append(this.div)}success(e,t=6e3){this.print(e,t,"#52b818","#bffdc0")}warning(e,t=6e3){this.print(e,t,"#b8ae18","#f8fdbf")}error(e,t=6e3){this.print(e,t,"#b96161","#fddede")}print=function(e,t,n,s){t<6e3&&(t=6e3);let a=function(e,t){let n,s,o=t;this.pause=function(){clearTimeout(n),o-=new Date-s},this.resume=function(){s=new Date,clearTimeout(n),n=setTimeout(e,o)},this.dead=function(){clearTimeout(n)},this.resume()},o=$(`
${e}
`);o.css({border:`1px solid ${n}`,"background-color":`${s}`,color:"#333",padding:"10px 30px","text-align":"center",display:"none",margin:"10px 0 0 0",width:"350px",opacity:"1",cursor:"pointer"}),o.hover(function(){$(this).css({opacity:"1"})},function(){$(this).css({opacity:"0.3"})}),this.div.append(o);let r=setTimeout(function(){o.fadeTo(1e3,.3)},2500);o.fadeIn(500).mouseenter(()=>{clearTimeout(r),i.pause()}).mouseleave(()=>{i.resume()}).click(()=>{i.dead(),o.fadeOut(0,function(){this.remove()})});let i=new a(()=>{o.fadeOut(500,function(){this.remove()})},t)}} diff --git a/test/index.html b/test/index.html new file mode 100644 index 0000000..9cc0570 --- /dev/null +++ b/test/index.html @@ -0,0 +1,18 @@ + + + + + + + + + + +