Correction de 'notif.js' correction
This commit is contained in:
parent
ecdd788e9e
commit
15b1aa47f7
|
@ -1,5 +1,5 @@
|
|||
var NotificationClass=function(a){this.container=a};NotificationClass.prototype={container:this.container,stack:[],types:["warning","info","success","error"],defaultTimeout:2E3,errorCodes:{}};var xxb=null;NotificationClass.prototype.pushStack=function(a,c,b){if(!(a instanceof Array&&b instanceof Array&&c.element instanceof Element))return null;var e=-1,d;for(d in a)if(-1<b.indexOf(a[d])){e=d;break}if(-1==e)return a.push(c)-1;a[e]=c;return e};
|
||||
NotificationClass.prototype.hide=function(a){if(isNaN(a))return!1;a=parseInt(a);this.stack[a].element instanceof Element&&this.container.removeChild(this.stack[a].element);this.stack[a]=null};
|
||||
NotificationClass.prototype.hide=function(a){if(isNaN(a))return!1;a=parseInt(a);null!=this.stack[a]&&null!=this.stack[a].element&this.stack[a].element instanceof Element&&this.container.removeChild(this.stack[a].element);this.stack[a]=null};
|
||||
NotificationClass.prototype.show=function(a,c,b,e){a=-1<this.types.indexOf(a)?a:this.types[0];c="string"==typeof c?c:"";b="string"==typeof b.toString()?b:"...";null!=this.errorCodes[b]&&(b=this.errorCodes[b]);e="number"==typeof e?e:this.defaultTimeout;var d={element:document.createElement("div"),type:a,title:c,message:b,timeout:null};d.element.className="notification-element";d.element.setAttribute("data-"+a,"");d.element.innerHTML="<p><strong>"+c+":</strong> "+b+"<p>";this.container.appendChild(d.element);
|
||||
var f=this.pushStack(this.stack,d,[null]);d.element.id=f;var g=this;d.element.className="notification-element notification-visible";setTimeout(function(){d.element.className="notification-element"},500+e);d.timeout=setTimeout(function(){g.hide(f)},500+e+500);d.element.addEventListener("click",function(a){g.hide(f)},!1);return d.element};NotificationClass.prototype.warning=function(a,c,b){return this.show("warning",a,c,b)};
|
||||
NotificationClass.prototype.info=function(a,c,b){return this.show("info",a,c,b)};NotificationClass.prototype.success=function(a,c,b){return this.show("success",a,c,b)};NotificationClass.prototype.error=function(a,c,b){return this.show("error",a,c,b)};
|
||||
|
|
|
@ -87,7 +87,7 @@ NotificationClass.prototype.hide = function(id){
|
|||
|
||||
|
||||
/* (1) Suppression de l'élément */
|
||||
if( this.stack[id].element instanceof Element )
|
||||
if( this.stack[id] != null && this.stack[id].element != null &this.stack[id].element instanceof Element )
|
||||
this.container.removeChild( this.stack[id].element );
|
||||
|
||||
/* (2) On supprime la notification de la pile */
|
||||
|
|
Loading…
Reference in New Issue