chat.js 120 KB

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