UNPKG

quoslibero

Version:

FusionCharts JavaScript charting framework

1 lines 2.21 kB
import{componentDispose,isIE}from'../../../fc-core/src/lib';var docmode8=8===window.document.documentMode,TITLE_HASH_STRING='$titleVal$',MSG_HASH_STRING='$msgVal$',LINK_HASH_STRING='$msgLinkVal$',msgTemplate={},CONTAINER_SPAN_STYLE={display:'block',paddingLeft:'10px',paddingRight:'10px',"font-family":'Arial',"font-size":'11px'};msgTemplate.literal=msgTemplate.info={title:'<span style="color: #005900">$titleVal$</span>',body:'<span">$msgVal$</span>'},msgTemplate.link={title:msgTemplate.info.title,body:'<a href="$msgLinkVal$">$msgVal$</a>'},msgTemplate.error={title:'<span style="color: #CC0000">$titleVal$</span>',body:'<span style="color: #CC0000">$msgVal$</span>'};class Message{constructor(a,b){this.config={},this.messageType=(a.msgType&&a.msgType.replace(/^[\r\n]+|\.|[\r\n]+$/g,'')||'').toLowerCase(),this.msgTitle=a.msgTitle,this.msgText=a.msgText,this.msgLink=a.msgLink,this.graphics={},this.linkedItems={msgLogger:b},this.msgObj=msgTemplate[this.messageType]||msgTemplate.literal,this.configureMsgTextAndMsgTitle()}configureMsgTextAndMsgTitle(){this.config.totalHTML='',this.msgTitle&&(this.config.titleHTML=this.msgObj.title.replace(TITLE_HASH_STRING,this.msgTitle),this.config.totalHTML+=this.config.titleHTML),this.msgText&&(this.config.msgHTML=this.msgObj.body.replace(MSG_HASH_STRING,this.msgText),this.config.msgHTML=this.config.msgHTML.replace(LINK_HASH_STRING,this.msgText),this.config.totalHTML+=this.config.msgHTML)}draw(){var a,b,c,d=this.graphics.element,e=this.linkedItems.msgLogger,f=e.graphics,g=f&&f.log&&f.log.element,h=f.logWrapper&&f.logWrapper.element,i=e.config;if(!d){for(a in d=this.graphics.element=window.document.createElement('span'),CONTAINER_SPAN_STYLE)d.style[a]=CONTAINER_SPAN_STYLE[a];g.appendChild&&g.appendChild(d)}this.graphics.element.innerHTML=this.config.totalHTML,isIE&&docmode8&&(b=g.innerHTML,g.innerHTML=b),i.scrollToBottom&&(i.dynamicScrolling=!0,c=h.scrollHeight,h.scrollTop=c)}dispose(){var a=this.linkedItems.msgLogger;a&&a.graphics&&a.graphics.log&&a.graphics.log.element&&a.graphics.log.element.removeChild&&a.graphics.log.element.removeChild(this.graphics.element),delete this.graphics.element,componentDispose.call(this)}}export default Message;