public_html/layouts/basic/modules/OSSMail/resources/checkmails.min.js.map
{"version":3,"file":"checkmails.min.js","sources":["checkmails.js"],"sourcesContent":["/* {[The file is published on the basis of YetiForce Public License 6.5 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */\n'use strict';\njQuery(function () {\n\tif ($('.js-header__btn--mail').data('numberunreademails') != undefined) {\n\t\twindow.stopScanMails = false;\n\t\tif (getUrlVars()['view'] != 'Popup') {\n\t\t\tstartCheckMails();\n\t\t}\n\t}\n\tif ($('.js-header__btn--mail select').length > 0) {\n\t\tregisterUserList();\n\t}\n});\n\nfunction registerUserList() {\n\tvar selectUsers = $('.js-header__btn--mail select');\n\tif (selectUsers.data('select2')) {\n\t\tselectUsers.select2('destroy');\n\t} else {\n\t\tselectUsers.on('change', handleChangeUserEvent);\n\t}\n\tApp.Fields.Picklist.showSelect2ElementView(selectUsers, {\n\t\ttemplateResult: function (data) {\n\t\t\tconst main = document.createElement('span');\n\t\t\tif (data.id) {\n\t\t\t\tconst element = $(data.element),\n\t\t\t\t\tmail = document.createElement('span');\n\t\t\t\tmail.innerText = data.text;\n\t\t\t\tmain.appendChild(mail);\n\t\t\t\tif (element.data('nomail')) {\n\t\t\t\t\tconst badge = document.createElement('span');\n\t\t\t\t\tbadge.className = 'badge badge-danger ml-1';\n\t\t\t\t\tbadge.innerText = element.data('nomail');\n\t\t\t\t\tmain.appendChild(badge);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmain.innerText = data.text;\n\t\t\t}\n\t\t\treturn main;\n\t\t},\n\t\ttemplateSelection: function (data) {\n\t\t\tconst element = $(data.element),\n\t\t\t\tmain = document.createElement('span'),\n\t\t\t\tmail = document.createElement('span');\n\t\t\tmail.innerText = data.text;\n\t\t\tmain.appendChild(mail);\n\t\t\tif (element.data('nomail')) {\n\t\t\t\tconst badge = document.createElement('span');\n\t\t\t\tbadge.className = 'badge badge-danger ml-1';\n\t\t\t\tbadge.innerText = element.data('nomail');\n\t\t\t\tmain.appendChild(badge);\n\t\t\t}\n\t\t\treturn main;\n\t\t},\n\t\tcloseOnSelect: true\n\t});\n\tconst select2Instance = selectUsers.data('select2');\n\tselect2Instance.$dropdown.on('mouseup', 'li', function (e) {\n\t\tif (jQuery(e.currentTarget).attr('aria-selected') == 'true') {\n\t\t\tselectUsers.trigger('change');\n\t\t}\n\t});\n\tselect2Instance.$container.find('.select2-selection__rendered').on('mousedown', function (e) {\n\t\te.stopPropagation();\n\t\tselectUsers.trigger('change');\n\t});\n\t$('.js-mail-list').on('click', '.js-mail-link', handleChangeUserEvent);\n}\n\nfunction handleChangeUserEvent() {\n\tAppConnector.request({\n\t\tmodule: 'OSSMail',\n\t\taction: 'SetUser',\n\t\tuser: $(this).val()\n\t}).done(function (_) {\n\t\tif (app.getModuleName() == 'OSSMail') {\n\t\t\twindow.location.href = window.location.href;\n\t\t} else {\n\t\t\twindow.location.href = 'index.php?module=OSSMail&view=Index';\n\t\t}\n\t});\n}\n\nfunction startCheckMails() {\n\tlet users = [];\n\tlet timeCheckingMails = $('.js-header__btn--mail').data('interval');\n\t$('.js-header__btn--mail .noMails').each(function (_) {\n\t\tusers.push($(this).data('id'));\n\t});\n\tif (users.length > 0) {\n\t\tcheckMails(users, true);\n\t\tlet refreshIntervalId = setInterval(function () {\n\t\t\tif (window.stopScanMails == false) {\n\t\t\t\tcheckMails(users);\n\t\t\t} else {\n\t\t\t\tclearInterval(refreshIntervalId);\n\t\t\t}\n\t\t}, timeCheckingMails * 1000);\n\t}\n}\n\nfunction checkMails(users, initial = false) {\n\tlet reloadSelect = false;\n\tAppConnector.request({\n\t\tmodule: 'OSSMail',\n\t\taction: 'CheckMails',\n\t\tusers: users\n\t})\n\t\t.done(function (response) {\n\t\t\tif (response.success && response.success.error != true && response.result.error != true) {\n\t\t\t\tlet result = response.result;\n\t\t\t\t$('.js-header__btn--mail .noMails').each(function (_) {\n\t\t\t\t\tlet element = jQuery(this);\n\t\t\t\t\tlet id = element.data('id');\n\t\t\t\t\tif (jQuery.inArray(id, result)) {\n\t\t\t\t\t\tlet num = result[id];\n\t\t\t\t\t\tif (element.is('option')) {\n\t\t\t\t\t\t\telement.data('nomail', num);\n\t\t\t\t\t\t\treloadSelect = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlet prevVal = element.data('nomail');\n\t\t\t\t\t\t\telement.data('nomail', num);\n\t\t\t\t\t\t\tlet text = '';\n\t\t\t\t\t\t\tif (num > 0) {\n\t\t\t\t\t\t\t\ttext = ' <span class=\"badge badge-danger mr-1\">' + num + '</span>';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telement.html(text);\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tinitial === false &&\n\t\t\t\t\t\t\t\t(this.tagName === 'SPAN' || this.selected) &&\n\t\t\t\t\t\t\t\t((prevVal < num && prevVal >= 0) || (!prevVal && num > 0))\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\telement.parent().effect('pulsate', 1500);\n\t\t\t\t\t\t\t\tapp.playSound('MAILS');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (reloadSelect) {\n\t\t\t\t\tregisterUserList();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twindow.stopScanMails = true;\n\t\t\t}\n\t\t})\n\t\t.fail(function () {\n\t\t\twindow.stopScanMails = true;\n\t\t});\n}\n\nfunction getUrlVars() {\n\tlet vars = {};\n\twindow.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {\n\t\tvars[key] = value;\n\t});\n\treturn vars;\n}\n"],"names":["jQuery","$","data","window","stopScanMails","getUrlVars","view","startCheckMails","length","registerUserList","selectUsers","select2","on","handleChangeUserEvent","App","Fields","Picklist","showSelect2ElementView","templateResult","main","document","createElement","id","element","mail","innerText","text","appendChild","badge","className","templateSelection","closeOnSelect","select2Instance","$dropdown","e","currentTarget","attr","trigger","$container","find","stopPropagation","AppConnector","request","module","action","user","val","done","location","href","app","getModuleName","users","timeCheckingMails","each","push","checkMails","refreshIntervalId","setInterval","clearInterval","initial","arguments","reloadSelect","response","success","error","result","inArray","num","is","prevVal","html","tagName","selected","parent","effect","playSound","fail","vars","replace","m","key","value"],"mappings":";;AAAA,kKACA,YAAY,CACZA,MAAM,CAAC,UAAY,CACdC,CAAC,CAAC,uBAAuB,CAAC,CAACC,IAAI,CAAC,oBAAoB,CAAC,EAAA,IAAa,GACrEC,MAAM,CAACC,aAAa,CAAA,CAAA,CAAQ,CACA,OAAO,EAA/BC,UAAU,EAAE,CAAAC,IAAmB,EAClCC,eAAe,EAAE,CAG4B,CAAA,CAAC,CAA5CN,CAAC,CAAC,8BAA8B,CAAC,CAACO,MAAU,EAC/CC,gBAAgB,GAElB,CAAC,CAAC,CAEF,SAASA,gBAAgBA,EAAG,CAC3B,IAAIC,WAAW,CAAGT,CAAC,CAAC,8BAA8B,CAAC,CAC/CS,WAAW,CAACR,IAAI,CAAC,SAAS,CAAC,CAC9BQ,WAAW,CAACC,OAAO,CAAC,SAAS,CAAC,CAE9BD,WAAW,CAACE,EAAE,CAAC,QAAQ,CAAEC,qBAAqB,CAAC,CAEhDC,GAAG,CAACC,MAAM,CAACC,QAAQ,CAACC,sBAAsB,CAACP,WAAW,CAAE,CACvDQ,cAAc,CAAE,SAAAA,eAAUhB,IAAI,CAAE,CAC/B,IAAMiB,IAAI,CAAGC,QAAQ,CAACC,aAAa,CAAC,MAAM,CAAC,CAC3C,GAAInB,IAAI,CAACoB,EAAE,CAAE,CACZ,IAAMC,OAAO,CAAGtB,CAAC,CAACC,IAAI,CAACqB,OAAO,CAAC,CAC9BC,IAAI,CAAGJ,QAAQ,CAACC,aAAa,CAAC,MAAM,CAAC,CAGtC,GAFAG,IAAI,CAACC,SAAS,CAAGvB,IAAI,CAACwB,IAAI,CAC1BP,IAAI,CAACQ,WAAW,CAACH,IAAI,CAAC,CAClBD,OAAO,CAACrB,IAAI,CAAC,QAAQ,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