chat.js 117 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663
  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…': 'Ecrivez 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.': '',
  926. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  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!': '',
  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 kolege 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': 'Š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, proces traje duže nego što se očekivalo da biste dobili slobodan termin. Molimo, pokušajte ponovno kasnije ili nam pošaljite e-mail. Hvala!',
  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. 'nl': {
  990. '<strong>Chat</strong> with us!': '<strong>Chat</strong> met ons!',
  991. 'All colleagues are busy.': 'Alle collega\'s zijn bezet.',
  992. 'Chat closed by %s': 'Chat gesloten door %s',
  993. 'Compose your message…': 'Stel je bericht op…',
  994. 'Connecting': 'Verbinden',
  995. 'Connection lost': 'Verbinding verbroken',
  996. 'Connection re-established': 'Verbinding hersteld',
  997. 'Offline': 'Offline',
  998. 'Online': 'Online',
  999. 'Scroll down to see new messages': 'Scroll naar beneden om nieuwe tickets te bekijken',
  1000. 'Send': 'Verstuur',
  1001. '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.',
  1002. '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.',
  1003. 'Start new conversation': 'Nieuw gesprek starten',
  1004. 'Today': 'Vandaag',
  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!': '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!',
  1006. 'You are on waiting list position <strong>%s</strong>.': 'Je bevindt zich op wachtlijstpositie <strong>%s</strong>.'
  1007. },
  1008. 'pl': {
  1009. '<strong>Chat</strong> with us!': '<strong>Czatuj</strong> z nami!',
  1010. 'All colleagues are busy.': 'Wszyscy agenci są zajęci.',
  1011. 'Chat closed by %s': 'Chat zamknięty przez %s',
  1012. 'Compose your message…': 'Skomponuj swoją wiadomość…',
  1013. 'Connecting': 'Łączenie',
  1014. 'Connection lost': 'Utracono połączenie',
  1015. 'Connection re-established': 'Ponowne nawiązanie połączenia',
  1016. 'Offline': 'Offline',
  1017. 'Online': 'Online',
  1018. 'Scroll down to see new messages': 'Skroluj w dół, aby zobaczyć wiadomości',
  1019. 'Send': 'Wyślij',
  1020. '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.',
  1021. '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.',
  1022. 'Start new conversation': 'Rozpocznij nową rozmowę',
  1023. 'Today': 'Dzisiaj',
  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!': 'Przepraszamy, znalezienie wolnego konsultanta zajmuje więcej czasu niż oczekiwano. Spróbuj ponownie później lub wyślij nam e-mail. Dziękujemy!',
  1025. 'You are on waiting list position <strong>%s</strong>.': 'Jesteś na pozycji listy oczekujących <strong>%s</strong>.'
  1026. },
  1027. 'pt-br': {
  1028. '<strong>Chat</strong> with us!': '<strong>Converse</strong> conosco!',
  1029. 'All colleagues are busy.': 'Nossos atendentes estão ocupados.',
  1030. 'Chat closed by %s': 'Chat encerrado por %s',
  1031. 'Compose your message…': 'Escreva sua mensagem…',
  1032. 'Connecting': 'Conectando',
  1033. 'Connection lost': 'Conexão perdida',
  1034. 'Connection re-established': 'Conexão restabelecida',
  1035. 'Offline': 'Desconectado',
  1036. 'Online': 'Online',
  1037. 'Scroll down to see new messages': 'Rolar para baixo para ver novas mensagems',
  1038. 'Send': 'Enviar',
  1039. '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.',
  1040. '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.',
  1041. 'Start new conversation': 'Iniciar uma nova conversa',
  1042. 'Today': 'Hoje',
  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!': 'Lamentamos, está demorando mais do que o esperado para conseguir uma vaga. Tente novamente mais tarde ou envie-nos um e-mail. Obrigado!',
  1044. 'You are on waiting list position <strong>%s</strong>.': 'Você está na posição <strong>%s</strong> da lista de espera.'
  1045. },
  1046. 'ru': {
  1047. '<strong>Chat</strong> with us!': '<strong>Напишите</strong> нам!',
  1048. 'All colleagues are busy.': 'Все коллеги заняты.',
  1049. 'Chat closed by %s': 'Чат закрыт %s',
  1050. 'Compose your message…': 'Составьте сообщение…',
  1051. 'Connecting': 'Подключение',
  1052. 'Connection lost': 'Подключение потеряно',
  1053. 'Connection re-established': 'Подключение восстановлено',
  1054. 'Offline': 'Оффлайн',
  1055. 'Online': 'В сети',
  1056. 'Scroll down to see new messages': 'Прокрутите вниз, чтобы увидеть новые сообщения',
  1057. 'Send': 'Отправить',
  1058. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  1059. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  1060. 'Start new conversation': 'Начать новую беседу',
  1061. 'Today': 'Сегодня',
  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!': '',
  1063. 'You are on waiting list position <strong>%s</strong>.': 'Вы находитесь в списке ожидания <strong>%s</strong>.'
  1064. },
  1065. 'sr': {
  1066. '<strong>Chat</strong> with us!': '<strong>Ћаскајте</strong> са нама!',
  1067. 'All colleagues are busy.': 'Све колеге су заузете.',
  1068. 'Chat closed by %s': 'Ћаскање затворено од стране %s',
  1069. 'Compose your message…': 'Напишите поруку…',
  1070. 'Connecting': 'Повезивање',
  1071. 'Connection lost': 'Веза је изгубљена',
  1072. 'Connection re-established': 'Веза је поново успостављена',
  1073. 'Offline': 'Одсутан(а)',
  1074. 'Online': 'Доступан(а)',
  1075. 'Scroll down to see new messages': 'Скролујте на доле за нове поруке',
  1076. 'Send': 'Пошаљи',
  1077. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': 'Пошто нисте одговорили у последњих %s минут(a), ваш разговор је завршен.',
  1078. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': 'Пошто нисте одговорили у последњих %s минут(a), ваш разговор са <strong>%s</strong> је завршен.',
  1079. 'Start new conversation': 'Започни нови разговор',
  1080. 'Today': 'Данас',
  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!': 'Жао нам је, добијање празног термина траје дуже од очекиваног. Молимо покушајте поново касније или нам пошаљите имејл поруку. Хвала вам!',
  1082. 'You are on waiting list position <strong>%s</strong>.': 'Ви сте тренутно <strong>%s.</strong> у реду за чекање.'
  1083. },
  1084. 'sr-latn-rs': {
  1085. '<strong>Chat</strong> with us!': '<strong>Ćaskajte</strong> sa nama!',
  1086. 'All colleagues are busy.': 'Sve kolege su zauzete.',
  1087. 'Chat closed by %s': 'Ćaskanje zatvoreno od strane %s',
  1088. 'Compose your message…': 'Napišite poruku…',
  1089. 'Connecting': 'Povezivanje',
  1090. 'Connection lost': 'Veza je izgubljena',
  1091. 'Connection re-established': 'Veza je ponovo uspostavljena',
  1092. 'Offline': 'Odsutan(a)',
  1093. 'Online': 'Dostupan(a)',
  1094. 'Scroll down to see new messages': 'Skrolujte na dole za nove poruke',
  1095. 'Send': 'Pošalji',
  1096. '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.',
  1097. '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.',
  1098. 'Start new conversation': 'Započni novi razgovor',
  1099. 'Today': 'Danas',
  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!': 'Ž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!',
  1101. 'You are on waiting list position <strong>%s</strong>.': 'Vi ste trenutno <strong>%s.</strong> u redu za čekanje.'
  1102. },
  1103. 'sv': {
  1104. '<strong>Chat</strong> with us!': '<strong>Chatta</strong> med oss!',
  1105. 'All colleagues are busy.': 'Alla kollegor är upptagna.',
  1106. 'Chat closed by %s': 'Chatt stängd av %s',
  1107. 'Compose your message…': 'Skriv ditt meddelande …',
  1108. 'Connecting': 'Ansluter',
  1109. 'Connection lost': 'Anslutningen försvann',
  1110. 'Connection re-established': 'Anslutningen återupprättas',
  1111. 'Offline': 'Offline',
  1112. 'Online': 'Online',
  1113. 'Scroll down to see new messages': 'Bläddra ner för att se nya meddelanden',
  1114. 'Send': 'Skicka',
  1115. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  1116. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  1117. 'Start new conversation': 'Starta ny konversation',
  1118. 'Today': 'Idag',
  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!': '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!',
  1120. 'You are on waiting list position <strong>%s</strong>.': 'Du är på väntelistan som position <strong>%s</strong>.'
  1121. },
  1122. 'zh-cn': {
  1123. '<strong>Chat</strong> with us!': '发起<strong>即时对话</strong>!',
  1124. 'All colleagues are busy.': '所有同事都很忙。',
  1125. 'Chat closed by %s': '对话被 %s 终止',
  1126. 'Compose your message…': '编辑您的信息…',
  1127. 'Connecting': '连接中',
  1128. 'Connection lost': '连接丢失',
  1129. 'Connection re-established': '正在重新建立连接',
  1130. 'Offline': '离线',
  1131. 'Online': '在线',
  1132. 'Scroll down to see new messages': '向下滚动以查看新消息',
  1133. 'Send': '发送',
  1134. 'Since you didn\'t respond in the last %s minutes your conversation was closed.': '',
  1135. 'Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> was closed.': '',
  1136. 'Start new conversation': '开始新的会话',
  1137. 'Today': '今天',
  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!': '',
  1139. 'You are on waiting list position <strong>%s</strong>.': '您目前的等候位置是第 <strong>%s</strong> 位.'
  1140. }
  1141. };
  1142. ZammadChat.prototype.sessionId = void 0;
  1143. ZammadChat.prototype.scrolledToBottom = true;
  1144. ZammadChat.prototype.scrollSnapTolerance = 10;
  1145. ZammadChat.prototype.richTextFormatKey = {
  1146. 66: true,
  1147. 73: true,
  1148. 85: true,
  1149. 83: true
  1150. };
  1151. ZammadChat.prototype.T = function() {
  1152. var item, items, j, len, string, translations;
  1153. string = arguments[0], items = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  1154. if (this.options.lang && this.options.lang !== 'en') {
  1155. if (!this.translations[this.options.lang]) {
  1156. this.log.notice("Translation '" + this.options.lang + "' needed!");
  1157. } else {
  1158. translations = this.translations[this.options.lang];
  1159. if (!translations[string]) {
  1160. this.log.notice("Translation needed for '" + string + "'");
  1161. }
  1162. string = translations[string] || string;
  1163. }
  1164. }
  1165. if (items) {
  1166. for (j = 0, len = items.length; j < len; j++) {
  1167. item = items[j];
  1168. string = string.replace(/%s/, item);
  1169. }
  1170. }
  1171. return string;
  1172. };
  1173. ZammadChat.prototype.view = function(name) {
  1174. return (function(_this) {
  1175. return function(options) {
  1176. if (!options) {
  1177. options = {};
  1178. }
  1179. options.T = _this.T;
  1180. options.background = _this.options.background;
  1181. options.flat = _this.options.flat;
  1182. options.fontSize = _this.options.fontSize;
  1183. return window.zammadChatTemplates[name](options);
  1184. };
  1185. })(this);
  1186. };
  1187. function ZammadChat(options) {
  1188. this.removeAttributes = bind(this.removeAttributes, this);
  1189. this.startTimeoutObservers = bind(this.startTimeoutObservers, this);
  1190. this.onCssLoaded = bind(this.onCssLoaded, this);
  1191. this.setAgentOnlineState = bind(this.setAgentOnlineState, this);
  1192. this.onConnectionEstablished = bind(this.onConnectionEstablished, this);
  1193. this.setSessionId = bind(this.setSessionId, this);
  1194. this.onConnectionReestablished = bind(this.onConnectionReestablished, this);
  1195. this.reconnect = bind(this.reconnect, this);
  1196. this.destroy = bind(this.destroy, this);
  1197. this.onScrollHintClick = bind(this.onScrollHintClick, this);
  1198. this.detectScrolledtoBottom = bind(this.detectScrolledtoBottom, this);
  1199. this.onLeaveTemporary = bind(this.onLeaveTemporary, this);
  1200. this.onAgentTypingEnd = bind(this.onAgentTypingEnd, this);
  1201. this.onAgentTypingStart = bind(this.onAgentTypingStart, this);
  1202. this.onQueue = bind(this.onQueue, this);
  1203. this.onQueueScreen = bind(this.onQueueScreen, this);
  1204. this.onWebSocketClose = bind(this.onWebSocketClose, this);
  1205. this.onCloseAnimationEnd = bind(this.onCloseAnimationEnd, this);
  1206. this.close = bind(this.close, this);
  1207. this.toggle = bind(this.toggle, this);
  1208. this.sessionClose = bind(this.sessionClose, this);
  1209. this.onOpenAnimationEnd = bind(this.onOpenAnimationEnd, this);
  1210. this.open = bind(this.open, this);
  1211. this.renderMessage = bind(this.renderMessage, this);
  1212. this.receiveMessage = bind(this.receiveMessage, this);
  1213. this.onSubmit = bind(this.onSubmit, this);
  1214. this.onFocus = bind(this.onFocus, this);
  1215. this.onInput = bind(this.onInput, this);
  1216. this.onReopenSession = bind(this.onReopenSession, this);
  1217. this.onError = bind(this.onError, this);
  1218. this.onWebSocketMessage = bind(this.onWebSocketMessage, this);
  1219. this.send = bind(this.send, this);
  1220. this.checkForEnter = bind(this.checkForEnter, this);
  1221. this.render = bind(this.render, this);
  1222. this.view = bind(this.view, this);
  1223. this.T = bind(this.T, this);
  1224. this.options = $.extend({}, this.defaults, options);
  1225. ZammadChat.__super__.constructor.call(this, this.options);
  1226. this.isFullscreen = window.matchMedia && window.matchMedia('(max-width: 768px)').matches;
  1227. this.scrollRoot = $(this.getScrollRoot());
  1228. if (!$) {
  1229. this.state = 'unsupported';
  1230. this.log.notice('Chat: no jquery found!');
  1231. return;
  1232. }
  1233. if (!window.WebSocket || !sessionStorage) {
  1234. this.state = 'unsupported';
  1235. this.log.notice('Chat: Browser not supported!');
  1236. return;
  1237. }
  1238. if (!this.options.chatId) {
  1239. this.state = 'unsupported';
  1240. this.log.error('Chat: need chatId as option!');
  1241. return;
  1242. }
  1243. if (!this.options.lang) {
  1244. this.options.lang = $('html').attr('lang');
  1245. }
  1246. if (this.options.lang) {
  1247. if (!this.translations[this.options.lang]) {
  1248. this.log.debug("lang: No " + this.options.lang + " found, try first two letters");
  1249. this.options.lang = this.options.lang.replace(/-.+?$/, '');
  1250. }
  1251. this.log.debug("lang: " + this.options.lang);
  1252. }
  1253. if (!this.options.host) {
  1254. this.detectHost();
  1255. }
  1256. this.loadCss();
  1257. this.io = new Io(this.options);
  1258. this.io.set({
  1259. onOpen: this.render,
  1260. onClose: this.onWebSocketClose,
  1261. onMessage: this.onWebSocketMessage,
  1262. onError: this.onError
  1263. });
  1264. this.io.connect();
  1265. }
  1266. ZammadChat.prototype.getScrollRoot = function() {
  1267. var end, html, start;
  1268. if ('scrollingElement' in document) {
  1269. return document.scrollingElement;
  1270. }
  1271. html = document.documentElement;
  1272. start = html.scrollTop;
  1273. html.scrollTop = start + 1;
  1274. end = html.scrollTop;
  1275. html.scrollTop = start;
  1276. if (end > start) {
  1277. return html;
  1278. } else {
  1279. return document.body;
  1280. }
  1281. };
  1282. ZammadChat.prototype.render = function() {
  1283. if (!this.el || !$('.zammad-chat').get(0)) {
  1284. this.renderBase();
  1285. }
  1286. $("." + this.options.buttonClass).addClass(this.options.inactiveClass);
  1287. this.setAgentOnlineState('online');
  1288. this.log.debug('widget rendered');
  1289. this.startTimeoutObservers();
  1290. this.idleTimeout.start();
  1291. this.sessionId = sessionStorage.getItem('sessionId');
  1292. return this.send('chat_status_customer', {
  1293. session_id: this.sessionId,
  1294. url: window.location.href
  1295. });
  1296. };
  1297. ZammadChat.prototype.renderBase = function() {
  1298. this.el = $(this.view('chat')({
  1299. title: this.options.title,
  1300. scrollHint: this.options.scrollHint
  1301. }));
  1302. this.options.target.append(this.el);
  1303. this.input = this.el.find('.zammad-chat-input');
  1304. this.el.find('.js-chat-open').on('click', this.open);
  1305. this.el.find('.js-chat-toggle').on('click', this.toggle);
  1306. this.el.find('.js-chat-status').on('click', this.stopPropagation);
  1307. this.el.find('.zammad-chat-controls').on('submit', this.onSubmit);
  1308. this.el.find('.zammad-chat-body').on('scroll', this.detectScrolledtoBottom);
  1309. this.el.find('.zammad-scroll-hint').on('click', this.onScrollHintClick);
  1310. this.input.on({
  1311. keydown: this.checkForEnter,
  1312. input: this.onInput
  1313. });
  1314. this.input.on('keydown', (function(_this) {
  1315. return function(e) {
  1316. var richtTextControl;
  1317. richtTextControl = false;
  1318. if (!e.altKey && !e.ctrlKey && e.metaKey) {
  1319. richtTextControl = true;
  1320. } else if (!e.altKey && e.ctrlKey && !e.metaKey) {
  1321. richtTextControl = true;
  1322. }
  1323. if (richtTextControl && _this.richTextFormatKey[e.keyCode]) {
  1324. e.preventDefault();
  1325. if (e.keyCode === 66) {
  1326. document.execCommand('bold');
  1327. return true;
  1328. }
  1329. if (e.keyCode === 73) {
  1330. document.execCommand('italic');
  1331. return true;
  1332. }
  1333. if (e.keyCode === 85) {
  1334. document.execCommand('underline');
  1335. return true;
  1336. }
  1337. if (e.keyCode === 83) {
  1338. document.execCommand('strikeThrough');
  1339. return true;
  1340. }
  1341. }
  1342. };
  1343. })(this));
  1344. this.input.on('paste', (function(_this) {
  1345. return function(e) {
  1346. var clipboardData, docType, html, htmlTmp, imageFile, imageInserted, item, match, reader, regex, replacementTag, sanitized, text;
  1347. e.stopPropagation();
  1348. e.preventDefault();
  1349. clipboardData;
  1350. if (e.clipboardData) {
  1351. clipboardData = e.clipboardData;
  1352. } else if (window.clipboardData) {
  1353. clipboardData = window.clipboardData;
  1354. } else if (e.originalEvent.clipboardData) {
  1355. clipboardData = e.originalEvent.clipboardData;
  1356. } else {
  1357. throw 'No clipboardData support';
  1358. }
  1359. imageInserted = false;
  1360. if (clipboardData && clipboardData.items && clipboardData.items[0]) {
  1361. item = clipboardData.items[0];
  1362. if (item.kind === 'file' && (item.type === 'image/png' || item.type === 'image/jpeg')) {
  1363. imageFile = item.getAsFile();
  1364. reader = new FileReader();
  1365. reader.onload = function(e) {
  1366. var img, insert, result;
  1367. result = e.target.result;
  1368. img = document.createElement('img');
  1369. img.src = result;
  1370. insert = function(dataUrl, width, height, isRetina) {
  1371. if (_this.isRetina()) {
  1372. width = width / 2;
  1373. height = height / 2;
  1374. }
  1375. result = dataUrl;
  1376. img = "<img style=\"width: 100%; max-width: " + width + "px;\" src=\"" + result + "\">";
  1377. return document.execCommand('insertHTML', false, img);
  1378. };
  1379. return _this.resizeImage(img.src, 460, 'auto', 2, 'image/jpeg', 'auto', insert);
  1380. };
  1381. reader.readAsDataURL(imageFile);
  1382. imageInserted = true;
  1383. }
  1384. }
  1385. if (imageInserted) {
  1386. return;
  1387. }
  1388. text = void 0;
  1389. docType = void 0;
  1390. try {
  1391. text = clipboardData.getData('text/html');
  1392. docType = 'html';
  1393. if (!text || text.length === 0) {
  1394. docType = 'text';
  1395. text = clipboardData.getData('text/plain');
  1396. }
  1397. if (!text || text.length === 0) {
  1398. docType = 'text2';
  1399. text = clipboardData.getData('text');
  1400. }
  1401. } catch (error) {
  1402. e = error;
  1403. console.log('Sorry, can\'t insert markup because browser is not supporting it.');
  1404. docType = 'text3';
  1405. text = clipboardData.getData('text');
  1406. }
  1407. if (docType === 'text' || docType === 'text2' || docType === 'text3') {
  1408. text = '<div>' + text.replace(/\n/g, '</div><div>') + '</div>';
  1409. text = text.replace(/<div><\/div>/g, '<div><br></div>');
  1410. }
  1411. console.log('p', docType, text);
  1412. if (docType === 'html') {
  1413. sanitized = DOMPurify.sanitize(text);
  1414. _this.log.debug('sanitized HTML clipboard', sanitized);
  1415. html = $("<div>" + sanitized + "</div>");
  1416. match = false;
  1417. htmlTmp = text;
  1418. regex = new RegExp('<(/w|w)\:[A-Za-z]');
  1419. if (htmlTmp.match(regex)) {
  1420. match = true;
  1421. htmlTmp = htmlTmp.replace(regex, '');
  1422. }
  1423. regex = new RegExp('<(/o|o)\:[A-Za-z]');
  1424. if (htmlTmp.match(regex)) {
  1425. match = true;
  1426. htmlTmp = htmlTmp.replace(regex, '');
  1427. }
  1428. if (match) {
  1429. html = _this.wordFilter(html);
  1430. }
  1431. html = $(html);
  1432. html.contents().each(function() {
  1433. if (this.nodeType === 8) {
  1434. return $(this).remove();
  1435. }
  1436. });
  1437. html.find('a, font, small, time, form, label').replaceWith(function() {
  1438. return $(this).contents();
  1439. });
  1440. replacementTag = 'div';
  1441. html.find('textarea').each(function() {
  1442. var newTag, outer;
  1443. outer = this.outerHTML;
  1444. regex = new RegExp('<' + this.tagName, 'i');
  1445. newTag = outer.replace(regex, '<' + replacementTag);
  1446. regex = new RegExp('</' + this.tagName, 'i');
  1447. newTag = newTag.replace(regex, '</' + replacementTag);
  1448. return $(this).replaceWith(newTag);
  1449. });
  1450. html.find('font, img, svg, input, select, button, style, applet, embed, noframes, canvas, script, frame, iframe, meta, link, title, head, fieldset').remove();
  1451. _this.removeAttributes(html);
  1452. text = html.html();
  1453. }
  1454. if (docType === 'text3') {
  1455. _this.pasteHtmlAtCaret(text);
  1456. } else {
  1457. document.execCommand('insertHTML', false, text);
  1458. }
  1459. return true;
  1460. };
  1461. })(this));
  1462. this.input.on('drop', (function(_this) {
  1463. return function(e) {
  1464. var dataTransfer, file, reader, x, y;
  1465. e.stopPropagation();
  1466. e.preventDefault();
  1467. dataTransfer;
  1468. if (window.dataTransfer) {
  1469. dataTransfer = window.dataTransfer;
  1470. } else if (e.originalEvent.dataTransfer) {
  1471. dataTransfer = e.originalEvent.dataTransfer;
  1472. } else {
  1473. throw 'No clipboardData support';
  1474. }
  1475. x = e.clientX;
  1476. y = e.clientY;
  1477. file = dataTransfer.files[0];
  1478. if (file.type.match('image.*')) {
  1479. reader = new FileReader();
  1480. reader.onload = function(e) {
  1481. var img, insert, result;
  1482. result = e.target.result;
  1483. img = document.createElement('img');
  1484. img.src = result;
  1485. insert = function(dataUrl, width, height, isRetina) {
  1486. var pos, range;
  1487. if (_this.isRetina()) {
  1488. width = width / 2;
  1489. height = height / 2;
  1490. }
  1491. result = dataUrl;
  1492. img = $("<img style=\"width: 100%; max-width: " + width + "px;\" src=\"" + result + "\">");
  1493. img = img.get(0);
  1494. if (document.caretPositionFromPoint) {
  1495. pos = document.caretPositionFromPoint(x, y);
  1496. range = document.createRange();
  1497. range.setStart(pos.offsetNode, pos.offset);
  1498. range.collapse();
  1499. return range.insertNode(img);
  1500. } else if (document.caretRangeFromPoint) {
  1501. range = document.caretRangeFromPoint(x, y);
  1502. return range.insertNode(img);
  1503. } else {
  1504. return console.log('could not find carat');
  1505. }
  1506. };
  1507. return _this.resizeImage(img.src, 460, 'auto', 2, 'image/jpeg', 'auto', insert);
  1508. };
  1509. return reader.readAsDataURL(file);
  1510. }
  1511. };
  1512. })(this));
  1513. $(window).on('beforeunload', (function(_this) {
  1514. return function() {
  1515. return _this.onLeaveTemporary();
  1516. };
  1517. })(this));
  1518. $(window).on('hashchange', (function(_this) {
  1519. return function() {
  1520. if (_this.isOpen) {
  1521. if (_this.sessionId) {
  1522. _this.send('chat_session_notice', {
  1523. session_id: _this.sessionId,
  1524. message: window.location.href
  1525. });
  1526. }
  1527. return;
  1528. }
  1529. return _this.idleTimeout.start();
  1530. };
  1531. })(this));
  1532. if (this.isFullscreen) {
  1533. return this.input.on({
  1534. focus: this.onFocus,
  1535. focusout: this.onFocusOut
  1536. });
  1537. }
  1538. };
  1539. ZammadChat.prototype.stopPropagation = function(event) {
  1540. return event.stopPropagation();
  1541. };
  1542. ZammadChat.prototype.checkForEnter = function(event) {
  1543. if (!this.inputDisabled && !event.shiftKey && event.keyCode === 13) {
  1544. event.preventDefault();
  1545. return this.sendMessage();
  1546. }
  1547. };
  1548. ZammadChat.prototype.send = function(event, data) {
  1549. if (data == null) {
  1550. data = {};
  1551. }
  1552. data.chat_id = this.options.chatId;
  1553. return this.io.send(event, data);
  1554. };
  1555. ZammadChat.prototype.onWebSocketMessage = function(pipes) {
  1556. var j, len, pipe;
  1557. for (j = 0, len = pipes.length; j < len; j++) {
  1558. pipe = pipes[j];
  1559. this.log.debug('ws:onmessage', pipe);
  1560. switch (pipe.event) {
  1561. case 'chat_error':
  1562. this.log.notice(pipe.data);
  1563. if (pipe.data && pipe.data.state === 'chat_disabled') {
  1564. this.destroy({
  1565. remove: true
  1566. });
  1567. }
  1568. break;
  1569. case 'chat_session_message':
  1570. if (pipe.data.self_written) {
  1571. return;
  1572. }
  1573. this.receiveMessage(pipe.data);
  1574. break;
  1575. case 'chat_session_typing':
  1576. if (pipe.data.self_written) {
  1577. return;
  1578. }
  1579. this.onAgentTypingStart();
  1580. break;
  1581. case 'chat_session_start':
  1582. this.onConnectionEstablished(pipe.data);
  1583. break;
  1584. case 'chat_session_queue':
  1585. this.onQueueScreen(pipe.data);
  1586. break;
  1587. case 'chat_session_closed':
  1588. this.onSessionClosed(pipe.data);
  1589. break;
  1590. case 'chat_session_left':
  1591. this.onSessionClosed(pipe.data);
  1592. break;
  1593. case 'chat_session_notice':
  1594. this.addStatus(this.T(pipe.data.message));
  1595. break;
  1596. case 'chat_status_customer':
  1597. switch (pipe.data.state) {
  1598. case 'online':
  1599. this.sessionId = void 0;
  1600. if (!this.options.cssAutoload || this.cssLoaded) {
  1601. this.onReady();
  1602. } else {
  1603. this.socketReady = true;
  1604. }
  1605. break;
  1606. case 'offline':
  1607. this.onError('Zammad Chat: No agent online');
  1608. break;
  1609. case 'chat_disabled':
  1610. this.onError('Zammad Chat: Chat is disabled');
  1611. break;
  1612. case 'no_seats_available':
  1613. this.onError("Zammad Chat: Too many clients in queue. Clients in queue: " + pipe.data.queue);
  1614. break;
  1615. case 'reconnect':
  1616. this.onReopenSession(pipe.data);
  1617. }
  1618. }
  1619. }
  1620. };
  1621. ZammadChat.prototype.onReady = function() {
  1622. var base;
  1623. this.log.debug('widget ready for use');
  1624. $("." + this.options.buttonClass).on('click', this.open).removeClass(this.options.inactiveClass);
  1625. if (typeof (base = this.options).onReady === "function") {
  1626. base.onReady();
  1627. }
  1628. if (this.options.show) {
  1629. return this.show();
  1630. }
  1631. };
  1632. ZammadChat.prototype.onError = function(message) {
  1633. var base;
  1634. this.log.debug(message);
  1635. this.addStatus(message);
  1636. $("." + this.options.buttonClass).hide();
  1637. if (this.isOpen) {
  1638. this.disableInput();
  1639. this.destroy({
  1640. remove: false
  1641. });
  1642. } else {
  1643. this.destroy({
  1644. remove: true
  1645. });
  1646. }
  1647. return typeof (base = this.options).onError === "function" ? base.onError(message) : void 0;
  1648. };
  1649. ZammadChat.prototype.onReopenSession = function(data) {
  1650. var j, len, message, ref, unfinishedMessage;
  1651. this.log.debug('old messages', data.session);
  1652. this.inactiveTimeout.start();
  1653. unfinishedMessage = sessionStorage.getItem('unfinished_message');
  1654. if (data.agent) {
  1655. this.onConnectionEstablished(data);
  1656. ref = data.session;
  1657. for (j = 0, len = ref.length; j < len; j++) {
  1658. message = ref[j];
  1659. this.renderMessage({
  1660. message: message.content,
  1661. id: message.id,
  1662. from: message.created_by_id ? 'agent' : 'customer'
  1663. });
  1664. }
  1665. if (unfinishedMessage) {
  1666. this.input.html(unfinishedMessage);
  1667. }
  1668. }
  1669. if (data.position) {
  1670. this.onQueue(data);
  1671. }
  1672. this.show();
  1673. this.open();
  1674. this.scrollToBottom();
  1675. if (unfinishedMessage) {
  1676. return this.input.trigger('focus');
  1677. }
  1678. };
  1679. ZammadChat.prototype.onInput = function() {
  1680. this.el.find('.zammad-chat-message--unread').removeClass('zammad-chat-message--unread');
  1681. sessionStorage.setItem('unfinished_message', this.input.html());
  1682. return this.onTyping();
  1683. };
  1684. ZammadChat.prototype.onFocus = function() {
  1685. var keyboardShown;
  1686. $(window).scrollTop(10);
  1687. keyboardShown = $(window).scrollTop() > 0;
  1688. $(window).scrollTop(0);
  1689. if (keyboardShown) {
  1690. return this.log.notice('virtual keyboard shown');
  1691. }
  1692. };
  1693. ZammadChat.prototype.onFocusOut = function() {};
  1694. ZammadChat.prototype.onTyping = function() {
  1695. if (this.isTyping && this.isTyping > new Date(new Date().getTime() - 1500)) {
  1696. return;
  1697. }
  1698. this.isTyping = new Date();
  1699. this.send('chat_session_typing', {
  1700. session_id: this.sessionId
  1701. });
  1702. return this.inactiveTimeout.start();
  1703. };
  1704. ZammadChat.prototype.onSubmit = function(event) {
  1705. event.preventDefault();
  1706. return this.sendMessage();
  1707. };
  1708. ZammadChat.prototype.sendMessage = function() {
  1709. var message, messageElement;
  1710. message = this.input.html();
  1711. if (!message) {
  1712. return;
  1713. }
  1714. this.inactiveTimeout.start();
  1715. sessionStorage.removeItem('unfinished_message');
  1716. messageElement = this.view('message')({
  1717. message: message,
  1718. from: 'customer',
  1719. id: this._messageCount++,
  1720. unreadClass: ''
  1721. });
  1722. this.maybeAddTimestamp();
  1723. if (this.el.find('.zammad-chat-message--typing').get(0)) {
  1724. this.lastAddedType = 'typing-placeholder';
  1725. this.el.find('.zammad-chat-message--typing').before(messageElement);
  1726. } else {
  1727. this.lastAddedType = 'message--customer';
  1728. this.el.find('.zammad-chat-body').append(messageElement);
  1729. }
  1730. this.input.html('');
  1731. this.scrollToBottom();
  1732. return this.send('chat_session_message', {
  1733. content: message,
  1734. id: this._messageCount,
  1735. session_id: this.sessionId
  1736. });
  1737. };
  1738. ZammadChat.prototype.receiveMessage = function(data) {
  1739. this.inactiveTimeout.start();
  1740. this.onAgentTypingEnd();
  1741. this.maybeAddTimestamp();
  1742. this.renderMessage({
  1743. message: data.message.content,
  1744. id: data.id,
  1745. from: 'agent'
  1746. });
  1747. return this.scrollToBottom({
  1748. showHint: true
  1749. });
  1750. };
  1751. ZammadChat.prototype.renderMessage = function(data) {
  1752. this.lastAddedType = "message--" + data.from;
  1753. data.unreadClass = document.hidden ? ' zammad-chat-message--unread' : '';
  1754. return this.el.find('.zammad-chat-body').append(this.view('message')(data));
  1755. };
  1756. ZammadChat.prototype.open = function() {
  1757. var remainerHeight;
  1758. if (this.isOpen) {
  1759. this.log.debug('widget already open, block');
  1760. return;
  1761. }
  1762. this.isOpen = true;
  1763. this.log.debug('open widget');
  1764. this.show();
  1765. if (!this.sessionId) {
  1766. this.showLoader();
  1767. }
  1768. this.el.addClass('zammad-chat-is-open');
  1769. remainerHeight = this.el.height() - this.el.find('.zammad-chat-header').outerHeight();
  1770. this.el.css('bottom', -remainerHeight);
  1771. if (!this.sessionId) {
  1772. this.el.animate({
  1773. bottom: 0
  1774. }, 500, this.onOpenAnimationEnd);
  1775. return this.send('chat_session_init', {
  1776. url: window.location.href
  1777. });
  1778. } else {
  1779. this.el.css('bottom', 0);
  1780. return this.onOpenAnimationEnd();
  1781. }
  1782. };
  1783. ZammadChat.prototype.onOpenAnimationEnd = function() {
  1784. var base;
  1785. this.idleTimeout.stop();
  1786. if (this.isFullscreen) {
  1787. this.disableScrollOnRoot();
  1788. }
  1789. return typeof (base = this.options).onOpenAnimationEnd === "function" ? base.onOpenAnimationEnd() : void 0;
  1790. };
  1791. ZammadChat.prototype.sessionClose = function() {
  1792. this.send('chat_session_close', {
  1793. session_id: this.sessionId
  1794. });
  1795. this.inactiveTimeout.stop();
  1796. this.waitingListTimeout.stop();
  1797. sessionStorage.removeItem('unfinished_message');
  1798. if (this.onInitialQueueDelayId) {
  1799. clearTimeout(this.onInitialQueueDelayId);
  1800. }
  1801. return this.setSessionId(void 0);
  1802. };
  1803. ZammadChat.prototype.toggle = function(event) {
  1804. if (this.isOpen) {
  1805. return this.close(event);
  1806. } else {
  1807. return this.open(event);
  1808. }
  1809. };
  1810. ZammadChat.prototype.close = function(event) {
  1811. var remainerHeight;
  1812. if (!this.isOpen) {
  1813. this.log.debug('can\'t close widget, it\'s not open');
  1814. return;
  1815. }
  1816. if (this.initDelayId) {
  1817. clearTimeout(this.initDelayId);
  1818. }
  1819. if (this.sessionId) {
  1820. this.log.debug('session close before widget close');
  1821. this.sessionClose();
  1822. }
  1823. this.log.debug('close widget');
  1824. if (event) {
  1825. event.stopPropagation();
  1826. }
  1827. if (this.isFullscreen) {
  1828. this.enableScrollOnRoot();
  1829. }
  1830. remainerHeight = this.el.height() - this.el.find('.zammad-chat-header').outerHeight();
  1831. return this.el.animate({
  1832. bottom: -remainerHeight
  1833. }, 500, this.onCloseAnimationEnd);
  1834. };
  1835. ZammadChat.prototype.onCloseAnimationEnd = function() {
  1836. var base;
  1837. this.el.css('bottom', '');
  1838. this.el.removeClass('zammad-chat-is-open');
  1839. this.showLoader();
  1840. this.el.find('.zammad-chat-welcome').removeClass('zammad-chat-is-hidden');
  1841. this.el.find('.zammad-chat-agent').addClass('zammad-chat-is-hidden');
  1842. this.el.find('.zammad-chat-agent-status').addClass('zammad-chat-is-hidden');
  1843. this.isOpen = false;
  1844. if (typeof (base = this.options).onCloseAnimationEnd === "function") {
  1845. base.onCloseAnimationEnd();
  1846. }
  1847. return this.io.reconnect();
  1848. };
  1849. ZammadChat.prototype.onWebSocketClose = function() {
  1850. if (this.isOpen) {
  1851. return;
  1852. }
  1853. if (this.el) {
  1854. this.el.removeClass('zammad-chat-is-shown');
  1855. return this.el.removeClass('zammad-chat-is-loaded');
  1856. }
  1857. };
  1858. ZammadChat.prototype.show = function() {
  1859. if (this.state === 'offline') {
  1860. return;
  1861. }
  1862. this.el.addClass('zammad-chat-is-loaded');
  1863. return this.el.addClass('zammad-chat-is-shown');
  1864. };
  1865. ZammadChat.prototype.disableInput = function() {
  1866. this.inputDisabled = true;
  1867. this.input.prop('contenteditable', false);
  1868. this.el.find('.zammad-chat-send').prop('disabled', true);
  1869. return this.io.close();
  1870. };
  1871. ZammadChat.prototype.enableInput = function() {
  1872. this.inputDisabled = false;
  1873. this.input.prop('contenteditable', true);
  1874. return this.el.find('.zammad-chat-send').prop('disabled', false);
  1875. };
  1876. ZammadChat.prototype.hideModal = function() {
  1877. return this.el.find('.zammad-chat-modal').html('');
  1878. };
  1879. ZammadChat.prototype.onQueueScreen = function(data) {
  1880. var show;
  1881. this.setSessionId(data.session_id);
  1882. show = (function(_this) {
  1883. return function() {
  1884. _this.onQueue(data);
  1885. return _this.waitingListTimeout.start();
  1886. };
  1887. })(this);
  1888. if (this.initialQueueDelay && !this.onInitialQueueDelayId) {
  1889. this.onInitialQueueDelayId = setTimeout(show, this.initialQueueDelay);
  1890. return;
  1891. }
  1892. if (this.onInitialQueueDelayId) {
  1893. clearTimeout(this.onInitialQueueDelayId);
  1894. }
  1895. return show();
  1896. };
  1897. ZammadChat.prototype.onQueue = function(data) {
  1898. this.log.notice('onQueue', data.position);
  1899. this.inQueue = true;
  1900. return this.el.find('.zammad-chat-modal').html(this.view('waiting')({
  1901. position: data.position
  1902. }));
  1903. };
  1904. ZammadChat.prototype.onAgentTypingStart = function() {
  1905. if (this.stopTypingId) {
  1906. clearTimeout(this.stopTypingId);
  1907. }
  1908. this.stopTypingId = setTimeout(this.onAgentTypingEnd, 3000);
  1909. if (this.el.find('.zammad-chat-message--typing').get(0)) {
  1910. return;
  1911. }
  1912. this.maybeAddTimestamp();
  1913. this.el.find('.zammad-chat-body').append(this.view('typingIndicator')());
  1914. if (!this.isVisible(this.el.find('.zammad-chat-message--typing'), true)) {
  1915. return;
  1916. }
  1917. return this.scrollToBottom();
  1918. };
  1919. ZammadChat.prototype.onAgentTypingEnd = function() {
  1920. return this.el.find('.zammad-chat-message--typing').remove();
  1921. };
  1922. ZammadChat.prototype.onLeaveTemporary = function() {
  1923. if (!this.sessionId) {
  1924. return;
  1925. }
  1926. return this.send('chat_session_leave_temporary', {
  1927. session_id: this.sessionId
  1928. });
  1929. };
  1930. ZammadChat.prototype.maybeAddTimestamp = function() {
  1931. var label, time, timestamp;
  1932. timestamp = Date.now();
  1933. if (!this.lastTimestamp || (timestamp - this.lastTimestamp) > this.showTimeEveryXMinutes * 60000) {
  1934. label = this.T('Today');
  1935. time = new Date().toTimeString().substr(0, 5);
  1936. if (this.lastAddedType === 'timestamp') {
  1937. this.updateLastTimestamp(label, time);
  1938. return this.lastTimestamp = timestamp;
  1939. } else {
  1940. this.el.find('.zammad-chat-body').append(this.view('timestamp')({
  1941. label: label,
  1942. time: time
  1943. }));
  1944. this.lastTimestamp = timestamp;
  1945. this.lastAddedType = 'timestamp';
  1946. return this.scrollToBottom();
  1947. }
  1948. }
  1949. };
  1950. ZammadChat.prototype.updateLastTimestamp = function(label, time) {
  1951. if (!this.el) {
  1952. return;
  1953. }
  1954. return this.el.find('.zammad-chat-body').find('.zammad-chat-timestamp').last().replaceWith(this.view('timestamp')({
  1955. label: label,
  1956. time: time
  1957. }));
  1958. };
  1959. ZammadChat.prototype.addStatus = function(status) {
  1960. if (!this.el) {
  1961. return;
  1962. }
  1963. this.maybeAddTimestamp();
  1964. this.el.find('.zammad-chat-body').append(this.view('status')({
  1965. status: status
  1966. }));
  1967. return this.scrollToBottom();
  1968. };
  1969. ZammadChat.prototype.detectScrolledtoBottom = function() {
  1970. var scrollBottom;
  1971. scrollBottom = this.el.find('.zammad-chat-body').scrollTop() + this.el.find('.zammad-chat-body').outerHeight();
  1972. this.scrolledToBottom = Math.abs(scrollBottom - this.el.find('.zammad-chat-body').prop('scrollHeight')) <= this.scrollSnapTolerance;
  1973. if (this.scrolledToBottom) {
  1974. return this.el.find('.zammad-scroll-hint').addClass('is-hidden');
  1975. }
  1976. };
  1977. ZammadChat.prototype.showScrollHint = function() {
  1978. this.el.find('.zammad-scroll-hint').removeClass('is-hidden');
  1979. return this.el.find('.zammad-chat-body').scrollTop(this.el.find('.zammad-chat-body').scrollTop() + this.el.find('.zammad-scroll-hint').outerHeight());
  1980. };
  1981. ZammadChat.prototype.onScrollHintClick = function() {
  1982. return this.el.find('.zammad-chat-body').animate({
  1983. scrollTop: this.el.find('.zammad-chat-body').prop('scrollHeight')
  1984. }, 300);
  1985. };
  1986. ZammadChat.prototype.scrollToBottom = function(arg) {
  1987. var showHint;
  1988. showHint = (arg != null ? arg : {
  1989. showHint: false
  1990. }).showHint;
  1991. if (this.scrolledToBottom) {
  1992. return this.el.find('.zammad-chat-body').scrollTop($('.zammad-chat-body').prop('scrollHeight'));
  1993. } else if (showHint) {
  1994. return this.showScrollHint();
  1995. }
  1996. };
  1997. ZammadChat.prototype.destroy = function(params) {
  1998. if (params == null) {
  1999. params = {};
  2000. }
  2001. this.log.debug('destroy widget', params);
  2002. this.setAgentOnlineState('offline');
  2003. if (params.remove && this.el) {
  2004. this.el.remove();
  2005. $("." + this.options.buttonClass).hide();
  2006. }
  2007. if (this.waitingListTimeout) {
  2008. this.waitingListTimeout.stop();
  2009. }
  2010. if (this.inactiveTimeout) {
  2011. this.inactiveTimeout.stop();
  2012. }
  2013. if (this.idleTimeout) {
  2014. this.idleTimeout.stop();
  2015. }
  2016. return this.io.close();
  2017. };
  2018. ZammadChat.prototype.reconnect = function() {
  2019. this.log.notice('reconnecting');
  2020. this.disableInput();
  2021. this.lastAddedType = 'status';
  2022. this.setAgentOnlineState('connecting');
  2023. return this.addStatus(this.T('Connection lost'));
  2024. };
  2025. ZammadChat.prototype.onConnectionReestablished = function() {
  2026. var base;
  2027. this.lastAddedType = 'status';
  2028. this.setAgentOnlineState('online');
  2029. this.addStatus(this.T('Connection re-established'));
  2030. return typeof (base = this.options).onConnectionReestablished === "function" ? base.onConnectionReestablished() : void 0;
  2031. };
  2032. ZammadChat.prototype.onSessionClosed = function(data) {
  2033. var base;
  2034. this.addStatus(this.T('Chat closed by %s', data.realname));
  2035. this.disableInput();
  2036. this.setAgentOnlineState('offline');
  2037. this.inactiveTimeout.stop();
  2038. return typeof (base = this.options).onSessionClosed === "function" ? base.onSessionClosed(data) : void 0;
  2039. };
  2040. ZammadChat.prototype.setSessionId = function(id) {
  2041. this.sessionId = id;
  2042. if (id === void 0) {
  2043. return sessionStorage.removeItem('sessionId');
  2044. } else {
  2045. return sessionStorage.setItem('sessionId', id);
  2046. }
  2047. };
  2048. ZammadChat.prototype.onConnectionEstablished = function(data) {
  2049. var base;
  2050. if (this.onInitialQueueDelayId) {
  2051. clearTimeout(this.onInitialQueueDelayId);
  2052. }
  2053. this.inQueue = false;
  2054. if (data.agent) {
  2055. this.agent = data.agent;
  2056. }
  2057. if (data.session_id) {
  2058. this.setSessionId(data.session_id);
  2059. }
  2060. this.el.find('.zammad-chat-body').html('');
  2061. this.el.find('.zammad-chat-agent').html(this.view('agent')({
  2062. agent: this.agent
  2063. }));
  2064. this.enableInput();
  2065. this.hideModal();
  2066. this.el.find('.zammad-chat-welcome').addClass('zammad-chat-is-hidden');
  2067. this.el.find('.zammad-chat-agent').removeClass('zammad-chat-is-hidden');
  2068. this.el.find('.zammad-chat-agent-status').removeClass('zammad-chat-is-hidden');
  2069. if (!this.isFullscreen) {
  2070. this.input.trigger('focus');
  2071. }
  2072. this.setAgentOnlineState('online');
  2073. this.waitingListTimeout.stop();
  2074. this.idleTimeout.stop();
  2075. this.inactiveTimeout.start();
  2076. return typeof (base = this.options).onConnectionEstablished === "function" ? base.onConnectionEstablished(data) : void 0;
  2077. };
  2078. ZammadChat.prototype.showCustomerTimeout = function() {
  2079. var reload;
  2080. this.el.find('.zammad-chat-modal').html(this.view('customer_timeout')({
  2081. agent: this.agent.name,
  2082. delay: this.options.inactiveTimeout
  2083. }));
  2084. reload = function() {
  2085. return location.reload();
  2086. };
  2087. this.el.find('.js-restart').on('click', reload);
  2088. return this.sessionClose();
  2089. };
  2090. ZammadChat.prototype.showWaitingListTimeout = function() {
  2091. var reload;
  2092. this.el.find('.zammad-chat-modal').html(this.view('waiting_list_timeout')({
  2093. delay: this.options.watingListTimeout
  2094. }));
  2095. reload = function() {
  2096. return location.reload();
  2097. };
  2098. this.el.find('.js-restart').on('click', reload);
  2099. return this.sessionClose();
  2100. };
  2101. ZammadChat.prototype.showLoader = function() {
  2102. return this.el.find('.zammad-chat-modal').html(this.view('loader')());
  2103. };
  2104. ZammadChat.prototype.setAgentOnlineState = function(state) {
  2105. var capitalizedState;
  2106. this.state = state;
  2107. if (!this.el) {
  2108. return;
  2109. }
  2110. capitalizedState = state.charAt(0).toUpperCase() + state.slice(1);
  2111. return this.el.find('.zammad-chat-agent-status').attr('data-status', state).text(this.T(capitalizedState));
  2112. };
  2113. ZammadChat.prototype.detectHost = function() {
  2114. var protocol;
  2115. protocol = 'ws://';
  2116. if (scriptProtocol === 'https') {
  2117. protocol = 'wss://';
  2118. }
  2119. return this.options.host = "" + protocol + scriptHost + "/ws";
  2120. };
  2121. ZammadChat.prototype.loadCss = function() {
  2122. var newSS, styles, url;
  2123. if (!this.options.cssAutoload) {
  2124. return;
  2125. }
  2126. url = this.options.cssUrl;
  2127. if (!url) {
  2128. url = this.options.host.replace(/^wss/i, 'https').replace(/^ws/i, 'http').replace(/\/ws$/i, '');
  2129. url += '/assets/chat/chat.css';
  2130. }
  2131. this.log.debug("load css from '" + url + "'");
  2132. styles = "@import url('" + url + "');";
  2133. newSS = document.createElement('link');
  2134. newSS.onload = this.onCssLoaded;
  2135. newSS.rel = 'stylesheet';
  2136. newSS.href = 'data:text/css,' + escape(styles);
  2137. return document.getElementsByTagName('head')[0].appendChild(newSS);
  2138. };
  2139. ZammadChat.prototype.onCssLoaded = function() {
  2140. var base;
  2141. this.cssLoaded = true;
  2142. if (this.socketReady) {
  2143. this.onReady();
  2144. }
  2145. return typeof (base = this.options).onCssLoaded === "function" ? base.onCssLoaded() : void 0;
  2146. };
  2147. ZammadChat.prototype.startTimeoutObservers = function() {
  2148. this.idleTimeout = new Timeout({
  2149. logPrefix: 'idleTimeout',
  2150. debug: this.options.debug,
  2151. timeout: this.options.idleTimeout,
  2152. timeoutIntervallCheck: this.options.idleTimeoutIntervallCheck,
  2153. callback: (function(_this) {
  2154. return function() {
  2155. _this.log.debug('Idle timeout reached, hide widget', new Date);
  2156. return _this.destroy({
  2157. remove: true
  2158. });
  2159. };
  2160. })(this)
  2161. });
  2162. this.inactiveTimeout = new Timeout({
  2163. logPrefix: 'inactiveTimeout',
  2164. debug: this.options.debug,
  2165. timeout: this.options.inactiveTimeout,
  2166. timeoutIntervallCheck: this.options.inactiveTimeoutIntervallCheck,
  2167. callback: (function(_this) {
  2168. return function() {
  2169. _this.log.debug('Inactive timeout reached, show timeout screen.', new Date);
  2170. _this.showCustomerTimeout();
  2171. return _this.destroy({
  2172. remove: false
  2173. });
  2174. };
  2175. })(this)
  2176. });
  2177. return this.waitingListTimeout = new Timeout({
  2178. logPrefix: 'waitingListTimeout',
  2179. debug: this.options.debug,
  2180. timeout: this.options.waitingListTimeout,
  2181. timeoutIntervallCheck: this.options.waitingListTimeoutIntervallCheck,
  2182. callback: (function(_this) {
  2183. return function() {
  2184. _this.log.debug('Waiting list timeout reached, show timeout screen.', new Date);
  2185. _this.showWaitingListTimeout();
  2186. return _this.destroy({
  2187. remove: false
  2188. });
  2189. };
  2190. })(this)
  2191. });
  2192. };
  2193. ZammadChat.prototype.disableScrollOnRoot = function() {
  2194. this.rootScrollOffset = this.scrollRoot.scrollTop();
  2195. return this.scrollRoot.css({
  2196. overflow: 'hidden',
  2197. position: 'fixed'
  2198. });
  2199. };
  2200. ZammadChat.prototype.enableScrollOnRoot = function() {
  2201. this.scrollRoot.scrollTop(this.rootScrollOffset);
  2202. return this.scrollRoot.css({
  2203. overflow: '',
  2204. position: ''
  2205. });
  2206. };
  2207. ZammadChat.prototype.isVisible = function(el, partial, hidden, direction) {
  2208. 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;
  2209. if (el.length < 1) {
  2210. return;
  2211. }
  2212. $w = $(window);
  2213. $t = el.length > 1 ? el.eq(0) : el;
  2214. t = $t.get(0);
  2215. vpWidth = $w.width();
  2216. vpHeight = $w.height();
  2217. direction = direction ? direction : 'both';
  2218. clientSize = hidden === true ? t.offsetWidth * t.offsetHeight : true;
  2219. if (typeof t.getBoundingClientRect === 'function') {
  2220. rec = t.getBoundingClientRect();
  2221. tViz = rec.top >= 0 && rec.top < vpHeight;
  2222. bViz = rec.bottom > 0 && rec.bottom <= vpHeight;
  2223. lViz = rec.left >= 0 && rec.left < vpWidth;
  2224. rViz = rec.right > 0 && rec.right <= vpWidth;
  2225. vVisible = partial ? tViz || bViz : tViz && bViz;
  2226. hVisible = partial ? lViz || rViz : lViz && rViz;
  2227. if (direction === 'both') {
  2228. return clientSize && vVisible && hVisible;
  2229. } else if (direction === 'vertical') {
  2230. return clientSize && vVisible;
  2231. } else if (direction === 'horizontal') {
  2232. return clientSize && hVisible;
  2233. }
  2234. } else {
  2235. viewTop = $w.scrollTop();
  2236. viewBottom = viewTop + vpHeight;
  2237. viewLeft = $w.scrollLeft();
  2238. viewRight = viewLeft + vpWidth;
  2239. offset = $t.offset();
  2240. _top = offset.top;
  2241. _bottom = _top + $t.height();
  2242. _left = offset.left;
  2243. _right = _left + $t.width();
  2244. compareTop = partial === true ? _bottom : _top;
  2245. compareBottom = partial === true ? _top : _bottom;
  2246. compareLeft = partial === true ? _right : _left;
  2247. compareRight = partial === true ? _left : _right;
  2248. if (direction === 'both') {
  2249. return !!clientSize && ((compareBottom <= viewBottom) && (compareTop >= viewTop)) && ((compareRight <= viewRight) && (compareLeft >= viewLeft));
  2250. } else if (direction === 'vertical') {
  2251. return !!clientSize && ((compareBottom <= viewBottom) && (compareTop >= viewTop));
  2252. } else if (direction === 'horizontal') {
  2253. return !!clientSize && ((compareRight <= viewRight) && (compareLeft >= viewLeft));
  2254. }
  2255. }
  2256. };
  2257. ZammadChat.prototype.isRetina = function() {
  2258. var mq;
  2259. if (window.matchMedia) {
  2260. 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)');
  2261. return mq && mq.matches || (window.devicePixelRatio > 1);
  2262. }
  2263. return false;
  2264. };
  2265. ZammadChat.prototype.resizeImage = function(dataURL, x, y, sizeFactor, type, quallity, callback, force) {
  2266. var imageObject;
  2267. if (x == null) {
  2268. x = 'auto';
  2269. }
  2270. if (y == null) {
  2271. y = 'auto';
  2272. }
  2273. if (sizeFactor == null) {
  2274. sizeFactor = 1;
  2275. }
  2276. if (force == null) {
  2277. force = true;
  2278. }
  2279. imageObject = new Image();
  2280. imageObject.onload = function() {
  2281. var canvas, context, factor, imageHeight, imageWidth, newDataUrl, resize;
  2282. imageWidth = imageObject.width;
  2283. imageHeight = imageObject.height;
  2284. console.log('ImageService', 'current size', imageWidth, imageHeight);
  2285. if (y === 'auto' && x === 'auto') {
  2286. x = imageWidth;
  2287. y = imageHeight;
  2288. }
  2289. if (y === 'auto') {
  2290. factor = imageWidth / x;
  2291. y = imageHeight / factor;
  2292. }
  2293. if (x === 'auto') {
  2294. factor = imageWidth / y;
  2295. x = imageHeight / factor;
  2296. }
  2297. resize = false;
  2298. if (x < imageWidth || y < imageHeight) {
  2299. resize = true;
  2300. x = x * sizeFactor;
  2301. y = y * sizeFactor;
  2302. } else {
  2303. x = imageWidth;
  2304. y = imageHeight;
  2305. }
  2306. canvas = document.createElement('canvas');
  2307. canvas.width = x;
  2308. canvas.height = y;
  2309. context = canvas.getContext('2d');
  2310. context.drawImage(imageObject, 0, 0, x, y);
  2311. if (quallity === 'auto') {
  2312. if (x < 200 && y < 200) {
  2313. quallity = 1;
  2314. } else if (x < 400 && y < 400) {
  2315. quallity = 0.9;
  2316. } else if (x < 600 && y < 600) {
  2317. quallity = 0.8;
  2318. } else if (x < 900 && y < 900) {
  2319. quallity = 0.7;
  2320. } else {
  2321. quallity = 0.6;
  2322. }
  2323. }
  2324. newDataUrl = canvas.toDataURL(type, quallity);
  2325. if (resize) {
  2326. console.log('ImageService', 'resize', x / sizeFactor, y / sizeFactor, quallity, (newDataUrl.length * 0.75) / 1024 / 1024, 'in mb');
  2327. callback(newDataUrl, x / sizeFactor, y / sizeFactor, true);
  2328. return;
  2329. }
  2330. console.log('ImageService', 'no resize', x, y, quallity, (newDataUrl.length * 0.75) / 1024 / 1024, 'in mb');
  2331. return callback(newDataUrl, x, y, false);
  2332. };
  2333. return imageObject.src = dataURL;
  2334. };
  2335. ZammadChat.prototype.pasteHtmlAtCaret = function(html) {
  2336. var el, frag, lastNode, node, range, sel;
  2337. sel = void 0;
  2338. range = void 0;
  2339. if (window.getSelection) {
  2340. sel = window.getSelection();
  2341. if (sel.getRangeAt && sel.rangeCount) {
  2342. range = sel.getRangeAt(0);
  2343. range.deleteContents();
  2344. el = document.createElement('div');
  2345. el.innerHTML = html;
  2346. frag = document.createDocumentFragment(node, lastNode);
  2347. while (node = el.firstChild) {
  2348. lastNode = frag.appendChild(node);
  2349. }
  2350. range.insertNode(frag);
  2351. if (lastNode) {
  2352. range = range.cloneRange();
  2353. range.setStartAfter(lastNode);
  2354. range.collapse(true);
  2355. sel.removeAllRanges();
  2356. return sel.addRange(range);
  2357. }
  2358. }
  2359. } else if (document.selection && document.selection.type !== 'Control') {
  2360. return document.selection.createRange().pasteHTML(html);
  2361. }
  2362. };
  2363. ZammadChat.prototype.wordFilter = function(editor) {
  2364. var content, last_level, pnt;
  2365. content = editor.html();
  2366. content = content.replace(/<!--[\s\S]+?-->/gi, '');
  2367. content = content.replace(/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi, '');
  2368. content = content.replace(/<(\/?)s>/gi, '<$1strike>');
  2369. content = content.replace(/&nbsp;/gi, ' ');
  2370. editor.html(content);
  2371. $('p', editor).each(function() {
  2372. var matches, str;
  2373. str = $(this).attr('style');
  2374. matches = /mso-list:\w+ \w+([0-9]+)/.exec(str);
  2375. if (matches) {
  2376. return $(this).data('_listLevel', parseInt(matches[1], 10));
  2377. }
  2378. });
  2379. last_level = 0;
  2380. pnt = null;
  2381. $('p', editor).each(function() {
  2382. var cur_level, i, j, list_tag, matches, ref, ref1, ref2, start, txt;
  2383. cur_level = $(this).data('_listLevel');
  2384. if (cur_level !== void 0) {
  2385. txt = $(this).text();
  2386. list_tag = '<ul></ul>';
  2387. if (/^\s*\w+\./.test(txt)) {
  2388. matches = /([0-9])\./.exec(txt);
  2389. if (matches) {
  2390. start = parseInt(matches[1], 10);
  2391. list_tag = (ref = start > 1) != null ? ref : '<ol start="' + start + {
  2392. '"></ol>': '<ol></ol>'
  2393. };
  2394. } else {
  2395. list_tag = '<ol></ol>';
  2396. }
  2397. }
  2398. if (cur_level > last_level) {
  2399. if (last_level === 0) {
  2400. $(this).before(list_tag);
  2401. pnt = $(this).prev();
  2402. } else {
  2403. pnt = $(list_tag).appendTo(pnt);
  2404. }
  2405. }
  2406. if (cur_level < last_level) {
  2407. for (i = j = ref1 = i, ref2 = last_level - cur_level; ref1 <= ref2 ? j <= ref2 : j >= ref2; i = ref1 <= ref2 ? ++j : --j) {
  2408. pnt = pnt.parent();
  2409. }
  2410. }
  2411. $('span:first', this).remove();
  2412. pnt.append('<li>' + $(this).html() + '</li>');
  2413. $(this).remove();
  2414. return last_level = cur_level;
  2415. } else {
  2416. return last_level = 0;
  2417. }
  2418. });
  2419. $('[style]', editor).removeAttr('style');
  2420. $('[align]', editor).removeAttr('align');
  2421. $('span', editor).replaceWith(function() {
  2422. return $(this).contents();
  2423. });
  2424. $('span:empty', editor).remove();
  2425. $("[class^='Mso']", editor).removeAttr('class');
  2426. $('p:empty', editor).remove();
  2427. return editor;
  2428. };
  2429. ZammadChat.prototype.removeAttribute = function(element) {
  2430. var $element, att, j, len, ref;
  2431. if (!element) {
  2432. return;
  2433. }
  2434. $element = $(element);
  2435. ref = element.attributes;
  2436. for (j = 0, len = ref.length; j < len; j++) {
  2437. att = ref[j];
  2438. if (att && att.name) {
  2439. element.removeAttribute(att.name);
  2440. }
  2441. }
  2442. return $element.removeAttr('style').removeAttr('class').removeAttr('lang').removeAttr('type').removeAttr('align').removeAttr('id').removeAttr('wrap').removeAttr('title');
  2443. };
  2444. ZammadChat.prototype.removeAttributes = function(html, parent) {
  2445. if (parent == null) {
  2446. parent = true;
  2447. }
  2448. if (parent) {
  2449. html.each((function(_this) {
  2450. return function(index, element) {
  2451. return _this.removeAttribute(element);
  2452. };
  2453. })(this));
  2454. }
  2455. html.find('*').each((function(_this) {
  2456. return function(index, element) {
  2457. return _this.removeAttribute(element);
  2458. };
  2459. })(this));
  2460. return html;
  2461. };
  2462. return ZammadChat;
  2463. })(Base);
  2464. return window.ZammadChat = ZammadChat;
  2465. })(window.jQuery, window);