chat.js 110 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587
  1. if (!window.zammadChatTemplates) {
  2. window.zammadChatTemplates = {};
  3. }
  4. window.zammadChatTemplates["agent"] = function(__obj) {
  5. if (!__obj) __obj = {};
  6. var __out = [], __capture = function(callback) {
  7. var out = __out, result;
  8. __out = [];
  9. callback.call(this);
  10. result = __out.join('');
  11. __out = out;
  12. return __safe(result);
  13. }, __sanitize = function(value) {
  14. if (value && value.ecoSafe) {
  15. return value;
  16. } else if (typeof value !== 'undefined' && value != null) {
  17. return __escape(value);
  18. } else {
  19. return '';
  20. }
  21. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  22. __safe = __obj.safe = function(value) {
  23. if (value && value.ecoSafe) {
  24. return value;
  25. } else {
  26. if (!(typeof value !== 'undefined' && value != null)) value = '';
  27. var result = new String(value);
  28. result.ecoSafe = true;
  29. return result;
  30. }
  31. };
  32. if (!__escape) {
  33. __escape = __obj.escape = function(value) {
  34. return ('' + value)
  35. .replace(/&/g, '&')
  36. .replace(/</g, '&lt;')
  37. .replace(/>/g, '&gt;')
  38. .replace(/"/g, '&quot;');
  39. };
  40. }
  41. (function() {
  42. (function() {
  43. if (this.agent.avatar) {
  44. __out.push('\n<img class="zammad-chat-agent-avatar" src="');
  45. __out.push(__sanitize(this.agent.avatar));
  46. __out.push('">\n');
  47. }
  48. __out.push('\n<span class="zammad-chat-agent-sentence">\n <span class="zammad-chat-agent-name">');
  49. __out.push(__sanitize(this.agent.name));
  50. __out.push('</span>\n</span>');
  51. }).call(this);
  52. }).call(__obj);
  53. __obj.safe = __objSafe, __obj.escape = __escape;
  54. return __out.join('');
  55. };
  56. /*! @license DOMPurify 2.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.1/LICENSE */
  57. !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).DOMPurify=t()}(this,(function(){"use strict";var e=Object.hasOwnProperty,t=Object.setPrototypeOf,n=Object.isFrozen,r=Object.getPrototypeOf,o=Object.getOwnPropertyDescriptor,i=Object.freeze,a=Object.seal,l=Object.create,c="undefined"!=typeof Reflect&&Reflect,s=c.apply,u=c.construct;s||(s=function(e,t,n){return e.apply(t,n)}),i||(i=function(e){return e}),a||(a=function(e){return e}),u||(u=function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(t))))});var f,m=x(Array.prototype.forEach),d=x(Array.prototype.pop),p=x(Array.prototype.push),g=x(String.prototype.toLowerCase),h=x(String.prototype.match),y=x(String.prototype.replace),v=x(String.prototype.indexOf),b=x(String.prototype.trim),T=x(RegExp.prototype.test),A=(f=TypeError,function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return u(f,t)});function x(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return s(e,t,r)}}function S(e,r){t&&t(e,null);for(var o=r.length;o--;){var i=r[o];if("string"==typeof i){var a=g(i);a!==i&&(n(r)||(r[o]=a),i=a)}e[i]=!0}return e}function w(t){var n=l(null),r=void 0;for(r in t)s(e,t,[r])&&(n[r]=t[r]);return n}function N(e,t){for(;null!==e;){var n=o(e,t);if(n){if(n.get)return x(n.get);if("function"==typeof n.value)return x(n.value)}e=r(e)}return function(e){return console.warn("fallback value for",e),null}}var k=i(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),E=i(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),D=i(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),O=i(["animate","color-profile","cursor","discard","fedropshadow","feimage","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),R=i(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),_=i(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),M=i(["#text"]),L=i(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),F=i(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),I=i(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),C=i(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),z=a(/\{\{[\s\S]*|[\s\S]*\}\}/gm),H=a(/<%[\s\S]*|[\s\S]*%>/gm),U=a(/^data-[\-\w.\u00B7-\uFFFF]/),j=a(/^aria-[\-\w]+$/),B=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),P=a(/^(?:\w+script|data):/i),W=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),G="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 q(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var K=function(){return"undefined"==typeof window?null:window},V=function(e,t){if("object"!==(void 0===e?"undefined":G(e))||"function"!=typeof e.createPolicy)return null;var n=null,r="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(r)&&(n=t.currentScript.getAttribute(r));var o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}};return function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:K(),n=function(t){return e(t)};if(n.version="2.3.1",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var r=t.document,o=t.document,a=t.DocumentFragment,l=t.HTMLTemplateElement,c=t.Node,s=t.Element,u=t.NodeFilter,f=t.NamedNodeMap,x=void 0===f?t.NamedNodeMap||t.MozNamedAttrMap:f,Y=t.Text,X=t.Comment,$=t.DOMParser,Z=t.trustedTypes,J=s.prototype,Q=N(J,"cloneNode"),ee=N(J,"nextSibling"),te=N(J,"childNodes"),ne=N(J,"parentNode");if("function"==typeof l){var re=o.createElement("template");re.content&&re.content.ownerDocument&&(o=re.content.ownerDocument)}var oe=V(Z,r),ie=oe&&ze?oe.createHTML(""):"",ae=o,le=ae.implementation,ce=ae.createNodeIterator,se=ae.createDocumentFragment,ue=ae.getElementsByTagName,fe=r.importNode,me={};try{me=w(o).documentMode?o.documentMode:{}}catch(e){}var de={};n.isSupported="function"==typeof ne&&le&&void 0!==le.createHTMLDocument&&9!==me;var pe=z,ge=H,he=U,ye=j,ve=P,be=W,Te=B,Ae=null,xe=S({},[].concat(q(k),q(E),q(D),q(R),q(M))),Se=null,we=S({},[].concat(q(L),q(F),q(I),q(C))),Ne=null,ke=null,Ee=!0,De=!0,Oe=!1,Re=!1,_e=!1,Me=!1,Le=!1,Fe=!1,Ie=!1,Ce=!0,ze=!1,He=!0,Ue=!0,je=!1,Be={},Pe=null,We=S({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Ge=null,qe=S({},["audio","video","img","source","image","track"]),Ke=null,Ve=S({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ye="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",$e="http://www.w3.org/1999/xhtml",Ze=$e,Je=!1,Qe=null,et=o.createElement("form"),tt=function(e){Qe&&Qe===e||(e&&"object"===(void 0===e?"undefined":G(e))||(e={}),e=w(e),Ae="ALLOWED_TAGS"in e?S({},e.ALLOWED_TAGS):xe,Se="ALLOWED_ATTR"in e?S({},e.ALLOWED_ATTR):we,Ke="ADD_URI_SAFE_ATTR"in e?S(w(Ve),e.ADD_URI_SAFE_ATTR):Ve,Ge="ADD_DATA_URI_TAGS"in e?S(w(qe),e.ADD_DATA_URI_TAGS):qe,Pe="FORBID_CONTENTS"in e?S({},e.FORBID_CONTENTS):We,Ne="FORBID_TAGS"in e?S({},e.FORBID_TAGS):{},ke="FORBID_ATTR"in e?S({},e.FORBID_ATTR):{},Be="USE_PROFILES"in e&&e.USE_PROFILES,Ee=!1!==e.ALLOW_ARIA_ATTR,De=!1!==e.ALLOW_DATA_ATTR,Oe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Re=e.SAFE_FOR_TEMPLATES||!1,_e=e.WHOLE_DOCUMENT||!1,Fe=e.RETURN_DOM||!1,Ie=e.RETURN_DOM_FRAGMENT||!1,Ce=!1!==e.RETURN_DOM_IMPORT,ze=e.RETURN_TRUSTED_TYPE||!1,Le=e.FORCE_BODY||!1,He=!1!==e.SANITIZE_DOM,Ue=!1!==e.KEEP_CONTENT,je=e.IN_PLACE||!1,Te=e.ALLOWED_URI_REGEXP||Te,Ze=e.NAMESPACE||$e,Re&&(De=!1),Ie&&(Fe=!0),Be&&(Ae=S({},[].concat(q(M))),Se=[],!0===Be.html&&(S(Ae,k),S(Se,L)),!0===Be.svg&&(S(Ae,E),S(Se,F),S(Se,C)),!0===Be.svgFilters&&(S(Ae,D),S(Se,F),S(Se,C)),!0===Be.mathMl&&(S(Ae,R),S(Se,I),S(Se,C))),e.ADD_TAGS&&(Ae===xe&&(Ae=w(Ae)),S(Ae,e.ADD_TAGS)),e.ADD_ATTR&&(Se===we&&(Se=w(Se)),S(Se,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&S(Ke,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(Pe===We&&(Pe=w(Pe)),S(Pe,e.FORBID_CONTENTS)),Ue&&(Ae["#text"]=!0),_e&&S(Ae,["html","head","body"]),Ae.table&&(S(Ae,["tbody"]),delete Ne.tbody),i&&i(e),Qe=e)},nt=S({},["mi","mo","mn","ms","mtext"]),rt=S({},["foreignobject","desc","title","annotation-xml"]),ot=S({},E);S(ot,D),S(ot,O);var it=S({},R);S(it,_);var at=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:$e,tagName:"template"});var n=g(e.tagName),r=g(t.tagName);if(e.namespaceURI===Xe)return t.namespaceURI===$e?"svg"===n:t.namespaceURI===Ye?"svg"===n&&("annotation-xml"===r||nt[r]):Boolean(ot[n]);if(e.namespaceURI===Ye)return t.namespaceURI===$e?"math"===n:t.namespaceURI===Xe?"math"===n&&rt[r]:Boolean(it[n]);if(e.namespaceURI===$e){if(t.namespaceURI===Xe&&!rt[r])return!1;if(t.namespaceURI===Ye&&!nt[r])return!1;var o=S({},["title","style","font","a","script"]);return!it[n]&&(o[n]||!ot[n])}return!1},lt=function(e){p(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=ie}catch(t){e.remove()}}},ct=function(e,t){try{p(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){p(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Se[e])if(Fe||Ie)try{lt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},st=function(e){var t=void 0,n=void 0;if(Le)e="<remove></remove>"+e;else{var r=h(e,/^[\r\n\t ]+/);n=r&&r[0]}var i=oe?oe.createHTML(e):e;if(Ze===$e)try{t=(new $).parseFromString(i,"text/html")}catch(e){}if(!t||!t.documentElement){t=le.createDocument(Ze,"template",null);try{t.documentElement.innerHTML=Je?"":i}catch(e){}}var a=t.body||t.documentElement;return e&&n&&a.insertBefore(o.createTextNode(n),a.childNodes[0]||null),Ze===$e?ue.call(t,_e?"html":"body")[0]:_e?t.documentElement:a},ut=function(e){return ce.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null,!1)},ft=function(e){return!(e instanceof Y||e instanceof X)&&!("string"==typeof e.nodeName&&"string"==typeof e.textContent&&"function"==typeof e.removeChild&&e.attributes instanceof x&&"function"==typeof e.removeAttribute&&"function"==typeof e.setAttribute&&"string"==typeof e.namespaceURI&&"function"==typeof e.insertBefore)},mt=function(e){return"object"===(void 0===c?"undefined":G(c))?e instanceof c:e&&"object"===(void 0===e?"undefined":G(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},dt=function(e,t,r){de[e]&&m(de[e],(function(e){e.call(n,t,r,Qe)}))},pt=function(e){var t=void 0;if(dt("beforeSanitizeElements",e,null),ft(e))return lt(e),!0;if(h(e.nodeName,/[\u0080-\uFFFF]/))return lt(e),!0;var r=g(e.nodeName);if(dt("uponSanitizeElement",e,{tagName:r,allowedTags:Ae}),!mt(e.firstElementChild)&&(!mt(e.content)||!mt(e.content.firstElementChild))&&T(/<[/\w]/g,e.innerHTML)&&T(/<[/\w]/g,e.textContent))return lt(e),!0;if("select"===r&&T(/<template/i,e.innerHTML))return lt(e),!0;if(!Ae[r]||Ne[r]){if(Ue&&!Pe[r]){var o=ne(e)||e.parentNode,i=te(e)||e.childNodes;if(i&&o)for(var a=i.length-1;a>=0;--a)o.insertBefore(Q(i[a],!0),ee(e))}return lt(e),!0}return e instanceof s&&!at(e)?(lt(e),!0):"noscript"!==r&&"noembed"!==r||!T(/<\/no(script|embed)/i,e.innerHTML)?(Re&&3===e.nodeType&&(t=e.textContent,t=y(t,pe," "),t=y(t,ge," "),e.textContent!==t&&(p(n.removed,{element:e.cloneNode()}),e.textContent=t)),dt("afterSanitizeElements",e,null),!1):(lt(e),!0)},gt=function(e,t,n){if(He&&("id"===t||"name"===t)&&(n in o||n in et))return!1;if(De&&!ke[t]&&T(he,t));else if(Ee&&T(ye,t));else{if(!Se[t]||ke[t])return!1;if(Ke[t]);else if(T(Te,y(n,be,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(n,"data:")||!Ge[e]){if(Oe&&!T(ve,y(n,be,"")));else if(n)return!1}else;}return!0},ht=function(e){var t=void 0,r=void 0,o=void 0,i=void 0;dt("beforeSanitizeAttributes",e,null);var a=e.attributes;if(a){var l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Se};for(i=a.length;i--;){var c=t=a[i],s=c.name,u=c.namespaceURI;if(r=b(t.value),o=g(s),l.attrName=o,l.attrValue=r,l.keepAttr=!0,l.forceKeepAttr=void 0,dt("uponSanitizeAttribute",e,l),r=l.attrValue,!l.forceKeepAttr&&(ct(s,e),l.keepAttr))if(T(/\/>/i,r))ct(s,e);else{Re&&(r=y(r,pe," "),r=y(r,ge," "));var f=e.nodeName.toLowerCase();if(gt(f,o,r))try{u?e.setAttributeNS(u,s,r):e.setAttribute(s,r),d(n.removed)}catch(e){}}}dt("afterSanitizeAttributes",e,null)}},yt=function e(t){var n=void 0,r=ut(t);for(dt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)dt("uponSanitizeShadowNode",n,null),pt(n)||(n.content instanceof a&&e(n.content),ht(n));dt("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e,o){var i=void 0,l=void 0,s=void 0,u=void 0,f=void 0;if((Je=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!mt(e)){if("function"!=typeof e.toString)throw A("toString is not a function");if("string"!=typeof(e=e.toString()))throw A("dirty is not a string, aborting")}if(!n.isSupported){if("object"===G(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(mt(e))return t.toStaticHTML(e.outerHTML)}return e}if(Me||tt(o),n.removed=[],"string"==typeof e&&(je=!1),je);else if(e instanceof c)1===(l=(i=st("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?i=l:i.appendChild(l);else{if(!Fe&&!Re&&!_e&&-1===e.indexOf("<"))return oe&&ze?oe.createHTML(e):e;if(!(i=st(e)))return Fe?null:ie}i&&Le&&lt(i.firstChild);for(var m=ut(je?e:i);s=m.nextNode();)3===s.nodeType&&s===u||pt(s)||(s.content instanceof a&&yt(s.content),ht(s),u=s);if(u=null,je)return e;if(Fe){if(Ie)for(f=se.call(i.ownerDocument);i.firstChild;)f.appendChild(i.firstChild);else f=i;return Ce&&(f=fe.call(r,f,!0)),f}var d=_e?i.outerHTML:i.innerHTML;return Re&&(d=y(d,pe," "),d=y(d,ge," ")),oe&&ze?oe.createHTML(d):d},n.setConfig=function(e){tt(e),Me=!0},n.clearConfig=function(){Qe=null,Me=!1},n.isValidAttribute=function(e,t,n){Qe||tt({});var r=g(e),o=g(t);return gt(r,o,n)},n.addHook=function(e,t){"function"==typeof t&&(de[e]=de[e]||[],p(de[e],t))},n.removeHook=function(e){de[e]&&d(de[e])},n.removeHooks=function(e){de[e]&&(de[e]=[])},n.removeAllHooks=function(){de={}},n}()}));
  58. //# sourceMappingURL=purify.min.js.map
  59. var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  60. slice = [].slice,
  61. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  62. hasProp = {}.hasOwnProperty;
  63. (function($, window) {
  64. var Base, Io, Log, Timeout, ZammadChat, myScript, scriptHost, scriptProtocol, scripts;
  65. scripts = document.getElementsByTagName('script');
  66. myScript = scripts[scripts.length - 1];
  67. scriptProtocol = window.location.protocol.replace(':', '');
  68. if (myScript && myScript.src) {
  69. scriptHost = myScript.src.match('.*://([^:/]*).*')[1];
  70. scriptProtocol = myScript.src.match('(.*)://[^:/]*.*')[1];
  71. }
  72. Base = (function() {
  73. Base.prototype.defaults = {
  74. debug: false
  75. };
  76. function Base(options) {
  77. this.options = $.extend({}, this.defaults, options);
  78. this.log = new Log({
  79. debug: this.options.debug,
  80. logPrefix: this.options.logPrefix || this.logPrefix
  81. });
  82. }
  83. return Base;
  84. })();
  85. Log = (function() {
  86. Log.prototype.defaults = {
  87. debug: false
  88. };
  89. function Log(options) {
  90. this.log = bind(this.log, this);
  91. this.error = bind(this.error, this);
  92. this.notice = bind(this.notice, this);
  93. this.debug = bind(this.debug, this);
  94. this.options = $.extend({}, this.defaults, options);
  95. }
  96. Log.prototype.debug = function() {
  97. var items;
  98. items = 1 <= arguments.length ? slice.call(arguments, 0) : [];
  99. if (!this.options.debug) {
  100. return;
  101. }
  102. return this.log('debug', items);
  103. };
  104. Log.prototype.notice = function() {
  105. var items;
  106. items = 1 <= arguments.length ? slice.call(arguments, 0) : [];
  107. return this.log('notice', items);
  108. };
  109. Log.prototype.error = function() {
  110. var items;
  111. items = 1 <= arguments.length ? slice.call(arguments, 0) : [];
  112. return this.log('error', items);
  113. };
  114. Log.prototype.log = function(level, items) {
  115. var item, j, len, logString;
  116. items.unshift('||');
  117. items.unshift(level);
  118. items.unshift(this.options.logPrefix);
  119. console.log.apply(console, items);
  120. if (!this.options.debug) {
  121. return;
  122. }
  123. logString = '';
  124. for (j = 0, len = items.length; j < len; j++) {
  125. item = items[j];
  126. logString += ' ';
  127. if (typeof item === 'object') {
  128. logString += JSON.stringify(item);
  129. } else if (item && item.toString) {
  130. logString += item.toString();
  131. } else {
  132. logString += item;
  133. }
  134. }
  135. return $('.js-chatLogDisplay').prepend('<div>' + logString + '</div>');
  136. };
  137. return Log;
  138. })();
  139. Timeout = (function(superClass) {
  140. extend(Timeout, superClass);
  141. Timeout.prototype.timeoutStartedAt = null;
  142. Timeout.prototype.logPrefix = 'timeout';
  143. Timeout.prototype.defaults = {
  144. debug: false,
  145. timeout: 4,
  146. timeoutIntervallCheck: 0.5
  147. };
  148. function Timeout(options) {
  149. this.stop = bind(this.stop, this);
  150. this.start = bind(this.start, this);
  151. Timeout.__super__.constructor.call(this, options);
  152. }
  153. Timeout.prototype.start = function() {
  154. var check, timeoutStartedAt;
  155. this.stop();
  156. timeoutStartedAt = new Date;
  157. check = (function(_this) {
  158. return function() {
  159. var timeLeft;
  160. timeLeft = new Date - new Date(timeoutStartedAt.getTime() + _this.options.timeout * 1000 * 60);
  161. _this.log.debug("Timeout check for " + _this.options.timeout + " minutes (left " + (timeLeft / 1000) + " sec.)");
  162. if (timeLeft < 0) {
  163. return;
  164. }
  165. _this.stop();
  166. return _this.options.callback();
  167. };
  168. })(this);
  169. this.log.debug("Start timeout in " + this.options.timeout + " minutes");
  170. return this.intervallId = setInterval(check, this.options.timeoutIntervallCheck * 1000 * 60);
  171. };
  172. Timeout.prototype.stop = function() {
  173. if (!this.intervallId) {
  174. return;
  175. }
  176. this.log.debug("Stop timeout of " + this.options.timeout + " minutes");
  177. return clearInterval(this.intervallId);
  178. };
  179. return Timeout;
  180. })(Base);
  181. Io = (function(superClass) {
  182. extend(Io, superClass);
  183. Io.prototype.logPrefix = 'io';
  184. function Io(options) {
  185. this.ping = bind(this.ping, this);
  186. this.send = bind(this.send, this);
  187. this.reconnect = bind(this.reconnect, this);
  188. this.close = bind(this.close, this);
  189. this.connect = bind(this.connect, this);
  190. this.set = bind(this.set, this);
  191. Io.__super__.constructor.call(this, options);
  192. }
  193. Io.prototype.set = function(params) {
  194. var key, results, value;
  195. results = [];
  196. for (key in params) {
  197. value = params[key];
  198. results.push(this.options[key] = value);
  199. }
  200. return results;
  201. };
  202. Io.prototype.connect = function() {
  203. this.log.debug("Connecting to " + this.options.host);
  204. this.ws = new window.WebSocket("" + this.options.host);
  205. this.ws.onopen = (function(_this) {
  206. return function(e) {
  207. _this.log.debug('onOpen', e);
  208. _this.options.onOpen(e);
  209. return _this.ping();
  210. };
  211. })(this);
  212. this.ws.onmessage = (function(_this) {
  213. return function(e) {
  214. var j, len, pipe, pipes;
  215. pipes = JSON.parse(e.data);
  216. _this.log.debug('onMessage', e.data);
  217. for (j = 0, len = pipes.length; j < len; j++) {
  218. pipe = pipes[j];
  219. if (pipe.event === 'pong') {
  220. _this.ping();
  221. }
  222. }
  223. if (_this.options.onMessage) {
  224. return _this.options.onMessage(pipes);
  225. }
  226. };
  227. })(this);
  228. this.ws.onclose = (function(_this) {
  229. return function(e) {
  230. _this.log.debug('close websocket connection', e);
  231. if (_this.pingDelayId) {
  232. clearTimeout(_this.pingDelayId);
  233. }
  234. if (_this.manualClose) {
  235. _this.log.debug('manual close, onClose callback');
  236. _this.manualClose = false;
  237. if (_this.options.onClose) {
  238. return _this.options.onClose(e);
  239. }
  240. } else {
  241. _this.log.debug('error close, onError callback');
  242. if (_this.options.onError) {
  243. return _this.options.onError('Connection lost...');
  244. }
  245. }
  246. };
  247. })(this);
  248. return this.ws.onerror = (function(_this) {
  249. return function(e) {
  250. _this.log.debug('onError', e);
  251. if (_this.options.onError) {
  252. return _this.options.onError(e);
  253. }
  254. };
  255. })(this);
  256. };
  257. Io.prototype.close = function() {
  258. this.log.debug('close websocket manually');
  259. this.manualClose = true;
  260. return this.ws.close();
  261. };
  262. Io.prototype.reconnect = function() {
  263. this.log.debug('reconnect');
  264. this.close();
  265. return this.connect();
  266. };
  267. Io.prototype.send = function(event, data) {
  268. var msg;
  269. if (data == null) {
  270. data = {};
  271. }
  272. this.log.debug('send', event, data);
  273. msg = JSON.stringify({
  274. event: event,
  275. data: data
  276. });
  277. return this.ws.send(msg);
  278. };
  279. Io.prototype.ping = function() {
  280. var localPing;
  281. localPing = (function(_this) {
  282. return function() {
  283. return _this.send('ping');
  284. };
  285. })(this);
  286. return this.pingDelayId = setTimeout(localPing, 29000);
  287. };
  288. return Io;
  289. })(Base);
  290. ZammadChat = (function(superClass) {
  291. extend(ZammadChat, superClass);
  292. ZammadChat.prototype.defaults = {
  293. chatId: void 0,
  294. show: true,
  295. target: $('body'),
  296. host: '',
  297. debug: false,
  298. flat: false,
  299. lang: void 0,
  300. cssAutoload: true,
  301. cssUrl: void 0,
  302. fontSize: void 0,
  303. buttonClass: 'open-zammad-chat',
  304. inactiveClass: 'is-inactive',
  305. title: '<strong>Chat</strong> with us!',
  306. scrollHint: 'Scroll down to see new messages',
  307. idleTimeout: 6,
  308. idleTimeoutIntervallCheck: 0.5,
  309. inactiveTimeout: 8,
  310. inactiveTimeoutIntervallCheck: 0.5,
  311. waitingListTimeout: 4,
  312. waitingListTimeoutIntervallCheck: 0.5,
  313. onReady: void 0,
  314. onCloseAnimationEnd: void 0,
  315. onError: void 0,
  316. onOpenAnimationEnd: void 0,
  317. onConnectionReestablished: void 0,
  318. onSessionClosed: void 0,
  319. onConnectionEstablished: void 0,
  320. onCssLoaded: void 0
  321. };
  322. ZammadChat.prototype.logPrefix = 'chat';
  323. ZammadChat.prototype._messageCount = 0;
  324. ZammadChat.prototype.isOpen = false;
  325. ZammadChat.prototype.blinkOnlineInterval = null;
  326. ZammadChat.prototype.stopBlinOnlineStateTimeout = null;
  327. ZammadChat.prototype.showTimeEveryXMinutes = 2;
  328. ZammadChat.prototype.lastTimestamp = null;
  329. ZammadChat.prototype.lastAddedType = null;
  330. ZammadChat.prototype.inputDisabled = false;
  331. ZammadChat.prototype.inputTimeout = null;
  332. ZammadChat.prototype.isTyping = false;
  333. ZammadChat.prototype.state = 'offline';
  334. ZammadChat.prototype.initialQueueDelay = 10000;
  335. ZammadChat.prototype.translations = {
  336. 'de': {
  337. '<strong>Chat</strong> with us!': '<strong>Chatte</strong> mit uns!',
  338. 'All colleagues are busy.': 'Alle Kollegen sind beschäftigt.',
  339. 'Chat closed by %s': 'Chat von %s geschlossen',
  340. 'Compose your message…': 'Verfassen Sie Ihre Nachricht…',
  341. 'Connecting': 'Verbinde',
  342. 'Connection lost': 'Verbindung verloren',
  343. 'Connection re-established': 'Verbindung wieder aufgebaut',
  344. 'Offline': 'Offline',
  345. 'Online': 'Online',
  346. 'Scroll down to see new messages': 'Nach unten scrollen um neue Nachrichten zu sehen',
  347. 'Send': 'Senden',
  348. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Da Sie innerhalb der letzten %s Minuten nicht reagiert haben, wurde Ihre Unterhaltung geschlossen.',
  349. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Da Sie innerhalb der letzten %s Minuten nicht reagiert haben, wurde Ihre Unterhaltung mit <strong>%s</strong> geschlossen.',
  350. 'Start new conversation': 'Neue Unterhaltung starten',
  351. 'Today': 'Heute',
  352. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Entschuldigung, es dauert länger als erwartet einen freien Platz zu bekommen. Versuchen Sie es später erneut oder senden Sie uns eine E-Mail. Vielen Dank!',
  353. 'You are on waiting list position <strong>%s</strong>.': 'Sie sind in der Warteliste auf Position <strong>%s</strong>.'
  354. },
  355. 'es': {
  356. '<strong>Chat</strong> with us!': '<strong>Chatee</strong> con nosotros!',
  357. 'All colleagues are busy.': 'Todos los colegas están ocupados.',
  358. 'Chat closed by %s': 'Chat cerrado por %s',
  359. 'Compose your message…': 'Escribe tu mensaje…',
  360. 'Connecting': 'Conectando',
  361. 'Connection lost': 'Conexión perdida',
  362. 'Connection re-established': 'Conexión reestablecida',
  363. 'Offline': 'Desconectado',
  364. 'Online': 'En línea',
  365. 'Scroll down to see new messages': 'Haga scroll hacia abajo para ver nuevos mensajes',
  366. 'Send': 'Enviar',
  367. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  368. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  369. 'Start new conversation': 'Iniciar nueva conversación',
  370. 'Today': 'Hoy',
  371. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': '',
  372. 'You are on waiting list position <strong>%s</strong>.': 'Usted está en la posición <strong>%s</strong> de la lista de espera.'
  373. },
  374. 'fr': {
  375. '<strong>Chat</strong> with us!': '<strong>Chattez</strong> avec nous!',
  376. 'All colleagues are busy.': 'Tout les agents sont occupés.',
  377. 'Chat closed by %s': 'Chat fermé par %s',
  378. 'Compose your message…': 'Ecrivez votre message…',
  379. 'Connecting': 'Connexion',
  380. 'Connection lost': 'Connexion perdue',
  381. 'Connection re-established': 'Connexion ré-établie',
  382. 'Offline': 'Hors-ligne',
  383. 'Online': 'En ligne',
  384. 'Scroll down to see new messages': 'Défiler vers le bas pour voir les nouveaux messages',
  385. 'Send': 'Envoyer',
  386. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  387. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  388. 'Start new conversation': 'Démarrer une nouvelle conversation',
  389. 'Today': 'Aujourd\'hui',
  390. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': '',
  391. 'You are on waiting list position <strong>%s</strong>.': 'Vous êtes actuellement en position <strong>%s</strong> dans la file d\'attente.'
  392. },
  393. 'hr': {
  394. '<strong>Chat</strong> with us!': '<strong>Čavrljajte</strong> sa nama!',
  395. 'All colleagues are busy.': 'Svi kolege su zauzeti.',
  396. 'Chat closed by %s': '%s zatvara chat',
  397. 'Compose your message…': 'Sastavite poruku…',
  398. 'Connecting': 'Povezivanje',
  399. 'Connection lost': 'Veza prekinuta',
  400. 'Connection re-established': 'Veza je ponovno uspostavljena',
  401. 'Offline': 'Odsutan',
  402. 'Online': 'Dostupan(a)',
  403. 'Scroll down to see new messages': 'Pomaknite se prema dolje da biste vidjeli nove poruke',
  404. 'Send': 'Šalji',
  405. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Budući da niste odgovorili u posljednjih %s minuta, Vaš je razgovor zatvoren.',
  406. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Budući da niste odgovorili u posljednjih %s minuta, Vaš je razgovor s <strong>%</strong>s zatvoren.',
  407. 'Start new conversation': 'Započni novi razgovor',
  408. 'Today': 'Danas',
  409. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Oprostite, proces traje duže nego što se očekivalo da biste dobili slobodan termin. Molimo, pokušajte ponovno kasnije ili nam pošaljite e-mail. Hvala!',
  410. 'You are on waiting list position <strong>%s</strong>.': 'Nalazite se u redu čekanja na poziciji <strong>%s</strong>.'
  411. },
  412. 'it': {
  413. '<strong>Chat</strong> with us!': '<strong>Chatta</strong> con noi!',
  414. 'All colleagues are busy.': 'Tutti i colleghi sono occupati.',
  415. 'Chat closed by %s': 'Chat chiusa da %s',
  416. 'Compose your message…': 'Scrivi il tuo messaggio…',
  417. 'Connecting': 'Connessione in corso',
  418. 'Connection lost': 'Connessione persa',
  419. 'Connection re-established': 'Connessione ristabilita',
  420. 'Offline': 'Offline',
  421. 'Online': 'Online',
  422. 'Scroll down to see new messages': 'Scorri verso il basso per vedere i nuovi messaggi',
  423. 'Send': 'Invia',
  424. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  425. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  426. 'Start new conversation': 'Avvia una nuova chat',
  427. 'Today': 'Oggi',
  428. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': '',
  429. 'You are on waiting list position <strong>%s</strong>.': 'Sei alla posizione <strong>%s</strong> della lista di attesa.'
  430. },
  431. 'nl': {
  432. '<strong>Chat</strong> with us!': '<strong>Chat</strong> met ons!',
  433. 'All colleagues are busy.': 'Alle collega\'s zijn bezet.',
  434. 'Chat closed by %s': 'Chat gesloten door %s',
  435. 'Compose your message…': 'Stel je bericht op…',
  436. 'Connecting': 'Verbinden',
  437. 'Connection lost': 'Verbinding verbroken',
  438. 'Connection re-established': 'Verbinding hersteld',
  439. 'Offline': 'Offline',
  440. 'Online': 'Online',
  441. 'Scroll down to see new messages': 'Scroll naar beneden om nieuwe tickets te bekijken',
  442. 'Send': 'Verstuur',
  443. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  444. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  445. 'Start new conversation': 'Nieuw gesprek starten',
  446. 'Today': 'Vandaag',
  447. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': '',
  448. 'You are on waiting list position <strong>%s</strong>.': 'U bevindt zich op wachtlijstpositie <strong>%s</strong>.'
  449. },
  450. 'pl': {
  451. '<strong>Chat</strong> with us!': '<strong>Czatuj</strong> z nami!',
  452. 'All colleagues are busy.': 'Wszyscy agenci są zajęci.',
  453. 'Chat closed by %s': 'Chat zamknięty przez %s',
  454. 'Compose your message…': 'Skomponuj swoją wiadomość…',
  455. 'Connecting': 'Łączenie',
  456. 'Connection lost': 'Utracono połączenie',
  457. 'Connection re-established': 'Ponowne nawiązanie połączenia',
  458. 'Offline': 'Offline',
  459. 'Online': 'Online',
  460. 'Scroll down to see new messages': 'Skroluj w dół, aby zobaczyć wiadomości',
  461. 'Send': 'Wyślij',
  462. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  463. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  464. 'Start new conversation': 'Rozpocznij nową rozmowę',
  465. 'Today': 'Dzisiaj',
  466. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': '',
  467. 'You are on waiting list position <strong>%s</strong>.': 'Jesteś na pozycji listy oczekujących <strong>%s</strong>.'
  468. },
  469. 'pt-br': {
  470. '<strong>Chat</strong> with us!': '<strong>Converse</strong> conosco!',
  471. 'All colleagues are busy.': 'Nossos atendentes estão ocupados.',
  472. 'Chat closed by %s': 'Chat encerrado por %s',
  473. 'Compose your message…': 'Escreva sua mensagem…',
  474. 'Connecting': 'Conectando',
  475. 'Connection lost': 'Conexão perdida',
  476. 'Connection re-established': 'Conexão restabelecida',
  477. 'Offline': 'Desconectado',
  478. 'Online': 'Online',
  479. 'Scroll down to see new messages': 'Rolar para baixo para ver novas mensagems',
  480. 'Send': 'Enviar',
  481. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  482. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  483. 'Start new conversation': 'Iniciar uma nova conversa',
  484. 'Today': 'Hoje',
  485. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': '',
  486. 'You are on waiting list position <strong>%s</strong>.': 'Você está na posição <strong>%s</strong> da lista de espera.'
  487. },
  488. 'ru': {
  489. '<strong>Chat</strong> with us!': '<strong>Напишите</strong> нам!',
  490. 'All colleagues are busy.': 'Все коллеги заняты.',
  491. 'Chat closed by %s': 'Чат закрыт %s',
  492. 'Compose your message…': 'Составьте сообщение…',
  493. 'Connecting': 'Подключение',
  494. 'Connection lost': 'Подключение потеряно',
  495. 'Connection re-established': 'Подключение восстановлено',
  496. 'Offline': 'Оффлайн',
  497. 'Online': 'В сети',
  498. 'Scroll down to see new messages': 'Прокрутите вниз, чтобы увидеть новые сообщения',
  499. 'Send': 'Отправить',
  500. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  501. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  502. 'Start new conversation': 'Начать новую беседу',
  503. 'Today': 'Сегодня',
  504. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': '',
  505. 'You are on waiting list position <strong>%s</strong>.': 'Вы находитесь в списке ожидания <strong>%s</strong>.'
  506. },
  507. 'sr': {
  508. '<strong>Chat</strong> with us!': '<strong>Ћаскајте</strong> са нама!',
  509. 'All colleagues are busy.': 'Све колеге су заузете.',
  510. 'Chat closed by %s': 'Ћаскање затворено од стране %s',
  511. 'Compose your message…': 'Напишите поруку…',
  512. 'Connecting': 'Повезивање',
  513. 'Connection lost': 'Веза је изгубљена',
  514. 'Connection re-established': 'Веза је поново успостављена',
  515. 'Offline': 'Одсутан(а)',
  516. 'Online': 'Доступан(а)',
  517. 'Scroll down to see new messages': 'Скролујте на доле за нове поруке',
  518. 'Send': 'Пошаљи',
  519. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Пошто нисте одговорили у последњих %s минут(a), ваш разговор је завршен.',
  520. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Пошто нисте одговорили у последњих %s минут(a), ваш разговор са <strong>%s</strong> је завршен.',
  521. 'Start new conversation': 'Започни нови разговор',
  522. 'Today': 'Данас',
  523. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Жао нам је, добијање празног термина траје дуже од очекиваног. Молимо покушајте поново касније или нам пошаљите имејл поруку. Хвала вам!',
  524. 'You are on waiting list position <strong>%s</strong>.': 'Ви сте тренутно <strong>%s.</strong> у реду за чекање.'
  525. },
  526. 'sr-latn-rs': {
  527. '<strong>Chat</strong> with us!': '<strong>Ćaskajte</strong> sa nama!',
  528. 'All colleagues are busy.': 'Sve kolege su zauzete.',
  529. 'Chat closed by %s': 'Ćaskanje zatvoreno od strane %s',
  530. 'Compose your message…': 'Napišite poruku…',
  531. 'Connecting': 'Povezivanje',
  532. 'Connection lost': 'Veza je izgubljena',
  533. 'Connection re-established': 'Veza je ponovo uspostavljena',
  534. 'Offline': 'Odsutan(a)',
  535. 'Online': 'Dostupan(a)',
  536. 'Scroll down to see new messages': 'Skrolujte na dole za nove poruke',
  537. 'Send': 'Pošalji',
  538. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Pošto niste odgovorili u poslednjih %s minut(a), vaš razgovor je završen.',
  539. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Pošto niste odgovorili u poslednjih %s minut(a), vaš razgovor sa <strong>%s</strong> je završen.',
  540. 'Start new conversation': 'Započni novi razgovor',
  541. 'Today': 'Danas',
  542. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Žao nam je, dobijanje praznog termina traje duže od očekivanog. Molimo pokušajte ponovo kasnije ili nam pošaljite imejl poruku. Hvala vam!',
  543. 'You are on waiting list position <strong>%s</strong>.': 'Vi ste trenutno <strong>%s.</strong> u redu za čekanje.'
  544. },
  545. 'sv': {
  546. '<strong>Chat</strong> with us!': '<strong>Chatta</strong> med oss!',
  547. 'All colleagues are busy.': 'Alla kollegor är upptagna.',
  548. 'Chat closed by %s': 'Chatt stängd av %s',
  549. 'Compose your message…': 'Skriv ditt meddelande …',
  550. 'Connecting': 'Ansluter',
  551. 'Connection lost': 'Anslutningen försvann',
  552. 'Connection re-established': 'Anslutningen återupprättas',
  553. 'Offline': 'Offline',
  554. 'Online': 'Online',
  555. 'Scroll down to see new messages': 'Bläddra ner för att se nya meddelanden',
  556. 'Send': 'Skicka',
  557. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  558. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  559. 'Start new conversation': 'Starta ny konversation',
  560. 'Today': 'Idag',
  561. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Det tar tyvärr längre tid än förväntat att få en ledig plats. Försök igen senare eller skicka ett mejl till oss. Tack!',
  562. 'You are on waiting list position <strong>%s</strong>.': 'Du är på väntelistan som position <strong>%s</strong>.'
  563. }
  564. };
  565. ZammadChat.prototype.sessionId = void 0;
  566. ZammadChat.prototype.scrolledToBottom = true;
  567. ZammadChat.prototype.scrollSnapTolerance = 10;
  568. ZammadChat.prototype.richTextFormatKey = {
  569. 66: true,
  570. 73: true,
  571. 85: true,
  572. 83: true
  573. };
  574. ZammadChat.prototype.T = function() {
  575. var item, items, j, len, string, translations;
  576. string = arguments[0], items = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  577. if (this.options.lang && this.options.lang !== 'en') {
  578. if (!this.translations[this.options.lang]) {
  579. this.log.notice("Translation '" + this.options.lang + "' needed!");
  580. } else {
  581. translations = this.translations[this.options.lang];
  582. if (!translations[string]) {
  583. this.log.notice("Translation needed for '" + string + "'");
  584. }
  585. string = translations[string] || string;
  586. }
  587. }
  588. if (items) {
  589. for (j = 0, len = items.length; j < len; j++) {
  590. item = items[j];
  591. string = string.replace(/%s/, item);
  592. }
  593. }
  594. return string;
  595. };
  596. ZammadChat.prototype.view = function(name) {
  597. return (function(_this) {
  598. return function(options) {
  599. if (!options) {
  600. options = {};
  601. }
  602. options.T = _this.T;
  603. options.background = _this.options.background;
  604. options.flat = _this.options.flat;
  605. options.fontSize = _this.options.fontSize;
  606. return window.zammadChatTemplates[name](options);
  607. };
  608. })(this);
  609. };
  610. function ZammadChat(options) {
  611. this.removeAttributes = bind(this.removeAttributes, this);
  612. this.startTimeoutObservers = bind(this.startTimeoutObservers, this);
  613. this.onCssLoaded = bind(this.onCssLoaded, this);
  614. this.setAgentOnlineState = bind(this.setAgentOnlineState, this);
  615. this.onConnectionEstablished = bind(this.onConnectionEstablished, this);
  616. this.setSessionId = bind(this.setSessionId, this);
  617. this.onConnectionReestablished = bind(this.onConnectionReestablished, this);
  618. this.reconnect = bind(this.reconnect, this);
  619. this.destroy = bind(this.destroy, this);
  620. this.onScrollHintClick = bind(this.onScrollHintClick, this);
  621. this.detectScrolledtoBottom = bind(this.detectScrolledtoBottom, this);
  622. this.onLeaveTemporary = bind(this.onLeaveTemporary, this);
  623. this.onAgentTypingEnd = bind(this.onAgentTypingEnd, this);
  624. this.onAgentTypingStart = bind(this.onAgentTypingStart, this);
  625. this.onQueue = bind(this.onQueue, this);
  626. this.onQueueScreen = bind(this.onQueueScreen, this);
  627. this.onWebSocketClose = bind(this.onWebSocketClose, this);
  628. this.onCloseAnimationEnd = bind(this.onCloseAnimationEnd, this);
  629. this.close = bind(this.close, this);
  630. this.toggle = bind(this.toggle, this);
  631. this.sessionClose = bind(this.sessionClose, this);
  632. this.onOpenAnimationEnd = bind(this.onOpenAnimationEnd, this);
  633. this.open = bind(this.open, this);
  634. this.renderMessage = bind(this.renderMessage, this);
  635. this.receiveMessage = bind(this.receiveMessage, this);
  636. this.onSubmit = bind(this.onSubmit, this);
  637. this.onFocus = bind(this.onFocus, this);
  638. this.onInput = bind(this.onInput, this);
  639. this.onReopenSession = bind(this.onReopenSession, this);
  640. this.onError = bind(this.onError, this);
  641. this.onWebSocketMessage = bind(this.onWebSocketMessage, this);
  642. this.send = bind(this.send, this);
  643. this.checkForEnter = bind(this.checkForEnter, this);
  644. this.render = bind(this.render, this);
  645. this.view = bind(this.view, this);
  646. this.T = bind(this.T, this);
  647. this.options = $.extend({}, this.defaults, options);
  648. ZammadChat.__super__.constructor.call(this, this.options);
  649. this.isFullscreen = window.matchMedia && window.matchMedia('(max-width: 768px)').matches;
  650. this.scrollRoot = $(this.getScrollRoot());
  651. if (!$) {
  652. this.state = 'unsupported';
  653. this.log.notice('Chat: no jquery found!');
  654. return;
  655. }
  656. if (!window.WebSocket || !sessionStorage) {
  657. this.state = 'unsupported';
  658. this.log.notice('Chat: Browser not supported!');
  659. return;
  660. }
  661. if (!this.options.chatId) {
  662. this.state = 'unsupported';
  663. this.log.error('Chat: need chatId as option!');
  664. return;
  665. }
  666. if (!this.options.lang) {
  667. this.options.lang = $('html').attr('lang');
  668. }
  669. if (this.options.lang) {
  670. if (!this.translations[this.options.lang]) {
  671. this.log.debug("lang: No " + this.options.lang + " found, try first two letters");
  672. this.options.lang = this.options.lang.replace(/-.+?$/, '');
  673. }
  674. this.log.debug("lang: " + this.options.lang);
  675. }
  676. if (!this.options.host) {
  677. this.detectHost();
  678. }
  679. this.loadCss();
  680. this.io = new Io(this.options);
  681. this.io.set({
  682. onOpen: this.render,
  683. onClose: this.onWebSocketClose,
  684. onMessage: this.onWebSocketMessage,
  685. onError: this.onError
  686. });
  687. this.io.connect();
  688. }
  689. ZammadChat.prototype.getScrollRoot = function() {
  690. var end, html, start;
  691. if ('scrollingElement' in document) {
  692. return document.scrollingElement;
  693. }
  694. html = document.documentElement;
  695. start = html.scrollTop;
  696. html.scrollTop = start + 1;
  697. end = html.scrollTop;
  698. html.scrollTop = start;
  699. if (end > start) {
  700. return html;
  701. } else {
  702. return document.body;
  703. }
  704. };
  705. ZammadChat.prototype.render = function() {
  706. if (!this.el || !$('.zammad-chat').get(0)) {
  707. this.renderBase();
  708. }
  709. $("." + this.options.buttonClass).addClass(this.options.inactiveClass);
  710. this.setAgentOnlineState('online');
  711. this.log.debug('widget rendered');
  712. this.startTimeoutObservers();
  713. this.idleTimeout.start();
  714. this.sessionId = sessionStorage.getItem('sessionId');
  715. return this.send('chat_status_customer', {
  716. session_id: this.sessionId,
  717. url: window.location.href
  718. });
  719. };
  720. ZammadChat.prototype.renderBase = function() {
  721. this.el = $(this.view('chat')({
  722. title: this.options.title,
  723. scrollHint: this.options.scrollHint
  724. }));
  725. this.options.target.append(this.el);
  726. this.input = this.el.find('.zammad-chat-input');
  727. this.el.find('.js-chat-open').on('click', this.open);
  728. this.el.find('.js-chat-toggle').on('click', this.toggle);
  729. this.el.find('.js-chat-status').on('click', this.stopPropagation);
  730. this.el.find('.zammad-chat-controls').on('submit', this.onSubmit);
  731. this.el.find('.zammad-chat-body').on('scroll', this.detectScrolledtoBottom);
  732. this.el.find('.zammad-scroll-hint').on('click', this.onScrollHintClick);
  733. this.input.on({
  734. keydown: this.checkForEnter,
  735. input: this.onInput
  736. });
  737. this.input.on('keydown', (function(_this) {
  738. return function(e) {
  739. var richtTextControl;
  740. richtTextControl = false;
  741. if (!e.altKey && !e.ctrlKey && e.metaKey) {
  742. richtTextControl = true;
  743. } else if (!e.altKey && e.ctrlKey && !e.metaKey) {
  744. richtTextControl = true;
  745. }
  746. if (richtTextControl && _this.richTextFormatKey[e.keyCode]) {
  747. e.preventDefault();
  748. if (e.keyCode === 66) {
  749. document.execCommand('bold');
  750. return true;
  751. }
  752. if (e.keyCode === 73) {
  753. document.execCommand('italic');
  754. return true;
  755. }
  756. if (e.keyCode === 85) {
  757. document.execCommand('underline');
  758. return true;
  759. }
  760. if (e.keyCode === 83) {
  761. document.execCommand('strikeThrough');
  762. return true;
  763. }
  764. }
  765. };
  766. })(this));
  767. this.input.on('paste', (function(_this) {
  768. return function(e) {
  769. var clipboardData, docType, html, htmlTmp, imageFile, imageInserted, item, match, reader, regex, replacementTag, sanitized, text;
  770. e.stopPropagation();
  771. e.preventDefault();
  772. clipboardData;
  773. if (e.clipboardData) {
  774. clipboardData = e.clipboardData;
  775. } else if (window.clipboardData) {
  776. clipboardData = window.clipboardData;
  777. } else if (e.originalEvent.clipboardData) {
  778. clipboardData = e.originalEvent.clipboardData;
  779. } else {
  780. throw 'No clipboardData support';
  781. }
  782. imageInserted = false;
  783. if (clipboardData && clipboardData.items && clipboardData.items[0]) {
  784. item = clipboardData.items[0];
  785. if (item.kind === 'file' && (item.type === 'image/png' || item.type === 'image/jpeg')) {
  786. imageFile = item.getAsFile();
  787. reader = new FileReader();
  788. reader.onload = function(e) {
  789. var img, insert, result;
  790. result = e.target.result;
  791. img = document.createElement('img');
  792. img.src = result;
  793. insert = function(dataUrl, width, height, isRetina) {
  794. if (_this.isRetina()) {
  795. width = width / 2;
  796. height = height / 2;
  797. }
  798. result = dataUrl;
  799. img = "<img style=\"width: 100%; max-width: " + width + "px;\" src=\"" + result + "\">";
  800. return document.execCommand('insertHTML', false, img);
  801. };
  802. return _this.resizeImage(img.src, 460, 'auto', 2, 'image/jpeg', 'auto', insert);
  803. };
  804. reader.readAsDataURL(imageFile);
  805. imageInserted = true;
  806. }
  807. }
  808. if (imageInserted) {
  809. return;
  810. }
  811. text = void 0;
  812. docType = void 0;
  813. try {
  814. text = clipboardData.getData('text/html');
  815. docType = 'html';
  816. if (!text || text.length === 0) {
  817. docType = 'text';
  818. text = clipboardData.getData('text/plain');
  819. }
  820. if (!text || text.length === 0) {
  821. docType = 'text2';
  822. text = clipboardData.getData('text');
  823. }
  824. } catch (error) {
  825. e = error;
  826. console.log('Sorry, can\'t insert markup because browser is not supporting it.');
  827. docType = 'text3';
  828. text = clipboardData.getData('text');
  829. }
  830. if (docType === 'text' || docType === 'text2' || docType === 'text3') {
  831. text = '<div>' + text.replace(/\n/g, '</div><div>') + '</div>';
  832. text = text.replace(/<div><\/div>/g, '<div><br></div>');
  833. }
  834. console.log('p', docType, text);
  835. if (docType === 'html') {
  836. sanitized = DOMPurify.sanitize(text);
  837. _this.log.debug('sanitized HTML clipboard', sanitized);
  838. html = $("<div>" + sanitized + "</div>");
  839. match = false;
  840. htmlTmp = text;
  841. regex = new RegExp('<(/w|w)\:[A-Za-z]');
  842. if (htmlTmp.match(regex)) {
  843. match = true;
  844. htmlTmp = htmlTmp.replace(regex, '');
  845. }
  846. regex = new RegExp('<(/o|o)\:[A-Za-z]');
  847. if (htmlTmp.match(regex)) {
  848. match = true;
  849. htmlTmp = htmlTmp.replace(regex, '');
  850. }
  851. if (match) {
  852. html = _this.wordFilter(html);
  853. }
  854. html = $(html);
  855. html.contents().each(function() {
  856. if (this.nodeType === 8) {
  857. return $(this).remove();
  858. }
  859. });
  860. html.find('a, font, small, time, form, label').replaceWith(function() {
  861. return $(this).contents();
  862. });
  863. replacementTag = 'div';
  864. html.find('textarea').each(function() {
  865. var newTag, outer;
  866. outer = this.outerHTML;
  867. regex = new RegExp('<' + this.tagName, 'i');
  868. newTag = outer.replace(regex, '<' + replacementTag);
  869. regex = new RegExp('</' + this.tagName, 'i');
  870. newTag = newTag.replace(regex, '</' + replacementTag);
  871. return $(this).replaceWith(newTag);
  872. });
  873. html.find('font, img, svg, input, select, button, style, applet, embed, noframes, canvas, script, frame, iframe, meta, link, title, head, fieldset').remove();
  874. _this.removeAttributes(html);
  875. text = html.html();
  876. }
  877. if (docType === 'text3') {
  878. _this.pasteHtmlAtCaret(text);
  879. } else {
  880. document.execCommand('insertHTML', false, text);
  881. }
  882. return true;
  883. };
  884. })(this));
  885. this.input.on('drop', (function(_this) {
  886. return function(e) {
  887. var dataTransfer, file, reader, x, y;
  888. e.stopPropagation();
  889. e.preventDefault();
  890. dataTransfer;
  891. if (window.dataTransfer) {
  892. dataTransfer = window.dataTransfer;
  893. } else if (e.originalEvent.dataTransfer) {
  894. dataTransfer = e.originalEvent.dataTransfer;
  895. } else {
  896. throw 'No clipboardData support';
  897. }
  898. x = e.clientX;
  899. y = e.clientY;
  900. file = dataTransfer.files[0];
  901. if (file.type.match('image.*')) {
  902. reader = new FileReader();
  903. reader.onload = function(e) {
  904. var img, insert, result;
  905. result = e.target.result;
  906. img = document.createElement('img');
  907. img.src = result;
  908. insert = function(dataUrl, width, height, isRetina) {
  909. var pos, range;
  910. if (_this.isRetina()) {
  911. width = width / 2;
  912. height = height / 2;
  913. }
  914. result = dataUrl;
  915. img = $("<img style=\"width: 100%; max-width: " + width + "px;\" src=\"" + result + "\">");
  916. img = img.get(0);
  917. if (document.caretPositionFromPoint) {
  918. pos = document.caretPositionFromPoint(x, y);
  919. range = document.createRange();
  920. range.setStart(pos.offsetNode, pos.offset);
  921. range.collapse();
  922. return range.insertNode(img);
  923. } else if (document.caretRangeFromPoint) {
  924. range = document.caretRangeFromPoint(x, y);
  925. return range.insertNode(img);
  926. } else {
  927. return console.log('could not find carat');
  928. }
  929. };
  930. return _this.resizeImage(img.src, 460, 'auto', 2, 'image/jpeg', 'auto', insert);
  931. };
  932. return reader.readAsDataURL(file);
  933. }
  934. };
  935. })(this));
  936. $(window).on('beforeunload', (function(_this) {
  937. return function() {
  938. return _this.onLeaveTemporary();
  939. };
  940. })(this));
  941. $(window).on('hashchange', (function(_this) {
  942. return function() {
  943. if (_this.isOpen) {
  944. if (_this.sessionId) {
  945. _this.send('chat_session_notice', {
  946. session_id: _this.sessionId,
  947. message: window.location.href
  948. });
  949. }
  950. return;
  951. }
  952. return _this.idleTimeout.start();
  953. };
  954. })(this));
  955. if (this.isFullscreen) {
  956. return this.input.on({
  957. focus: this.onFocus,
  958. focusout: this.onFocusOut
  959. });
  960. }
  961. };
  962. ZammadChat.prototype.stopPropagation = function(event) {
  963. return event.stopPropagation();
  964. };
  965. ZammadChat.prototype.checkForEnter = function(event) {
  966. if (!this.inputDisabled && !event.shiftKey && event.keyCode === 13) {
  967. event.preventDefault();
  968. return this.sendMessage();
  969. }
  970. };
  971. ZammadChat.prototype.send = function(event, data) {
  972. if (data == null) {
  973. data = {};
  974. }
  975. data.chat_id = this.options.chatId;
  976. return this.io.send(event, data);
  977. };
  978. ZammadChat.prototype.onWebSocketMessage = function(pipes) {
  979. var j, len, pipe;
  980. for (j = 0, len = pipes.length; j < len; j++) {
  981. pipe = pipes[j];
  982. this.log.debug('ws:onmessage', pipe);
  983. switch (pipe.event) {
  984. case 'chat_error':
  985. this.log.notice(pipe.data);
  986. if (pipe.data && pipe.data.state === 'chat_disabled') {
  987. this.destroy({
  988. remove: true
  989. });
  990. }
  991. break;
  992. case 'chat_session_message':
  993. if (pipe.data.self_written) {
  994. return;
  995. }
  996. this.receiveMessage(pipe.data);
  997. break;
  998. case 'chat_session_typing':
  999. if (pipe.data.self_written) {
  1000. return;
  1001. }
  1002. this.onAgentTypingStart();
  1003. break;
  1004. case 'chat_session_start':
  1005. this.onConnectionEstablished(pipe.data);
  1006. break;
  1007. case 'chat_session_queue':
  1008. this.onQueueScreen(pipe.data);
  1009. break;
  1010. case 'chat_session_closed':
  1011. this.onSessionClosed(pipe.data);
  1012. break;
  1013. case 'chat_session_left':
  1014. this.onSessionClosed(pipe.data);
  1015. break;
  1016. case 'chat_session_notice':
  1017. this.addStatus(this.T(pipe.data.message));
  1018. break;
  1019. case 'chat_status_customer':
  1020. switch (pipe.data.state) {
  1021. case 'online':
  1022. this.sessionId = void 0;
  1023. if (!this.options.cssAutoload || this.cssLoaded) {
  1024. this.onReady();
  1025. } else {
  1026. this.socketReady = true;
  1027. }
  1028. break;
  1029. case 'offline':
  1030. this.onError('Zammad Chat: No agent online');
  1031. break;
  1032. case 'chat_disabled':
  1033. this.onError('Zammad Chat: Chat is disabled');
  1034. break;
  1035. case 'no_seats_available':
  1036. this.onError("Zammad Chat: Too many clients in queue. Clients in queue: " + pipe.data.queue);
  1037. break;
  1038. case 'reconnect':
  1039. this.onReopenSession(pipe.data);
  1040. }
  1041. }
  1042. }
  1043. };
  1044. ZammadChat.prototype.onReady = function() {
  1045. var base;
  1046. this.log.debug('widget ready for use');
  1047. $("." + this.options.buttonClass).on('click', this.open).removeClass(this.options.inactiveClass);
  1048. if (typeof (base = this.options).onReady === "function") {
  1049. base.onReady();
  1050. }
  1051. if (this.options.show) {
  1052. return this.show();
  1053. }
  1054. };
  1055. ZammadChat.prototype.onError = function(message) {
  1056. var base;
  1057. this.log.debug(message);
  1058. this.addStatus(message);
  1059. $("." + this.options.buttonClass).hide();
  1060. if (this.isOpen) {
  1061. this.disableInput();
  1062. this.destroy({
  1063. remove: false
  1064. });
  1065. } else {
  1066. this.destroy({
  1067. remove: true
  1068. });
  1069. }
  1070. return typeof (base = this.options).onError === "function" ? base.onError(message) : void 0;
  1071. };
  1072. ZammadChat.prototype.onReopenSession = function(data) {
  1073. var j, len, message, ref, unfinishedMessage;
  1074. this.log.debug('old messages', data.session);
  1075. this.inactiveTimeout.start();
  1076. unfinishedMessage = sessionStorage.getItem('unfinished_message');
  1077. if (data.agent) {
  1078. this.onConnectionEstablished(data);
  1079. ref = data.session;
  1080. for (j = 0, len = ref.length; j < len; j++) {
  1081. message = ref[j];
  1082. this.renderMessage({
  1083. message: message.content,
  1084. id: message.id,
  1085. from: message.created_by_id ? 'agent' : 'customer'
  1086. });
  1087. }
  1088. if (unfinishedMessage) {
  1089. this.input.html(unfinishedMessage);
  1090. }
  1091. }
  1092. if (data.position) {
  1093. this.onQueue(data);
  1094. }
  1095. this.show();
  1096. this.open();
  1097. this.scrollToBottom();
  1098. if (unfinishedMessage) {
  1099. return this.input.trigger('focus');
  1100. }
  1101. };
  1102. ZammadChat.prototype.onInput = function() {
  1103. this.el.find('.zammad-chat-message--unread').removeClass('zammad-chat-message--unread');
  1104. sessionStorage.setItem('unfinished_message', this.input.html());
  1105. return this.onTyping();
  1106. };
  1107. ZammadChat.prototype.onFocus = function() {
  1108. var keyboardShown;
  1109. $(window).scrollTop(10);
  1110. keyboardShown = $(window).scrollTop() > 0;
  1111. $(window).scrollTop(0);
  1112. if (keyboardShown) {
  1113. return this.log.notice('virtual keyboard shown');
  1114. }
  1115. };
  1116. ZammadChat.prototype.onFocusOut = function() {};
  1117. ZammadChat.prototype.onTyping = function() {
  1118. if (this.isTyping && this.isTyping > new Date(new Date().getTime() - 1500)) {
  1119. return;
  1120. }
  1121. this.isTyping = new Date();
  1122. this.send('chat_session_typing', {
  1123. session_id: this.sessionId
  1124. });
  1125. return this.inactiveTimeout.start();
  1126. };
  1127. ZammadChat.prototype.onSubmit = function(event) {
  1128. event.preventDefault();
  1129. return this.sendMessage();
  1130. };
  1131. ZammadChat.prototype.sendMessage = function() {
  1132. var message, messageElement;
  1133. message = this.input.html();
  1134. if (!message) {
  1135. return;
  1136. }
  1137. this.inactiveTimeout.start();
  1138. sessionStorage.removeItem('unfinished_message');
  1139. messageElement = this.view('message')({
  1140. message: message,
  1141. from: 'customer',
  1142. id: this._messageCount++,
  1143. unreadClass: ''
  1144. });
  1145. this.maybeAddTimestamp();
  1146. if (this.el.find('.zammad-chat-message--typing').get(0)) {
  1147. this.lastAddedType = 'typing-placeholder';
  1148. this.el.find('.zammad-chat-message--typing').before(messageElement);
  1149. } else {
  1150. this.lastAddedType = 'message--customer';
  1151. this.el.find('.zammad-chat-body').append(messageElement);
  1152. }
  1153. this.input.html('');
  1154. this.scrollToBottom();
  1155. return this.send('chat_session_message', {
  1156. content: message,
  1157. id: this._messageCount,
  1158. session_id: this.sessionId
  1159. });
  1160. };
  1161. ZammadChat.prototype.receiveMessage = function(data) {
  1162. this.inactiveTimeout.start();
  1163. this.onAgentTypingEnd();
  1164. this.maybeAddTimestamp();
  1165. this.renderMessage({
  1166. message: data.message.content,
  1167. id: data.id,
  1168. from: 'agent'
  1169. });
  1170. return this.scrollToBottom({
  1171. showHint: true
  1172. });
  1173. };
  1174. ZammadChat.prototype.renderMessage = function(data) {
  1175. this.lastAddedType = "message--" + data.from;
  1176. data.unreadClass = document.hidden ? ' zammad-chat-message--unread' : '';
  1177. return this.el.find('.zammad-chat-body').append(this.view('message')(data));
  1178. };
  1179. ZammadChat.prototype.open = function() {
  1180. var remainerHeight;
  1181. if (this.isOpen) {
  1182. this.log.debug('widget already open, block');
  1183. return;
  1184. }
  1185. this.isOpen = true;
  1186. this.log.debug('open widget');
  1187. this.show();
  1188. if (!this.sessionId) {
  1189. this.showLoader();
  1190. }
  1191. this.el.addClass('zammad-chat-is-open');
  1192. remainerHeight = this.el.height() - this.el.find('.zammad-chat-header').outerHeight();
  1193. this.el.css('bottom', -remainerHeight);
  1194. if (!this.sessionId) {
  1195. this.el.animate({
  1196. bottom: 0
  1197. }, 500, this.onOpenAnimationEnd);
  1198. return this.send('chat_session_init', {
  1199. url: window.location.href
  1200. });
  1201. } else {
  1202. this.el.css('bottom', 0);
  1203. return this.onOpenAnimationEnd();
  1204. }
  1205. };
  1206. ZammadChat.prototype.onOpenAnimationEnd = function() {
  1207. var base;
  1208. this.idleTimeout.stop();
  1209. if (this.isFullscreen) {
  1210. this.disableScrollOnRoot();
  1211. }
  1212. return typeof (base = this.options).onOpenAnimationEnd === "function" ? base.onOpenAnimationEnd() : void 0;
  1213. };
  1214. ZammadChat.prototype.sessionClose = function() {
  1215. this.send('chat_session_close', {
  1216. session_id: this.sessionId
  1217. });
  1218. this.inactiveTimeout.stop();
  1219. this.waitingListTimeout.stop();
  1220. sessionStorage.removeItem('unfinished_message');
  1221. if (this.onInitialQueueDelayId) {
  1222. clearTimeout(this.onInitialQueueDelayId);
  1223. }
  1224. return this.setSessionId(void 0);
  1225. };
  1226. ZammadChat.prototype.toggle = function(event) {
  1227. if (this.isOpen) {
  1228. return this.close(event);
  1229. } else {
  1230. return this.open(event);
  1231. }
  1232. };
  1233. ZammadChat.prototype.close = function(event) {
  1234. var remainerHeight;
  1235. if (!this.isOpen) {
  1236. this.log.debug('can\'t close widget, it\'s not open');
  1237. return;
  1238. }
  1239. if (this.initDelayId) {
  1240. clearTimeout(this.initDelayId);
  1241. }
  1242. if (this.sessionId) {
  1243. this.log.debug('session close before widget close');
  1244. this.sessionClose();
  1245. }
  1246. this.log.debug('close widget');
  1247. if (event) {
  1248. event.stopPropagation();
  1249. }
  1250. if (this.isFullscreen) {
  1251. this.enableScrollOnRoot();
  1252. }
  1253. remainerHeight = this.el.height() - this.el.find('.zammad-chat-header').outerHeight();
  1254. return this.el.animate({
  1255. bottom: -remainerHeight
  1256. }, 500, this.onCloseAnimationEnd);
  1257. };
  1258. ZammadChat.prototype.onCloseAnimationEnd = function() {
  1259. var base;
  1260. this.el.css('bottom', '');
  1261. this.el.removeClass('zammad-chat-is-open');
  1262. this.showLoader();
  1263. this.el.find('.zammad-chat-welcome').removeClass('zammad-chat-is-hidden');
  1264. this.el.find('.zammad-chat-agent').addClass('zammad-chat-is-hidden');
  1265. this.el.find('.zammad-chat-agent-status').addClass('zammad-chat-is-hidden');
  1266. this.isOpen = false;
  1267. if (typeof (base = this.options).onCloseAnimationEnd === "function") {
  1268. base.onCloseAnimationEnd();
  1269. }
  1270. return this.io.reconnect();
  1271. };
  1272. ZammadChat.prototype.onWebSocketClose = function() {
  1273. if (this.isOpen) {
  1274. return;
  1275. }
  1276. if (this.el) {
  1277. this.el.removeClass('zammad-chat-is-shown');
  1278. return this.el.removeClass('zammad-chat-is-loaded');
  1279. }
  1280. };
  1281. ZammadChat.prototype.show = function() {
  1282. if (this.state === 'offline') {
  1283. return;
  1284. }
  1285. this.el.addClass('zammad-chat-is-loaded');
  1286. return this.el.addClass('zammad-chat-is-shown');
  1287. };
  1288. ZammadChat.prototype.disableInput = function() {
  1289. this.inputDisabled = true;
  1290. this.input.prop('contenteditable', false);
  1291. this.el.find('.zammad-chat-send').prop('disabled', true);
  1292. return this.io.close();
  1293. };
  1294. ZammadChat.prototype.enableInput = function() {
  1295. this.inputDisabled = false;
  1296. this.input.prop('contenteditable', true);
  1297. return this.el.find('.zammad-chat-send').prop('disabled', false);
  1298. };
  1299. ZammadChat.prototype.hideModal = function() {
  1300. return this.el.find('.zammad-chat-modal').html('');
  1301. };
  1302. ZammadChat.prototype.onQueueScreen = function(data) {
  1303. var show;
  1304. this.setSessionId(data.session_id);
  1305. show = (function(_this) {
  1306. return function() {
  1307. _this.onQueue(data);
  1308. return _this.waitingListTimeout.start();
  1309. };
  1310. })(this);
  1311. if (this.initialQueueDelay && !this.onInitialQueueDelayId) {
  1312. this.onInitialQueueDelayId = setTimeout(show, this.initialQueueDelay);
  1313. return;
  1314. }
  1315. if (this.onInitialQueueDelayId) {
  1316. clearTimeout(this.onInitialQueueDelayId);
  1317. }
  1318. return show();
  1319. };
  1320. ZammadChat.prototype.onQueue = function(data) {
  1321. this.log.notice('onQueue', data.position);
  1322. this.inQueue = true;
  1323. return this.el.find('.zammad-chat-modal').html(this.view('waiting')({
  1324. position: data.position
  1325. }));
  1326. };
  1327. ZammadChat.prototype.onAgentTypingStart = function() {
  1328. if (this.stopTypingId) {
  1329. clearTimeout(this.stopTypingId);
  1330. }
  1331. this.stopTypingId = setTimeout(this.onAgentTypingEnd, 3000);
  1332. if (this.el.find('.zammad-chat-message--typing').get(0)) {
  1333. return;
  1334. }
  1335. this.maybeAddTimestamp();
  1336. this.el.find('.zammad-chat-body').append(this.view('typingIndicator')());
  1337. if (!this.isVisible(this.el.find('.zammad-chat-message--typing'), true)) {
  1338. return;
  1339. }
  1340. return this.scrollToBottom();
  1341. };
  1342. ZammadChat.prototype.onAgentTypingEnd = function() {
  1343. return this.el.find('.zammad-chat-message--typing').remove();
  1344. };
  1345. ZammadChat.prototype.onLeaveTemporary = function() {
  1346. if (!this.sessionId) {
  1347. return;
  1348. }
  1349. return this.send('chat_session_leave_temporary', {
  1350. session_id: this.sessionId
  1351. });
  1352. };
  1353. ZammadChat.prototype.maybeAddTimestamp = function() {
  1354. var label, time, timestamp;
  1355. timestamp = Date.now();
  1356. if (!this.lastTimestamp || (timestamp - this.lastTimestamp) > this.showTimeEveryXMinutes * 60000) {
  1357. label = this.T('Today');
  1358. time = new Date().toTimeString().substr(0, 5);
  1359. if (this.lastAddedType === 'timestamp') {
  1360. this.updateLastTimestamp(label, time);
  1361. return this.lastTimestamp = timestamp;
  1362. } else {
  1363. this.el.find('.zammad-chat-body').append(this.view('timestamp')({
  1364. label: label,
  1365. time: time
  1366. }));
  1367. this.lastTimestamp = timestamp;
  1368. this.lastAddedType = 'timestamp';
  1369. return this.scrollToBottom();
  1370. }
  1371. }
  1372. };
  1373. ZammadChat.prototype.updateLastTimestamp = function(label, time) {
  1374. if (!this.el) {
  1375. return;
  1376. }
  1377. return this.el.find('.zammad-chat-body').find('.zammad-chat-timestamp').last().replaceWith(this.view('timestamp')({
  1378. label: label,
  1379. time: time
  1380. }));
  1381. };
  1382. ZammadChat.prototype.addStatus = function(status) {
  1383. if (!this.el) {
  1384. return;
  1385. }
  1386. this.maybeAddTimestamp();
  1387. this.el.find('.zammad-chat-body').append(this.view('status')({
  1388. status: status
  1389. }));
  1390. return this.scrollToBottom();
  1391. };
  1392. ZammadChat.prototype.detectScrolledtoBottom = function() {
  1393. var scrollBottom;
  1394. scrollBottom = this.el.find('.zammad-chat-body').scrollTop() + this.el.find('.zammad-chat-body').outerHeight();
  1395. this.scrolledToBottom = Math.abs(scrollBottom - this.el.find('.zammad-chat-body').prop('scrollHeight')) <= this.scrollSnapTolerance;
  1396. if (this.scrolledToBottom) {
  1397. return this.el.find('.zammad-scroll-hint').addClass('is-hidden');
  1398. }
  1399. };
  1400. ZammadChat.prototype.showScrollHint = function() {
  1401. this.el.find('.zammad-scroll-hint').removeClass('is-hidden');
  1402. return this.el.find('.zammad-chat-body').scrollTop(this.el.find('.zammad-chat-body').scrollTop() + this.el.find('.zammad-scroll-hint').outerHeight());
  1403. };
  1404. ZammadChat.prototype.onScrollHintClick = function() {
  1405. return this.el.find('.zammad-chat-body').animate({
  1406. scrollTop: this.el.find('.zammad-chat-body').prop('scrollHeight')
  1407. }, 300);
  1408. };
  1409. ZammadChat.prototype.scrollToBottom = function(arg) {
  1410. var showHint;
  1411. showHint = (arg != null ? arg : {
  1412. showHint: false
  1413. }).showHint;
  1414. if (this.scrolledToBottom) {
  1415. return this.el.find('.zammad-chat-body').scrollTop($('.zammad-chat-body').prop('scrollHeight'));
  1416. } else if (showHint) {
  1417. return this.showScrollHint();
  1418. }
  1419. };
  1420. ZammadChat.prototype.destroy = function(params) {
  1421. if (params == null) {
  1422. params = {};
  1423. }
  1424. this.log.debug('destroy widget', params);
  1425. this.setAgentOnlineState('offline');
  1426. if (params.remove && this.el) {
  1427. this.el.remove();
  1428. $("." + this.options.buttonClass).hide();
  1429. }
  1430. if (this.waitingListTimeout) {
  1431. this.waitingListTimeout.stop();
  1432. }
  1433. if (this.inactiveTimeout) {
  1434. this.inactiveTimeout.stop();
  1435. }
  1436. if (this.idleTimeout) {
  1437. this.idleTimeout.stop();
  1438. }
  1439. return this.io.close();
  1440. };
  1441. ZammadChat.prototype.reconnect = function() {
  1442. this.log.notice('reconnecting');
  1443. this.disableInput();
  1444. this.lastAddedType = 'status';
  1445. this.setAgentOnlineState('connecting');
  1446. return this.addStatus(this.T('Connection lost'));
  1447. };
  1448. ZammadChat.prototype.onConnectionReestablished = function() {
  1449. var base;
  1450. this.lastAddedType = 'status';
  1451. this.setAgentOnlineState('online');
  1452. this.addStatus(this.T('Connection re-established'));
  1453. return typeof (base = this.options).onConnectionReestablished === "function" ? base.onConnectionReestablished() : void 0;
  1454. };
  1455. ZammadChat.prototype.onSessionClosed = function(data) {
  1456. var base;
  1457. this.addStatus(this.T('Chat closed by %s', data.realname));
  1458. this.disableInput();
  1459. this.setAgentOnlineState('offline');
  1460. this.inactiveTimeout.stop();
  1461. return typeof (base = this.options).onSessionClosed === "function" ? base.onSessionClosed(data) : void 0;
  1462. };
  1463. ZammadChat.prototype.setSessionId = function(id) {
  1464. this.sessionId = id;
  1465. if (id === void 0) {
  1466. return sessionStorage.removeItem('sessionId');
  1467. } else {
  1468. return sessionStorage.setItem('sessionId', id);
  1469. }
  1470. };
  1471. ZammadChat.prototype.onConnectionEstablished = function(data) {
  1472. var base;
  1473. if (this.onInitialQueueDelayId) {
  1474. clearTimeout(this.onInitialQueueDelayId);
  1475. }
  1476. this.inQueue = false;
  1477. if (data.agent) {
  1478. this.agent = data.agent;
  1479. }
  1480. if (data.session_id) {
  1481. this.setSessionId(data.session_id);
  1482. }
  1483. this.el.find('.zammad-chat-body').html('');
  1484. this.el.find('.zammad-chat-agent').html(this.view('agent')({
  1485. agent: this.agent
  1486. }));
  1487. this.enableInput();
  1488. this.hideModal();
  1489. this.el.find('.zammad-chat-welcome').addClass('zammad-chat-is-hidden');
  1490. this.el.find('.zammad-chat-agent').removeClass('zammad-chat-is-hidden');
  1491. this.el.find('.zammad-chat-agent-status').removeClass('zammad-chat-is-hidden');
  1492. if (!this.isFullscreen) {
  1493. this.input.trigger('focus');
  1494. }
  1495. this.setAgentOnlineState('online');
  1496. this.waitingListTimeout.stop();
  1497. this.idleTimeout.stop();
  1498. this.inactiveTimeout.start();
  1499. return typeof (base = this.options).onConnectionEstablished === "function" ? base.onConnectionEstablished(data) : void 0;
  1500. };
  1501. ZammadChat.prototype.showCustomerTimeout = function() {
  1502. var reload;
  1503. this.el.find('.zammad-chat-modal').html(this.view('customer_timeout')({
  1504. agent: this.agent.name,
  1505. delay: this.options.inactiveTimeout
  1506. }));
  1507. reload = function() {
  1508. return location.reload();
  1509. };
  1510. this.el.find('.js-restart').on('click', reload);
  1511. return this.sessionClose();
  1512. };
  1513. ZammadChat.prototype.showWaitingListTimeout = function() {
  1514. var reload;
  1515. this.el.find('.zammad-chat-modal').html(this.view('waiting_list_timeout')({
  1516. delay: this.options.watingListTimeout
  1517. }));
  1518. reload = function() {
  1519. return location.reload();
  1520. };
  1521. this.el.find('.js-restart').on('click', reload);
  1522. return this.sessionClose();
  1523. };
  1524. ZammadChat.prototype.showLoader = function() {
  1525. return this.el.find('.zammad-chat-modal').html(this.view('loader')());
  1526. };
  1527. ZammadChat.prototype.setAgentOnlineState = function(state) {
  1528. var capitalizedState;
  1529. this.state = state;
  1530. if (!this.el) {
  1531. return;
  1532. }
  1533. capitalizedState = state.charAt(0).toUpperCase() + state.slice(1);
  1534. return this.el.find('.zammad-chat-agent-status').attr('data-status', state).text(this.T(capitalizedState));
  1535. };
  1536. ZammadChat.prototype.detectHost = function() {
  1537. var protocol;
  1538. protocol = 'ws://';
  1539. if (scriptProtocol === 'https') {
  1540. protocol = 'wss://';
  1541. }
  1542. return this.options.host = "" + protocol + scriptHost + "/ws";
  1543. };
  1544. ZammadChat.prototype.loadCss = function() {
  1545. var newSS, styles, url;
  1546. if (!this.options.cssAutoload) {
  1547. return;
  1548. }
  1549. url = this.options.cssUrl;
  1550. if (!url) {
  1551. url = this.options.host.replace(/^wss/i, 'https').replace(/^ws/i, 'http').replace(/\/ws$/i, '');
  1552. url += '/assets/chat/chat.css';
  1553. }
  1554. this.log.debug("load css from '" + url + "'");
  1555. styles = "@import url('" + url + "');";
  1556. newSS = document.createElement('link');
  1557. newSS.onload = this.onCssLoaded;
  1558. newSS.rel = 'stylesheet';
  1559. newSS.href = 'data:text/css,' + escape(styles);
  1560. return document.getElementsByTagName('head')[0].appendChild(newSS);
  1561. };
  1562. ZammadChat.prototype.onCssLoaded = function() {
  1563. var base;
  1564. this.cssLoaded = true;
  1565. if (this.socketReady) {
  1566. this.onReady();
  1567. }
  1568. return typeof (base = this.options).onCssLoaded === "function" ? base.onCssLoaded() : void 0;
  1569. };
  1570. ZammadChat.prototype.startTimeoutObservers = function() {
  1571. this.idleTimeout = new Timeout({
  1572. logPrefix: 'idleTimeout',
  1573. debug: this.options.debug,
  1574. timeout: this.options.idleTimeout,
  1575. timeoutIntervallCheck: this.options.idleTimeoutIntervallCheck,
  1576. callback: (function(_this) {
  1577. return function() {
  1578. _this.log.debug('Idle timeout reached, hide widget', new Date);
  1579. return _this.destroy({
  1580. remove: true
  1581. });
  1582. };
  1583. })(this)
  1584. });
  1585. this.inactiveTimeout = new Timeout({
  1586. logPrefix: 'inactiveTimeout',
  1587. debug: this.options.debug,
  1588. timeout: this.options.inactiveTimeout,
  1589. timeoutIntervallCheck: this.options.inactiveTimeoutIntervallCheck,
  1590. callback: (function(_this) {
  1591. return function() {
  1592. _this.log.debug('Inactive timeout reached, show timeout screen.', new Date);
  1593. _this.showCustomerTimeout();
  1594. return _this.destroy({
  1595. remove: false
  1596. });
  1597. };
  1598. })(this)
  1599. });
  1600. return this.waitingListTimeout = new Timeout({
  1601. logPrefix: 'waitingListTimeout',
  1602. debug: this.options.debug,
  1603. timeout: this.options.waitingListTimeout,
  1604. timeoutIntervallCheck: this.options.waitingListTimeoutIntervallCheck,
  1605. callback: (function(_this) {
  1606. return function() {
  1607. _this.log.debug('Waiting list timeout reached, show timeout screen.', new Date);
  1608. _this.showWaitingListTimeout();
  1609. return _this.destroy({
  1610. remove: false
  1611. });
  1612. };
  1613. })(this)
  1614. });
  1615. };
  1616. ZammadChat.prototype.disableScrollOnRoot = function() {
  1617. this.rootScrollOffset = this.scrollRoot.scrollTop();
  1618. return this.scrollRoot.css({
  1619. overflow: 'hidden',
  1620. position: 'fixed'
  1621. });
  1622. };
  1623. ZammadChat.prototype.enableScrollOnRoot = function() {
  1624. this.scrollRoot.scrollTop(this.rootScrollOffset);
  1625. return this.scrollRoot.css({
  1626. overflow: '',
  1627. position: ''
  1628. });
  1629. };
  1630. ZammadChat.prototype.isVisible = function(el, partial, hidden, direction) {
  1631. var $t, $w, _bottom, _left, _right, _top, bViz, clientSize, compareBottom, compareLeft, compareRight, compareTop, hVisible, lViz, offset, rViz, rec, t, tViz, vVisible, viewBottom, viewLeft, viewRight, viewTop, vpHeight, vpWidth;
  1632. if (el.length < 1) {
  1633. return;
  1634. }
  1635. $w = $(window);
  1636. $t = el.length > 1 ? el.eq(0) : el;
  1637. t = $t.get(0);
  1638. vpWidth = $w.width();
  1639. vpHeight = $w.height();
  1640. direction = direction ? direction : 'both';
  1641. clientSize = hidden === true ? t.offsetWidth * t.offsetHeight : true;
  1642. if (typeof t.getBoundingClientRect === 'function') {
  1643. rec = t.getBoundingClientRect();
  1644. tViz = rec.top >= 0 && rec.top < vpHeight;
  1645. bViz = rec.bottom > 0 && rec.bottom <= vpHeight;
  1646. lViz = rec.left >= 0 && rec.left < vpWidth;
  1647. rViz = rec.right > 0 && rec.right <= vpWidth;
  1648. vVisible = partial ? tViz || bViz : tViz && bViz;
  1649. hVisible = partial ? lViz || rViz : lViz && rViz;
  1650. if (direction === 'both') {
  1651. return clientSize && vVisible && hVisible;
  1652. } else if (direction === 'vertical') {
  1653. return clientSize && vVisible;
  1654. } else if (direction === 'horizontal') {
  1655. return clientSize && hVisible;
  1656. }
  1657. } else {
  1658. viewTop = $w.scrollTop();
  1659. viewBottom = viewTop + vpHeight;
  1660. viewLeft = $w.scrollLeft();
  1661. viewRight = viewLeft + vpWidth;
  1662. offset = $t.offset();
  1663. _top = offset.top;
  1664. _bottom = _top + $t.height();
  1665. _left = offset.left;
  1666. _right = _left + $t.width();
  1667. compareTop = partial === true ? _bottom : _top;
  1668. compareBottom = partial === true ? _top : _bottom;
  1669. compareLeft = partial === true ? _right : _left;
  1670. compareRight = partial === true ? _left : _right;
  1671. if (direction === 'both') {
  1672. return !!clientSize && ((compareBottom <= viewBottom) && (compareTop >= viewTop)) && ((compareRight <= viewRight) && (compareLeft >= viewLeft));
  1673. } else if (direction === 'vertical') {
  1674. return !!clientSize && ((compareBottom <= viewBottom) && (compareTop >= viewTop));
  1675. } else if (direction === 'horizontal') {
  1676. return !!clientSize && ((compareRight <= viewRight) && (compareLeft >= viewLeft));
  1677. }
  1678. }
  1679. };
  1680. ZammadChat.prototype.isRetina = function() {
  1681. var mq;
  1682. if (window.matchMedia) {
  1683. mq = window.matchMedia('only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3), only screen and (min-resolution: 1.3dppx)');
  1684. return mq && mq.matches || (window.devicePixelRatio > 1);
  1685. }
  1686. return false;
  1687. };
  1688. ZammadChat.prototype.resizeImage = function(dataURL, x, y, sizeFactor, type, quallity, callback, force) {
  1689. var imageObject;
  1690. if (x == null) {
  1691. x = 'auto';
  1692. }
  1693. if (y == null) {
  1694. y = 'auto';
  1695. }
  1696. if (sizeFactor == null) {
  1697. sizeFactor = 1;
  1698. }
  1699. if (force == null) {
  1700. force = true;
  1701. }
  1702. imageObject = new Image();
  1703. imageObject.onload = function() {
  1704. var canvas, context, factor, imageHeight, imageWidth, newDataUrl, resize;
  1705. imageWidth = imageObject.width;
  1706. imageHeight = imageObject.height;
  1707. console.log('ImageService', 'current size', imageWidth, imageHeight);
  1708. if (y === 'auto' && x === 'auto') {
  1709. x = imageWidth;
  1710. y = imageHeight;
  1711. }
  1712. if (y === 'auto') {
  1713. factor = imageWidth / x;
  1714. y = imageHeight / factor;
  1715. }
  1716. if (x === 'auto') {
  1717. factor = imageWidth / y;
  1718. x = imageHeight / factor;
  1719. }
  1720. resize = false;
  1721. if (x < imageWidth || y < imageHeight) {
  1722. resize = true;
  1723. x = x * sizeFactor;
  1724. y = y * sizeFactor;
  1725. } else {
  1726. x = imageWidth;
  1727. y = imageHeight;
  1728. }
  1729. canvas = document.createElement('canvas');
  1730. canvas.width = x;
  1731. canvas.height = y;
  1732. context = canvas.getContext('2d');
  1733. context.drawImage(imageObject, 0, 0, x, y);
  1734. if (quallity === 'auto') {
  1735. if (x < 200 && y < 200) {
  1736. quallity = 1;
  1737. } else if (x < 400 && y < 400) {
  1738. quallity = 0.9;
  1739. } else if (x < 600 && y < 600) {
  1740. quallity = 0.8;
  1741. } else if (x < 900 && y < 900) {
  1742. quallity = 0.7;
  1743. } else {
  1744. quallity = 0.6;
  1745. }
  1746. }
  1747. newDataUrl = canvas.toDataURL(type, quallity);
  1748. if (resize) {
  1749. console.log('ImageService', 'resize', x / sizeFactor, y / sizeFactor, quallity, (newDataUrl.length * 0.75) / 1024 / 1024, 'in mb');
  1750. callback(newDataUrl, x / sizeFactor, y / sizeFactor, true);
  1751. return;
  1752. }
  1753. console.log('ImageService', 'no resize', x, y, quallity, (newDataUrl.length * 0.75) / 1024 / 1024, 'in mb');
  1754. return callback(newDataUrl, x, y, false);
  1755. };
  1756. return imageObject.src = dataURL;
  1757. };
  1758. ZammadChat.prototype.pasteHtmlAtCaret = function(html) {
  1759. var el, frag, lastNode, node, range, sel;
  1760. sel = void 0;
  1761. range = void 0;
  1762. if (window.getSelection) {
  1763. sel = window.getSelection();
  1764. if (sel.getRangeAt && sel.rangeCount) {
  1765. range = sel.getRangeAt(0);
  1766. range.deleteContents();
  1767. el = document.createElement('div');
  1768. el.innerHTML = html;
  1769. frag = document.createDocumentFragment(node, lastNode);
  1770. while (node = el.firstChild) {
  1771. lastNode = frag.appendChild(node);
  1772. }
  1773. range.insertNode(frag);
  1774. if (lastNode) {
  1775. range = range.cloneRange();
  1776. range.setStartAfter(lastNode);
  1777. range.collapse(true);
  1778. sel.removeAllRanges();
  1779. return sel.addRange(range);
  1780. }
  1781. }
  1782. } else if (document.selection && document.selection.type !== 'Control') {
  1783. return document.selection.createRange().pasteHTML(html);
  1784. }
  1785. };
  1786. ZammadChat.prototype.wordFilter = function(editor) {
  1787. var content, last_level, pnt;
  1788. content = editor.html();
  1789. content = content.replace(/<!--[\s\S]+?-->/gi, '');
  1790. content = content.replace(/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi, '');
  1791. content = content.replace(/<(\/?)s>/gi, '<$1strike>');
  1792. content = content.replace(/&nbsp;/gi, ' ');
  1793. editor.html(content);
  1794. $('p', editor).each(function() {
  1795. var matches, str;
  1796. str = $(this).attr('style');
  1797. matches = /mso-list:\w+ \w+([0-9]+)/.exec(str);
  1798. if (matches) {
  1799. return $(this).data('_listLevel', parseInt(matches[1], 10));
  1800. }
  1801. });
  1802. last_level = 0;
  1803. pnt = null;
  1804. $('p', editor).each(function() {
  1805. var cur_level, i, j, list_tag, matches, ref, ref1, ref2, start, txt;
  1806. cur_level = $(this).data('_listLevel');
  1807. if (cur_level !== void 0) {
  1808. txt = $(this).text();
  1809. list_tag = '<ul></ul>';
  1810. if (/^\s*\w+\./.test(txt)) {
  1811. matches = /([0-9])\./.exec(txt);
  1812. if (matches) {
  1813. start = parseInt(matches[1], 10);
  1814. list_tag = (ref = start > 1) != null ? ref : '<ol start="' + start + {
  1815. '"></ol>': '<ol></ol>'
  1816. };
  1817. } else {
  1818. list_tag = '<ol></ol>';
  1819. }
  1820. }
  1821. if (cur_level > last_level) {
  1822. if (last_level === 0) {
  1823. $(this).before(list_tag);
  1824. pnt = $(this).prev();
  1825. } else {
  1826. pnt = $(list_tag).appendTo(pnt);
  1827. }
  1828. }
  1829. if (cur_level < last_level) {
  1830. for (i = j = ref1 = i, ref2 = last_level - cur_level; ref1 <= ref2 ? j <= ref2 : j >= ref2; i = ref1 <= ref2 ? ++j : --j) {
  1831. pnt = pnt.parent();
  1832. }
  1833. }
  1834. $('span:first', this).remove();
  1835. pnt.append('<li>' + $(this).html() + '</li>');
  1836. $(this).remove();
  1837. return last_level = cur_level;
  1838. } else {
  1839. return last_level = 0;
  1840. }
  1841. });
  1842. $('[style]', editor).removeAttr('style');
  1843. $('[align]', editor).removeAttr('align');
  1844. $('span', editor).replaceWith(function() {
  1845. return $(this).contents();
  1846. });
  1847. $('span:empty', editor).remove();
  1848. $("[class^='Mso']", editor).removeAttr('class');
  1849. $('p:empty', editor).remove();
  1850. return editor;
  1851. };
  1852. ZammadChat.prototype.removeAttribute = function(element) {
  1853. var $element, att, j, len, ref;
  1854. if (!element) {
  1855. return;
  1856. }
  1857. $element = $(element);
  1858. ref = element.attributes;
  1859. for (j = 0, len = ref.length; j < len; j++) {
  1860. att = ref[j];
  1861. if (att && att.name) {
  1862. element.removeAttribute(att.name);
  1863. }
  1864. }
  1865. return $element.removeAttr('style').removeAttr('class').removeAttr('lang').removeAttr('type').removeAttr('align').removeAttr('id').removeAttr('wrap').removeAttr('title');
  1866. };
  1867. ZammadChat.prototype.removeAttributes = function(html, parent) {
  1868. if (parent == null) {
  1869. parent = true;
  1870. }
  1871. if (parent) {
  1872. html.each((function(_this) {
  1873. return function(index, element) {
  1874. return _this.removeAttribute(element);
  1875. };
  1876. })(this));
  1877. }
  1878. html.find('*').each((function(_this) {
  1879. return function(index, element) {
  1880. return _this.removeAttribute(element);
  1881. };
  1882. })(this));
  1883. return html;
  1884. };
  1885. return ZammadChat;
  1886. })(Base);
  1887. return window.ZammadChat = ZammadChat;
  1888. })(window.jQuery, window);
  1889. if (!window.zammadChatTemplates) {
  1890. window.zammadChatTemplates = {};
  1891. }
  1892. window.zammadChatTemplates["chat"] = function(__obj) {
  1893. if (!__obj) __obj = {};
  1894. var __out = [], __capture = function(callback) {
  1895. var out = __out, result;
  1896. __out = [];
  1897. callback.call(this);
  1898. result = __out.join('');
  1899. __out = out;
  1900. return __safe(result);
  1901. }, __sanitize = function(value) {
  1902. if (value && value.ecoSafe) {
  1903. return value;
  1904. } else if (typeof value !== 'undefined' && value != null) {
  1905. return __escape(value);
  1906. } else {
  1907. return '';
  1908. }
  1909. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  1910. __safe = __obj.safe = function(value) {
  1911. if (value && value.ecoSafe) {
  1912. return value;
  1913. } else {
  1914. if (!(typeof value !== 'undefined' && value != null)) value = '';
  1915. var result = new String(value);
  1916. result.ecoSafe = true;
  1917. return result;
  1918. }
  1919. };
  1920. if (!__escape) {
  1921. __escape = __obj.escape = function(value) {
  1922. return ('' + value)
  1923. .replace(/&/g, '&amp;')
  1924. .replace(/</g, '&lt;')
  1925. .replace(/>/g, '&gt;')
  1926. .replace(/"/g, '&quot;');
  1927. };
  1928. }
  1929. (function() {
  1930. (function() {
  1931. __out.push('<div class="zammad-chat');
  1932. if (this.flat) {
  1933. __out.push(__sanitize(' zammad-chat--flat'));
  1934. }
  1935. __out.push('"');
  1936. if (this.fontSize) {
  1937. __out.push(__sanitize(" style='font-size: " + this.fontSize + "'"));
  1938. }
  1939. __out.push('>\n <div class="zammad-chat-header js-chat-open"');
  1940. if (this.background) {
  1941. __out.push(__sanitize(" style='background: " + this.background + "'"));
  1942. }
  1943. __out.push('>\n <div class="zammad-chat-header-controls js-chat-toggle">\n <span class="zammad-chat-agent-status zammad-chat-is-hidden js-chat-status" data-status="online"></span>\n <span class="zammad-chat-header-icon">\n <svg class="zammad-chat-header-icon-open" width="13" height="7" viewBox="0 0 13 7"><path d="M10.807 7l1.4-1.428-5-4.9L6.5-.02l-.7.7-4.9 4.9 1.414 1.413L6.5 2.886 10.807 7z" fill-rule="evenodd"/></svg>\n <svg class="zammad-chat-header-icon-close" width="13" height="13" viewBox="0 0 13 13"><path d="m2.241.12l-2.121 2.121 4.243 4.243-4.243 4.243 2.121 2.121 4.243-4.243 4.243 4.243 2.121-2.121-4.243-4.243 4.243-4.243-2.121-2.121-4.243 4.243-4.243-4.243" fill-rule="evenodd"/></svg>\n </span>\n </div>\n <div class="zammad-chat-agent zammad-chat-is-hidden">\n </div>\n <div class="zammad-chat-welcome">\n <svg class="zammad-chat-icon" viewBox="0 0 24 24" width="24" height="24"><path d="M2 5C2 4 3 3 4 3h16c1 0 2 1 2 2v10C22 16 21 17 20 17H4C3 17 2 16 2 15V5zM12 17l6 4v-4h-6z"/></svg>\n <span class="zammad-chat-welcome-text">');
  1944. __out.push(this.T(this.title));
  1945. __out.push('</span>\n </div>\n </div>\n <div class="zammad-chat-modal"></div>\n <div class="zammad-scroll-hint is-hidden">\n <svg class="zammad-scroll-hint-icon" width="20" height="18" viewBox="0 0 20 18"><path d="M0,2.00585866 C0,0.898053512 0.898212381,0 1.99079514,0 L18.0092049,0 C19.1086907,0 20,0.897060126 20,2.00585866 L20,11.9941413 C20,13.1019465 19.1017876,14 18.0092049,14 L1.99079514,14 C0.891309342,14 0,13.1029399 0,11.9941413 L0,2.00585866 Z M10,14 L16,18 L16,14 L10,14 Z" fill-rule="evenodd"/></svg>\n ');
  1946. __out.push(this.T(this.scrollHint));
  1947. __out.push('\n </div>\n <div class="zammad-chat-body"></div>\n <form class="zammad-chat-controls">\n <div class="zammad-chat-input" rows="1" placeholder="');
  1948. __out.push(this.T('Compose your message…'));
  1949. __out.push('" contenteditable="true"></div>\n <button type="submit" class="zammad-chat-button zammad-chat-send"');
  1950. if (this.background) {
  1951. __out.push(__sanitize(" style='background: " + this.background + "'"));
  1952. }
  1953. __out.push('>');
  1954. __out.push(this.T('Send'));
  1955. __out.push('</button>\n </form>\n</div>');
  1956. }).call(this);
  1957. }).call(__obj);
  1958. __obj.safe = __objSafe, __obj.escape = __escape;
  1959. return __out.join('');
  1960. };
  1961. if (!window.zammadChatTemplates) {
  1962. window.zammadChatTemplates = {};
  1963. }
  1964. window.zammadChatTemplates["customer_timeout"] = function(__obj) {
  1965. if (!__obj) __obj = {};
  1966. var __out = [], __capture = function(callback) {
  1967. var out = __out, result;
  1968. __out = [];
  1969. callback.call(this);
  1970. result = __out.join('');
  1971. __out = out;
  1972. return __safe(result);
  1973. }, __sanitize = function(value) {
  1974. if (value && value.ecoSafe) {
  1975. return value;
  1976. } else if (typeof value !== 'undefined' && value != null) {
  1977. return __escape(value);
  1978. } else {
  1979. return '';
  1980. }
  1981. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  1982. __safe = __obj.safe = function(value) {
  1983. if (value && value.ecoSafe) {
  1984. return value;
  1985. } else {
  1986. if (!(typeof value !== 'undefined' && value != null)) value = '';
  1987. var result = new String(value);
  1988. result.ecoSafe = true;
  1989. return result;
  1990. }
  1991. };
  1992. if (!__escape) {
  1993. __escape = __obj.escape = function(value) {
  1994. return ('' + value)
  1995. .replace(/&/g, '&amp;')
  1996. .replace(/</g, '&lt;')
  1997. .replace(/>/g, '&gt;')
  1998. .replace(/"/g, '&quot;');
  1999. };
  2000. }
  2001. (function() {
  2002. (function() {
  2003. __out.push('<div class="zammad-chat-modal-text">\n ');
  2004. if (this.agent) {
  2005. __out.push('\n ');
  2006. __out.push(this.T('Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.', this.delay, this.agent));
  2007. __out.push('\n ');
  2008. } else {
  2009. __out.push('\n ');
  2010. __out.push(this.T('Since you didn\'t respond in the last %s minutes your conversation was closed.', this.delay));
  2011. __out.push('\n ');
  2012. }
  2013. __out.push('\n <br>\n <div class="zammad-chat-button js-restart"');
  2014. if (this.background) {
  2015. __out.push(__sanitize(" style='background: " + this.background + "'"));
  2016. }
  2017. __out.push('>');
  2018. __out.push(this.T('Start new conversation'));
  2019. __out.push('</div>\n</div>');
  2020. }).call(this);
  2021. }).call(__obj);
  2022. __obj.safe = __objSafe, __obj.escape = __escape;
  2023. return __out.join('');
  2024. };
  2025. if (!window.zammadChatTemplates) {
  2026. window.zammadChatTemplates = {};
  2027. }
  2028. window.zammadChatTemplates["loader"] = function(__obj) {
  2029. if (!__obj) __obj = {};
  2030. var __out = [], __capture = function(callback) {
  2031. var out = __out, result;
  2032. __out = [];
  2033. callback.call(this);
  2034. result = __out.join('');
  2035. __out = out;
  2036. return __safe(result);
  2037. }, __sanitize = function(value) {
  2038. if (value && value.ecoSafe) {
  2039. return value;
  2040. } else if (typeof value !== 'undefined' && value != null) {
  2041. return __escape(value);
  2042. } else {
  2043. return '';
  2044. }
  2045. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  2046. __safe = __obj.safe = function(value) {
  2047. if (value && value.ecoSafe) {
  2048. return value;
  2049. } else {
  2050. if (!(typeof value !== 'undefined' && value != null)) value = '';
  2051. var result = new String(value);
  2052. result.ecoSafe = true;
  2053. return result;
  2054. }
  2055. };
  2056. if (!__escape) {
  2057. __escape = __obj.escape = function(value) {
  2058. return ('' + value)
  2059. .replace(/&/g, '&amp;')
  2060. .replace(/</g, '&lt;')
  2061. .replace(/>/g, '&gt;')
  2062. .replace(/"/g, '&quot;');
  2063. };
  2064. }
  2065. (function() {
  2066. (function() {
  2067. __out.push('<span class="zammad-chat-loading-animation">\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n</span>\n<span class="zammad-chat-modal-text">');
  2068. __out.push(this.T('Connecting'));
  2069. __out.push('</span>');
  2070. }).call(this);
  2071. }).call(__obj);
  2072. __obj.safe = __objSafe, __obj.escape = __escape;
  2073. return __out.join('');
  2074. };
  2075. if (!window.zammadChatTemplates) {
  2076. window.zammadChatTemplates = {};
  2077. }
  2078. window.zammadChatTemplates["message"] = function(__obj) {
  2079. if (!__obj) __obj = {};
  2080. var __out = [], __capture = function(callback) {
  2081. var out = __out, result;
  2082. __out = [];
  2083. callback.call(this);
  2084. result = __out.join('');
  2085. __out = out;
  2086. return __safe(result);
  2087. }, __sanitize = function(value) {
  2088. if (value && value.ecoSafe) {
  2089. return value;
  2090. } else if (typeof value !== 'undefined' && value != null) {
  2091. return __escape(value);
  2092. } else {
  2093. return '';
  2094. }
  2095. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  2096. __safe = __obj.safe = function(value) {
  2097. if (value && value.ecoSafe) {
  2098. return value;
  2099. } else {
  2100. if (!(typeof value !== 'undefined' && value != null)) value = '';
  2101. var result = new String(value);
  2102. result.ecoSafe = true;
  2103. return result;
  2104. }
  2105. };
  2106. if (!__escape) {
  2107. __escape = __obj.escape = function(value) {
  2108. return ('' + value)
  2109. .replace(/&/g, '&amp;')
  2110. .replace(/</g, '&lt;')
  2111. .replace(/>/g, '&gt;')
  2112. .replace(/"/g, '&quot;');
  2113. };
  2114. }
  2115. (function() {
  2116. (function() {
  2117. __out.push('<div class="zammad-chat-message zammad-chat-message--');
  2118. __out.push(__sanitize(this.from));
  2119. __out.push(__sanitize(this.unreadClass));
  2120. __out.push('">\n <span class="zammad-chat-message-body"');
  2121. if (this.background && this.from === 'customer') {
  2122. __out.push(__sanitize(" style='background: " + this.background + "'"));
  2123. }
  2124. __out.push('>');
  2125. __out.push(this.message);
  2126. __out.push('</span>\n</div>');
  2127. }).call(this);
  2128. }).call(__obj);
  2129. __obj.safe = __objSafe, __obj.escape = __escape;
  2130. return __out.join('');
  2131. };
  2132. if (!window.zammadChatTemplates) {
  2133. window.zammadChatTemplates = {};
  2134. }
  2135. window.zammadChatTemplates["status"] = function(__obj) {
  2136. if (!__obj) __obj = {};
  2137. var __out = [], __capture = function(callback) {
  2138. var out = __out, result;
  2139. __out = [];
  2140. callback.call(this);
  2141. result = __out.join('');
  2142. __out = out;
  2143. return __safe(result);
  2144. }, __sanitize = function(value) {
  2145. if (value && value.ecoSafe) {
  2146. return value;
  2147. } else if (typeof value !== 'undefined' && value != null) {
  2148. return __escape(value);
  2149. } else {
  2150. return '';
  2151. }
  2152. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  2153. __safe = __obj.safe = function(value) {
  2154. if (value && value.ecoSafe) {
  2155. return value;
  2156. } else {
  2157. if (!(typeof value !== 'undefined' && value != null)) value = '';
  2158. var result = new String(value);
  2159. result.ecoSafe = true;
  2160. return result;
  2161. }
  2162. };
  2163. if (!__escape) {
  2164. __escape = __obj.escape = function(value) {
  2165. return ('' + value)
  2166. .replace(/&/g, '&amp;')
  2167. .replace(/</g, '&lt;')
  2168. .replace(/>/g, '&gt;')
  2169. .replace(/"/g, '&quot;');
  2170. };
  2171. }
  2172. (function() {
  2173. (function() {
  2174. __out.push('<div class="zammad-chat-status">\n <div class="zammad-chat-status-inner">\n ');
  2175. __out.push(this.status);
  2176. __out.push('\n </div>\n</div>');
  2177. }).call(this);
  2178. }).call(__obj);
  2179. __obj.safe = __objSafe, __obj.escape = __escape;
  2180. return __out.join('');
  2181. };
  2182. if (!window.zammadChatTemplates) {
  2183. window.zammadChatTemplates = {};
  2184. }
  2185. window.zammadChatTemplates["timestamp"] = function(__obj) {
  2186. if (!__obj) __obj = {};
  2187. var __out = [], __capture = function(callback) {
  2188. var out = __out, result;
  2189. __out = [];
  2190. callback.call(this);
  2191. result = __out.join('');
  2192. __out = out;
  2193. return __safe(result);
  2194. }, __sanitize = function(value) {
  2195. if (value && value.ecoSafe) {
  2196. return value;
  2197. } else if (typeof value !== 'undefined' && value != null) {
  2198. return __escape(value);
  2199. } else {
  2200. return '';
  2201. }
  2202. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  2203. __safe = __obj.safe = function(value) {
  2204. if (value && value.ecoSafe) {
  2205. return value;
  2206. } else {
  2207. if (!(typeof value !== 'undefined' && value != null)) value = '';
  2208. var result = new String(value);
  2209. result.ecoSafe = true;
  2210. return result;
  2211. }
  2212. };
  2213. if (!__escape) {
  2214. __escape = __obj.escape = function(value) {
  2215. return ('' + value)
  2216. .replace(/&/g, '&amp;')
  2217. .replace(/</g, '&lt;')
  2218. .replace(/>/g, '&gt;')
  2219. .replace(/"/g, '&quot;');
  2220. };
  2221. }
  2222. (function() {
  2223. (function() {
  2224. __out.push('<div class="zammad-chat-timestamp"><strong>');
  2225. __out.push(__sanitize(this.label));
  2226. __out.push('</strong> ');
  2227. __out.push(__sanitize(this.time));
  2228. __out.push('</div>');
  2229. }).call(this);
  2230. }).call(__obj);
  2231. __obj.safe = __objSafe, __obj.escape = __escape;
  2232. return __out.join('');
  2233. };
  2234. if (!window.zammadChatTemplates) {
  2235. window.zammadChatTemplates = {};
  2236. }
  2237. window.zammadChatTemplates["typingIndicator"] = function(__obj) {
  2238. if (!__obj) __obj = {};
  2239. var __out = [], __capture = function(callback) {
  2240. var out = __out, result;
  2241. __out = [];
  2242. callback.call(this);
  2243. result = __out.join('');
  2244. __out = out;
  2245. return __safe(result);
  2246. }, __sanitize = function(value) {
  2247. if (value && value.ecoSafe) {
  2248. return value;
  2249. } else if (typeof value !== 'undefined' && value != null) {
  2250. return __escape(value);
  2251. } else {
  2252. return '';
  2253. }
  2254. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  2255. __safe = __obj.safe = function(value) {
  2256. if (value && value.ecoSafe) {
  2257. return value;
  2258. } else {
  2259. if (!(typeof value !== 'undefined' && value != null)) value = '';
  2260. var result = new String(value);
  2261. result.ecoSafe = true;
  2262. return result;
  2263. }
  2264. };
  2265. if (!__escape) {
  2266. __escape = __obj.escape = function(value) {
  2267. return ('' + value)
  2268. .replace(/&/g, '&amp;')
  2269. .replace(/</g, '&lt;')
  2270. .replace(/>/g, '&gt;')
  2271. .replace(/"/g, '&quot;');
  2272. };
  2273. }
  2274. (function() {
  2275. (function() {
  2276. __out.push('<div class="zammad-chat-message zammad-chat-message--typing zammad-chat-message--agent">\n <span class="zammad-chat-message-body">\n <span class="zammad-chat-loading-animation">\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n </span>\n </span>\n</div>');
  2277. }).call(this);
  2278. }).call(__obj);
  2279. __obj.safe = __objSafe, __obj.escape = __escape;
  2280. return __out.join('');
  2281. };
  2282. if (!window.zammadChatTemplates) {
  2283. window.zammadChatTemplates = {};
  2284. }
  2285. window.zammadChatTemplates["waiting"] = function(__obj) {
  2286. if (!__obj) __obj = {};
  2287. var __out = [], __capture = function(callback) {
  2288. var out = __out, result;
  2289. __out = [];
  2290. callback.call(this);
  2291. result = __out.join('');
  2292. __out = out;
  2293. return __safe(result);
  2294. }, __sanitize = function(value) {
  2295. if (value && value.ecoSafe) {
  2296. return value;
  2297. } else if (typeof value !== 'undefined' && value != null) {
  2298. return __escape(value);
  2299. } else {
  2300. return '';
  2301. }
  2302. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  2303. __safe = __obj.safe = function(value) {
  2304. if (value && value.ecoSafe) {
  2305. return value;
  2306. } else {
  2307. if (!(typeof value !== 'undefined' && value != null)) value = '';
  2308. var result = new String(value);
  2309. result.ecoSafe = true;
  2310. return result;
  2311. }
  2312. };
  2313. if (!__escape) {
  2314. __escape = __obj.escape = function(value) {
  2315. return ('' + value)
  2316. .replace(/&/g, '&amp;')
  2317. .replace(/</g, '&lt;')
  2318. .replace(/>/g, '&gt;')
  2319. .replace(/"/g, '&quot;');
  2320. };
  2321. }
  2322. (function() {
  2323. (function() {
  2324. __out.push('<div class="zammad-chat-modal-text">\n <span class="zammad-chat-loading-animation">\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n </span>\n ');
  2325. __out.push(this.T('All colleagues are busy.'));
  2326. __out.push('<br>\n ');
  2327. __out.push(this.T('You are on waiting list position <strong>%s</strong>.', this.position));
  2328. __out.push('\n</div>');
  2329. }).call(this);
  2330. }).call(__obj);
  2331. __obj.safe = __objSafe, __obj.escape = __escape;
  2332. return __out.join('');
  2333. };
  2334. if (!window.zammadChatTemplates) {
  2335. window.zammadChatTemplates = {};
  2336. }
  2337. window.zammadChatTemplates["waiting_list_timeout"] = function(__obj) {
  2338. if (!__obj) __obj = {};
  2339. var __out = [], __capture = function(callback) {
  2340. var out = __out, result;
  2341. __out = [];
  2342. callback.call(this);
  2343. result = __out.join('');
  2344. __out = out;
  2345. return __safe(result);
  2346. }, __sanitize = function(value) {
  2347. if (value && value.ecoSafe) {
  2348. return value;
  2349. } else if (typeof value !== 'undefined' && value != null) {
  2350. return __escape(value);
  2351. } else {
  2352. return '';
  2353. }
  2354. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  2355. __safe = __obj.safe = function(value) {
  2356. if (value && value.ecoSafe) {
  2357. return value;
  2358. } else {
  2359. if (!(typeof value !== 'undefined' && value != null)) value = '';
  2360. var result = new String(value);
  2361. result.ecoSafe = true;
  2362. return result;
  2363. }
  2364. };
  2365. if (!__escape) {
  2366. __escape = __obj.escape = function(value) {
  2367. return ('' + value)
  2368. .replace(/&/g, '&amp;')
  2369. .replace(/</g, '&lt;')
  2370. .replace(/>/g, '&gt;')
  2371. .replace(/"/g, '&quot;');
  2372. };
  2373. }
  2374. (function() {
  2375. (function() {
  2376. __out.push('<div class="zammad-chat-modal-text">\n ');
  2377. __out.push(this.T('We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!'));
  2378. __out.push('\n <br>\n <div class="zammad-chat-button js-restart"');
  2379. if (this.background) {
  2380. __out.push(__sanitize(" style='background: " + this.background + "'"));
  2381. }
  2382. __out.push('>');
  2383. __out.push(this.T('Start new conversation'));
  2384. __out.push('</div>\n</div>');
  2385. }).call(this);
  2386. }).call(__obj);
  2387. __obj.safe = __objSafe, __obj.escape = __escape;
  2388. return __out.join('');
  2389. };