chat.js 121 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701
  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. if (!window.zammadChatTemplates) {
  57. window.zammadChatTemplates = {};
  58. }
  59. window.zammadChatTemplates["chat"] = function(__obj) {
  60. if (!__obj) __obj = {};
  61. var __out = [], __capture = function(callback) {
  62. var out = __out, result;
  63. __out = [];
  64. callback.call(this);
  65. result = __out.join('');
  66. __out = out;
  67. return __safe(result);
  68. }, __sanitize = function(value) {
  69. if (value && value.ecoSafe) {
  70. return value;
  71. } else if (typeof value !== 'undefined' && value != null) {
  72. return __escape(value);
  73. } else {
  74. return '';
  75. }
  76. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  77. __safe = __obj.safe = function(value) {
  78. if (value && value.ecoSafe) {
  79. return value;
  80. } else {
  81. if (!(typeof value !== 'undefined' && value != null)) value = '';
  82. var result = new String(value);
  83. result.ecoSafe = true;
  84. return result;
  85. }
  86. };
  87. if (!__escape) {
  88. __escape = __obj.escape = function(value) {
  89. return ('' + value)
  90. .replace(/&/g, '&amp;')
  91. .replace(/</g, '&lt;')
  92. .replace(/>/g, '&gt;')
  93. .replace(/"/g, '&quot;');
  94. };
  95. }
  96. (function() {
  97. (function() {
  98. __out.push('<div class="zammad-chat');
  99. if (this.flat) {
  100. __out.push(__sanitize(' zammad-chat--flat'));
  101. }
  102. __out.push('"');
  103. if (this.fontSize) {
  104. __out.push(__sanitize(" style='font-size: " + this.fontSize + "'"));
  105. }
  106. __out.push('>\n <div class="zammad-chat-header js-chat-open"');
  107. if (this.background) {
  108. __out.push(__sanitize(" style='background: " + this.background + "'"));
  109. }
  110. __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">');
  111. __out.push(this.T(this.title));
  112. __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 ');
  113. __out.push(this.T(this.scrollHint));
  114. __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="');
  115. __out.push(this.T('Compose your message…'));
  116. __out.push('" contenteditable="true"></div>\n <button type="submit" class="zammad-chat-button zammad-chat-send"');
  117. if (this.background) {
  118. __out.push(__sanitize(" style='background: " + this.background + "'"));
  119. }
  120. __out.push('>');
  121. __out.push(this.T('Send'));
  122. __out.push('</button>\n </form>\n</div>');
  123. }).call(this);
  124. }).call(__obj);
  125. __obj.safe = __objSafe, __obj.escape = __escape;
  126. return __out.join('');
  127. };
  128. if (!window.zammadChatTemplates) {
  129. window.zammadChatTemplates = {};
  130. }
  131. window.zammadChatTemplates["customer_timeout"] = function(__obj) {
  132. if (!__obj) __obj = {};
  133. var __out = [], __capture = function(callback) {
  134. var out = __out, result;
  135. __out = [];
  136. callback.call(this);
  137. result = __out.join('');
  138. __out = out;
  139. return __safe(result);
  140. }, __sanitize = function(value) {
  141. if (value && value.ecoSafe) {
  142. return value;
  143. } else if (typeof value !== 'undefined' && value != null) {
  144. return __escape(value);
  145. } else {
  146. return '';
  147. }
  148. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  149. __safe = __obj.safe = function(value) {
  150. if (value && value.ecoSafe) {
  151. return value;
  152. } else {
  153. if (!(typeof value !== 'undefined' && value != null)) value = '';
  154. var result = new String(value);
  155. result.ecoSafe = true;
  156. return result;
  157. }
  158. };
  159. if (!__escape) {
  160. __escape = __obj.escape = function(value) {
  161. return ('' + value)
  162. .replace(/&/g, '&amp;')
  163. .replace(/</g, '&lt;')
  164. .replace(/>/g, '&gt;')
  165. .replace(/"/g, '&quot;');
  166. };
  167. }
  168. (function() {
  169. (function() {
  170. __out.push('<div class="zammad-chat-modal-text">\n ');
  171. if (this.agent) {
  172. __out.push('\n ');
  173. __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));
  174. __out.push('\n ');
  175. } else {
  176. __out.push('\n ');
  177. __out.push(this.T('Since you didn\'t respond in the last %s minutes your conversation was closed.', this.delay));
  178. __out.push('\n ');
  179. }
  180. __out.push('\n <br>\n <div class="zammad-chat-button js-restart"');
  181. if (this.background) {
  182. __out.push(__sanitize(" style='background: " + this.background + "'"));
  183. }
  184. __out.push('>');
  185. __out.push(this.T('Start new conversation'));
  186. __out.push('</div>\n</div>');
  187. }).call(this);
  188. }).call(__obj);
  189. __obj.safe = __objSafe, __obj.escape = __escape;
  190. return __out.join('');
  191. };
  192. if (!window.zammadChatTemplates) {
  193. window.zammadChatTemplates = {};
  194. }
  195. window.zammadChatTemplates["loader"] = function(__obj) {
  196. if (!__obj) __obj = {};
  197. var __out = [], __capture = function(callback) {
  198. var out = __out, result;
  199. __out = [];
  200. callback.call(this);
  201. result = __out.join('');
  202. __out = out;
  203. return __safe(result);
  204. }, __sanitize = function(value) {
  205. if (value && value.ecoSafe) {
  206. return value;
  207. } else if (typeof value !== 'undefined' && value != null) {
  208. return __escape(value);
  209. } else {
  210. return '';
  211. }
  212. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  213. __safe = __obj.safe = function(value) {
  214. if (value && value.ecoSafe) {
  215. return value;
  216. } else {
  217. if (!(typeof value !== 'undefined' && value != null)) value = '';
  218. var result = new String(value);
  219. result.ecoSafe = true;
  220. return result;
  221. }
  222. };
  223. if (!__escape) {
  224. __escape = __obj.escape = function(value) {
  225. return ('' + value)
  226. .replace(/&/g, '&amp;')
  227. .replace(/</g, '&lt;')
  228. .replace(/>/g, '&gt;')
  229. .replace(/"/g, '&quot;');
  230. };
  231. }
  232. (function() {
  233. (function() {
  234. __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">');
  235. __out.push(this.T('Connecting'));
  236. __out.push('</span>');
  237. }).call(this);
  238. }).call(__obj);
  239. __obj.safe = __objSafe, __obj.escape = __escape;
  240. return __out.join('');
  241. };
  242. if (!window.zammadChatTemplates) {
  243. window.zammadChatTemplates = {};
  244. }
  245. window.zammadChatTemplates["message"] = function(__obj) {
  246. if (!__obj) __obj = {};
  247. var __out = [], __capture = function(callback) {
  248. var out = __out, result;
  249. __out = [];
  250. callback.call(this);
  251. result = __out.join('');
  252. __out = out;
  253. return __safe(result);
  254. }, __sanitize = function(value) {
  255. if (value && value.ecoSafe) {
  256. return value;
  257. } else if (typeof value !== 'undefined' && value != null) {
  258. return __escape(value);
  259. } else {
  260. return '';
  261. }
  262. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  263. __safe = __obj.safe = function(value) {
  264. if (value && value.ecoSafe) {
  265. return value;
  266. } else {
  267. if (!(typeof value !== 'undefined' && value != null)) value = '';
  268. var result = new String(value);
  269. result.ecoSafe = true;
  270. return result;
  271. }
  272. };
  273. if (!__escape) {
  274. __escape = __obj.escape = function(value) {
  275. return ('' + value)
  276. .replace(/&/g, '&amp;')
  277. .replace(/</g, '&lt;')
  278. .replace(/>/g, '&gt;')
  279. .replace(/"/g, '&quot;');
  280. };
  281. }
  282. (function() {
  283. (function() {
  284. __out.push('<div class="zammad-chat-message zammad-chat-message--');
  285. __out.push(__sanitize(this.from));
  286. __out.push(__sanitize(this.unreadClass));
  287. __out.push('">\n <span class="zammad-chat-message-body"');
  288. if (this.background && this.from === 'customer') {
  289. __out.push(__sanitize(" style='background: " + this.background + "'"));
  290. }
  291. __out.push('>');
  292. __out.push(this.message);
  293. __out.push('</span>\n</div>');
  294. }).call(this);
  295. }).call(__obj);
  296. __obj.safe = __objSafe, __obj.escape = __escape;
  297. return __out.join('');
  298. };
  299. if (!window.zammadChatTemplates) {
  300. window.zammadChatTemplates = {};
  301. }
  302. window.zammadChatTemplates["status"] = function(__obj) {
  303. if (!__obj) __obj = {};
  304. var __out = [], __capture = function(callback) {
  305. var out = __out, result;
  306. __out = [];
  307. callback.call(this);
  308. result = __out.join('');
  309. __out = out;
  310. return __safe(result);
  311. }, __sanitize = function(value) {
  312. if (value && value.ecoSafe) {
  313. return value;
  314. } else if (typeof value !== 'undefined' && value != null) {
  315. return __escape(value);
  316. } else {
  317. return '';
  318. }
  319. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  320. __safe = __obj.safe = function(value) {
  321. if (value && value.ecoSafe) {
  322. return value;
  323. } else {
  324. if (!(typeof value !== 'undefined' && value != null)) value = '';
  325. var result = new String(value);
  326. result.ecoSafe = true;
  327. return result;
  328. }
  329. };
  330. if (!__escape) {
  331. __escape = __obj.escape = function(value) {
  332. return ('' + value)
  333. .replace(/&/g, '&amp;')
  334. .replace(/</g, '&lt;')
  335. .replace(/>/g, '&gt;')
  336. .replace(/"/g, '&quot;');
  337. };
  338. }
  339. (function() {
  340. (function() {
  341. __out.push('<div class="zammad-chat-status">\n <div class="zammad-chat-status-inner">\n ');
  342. __out.push(this.status);
  343. __out.push('\n </div>\n</div>');
  344. }).call(this);
  345. }).call(__obj);
  346. __obj.safe = __objSafe, __obj.escape = __escape;
  347. return __out.join('');
  348. };
  349. if (!window.zammadChatTemplates) {
  350. window.zammadChatTemplates = {};
  351. }
  352. window.zammadChatTemplates["timestamp"] = function(__obj) {
  353. if (!__obj) __obj = {};
  354. var __out = [], __capture = function(callback) {
  355. var out = __out, result;
  356. __out = [];
  357. callback.call(this);
  358. result = __out.join('');
  359. __out = out;
  360. return __safe(result);
  361. }, __sanitize = function(value) {
  362. if (value && value.ecoSafe) {
  363. return value;
  364. } else if (typeof value !== 'undefined' && value != null) {
  365. return __escape(value);
  366. } else {
  367. return '';
  368. }
  369. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  370. __safe = __obj.safe = function(value) {
  371. if (value && value.ecoSafe) {
  372. return value;
  373. } else {
  374. if (!(typeof value !== 'undefined' && value != null)) value = '';
  375. var result = new String(value);
  376. result.ecoSafe = true;
  377. return result;
  378. }
  379. };
  380. if (!__escape) {
  381. __escape = __obj.escape = function(value) {
  382. return ('' + value)
  383. .replace(/&/g, '&amp;')
  384. .replace(/</g, '&lt;')
  385. .replace(/>/g, '&gt;')
  386. .replace(/"/g, '&quot;');
  387. };
  388. }
  389. (function() {
  390. (function() {
  391. __out.push('<div class="zammad-chat-timestamp"><strong>');
  392. __out.push(__sanitize(this.label));
  393. __out.push('</strong> ');
  394. __out.push(__sanitize(this.time));
  395. __out.push('</div>');
  396. }).call(this);
  397. }).call(__obj);
  398. __obj.safe = __objSafe, __obj.escape = __escape;
  399. return __out.join('');
  400. };
  401. if (!window.zammadChatTemplates) {
  402. window.zammadChatTemplates = {};
  403. }
  404. window.zammadChatTemplates["typingIndicator"] = function(__obj) {
  405. if (!__obj) __obj = {};
  406. var __out = [], __capture = function(callback) {
  407. var out = __out, result;
  408. __out = [];
  409. callback.call(this);
  410. result = __out.join('');
  411. __out = out;
  412. return __safe(result);
  413. }, __sanitize = function(value) {
  414. if (value && value.ecoSafe) {
  415. return value;
  416. } else if (typeof value !== 'undefined' && value != null) {
  417. return __escape(value);
  418. } else {
  419. return '';
  420. }
  421. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  422. __safe = __obj.safe = function(value) {
  423. if (value && value.ecoSafe) {
  424. return value;
  425. } else {
  426. if (!(typeof value !== 'undefined' && value != null)) value = '';
  427. var result = new String(value);
  428. result.ecoSafe = true;
  429. return result;
  430. }
  431. };
  432. if (!__escape) {
  433. __escape = __obj.escape = function(value) {
  434. return ('' + value)
  435. .replace(/&/g, '&amp;')
  436. .replace(/</g, '&lt;')
  437. .replace(/>/g, '&gt;')
  438. .replace(/"/g, '&quot;');
  439. };
  440. }
  441. (function() {
  442. (function() {
  443. __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>');
  444. }).call(this);
  445. }).call(__obj);
  446. __obj.safe = __objSafe, __obj.escape = __escape;
  447. return __out.join('');
  448. };
  449. if (!window.zammadChatTemplates) {
  450. window.zammadChatTemplates = {};
  451. }
  452. window.zammadChatTemplates["waiting_list_timeout"] = function(__obj) {
  453. if (!__obj) __obj = {};
  454. var __out = [], __capture = function(callback) {
  455. var out = __out, result;
  456. __out = [];
  457. callback.call(this);
  458. result = __out.join('');
  459. __out = out;
  460. return __safe(result);
  461. }, __sanitize = function(value) {
  462. if (value && value.ecoSafe) {
  463. return value;
  464. } else if (typeof value !== 'undefined' && value != null) {
  465. return __escape(value);
  466. } else {
  467. return '';
  468. }
  469. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  470. __safe = __obj.safe = function(value) {
  471. if (value && value.ecoSafe) {
  472. return value;
  473. } else {
  474. if (!(typeof value !== 'undefined' && value != null)) value = '';
  475. var result = new String(value);
  476. result.ecoSafe = true;
  477. return result;
  478. }
  479. };
  480. if (!__escape) {
  481. __escape = __obj.escape = function(value) {
  482. return ('' + value)
  483. .replace(/&/g, '&amp;')
  484. .replace(/</g, '&lt;')
  485. .replace(/>/g, '&gt;')
  486. .replace(/"/g, '&quot;');
  487. };
  488. }
  489. (function() {
  490. (function() {
  491. __out.push('<div class="zammad-chat-modal-text">\n ');
  492. __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!'));
  493. __out.push('\n <br>\n <div class="zammad-chat-button js-restart"');
  494. if (this.background) {
  495. __out.push(__sanitize(" style='background: " + this.background + "'"));
  496. }
  497. __out.push('>');
  498. __out.push(this.T('Start new conversation'));
  499. __out.push('</div>\n</div>');
  500. }).call(this);
  501. }).call(__obj);
  502. __obj.safe = __objSafe, __obj.escape = __escape;
  503. return __out.join('');
  504. };
  505. if (!window.zammadChatTemplates) {
  506. window.zammadChatTemplates = {};
  507. }
  508. window.zammadChatTemplates["waiting"] = function(__obj) {
  509. if (!__obj) __obj = {};
  510. var __out = [], __capture = function(callback) {
  511. var out = __out, result;
  512. __out = [];
  513. callback.call(this);
  514. result = __out.join('');
  515. __out = out;
  516. return __safe(result);
  517. }, __sanitize = function(value) {
  518. if (value && value.ecoSafe) {
  519. return value;
  520. } else if (typeof value !== 'undefined' && value != null) {
  521. return __escape(value);
  522. } else {
  523. return '';
  524. }
  525. }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
  526. __safe = __obj.safe = function(value) {
  527. if (value && value.ecoSafe) {
  528. return value;
  529. } else {
  530. if (!(typeof value !== 'undefined' && value != null)) value = '';
  531. var result = new String(value);
  532. result.ecoSafe = true;
  533. return result;
  534. }
  535. };
  536. if (!__escape) {
  537. __escape = __obj.escape = function(value) {
  538. return ('' + value)
  539. .replace(/&/g, '&amp;')
  540. .replace(/</g, '&lt;')
  541. .replace(/>/g, '&gt;')
  542. .replace(/"/g, '&quot;');
  543. };
  544. }
  545. (function() {
  546. (function() {
  547. __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 ');
  548. __out.push(this.T('All colleagues are busy.'));
  549. __out.push('<br>\n ');
  550. __out.push(this.T('You are on waiting list position <strong>%s</strong>.', this.position));
  551. __out.push('\n</div>');
  552. }).call(this);
  553. }).call(__obj);
  554. __obj.safe = __objSafe, __obj.escape = __escape;
  555. return __out.join('');
  556. };
  557. /*! @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 */
  558. !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}()}));
  559. //# sourceMappingURL=purify.min.js.map
  560. var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  561. slice = [].slice,
  562. 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; },
  563. hasProp = {}.hasOwnProperty;
  564. (function($, window) {
  565. var Base, Io, Log, Timeout, ZammadChat, myScript, scriptHost, scriptProtocol, scripts;
  566. scripts = document.getElementsByTagName('script');
  567. myScript = scripts[scripts.length - 1];
  568. scriptProtocol = window.location.protocol.replace(':', '');
  569. if (myScript && myScript.src) {
  570. scriptHost = myScript.src.match('.*://([^:/]*).*')[1];
  571. scriptProtocol = myScript.src.match('(.*)://[^:/]*.*')[1];
  572. }
  573. Base = (function() {
  574. Base.prototype.defaults = {
  575. debug: false
  576. };
  577. function Base(options) {
  578. this.options = $.extend({}, this.defaults, options);
  579. this.log = new Log({
  580. debug: this.options.debug,
  581. logPrefix: this.options.logPrefix || this.logPrefix
  582. });
  583. }
  584. return Base;
  585. })();
  586. Log = (function() {
  587. Log.prototype.defaults = {
  588. debug: false
  589. };
  590. function Log(options) {
  591. this.log = bind(this.log, this);
  592. this.error = bind(this.error, this);
  593. this.notice = bind(this.notice, this);
  594. this.debug = bind(this.debug, this);
  595. this.options = $.extend({}, this.defaults, options);
  596. }
  597. Log.prototype.debug = function() {
  598. var items;
  599. items = 1 <= arguments.length ? slice.call(arguments, 0) : [];
  600. if (!this.options.debug) {
  601. return;
  602. }
  603. return this.log('debug', items);
  604. };
  605. Log.prototype.notice = function() {
  606. var items;
  607. items = 1 <= arguments.length ? slice.call(arguments, 0) : [];
  608. return this.log('notice', items);
  609. };
  610. Log.prototype.error = function() {
  611. var items;
  612. items = 1 <= arguments.length ? slice.call(arguments, 0) : [];
  613. return this.log('error', items);
  614. };
  615. Log.prototype.log = function(level, items) {
  616. var item, j, len, logString;
  617. items.unshift('||');
  618. items.unshift(level);
  619. items.unshift(this.options.logPrefix);
  620. console.log.apply(console, items);
  621. if (!this.options.debug) {
  622. return;
  623. }
  624. logString = '';
  625. for (j = 0, len = items.length; j < len; j++) {
  626. item = items[j];
  627. logString += ' ';
  628. if (typeof item === 'object') {
  629. logString += JSON.stringify(item);
  630. } else if (item && item.toString) {
  631. logString += item.toString();
  632. } else {
  633. logString += item;
  634. }
  635. }
  636. return $('.js-chatLogDisplay').prepend('<div>' + logString + '</div>');
  637. };
  638. return Log;
  639. })();
  640. Timeout = (function(superClass) {
  641. extend(Timeout, superClass);
  642. Timeout.prototype.timeoutStartedAt = null;
  643. Timeout.prototype.logPrefix = 'timeout';
  644. Timeout.prototype.defaults = {
  645. debug: false,
  646. timeout: 4,
  647. timeoutIntervallCheck: 0.5
  648. };
  649. function Timeout(options) {
  650. this.stop = bind(this.stop, this);
  651. this.start = bind(this.start, this);
  652. Timeout.__super__.constructor.call(this, options);
  653. }
  654. Timeout.prototype.start = function() {
  655. var check, timeoutStartedAt;
  656. this.stop();
  657. timeoutStartedAt = new Date;
  658. check = (function(_this) {
  659. return function() {
  660. var timeLeft;
  661. timeLeft = new Date - new Date(timeoutStartedAt.getTime() + _this.options.timeout * 1000 * 60);
  662. _this.log.debug("Timeout check for " + _this.options.timeout + " minutes (left " + (timeLeft / 1000) + " sec.)");
  663. if (timeLeft < 0) {
  664. return;
  665. }
  666. _this.stop();
  667. return _this.options.callback();
  668. };
  669. })(this);
  670. this.log.debug("Start timeout in " + this.options.timeout + " minutes");
  671. return this.intervallId = setInterval(check, this.options.timeoutIntervallCheck * 1000 * 60);
  672. };
  673. Timeout.prototype.stop = function() {
  674. if (!this.intervallId) {
  675. return;
  676. }
  677. this.log.debug("Stop timeout of " + this.options.timeout + " minutes");
  678. return clearInterval(this.intervallId);
  679. };
  680. return Timeout;
  681. })(Base);
  682. Io = (function(superClass) {
  683. extend(Io, superClass);
  684. Io.prototype.logPrefix = 'io';
  685. function Io(options) {
  686. this.ping = bind(this.ping, this);
  687. this.send = bind(this.send, this);
  688. this.reconnect = bind(this.reconnect, this);
  689. this.close = bind(this.close, this);
  690. this.connect = bind(this.connect, this);
  691. this.set = bind(this.set, this);
  692. Io.__super__.constructor.call(this, options);
  693. }
  694. Io.prototype.set = function(params) {
  695. var key, results, value;
  696. results = [];
  697. for (key in params) {
  698. value = params[key];
  699. results.push(this.options[key] = value);
  700. }
  701. return results;
  702. };
  703. Io.prototype.connect = function() {
  704. this.log.debug("Connecting to " + this.options.host);
  705. this.ws = new window.WebSocket("" + this.options.host);
  706. this.ws.onopen = (function(_this) {
  707. return function(e) {
  708. _this.log.debug('onOpen', e);
  709. _this.options.onOpen(e);
  710. return _this.ping();
  711. };
  712. })(this);
  713. this.ws.onmessage = (function(_this) {
  714. return function(e) {
  715. var j, len, pipe, pipes;
  716. pipes = JSON.parse(e.data);
  717. _this.log.debug('onMessage', e.data);
  718. for (j = 0, len = pipes.length; j < len; j++) {
  719. pipe = pipes[j];
  720. if (pipe.event === 'pong') {
  721. _this.ping();
  722. }
  723. }
  724. if (_this.options.onMessage) {
  725. return _this.options.onMessage(pipes);
  726. }
  727. };
  728. })(this);
  729. this.ws.onclose = (function(_this) {
  730. return function(e) {
  731. _this.log.debug('close websocket connection', e);
  732. if (_this.pingDelayId) {
  733. clearTimeout(_this.pingDelayId);
  734. }
  735. if (_this.manualClose) {
  736. _this.log.debug('manual close, onClose callback');
  737. _this.manualClose = false;
  738. if (_this.options.onClose) {
  739. return _this.options.onClose(e);
  740. }
  741. } else {
  742. _this.log.debug('error close, onError callback');
  743. if (_this.options.onError) {
  744. return _this.options.onError('Connection lost...');
  745. }
  746. }
  747. };
  748. })(this);
  749. return this.ws.onerror = (function(_this) {
  750. return function(e) {
  751. _this.log.debug('onError', e);
  752. if (_this.options.onError) {
  753. return _this.options.onError(e);
  754. }
  755. };
  756. })(this);
  757. };
  758. Io.prototype.close = function() {
  759. this.log.debug('close websocket manually');
  760. this.manualClose = true;
  761. return this.ws.close();
  762. };
  763. Io.prototype.reconnect = function() {
  764. this.log.debug('reconnect');
  765. this.close();
  766. return this.connect();
  767. };
  768. Io.prototype.send = function(event, data) {
  769. var msg;
  770. if (data == null) {
  771. data = {};
  772. }
  773. this.log.debug('send', event, data);
  774. msg = JSON.stringify({
  775. event: event,
  776. data: data
  777. });
  778. return this.ws.send(msg);
  779. };
  780. Io.prototype.ping = function() {
  781. var localPing;
  782. localPing = (function(_this) {
  783. return function() {
  784. return _this.send('ping');
  785. };
  786. })(this);
  787. return this.pingDelayId = setTimeout(localPing, 29000);
  788. };
  789. return Io;
  790. })(Base);
  791. ZammadChat = (function(superClass) {
  792. extend(ZammadChat, superClass);
  793. ZammadChat.prototype.defaults = {
  794. chatId: void 0,
  795. show: true,
  796. target: $('body'),
  797. host: '',
  798. debug: false,
  799. flat: false,
  800. lang: void 0,
  801. cssAutoload: true,
  802. cssUrl: void 0,
  803. fontSize: void 0,
  804. buttonClass: 'open-zammad-chat',
  805. inactiveClass: 'is-inactive',
  806. title: '<strong>Chat</strong> with us!',
  807. scrollHint: 'Scroll down to see new messages',
  808. idleTimeout: 6,
  809. idleTimeoutIntervallCheck: 0.5,
  810. inactiveTimeout: 8,
  811. inactiveTimeoutIntervallCheck: 0.5,
  812. waitingListTimeout: 4,
  813. waitingListTimeoutIntervallCheck: 0.5,
  814. onReady: void 0,
  815. onCloseAnimationEnd: void 0,
  816. onError: void 0,
  817. onOpenAnimationEnd: void 0,
  818. onConnectionReestablished: void 0,
  819. onSessionClosed: void 0,
  820. onConnectionEstablished: void 0,
  821. onCssLoaded: void 0
  822. };
  823. ZammadChat.prototype.logPrefix = 'chat';
  824. ZammadChat.prototype._messageCount = 0;
  825. ZammadChat.prototype.isOpen = false;
  826. ZammadChat.prototype.blinkOnlineInterval = null;
  827. ZammadChat.prototype.stopBlinOnlineStateTimeout = null;
  828. ZammadChat.prototype.showTimeEveryXMinutes = 2;
  829. ZammadChat.prototype.lastTimestamp = null;
  830. ZammadChat.prototype.lastAddedType = null;
  831. ZammadChat.prototype.inputDisabled = false;
  832. ZammadChat.prototype.inputTimeout = null;
  833. ZammadChat.prototype.isTyping = false;
  834. ZammadChat.prototype.state = 'offline';
  835. ZammadChat.prototype.initialQueueDelay = 10000;
  836. ZammadChat.prototype.translations = {
  837. 'cs': {
  838. '<strong>Chat</strong> with us!': '<strong>Chatujte</strong> s námi!',
  839. 'All colleagues are busy.': 'Všichni kolegové jsou vytíženi.',
  840. 'Chat closed by %s': '%s ukončil konverzaci',
  841. 'Compose your message…': 'Napište svou zprávu…',
  842. 'Connecting': 'Připojování',
  843. 'Connection lost': 'Připojení ztraceno',
  844. 'Connection re-established': 'Připojení obnoveno',
  845. 'Offline': 'Offline',
  846. 'Online': 'Online',
  847. 'Scroll down to see new messages': 'Srolujte dolů pro zobrazení nových zpráv',
  848. 'Send': 'Odeslat',
  849. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Jelikož jste nereagovali v posledních %s minutách, vaše konverzace byla uzavřena.',
  850. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Jelikož jste nereagovali v posledních %s minutách, vaše konverzace s <strong>%s</strong> byla uzavřena.',
  851. 'Start new conversation': 'Zahájit novou konverzaci',
  852. 'Today': 'Dnes',
  853. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Omlouváme se, že musíte čekat déle, než je vhodné pro získání slotu. Prosím, zkuste to později, případně nám napište e-mail. Děkujeme!',
  854. 'You are on waiting list position <strong>%s</strong>.': 'Jste <strong>%s</strong>. v pořadí na čekací listině.'
  855. },
  856. 'da': {
  857. '<strong>Chat</strong> with us!': '<strong>Chat</strong> med os!',
  858. 'All colleagues are busy.': 'Alle medarbejdere er optaget.',
  859. 'Chat closed by %s': 'Chat lukket af %s',
  860. 'Compose your message…': 'Skriv din besked…',
  861. 'Connecting': 'Forbinder',
  862. 'Connection lost': 'Forbindelse mistet',
  863. 'Connection re-established': 'Forbindelse genoprettet',
  864. 'Offline': 'Offline',
  865. 'Online': 'Online',
  866. 'Scroll down to see new messages': 'Scroll ned for at se nye beskeder',
  867. 'Send': 'Afsend',
  868. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  869. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  870. 'Start new conversation': 'Start en ny samtale',
  871. 'Today': 'I dag',
  872. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': '',
  873. 'You are on waiting list position <strong>%s</strong>.': 'Du er i kø som nummer <strong>%s</strong>.'
  874. },
  875. 'de': {
  876. '<strong>Chat</strong> with us!': '<strong>Chatte</strong> mit uns!',
  877. 'All colleagues are busy.': 'Alle Kollegen sind beschäftigt.',
  878. 'Chat closed by %s': 'Chat von %s geschlossen',
  879. 'Compose your message…': 'Verfassen Sie Ihre Nachricht…',
  880. 'Connecting': 'Verbinde',
  881. 'Connection lost': 'Verbindung verloren',
  882. 'Connection re-established': 'Verbindung wieder aufgebaut',
  883. 'Offline': 'Offline',
  884. 'Online': 'Online',
  885. 'Scroll down to see new messages': 'Nach unten scrollen um neue Nachrichten zu sehen',
  886. 'Send': 'Senden',
  887. '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.',
  888. '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.',
  889. 'Start new conversation': 'Neue Unterhaltung starten',
  890. 'Today': 'Heute',
  891. '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!',
  892. 'You are on waiting list position <strong>%s</strong>.': 'Sie sind in der Warteliste auf Position <strong>%s</strong>.'
  893. },
  894. 'es': {
  895. '<strong>Chat</strong> with us!': '<strong>Chatee</strong> con nosotros!',
  896. 'All colleagues are busy.': 'Todos los colegas están ocupados.',
  897. 'Chat closed by %s': 'Chat cerrado por %s',
  898. 'Compose your message…': 'Escribe tu mensaje…',
  899. 'Connecting': 'Conectando',
  900. 'Connection lost': 'Conexión perdida',
  901. 'Connection re-established': 'Conexión reestablecida',
  902. 'Offline': 'Desconectado',
  903. 'Online': 'En línea',
  904. 'Scroll down to see new messages': 'Desplace hacia abajo para ver nuevos mensajes',
  905. 'Send': 'Enviar',
  906. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Debido a que usted no ha respondido en los últimos %s minutos, su conversación se ha cerrado.',
  907. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Debido a que usted no ha respondido en los últimos %s minutos, su conversación con <strong>%s</strong> se ha cerrado.',
  908. 'Start new conversation': 'Iniciar nueva conversación',
  909. 'Today': 'Hoy',
  910. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Lo sentimos, estamos tardando más de lo esperado para asignar un agente. Inténtelo de nuevo más tarde o envíenos un correo electrónico. ¡Gracias!',
  911. 'You are on waiting list position <strong>%s</strong>.': 'Usted está en la posición <strong>%s</strong> de la lista de espera.'
  912. },
  913. 'fr': {
  914. '<strong>Chat</strong> with us!': '<strong>Chattez</strong> avec nous !',
  915. 'All colleagues are busy.': 'Tous les agents sont occupés.',
  916. 'Chat closed by %s': 'Chat fermé par %s',
  917. 'Compose your message…': 'Écrivez votre message…',
  918. 'Connecting': 'Connexion',
  919. 'Connection lost': 'Connexion perdue',
  920. 'Connection re-established': 'Connexion ré-établie',
  921. 'Offline': 'Hors-ligne',
  922. 'Online': 'En ligne',
  923. 'Scroll down to see new messages': 'Défiler vers le bas pour voir les nouveaux messages',
  924. 'Send': 'Envoyer',
  925. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Sans réponse de votre part depuis %s minutes, votre conservation a été fermée.',
  926. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Sans réponse de votre part depuis %s minutes, votre conversation avec <strong>%s</strong> a été fermée.',
  927. 'Start new conversation': 'Démarrer une nouvelle conversation',
  928. 'Today': 'Aujourd\'hui',
  929. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Nous sommes désolés, trouver un agent disponible prend plus de temps que prévu. Réessayez plus tard ou envoyez-nous un mail. Merci !',
  930. 'You are on waiting list position <strong>%s</strong>.': 'Vous êtes actuellement en position <strong>%s</strong> dans la file d\'attente.'
  931. },
  932. 'hr': {
  933. '<strong>Chat</strong> with us!': '<strong>Čavrljajte</strong> sa nama!',
  934. 'All colleagues are busy.': 'Svi agenti su zauzeti.',
  935. 'Chat closed by %s': '%s zatvara chat',
  936. 'Compose your message…': 'Sastavite poruku…',
  937. 'Connecting': 'Povezivanje',
  938. 'Connection lost': 'Veza prekinuta',
  939. 'Connection re-established': 'Veza je ponovno uspostavljena',
  940. 'Offline': 'Odsutan',
  941. 'Online': 'Dostupan(a)',
  942. 'Scroll down to see new messages': 'Pomaknite se prema dolje da biste vidjeli nove poruke',
  943. 'Send': 'Pošalji',
  944. '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.',
  945. '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.',
  946. 'Start new conversation': 'Započni novi razgovor',
  947. 'Today': 'Danas',
  948. '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, traje duže nego inače za dobiti slobodan termin. Molimo, pokušajte ponovno kasnije ili nam pošaljite e-mail. Hvala!',
  949. 'You are on waiting list position <strong>%s</strong>.': 'Nalazite se u redu čekanja na poziciji <strong>%s</strong>.'
  950. },
  951. 'hu': {
  952. '<strong>Chat</strong> with us!': '<strong>Csevegjen</strong> velünk!',
  953. 'All colleagues are busy.': 'Minden munkatársunk foglalt.',
  954. 'Chat closed by %s': 'A csevegés %s által lezárva',
  955. 'Compose your message…': 'Fogalmazza meg üzenetét…',
  956. 'Connecting': 'Csatlakozás',
  957. 'Connection lost': 'A kapcsolat megszakadt',
  958. 'Connection re-established': 'A kapcsolat helyreállt',
  959. 'Offline': 'Offline',
  960. 'Online': 'Online',
  961. 'Scroll down to see new messages': 'Görgessen lefelé az új üzenetek megtekintéséhez',
  962. 'Send': 'Küldés',
  963. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Mivel az elmúlt %s percben nem válaszolt, a beszélgetése lezárásra került.',
  964. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Mivel az elmúlt %s percben nem válaszolt, <strong>%s</strong> munkatársunkkal folytatott beszélgetését lezártuk.',
  965. 'Start new conversation': 'Új beszélgetés indítása',
  966. 'Today': 'Ma',
  967. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Sajnáljuk, hogy a vártnál hosszabb ideig tart a helyfoglalás. Kérjük, próbálja meg később újra, vagy küldjön nekünk egy e-mailt. Köszönjük!',
  968. 'You are on waiting list position <strong>%s</strong>.': 'Ön a várólistán a <strong>%s</strong> helyen szerepel.'
  969. },
  970. 'it': {
  971. '<strong>Chat</strong> with us!': '<strong>Chatta</strong> con noi!',
  972. 'All colleagues are busy.': 'Tutti i colleghi sono occupati.',
  973. 'Chat closed by %s': 'Chat chiusa da %s',
  974. 'Compose your message…': 'Scrivi il tuo messaggio…',
  975. 'Connecting': 'Connessione in corso',
  976. 'Connection lost': 'Connessione persa',
  977. 'Connection re-established': 'Connessione ristabilita',
  978. 'Offline': 'Offline',
  979. 'Online': 'Online',
  980. 'Scroll down to see new messages': 'Scorri verso il basso per vedere i nuovi messaggi',
  981. 'Send': 'Invia',
  982. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Dato che non hai risposto negli ultimi %s minuti, la conversazione è stata chiusa.',
  983. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Dato che non hai risposto negli ultimi %s minuti, la conversazione con <strong>%s</strong> è stata chiusa.',
  984. 'Start new conversation': 'Avvia una nuova chat',
  985. 'Today': 'Oggi',
  986. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Siamo spiacenti, ci vuole più tempo del previsto per ottenere uno spazio libero. Riprova più tardi o inviaci un\'e-mail. Grazie!',
  987. 'You are on waiting list position <strong>%s</strong>.': 'Sei alla posizione <strong>%s</strong> della lista di attesa.'
  988. },
  989. 'lt': {
  990. '<strong>Chat</strong> with us!': '<strong>Kalbėkitės</strong> su mumis!',
  991. 'All colleagues are busy.': 'Visi kolegos užimti.',
  992. 'Chat closed by %s': '%s uždarė pokalbį',
  993. 'Compose your message…': 'Rašykite žinutę…',
  994. 'Connecting': 'Jungiamasi',
  995. 'Connection lost': 'Dingo ryšys',
  996. 'Connection re-established': 'Ryšys atnaujintas',
  997. 'Offline': 'Atsijungęs',
  998. 'Online': 'Prisijungęs',
  999. 'Scroll down to see new messages': 'Naujos žinutės žemiau',
  1000. 'Send': 'Siųsti',
  1001. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Jūsų pokalbis buvo uždarytas, nes nieko neatsakėte per %s minučių.',
  1002. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Jūsų pokalbis su <strong>%s</strong> buvo uždarytas, nes nieko neatsakėte per %s minučių.',
  1003. 'Start new conversation': 'Pradėti naują pokalbį',
  1004. 'Today': 'Šiandien',
  1005. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Atsiprašome, kad tenka laukti atskymo. Bandykite vėliau arba rašykite el. paštu. Ačiū!',
  1006. 'You are on waiting list position <strong>%s</strong>.': 'Esate <strong>%s</strong> eilėje.'
  1007. },
  1008. 'nl': {
  1009. '<strong>Chat</strong> with us!': '<strong>Chat</strong> met ons!',
  1010. 'All colleagues are busy.': 'Alle collega\'s zijn bezet.',
  1011. 'Chat closed by %s': 'Chat gesloten door %s',
  1012. 'Compose your message…': 'Stel je bericht op…',
  1013. 'Connecting': 'Verbinden',
  1014. 'Connection lost': 'Verbinding verbroken',
  1015. 'Connection re-established': 'Verbinding hersteld',
  1016. 'Offline': 'Offline',
  1017. 'Online': 'Online',
  1018. 'Scroll down to see new messages': 'Scroll naar beneden om nieuwe tickets te bekijken',
  1019. 'Send': 'Verstuur',
  1020. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'De chat is afgesloten omdat je de laatste %s minuten niet hebt gereageerd.',
  1021. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Je chat met <strong>%s</strong> is afgesloten omdat je niet hebt gereageerd in de laatste %s minuten.',
  1022. 'Start new conversation': 'Nieuw gesprek starten',
  1023. 'Today': 'Vandaag',
  1024. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Het spijt ons, het duurt langer dan verwacht om een chat te starten. Probeer het later nog eens of stuur ons een e-mail. Bedankt!',
  1025. 'You are on waiting list position <strong>%s</strong>.': 'Je bevindt zich op wachtlijstpositie <strong>%s</strong>.'
  1026. },
  1027. 'pl': {
  1028. '<strong>Chat</strong> with us!': '<strong>Czatuj</strong> z nami!',
  1029. 'All colleagues are busy.': 'Wszyscy agenci są zajęci.',
  1030. 'Chat closed by %s': 'Chat zamknięty przez %s',
  1031. 'Compose your message…': 'Skomponuj swoją wiadomość…',
  1032. 'Connecting': 'Łączenie',
  1033. 'Connection lost': 'Utracono połączenie',
  1034. 'Connection re-established': 'Ponowne nawiązanie połączenia',
  1035. 'Offline': 'Offline',
  1036. 'Online': 'Online',
  1037. 'Scroll down to see new messages': 'Skroluj w dół, aby zobaczyć wiadomości',
  1038. 'Send': 'Wyślij',
  1039. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Ponieważ nie odpowiedziałeś w ciągu ostatnich %s minut, Twoja rozmowa została zamknięta.',
  1040. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Ponieważ nie odpowiedziałeś w ciągu ostatnich %s minut, Twoja rozmowa z <strong>%s</strong> została zamknięta.',
  1041. 'Start new conversation': 'Rozpocznij nową rozmowę',
  1042. 'Today': 'Dzisiaj',
  1043. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Przepraszamy, znalezienie wolnego konsultanta zajmuje więcej czasu niż oczekiwano. Spróbuj ponownie później lub wyślij nam e-mail. Dziękujemy!',
  1044. 'You are on waiting list position <strong>%s</strong>.': 'Jesteś na pozycji listy oczekujących <strong>%s</strong>.'
  1045. },
  1046. 'pt-br': {
  1047. '<strong>Chat</strong> with us!': '<strong>Converse</strong> conosco!',
  1048. 'All colleagues are busy.': 'Nossos atendentes estão ocupados.',
  1049. 'Chat closed by %s': 'Chat encerrado por %s',
  1050. 'Compose your message…': 'Escreva sua mensagem…',
  1051. 'Connecting': 'Conectando',
  1052. 'Connection lost': 'Conexão perdida',
  1053. 'Connection re-established': 'Conexão restabelecida',
  1054. 'Offline': 'Desconectado',
  1055. 'Online': 'Online',
  1056. 'Scroll down to see new messages': 'Rolar para baixo para ver novas mensagems',
  1057. 'Send': 'Enviar',
  1058. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Como você não respondeu nos últimos %s minutos, sua conversa foi encerrada.',
  1059. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Como você não respondeu nos últimos %s minutos, sua conversa com <strong>%s</strong> foi encerrada.',
  1060. 'Start new conversation': 'Iniciar uma nova conversa',
  1061. 'Today': 'Hoje',
  1062. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Lamentamos, está demorando mais do que o esperado para conseguir uma vaga. Tente novamente mais tarde ou envie-nos um e-mail. Obrigado!',
  1063. 'You are on waiting list position <strong>%s</strong>.': 'Você está na posição <strong>%s</strong> da lista de espera.'
  1064. },
  1065. 'ro': {
  1066. '<strong>Chat</strong> with us!': '<strong>Comunică</strong> cu noi!',
  1067. 'All colleagues are busy.': 'Toți colegii sunt ocupați momentan.',
  1068. 'Chat closed by %s': 'Chat închis de către %s',
  1069. 'Compose your message…': 'Compune-ți mesajul…',
  1070. 'Connecting': 'Se conectează',
  1071. 'Connection lost': 'Conexiune pierdută',
  1072. 'Connection re-established': 'Conexiune restabilită',
  1073. 'Offline': 'Offline',
  1074. 'Online': 'Online',
  1075. 'Scroll down to see new messages': 'Derulați în jos pentru a vedea mesajele noi',
  1076. 'Send': 'Trimite',
  1077. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Deoarece nu ai răspuns în ultimele %s minute, conversația ta a fost închisă.',
  1078. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Deoarece nu ai răspuns în ultimele %s minute, conversația ta cu <strong>%s</strong> a fost închisă.',
  1079. 'Start new conversation': 'Începe o conversație nouă',
  1080. 'Today': 'Azi',
  1081. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Ne pare rău, durează mai mult decât ne așteptam să obținem un loc. Te rugăm să încerci din nou mai târziu sau să ne trimiți un email. Mulțumim!',
  1082. 'You are on waiting list position <strong>%s</strong>.': 'Aveți poziția <strong>%s</strong> în lista de așteptare.'
  1083. },
  1084. 'ru': {
  1085. '<strong>Chat</strong> with us!': '<strong>Напишите</strong> нам!',
  1086. 'All colleagues are busy.': 'Все коллеги заняты.',
  1087. 'Chat closed by %s': 'Чат закрыт %s',
  1088. 'Compose your message…': 'Составьте сообщение…',
  1089. 'Connecting': 'Подключение',
  1090. 'Connection lost': 'Подключение потеряно',
  1091. 'Connection re-established': 'Подключение восстановлено',
  1092. 'Offline': 'Оффлайн',
  1093. 'Online': 'В сети',
  1094. 'Scroll down to see new messages': 'Прокрутите вниз, чтобы увидеть новые сообщения',
  1095. 'Send': 'Отправить',
  1096. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Поскольку Вы не ответили в течение последних %s минут, Ваш разговор был закрыт.',
  1097. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Поскольку Вы не ответили в течение последних %s минут, Ваш разговор с <strong>%s</strong> был закрыт.',
  1098. 'Start new conversation': 'Начать новый разговор',
  1099. 'Today': 'Сегодня',
  1100. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Извините, получение свободного слота занимает больше времени, чем ожидалось. Пожалуйста, повторите попытку позже или отправьте нам электронное письмо. Благодарим Вас!',
  1101. 'You are on waiting list position <strong>%s</strong>.': 'Вы находитесь в списке ожидания <strong>%s</strong>.'
  1102. },
  1103. 'sr': {
  1104. '<strong>Chat</strong> with us!': '<strong>Ћаскајте</strong> са нама!',
  1105. 'All colleagues are busy.': 'Све колеге су заузете.',
  1106. 'Chat closed by %s': 'Ћаскање затворено од стране %s',
  1107. 'Compose your message…': 'Напишите поруку…',
  1108. 'Connecting': 'Повезивање',
  1109. 'Connection lost': 'Веза је изгубљена',
  1110. 'Connection re-established': 'Веза је поново успостављена',
  1111. 'Offline': 'Одсутан(а)',
  1112. 'Online': 'Доступан(а)',
  1113. 'Scroll down to see new messages': 'Скролујте на доле за нове поруке',
  1114. 'Send': 'Пошаљи',
  1115. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Пошто нисте одговорили у последњих %s минут(a), ваш разговор је завршен.',
  1116. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Пошто нисте одговорили у последњих %s минут(a), ваш разговор са <strong>%s</strong> је завршен.',
  1117. 'Start new conversation': 'Започни нови разговор',
  1118. 'Today': 'Данас',
  1119. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': 'Жао нам је, добијање празног термина траје дуже од очекиваног. Молимо покушајте поново касније или нам пошаљите имејл поруку. Хвала вам!',
  1120. 'You are on waiting list position <strong>%s</strong>.': 'Ви сте тренутно <strong>%s.</strong> у реду за чекање.'
  1121. },
  1122. 'sr-latn-rs': {
  1123. '<strong>Chat</strong> with us!': '<strong>Ćaskajte</strong> sa nama!',
  1124. 'All colleagues are busy.': 'Sve kolege su zauzete.',
  1125. 'Chat closed by %s': 'Ćaskanje zatvoreno od strane %s',
  1126. 'Compose your message…': 'Napišite poruku…',
  1127. 'Connecting': 'Povezivanje',
  1128. 'Connection lost': 'Veza je izgubljena',
  1129. 'Connection re-established': 'Veza je ponovo uspostavljena',
  1130. 'Offline': 'Odsutan(a)',
  1131. 'Online': 'Dostupan(a)',
  1132. 'Scroll down to see new messages': 'Skrolujte na dole za nove poruke',
  1133. 'Send': 'Pošalji',
  1134. '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.',
  1135. '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.',
  1136. 'Start new conversation': 'Započni novi razgovor',
  1137. 'Today': 'Danas',
  1138. '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!',
  1139. 'You are on waiting list position <strong>%s</strong>.': 'Vi ste trenutno <strong>%s.</strong> u redu za čekanje.'
  1140. },
  1141. 'sv': {
  1142. '<strong>Chat</strong> with us!': '<strong>Chatta</strong> med oss!',
  1143. 'All colleagues are busy.': 'Alla kollegor är upptagna.',
  1144. 'Chat closed by %s': 'Chatt stängd av %s',
  1145. 'Compose your message…': 'Skriv ditt meddelande …',
  1146. 'Connecting': 'Ansluter',
  1147. 'Connection lost': 'Anslutningen försvann',
  1148. 'Connection re-established': 'Anslutningen återupprättas',
  1149. 'Offline': 'Offline',
  1150. 'Online': 'Online',
  1151. 'Scroll down to see new messages': 'Bläddra ner för att se nya meddelanden',
  1152. 'Send': 'Skicka',
  1153. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Din chatt avslutades då du inte svarade inom %s minuter.',
  1154. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Chatten stängdes eftersom du inte svarat inom %s minuter i din konversation med <strong>%s</strong>.',
  1155. 'Start new conversation': 'Starta ny konversation',
  1156. 'Today': 'Idag',
  1157. '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!',
  1158. 'You are on waiting list position <strong>%s</strong>.': 'Du är på väntelistan som position <strong>%s</strong>.'
  1159. },
  1160. 'zh-cn': {
  1161. '<strong>Chat</strong> with us!': '发起<strong>即时对话</strong>!',
  1162. 'All colleagues are busy.': '所有同事都很忙。',
  1163. 'Chat closed by %s': '对话已被 %s 关闭',
  1164. 'Compose your message…': '编辑您的信息…',
  1165. 'Connecting': '连接中',
  1166. 'Connection lost': '连接丢失',
  1167. 'Connection re-established': '正在重新建立连接',
  1168. 'Offline': '离线',
  1169. 'Online': '在线',
  1170. 'Scroll down to see new messages': '向下滚动以查看新消息',
  1171. 'Send': '发送',
  1172. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '"由于您超过 %s 分钟没有任何回复',
  1173. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '"由于您超过 %s 分钟没有回复',
  1174. 'Start new conversation': '开始新的会话',
  1175. 'Today': '今天',
  1176. 'We are sorry, it is taking longer than expected to get a slot. Please try again later or send us an email. Thank you!': '',
  1177. 'You are on waiting list position <strong>%s</strong>.': '您目前的等候位置是第 <strong>%s</strong> 位.'
  1178. }
  1179. };
  1180. ZammadChat.prototype.sessionId = void 0;
  1181. ZammadChat.prototype.scrolledToBottom = true;
  1182. ZammadChat.prototype.scrollSnapTolerance = 10;
  1183. ZammadChat.prototype.richTextFormatKey = {
  1184. 66: true,
  1185. 73: true,
  1186. 85: true,
  1187. 83: true
  1188. };
  1189. ZammadChat.prototype.T = function() {
  1190. var item, items, j, len, string, translations;
  1191. string = arguments[0], items = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  1192. if (this.options.lang && this.options.lang !== 'en') {
  1193. if (!this.translations[this.options.lang]) {
  1194. this.log.notice("Translation '" + this.options.lang + "' needed!");
  1195. } else {
  1196. translations = this.translations[this.options.lang];
  1197. if (!translations[string]) {
  1198. this.log.notice("Translation needed for '" + string + "'");
  1199. }
  1200. string = translations[string] || string;
  1201. }
  1202. }
  1203. if (items) {
  1204. for (j = 0, len = items.length; j < len; j++) {
  1205. item = items[j];
  1206. string = string.replace(/%s/, item);
  1207. }
  1208. }
  1209. return string;
  1210. };
  1211. ZammadChat.prototype.view = function(name) {
  1212. return (function(_this) {
  1213. return function(options) {
  1214. if (!options) {
  1215. options = {};
  1216. }
  1217. options.T = _this.T;
  1218. options.background = _this.options.background;
  1219. options.flat = _this.options.flat;
  1220. options.fontSize = _this.options.fontSize;
  1221. return window.zammadChatTemplates[name](options);
  1222. };
  1223. })(this);
  1224. };
  1225. function ZammadChat(options) {
  1226. this.removeAttributes = bind(this.removeAttributes, this);
  1227. this.startTimeoutObservers = bind(this.startTimeoutObservers, this);
  1228. this.onCssLoaded = bind(this.onCssLoaded, this);
  1229. this.setAgentOnlineState = bind(this.setAgentOnlineState, this);
  1230. this.onConnectionEstablished = bind(this.onConnectionEstablished, this);
  1231. this.setSessionId = bind(this.setSessionId, this);
  1232. this.onConnectionReestablished = bind(this.onConnectionReestablished, this);
  1233. this.reconnect = bind(this.reconnect, this);
  1234. this.destroy = bind(this.destroy, this);
  1235. this.onScrollHintClick = bind(this.onScrollHintClick, this);
  1236. this.detectScrolledtoBottom = bind(this.detectScrolledtoBottom, this);
  1237. this.onLeaveTemporary = bind(this.onLeaveTemporary, this);
  1238. this.onAgentTypingEnd = bind(this.onAgentTypingEnd, this);
  1239. this.onAgentTypingStart = bind(this.onAgentTypingStart, this);
  1240. this.onQueue = bind(this.onQueue, this);
  1241. this.onQueueScreen = bind(this.onQueueScreen, this);
  1242. this.onWebSocketClose = bind(this.onWebSocketClose, this);
  1243. this.onCloseAnimationEnd = bind(this.onCloseAnimationEnd, this);
  1244. this.close = bind(this.close, this);
  1245. this.toggle = bind(this.toggle, this);
  1246. this.sessionClose = bind(this.sessionClose, this);
  1247. this.onOpenAnimationEnd = bind(this.onOpenAnimationEnd, this);
  1248. this.open = bind(this.open, this);
  1249. this.renderMessage = bind(this.renderMessage, this);
  1250. this.receiveMessage = bind(this.receiveMessage, this);
  1251. this.onSubmit = bind(this.onSubmit, this);
  1252. this.onFocus = bind(this.onFocus, this);
  1253. this.onInput = bind(this.onInput, this);
  1254. this.onReopenSession = bind(this.onReopenSession, this);
  1255. this.onError = bind(this.onError, this);
  1256. this.onWebSocketMessage = bind(this.onWebSocketMessage, this);
  1257. this.send = bind(this.send, this);
  1258. this.checkForEnter = bind(this.checkForEnter, this);
  1259. this.render = bind(this.render, this);
  1260. this.view = bind(this.view, this);
  1261. this.T = bind(this.T, this);
  1262. this.options = $.extend({}, this.defaults, options);
  1263. ZammadChat.__super__.constructor.call(this, this.options);
  1264. this.isFullscreen = window.matchMedia && window.matchMedia('(max-width: 768px)').matches;
  1265. this.scrollRoot = $(this.getScrollRoot());
  1266. if (!$) {
  1267. this.state = 'unsupported';
  1268. this.log.notice('Chat: no jquery found!');
  1269. return;
  1270. }
  1271. if (!window.WebSocket || !sessionStorage) {
  1272. this.state = 'unsupported';
  1273. this.log.notice('Chat: Browser not supported!');
  1274. return;
  1275. }
  1276. if (!this.options.chatId) {
  1277. this.state = 'unsupported';
  1278. this.log.error('Chat: need chatId as option!');
  1279. return;
  1280. }
  1281. if (!this.options.lang) {
  1282. this.options.lang = $('html').attr('lang');
  1283. }
  1284. if (this.options.lang) {
  1285. if (!this.translations[this.options.lang]) {
  1286. this.log.debug("lang: No " + this.options.lang + " found, try first two letters");
  1287. this.options.lang = this.options.lang.replace(/-.+?$/, '');
  1288. }
  1289. this.log.debug("lang: " + this.options.lang);
  1290. }
  1291. if (!this.options.host) {
  1292. this.detectHost();
  1293. }
  1294. this.loadCss();
  1295. this.io = new Io(this.options);
  1296. this.io.set({
  1297. onOpen: this.render,
  1298. onClose: this.onWebSocketClose,
  1299. onMessage: this.onWebSocketMessage,
  1300. onError: this.onError
  1301. });
  1302. this.io.connect();
  1303. }
  1304. ZammadChat.prototype.getScrollRoot = function() {
  1305. var end, html, start;
  1306. if ('scrollingElement' in document) {
  1307. return document.scrollingElement;
  1308. }
  1309. html = document.documentElement;
  1310. start = html.scrollTop;
  1311. html.scrollTop = start + 1;
  1312. end = html.scrollTop;
  1313. html.scrollTop = start;
  1314. if (end > start) {
  1315. return html;
  1316. } else {
  1317. return document.body;
  1318. }
  1319. };
  1320. ZammadChat.prototype.render = function() {
  1321. if (!this.el || !$('.zammad-chat').get(0)) {
  1322. this.renderBase();
  1323. }
  1324. $("." + this.options.buttonClass).addClass(this.options.inactiveClass);
  1325. this.setAgentOnlineState('online');
  1326. this.log.debug('widget rendered');
  1327. this.startTimeoutObservers();
  1328. this.idleTimeout.start();
  1329. this.sessionId = sessionStorage.getItem('sessionId');
  1330. return this.send('chat_status_customer', {
  1331. session_id: this.sessionId,
  1332. url: window.location.href
  1333. });
  1334. };
  1335. ZammadChat.prototype.renderBase = function() {
  1336. this.el = $(this.view('chat')({
  1337. title: this.options.title,
  1338. scrollHint: this.options.scrollHint
  1339. }));
  1340. this.options.target.append(this.el);
  1341. this.input = this.el.find('.zammad-chat-input');
  1342. this.el.find('.js-chat-open').on('click', this.open);
  1343. this.el.find('.js-chat-toggle').on('click', this.toggle);
  1344. this.el.find('.js-chat-status').on('click', this.stopPropagation);
  1345. this.el.find('.zammad-chat-controls').on('submit', this.onSubmit);
  1346. this.el.find('.zammad-chat-body').on('scroll', this.detectScrolledtoBottom);
  1347. this.el.find('.zammad-scroll-hint').on('click', this.onScrollHintClick);
  1348. this.input.on({
  1349. keydown: this.checkForEnter,
  1350. input: this.onInput
  1351. });
  1352. this.input.on('keydown', (function(_this) {
  1353. return function(e) {
  1354. var richtTextControl;
  1355. richtTextControl = false;
  1356. if (!e.altKey && !e.ctrlKey && e.metaKey) {
  1357. richtTextControl = true;
  1358. } else if (!e.altKey && e.ctrlKey && !e.metaKey) {
  1359. richtTextControl = true;
  1360. }
  1361. if (richtTextControl && _this.richTextFormatKey[e.keyCode]) {
  1362. e.preventDefault();
  1363. if (e.keyCode === 66) {
  1364. document.execCommand('bold');
  1365. return true;
  1366. }
  1367. if (e.keyCode === 73) {
  1368. document.execCommand('italic');
  1369. return true;
  1370. }
  1371. if (e.keyCode === 85) {
  1372. document.execCommand('underline');
  1373. return true;
  1374. }
  1375. if (e.keyCode === 83) {
  1376. document.execCommand('strikeThrough');
  1377. return true;
  1378. }
  1379. }
  1380. };
  1381. })(this));
  1382. this.input.on('paste', (function(_this) {
  1383. return function(e) {
  1384. var clipboardData, docType, html, htmlTmp, imageFile, imageInserted, item, match, reader, regex, replacementTag, sanitized, text;
  1385. e.stopPropagation();
  1386. e.preventDefault();
  1387. clipboardData;
  1388. if (e.clipboardData) {
  1389. clipboardData = e.clipboardData;
  1390. } else if (window.clipboardData) {
  1391. clipboardData = window.clipboardData;
  1392. } else if (e.originalEvent.clipboardData) {
  1393. clipboardData = e.originalEvent.clipboardData;
  1394. } else {
  1395. throw 'No clipboardData support';
  1396. }
  1397. imageInserted = false;
  1398. if (clipboardData && clipboardData.items && clipboardData.items[0]) {
  1399. item = clipboardData.items[0];
  1400. if (item.kind === 'file' && (item.type === 'image/png' || item.type === 'image/jpeg')) {
  1401. imageFile = item.getAsFile();
  1402. reader = new FileReader();
  1403. reader.onload = function(e) {
  1404. var img, insert, result;
  1405. result = e.target.result;
  1406. img = document.createElement('img');
  1407. img.src = result;
  1408. insert = function(dataUrl, width, height, isRetina) {
  1409. if (_this.isRetina()) {
  1410. width = width / 2;
  1411. height = height / 2;
  1412. }
  1413. result = dataUrl;
  1414. img = "<img style=\"width: 100%; max-width: " + width + "px;\" src=\"" + result + "\">";
  1415. return document.execCommand('insertHTML', false, img);
  1416. };
  1417. return _this.resizeImage(img.src, 460, 'auto', 2, 'image/jpeg', 'auto', insert);
  1418. };
  1419. reader.readAsDataURL(imageFile);
  1420. imageInserted = true;
  1421. }
  1422. }
  1423. if (imageInserted) {
  1424. return;
  1425. }
  1426. text = void 0;
  1427. docType = void 0;
  1428. try {
  1429. text = clipboardData.getData('text/html');
  1430. docType = 'html';
  1431. if (!text || text.length === 0) {
  1432. docType = 'text';
  1433. text = clipboardData.getData('text/plain');
  1434. }
  1435. if (!text || text.length === 0) {
  1436. docType = 'text2';
  1437. text = clipboardData.getData('text');
  1438. }
  1439. } catch (error) {
  1440. e = error;
  1441. console.log('Sorry, can\'t insert markup because browser is not supporting it.');
  1442. docType = 'text3';
  1443. text = clipboardData.getData('text');
  1444. }
  1445. if (docType === 'text' || docType === 'text2' || docType === 'text3') {
  1446. text = '<div>' + text.replace(/\n/g, '</div><div>') + '</div>';
  1447. text = text.replace(/<div><\/div>/g, '<div><br></div>');
  1448. }
  1449. console.log('p', docType, text);
  1450. if (docType === 'html') {
  1451. sanitized = DOMPurify.sanitize(text);
  1452. _this.log.debug('sanitized HTML clipboard', sanitized);
  1453. html = $("<div>" + sanitized + "</div>");
  1454. match = false;
  1455. htmlTmp = text;
  1456. regex = new RegExp('<(/w|w)\:[A-Za-z]');
  1457. if (htmlTmp.match(regex)) {
  1458. match = true;
  1459. htmlTmp = htmlTmp.replace(regex, '');
  1460. }
  1461. regex = new RegExp('<(/o|o)\:[A-Za-z]');
  1462. if (htmlTmp.match(regex)) {
  1463. match = true;
  1464. htmlTmp = htmlTmp.replace(regex, '');
  1465. }
  1466. if (match) {
  1467. html = _this.wordFilter(html);
  1468. }
  1469. html = $(html);
  1470. html.contents().each(function() {
  1471. if (this.nodeType === 8) {
  1472. return $(this).remove();
  1473. }
  1474. });
  1475. html.find('a, font, small, time, form, label').replaceWith(function() {
  1476. return $(this).contents();
  1477. });
  1478. replacementTag = 'div';
  1479. html.find('textarea').each(function() {
  1480. var newTag, outer;
  1481. outer = this.outerHTML;
  1482. regex = new RegExp('<' + this.tagName, 'i');
  1483. newTag = outer.replace(regex, '<' + replacementTag);
  1484. regex = new RegExp('</' + this.tagName, 'i');
  1485. newTag = newTag.replace(regex, '</' + replacementTag);
  1486. return $(this).replaceWith(newTag);
  1487. });
  1488. html.find('font, img, svg, input, select, button, style, applet, embed, noframes, canvas, script, frame, iframe, meta, link, title, head, fieldset').remove();
  1489. _this.removeAttributes(html);
  1490. text = html.html();
  1491. }
  1492. if (docType === 'text3') {
  1493. _this.pasteHtmlAtCaret(text);
  1494. } else {
  1495. document.execCommand('insertHTML', false, text);
  1496. }
  1497. return true;
  1498. };
  1499. })(this));
  1500. this.input.on('drop', (function(_this) {
  1501. return function(e) {
  1502. var dataTransfer, file, reader, x, y;
  1503. e.stopPropagation();
  1504. e.preventDefault();
  1505. dataTransfer;
  1506. if (window.dataTransfer) {
  1507. dataTransfer = window.dataTransfer;
  1508. } else if (e.originalEvent.dataTransfer) {
  1509. dataTransfer = e.originalEvent.dataTransfer;
  1510. } else {
  1511. throw 'No clipboardData support';
  1512. }
  1513. x = e.clientX;
  1514. y = e.clientY;
  1515. file = dataTransfer.files[0];
  1516. if (file.type.match('image.*')) {
  1517. reader = new FileReader();
  1518. reader.onload = function(e) {
  1519. var img, insert, result;
  1520. result = e.target.result;
  1521. img = document.createElement('img');
  1522. img.src = result;
  1523. insert = function(dataUrl, width, height, isRetina) {
  1524. var pos, range;
  1525. if (_this.isRetina()) {
  1526. width = width / 2;
  1527. height = height / 2;
  1528. }
  1529. result = dataUrl;
  1530. img = $("<img style=\"width: 100%; max-width: " + width + "px;\" src=\"" + result + "\">");
  1531. img = img.get(0);
  1532. if (document.caretPositionFromPoint) {
  1533. pos = document.caretPositionFromPoint(x, y);
  1534. range = document.createRange();
  1535. range.setStart(pos.offsetNode, pos.offset);
  1536. range.collapse();
  1537. return range.insertNode(img);
  1538. } else if (document.caretRangeFromPoint) {
  1539. range = document.caretRangeFromPoint(x, y);
  1540. return range.insertNode(img);
  1541. } else {
  1542. return console.log('could not find carat');
  1543. }
  1544. };
  1545. return _this.resizeImage(img.src, 460, 'auto', 2, 'image/jpeg', 'auto', insert);
  1546. };
  1547. return reader.readAsDataURL(file);
  1548. }
  1549. };
  1550. })(this));
  1551. $(window).on('beforeunload', (function(_this) {
  1552. return function() {
  1553. return _this.onLeaveTemporary();
  1554. };
  1555. })(this));
  1556. $(window).on('hashchange', (function(_this) {
  1557. return function() {
  1558. if (_this.isOpen) {
  1559. if (_this.sessionId) {
  1560. _this.send('chat_session_notice', {
  1561. session_id: _this.sessionId,
  1562. message: window.location.href
  1563. });
  1564. }
  1565. return;
  1566. }
  1567. return _this.idleTimeout.start();
  1568. };
  1569. })(this));
  1570. if (this.isFullscreen) {
  1571. return this.input.on({
  1572. focus: this.onFocus,
  1573. focusout: this.onFocusOut
  1574. });
  1575. }
  1576. };
  1577. ZammadChat.prototype.stopPropagation = function(event) {
  1578. return event.stopPropagation();
  1579. };
  1580. ZammadChat.prototype.checkForEnter = function(event) {
  1581. if (!this.inputDisabled && !event.shiftKey && event.keyCode === 13) {
  1582. event.preventDefault();
  1583. return this.sendMessage();
  1584. }
  1585. };
  1586. ZammadChat.prototype.send = function(event, data) {
  1587. if (data == null) {
  1588. data = {};
  1589. }
  1590. data.chat_id = this.options.chatId;
  1591. return this.io.send(event, data);
  1592. };
  1593. ZammadChat.prototype.onWebSocketMessage = function(pipes) {
  1594. var j, len, pipe;
  1595. for (j = 0, len = pipes.length; j < len; j++) {
  1596. pipe = pipes[j];
  1597. this.log.debug('ws:onmessage', pipe);
  1598. switch (pipe.event) {
  1599. case 'chat_error':
  1600. this.log.notice(pipe.data);
  1601. if (pipe.data && pipe.data.state === 'chat_disabled') {
  1602. this.destroy({
  1603. remove: true
  1604. });
  1605. }
  1606. break;
  1607. case 'chat_session_message':
  1608. if (pipe.data.self_written) {
  1609. return;
  1610. }
  1611. this.receiveMessage(pipe.data);
  1612. break;
  1613. case 'chat_session_typing':
  1614. if (pipe.data.self_written) {
  1615. return;
  1616. }
  1617. this.onAgentTypingStart();
  1618. break;
  1619. case 'chat_session_start':
  1620. this.onConnectionEstablished(pipe.data);
  1621. break;
  1622. case 'chat_session_queue':
  1623. this.onQueueScreen(pipe.data);
  1624. break;
  1625. case 'chat_session_closed':
  1626. this.onSessionClosed(pipe.data);
  1627. break;
  1628. case 'chat_session_left':
  1629. this.onSessionClosed(pipe.data);
  1630. break;
  1631. case 'chat_session_notice':
  1632. this.addStatus(this.T(pipe.data.message));
  1633. break;
  1634. case 'chat_status_customer':
  1635. switch (pipe.data.state) {
  1636. case 'online':
  1637. this.sessionId = void 0;
  1638. if (!this.options.cssAutoload || this.cssLoaded) {
  1639. this.onReady();
  1640. } else {
  1641. this.socketReady = true;
  1642. }
  1643. break;
  1644. case 'offline':
  1645. this.onError('Zammad Chat: No agent online');
  1646. break;
  1647. case 'chat_disabled':
  1648. this.onError('Zammad Chat: Chat is disabled');
  1649. break;
  1650. case 'no_seats_available':
  1651. this.onError("Zammad Chat: Too many clients in queue. Clients in queue: " + pipe.data.queue);
  1652. break;
  1653. case 'reconnect':
  1654. this.onReopenSession(pipe.data);
  1655. }
  1656. }
  1657. }
  1658. };
  1659. ZammadChat.prototype.onReady = function() {
  1660. var base;
  1661. this.log.debug('widget ready for use');
  1662. $("." + this.options.buttonClass).on('click', this.open).removeClass(this.options.inactiveClass);
  1663. if (typeof (base = this.options).onReady === "function") {
  1664. base.onReady();
  1665. }
  1666. if (this.options.show) {
  1667. return this.show();
  1668. }
  1669. };
  1670. ZammadChat.prototype.onError = function(message) {
  1671. var base;
  1672. this.log.debug(message);
  1673. this.addStatus(message);
  1674. $("." + this.options.buttonClass).hide();
  1675. if (this.isOpen) {
  1676. this.disableInput();
  1677. this.destroy({
  1678. remove: false
  1679. });
  1680. } else {
  1681. this.destroy({
  1682. remove: true
  1683. });
  1684. }
  1685. return typeof (base = this.options).onError === "function" ? base.onError(message) : void 0;
  1686. };
  1687. ZammadChat.prototype.onReopenSession = function(data) {
  1688. var j, len, message, ref, unfinishedMessage;
  1689. this.log.debug('old messages', data.session);
  1690. this.inactiveTimeout.start();
  1691. unfinishedMessage = sessionStorage.getItem('unfinished_message');
  1692. if (data.agent) {
  1693. this.onConnectionEstablished(data);
  1694. ref = data.session;
  1695. for (j = 0, len = ref.length; j < len; j++) {
  1696. message = ref[j];
  1697. this.renderMessage({
  1698. message: message.content,
  1699. id: message.id,
  1700. from: message.created_by_id ? 'agent' : 'customer'
  1701. });
  1702. }
  1703. if (unfinishedMessage) {
  1704. this.input.html(unfinishedMessage);
  1705. }
  1706. }
  1707. if (data.position) {
  1708. this.onQueue(data);
  1709. }
  1710. this.show();
  1711. this.open();
  1712. this.scrollToBottom();
  1713. if (unfinishedMessage) {
  1714. return this.input.trigger('focus');
  1715. }
  1716. };
  1717. ZammadChat.prototype.onInput = function() {
  1718. this.el.find('.zammad-chat-message--unread').removeClass('zammad-chat-message--unread');
  1719. sessionStorage.setItem('unfinished_message', this.input.html());
  1720. return this.onTyping();
  1721. };
  1722. ZammadChat.prototype.onFocus = function() {
  1723. var keyboardShown;
  1724. $(window).scrollTop(10);
  1725. keyboardShown = $(window).scrollTop() > 0;
  1726. $(window).scrollTop(0);
  1727. if (keyboardShown) {
  1728. return this.log.notice('virtual keyboard shown');
  1729. }
  1730. };
  1731. ZammadChat.prototype.onFocusOut = function() {};
  1732. ZammadChat.prototype.onTyping = function() {
  1733. if (this.isTyping && this.isTyping > new Date(new Date().getTime() - 1500)) {
  1734. return;
  1735. }
  1736. this.isTyping = new Date();
  1737. this.send('chat_session_typing', {
  1738. session_id: this.sessionId
  1739. });
  1740. return this.inactiveTimeout.start();
  1741. };
  1742. ZammadChat.prototype.onSubmit = function(event) {
  1743. event.preventDefault();
  1744. return this.sendMessage();
  1745. };
  1746. ZammadChat.prototype.sendMessage = function() {
  1747. var message, messageElement;
  1748. message = this.input.html();
  1749. if (!message) {
  1750. return;
  1751. }
  1752. this.inactiveTimeout.start();
  1753. sessionStorage.removeItem('unfinished_message');
  1754. messageElement = this.view('message')({
  1755. message: message,
  1756. from: 'customer',
  1757. id: this._messageCount++,
  1758. unreadClass: ''
  1759. });
  1760. this.maybeAddTimestamp();
  1761. if (this.el.find('.zammad-chat-message--typing').get(0)) {
  1762. this.lastAddedType = 'typing-placeholder';
  1763. this.el.find('.zammad-chat-message--typing').before(messageElement);
  1764. } else {
  1765. this.lastAddedType = 'message--customer';
  1766. this.el.find('.zammad-chat-body').append(messageElement);
  1767. }
  1768. this.input.html('');
  1769. this.scrollToBottom();
  1770. return this.send('chat_session_message', {
  1771. content: message,
  1772. id: this._messageCount,
  1773. session_id: this.sessionId
  1774. });
  1775. };
  1776. ZammadChat.prototype.receiveMessage = function(data) {
  1777. this.inactiveTimeout.start();
  1778. this.onAgentTypingEnd();
  1779. this.maybeAddTimestamp();
  1780. this.renderMessage({
  1781. message: data.message.content,
  1782. id: data.id,
  1783. from: 'agent'
  1784. });
  1785. return this.scrollToBottom({
  1786. showHint: true
  1787. });
  1788. };
  1789. ZammadChat.prototype.renderMessage = function(data) {
  1790. this.lastAddedType = "message--" + data.from;
  1791. data.unreadClass = document.hidden ? ' zammad-chat-message--unread' : '';
  1792. return this.el.find('.zammad-chat-body').append(this.view('message')(data));
  1793. };
  1794. ZammadChat.prototype.open = function() {
  1795. var remainerHeight;
  1796. if (this.isOpen) {
  1797. this.log.debug('widget already open, block');
  1798. return;
  1799. }
  1800. this.isOpen = true;
  1801. this.log.debug('open widget');
  1802. this.show();
  1803. if (!this.sessionId) {
  1804. this.showLoader();
  1805. }
  1806. this.el.addClass('zammad-chat-is-open');
  1807. remainerHeight = this.el.height() - this.el.find('.zammad-chat-header').outerHeight();
  1808. this.el.css('bottom', -remainerHeight);
  1809. if (!this.sessionId) {
  1810. this.el.animate({
  1811. bottom: 0
  1812. }, 500, this.onOpenAnimationEnd);
  1813. return this.send('chat_session_init', {
  1814. url: window.location.href
  1815. });
  1816. } else {
  1817. this.el.css('bottom', 0);
  1818. return this.onOpenAnimationEnd();
  1819. }
  1820. };
  1821. ZammadChat.prototype.onOpenAnimationEnd = function() {
  1822. var base;
  1823. this.idleTimeout.stop();
  1824. if (this.isFullscreen) {
  1825. this.disableScrollOnRoot();
  1826. }
  1827. return typeof (base = this.options).onOpenAnimationEnd === "function" ? base.onOpenAnimationEnd() : void 0;
  1828. };
  1829. ZammadChat.prototype.sessionClose = function() {
  1830. this.send('chat_session_close', {
  1831. session_id: this.sessionId
  1832. });
  1833. this.inactiveTimeout.stop();
  1834. this.waitingListTimeout.stop();
  1835. sessionStorage.removeItem('unfinished_message');
  1836. if (this.onInitialQueueDelayId) {
  1837. clearTimeout(this.onInitialQueueDelayId);
  1838. }
  1839. return this.setSessionId(void 0);
  1840. };
  1841. ZammadChat.prototype.toggle = function(event) {
  1842. if (this.isOpen) {
  1843. return this.close(event);
  1844. } else {
  1845. return this.open(event);
  1846. }
  1847. };
  1848. ZammadChat.prototype.close = function(event) {
  1849. var remainerHeight;
  1850. if (!this.isOpen) {
  1851. this.log.debug('can\'t close widget, it\'s not open');
  1852. return;
  1853. }
  1854. if (this.initDelayId) {
  1855. clearTimeout(this.initDelayId);
  1856. }
  1857. if (this.sessionId) {
  1858. this.log.debug('session close before widget close');
  1859. this.sessionClose();
  1860. }
  1861. this.log.debug('close widget');
  1862. if (event) {
  1863. event.stopPropagation();
  1864. }
  1865. if (this.isFullscreen) {
  1866. this.enableScrollOnRoot();
  1867. }
  1868. remainerHeight = this.el.height() - this.el.find('.zammad-chat-header').outerHeight();
  1869. return this.el.animate({
  1870. bottom: -remainerHeight
  1871. }, 500, this.onCloseAnimationEnd);
  1872. };
  1873. ZammadChat.prototype.onCloseAnimationEnd = function() {
  1874. var base;
  1875. this.el.css('bottom', '');
  1876. this.el.removeClass('zammad-chat-is-open');
  1877. this.showLoader();
  1878. this.el.find('.zammad-chat-welcome').removeClass('zammad-chat-is-hidden');
  1879. this.el.find('.zammad-chat-agent').addClass('zammad-chat-is-hidden');
  1880. this.el.find('.zammad-chat-agent-status').addClass('zammad-chat-is-hidden');
  1881. this.isOpen = false;
  1882. if (typeof (base = this.options).onCloseAnimationEnd === "function") {
  1883. base.onCloseAnimationEnd();
  1884. }
  1885. return this.io.reconnect();
  1886. };
  1887. ZammadChat.prototype.onWebSocketClose = function() {
  1888. if (this.isOpen) {
  1889. return;
  1890. }
  1891. if (this.el) {
  1892. this.el.removeClass('zammad-chat-is-shown');
  1893. return this.el.removeClass('zammad-chat-is-loaded');
  1894. }
  1895. };
  1896. ZammadChat.prototype.show = function() {
  1897. if (this.state === 'offline') {
  1898. return;
  1899. }
  1900. this.el.addClass('zammad-chat-is-loaded');
  1901. return this.el.addClass('zammad-chat-is-shown');
  1902. };
  1903. ZammadChat.prototype.disableInput = function() {
  1904. this.inputDisabled = true;
  1905. this.input.prop('contenteditable', false);
  1906. this.el.find('.zammad-chat-send').prop('disabled', true);
  1907. return this.io.close();
  1908. };
  1909. ZammadChat.prototype.enableInput = function() {
  1910. this.inputDisabled = false;
  1911. this.input.prop('contenteditable', true);
  1912. return this.el.find('.zammad-chat-send').prop('disabled', false);
  1913. };
  1914. ZammadChat.prototype.hideModal = function() {
  1915. return this.el.find('.zammad-chat-modal').html('');
  1916. };
  1917. ZammadChat.prototype.onQueueScreen = function(data) {
  1918. var show;
  1919. this.setSessionId(data.session_id);
  1920. show = (function(_this) {
  1921. return function() {
  1922. _this.onQueue(data);
  1923. return _this.waitingListTimeout.start();
  1924. };
  1925. })(this);
  1926. if (this.initialQueueDelay && !this.onInitialQueueDelayId) {
  1927. this.onInitialQueueDelayId = setTimeout(show, this.initialQueueDelay);
  1928. return;
  1929. }
  1930. if (this.onInitialQueueDelayId) {
  1931. clearTimeout(this.onInitialQueueDelayId);
  1932. }
  1933. return show();
  1934. };
  1935. ZammadChat.prototype.onQueue = function(data) {
  1936. this.log.notice('onQueue', data.position);
  1937. this.inQueue = true;
  1938. return this.el.find('.zammad-chat-modal').html(this.view('waiting')({
  1939. position: data.position
  1940. }));
  1941. };
  1942. ZammadChat.prototype.onAgentTypingStart = function() {
  1943. if (this.stopTypingId) {
  1944. clearTimeout(this.stopTypingId);
  1945. }
  1946. this.stopTypingId = setTimeout(this.onAgentTypingEnd, 3000);
  1947. if (this.el.find('.zammad-chat-message--typing').get(0)) {
  1948. return;
  1949. }
  1950. this.maybeAddTimestamp();
  1951. this.el.find('.zammad-chat-body').append(this.view('typingIndicator')());
  1952. if (!this.isVisible(this.el.find('.zammad-chat-message--typing'), true)) {
  1953. return;
  1954. }
  1955. return this.scrollToBottom();
  1956. };
  1957. ZammadChat.prototype.onAgentTypingEnd = function() {
  1958. return this.el.find('.zammad-chat-message--typing').remove();
  1959. };
  1960. ZammadChat.prototype.onLeaveTemporary = function() {
  1961. if (!this.sessionId) {
  1962. return;
  1963. }
  1964. return this.send('chat_session_leave_temporary', {
  1965. session_id: this.sessionId
  1966. });
  1967. };
  1968. ZammadChat.prototype.maybeAddTimestamp = function() {
  1969. var label, time, timestamp;
  1970. timestamp = Date.now();
  1971. if (!this.lastTimestamp || (timestamp - this.lastTimestamp) > this.showTimeEveryXMinutes * 60000) {
  1972. label = this.T('Today');
  1973. time = new Date().toTimeString().substr(0, 5);
  1974. if (this.lastAddedType === 'timestamp') {
  1975. this.updateLastTimestamp(label, time);
  1976. return this.lastTimestamp = timestamp;
  1977. } else {
  1978. this.el.find('.zammad-chat-body').append(this.view('timestamp')({
  1979. label: label,
  1980. time: time
  1981. }));
  1982. this.lastTimestamp = timestamp;
  1983. this.lastAddedType = 'timestamp';
  1984. return this.scrollToBottom();
  1985. }
  1986. }
  1987. };
  1988. ZammadChat.prototype.updateLastTimestamp = function(label, time) {
  1989. if (!this.el) {
  1990. return;
  1991. }
  1992. return this.el.find('.zammad-chat-body').find('.zammad-chat-timestamp').last().replaceWith(this.view('timestamp')({
  1993. label: label,
  1994. time: time
  1995. }));
  1996. };
  1997. ZammadChat.prototype.addStatus = function(status) {
  1998. if (!this.el) {
  1999. return;
  2000. }
  2001. this.maybeAddTimestamp();
  2002. this.el.find('.zammad-chat-body').append(this.view('status')({
  2003. status: status
  2004. }));
  2005. return this.scrollToBottom();
  2006. };
  2007. ZammadChat.prototype.detectScrolledtoBottom = function() {
  2008. var scrollBottom;
  2009. scrollBottom = this.el.find('.zammad-chat-body').scrollTop() + this.el.find('.zammad-chat-body').outerHeight();
  2010. this.scrolledToBottom = Math.abs(scrollBottom - this.el.find('.zammad-chat-body').prop('scrollHeight')) <= this.scrollSnapTolerance;
  2011. if (this.scrolledToBottom) {
  2012. return this.el.find('.zammad-scroll-hint').addClass('is-hidden');
  2013. }
  2014. };
  2015. ZammadChat.prototype.showScrollHint = function() {
  2016. this.el.find('.zammad-scroll-hint').removeClass('is-hidden');
  2017. return this.el.find('.zammad-chat-body').scrollTop(this.el.find('.zammad-chat-body').scrollTop() + this.el.find('.zammad-scroll-hint').outerHeight());
  2018. };
  2019. ZammadChat.prototype.onScrollHintClick = function() {
  2020. return this.el.find('.zammad-chat-body').animate({
  2021. scrollTop: this.el.find('.zammad-chat-body').prop('scrollHeight')
  2022. }, 300);
  2023. };
  2024. ZammadChat.prototype.scrollToBottom = function(arg) {
  2025. var showHint;
  2026. showHint = (arg != null ? arg : {
  2027. showHint: false
  2028. }).showHint;
  2029. if (this.scrolledToBottom) {
  2030. return this.el.find('.zammad-chat-body').scrollTop($('.zammad-chat-body').prop('scrollHeight'));
  2031. } else if (showHint) {
  2032. return this.showScrollHint();
  2033. }
  2034. };
  2035. ZammadChat.prototype.destroy = function(params) {
  2036. if (params == null) {
  2037. params = {};
  2038. }
  2039. this.log.debug('destroy widget', params);
  2040. this.setAgentOnlineState('offline');
  2041. if (params.remove && this.el) {
  2042. this.el.remove();
  2043. $("." + this.options.buttonClass).hide();
  2044. }
  2045. if (this.waitingListTimeout) {
  2046. this.waitingListTimeout.stop();
  2047. }
  2048. if (this.inactiveTimeout) {
  2049. this.inactiveTimeout.stop();
  2050. }
  2051. if (this.idleTimeout) {
  2052. this.idleTimeout.stop();
  2053. }
  2054. return this.io.close();
  2055. };
  2056. ZammadChat.prototype.reconnect = function() {
  2057. this.log.notice('reconnecting');
  2058. this.disableInput();
  2059. this.lastAddedType = 'status';
  2060. this.setAgentOnlineState('connecting');
  2061. return this.addStatus(this.T('Connection lost'));
  2062. };
  2063. ZammadChat.prototype.onConnectionReestablished = function() {
  2064. var base;
  2065. this.lastAddedType = 'status';
  2066. this.setAgentOnlineState('online');
  2067. this.addStatus(this.T('Connection re-established'));
  2068. return typeof (base = this.options).onConnectionReestablished === "function" ? base.onConnectionReestablished() : void 0;
  2069. };
  2070. ZammadChat.prototype.onSessionClosed = function(data) {
  2071. var base;
  2072. this.addStatus(this.T('Chat closed by %s', data.realname));
  2073. this.disableInput();
  2074. this.setAgentOnlineState('offline');
  2075. this.inactiveTimeout.stop();
  2076. return typeof (base = this.options).onSessionClosed === "function" ? base.onSessionClosed(data) : void 0;
  2077. };
  2078. ZammadChat.prototype.setSessionId = function(id) {
  2079. this.sessionId = id;
  2080. if (id === void 0) {
  2081. return sessionStorage.removeItem('sessionId');
  2082. } else {
  2083. return sessionStorage.setItem('sessionId', id);
  2084. }
  2085. };
  2086. ZammadChat.prototype.onConnectionEstablished = function(data) {
  2087. var base;
  2088. if (this.onInitialQueueDelayId) {
  2089. clearTimeout(this.onInitialQueueDelayId);
  2090. }
  2091. this.inQueue = false;
  2092. if (data.agent) {
  2093. this.agent = data.agent;
  2094. }
  2095. if (data.session_id) {
  2096. this.setSessionId(data.session_id);
  2097. }
  2098. this.el.find('.zammad-chat-body').html('');
  2099. this.el.find('.zammad-chat-agent').html(this.view('agent')({
  2100. agent: this.agent
  2101. }));
  2102. this.enableInput();
  2103. this.hideModal();
  2104. this.el.find('.zammad-chat-welcome').addClass('zammad-chat-is-hidden');
  2105. this.el.find('.zammad-chat-agent').removeClass('zammad-chat-is-hidden');
  2106. this.el.find('.zammad-chat-agent-status').removeClass('zammad-chat-is-hidden');
  2107. if (!this.isFullscreen) {
  2108. this.input.trigger('focus');
  2109. }
  2110. this.setAgentOnlineState('online');
  2111. this.waitingListTimeout.stop();
  2112. this.idleTimeout.stop();
  2113. this.inactiveTimeout.start();
  2114. return typeof (base = this.options).onConnectionEstablished === "function" ? base.onConnectionEstablished(data) : void 0;
  2115. };
  2116. ZammadChat.prototype.showCustomerTimeout = function() {
  2117. var reload;
  2118. this.el.find('.zammad-chat-modal').html(this.view('customer_timeout')({
  2119. agent: this.agent.name,
  2120. delay: this.options.inactiveTimeout
  2121. }));
  2122. reload = function() {
  2123. return location.reload();
  2124. };
  2125. this.el.find('.js-restart').on('click', reload);
  2126. return this.sessionClose();
  2127. };
  2128. ZammadChat.prototype.showWaitingListTimeout = function() {
  2129. var reload;
  2130. this.el.find('.zammad-chat-modal').html(this.view('waiting_list_timeout')({
  2131. delay: this.options.watingListTimeout
  2132. }));
  2133. reload = function() {
  2134. return location.reload();
  2135. };
  2136. this.el.find('.js-restart').on('click', reload);
  2137. return this.sessionClose();
  2138. };
  2139. ZammadChat.prototype.showLoader = function() {
  2140. return this.el.find('.zammad-chat-modal').html(this.view('loader')());
  2141. };
  2142. ZammadChat.prototype.setAgentOnlineState = function(state) {
  2143. var capitalizedState;
  2144. this.state = state;
  2145. if (!this.el) {
  2146. return;
  2147. }
  2148. capitalizedState = state.charAt(0).toUpperCase() + state.slice(1);
  2149. return this.el.find('.zammad-chat-agent-status').attr('data-status', state).text(this.T(capitalizedState));
  2150. };
  2151. ZammadChat.prototype.detectHost = function() {
  2152. var protocol;
  2153. protocol = 'ws://';
  2154. if (scriptProtocol === 'https') {
  2155. protocol = 'wss://';
  2156. }
  2157. return this.options.host = "" + protocol + scriptHost + "/ws";
  2158. };
  2159. ZammadChat.prototype.loadCss = function() {
  2160. var newSS, styles, url;
  2161. if (!this.options.cssAutoload) {
  2162. return;
  2163. }
  2164. url = this.options.cssUrl;
  2165. if (!url) {
  2166. url = this.options.host.replace(/^wss/i, 'https').replace(/^ws/i, 'http').replace(/\/ws$/i, '');
  2167. url += '/assets/chat/chat.css';
  2168. }
  2169. this.log.debug("load css from '" + url + "'");
  2170. styles = "@import url('" + url + "');";
  2171. newSS = document.createElement('link');
  2172. newSS.onload = this.onCssLoaded;
  2173. newSS.rel = 'stylesheet';
  2174. newSS.href = 'data:text/css,' + escape(styles);
  2175. return document.getElementsByTagName('head')[0].appendChild(newSS);
  2176. };
  2177. ZammadChat.prototype.onCssLoaded = function() {
  2178. var base;
  2179. this.cssLoaded = true;
  2180. if (this.socketReady) {
  2181. this.onReady();
  2182. }
  2183. return typeof (base = this.options).onCssLoaded === "function" ? base.onCssLoaded() : void 0;
  2184. };
  2185. ZammadChat.prototype.startTimeoutObservers = function() {
  2186. this.idleTimeout = new Timeout({
  2187. logPrefix: 'idleTimeout',
  2188. debug: this.options.debug,
  2189. timeout: this.options.idleTimeout,
  2190. timeoutIntervallCheck: this.options.idleTimeoutIntervallCheck,
  2191. callback: (function(_this) {
  2192. return function() {
  2193. _this.log.debug('Idle timeout reached, hide widget', new Date);
  2194. return _this.destroy({
  2195. remove: true
  2196. });
  2197. };
  2198. })(this)
  2199. });
  2200. this.inactiveTimeout = new Timeout({
  2201. logPrefix: 'inactiveTimeout',
  2202. debug: this.options.debug,
  2203. timeout: this.options.inactiveTimeout,
  2204. timeoutIntervallCheck: this.options.inactiveTimeoutIntervallCheck,
  2205. callback: (function(_this) {
  2206. return function() {
  2207. _this.log.debug('Inactive timeout reached, show timeout screen.', new Date);
  2208. _this.showCustomerTimeout();
  2209. return _this.destroy({
  2210. remove: false
  2211. });
  2212. };
  2213. })(this)
  2214. });
  2215. return this.waitingListTimeout = new Timeout({
  2216. logPrefix: 'waitingListTimeout',
  2217. debug: this.options.debug,
  2218. timeout: this.options.waitingListTimeout,
  2219. timeoutIntervallCheck: this.options.waitingListTimeoutIntervallCheck,
  2220. callback: (function(_this) {
  2221. return function() {
  2222. _this.log.debug('Waiting list timeout reached, show timeout screen.', new Date);
  2223. _this.showWaitingListTimeout();
  2224. return _this.destroy({
  2225. remove: false
  2226. });
  2227. };
  2228. })(this)
  2229. });
  2230. };
  2231. ZammadChat.prototype.disableScrollOnRoot = function() {
  2232. this.rootScrollOffset = this.scrollRoot.scrollTop();
  2233. return this.scrollRoot.css({
  2234. overflow: 'hidden',
  2235. position: 'fixed'
  2236. });
  2237. };
  2238. ZammadChat.prototype.enableScrollOnRoot = function() {
  2239. this.scrollRoot.scrollTop(this.rootScrollOffset);
  2240. return this.scrollRoot.css({
  2241. overflow: '',
  2242. position: ''
  2243. });
  2244. };
  2245. ZammadChat.prototype.isVisible = function(el, partial, hidden, direction) {
  2246. 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;
  2247. if (el.length < 1) {
  2248. return;
  2249. }
  2250. $w = $(window);
  2251. $t = el.length > 1 ? el.eq(0) : el;
  2252. t = $t.get(0);
  2253. vpWidth = $w.width();
  2254. vpHeight = $w.height();
  2255. direction = direction ? direction : 'both';
  2256. clientSize = hidden === true ? t.offsetWidth * t.offsetHeight : true;
  2257. if (typeof t.getBoundingClientRect === 'function') {
  2258. rec = t.getBoundingClientRect();
  2259. tViz = rec.top >= 0 && rec.top < vpHeight;
  2260. bViz = rec.bottom > 0 && rec.bottom <= vpHeight;
  2261. lViz = rec.left >= 0 && rec.left < vpWidth;
  2262. rViz = rec.right > 0 && rec.right <= vpWidth;
  2263. vVisible = partial ? tViz || bViz : tViz && bViz;
  2264. hVisible = partial ? lViz || rViz : lViz && rViz;
  2265. if (direction === 'both') {
  2266. return clientSize && vVisible && hVisible;
  2267. } else if (direction === 'vertical') {
  2268. return clientSize && vVisible;
  2269. } else if (direction === 'horizontal') {
  2270. return clientSize && hVisible;
  2271. }
  2272. } else {
  2273. viewTop = $w.scrollTop();
  2274. viewBottom = viewTop + vpHeight;
  2275. viewLeft = $w.scrollLeft();
  2276. viewRight = viewLeft + vpWidth;
  2277. offset = $t.offset();
  2278. _top = offset.top;
  2279. _bottom = _top + $t.height();
  2280. _left = offset.left;
  2281. _right = _left + $t.width();
  2282. compareTop = partial === true ? _bottom : _top;
  2283. compareBottom = partial === true ? _top : _bottom;
  2284. compareLeft = partial === true ? _right : _left;
  2285. compareRight = partial === true ? _left : _right;
  2286. if (direction === 'both') {
  2287. return !!clientSize && ((compareBottom <= viewBottom) && (compareTop >= viewTop)) && ((compareRight <= viewRight) && (compareLeft >= viewLeft));
  2288. } else if (direction === 'vertical') {
  2289. return !!clientSize && ((compareBottom <= viewBottom) && (compareTop >= viewTop));
  2290. } else if (direction === 'horizontal') {
  2291. return !!clientSize && ((compareRight <= viewRight) && (compareLeft >= viewLeft));
  2292. }
  2293. }
  2294. };
  2295. ZammadChat.prototype.isRetina = function() {
  2296. var mq;
  2297. if (window.matchMedia) {
  2298. 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)');
  2299. return mq && mq.matches || (window.devicePixelRatio > 1);
  2300. }
  2301. return false;
  2302. };
  2303. ZammadChat.prototype.resizeImage = function(dataURL, x, y, sizeFactor, type, quallity, callback, force) {
  2304. var imageObject;
  2305. if (x == null) {
  2306. x = 'auto';
  2307. }
  2308. if (y == null) {
  2309. y = 'auto';
  2310. }
  2311. if (sizeFactor == null) {
  2312. sizeFactor = 1;
  2313. }
  2314. if (force == null) {
  2315. force = true;
  2316. }
  2317. imageObject = new Image();
  2318. imageObject.onload = function() {
  2319. var canvas, context, factor, imageHeight, imageWidth, newDataUrl, resize;
  2320. imageWidth = imageObject.width;
  2321. imageHeight = imageObject.height;
  2322. console.log('ImageService', 'current size', imageWidth, imageHeight);
  2323. if (y === 'auto' && x === 'auto') {
  2324. x = imageWidth;
  2325. y = imageHeight;
  2326. }
  2327. if (y === 'auto') {
  2328. factor = imageWidth / x;
  2329. y = imageHeight / factor;
  2330. }
  2331. if (x === 'auto') {
  2332. factor = imageWidth / y;
  2333. x = imageHeight / factor;
  2334. }
  2335. resize = false;
  2336. if (x < imageWidth || y < imageHeight) {
  2337. resize = true;
  2338. x = x * sizeFactor;
  2339. y = y * sizeFactor;
  2340. } else {
  2341. x = imageWidth;
  2342. y = imageHeight;
  2343. }
  2344. canvas = document.createElement('canvas');
  2345. canvas.width = x;
  2346. canvas.height = y;
  2347. context = canvas.getContext('2d');
  2348. context.drawImage(imageObject, 0, 0, x, y);
  2349. if (quallity === 'auto') {
  2350. if (x < 200 && y < 200) {
  2351. quallity = 1;
  2352. } else if (x < 400 && y < 400) {
  2353. quallity = 0.9;
  2354. } else if (x < 600 && y < 600) {
  2355. quallity = 0.8;
  2356. } else if (x < 900 && y < 900) {
  2357. quallity = 0.7;
  2358. } else {
  2359. quallity = 0.6;
  2360. }
  2361. }
  2362. newDataUrl = canvas.toDataURL(type, quallity);
  2363. if (resize) {
  2364. console.log('ImageService', 'resize', x / sizeFactor, y / sizeFactor, quallity, (newDataUrl.length * 0.75) / 1024 / 1024, 'in mb');
  2365. callback(newDataUrl, x / sizeFactor, y / sizeFactor, true);
  2366. return;
  2367. }
  2368. console.log('ImageService', 'no resize', x, y, quallity, (newDataUrl.length * 0.75) / 1024 / 1024, 'in mb');
  2369. return callback(newDataUrl, x, y, false);
  2370. };
  2371. return imageObject.src = dataURL;
  2372. };
  2373. ZammadChat.prototype.pasteHtmlAtCaret = function(html) {
  2374. var el, frag, lastNode, node, range, sel;
  2375. sel = void 0;
  2376. range = void 0;
  2377. if (window.getSelection) {
  2378. sel = window.getSelection();
  2379. if (sel.getRangeAt && sel.rangeCount) {
  2380. range = sel.getRangeAt(0);
  2381. range.deleteContents();
  2382. el = document.createElement('div');
  2383. el.innerHTML = html;
  2384. frag = document.createDocumentFragment(node, lastNode);
  2385. while (node = el.firstChild) {
  2386. lastNode = frag.appendChild(node);
  2387. }
  2388. range.insertNode(frag);
  2389. if (lastNode) {
  2390. range = range.cloneRange();
  2391. range.setStartAfter(lastNode);
  2392. range.collapse(true);
  2393. sel.removeAllRanges();
  2394. return sel.addRange(range);
  2395. }
  2396. }
  2397. } else if (document.selection && document.selection.type !== 'Control') {
  2398. return document.selection.createRange().pasteHTML(html);
  2399. }
  2400. };
  2401. ZammadChat.prototype.wordFilter = function(editor) {
  2402. var content, last_level, pnt;
  2403. content = editor.html();
  2404. content = content.replace(/<!--[\s\S]+?-->/gi, '');
  2405. content = content.replace(/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi, '');
  2406. content = content.replace(/<(\/?)s>/gi, '<$1strike>');
  2407. content = content.replace(/&nbsp;/gi, ' ');
  2408. editor.html(content);
  2409. $('p', editor).each(function() {
  2410. var matches, str;
  2411. str = $(this).attr('style');
  2412. matches = /mso-list:\w+ \w+([0-9]+)/.exec(str);
  2413. if (matches) {
  2414. return $(this).data('_listLevel', parseInt(matches[1], 10));
  2415. }
  2416. });
  2417. last_level = 0;
  2418. pnt = null;
  2419. $('p', editor).each(function() {
  2420. var cur_level, i, j, list_tag, matches, ref, ref1, ref2, start, txt;
  2421. cur_level = $(this).data('_listLevel');
  2422. if (cur_level !== void 0) {
  2423. txt = $(this).text();
  2424. list_tag = '<ul></ul>';
  2425. if (/^\s*\w+\./.test(txt)) {
  2426. matches = /([0-9])\./.exec(txt);
  2427. if (matches) {
  2428. start = parseInt(matches[1], 10);
  2429. list_tag = (ref = start > 1) != null ? ref : '<ol start="' + start + {
  2430. '"></ol>': '<ol></ol>'
  2431. };
  2432. } else {
  2433. list_tag = '<ol></ol>';
  2434. }
  2435. }
  2436. if (cur_level > last_level) {
  2437. if (last_level === 0) {
  2438. $(this).before(list_tag);
  2439. pnt = $(this).prev();
  2440. } else {
  2441. pnt = $(list_tag).appendTo(pnt);
  2442. }
  2443. }
  2444. if (cur_level < last_level) {
  2445. for (i = j = ref1 = i, ref2 = last_level - cur_level; ref1 <= ref2 ? j <= ref2 : j >= ref2; i = ref1 <= ref2 ? ++j : --j) {
  2446. pnt = pnt.parent();
  2447. }
  2448. }
  2449. $('span:first', this).remove();
  2450. pnt.append('<li>' + $(this).html() + '</li>');
  2451. $(this).remove();
  2452. return last_level = cur_level;
  2453. } else {
  2454. return last_level = 0;
  2455. }
  2456. });
  2457. $('[style]', editor).removeAttr('style');
  2458. $('[align]', editor).removeAttr('align');
  2459. $('span', editor).replaceWith(function() {
  2460. return $(this).contents();
  2461. });
  2462. $('span:empty', editor).remove();
  2463. $("[class^='Mso']", editor).removeAttr('class');
  2464. $('p:empty', editor).remove();
  2465. return editor;
  2466. };
  2467. ZammadChat.prototype.removeAttribute = function(element) {
  2468. var $element, att, j, len, ref;
  2469. if (!element) {
  2470. return;
  2471. }
  2472. $element = $(element);
  2473. ref = element.attributes;
  2474. for (j = 0, len = ref.length; j < len; j++) {
  2475. att = ref[j];
  2476. if (att && att.name) {
  2477. element.removeAttribute(att.name);
  2478. }
  2479. }
  2480. return $element.removeAttr('style').removeAttr('class').removeAttr('lang').removeAttr('type').removeAttr('align').removeAttr('id').removeAttr('wrap').removeAttr('title');
  2481. };
  2482. ZammadChat.prototype.removeAttributes = function(html, parent) {
  2483. if (parent == null) {
  2484. parent = true;
  2485. }
  2486. if (parent) {
  2487. html.each((function(_this) {
  2488. return function(index, element) {
  2489. return _this.removeAttribute(element);
  2490. };
  2491. })(this));
  2492. }
  2493. html.find('*').each((function(_this) {
  2494. return function(index, element) {
  2495. return _this.removeAttribute(element);
  2496. };
  2497. })(this));
  2498. return html;
  2499. };
  2500. return ZammadChat;
  2501. })(Base);
  2502. return window.ZammadChat = ZammadChat;
  2503. })(window.jQuery, window);