Skip to content

Instantly share code, notes, and snippets.

@bryanwillis
Last active June 28, 2019 22:55
Show Gist options
  • Save bryanwillis/bb20558a85ce821d917d9e37e4ea25cd to your computer and use it in GitHub Desktop.
Save bryanwillis/bb20558a85ce821d917d9e37e4ea25cd to your computer and use it in GitHub Desktop.
function recordNavigation() {
var next = $("#detailNext"),
prev = $("#detailPrevious"),
back = $("#backArrowDV img");
next.hasClass("disabled") && next.is(":visible") ? next.trigger("click") : prev.hasClass("disabled") && prev.is(":visible") ? prev.trigger("click") : back.trigger("click")
}
function validateVariableGroup() {
var label = $("#cVarCgroupName_label").text(),
check = emptyCheck("cVarCgroupName", label);
return check
}
function checkForEmailRegeneration(status) {
null != status && "null" != status && "true" == status && showLightBox("regenerationMsgDiv")
}
function showLightBox(id) {
Utils.showHideLoadingDiv(), $("#" + id).addClass("newPopup p30"), getObj(id).style.zIndex = 21, getObj(id).style.position = "absolute", freezeBackground(), $("#" + id).show(), mailsetCenter(id)
}
function removeEmailFields(el) {
var _el = $(el),
len = $("tr.addField").length;
$("tr.addField").length > 1 && (_el.closest("tr.addField").remove(), 1 == $("tr.addField").length && ($("tr.addField:eq(" + (len - 2) + ")").find("td:last-child").find(".removeCriteria").hide(), $("tr.addField:eq(" + (len - 2) + ")").find("td:last-child").find(".addBccEmail").show()), $("tr.addField:eq(" + (len - 2) + ")").find("td:last-child").find(".addBccEmail").show(), $("tr.addField:eq(" + (len - 2) + ")").find("td:last-child").find(".removeCriteria").hide())
}
function saveAcceptableEmails() {
for (var acceptableEmails = document.getElementsByName("acceptableEmails"), emailsArr = new Array, email_pattern = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,22})$/, tempEmailAddress = "", excludeDomains = document.getElementById("excludeDomains").value, excludeDomainsArray = excludeDomains.split(","), i = 0; i < acceptableEmails.length; i++)
if (tempEmailAddress = acceptableEmails[i].value.replace(/\s/g, ""), email_pattern.test(tempEmailAddress) && tempEmailAddress.length < 100)
emailsArr.push(tempEmailAddress);
else if ("undefined" != acceptableEmails[i].value && tempEmailAddress.length)
return crmui.showMsgBand("error", I18n.getMsg("bccdropbox.otheremail.addr.invalid"), 3e3, ""), acceptableEmails[i].focus(), !1;
if (0 == emailsArr.length)
return crmui.showMsgBand("error", I18n.getMsg("bccdropbox.otheremail.addr.empty"), 3e3, ""), !1;
if (excludeDomains.length > 1e3)
return $("#excludeDomains_errorMsg").addClass("bccErrTxt"), $("#excludeDomains").addClass("bccInptErr"), showAnimatePopup("BCCDropboxId"), !1;
for (var k = 0; k < excludeDomainsArray.length; k++)
for (var j = k + 1; j < excludeDomainsArray.length; j++)
if (excludeDomainsArray[k] == excludeDomainsArray[j])
return $("#excludeDomains_errorMsg").addClass("bccErrTxt"), $("#excludeDomains_errorMsg").text(I18n.getMsg("bccdropbox.domainsname.duplicate.alert", [++k, ++j])).show(), $("html, body").animate({
scrollTop: excludeDomains_errorMsg.offset().top - 50
}, "600"), !1;
if (1 == isEmailsRepeated(emailsArr))
return !1;
var re = /^(@*([A-Za-z0-9\-]+(\.[a-zA-Z0-9\-]{1,20}){1,10})+,*){0,10}$/,
len = (excludeDomains.lastIndexOf(","), excludeDomains.length);
if (0 == len || re.test(excludeDomains) && excludeDomains.lastIndexOf(",") != excludeDomains.length - 1) {
var posturl = "/recruit/BCCDropbox.do",
param = "action=saveAcceptableEmails&acceptableEmails=" + encodeURIComponent(emailsArr.toString()) + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken);
Utils.showHideLoadingDiv(!0), $.ajax({
type: "POST",
url: posturl,
data: param,
success: function(data) {
if (Utils.showHideLoadingDiv(), "100" == data) {
existing_acceptable_emails = emailsArr, rearrangeEmailsInTextBox(emailsArr);
var posturl1 = "/recruit/BCCDropbox.do",
param1 = "action=saveExcludeDomains&excludeDomains=" + encodeURIComponent(excludeDomains) + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken);
$.ajax({
type: "POST",
url: posturl1,
data: param1,
success: function() {
var bccdropSuccMsg = I18n.getMsg("bccdropbox.otheremail.addr.success");
crmui.showMsgBand("success", bccdropSuccMsg, 3e3, "")
}
})
} else
"-1" == data ? crmui.showMsgBand("error", I18n.getMsg("bccdropbox.otheremail.addr.err"), 3e3, "") : crmui.showMsgBand("error", I18n.getMsg("crm.security.error.add.user"), 3e3, "")
},
error: function() {
Utils.showHideLoadingDiv(), crmui.showMsgBand("error", I18n.getMsg("crm.security.error.add.user"), 3e3, "")
}
})
} else {
var regex = /^((@*[A-Za-z0-9\-]+(\.[a-zA-Z0-9\-]{1,20}){1,10})+,*)*$/,
str = excludeDomains.split(",");
if (!regex.test(excludeDomains) || excludeDomains.lastIndexOf(",") == excludeDomains.length - 1)
return $("#excludeDomains").addClass("bccInptErr"), $("#excludeDomains_errorMsg").addClass("bccErrTxt"), $("#excludeDomains_errorMsg").text("Please enter a valid domain.").show(), $("html, body").animate({
scrollTop: $("#excludeDomains_errorMsg").offset().top - 50
}, "600"), !1;
if (str.length > 10)
return $("#excludeDomains_errorMsg").addClass("bccErrTxt"), $("#excludeDomains_errorMsg").text("You can add a maximum of 10 domains.").show(), $("html, body").animate({
scrollTop: $("#excludeDomains_errorMsg").offset().top - 50
}, "600"), !1
}
}
function isEmailsRepeated() {
for (var emailsArr = document.getElementsByName("acceptableEmails"), abbreviations = ["st", "nd", "rd", "th", "th"], i = 0; i < emailsArr.length; i++)
for (var j = i + 1; j < emailsArr.length; j++)
if ("undefined" != typeof emailsArr[i].value && "undefined" != typeof emailsArr[j].value && emailsArr[i].value.replace(/\s/g, "").length > 0 && emailsArr[j].value.replace(/\s/g, "").length > 0 && emailsArr[i].value == emailsArr[j].value)
return alert(i + 1 + abbreviations[i] + " and " + (j + 1) + abbreviations[j] + " email address (" + emailsArr[i].value + ") is repeating. Please enter unique Email address in each fields."), !0;
return !1
}
function rearrangeEmailsInTextBox(emailsArr) {
for (var acceptableEmailsLen = document.getElementsByName("acceptableEmails").length, i = 0; acceptableEmailsLen > i; i++)
"undefined" == typeof emailsArr[i] || 0 == emailsArr[i].length ? $(".addField:last-child").remove() : $('input[name="acceptableEmails"]:eq(' + i + ")").val(emailsArr[i]);
$(".addField").length < acceptableEmailsLen && ($("#bccDropboxEmailFields").find(".addBccEmail").last().show(), $("#bccDropboxEmailFields").find(".bcc-removeCriteria").last().hide())
}
function triggerBccEmailRegenration(viewedUserId) {
var posturl = "/recruit/BCCDropbox.do",
param = "action=triggerRegeneration&viewedUserId=" + viewedUserId + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken);
Utils.showHideLoadingDiv(!0), $.ajax({
type: "POST",
url: posturl,
data: param,
success: function(data) {
Utils.showHideLoadingDiv(), "100" == data ? ($("#triggerBccEmailReGen").hide(), $("#AfterTriggerringBccEmailReGen").show(), setTimeout(function() {
$("#AfterTriggerringBccEmailReGen").attr("style", "")
}, 3e3)) : alert(I18n.getMsg("crm.security.error.add.user"))
},
error: function() {
Utils.showHideLoadingDiv(), alert(I18n.getMsg("crm.security.error.add.user"))
}
})
}
function regenerateBCCEmailAddress() {
var params = "action=regenerate&" + csrfParamName + "=" + encodeURIComponent(csrfToken);
loadThisPage("BCCDropbox", "BCCDropbox.do", "general", showRenegerationSuccessMsg, params)
}
function addEmailFields() {
var len = $("tr.addField").length;
$("tr.addField").length < 5 && ($("tr.addField:eq(" + (len - 1) + ")").clone().appendTo("#bccDropboxEmailFields"), $("tr.addField:eq(" + (len - 1) + ")").find("td:last-child").find(".addBccEmail").hide(), $("tr.addField:eq(" + (len - 1) + ")").find("td:last-child").find(".deleteIcon").show(), $("tr.addField:eq(" + len + ")").find("input:text").val(""), 5 == $("tr.addField").length && ($("tr.addField:eq(" + len + ")").find("td:last-child").find(".addBccEmail").hide(), $("tr.addField:eq(" + len + ")").find("td:last-child").find(".deleteIcon").show()))
}
function showRenegerationSuccessMsg() {
removeFreezeLayer();
var regenSuccessmsg = I18n.getMsg("bccdropbox.user.regen.success");
crmui.showMsgBand("success", regenSuccessmsg, 3e3, "")
}
function updateSearchPattern(contactCreateRole, leadCreateRole) {
var options = document.getElementsByName("srchPattern"),
option_len = options.length,
selected_option = 0,
selOpt = 1,
hideEl1 = !1,
hideEl2 = !1,
hideEl3 = !1;
null != $("#hiddenDefault1") && (hideEl1 = $("#hiddenDefault1").is(":visible")), null != $("#hiddenDefault2") && (hideEl2 = $("#hiddenDefault2").is(":visible")), null != $("#hiddenDefault3") && (hideEl3 = $("#hiddenOptionsDiv3").is(":visible"));
for (var i = 0; option_len > i; i++)
selOpt = i + 1, 1 == options[i].checked && (selected_option = selOpt, void 0 != $('input[name="srchPattern3"]:checked').val() && (hideEl1 || hideEl2 || hideEl3) && (1 == selOpt ? "true" == leadCreateRole && (selected_option = $('input[name="srchPattern3"]:checked').val()) : 2 == selOpt ? "true" == contactCreateRole ? (selected_option = parseInt($('input[name="srchPattern3"]:checked').val()) + 1, "true" == leadCreateRole && selected_option++) : "true" == leadCreateRole && selected_option++ : "true" == contactCreateRole && "true" == leadCreateRole ? 1 == $('input[name="srchPattern3"]:checked').val() ? $("#createWhichModule").length && (selected_option = $("#createWhichModule").val()) : selected_option = parseInt(selOpt) + 4 : ("true" == contactCreateRole || "true" == leadCreateRole) && (selected_option = parseInt($('input[name="srchPattern3"]:checked').val()) + selopt)));
var posturl = "/recruit/BCCDropbox.do",
param = "action=updateSearchPattern&selectedOption=" + selected_option + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken);
Utils.showHideLoadingDiv(!0), $.ajax({
type: "POST",
url: posturl,
data: param,
dataType: "json",
success: function(data) {
if (Utils.showHideLoadingDiv(), "100" == data.result) {
$("#bccDropboxChangePattern").hide(), removeFreezeLayer(), $("#searchPatternDiv span").text(data.resourceValue);
var bccUpdateSucc = I18n.getMsg("bccdropbox.search.pattern.success");
crmui.showMsgBand("success", bccUpdateSucc, 3e3, "")
} else
alert(I18n.getMsg("crm.security.error.add.user"))
},
error: function() {
Utils.showHideLoadingDiv(), alert(I18n.getMsg("crm.security.error.add.user"))
}
})
}
function showNHideSuccessMsg(successMsgDivId) {
$.scrollTo("#basic", {
axis: "y",
duration: 1e3,
offset: -50
}), $("#" + successMsgDivId).show(), $("#result").addClass("posRel"), $(".sarr").hide();
var pos = $("#result").width() / 2 - $("#succMsgTbl").width() / 2;
$("#succMsgTbl").css("left", pos), setTimeout('callBckAfterSuccessMsgDisp( "' + successMsgDivId + '" )', 3e3)
}
function showNHideBCCSuccessMsg(successMsgDivId) {
$("#" + successMsgDivId).show()
}
function callBckAfterSuccessMsgDisp(successMsgDivId) {
$("#" + successMsgDivId).hide(), $("#result").removeClass("posRel"), $(".sarr").show()
}
function validationCheck(el) {
var _el = $(el);
_el.hasClass("bccInptErr") && ($(".bccInptErr").removeClass("bccInptErr"), $("#excludeDomains_errorMsg").hide())
}
function triggerHiddenOptions(el) {
var _el = $(el);
_el.closest("tr").find("input")[0].click()
}
function bccDropboxSearchHiddenOptions(noOfOptionsProvided, selOption, contactCreateRole, LeadCreateRole) {
3 == selOption ? ("true" == contactCreateRole || "true" == LeadCreateRole) && ($("#hiddenOptionsDiv3").slideDown(), $("#hiddenDefault3").prop("checked", !0)) : (document.getElementById("hiddenOptionsDiv3").style.display = "none", $("#hiddenOptionsDiv3").slideUp()), 2 == selOption ? "true" == contactCreateRole && ($("#hiddenOptionsDiv2").slideDown(), $("#hiddenDefault2").prop("checked", !0)) : $("#hiddenOptionsDiv2").slideUp(), 1 == selOption ? "true" == LeadCreateRole && ($("#hiddenOptionsDiv1").slideDown(), $("#hiddenDefault1").prop("checked", !0)) : $("#hiddenOptionsDiv1").slideUp()
}
function associateJO(module, elem) {
var permission = elem && 0 != elem.length ? $(elem).data("permission") : !0;
if (!permission)
return Utils.displayPermissionDenied(), !1;
if ($("#smeEntityId").length > 0)
return crmTab.commentAndAssociate(), !1;
var form = document.viewentityform;
"undefined" != typeof formobj && (form = formobj[0]);
var listview = !0;
if (void 0 != form && (listview = !1), listview)
noofrows = crmTab.getFromCache(module).body.length, 0 == noofrows && (noofrows = crmTab.getFromCache(module).address.address_jsonarrayObj.length), checked = crmTab.getFromCache(module).selectedIds.length;
else {
if (!$("[name=chk]"))
return;
noofrows = $("[name=chk]").length, checked = $("[name=chk]:checked").length
}
var append_ids = "",
append_names = "";
if (1 == noofrows) {
if (0 == checked) {
var str = I18n.getMsg("crm.alert.select.one", module);
return alert(str), !1
}
if (1 == listview)
append_ids = crmTab.getFromCache(module).selectedIds[0];
else {
var values = $("[name=chk]")[0].value.split("&&||");
append_ids = values[0], append_names = values[1]
}
document.viewentityform && (form.idlist.value = append_ids, form.namelist.value = append_names)
} else if (0 != noofrows) {
if (0 == checked) {
void 0 == module && (module = "");
var str = I18n.getMsg("crm.alert.select.one", module);
return alert(str), !1
}
if (1 == listview)
append_ids = crmListView.getObject().selectedIds.join(";");
else {
var chkObj = $("[name=chk]");
for (i = 0; noofrows > i; i++)
if (chkObj[i].checked) {
var values = chkObj[i].value.split("&&||"),
ids = values[0],
names = values[1];
append_ids = ids + ";" + append_ids, append_names = names + "&&##" + append_names
}
document.viewentityform && (form.idlist.value = append_ids, form.namelist.value = append_names)
}
}
if ("asspopout" == ZRCommonUtil.FILTERRECORDS)
ZRAssociateUtil.assoCandForDiffJob(void 0, void 0, append_ids, ZRCommonUtil.FILTERJOBID);
else {
var loc = "/recruit/AddRecords.do?module=Potentials&relmodule=Leads&isBulk=true";
Crm.addToHistory(void 0, void 0, {
clickId: "actionMenu",
entityId: append_ids,
isBulk: "true",
module: "Potentials",
relmodule: "Leads",
calleeObj: "Crm"
}, loc)
}
}
function loadOptionsElement(target, optionKeyValues) {
var tgt = $(target),
count = 0,
optionArr = ZRCommonUtil.convertStringToJson(optionKeyValues);
for (var i in optionArr)
tgt.append(Utils.createHTML({
name: "option",
attr: {
value: i
},
child: [{
name: "text",
html: I18n.getMsg(optionArr[i])
}]
})), count++;
if (1 != count) {
var noneI18n = "- " + I18n.getMsg("crm.report.none") + " -";
tgt.prepend(Utils.createHTML({
name: "option",
attr: {
value: "None`true"
},
html: noneI18n
}))
}
var firstOption = $(tgt.find("option").first());
firstOption.attr("selected", "true"), tgt.attr("data-previousValue", firstOption.val())
}
function createAlert(msg, isBody) {
removeAlert();
var errElem = Utils.createHTML({
name: "div",
attr: {
"class": "up-error alertInsideComponent mT5"
},
child: [{
name: "div",
attr: {
"class": "alt-failure"
},
child: [{
name: "i",
attr: {
"class": "fa fa-exclamation-circle fa-fw"
}
}, {
name: "span",
html: msg,
child: [{
name: "a",
attr: {
"class": "at-close",
href: "javascript:void(0)"
},
html: "x",
events: [{
name: "click",
fn: "removeAlert"
}]
}]
}]
}]
}),
fileAttachContainerelem = $("#fileAttachContainer");
if (isBody) {
var errElem = Utils.createHTML({
name: "div",
attr: {
"class": "up-error alertInComponent"
},
child: [{
name: "div",
attr: {
"class": "alt-failure"
},
child: [{
name: "i",
attr: {
"class": "fa fa-exclamation-circle fa-fw"
}
}, {
name: "span",
html: msg,
child: [{
name: "a",
attr: {
"class": "at-close",
href: "javascript:void(0)"
},
html: "x",
events: [{
name: "click",
fn: "removeAlert"
}]
}]
}]
}]
});
isBody.prepend(errElem)
} else
fileAttachContainerelem.length && (fileAttachContainerelem.before(errElem), fileAttachContainerelem.addClass("mT5"), fileAttachContainerelem.removeClass("mT20"), $(".subAttachDialogDiv").css("height", "685px"));
$(errElem).show(), isBody && setTimeout(function() {
removeAlert()
}, 5e3)
}
function removeAlert() {
var errMsgElem = $(".up-error");
errMsgElem.length && errMsgElem.remove();
var fileAttachContainerelem = $("#fileAttachContainer");
fileAttachContainerelem.addClass("mT20"), fileAttachContainerelem.removeClass("mT5"), $(".subAttachDialogDiv").height("height", "650px")
}
function checkAttachFileForDesktop() {
if ($("#desktopTab").length) {
var lielems = $("#filesUl").find("li"),
count = lielems.length,
attachLimit = 20,
filesize = 0;
if (lielems.each(function(i, lielem) {
if (lielem = $(lielem), lielem.data("droppingFieldName")) {
var file = dropFiles[lielem.data("droppingFieldName")][lielem.data("dropNo")],
fileType = file.type;
if ("application/x-ms-dos-executable" == fileType || "application/x-msdownload" == fileType)
return createAlert(I18n.getMsg("crm.cloudpicker.invalid.filetype")), !1;
filesize += file.size
}
}), 0 == filesize || 0 == count)
return createAlert(I18n.getMsg("crm.cloudpicker.attaching.nofile")), !1;
if (filesize > 1024 * attachLimit * 1024)
return createAlert(I18n.getMsg("crm.cloudpicker.attach.size.exceed", "20MB")), !1;
if (count > 5)
return createAlert(I18n.getMsg("crm.cloudpicker.file.limit.exceed", "5")), !1;
if (!$("#cate").is(":visible") && $("#atch").is(":visible")) {
$("#fileAttachForm input[name=Attach]").attr({
style: "opacity: 0.7;",
disabled: "true"
}), $("#atch").hide(), $("#shownotes").css("border", "none"), $("#cate").show();
var pElem = $(Utils.createHTML({
name: "div",
attr: {
id: "tempDiv"
}
})),
noOfSelect = count;
lielems.each(function(i, lielem) {
if (lielem = $(lielem), lielem.data("droppingFieldName")) {
var file = dropFiles[lielem.data("droppingFieldName")][lielem.data("dropNo")];
if (file) {
var categories = Utils.createHTML({
name: "div",
attr: {
"class": "newSelect marL20"
},
child: [{
name: "select",
attr: {
id: "select_" + i,
name: "select_" + i,
"class": "select fR w200"
}
}]
}),
name = file.name,
attachClass = ZRFileUtil.getAttachClassName(name),
displayName = name;
if (name.length > 30) {
var dotObj = ZRFileUtil.getAttachDotVal(name, "30");
displayName = dotObj.dotVal
}
var title = Utils.createHTML({
name: "b",
attr: {
title: $ESAPI.encoder().encodeForHTMLAttribute(name)
},
child: [{
name: "text",
html: displayName
}]
}),
addElem = Utils.createHTML({
name: "p",
attr: {
"class": "att-list",
style: "border:none;"
},
child: [{
name: "img",
attr: {
width: "16px",
border: "0",
align: "absmiddle",
hspace: "3",
height: "16px",
style: "display:inline-block;",
"class": attachClass,
src: "images/spacer.gif"
}
}]
});
$(addElem).append(title).append(categories), pElem.append(addElem)
}
}
});
var attachListElem = $("#attachList");
attachListElem.append(pElem);
var compleSelectElemt = attachListElem.find("select");
compleSelectElemt.each(function(selectNo, item) {
loadOptionsElement(item, $("#categories").html())
}), compleSelectElemt.on("change", function(ev) {
ChangeOptionComponent(ev.target, noOfSelect)
});
var componentElem = $("#attachmentUl");
componentElem && componentElem.length > 0 && (componentElem.parent().addClass("dN"), componentElem.parent().parent().removeClass("pbr-modal-container"));
var filesUlelem = $("#filesUl");
return filesUlelem && filesUlelem.length > 0 && filesUlelem.hide(), !1
}
}
var list = $("#attachmentList").val();
if (null != list && list.length > 0) {
var callbacks = {
success: function(data) {
if (data.indexOf("isStorageLimitExceed") > 1)
ZRCommonUtil.createInfoBox({
title: I18n.getMsg("crm.formula.alert"),
content: I18n.getMsg("file.exceed.desktop"),
saveclass: "primarybtn"
});
else {
$("#ajax_load_tab").show();
var module = $("#module");
$("#candInnerQV").length > 0 && $("#candInnerQV").remove(), module && module.length > 0 && "Events" == module.val() ? $("body").append(data) : reloadPersonality("attachmentspersonality")
}
close2Comp(), $("#ajax_load_tab").hide()
},
fail: function(data) {
ZRCommonUtil.createInfoBox(data.indexOf("isStorageLimitExceed") > 1 ? {
title: I18n.getMsg("crm.formula.alert"),
content: I18n.getMsg("file.exceed.desktop"),
saveclass: "primarybtn"
} : data.indexOf("isFileSizeExceed") > 1 ? {
title: I18n.getMsg("crm.livedesk.error"),
content: I18n.getMsg("crm.cloudpicker.attach.size.exceed", "20MB"),
saveclass: "primarybtn"
} : {
title: I18n.getMsg("crm.livedesk.error"),
content: I18n.getMsg("crm.security.error.add.user"),
saveclass: "primarybtn"
}), close2Comp(), $("#ajax_load_tab").hide()
}
},
formData = ZRCommonUtil.formData2Query(document.fileAttachForm);
formData[csrfParamName] = csrfToken;
var cvidElem = $("input[name='cvid']");
cvidElem.length && (formData.cvid = cvidElem.val());
var attachTotCntElem = $("#attachTotCnt");
return attachTotCntElem.length && (formData.attachTotCnt = attachTotCntElem.val()), formData.isCloudPicker1 = "true", ZRCommonUtil.ajaxUpload(document.fileAttachForm.action, formData, callbacks, "html", !1, !1), !1
}
}
function validationForImportFrmDoc() {
var length = 0,
size = 0,
fileInps = $("form[name = 'downloadzipfiles']").find("input[type='file']"),
fileFieldName = $(fileInps[0]).attr("name");
if (dropFiles && dropFiles[fileFieldName])
for (var ifd = 0; ifd < dropFiles[fileFieldName].length; ifd++)
if (dropFiles[fileFieldName][ifd]) {
var filName = dropFiles[fileFieldName][ifd].name,
fileExt = filName.substring(filName.lastIndexOf(".") + 1, filName.length),
fileRegex = "^[dprthzoDPRTHZO]{1}[odtxliODTXLI]{1}[cftmpxlCFTMPXL]+$";
fileExt.match(fileRegex) && (length += 1, size += dropFiles[fileFieldName][ifd].size)
}
var strJsonElem = $("#strJson");
if (strJsonElem && strJsonElem.length > 0) {
var strJsonVal = ZRCommonUtil.convertStringToJson(strJsonElem.val());
for (var key in strJsonVal) {
var typeOfService = strJsonVal[key];
typeOfService && (length += typeOfService.length)
}
}
var resultJson = {};
return resultJson.length = length, resultJson.size = size, JSON.stringify(resultJson)
}
function clickForImport(eve, target, tgt) {
tgt = $(tgt);
var inputElem = tgt.parent().next("div.input-base").find("input[type='file']").first();
inputElem.click()
}
function removingDesktopFiles() {
var ulElem = $("#filesUl");
if (ulElem.length) {
var liElem = ulElem.find("li");
liElem.each(function(i, dropli) {
dropli = $(dropli);
var dropFieldName = dropli.data("droppingFieldName"),
dropNo = dropli.data("dropNo");
dropFieldName && (dropFiles[dropFieldName][dropNo] = void 0)
})
}
}
function closingFiles() {
removingDesktopFiles();
var errMsgElem = $(".up-error.alertInsideComponent");
errMsgElem.length && errMsgElem.remove(), $("#mainAttachDialogdiv").remove(), $("#attachmentFreezeLayer").remove()
}
function showingFiles(eve, trgt, target, from, initialfile, customFunction) {
var tgt,
parentTd,
tempFileCount = 0,
tempSizeForBlock = 0,
removalLength = 0,
lielems = $("#filesUl").find("li"),
desktopTabElem = $("#desktopTab");
if (desktopTabElem.length && (!lielems || !lielems.length))
return createAlert(I18n.getMsg("crm.cloudpicker.attaching.nofile")), !1;
from && "importFromSpreadsheet" == from ? tgt = $("#import_excel_file") : !from || "importFromDocument" !== from && "fromSendMail" != from ? from && "migrateFromOtherRecruit" === from ? tgt = $("#attachmentLocation") : parentTd = from && "createEntity" == from ? $(target).parents(".cloudPickerTD").eq(0) : $(target).parents("td").eq(0) : parentTd = $(target).parent().next("div.input-base"), parentTd && parentTd.length && (tgt = parentTd.find("input[type=file]"));
for (var fileno = 0, i = 0; i < lielems.length && (fileno = lielems.eq(i).data("dropNo"), void 0 == fileno); i++)
;
var fileFieldName = tgt.attr("name");
if (from && ("createEntity" == from || "fromSendMail" == from) && desktopTabElem.length) {
if (dropFiles && dropFiles[fileFieldName])
for (var i = fileno; i < dropFiles[fileFieldName].length && dropFiles[fileFieldName][i]; i++)
tempSizeForBlock += dropFiles[fileFieldName][i].size;
if (tempSizeForBlock > 10485760)
return createAlert(I18n.getMsg("crm.cloudpicker.attach.size.exceed", "10MB")), !1
}
if (from && "importFromDocument" == from && desktopTabElem.length) {
var tempJson = ZRCommonUtil.convertStringToJson(validationForImportFrmDoc());
if (tempJson.length > 10)
return createAlert(I18n.getMsg("crm.cloudpicker.nooffiles.exceed")), !1;
if (tempJson.size > 104857600)
return createAlert(I18n.getMsg("crm.cloudpicker.attach.size.exceed", "100MB")), !1
}
if (dropFiles && dropFiles[fileFieldName]) {
initialfile && (fileno = dropFiles[fileFieldName].length - initialfile);
for (var i = fileno; i < dropFiles[fileFieldName].length; i++) {
var file = dropFiles[fileFieldName][i];
if (file) {
tempFileCount += 1;
var fileName = file.name,
size = file.size;
if (from && "importFromSpreadsheet" == from) {
var ext = fileName.substring(fileName.lastIndexOf("."), fileName.length);
if (".xls" != ext && ".xlsx" != ext && ".csv" != ext && ".vcf" != ext && ".ics" != ext)
return dropFiles[fileFieldName][i] = void 0, createAlert(I18n.getMsg("crm.cloudpicker.invalid.filetype")), !1;
var ssFileNameElem = $("#import_xls_filename");
ssFileNameElem.text(fileName).show(), ssFileNameElem.addClass("focus-line");
var strJson = $("#strJson");
strJson && strJson.length > 0 && strJson.remove(), createFileElement(fileName, size, from, tgt), dropFiles[fileFieldName] = [dropFiles[fileFieldName][i]];
break
}
if (from && "migrateFromOtherRecruit" == from) {
var ext = fileName.substring(fileName.lastIndexOf("."), fileName.length);
if (".zip" != ext)
return dropFiles[fileFieldName][i] = void 0, createAlert(I18n.getMsg("crm.cloudpicker.invalid.filetype")), !1;
var ssFileNameElem = $("#import_xls_filename");
ssFileNameElem.text(fileName).show(), ssFileNameElem.addClass("focus-line");
var strJson = $("#strJson");
if (strJson && strJson.length > 0 && strJson.remove(), !ZRCommonUtil.isEmpty(fileName)) {
var dotObj = ZRFileUtil.getAttachDotVal(fileName, "20"),
tempfileName = dotObj.dotVal,
titleStr = dotObj.title;
titleStr || (titleStr = tempfileName);
var elem = Utils.createHTML({
name: "div",
data: {
droppingFieldName: fileFieldName,
dropNo: 0
},
attr: {
id: "econ_parent_1",
"class": "fileInfo fileNameInIFD fileLiClass",
style: "background-color:#f6f6f6;width:420px;padding:1px"
},
child: [{
name: "div",
attr: {
id: "econid_1",
"class": "gnormallable",
style: "font-size: 13px; padding: 4px 1px;",
title: titleStr
},
html: $ESAPI.encoder().encodeForHTML(tempfileName)
}, {
name: "a",
attr: {
href: "javascript:void(0)",
"class": "removImportFromDoc"
},
events: [{
name: "click",
fn: "removeFile",
args: [from]
}],
html: "X"
}]
});
tgt.parents("td").eq(0).append(elem), dropFiles[fileFieldName] = [dropFiles[fileFieldName][i]];
break
}
} else if (!from || "importFromDocument" != from && "fromSendMail" != from) {
if (from && "createEntity" == from) {
var tempCount = i;
if (tgt.data("attachdetail") && "false" == tgt.data("attachdetail").isbulk) {
var attachTypeId = tgt.data("attachdetail").attachid,
strJson = $("#strJson");
if (strJson.length) {
var respVal = ZRCommonUtil.convertStringToJson(strJson.val());
for (var type in respVal) {
for (var docInfo = respVal[type], doc = 0; doc < docInfo.length; doc++)
docInfo[doc].attachmentTypeId == attachTypeId && docInfo.splice(doc, 1);
respVal[type] = docInfo
}
strJson.val(JSON.stringify(respVal))
}
parentTd.find(".addEntFileDetail").remove(), dropFiles[fileFieldName] = [dropFiles[fileFieldName][i]], tempCount = 0
}
createFileElement(fileName, size, from, tgt, void 0, void 0, fileFieldName, tempCount)
} else if (customFunction && "function" == typeof customFunction) {
var tempJson = {};
tempJson.fileName = fileName, tempJson.size = size, tempJson.fileFieldName = fileFieldName, tempJson.fileNo = i, customFunction(tempJson)
}
} else if ("importFromDocument" == from) {
var fileExt = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length),
fileRegex = "^[dprthzoDPRTHZO]{1}[odtxliODTXLI]{1}[cftmpxlCFTMPXL]+$";
fileExt.match(fileRegex) ? createFileElement(fileName, size, from, tgt, void 0, void 0, fileFieldName, i) : (removalLength++, dropFiles[fileFieldName][i] = void 0)
} else
createSendMailElement(fileName, size, from, tgt, void 0, void 0, i, file, void 0, void 0)
}
}
}
if (tempFileCount || (removalLength = lielems.length), removalLength && removalLength == dropFiles[fileFieldName].length - fileno && desktopTabElem.length)
return "importFromDocument" == from ? createAlert(I18n.getMsg("crm.cloudpicker.invalid.msg.for.import", ["0/" + removalLength, removalLength + "/" + removalLength])) : "importFromSpreadsheet" == from && createAlert(I18n.getMsg("crm.cloudpicker.invalid.filetype")), !1;
if (removalLength) {
var totalFileLength = dropFiles[fileFieldName].length - fileno,
addedNoOfFiles = totalFileLength - removalLength;
return createAlert(I18n.getMsg("crm.cloudpicker.invalid.msg.for.import", [addedNoOfFiles + "/" + totalFileLength, removalLength + "/" + totalFileLength]), $("body")), $("#mainAttachDialogdiv").remove(), $("#attachmentFreezeLayer").remove(), !1
}
var errMsgElem = $(".up-error.alertInsideComponent");
errMsgElem.length && errMsgElem.remove(), $("#mainAttachDialogdiv").remove(), $("#attachmentFreezeLayer").remove()
}
function changingDesktop(event, target, params, createDetailElem, files) {
if (event)
var tgt = $(event.target);
else if (target)
var tgt = $(target);
removeAlert();
var from = tgt.data("from"),
allFiles = tgt[0].files,
filesArray = $.makeArray(allFiles),
fileElementName = tgt.attr("name"),
fileUl = $("#filesUl");
(void 0 == params || void 0 == params.isVendorPortal) && tgt.val(""), fileUl && 0 != fileUl.length || !filesArray.length || creatingFileUlElm();
for (var c = 0; c < filesArray.length; c++) {
var file = filesArray[c];
if (file && file.name) {
var fileName = file.name,
size = file.size,
desktopComponentDiv = $("#desktopTab");
if (void 0 == dropFiles && (dropFiles = {}), dropFiles[fileElementName] || (dropFiles[fileElementName] = []), from && "createEntity" == from) {
var isbulk = tgt.data("attachdetail").isbulk;
if ("false" == isbulk && desktopComponentDiv.length) {
for (var lielems = fileUl.find("li"), k = 0; k < lielems.length; k++) {
var tempfileno = lielems.eq(k).data("dropNo");
void 0 != tempfileno && lielems.eq(k).data("droppingFieldName") == fileElementName && dropFiles[fileElementName] && (dropFiles[fileElementName][tempfileno] = void 0)
}
if (dropFiles[fileElementName] && dropFiles[fileElementName].length)
for (var j = 0; tempfileno > j; j++)
if (dropFiles[fileElementName][j]) {
dropFiles[fileElementName] = [dropFiles[fileElementName][j]];
break
}
fileUl.empty()
}
var tempArrayLength = dropFiles[fileElementName].length;
desktopComponentDiv.length && createFileElement(fileName, size, "createEntityComponent", void 0, void 0, void 0, fileElementName, tempArrayLength)
} else if (from && "importFromDocument" == from) {
var tempArrayLength = dropFiles[fileElementName].length;
desktopComponentDiv.length && createFileElement(fileName, size, "importFDdropFiles", void 0, void 0, void 0, fileElementName, tempArrayLength)
} else if (from && "importFromSpreadsheet" == from)
if (desktopComponentDiv.length) {
for (var lielems = fileUl.find("li"), k = 0; k < lielems.length; k++) {
var tempfileno = lielems.eq(k).data("dropNo");
void 0 != tempfileno && lielems.eq(k).data("droppingFieldName") == fileElementName && dropFiles[fileElementName] && (dropFiles[fileElementName][tempfileno] = void 0)
}
if (dropFiles[fileElementName] && dropFiles[fileElementName].length)
for (var j = 0; tempfileno > j; j++)
if (dropFiles[fileElementName][j]) {
dropFiles[fileElementName] = [dropFiles[fileElementName][j]];
break
}
fileUl.empty();
var tempArrayLength = dropFiles[fileElementName].length;
createFileElement(fileName, size, "importFromSpreadsheet", void 0, void 0, void 0, fileElementName, tempArrayLength)
} else {
dropFiles[fileElementName] = [];
var ssFileNameElem = $("#import_xls_filename");
ssFileNameElem.text(fileName).show(), ssFileNameElem.addClass("focus-line");
var strJson = $("#strJson");
strJson && strJson.length > 0 && strJson.remove()
}
else if (params) {
params = ZRCommonUtil.convertStringToJson(params);
var singleInput = params.singleInput ? params.singleInput : void 0,
isSingle = params.single ? params.single : !1,
uniqueVariable = params.uniqueVariable ? params.uniqueVariable : void 0,
uniqueValue = params.uniqueValue ? params.uniqueValue : void 0,
paramfrom = params.from ? params.from : void 0;
if (dropFiles[fileElementName] || (dropFiles[fileElementName] = []), desktopComponentDiv.length) {
if (isSingle) {
for (var lielems = fileUl.find("li"), k = 0; k < lielems.length; k++) {
var tempfileno = lielems.eq(k).data("dropNo");
void 0 != tempfileno && lielems.eq(k).data("droppingFieldName") == fileElementName && dropFiles[fileElementName] && (dropFiles[fileElementName][tempfileno] = void 0)
}
if (dropFiles[fileElementName] && dropFiles[fileElementName].length)
for (var j = 0; tempfileno > j; j++)
if (dropFiles[fileElementName][j]) {
dropFiles[fileElementName] = [dropFiles[fileElementName][j]];
break
}
fileUl.empty()
}
var tempArrayLength = dropFiles[fileElementName].length;
createFileElement(fileName, size, paramfrom, void 0, void 0, void 0, fileElementName, tempArrayLength)
} else {
if (isSingle) {
dropFiles[fileElementName] = [];
var strJsonElem = $("#strJson");
if (strJsonElem.length && uniqueVariable && uniqueValue) {
var respVal = ZRCommonUtil.convertStringToJson(strJsonElem.val());
for (var type in respVal) {
for (var docInfo = respVal[type], doc = 0; doc < docInfo.length; doc++)
docInfo[doc][uniqueVariable] == uniqueValue && docInfo.splice(doc, 1);
respVal[type] = docInfo
}
strJsonElem.val(JSON.stringify(respVal))
}
strJsonElem && singleInput && strJsonElem.remove()
}
var tempArrayLength = dropFiles[fileElementName].length;
if (createDetailElem && "function" == typeof createDetailElem) {
fileName = ZRFileUtil.getFileName(fileName);
var tempargs = {
fileName: fileName,
noOfFiles: tempArrayLength
};
createDetailElem(tempargs)
}
}
params.callback && "function" == typeof params.callback && params.callback()
} else {
var tempArrayLength = dropFiles[fileElementName].length;
createFileElement(fileName, size, "detailDropFiles", void 0, void 0, void 0, fileElementName, tempArrayLength)
}
dropFiles[fileElementName].push(filesArray[c])
}
}
if (files && tgt.length) {
var filesArray = files,
isBulk = tgt.data("isBulk"),
fieldName = tgt.attr("name");
if (isBulk) {
fileUl && 0 != fileUl.length || creatingFileUlElm();
for (var i = 0; i < filesArray.length; i++) {
dropFiles[fieldName] || (dropFiles[fieldName] = []);
var tempLength = dropFiles[fieldName].length;
dropFiles[fieldName].push(filesArray[i]), createFileElement(filesArray[i].name, filesArray[i].size, void 0, void 0, void 0, void 0, fieldName, tempLength)
}
} else {
if (filesArray.length > 1)
return void createAlert(I18n.getMsg("crm.cloudpicker.importfromss.exceed.filelimit"));
if (1 == filesArray.length) {
if (fileUl = $("#fileUl"), fileUl && fileUl.length > 0) {
for (var lielems = fileUl.find("li"), k = 0; k < lielems.length; k++) {
var tempfileno = lielems.eq(k).data("dropNo");
void 0 != tempfileno && lielems.eq(k).data("droppingFieldName") == fieldName && dropFiles[fieldName] && (dropFiles[fieldName][tempfileno] = void 0)
}
fileUl.parent().remove()
}
if (dropFiles[fieldName] && dropFiles[fieldName].length)
for (var j = 0; tempfileno > j; j++)
if (dropFiles[fieldName][j]) {
dropFiles[fieldName] = [dropFiles[fieldName][j]];
break
}
dropFiles[fieldName] || (dropFiles[fieldName] = []), creatingFileUlElm(), createFileElement(filesArray[0].name, filesArray[0].size, "importFromSpreadsheet", void 0, void 0, void 0, fieldName, 0), dropFiles[fieldName].push(filesArray[0])
}
}
}
!from || "importFromDocument" != from && "fromSendMail" != from || desktopComponentDiv.length ? from && "createEntity" == from && !desktopComponentDiv.length && showingFiles(void 0, void 0, tgt, from, filesArray.length) : showingFiles(void 0, void 0, "#mainmenua_econn_0", from, filesArray.length), $(".at-desk").attr("style", "width:40%")
}
function createFileElement(fileName, size, from, tgt, docId, attachmentTypeId, droppingFieldName, dropNo) {
if (fileName = ZRFileUtil.getFileName(fileName), !ZRCommonUtil.isEmpty(fileName)) {
var dotObj = ZRFileUtil.getAttachDotVal(fileName, "20");
fileName = dotObj.dotVal;
var titleStr = dotObj.title;
if (titleStr || (titleStr = fileName), !from || "createEntity" != from && "createEntityCloud" != from)
if (!from || "importFromDocument" != from && "migrateFromOtherRecruit" != from && "fromSendMail" != from) {
var elem = Utils.createHTML({
name: "li",
attr: {
"class": "fileLiClass"
},
data: {
droppingFieldName: droppingFieldName,
dropNo: dropNo
},
child: [{
name: "span",
attr: {
title: titleStr
},
html: $ESAPI.encoder().encodeForHTML(fileName)
}, {
name: "a",
attr: {
href: "javascript:void(0)",
"class": "at-close"
},
events: [{
name: "click",
fn: "removeFile",
args: [from]
}],
html: "X"
}]
}),
filesUl = $("#filesUl");
filesUl && filesUl.length > 0 && filesUl.append(elem)
} else if (tgt && tgt.length && "fromSendMail" == from)
ZRMailUtil.constructAttachFile(fileName, size, dropNo, dropNo, void 0, void 0);
else {
var elem = Utils.createHTML({
name: "div",
data: {
fileno: docId,
attachmentTypeId: attachmentTypeId,
droppingFieldName: droppingFieldName,
dropNo: dropNo
},
attr: {
id: "econ_parent_1",
"class": "fileInfo fileNameInIFD fileLiClass",
style: "background-color:#f6f6f6;width:420px;padding:1px"
},
child: [{
name: "div",
attr: {
id: "econid_1",
"class": "gnormallable",
style: "font-size: 13px; padding: 4px 1px;",
title: titleStr
},
html: $ESAPI.encoder().encodeForHTML(fileName)
}, {
name: "a",
attr: {
href: "javascript:void(0)",
"class": "removImportFromDoc"
},
events: [{
name: "click",
fn: "removeFile",
args: [from]
}],
html: "X"
}]
});
tgt && tgt.length && ("importFromDocument" == from || "fromSendMail" == from) ? tgt.parents("form").find("#mainmenua_econn_0").prepend(elem) : tgt && tgt.length && tgt.parents("td").eq(0).append(elem)
}
else {
var elem = Utils.createHTML({
name: "span",
data: {
fileno: docId,
attachmentTypeId: attachmentTypeId,
droppingFieldName: droppingFieldName,
dropNo: dropNo
},
attr: {
"class": "attach-file-list fL btn-chosen-value addEntFileDetail",
title: titleStr
},
html: $ESAPI.encoder().encodeForHTML(fileName),
child: [{
name: "a",
attr: {
"class": "removalTd",
href: "javascript:void(0)"
},
events: [{
name: "click",
fn: "removeFile",
args: [from]
}],
html: "&times;"
}]
});
tgt && tgt.length && tgt.parents(".cloudPickerTD").eq(0).append(elem)
}
}
}
function createSendMailElement(fileName, size, from, tgt, docId, attachmentTypeId, dropNo, fileArr, service, allFields) {
ZRCommonUtil.isEmpty(fileName) || tgt && tgt.length && "fromSendMail" == from && ZRMailUtil.constructAttachFile(fileName, size, dropNo, dropNo, fileArr, service, allFields)
}
function removeFile(event, target, from, callback) {
var tgt = $(event.target);
if (!from || "createEntityCloud" != from && "importFromDocument" != from && "migrateFromOtherRecruit" != from && "fromSendMail" != from)
if (from && "createEntity" == from) {
var lielem = tgt.parents("span");
void 0 != Crm.requestParam.parsedFileName && null != Crm.requestParam.parsedFileName && (ZRCommonUtil.deleteFileFromZfs(Crm.requestParam.parsedFileName), Crm.requestParam.parsedFileName = "")
} else
var lielem = tgt.parents(".fileLiClass").eq(0);
else {
if ("importFromDocument" == from || "migrateFromOtherRecruit" == from || "fromSendMail" == from)
var lielem = tgt.parents(".fileNameInIFD");
else
var lielem = tgt.parents("span");
var fileNo = lielem.data("fileno"),
attachmentTypeId = lielem.data("attachmentTypeId"),
strJsonElem = $("#strJson");
if (strJsonElem && strJsonElem.length > 0) {
var value = ZRCommonUtil.convertStringToJson(strJsonElem.val()),
newValue = {},
isRemoved = !1;
for (var type in value)
if (newValue[type] = [], value[type])
for (var j = 0; j < value[type].length; j++)
value[type][j].docId != fileNo || value[type][j].attachmentTypeId != attachmentTypeId || isRemoved ? newValue[type].push(value[type][j]) : isRemoved = !0;
strJsonElem.val(JSON.stringify(newValue))
}
}
var ulElem = lielem.parents("ul#filesUl");
if (lielem && lielem.length) {
var dropFileNo = lielem.data("dropNo"),
droppingFieldName = lielem.data("droppingFieldName");
dropFiles[droppingFieldName] && (dropFileNo || 0 == dropFileNo ? dropFiles[droppingFieldName][dropFileNo] = void 0 : dropFiles[droppingFieldName] = void 0, dropFiles[droppingFieldName] && 1 == dropFiles[droppingFieldName].length && (dropFiles[droppingFieldName] = void 0));
var uniqueValue = lielem.data("uniqueValue"),
uniqueVariable = lielem.data("uniqueVariable");
if (uniqueValue && uniqueVariable) {
var strJsonElem = $("#strJson");
if (strJsonElem.length) {
var respVal = ZRCommonUtil.convertStringToJson(strJsonElem.val());
for (var type in respVal) {
for (var docInfo = respVal[type], doc = 0; doc < docInfo.length; doc++)
docInfo[doc][uniqueVariable] == uniqueValue && docInfo.splice(doc, 1);
respVal[type] = docInfo
}
strJsonElem.val(JSON.stringify(respVal))
}
}
}
if (lielem.remove(), ulElem && 0 == ulElem.find("li").length) {
var listelem = $(".at-file-list");
listelem && listelem.length > 0 && (listelem.remove(), $(".at-desk").attr("style", "width:100%"))
} else if ("detailDropFiles" == from && $("#fileAttachContainer").length && ulElem && 0 !== ulElem.find("li").length) {
var attachLimit = 20,
filesize = 0,
listItems = ulElem.find("li");
listItems.each(function(i, ulelem) {
if (ulelem = $(ulelem), ulelem.data("droppingFieldName")) {
var file = dropFiles[ulelem.data("droppingFieldName")][ulelem.data("dropNo")];
filesize += file.size
}
}), 1024 * attachLimit * 1024 > filesize && removeAlert()
}
callback && "function" == typeof callback && callback()
}
function openAttachmentComponent(attachmentParams, target, uploadElement, selectedDiv, substituteClass) {
if (!attachmentParams && uploadElement && (uploadElement = $(uploadElement), attachmentParams = uploadElement.data("attachmentparams"), attachmentParams.catIds = JSON.stringify(uploadElement.data("options"))), target && (target = "#" + $(target).attr("id")), attachmentParams && "importFromDocument" == attachmentParams.from) {
var tempJson = ZRCommonUtil.convertStringToJson(validationForImportFrmDoc());
if (10 - tempJson.length < 1)
return createAlert(I18n.getMsg("crm.cloudpicker.nooffiles.exceed"), $("body")), !1
}
if (selectedDiv) {
$("form[name='fileAttachForm']").remove(), $(".componentUl").hide();
var componentElem = Utils.createHTML({
name: "div",
attr: {
"class": "pbr-modal pb-animate-modal pb-candidate-modal md-show",
id: "mainAttachDialogdiv"
},
child: [{
name: "div",
attr: {
"class": "pbr-modal-container clearfix subAttachDialogDiv"
},
child: [{
name: "a",
attr: {
"class": "cls-btn",
href: "javascript:void(0);"
},
events: [{
name: "click",
fn: closingFiles
}]
}, {
name: "div",
attr: {
"class": "at-tab-list pT20 pB5"
},
child: [{
name: "ul",
attr: {
id: "attachmentUl"
},
child: [{
name: "li",
attr: {
name: "#desktopTab"
},
child: [{
name: "a",
attr: {
href: "javascript:;",
id: "componentDesktop"
},
html: I18n.getMsg("crm.cloudpicker.desktop"),
data: {
targetdiv: "#desktopTab"
}
}]
}]
}]
}, {
name: "div",
attr: {
"class": "mT20",
id: "fileAttachContainer"
},
child: [{
name: "div",
attr: {
"class": "atcont",
id: "desktopTab"
}
}]
}]
}]
});
$(componentElem).css("z-index", "10002"), $("body").prepend(componentElem), $("body").prepend(Utils.createHTML({
name: "div",
attr: {
"class": "freezeLayer",
id: "attachmentFreezeLayer"
}
}));
var ulElement = $("#attachmentUl"),
containerElement = $("#fileAttachContainer"),
desktopTabElem = $("#desktopTab");
if (attachmentParams && "true" == isDocsAvailable) {
var length = void 0;
"importFromDocument" == attachmentParams.from ? length = 10 - tempJson.length : "importFromSpreadsheet" == attachmentParams.from && (length = 1);
var liDocsElement = Utils.createHTML({
name: "li",
attr: {
name: "#documentsTab"
},
child: [{
name: "a",
attr: {
href: "javascript:;",
id: "componentDocs"
},
data: {
targetdiv: "#documentsTab"
},
html: I18n.getMsg("crm.cloudpicker.documents"),
events: [{
name: "click",
fn: componentopenZDocsLinkDialog,
args: [attachmentParams.zgid, "component", length, attachmentParams.isBulk, attachmentParams.extraparams]
}]
}]
});
ulElement.append(liDocsElement);
var docsDivElement = Utils.createHTML({
name: "div",
attr: {
"class": "atcont",
id: "documentsTab"
},
child: [{
name: "div",
attr: {
id: "docsTab"
}
}]
});
containerElement.append(docsDivElement);
var documentTabElem = $("#documentsTab");
documentTabElem.append(Utils.createHTML({
name: "div",
attr: {
"class": "clearB"
}
})), documentTabElem.append(Utils.createHTML({
name: "div",
attr: {
"class": "at-mT120 fR componentSaveCancel",
id: "componentSaveCancel"
},
child: [{
name: "input",
attr: {
value: I18n.getMsg("crm.button.cancel"),
name: "Cancel",
"class": "newgraybtn mR10",
type: "button"
},
events: [{
name: "click",
fn: "close2Comp"
}]
}, {
name: "input",
attr: {
"class": "primarybtn",
value: I18n.getMsg("crm.button.attach"),
type: "button"
},
events: [{
name: "click",
fn: getResponseFromDocs,
args: [attachmentParams.attachmentTypeId, attachmentParams.isBulk, attachmentParams.from, attachmentParams.extraparams]
}]
}]
}))
}
if (attachmentParams && "true" == isGadgetsAvailable && gadgetsUrlForCloud && crmUrlForCloud) {
var length = void 0;
"importFromDocument" == attachmentParams.from ? length = 10 - tempJson.length : ("importFromSpreadsheet" == attachmentParams.from || "migrateFromOtherRecruit" == attachmentParams.from) && (length = 1), (attachmentParams.attachlimit || 0 == attachmentParams.attachlimit) && (length = attachmentParams.attachlimit);
var liGadgetsElement = Utils.createHTML({
name: "li",
attr: {
name: "#cloudPickerTab"
},
child: [{
name: "a",
attr: {
href: "javascript:;",
id: "componentCloud"
},
html: I18n.getMsg("crm.cloudpicker.cloud"),
data: {
targetdiv: "#cloudPickerTab"
},
events: [{
name: "click",
fn: componentOpenForDocs,
args: ["gdoc", gadgetsUrlForCloud, crmUrlForCloud, "component", attachmentParams.attachmentTypeId, attachmentParams.isBulk, attachmentParams.from, length, attachmentParams.extraparams]
}]
}]
});
ulElement.append(liGadgetsElement);
var gadgetsDivElement = Utils.createHTML({
name: "div",
attr: {
"class": "atcont",
id: "cloudPickerTab"
}
});
containerElement.append(gadgetsDivElement)
}
if (attachmentParams && attachmentParams.entityId && attachmentParams.module) {
var moduleElem = $("input[name='module']");
moduleElem.length && "Activities" !== moduleElem.val() && (attachmentParams.module = moduleElem.val());
var dropLables = function() {
$("#attach0").click()
},
desktopElement = Utils.createHTML({
name: "form",
attr: {
onsubmit: "return checkAttachFileForDesktop();",
method: "post",
name: "fileAttachForm",
target: "AttachmentFrame",
enctype: "multipart/form-data",
action: "/recruit/fileattach.do?id=" + attachmentParams.entityId + "&module=" + attachmentParams.module
},
child: [{
name: "div",
attr: {
id: "atch",
name: "atch"
},
child: [{
name: "div",
attr: {
"class": "pR"
},
child: [{
name: "input",
attr: {
id: "attach0",
type: "file",
"class": "at-btn",
name: "theFile",
multiple: "multiple"
},
events: [{
name: "change",
fn: "changingDesktop"
}]
}, {
name: "div",
data: {
fileno: 0
},
attr: {
ondrop: "droppingFiles(event,'detailDropFiles');",
id: "labelForDesktop",
"for": "attach0",
"class": "at-desk at-desk1"
},
events: [{
name: "click",
fn: dropLables
}],
child: [{
name: "span",
html: I18n.getMsg("crm.cloudpicker.description")
}]
}]
}, {
name: "div",
attr: {
"class": "clearB"
}
}, {
name: "div",
attr: {
"class": "mT20 fR componentSaveCancel",
id: "componentSaveCancel"
},
child: [{
name: "input",
attr: {
value: I18n.getMsg("crm.button.cancel"),
name: "Cancel",
"class": "newgraybtn mR10",
type: "button",
id: "closeAttachmentComponent"
}
}, {
name: "input",
attr: {
"class": "primarybtn",
value: I18n.getMsg("crm.button.attach"),
type: "submit"
}
}]
}]
}, {
name: "div",
attr: {
id: "categories",
name: "categories",
"class": "dN"
},
child: [{
name: "text",
html: attachmentParams.catIds
}]
}, {
name: "div",
attr: {
id: "cate",
"class": "delete-type-pop attachment-list-pop bsd",
style: "display:none; position: absolute; top: 50%; margin-left: -225px; margin-top: -75px; left: 50%;"
},
data: {
dialog: "remove",
removefreeze: "true"
},
child: [{
name: "a",
attr: {
href: "javascript:;",
"class": "close-confirm zrc-icon-closeb top16",
title: "Close"
},
events: [{
name: "click",
fn: "close2Comp"
}]
}, {
name: "h4",
attr: {
"class": "pop-heading"
},
html: I18n.getMsg("crm.setup.customization.attachmenttype")
}, {
name: "div",
attr: {
"class": "att-list-block",
id: "attachment-list-div"
},
child: [{
name: "div",
attr: {
id: "attachList"
}
}, {
name: "div",
attr: {
"class": "tac mT20"
},
child: [{
name: "input",
attr: {
type: "button",
value: I18n.getMsg("crm.button.save"),
name: "save",
"class": "primarybtn"
},
events: [{
name: "click",
fn: "ZRFileUtil.checkCategories",
args: ["true"]
}]
}, {
name: "input",
attr: {
type: "hidden",
id: "attachmentList",
name: "attachmentList"
}
}]
}]
}]
}]
});
desktopTabElem.append(desktopElement)
} else if (attachmentParams && attachmentParams.module && "createEntity" === attachmentParams.from) {
var desktopElement = Utils.createHTML({
name: "label",
data: {
fileno: 0
},
events: [{
name: "click",
fn: triggerAttachClick,
args: [void 0, target]
}],
attr: {
id: "labelForDesktop",
"class": "at-desk at-desk1 pR",
ondrop: "droppingFiles(event,'" + attachmentParams.from + "','" + target + "');"
},
child: [{
name: "span",
html: I18n.getMsg("crm.cloudpicker.description")
}]
});
desktopTabElem.append(desktopElement), desktopTabElem.append(Utils.createHTML({
name: "div",
attr: {
"class": "clearB"
}
})), desktopTabElem.append(Utils.createHTML({
name: "div",
attr: {
"class": "mT20 fR componentSaveCancel",
id: "componentSaveCancel"
},
child: [{
name: "input",
attr: {
value: I18n.getMsg("crm.button.cancel"),
name: "Cancel",
"class": "newgraybtn mR10",
type: "button",
id: "closeAttachment"
},
events: [{
name: "click",
fn: closingFiles
}]
}, {
name: "input",
attr: {
"class": "primarybtn",
value: I18n.getMsg("crm.button.attach"),
type: "button"
},
events: [{
name: "click",
fn: showingFiles,
args: [target, "createEntity"]
}]
}]
}))
} else if (attachmentParams && attachmentParams.module && ("importFromDocument" === attachmentParams.from || "importFromSpreadsheet" === attachmentParams.from || "migrateFromOtherRecruit" == attachmentParams.from || "fromSendMail" === attachmentParams.from)) {
var desktopElement = Utils.createHTML({
name: "label",
attr: {
id: "labelForDesktop",
ondrop: "droppingFiles(event,'" + attachmentParams.from + "');",
"class": "at-desk at-desk1 pR"
},
events: [{
name: "click",
fn: clickForImport,
args: [target]
}],
child: [{
name: "span",
html: I18n.getMsg("crm.cloudpicker.description")
}]
});
desktopTabElem.append(desktopElement), desktopTabElem.append(Utils.createHTML({
name: "div",
attr: {
"class": "clearB"
}
})), desktopTabElem.append(Utils.createHTML({
name: "div",
attr: {
"class": "mT20 fR componentSaveCancel",
id: "componentSaveCancel"
},
child: [{
name: "input",
attr: {
value: I18n.getMsg("crm.button.cancel"),
name: "Cancel",
"class": "newgraybtn mR10",
type: "button",
id: "closeAttachment"
},
events: [{
name: "click",
fn: closingFiles
}]
}, {
name: "input",
attr: {
"class": "primarybtn",
value: I18n.getMsg("crm.button.attach"),
type: "button"
},
events: [{
name: "click",
fn: showingFiles,
args: [target, attachmentParams.from]
}]
}]
}))
} else
attachmentParams && attachmentParams.desktopElement && "function" == typeof attachmentParams.desktopElement && attachmentParams.desktopElement(desktopTabElem);
attachmentParams && attachmentParams.callbackFun && "function" == typeof attachmentParams.callbackFun && attachmentParams.callbackFun(), 0 == CloudPickerComponent.isLoaded && CloudPickerComponent.init(), $(".atcont").hide();
var showDiv = $(".atcont" + selectedDiv);
showDiv.length ? $('.at-tab-list li[name="' + selectedDiv + '"] a').click() : ($(".atcont:first").show(), $(".at-tab-list li:eq(0)").addClass("active"))
} else {
substituteClass || (substituteClass = "atch-list");
var popupElem = Utils.createHTML({
name: "ul",
attr: {
"class": substituteClass + " componentUl"
},
child: [{
name: "li",
html: I18n.getMsg("crm.cloudpicker.desktop"),
events: [{
name: "click",
fn: openAttachComponent,
args: [attachmentParams, target, uploadElement, "#desktopTab", substituteClass]
}]
}]
}),
componentUlElem = $(target).find(".atDropDown").append(popupElem);
componentUlElem = $(componentUlElem).find(".componentUl"), attachmentParams && "true" == isGadgetsAvailable && gadgetsUrlForCloud && crmUrlForCloud && componentUlElem.append(Utils.createHTML({
name: "li",
html: I18n.getMsg("crm.cloudpicker.cloud"),
events: [{
name: "click",
fn: openAttachComponent,
args: [attachmentParams, target, uploadElement, "#cloudPickerTab", substituteClass]
}]
})), attachmentParams && "true" == isDocsAvailable && componentUlElem.append(Utils.createHTML({
name: "li",
html: I18n.getMsg("crm.cloudpicker.documents"),
events: [{
name: "click",
fn: openAttachComponent,
args: [attachmentParams, target, uploadElement, "#documentsTab", substituteClass]
}]
}))
}
}
function creatingFileUlElm() {
var desktopTabElm = $("#desktopTab"),
filesElem = Utils.createHTML({
name: "div",
attr: {
"class": "at-file-list"
},
child: [{
name: "ul",
attr: {
id: "filesUl"
}
}]
});
desktopTabElm.prepend(filesElem)
}
function droppingFiles(e, from, target) {
e.preventDefault(), e.stopPropagation();
var filesize = 0,
fileUl = $("#filesUl");
fileUl.parent().show();
var ele = $("#labelForDesktop");
if ($(ele).removeClass("fullWidth"), e.dataTransfer) {
var filesArray = $.makeArray(e.dataTransfer.files);
if (filesArray && filesArray.length)
if ("createEntity" == from) {
var tgt = $(target).next(".file-hide"),
isbulk = tgt.data("attachdetail").isbulk,
fileFieldName = "theFile_property(",
fieldName = tgt.attr("name"),
attachType = "";
if ("false" == isbulk && filesArray.length > 1) {
if (fieldName && "" != fieldName && 0 == fieldName.indexOf(fileFieldName)) {
var endIndex = fieldName.lastIndexOf(")");
attachType = fieldName.substring(17, endIndex)
}
var alertMsg = "" != attachType ? I18n.getMsg("crm.clouldpicker.add.entity.bulkerr.msg", attachType) : I18n.getMsg("crm.cloudpicker.importfromss.exceed.filelimit");
return void createAlert(alertMsg)
}
if ("false" == isbulk) {
if (fileUl && fileUl.length > 0) {
for (var lielems = fileUl.find("li"), k = 0; k < lielems.length; k++) {
var tempfileno = lielems.eq(k).data("dropNo");
void 0 != tempfileno && lielems.eq(k).data("droppingFieldName") == fieldName && dropFiles[fieldName] && (dropFiles[fieldName][tempfileno] = void 0)
}
fileUl.parent().remove()
}
if (dropFiles[fieldName] && dropFiles[fieldName].length)
for (var j = 0; tempfileno > j; j++)
if (dropFiles[fieldName][j]) {
dropFiles[fieldName] = [dropFiles[fieldName][j]];
break
}
}
for (var j = 0; null != filesArray && void 0 != filesArray && j < filesArray.length; j++)
filesize = null != filesArray[j] && void 0 != filesArray[j] && void 0 != filesArray[j].size ? filesize + filesArray[j].size : filesize;
if (filesize > 10485760)
return createAlert(I18n.getMsg("crm.cloudpicker.attach.size.exceed", "10MB")), !1;
fileUl = $("#filesUl"), fileUl && 0 != fileUl.length || creatingFileUlElm();
for (var i = 0; i < filesArray.length; i++) {
dropFiles[fieldName] || (dropFiles[fieldName] = []);
var tempLength = dropFiles[fieldName].length;
dropFiles[fieldName].push(filesArray[i]), createFileElement(filesArray[i].name, filesArray[i].size, "createEntityComponent", void 0, void 0, void 0, fieldName, tempLength)
}
$(".at-desk").attr("style", "width:40%")
} else if (from && "detailDropFiles" == from) {
for (var fieldName = "theFile", j = 0; null != filesArray && void 0 != filesArray && j < filesArray.length; j++)
filesize = null != filesArray[j] && void 0 != filesArray[j] && void 0 != filesArray[j].size ? filesize + filesArray[j].size : filesize;
if (filesize > 10485760)
return createAlert(I18n.getMsg("crm.cloudpicker.attach.size.exceed", "10MB")), !1;
fileUl && 0 != fileUl.length || creatingFileUlElm();
for (var i = 0; i < filesArray.length; i++) {
dropFiles[fieldName] || (dropFiles[fieldName] = []);
var tempLength = dropFiles[fieldName].length;
dropFiles[fieldName].push(filesArray[i]), createFileElement(filesArray[i].name, filesArray[i].size, "detailDropFiles", void 0, void 0, void 0, fieldName, tempLength)
}
$(".at-desk").attr("style", "width:40%")
} else if (!from || "importFromDocument" != from && "fromSendMail" != from)
if (!from || "importFromSpreadsheet" != from && "migrateFromOtherRecruit" != from)
target && (target = $("input[name=" + target + "]"), changingDesktop(void 0, target, void 0, void 0, filesArray));
else {
var imoprtDragEle = $("#importsecondaryItem");
if (imoprtDragEle.length && imoprtDragEle.show(), "importFromSpreadsheet" == from)
var fileElem = $("#import_excel_file");
else
var fileElem = $("#attachmentLocation");
var fieldName = fileElem.attr("name");
if (filesArray.length > 1)
return void createAlert(I18n.getMsg("crm.cloudpicker.importfromss.exceed.filelimit"));
if (1 == filesArray.length) {
if (fileUl && fileUl.length > 0) {
for (var lielems = fileUl.find("li"), k = 0; k < lielems.length; k++) {
var tempfileno = lielems.eq(k).data("dropNo");
void 0 != tempfileno && lielems.eq(k).data("droppingFieldName") == fieldName && dropFiles[fieldName] && (dropFiles[fieldName][tempfileno] = void 0)
}
fileUl.parent().remove()
}
if (dropFiles[fieldName] && dropFiles[fieldName].length)
for (var j = 0; tempfileno > j; j++)
if (dropFiles[fieldName][j]) {
dropFiles[fieldName] = [dropFiles[fieldName][j]];
break
}
dropFiles[fieldName] || (dropFiles[fieldName] = []), creatingFileUlElm(), createFileElement(filesArray[0].name, filesArray[0].size, "importFromSpreadsheet", void 0, void 0, void 0, fieldName, dropFiles[fieldName].length), dropFiles[fieldName].push(filesArray[0]), $(".at-desk").attr("style", "width:40%")
}
}
else {
var imoprtDragEle = $("#importsecondaryItem");
imoprtDragEle.length && imoprtDragEle.show();
var fieldName = "theFile";
if ("fromSendMail" == from) {
for (var j = 0; null != filesArray && void 0 != filesArray && j < filesArray.length; j++)
filesize = null != filesArray[j] && void 0 != filesArray[j] && void 0 != filesArray[j].size ? filesize + filesArray[j].size : filesize;
if (filesize > 10485760)
return createAlert(I18n.getMsg("crm.cloudpicker.attach.size.exceed", "10MB")), !1
}
fileUl && 0 != fileUl.length || creatingFileUlElm();
for (var i = 0; i < filesArray.length; i++) {
dropFiles[fieldName] || (dropFiles[fieldName] = []);
var tempLength = dropFiles[fieldName].length;
dropFiles[fieldName].push(filesArray[i]), createFileElement(filesArray[i].name, filesArray[i].size, "importFDdropFiles", void 0, void 0, void 0, fieldName, tempLength)
}
$(".at-desk").attr("style", "width:40%")
}
}
}
function triggerAttachClick(ev, tgt, event, target) {
ZRCommonUtil.triggerAttachClick(event, target)
}
function componentOpenForDocs(event, tgt, mode, attachUrl, crmUrl, from, attachmentTypeId, isBulk, targetFrom, attachlmt, extraparams) {
var loadingEle = $("#ajax_load_tab");
return loadingEle.show(), targetFrom && ("importFromDocument" == targetFrom || "importFromSpreadsheet" == targetFrom || "migrateFromOtherRecruit" == targetFrom) || extraparams ? openForDocs(mode, attachUrl, crmUrl, from, attachmentTypeId, isBulk, targetFrom, attachlmt, extraparams) : openForDocs(mode, attachUrl, crmUrl, from, attachmentTypeId, isBulk, targetFrom, void 0, extraparams), setTimeout(function() {
tgt = $("a#componentCloud"), $(".at-tab-list li").removeClass("active"), tgt.parent().addClass("active");
var currentTab = tgt.data("targetdiv");
currentTab != Utils.getCookie("lastDivForCloudPicker") && removeAlert(), document.cookie = "lastDivForCloudPicker=" + currentTab, $("#docsTab").empty(), $(".atcont").hide(), $(currentTab).show(), loadingEle.hide()
}, 500), !1
}
function componentopenZDocsLinkDialog(event, tgt, zgid, from, attachlmt, isBulk, extraparams) {
var loadingEle = $("#ajax_load_tab");
return loadingEle.show(), $("#docsTab").empty(), openZDocsLinkDialog(zgid, from, attachlmt, isBulk, extraparams), setTimeout(function() {
var tgt = $("a#componentDocs");
$(".at-tab-list li").removeClass("active"), tgt.parent().addClass("active");
var currentTab = tgt.data("targetdiv");
currentTab != Utils.getCookie("lastDivForCloudPicker") && removeAlert(), document.cookie = "lastDivForCloudPicker=" + currentTab, $("#cloudPickerTab").empty(), $(".atcont").hide(), $(currentTab).show(), loadingEle.hide()
}, 500), !1
}
function close2Comp() {
var errMsgElem = $(".up-error.alertInsideComponent");
errMsgElem.length && errMsgElem.remove();
var freezeLayerElem = $("#attachmentFreezeLayer");
freezeLayerElem && freezeLayerElem.length && freezeLayerElem.remove();
var secComp = $("#cloud1");
secComp && secComp.length > 0 && secComp.parent().remove();
var componentDiv = document.getElementById("mainAttachDialogdiv");
componentDiv && componentDiv.parentNode.removeChild(componentDiv), $("form[name=fileAttachForm]").remove(), dropFiles = {}, removeFreezeLayer(), $(".componentUl").remove()
}
function attachUsingComponent() {
var types = [],
alertMsg = !1,
list = $(".att-list"),
listObj = "";
for (i = 0; i < list.length; i++) {
var type = $(list[i]).find("select");
type = $(type).val();
var found = $.inArray(type, types);
if (null === type || "None" === type.split("`")[0]) {
createAlert(I18n.getMsg("crm.attachment.choose.error"), $("body")), alertMsg = !0;
break
}
if (-1 != found && "false" === type.split("`")[1]) {
createAlert(I18n.getMsg("crm.attachment.type.error"), $("body")), alertMsg = !0;
break
}
types.push(type), listObj = "" === listObj ? type : listObj + "," + type
}
if (!alertMsg) {
var attList = document.getElementById("attachmentList");
attList.value = listObj, submitUsingComponent()
}
}
function submitUsingComponent() {
submitForCloudPicker()
}
function submitForCloudPicker(from) {
var alertMsg,
module = "",
action = "",
isReturn = !1,
returnVal = !1;
if (loadAjaxTab(""), from && "createEntity" == from) {
isReturn = !0, module = $("#module").val();
var strJson = $("#strJson").val();
action = "/recruit/docsSubmit.do?strjson=" + encodeURIComponent(strJson) + "&module=" + module + "&pname=ATTACHMENTSPERSONALITY&" + csrfParamName + "=" + csrfToken
} else {
var anchorId = $("#anchorId").val(),
entityId = $("#entityId").val();
module = $("#moduleForIFrame").val(), document.submitComponentForm.action = "/recruit/docsSubmit.do?" + formData2QueryString(document.getElementsByName("submitComponentForm")[0]) + "entityID=" + entityId + "&module=" + module + "&anchorId=" + anchorId + "&pname=ATTACHMENTSPERSONALITY&" + csrfParamName + "=" + csrfToken, action = document.submitComponentForm.action
}
return mR(action, function(resp) {
var listRelationId = parent.$("[name=ID_ATTACHMENTSPERSONALITY]").val();
null != resp && void 0 != resp && resp.indexOf("cloudPickerStorageExceeded") > -1 ? alertMsg = I18n.getMsg("file.exceed.desktop") : null != resp && void 0 != resp && resp.indexOf("cloudPickerLimitExceeded") > -1 ? alertMsg = I18n.getMsg("crm.mail.attach.restriction.individual.error") : "Events" != module || isReturn ? isReturn ? null != resp && void 0 != resp && (returnVal = resp) : (reloadPersonality("attachmentspersonality"), replacePersonality(resp, listRelationId)) : ($("#show #eventsRightPanelAttachDiv").html($(resp).find("#eventsRightPanelAttachDiv").html()), $(".cntSpn").show()), isReturn || parent.clearShowCacheObj("tab_" + module)
}, void 0, void 0, void 0, !1), isReturn || close2Comp(), alertMsg && ZRCommonUtil.createInfoBox({
title: I18n.getMsg("crm.formula.alert"),
content: alertMsg,
saveclass: "primarybtn"
}), returnVal
}
function ChangeOptionComponent(chBox, noOfSelect) {
var checkBoxElem = $(chBox),
str = checkBoxElem.val(),
isBulk = str.split("`")[1],
previousValue = checkBoxElem.attr("data-previousValue"),
isBulk1 = previousValue.split("`")[1];
checkBoxElem.attr("data-previousValue", str);
for (var i = (str.split("`")[0], 0); noOfSelect > i; i++)
for (var item = $("#select_" + i)[0], options = $("#select_" + i + " option"), k = 0; k < options.length; k++) {
var thisoption = options.eq(k),
str1 = thisoption.val();
previousValue === str1 && "false" === isBulk1 && thisoption.prop("disabled", !1), str === str1 && "false" === isBulk && item !== chBox && thisoption.prop("disabled", !0)
}
}
function triggerFileClickForDetailPage(attachmentParams, element) {
if (element) {
var elem = $(element);
attachmentParams = elem.data("attachmentparams"), attachmentParams.catIds = elem.data("options")
}
var formElem = $("form[name='fileAttachForm']");
formElem.length && formElem.remove();
var desktopElement = Utils.createHTML({
name: "form",
attr: {
onsubmit: "return checkAttachFileForDesktop();",
method: "post",
name: "fileAttachForm",
target: "AttachmentFrame",
enctype: "multipart/form-data",
id: "fileAttachFormFromComponent",
action: "/recruit/fileattach.do?id=" + attachmentParams.entityId + "&module=" + attachmentParams.module
},
child: [{
name: "div",
attr: {
id: "atch",
name: "atch"
},
child: [{
name: "input",
attr: {
id: "attach0",
type: "file",
"class": "at-btn",
name: "theFile",
multiple: "multiple"
},
events: [{
name: "change",
fn: "changingdesktopInDetail",
args: [attachmentParams.catIds]
}]
}]
}, {
name: "div",
attr: {
id: "cate",
"class": "delete-type-pop attachment-list-pop bsd",
style: "display:none; position: fixed; top: 50%; margin-left: -225px; margin-top: -75px; left: 50%;"
},
data: {
dialog: "remove",
removefreeze: "true"
},
child: [{
name: "a",
attr: {
href: "javascript:;",
"class": "close-confirm zrc-icon-closeb top16",
title: "Close"
},
events: [{
name: "click",
fn: "close2Comp"
}]
}, {
name: "h4",
attr: {
"class": "pop-heading"
},
html: I18n.getMsg("crm.setup.customization.attachmenttype")
}, {
name: "div",
attr: {
"class": "att-list-block",
id: "attachment-list-div"
},
child: [{
name: "div",
attr: {
id: "attachList"
}
}, {
name: "div",
attr: {
"class": "tac mT20"
},
child: [{
name: "input",
attr: {
type: "button",
value: I18n.getMsg("crm.button.save"),
name: "save",
"class": "primarybtn"
},
events: [{
name: "click",
fn: "ZRFileUtil.checkCategories",
args: ["true"]
}]
}, {
name: "input",
attr: {
type: "hidden",
id: "attachmentList",
name: "attachmentList"
}
}]
}]
}]
}]
});
$("body").append(desktopElement), $(desktopElement).find("input[type=file]").click()
}
function changingdesktopInDetail(event, target, catIds) {
for (var tgt = $(target), files = tgt[0].files, count = files.length, attachLimit = 20, attachCountLimit = 25, filesize = 0, formElem = tgt.parents("form").eq(0), i = 0; i < files.length; i++) {
var file = files[i];
if (file) {
var fileType = file.type;
if ("application/x-ms-dos-executable" == fileType || "application/x-msdownload" == fileType)
return ZRCommonUtil.createInfoBox({
title: I18n.getMsg("crm.livedesk.error"),
content: I18n.getMsg("crm.cloudpicker.invalid.filetype"),
saveclass: "primarybtn"
}), !1;
filesize += file.size
}
}
if (count > attachCountLimit)
return ZRCommonUtil.createInfoBox({
title: I18n.getMsg("crm.livedesk.error"),
content: I18n.getMsg("crm.cloudpicker.attach.count.exceed", attachCountLimit),
saveclass: "primarybtn"
}), !1;
if (filesize > 1024 * attachLimit * 1024)
return ZRCommonUtil.createInfoBox({
title: I18n.getMsg("crm.livedesk.error"),
content: I18n.getMsg("crm.cloudpicker.attach.size.exceed", "20MB"),
saveclass: "primarybtn"
}), !1;
for (var pElem = $(Utils.createHTML({
name: "div",
attr: {
id: "tempDiv"
}
})), noOfSelect = count, i = 0; i < files.length; i++) {
var file = files[i];
if (file) {
var categories = Utils.createHTML({
name: "select",
attr: {
id: "select_" + i,
name: "select_" + i,
"class": "select fR w200"
}
}),
name = file.name,
displayName = name;
if (name.length > 30) {
var dotObj = ZRFileUtil.getAttachDotVal(name, "30");
displayName = dotObj.dotVal
}
var title = Utils.createHTML({
name: "b",
attr: {
title: $ESAPI.encoder().encodeForHTMLAttribute(name)
},
child: [{
name: "text",
html: displayName
}]
}),
addElem = Utils.createHTML({
name: "p",
attr: {
"class": "att-list",
style: "border:none;"
},
child: [{
name: "img",
attr: {
width: "16px",
border: "0",
align: "absmiddle",
hspace: "3",
height: "16px",
"class": "file-icon",
src: "images/spacer.gif"
}
}]
});
$(addElem).append(title).append(categories), pElem.append(addElem)
}
}
var attachListElem = formElem.find("#attachList");
attachListElem.append(pElem.html());
var compleSelectElemt = attachListElem.find("select");
compleSelectElemt.each(function(selectNo, item) {
loadOptionsElement(item, catIds)
}), compleSelectElemt.on("change", function(ev) {
ChangeOptionComponent(ev.target, noOfSelect)
}), freezeBackground(), formElem.find("#cate").show()
}
crmRelatedList = {
Module: "",
EntityId: "",
EachModuleData: {},
ListIds: [],
load: function(module, entityId, moduleData, isNavigation, clickId, emailist) {
if (crmRelatedList.TEMPLATE_SUBMITTOCLIENT = 100, crmRelatedList.tempData = moduleData, !moduleData.Converted_Lead) {
var projectIntegration = 0,
projectListRelationId = "",
returnAnchor = "",
authMsg = "",
portalName = "",
projId = "",
invoiceListRelationId = "",
expenseListRelationId = "",
zsubscriptionsListRelationId = "",
supportIntegration = 0,
mailIntegration = 0,
invoiceIntegration = 0,
expenseIntegration = 0,
subscriptionsIntegration = 0,
socialPers = !1;
if ("string" == typeof moduleData && (moduleData = JSON.parse(moduleData)), module != crmRelatedList.Module && (crmRelatedList.EachModuleData = {}), moduleData.listLabelsJson) {
returnJson.relListLabelsJson.relListLabelJson = moduleData.listLabelsJson, detailView.formNewLeftPanel();
var tableHtmlFun = Handlebars.getTemplate("relatedlist", "RelatedList"),
headerHtml = tableHtmlFun(returnJson.relListLabelsJson);
$("#relatedPageContent").html(headerHtml)
}
crmRelatedList.Module = module, crmRelatedList.EntityId = entityId;
var response = moduleData[crmRelatedList.Module];
for (key1 in response) {
var dataObj = {};
response.hasOwnProperty(key1) && (dataObj = response[key1], crmRelatedList.EachModuleData[key1] = dataObj), dataObj.proceed = moduleData.proceed;
var tableHtmlFun = Handlebars.getTemplate("relatedlist", "RelatedListData"),
tableHtml = tableHtmlFun(dataObj);
if ("RELATEDLISTPERSONALITY" == dataObj.name)
$("#customRelatedListDiv_" + dataObj.listRelationId).html(tableHtml);
else if ("RATINGSREVIEWSPERSONALITY" == dataObj.name) {
var data = dataObj.REVIEW_DATA,
ratingReviewHtml = document.createElement("ratings-reviews"),
showttvalue = I18n.getMsg("cl.detailpage.notes.addedbyclientuser", Handlebars.helpers.getCrmModuleInfo("Accounts", "true"));
data.picklistmap && data.picklistmap.splice(2, 0, {
systemvalue: "Job Based",
uservalue: I18n.getMsg("zr.ratings.reviews.job.based.review")
});
var revRecords = ZRQuestionnaire.getRatingsReviewsRecords(data),
compData = {
meta: {
isLocked: data.isLocked,
isAdminUser: data.isAdminUser,
currentUser: data.currentUser,
picklistmap: data.picklistmap,
leadId: data.leadId,
showttvalue: showttvalue
},
records: revRecords
};
ratingReviewHtml.setData(compData), $("#" + dataObj.listRelationId).html(ratingReviewHtml);
var noRecDiv;
void 0 === data.MODEL_DATA && void 0 !== (noRecDiv = $("#" + dataObj.listRelationId).find(".norec")[0]) && $(noRecDiv).attr("style", "border-top:0px;")
} else
"SUPPORTPERSONALITY" == dataObj.name ? $("#supportdiv").html(tableHtml) : "EMAILSPERSONALITY" == dataObj.name ? emailist || $("#" + dataObj.listRelationId).html(tableHtml) : $("#" + dataObj.listRelationId).html(tableHtml);
if ($(".atchName a").bind("mouseenter", function() {
$(this).outerWidth() > $(this).closest(".atchName").outerWidth() && !$(this).attr("title") && $(this).attr("title", $(this).text().trim())
}), dataObj.isShowColumns) {
var columnsList = "";
$("#" + dataObj.name + "_" + dataObj.listRelationId).siblings("#relatedListCols").length && (columnsList = $("#" + dataObj.name + "_" + dataObj.listRelationId).siblings("#relatedListCols")), $("#" + dataObj.name + "_" + dataObj.listRelationId).after(columnsList)
} else
$("[ddid=" + dataObj.listRelationId + "]").find("#showCustomizeList").remove();
if ("EMAILSPERSONALITY" == dataObj.name && ("Leads" == crmRelatedList.Module || "Vendors" == crmRelatedList.Module || "Contacts" == crmRelatedList.Module || "Accounts" == crmRelatedList.Module || "Potentials" == crmRelatedList.Module || "Quotes" == crmRelatedList.Module || "SalesOrders" == crmRelatedList.Module || "PurchaseOrders" == crmRelatedList.Module || "Invoices" == crmRelatedList.Module || dataObj.isCustomModule || crmRelatedList.Module && -1 !== crmRelatedList.Module.indexOf("CustomModule"))) {
dataObj.mailObj.module = crmRelatedList.Module, dataObj.mailObj.entityId = crmRelatedList.EntityId, dataObj.mailObj.loginUserId = Crm.userDetails.USER_ID, dataObj.mailObj.singularMod = Crm.moduleInfo[crmRelatedList.Module][0], dataObj.mailObj.selectedUserid = void 0 !== $("#userSelDropdownInAccNEWInp").data("userid") ? $("#userSelDropdownInAccNEWInp").data("userid") : Crm.userDetails.USER_ID, dataObj.mailObj.selectedUsername = void 0 !== $("#userSelDropdownInAccNEWInp").data("username") ? $("#userSelDropdownInAccNEWInp").data("username") : Crm.userDetails.DISPLAY_NAME, dataObj.mailObj.selectedContact = void 0 !== $("#contactSelDropdownInAcc :selected").attr("value") ? $("#contactSelDropdownInAcc :selected").attr("value") : crmRelatedList.EntityId, dataObj.mailObj.contactEmails = dataObj.contactEmails;
for (var allUsersListJson = [], allUsersList = [], i = 0; i < allUsersListJson.length; i++) {
var userData = allUsersListJson[i];
if ("user" === userData.type && "Interviewer" !== userData.profileName && "Guest" !== userData.profileName) {
var UserName = (userData.firstName && 0 != userData.firstName.length ? userData.firstName + " " : "") + userData.lastName,
userMap = {};
userMap.name = UserName, userMap.id = userData.id, allUsersList.push(userMap)
}
}
dataObj.mailObj.usersArray = allUsersList, mailIntegration = 1, dataObj.mailObj.contactObject = dataObj.contactObject, $("#zmailEmail").val(dataObj.contactEmails)
}
var perActionParam = {
actions: dataObj.ACTIONS,
rid: dataObj.listRelationId,
name: dataObj.name,
mailObj: dataObj.mailObj,
entityId: crmRelatedList.EntityId,
moduleName: crmRelatedList.Module,
createAttachTypes: dataObj.createAttachTypes,
SELECTED_STATUS: dataObj.SELECTED_STATUS
};
dataObj && dataObj.options && (perActionParam.options = JSON.stringify(dataObj.options)), "ACTIVITYPERSONALITY" === dataObj.name && (perActionParam.activityType = dataObj.activityType);
var personalityActionFun = Handlebars.getTemplate("relatedlist", "personalityAction"),
actionHtml = personalityActionFun(perActionParam);
if (0 == dataObj.body.length && "PROJECTSPERSONALITY" != dataObj.name && "ATTACHMENTSPERSONALITY" != dataObj.name ? "SOCIALPERSONALITY" == dataObj.name ? socialPers = !0 : ($("#ract_" + dataObj.listRelationId).html(""), "EMAILSPERSONALITY" == dataObj.name || "PRODUCTSPERSONALITY" == dataObj.name || "ACTIVITYPERSONALITY" === dataObj.name || "OFFERSPERSONALITY" === dataObj.name ? ($("#ract_" + dataObj.listRelationId).html(actionHtml), returnJson && returnJson.recordInStatusProcess && "true" === returnJson.recordInStatusProcess && ("PRODUCTSPERSONALITY" == dataObj.name || "OFFERSPERSONALITY" == dataObj.name) && $("#ract_" + dataObj.listRelationId).find("a").remove()) : "Leads" == crmRelatedList.Module && returnJson && returnJson.recordInStatusProcess && "true" === returnJson.recordInStatusProcess && "PRODUCTSPERSONALITY_SUBMISSIONPERSONALITY_OFFERSPERSONALITY".indexOf(dataObj.name) > -1 || $("#norec_" + dataObj.listRelationId).html(actionHtml)) : "Leads" == crmRelatedList.Module && returnJson && returnJson.recordInStatusProcess && "true" === returnJson.recordInStatusProcess && "PRODUCTSPERSONALITY_SUBMISSIONPERSONALITY_OFFERSPERSONALITY".indexOf(dataObj.name) > -1 ? ($("#ract_" + dataObj.listRelationId).html(actionHtml), $("#ract_" + dataObj.listRelationId).find("a").remove()) : $("#ract_" + dataObj.listRelationId).html(actionHtml), "ACTIVITYPERSONALITY" === dataObj.name && ($("#todosFilter").selectBox("destory").show(), $("#todosFilter").selectBox({
callback: function(type, element) {
if ("select" === type) {
var selected = element._baseElem.data("selected"),
activityType = selected[0].value,
data = $("#todosFilter").data(),
newParams = {
module: data.module,
pname: data.pname,
id: data.id,
activityType: activityType
};
crmRelatedList.ajaxReq(newParams, null)
}
}
})), $("#filter_interview").selectBox("destory").show(), $("#filter_interview").selectBox({
parent: $("body"),
callback: function(type, element) {
if ("select" === type) {
var selected = element._baseElem.data("selected"),
actualValue = selected[0].value,
newParams = {
module: module,
id: entityId,
rid: $("#filter_interview").data("rid"),
fromIndex: 1,
itype: actualValue
};
crmRelatedList.ajaxReq(newParams, null)
}
}
}), "EMAILSPERSONALITY" == dataObj.name) {
$("#selectMails, #contactSelDropdownInAcc").selectBox("destory").show();
var $userSelDropDownElem = $("#userSelDropdownInAccNEW");
void 0 !== $userSelDropDownElem.data("userlist") && $("#userSelDropdownInAccNEW").userList("destroy");
var params = {
action: "active",
multiple: !1,
issearch: !0,
isgroup: !1,
maxselect: 1,
val: "ALL" !== dataObj.mailObj.selectedUserid ? dataObj.mailObj.selectedUserid + "" : void 0,
type: "EmailRelatedList",
format: "Name",
callback: function(type, $this, curElem) {
if ("select" === type || "create" === type || "open" === type || "search" === type || "next" === type || "prev" === type) {
var $elem = $this.$element,
$drop = $this._baseElem,
elemPos = $elem.offset();
if (elemPos.left + $drop.outerWidth() > window.innerWidth && $drop.css({
left: elemPos.left - $drop.outerWidth() + $elem.outerWidth() + "px"
}), "create" === type && $this._dropdown.prepend($this._getItem([{
id: "ALL",
profileName: "Administrator",
fullName: I18n.getMsg("crm.label.all")
}], "user")), "select" === type) {
var selected = (curElem.data(), $this._baseElem.data("selected"));
$this.$element.find(".chosen-choices").text("");
var $newInp = $("#userSelDropdownInAccNEWInp");
$newInp.data("userid", selected[0].id), $newInp.data("username", "ALL" === selected[0].id && void 0 === selected[0].item ? I18n.getMsg("crm.label.all") : selected[0].item.fullName), $("#userSelDropdownInAccNEWVal").text("ALL" === selected[0].id && void 0 === selected[0].item ? I18n.getMsg("crm.label.all") : selected[0].item.fullName);
{
$("#selectMails")
}
showMailsList($newInp.data("entidforzmail"), "", "", $newInp.data("rid"), "-10", "next", "", "true", $newInp.data("mailmodule"), "true", $newInp)
}
}
}
};
$("#selectMails").selectBox();
var $useSelDropDownElem = $("#userSelDropdownInAccNEW");
$useSelDropDownElem.userList(params), $useSelDropDownElem.on("click", function() {
var $ulistElem = $("#userSelDropdownInAccNEW-ulist");
$ulistElem.length > 0 && $ulistElem.hasClass("disN") && (sE(event), $useSelDropDownElem.userList("open"))
}), $("#contactSelDropdownInAcc").selectBox({
callback: function(type, element) {
if ("select" === type || "create" === type || "open" === type) {
var $this = $(element._baseElem[0]),
$drop = $(element._dropdown[0]),
elemPos = $this.offset();
elemPos.left + $drop.outerWidth() > window.innerWidth && $(element._dropdown[0]).css({
left: elemPos.left - $drop.outerWidth() + $this.outerWidth() + "px"
}), "create" === type && ($(element._baseElem[0]).addClass("eml minW100 texAL"), $(element._baseElem).prepend("userSelDropdownInAcc" === element.$element[0].id ? "<em class='zrc-tag-label or fieldst'>" + I18n.getMsg("User") + "</em>" : "Leads" == crmRelatedList.Module ? "<em class='zrc-tag-label fieldst'>" + I18n.getMsg("Candidate") + "</em>" : "Vendors" == crmRelatedList.Module ? "<em class='zrc-tag-label fieldst'>" + I18n.getMsg("Vendors") + "</em>" : "<em class='zrc-tag-label fieldst'>" + I18n.getMsg("Contact") + "</em>"), ("Leads" == crmRelatedList.Module || "Contacts" == crmRelatedList.Module || "Vendors" == crmRelatedList.Module) && "contactSelDropdownInAcc" === element.$element[0].id && ($(element._baseElem[0]).addClass("noopt"), $(element._dropdown).remove()))
}
}
})
}
"RELATEDLISTPERSONALITY" == dataObj.name && ($("#relPersAction_" + dataObj.listRelationId).html($("#norec_" + dataObj.listRelationId).html()), $("#norec_" + dataObj.listRelationId).remove()), "PROJECTSPERSONALITY" == dataObj.name && (authMsg = dataObj.ProjectObj.authMsg, portalName = dataObj.ProjectObj.portalName, getObj("portalname").value = portalName, void 0 != dataObj.ProjectObj.projectIdList && "" != dataObj.ProjectObj.projectIdList && (projectIntegration = 1, projectListRelationId = dataObj.listRelationId, returnAnchor = dataObj.name.toLowerCase() + "_" + dataObj.listRelationId, projId = dataObj.ProjectObj.projectIdList, $("#norec_" + dataObj.listRelationId).remove())), "SUPPORTPERSONALITY" == dataObj.name && void 0 != dataObj.SupportObj.supportTicket && void 0 != dataObj.SupportObj.supportzuid && (supportIntegration = 1), "ZINVOICEPERSONALITY" == dataObj.name && (invoiceIntegration = 1, invoiceListRelationId = dataObj.listRelationId), "ZEXPENSEPERSONALITY" == dataObj.name && (expenseIntegration = 1, expenseListRelationId = dataObj.listRelationId), "ZSUBSCRIPTIONSPERSONALITY" == dataObj.name && (subscriptionsIntegration = 1, zsubscriptionsListRelationId = dataObj.listRelationId);
var relModule = detailView.relatedPersonalityList[dataObj.name];
!isNavigation && relModule && detailView.loadRelatedDetails($("#module").val(), $("#entityId").val(), relModule), "navigate_next_rellist" === clickId && populateRLCount(dataObj.listRelationId, void 0, !0), "ACTIVITIESPERSONALITY" == dataObj.name
}
Crm.userDetails && Crm.userDetails.PROFILE_NAME && ("Interviewer" == Crm.userDetails.PROFILE_NAME || "Guest" == Crm.userDetails.PROFILE_NAME) && $("#newleft_OrganizeRL").remove();
var accObj = getObj("accountId"),
potAccObj = getObj("Potential_accountId");
accObj && potAccObj && (potAccObj.value = accObj.value), getObj("entityName") && getObj("fullname") && (getObj("fullname").value = getObj("entityName").value), getObj("emailId") && getObj("zmailEmail") && (getObj("emailId").value = getObj("zmailEmail").value);
var zc_map = "" + projectIntegration + mailIntegration + supportIntegration + invoiceIntegration + expenseIntegration + subscriptionsIntegration;
if (zc_map.indexOf("1") > -1) {
var cvid = detailView.changedBCJson.hidden.cvid;
"EMAILSPERSONALITY" == dataObj.name ? emailist || getIntegList(zc_map, projectListRelationId, crmRelatedList.EntityId, returnAnchor, crmRelatedList.Module, cvid ? cvid : getObj("cvid").value, portalName, authMsg, 1, projId, crmRelatedList.EntityId, invoiceListRelationId, expenseListRelationId, zsubscriptionsListRelationId, "true") : getIntegList(zc_map, projectListRelationId, crmRelatedList.EntityId, returnAnchor, crmRelatedList.Module, cvid ? cvid : getObj("cvid").value, portalName, authMsg, 1, projId, crmRelatedList.EntityId, invoiceListRelationId, expenseListRelationId, zsubscriptionsListRelationId, "true")
}
if (socialPers && crmSocialInteraction.fetchSocialRelatedList(), moduleData.notes && !($("#noteDetails").length && $("#noteDetails").html().length > 0)) {
var templateSource;
detailView.notesObj = moduleData.notes, templateSource = moduleData.isOlderNotes ? Handlebars.getTemplate("Notes", "CrmNotes_DetailsPageOlder") : Handlebars.getTemplate("Notes", "CrmNotes_DetailsPage"), $("#relNotesInRL").html(templateSource(moduleData.notes)), $("a.imageGallery").colorbox()
}
transferRelatedDetails(), placeExtra(), fetchCustomRelatedList(), "navigate_next_rellist" !== clickId && "navigate_previous_rellist" !== clickId && populateRLCount(), "undefined" != typeof Crm && Crm.scrollPage();
var isEntityLocked = "false",
isActionsLocked = "false";
"Leads" == crmRelatedList.Module ? (isEntityLocked = $("#isCandidatesLocked").val(), isActionsLocked = $("#isActionsLocked").val()) : "Potentials" == crmRelatedList.Module ? isEntityLocked = $("#isJobopeningLocked").val() : "Contacts" == crmRelatedList.Module ? isActionsLocked = $("#isActionsLocked").val() : "Products" == crmRelatedList.Module && "true" == $("#isInterviewLocked").val() && $("#detail_status_link").remove(), "true" == isEntityLocked && (ZRCommonUtil.removeLinksFromDetailPage(), $("#detail_status_link").remove()), "true" == isActionsLocked && (ZRCommonUtil.removeActionsFromDetailPage(), $("#detail_status_link").remove()), moduleData.lockedUnderApproval && (ZRCommonUtil.removeActionsFromDetailPageforApprovals(), ZRCommonUtil.removeLinksFromDetailPageforApprovals()), crmRelatedList.removeExtraSeparator(), ZRCommonUtil.toggleAnswerSheet()
}
},
removeExtraSeparator: function() {
for (var liElement = $("#customizedd ul li"), len = liElement.length, i = 0; len > i; i++)
if (len - 2 >= i) {
var liA = liElement[i],
liB = liElement[i + 1];
$(liA).hasClass("dd-sep") === !0 && $(liB).hasClass("dd-sep") === !0 && $(liA).remove()
}
},
mOverEv: function(el) {
$("#rlDropDown_" + $(el).attr("ddid")).css("visibility", "visible"), $("#" + $(el).attr("ddname") + "_" + $(el).attr("ddid")).css("visibility", "visible")
},
mOutEv: function(el) {
"newRlEdit" == $("#rlDropDown_" + $(el).attr("ddid")).attr("class") && $("#rlDropDown_" + $(el).attr("ddid")).css("visibility", "hidden"), "newRlEdit" == $("#" + $(el).attr("ddname") + "_" + $(el).attr("ddid")).attr("class") && $("#" + $(el).attr("ddname") + "_" + $(el).attr("ddid")).css("visibility", "hidden")
},
navigate: function(ev, targetElem) {
var clickId = $(targetElem).attr("data-cid"),
dataObj = {};
targetElem && (dataObj = JSON.parse($(targetElem).attr("data-params")));
var params = {};
"PRODUCTSPERSONALITY" === dataObj.name && (params.itype = $("#filter_interview").val()), params.id = crmRelatedList.EntityId, params.module = crmRelatedList.Module, params.rid = dataObj.rid, params.isSortRequest = !1, "navigate_next_rellist" === clickId ? params.fromIndex = parseInt(dataObj.fromIndex) + 10 : "navigate_previous_rellist" === clickId && (params.fromIndex = parseInt(dataObj.fromIndex) - 10), "ACTIVITYPERSONALITY" === dataObj.name && (params.activityType = $("#todosFilter").val()), crmRelatedList.ajaxReq(params, clickId)
},
ajaxReq: function(params, clickId) {
var reqPool = new crmRequestPool;
loadAjaxTab("", "lightblue"), reqPool.initiate({
action: "/recruit/NewRelatedList.do?action=getData",
type: "GET",
data: params,
success: function(res) {
Utils.showHideLoadingDiv(), crmRelatedList.load(params.module, params.id, res, !0, clickId)
}
})
},
sortColumn: function(ev, targetElem) {
var dataParams = JSON.parse($(targetElem).attr("data-params")),
dataEnc = $(targetElem).attr("data-enc"),
isSortAllowed = !(void 0 !== dataEnc && (dataEnc === !0 || "true" === dataEnc)),
fieldLabel = (dataParams.columnName, dataParams.fieldLabel),
fieldId = dataParams.fieldId;
"" == fieldId && (fieldId = fieldLabel, dataParams.fieldId = fieldLabel);
var previousObject = crmRelatedList.getSetSinglePersonalityData(dataParams.rid, "get"),
prevSortColumn = previousObject.sortColumnId,
prevSortOrder = previousObject.sortOrderString,
sortOrderString = (previousObject.module, prevSortOrder);
fieldId === prevSortColumn ? "sort_asc" == prevSortOrder && (sortOrderString = "sort_desc") : sortOrderString = "sort_asc";
for (var previousFieldLabel = "", headLabelsLength = previousObject.heading.length, i = 0; headLabelsLength > i; i++)
if (previousObject.heading[i].FIELDID == prevSortColumn || "" == previousObject.heading[i].FIELDID && previousObject.heading[i].FIELDLABEL == prevSortColumn) {
previousFieldLabel = previousObject.heading[i].FIELDLABEL;
{
previousObject.module
}
previousFieldLabel = previousObject.heading[i].COLUMNNAME == dataParams.columnName ? previousObject.heading[i].FIELDLABEL : previousObject.heading[i].FIELDID;
break
}
void 0 !== isSortAllowed && isSortAllowed && showRelListSortDiv(dataParams.fieldLabel, previousObject.name.toLowerCase() + "_" + previousObject.listRelationId, "" == fieldId ? null : encodeURIComponent(previousFieldLabel), targetElem, ev, "Asc", "Desc", previousFieldLabel, prevSortOrder, "Unsort", !0, fieldId), sE(ev)
},
getPersonalityModuleObj: function(pId) {
var data = crmRelatedList.EachModuleData;
for (key in data)
if (data.hasOwnProperty(key) && key == pId)
return data[key]
},
getSetSinglePersonalityData: function(rId, action, setValue) {
var data = crmRelatedList.EachModuleData;
for (var key in data)
if (data[key].listRelationId == rId) {
if ("get" == action)
return data[key];
data[key] = setValue
}
},
getTaregetString: function(rid) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj(rid);
return currentRelModel.name.toLowerCase() + "_" + currentRelModel.listRelationId
},
toggle: function(event) {
var rId = JSON.parse($(event.target).attr("data-params")).rid,
listTable = $("div[data-rnode='" + rId + "']");
listTable.toggleClass("listHide")
},
checkBodyContent: function(rid) {
var rlObj = crmRelatedList.getSetSinglePersonalityData(rid, "get");
return 0 == rlObj.body.length ? !1 : !0
},
checkColumns: function(rid) {
var body = crmRelatedList.getPersonalityModuleObj(rid);
return 0 == body.length ? !1 : !0
},
createEditLink: function(module, entityId, targetString, recordNum) {
var primModule = crmRelatedList.Module,
parentEditentityId = crmRelatedList.EntityId,
url = "/recruit/EditEntity.do?module=" + encodeURIComponent(module) + "&id=" + entityId + "&returnAnchor=" + targetString + "&editprimmodule=" + (null == primModule ? null : encodeURIComponent(primModule)) + "&parenteditentityid=" + parentEditentityId;
return void 0 != recordNum && (url = url + "&recordNum=" + (null == recordNum ? null : encodeURIComponent(recordNum))), url
},
createDeleteLink: function(module, entityId, targetString, isToModuleNeeded, isCustLookUp, toModule) {
var primModule = crmRelatedList.Module,
parentEditentityId = crmRelatedList.EntityId,
url = "/recruit/MassDelete.do?module=" + encodeURIComponent(module) + "&id=" + entityId + "&actModule=" + (null == primModule ? null : encodeURIComponent(primModule)) + "&actId=" + parentEditentityId + "&nextStep=relatedlist";
return isToModuleNeeded && (url = url + "&tomodule=" + encodeURIComponent(toModule)), void 0 != isCustLookUp && (url = url + "&isCustLukup=" + isCustLookUp), url = url + "&isajax=true#" + targetString, targetString && "productspersonality" === targetString.split("_")[0] && (url = void 0 !== $("#filter_interview").val() ? url + "&itype=" + $("#filter_interview").val() : url + "&itype=ALL"), url
},
createStatusChangeLink: function(rid, module, entityId, targetString) {
var primModule = crmRelatedList.Module,
parentEditentityId = crmRelatedList.EntityId,
personalityData = crmRelatedList.getSetSinglePersonalityData(rid, "get"),
previous_sort_column = personalityData.sortColumnId,
previous_sort_order = personalityData.sortOrderString,
url = "/recruit/CampaignStatusChange.do?module=" + encodeURIComponent(module) + "&id=" + entityId + "&parentModule=" + (null == primModule ? null : encodeURIComponent(primModule)) + "&action=showStatus&parentId=" + parentEditentityId + "&isajax=true&returnAnchor=" + targetString + "&sortColumnString_" + rid + "=" + (null == previous_sort_column ? null : encodeURIComponent(previous_sort_column)) + "&sortOrderString_" + rid + "=" + (null == previous_sort_column ? null : encodeURIComponent(previous_sort_order)) + "&listRelationID=" + rid;
return url
},
createCloseLink: function(entityId, targetString) {
var module = crmRelatedList.Module,
url = "/recruit/closeTask.do?action=CloseTask&taskid=" + entityId + "&&module=" + (null == module ? null : encodeURIComponent(module)) + "&id=" + crmRelatedList.EntityId + "&nextStep=relatedlist&isajax=true#" + targetString;
return url
},
creareEditLinkForProducts: function(rid, personality, targetString, entityId, fromModule, toModule) {
var module = crmRelatedList.Module;
return "/recruit/ShowMultiValuesForAdd.do?moduleid=" + crmRelatedList.EntityId + "&rid=" + rid + "&pname=" + personality + "&returnAnchor=" + targetString + "&tomodule=" + encodeURIComponent(toModule) + "&Edit=true&othermoduleid=" + entityId + "&frommodule=" + (null == module ? null : encodeURIComponent(module))
},
createRemoveLinkForContactRole: function(contactId, potentialId, targetString) {
var appendIds = "";
return null != contactId && (appendIds = appendIds + "&whoId=" + contactId), null != potentialId && (appendIds = appendIds + "&whatId=" + potentialId), "/recruit/potentials/deleteContPotRel.do?module=Potentials" + appendIds + "&nextStep=relatedlist&isajax=true#" + targetString
},
attachDocuments: function(event) {
$(".atch-droplist").hide(0), crmRelatedList.attachCloudPicker(event, "#documentsTab")
},
attachDesktop: function(event) {
$(".atch-droplist").hide(0), crmRelatedList.attachCloudPicker(event, "#desktopTab")
},
attachZDocs: function() {
$(".atch-droplist").hide(0), openForDocs("zdoc", Crm.RebrandProperties.docsURL)
},
attachGDocs: function(event) {
$(".atch-droplist").hide(0), crmRelatedList.attachCloudPicker(event, "#cloudPickerTab")
},
attachLink: function() {
crmRelatedList.refreshInput(), showAnimatePopup("addLinkPop"), $(".atch-droplist").hide(0)
},
attachCloudPicker: function(event, selectedTab) {
$(".atch-droplist").hide(0);
var tgt = $(event.target),
uploadElem = tgt.parents("td").eq(0).find("#uploadElement").eq(0);
if (0 == uploadElem.length) {
var personalityid = tgt.data("relid");
personalityid && (uploadElem = $("#ract_" + personalityid).find("#uploadElement").eq(0))
}
var attachmentParams = {};
attachmentParams.entityId = uploadElem.data("entityid"), attachmentParams.module = uploadElem.data("module"), attachmentParams.zgid = Crm.userDetails.ZGID, attachmentParams.catIds = JSON.stringify(uploadElem.data("options")), openAttachmentComponent(attachmentParams, void 0, void 0, selectedTab, void 0)
},
directUpload: function(event) {
var tgt = $(event.target),
uploadElem = tgt.parents("td").eq(0).find("#uploadElement"),
attachmentParams = {};
attachmentParams.entityId = uploadElem.data("entityid"), attachmentParams.module = uploadElem.data("module"), attachmentParams.catIds = JSON.stringify(uploadElem.data("options")), triggerFileClickForDetailPage(attachmentParams)
},
addNew: function(event, targetElem) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid")),
dataParams = {
module: currentRelModel.module,
primid: crmRelatedList.EntityId,
primmodule: encodeURIComponent(crmRelatedList.Module),
returnAnchor: currentRelModel.name.toLowerCase() + "_" + currentRelModel.listRelationId,
listRelationId: currentRelModel.listRelationId,
calleeObj: "Crm",
clickId: "createbtn"
};
$(targetElem).attr("data-params", JSON.stringify(dataParams)), Crm.addToHistory(event, targetElem)
},
addProducts: function(event) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid")),
personalityString = currentRelModel.name.toLowerCase() + "_" + currentRelModel.listRelationId;
addMultiValue(crmRelatedList.EntityId, encodeURIComponent(crmRelatedList.Module), encodeURIComponent(currentRelModel.module), personalityString, void 0, void 0, currentRelModel.listRelationId)
},
addPotentialsProducts: function(event) {
var parentCurrencyISOCode,
parentExchangeRate,
currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid")),
personalityString = currentRelModel.name.toLowerCase() + "_" + currentRelModel.listRelationId;
parentCurrencyISOCode = getObj("parentCurrencyISOCode").value, parentExchangeRate = getObj("parentExchangeRate").value, addMultiValue(crmRelatedList.EntityId, encodeURIComponent(crmRelatedList.Module), encodeURIComponent(currentRelModel.module), personalityString, parentCurrencyISOCode, parentExchangeRate, currentRelModel.listRelationId)
},
importListPrice: function(event, targetElem) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid")),
dataParams = {
module: encodeURIComponent(currentRelModel.module),
priceBookId: crmRelatedList.EntityId,
dataScope: "myData",
calleeObj: "Crm",
clickId: "importbtn"
};
$(targetElem).attr("data-params", JSON.stringify(dataParams)), Crm.addToHistory(event, targetElem)
},
editProducts: function(event) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid"));
editAllValues(crmRelatedList.EntityId, encodeURIComponent(crmRelatedList.Module), encodeURIComponent(currentRelModel.module), void 0, void 0, currentRelModel.listRelationId, currentRelModel.name)
},
newTask: function(event, targetElem) {
selectAction("NewTask", crmRelatedList.getTaregetString($(event.target).attr("data-relid")), encodeURIComponent(crmRelatedList.Module), crmRelatedList.EntityId, targetElem)
},
newEvent: function(event, targetElem) {
Events.globalCreate(event, "relatedlist_new", targetElem)
},
logCall: function(event, targetElem) {
selectAction("NewCall", crmRelatedList.getTaregetString($(event.target).attr("data-relid")), encodeURIComponent(crmRelatedList.Module), crmRelatedList.EntityId, targetElem)
},
sendMailEvent: function() {
var singular_module = Crm.moduleInfo[crmRelatedList.Module][0];
EntSendMail(encodeURIComponent(crmRelatedList.Module), crmRelatedList.EntityId, "", singular_module)
},
addCampaigns: function(event) {
crmRelatedList.addProducts(event)
},
newPotential: function(event, targetElem) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid")),
dataParams = {
module: encodeURIComponent(currentRelModel.module),
primid: crmRelatedList.EntityId,
primmodule: encodeURIComponent(crmRelatedList.Module),
returnAnchor: currentRelModel.name.toLowerCase() + "_" + currentRelModel.listRelationId,
listRelationId: currentRelModel.listRelationId,
ownerId: $.parseJSON($("#ownerName_id").attr("data-params")).userId,
isCustLookup: !1,
calleeObj: "Crm",
clickId: "createbtn"
};
$(targetElem).attr("data-params", JSON.stringify(dataParams)), Crm.addToHistory(event, targetElem)
},
newPotentialForContacts: function(event, targetElem) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid")),
dataParams = {
module: encodeURIComponent(currentRelModel.module),
primid: crmRelatedList.EntityId,
primmodule: encodeURIComponent(crmRelatedList.Module),
returnAnchor: currentRelModel.name.toLowerCase() + "_" + currentRelModel.listRelationId,
listRelationId: currentRelModel.listRelationId,
cvid: getObj("cvid").value,
recordNum: getObj("recordNum").value,
relmodule: encodeURIComponent(crmRelatedList.Module),
calleeObj: "Crm",
clickId: "createbtn"
};
$(targetElem).attr("data-params", JSON.stringify(dataParams)), Crm.addToHistory(event, targetElem)
},
newCompetitor: function(event) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid"));
selectAction("Competitor", crmRelatedList.getTaregetString($(event.target).attr("data-relid")), void 0, void 0, currentRelModel.listRelationId)
},
addContactRoles: function(event, targetElem) {
var dataParams = {
returnAnchor: crmRelatedList.getTaregetString($(event.target).attr("data-relid")),
calleeObj: "Crm",
clickId: "addContactRole"
};
$(targetElem).attr("data-params", JSON.stringify(dataParams)), Crm.addToHistory(event, targetElem)
},
editContactRoles: function(event, targetElem) {
var dataParams = {
returnAnchor: crmRelatedList.getTaregetString($(event.target).attr("data-relid")),
calleeObj: "Crm",
clickId: "editContactRole"
};
$(targetElem).attr("data-params", JSON.stringify(dataParams)), Crm.addToHistory(event, targetElem)
},
newProject: function() {
selectAction("Project", crmRelatedList.getTaregetString($(event.target).attr("data-relid")))
},
newAssociateProject: function() {
selectAction("Associate Project", crmRelatedList.getTaregetString($(event.target).attr("data-relid")))
},
addRecords: function(event, targetElem) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid")),
dataParams = {
module: encodeURIComponent(currentRelModel.module),
actiontype: "mass_addRecords",
lookback: "showdetails",
entityId: crmRelatedList.EntityId,
recordName: getObj("entityName").value,
calleeObj: "Crm",
clickId: "addRecords"
};
$(targetElem).attr("data-params", JSON.stringify(dataParams)), Crm.addToHistory(event, targetElem)
},
importAction: function(event, targetElem) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid")),
dataParams = {
module: encodeURIComponent(currentRelModel.module),
campaignId: crmRelatedList.EntityId,
dataScope: "myData",
calleeObj: "Crm",
clickId: "importbtn"
};
$(targetElem).attr("data-params", JSON.stringify(dataParams)), Crm.addToHistory(event, targetElem)
},
updateCampaignStatus: function(event) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid"));
updateCampaignStatusWizard(encodeURIComponent(crmRelatedList.Module), encodeURIComponent(currentRelModel.module), crmRelatedList.EntityId)
},
importOrgAction: function(event, targetElem) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target).attr("data-relid")),
dataParams = {
module: encodeURIComponent(currentRelModel.module),
campaignId: crmRelatedList.EntityId,
dataScope: "myOrgData",
calleeObj: "Crm",
clickId: "importbtn"
};
$(targetElem).attr("data-params", JSON.stringify(dataParams)), Crm.addToHistory(event, targetElem)
},
hideRLPersonality: function(event) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target.parentElement).attr("data-relid"));
doCustomRleatedList(currentRelModel.name.toLowerCase() + "_" + currentRelModel.listRelationId, "hide")
},
reorderRLPersonality: function(event) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target.parentElement).attr("data-relid"));
doCustomRleatedList(currentRelModel.name.toLowerCase() + "_" + currentRelModel.listRelationId, "reorder")
},
editRLPersonality: function(event) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target.parentElement).attr("data-relid"));
doCustomRleatedList(currentRelModel.name.toLowerCase() + "_" + currentRelModel.listRelationId, "edit")
},
deleteRLPersonality: function(event) {
var currentRelModel = crmRelatedList.getPersonalityModuleObj($(event.target.parentElement).attr("data-relid"));
doCustomRleatedList(currentRelModel.name.toLowerCase() + "_" + currentRelModel.listRelationId, "del")
},
sendsurvey: function(event, targetElem) {
var singular_module = Crm.moduleInfo[crmRelatedList.Module][0],
dataParams = {
action: "surveyDetails",
from: "sendsurvey",
entityId: crmRelatedList.EntityId,
module: crmRelatedList.Module,
singularmod: singular_module
};
$(targetElem).attr("data-params", JSON.stringify(dataParams)), ZSurvey.showSurveyDetails(targetElem)
},
attendsurvey: function(event, targetElem) {
var singular_module = Crm.moduleInfo[crmRelatedList.Module][0],
dataParams = {
action: "surveyDetails",
from: "attendsurvey",
entityId: crmRelatedList.EntityId,
module: crmRelatedList.Module,
singularmod: singular_module
};
$(targetElem).attr("data-params", JSON.stringify(dataParams)), ZSurvey.showSurveyDetails(targetElem)
},
showatchPop: function(ev, ele) {
"none" == $(ele).parent().children("ul").css("display") ? $(ele).parent().children("ul").stop().slideDown(200) : $(ele).parent().children("ul").stop().slideUp(0)
},
showAtch_cntPop: function(eleId) {
$("#" + eleId).addClass("zcrm-show")
},
enableBtnAtc: function(ele) {
"" != $(ele).val() ? $("#attachlinkbtn").removeAttr("disabled") : $("#attachlinkbtn").attr("disabled", "disabled")
},
openLinkAndTitleChange: function(url, linkURL, ele) {
window.open(linkURL), $.ajax({
type: "GET",
url: url,
success: function(res) {
if ("" != res) {
var json = JSON.parse(res);
json.hasOwnProperty("Changed_Name") && ($(ele).closest("td").css({
"border-left-color": "#f00",
"border-left-width": "2px",
"border-left-style": "solid"
}), ele.textContent = json.Changed_Name)
}
}
})
},
refreshInput: function() {
$("#attachmentUrl").closest("td").replaceWith('<td><input type="text" name="attachmentUrl" id="attachmentUrl" oninput="crmRelatedList.enableBtnAtc(this);" style="width:100%" maxlength="3000" /></td>'), crmRelatedList.enableBtnAtc($("#attachmentUrl"))
},
addLink: function() {
Utils.showHideLoadingDiv(!0);
var linkUrl = $("#attachmentUrl").val();
if (linkUrl.length > 3e3)
return Utils.showHideLoadingDiv(!1), Utils.showErrorMsg(I18n.getMsg("maxlenmsg"), $("#attachmentUrl").closest("td"), $("#attachmentUrl").closest("td")), !1;
if (!Utils.isValidWebUrl(linkUrl))
return Utils.showHideLoadingDiv(!1), Utils.showErrorMsg(I18n.getMsg("crm.custombutton.valid.url.check"), $("#attachmentUrl").closest("td"), $("#attachmentUrl").closest("td")), !1;
var reqUrl = document.linkAttachForm.action;
getElemById("attachTotCnt") && (reqUrl += "&attachTotCnt=" + getElemById("attachTotCnt").value);
var postData = $(document.linkAttachForm).serialize();
return $.ajax({
type: "POST",
url: reqUrl,
data: postData,
success: function(res) {
if (Utils.showHideLoadingDiv(!1), "Link already exists" == res)
Utils.showErrorMsg(I18n.getMsg("crm.attach.link.exists"), $("#attachmentUrl").closest("td"), $("#attachmentUrl").closest("td"));
else if (hideAnimatePopup("addLinkPop"), getElemById("attachTotCnt")) {
var tempDiv = document.createElement("tempDivForAttLink");
tempDiv.innerHTML = res;
var eventAttachmentDiv = getElemById("eventAttachmentDiv");
eventAttachmentDiv.appendChild(tempDiv), EvalInnerScript(tempDiv), eventAttachmentDiv.removeChild(tempDiv)
} else
crmRelatedList.load(crmRelatedList.Module, crmRelatedList.EntityId, res)
},
error: function() {
hideAnimatePopup("addLinkPop"), Utils.showHideLoadingDiv(!1)
}
}), !1
},
relListClientSubmission: function() {
ZRMailUtil.singleForwardToClient(crmRelatedList.EntityId)
},
relShareToVendors: function() {
ZRVendorPortal.shareToVendors(crmRelatedList.EntityId)
},
restrictProcessing: function(event) {
var param = {},
targetElem = $(event.target),
invokeId = targetElem.data("cid"),
entityName = $("#entityName").val(),
str = "";
param.entityId = this.EntityId, param.entityName = entityName, param.step = "restrictProcessing", param.module = getObj("module").value, "restrictProcessing" == invokeId ? (str = I18n.getMsg("crm.request.restrict.processing.message", entityName), showDeletePopup(str, "crm.request.restrict.processing.confirmation", "", "", ""), $("#candInnerQV").length > 0 && $("#candInnerQV").css("z-index", "21")) : "removeRestriction" == invokeId && (str = I18n.getMsg("crm.request.remove.restriction.message", entityName), showDeletePopup(str, "crm.request.remove.restriction.confirmation", "", "", "")), $("#deletepopup").find("#deleteButton").click(function() {
url = "/recruit/restrictProcessing.do", ZRCommonUtil.ajaxPostMethod(url, param, !1, "json", void 0, function(data, undefined) {
if ($("#deletepopup").is(":visible") && hideAnimatePopup("deletepopup"), "Success" == data.message) {
if ("restrictProcessing" == invokeId) {
if ($("#candInnerQV").length > 0)
ZRQuickView.unfreezeQuickView(), $("#candInnerQV").removeClass("slideInRight").addClass("slideOutRight"), $("#fetchdate_title").click();
else {
ZRCommonUtil.removeActionsFromDetailPage(), $("#detail_status_link").remove();
var restrictionElement = $("[data-cid=restrictProcessing]");
if (restrictionElement.length > 0) {
var createElem = Utils.createHTML({
name: "li",
child: [{
name: "a",
html: I18n.getMsg("crm.request.remove.restriction"),
attr: {
href: "javascript:;",
"data-callid": "removeRestriction",
"data-cid": "removeRestriction",
name: "removeRestriction",
"data-zcqa": "removeRestriction",
title: I18n.getMsg("crm.request.remove.restriction")
}
}]
});
$("#CustomizeActionDD ul").append(createElem), restrictionElement.remove()
}
}
return
}
var url = "/recruit/ShowEntityInfo.do?id=" + getObj("id").value + "&module=" + getObj("module").value + "&cvid=" + getObj("cvid").value + "&recordNum=" + getObj("recordNum").value;
return detailView.load(url, undefined, undefined, "show"), void crmTab.deleteFromCache(module)
}
}, function(xhr) {
xhr.responseText, xhr.status
})
})
},
reactivateCandidate: function() {
var param = {},
entityName = $("#entityName").val(),
str = I18n.getMsg("crm.request.reactivate.candidate.message", entityName);
param.entityId = this.EntityId, param.entityName = entityName, param.module = getObj("module").value, param.step = "reactivateCandidate", showDeletePopup(str, "crm.request.reactivate.candidate.confirmation", "", "", ""), $("#deletepopup").find("#deleteButton").click(function() {
url = "/recruit/reactivateCandidate.do", ZRCommonUtil.ajaxPostMethod(url, param, !1, "json", void 0, function(data) {
return $("#deletepopup").is(":visible") && hideAnimatePopup("deletepopup"), "Success" == data.message ? void this.recordNavigation() : void 0
}, function(xhr) {
xhr.responseText, xhr.status
})
})
},
generateOfferLetter: function(ev, targetElem) {
ZROfferUtil.generateOfferLetter(ev, targetElem)
},
relQuickActionHandler: function(event) {
var targetElem = $(event.target),
invokeId = targetElem.data("callid");
if ($("#zia-suggestions zia-suggestions").length > 0 && $("#candInnerQV #" + invokeId).length > 0 ? $("#candInnerQV #" + invokeId).trigger("click") : $("#" + invokeId).trigger("click"), "sendEntityMailLink" === invokeId && 0 === $("#sendEntityMailLink").size()) {
var msg = I18n.getMsg("crm.templateedit.massmail.unableto", I18n.getMsg(module)),
params = {
type: "failure-box",
boldmsg: "",
msg: msg,
display: "pop",
duration: 3500
};
return void ZRComponent.openAlertMessage(params)
}
},
requestGDPRConsent: function(event) {
$(event.target);
ZRMailUtil.requestGDPRConsent(crmRelatedList.EntityId, crmRelatedList.Module)
},
relHandleAssociateQuestionnaire: function(event) {
var target = $(event.target);
ZRQuestionnaire.associateQuestionnaire(target)
},
relHandleRemoveQuestionnaire: function(event) {
var target = $(event.target);
ZRQuestionnaire.removeAssociation(target)
},
findMatchingRecords: function(event) {
var tgt = $(event.target),
data = $(tgt).data("params");
ZRSME.validateEntity(data.module, data.entityid, data.quickView)
},
enrichEntity: function(event) {
var tgt = $(event.target),
params = $(tgt).data("params"),
content = document.createElement("zr-enrich");
content.setData({
isLoaded: !1
}), $("body").append(content), store.findAll("zr-enrich", {
id: params.entityid,
module: params.module
}).then(function(data) {
if (data && "success" === data.message)
store.findRecord(moduleRecordMapping[params.module].id, params.entityid).then(function() {
document.getElementsByTagName("zr-enrich")[0].setData({
entity: store.peekRecord(moduleRecordMapping[params.module].id, params.entityid),
enriched: data,
isLoaded: !0
})
});
else if (data && "limitreached" === data.message) {
var cData = {
isLoaded: !0,
entityid: params.entityid,
module: params.module,
reason: data.reason,
showreload: !1
};
document.getElementsByTagName("zr-enrich")[0].setData(cData)
} else {
var cData = {
isLoaded: !0,
entityid: params.entityid,
module: params.module,
reason: data.reason
};
data && data.lnurl && (cData.showreload = !1), document.getElementsByTagName("zr-enrich")[0].setData(cData)
}
})
},
publishToJB: function() {
var tgt = $(event.target),
data = $(tgt).data("params");
ZRPublishUtil.validateAndPublishJO(data && data.quickView ? !0 : !1)
},
rePublishToJB: function() {
ZRJobBoardsUtil.rePublishRLAction()
},
unPublishFromJB: function(event) {
var target = $(event.target);
ZRJobBoardsUtil.unPublishRLAction(target)
},
unPublishAllFromJB: function() {
ZRJobBoardsUtil.unPublishAllRLAction()
},
editWebFormJB: function() {
ZRJobBoardsUtil.changeWebFormRLAction()
},
publishUrlJB: function() {
ZRJobBoardsUtil.publishUrlJobRLAction()
},
changeMemberStatus: function() {
updateCampaignStatusWizard("Potentials", "Leads", crmRelatedList.EntityId)
},
relListSendSMS: function() {
$("#qv-main-container").length > 0 ? ZRSMSUtil.loadSendSMS(JSON.parse($("#qv-main-container").attr("data-params")).module, crmRelatedList.EntityId, "detailPage") : ZRSMSUtil.loadSendSMS(crmRelatedList.Module, crmRelatedList.EntityId, "detailPage")
},
unAssociateLinkClickHandler: function(event, targetElem) {
$(targetElem).data("params") ? $(targetElem).data("params") : {};
ZRAssociateUtil.actionEvent(event, '"+potentialid+"', '"+recordName+"'), sE(event)
},
loadCrmSyncedRecordActivitiesOpen: function(event, targetElem) {
ZRNoteUtil.loadCrmSyncedRecordActivities(targetElem, "open")
},
loadCrmSyncedRecordActivitiesClosed: function(event, targetElem) {
ZRNoteUtil.loadCrmSyncedRecordActivities(targetElem, "closed")
},
clickEventIdVsMethodMapping: {
toggleList: "crmRelatedList.toggle",
navigate_previous_rellist: "crmRelatedList.navigate",
navigate_next_rellist: "crmRelatedList.navigate",
sortColumnRL: "crmRelatedList.sortColumn",
attachDocuments: "crmRelatedList.attachDocuments",
attachDesktop: "crmRelatedList.attachDesktop",
attachZDocs: "crmRelatedList.attachZDocs",
attachGDocs: "crmRelatedList.attachGDocs",
attachLink: "crmRelatedList.attachLink",
addProducts: "crmRelatedList.addProducts",
addNew: "crmRelatedList.addNew",
addVendorProducts: "crmRelatedList.addVendorProducts",
addPotentialsProducts: "crmRelatedList.addPotentialsProducts",
importListPrice: "crmRelatedList.importListPrice",
editProducts: "crmRelatedList.editProducts",
newTask: "crmRelatedList.newTask",
newEvent: "crmRelatedList.newEvent",
logCall: "crmRelatedList.logCall",
getCrmActivitiesOpen: "crmRelatedList.loadCrmSyncedRecordActivitiesOpen",
getCrmActivitiesClosed: "crmRelatedList.loadCrmSyncedRecordActivitiesClosed",
sendMailEvent: "crmRelatedList.sendMailEvent",
addCampaigns: "crmRelatedList.addProducts",
newPotential: "crmRelatedList.newPotential",
newPotentialForContacts: "crmRelatedList.newPotentialForContacts",
newCompetitor: "crmRelatedList.newCompetitor",
addContactRoles: "crmRelatedList.addContactRoles",
editContactRoles: "crmRelatedList.editContactRoles",
newProject: "crmRelatedList.newProject",
newAssociateProject: "crmRelatedList.newAssociateProject",
addRecordsRL: "crmRelatedList.addRecords",
importAction: "crmRelatedList.importAction",
updateCampaignStatus: "crmRelatedList.updateCampaignStatus",
importOrgAction: "crmRelatedList.importOrgAction",
hideRLPersonality: "crmRelatedList.hideRLPersonality",
reorderRLPersonality: "crmRelatedList.reorderRLPersonality",
editRLPersonality: "crmRelatedList.editRLPersonality",
deleteRLPersonality: "crmRelatedList.deleteRLPersonality",
sendsurvey: "crmRelatedList.sendsurvey",
attendsurvey: "crmRelatedList.attendsurvey",
relClientSubmission: "crmRelatedList.relListClientSubmission",
generateOfferLetter: "crmRelatedList.generateOfferLetter",
link_relJBPublish: "crmRelatedList.publishToJB",
link_relJBRePublish: "crmRelatedList.rePublishToJB",
link_relJBUnPublish: "crmRelatedList.unPublishFromJB",
link_relJBUnPublishAll: "crmRelatedList.unPublishAllFromJB",
link_relJBEditWebForm: "crmRelatedList.editWebFormJB",
link_relJBPublishUrl: "crmRelatedList.publishUrlJB",
changeMemberStatus: "crmRelatedList.changeMemberStatus",
relListSendSMS: "crmRelatedList.relListSendSMS",
relQuickAction: "crmRelatedList.relQuickActionHandler",
requestGDPRConsent: "crmRelatedList.requestGDPRConsent",
restrictProcessing: "crmRelatedList.restrictProcessing",
reactivateCandidate: "crmRelatedList.reactivateCandidate",
removeRestriction: "crmRelatedList.restrictProcessing",
relAssociateQuestionnaire: "crmRelatedList.relHandleAssociateQuestionnaire",
relRemoveQuestionnaire: "crmRelatedList.relHandleRemoveQuestionnaire",
relShareToVendors: "crmRelatedList.relShareToVendors",
findMatchingRecords: "crmRelatedList.findMatchingRecords",
enrichEntity: "crmRelatedList.enrichEntity",
showatchpop: "crmRelatedList.showatchPop"
},
clickHandler: function(ev, targetElem, clickId) {
return this.clickEventIdVsMethodMapping[clickId] ? (Utils.executeFunctionByName(this.clickEventIdVsMethodMapping[clickId], window, ev, targetElem), !1) : !0
}
}, Handlebars.registerHelper("hasInterviewRecords", function(relId, op) {
var personality = crmRelatedList.EachModuleData[relId];
return "PRODUCTSPERSONALITY" == personality.name && personality.body.length > 0 ? op.fn(this) : op.inverse(this)
}), Handlebars.registerHelper("stringify", function(obj) {
return JSON.stringify(obj)
}), Handlebars.registerHelper("isDefaultMailFilter", function() {
return JSON.stringify(obj)
}), Handlebars.registerHelper("showNavigation", function(fromIndex, toIndex, limit, list, op) {
return fromIndex = parseInt(fromIndex), toIndex = parseInt(toIndex), fromIndex >= parseInt(limit) || list.length >= parseInt(limit) ? op.fn(this) : op.inverse(this)
}), Handlebars.registerHelper("isNotUndefined", function(val, op) {
return val ? op.fn(this) : op.inverse(this)
}), Handlebars.registerHelper("isBodyContentAvailable", function(rid, op) {
return crmRelatedList.checkBodyContent(rid) ? op.fn(this) : op.inverse(this)
}), Handlebars.registerHelper("compareNumbers", function(val1, val2, op) {
return val1 === val2 ? op.fn(this) : op.inverse(this)
}), Handlebars.registerHelper("getId", function(name, id) {
var ret = "";
return ret = "RELATEDLISTPERSONALITY" == name ? "customRelatedListDiv_" + id : "SUPPORTPERSONALITY" == name ? "supportdiv" : id
}), Handlebars.registerHelper("getStyleAttr", function(name, op) {
return "RELATEDLISTPERSONALITY" != name && "SUPPORTPERSONALITY" != name ? op.fn(this) : op.inverse(this)
}), Handlebars.registerHelper("checkForRlHandling", function(val1, val2, personality, op) {
return "COMPETITORNAME" == val1[val2].COLUMNNAME ? op.fn(this) : ("SUBJECT" != val1[val2].COLUMNNAME || "ACTIVITYHISTORYPERSONALITY" != personality && "ACTIVITYPERSONALITY" != personality) && ("ATTACHMENTSPERSONALITY" != personality || "NAME" != val1[val2].COLUMNNAME && "ATTACHMENTSIZE" != val1[val2].COLUMNNAME && "MODIFIEDTIME" != val1[val2].COLUMNNAME && "LABEL" != val1[val2].COLUMNNAME) && ("SURVEYPERSONALITY" != personality || "UNIQUEID" != val1[val2].COLUMNNAME && "SOURCE" != val1[val2].COLUMNNAME) && ("SMSPERSONALITY" != personality || "Message" != val1[val2].FIELDLABEL && "Status" != val1[val2].FIELDLABEL) ? op.inverse(this) : op.fn(this)
}), Handlebars.registerHelper("chattedDiv", function(chatted) {
return void 0 != chatted && 0 != chatted ? "<td><span class='siq-chatted'></span></td>" : "<td></td>"
}), Handlebars.registerHelper("checkStringRL", function(value, heading, index, body, module, rid, personality, fromIndex, option) {
var res = "";
if ("COMPETITORSPERSONALITY" == personality)
res = "<a id='relatedList_" + body.ENTITYID + "' data-zcqa='relatedList_" + option.fn(this) + "' class='link' href='javascript:;' onclick='Utils.openCustomLookup(\"/recruit/potentials/ViewCompetitor.do?id=" + body.ENTITYID + "&module=Potentials&returnAnchor=competitorspersonality_" + rid + '", undefined, "topBandPopup");\'>' + option.fn(this) + "</a>";
else if ("SMSPERSONALITY" == personality)
"Message" == heading[index].FIELDLABEL ? (res = '<input id="smsIndex" type="hidden" value=' + index + ">", res += body.incoming ? '<span class="sms-blue-icon"></span>' : '<span class="sms-green-icon"></span>', value.length > 30 && (value = value.substring(0, 29) + "..."), res += '<a href="javascript:;" onclick="ZRSMSUtil.loadSendSMS(\'' + module + "','" + body.entityId + "','detailPage'," + fromIndex + ",'" + body.SMSHistoryId + "');sE(event);\" >" + $ESAPI.encoder().encodeForHTML(value) + "</a>") : "Status" == heading[index].FIELDLABEL && ("Success" == body.isSuccess || 1 == body.isSuccess ? res = "queued" == value ? "<span class='sms-orange' >" + I18n.getMsg("crm.sms.status.queued") + "</span>" : "received" == value ? "<span class='colGR' >" + I18n.getMsg("Received") + "</span>" : "<span class='colGR' >" + I18n.getMsg("Delivered") + "</span>" : (res += '<span class="fL sms-fail mR5">' + I18n.getMsg("crm.sms.status.failed"), res += '<span class="sms-failed-icon fL"></span>', res += '<span class="sms-failedpop">' + $ESAPI.encoder().encodeForHTML(value) + "</span></span>"));
else if ("ACTIVITYHISTORYPERSONALITY" == personality || "ACTIVITYPERSONALITY" == personality) {
var pn = "ap";
pn = "ACTIVITYHISTORYPERSONALITY" == personality ? "ahp" : "ACTIVITYPERSONALITY" == personality ? "ap" : pn;
var head = {
Leads: "LASTNAME",
Activities: "SUBJECT",
Accounts: "ACCOUNTNAME",
Contacts: "LASTNAME",
Potentials: "POTENTIALNAME",
Campaigns: "CAMPAIGNNAME",
Cases: "CASESUBJECT",
Solutions: "SOLUTIONTITLE",
Products: "PRODUCTNAME",
Vendors: "VENDORNAME",
PriceBooks: "BOOKNAME",
Quotes: "QUOTESUBJECT",
SalesOrders: "SALESORDERSUBJECT",
PurchaseOrders: "PURCHASEORDERSUBJECT",
Invoices: "INVOICESUBJECT",
Forecasts: "FORECASTNAME",
Visits: "VISITEDPAGE"
};
if (0 == module.indexOf("CustomModule") && "NAME" == heading[index].COLUMNNAME || heading[index].COLUMNNAME == head[module]) {
var permission = (body.relContactId ? body.relContactId : null, "Crm_Implied_View_" + module);
crmListView.changedPermissionsForZBModules.hasOwnProperty(permission) && (permission = crmListView.changedPermissionsForZBModules[permission]), permission = Crm.userDetails.permissions[permission];
var res = "<a ";
res += permission > -1 ? 'data-cid="detailView" href="/recruit/EntityInfo.do?id=' + body.ENTITYID + "&module=" + body.MODULE + '"' : 'href="javascript:;" title="permission denied" data-permission="false"', res += 'id="relatedList_' + body.ENTITYID + "\" data-zcqa='relatedList_" + option.fn(this) + '\' data-params=\'{"fromActivityListView":"true","pfrom":"rel","module":"' + body.MODULE + '","id":"' + body.ENTITYID + '","pn":"' + pn + '","peId":"' + crmRelatedList.EntityId + '","bMod":"' + crmRelatedList.Module + '","lookback":"true"', res += '}\' class="link"', res += ">" + option.fn(this) + "</a>"
}
} else if ("ATTACHMENTSPERSONALITY" == personality) {
if ("NAME" == heading[index].COLUMNNAME) {
var fileName = value,
len = fileName.length,
pos = fileName.lastIndexOf("."),
extn = "";
0 != len && pos > -1 && (extn = fileName.substring(pos + 1, len), extn = extn.toLowerCase()), value = ZRFileUtil.getAttachDotVal(fileName, 30).dotVal;
var extnvalue = body.extn,
mode = body.mode,
isLinkDocs = body.isLinkDocs,
res = '<div class="atchName" style="max-width:600px">';
if (void 0 != isLinkDocs && isLinkDocs == crmConstants.Attachment_fromDesktop) {
if ("pdf" == extn)
res += "<a id='relatedList_" + body.ENTITYID + "' onClick=\"javascript:openSheetForExport('" + $ESAPI.encoder().encodeForJavaScript("/recruit/ViewAttachment?fileId=" + body.FILEID + "&module=" + encodeURIComponent(crmRelatedList.Module) + "&parentId=" + crmRelatedList.EntityId + "&creatorId=" + body.CreaterId + "&id=" + body.ENTITYID + "&name=" + encodeURIComponent(fileName) + "&downLoadMode=pdfViewPlugin") + '\',\'pdfViewPlugin\');sE(event);" style="cursor: pointer"> <img src="' + crmConstants.imgStaticPath + "/spacer.gif\" class='" + extnvalue + "-icon' border='0' hspace='3' height='16px' width='16px' align='absmiddle' >";
else if ("" != mode)
res += "<a id='relatedList_" + body.ENTITYID + "' title ='" + $ESAPI.encoder().encodeForHTMLAttribute(fileName) + '\' data-attachdetail=\'{"attachmentId":"' + body.ENTITYID + '", "pkid":"' + crmRelatedList.EntityId + '", "fileId":"' + body.FILEID + '", "creatorId":"' + body.CreaterId + '", "module":"' + encodeURIComponent(crmRelatedList.Module) + '", "fileName":"' + $ESAPI.encoder().encodeForHTMLAttribute(fileName) + '", "isList":"false", "linkDocs":"false", "pasteDiv":"#relatedPageContent", "isAttachmentPermission":"' + crmRelatedList.EachModuleData[rid].editAttachTypes[body.attachTypeId] + '", "isDownloadAttachPerm":"' + crmRelatedList.EachModuleData[rid].dowloadAttachTypes[body.attachTypeId] + '"}\' style="cursor: pointer" onclick="ZRFileUtil.viewAttachment(this);sE(event)"> <img src="' + crmConstants.imgStaticPath + "/spacer.gif\" class='" + extnvalue + "-icon' border='0' hspace='3' height='16px' width='16px' align='absmiddle' >";
else if ("png" == extnvalue) {
var isDownloadAttachPerm = crmRelatedList.EachModuleData[rid].dowloadAttachTypes[body.attachTypeId] ? !0 : !1;
res += isDownloadAttachPerm === !0 ? "<a id='relatedList_" + body.ENTITYID + '\' onClick="showImagePreview(this)" href="/recruit/ViewImage?fileId=' + body.FILEID + "&module=" + encodeURIComponent(crmRelatedList.Module) + "&parentId=" + crmRelatedList.EntityId + "&creatorId=" + body.CreaterId + "&id=" + body.ENTITYID + "&name=" + encodeURIComponent(fileName) + '&downLoadMode=default" class="cboxElement" style="cursor: pointer" name=\'cboxElement\'> <img src="' + crmConstants.imgStaticPath + "/spacer.gif\" class='" + extnvalue + "-icon' border='0' hspace='3' height='16px' width='16px' align='absmiddle'>" : "<a id='relatedList_" + body.ENTITYID + "' target='_blank' href=\"/recruit/ViewAttachment?fileId=" + body.FILEID + "&module=" + encodeURIComponent(crmRelatedList.Module) + "&parentId=" + crmRelatedList.EntityId + "&creatorId=" + body.CreaterId + "&id=" + body.ENTITYID + "&name=" + encodeURIComponent(fileName) + '&downLoadMode=image" > <img src="' + crmConstants.imgStaticPath + "/spacer.gif\" class='" + extnvalue + "-icon' border='0' hspace='3' height='16px' width='16px' align='absmiddle'>"
} else {
var isDownloadAttachPerm = crmRelatedList.EachModuleData[rid].dowloadAttachTypes[body.attachTypeId] ? !0 : !1;
res += isDownloadAttachPerm === !0 ? "<a id='relatedList_" + body.ENTITYID + "' href=\"/recruit/ViewAttachment?fileId=" + body.FILEID + "&module=" + encodeURIComponent(crmRelatedList.Module) + "&parentId=" + crmRelatedList.EntityId + "&creatorId=" + body.CreaterId + "&id=" + body.ENTITYID + "&name=" + encodeURIComponent(fileName) + '&downLoadMode=default" style="cursor: pointer" title=\'' + I18n.getMsg("crm.view.attachment.download") + "' > <img src=\"" + crmConstants.imgStaticPath + "/spacer.gif\" class='" + extnvalue + "-icon disIB' border='0' hspace='3' height='16px' width='16px' align='absmiddle'>" : '<a><img src="' + crmConstants.imgStaticPath + "/spacer.gif\" class='" + extnvalue + "-icon disIB' border='0' hspace='3' height='16px' width='16px' align='absmiddle'>"
}
value = $ESAPI.encoder().encodeForHTML(value)
} else
void 0 != isLinkDocs && isLinkDocs == crmConstants.Attachment_fromDocs ? res += "<a id='relatedList_" + body.ENTITYID + "' onClick=\"showExportMenu('" + $ESAPI.encoder().encodeForJavaScript("/recruit/ViewAttachment?fileId=" + body.ZDOCS_FILEID + "&module=" + encodeURIComponent(crmRelatedList.Module) + "&parentId=" + crmRelatedList.EntityId + "&creatorId=" + body.CreaterId + "&id=" + body.ENTITYID + "&name=" + encodeURIComponent(fileName) + "&linkDocs=true") + "','" + body.attachExt + "','" + body.ENTITYID + "','','true');sE(event);\" style=\"cursor: pointer\"> <img src=\"" + crmConstants.imgStaticPath + "/spacer.gif\" class='" + extnvalue + "-icon' border='0' hspace='3' height='16px' width='16px' align='absmiddle' >" : void 0 != isLinkDocs && isLinkDocs == crmConstants.Attachment_fromLinkUrl && (value = $ESAPI.encoder().encodeForHTML(value), res += '<div class = "link-iconAtc mR10 dIB vmiddle" border="0" hspace="3" height="16px" width="16px" align="absmiddle"></div> <a id=\'relatedList_' + body.ENTITYID + "' onClick=\"crmRelatedList.openLinkAndTitleChange('" + $ESAPI.encoder().encodeForJavaScript("/recruit/ViewAttachment?module=" + encodeURIComponent(crmRelatedList.Module) + "&id=" + body.ENTITYID + "&name=" + encodeURIComponent(fileName) + "&linkURL=" + encodeURIComponent(body.linkURL) + "&isLink=true") + "','" + $ESAPI.encoder().encodeForHTMLAttribute($ESAPI.encoder().encodeForJavaScript(body.linkURL)) + '\',this);sE(event);" target="_blank" style="cursor: pointer">');
res += value + "</a>", ("mp3" == extn || "wav" == extn) && (res += '<span class="cP icon_play dIB verAM marL10" onclick="playAudio(this,\'' + body.ENTITYID + '\')" style="display: none;" onmouseover="zctt.showtt(\'' + I18n.getMsg("crm.button.play") + '\')" onmouseout="zctt.hidett()"></span>', res += $.browser.name.indexOf("MSIE") > -1 ? '<embed id="' + body.ENTITYID + '_audio" src="/recruit/ViewAttachment?fileId=' + body.FILEID + "&module=" + encodeURIComponent(crmRelatedList.Module) + "&parentId=" + crmRelatedList.EntityId + "&creatorId=" + body.CreaterId + "&id=" + body.ENTITYID + "&name=" + encodeURIComponent(fileName) + '" autoplay="false" style="display:none"/>' : '<audio id="' + body.ENTITYID + '_audio" class="mt10" hidden="true" src="/recruit/ViewAttachment?fileId=' + body.FILEID + "&module=" + encodeURIComponent(crmRelatedList.Module) + "&parentId=" + crmRelatedList.EntityId + "&creatorId=" + body.CreaterId + "&id=" + body.ENTITYID + "&name=" + encodeURIComponent(fileName) + '" controls preload="auto">'), res += "</div>"
} else if ("ATTACHMENTSIZE" == heading[index].COLUMNNAME) {
var fileSize = value,
isLinkDocs = body.isLinkDocs,
zDocs_fileId = "";
if (void 0 != isLinkDocs && 1 == isLinkDocs && (zDocs_fileId = body.ZDOCS_FILEID, fileSize = body.FILESIZE), void 0 != isLinkDocs && 2 == isLinkDocs)
return "-";
fileSize.indexOf("KB") > -1 ? res = fileSize.replace(/KB/g, I18n.getMsg("KB")) : fileSize.indexOf("MB") > -1 && (res = fileSize.replace("/MB/g", I18n.getMsg("MB")))
} else
"MODIFIEDTIME" == heading[index].COLUMNNAME && (res = "<span onmouseover=\"zctt.showtt('" + body.dateToolTip + '\')" onmouseout="zctt.hidett()">' + value + "</span>");
"LABEL" == heading[index].COLUMNNAME && (res = "<div class='cd-attachcategory' id='attachment_type_" + body.ENTITYID + '\'> <span class="attach-type-link">' + value + "</span> ", "ICS" != value && "Guest" != Crm.userDetails.PROFILE_NAME && "Interviewer" != Crm.userDetails.PROFILE_NAME && 1 == body.isEditAttachPermission && (res += "<a onmouseover=\"zctt.showtt('" + I18n.getMsg("crm.relatedlist.attachment.changeattachmentcategory") + '\')" onmouseout="zctt.hidett()" href="javascript:void(0)" class="typeedit" onclick="ZRSetupUtil.changeFileType(\'' + crmRelatedList.Module + "','" + body.attachTypeId + "','" + body.ENTITYID + "','" + body.ParentId + "')\"><span class='link neweditIcon dIB'></span></a> "), res += "</div>")
} else if ("SURVEYPERSONALITY" == personality)
if ("SOURCE" == heading[index].COLUMNNAME)
res = I18n.getMsg(value);
else if ("UNIQUEID" == heading[index].COLUMNNAME) {
var resInfo = body.uniqueId,
sMail = encodeURIComponent(body.sEmail);
res = void 0 != resInfo && 0 != resInfo ? '<a href=\'javascript:void(0);\' onclick=\'ZSurvey.viewResponse(this);\' data-params=\'{"action" : "viewResponse", "uniqueid":"' + resInfo + '","responseid":"' + body.RESPONSEID + '" , "zcrmemail":"' + sMail + "\"}'>" + I18n.getMsg("crm.zsurvey.label.view.response") + "</a>" : '<span class="f12" >' + I18n.getMsg("crm.survey.response.yettorespond") + "</span>"
}
return res
}), Handlebars.registerHelper("getDownloadLink", function(value, heading, index, body, module, rid, personality) {
var res = "",
isLinkDocs = body.isLinkDocs;
if ("ATTACHMENTSPERSONALITY" == personality && 2 != isLinkDocs && 0 == index) {
for (var fileName = "", i = 0; i < heading.length; i++)
if ("NAME" == heading[i].COLUMNNAME) {
fileName = body.CONTENT[i];
break
}
var fileId = "",
linkDocsParam = "",
len = fileName.length,
pos = fileName.lastIndexOf("."),
attachExt = "";
0 != len && pos > -1 && (attachExt = fileName.substring(pos + 1, len), attachExt = attachExt.toLowerCase()), void 0 != isLinkDocs && 1 == isLinkDocs ? (fileId = body.ZDOCS_FILEID, linkDocsParam = "&linkDocs=true") : (fileId = body.FILEID, linkDocsParam = "");
var isDownloadAttachPerm = crmRelatedList.EachModuleData[rid].dowloadAttachTypes[body.attachTypeId] ? !0 : !1;
1 == isDownloadAttachPerm && (res = '<div class="cd-downbox" style="display:inline-block;"><a onmouseover="zctt.showtt(\'' + I18n.getMsg("crm.view.attachment.download") + '\')" onmouseout="zctt.hidett()" id="downloadlink" class="svgIconsImg dIB downloadLinkImg" href="/recruit/ViewAttachment?fileId=' + fileId + "&module=" + encodeURIComponent(crmRelatedList.Module) + "&parentId=" + crmRelatedList.EntityId + "&creatorId=" + body.CreaterId + "&id=" + body.ENTITYID + "&name=" + encodeURIComponent(fileName) + "&downLoadMode=default" + linkDocsParam, res += '" style="cursor: pointer"></a></div>')
}
return res
}), Handlebars.registerHelper("checkSortArrow", function(fieldId, sortColumnId, fieldLabel, op) {
return "" == fieldId && sortColumnId == fieldLabel ? op.fn(this) : fieldId == sortColumnId ? op.fn(this) : op.inverse(this)
}), Handlebars.registerHelper("getClassNames", function(isNewCreateLink) {
var returnString = "";
return returnString = isNewCreateLink ? isNewCreateLink + " createlink" : "tb_newsmallbtn"
}), Handlebars.registerHelper("getLinksForIndeed", function() {
var indeedData = detailView.changedBCJson.indeedData,
href = "",
city = indeedData.city ? indeedData.city : "",
state = indeedData.state ? indeedData.state : "",
country = indeedData.country ? indeedData.country : "",
entityId = detailView.entityId,
BCViewObject = detailView.changedBCJson.BCViewObject,
potentialName = $.map(BCViewObject, function(key) {
return "POTENTIALNAME" == key.colname ? key.defaultvalue : void 0
})[0];
return indeedData.indeedLink && "Potentials" == indeedData.indeedLinkFor ? href = "/recruit/SearchIndeed.do?title=" + potentialName + "&city=" + city + "&state=" + state + "&co=" + country + "&jobId=" + entityId : indeedData.indeedLink && "Leads" == indeedData.indeedLinkFor && (href = Crm.RebrandProperties.indeedURL + indeedData.indeedLink), href
}), Handlebars.registerHelper("getSplitValues", function(val, spliter, splitIndex) {
return val.split(spliter)[splitIndex]
}), Handlebars.registerHelper("getFilterType", function(selectedFilter, curFilter) {
return selectedFilter === curFilter ? "selected = 'selected'" : ""
}), Handlebars.registerHelper("getEditDeleteLinks", function(rid, row, op) {
var editLink = "",
deleteLink = "",
closeLink = "",
editzcqa = "",
deletezcqa = "",
closezcqa = "",
isCallLink = !1,
personalityObj = crmRelatedList.getPersonalityModuleObj(rid),
personality = personalityObj.name,
targetString = crmRelatedList.getTaregetString(rid),
isToModuleNeeded = !1,
primaryModule = crmRelatedList.Module,
unassociateLink = "",
viewNotesData = "",
viewMailData = {},
viewSMSLink = "",
relModule = row.MODULE ? row.MODULE : "";
if ("ACCOUNTSPERSONALITY" == personality)
isToModuleNeeded = !0, editLink = crmRelatedList.createEditLink(row.MODULE, row.ENTITYID, targetString), deleteLink = crmRelatedList.createDeleteLink(row.MODULE, row.ENTITYID, targetString, isToModuleNeeded, void 0, row.MODULE);
else if ("SUBMISSIONPERSONALITY" == personality)
viewNotesData = {
pkid: crmRelatedList.EntityId + "",
module: crmRelatedList.Module,
noteid: row.NOTEID + "",
rating: row.RATING,
reviewedby: row.REVIEWDBYNAME
}, viewNotesData = JSON.stringify(viewNotesData), row.TEMPLATE_SUBMITTOCLIENT = crmRelatedList.TEMPLATE_SUBMITTOCLIENT, viewMailData = row;
else if ("SMSPERSONALITY" == personality)
viewSMSLink = "onclick=ZRSMSUtil.viewSMSHistoryDetail('" + row.SMSHistoryId + "','" + crmRelatedList.Module + "','body');";
else if ("CHILDACCOUNTSPERSONALITY" == personality || "POTENTIALSPERSONALITY" == personality || "CASESPERSONALITY" == personality || "QUOTESPERSONALITY" == personality || "SALESORDERSPERSONALITY" == personality || "PURCHASEORDERSPERSONALITY" == personality || "INVOICESPERSONALITY" == personality || "SOLUTIONSPERSONALITY" == personality || "VENDORSPERSONALITY" == personality)
isToModuleNeeded = "POTENTIALSPERSONALITY" == personality ? !0 : !1, editLink = crmRelatedList.createEditLink(row.MODULE, row.ENTITYID, targetString, getObj("recordNum").value), ("SOLUTIONSPERSONALITY" == personality || "VENDORSPERSONALITY" == personality) && (editLink = crmRelatedList.createEditLink(row.MODULE, row.ENTITYID, targetString)), deleteLink = crmRelatedList.createDeleteLink(row.MODULE, row.ENTITYID, targetString, isToModuleNeeded, void 0, row.MODULE), "POTENTIALSPERSONALITY" == personality && ("Leads" === primaryModule && "Potentials" === row.MODULE && (editLink = crmRelatedList.createStatusChangeLink(rid, row.MODULE, row.ENTITYID, targetString, getObj("recordNum").value)), "Leads" === primaryModule && (unassociateLink = "onclick=ZRAssociateUtil.actionEvent(event,'" + crmRelatedList.EntityId + "','" + $ESAPI.encoder().encodeForHTMLAttribute(row.CONTENT[0]) + "');sE(event) data-pkid=" + row.ENTITYID));
else if ("CONTACTSPERSONALITY" == personality || "CAMPAIGNSPERSONALITY" == personality || "LEADSPERSONALITY" == personality) {
isToModuleNeeded = !0;
var parentModule = crmRelatedList.Module;
!personalityObj.isCustLookUp && "Campaigns" == parentModule || !personalityObj.isCustLookUp && "CAMPAIGNSPERSONALITY" == personality ? (editLink = crmRelatedList.createStatusChangeLink(rid, row.MODULE, row.ENTITYID, targetString, getObj("recordNum").value), deleteLink = crmRelatedList.createDeleteLink("MultiValued", row.ENTITYID, targetString, isToModuleNeeded, personalityObj.isCustLookUp, row.MODULE)) : (deleteLink = crmRelatedList.createDeleteLink(row.MODULE, row.ENTITYID, targetString, isToModuleNeeded, personalityObj.isCustLookUp, row.MODULE), editLink = "LEADSPERSONALITY" == personality && "Potentials" === primaryModule ? crmRelatedList.createStatusChangeLink(rid, row.MODULE, row.ENTITYID, targetString, getObj("recordNum").value) : crmRelatedList.createEditLink(row.MODULE, row.ENTITYID, targetString, getObj("recordNum").value), "Potentials" === primaryModule && (unassociateLink = "onclick=ZRAssociateUtil.actionEvent(event,'" + crmRelatedList.EntityId + "','" + $ESAPI.encoder().encodeForHTMLAttribute(row.CONTENT[0]) + "');sE(event) data-pkid=" + row.ENTITYID))
} else if ("VISITSPERSONALITY" == personality)
isToModuleNeeded = !0, deleteLink = crmRelatedList.createDeleteLink(row.MODULE, row.ENTITYID, targetString, isToModuleNeeded, personalityObj.isCustLookUp, row.MODULE);
else if (personalityObj.isCustomModule)
isToModuleNeeded = !0, editLink = crmRelatedList.createEditLink(row.MODULE, row.ENTITYID, targetString), deleteLink = crmRelatedList.createDeleteLink(row.MODULE, row.ENTITYID, targetString, isToModuleNeeded, personalityObj.isCustLookUp, row.MODULE);
else if ("EMAILSPERSONALITY" == personality)
isToModuleNeeded = !1, deleteLink = crmRelatedList.createDeleteLink(row.MODULE, row.ENTITYID, targetString, isToModuleNeeded);
else if ("ACTIVITYPERSONALITY" == personality || "ACTIVITYHISTORYPERSONALITY" == personality || "INVITEDEVENTSPERSONALITY" == personality) {
var activityType = (crmRelatedList.getSetSinglePersonalityData(rid, "get"), void 0 != personalityObj.activityType ? personalityObj.activityType : "All");
isToModuleNeeded = !1, deleteLink = crmRelatedList.createDeleteLink(row.MODULE, row.ENTITYID, targetString, isToModuleNeeded) + "&activityType=" + activityType, editLink = crmRelatedList.createEditLink(row.MODULE, row.ENTITYID, targetString, getObj("recordNum").value) + "&activityType=" + activityType, "Tasks" != row.MODULE || "ACTIVITYHISTORYPERSONALITY" == personality || 2 == row.approveStatus || row.COMPLETED || (closeLink = crmRelatedList.createCloseLink(row.ENTITYID, targetString) + "&activityType=" + activityType, closezcqa = "lnk_delete_Tasks"), "Calls" != row.MODULE || "ACTIVITYHISTORYPERSONALITY" == personality || 2 == row.approveStatus || "Scheduled" != row.CALLSTATUS && "Overdue" != row.CALLSTATUS || (isCallLink = !0, deletezcqa = "relatedListMore_Calls")
} else if ("COMPETITORSPERSONALITY" == personality) {
var recordNum = getObj("recordNum").value;
editLink = "/recruit/potentials/EditCompetitor.do?id=" + crmRelatedList.EntityId + "&module=Potentials&competitorid=" + row.ENTITYID + "&rid=" + rid + "&returnAnchor=" + targetString + "&recordNum=" + (null == recordNum ? null : encodeURIComponent(recordNum)), deleteLink = "/recruit/potentials/DeletingCompetitor.do?competitorid=" + row.ENTITYID + "&nextStep=relatedlist&isajax=true#" + targetString
} else if ("PRICEBOOKSPERSONALITY" == personality)
isToModuleNeeded = !0, editLink = crmRelatedList.creareEditLinkForProducts(rid, personality, targetString, row.ENTITYID, crmRelatedList.Module, row.MODULE), deleteLink = crmRelatedList.createDeleteLink(row.MODULE, row.ENTITYID, targetString, isToModuleNeeded, personalityObj.isCustLookUp, row.MODULE), personalityObj.isCustLookUp || (deleteLink = crmRelatedList.createDeleteLink("MultiValued", row.ENTITYID, targetString, isToModuleNeeded, personalityObj.isCustLookUp, row.MODULE));
else if ("PRODUCTSPERSONALITY" == personality) {
isToModuleNeeded = !0;
var fromoModule = crmRelatedList.Module,
toModule = row.MODULE;
editLink = crmRelatedList.createEditLink(rid, personality, targetString, row.ENTITYID, crmRelatedList.Module, row.MODULE), deleteLink = crmRelatedList.createDeleteLink(row.MODULE, row.ENTITYID, targetString, isToModuleNeeded, personalityObj.isCustLookUp, row.MODULE), !personalityObj.isCustLookUp && "Leads" == crmRelatedList.Module && Crm.userDetails.permissions["Crm_Implied_Edit_" + row.MODULE] && (deleteLink = crmRelatedList.createDeleteLink("MultiValued", row.ENTITYID, targetString, isToModuleNeeded, personalityObj.isCustLookUp, row.MODULE)), "PRODUCTSPERSONALITY" == personality && "Leads" != crmRelatedList.Module && (deleteLink = ""), "PriceBooks" == fromoModule && "Products" == toModule || "Products" == fromoModule && "PriceBooks" == toModule || ("Vendors" == fromoModule ? (isToModuleNeeded = !1, editLink = crmRelatedList.createEditLink(row.MODULE, row.ENTITYID, targetString), deleteLink = crmRelatedList.createDeleteLink(row.MODULE, row.ENTITYID, targetString, isToModuleNeeded)) : ("Leads" != fromoModule || "Products" != toModule) && (editLink = ""))
} else
"CONTACTSROLESPERSONALITY" == personality ? deleteLink = crmRelatedList.createRemoveLinkForContactRole(row.CONTACTID, row.POTENTIALID, targetString) : "ATTACHMENTSPERSONALITY" == personality && (deleteLink = void 0 != crmRelatedList.EachModuleData[rid].deleteAttachTypes[row.attachTypeId] && 1 == crmRelatedList.EachModuleData[rid].deleteAttachTypes[row.attachTypeId] ? "/recruit/deleteattachment.do?attachmentid=" + row.ENTITYID + "&module=" + encodeURIComponent(crmRelatedList.Module) + "&id=" + crmRelatedList.EntityId + "&nextStep=relatedlist&isajax=true&creatorId=" + row.CreaterId + "#" + targetString : "");
if (this.links = {}, "OFFERSPERSONALITY" === personality && ("Accounts" != crmRelatedList.Module && Crm.userDetails.permissions.Crm_Implied_Generate_Offer_Letter && "Offer-Withdrawn" !== row.status && (this.links.offerpersonality = !0), this.links.offerdownload = !0, this.links.showOfferOptions = "Potentials" === crmRelatedList.Module ? 0 == returnJson.recordInLeadStatusProcess || void 0 == returnJson.recordInLeadStatusProcess : "Leads" === crmRelatedList.Module ? 0 == returnJson.recordInStatusProcess || void 0 == returnJson.recordInStatusProcess : !1, this.links.showchangeexpiry = "Contract" === this.employmenttype && ("Offer-Made" === this.status || "Offer-Accepted" === this.status || "To-be-Offered" === this.status), this.links.showresendemail = "Offer-Made" === this.status && this.generatedtype === ZROfferUtil.offercontracttype.Email, this.links.showofferedit = this.links.showOfferOptions && ("Offer-Made" === this.status || "Offer-Declined" === this.status || "To-be-Offered" === this.status) && this.generatedtype === ZROfferUtil.offercontracttype.Email, this.links.showsendtoesign = this.links.showOfferOptions && this.generatedtype != ZROfferUtil.offercontracttype.Email && "To-be-Offered" === this.status, this.links.editandsendtosign = this.links.showOfferOptions && this.generatedtype != ZROfferUtil.offercontracttype.Email && "To-be-Offered" === this.status, this.links.showofferwithdraw = this.links.showOfferOptions && ("Offer-Made" === this.status || "Offer-Accepted" === this.status), this.links.deleteoffer = "To-be-Offered" === this.status && this.generatedtype != ZROfferUtil.offercontracttype.Email, this.links.offerpersonality = this.links.offerpersonality && (this.links.showchangeexpiry || this.links.showresendemail || this.links.showofferedit || this.links.showofferwithdraw || this.links.deleteoffer || this.links.editandsendtosign || this.links.showsendtoesign)), "" != editLink) {
var isEventEdit,
isShowStatusChange,
isEditEntity,
dataParams = {};
if (-1 != editLink.indexOf("EditEntity.do?") && Crm.userDetails.permissions["Crm_Implied_Edit_" + row.MODULE]) {
var editParams = editLink.substring(editLink.indexOf("?") + 1),
moduleName = editParams.substring(0, editParams.indexOf("&"));
if (moduleName = moduleName.substring(moduleName.indexOf("=") + 1), "ACTIVITYPERSONALITY" == personality || "ACTIVITYHISTORYPERSONALITY" == personality || "INVITEDEVENTSPERSONALITY" == personality)
if (-1 != editParams.indexOf("Events"))
isEventEdit = !0, editzcqa = "relatedListEdit_Events", dataParams = {
module: "Events",
id: row.ENTITYID,
from: "relatedlist_new"
};
else {
isEditEntity = !0;
var activityType = void 0 != personalityObj.activityType ? personalityObj.activityType : "All";
editzcqa = "relatedListEdit_" + $ESAPI.encoder().encodeForHTML(row.MODULE), dataParams = {
goTo: targetString,
module: encodeURIComponent(row.MODULE),
id: row.ENTITYID,
activityType: activityType
}
}
else
isEditEntity = !0, editzcqa = "relatedListEdit_" + $ESAPI.encoder().encodeForHTML(row.MODULE), dataParams = {
goTo: targetString,
module: encodeURIComponent(row.MODULE),
id: row.ENTITYID
}
} else
personalityObj.isCustLookUp || "CAMPAIGNSPERSONALITY" != personality && "CONTACTSPERSONALITY" != personality && "LEADSPERSONALITY" != personality && "POTENTIALSPERSONALITY" != personality || (editzcqa = "relatedListEdit_Campaigns", isShowStatusChange = !0);
this.links.editObj = {
url: editLink,
dataCid: "editbtn",
dataParams: dataParams,
isShowStatusChange: isShowStatusChange,
isEditEntity: isEditEntity,
isEventEdit: isEventEdit,
editzcqa: editzcqa
}
}
var permissionCheck = "ATTACHMENTSPERSONALITY" !== personality ? Crm.userDetails.permissions["Crm_Implied_Delete_" + relModule] : row.isDeleteAttachPermission;
if ("" != deleteLink && "" != relModule && permissionCheck) {
var isShowInvoiceMenu = !1,
isRemoveLink = !1,
warningMsg = "",
dataParamsDel = {};
if (personalityObj.isCustLookup || "INVOICESPERSONALITY" != personality && "SALESORDERSPERSONALITY" != personality && "QUOTESPERSONALITY" != personality ? "VISITACTIONSPERSONALITY" != personality && "SURVEYPERSONALITY" != personality && (deletezcqa = "lnk_delete_" + row.MODULE) : (isShowInvoiceMenu = !0, deletezcqa = "showSettings_" + row.MODULE, dataParamsDel = {
module: encodeURIComponent(row.MODULE),
relatedContactId: row.relContactId,
id: row.ENTITYID,
deleteLink: deleteLink,
isApproved: row.approveStatus
}), !personalityObj.isCustLookUp && ("CAMPAIGNSPERSONALITY" == personality || "PRICEBOOKSPERSONALITY" == personality || "CONTACTSROLESPERSONALITY" == personality || "Campaigns" == crmRelatedList.Module && ("Leads" == row.MODULE || "Contacts" == row.MODULE))) {
deletezcqa = "", isRemoveLink = !0;
var removeMod = "";
removeMod = "CONTACTSROLESPERSONALITY" == personality ? Crm.moduleInfo.Contacts[0] : Crm.moduleInfo[row.MODULE][0], warningMsg = I18n.getMsg("crm.warning.deassociate.entity", [removeMod, Crm.moduleInfo[crmRelatedList.Module][0]])
}
this.links.deleteObj = {
url: deleteLink,
isShowInvoiceMenu: isShowInvoiceMenu,
isRemoveLink: isRemoveLink,
warningMsg: warningMsg,
dataParamsDel: dataParamsDel,
isCallLink: isCallLink,
deletezcqa: deletezcqa
}, "Accounts" == detailView.currentModule && "POTENTIALSPERSONALITY" == personality && delete this.links.deleteObj
}
return "" != closeLink && (this.links.closeObj = {
url: closeLink,
closezcqa: closezcqa
}), "" !== unassociateLink && unassociateLink.length && (this.links.unassociateObj = {
link: unassociateLink
}, this.links.deleteObj = void 0), "SUBMISSIONPERSONALITY" != personality || "" == viewNotesData && "" == viewMailData || (this.links.clientSubmissionObj = void 0 == row || 0 == row.NOTEID.length || "null" == row.NOTEID ? {
mailLink: viewMailData
} : {
notesLink: {
data: viewNotesData
},
mailLink: viewMailData
}, this.links.editObj = void 0, this.links.deleteObj = void 0, this.links.unassociateObj = void 0), "SMSPERSONALITY" == personality && (this.links.smsObj = {
viewSMSLink: viewSMSLink
}, this.links.editObj = void 0, this.links.deleteObj = void 0, this.links.unassociateObj = void 0, this.links.clientSubmissionObj = void 0), op.fn(this)
}), Handlebars.registerHelper("isSortableRL", function(a, pers, colname, op) {
return 3 == a || 999 == a || 208 == a || 110 == a || 80 == a || 82 == a || "POTSTAGEHISTPERSONALITY" == pers || "OFFERSPERSONALITY" == pers && "GENERATEDTYPE" == colname ? op.inverse(this) : op.fn(this)
}), Handlebars.registerHelper("ifNotInventoryModule", function(module, op) {
return "Quotes" != module && "Invoices" != module && "PurchaseOrders" != module && "SalesOrders" != module ? op.fn(this) : op.inverse(this)
}), Handlebars.registerHelper("getEntityId", function() {
return $("#id").val()
}), Handlebars.registerHelper("checkStringRelList", function(value, heading, index, body, cvid, module, personality, option) {
if (cvid || (cvid = null), "Contact Roles" == module)
module = "Contacts";
else if ("Invited Events" == module) {
if ("SUBJECT" == heading[index].COLUMNNAME)
return option.fn(this);
module = "Activities"
}
if ("Member Status" == heading[index].COLUMNALIAS && void 0 != body.REMARKS)
return "<span style='cursor: pointer' onmouseout='zctt.hidett();' onmouseover='zctt.showtt( \"" + body.REMARKS + "\")'>" + option.fn(this) + "</span>";
if ("QUESTIONNAIRENAME" == heading[index].COLUMNNAME || "QUESTIONNAIREID" == heading[index].COLUMNNAME) {
if ("Products" === module)
return $ESAPI.encoder().encodeForHTML(value.DISPLAYLABEL);
var qeJOName;
if (null != value) {
if (qeJOName = value.split("-~-~-"), qeJOName.length >= 2) {
var dataobj = {
entityId: $("#entityId").val(),
id: body.ENTITYID,
subId: qeJOName[1]
};
return 4 === qeJOName.length ? "<a href='javascript:void(0);' onclick='ZRQuestionnaire.showEntity(" + JSON.stringify(dataobj) + ");sE();'>" + $ESAPI.encoder().encodeForHTML(qeJOName[0]) + " <span class='disIB fonS3 gray6'>" + I18n.getMsg("crm.label.for") + "</span> <a target='_blank' href='/recruit/EntityInfo.do?module=JobOpenings&id=" + qeJOName[2] + "'>" + $ESAPI.encoder().encodeForHTML(qeJOName[3]) + "</a></a>" : "<a href='javascript:void(0);' onclick='ZRQuestionnaire.showEntity(" + JSON.stringify(dataobj) + ");sE();'>" + $ESAPI.encoder().encodeForHTML(qeJOName[0]) + "</a>"
}
var dataobj = {
id: body.ENTITYID
};
return "<a href='javascript:void(0);' onclick='ZRQuestionnaire.listQuestionnaire(" + JSON.stringify(dataobj) + ");sE();'>" + $ESAPI.encoder().encodeForHTML(qeJOName[0]) + "</a>"
}
} else if ("VENDORNAME" == heading[index].COLUMNNAME && "Potentials" == module) {
if (null != value) {
var vendorId = value.ENTITYID;
if (void 0 != vendorId)
return "<a target='_blank' href='/recruit/EntityInfo.do?module=" + value.module + "&id=" + value.ENTITYID + "'>" + $ESAPI.encoder().encodeForHTML(value.vendorName) + "</a>"
}
} else if ("LEADID" == heading[index].COLUMNNAME && "Potentials" == module && "Applied Candidates" == heading[index].FIELDLABEL) {
if (null != value) {
var count = value.SUBMITTEDCOUNT;
if (void 0 != count)
return "<span>" + $ESAPI.encoder().encodeForHTML(count) + "</span>"
}
} else if ("SHAREDVENDORSPERSONALITY" == personality && "ISPUBLISH" == heading[index].COLUMNNAME && "Potentials" == module) {
if (null != value) {
var data = value.vendorId;
return void 0 != data ? '<a href="javascript:;" onclick="ZRVendorPortal.unPublishJobForThisVendor(\'' + $ESAPI.encoder().encodeForJavaScript(value.vendorId) + "','" + $ESAPI.encoder().encodeForJavaScript(value.jobId) + "' );\">" + I18n.getMsg("crm.jobboards.job.unpublish.button") + "</a>" : "--"
}
} else if ("OFFERSPERSONALITY" === personality && ZROfferUtil.relatedListColumnsModify.indexOf(heading[index].COLUMNNAME) >= 0)
switch (heading[index].COLUMNNAME) {
case "OFFERTEMPLATENAME":
return "<a target='_blank' href='/recruit/viewOfferFile?entityId=" + body.leadid + "&offerId=" + value.ENTITYID + "&module=Offers&downLoadMode=pdfViewPlugin'><i class='fa fa-file-pdf-o' style='color: #882321;'></i>&nbsp;&nbsp;&nbsp;" + $ESAPI.encoder().encodeForHTML(value.DISPLAYLABEL) + "</a>";
case "EMPLOYMENTTYPE":
return "Permanent" === value ? I18n.getMsg("Permanent") : (body.columnname = "EMPLOYMENTTYPE", Handlebars.getTemplate("OfferManagement", "RelatedListOfferNotes")(body));
case "STATUS":
return body.columnname = "STATUS", body.statusvalue = value, "Offer-Accepted" === value || "Offer-Declined" === value || "Offer-Withdrawn" === value && "" !== body.NOTE_CONTENT ? Handlebars.getTemplate("OfferManagement", "RelatedListOfferNotes")(body) : I18n.getMsg(value)
}
else {
if ("object" != typeof value && void 0 !== heading) {
if (void 0 === heading[index])
return;
if (21 == heading[index].UITYPE) {
var res = "",
http = "http",
https = "https";
return "" === value || 0 != value.indexOf(http) && 0 != value.indexOf(https) ? "" != value && (res = '<a data-cid="dummy" class="link" href="' + http + "://" + option.fn(this) + '" target="_blank">' + option.fn(this) + "</a>") : res = '<a data-cid="dummy" class="link" href="' + option.fn(this) + '" target="_blank">' + option.fn(this) + "</a>", res
}
if (301 == heading[index].UITYPE || 300 == heading[index].UITYPE) {
var res = "";
return res = value === !0 || "true" == value ? '<img src="' + Search.spacerImg + '" class="yes">' : '<img src="' + Search.spacerImg + '" class="no-new" width="9" height="9">'
}
if (100 == heading[index].UITYPE) {
var res = option.fn(this);
return "" != value && (res = res.replace(/;/g, "; ")), res
}
if (22 == heading[index].UITYPE) {
var res = "";
if ("" != value) {
var display = option.fn(this);
DWRutil.getTwHandlerVal(value, {
callback: function(str) {
if (null != str && "null" != str && str.trim().length > 0) {
res = ' <a data-cid="dummy" class="link" href="' + RebrandLinkUtil.getProperties("TW_URL") + "/" + str + '" target="_blank" id="subvalue_Twitter">' + display + "</a>"
} else
res = ' <span id="subvalue_Twitter">' + display + "</span>"
}
})
}
return res
}
if (38 == heading[index].UITYPE)
return parseFloat(option.fn(this));
if (33 == heading[index].UITYPE)
return "" == value ? option.fn(this) : customViewObject && 1 == customViewObject.outbound ? "<div onmouseover='editmouseover(this,\"phone\");' onmouseout='editmouseout(this, \"phone\");' class='phoneRtl' style='min-width:100%'>" + option.fn(this) + "<a style='visibility:hidden;' href='javascript:;' class='calliconOuter fN' onmouseover='showCallButtonlabel(this)' onmouseout='hideCallButtonlabel(this)' onclick=\"sE();click2Call('" + value + "','" + Crm.userDetails.ZGID + "','" + Crm.userDetails.USER_ID + "','" + body.ENTITYID + "','','" + module + "')\"><i class='callIcon'></i><span id='calllabel1'>" + I18n.getMsg("Call") + "</span></a></div>" : Crm.userDetails.ZPBENABLED ? "<div class='phoneRtl' style='min-width:100%;position:relative'>" + option.fn(this) + "<span style='position:absolute'><zpb-phone number='" + option.fn(this) + "' module='" + module + "' recordid='" + body.ENTITYID + "'></zpb-phone></span></div>" : "<div onmouseover='editmouseover(this, \"phone\");' onmouseout='editmouseout(this, \"phone\");' class='phoneRtl' style='min-width:100%'>" + option.fn(this) + "<a style='visibility:hidden;' class='pH2 phoneRtl' title='" + I18n.getMsg("crm.phoneNo.Link.Title") + "' href='skype:" + value + "?call' onclick='sE();'></a></div>";
var head = {
Leads: "LASTNAME",
Activities: "SUBJECT",
Accounts: "ACCOUNTNAME",
Contacts: "LASTNAME",
Potentials: "POTENTIALNAME",
Campaigns: "CAMPAIGNNAME",
Cases: "CASESUBJECT",
Solutions: "SOLUTIONTITLE",
Products: "PRODUCTNAME",
Vendors: "VENDORNAME",
PriceBooks: "BOOKNAME",
Quotes: "QUOTESUBJECT",
SalesOrders: "SALESORDERSUBJECT",
PurchaseOrders: "PURCHASEORDERSUBJECT",
Invoices: "INVOICESUBJECT",
Forecasts: "FORECASTNAME",
Visits: "VISITEDPAGE"
};
if (0 == module.indexOf("CustomModule") && "NAME" == heading[index].COLUMNNAME || heading[index].COLUMNNAME == head[module]) {
var relContactId = body.relContactId ? body.relContactId : null,
permission = "Crm_Implied_View_" + module;
crmListView.changedPermissionsForZBModules.hasOwnProperty(permission) && (permission = crmListView.changedPermissionsForZBModules[permission]), permission = Crm.userDetails.permissions[permission];
var res = "<a ";
return permission > -1 ? (res += 'data-cid="detailView" href="/recruit/EntityInfo.do?id=' + body.ENTITYID + "&module=" + body.MODULE, "Potentials" == crmRelatedList.Module && "LEADSPERSONALITY" == personality && (res += "&assoJOId=" + crmRelatedList.EntityId + "&lookback=assoJob"), res += '"') : res += 'href="javascript:;" title="permission denied" data-permission="false"', res += 'id="relatedList_' + body.ENTITYID + "\" data-zcqa='relatedList_" + option.fn(this) + "'", res += "Potentials" == crmRelatedList.Module && "LEADSPERSONALITY" == personality ? 'data-params=\'{"pfrom":"rel","relContactId":"' + relContactId + '","module":"' + body.MODULE + '","id":"' + body.ENTITYID + '","cvid":"' + cvid + '","recordNum":"' + recordNum + '","lookback":"assoJob","assoJOId":"' + crmRelatedList.EntityId + '"' : 'data-params=\'{"pfrom":"rel","relContactId":"' + relContactId + '","module":"' + body.MODULE + '","id":"' + body.ENTITYID + '","cvid":"' + cvid + '","recordNum":"' + recordNum + '","lookback":"true"', res += '}\' class="link"', res += ">" + option.fn(this) + "</a>"
}
return option.fn(this)
}
if (void 0 !== heading[index]) {
if (4 == heading[index].UITYPE && "Accounts" == body.MODULE)
return option.fn(this.DISPLAYLABEL);
if (4 != heading[index].UITYPE || "Calls" != body.MODULE && "Tasks" != body.MODULE && "Events" != body.MODULE) {
if ("User" === value.MODULE)
return '<span purpose="showUserBC" data-params=\'{"userId":"' + this.ENTITYID + "\"}'>" + option.fn(this.DISPLAYLABEL) + "</span>";
if ("SITENAME" == heading[index].COLUMNNAME)
return res = "Facebook" == value.jboardName || "Twitter" == value.jboardName ? value.jboardName + ' &nbsp;<i class="fa fa-info-circle curP" onclick="javascript:ZRSRUtil.getJobPostedPages(this,\'' + $ESAPI.encoder().encodeForJavaScript(value.ENTITYID) + "','" + $ESAPI.encoder().encodeForJavaScript(value.jboardName) + "');\"></i>" : "BroadBean" === value.jboardName || "LogicMelon" === value.jboardName ? ' &nbsp;<a href="javascript:;" onclick="ZRPublishUtil.showJBPostedDetails(\'' + $ESAPI.encoder().encodeForJavaScript(value.jobBoardId) + "','" + $ESAPI.encoder().encodeForJavaScript(value.jboardName) + "');\">" + value.jboardName + "</a>" : ' &nbsp;<a href="javascript:;" onclick="ZRPublishUtil.showJBPostedDetails(\'' + $ESAPI.encoder().encodeForJavaScript(value.jobBoardId) + "');\">" + value.jboardName + "</a>";
if ("JB_FINDJOB" == heading[index].COLUMNNAME)
return res = "-" !== value.findJobsLink ? ' &nbsp;<a href="' + $ESAPI.encoder().encodeForHTMLAttribute(value.findJobsLink) + '" data-zcqa="link_relJBFindJob" class="ss-url" target="_blank" rel="noopener noreferrer"></a>' : '<span class="disIB marL10">&ndash;</span>';
if ("JB_EXPIRESON" == heading[index].COLUMNNAME)
return res = "NA" !== value.expiresOn ? '<span class="ss-dateexpires">' + value.expiresOn + "</span>" : '<span class="disIB marL10">&ndash;</span>';
if ("JB_PUBLISHTYPE" == heading[index].COLUMNNAME)
return res = "true" === value.isPaidJobBoard ? '&nbsp;<span class="jpr-paid">' + value.jbPublishType + "</span>" : '&nbsp;<span class="jpr-free">' + value.jbPublishType + "</span>";
if ("PUBLISHSTATUS" == heading[index].COLUMNNAME)
return res = "-" !== value.jobStatus ? ' &nbsp;<span class="ss-dot ' + ("Active" === value.jobStatus ? "ss-active" : "Queued" === value.jobStatus ? "ss-inque" : "ss-expired") + '"></span>' + I18n.getMsg("Active" === value.jobStatus ? "Active" : "Queued" === value.jobStatus ? "crm.sms.status.queued" : "Expired" === value.jobStatus ? "Expired" : "crm.import.status.failed") : '<span class="disIB marL10">&ndash;</span>';
if ("UNPUBLISH" == heading[index].COLUMNNAME)
return res = '<a name="jbiUnPublish" href="javascript:void(0);" data-zcqa="link_relJBUnPublish" data-cid="link_relJBUnPublish" data-jboardid="' + $ESAPI.encoder().encodeForHTMLAttribute(value.jobBoardId) + '" data-jboardname="' + $ESAPI.encoder().encodeForHTMLAttribute(value.jboardName) + '">' + I18n.getMsg("crm.jobboards.job.unpublish.button") + "</a>";
var permission = "Crm_Implied_View_" + module;
crmListView.changedPermissionsForZBModules.hasOwnProperty(permission) && (permission = crmListView.changedPermissionsForZBModules[permission]), permission = Crm.userDetails.permissions[permission];
var res = "<a ";
return res += permission > -1 ? 'data-cid="detailView" data-params=\'{"pfrom":"rel","relContactId":"null","module":"' + value.MODULE + '","id":"' + value.ENTITYID + '","lookback":"true"}\' href="/recruit/EntityInfo.do?id=' + value.ENTITYID + "&module=" + value.MODULE + '"' : 'href="javascript:;" title="Permission denied" data-permission="false"', res += 'id="relatedList_' + value.ENTITYID + "\" data-zcqa='relatedList_" + option.fn(this.DISPLAYLABEL) + '\' class="link">' + option.fn(this.DISPLAYLABEL) + "</a>"
}
var mod = this.MODULE,
permission = "Crm_Implied_View_" + mod;
crmListView.changedPermissionsForZBModules.hasOwnProperty(permission) && (permission = crmListView.changedPermissionsForZBModules[permission]), permission = Crm.userDetails.permissions[permission], mod = mod.slice(0, mod.lastIndexOf("s"));
var res = "<a ";
return res += permission > -1 ? 'data-cid="detailView" data-params=\'{"pfrom":"rel","relContactId":"' + (body.relContactId ? body.relContactId : null) + '","module":"' + this.MODULE + '","id":"' + this.ENTITYID + '","lookback":"true"}\' href="/recruit/EntityInfo.do?id=' + this.ENTITYID + "&module=" + this.MODULE + '"onmouseover="showRelatedFields_new(\'' + this.MODULE + "','" + this.ENTITYID + '\',this)" onmouseout="hideLoadingDiv();"' : 'href="javascript:;" title="permission denied" data-permission="false"', res += ' id="relatedList_' + this.ENTITYID + "\" data-zcqa='relatedList_" + option.fn(this.DISPLAYLABEL) + '\' class="link">', res += option.fn(this.DISPLAYLABEL), res += "</a>"
}
}
});
var cVar = {
variableObj: void 0,
groupObj: void 0,
editVarGroupId: void 0,
jquerySection: function() {
$("body").click(function() {
$("#viewCvariablesPOP").addClass("hide")
})
},
createGroup: function() {
var reqPool = new crmRequestPool,
params = csrfParamName + "=" + encodeURIComponent(csrfToken);
reqPool.initiate({
action: "/recruit/Variables.do?action=createGroup",
type: "POST",
data: params,
success: function(responseJSon) {
if ("Limit Exceeded" == responseJSon.trim())
crmui.showMsgBand("alert", I18n.getMsg("crm.variable.group.exceed.msg"), "3000");
else if ("" == responseJSon) {
var jsn = Object();
jsn.groupAction = "crm.variables.createnewgroup", $("#result").append($(Handlebars.templates.crmVariableGroup(jsn))), $("#groupaction").attr("action", "saveGroup"), $("#cVargroupPop").show(), $("#cVarGroupItems_chosen").hide(), $("#cVarCgroupName").val(""), $("#cVargroupAPIName").val(""), $("#cVarCgroupDesc").val(""), showAnimatePopup("cVargroupPop"), setFocusClass($("#cVarCgroupName")[0]), setTimeout(function() {
$("#cVarCgroupName").focus()
}, 100)
}
}
})
},
createVariable: function() {
var reqPool = new crmRequestPool,
params = csrfParamName + "=" + encodeURIComponent(csrfToken),
groupId = $(".cVarList").val();
reqPool.initiate({
action: "/recruit/Variables.do?action=createVariable&groupId=" + groupId,
type: "POST",
data: params,
success: function(responseJSon) {
"" != responseJSon && (cVar.createVariableRow(responseJSon), $("#cVarGroupItems").val(responseJSon.popGroupId).trigger("chosen:updated"), $("#cVarNAME").focus(), $("#cVarNAME").closest(".labelValCreate,.tabDiv").addClass("focusEleField"))
}
})
},
variableList: function(txt, params) {
if (params && params.variableId) {
var groupId = params.groupId;
groupId = void 0 != groupId ? groupId : "1";
var dataparam = txt.variableDetails,
creJson = Object();
creJson.editvariable = I18n.getMsg("crm.variable.editcrmvariable"), creJson.save = I18n.getMsg("crm.button.save"), creJson.cancel = I18n.getMsg("crm.button.cancel");
var vId = dataparam.variableId,
uiType = dataparam.editUitype,
val = dataparam.value,
gId = dataparam.groupId,
apiName = dataparam.sysRefName,
description = dataparam.description,
uiTypeStr = dataparam.uiType,
varName = dataparam.variableName,
frag = document.createDocumentFragment();
$(frag).append(crmTemplate.createvarFieldRow(cVar.createNewVariableName(varName))), $(frag).append(crmTemplate.createvarFieldRow(cVar.createNewvariableApiName(apiName))), $(frag).append(crmTemplate.createvarFieldRow(cVar.createNewVarDesc(description))), $(frag).append(crmTemplate.createvarFieldRow(cVar.editDataType(uiTypeStr)));
var fieldDiv = "crmdivVal",
valueLabel = "Value",
labelId = "fieldValue",
readOnly = "false",
displaylabel = I18n.getMsg("crm.label.value"),
elem1 = $(Handlebars.templates.crmCreateVariables(creJson));
$("#result").html(elem1), $("#createeditvar").html(frag), $("#createeditvar").show();
var resDiv = crmTemplate.createvarFieldRow(cVar.getjsonValueHandlebar(uiType, val, fieldDiv, valueLabel, labelId, readOnly, displaylabel));
$("#crmdivVal").replaceWith(resDiv), $("#createeditvarvalue").show(), $("#createeditvarvalue").html(crmTemplate.createvarFieldRow(cVar.createNewGroup(txt))), $("#cVarGroupItems").val(gId).trigger("chosen:updated"), $("#saveVar").attr("id_attr", vId), $("#cVarSelectType").attr("data-editUiType", uiType), $("#saveVar").prop("disabled", !1), $("#saveVar").attr("groupId", groupId), $("#fieldDiv_cVarSelectType").addClass("cVarGroupChCtn"), cVar.updateChosen(), setFocusClass($("#cVarNAME")[0]), setTimeout(function() {
$("#cVarNAME").focus()
}, 100), Utils.showHideLoadingDiv(), EvalInnerScript(getObj("mainResult")), divId = params.subTab, crmSetup.selectSetupTab("general", divId, "crmvariables"), crmSetup.SetHeight_setup_inner_content(), adSearchClose()
} else {
if (!params || "createVariable" != params.action) {
cVar.variableObj = txt;
var headJson = new Array;
headJson.push("crm.variables.variablename"), headJson.push("crm.variables.datatype"), headJson.push("crm.variables.value"), headJson.push("crm.crmvariables.groupname");
var responseJson = ZRCommonUtil.convertStringToJson(txt);
responseJson.title = "crm.crmvariables", responseJson.helpURL || (responseJson.helpURL = ""), responseJson.description = I18n.getValueForFields("crm.crmvariables.definition", "Zoho"), responseJson.featureName = I18n.getValueForFields("crm.crmvariables"), responseJson.createButton = "crm.crmvariables.createvariable", responseJson.heading = headJson, responseJson.fcrmVar = I18n.getValueForFields("crm.variables.fcrmvar"), responseJson.createVar = "", responseJson.setup = "cVar.showCustomSettings(this);", responseJson.editfn = "", responseJson.deletefn = "cVar.showDeletePop(this)", responseJson.deletConform = "crm.variables.delete.variablemesage", responseJson.editcrmvariable = "crm.variable.editcrmvariable.values", responseJson.groupName = "crm.variables.creategroupname", responseJson.groupDescription = "crm.variables.createvariabledescription", responseJson.grouprename = "crm.variable.grouprename", responseJson.deletevar = "crm.button.delete", responseJson.searchvariable = "crm.variables.searchvariables", responseJson.done = "Done", responseJson.save = "crm.button.save", responseJson.cancel = "crm.button.cancel", responseJson.cid = "cVarEdit", resJson = responseJson, resJson.createcidparams = '{"subTab":"crmvariables","action":"variables","tab":"general","calleeObj":"crmSetup","groupId":"1"}', Handlebars.registerPartial("crmSetUpInnerHeader", Handlebars.templates.crmSetUpInnerHeader), Handlebars.registerPartial("tabularView", Handlebars.templates.tabularView);
var divElem = Handlebars.templates.crmVariables(responseJson);
return Crm.addToHistory(void 0, void 0, {
pageTitle: "crm.crmvariables",
action: "variables",
actionMapping: "Variables",
calleeObj: "crmDummy",
orgCalleeObj: "crmSetup",
tab: "general",
subTab: "crmvariables"
}), $("#result").html(divElem), divElem
}
var gId = params.groupId;
cVar.createVariableRow(txt), setFocusClass($("#cVarNAME")[0]), $("#saveVar").attr("groupId", gId), setTimeout(function() {
$("#cVarNAME").focus()
}, 100), Utils.showHideLoadingDiv(), EvalInnerScript(getObj("mainResult")), divId = params.subTab, 1 != txt.popGroupId && $("#cVarGroupItems").val(txt.popGroupId).trigger("chosen:updated"), crmSetup.selectSetupTab("general", divId, "crmvariables"), crmSetup.SetHeight_setup_inner_content(), $("#fieldDiv_cVarSelectType").find(".labelValCreate").find(".newSelect").length || $("#fieldDiv_cVarSelectType").find(".labelValCreate").wrapInner('<div class="newSelectCrmVar"></div>'), adSearchClose()
}
},
updateChosen: function() {
var gLen = $("#cVarGroupItems > option ").length;
$("#fieldDiv_cVarGroupItems").addClass("cVarGroupCtn"), $(".cVarGroupCtn select").on("chosen:ready", function() {
if (10 >= gLen)
var createGroup = "<div class='cVarGroupBtn col333 bgf5f5f5 proximaNovaRegular p5 f15 cP pL25 bT2'><span class='cVarplusBtn mR3'></span><span class='cVarGroupTxt ' onclick='cVar.createGroup();sE(event);'>" + I18n.getValueForFields("crm.variables.createnewgroup") + "</span></div>";
else
var createGroup = "<div class='cVarGroupBtn col333 bgf5f5f5 proximaNovaRegular p5 f15 cP pL25 bT2' style='opacity: 0.5;cursor:text' onmouseover='zctt.showtt(&quot;" + I18n.getValueForFields("crm.variable.group.exceed.msg") + "&quot;)' onmouseout='zctt.hidett()'><span class='cVarplusBtn mR3'></span><span class='cVarGroupTxt'>" + I18n.getValueForFields("crm.variables.createnewgroup") + "</span></div>";
isPluginOrg || $(this).next().find("ul.chosen-results").after(createGroup)
}).chosen({
disable_search_threshold: 10,
"min-width": "40%",
"max-width": "100%",
no_results_text: "No Result for",
search_contains: !0,
placeholder_text_multiple: " ",
placeholder_text_single: " "
});
var cVarGroupChosen = $("#cVarGroupItems_chosen");
cVarGroupChosen.length && setTimeout(function() {
cVarGroupChosen.find(".cVarGroupBtn").innerWidth() > cVarGroupChosen.find(".chosen-drop").innerWidth() && cVarGroupChosen.find(".chosen-drop").css({
width: cVarGroupChosen.find(".cVarGroupBtn").innerWidth()
})
}, 500)
},
crmVariableSetting: function(jsn) {
var html = cVar.variableList(jsn);
$("#result").empty(), $("#result")[0].innerHTML = html, Utils.bindChosen(".cVarGroup select"), cVar.searchVariable()
},
showCustomFieldPop: function() {
showAnimatePopup("cVargroupPop"), $("#cFieldsSave").val("Add"), setTimeout(function() {
$("#cVarLbl").focus()
}, 1e3)
},
checkforSpecilChar: function(id) {
var elem = $("#" + id),
value = elem.val().trim(),
reg = /[^~`'!@$:,.{}/#%^&*()+=[\]|\;"<>\\]/g;
("cVargroupAPIName" == id || "cVarAPINAME" == id) && (reg = /[^~`'!@$:,.{}/#%^&*()+=[\]|\;"<>\\ ]/g);
var excldCharsArr = getClrTxtPtnResChars(value, reg),
paramArr = [];
return paramArr.push($("#" + id + "_label").text()), paramArr.push(excldCharsArr.join(" ")), 1 == excldCharsArr.length && "cVargroupAPIName" != id && "cVarAPINAME" != id ? (Crm.showErrorMsg(I18n.getValueForFields("crm.variable.validationFail.alert", paramArr), elem), !0) : 0 == excldCharsArr.length || "cVargroupAPIName" != id && "cVarAPINAME" != id ? excldCharsArr.length > 1 ? (Crm.showErrorMsg(I18n.getValueForFields("crm.variable.validationFail.alert.moreThanOneChar", paramArr), elem), !0) : void 0 : (Crm.showErrorMsg(I18n.getValueForFields("crm.variable.validationFail.alert.space"), elem), !0)
},
showDeletePop: function(el) {
var dataparam = $(el).closest("tr").attr("data-params"),
dataJson = JSON.parse(dataparam),
vId = dataJson.variableId,
vName = dataJson.variableName,
gId = dataJson.groupId;
cVar.mb_permanentDeleteCustomField(vId, vName, gId)
},
validateApiName: function(apiName) {
return apiName.match(/^[A-Za-z0-9_]*$/) ? !1 : !0
},
checkForDuplicateName: function() {
var gName = (cVar.validateVariable("cVarCgroupName"), $("#cVarCgroupName").val().trim()),
actn = "checkGrpName",
params = "gName=" + gName,
groupId = $("#cFieldsSave").attr("id_attr");
groupId = void 0 != groupId ? groupId : "";
var reqPool = new crmRequestPool;
reqPool.initiate({
action: "/recruit/Variables.do?action=" + actn + "&step1=save&gId=" + groupId,
type: "GET",
data: params,
success: function(responseJSon) {
var duplicate = void 0 != responseJSon.duplicate ? !0 : !1;
if (duplicate) {
var dupValue = responseJSon.dupValue;
dupValue = dupValue.split(":");
var dubvName = dupValue[0],
obj = $("#cVarCgroupName"),
label = $("#cVarCgroupName_label").text();
if ("GName" == dubvName) {
var dupMap = responseJSon.dupMap,
gName = dupMap.groupName,
ModuleName = dupMap.ModuleName;
"exist" == gName ? (Crm.showErrorMsg(I18n.getValueForFields("crm.variable.groupnameexist", label), obj), $("#cVarCgroupName").attr("duplicate", !0)) : "exist" == ModuleName && (Crm.showErrorMsg(I18n.getValueForFields("crm.variable.modulenameexist"), obj), $("#cVarCgroupName").attr("duplicate", !0))
}
} else
$("#cVarCgroupName").attr("duplicate", !1), cVar.genGroupApiname("cVarCgroupName"), cVar.setFocus("cVargroupAPIName")
}
})
},
addCustomFields: function() {
$(".errorFieldP").removeClass("errorFieldP"), $(".errorMsgDesc").remove();
var apiName = $("#cVargroupAPIName").val().trim(),
validate1 = cVar.validateVariable("cVarCgroupName"),
validate2 = cVar.validateVariable("cVargroupAPIName");
if (!validate1 && !validate2) {
var actn = "saveGroup",
gName = $("#cVarCgroupName").val().trim(),
gDescription = $("#cVarCgroupDesc").val().trim(),
params = csrfParamName + "=" + encodeURIComponent(csrfToken);
params = params + "&gName=" + encodeURIComponent(gName) + "&gDesc=" + encodeURIComponent(gDescription) + "&gSysRefName=" + encodeURIComponent(apiName);
var groupId = $("#cFieldsSave").attr("id_attr");
groupId = void 0 == groupId ? "" : groupId;
var groupIdAction = groupId;
$("#ajax_load_tab").show();
var reqPool = new crmRequestPool;
reqPool.initiate({
action: "/recruit/Variables.do?action=" + actn + "&step1=save&gId=" + groupId,
type: "POST",
data: params,
success: function(responseJSon) {
var duplicate = void 0 != responseJSon.duplicate ? !0 : !1,
mandatory = void 0 != responseJSon.mandatory ? !0 : !1;
if (mandatory) {
var obj = $("#cVarCgroupName"),
label = $("#cVarCgroupName_label").text();
Crm.showErrorMsg(I18n.getValueForFields("crm.variables.dupicatevariable", label), obj)
} else if (duplicate) {
var dupValue = responseJSon.dupValue;
dupValue = dupValue.split(":");
var dubvName = dupValue[0],
apiName = dupValue[1],
obj = $("#cVarCgroupName"),
label = $("#cVarCgroupName_label").text(),
apiObj = $("#cVargroupAPIName"),
apilabel = $("#cVargroupAPIName_label").text();
if ("GAPIName" == apiName && Crm.showErrorMsg(I18n.getValueForFields("crm.variable.groupnameexist", apilabel), apiObj), "GName" == dubvName) {
var dupMap = responseJSon.dupMap,
groupName = dupMap.groupName,
ModuleName = dupMap.ModuleName;
"exist" == groupName ? (Crm.showErrorMsg(I18n.getValueForFields("crm.variable.groupnameexist", label), obj), $("#cVarCgroupName").attr("duplicate", !0)) : "exist" == ModuleName && (Crm.showErrorMsg(I18n.getValueForFields("crm.variable.modulenameexist"), obj), $("#cVarCgroupName").attr("duplicate", !0))
}
$("#ajax_load_tab").hide()
} else {
if ($("#cVarCgroupName").attr("duplicate", !1), groupId = responseJSon.groupId, "" == groupIdAction) {
hideAnimatePopup("cVargroupPop"), $("#cVarGroupItems_chosen").show();
var option = $("<option/>");
option.attr({
value: groupId,
gdesc: responseJSon.groupDescription,
gapiname: responseJSon.gsysRefName
}).text($("#cVarCgroupName").val().trim()), $(".cVarGroupCtn select").prepend(option), $(".cVarGroupCtn select").val(1).trigger("chosen:updated");
var chsnnewWd,
_cVarGroupItem = $("#cVarGroupItems_chosen"),
cVarGroupItemWidth = _cVarGroupItem.find(".chosen-single span").innerWidth() + 25;
cVarGroupItemWidth < _cVarGroupItem.closest(".labelValCreate").innerWidth() && (chsnnewWd = cVarGroupItemWidth, $("#cVarGroupItems_chosen").css({
width: chsnnewWd
})), $("#cvarGroupDesc").val(responseJSon.groupDescription)
} else if ("" == !groupIdAction || void 0 == !groupIdAction) {
var req = new crmRequestPool,
params = csrfParamName + "=" + encodeURIComponent(csrfToken);
req.initiate({
action: "/recruit/Variables.do?action=variables",
type: "POST",
data: params,
success: function(resposneHtml) {
hideAnimatePopup("cVargroupPop");
var txt = cVar.variableList(resposneHtml);
$("#result").empty(), $("#result")[0].innerHTML = txt, $(".cVarGroup select").next(".select2").remove(), $(".cVarList option[value=" + groupId + "]").attr("selected", "selected"), Utils.bindChosen(".cVarGroup select"), cVar.getGroupList(void 0, groupId), cVar.searchVariable(), crmui.showMsgBand("success", I18n.getMsg("crm.variable.group.rename.success"), "3000")
}
})
}
$("#ajax_load_tab").hide()
}
$("#ajax_load_tab").hide()
}
})
}
},
removeErrorMsg: function() {
$(".errorFieldP").removeClass("errorFieldP"), $(".errorMsgDesc").remove()
},
cancelgroupName: function() {
$("#cVarGroupItems_chosen").show(), hideAnimatePopup("cVargroupPop")
},
addGroupCustomVariables: function() {
hideAnimatePopup("cVarPop"), $(".cFieldTable tr.topband_dv_row").eq(0).addClass("bgECF7FF"), setTimeout(function() {
$(".cFieldTable tr.topband_dv_row").eq(0).addClass("bgFFF")
}, 2e3)
},
checkUncheck: function(el) {
var curEl = $(el);
curEl.hasClass("customCheckBoxChecked") ? curEl.removeClass("customCheckBoxChecked") : curEl.addClass("customCheckBoxChecked")
},
createCvar: function() {
document.getElementById("cancelsBox1").setAttribute("onclick", "cVar.showPage1()"), $(".cFieldTable").addClass("hide")
},
updategroupId: function(e) {
var dataparam = JSON.parse($("#cFieldsSave").attr("data-params"));
dataparam.groupId = e.value, $("#cFieldsSave").attr("data-params", JSON.stringify(dataparam))
},
getGroupList: function(e1, eid) {
var nR = 0,
gId = "";
if (gId = void 0 == e1 ? eid : e1.value, groupObj = gId, $(".topband_dv_row").each(function() {
var dataparam = $(this).attr("data-params"),
dataJson = JSON.parse(dataparam),
groupId = dataJson.groupId;
if (gId != groupId && 1 != gId)
$(this).hide();
else {
$(this).show();
var editparam = JSON.parse($(this).closest("tr").find("#cvarEdit").attr("data-params"));
editparam.groupId = gId, $(this).closest("tr").find("#cvarEdit").attr("data-params", JSON.stringify(editparam)), nR += 1
}
}), 1 != gId && nR > 0) {
$("#gearIcon").show();
var isgeneral = $(".cVarList option:selected").attr("isgeneral");
1 == isgeneral ? $("#Rename").hide() : $("#Rename").show()
} else
$("#gearIcon").hide()
},
createCVar: function() {
$(".createCustomVariable").removeClass("hide"), $(".editCustomVariable").addClass("hide"), $(".page2 h2").html("Create Custom variable"), cVar.showPage2()
},
editCustomFields: function(el) {
cVar.showCustomFieldPop(), $("#cVarCfieldName").val($.trim($(el).closest("tr").find("td").eq(1).html())), $("#cVarCfieldAPIName").val($.trim($(el).closest("tr").find("td").eq(2).html())), $("#cVarCfieldDesc").val($.trim($(el).closest("tr").find("td").eq(3).html())), $("#cVarCfieldDefVal").val($.trim($(el).closest("tr").find("td").eq(4).html())), $("#cFieldsSave").val("Save")
},
editCustomVariables: function(el) {
showAnimatePopup("cVarPop"), $("#cVarENAME").val($.trim($(el).closest("tr").find("td").eq(1).html())), $("#cVarEAPINAME").val($.trim($(el).closest("tr").find("td").eq(2).html())), $("#cVarEDesc").val($.trim($(el).closest("tr").find("td").eq(3).html())), $("#cVarCfieldDefVal").val($.trim($(el).closest("tr").find("td").eq(4).html())), $(".cVarType").val($.trim($(el).closest("tr").find("td").eq(3).attr("varType"))).attr("disabled", !0), $(".cVarType").change()
},
viewChanges: function(el) {
sE(event), curEl = $(el);
var leftPos = curEl.offset().left,
topPos = curEl.offset().top;
$("#viewCvariablesPOP").removeClass("hide").css({
left: leftPos + curEl.width() - $("#viewCvariablesPOP").outerWidth() + "px",
top: topPos - $("#viewCvariablesPOP").outerHeight() + "px"
})
},
showCustomSettings: function() {
Crm.menu.createMenu(window.event, "groupSetup")
},
searchVariable: function() {
$("#searchVar").on("keyup", function(e) {
var searchString = ($(".searchCustom").val().trim(), $(".searchCustom").val().trim().replace(/^\s+/gi, "")),
keyCode = e.keyCode ? e.keyCode : e.which;
13 == keyCode && $(".searchCustom").val(searchString), cVar.searchVar(searchString.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"))
}).keypress(function(e) {
var keyCode = e.keyCode ? e.keyCode : e.which;
return 13 == keyCode ? (sE(), !1) : void 0
})
},
searchVar: function(value) {
var groupId = $(".cVarList").val();
value = value.toLowerCase();
var nR = 0;
$(".topband_dv_row").each(function() {
var dataparam = $(this).attr("data-params"),
dataJson = JSON.parse(dataparam),
gId = dataJson.groupId;
$row = $(this);
var id = $row.find("td:eq(1)").text(),
id2 = $row.find("td:eq(2)").text(),
id3 = $row.find("td:eq(3)").text();
-1 == id.toLowerCase().search(value) && -1 == id2.toLowerCase().search(value) && -1 == id3.toLowerCase().search(value) || groupId != gId && 1 != groupId ? $(this).hide() : ($(this).show(), nR += 1), 0 >= nR ? $("#noRecordsFound").show() : $("#noRecordsFound").hide()
})
},
updateBulkVariables: function() {
var idArr = Array(),
valObjArr = Array();
if ($("#bulkVarList .tabDivCreate").each(function() {
var varObj = {},
id = void 0 == $(this).find("input").attr("id") ? $(this).find("textarea").attr("id") : $(this).find("input").attr("id");
idArr.push(id), varObj.varId = id;
var elem = $("#" + id),
data = elem.data(),
contentType = data.contenttype,
value = $("#" + id).val().trim();
value = "Boolean" == contentType ? elem.is(":checked") ? "ON" : "OFF" : value;
var timeVal = "";
if (null != $("#" + id + "_TimeOption").val()) {
var meridiem = Utils.getMeridiem($("#" + elem.attr("id") + "_TimeOption").timeEntry("getTime")).toUpperCase();
timeVal = $("#" + id + "_TimeOption").val().split(" ")[0] + " " + meridiem
}
"DateTime" === contentType && "" == value && ($("#" + elem.attr("id") + "_TimeOption").val(""), timeVal = ""), void 0 != timeVal && "" != timeVal && (value = value + " " + timeVal), varObj.value = value, valObjArr.push(varObj)
}), Crm.validateFormFields(idArr)) {
$("#ajax_load_tab").show();
var groupId = $(".cVarList").val(),
grName = $(".cVarList option:selected").text(),
resJson = Object();
resJson.varDetails = valObjArr, resJson.groupId = $(".cVarList").val();
var reqPool = new crmRequestPool;
reqPool.initiate({
action: "/recruit/Variables.do?action=updateBulkVariables",
type: "POST",
data: {
loadProds: 1,
updateVarJson: JSON.stringify(resJson),
crmcsrfparam: encodeURIComponent(csrfToken)
},
dataType: "JSON",
success: function(resJsn) {
hideAnimatePopup("editAllCvar");
var txt = cVar.variableList(JSON.stringify(resJsn));
$("#result").empty(), $("#result")[0].innerHTML = txt, $(".cVarGroup select").next(".select2").remove(), $(".cVarList option[value=" + groupId + "]").attr("selected", "selected"), Utils.bindChosen(".cVarGroup select"), crmui.showMsgBand("success", I18n.getMsg("crm.variable.bulk.update", grName), "3000"), cVar.getGroupList(void 0, groupId), cVar.searchVariable(), $("#ajax_load_tab").hide()
}
})
}
},
bulkEditCancel: function() {
$("#bulkVarList").html("")
},
editGroup: function() {
var id = groupObj,
reqPool = new crmRequestPool,
params = csrfParamName + "=" + encodeURIComponent(csrfToken);
params = params + "&groupId=" + id, reqPool.initiate({
action: "/recruit/Variables.do?action=updateGroup",
type: "GET",
data: params,
success: function(responseJSon) {
gName = void 0 != responseJSon.groupName ? responseJSon.groupName : "", desc = void 0 != responseJSon.gDescription ? responseJSon.gDescription : "", gsysRefname = void 0 != responseJSon.gSysRefname ? responseJSon.gSysRefname : "", groupId = responseJSon.gId;
var jsn = Object();
jsn.groupAction = "crm.variable.editgroup", $("#result").append($(Handlebars.templates.crmVariableGroup(jsn))), $("#cVargroupPop").show(), $("#groupaction").attr("action", "saveGroup"), $("#cVarCgroupName").val(gName), $("#cVarCgroupDesc").val(desc), $("#cVargroupAPIName").val(gsysRefname), $("#cFieldsSave").attr("id_attr", groupId), showAnimatePopup("cVargroupPop"), setFocusClass($("#cVarCgroupName")[0]), setTimeout(function() {
$("#cVarCgroupName").focus()
}, 100), $(".errorFieldP").removeClass("errorFieldP"), $(".errorMsgDesc").remove()
}
})
},
getVarApiName: function(id) {
var varId = $("#saveVar").attr("id_attr"),
apinameValue = $("#cVarAPINAME").val().trim(),
varName = $("#cVarNAME").val().trim(),
groupId = $("#cVarGroupItems").val();
if (("" != varName || "" != apinameValue) && ("cVarNAME" != id || "" == varName || cVar.validateVariable("cVarNAME") ? "cVarAPINAME" != id || "" == varName || cVar.validateVariable("cVarNAME") || "" != apinameValue || "" == apinameValue && (cVar.reqgenApiname(varName, varId, groupId, apinameValue), $("#cVarAPINAME").focus()) : "" == apinameValue && (cVar.reqgenApiname(varName, varId, groupId, apinameValue), $("#cVarAPINAME").focus()), "cVarAPINAME" == id && "" != apinameValue && !cVar.validateVariable("cVarAPINAME")))
if (cVar.validateApiName(apinameValue)) {
var obj = ($("#cVarAPINAME_label").text(), $("#cVarAPINAME")),
elem = $("#" + id),
value = elem.val().trim(),
reg = /[^~`'!@$:,.{}/#%^&*()+=[\]|\;"<>\\]/g,
excldCharsArr = getClrTxtPtnResChars(value, reg),
paramArr = [];
paramArr.push($("#" + id + "_label").text()), paramArr.push(excldCharsArr.join(" ")), Crm.showErrorMsg(I18n.getValueForFields("crm.variable.validationFail.alert.moreThanOneChar", paramArr), obj)
} else
varName = apinameValue, cVar.reqgenApiname(varName, varId, groupId, apinameValue)
},
reqgenApiname: function(varName, id, groupId, apiName) {
if ("" != varName) {
var reqPool = new crmRequestPool,
params = "varName=" + varName,
params = "" != id ? params + "&varId=" + id : params;
params = "" != groupId ? params + "&groupId=" + groupId : params, params = void 0 != apiName ? params + "&apiName=" + apiName : params, reqPool.initiate({
action: "/recruit/Variables.do?action=genApiName",
type: "GET",
data: params,
success: function(responseJSon) {
var duplicate = responseJSon.duplicate;
if ("exist" != duplicate) {
var apiName = responseJSon.varApiName;
return $("#cVarAPINAME").val(apiName), cVar.checkforVarSave(), apiName
}
var apiObj = $("#cVarAPINAME"),
apilabel = $("#cVarAPINAME_label").text();
Crm.showErrorMsg(I18n.getValueForFields("crm.variables.dupicatevariable", apilabel), apiObj)
}
})
}
},
setFocus: function(id) {
$("#" + id).focus(), $("#" + id).closest(".labelValCreate,.tabDiv").addClass("focusEleField")
},
editAllCrmVariables: function() {
var popJson = {};
popJson.groupName = $(".cVarList option:selected").text(), popJson.done = "Done", popJson.cancel = "crm.button.cancel";
var editAllCvar = Handlebars.templates.crmVariablesPopup(popJson);
$("#result").append(editAllCvar);
var gId = (new Array, ""),
groupId = $(".cVarList").val(),
frag = document.createDocumentFragment();
$(".topband_dv_row").each(function(index) {
var dataparam = $(this).attr("data-params"),
dataJson = JSON.parse(dataparam);
if (groupId == dataJson.groupId) {
var labelId = "bulkedit_" + dataJson.variableId;
gId = dataJson.groupId;
var valueLabel = dataJson.variableName,
uiType = dataJson.uiType,
value = dataJson.value,
fieldDiv = "bulkVarEdit" + index,
readOnly = "false",
displaylabel = dataJson.variableName,
res = crmTemplate.createvarFieldRow(cVar.getjsonValueHandlebar(uiType, value, fieldDiv, valueLabel, labelId, readOnly, displaylabel));
$(frag).append(res)
}
}), $("#bulkVarList").append(frag), showAnimatePopup("editAllCvar");
var varId = $('[id^="bulkedit"]').eq(0).attr("id");
$("#" + varId).closest(".labelValCreate,.tabDiv").addClass("focusEleField"), setTimeout(function() {
var fieldType = $("#" + varId).attr("data-fieldtype");
"dateField" != fieldType && $("#" + varId).focus()
}, 300)
},
cancelBulkVar: function() {
hideAnimatePopup("editAllCvar")
},
createValueRow: function() {
var selObj = $("#cVarSelectType"),
uiType = selObj.val(),
fieldDiv = "crmdivVal",
valueLabel = "Value",
labelId = "fieldValue",
readOnly = "false",
displaylabel = I18n.getMsg("crm.label.value"),
resDiv = crmTemplate.createvarFieldRow(cVar.getjsonValueHandlebar(uiType, void 0, fieldDiv, valueLabel, labelId, readOnly, displaylabel));
$("#crmdivVal").replaceWith(resDiv)
},
createNewVariableName: function(value) {
var createJson = Object();
return createJson.displaylabel = I18n.getValueForFields("crm.variables.createvariablename"), createJson.valueLabel = "cVarNAME", createJson.labelId = "cVarNAME", createJson.maxlength = "50", createJson.contentType = "text", createJson.i18fieldType = I18n.getValueForFields("crm.variables.createvariablename"), createJson.blurfn = "cVar.blurVarfn('cVarNAME');cVar.removeErrorDiv(this);", createJson.focusOutfn = "cVar.blurVarfn('cVarNAME');cVar.removeErrorDiv(this);", createJson.readOnly = "false", createJson.mandate = "true", createJson.defaultValue = value, createJson.type = "text", createJson.fieldDiv = "fieldDiv_cVarNAME", createJson
},
createNewvariableApiName: function(value) {
var createJson = Object();
return createJson.displaylabel = I18n.getValueForFields("crm.variables.apiname"), createJson.valueLabel = "cVarAPINAME", createJson.labelId = "cVarAPINAME", createJson.maxlength = "100", createJson.contentType = "text", createJson.i18fieldType = I18n.getValueForFields("crm.variables.apiname"), createJson.blurfn = "cVar.blurVarfn('cVarAPINAME');cVar.removeErrorDiv(this);", createJson.focusOutfn = "cVar.blurVarfn('cVarAPINAME');cVar.removeErrorDiv(this);", createJson.readOnly = "false", createJson.mandate = "true", createJson.defaultValue = value, createJson.type = "text", createJson.style = "display:none", createJson.fieldDiv = "fieldDiv_cVarAPINAME", createJson
},
createNewVarDesc: function(value) {
var createJson = Object();
return createJson.displaylabel = I18n.getValueForFields("crm.variables.createvariabledescription"), createJson.valueLabel = "cVarDesc_label", createJson.labelId = "cVarDesc", createJson.maxlength = "1000", createJson.contentType = "textarea", createJson.i18fieldType = I18n.getValueForFields("crm.variables.createvariabledescription"), createJson.readOnly = "false", createJson.mandate = "false", createJson.defaultValue = value, createJson.type = "textarea", createJson.fieldDiv = "fieldDiv_cVarDesc", createJson
},
createNewDataType: function(value) {
var createJson = Object();
return createJson.displaylabel = I18n.getValueForFields("crm.variables.createvariabletype"), createJson.valueLabel = "cVarSelectType", createJson.labelId = "cVarSelectType", createJson.maxlength = "100", createJson.contentType = "select", createJson.i18fieldType = I18n.getValueForFields("crm.variables.createvariabletype"), createJson.readOnly = "false", createJson.mandate = "true", createJson.defaultValue = value, createJson.type = "select", createJson.fieldDiv = "fieldDiv_cVarSelectType", createJson.onclick = "sE(event)", createJson.onchange = "cVar.createValueRow();cVar.blurVarfn();cVar.removeErrorDiv(this);", createJson.selectDetails = [{
selectValue: "",
selectOption: I18n.getValueForFields("crm.select")
}, {
selectValue: 1,
selectOption: I18n.getValueForFields("crm.field.label.single.line")
}, {
selectValue: 32,
selectOption: I18n.getValueForFields("crm.field.label.integer")
}, {
selectValue: 34,
selectOption: I18n.getValueForFields("crm.field.label.percentage")
}, {
selectValue: 38,
selectOption: I18n.getValueForFields("crm.field.label.decimal")
}, {
selectValue: 36,
selectOption: I18n.getValueForFields("crm.field.label.currency")
}, {
selectValue: 24,
selectOption: I18n.getValueForFields("crm.field.label.date")
}, {
selectValue: 30,
selectOption: I18n.getValueForFields("crm.field.label.date.time")
}, {
selectValue: 25,
selectOption: I18n.getValueForFields("crm.field.label.email")
}, {
selectValue: 33,
selectOption: I18n.getValueForFields("crm.field.label.phone")
}, {
selectValue: 21,
selectOption: I18n.getValueForFields("crm.field.label.url")
}, {
selectValue: 110,
selectOption: I18n.getValueForFields("crm.field.label.text.area")
}, {
selectValue: 301,
selectOption: I18n.getValueForFields("crm.field.label.check.box")
}, {
selectValue: 52,
selectOption: I18n.getValueForFields("crm.field.label.long.integer")
}], createJson
},
createNewGroup: function(responseJSon) {
var createJson = Object();
return createJson.displaylabel = I18n.getValueForFields("crm.variables.createvariablegroup"), createJson.valueLabel = "cVarGroupItems_label", createJson.labelId = "cVarGroupItems", createJson.maxlength = "100", createJson.contentType = "select", createJson.onchange = "cVar.checkforVarSave()", createJson.i18fieldType = I18n.getValueForFields("crm.variables.createvariablegroup"), createJson.readOnly = "false", createJson.mandate = "true", createJson.type = "select", createJson.fieldDiv = "fieldDiv_cVarGroupItems", createJson.selectDetails = responseJSon.groupDetails, createJson
},
createVariableRow: function(responseJSon) {
var creJson = Object();
creJson.editvariable = I18n.getMsg("crm.variables.createcrmvalue"), creJson.save = I18n.getMsg("crm.button.save"), creJson.cancel = I18n.getMsg("crm.button.cancel");
var hj = cVar.createNewVariableName(),
frag = document.createDocumentFragment(),
elem = $(Handlebars.templates.crmFormFields(hj));
$(frag).append(elem), $(frag).append(crmTemplate.createvarFieldRow(cVar.createNewvariableApiName())), $(frag).append(crmTemplate.createvarFieldRow(cVar.createNewVarDesc())), $(frag).append(crmTemplate.createvarFieldRow(cVar.createNewDataType())), $(frag).append();
var elem1 = $(Handlebars.templates.crmCreateVariables(creJson));
$("#result").html(elem1), $("#createeditvar").html(frag), $("#createeditvar").show(), $("#createeditvarvalue").html($(Handlebars.templates.crmFormFields(cVar.createNewGroup(responseJSon)))), $("#createeditvarvalue").show(), cVar.updateChosen()
},
editDataType: function(value) {
var createJson = Object();
return createJson.displaylabel = I18n.getValueForFields("crm.variables.createvariabletype"), createJson.valueLabel = "cVarSelectType_label", createJson.labelId = "cVarSelectType", createJson.maxlength = "100", createJson.contentType = "select", createJson.i18fieldType = I18n.getValueForFields("crm.variables.createvariabletype"), createJson.readOnly = "true", createJson.mandate = "true", createJson.defaultValue = value, createJson.type = "text", createJson.fieldDiv = "fieldDiv_cVarSelectType", createJson.onclick = "sE(event)", createJson.onchange = "cVar.createValueRow();cVar.blurVarfn();cVar.removeErrorDiv(this);", createJson
},
getjsonValueHandlebar: function(uiType, value, fieldDiv, valueLabel, labelId, readOnly, displaylabel) {
value = void 0 == value ? "" : value;
var dataObj = {},
type = "text",
mandate = "false",
fieldTypeMap = {
1: "Text",
32: "Number",
110: "Textarea",
21: "URL",
24: "Date",
30: "DateTime",
25: "Email",
33: "Phone",
34: "Percent",
38: "Decimal",
36: "Currency",
300: "Boolean",
301: "Boolean",
52: "LongInteger"
},
i18NfieldTypeMap = {
1: "crm.field.label.single.line",
32: "crm.field.label.integer",
34: "crm.field.label.percentage",
38: "crm.field.label.decimal",
36: "crm.field.label.currency",
24: "crm.field.label.date",
30: "crm.field.label.date.time",
25: "crm.field.label.email",
33: "crm.field.label.phone",
21: "crm.field.label.url",
110: "crm.field.label.text.area",
301: "crm.field.label.check.box",
52: "crm.field.label.long.integer"
},
maxLenMap = {
1: 255,
32: 9,
34: 250,
38: 16,
35: 16,
33: 30,
25: 255,
21: 255,
110: 3e3,
52: 18,
36: 16
},
decLenMap = {
38: 9,
36: 9
};
if (24 == uiType)
type = "date", dataObj.showexecution = "false", dataObj.datePattern = "mm/dd/yyyy";
else if (30 == uiType) {
if (type = "datetime", dataObj.showexecution = "false", dataObj.datePattern = "mm/dd/yyyy", dataObj.timePattern = "hh:mm a", "" != value && " " != value) {
var dt = " " != value ? new Date(value) : new Date,
pattern = dataObj.datePattern,
defVal = Utils.convertTo12HoursFormatTimeObj(dt);
value = crmCalendar.convertToUserDatePattern(dt.getDate() + " " + dt.getMonth() + " " + dt.getFullYear(), pattern), timeVal = defVal.hrs + ":" + defVal.mins + " " + I18n.getMsg(defVal.meridiem.toUpperCase()), dataObj.timevalue = timeVal
}
} else
300 == uiType || 301 == uiType ? (type = "checkbox", value = "ON" == value ? "true" : "false") : 110 == uiType ? type = "textarea" : 36 == uiType && (type = "currency");
var contentType = fieldTypeMap[uiType];
return dataObj.type = type, dataObj.i18fieldType = I18n.getMsg(i18NfieldTypeMap[uiType]), dataObj.fieldDiv = fieldDiv, dataObj.valueLabel = valueLabel, dataObj.labelId = labelId, dataObj.readOnly = readOnly, dataObj.contentType = contentType, dataObj.defaultValue = value, dataObj.mandate = mandate, dataObj.displaylabel = displaylabel, dataObj.maxlength = maxLenMap[uiType], dataObj.decimalLength = decLenMap[uiType], dataObj.blurfn = "cVar.removeErrorDiv(this);", dataObj
},
removeErrorDiv: function(rem) {
var id = rem.id;
$("#errorMsg_" + id).hide(), $(rem).closest(".errorFieldP").removeClass("errorFieldP")
},
notifyUser: function(notificationType, content, duration) {
var notificationObj = $("#dispMsg");
notificationObj.removeClass().html("");
var iconI = $("<i/>").addClass("fL infoAlertMsgIc formBuildIcons"),
closeIcon = $("<i/>").addClass("closeIcon formBuildIcons fR mT5 mL5 cP").attr("onclick", "$(this).parent().fadeOut()");
"alert" === notificationType ? (notificationObj.attr("class", "crmVarTrans errorAlertMsg proxima fontSmooth f13"), iconI = $("<i/>").addClass("fL errAlertMsgIc phonePage formBuildIcons"), closeIcon = $("<i/>").addClass("closeIconErr formBuildIcons fR mT5 mL5 cP").attr("onclick", "$(this).parent().fadeOut()")) : "success" === notificationType ? (notificationObj.attr("class", "crmVarTrans successAlertMsg proxima fontSmooth f13"), iconI = $("<i/>").addClass("fL successAlertMsgIc phonePage formBuildIcons")) : notificationObj.attr("class", "infoMsgAlert proxima fontSmooth f13");
var totalWidth = $("#result").width(),
dispMsgLeft = totalWidth / 2 + $("#setup_new_leftmenuDiv").innerWidth(),
succAlertTop = $("#setupInnerLinks").innerHeight() + $("#tabLayer").innerHeight(),
relativeTo = 0;
$("#addCustomVariable").length > 0 && (relativeTo = $("#addCustomVariable").width() / 2), void 0 !== duration ? (setTimeout(function() {
notificationObj.html(iconI).append($("<span>").addClass("mL8").html(content)).css({
top: succAlertTop,
"z-index": 10,
position: "absolute",
left: dispMsgLeft - notificationObj.innerWidth() / 2,
display: "inline-block"
}).addClass("zcrm-trans").delay(duration).fadeOut()
}, 700), setTimeout(function() {
notificationObj.removeClass("zcrm-trans")
}, duration + 200)) : notificationObj.html(iconI).append($("<span>").addClass("mL8").html(content)).css({
top: succAlertTop,
"z-index": 10,
position: "absolute",
left: dispMsgLeft - notificationObj.innerWidth() / 2,
display: "inline-block"
}).append(closeIcon).fadeIn()
},
validateVariable: function(id) {
var label = $("#" + id + "_label").text(),
obj = $("#" + id),
check = Utils.isFieldEmpty(obj);
return check && "Variable Type" == label ? Crm.showErrorMsg(I18n.getValueForFields("crm.variable.crmvariabletype.empty", label), obj) : check && "API Name" == label ? Crm.showErrorMsg(I18n.getValueForFields("crm.variable.crmvariableAPIName.empty"), obj) : !check || "Variable Name" != label && "Group Name" != label ? check ? Crm.showErrorMsg(I18n.getValueForFields("crm.field.empty.check", label), obj) : check = cVar.checkforSpecilChar(id) : Crm.showErrorMsg(I18n.getValueForFields("crm.variable.crmvariableVarName.empty", label), obj), check
},
checkforVarSave: function() {
var varName = $("#cVarNAME").val().trim(),
varApiName = $("#cVarAPINAME").val().trim(),
varType = $("#cVarSelectType").val().trim();
"" != varName && "" != varApiName && "" != varType && $("#saveVar").prop("disabled", !1)
},
blurVarfn: function(id) {
cVar.getVarApiName(id), cVar.checkforVarSave()
},
genGroupApiname: function(id) {
$(".errorFieldP").removeClass("errorFieldP"), $(".errorMsgDesc").remove();
var dupGName = $("#cVarCgroupName").attr("duplicate");
if ("false" == dupGName) {
var grpId = $("#cFieldsSave").attr("id_attr");
grpId = void 0 != grpId ? grpId : "";
var grpName = $("#cVarCgroupName").val().trim(),
apinameValue = $("#cVargroupAPIName").val().trim();
"cVarCgroupName" != id || "" == grpName || cVar.validateVariable("cVarCgroupName") || "" == apinameValue && (Crm.showErrorMsg(I18n.getValueForFields("crm.variable.crmvariableAPIName.empty"), "APIName"), cVar.reqGroupApiName(grpName, grpId)), "cVargroupAPIName" != id || "" == grpName || "" != apinameValue || cVar.validateVariable("cVarCgroupName") || "" == apinameValue && cVar.reqGroupApiName(grpName, grpId), "cVargroupAPIName" != id || "" == apinameValue || cVar.validateVariable("cVargroupAPIName") || cVar.reqGroupApiName(apinameValue, grpId)
}
},
reqGroupApiName: function(grpName, grpId) {
var reqPool = new crmRequestPool,
params = "varGrpName=" + grpName;
params = "" != grpId ? params + "&groupId=" + grpId : params, reqPool.initiate({
action: "/recruit/Variables.do?action=gengroupApiName",
type: "GET",
data: params,
success: function(responseJSon) {
var apiName = responseJSon.groupApiName;
return $("#cVargroupAPIName").val(apiName), apiName
}
})
},
deleteVar: function() {
var varId = $("#deleteConfirmBtn").attr("varid");
$("#deleteConfirmBtn").attr("disabled", "true").addClass("disabled");
var groupId = (resJson.groupList, $("#deleteConfirmBtn").attr("groupId")),
vName = $("#deleteConfirmBtn").attr("varName"),
params = csrfParamName + "=" + encodeURIComponent(csrfToken),
reqPool = new crmRequestPool;
reqPool.initiate({
action: "/recruit/Variables.do?action=deleteVariables&varId=" + varId,
type: "POST",
data: params,
success: function(responseHtml) {
responseHtml = JSON.stringify(responseHtml), groupId = -1 != responseHtml.search(groupId) ? groupId : 1;
var txt = cVar.variableList(responseHtml);
$("#result").empty(), $("#result")[0].innerHTML = txt, hideAnimatePopup("cVarDeletePop"), cVar.searchVariable(), vName = " ' " + vName + " ' ";
var msg = I18n.getValueForFields("crm.variable.delete", vName);
$(".cVarGroup select").next(".select2").remove(), Utils.bindChosen(".cVarGroup select"), crmui.showMsgBand("success", msg, "3000")
}
})
},
getactionUrl: function(params) {
return params.action = "variables", params.groupId && (params.action = "createVariable"), params.variableId && (params.action = "updateVar"), params
},
cancelVar: function() {
var grId = $("#saveVar").attr("groupId");
grId = void 0 != grId ? grId : 1;
var reqPool = new crmRequestPool;
reqPool.initiate({
action: "/recruit/Variables.do?action=variables",
type: "POST",
success: function(respHTML) {
var txt = cVar.variableList(respHTML);
if ($("#result").empty(), $("#result")[0].innerHTML = txt, setTimeout(function() {
crmLayout.Resize.Setup()
}, 300), void 0 === $("#cFieldsSave").attr("data-params"))
var dataparam = {};
else
var dataparam = JSON.parse($("#cFieldsSave").attr("data-params"));
dataparam.groupId = grId, $("#cFieldsSave").attr("data-params", JSON.stringify(dataparam)), $(".cVarGroup select").next(".select2").remove(), $(".cVarList option[value=" + grId + "]").attr("selected", "selected"), Utils.bindChosen(".cVarGroup select"), cVar.getGroupList(void 0, grId), cVar.searchVariable()
}
})
},
mb_permanentDeleteCustomField: function(vId, vName, gId) {
cVar.deleteCheck(vId, vName, gId)
},
deleteCheck: function(id, name, grpId) {
var cvstr,
reqPool = new crmRequestPool,
param = "varId=" + id + "&grpId=" + grpId + "&varName=" + name + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken);
$("#ajax_load_tab").show(), reqPool.initiate({
action: "/recruit/Variables.do?action=checkVarDelete",
type: "POST",
data: param,
success: function(respHTML) {
"false" == respHTML ? ($("#deleteConfirmBtn").attr("varId", id), $("#deleteConfirmBtn").attr("groupId", grpId), name = " " + name, $("#deleteConfirmBtn").attr("varName", name), $(".cVarCustomFieldName").html(name), showAnimatePopup("cVarDeletePop")) : (cvstr = respHTML, $("#deleteInfo1").empty(), getElemById("deleteInfo1").innerHTML = I18n.getMsg("crm.variable.delete.before.pop", name), cVar.deleteCRFWarning(id, cvstr, grpId, name)), $("#ajax_load_tab").hide()
}
})
},
deleteCRFWarning: function(id, cvstr) {
freezeBackground();
var isfieldUsedInForecast = !1;
$("#itdiv").empty(), $("#etdiv").empty(), $("#wfTaskdiv").empty(), $("#wfWHdiv").empty(), getElemById("itdiv").innerHTML = "", getElemById("etdiv").innerHTML = "", getElemById("wfTaskdiv").innerHTML = "", getElemById("wfWHdiv").innerHTML = "", getElemById("ithead").style.display = "none", getElemById("ethead").style.display = "none", getElemById("wfTaskhead").style.display = "none", getElemById("wfWHdiv").style.display = "none", getElemById("wfWHhead").style.display = "none";
var cfUsedPlaces = cvstr.split("|*|");
if (cfUsedPlaces.length > 2) {
var cfJsonObj = JSON.parse(cfUsedPlaces[2]);
for (var key in cfJsonObj) {
var values = cfJsonObj[key];
"inventoryRecords" == key ? cVar.showCFoffectedRecords(values, "it", "/recruit/PrintLayout.do?step=edit&templateId=") : "emailTemplateRecords" == key ? cVar.showCFoffectedRecords(values, "et", "/recruit/ShowSetup.do?tab=custom&subTab=email&step=editEmailTemplate&emailTemplateId=") : "workFlowTask" == key ? cVar.showCFoffectedRecords(values, "wfTask", "/recruit/ShowSetup.do?tab=automate&subTab=task&step=showTask&taskId=") : "workFlowWebHookRecords" == key && cVar.showCFoffectedRecords(values, "wfWH", "/recruit/ShowSetup.do?tab=automate&subTab=webhook&step=showWebHook&webHookId=")
}
}
var cvnames = cfUsedPlaces[0],
cvids = cfUsedPlaces[1].split("~~"),
isInaccessibleCVsPresent = (cfUsedPlaces[1], !1);
if (cvnames.indexOf("||**||true") > -1 && (cvnames = cvnames.replace("||**||true", ""), isInaccessibleCVsPresent = !0), cvnames = cvnames.split("~~"), isInaccessibleCVsPresent || cvnames[0].length && !isfieldUsedInForecast) {
var ul = document.createElement("ul");
for (ul.style.marginTop = "0px", i = 0; i < cvnames.length - 1; i++) {
var li = document.createElement("li"),
editCV = document.createElement("a");
editCV.textContent = revertSplChrs(cvnames[i]);
var editurl = "/recruit/EditCV.do?module=" + module + "&cvid=" + cvids[i];
editCV.setAttribute("href", editurl), editCV.setAttribute("target", "_blank"), li.appendChild(editCV), ul.appendChild(li)
}
}
isfieldUsedInForecast || $("#deleteInfo2,#deleteDetails,#deleteInfo1").show(), crmui.showPop("deletefield", !0)
},
showCFoffectedRecords: function(values, elemName, editUrl) {
edUrl = editUrl, getElemById(elemName + "head").style.display = "", getElemById(elemName + "div").style.display = "";
var ul = document.createElement("ul");
for (var id in values) {
var IRDetails = values[id],
li = document.createElement("li");
li.setAttribute("class", "p3");
var editIR = document.createElement("a");
editIR.textContent = IRDetails[0];
var editModName = document.createElement("span");
editModName.textContent = "- " + IRDetails[1], editModName.setAttribute("class", "dIB mL5 color_3 fs");
var editUrl = edUrl + id,
editUrl = edUrl + id;
editIR.setAttribute("href", editUrl), editIR.setAttribute("target", "_blank"), li.appendChild(editIR), li.appendChild(editModName), ul.appendChild(li)
}
getElemById(elemName + "div").appendChild(ul)
},
createVar: function() {
$("#saveVar").prop("disabled", !0), $(".errorFieldP").removeClass("errorFieldP"), $(".errorMsgDesc").remove();
var validation1 = !cVar.validateVariable("cVarNAME"),
validation2 = !cVar.validateVariable("cVarSelectType"),
validation3 = !cVar.validateVariable("cVarGroupItems"),
validation4 = !cVar.validateVariable("cVarAPINAME"),
validation = validation1 && validation2 && validation3 && validation4,
apiName = $("#cVarAPINAME").val().trim(),
elem = $("#fieldValue"),
data = elem.data(),
type = (data.displaylabel, data.contenttype);
if ("DateTime" === type) {
var dateVal = ($("#" + elem.attr("id") + "_TimeOption").val().split(" ")[0], $("#" + elem.attr("id")).val());
"" == dateVal && $("#" + elem.attr("id") + "_TimeOption").val("");
var meridiem = Utils.getMeridiem($("#" + elem.attr("id") + "_TimeOption").timeEntry("getTime")).toUpperCase()
}
var obj = ["cVarNAME", "cVarAPINAME", "fieldValue"];
if (cVar.validateApiName(apiName)) {
var obj = ($("#cVarAPINAME_label").text(), $("#cVarAPINAME")),
elem = $("#cVarAPINAME"),
value = elem.val().trim(),
reg = /[^~`'!@$:,.{}/#%^&*()+=[\]|\;"<>\\]/g,
excldCharsArr = getClrTxtPtnResChars(value, reg);
if (0 == excldCharsArr.length)
Crm.showErrorMsg(I18n.getValueForFields("crm.variable.validationFail.alert.space"), obj);
else {
var paramArr = [];
paramArr.push($("#cVarAPINAME_label").text()), paramArr.push(excldCharsArr.join(" ")), Crm.showErrorMsg(I18n.getValueForFields("crm.variable.validationFail.alert.moreThanOneChar", paramArr), obj)
}
} else if (validation && Crm.validateFormFields(obj)) {
var vName = $("#cVarNAME").val().trim(),
fdObj = $("#fieldValue"),
timeVal = "";
null != $("#fieldValue_TimeOption").val() && (timeVal = $("#fieldValue_TimeOption").val().split(" ")[0] + " " + meridiem);
var varId = $("#saveVar").attr("id_attr"),
action = "saveVariable",
desc = $("#cVarDesc").val().trim(),
uiType = $("#cVarSelectType").val(),
editUiType = $("#cVarSelectType").attr("data-editUiType");
uiType = "" != varId ? editUiType : uiType;
var val = $("#fieldValue").val().trim(),
gId = $("#cVarGroupItems").val(),
groupListId = $("#saveVar").attr("groupId"),
groupName = $("#cVarGroupItems option:selected").text(),
groupDesc = $("#cVarGroupItems option:selected").attr("gdesc"),
groupParam = "",
groupApiName = $("#cVarGroupItems option:selected").attr("gapiname");
30 == uiType && "" != val && (val = val + " " + timeVal), (301 == uiType || 300 == uiType) && (val = fdObj.is(":checked") ? "ON" : "OFF"), 1 == gId && (groupParam = "&groupName=" + groupName + "&groupDesc=" + groupDesc + "&gSysRefName=" + groupApiName), 3 == gId && (groupParam = "&groupName=" + groupName + "&groupDesc=" + groupDesc + "&gSysRefName=" + groupName);
var params = csrfParamName + "=" + encodeURIComponent(csrfToken);
params = params + "&varName=" + encodeURIComponent(vName) + "&varDesc=" + encodeURIComponent(desc) + "&varValue=" + encodeURIComponent(val) + "&groupId=" + gId + "&uiType=" + uiType + "&varId=" + varId + "&sysRefName=" + apiName + groupParam;
var reqPool = new crmRequestPool;
$("#ajax_load_tab").show(), reqPool.initiate({
action: "/recruit/Variables.do?action=" + action + "&step1=save",
type: "POST",
data: params,
success: function(respHTML) {
if ("Limit Exceeded" == respHTML.LIMIT)
crmui.showMsgBand("error", I18n.getValueForFields("crm.variable.limit.exceed.msg"), 7e3);
else {
var responseJson = ZRCommonUtil.convertStringToJson(respHTML),
duplicate = responseJson.duplicate;
if ("error" == respHTML.ERROR)
crmui.showMsgBand("error", I18n.getValueForFields("crm.security.error.add.user"), 7e3);
else if ("exist" == duplicate) {
var dupValue = responseJson.dupValue;
dupValue = dupValue.split(":");
var dubvName = dupValue[0],
apiName = dupValue[1],
obj = $("#cVarNAME"),
label = $("#cVarNAME_label").text(),
apiObj = $("#cVarAPINAME"),
apilabel = $("#cVarAPINAME_label").text();
"APIName" == apiName && Crm.showErrorMsg(I18n.getValueForFields("crm.variables.dupicatevariable", apilabel), apiObj), "VName" == dubvName && Crm.showErrorMsg(I18n.getValueForFields("crm.variables.dupicatevariable", label), obj)
} else {
var responseJson = ZRCommonUtil.convertStringToJson(respHTML);
cVar.crmVariableSetting(respHTML);
var trOffScTop,
variableid = responseJson.variableId,
scrollObj = $("#setup_new_ContentDiv");
trOffScTop = $("#row_" + variableid).offset().top + scrollObj.scrollTop() - 210, scrollObj.animate({
scrollTop: trOffScTop
}), $("#row_" + variableid).addClass("trialyellowbox"), $("#row_" + variableid).find("td:first").css({
"border-left": "1px solid red"
}), setTimeout(function() {
$("#row_" + variableid).addClass("tdout"), $("#row_" + variableid).find("td:first").css({
"border-left": ""
}), variableid = void 0
}, 5e3);
var msg = "" != varId ? I18n.getValueForFields("crm.variables.updatemsg", vName) : I18n.getValueForFields("crm.variables.suceessmsg", vName);
$(".cVarList option[value=" + groupListId + "]").attr("selected", "selected"), Utils.bindChosen(".cVarList"), cVar.getGroupList(void 0, groupListId), crmui.showMsgBand("success", msg, "3000")
}
}
$("#ajax_load_tab").hide()
}
})
} else
$("#saveVar").prop("disabled", !1)
},
show: function(el) {
var curEl = $(el);
tarretEl = curEl.find(".filterListCtn")
},
hide: function(el, cName) {
var curEl = $(el);
tarretEl = curEl.find(".filterListCtn"), tarretEl.addClass(cName)
},
showusers: function(el) {
$(el).closest("li").nextAll("li").removeClass("hide")
}
};
$(function() {
cVar.jquerySection(), cVar.searchVariable()
});
var msApps = {
userList: "",
approvalList: "",
contactFieldIdVsLabel: {},
jsonObj: {},
preMapping: {
Email1: "Email",
Email2: "Secondary Email",
Email3: "Email3",
"Business Street": "Mailing Street",
"Business City": "Mailing City",
"Business State": "Mailing State",
"Business ZIP": "Mailing Zip",
"Business Country": "Mailing Country",
"Home Street": "Other Street",
"Home City": "Other City",
"Home State": "Other State",
"Home ZIP": "Other Zip",
"Home Country": "Other Country",
"Instant message": "Skype ID",
"First Name": "First Name",
"Last Name": "Last Name",
"Middle Name": "Middle Name",
Title: "Title",
Suffix: "Suffix",
"Yomi First Name": "Yomi First Name",
"Yomi Last Name": "Yomi Last Name",
"Nick Name": "Nick Name",
"Significant Other": "Significant Other",
"Birth day": "Date of Birth",
"Business Phone": "Phone",
"Home Phone": "Home Phone",
Mobile: "Mobile",
"Job Title": "Job Title",
Department: "Department",
Company: "Account Name",
Office: "Office",
Manager: "Manager",
Assistant: "Assistant",
"Yomi Company": "Yomi Company"
},
fieldTypes: ["Email", "Name", "Phone", "IM", "Notes", "String", "Date"],
msCallBackfn: function() {
var jsonobject = arguments[0];
jsonObj = jsonobject, $("#overlayHeader").hide(), $("#settingInner").hide(), $("#setupshow").show(), $("#mainResult").show(), msApps.contacts_configuration = jsonobject.configuration, msApps.isSSOUser = jsonobject.isSSOUser;
var template = Handlebars.getTemplate("microsoft", "MScalendar"),
fillHtml = template(jsonobject);
$("#result").html(fillHtml), msApps.contactsUrl = jsonobject.contactsUrl, msApps.delete_in_crm = jsonobject.configuration.delete_in_crm, msApps.active = jsonobject.configuration.active
},
warningAlert: function(alert) {
showAnimatePopup(alert)
},
contactFieldMapper: function() {
msApps.getCRMContactFields().then(function(msContFieldVsNameMap) {
msContFieldVsNameMap.isSSOUser = msApps.isSSOUser, msApps.openFieldMapper(msApps.getContactSyncData(msContFieldVsNameMap))
})
},
openFieldMapper: function(data, isEditCall) {
data.fieldTypes = msApps.fieldTypes;
for (var sectionArr = msApps.contacts_configuration.microsoft_sections, tp_fields = {}, sectionArrLen = sectionArr.length, i = 0; sectionArrLen > i; i++) {
var indArr = [],
sectionObj = sectionArr[i],
sectionName = sectionObj.name,
dataType = "";
dataType = "Name" == sectionName || "Address" == sectionName || "Work" == sectionName || "Other" == sectionName ? "String" : sectionName;
for (var fieldArr = sectionObj.fields, fieldArrLen = fieldArr.length, j = 0; fieldArrLen > j; j++) {
var fieldObj = fieldArr[j],
indObj = {};
indObj.fieldName = I18n.getMsg(msApps.preMapping[fieldObj.field_label]), indObj.fieldLabel = fieldObj.field_label, "Birth day" == fieldObj.field_label && (dataType = "Date"), indObj.dataType = dataType, indArr.push(indObj)
}
tp_fields[sectionName] = indArr
}
data.Contacts.tp_field = tp_fields, data.isSSOUser = msApps.isSSOUser;
var template = Handlebars.getTemplate("microsoft", "ContactFieldMapper"),
fillHtml = template(data);
$("#fieldMap_contact").html(fillHtml), msApps.mapField(data, isEditCall), msApps.applystyleForFieldMapper("fieldMap_contact"), isEditCall || $("#fieldmapoptions [id^=crmfield_]").selectBox(), Utils.showHideLoadingDiv(!1)
},
cancelDiv: function(id) {
hideAnimatePopup(id), $("body").removeClass("oH")
},
mapField: function(jobj, isEditCall) {
var msField = jobj.Contacts.tp_field;
if (!isEditCall) {
var legendElemShown = !1,
legendElem = $("#ms_legend_privacy");
$.each(msField, function(index, item) {
$.each(item, function(i, jarr) {
var selectElem = $("#crmfield_" + jarr.fieldLabel.replace(new RegExp(" ", "g"), "_"));
if (selectElem.length) {
selectElem.val(jarr.fieldName);
var selectData = selectElem.find(":selected").data(),
isRestrictedField = selectData ? selectData.restrictedField : !1,
isPrivateField = selectData ? selectData.privateField : !1;
isRestrictedField ? (legendElemShown || (legendElemShown = !0, legendElem.show()), msApps.showHidePIField("restricted", selectElem)) : isPrivateField && msApps.showHidePIField("private", selectElem)
}
})
})
}
setTimeout(function() {
$(".fieldmapper").select2({
placeholder: I18n.getMsg("None"),
allowClear: !1,
matcher: function(params, data) {
return msApps.findMatcher(params, data)
},
templateResult: msApps.formatSelect2,
templateSelection: msApps.formatSelect2,
escapeMarkup: function(m) {
return m
}
})
}, 1)
},
findMatcher: function(param, item) {
var originalOption = item.element;
if (void 0 != param.term) {
var originalOptionEle = $(originalOption),
mail = originalOptionEle.data("fieldname"),
fn = originalOptionEle.data("fieldlabel");
if (originalOptionEle.data("optgroup")) {
var original_matcher = $.fn.select2.defaults.defaults.matcher,
result = original_matcher(param, item),
itemChildren = item ? item.children : null,
resultChildren = result ? result.children : null;
return result && itemChildren && resultChildren && itemChildren.length != resultChildren.length && (result[children] = itemChildren), result
}
return void 0 == mail || void 0 == param.term || void 0 == fn || 0 != mail.toUpperCase().indexOf(param.term.toUpperCase()) && 0 != fn.toUpperCase().indexOf(param.term.toUpperCase()) ? null : item
}
return item
},
applystyleForFieldMapper: function(elemId) {
var emeId = $("#" + elemId),
scrollEle = emeId.find(".popup-model-content");
if (scrollEle[0]) {
var totalScroll = scrollEle.scrollTop() + scrollEle.outerHeight(),
scrollHeight = scrollEle[0].scrollHeight;
scrollHeight > totalScroll && emeId.find(".popup-model-footer").addClass("scroll-sh"), scrollEle.on("scroll", function() {
var emeId = $("#" + elemId),
scrollEle = emeId.find(".popup-model-content");
scrollEle.scrollTop() + scrollEle.innerHeight() >= scrollEle[0].scrollHeight ? emeId.find(".popup-model-footer").removeClass("scroll-sh") : emeId.find(".popup-model-footer").addClass("scroll-sh")
})
}
$("body").addClass("oH"), emeId.show().addClass("zcrm-show"), showFreezeLayer()
},
getCRMContactFields: function() {
return new Promise(function(resolve) {
if (msApps.crmContactFields)
return void resolve(msApps.crmContactFields);
var url = "/recruit/v2/settings/fields?module=Contacts";
Utils.showHideLoadingDiv(), (new crmRequestPool).initiate({
type: "GET",
action: url,
headers: {
"X-ZCSRF-TOKEN": csrfParamName + "=" + csrfToken
},
success: function(data) {
if (data.fields) {
var crmFields = data.fields,
msContFieldVsNameMap = {};
for (var i in crmFields) {
var fieldObj = crmFields[i],
ui_type = fieldObj.ui_type,
indObj = {},
fldLabl = fieldObj.field_label;
if (indObj.fieldLabel = fldLabl, indObj.fieldName = fldLabl, indObj.fieldId = fieldObj.id, msApps.contactFieldIdVsLabel[fieldObj.id] = fldLabl, 0 == fieldObj.read_only && 1 == fieldObj.visible)
switch (ui_type) {
case 1:
case 25:
case 2:
case 4:
"email" == fieldObj.data_type ? msApps.populateCrmFieldMap(indObj, "Email", msContFieldVsNameMap) : msApps.populateCrmFieldMap(indObj, "String", msContFieldVsNameMap);
break;
case 24:
msApps.populateCrmFieldMap(indObj, "Date", msContFieldVsNameMap);
break;
case 37:
msApps.populateCrmFieldMap(indObj, "IM", msContFieldVsNameMap);
break;
case 3:
msApps.populateCrmFieldMap(indObj, "Notes", msContFieldVsNameMap);
break;
case 33:
msApps.populateCrmFieldMap(indObj, "Phone", msContFieldVsNameMap);
break;
case 27:
case 127:
msApps.populateCrmFieldMap(indObj, "String", msContFieldVsNameMap)
}
}
msApps.crmContactFields = msContFieldVsNameMap, msApps.contactsUrl, resolve(msContFieldVsNameMap)
}
},
error: function() {
Utils.showHideLoadingDiv(!1)
}
})
})
},
populateCrmFieldMap: function(indObj, dataType, populateMap) {
indObj.dataType = dataType, populateMap[dataType] ? populateMap[dataType].push(indObj) : populateMap[dataType] = [indObj]
},
getContactSyncData: function(msContFieldVsNameMap) {
var syncConfig = msApps.contacts_configuration,
paramData = {},
fieldMapData = {};
return fieldMapData.crm_field = msContFieldVsNameMap, fieldMapData.tp_field = msApps.tp_fields, fieldMapData.is_consent_enabled = !1, fieldMapData.restricted_field = {}, paramData.Contacts = fieldMapData, void 0 != syncConfig && (fieldMapData.delete_in_crm = syncConfig.delete_in_crm ? !0 : !1, paramData.active = syncConfig.active), paramData.isSSOUser = msContFieldVsNameMap.isSSOUser, paramData
},
deactivate: function(product) {
var params = csrfParamName + "=" + encodeURIComponent(csrfToken),
url = "/recruit/MSApps.do?mode=" + product + "&action=delete";
Utils.showHideLoadingDiv(!0), $.ajax({
type: "POST",
url: url,
data: params,
success: function(data) {
var jsonobject = data;
jsonObj = jsonobject, msApps.contacts_configuration.active = "false", $("#result").html(Handlebars.templates.MScalendar(jsonobject)), Utils.showHideLoadingDiv(!1), hideAnimatePopup("msAlertDiv")
}
})
},
popupRequestUserDetails: function() {
var params = "",
exceptZuid = $("#reqZUID") && "" != $("#reqZUID").val() && "null" != $("#reqZUID").val() ? "&reqZUID=" + $("#reqZUID").val() : "",
url = "/recruit/MSApps.do?mode=USERS&action=getReqUser" + exceptZuid;
Utils.showHideLoadingDiv(!0), $.ajax({
type: "POST",
url: url,
data: params,
success: function(data) {
Utils.showHideLoadingDiv(!1);
var jsonobject = $.parseJSON(data);
msApps.approvalList = jsonobject, msApps.openApproveUserPopup()
}
})
},
openApproveUserPopup: function() {
var url = "/recruit/Security.do?actionName=newUser&mode=create&showAddUser=",
params = "";
return $.ajax({
type: "POST",
url: url,
data: params,
success: function(res) {
$("#topBandPopup").html(res), showAnimatePopup("topBandPopup"), $("#fromTP").show();
var optionVal = "<option></option>";
$("#tpUsers").append(optionVal), $(msApps.approvalList).each(function(index, element) {
var key = element.id,
optionVal = (element.displayName, "<option data-fullname='" + element.displayName + "' data-fn='" + element.givenName + "' data-ln='" + element.surname + "' data-tpemail='" + element.tpEmail + "' data-email='" + element.mail + "' value='" + key + "' selected>" + element.displayName + "</option>");
$("#tpUsers").append(optionVal)
}), $("#tpUsers").select2({
placeholder: I18n.getMsg("crm.lar.rr.chooseUser"),
allowClear: !1,
templateResult: tpuserName,
templateSelection: tpuserName,
escapeMarkup: function(m) {
return m
}
}), $("#fromTP").hide(), $("#fN").hide(), $("#lN").hide(), $("#fullName").show(), $("#approveBTN").show(), $("#addUserBTN").hide(), $("#eM").hide(), $("#tpEmail").show(), $("#Name").attr("disabled", "disabled"), $("#j_username").attr("disabled", "disabled"), $("#tp_username") && $("#tp_username").attr("disabled", "disabled")
}
}), !1
},
openAdduserDiv: function() {
if ("" == msApps.userList) {
var params = "",
exceptZuid = $("#reqZUID") && "" != $("#reqZUID").val() && "null" != $("#reqZUID").val() ? "&reqZUID=" + $("#reqZUID").val() : "",
url = "/recruit/MSApps.do?mode=USERS&action=getUser" + exceptZuid;
Utils.showHideLoadingDiv(!0), $.ajax({
type: "GET",
url: url,
data: params,
success: function(data) {
Utils.showHideLoadingDiv(!1);
var jsonobject = $.parseJSON(data);
if (void 0 == jsonobject.value && "Unauthorized" == jsonobject.recruitMessage) {
var title = I18n.getMsg("zr.sso.authentication.error.title"),
content = I18n.getMsg("zr.sso.authentication.error.content"),
savebtn = I18n.getMsg("zr.sso.authentication.error.reauthenticate");
ZRCommonUtil.openConfirmationAlert({
isNew: !0,
messageType: "info",
savebtn: savebtn,
content: content,
title: title
}, function() {
window.location.href = jsonobject.redirectionURL
})
} else if ("SUCCESS" == jsonobject.recruitMessage)
msApps.userList = jsonobject.value, msApps.approvalList = jsonobject.approval, showCustomizePopup("addMSUser", "", msApps.userList);
else {
var params = {
removefreeze: !1,
type: "failure",
scroll: !1,
baseid: "error-alert-message",
msg: I18n.getMsg("game.common.error"),
display: "inline",
displayId: "uniquieId"
};
ZRComponent.openAlertMessage(params)
}
}
})
} else
showCustomizePopup("addMSUser", "", msApps.userList)
},
updateUsers: function(id) {
$(msApps.userList).each(function(index, element) {
if (id === element.id) {
var firstName = null != element.surname && void 0 != element.surname ? element.displayName.replace(element.surname, "") : element.displayName;
$("#firstName").val(firstName), $("#lastName_focus").val(element.surname), $("#j_username").val(element.mail)
}
})
},
approveUser: function(valFunctionInfo, formObj) {
var functionName = "",
isValidated = !0;
if (valFunctionInfo && valFunctionInfo.length) {
functionName = valFunctionInfo[0];
var fArgs = valFunctionInfo.slice(1);
isValidated = window[functionName].apply(window, fArgs)
}
if (isValidated) {
$("#j_approve").attr("disabled", "disabled").val(I18n.getMsg("crm.signup.wait") + "..."), hideAnimatePopup("topBandPopup"), Utils.showHideLoadingDiv(!0);
var LINK = msApps.approvalList.LINK,
postData = formData2QueryString(formObj),
isAsynchronous = !1;
$.ajax({
type: "POST",
url: LINK,
data: postData,
async: void 0 != isAsynchronous ? isAsynchronous : !0,
success: function() {
window.location.href = "/recruit/ShowSetup.do?tab=usersPermi&subTab=users&show=approved&approvedZUID=" + $("#reqZUID").val()
},
error: function(http) {
http.status === crmConstants.limitExceedsCode && Search.displayLookupExceedsMsg(http), Utils.showHideLoadingDiv()
}
})
}
},
validateApproveUser: function() {
$("#j_approve").attr("disabled", "disabled");
var orgObj = getObj("orgName");
return orgObj && "" == orgObj.value ? ($(getObj("userErrorMsgDisp")).empty(), getObj("userErrorMsgDisp").innerHTML = document.getElementById("compnamealert").value, getObj("userErrorMsgDisp").style.display = "block", $("#j_approve").removeAttr("disabled"), !1) : (getElemById("terIds") && setTerritoryValue(), msApps.approveUser(["newUserForm"], document.addUserForm, "", "", "", !1), void $("#j_approve").removeAttr("disabled"))
},
removeAddeduserFromUserList: function(userEmail) {
$(msApps.userList).each(function(index, element) {
userEmail === element.mail && msApps.userList.splice(index, 1)
})
},
enableContactSync: function(product, isSSOUser, fieldUpdate) {
var isvalidmapping = msApps.validateFieldMapper();
if (isvalidmapping) {
var tobedelete = $("#tobeDeleted").prop("checked") ? !0 : !1,
fieldMapper = [];
$(".msContactFldSelect1").map(function() {
var currElem = $(this),
id = currElem.attr("id"),
idcounter = msApps.splitbyFirstOccurence(id),
crmdataVal = $("#" + id).find(":selected").data("fieldid");
crmdataVal = void 0 != crmdataVal ? crmdataVal : "";
var msdataVal = $("#msField_" + idcounter).find(":selected").data("fieldlabel"),
field = {
microsoft_field: msdataVal,
crm_field: crmdataVal
};
fieldMapper.push(field)
}).get();
var params = {},
Contacts = [],
contactObj = {},
configuration = {};
configuration.mapped_fields = fieldMapper, configuration.delete_in_crm = tobedelete, contactObj.configuration = configuration, Contacts.push(contactObj), params.Contacts = Contacts, msApps.contacts_configuration && (msApps.contacts_configuration.mapped_fields = fieldMapper, msApps.contacts_configuration.delete_in_crm = tobedelete), void 0 != fieldUpdate && "true" == fieldUpdate ? (params.fieldsUpdate = "true", msApps.connectService(product, JSON.stringify(params), "msApps.saveContactsCallbackfn", "POST", "Contacts")) : isSSOUser ? msApps.enableContactSyncFromMS() : openPopUp("Microsoft", this, msApps.contactsUrl, "Microsoft", 600, 500, "menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes")
}
},
enableContactSyncFromMS: function() {
var params = {},
Contacts = [],
contactObj = {},
configuration = {};
configuration.mapped_fields = msApps.contacts_configuration.mapped_fields, configuration.delete_in_crm = msApps.contacts_configuration.delete_in_crm, contactObj.configuration = configuration, Contacts.push(contactObj), params.Contacts = Contacts, msApps.connectService("Contacts", JSON.stringify(params), "msApps.saveContactsCallbackfn", "POST", "Contacts")
},
editContactSync: function() {
var configuration = msApps.contacts_configuration;
configuration.active = "true", msApps.getCRMContactFields().then(function(msContFieldVsNameMap) {
msApps.openFieldMapper(msApps.getContactSyncData(msContFieldVsNameMap), !0);
var savedField = configuration.mapped_fields,
legendElem = $("#ms_legend_privacy");
$.each(savedField, function(i, item) {
var msFiledLabel = item.microsoft_field,
crmFiledName = item.crm_field;
msApps.contactFieldIdVsLabel && msApps.contactFieldIdVsLabel[crmFiledName] && (crmFiledName = msApps.contactFieldIdVsLabel[crmFiledName]);
var selectElem = $("#crmfield_" + msFiledLabel.replace(new RegExp(" ", "g"), "_"));
selectElem.val(crmFiledName).change();
var selectData = selectElem.find(":selected").data(),
isPrivateField = selectData ? selectData.isRestrictedField : !1,
isRestrictedField = selectData ? selectData.restrictedField : !1;
if (isPrivateField) {
var imgElem = selectElem.closest("td").find('[name="gdpr_privateField"]');
isRestrictedField && (imgElem.addClass("MSRestrictedRow").removeClass("MSprivateFieldRow"), legendElem.show()), imgElem.show()
}
}), $("#fieldmapoptions [id^=crmfield_]").selectBox()
})
},
validateFieldMapper: function() {
var isValid = !0,
frstNameElem = $("#crmfield_First_Name"),
msFirstNameMappedField = frstNameElem.val();
if ("None" == msFirstNameMappedField)
return frstNameElem.focus(), Utils.showCustomAlert(I18n.getMsg("crm.office365.mandatory.alert", "First Name")), !1;
var dataTypeValidation = msApps.validateDataType();
if (!dataTypeValidation)
return !1;
var values = $(".msContactFldSelect1").map(function() {
var objElem = $(this),
selectElem = objElem,
selectVal = selectElem.val();
return "None" == selectVal ? "" : selectVal
}).get();
return $(values).each(function(index, value) {
var existAlready = parseInt($.inArray(value, values));
existAlready != index && "" !== value && (isValid = !1, Utils.showCustomAlert(I18n.getMsg("crm.gapps.contactsync.showform.alert.samemappingvalue", [value, Crm.brandName + " Recruit"])))
}), isValid
},
validateDataType: function() {
var isValid = !0;
return $(".msContactFldSelect1").map(function() {
var objELem = $(this),
id = objELem.attr("id"),
idcounter = msApps.splitbyFirstOccurence(id),
selectedIdElem = $("#" + id).find(":selected"),
selectedfldElem = $("#msField_" + idcounter).find(":selected"),
crmdataType = selectedIdElem.data("datatype"),
msdataType = selectedfldElem.data("datatype");
if (void 0 != crmdataType && "" != crmdataType && crmdataType != msdataType) {
var crmdataVal = selectedIdElem.data("fieldlabel"),
msdataVal = selectedfldElem.data("fieldlabel");
$("#crmfield_" + idcounter).focus(), Utils.showCustomAlert(crmdataVal + " and " + msdataVal + " data type is mismatched"), isValid = !1
}
}).get(), isValid
},
splitbyFirstOccurence: function(str) {
var retStr = null;
return void 0 !== str && (retStr = str.split(/_(.+)/)[1]), retStr
},
changeCrmField: function(obj) {
var selectElem = $(obj),
selectdata = selectElem.find(":selected").data(),
isPrivateField = selectdata ? selectdata.privateField : !1,
isRestrictedField = selectdata ? selectdata.restrictedField : !1,
imgElem = selectElem.closest("td").find('[name="gdpr_privateField"]');
isPrivateField ? (isRestrictedField && (imgElem.addClass("MSRestrictedRow").removeClass("MSprivateFieldRow"), $("#ms_legend_privacy").show()), imgElem.show()) : (imgElem.addClass("MSprivateFieldRow").removeClass("MSRestrictedRow"), imgElem.hide())
},
manageConfig: function(show) {
jsonObj.MSAuth = show;
var template = Handlebars.getTemplate("microsoft", "MScalendar"),
fillHtml = template(jsonObj);
$("#result").html(fillHtml)
},
connectService: function(module, params, callBackfn, httpMethod, targetId) {
var httMthd = void 0 === httpMethod ? "POST" : httpMethod,
url = "",
paramsJSON = JSON.parse(params);
url = "/recruit/MSApps.do?mode=" + module.toUpperCase() + "&action=createContact", void 0 != paramsJSON.fieldsUpdate && "true" == paramsJSON.fieldsUpdate && (url = "/recruit/MSApps.do?mode=" + module.toUpperCase() + "&action=fieldsUpdate");
var headers = {
"X-ZCSRF-TOKEN": csrfParamName + "=" + csrfToken,
new_ms_api: "true"
};
Utils.showHideLoadingDiv(!0);
var reqPool = new crmRequestPool;
reqPool.initiate({
type: httMthd,
action: url,
data: params,
contentType: "application/json",
dataType: "json",
headers: headers,
success: function(data) {
if (Utils.showHideLoadingDiv(!1), void 0 !== targetId)
if ("Calendars" === targetId)
data && data.Calendars && data.Calendars[0] && (data = data.Calendars[0], data.code && "SUCCESS" == data.code && (data = data.details, data.active = !1), msApps.calSyncId = data.id), $("#" + targetId).html(Handlebars.templates.MScalendar(data));
else if ("Contacts" === targetId) {
if (data && data.Contacts && data.Contacts[0]) {
if (data = data.Contacts[0], data.configuration && data.configuration.microsoft_sections) {
msApps.contacts_configuration = data.configuration, msApps.contacts_configuration.active = data.active;
for (var sectionArr = data.configuration.microsoft_sections, tp_fields = {}, sectionArrLen = sectionArr.length, i = 0; sectionArrLen > i; i++) {
var indArr = [],
sectionObj = sectionArr[i],
sectionName = sectionObj.name,
dataType = "";
dataType = "Name" == sectionName || "Address" == sectionName || "Work" == sectionName || "Other" == sectionName ? "String" : sectionName;
for (var fieldArr = sectionObj.fields, fieldArrLen = fieldArr.length, j = 0; fieldArrLen > j; j++) {
var fieldObj = fieldArr[j],
indObj = {};
indObj.fieldName = I18n.getMsg(msApps.preMapping[fieldObj.field_label]), indObj.fieldLabel = fieldObj.field_label, "Birth day" == fieldObj.field_label && (dataType = "Date"), indObj.dataType = dataType, indArr.push(indObj)
}
tp_fields[sectionName] = indArr
}
msApps.tp_fields = tp_fields
}
data.code && "SUCCESS" == data.code && (data = data.details, data.active = !1), msApps.contSyncId = data.id
}
var template = Handlebars.getTemplate("microsoft", "MScalendar"),
fillHtml = template(data);
hideFreezeLayer(), $("#result").html(fillHtml)
} else
"Tasks" === targetId && (data = data.Tasks, void 0 != data.details && "" != data.details && (data = data.details), $("#" + targetId).html(Handlebars.templates.MStask(data)))
},
error: function() {
Utils.showHideLoadingDiv(!1), hideAnimatePopup("fieldMap_contact")
}
})
},
accessSignin: function(isSSOUser) {
isSSOUser ? callGAppsURL("/recruit/MSApps.do?mode=CALENDARS&action=create") : openPopUp("Microsoft", this, jsonObj.calendarsUrl, "Microsoft", 600, 500, "menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes")
}
},
CFSchedulerJSObject = new function() {};
CFSchedulerJSObject.TableLastSortedColumn = -1, CFSchedulerJSObject.monthNames = [I18n.getMsg("January"), I18n.getMsg("February"), I18n.getMsg("March"), I18n.getMsg("April"), I18n.getMsg("May"), I18n.getMsg("June"), I18n.getMsg("July"), I18n.getMsg("August"), I18n.getMsg("September"), I18n.getMsg("October"), I18n.getMsg("November"), I18n.getMsg("December")], CFSchedulerJSObject.cfsGlobalTimeout = null, CFSchedulerJSObject.schFilter = function(e) {
null != CFSchedulerJSObject.cfsGlobalTimeout && clearTimeout(CFSchedulerJSObject.cfsGlobalTimeout), CFSchedulerJSObject.cfsGlobalTimeout = setTimeout(function() {
if (CFSchedulerJSObject.cfsGlobalTimeout = null, $("#PublicEmailTemplates").hide(), $("#schedules_CF_tab").show(), 27 == e.keyCode)
$("#kwd_search").val("").trigger("keyup");
else {
var Ji = $("#kwd_search"),
Jrows = $("#table-1 tbody > tr"),
term = $.trim(Ji.val().toLowerCase());
if (0 === term.length)
return void Jrows.show();
Jrows.hide().filter(function() {
return this.cells[1].textContent.toLowerCase().indexOf(term.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1")) > -1
}).show(), 0 == $(".contentRows:visible").length && ($("#PublicEmailTemplates").fadeIn(150), $("#schedules_CF_tab").hide())
}
}, 50)
}, CFSchedulerJSObject.failcustom = function(obj) {
"custom" == $(obj).val() ? $("#failcustomDiv").show().find("input:text").val("") : ($("#failcustomDiv").hide(), $("#ErrMsg").show())
}, CFSchedulerJSObject.updateCheckBox = function() {
$("#myswitchBar").attr("checked", !$("#myswitchBar").attr("checked"))
}, CFSchedulerJSObject.showNewCalen = function(inputName, dateval, isFldUpd, uiType, fromCriteria) {
if ("createDate" == uiType) {
var d = new Date,
dateForCalStart = d.getMonth() + 1 + "," + d.getDate() + "," + d.getFullYear();
d.setDate(d.getDate() + 90);
var dateForCalEnd = d.getMonth() + 1 + "," + d.getDate() + "," + d.getFullYear()
} else if ("startDate" == uiType) {
var d = new Date;
d.setDate(d.getDate() - 90);
var dateForCalStart = d.getMonth() + 1 + "," + d.getDate() + "," + d.getFullYear();
d = new Date;
var dateForCalEnd = d.getMonth() + 1 + "," + d.getDate() + "," + d.getFullYear()
} else if ("endDate" == uiType) {
var cusDateFrom = $("#cusDateFrom").val(),
schDateObj = crmCalendar.getDateObjectFromGivenDateString(cusDateFrom),
myDate = Utils.convertUsrtoDefaultDatePattern(schDateObj);
if (cusDateFrom = $.datepicker.formatDate("mm/dd/yy", myDate), cusDateFrom.length < 1)
return $("#cusDateFrom").focus(), void crmui.showMsgBand("error", I18n.getMsg("crm.cfs.alert.history.date"), 4e3, "");
var d = new Date(Date.parse(cusDateFrom)),
dateForCalStart = d.getMonth() + 1 + "," + d.getDate() + "," + d.getFullYear();
d = new Date;
var dateForCalEnd = d.getMonth() + 1 + "," + d.getDate() + "," + d.getFullYear()
}
if (crmCalendar.showCalendar(fromCriteria, void 0, void 0, isFldUpd, void 0, void 0, dateForCalStart, dateForCalEnd), "createDate" == uiType && "" != $("#schDate").val()) {
var dtObj1 = new Date(crmCalendar.getDateObjectFromGivenDateString($("#schDate").val()));
if (null != dtObj1.getMonth() && void 0 != dtObj1.getMonth() && "" != dtObj1.getMonth())
var month1 = crmCalendar.monthName[dtObj1.getMonth()].html;
$("#year_month_specify").text(I18n.getMsg("crm.recurring.custom.yearly.repeat.on", I18n.getMsg([month1])))
}
return !1
}, CFSchedulerJSObject.trigSch = function(schID) {
var elem = $("#last_" + schID),
tempVal = elem.text();
elem.text(I18n.getMsg("crm.cfs.Triggered"));
var requestPool = new crmRequestPool,
url = "/recruit/CFSchedulers.do",
params = "action=triggerSch&schID=" + schID + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken);
requestPool.doAjax(url, function(response) {
if (null !== response && "" !== response) {
var jsonRes = $.parseJSON(response);
"0" != jsonRes.status ? (elem.text(jsonRes.execTime), "s" === jsonRes.status ? crmui.showMsgBand("success", I18n.getMsg("crm.cfs.alert.job.sucess"), 4e3, "") : "f" === jsonRes.status && crmui.showMsgBand("error", I18n.getMsg("crm.cfs.alert.job.fail"), 4e3, ""), elem.attr("onmouseover", "crmui.toolTip_show(this, 'left', '" + jsonRes.execTimeFF + "');"), elem.attr("onmouseout", "crmui.toolTip_hide();")) : (elem.text(tempVal), "blocked" == jsonRes.trigVal ? crmui.showMsgBand("error", I18n.getMsg("crm.cfs.alert.nomanual"), 4e3, "") : crmui.showMsgBand("error", I18n.getMsg("crm.cfs.msg.inacsch"), 4e3, ""))
}
}, params)
}, CFSchedulerJSObject.viewHist = function() {
Utils.showHideLoadingDiv(!0);
var url = "/recruit/CFSchedulers.do",
params = "action=viewHist",
histParam = {
action: "viewHist"
};
(new crmRequestPool).initiate({
action: url,
type: "GET",
data: histParam,
success: function(response) {
$("#result").html(response), Utils.showHideLoadingDiv(), $("#op2").addClass("sel"), $("#op1").removeClass("sel"), $("#schedules_CF_tab,#kwd_search_div,#btnNewScheduler").hide(), $("#schedules_fail_tab,#ErrMsg").show(), $("#table-2-head,#failTabNoRecord").removeClass("hide"), $("#schedules_fail_tab").find("select").find("option:first").attr("selected", "selected"), Utils.bindChosen("select");
var histURL = url + "&" + params,
histURL = "/recruit/ShowSetup.do?tab=automate&subTab=cfSchedulers&action=ViewSch",
histParam = {
tab: "automate",
subTab: "cfSchedulers",
calleeObj: "crmSetup",
action: "ViewSch"
};
Crm.addToHistory(void 0, void 0, histParam, histURL)
}
})
}, CFSchedulerJSObject.viewMain = function() {
Utils.showHideLoadingDiv(!0);
var url = "/recruit/CFSchedulers.do",
histParam = {
action: "ViewSch"
};
(new crmRequestPool).initiate({
action: url,
type: "GET",
data: histParam,
success: function(response) {
$("#result").html(response), $("#op2").removeClass("sel"), $("#op1").addClass("sel"), $("#schedules_CF_tab,#kwd_search_div,#btnNewScheduler").show(), $("#schedules_fail_tab,#ErrMsg,#failTabNoRecord").hide(), Utils.showHideLoadingDiv();
var histURL = "/recruit/ShowSetup.do?tab=automate&subTab=cfSchedulers&action=ViewSch",
histParam = {
tab: "automate",
subTab: "cfSchedulers",
calleeObj: "crmSetup",
action: "ViewSch"
};
Crm.addToHistory(void 0, void 0, histParam, histURL)
}
})
}, CFSchedulerJSObject.editCfsStatus = function(obj) {
crmui.toolTip_hide();
var popDiv = $("#deactiveSchPopup"),
tdElem = $("#" + obj.closest("td").getAttribute("id"));
if (tdElem.find('input[type="checkbox"]').is(":checked")) {
if ($("#deactivePopup").removeClass("popInListView popInDetailView"), Crm.userDetails.RTL_ENABLED) {
var rtlPos = crmui.getOffset(obj);
rtlPos.left = rtlPos.left - $(obj).outerWidth() / 2 - 40, freezeBackground(), $("#FreezeLayer").css({
opacity: "0.35"
}).show(), popDiv.css({
position: "absolute",
left: rtlPos.left,
top: rtlPos.top + 33
}).addClass("scalePopOne").show()
} else {
var off = crmui.getOffset(obj);
$(window).height() - off.top < popDiv.innerHeight() + 15 ? (popDiv.addClass("shownTop"), off.left = $(window).width() - off.left - $(obj).outerWidth() / 2 - popDiv.outerWidth() / 4, freezeBackground(), $("#FreezeLayer").css({
opacity: "0.35"
}).show(), popDiv.css({
position: "absolute",
right: off.left + 20,
top: off.top - (popDiv.innerHeight() + 15),
left: ""
}).addClass("scalePopOne popInListView").show()) : (popDiv.removeClass("shownTop"), off.left = $(window).width() - off.left - $(obj).outerWidth() / 2 - popDiv.outerWidth() / 4, freezeBackground(), $("#FreezeLayer").css({
opacity: "0.35"
}).show(), popDiv.css({
position: "absolute",
right: off.left + 20,
top: off.top + 33,
left: ""
}).addClass("scalePopOne popInListView").show())
}
$("#cfsDeactivateBtn").unbind("click").click(function() {
popDiv.hide().removeClass("scalePopOne"), removeFreezeLayer(), tdElem.removeClass("active").addClass("inactive").find("input:checkbox").removeAttr("checked"), CFSchedulerJSObject.updateStatus(tdElem, tdElem.attr("id").split("_")[1], 1)
}), $("#cfsDeactivateCancelBtn").unbind("click").click(function() {
popDiv.hide().removeClass("scalePopOne"), removeFreezeLayer()
})
} else
CFSchedulerJSObject.updateStatus(tdElem, tdElem.attr("id").split("_")[1], 0), tdElem.removeClass("inactive").addClass("active").find("input:checkbox").attr("checked", !0)
}, CFSchedulerJSObject.updateStatus = function(obj, schID) {
for (var elem = $("#next_" + schID), url = "/recruit/CFSchedulers.do", params = "action=swapStatus&schID=" + schID + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken), requestPool = new crmRequestPool, nameMap = $("#schNameMap").val().replace("}", "").split(","), schName = "", i = 1; i < nameMap.length; i++)
if (nameMap[i].split("=")[0].trim() == schID.trim()) {
schName = nameMap[i].split("=")[1];
break
}
requestPool.doAjax(url, function(response) {
var jsonRes = $.parseJSON(response),
newA = document.createElement("a");
newA.setAttribute("href", "javascript:;"), newA.text = I18n.getMsg("crm.cfs.runnow.label"), "0" == jsonRes.stat.trim() ? (newA.setAttribute("class", "link disabled"), newA.setAttribute("onmouseover", "crmui.toolTip_show(this,'left'," + I18n.getMsg("crm.cfs.msg.inacsch") + ");"), newA.setAttribute("onmouseout", "crmui.toolTip_hide();"), obj.find(".onOffSwt").removeAttr("onmouseover"), obj.find(".onOffSwt").unbind("mouseover").mouseover(function() {
crmui.toolTip_show(this, "center", I18n.getMsg("crm.cfs.actnow"))
}), elem.text("-"), elem.attr("onmouseover", "crmui.toolTip_show(this, 'left', '" + I18n.getMsg("crm.cfs.deactivatedsch") + "');"), elem.attr("onmouseout", "crmui.toolTip_hide();"), crmui.showMsgBand("info", I18n.getMsg("crm.cfs.statusdeact", '"' + $ESAPI.encoder().encodeForHTML(schName) + '"') + " ", 4e3, "")) : (newA.setAttribute("onclick", "CFSchedulerJSObject.trigSch('" + schID + "');"), newA.setAttribute("class", "link"), obj.find(".onOffSwt").removeAttr("onmouseover"), obj.find(".onOffSwt").unbind("mouseover").mouseover(function() {
crmui.toolTip_show(this, "center", I18n.getMsg("crm.cfs.deactnow"))
}), elem.text(jsonRes.execTime), elem.attr("onmouseover", "crmui.toolTip_show(this, 'left', '" + jsonRes.execTimeFF + "');"), elem.attr("onmouseout", "crmui.toolTip_hide();"), crmui.showMsgBand("info", I18n.getMsg("crm.cfs.statusact", '"' + $ESAPI.encoder().encodeForHTML(schName) + '"') + " ", 4e3, "")), $("#xx_" + schID).empty().append(newA)
}, params)
}, CFSchedulerJSObject.renderHistSchName = function() {
var objValue = $("#SchNameList :selected").val();
"All Schedules" != objValue ? $(".schNameHead").addClass("hide") : $(".schNameHead").removeClass("hide")
}, CFSchedulerJSObject.leavePage = function() {
var url = "/recruit/CFSchedulers.do",
params = "action=ViewSch";
if (formAltered) {
var confirmBoxId = "stayonPageConfirmBox",
confirmBox = $("#" + confirmBoxId);
freezeBackground(), mailsetCenter(confirmBoxId), confirmBox.focus(), confirmBox.find(".leavePage").unbind("click").click(function() {
confirmBox.hide(), Utils.showHideLoadingDiv(!0), (new crmRequestPool).initiate({
action: url,
type: "GET",
data: params,
success: function(response) {
$("#result").html(response), Utils.showHideLoadingDiv()
}
}), removeFreezeLayer()
}), confirmBox.find(".stayPage").unbind("click").click(function() {
confirmBox.hide(), removeFreezeLayer()
})
} else
Utils.showHideLoadingDiv(!0), (new crmRequestPool).initiate({
action: url,
type: "GET",
data: params,
success: function(response) {
$("#result").html(response), Utils.showHideLoadingDiv()
}
})
}, CFSchedulerJSObject.editCFScheduler = function(schID) {
Utils.showHideLoadingDiv(!0);
var url = "/recruit/CFSchedulers.do",
params = "action=editSch&schID=" + schID;
if (paramsHist = {}, paramsHist.action = "editSch", -1 !== Crm.calPreferences.HOLIDAY1 && -1 !== Crm.calPreferences.HOLIDAY2)
var val = I18n.getMsg("crm.label.except.holiday2", [I18n.getMsg(crmCalendar.daysFullString[Crm.calPreferences.HOLIDAY1]), I18n.getMsg(crmCalendar.daysFullString[Crm.calPreferences.HOLIDAY2])]);
else
var val = I18n.getMsg("crm.label.except.holiday1", [I18n.getMsg(crmCalendar.daysFullString[Crm.calPreferences.HOLIDAY1])]);
var nameMap = $("#schNameMap").val();
(new crmRequestPool).initiate({
action: url,
type: "GET",
data: params,
success: function(response) {
if ($("#result").html(response), "crm.cfs.notcrm.schedule" != response) {
Utils.showHideLoadingDiv();
var histURL = "/recruit/ShowSetup.do?tab=automate&subTab=cfSchedulers&action=ViewSch",
histParam = {
tab: "automate",
subTab: "cfSchedulers",
calleeObj: "crmSetup",
action: "ViewSch"
};
Crm.addToHistory(void 0, void 0, histParam, histURL), $("#lbl_holiday").text(val), $("#schNameMap").val(nameMap);
var isCustomRecur = $("#isCustomRecur").val(),
freqtype = $("#custFrequency").val();
"5" == isCustomRecur && ($("#schFreq").val(freqtype), $("input:checkbox[id=Crm_CFS_RECURRING_FREQUENCY_Custom]").attr("checked", "checked"), CFSchedulerJSObject.freqChange(), $("#cusRecDiv1,#cusRecDiv2").show(), "1" == $("#hiddenOption").val() ? $('input[name=monthlyhidden][value="1"]').attr("checked", !0) : $('input[name=monthlyhidden][value="2"]').attr("checked", !0), "yes" == $("#holidayOption").val() ? $("#myswitchBar").attr("checked", !0) : $("#myswitchBar").removeAttr("checked")), $("#trDesc,#trScheduleName,#trDesc,#repeatFreq,#trCFOptions").removeClass("hide"), $("#saveButton").val(I18n.getMsg("crm.button.update")), $("#isEdit").val("Edit"), $("#cfSchId").val(schID), $("#cfsPageTitle").text(I18n.getMsg("crm.cfs.edittitle")), $("#chooseCFAction").val("customfunctions"), CFSchedulerJSObject.chooseFunction("edit"), "-1" != $("#schFreq :selected").val() && $("#saveButton").removeClass("inActiveSec"), "0" != freqtype && "-1" != freqtype ? $("#Crm_CFS_RECURRING_FREQUENCY_CustomDiv").removeClass("hide") : $("#Crm_CFS_RECURRING_FREQUENCY_CustomDiv").addClass("hide"), "yes" == $("#hasStarted").val() && $("#schDate").attr("disabled", !0).addClass("disableLink"), "" == $("#description").val().trim() ? ($("#descLink").removeClass("hide"), $("#trDesc").addClass("hide")) : ($("#descLink").addClass("hide"), $("#description").css({
height: "18px"
})), Utils.bindChosen("#CFSchedulerTable select")
}
}
})
}, CFSchedulerJSObject.hideFreq = function() {
$("#repeatFreq").addClass("hide")
}, CFSchedulerJSObject.showCustFunc = function() {
var freqtype = $("#schFreq :selected").val();
$("#Crm_CFS_RECURRING_FREQUENCY_Custom").is(":checked") && "0" != freqtype && "-1" != freqtype ? (CFSchedulerJSObject.freqChange(), $("#cusRecDiv1,#cusRecDiv2").show().contents().slideDown(), $("#p2").removeClass("hide"), Utils.bindChosen("#CFSchedulerTable select")) : ($("#cusRecDiv1,#cusRecDiv2").hide(), $("#p2").addClass("hide"))
}, CFSchedulerJSObject.freqChange = function() {
var freqtype = $("#schFreq :selected").val();
if ("-1" != freqtype && "-1" != $("#chooseCFAction :selected").val() ? $("#saveButton").removeClass("inActiveSec") : $("#saveButton").addClass("inActiveSec"), "0" != freqtype && "-1" != freqtype ? $("#cusRecDiv1,#cusRecDiv2,#Crm_CFS_RECURRING_FREQUENCY_CustomDiv").removeClass("hide") : $("#cusRecDiv1,#cusRecDiv2,#Crm_CFS_RECURRING_FREQUENCY_CustomDiv").addClass("hide"), $("#countnumber,#RECURRING_PERIOD_UNIT,#cfsWeekdayList,#p1,#p2,#satsun").addClass("hide"), "1" == freqtype)
$("#countnumber,#RECURRING_PERIOD_UNIT,#satsun").removeClass("hide"), $("#skipFreqLabel").text("day(s)");
else if ("2" == freqtype)
$("#countnumber,#RECURRING_PERIOD_UNIT,#cfsWeekdayList").removeClass("hide"), $("#skipFreqLabel").text("week(s)");
else if ("3" == freqtype)
$("#countnumber,#RECURRING_PERIOD_UNIT,#p1").removeClass("hide"), $("#Crm_CFS_RECURRING_FREQUENCY_Custom").is(":checked") && $("#p2").removeClass("hide"), $("#year_month_specify").text(I18n.getMsg("crm.cfs.repeat.month.span")), $("#skipFreqLabel").text("month(s)");
else if ("4" == freqtype) {
if ($("#countnumber,#RECURRING_PERIOD_UNIT,#p1").removeClass("hide"), $("#Crm_CFS_RECURRING_FREQUENCY_Custom").is(":checked") && $("#p2").removeClass("hide"), "" != $("#schDate").val()) {
var schDateObj = crmCalendar.getDateObjectFromGivenDateString($("#schDate").val()),
myDate = Utils.convertUsrtoDefaultDatePattern(schDateObj),
stddate = $.datepicker.formatDate("mm/dd/yy", myDate),
datee = new Date(Date.parse(stddate)),
month1 = crmCalendar.monthName[datee.getMonth()].html;
$("#year_month_specify").text(I18n.getMsg("crm.recurring.custom.yearly.repeat.on", I18n.getMsg([month1])))
} else {
var n = CFSchedulerJSObject.monthNames[(new Date).getMonth()];
$("#year_month_specify").text(I18n.getMsg("crm.recurring.custom.yearly.repeat.on", I18n.getMsg([n])))
}
$("#skipFreqLabel").text("year(s)")
} else
$("#countnumber,#RECURRING_PERIOD_UNIT,#p1,#p2,#satsun").addClass("hide"), $("#year_month_specify").text("");
Utils.bindChosen("#CFSchedulerTable select")
}, CFSchedulerJSObject.chooseFunction = function(mode) {
var objValue = $("#chooseCFAction :selected").val();
"customfunctions" === objValue ? ("edit" != mode ? (freezeBackground(), CFSchedulerJSObject.createNewFunction()) : ($("#customFunctionNameDisp,#editCustomFunction,#remoteCustomFunction").removeClass("hide"), $("#chooseCFActionSelect,#undoCustomFunctionChange").addClass("hide"), $("#chooseCFAction").attr("disabled", !0)), $("#trCFSaveButton").removeClass("hide"), "-1" != $("#schFreq :selected").val() && $("#saveButton").removeClass("inActiveSec"), $("#urlContent,.selectedactionsCtn,.viewBtnPlace,#trCBDisplay").addClass("hide"), $("#expression").val("")) : "existing" === objValue ? (CFSchedulerJSObject.listCustomFunctions("function"), $("#trCFSaveButton").removeClass("hide"), "-1" != $("#schFreq :selected").val() && $("#saveButton").removeClass("inActiveSec")) : "gallery" === objValue ? (CFSchedulerJSObject.listCustomFunctions("gallery"), $("#trCFSaveButton").removeClass("hide"), "-1" != $("#schFreq :selected").val() && $("#saveButton").removeClass("inActiveSec"), $("#urlContent,.selectedactionsCtn,.viewBtnPlace,#trCBDisplay").addClass("hide"), $("#expression").val("")) : ($("#urlContent,.selectedactionsCtn,.viewBtnPlace,#customFunctionNameDisp,#editCustomFunction,#remoteCustomFunction,#undoCustomFunctionChange").addClass("hide"), $("#saveButton").addClass("inActiveSec"))
}, CFSchedulerJSObject.createNewFunction = function() {
"function" == typeof handlePostMessage && (window.addEventListener ? removeEventListener("message", handlePostMessage, !1) : detatchEvent("onmessage", handlePostMessage));
var url = "/recruit/CFSchedulers.do",
params = "action=createNewCustomFunction",
requestPool = new crmRequestPool;
requestPool.doAjax(url, function(resp) {
if ("crm.custombutton.error.usermail.notconfirmed" == resp)
crmui.showMsgBand("error", I18n.getMsg("crm.custombutton.error.usermail.notconfirmed"), 4e3, ""), removeFreezeLayer(), $("#chooseCFAction").val("-1").trigger("change.select2"), Utils.bindChosen("#CFSchedulerTable select");
else {
var newRelatedListPopupDiv = $("#newRelatedListPopUpDiv");
newRelatedListPopupDiv.html(resp).css("zIndex", 1e4).show(), Utils.showHideLoadingDiv(), newRelatedListPopupDiv.css({
padding: "0px",
width: "1000px"
}), crmui.showPop("newRelatedListPopUpDiv")
}
}, params, void 0, void 0, void 0, "GET")
}, CFSchedulerJSObject.cancelOperationInCustomFunction = function(mode, fromSrc) {
"edit" === mode ? CFSchedulerJSObject.closeDiv("newRelatedListPopUpDiv") : "configure" === mode ? CFSchedulerJSObject.listCustomFunctions(fromSrc) : (CFSchedulerJSObject.closeDiv("newRelatedListPopUpDiv"), $("#chooseCFAction").val("-1"), $("#chooseCFAction").trigger("change.select2"), Utils.bindChosen("#CFSchedulerTable select"), Utils.showHideLoadingDiv())
}, CFSchedulerJSObject.listCustomFunctions = function(fromSrc) {
var url = "/recruit/CFSchedulers.do",
params = "action=listCFSFunctions&fromSrc=" + fromSrc;
Utils.showHideLoadingDiv(!0), (new crmRequestPool).initiate({
action: url,
type: "GET",
data: params,
success: function(resp) {
if ("crm.custombutton.error.usermail.notconfirmed" == resp)
crmui.showMsgBand("error", I18n.getMsg("crm.custombutton.error.usermail.notconfirmed"), 4e3, ""), removeFreezeLayer(), $("#chooseCFAction").val("-1");
else {
var newRelatedListPopupDiv = $("#newRelatedListPopUpDiv");
newRelatedListPopupDiv.html(resp), $("#newRelatedListPopUpDiv").removeClass().addClass("newpopup p30 w720"), newRelatedListPopupDiv.css("zIndex", 250), Utils.showHideLoadingDiv(), newRelatedListPopupDiv.css({
padding: "0px"
}), newRelatedListPopupDiv.css({
width: "60%"
}), crmui.showPop("newRelatedListPopUpDiv")
}
}
})
}, CFSchedulerJSObject.closeCustomFunctionConfigDiv = function() {
crmui.hidePopup("newRelatedListPopUpDiv"), $("#chooseCFAction").val("-1").trigger("change.select2"), Utils.bindChosen("#CFSchedulerTable select")
}, CFSchedulerJSObject.saveCFSchedulerDeluge = function(functionName, otherParamNames, otherParamVals, entityParamNames, entityParamVals, workflowLinkId, isCreatorCalled, paramsNotChanged, description) {
var action = "saveCFSDetails",
schID = -1,
schIDfromReq = $("#cfSchId").val();
"" !== schIDfromReq && (schID = schIDfromReq), "" !== schID && -1 != schID && (action = "updateCFSDetails");
var url = "/recruit/CFSchedulers.do",
params = "action=" + action + "&schID=" + schID + "&functionName=" + encodeURIComponent(functionName) + "&otherParamNames=" + encodeURIComponent(otherParamNames) + "&otherParamVals=" + encodeURIComponent(otherParamVals) + "&entityParamNames=" + encodeURIComponent(entityParamNames) + "&entityParamVals=" + encodeURIComponent(entityParamVals);
params = params + "&workflowLinkId=" + workflowLinkId + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken), description && (params = params + "&desc=" + encodeURIComponent(description));
var requestPool = new crmRequestPool;
requestPool.doAjax(url, function(response) {
if (isCreatorCalled) {
var jsonRes = $.parseJSON(response);
$("#customFunctionNameDisp").text(jsonRes.funcName), $("#cfSchId").val(jsonRes.schId), $("#workflowLinkId").val(jsonRes.workflowLinkId), $("#customFunctionNameDisp,#editCustomFunction,#remoteCustomFunction").removeClass("hide"), $("#chooseCFActionSelect,#undoCustomFunctionChange").addClass("hide"), $("#chooseCFAction").attr("disabled", !0)
}
}, params)
}, CFSchedulerJSObject.validateSplCharInNameField = function(fieldValue) {
var i,
splCharArrayForTabs = new Array("`", "~", "!", "#", "^", "*", "[", "]", "{", "}", "|", "\\", '"', ";", "'", "&", "+", "%", "(", ")", "@", "?", ":", "<", ">", ":", ",", "$", "=", "/");
for (i = 0; i < splCharArrayForTabs.length; i++)
if (fieldValue.indexOf(splCharArrayForTabs[i]) >= 0)
return !0;
return !1
}, CFSchedulerJSObject.cfSchedulerSubmit = function() {
$(".red").removeClass("red"), $("#remoteCustomFunction").addClass("red"), $(".redTxt").removeClass("redTxt"), $(".errMsg").addClass("hide");
var hasStarted = $("#hasStarted").val(),
nameObj = $("#cfSchedulerName"),
isCustomRec = "no",
workflowLinkId = $("#workflowLinkId").val(),
error = !1,
schName = nameObj.val(),
schDesc = $("#description").val(),
schDate = $("#schDate").val();
"yes" == hasStarted && (schDate = $("#schDateOrg").val());
var schTime = $("#schTime").val();
if ("" === schName)
nameObj.focus().select().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), nameObj.next().next().removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.NameRequired")), error = !0;
else if ("" !== schName)
if (error = CFSchedulerJSObject.validateSplCharInNameField(schName))
nameObj.focus().select().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), nameObj.next().next().removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.NoSplCharsInName"));
else
for (var nameArr = $("#schNameMap").val().replace("}", ""), nameMap = nameArr.split(","), cfsName = $("#cfsName").val(), i = 1; i < nameMap.length; i++) {
var schNameOb = nameMap[i].split("=");
if (("Edit" != $("#isEdit").val() || schNameOb[1].toLowerCase() != cfsName.toLowerCase()) && void 0 != schNameOb[1] && schName.toLowerCase() == schNameOb[1].toLowerCase()) {
nameObj.focus().select().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), nameObj.next().next().removeClass("hide").text(I18n.getMsg("crm.cfs.schName.exist")), error = !0;
break
}
}
else
schName > 30 && (nameObj.focus().select().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), nameObj.next().removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.name.exceedLength")), error = !0);
schDesc > 250 && ($("#description").focus().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), $("#description").next().removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.desc.exceedLength")), error = !0);
var schDateObj = crmCalendar.getDateObjectFromGivenDateString(schDate),
myDate = Utils.convertUsrtoDefaultDatePattern(schDateObj),
stddate = $.datepicker.formatDate("mm/dd/yy", myDate);
if ("" == schDate.trim() ? ($("#schDate").focus().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), $("#schDate").next().removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.DateRequired")), error = !0) : "" !== stddate && (Utils.isValidDate("mm/dd/yyyy", stddate) || ($("#schDate").focus().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), $("#schDate").next().removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.InvalidDate")), error = !0)), "" === schTime)
$("#schTime").focus().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), $("#schTime").next().removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.TimeRequired")), error = !0;
else {
if ("HH:mm" === Crm.userDetails.TIME_FORMAT)
var regex = /^([0]?[0-9]|1[0-9]|2[0-3]):([0,3][0])\s?$/i;
else
var regex = /^([0]\d|[1][0-2]):([0,3][0])\s?(?:AM|PM)$/i;
schTime = schTime.replace(I18n.getMsg("AM"), "AM"), schTime = schTime.replace(I18n.getMsg("PM"), "PM"), "" == schTime || regex.test(schTime) || ($("#schTime").focus().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), $("#schTime").next().removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.Validtime")), error = !0)
}
var tomoevent = !1;
new Date >= new Date(Date.parse(stddate + " " + schTime)) && "no" == hasStarted ? ($("#schTime").focus().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), $("#schTime").next().removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.ValidDatetime")), error = !0) : new Date > new Date(Date.parse(stddate + " " + schTime)) && "yes" == hasStarted ? (tomoevent = !0, myDate.setTime(myDate.getTime() + 864e5), stddate = $.datepicker.formatDate("mm/dd/yy", myDate)) : (myDate.getTime() - (new Date).getTime()) / 864e5 > 90 && ($("#schTime").focus().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), $("#schTime").next().removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.Validtime")), error = !0);
var monthlyhidden = "1",
weeksequence = "",
yearlyhidden = "1",
monthVal = "" + stddate.split("/")[0],
dayOfMonth = "" + stddate.split("/")[1],
weekdays = "",
exceptHoliday = "",
selectedWeekDays = "-1",
freq = $("#schFreq :selected").val();
$("#Crm_CFS_RECURRING_FREQUENCY_Custom").is(":checked") && (freq = "5");
var repeatEveryCnt = "1";
if ("5" == freq) {
var newFreq = $("#schFreq :selected").val();
if ("88" != newFreq)
if (freq = newFreq, isCustomRec = "yes", "1" == freq)
$("#myswitchBar").is(":checked") && (exceptHoliday = parseInt(Crm.calPreferences.HOLIDAY1) + 1, "-1" != Crm.calPreferences.HOLIDAY2 && (exceptHoliday += "," + (parseInt(Crm.calPreferences.HOLIDAY2) + 1))), repeatEveryCnt = $("#skipFreq").val();
else if ("2" == freq) {
var element = $("div[id^='selectedDay_']");
for (i = 0; i < element.length; i++)
selectedWeekDays = "-1" === selectedWeekDays ? $(element[i]).attr("id").split("selectedDay_")[1] : selectedWeekDays + "," + $(element[i]).attr("id").split("selectedDay_")[1];
"-1" === selectedWeekDays && (crmui.showMsgBand("error", I18n.getMsg("crm.cfs.select.atleast.oneday"), 4e3, ""), $("#weekTxt").focus().closest("td").removeClass("wf_setFocus").addClass("red"), error = !0), repeatEveryCnt = $("#skipFreq").val()
} else if ("3" == freq) {
var myRadio = $("input[name=monthlyhidden]");
monthlyhidden = myRadio.filter(":checked").val(), "1" == monthlyhidden ? dayOfMonth = $("#Crm_Cfs_RECURRING_CUSTOM_MONTH_REPEAT_ON_DAY :selected").val() : "2" == monthlyhidden ? (weeksequence = $("#Crm_Cfs_RECURRING_CUSTOM_OCCUR_FIRST :selected").val(), weekdays = $("#Crm_Cfs_RECURRING_CUSTOM_OCCUR_DAY :selected").val()) : (crmui.showMsgBand("error", I18n.getMsg("crm.cfs.select.atleast.oneweekday"), 4e3, ""), error = !0), repeatEveryCnt = $("#skipFreq").val()
} else if ("4" == freq) {
var myRadio = $("input[name=monthlyhidden]");
yearlyhidden = myRadio.filter(":checked").val(), "1" == yearlyhidden ? dayOfMonth = $("#Crm_Cfs_RECURRING_CUSTOM_MONTH_REPEAT_ON_DAY :selected").val() : "2" == yearlyhidden ? (weeksequence = $("#Crm_Cfs_RECURRING_CUSTOM_OCCUR_FIRST :selected").val(), weekdays = $("#Crm_Cfs_RECURRING_CUSTOM_OCCUR_DAY :selected").val()) : (crmui.showMsgBand("error", I18n.getMsg("crm.cfs.select.atleast.oneweekday"), 4e3, ""), error = !0), repeatEveryCnt = $("#skipFreq").val()
}
}
(null === repeatEveryCnt || isNaN(repeatEveryCnt) || "" === repeatEveryCnt || "0" == repeatEveryCnt) && (crmui.showMsgBand("error", I18n.getMsg("crm.cfs.validnumber"), 4e3, ""), $("#skipFreq").focus().addClass("red"), error = !0);
var period = "";
switch (freq) {
case "0":
period = "once";
break;
case "1":
period = "daily";
break;
case "2":
period = "weekly";
break;
case "3":
period = "monthly";
break;
case "4":
period = "yearly"
}
var schFreq = $("#schFreq :selected").val();
"-1" === schFreq && ($("#schFreq").focus().select().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), $("#errorMsg_cfs_freq_req").removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.FreqRequired")), error = !0);
var invoke = $("#chooseCFAction :selected").val();
if ("-1" === invoke && ($("#chooseCFAction").focus().select().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), $("#errorMsg_cfs_func_req").removeClass("hide").text(I18n.getMsg("crm.cfs.JSAlert.whatHasToHappen")), error = !0), error)
return !1;
var schId = -1,
isEdit = $("#isEdit").val();
"" !== $("#cfSchId").val() && (schId = $("#cfSchId").val());
var url = "/recruit/CFSchedulers.do",
params = "action=updateSch&reqSchId=" + schId + "&schName=" + encodeURIComponent(schName) + "&isEdit=" + isEdit + "&schDesc=" + encodeURIComponent(schDesc) + "&schDate=" + stddate + "&schTime=" + schTime + "&workflowLinkId=" + workflowLinkId;
params = params + "&repeatEveryCnt=" + repeatEveryCnt + "&isCustomRec=" + isCustomRec + "&period=" + period + "&exceptHoliday=" + exceptHoliday + "&selectedWeekDays=" + selectedWeekDays + "&monthlyhidden=" + monthlyhidden + "&yearlyhidden=" + yearlyhidden + "&weeksequence=" + weeksequence + "&weekdays=" + weekdays + "&dayOfMonth=" + dayOfMonth + "&monthVal=" + monthVal + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken);
var requestPool = new crmRequestPool;
requestPool.doAjax(url, function(response) {
"err.occured" === response ? (doAjaxUpdate("result", "/recruit/CFSchedulers.do?action=ViewSch"), crmui.showMsgBand("error", I18n.getMsg("crm.cfs.error.occured"), 5e3, "")) : ($("#result").html(response), window.scrollTo(0, 0), "Edit" != isEdit ? crmui.showMsgBand("success", I18n.getMsg("crm.cfs.created", '"' + $ESAPI.encoder().encodeForHTML(schName) + '"'), 5e3, "") : crmui.showMsgBand("success", I18n.getMsg("crm.cfs.updated", '"' + $ESAPI.encoder().encodeForHTML(schName) + '"'), 5e3, ""))
}, params)
}, CFSchedulerJSObject.deleteCFScheduler = function(schID) {
crmui.toolTip_hide(), $("#cfs_sch_" + schID + "_true").length > 0 ? (showDeletePopup(I18n.getMsg("crm.cfs.deleteconfirm"), "crm.cfs.yes.delete", "", "", this), $("#deletepopup").find("#deleteButton").unbind("click").click(function() {
hideAnimatePopup("deletepopup");
var url = "/recruit/CFSchedulers.do",
params = "action=delSch&schID=" + schID + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken);
paramsHist = {}, paramsHist.action = "delSch";
for (var schName, nameMap = $("#schNameMap").val().replace("}", "").split(","), i = 1; i < nameMap.length; i++)
if (nameMap[i].split("=")[0].trim() == schID.trim()) {
schName = nameMap[i].split("=")[1];
break
}
var requestPool = new crmRequestPool;
requestPool.doAjax(url, function(response) {
window.scrollTo(0, 0);
var jsonRes = $.parseJSON(response);
$(".contentRows #cfs_sch_" + schID + "_true").parent().slideUp(), crmui.showMsgBand("success", I18n.getMsg("crm.cfs.deleted", '"' + $ESAPI.encoder().encodeForHTML(schName) + '"'), 5e3, ""), "0" == jsonRes.size || "-1" == jsonRes.size ? doAjaxUpdate("result", "/recruit/CFSchedulers.do?action=ViewSch") : "9" == jsonRes.size && $("#btnNewScheduler").removeClass("disabled").removeAttr("onmouseover").removeAttr("onmouseout").attr("onclick", "CFSchedulerJSObject.createNewScheduler();")
}, params)
})) : crmui.showMsgBand("success", I18n.getMsg("crm.cfs.nodelete"), 5e3, "")
}, CFSchedulerJSObject.closeDiv = function(div) {
crmui.hidePopup(div)
}, CFSchedulerJSObject.weekDropDown = function(el, target) {
var x = $(el).position().left,
y = $(el).offset().top,
myHt = $("." + target).innerHeight();
$("." + target).fadeIn(100), $("." + target).css(myHt < $(window).height() - (y + 55) ? {
left: x,
top: "35px"
} : {
left: x,
top: "-233px"
}), $(".dropInput").removeAttr("placeholder"), $(".dropInput").focus(), $("body,#setup_new_ContentDiv").css("overflow", "hidden")
}, CFSchedulerJSObject.addWeekDay = function(target) {
checkedVal = $("#" + target).find("li").find('input[type="checkbox"]:checked'), !checkedVal.length > 0 ? crmui.showMsgBand("error", I18n.getMsg("crm.cfs.select.atleast.oneday"), 4e3, "") : ($(".zs-token-selected").remove(), $.each(checkedVal, function(i) {
weekDayName = $("#" + target).find("li").find('input[type="checkbox"]:checked').eq(i).attr("name"), weekDayId = $("#" + target).find("li").find('input[type="checkbox"]:checked').eq(i).attr("id"), spanAdd = '<div class="zs-token-selected token-selected m5 tagger-tag">', spanAdd = spanAdd + '<div class="zso_floatLeft pR5 pL5 lh16 font-lucida f11 inlineBlock" id="selectedDay_' + weekDayId + '">' + weekDayName + "</div>", spanAdd += '<span onclick="CFSchedulerJSObject.deleteList(this,event)" class="cP" title="Remove Day">x</span>', $(".dropInput").before(spanAdd)
}), 0 === $(".profileListst .zs-token-selected").length ? $(".dropInput").attr("placeholder", I18n.getMsg("crm.cfs.jsp.clicktoadd")) : $(".dropInput").removeAttr("placeholder"), $("#" + target).hide())
}, CFSchedulerJSObject.cancelWeekDaysDiv = function() {
event.stopPropagation();
var weekdayList = $("#weekdayList");
weekdayList.hide(), weekdayList.find("li").find('input[type="checkbox"]').prop("checked", !1), $(".dropInput").attr("placeholder", I18n.getMsg("crm.cfs.jsp.clicktoadd")), $("body,#setup_new_ContentDiv").css("overflow", ""), $(".zso_floatLeft").each(function() {
var selDay = this.id;
weekdayList.find("li").find('input[type="checkbox"]').each(function() {
var op = this.id;
-1 != selDay.indexOf(op) && weekdayList.find("li").find('input[id="' + op + '"]').prop("checked", !0)
})
})
}, CFSchedulerJSObject.deleteList = function(el, e) {
e.stopPropagation(), $(el).parent().remove(), 0 === $(".profileListst .zs-token-selected").length ? $(".profileListst").parent().removeClass("p10 bdr1px") : $(".profileListst").parent().addClass("p10 bdr1px"), pName = $.trim($(el).prev("div").text()), $("#weekdayList").find("li").find('input[name="' + pName + '"]').prop("checked", !1)
}, CFSchedulerJSObject.showremoveCFAlert = function() {
freezeBackground(), mailsetCenter("removeCFWarningdiv"), $("#removeCFWarningdiv").removeClass("hide")
}, CFSchedulerJSObject.removeCustomFunction = function() {
$("#saveButton").addClass("inActiveSec"), $("#chooseCFAction").val("-1"), $("#chooseCFAction").trigger("change.select2"), $("#chooseCFAction").attr("disabled", !1), Utils.bindChosen("#CFSchedulerTable select"), $("#customFunctionNameDisp,#editCustomFunction,#removeCFWarningdiv,#remoteCustomFunction").addClass("hide"), $("#chooseCFActionSelect,#undoCustomFunctionChange").removeClass("hide")
}, CFSchedulerJSObject.undoCustomFunctionChange = function() {
"-1" != $("#schFreq :selected").val() && $("#saveButton").removeClass("inActiveSec"), $("#chooseCFAction").val("customfunctions"), $("#customFunctionNameDisp,#editCustomFunction,#removeCFWarningdiv,#remoteCustomFunction").removeClass("hide"), $("#chooseCFActionSelect,#undoCustomFunctionChange").addClass("hide"), $("#chooseCFAction").attr("disabled", !0), $(".selectedactionsCtn,.viewBtnPlace,#trCBDisplay").addClass("hide")
}, CFSchedulerJSObject.editCustomFunction = function() {
"function" == typeof handlePostMessage && (window.addEventListener ? removeEventListener("message", handlePostMessage, !1) : detatchEvent("onmessage", handlePostMessage)), $("body,#wfDelugeConfDIV").css("overflow", "hidden");
var cfSchId = $("#cfSchId").val(),
workflowLinkId = $("#workflowLinkId").val(),
url = "/recruit/CFSchedulers.do",
params = "action=associatedCFSFunctions&step=edit&schID=" + cfSchId + "&workflowLinkId=" + workflowLinkId + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken),
requestPool = new crmRequestPool;
requestPool.doAjax(url, function(resp) {
var newRelatedListPopupDiv = $("#newRelatedListPopUpDiv");
$("#newRelatedListPopUpDiv").removeClass().addClass("newpopup p30 w720"), newRelatedListPopupDiv.html(resp), "none" == newRelatedListPopupDiv.css("display") && (Utils.showHideLoadingDiv(), loadAjaxTab("", "lightblue"), $("#thirdPartyRowTag").bind("click", function() {
$("#thirdPartyRowTag").unbind("click")
})), newRelatedListPopupDiv.css({
zIndex: 1e4,
padding: "0px"
}), $("#wfDelugeConfDIV").length > 0 ? $("#wfDelugeConfDIV >div:first").css("height", "auto") : $("#newRelatedListPopUpDiv .pwie:first").css("height", "auto"), crmui.showPop("newRelatedListPopUpDiv"), Utils.showHideLoadingDiv()
}, params)
}, CFSchedulerJSObject.openCustomizeCFPopup = function(url, params, btnStatus) {
"function" == typeof handlePostMessage && (window.addEventListener ? removeEventListener("message", handlePostMessage, !1) : detatchEvent("onmessage", handlePostMessage));
var requestPool = new crmRequestPool;
requestPool.doAjax(url, function(resp) {
if ("customRelatedListIncreasedCountExceeded" == resp)
crmui.showMsgBand("error", I18n.getMsg("crm.label.newrelatedlist.increasedcount.exceeded"), 4e3, "");
else if ("customRelatedListCountExceeded" == resp)
crmui.showMsgBand("error", I18n.getMsg("crm.label.newrelatedlist.exceeded"), 4e3, "");
else {
var newRelatedListPopupDiv = $("#newRelatedListPopUpDiv");
newRelatedListPopupDiv.hide().removeClass().addClass("newpopup p30 w720"), newRelatedListPopupDiv.html(resp), setDivWidthHeight("newRelatedListPopUpDiv"), newRelatedListPopupDiv.css({
zIndex: 1e4,
padding: "0px"
}), "dublicate" === btnStatus ? newRelatedListPopupDiv.css({
padding: "0px",
width: "1000px"
}) : $("#wfDelugeConfDIV").length > 0 ? $("#wfDelugeConfDIV >div:first").css({
height: "auto"
}) : $("#newRelatedListPopUpDiv .pwie:first").height(newRelatedListPopupDiv.outerHeight() - 100), Utils.showHideLoadingDiv(), crmui.showPop("newRelatedListPopUpDiv")
}
}, params)
}, CFSchedulerJSObject.deleteCustomFunction = function(workflowLinkId) {
freezeBackground();
var a = confirm(I18n.getMsg("crm.custombutton.customfunction.remove.alert.msg"));
if (a) {
var url = "/recruit/CFSchedulers.do",
params = "action=deleteCustomFunction&workflowLinkId=" + workflowLinkId + "&" + csrfParamName + "=" + encodeURIComponent(csrfToken),
requestPool = new crmRequestPool;
requestPool.doAjax(url, function(resp) {
if ("customRelatedListIncreasedCountExceeded" == resp)
crmui.showMsgBand("error", I18n.getMsg("crm.label.newrelatedlist.increasedcount.exceeded"), 4e3, "");
else if ("customRelatedListCountExceeded" == resp)
crmui.showMsgBand("error", I18n.getMsg("crm.label.newrelatedlist.exceeded"), 4e3, "");
else {
var newRelatedListPopupDiv = $("#newRelatedListPopUpDiv");
newRelatedListPopupDiv.html(resp), newRelatedListPopupDiv.css("zIndex", 1e4), setDivWidthHeight("newRelatedListPopUpDiv"), newRelatedListPopupDiv.show(), Utils.showHideLoadingDiv(), mailsetCenter("newRelatedListPopUpDiv")
}
}, params)
}
}, CFSchedulerJSObject.createNewScheduler = function() {
var url = "/recruit/CFSchedulers.do",
params = "action=createSch&" + csrfParamName + "=" + encodeURIComponent(csrfToken);
if (paramsHist = {}, paramsHist.action = "createSch", -1 !== Crm.calPreferences.HOLIDAY1 && -1 !== Crm.calPreferences.HOLIDAY2)
var val = I18n.getMsg("crm.label.except.holiday2", [I18n.getMsg(crmCalendar.daysFullString[Crm.calPreferences.HOLIDAY1]), I18n.getMsg(crmCalendar.daysFullString[Crm.calPreferences.HOLIDAY2])]);
else
var val = I18n.getMsg("crm.label.except.holiday1", [I18n.getMsg(crmCalendar.daysFullString[Crm.calPreferences.HOLIDAY1])]);
var nameMap = $("#schNameMap").val(),
requestPool = new crmRequestPool;
requestPool.doAjax(url, function(response) {
if ("crm.cfs.total.limit.exceeded" != response) {
$("#result").html(response), $("#schNameMap").val(nameMap), $("#lbl_holiday").text(val), $("#isEdit").val("No"), window.scrollTo(0, 0);
var histURL = "/recruit/ShowSetup.do?tab=automate&subTab=cfSchedulers&action=ViewSch",
histParam = {
tab: "automate",
subTab: "cfSchedulers",
calleeObj: "crmSetup",
action: "ViewSch"
};
Crm.addToHistory(void 0, void 0, histParam, histURL), $("#cfSchedulerName").focus()
} else
crmui.showMsgBand("error", I18n.getMsg("crm.cfs.total.limit.exceeded"), 5e3, "")
}, params)
}, CFSchedulerJSObject.showSchPopup = function(el, schDesc, recSummary, crBy, mdBy) {
var content = "<table class='inst_Action p10' width='380' border='0' cellspacing='0' cellpadding='0'>";
schDesc.trim().length > 0 && null !== schDesc && "null" !== schDesc.toLowerCase ? (content += schDesc.split("\n").length > 4 ? "<tr><td class='wf_Tdbdr'>" + I18n.getMsg("crm.label.description") + " </td></tr><tr><td style='white-space:pre-line'><div>" + schDesc.substring(0, schDesc.indexOf(schDesc.split("\n")[4]) - 1) + " ...</div></td></tr>" : schDesc.length > 180 ? "<tr><td class='wf_Tdbdr'>" + I18n.getMsg("crm.label.description") + " </td></tr><tr><td style='white-space:pre-line'><div>" + schDesc.substring(0, 180) + " ...</div></td></tr>" : "<tr><td class='wf_Tdbdr'>" + I18n.getMsg("crm.label.description") + " </td></tr><tr><td style='white-space:pre-line'><div>" + schDesc + "</div></td></tr>", content += "<tr><td class='wf_Tdbdr pT20'>" + I18n.getMsg("crm.cfs.popupmsg1") + "</td></tr><tr><td style='white-space:normal'>" + recSummary + "</td></tr>") : content += "<tr><td class='wf_Tdbdr'>" + I18n.getMsg("crm.cfs.popupmsg1") + "</td></tr><tr><td style='white-space:normal'>" + recSummary + "</td></tr>", content += "<tr><td class='wf_Tdbdr pT20'>" + I18n.getMsg("crm.cfs.popupmsg2") + "</td></tr><tr><td style='white-space:normal'>" + crBy + "</td></tr>", content += "<tr><td class='wf_Tdbdr pT20'>" + I18n.getMsg("crm.cfs.popupmsg3") + "</td></tr><tr><td style='white-space:normal'>" + mdBy + "</td></tr>", content += "</table>", crmui.toolTip_show(el, "left", content, !0)
}, CFSchedulerJSObject.hideSchPopup = function() {
crmui.toolTip_hide()
}, $(document).on("keyup", function(evt) {
27 == evt.keyCode && $(".schedulerTable").length > 0 && CFSchedulerJSObject.leavePage()
}), CFSchedulerJSObject.weekdayText = function(ev) {
crmui.showMsgBand("info", I18n.getMsg("crm.cfs.selectweek"), 4200, ""), ev.preventDefault()
}, CFSchedulerJSObject.skipFreq = function(e) {
var code = e.which || e.keyCode;
code >= 48 && 57 >= code || code >= 0 && 31 >= code || 127 == code || (crmui.showMsgBand("error", I18n.getMsg("crm.cfs.onlynumerals"), 4200, ""), e.preventDefault())
}, CFSchedulerJSObject.cfSchedulerNamekeypress = function(e) {
var code = e.which || e.keyCode;
11 == code || 9 == code ? $("#schDate").focus() : code >= 65 && 90 >= code || code >= 48 && 57 >= code || code >= 97 && 122 >= code || 95 == code || 46 == code || 45 == code || 32 == code || 8 == code || 127 == code || (crmui.showMsgBand("error", I18n.getMsg("crm.cfs.noSpecialChar"), 4200, ""), e.preventDefault())
}, CFSchedulerJSObject.cfSchedulerNamefocusout = function() {
$(".red").removeClass("red"), $("#remoteCustomFunction").addClass("red"), $(".redTxt").removeClass("redTxt"), $(".errMsg").addClass("hide");
for (var name = $("#cfSchedulerName").val(), nameArr = $("#schNameMap").val().replace("}", ""), nameMap = nameArr.split(","), cfsName = $("#cfsName").val(), i = 1; i < nameMap.length; i++) {
var schName = nameMap[i].split("=");
if (("Edit" != $("#isEdit").val() || schName[1].toLowerCase().trim() != cfsName.toLowerCase().trim()) && name.toLowerCase().trim() == schName[1].toLowerCase().trim()) {
$("#cfSchedulerName").focus().select().closest("td").removeClass("wf_setFocus").addClass("red").prev("td").addClass("redTxt"), $("#cfSchedulerName").next().next().removeClass("hide").text(I18n.getMsg("crm.cfs.schName.exist"));
break
}
}
}, CFSchedulerJSObject.schDate = function(ev) {
var code = ev.which || ev.keyCode;
127 == code || 8 == code ? ($("#schDate").val(""), $("#cusDateFrom").val(""), $("#cusDateTo").val("")) : "" == $("#schDate").val() ? (ev.preventDefault(), crmui.showMsgBand("info", I18n.getMsg("crm.cfs.choosedate"), 4200, "")) : ev.preventDefault()
}, CFSchedulerJSObject.schTime = function(ev) {
var code = ev.which || ev.keyCode;
127 == code || 8 == code ? $("#schTime").val("") : "" == $("#schTime").val() ? (ev.preventDefault(), $("#schTime").trigger("click"), crmui.showMsgBand("info", I18n.getMsg("crm.cfs.choosetime"), 4200, "")) : (ev.preventDefault(), $("#schTime").trigger("click"))
}, CFSchedulerJSObject.SortTable = function(curObj) {
var type = arguments.length > 0 ? arguments[1] : "T",
table = document.getElementById($(curObj).closest("table").attr("id")),
tbody = table.getElementsByTagName("tbody")[0],
rows = tbody.getElementsByTagName("tr"),
sortColumn = $("th").index(curObj);
"table-2" == $(curObj).closest("table").attr("id") && (sortColumn -= 6);
var arrayOfRows = new Array;
type = type.toUpperCase();
for (var i = 0, len = rows.length; len > i; i++) {
arrayOfRows[i] = {}, arrayOfRows[i].oldIndex = i;
var celltext = rows[i].getElementsByTagName("td")[sortColumn].innerText.replace(/<[^>]*>/g, ""),
re = "N" == type ? /[^\.\-\+\d]/g : /[^a-zA-Z0-9]/g;
arrayOfRows[i].value = celltext.replace(re, "").substr(0, 25).toLowerCase()
}
if (sortColumn == CFSchedulerJSObject.TableLastSortedColumn)
arrayOfRows.reverse();
else
switch (CFSchedulerJSObject.TableLastSortedColumn = sortColumn, type) {
case "N":
arrayOfRows.sort(CFSchedulerJSObject.CompareRowOfNumbers);
break;
default:
arrayOfRows.sort(CFSchedulerJSObject.CompareRowOfText)
}
for (var newTableBody = document.createElement("tbody"), i = 0, len = arrayOfRows.length; len > i; i++)
newTableBody.appendChild(rows[arrayOfRows[i].oldIndex].cloneNode(!0));
table.replaceChild(newTableBody, tbody), function() {
$(".contentRows").mouseover(function() {
$(this).css("background-color", "#f6f2ed"), $(this).find("td:first-child").children("div").removeClass("vh")
}).mouseout(function() {
$(this).css("background-color", "#ffffff"), $(".contentRows td:first-child").children("div").addClass("vh")
})
}()
}, CFSchedulerJSObject.CompareRowOfText = function(a, b) {
var aval = a.value,
bval = b.value;
return aval == bval ? 0 : aval > bval ? 1 : -1
}, CFSchedulerJSObject.CompareRowOfNumbers = function(a, b) {
var aval = /\d/.test(a.value) ? parseFloat(a.value) : 0,
bval = /\d/.test(b.value) ? parseFloat(b.value) : 0;
return aval == bval ? 0 : aval > bval ? 1 : -1
}, CFSchedulerJSObject.myFilter = function() {
$("tr").show();
var schTimeElem = $("#SchTimeList");
$("#table-2").find("tr").not(":first").each(function() {
if ($("#SchNameList option:selected").text() != I18n.getMsg("crm.cfs.select.allsch") && $.trim($(this).find("td.failureName").text()).toLowerCase() != $("#SchNameList option:selected").text().toLowerCase() && $(this).hide(), "1" == schTimeElem.val()) {
var d = new Date;
d.setHours(0, 0, 0, 0), $.trim(Number($(this).find("td.failureTime").text())) < d.getTime() && $(this).hide()
} else if ("2" == schTimeElem.val()) {
var d = new Date;
d.setHours(0, 0, 0, 0), $.trim(Number($(this).find("td.failureTime").text())) > d.getTime() && $(this).hide(), d.setDate(d.getDate() - 1), $.trim(Number($(this).find("td.failureTime").text())) < d.getTime() && $(this).hide()
} else if ("3" == schTimeElem.val()) {
var d = new Date;
d.setDate(d.getDate() - 7), d.setHours(0, 0, 0, 0), $.trim(Number($(this).find("td.failureTime").text())) < d.getTime() && $(this).hide()
} else if ("4" == schTimeElem.val()) {
var d = new Date;
d.setDate(d.getDate() - 30), d.setHours(0, 0, 0, 0), $.trim(Number($(this).find("td.failureTime").text())) < d.getTime() && $(this).hide()
} else if ("custom" == schTimeElem.val())
if ("" == $("#cusDateFrom").val() || "" == $("#cusDateTo").val())
$(this).hide();
else {
var schDateObj = crmCalendar.getDateObjectFromGivenDateString($("#cusDateFrom").val()),
myDate = Utils.convertUsrtoDefaultDatePattern(schDateObj),
cusDate = $.datepicker.formatDate("mm/dd/yy", myDate),
d1 = new Date(Date.parse(cusDate));
schDateObj = crmCalendar.getDateObjectFromGivenDateString($("#cusDateTo").val()), myDate = Utils.convertUsrtoDefaultDatePattern(schDateObj), cusDate = $.datepicker.formatDate("mm/dd/yy", myDate);
var d2 = new Date(Date.parse(cusDate));
d2.setHours(23, 59, 59, 999), $.trim(Number($(this).find("td.failureTime").text())) < d1.getTime() && $(this).hide(), $.trim(Number($(this).find("td.failureTime").text())) > d2.getTime() && $(this).hide()
}
})
};
var time = 1e4,
TIMEOUT_CLEAR;
$(function() {
$("body").on("keyup keydown blur", ".textareachk", function() {
var elem = $(this),
data = elem.attr("data-textarea"),
value = elem.val();
value = void 0 != value ? value.trim() : "";
var valLen = value.length;
if (elem.removeAttr("placeholder"), void 0 != data && null != data && "" != data) {
"string" == typeof data && (data = JSON.parse(data));
var pastediv = $(data.pastediv);
(void 0 == pastediv || null == pastediv || 0 == pastediv.length) && (pastediv = $(this));
var errormaxClass = void 0 != data.errormaxclass ? data.errormaxclass : "error-msg cB ml160",
errorminClass = void 0 != data.errorminclass ? data.errorminclass : "error-msg cB ml160",
insertMethod = data.method,
maxLength = parseInt(data.maxlength),
minLength = parseInt(data.minlength),
remainingCount = parseInt(maxLength) - parseInt(valLen),
minCount = parseInt(maxLength - minLength),
errormaxContent = void 0 != data.errormaxcontent ? data.errormaxcontent : I18n.getMsg("crm.label.error.maxchar", [remainingCount]),
errorminContent = void 0 != data.errormincontent ? data.errormincontent : I18n.getMsg("crm.label.error.minchar", [remainingCount]),
disableBtn = data.disablebtn,
disableElem = $("#" + disableBtn);
if (0 != disableElem.length && disableElem.removeClass("btn-disable"), $("#maxerrordiv").remove(), valLen >= maxLength) {
if (pastediv) {
var errorElem = Utils.createHTML({
name: "span",
attr: {
"class": errormaxClass,
id: "maxerrordiv"
},
html: errormaxContent
});
insertMethod ? "before" == insertMethod ? pastediv.before(errorElem) : "append" == insertMethod ? pastediv.append(errorElem) : pastediv.after(errorElem) : pastediv.after(errorElem), 0 != disableElem.length && disableElem.addClass("btn-disable");
var newVal = value.substring(0, maxLength);
elem.val(newVal)
}
} else if (valLen > minCount && pastediv) {
var errorElem = Utils.createHTML({
name: "span",
attr: {
"class": errorminClass,
id: "maxerrordiv"
},
html: errorminContent
});
insertMethod ? "before" == insertMethod ? pastediv.before(errorElem) : "append" == insertMethod ? pastediv.append(errorElem) : pastediv.after(errorElem) : pastediv.after(errorElem)
}
}
}).on("click", "#listViewTable.listview tr", function(e) {
var stopEvent = !1;
if ($(e.target).is("td") || $(e.target).is("a") && $(e.target).hasClass("lookupColName")) {
if ($(e.target).is("td") && !$(e.target).closest("tr").attr("data-cid")) {
var tr = $(e.target).closest("tr"),
entityId = tr.attr("id"),
params = tr.data("params"),
module = params && params.hasOwnProperty("module") ? params.module : crmTab.selectedTab,
assoJOId = params && params.hasOwnProperty("assoJOId") ? params.assoJOId : void 0;
entityId && "listviewHeaderRow" !== entityId && ZRCommonUtil.getDetailView(entityId, module, !0, assoJOId), stopEvent = !0
} else if ($(e.target).is("a") && $(e.target).hasClass("lookupColName") && !$(e.target).attr("data-cid")) {
var params = $(e.target).data("params"),
module = params && params.hasOwnProperty("module") ? params.module : crmTab.selectedTab,
tr = $(e.target).closest("tr"),
assoJOId = void 0;
if ("Leads" === module) {
var newParams = tr.data("params");
assoJOId = newParams && newParams.hasOwnProperty("assoJOId") ? newParams.assoJOId : void 0
}
params.module.startsWith("CustomModule") ? ZRCommonUtil.getDetailView($(e.target).closest("tr").attr("id"), module) : ZRCommonUtil.getDetailView(params.entityId, module, !0, assoJOId), stopEvent = !0
}
stopEvent === !0 && sE(e)
}
}).on("click", "#jobPipelines #pipeline-jobstage,#jobPipelines #count-anchor,#jobPipelines #pipeline-arrow", function(event) {
sE(event);
var $tgt = $(event.target);
$tgt = $tgt.hasClass("pipeline-jobstage") ? $tgt : $tgt.closest(".pipeline-jobstage"), CrmDashboard.filterStageforPPWidget(event, $tgt)
}).on("click", "#showHideSearchCriteria", function() {
ZRCommonUtil.showHideSearchCriteria(), $(this).hide()
}).on("click", "#gsearchicon", function() {
ajaxGSearch("gsearchTextBox")
}).on("click", "#AttachPermDiv", function() {
ZRCommonUtil.delegateClickEventForAttachPerm(event)
}).on("change", "#AttachPermDiv", function(event) {
ZRCommonUtil.delegateChangeEventForAttachPerm(event)
}).on("click", ".expand-jbpipeline", function(event) {
sE(event), $(event.target).hasClass("expand") ? CrmDashboard.expandCollapseWidget("expand") : $(event.target).hasClass("expanded") && CrmDashboard.expandCollapseWidget("collapse")
}).on("click", ".expand-reports", function(event) {
sE(event);
var id = $(event.target).attr("id");
id = id.slice(id.indexOf("_") + 1), $(event.target).hasClass("expand") ? CrmDashboard.expandCollapseWidget("expand", id) : $(event.target).hasClass("expanded") && CrmDashboard.expandCollapseWidget("collapse", id)
}).on("click", "#sSearch", function() {
ZRCommonUtil.showHideSearchPopOver($(this))
}), $("#simpleGlobalSearch").click(function() {
ZRCommonUtil.searchFromBar()
}), $(".searchPopOver").click(function() {
event.stopPropagation()
}), $("#clearsearchtext").click(function() {
$("#gsearchTextBox").val("")
}), $(".cande").click(function() {
if (zctt.hidett(!0), "TAB" == ZRCommonUtil.SEARCHDEFAULT.trim()) {
var status = ZRCommonUtil.setDefaultSearchBarModule("Candidates"),
msg = "",
params = {};
"success" == status ? ($(this).addClass("act"), msg = I18n.getMsg("zr.search.bar.default.success.candidate"), params = {
type: "success-modal",
boldMsg: "",
msg: msg,
display: "pop",
duration: 5e3
}) : (msg = I18n.getMsg("zr.candidatereview.approveerror"), params = {
type: "failure-modal",
boldMsg: "",
msg: msg,
display: "pop",
duration: 3e3
}), ZRComponent.openAlertMessage(params)
} else {
var status = ZRCommonUtil.setDefaultSearchBarModule("TAB"),
msg = "",
params = {};
"success" == status ? ($(this).removeClass("act"), msg = I18n.getMsg("zr.search.bar.default.success.tab"), params = {
type: "success-modal",
boldMsg: "",
msg: msg,
display: "pop",
duration: 5e3
}) : (msg = I18n.getMsg("zr.candidatereview.approveerror"), params = {
type: "failure-modal",
boldMsg: "",
msg: msg,
display: "pop",
duration: 3e3
}), ZRComponent.openAlertMessage(params)
}
}).mouseover(function() {
ZRCommonUtil.SEARCHDEFAULT && "TAB" == ZRCommonUtil.SEARCHDEFAULT.trim() ? zctt.showtt(I18n.getMsg("zr.search.bar.default.success.tooltip.candidate"), void 0, void 0, void 0, void 0, "searchPopOverToolTip") : zctt.showtt(I18n.getMsg("zr.search.bar.default.success.tooltip.tab"), void 0, void 0, void 0, void 0, "searchPopOverToolTip")
}).mouseout(function() {
zctt.hidett(!0)
})
});
var ZRCommonUtil = {
ZCMODULEMAP: {
Leads: "Candidates",
Potentials: "Job Openings",
Accounts: "Clients",
Contacts: "Contacts",
Products: "Interviews",
Lead: "Candidate",
Potential: "Job Opening",
Account: "Client",
Contact: "Contact",
Product: "Interview",
Questionnaires: "Assessments"
},
ZRMODULEMAP: {
Candidates: "Leads",
JobOpenings: "Potentials",
Interviews: "Products",
Clients: "Accounts",
"Job Openings": "Potentials",
Assessments: "Questionnaires"
},
ISSOCIALNOTIFIED: !1,
ZRRECRUITURLS: ["/recruit/ResumeInboxSettings.do"],
ZRRECRUITERRORHANDLEDURLS: ["/recruit/GetJOList.do", "/recruit/GetQVInfo.do"],
SOURCESFORCLOUDPICKER: "zohodocs,gdrive,box,skydrive,dropbox,evernote",
NONEDITABLEPROFILE: ["Client Administrator", "Client Interviewer"],
isStaffingType: !0,
FILTERRECORDS: "",
FILTERJOBID: "",
FILTERJOBNAME: "",
FILTERCANDSTATUS: "",
CURRMODULE: "",
docsUrl: "",
SEARCHDEFAULT: void 0,
fromClientNavigation: !1,
showClientNavCtrls: !1,
init: function(type) {
1 == type && (ZRCommonUtil.ZCMODULEMAP.Accounts = "Departments", ZRCommonUtil.ZRMODULEMAP.Departments = "Accounts", ZRCommonUtil.isStaffingType = !1);
var template = Handlebars.getTemplate("common", "simpleSearchContainer");
$("#newSearchContainer").append(template()), isClientUser || ZRSimpleSearch.init()
},
isCVUsedInFeatures: function(cvid, module) {
var target = "false";
return "Leads|Candidiates|Accounts|Potentials|Contacts".indexOf(module) < 0 ? target : (ZRCommonUtil.ajaxGetMethod("/recruit/CheckBeforeCustomViewDelete.do?cvid=" + cvid + "&module=" + module, void 0, !1, "json", void 0, function(json) {
if (json = ZRCommonUtil.convertStringToJson(json), target = "true" == json.check ? "true" : target, "true" == target) {
var htmlBody = document.createDocumentFragment(),
errCount = 0,
liElem = document.createDocumentFragment();
$.each(json.schNames, function(index, element) {
liElem.appendChild(Utils.createHTML({
name: "li",
child: [{
name: "span"
}],
html: $ESAPI.encoder().encodeForHTML(element)
}))
});
var createElem = Utils.createHTML({
name: "div",
attr: {
"class": "f13 mB20 mT20"
},
child: [{
name: "div",
child: [{
name: "label",
html: I18n.getMsg("crm.label.scheduler.deletecustomviewmessage") + ":"
}, {
name: "ul",
attr: {
"class": "points"
}
}, {
name: "label",
html: I18n.getMsg("crm.label.scheduler.redirect")
}]
}]
});
$(createElem).find(".points").html(liElem), json.schNames.length > 0 && (htmlBody.appendChild(createElem), errCount++), liElem = document.createDocumentFragment(), $.each(json.arNames, function(index, element) {
liElem.appendChild(Utils.createHTML({
name: "li",
child: [{
name: "span"
}],
html: $ESAPI.encoder().encodeForHTML(element)
}))
});
var createElem1 = Utils.createHTML({
name: "div",
attr: {
"class": "f13 mB20 mT20"
},
child: [{
name: "div",
child: [{
name: "br"
}, {
name: "label",
html: I18n.getMsg("crm.label.autoresponder.deletecustomviewmessage") + ":"
}, {
name: "ul",
attr: {
"class": "points"
}
}, {
name: "label",
html: I18n.getMsg("crm.label.autoresponder.redirect")
}]
}]
});
$(createElem1).find(".points").html(liElem), json.arNames.length > 0 && (errCount > 0 && $(createElem1).prepend(Utils.createHTML({
name: "label",
html: "................................................................................................................................................"
})), htmlBody.appendChild(createElem1), errCount++), liElem = document.createDocumentFragment(), $.each(json.crmSync, function(index, element) {
liElem.appendChild(Utils.createHTML({
name: "li",
child: [{
name: "span"
}],
html: $ESAPI.encoder().encodeForHTML(element)
}))
});
var createElem2 = Utils.createHTML({
name: "div",
attr: {
"class": "f13 mB20 mT20"
},
child: [{
name: "div",
child: [{
name: "br"
}, {
name: "label",
html: I18n.getMsg("crm.sync.setting.crm.cv.delete.ass") + ":"
}, {
name: "ul",
attr: {
"class": "points"
}
}, {
name: "label",
html: I18n.getMsg("crm.sync.setting.crm.cv.redirect")
}]
}]
});
$(createElem2).find(".points").html(liElem), json.crmSync.length > 0 && (errCount > 0 && $(createElem2).prepend(Utils.createHTML({
name: "label",
html: "................................................................................................................................................"
})), htmlBody.appendChild(createElem2)), $("#combo").css("zIndex", "10"), ZRCommonUtil.createInfoBox({
modalclass: "w550",
titleclass: "til warning",
title: I18n.getMsg("crm.delete.error"),
content: htmlBody,
savebtn: I18n.getMsg("crm.button.ok")
}), $("input").focus()
}
}, function() {}), target)
},
zcModChangeUrl: function(url) {
return url && (url.indexOf("=Candidates") > -1 && (url = url.replace("=Candidates", "=Leads")), url.indexOf("=JobOpenings") > -1 && (url = url.replace("=JobOpenings", "=Potentials")), url.indexOf("=Interviews") > -1 && (url = url.replace("=Interviews", "=Products")), url.indexOf("=Clients") > -1 && (url = url.replace("=Clients", "=Accounts")), url.indexOf("=Assessments") > -1 && (url = url.replace("=Assessments", "=Questionnaires")), url.indexOf("=Departments") > -1 && (url = url.replace("=Departments", "=Accounts"))), url
},
zrModChangeUrl: function(url) {
if (url && (url.indexOf("=Leads") > -1 && (url = url.replace("=Leads", "=Candidates")), url.indexOf("=Potentials") > -1 && (url = url.replace("=Potentials", "=JobOpenings")), url.indexOf("=Products") > -1 && (url = url.replace("=Products", "=Interviews")), url.indexOf("=Questionnaires") > -1 && (url = url.replace("=Questionnaires", "=Assessments")), url.indexOf("=Accounts") > -1)) {
var replaceStr = "=" + ZRCommonUtil.ZCMODULEMAP.Accounts;
url = url.replace("=Accounts", replaceStr)
}
return url
},
ajaxUpload: function(url, urlData, callbacks, dataType, synchronous, singleUpload) {
$("#ajax_load_tab").show(), singleUpload = void 0 != singleUpload && null != singleUpload ? singleUpload : !1;
for (i in dropFiles) {
var k = 0;
if (dropFiles[i])
for (var j = 0; j < dropFiles[i].length; j++)
dropFiles[i][j] && (urlData[i][k] = dropFiles[i][j], k += 1)
}
var tempCallBacks = {
success: function(data) {
Utils.showHideLoadingDiv(!1), dropFiles = {}, callbacks.success(data)
},
fail: function(data) {
Utils.showHideLoadingDiv(!1), callbacks.fail(data)
}
};
$.ajaxUpload(url, urlData, tempCallBacks, dataType, synchronous, singleUpload)
},
ajaxFormSubmit: function(url, urlData, docForm, module, singleUpload, callBackFns) {
var params = ZRCommonUtil.formData2Query(docForm, urlData, module, singleUpload),
queryParams = formData2QueryString(docForm, module),
args = "";
void 0 != queryParams ? (args = queryParams, args += "&newModel=true") : args = "newModel=true";
var postData = Utils.splitStringToObj(args);
void 0 != module && (url = url + "?module=" + module);
var callbacks = {};
callBackFns && callBackFns.success && callBackFns.fail ? (callbacks.success = callBackFns.success, callbacks.fail = callBackFns.fail) : (callbacks.success = function(data) {
$("#ajax_load_tab").hide(), successCallback(data, url, module, args, void 0, void 0, void 0, postData)
}, callbacks.fail = function() {
$("#ajax_load_tab").hide(), alert(I18n.getMsg("crm.security.error.add.user"))
}), singleUpload = void 0 != singleUpload && null != singleUpload ? singleUpload : !1, ZRCommonUtil.ajaxUpload(url, params, callbacks, "html", !1, singleUpload)
},
formFile2Query: function(formName, data) {
(void 0 == data || null == data) && (data = {});
var inputElem = $("form[name=" + formName + "]").find("input[type=file]");
if ("parserReview" === data.isPRView || "resumeinboxPreview" === data.isPRView)
var inputElem = $("#secDiv_Attachment_Information").find("input[type=file]");
return $.each(inputElem, function(i, item) {
for (var elem = $(item), name = elem[0].name, fileArr = data.hasOwnProperty(name) ? data[name] : [], el = 0; el < elem.length; el++)
fileArr.push(elem[el]);
data[name] = fileArr
}), data
},
formData2Query: function(docForm, data, module) {
(void 0 == data || null == data) && (data = {}), data[csrfParamName] = encodeURIComponent(csrfToken), data.newModel = "true";
var formElem,
labelchk = "Home";
void 0 != module && (labelchk = module.toUpperCase().substring(0, module.length - 1) + "CF");
var frSettingsForm = void 0 !== docForm.frSettingsForm,
re = new RegExp("^" + labelchk),
re1 = new RegExp("^comboValue"),
tabularRe = new RegExp("^TF_[0-9]{7,21}|^Tabular_[0-9]{7,21}$");
for (i = 0; i < docForm.elements.length; i++) {
formElem = docForm.elements[i];
var formName = formElem.name,
formValue = formElem.value,
ifCondnChkvar = "module" != formName && "gsitesList" != formName && "gsitesName" != formName && "isShareGsite" != formName && "fieldname" != formName && "dateFields" != formName && "fieldlabel" != formName && "fielddatatype" != formName && "picklistFields" != formName && "fieldvalues" != formName && "mapValues" != formName && "fieldName" != formName && "fieldLabel" != formName && "fieldDatatype" != formName && "fieldUitype" != formName && "fieldId" != formName && "fieldTableName" != formName && "fieldLen" != formName && "dtPtn" != formName && "hdnRowStatus1" != formName && "focusid" != formName && formName.indexOf("uiType_") < 0 && "" != formName && "radiobtn" != formName;
if (void 0 != module && (ifCondnChkvar = "gsitesList" != formName && "gsitesName" != formName && "isShareGsite" != formName && "fieldname" != formName && "dateFields" != formName && "fieldlabel" != formName && "fielddatatype" != formName && "picklistFields" != formName && "fieldvalues" != formName && "mapValues" != formName && "fieldName" != formName && "fieldLabel" != formName && "fieldDatatype" != formName && "fieldUitype" != formName && "fieldId" != formName && "fieldTableName" != formName && "fieldLen" != formName && "dtPtn" != formName && "hdnRowStatus1" != formName && "focusid" != formName && formName.indexOf("uiType_") < 0 && !re.test(formName) && !re1.test(formName) && !tabularRe.test(formName) && "" != formName), ifCondnChkvar || frSettingsForm)
switch (formElem.type) {
case "text":
case "select-one":
case "password":
case "textarea":
data[formName] = trimBoth(formValue);
break;
case "hidden":
data[formName] = formValue;
break;
case "checkbox":
case "radio":
formElem.checked && (data[formName] = "zloginForm" == docForm.name ? encodeURIComponent(formValue) : formValue);
break;
case "file":
for (var currObj = getObj(formName), elem = $(currObj), fileArr = [], el = 0; el < elem.length; el++)
fileArr.push(elem[el]);
data[formName] = fileArr
}
}
if (frSettingsForm) {
var lyteDropDownElements = document.frGlobalSettingsForm.getElementsByTagName("lyte-dropdown");
for (i = 0; i < lyteDropDownElements.length; i++)
data[lyteDropDownElements[i].getAttribute("lt-prop-name")] = lyteDropDownElements[i].ltProp("selected")
}
return data
},
ajaxGetMethod: function(urlval, dataval, asyncval, datatype, pastediv, successFunc, failureFunc, showLoading, completeFunc) {
showLoading = void 0 != showLoading ? showLoading : !0, showLoading && $("#ajax_load_tab").show(), $.ajax({
type: "GET",
url: urlval,
dataType: datatype,
data: dataval,
async: asyncval,
complete: completeFunc,
success: function(data) {
$("#ajax_load_tab").hide(), successFunc(data, pastediv)
},
error: function(xhr) {
$("#ajax_load_tab").hide(), xhr.status !== crmConstants.errorStatusCode && failureFunc && failureFunc(xhr, pastediv)
}
})
},
ajaxPostMethod: function(urlval, dataval, asyncval, datatype, pastediv, successFunc, failureFunc, sendPlainData, requesttimeout) {
var csrf_Token = ZRCommonUtil.getCookieValue("crmcsr");
1 == sendPlainData ? dataval = dataval + "&" + csrfParamName + "=" + csrfToken : (dataval = ZRCommonUtil.convertStringToJson(dataval), csrf_Token && null != csrf_Token && (dataval[csrfParamName] = csrf_Token));
var prevLoadImg = dataval && dataval.prevLoadImg ? dataval.prevLoadImg : !1;
prevLoadImg || Utils.showHideLoadingDiv(!0), $.ajax({
type: "POST",
url: urlval,
dataType: datatype,
timeout: requesttimeout ? requesttimeout : 0,
data: dataval,
async: asyncval,
success: function(data) {
Utils.showHideLoadingDiv(!1), successFunc(data, pastediv)
},
error: function(xhr) {
Utils.showHideLoadingDiv(!1), xhr.status !== crmConstants.errorStatusCode && failureFunc && failureFunc(xhr, pastediv)
}
})
},
successFunction: function(data, pastediv) {
pastediv && pastediv.hide().html(data).show()
},
failureFunction: function(xhr, pastediv) {
var data = xhr.responseText,
json = ZRCommonUtil.convertStringToJson(data);
json && json.message && ("failure" === json.message ? data = I18n.getMsg("crm.security.error.add.user") : "iamerror" === json.message && (data = ZRCommonUtil.iamErrorMessage(json.errorObj))), pastediv ? pastediv.hide().html(data).show() : alert(data)
},
iamErrorMessage: function(json) {
var errorMessage = I18n.getMsg("crm.unable.to.process.request"),
errorCode = json.errorCode ? json.errorCode : json.errorObj ? json.errorObj.errorCode : void 0,
maxLen = json.maxLen;
return errorMessage = "XSS_DETECTED" === errorCode || "UNABLE_TO_PARSE_DATA_TYPE" === errorCode || "EXTRA_PARAM_FOUND" === errorCode || "MORE_THAN_MAX_OCCURANCE" === errorCode || "LESS_THAN_MIN_OCCURANCE" === errorCode ? I18n.getMsg("crm.iam.error.xssdetected") : "MORE_THAN_MAX_LENGTH" === errorCode ? I18n.getMsg("crm.iam.error.morethanmaxlength", [maxLen]) : I18n.getMsg("URL_RULE_NOT_CONFIGURED" === errorCode || "URL_ACTION_PARAM_MISSING" === errorCode || "INVALID_METHOD" === errorCode ? "crm.label.error.message1" : "FILE_SIZE_MORE_THAN_ALLOWED_SIZE" === errorCode ? "zats.error.filesizeismore" : "PATTERN_NOT_MATCHED" === errorCode ? "crm.alert.label.special.characters" : "POST_ONLY_URL" === errorCode ? "crm.unable.to.process.request" : "LESS_THAN_MIN_LENGTH" === errorCode ? "crm.iam.error.lessthanminlength" : "UNMATCHED_FILE_CONTENT_TYPE" === errorCode ? "crm.label.invalid.attach.alert" : "REMOTE_IP_LOCKED" === errorCode || "URL_ROLLING_THROTTLES_LIMIT_EXCEEDED" === errorCode ? "zr.qv.threshold.reached" : "crm.unable.to.process.request")
},
getCookieValue: function(cookieName) {
for (var cookieStr = document.cookie.split(";"), i = 0; i < cookieStr.length; i++) {
var cName = cookieStr[i].split("=");
if (cookieName.trim() == cName[0].trim())
return encodeURIComponent(cName[1])
}
return null
},
fetchScrollData: function(elem) {
elem && 0 != elem.length && elem.filter(":visible") && elem.unbind("scroll").bind("scroll", function() {
var $this = $(this),
data = $this.data("scrolldata");
data = data ? data : {}, data && "string" == typeof data && (data = JSON.parse(data));
var height = this.scrollHeight - $this.height(),
scroll = $this.scrollTop(),
isScrolledToEnd = scroll >= .8 * height;
if (isScrolledToEnd || (data.shownext = "true"), isScrolledToEnd && data && data.shownext && "true" === data.shownext) {
var callee = data.callee;
if (data.id && data.mode && "filterJobList" === data.mode && $("#loadingimg-" + data.id).show(), void 0 != callee) {
var func = "loadMoreData",
loadVar = "ISLOADMORE",
calleeObj = callee.split(".");
2 == calleeObj.length ? (callee = calleeObj[0], func = calleeObj[1]) : 3 == calleeObj.length ? (callee = calleeObj[0], func = calleeObj[1], loadVar = calleeObj[2]) : (callee = data.callee, func = "loadMoreData", loadVar = "ISLOADMORE"), window[callee][loadVar] || (data.isAppend = "true", data.action = "more", window[callee][loadVar] = !0, window[callee][func](data, function() {
window[callee][loadVar] = !1
}))
} else
void 0 != data.customfn && window[data.customfn].apply(this)
}
data && data.id && data.mode && "filterJobList" === data.mode && $("#loadingimg-" + data.id).attr("style", "display:none !important")
})
},
windowScrollData: function(elem) {
elem && 0 !== elem.length && $(window).unbind("scroll").bind("scroll", function() {
if ($(window).scrollTop() + $(window).height() >= $(document).height() - 50) {
var data = elem.data("scrolldata");
data = data ? data : {}, data && "string" == typeof data && (data = JSON.parse(data)), data && data.shownext && "true" === data.shownext && window[data.callee] && !window[data.callee].ISLOADMORE ? (data.isAppend = "true", data.action = "more", window[data.callee].ISLOADMORE = !0, window[data.callee].loadMoreData(data, function() {
window[data.callee].ISLOADMORE = !1
})) : data && data.shownext && "true" === data.shownext && data.customfn && window[data.customfn].apply(this)
}
})
},
autoComplete: function(target, dataVal) {
target.find(".ac-block").remove();
var autoPopUpFun,
autopopFun = function(ev, tgt) {
var params = $(tgt).data("lookup"),
currObj = getObj(params.fldName),
fldId = params.fldId,
id = fldId;
if (fldId.indexOf("property(") > -1)
try {
var prop_pattern = /property\([a-z]+\:(.*[^)])+/i;
id = fldId.match(prop_pattern)[1].replace(/[^a-z]/gi, "")
} catch (e) {
id = (new Date).getTime()
}
var winName = "Lookup" + id,
url = "/recruit/Search.do?searchmodule=" + params.searchmodule + "&fldName=" + params.fldName + "&fldId=" + params.fldId + "&fldLabel=" + params.fldLabel;
params.fldValue && (url = url + "&fldValue=" + params.fldValue), params.module && (url = url + "&module=" + params.module), params.potentialid && (url = url + "&potentialId=" + params.potentialid), params.productid && (url = url + "&productId=" + params.productid), params.leadid && (url = url + "&leadId=" + params.leadid), params.productId && (url = url + "&productId=" + params.productId), params.potentialName && (url = url + "&potentialName=" + params.potentialName), openPopUp("lookUpWin", currObj, url, winName, 900, 400, "menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes")
},
classStr = void 0 != dataVal.classStr ? dataVal.classStr : "w200",
blockClass = void 0 != dataVal.blockClass ? "ac-block " + dataVal.blockClass : "ac-block",
inputid = dataVal.inputid,
inputname = void 0 != dataVal.inputname ? dataVal.inputname : dataVal.inputid,
hiddenid = void 0 != dataVal.hiddenid ? dataVal.hiddenid : dataVal.inputid + "-hidden",
emptyId = dataVal.inputid + "-message",
hiddenname = void 0 != dataVal.hiddenname ? dataVal.hiddenname : hiddenid,
emptyMsg = void 0 != dataVal.emptymsg ? dataVal.emptymsg : I18n.getMsg("crm.potential.addnote.emptymessage"),
clearFun = function(ev, tgt, id, hidden, empty) {
dataVal.clearFun && (ZRCommonUtil.toggleClearLookupfield(!1, $(this)), dataVal.clearFun(ev, tgt, id, hidden));
var selectedId = $("#" + id);
if (selectedId.val("").data("selecteditem", ""), $("#" + hidden).val(""), $("#" + empty).html("").hide(), ZRCommonUtil.toggleClearLookupfield(!1, $("#" + id)), "true" == newUI) {
var managerULElem = $("#divmanager");
$("#" + id + "_clear_lookupfield").hide(), $("#span-" + hidden).text(""), $("#compose-jobopening #ul-sesc-entered").hide(), $("#" + inputid + "-err").hide();
var parentId = $(target).get(0).id;
if ($("#" + parentId).removeClass("zrc-error-field"), selectedId.show(), selectedId.focus(), selectedId.data("id", ""), "compose-jobopening-list" == id) {
var contacts = $("ul#toAddrDetails"),
value = $("#compose-client-list-hidden").val();
void 0 !== value && null !== value && 0 !== value.length && void 0 != contacts && ($("#toAddrDetails li").remove(), $("#compose-contacts").hide(), $("#chkAllContacts").hide())
}
managerULElem.length && ($("#compose-manager-id").val(""), managerULElem.empty())
}
},
dataId = "",
dataCID = "",
dataLabel = "",
lookupModule = "",
dataModule = "",
datazcqa = "",
dataproductId = "",
dataleadId = "",
datapotentialId = "",
datapotentialName = "",
newUI = "";
if (void 0 != dataVal && void 0 != dataVal.lookup) {
autoPopUpFun = "";
var lookup = dataVal.lookup;
void 0 != lookup.from && "changeStatus" == lookup.from && (autoPopUpFun = [{
name: "click",
fn: function(event) {
crmTemplate.showLookup(event)
}
}]), dataId = lookup.dataId ? lookup.dataId : "", dataCID = lookup.dataCID ? lookup.dataCID : "", dataLabel = lookup.label ? lookup.label : "", lookupModule = lookup.lookupModule ? lookup.lookupModule : "", dataModule = lookup.module ? lookup.module : "";
var placeholder = lookup.placeholder ? lookup.placeholder : I18n.getMsg("crm.label.search");
datazcqa = lookup.zcqa ? lookup.zcqa : "", dataproductId = lookup.productId ? lookup.productId : "", dataleadId = lookup.leadid ? lookup.leadid : "", datapotentialId = lookup.potentialid ? lookup.potentialid : "", datapotentialName = lookup.potentialName ? lookup.potentialName : "", newUI = lookup.newUI ? lookup.newUI : ""
} else
autoPopUpFun = [{
name: "click",
fn: autopopFun
}], dataCID = "";
var errorClass = "cl fL f11",
fromArray = ["NotesRL", "subToClient", "ClientJO", "changeStatus"];
void 0 != lookup.from && -1 !== $.inArray(lookup.from, fromArray) && (errorClass = "fL f11 marT5 cB posR ac-error");
var dataColname = void 0 != dataVal && void 0 != dataVal.inputData ? dataVal.inputData.dataColname : "",
searchMod = lookupModule;
"AssCand" == searchMod ? searchMod = "Leads" : ("AssJob" == searchMod || "ClientPot" == searchMod) && (searchMod = "Potentials");
var triggerLookup = !0;
if (void 0 != lookup.triggerLookup && (triggerLookup = lookup.triggerLookup), "true" == newUI) {
target.find(".zrc-value").remove();
var divElem = {
name: "div",
attr: {
"class": "zrc-value"
},
child: []
},
textboxElem = {
name: "input",
attr: {
type: "text",
"class": classStr,
id: inputid,
name: inputname,
"data-colname": dataColname,
onfocus: "ZRMailUtil.addFocusElem('" + inputid + "','true')",
onblur: "ZRMailUtil.addFocusElem('" + inputid + "','false')",
placeholder: placeholder
}
};
divElem.child.push(textboxElem);
var hiddenElem = {
name: "input",
attr: {
type: "hidden",
id: hiddenid,
name: hiddenname
}
};
divElem.child.push(hiddenElem);
var error_elem = {
name: "span",
attr: {
"class": "zrc-errMsg",
id: inputid + "-err",
style: "display:none"
},
html: I18n.getMsg("crm.social.search.noData")
};
divElem.child.push(error_elem);
var divElem_Img = {
name: "div",
attr: {
"class": "sesc-right bot5"
},
child: []
};
if (void 0 != lookup.from && "jobTemplates" == lookup.from)
var imgelem = {
name: "img",
attr: {
style: "width: 17px; height: 19px",
src: crmConstants.imgStaticPath + "/spacer.gif",
"class": "Accounts-small fR mR5 hIconO",
border: "0",
"data-lookup": JSON.stringify(dataVal.lookup),
id: dataId,
"data-cid": dataCID,
"data-label": dataLabel,
"data-lookup-module": lookupModule,
"data-module": dataModule,
"data-zcqa": datazcqa + dataCID,
"data-productId": dataproductId,
"data-leadid": dataleadId,
"data-potentialid": datapotentialId,
"data-potentialName": datapotentialName
},
events: autoPopUpFun
};
else
var imgelem = {
name: "img",
attr: {
src: crmConstants.imgStaticPath + "/spacer.gif",
"class": "fetchClientJo" === dataVal.params.mode || "fetchJoList" === dataVal.params.mode ? "Potentials-small wid20 hei16 opaP5 verAB" : "fetchClientList" === dataVal.params.mode ? "Accounts-small wid20 hei16 opaP5 verAB" : "OwnerNameLookup changeUserIcon",
border: "0",
"data-lookup": JSON.stringify(dataVal.lookup),
id: dataId,
"data-cid": dataCID,
"data-label": dataLabel,
"data-lookup-module": lookupModule,
"data-module": dataModule,
"data-zcqa": datazcqa + dataCID,
"data-productId": dataproductId,
"data-leadid": dataleadId,
"data-potentialid": datapotentialId,
"data-potentialName": datapotentialName
},
events: autoPopUpFun
};
if (dataVal.params && void 0 != dataVal.params.mode && "fetchJoList" === dataVal.params.mode)
var clearlookup = {
name: "img",
attr: {
src: crmConstants.imgStaticPath + "/spacer.gif",
"class": "clear_lookupfield verAT disIB marR8",
border: "0",
id: inputid + "_clear_lookupfield",
style: "display:none;"
},
events: [{
name: "click",
fn: clearFun,
args: [inputid, hiddenid, emptyId]
}]
};
else
var clearlookup = {
name: "img",
attr: {
src: crmConstants.imgStaticPath + "/spacer.gif",
"class": "fetchClientJo" === dataVal.params.mode ? "clear_lookupfield verAT marR10" : "clear_lookupfield",
border: "0",
id: inputid + "_clear_lookupfield",
style: "display:none;"
},
events: [{
name: "click",
fn: clearFun,
args: [inputid, hiddenid, emptyId]
}]
};
!dataVal.params || void 0 == dataVal.params.mode || "fetchClientJo" !== dataVal.params.mode && "fetchJoList" !== dataVal.params.mode && "fetchClientList" !== dataVal.params.mode ? (divElem_Img.child.push(imgelem), divElem_Img.child.push(clearlookup)) : (divElem_Img.child.push(clearlookup), divElem_Img.child.push(imgelem)), divElem.child.push(divElem_Img);
var createElem = Utils.createHTML(divElem)
} else
var createElem = Utils.createHTML({
name: "div",
attr: {
"class": blockClass
},
child: [{
name: "input",
attr: {
type: "text",
"class": classStr,
id: inputid,
name: inputname,
"data-colname": dataColname,
placeholder: placeholder
}
}, {
name: "input",
attr: {
type: "hidden",
id: hiddenid,
name: hiddenname
}
}, {
name: "img",
attr: {
src: crmConstants.imgStaticPath + "/spacer.gif",
"class": "clear_lookupfield cls",
border: "0",
style: "display:none"
},
events: [{
name: "click",
fn: clearFun,
args: [inputid, hiddenid, emptyId]
}]
}, {
name: "img",
attr: {
src: crmConstants.imgStaticPath + "/spacer.gif",
"class": "Potentials" === searchMod ? "Potentials-small lkup" : "Leads" === searchMod ? "changeUserIcon lkup" : "Accounts" === searchMod ? "Accounts-small lkup hei16 wid16 verAB" : "OwnerNameLookup changeUserIcon Potentials-small lkup",
border: "0",
"data-lookup": JSON.stringify(dataVal.lookup),
id: dataId,
"data-cid": dataCID,
"data-label": dataLabel,
"data-lookup-module": lookupModule,
"data-module": dataModule,
"data-zcqa": datazcqa + dataCID,
"data-productId": dataproductId,
"data-leadid": dataleadId,
"data-potentialid": datapotentialId,
"data-potentialName": datapotentialName
},
events: autoPopUpFun
}, {
name: "p",
attr: {
"class": errorClass,
style: "color:#D42A1C;display:none",
id: emptyId
},
html: I18n.getMsg("crm.social.search.noData")
}]
});
target.append(createElem);
var urlData = dataVal.params,
elem = $("#" + inputid),
hiddenElem = $("#" + hiddenid);
elem.focus();
var minlength = dataVal.minlength ? dataVal.minlength : 0;
minlength = "0" === minlength ? 0 : minlength;
var appendElem = dataVal.appendselector ? $(dataVal.appendselector) : elem.parent(),
selectFun = function(event, ui) {
return dataVal.selectFun && (ZRCommonUtil.toggleClearLookupfield(!0, $(this)), dataVal.selectFun(event, ui)), elem.val(ui.item.label).data("selecteditem", ui.item), hiddenElem.val(ui.item.value), ZRCommonUtil.toggleClearLookupfield(!0, $(this)), !1
},
focusFun = dataVal.focusFun ? dataVal.focusFun : function(event, ui) {
return 40 === event.which || 38 === event.which ? (elem.val(ui.item.label).data("selecteditem", ui.item), hiddenElem.val(ui.item.value), !1) : void 0
},
searchFun = dataVal.searchFun ? dataVal.searchFun : void 0,
closeFun = dataVal.closeFun ? dataVal.closeFun : function() {
$("#" + emptyId).html("").hide()
},
openFun = dataVal.openFun ? dataVal.openFun : function() {
$("#" + emptyId).html("").hide(), hiddenElem.val("")
},
successFun = dataVal.successFun ? dataVal.successFun : void 0,
changeFun = dataVal.changeFun ? dataVal.changeFun : void 0,
renderFun = function(ul, item) {
return dataVal.renderFun && item.label != emptyMsg ? (ul.addClass("maxH200 oveA"), dataVal.renderFun(ul, item)) : item.label == emptyMsg ? $("<li style='pointer-events:none;'>").data("item.autocomplete", item).append($("<a>").text(item.label)).appendTo(ul) : $("<li>").data("item.autocomplete", item).append($("<a>").text(item.label)).appendTo(ul.addClass("maxH200 oveA"))
},
asyncVal = !0;
if (void 0 != dataVal && void 0 != dataVal.lookup) {
var lookup = dataVal.lookup;
void 0 != lookup.from && "criteriaEditor" == lookup.from && (asyncVal = void 0 != dataVal.params.async ? dataVal.params.async : asyncVal)
}
var errorFun = dataVal.errorFun ? dataVal.errorFun : function(xhr) {
xhr.responseText;
$("#" + emptyId).addClass("pA"), $("#" + emptyId).html(I18n.getMsg("crm.security.error.add.user")).show()
};
elem.autocomplete({
source: function(request, response) {
urlData = void 0 === urlData || null === urlData ? {} : urlData, urlData.searchtxt = request.term, $.ajax({
url: dataVal.url,
dataType: "json",
data: urlData,
async: asyncVal,
success: function(data) {
if (void 0 != successFun)
successFun(data, response);
else {
var json = ZRCommonUtil.convertStringToJson(data);
if (json && json.message && "success" === json.message) {
var list = json.autoList;
if (void 0 != list)
$("#" + emptyId).html("").hide(), response(list);
else {
var list = {
label: emptyMsg
};
response(list)
}
}
}
},
error: errorFun
})
},
select: selectFun,
focus: focusFun,
search: searchFun,
close: closeFun,
open: openFun,
change: changeFun,
minLength: minlength,
appendTo: appendElem
}).data("ui-autocomplete")._renderItem = renderFun, elem.keyup(function() {
var value = $(this).val();
void 0 === value || null === value || "null" === value || 0 === value.length ? (clearFun(void 0, void 0, inputid, hiddenid, emptyId), ZRCommonUtil.toggleClearLookupfield(!1, $(this))) : ZRCommonUtil.toggleClearLookupfield(!0, $(this))
}), elem.click(function() {
$(this).parent("div").find(".ui-autocomplete").is(":hidden") && $(this).autocomplete("search", $(this).val())
}), triggerLookup && elem.autocomplete("search")
},
onCcandBcc: function(elem, dataVal) {
var urlData = dataVal.params,
minlength = dataVal.minlength ? dataVal.minlength : 1,
inputId = $(elem).attr("id"),
noData = !0;
void 0 === inputId && (inputId = "autoCompleteCC", $(elem).attr("id", inputId));
var doNotShowContacts = dataVal.doNotShowContacts,
inputName = $(elem).attr("name");
doNotShowContacts && inputName && ("ccAddress-dummy" === inputName || "bccAdress-dummy" === inputName) && (inputId = inputName.substring(0, inputName.lastIndexOf("-")));
var hiddenId = void 0 != dataVal.hiddenId ? dataVal.hiddenId : inputId + "-hidden";
doNotShowContacts && inputId && ("compose-client-cc-dummy" === inputId || "compose-client-bcc-dummy" === inputId) && (hiddenId = inputId.substring(0, inputId.lastIndexOf("-")));
var hiddenElem = $("#" + hiddenId),
emptyId = dataVal.inputid + "-message",
fromIndex = void 0 != dataVal.fromIndex ? dataVal.fromIndex : 0,
toIndex = void 0 != dataVal.toIndex ? dataVal.toIndex : 5,
allowSingleMailOnly = void 0 != dataVal.allowSingleMailOnly ? dataVal.allowSingleMailOnly : !1;
!doNotShowContacts || "ccAddress" !== inputName && "bccAddress" !== inputName || 0 !== $("#" + inputName + "-hidden").length || (inputId = inputName, $(elem).attr("name", inputId + "-dummy"), hiddenElem = Utils.createHTML({
name: "input",
attr: {
type: "hidden",
id: inputId + "-hidden",
name: inputName
}
}), hiddenId = inputId + "-hidden", $(elem).after(hiddenElem)), !doNotShowContacts || "compose-client-cc" !== inputId && "compose-client-bcc" !== inputId || 0 !== $("#" + inputId + "-dummy").length || ($(elem).attr("id", inputId + "-dummy"), hiddenElem = Utils.createHTML({
name: "input",
attr: {
type: "hidden",
id: inputId
}
}), hiddenId = inputId, $(elem).after(hiddenElem));
var selectFun = dataVal.selectFun ? dataVal.selectFun : function(event, ul) {
if (doNotShowContacts && (ul.item.value = ul.item.email, ul.item.email = ul.item.label), allowSingleMailOnly === !0)
$(elem).val(""), $(elem).blur(function() {
$(elem).val(ul.item.email)
}), $(elem).focus(function() {
$(elem).val(ul.item.email + ",")
});
else {
var entityData = $(elem).val(),
hiddenData = $("#" + hiddenId).val();
-1 === entityData.indexOf(",") ? ($(elem).val(ul.item.email + ","), $("#" + hiddenId).attr("value", ul.item.value + ",")) : ($(elem).val(entityData.substring(0, entityData.lastIndexOf(",") + 1) + ul.item.email + ","), hiddenData && $("#" + hiddenId).attr("value", hiddenData.substring(0, hiddenData.lastIndexOf(",") + 1) + ul.item.value + ","))
}
return $(elem).focus().val($(elem).val()), !1
},
focusFun = dataVal.focusFun ? dataVal.focusFun : function(event, ui) {
var entityData = $(elem).val();
return !ui.item || 40 !== event.which && 38 !== event.which ? void 0 : (doNotShowContacts ? elem.val(entityData.substr(0, entityData.lastIndexOf(",") + 1) + ui.item.label).data("selecteditem", ui.item) : elem.val(entityData.substr(0, entityData.lastIndexOf(",") + 1) + ui.item.email).data("selecteditem", ui.item), !1)
},
searchFun = dataVal.searchFun ? dataVal.searchFun : void 0,
closeFun = dataVal.closeFun ? dataVal.closeFun : void 0,
openFun = dataVal.openFun ? dataVal.openFun : function() {
noData && $(".ui-autocomplete").css("display", "none")
},
errorFun = dataVal.errorFun ? dataVal.errorFun : function(xhr) {
xhr.responseText;
$("#" + emptyId).html(I18n.getMsg("crm.security.error.add.user")).show()
},
renderFun = dataVal.renderFun ? dataVal.renderFun : function(ul, item) {
return doNotShowContacts && "Contacts" === item.module ? $("<li>").data("item.autocomplete", item).append('<a><span class="zrc-pic32"><img class="zrc-pic" src="' + encodeURI(item.photoUrl) + '"></span><span class="name">' + $ESAPI.encoder().encodeForHTML(item.label) + '</span><span class="email"> </span></a>').appendTo(ul.addClass("zrc-profile-list")) : $("<li>").data("item.autocomplete", item).append('<a><span class="zrc-pic32"><img class="zrc-pic" src="' + encodeURI(item.photoUrl) + '"></span><span class="name">' + $ESAPI.encoder().encodeForHTML(item.label) + '</span><span class="email">' + $ESAPI.encoder().encodeForHTML(item.email) + "</span></a>").appendTo(ul.addClass("zrc-profile-list"))
},
successFun = dataVal.successFun ? dataVal.successFun : function(data, response) {
var json = ZRCommonUtil.convertStringToJson(data);
if (json && json.message && "success" === json.message) {
var list = json.autoList;
json.doNotShowContacts === !0 && (doNotShowContacts = !0), void 0 != list ? response(list) : $(".ui-autocomplete").css("display", "none")
}
},
changeFun = dataVal.changeFun ? dataVal.changeFun : void 0,
renderMenuFun = dataVal.renderMenuFun ? dataVal.renderMenuFun : function(ul, items) {
var curModule,
self = this,
selectedVals = $(elem).val(),
selectedValsArr = selectedVals.split(",");
noData = !0, $.each(items, function(index, item) {
var checkForExist = item.email;
doNotShowContacts && (checkForExist = item.label), -1 == $.inArray(checkForExist, selectedValsArr) && (item.module != curModule && (ul.append('<li class="hdng"><a>' + $ESAPI.encoder().encodeForHTML(item.module) + "</a></li>"), curModule = item.module), self._renderItemData(ul, item), noData = !1)
})
},
autocomp = $(elem).autocomplete({
source: function(request, response) {
urlData = void 0 === urlData || null === urlData ? {} : urlData;
var searchTxt = request.term,
searchArr = searchTxt.split(",");
urlData.searchtxt = null != searchArr ? searchArr[searchArr.length - 1] : request.term, urlData.fromindex = fromIndex, urlData.toindex = toIndex, $.ajax({
url: dataVal.url,
dataType: "json",
data: urlData,
success: function(data) {
successFun(data, response)
},
error: errorFun
})
},
select: selectFun,
focus: focusFun,
search: searchFun,
close: closeFun,
open: openFun,
change: changeFun,
minLength: minlength
});
autocomp.data("ui-autocomplete")._renderMenu = renderMenuFun, autocomp.data("ui-autocomplete")._renderItem = renderFun
},
openDialog: function(divId) {
var elemId = $(divId);
if (elemId && 0 !== elemId.length) {
var removeFreeze = elemId.data("removefreeze") === !1 ? !1 : !0;
if (removeFreeze) {
$("#bg-light").remove();
var oFreezeLayer = document.createElement("div");
oFreezeLayer.id = "bg-light", oFreezeLayer.className = "bg-dark", document.body.appendChild(oFreezeLayer)
}
ZRCommonUtil.elementPosition(elemId)
}
},
createModal: function(params) {
params = ZRCommonUtil.convertStringToJson(params);
var mailNotificationPopUp = params && params.mailNotificationPopUp ? params.mailNotificationPopUp : void 0,
modalClass = params && params.modalclass ? "zcrm-modal zcrm-effect zcrm-show p0 " + params.modalclass : "zcrm-modal zcrm-effect zcrm-show wid700 p0",
divId = params && params.modalid ? params.modalid : "modal-block",
btnId = divId ? divId + "-btn" : "modal-block-btn",
title = params && params.title ? params.title : "",
description = params && params.description ? params.description : "",
descClass = params && params.descclass ? "poptitle-desc " + params.descclass : "poptitle-desc",
content = params && params.content ? params.content : "",
saveBtn = params && params.savebtn ? params.savebtn : I18n.getMsg("crm.button.save"),
cancelBtn = params && params.cancelbtn ? params.cancelbtn : I18n.getMsg("crm.button.cancel"),
saveBtnClass = params && params.saveclass ? params.saveclass : "primarybtn",
cancelBtnClass = params && params.cancelclass ? params.cancelclass : "newgraybtn marL15",
savefn = params && params.savefn ? params.savefn : void 0,
savearg = params && params.savearg ? params.savearg : [],
cancelfn = params && params.cancelfn ? params.cancelfn : function(ev, target) {
if (mailNotificationPopUp) {
var closeDiv = $(target).parents(".zrc-popup-modal").attr("id");
ZRCommonUtil.closeDialog(ev, target, "#" + closeDiv)
} else {
var closeDiv = $(target).parents(".zcrm-modal").attr("id");
ZRCommonUtil.closeDialog(ev, target, "#" + closeDiv)
}
},
closefn = params && params.closefn ? params.closefn : cancelfn,
cancelarg = params && params.cancelarg ? params.cancelarg : [],
callback = params && params.callback ? params.callback : void 0,
callbackarg = params && params.callbackarg ? params.callbackarg : void 0,
removefreeze = params && void 0 != params.removefreeze ? params.removefreeze : !0,
dialog = params && params.dialog ? params.dialog : "remove",
datazcqasave = params && params.zcqasave ? params.zcqasave : "savezcqa",
datazcqacancel = params && params.zcqacancel ? params.zcqacancel : "cancelzcqa",
removeCancelBtn = params && void 0 != params.removecancelbtn ? params.removecancelbtn : !1,
needCrossBtn = params && void 0 != params.needCrossBtn ? params.needCrossBtn : !1,
toRemove = params && void 0 != params.removeElem ? params.removeElem : !1,
headerClass = params && void 0 != params.hideHeader && params.hideHeader === !0 ? " disN" : "",
contentClass = params && void 0 != params.contentClass ? params.contentClass : "",
footerClass = params && void 0 != params.footerClass ? params.footerClass : "",
escapefn = params && params.escapefn ? params.escapefn : void 0,
helpUrlKey = params && params.helpurlkey ? params.helpurlkey : void 0,
crossBtnClass = params && params.crossBtnClass ? params.crossBtnClass : "close-modal zrc-icon-closeb top24 tranSP8",
helpUrlTag = {};
helpUrlKey && crmConstants.helpUrl[helpUrlKey] && (helpUrlTag = {
name: "div",
attr: {
"class": "helplnk"
},
child: [{
name: "a",
attr: {
"data-zcqa": "lnk_nt_help",
id: "context-helplink",
"class": "toplink",
href: "javascript:;"
},
events: [{
name: "click",
fn: function() {
openHelp(crmConstants.helpUrl["help.domain.url"] + crmConstants.helpUrl[helpUrlKey])
}
}],
html: I18n.getMsg("crm.label.context.help")
}]
});
var cancelBtn = {
name: "input",
attr: {
type: "button",
"class": cancelBtnClass,
"data-zcqa": datazcqacancel,
value: cancelBtn
},
html: cancelBtn,
events: [{
name: "click",
fn: cancelfn,
args: cancelarg
}]
};
removeCancelBtn && (cancelBtn = {});
var closeATag = {};
needCrossBtn && (closeATag = {
name: "a",
attr: {
href: "javascript:void(0)",
"class": crossBtnClass
},
events: [{
name: "click",
fn: closefn
}]
});
var createElem;
mailNotificationPopUp ? (modalClass = params && params.popupclass ? params.popupclass : "zrc-popup-modal zrc-popup-show p0 w1000 ppTop showPpTop", createElem = Utils.createHTML({
name: "div",
attr: {
"class": modalClass,
id: divId,
"data-removefreeze": removefreeze,
"data-dialog": dialog,
tabindex: "1"
},
child: [{
name: "a",
attr: {
"class": "zrc-close-popup",
href: "javascript:;"
},
events: [{
name: "click",
fn: cancelfn,
args: cancelarg
}]
}, {
name: "div",
attr: {
"class": "zrc-popup-container"
},
child: [{
name: "div",
child: [{
name: "div",
attr: {
"class": "popup-model-header f21 proximal bxShTp" + headerClass
},
html: title,
child: [{
name: "span",
attr: {
"class": descClass
},
html: description
}]
}, closeATag, helpUrlTag]
}, {
name: "div",
attr: {
"class": "popup-model-content " + contentClass
},
html: content
}, {
name: "div",
attr: {
"class": "popup-model-footer " + footerClass,
id: btnId
},
child: [cancelBtn, {
name: "input",
attr: {
type: "button",
"class": saveBtnClass,
"data-zcqa": datazcqasave,
value: saveBtn
},
html: saveBtn,
events: [{
name: "click",
fn: savefn,
args: savearg
}]
}]
}]
}]
})) : createElem = Utils.createHTML({
name: "div",
attr: {
"class": modalClass,
id: divId,
"data-removefreeze": removefreeze,
"data-dialog": dialog,
tabindex: "1"
},
child: [{
name: "div",
attr: {
"class": "zcrm-content boxSN"
},
child: [{
name: "div",
attr: {
"class": "popup-model-header f21 proximal bxShTp" + headerClass
},
html: title,
child: [{
name: "span",
attr: {
"class": descClass
},
html: description
}]
}, closeATag, helpUrlTag]
}, {
name: "div",
attr: {
"class": "popup-model-content " + contentClass
},
html: content
}, {
name: "div",
attr: {
"class": "popup-model-footer " + footerClass,
id: btnId
},
child: [cancelBtn, {
name: "input",
attr: {
type: "button",
"class": saveBtnClass,
"data-zcqa": datazcqasave,
value: saveBtn
},
html: saveBtn,
events: [{
name: "click",
fn: savefn,
args: savearg
}]
}]
}]
}), params.appendTo && $(params.appendTo).length > 0 ? $(params.appendTo).append(createElem) : $("body").append(createElem), crmui.showPop(divId, !1, toRemove, escapefn), $("#" + divId).focus(), "status-block" != divId && "org_modal" !== divId && "client-login-email-compose" !== divId && Utils.bindChosen($("#" + divId + " select")), callback && callback(callbackarg)
},
checkCustomDomainURL: function(URL) {
var customURL = URL,
urlregex = new RegExp(/^(ht|f)tps?:\/\/[a-zA-Z0-9-\.]+\.[a-z]{2,20}(\/[^\s<>%"\,;\\|\\\^\[\]`]+)?$/);
return urlregex.test(customURL) ? !0 : !1
},
checkDomainName: function(name) {
var urlregex = new RegExp("^[a-zA-Z0-9]+$");
return urlregex.test(name) ? !0 : !1
},
isNumericKeyCode: function(event) {
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
return keyCode >= 48 && 57 >= keyCode || 8 == keyCode || 189 == keyCode || 32 == keyCode || keyCode >= 96 && 105 >= keyCode
},
isAlphaKeyCode: function(event) {
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
return keyCode >= 65 && 90 >= keyCode || 8 == keyCode || 32 == keyCode || 190 == keyCode
},
isValidEmail: function(email) {
var regex = /^[a-zA-Z0-9_]([\w\-\.\+\']*)@([\w\-\.]*)(\.[a-zA-Z]{2,22}(\.[a-zA-Z]{2}){0,2})$/;
return email.match(regex)
},
createInfoBox: function(params) {
params = ZRCommonUtil.convertStringToJson(params);
var modalClass = params && params.modalclass ? "zpopup-modal zpopup-animate-modal " + params.modalclass : "zpopup-modal zpopup-animate-modal zwid600",
divId = params && params.modalid ? params.modalid : "modal-block",
title = params && params.title ? params.title : "",
content = params && params.content ? params.content : "",
titleClass = params && params.titleclass ? params.titleclass : ZRCommonUtil.isEmpty(content) ? "til msg" : "ic",
savefn = params && params.savefn ? params.savefn : function(ev, target) {
var closeDiv = $(target).parents(".zpopup-modal").attr("id");
ZRCommonUtil.closeDialog(ev, target, "#" + closeDiv)
},
savearg = params && params.savearg ? params.savearg : [],
saveBtn = params && params.savebtn ? params.savebtn : I18n.getMsg("crm.button.ok"),
callback = params && params.callback ? params.callback : void 0,
removefreeze = params && void 0 != params.removefreeze ? params.removefreeze : !0;
if (removefreeze) {
var ispoponpop = params && params.ispoponpop ? params.ispoponpop : !1;
ispoponpop && (removefreeze = !1)
}
var createElem,
dialog = params && params.dialog ? params.dialog : "remove",
isNewPop = params && params.isNew ? params.isNew : !1;
if (isNewPop) {
var saveBtnClass = params && params.saveclass ? params.saveclass : "primarybtn",
messageType = params && params.messageType ? params.messageType : "success",
buttonclass = "",
iconclass = "";
switch (messageType) {
case "success":
iconclass = "zrc-icon-tickm", buttonclass = "zrc-btn-primary marR0";
break;
case "warning":
iconclass = "zrc-icon-warningm", buttonclass = "zrc-btn-secondary zrc-popup-close";
break;
case "info":
iconclass = "zrc-icon-infom", buttonclass = "zrc-btn-primary marR0";
break;
case "error":
iconclass = "zrc-icon-errorm", buttonclass = "zrc-btn-negative marR0"
}
var popBtns,
makeConfirmationBox = params && params.makeConfirmationBox ? params.makeConfirmationBox : !1;
if (makeConfirmationBox) {
var noBtn = params && params.nobutton ? params.nobutton : I18n.getMsg("crm.button.close");
popBtns = [{
name: "a",
attr: {
href: "javascript:void(0)",
"class": "zrc-btn-secondary zrc-popup-close"
},
events: [{
name: "click",
fn: params.cancelCallee,
args: params.cancelArgs
}],
text: noBtn
}, {
name: "a",
attr: {
"class": buttonclass,
href: "javascript:void(0)"
},
events: [{
name: "click",
fn: params.callee,
args: params.args
}],
text: saveBtn + " "
}]
} else
popBtns = [{
name: "input",
attr: {
type: "button",
"class": buttonclass,
value: saveBtn
},
events: [{
name: "click",
fn: savefn,
args: savearg
}]
}];
createElem = Utils.createHTML({
name: "div",
attr: {
"class": modalClass,
id: divId,
"data-removefreeze": removefreeze,
"data-dialog": dialog
},
child: [{
name: "div",
attr: {
"class": "zpopup-modal-container clearfix"
},
child: [{
name: "div",
attr: {
"class": "pop-wrapper zrc-custom-cheackbox clearfix mT0"
},
child: [{
name: "p",
attr: {
"class": "f15"
},
child: [{
name: "div",
attr: {
style: "text-align:center;"
},
child: [{
name: "div",
child: [{
name: "span",
attr: {
"class": iconclass
}
}]
}, {
name: "div",
attr: {
id: "warningMsg",
"class": "f21 marT20"
},
html: title
}, {
name: "p",
attr: {
"class": "marT20 colG1 linH22 proRE"
},
html: content
}]
}]
}, {
name: "div",
attr: {
"class": " mT20 padT4 marB10 texAC",
"data-zcqa": "info-box-ok"
},
child: popBtns
}]
}]
}]
})
} else {
var saveBtnClass = params && params.saveclass ? params.saveclass : "newgreybtn mL5";
createElem = Utils.createHTML({
name: "div",
attr: {
"class": modalClass,
id: divId,
"data-removefreeze": removefreeze,
"data-dialog": dialog
},
child: [{
name: "div",
attr: {
"class": "zpopup-modal-container clearfix"
},
child: [{
name: "h2",
attr: {
"class": titleClass
},
html: title
}, {
name: "a",
attr: {
href: "javascript:;",
"class": "zcp-cls"
},
events: [{
name: "click",
fn: savefn,
args: savearg
}]
}, {
name: "div",
attr: {
"class": "pop-wrapper zrc-custom-cheackbox clearfix mT0"
},
child: [{
name: "p",
attr: {
"class": "f15"
},
html: content
}, {
name: "div",
attr: {
"class": "mT25 texAC",
"data-zcqa": "info-box-ok"
},
child: [{
name: "input",
attr: {
type: "button",
"class": saveBtnClass,
value: saveBtn
},
events: [{
name: "click",
fn: savefn,
args: savearg
}]
}]
}]
}]
}]
})
}
$("body").append(createElem), ZRCommonUtil.showInfoBox(divId), callback && callback()
},
showInfoBox: function(ids) {
("none" === $("#FreezeLayer").css("display") || 0 == $("#FreezeLayer").length) && (freezeBackground(), $("#FreezeLayer").hide(), $("#FreezeLayer").fadeIn()), setTimeout(function() {
$("#" + ids).addClass("zpopup-show")
}, 0)
},
createConfirmationBox: function(params) {
params = ZRCommonUtil.convertStringToJson(params);
var modalClass = params && params.modalclass ? "zpopup-modal zpopup-animate-modal " + params.modalclass : "zpopup-modal zpopup-animate-modal w350",
divId = params && params.modalid ? params.modalid : "modal-block",
title = params && params.title ? params.title : "",
content = params && params.content ? params.content : "",
titleClass = ZRCommonUtil.isEmpty(content) ? "til msg" : "ic",
savefn = params && params.savefn ? params.savefn : function(ev, target) {
var closeDiv = $(target).parents(".zpopup-modal").attr("id");
ZRCommonUtil.closeDialog(ev, target, "#" + closeDiv)
},
savearg = params && params.savearg ? params.savearg : [],
saveBtnClass = params && params.saveclass ? params.saveclass : "redbtn",
saveBtn = params && params.savebtn ? params.savebtn : I18n.getMsg("Delete"),
cancelBtn = params && params.cancelbtn ? params.cancelbtn : I18n.getMsg("crm.button.cancel"),
cancelBtnClass = params && params.cancelclass ? params.cancelclass : "newgreybtn mL5",
cancelfn = params && params.cancelfn ? params.cancelfn : function(ev, target) {
var closeDiv = $(target).parents(".zpopup-modal").attr("id");
ZRCommonUtil.closeDialog(ev, target, "#" + closeDiv)
},
cancelarg = params && params.cancelarg ? params.cancelarg : [],
callback = params && params.callback ? params.callback : void 0,
removefreeze = params && params.removefreeze ? params.removefreeze : !0,
dialog = params && params.dialog ? params.dialog : "remove",
datazcqasave = params && params.zcqasave ? params.zcqasave : "btn_confirm_ok",
datazcqacancel = params && params.zcqacancel ? params.zcqacancel : "btn_confirm_cancel",
createElem = Utils.createHTML({
name: "div",
attr: {
"class": modalClass,
id: divId,
"data-removefreeze": removefreeze,
"data-dialog": dialog
},
child: [{
name: "div",
attr: {
"class": "zpopup-modal-container clearfix"
},
child: [{
name: "h2",
attr: {
"class": titleClass
},
html: title
}, {
name: "div",
attr: {
"class": "pop-wrapper zrc-custom-cheackbox clearfix mT0"
},
child: [{
name: "p",
attr: {
"class": "f15"
},
html: content
}, {
name: "div",
attr: {
"class": "mT25 texAC",
"data-zcqa": "info-box-ok"
},
child: [{
name: "input",
attr: {
type: "button",
"class": saveBtnClass,
"data-zcqa": datazcqasave,
value: saveBtn
},
events: [{
name: "click",
fn: savefn,
args: savearg
}]
}, {
name: "input",
attr: {
type: "button",
"class": cancelBtnClass,
"data-zcqa": datazcqacancel,
value: cancelBtn
},
events: [{
name: "click",
fn: cancelfn,
args: cancelarg
}]
}]
}]
}]
}]
});
$("body").append(createElem), ZRCommonUtil.showInfoBox(divId), callback && callback()
},
openModal: function(divId) {
var elemId = $(divId);
if (elemId && 0 !== elemId.length) {
var removeFreeze = elemId.data("removefreeze") === !1 ? !1 : !0;
if (removeFreeze) {
$("#bg-light").remove();
var oFreezeLayer = document.createElement("div");
oFreezeLayer.id = "bg-light", oFreezeLayer.className = "bg-dark", document.body.appendChild(oFreezeLayer)
}
elemId.show()
}
},
reportSorting: function(url) {
url += "&clickId=CustomReport", Crm.isPageLoad = !0, crmReports.loadBodyContent(void 0, url)
},
removeFreeze: function() {
var scrid = document.getElementById("bg-light");
scrid && document.body.removeChild(scrid);
var id = document.getElementById("bg-dark");
id && document.body.removeChild(id);
var newFreezeLayer = document.getElementById("FreezeLayer");
newFreezeLayer && document.body.removeChild(newFreezeLayer)
},
createFreeze: function() {
$("#bg-light").remove();
var oFreezeLayer = document.createElement("div");
oFreezeLayer.id = "bg-light", oFreezeLayer.className = "bg-dark", document.body.appendChild(oFreezeLayer)
},
closeDialog: function(ev, target, divId) {
if (divId) {
var elem = $(divId);
if (elem && 0 !== elem.length) {
var removeFreeze = elem.data("removefreeze") === !1 ? !1 : !0;
removeFreeze && ZRCommonUtil.removeFreeze();
var isHide = "hide" === elem.data("dialog") ? !0 : !1;
isHide ? elem.hide() : elem.remove()
}
elem.hasClass("zpopup-show") && elem.removeClass("zpopup-show")
}
},
elementPosition: function(elem) {
var sTop = document.documentElement.scrollTop || document.body.scrollTop,
sLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
if ($(window).height() > elem.height())
elem.css({
display: "block",
position: "absolute",
left: "50%",
top: "50%",
"margin-left": -(elem.width() / 2) + sLeft,
"margin-top": -(elem.height() / 2) + sTop
});
else {
var tP = sTop + 10;
elem.css({
display: "block",
position: "absolute",
left: "50%",
top: tP,
"margin-left": -(elem.width() / 2) + sLeft,
"margin-top": "0px"
})
}
},
getPopoverPosition: function(targetElement) {
if (0 != targetElement.length) {
var positionData = ZRCommonUtil.convertStringToJson(targetElement.data("positiondata")),
modalElem = $(positionData.modal),
pmodalElem = $(positionData.pmodal),
scrollElem = $(positionData.scroll),
placement = positionData.placement;
placement = placement ? placement : "left";
var pos = ZRCommonUtil.getPosition(targetElement),
actualWidth = 0 != modalElem.length ? modalElem[0].offsetWidth : 0,
actualHeight = 0 != modalElem.length ? modalElem[0].offsetHeight : 0,
scrollElemTop = 0 != scrollElem.length ? scrollElem[0].scrollTop : 0;
pos.top = pos.top - scrollElemTop;
var tp,
pmodalTop = 0 != pmodalElem.length ? ZRCommonUtil.getPosition(pmodalElem).top + 15 : 0;
switch (placement) {
case "bottom":
pos.top = pos.top + pos.height, pos.left = pos.left + pos.width / 2 - actualWidth / 2;
var arrowTop = actualWidth / 2 - pos.width / 2;
tp = {
top: pos.top < 0 ? pmodalTop : pmodalTop > pos.top ? pmodalTop : pos.top,
left: pos.left - 10,
arrowPos: pos.top < 0 ? arrowTop + pos.top - pmodalTop : pmodalTop > pos.top ? arrowTop - (pmodalTop - pos.top) : arrowTop
};
break;
case "top":
pos.top = pos.top - actualHeight, pos.left = pos.left + pos.width / 2 - actualWidth / 2;
var arrowTop = actualWidth / 2 - pos.width / 2;
tp = {
top: pos.top < 0 ? pmodalTop : pmodalTop > pos.top ? pmodalTop : pos.top,
left: pos.left - 10,
arrowPos: pos.top < 0 ? arrowTop + pos.top - pmodalTop : pmodalTop > pos.top ? arrowTop - (pmodalTop - pos.top) : arrowTop
};
break;
case "left":
pos.top = pos.top + pos.height / 2 - actualHeight / 2, pos.left = pos.left - actualWidth;
var arrowTop = actualHeight / 2 - pos.height / 2;
tp = {
top: pos.top < 0 ? pmodalTop : pmodalTop > pos.top ? pmodalTop : pos.top,
left: pos.left - 10,
arrowPos: pos.top < 0 ? arrowTop + pos.top - pmodalTop : pmodalTop > pos.top ? arrowTop - (pmodalTop - pos.top) : arrowTop
};
break;
case "right":
pos.top = pos.top + pos.height / 2 - actualHeight / 2, pos.left = pos.left + pos.width;
var arrowTop = actualHeight / 2 - pos.height / 2;
tp = {
top: pos.top < 0 ? pmodalTop : pmodalTop > pos.top ? pmodalTop : pos.top,
left: pos.left + 10,
arrowPos: pos.top < 0 ? arrowTop + pos.top - pmodalTop : pmodalTop > pos.top ? arrowTop - (pmodalTop - pos.top) : arrowTop
};
break;
case "adjustable":
var diff = pos.top + actualHeight - $(window).height(),
arrowTop = actualHeight / 2 - pos.height / 2;
diff > 0 ? (pos.top = pos.top - diff, arrowTop = diff) : pos.top = pos.top + pos.height / 2 - actualHeight / 2, arrowTop = pos.top < 0 ? arrowTop + pos.top - pmodalTop : pmodalTop > pos.top ? arrowTop - (pmodalTop - pos.top) : arrowTop, pos.left = pos.left - actualWidth, tp = {
top: pos.top < 0 ? pmodalTop : pmodalTop > pos.top ? pmodalTop : pos.top,
left: pos.left - 10,
arrowPos: arrowTop
};
break;
case "rightadjustable":
var diff = pos.top + actualHeight - $(window).height(),
arrowTop = actualHeight / 2 - pos.height / 2;
diff > 0 ? (pos.top = pos.top - diff, arrowTop = diff) : pos.top = pos.top + pos.height / 2 - actualHeight / 2, arrowTop = pos.top < 0 ? arrowTop + pos.top - pmodalTop : pmodalTop > pos.top ? arrowTop - (pmodalTop - pos.top) : arrowTop, pos.left = pos.left + pos.width, tp = {
top: pos.top < 0 ? pmodalTop : pmodalTop > pos.top ? pmodalTop : pos.top,
left: pos.left + 10,
arrowPos: arrowTop
}
}
return tp
}
},
getPosition: function(element) {
element = void 0 !== element && "object" == typeof element && element.length > 0 ? element[0] : element;
var elementPos = element.getBoundingClientRect(),
left = Math.round(elementPos.left),
top = Math.round(elementPos.top),
right = Math.round(elementPos.right),
bottom = Math.round(elementPos.bottom);
return {
left: left,
top: top,
right: right,
bottom: bottom,
width: element.offsetWidth,
height: element.offsetHeight
}
},
divPositionValue: function(divId) {
var newValue = {},
windowHeight = $(window).height(),
windowWidth = $(window).width(),
scrollTop = $(document).scrollTop(),
scrollLeft = $(document).scrollLeft(),
divHeight = $(divId).height(),
divWidth = $(divId).width(),
topPos = new Number(scrollTop) + (new Number(windowHeight) / 2 - new Number(divHeight) / 2),
leftPos = new Number(scrollLeft) + (new Number(windowWidth / 2) - new Number(divWidth) / 2);
return newValue.leftLen = (leftPos > 0 ? leftPos : 0) + "px", newValue.topLen = (topPos > 0 ? topPos : 0) + "px", newValue
},
setToCenterOfParent: function(obj, parentObj) {
var newValue = {},
height = $(obj).height(),
width = $(obj).width();
return parentObj == window ? (newValue.top = $(parentObj).height() / 2 - height / 2, newValue.left = $(parentObj).width() / 2 - width / 2) : (newValue.top = $(parentObj).height() / 2 - height / 2 + $(parentObj).position().top, newValue.left = $(parentObj).width() / 2 - width / 2 + $(parentObj).position().left), newValue
},
trim: function(str) {
var value = "";
return void 0 != str && null != str && 0 != str.length && (value = str.replace(/^\s+|\s+$/g, "")), value
},
isEmpty: function(value) {
if ("string" == typeof value) {
if (value && null != value && "null" != value && 0 != value.trim().length)
return !1
} else {
if ("object" == typeof value)
return $.isEmptyObject(value);
if (value && null != value)
return !1
}
return !0
},
contains: function(arrList, value, type) {
type = void 0 === type || 0 === type.length ? "String" : type;
var isContains = !1;
return void 0 !== value && void 0 !== arrList && $.each(arrList, function(i, data) {
"String" === type ? data.trim().toLowerCase() === value.trim().toLowerCase() && (isContains = !0) : data === value && (isContains = !0)
}), isContains
},
convertStringToJson: function(json) {
return json = json ? json : {}, json && "string" == typeof json && (json = JSON.parse(json)), json
},
attachMoreUpload: function(ev, target, callbackFun) {
var fileElem = $(target),
name = fileElem.attr("name"),
attachDetail = fileElem.data("attachdetail");
"string" == typeof data && (attachDetail = JSON.parse(data));
var fileList = $(fileElem)[0].files;
if (fileList.length > 1)
$.each(fileList, function(i, file) {
var fileName = file.name,
fileSize = parseInt(file.size / 1024);
callbackFun && callbackFun(fileName, attachDetail, name, fileSize)
});
else {
var file = fileList[0],
fileName = file.name,
fileSize = parseInt(file.size / 1024);
callbackFun && callbackFun(fileName, attachDetail, name, fileSize)
}
},
changeSubject: function() {
var tempId = document.getElementById("templateId").value,
check = !1,
tempModule = "";
if ("None" != tempId) {
var index = tempId.split("~")[1],
subject = $("#template" + index).data("subject");
tempModule = $("#module").val();
var emailTempId = tempId.split("~")[0];
if ("Leads" === tempModule) {
var desc = "";
if (emailTempId && null != emailTempId) {
var urlData = {};
urlData.emailTemplateId = emailTempId, urlData.step = "getEmailTemplateBody", ZRCommonUtil.ajaxGetMethod("/recruit/Template.do", urlData, !1, "html", void 0, function(data) {
desc = data && null != data && "Empty" != data ? data : ""
}, function() {
ZRCommonUtil.displayErrorMsg("gSErrorMsg", I18n.getMsg("crm.fr.unknown"))
})
}
if (desc.indexOf("${Job Openings.") > -1 || subject.indexOf("${Job Openings.") > -1) {
if (ZRCommonUtil.FILTERJOBID && "" != ZRCommonUtil.FILTERJOBID && "Unassociated" != ZRCommonUtil.FILTERJOBID) {
var joName = ZRCommonUtil.FILTERJOBNAME && "" != ZRCommonUtil.FILTERJOBNAME && "Unassociated" != ZRCommonUtil.FILTERJOBNAME ? ZRCommonUtil.FILTERJOBNAME : "",
joId = ZRCommonUtil.FILTERJOBID && "" != ZRCommonUtil.FILTERJOBID && "Unassociated" != ZRCommonUtil.FILTERJOBID ? ZRCommonUtil.FILTERJOBID : "",
createElem = Utils.createHTML({
name: "div",
attr: {
"class": "ac-block"
},
child: [{
name: "input",
attr: {
type: "text",
"class": "pd w350 inpt",
id: "compose-jobopening-list",
name: "compose-jobopening-list",
value: joName,
readonly: "readonly"
}
}, {
name: "input",
attr: {
type: "hidden",
id: "compose-jobopening-list-hidden",
name: "compose-jobopening-list-hidden",
value: joId,
readonly: "readonly"
}
}]
});
$("#compose-jobopening-div").append(createElem)
} else {
{
var elem = $("#compose-jobopening-div"),
lookData = {
dataId: "compose-jobopening-list_img",
dataCID: "showLookup",
fldName: "compose-jobopening-list",
fldId: "compose-jobopening-list-hidden",
label: "compose-jobopening-list",
lookupModule: "Potentials",
placeholder: I18n.getMsg("crm.ss.search.module", Handlebars.helpers.getCrmModuleInfo("Potentials")),
module: "Leads"
};
$("#compose-jobopening-list")
}
ZRCommonUtil.autoComplete(elem, {
url: "/recruit/GetJoList.do",
params: {
mode: "fetchJoList"
},
inputid: "compose-jobopening-list",
classStr: "pd w350 inpt",
blockClass: "wd",
selectFun: function(event, ui) {
var inputElem = $("#compose-jobopening-list");
return inputElem.val(ui.item.label).data("selecteditem", ui.item), $("#compose-jobopening-list-hidden").val(ui.item.value), $("input[name=subject]").focus(), !1
},
lookup: lookData
})
}
document.getElementsByClassName("compose-jobopening")[0].style.display = "", ("" == ZRCommonUtil.FILTERJOBID || "Unassociated" == ZRCommonUtil.FILTERJOBID) && (document.getElementsByClassName("compose-jobopening")[1].style.display = "")
} else
check = !0
}
$("#insertTemplateDetail").empty(), document.getElementById("insertTemplateDetail").innerHTML = "<p class='mL10'>" + subject + "</p>"
} else
$("#insertTemplateDetail").empty(), document.getElementById("insertTemplateDetail").innerHTML = "<p class='mL10'>-<fmt:message key='Select Email Template'/>-</p>", check = !0;
check && "Leads" === tempModule && (document.getElementsByClassName("compose-jobopening")[0].style.display = "none", document.getElementsByClassName("compose-jobopening")[1].style.display = "none", $("#compose-jobopening-div").empty(), $("#associate").prop("checked", !1))
},
createAttachFileForManualTrigger: function(fileName, attachDetail) {
var attachId = attachDetail.attachid,
count = attachDetail.count,
isBulk = attachDetail.isbulk,
newcount = parseInt(count) + 1,
idStr = "MTAttachmentID_" + newcount;
if (fileName = ZRFileUtil.getFileName(fileName), !ZRCommonUtil.isEmpty(fileName)) {
var dotObj = ZRFileUtil.getAttachDotVal(fileName, "20");
fileName = dotObj.dotVal;
var titleStr = dotObj.title;
if (isBulk && "true" === isBulk) {
var elem = Utils.createHTML({
name: "span",
attr: {
"data-tf": "attach",
"data-attach": JSON.stringify(attachDetail),
"class": "fil attach-list new-attach",
title: titleStr
},
html: fileName,
child: [{
name: "a",
attr: {
href: "javascript:void(0)",
onclick: "ManualTrigger.deleteThisEmail(this);"
},
events: [{
name: "click",
fn: "ZRCommonUtil.removeAttachment",
args: [attachId, count]
}],
html: "x"
}]
});
$(".nsm-attach-category").prepend(elem);
var attachDetails = '{"attachid":"' + idStr + '","count":' + newcount + ',"isbulk":"true"}',
attachElem = Utils.createHTML({
name: "input",
attr: {
style: "opacity: 0;",
type: "file",
name: "manualTriggerAttachment_" + newcount,
onchange: "ZRCommonUtil.attachMoreUpload(undefined, this, ZRCommonUtil.createAttachFileForManualTrigger)",
"data-attachdetail": attachDetails,
id: idStr,
"class": "file-hide"
}
});
$("#" + attachId).hide(), $(".zrc-file-block").append(attachElem)
} else {
var elem = Utils.createHTML({
name: "span",
attr: {
"data-tf": "attach",
"data-attach": JSON.stringify(attachDetail),
"class": "fil attach-list new-attach",
title: titleStr
},
html: fileName,
child: [{
name: "a",
attr: {
href: "javascript:void(0)",
onclick: "ManualTrigger.deleteThisEmail(this);"
},
events: [{
name: "click",
fn: "ZRCommonUtil.removeAttachment",
args: [attachId, count]
}],
html: "x"
}]
});
$(".nsm-attach-category").prepend(elem)
}
}
},
constructAttachFile: function(fileName, attachDetail, inpName) {
var attachId = attachDetail.attachid,
count = attachDetail.count,
isBulk = attachDetail.isbulk,
newcount = parseInt(count) + 1,
moreAttachMsg = I18n.getMsg("crm.createform.section.attachmore");
"false" === isBulk && (2 == $("#theFile_" + attachId).children("span").length && $("#theFile_label_" + attachId).find("a").click(), moreAttachMsg = I18n.getMsg("crm.createform.section.browse"));
var idStr = "theFile_inp_" + attachId + "_" + newcount;
if (fileName = ZRFileUtil.getFileName(fileName), !ZRCommonUtil.isEmpty(fileName)) {
var dotObj = ZRFileUtil.getAttachDotVal(fileName, "20");
fileName = dotObj.dotVal;
var titleStr = dotObj.title,
elem = Utils.createHTML({
name: "span",
attr: {
"class": "attach-file-list btn-chosen-value",
title: titleStr
},
text: fileName,
child: [{
name: "a",
attr: {
href: "javascript:void(0)"
},
events: [{
name: "click",
fn: "ZRCommonUtil.removeAttachment",
args: [attachId, count]
}],
html: "&times;"
}]
});
$("#theFile_label_" + attachId).append(elem);
var attachElem = Utils.createHTML({
name: "span",
attr: {
id: idStr
},
child: [{
name: "a",
attr: {
href: "javascript:void(0)",
"class": " btn-chosen-file cus-file"
},
html: moreAttachMsg,
events: [{
name: "click",
fn: "ZRCommonUtil.triggerAttachClick"
}]
}, {
name: "input",
attr: {
"class": "file-hide",
style: "display:none",
uitype: "uploadfile",
"data-attachdetail": '{"attachid":"' + attachId + '", "count":"' + newcount + '", "isbulk":"' + isBulk + '"}',
type: "file",
name: inpName
},
events: [{
name: "change",
fn: "ZRCommonUtil.attachMoreUpload",
args: [ZRCommonUtil.constructAttachFile]
}]
}]
});
$("#theFile_" + attachId).append(attachElem), $("#" + idStr).siblings().hide()
}
},
removeAttachment: function(ev, target, attachId, count) {
$(target).parent().remove(), $("#theFile_inp_" + attachId + "_" + count).remove();
var childElem = $("#theFile_" + attachId).children();
1 == childElem.length && childElem.children("a.cus-file").html(I18n.getMsg("crm.createform.section.browse"))
},
getDotVal: function(value, len) {
var obj = {},
dotVal = value,
objLen = parseInt(len),
titleStr = "";
return value && null != value && "null" != value && value.length > objLen && (dotVal = value.substring(0, objLen), dotVal += "...", titleStr = value), obj.dotVal = dotVal, obj.title = titleStr, obj
},
scrollTo: function(elem, fast) {
fast = void 0 != fast ? fast : !1, $("html,body").animate({
scrollTop: elem.offset().top
}, fast ? "fast" : "slow")
},
openSaveAdvSearch: function() {
$(".attach-type-pop").remove();
var createElem = Utils.createHTML({
name: "div",
attr: {
"class": "attach-type-pop",
style: "display:none;"
},
child: [{
name: "a",
attr: {
"class": "zrc-icon-closeb close-confirm top20",
href: "javascript:void(0);"
},
events: [{
name: "click",
fn: "ZRCommonUtil.closeDialog",
args: [".attach-type-pop"]
}]
}, {
name: "h4",
attr: {
"class": "pop-heading"
},
html: I18n.getMsg("tab.candidates.advancesearch.search.savesearch")
}, {
name: "p",
child: [{
name: "label",
html: I18n.getMsg("tab.candidates.advancesearch.search.save") + ":"
}, {
name: "input",
attr: {
id: "saveSearchName",
name: "saveSearchName",
type: "text",
value: "",
"class": "textareachk",
"data-textarea": '{"maxlength": 100, "minlength": 50, "disablebtn": "advance_search_add"}'
}
}]
}, {
name: "div",
attr: {
"class": "btns-block mt50"
},
child: [{
name: "a",
attr: {
href: "javascript:void(0)",
"class": "primarybtn",
id: "advance_search_add"
},
html: I18n.getMsg("crm.button.add"),
events: [{
name: "click",
fn: "ZRCommonUtil.saveNewAdvSearch"
}]
}, {
name: "a",
attr: {
href: "javascript:void(0)",
"class": "newwhitebtn"
},
events: [{
name: "click",
fn: "ZRCommonUtil.closeDialog",
args: [".attach-type-pop"]
}],
html: I18n.getMsg("Cancel")
}]
}]
});
$("body").after(createElem), ZRCommonUtil.openDialog(".attach-type-pop"), $("#saveSearchName").focus()
},
saveAdvSearch: function() {
if (document.CreateCustomViewForm && document.CreateCustomViewForm.customviewname) {
var searchName = $("#saveSearchName").val();
document.CreateCustomViewForm.customviewname.value = searchName
}
emptyCheck("customviewname", I18n.getMsg("tab.candidates.advancesearch.search.save")) && document.CreateCustomViewForm && ("true" === document.CreateCustomViewForm.isSearch.value ? validate(!1, !0, void 0, "10") : validate(!1, !0))
},
saveNewAdvSearch: function() {
var searchName = $("#saveSearchName");
if (emptyCheck(searchName.attr("name"), I18n.getMsg("tab.candidates.advancesearch.search.save"))) {
var reg = /[^~`#%^&*()+={}[\]|\;"<>\\]/g,
splChars = getClrTxtPtnResChars(searchName.val(), reg);
if ("hidden" != searchName.type && "" != splChars) {
var fldProp = I18n.getMsg("crm.label.view.name");
return alert(1 == splChars.length ? I18n.getMsg("crm.clearTextPattern.validationFail.alert", [fldProp, splChars]) : I18n.getMsg("crm.clearTextPattern.validationFail.alert.moreThanOneChar", [fldProp, splChars])), !1
}
if (void 0 != searchName.val() && searchName.val().length > 50)
return alert(I18n.getMsg("crm.customview.alert.length")), !1;
var state = History.getState(),
dataObj = state.data;
for (var key in dataObj)
dataObj[key] = decodeURIComponent(dataObj[key]);
dataObj && dataObj.moduleName && ("Tasks" == dataObj.moduleName || "Events" == dataObj.moduleName || "Calls" == dataObj.moduleName) && (dataObj.module = "Activities"), "true" == dataObj.isSearch && (dataObj.customviewname = searchName.val(), doAjaxUpdate("saveAdvSearch", "/recruit/CreateCustomView.do", dataObj, function() {
crmTab.deleteFromCache(dataObj.module), Crm.addToHistory(void 0, void 0, {
clickId: "tab",
module: dataObj.module,
calleeObj: "crmTab",
clearCache: "true"
})
}))
}
},
parserOnClick: function(id) {
$("#" + id).click()
},
importXLSOnClick: function() {
var fileObject = $("#btn_UploadImportFile")[0].files[0],
shrinkedName = ZRCommonUtil.getDotVal(fileObject.name, 25),
size = ZRComponent.formatBytes(fileObject.size),
fileNameWithSize = shrinkedName.dotVal + " <span>" + size + "</span> <a class='import-close' href='javascript:;' title='Remove' onclick='javascript:ZRCommonUtil.removeAddedFile(this)'>&times;</a>";
$(".selectedFileBlk").html(fileNameWithSize).show().addClass("focus-line")
},
removeAddedFile: function(self) {
$("#btn_UploadImportFile").val(""), $(self).parent().html("&nbsp;"), $(".selectedFileBlk").removeClass("focus-line")
},
isValidWebUrl: function(fldLabel, url, isAlertNeed) {
if ("" === url)
return !0;
var httpProtocol = "http",
httpsProtocol = "https",
urlregex = new RegExp("^(" + httpProtocol + ":\\/\\/www.|" + httpsProtocol + ":\\/\\/www.|ftp:\\/\\/www.|www.|" + httpProtocol + ":\\/\\/|" + httpsProtocol + ":\\/\\/|ftp:\\/\\/|){1}[a-zA-Z0-9-€-ÿ]+(\\.[a-zA-Z0-9-\\_\\#\\:\\;\\?]+)+(/[\\w-\\;\\-\\*\\._\\?\\,\\:\\'/\\\\\\+&amp;%\\$#\\(\\)\\=~@€-ÿ]*)*$");
if (urlregex.test(url))
return !0;
if (void 0 == isAlertNeed || 1 == isAlertNeed) {
var replacedFldLabel = fldLabel.replace(/_____/g, ")").replace(/____/g, "(").replace(/___/g, ".");
alert(I18n.getValueForFields("crm.field.valid.check", replacedFldLabel))
}
return !1
},
showAdvSearchQuery: function(isSearchBar) {
if (isSearchBar && "true" === isSearchBar)
return ZRCommonUtil.showHideSearchPopOver($(this)), void sE(event);
var state = History.getState(),
params = state.data;
for (var key in params)
params[key] = decodeURIComponent(params[key]);
params.clickId = "CreateCV", params.action = "searchAgain", params.calleeObj = "Crm", "true" == params.isSearch && Crm.addToHistory(void 0, void 0, params)
},
fetchRecList: function(startLimit, rangeValue, sortCol, newAdvSearch, isTlinePrevOrNext, isQVPrevOrNext) {
if (startLimit && null != startLimit && void 0 != startLimit && "" != startLimit && "null" != startLimit && (document.CreateCustomViewForm && document.CreateCustomViewForm.startLimit ? document.CreateCustomViewForm.startLimit.value = startLimit : document.showcvdetails && document.showcvdetails.startLimit && (document.showcvdetails.startLimit.value = startLimit)), rangeValue && null != rangeValue && void 0 != rangeValue && "" != rangeValue && "null" != rangeValue && (document.CreateCustomViewForm && document.CreateCustomViewForm.range ? document.CreateCustomViewForm.range.value = rangeValue : document.showcvdetails && document.showcvdetails.range && (document.showcvdetails.range.value = rangeValue, document.showcvdetails.OnSelect && (document.showcvdetails.OnSelect.value = !0))), sortCol && null != sortCol && void 0 != sortCol && "" != sortCol && "null" != sortCol)
if (document.CreateCustomViewForm && document.CreateCustomViewForm.sortColumnString) {
var oldSortCol = document.CreateCustomViewForm.sortColumnString.value,
oldSortOrder = document.CreateCustomViewForm.sortOrderString.value;
oldSortCol && oldSortCol == sortCol && (document.CreateCustomViewForm.sortOrderString.value = oldSortOrder && "sort_desc" == oldSortOrder ? "sort_asc" : "sort_desc"), document.CreateCustomViewForm.sortColumnString.value = sortCol
} else if (document.showcvdetails && document.showcvdetails.sortColumnString) {
var oldSortCol = document.showcvdetails.sortColumnString.value,
oldSortOrder = document.showcvdetails.sortOrderString.value;
oldSortCol && oldSortCol == sortCol && (document.showcvdetails.sortOrderString.value = oldSortOrder && "sort_desc" == oldSortOrder ? "sort_asc" : "sort_desc"), document.showcvdetails.sortColumnString.value = sortCol
}
var module = $("#module").val();
if (module || (module = "Leads"), document.CreateCustomViewForm)
validate(!0, void 0, void 0, "10");
else if ("true" === newAdvSearch) {
var module = $("#module").val(),
searchString = $("#gsearchTextBox").val(),
sortOrderString = $('[name="sortOrderString"]').val();
("" == sortCol || "undefined" == sortCol) && (sortCol = $('input[name="sortColumnString"]').val()), ("" == rangeValue || "undefined" == rangeValue) && (rangeValue = $('input[name="range"]').val());
var postData = "moduleName=" + module + "&allKeywordSearch=" + encodeURIComponent(searchString) + "&isSearch=true&actionName=create&allFields=1&notesOnly=1&searchType=2&isSearchBar=true&sortOrderString=" + sortOrderString + "&sortColumnString=" + sortCol;
("Leads" === module || "Candidates" === module) && (postData += "&resumeOnly=1&otherAttachments=0", ("jobfilter" == ZRCommonUtil.FILTERRECORDS || "asspopout" == ZRCommonUtil.FILTERRECORDS) && (postData = postData + "&filterrecords=" + ZRCommonUtil.FILTERRECORDS + "&jobId=" + ZRCommonUtil.FILTERJOBID + "&status=" + ZRCommonUtil.FILTERCANDSTATUS + "&jobtitle=" + ZRCommonUtil.FILTERJOBNAME)), postData = postData + "&startLimit=" + startLimit + "&range=" + rangeValue, postData = postData + "&" + Territory.csrf();
var resObj = Utils.splitStringToObj(postData);
resObj.clickId = "advSearchResult", resObj.calleeObj = "Crm", isTlinePrevOrNext && (resObj.tlinePrevOrNext = isTlinePrevOrNext), isQVPrevOrNext && (resObj.qvPrevOrNext = isQVPrevOrNext), Crm.addToHistory(void 0, void 0, resObj)
} else {
var postData = formData2QueryString(document.showcvdetails);
"Leads" != module || "jobfilter" != ZRCommonUtil.FILTERRECORDS && "asspopout" != ZRCommonUtil.FILTERRECORDS || (postData = postData + "filterrecords=" + ZRCommonUtil.FILTERRECORDS + "&jobId=" + ZRCommonUtil.FILTERJOBID + "&status=" + ZRCommonUtil.FILTERCANDSTATUS + "&jobtitle=" + ZRCommonUtil.FILTERJOBNAME), doAjaxUpdate("advSearchResult", "/recruit/ShowSelectedCustomView.do?module=" + module + "&isload=false", postData, void 0, !0)
}
},
printPreviewDivContent: function(divId) {
var divContentsElem = $("#" + divId);
divContentsElem.find("input[name=chk]").remove(), divContentsElem.find("input[name=allcheck]").remove();
var divContents = divContentsElem.html(),
printWindow = window.open("", "", "height=400,width=800");
printWindow.document.write("<html><head><title>DIV Contents</title>"), printWindow.document.write("</head><body >"), printWindow.document.write("<link href='" + crmConstants.cssStaticPath + "/crmcontemporary.css' rel='stylesheet' type='text/css'>"), printWindow.document.write("<link href='" + crmConstants.cssStaticPath + "/recruit-style.css' rel='stylesheet' type='text/css'>"), printWindow.document.write("<link href='" + crmConstants.cssStaticPath + "/recruit-jobboards.css' rel='stylesheet' type='text/css'>"), printWindow.document.write("<div align='center'><input type='button' onclick='window.print()' value='Print Page' class='blueBtn' name='Print'> &nbsp; <input type='button' onclick='window.close()' value='Close' class='blueBtn' name='Close'></div>"), printWindow.document.write("<div class='advance-search-result'>"), printWindow.document.write(divContents), printWindow.document.write("</div>"), printWindow.document.write("<div align='center'><input type='button' onclick='window.print()' value='Print Page' class='blueBtn' name='Print'> &nbsp; <input type='button' onclick='window.close()' value='Close' class='blueBtn' name='Close'></div>"), printWindow.document.write("</body></html>"), printWindow.document.close()
},
fetchNaviSearchDetail: function(obj) {
var isSearch = obj.isSearch;
if (isSearch && ("true" == isSearch || 1 == isSearch)) {
var fetchRecordId = obj.id,
naviDataArrLen = parseInt(0),
naviDataArrIter = "";
naviDataArr && "" != naviDataArr.trim() && (naviDataArrIter = naviDataArr.split(","), naviDataArrLen = naviDataArrIter.length);
var prevRecord = "0",
nextRecord = "0";
if (0 == naviDataArrLen)
return void ZRCommonUtil.fetchNaviData(obj, naviDataArrIter, naviDataArrLen, prevRecord, nextRecord, 0);
for (var i = 0; naviDataArrLen > i; i++) {
var tempId = naviDataArrIter[i];
if (tempId && "undefined" != tempId && null != tempId && "null" != tempId && "" != tempId.trim() && fetchRecordId && "undefined" != fetchRecordId && null != fetchRecordId && "null" != fetchRecordId && "" != fetchRecordId.trim() && fetchRecordId == tempId) {
naviDataArrLen == i + 1 ? ZRCommonUtil.fetchNaviData(obj, naviDataArrIter, naviDataArrLen, prevRecord, nextRecord, i) : (naviDataArrLen - 1 > i && (nextRecord = naviDataArrIter[i + 1]), i > 0 && (prevRecord = naviDataArrIter[i - 1]), obj.nextRecord = "" + nextRecord, obj.prevRecord = "" + prevRecord, obj.isRecSearch = "true");
break
}
}
}
},
fetchNaviData: function(obj, naviDataArrIter, naviDataArrLen, prevRecord, nextRecord, i) {
if (void 0 != naviAdvDataUrl && "" != naviAdvDataUrl) {
obj && "Search Results" === obj.toolTip && "/recruit/ShowDetails.do" === naviAdvDataUrl && (naviAdvDataUrl = "/recruit/GSearch.do");
var urlToFetch = naviAdvDataUrl + "?" + decodeURIComponent(naviAdvDataParams),
parsedUrlObj = Utils.parseUrl(urlToFetch),
paramsObj = parsedUrlObj.params,
urlData = {};
if (void 0 != paramsObj) {
paramsObj.startLimit = naviDataArrLen + 1, paramsObj.range = 100, paramsObj.module = obj.module, paramsObj.sModules && (paramsObj.sModules = obj.module), paramsObj.searchCategory && (paramsObj.searchCategory = ""), paramsObj.fetchPkOnly = "true";
for (var key in paramsObj)
null != typeof paramsObj[key] && "" != typeof paramsObj[key] && "undefined" != typeof paramsObj[key] && (urlData[key] = paramsObj[key])
} else
urlData.startLimit = naviDataArrLen + 1, urlData.range = "100", urlData.module = obj.module, urlData.fetchPkOnly = "true";
("jobfilter" == ZRCommonUtil.FILTERRECORDS || "asspopout" == ZRCommonUtil.FILTERRECORDS) && (urlData.filterrecords = ZRCommonUtil.FILTERRECORDS, urlData.jobId = ZRCommonUtil.FILTERJOBID, urlData.status = ZRCommonUtil.FILTERCANDSTATUS, urlData.jobtitle = ZRCommonUtil.FILTERJOBNAME), ZRCommonUtil.ajaxPostMethod(naviAdvDataUrl, urlData, !1, "html", void 0, function(data) {
void 0 != naviDataArr && "" == naviDataArr ? naviDataArr = data : void 0 != naviDataArr && -1 == naviDataArr.indexOf(data) && (naviDataArr = naviDataArr + "," + data), naviDataArr && "" != naviDataArr.trim() && (naviDataArrIter = naviDataArr.split(","), naviDataArrLen = naviDataArrIter.length), naviDataArrLen - 1 > i && (nextRecord = naviDataArrIter[i + 1]), i > 0 && (prevRecord = naviDataArrIter[i - 1]), obj.nextRecord = "" + nextRecord, obj.prevRecord = "" + prevRecord, obj.isRecSearch = "true"
}, function() {})
}
},
triggerAttachClick: function(ev, target) {
var attachLimitsTD = $(target).closest("td");
if (attachLimitsTD) {
var attachLimitDetails = $(attachLimitsTD).data("attachLimitDetails");
if (attachLimitDetails) {
var attachLimit = parseInt(attachLimitDetails.attachLimit),
attachCount = (attachLimitDetails.checkLimit, $(".attach-file-list").length);
attachCount >= attachLimit ? alert(I18n.getMsg("crm.templateedit.attach.limit", attachLimit)) : $(target).next(".file-hide").click()
} else
$(target).next(".file-hide").click()
} else
$(target).next(".file-hide").click()
},
preventDefault: function(event) {
event = event || window.event, event.preventDefault && event.preventDefault(), event.returnValue = !1
},
showSuccessMessage: function(successMsg, timeDelay) {
crmui.showMsgBand("success", successMsg, void 0 != timeDelay && timeDelay >= 3e3 ? timeDelay : 5e3)
},
openConfirmationAlert: function(params, callee, args, cancelCallee, cancelArgs) {
var isNewPop = params && params.isNew ? params.isNew : !1;
if (isNewPop)
return params.callee = callee, params.args = args, params.cancelCallee = cancelCallee ? cancelCallee : "ZRCommonUtil.closeDialog", params.cancelArgs = cancelArgs ? cancelArgs : [".zpopup-modal"], params.makeConfirmationBox = !0, void ZRCommonUtil.createInfoBox(params);
cancelCallee || (cancelCallee = "ZRCommonUtil.closeDialog", cancelArgs = [".delete-confirm"]);
var removefreeze = params && params.removefreeze ? params.removefreeze : !0,
dialog = params && params.dialog ? params.dialog : "remove",
title = params && params.title ? params.title : I18n.getMsg("crm.image.delete.confirm"),
content = params && params.content ? params.content : "",
yesBtn = params && params.yesbutton ? params.yesbutton : I18n.getMsg("crm.button.ok"),
noBtn = params && params.nobutton ? params.nobutton : I18n.getMsg("crm.button.close"),
yesBtnClass = params && params.yesclass ? params.yesclass : "primarybtn",
classname = params && params.classname ? "delete-confirm bsd " + params.classname : "delete-confirm bsd",
headerTag = params && params.headerTag ? params.headerTag : "h4",
headerClass = params && params.headerClass ? params.headerClass : "delete-confirm-title",
createElem = Utils.createHTML({
name: "div",
attr: {
"class": classname,
"data-removefreeze": removefreeze,
"data-dialog": dialog
},
child: [{
name: headerTag,
attr: {
"class": headerClass
},
html: title
}, {
name: "div",
html: content
}, {
name: "div",
attr: {
"class": "delete-btns-block mT50"
},
child: [{
name: "a",
attr: {
"class": yesBtnClass,
href: "javascript:void(0)"
},
events: [{
name: "click",
fn: callee,
args: args
}],
html: yesBtn + " "
}, {
name: "a",
attr: {
href: "javascript:void(0)",
"class": "newgreybtn"
},
events: [{
name: "click",
fn: cancelCallee,
args: cancelArgs
}],
html: noBtn
}]
}]
});
$("body").append(createElem), ZRCommonUtil.openDialog(".delete-confirm")
},
applyNameSort: function(json, keyName) {
json && keyName && json.length <= 100 && json.sort(function(a, b) {
var nameA = a[keyName].toLowerCase(),
nameB = b[keyName].toLowerCase();
return nameB > nameA ? -1 : nameA > nameB ? 1 : 0
})
},
getPickListValue: function(params, callbackFun, errorFun) {
var urlData = "fieldid=" + params.fieldid + "&mode=combovalue&module=" + params.module;
ZRCommonUtil.ajaxGetMethod("/recruit/getPicklistValue.do", urlData, !1, "html", void 0, function(json) {
json = ZRCommonUtil.convertStringToJson(json), callbackFun && callbackFun(json)
}, function(xhr) {
var json = ZRCommonUtil.convertStringToJson(xhr.responseText);
errorFun && errorFun(json)
})
},
massUpdate: function(params, callbackFun, errorFun) {
var urlData = {};
urlData.module = params.module, urlData.mode = "massupdate", urlData.fieldid = params.fieldid, urlData.fieldvalue = params.fieldvalue, urlData.pkid = params.pkid, urlData.action = params.action, urlData.fromindex = params.fromindex, urlData.filterby = params.filterby, urlData.jobid = params.jobid, urlData.searchtxt = params.searchtxt, ZRCommonUtil.ajaxPostMethod("/recruit/MassUpdateFieldValue.do", urlData, !1, "html", void 0, function(json) {
json = ZRCommonUtil.convertStringToJson(json), callbackFun && callbackFun(json)
}, function(xhr, pasteDiv) {
errorFun ? errorFun(xhr, pasteDiv) : ZRCommonUtil.failureFunction(xhr, pasteDiv)
})
},
getTemplateDetail: function(templateId, callbackFun, errorFun) {
var selectedClient = $('input[name="compose-client-list-hidden"]').val(),
urlData = void 0,
bulkMail = void 0;
selectedClient ? urlData = "templateid=" + templateId + "&mode=getTemplateDetail&selectedClient=" + selectedClient : (urlData = "templateid=" + templateId + "&mode=getTemplateDetail", bulkMail = $("#mailsource").val(), void 0 != bulkMail && (urlData = urlData + "&bulkMail=" + bulkMail)), ZRCommonUtil.ajaxGetMethod("/recruit/GetTemplateDetail.do", urlData, !0, "html", void 0, function(json) {
json = ZRCommonUtil.convertStringToJson(json), callbackFun && callbackFun(json)
}, function(xhr) {
var json = ZRCommonUtil.convertStringToJson(xhr.reponseText);
errorFun && errorFun(json)
})
},
setEditorDetail: function(type, params) {
var mode = params && params.mode ? params.mode : "1",
content = params && params.content ? params.content : "",
modVal = void 0 != mode && null != mode && "1" == mode ? "richtext" : "plaintext",
editor = window[type];
"undefined" != typeof editor ? (editor.setContent(content), editor.setMode(modVal)) : ZRCommonUtil.createEditor(type, params)
},
createEditor: function(type, params) {
var idName = params && params.id ? params.id : "",
mode = params && params.mode ? params.mode : "1",
content = params && params.content ? params.content : "",
editorheight = params && params.editorHeight ? params.editorHeight : "",
onlyEditor = params && params.onlyeditor ? params.onlyeditor : !1,
textarea = params && params.textarea ? params.textarea : "textarea_" + idName,
input = params && params.input ? params.input : "input_" + idName,
modVal = void 0 != mode && null != mode && "1" == mode ? "richtext" : "plaintext",
toolbar = params && params.toolbar ? params.toolbar : "",
needPlainText = params && "false" == params.needplaintext ? !1 : !0,
editorFocus = params && "false" == params.needEditorFocus ? !1 : !0;
ZE_Init.needEditorFocus = editorFocus, ZE_Init.needplaintext = needPlainText, "" != toolbar && (ZE_Init.toolbarOrder = toolbar), window[type] = void 0;
var initobject = {
id: idName,
mode: modVal,
content: content,
editorheight: editorheight,
avoidMoreOption: "true"
};
if (window[type] = ZE.create(initobject), !onlyEditor && null != textarea && 0 != textarea.length) {
var createElem_textarea = Utils.createHTML({
name: "textarea",
attr: {
style: "display:none",
name: textarea,
id: "textarea_" + type,
value: content
}
}),
createElem_input = Utils.createHTML({
name: "input",
attr: {
name: input,
type: "hidden",
id: "input_" + type
}
}),
divId = document.getElementById(idName);
divId && void 0 != divId && (divId.parentNode.appendChild(createElem_textarea), divId.parentNode.appendChild(createElem_input))
}
"" != toolbar && ZRCommonUtil.setDefaultToolbarOder(), ZRCommonUtil.setEditorHeight()
},
setEditorHeight: function(parentId) {
var $ze_area = $(void 0 != parentId ? "#" + parentId + " .ze_area" : ".ze_area"),
editorHeight = $ze_area.height() > 50 ? $ze_area.height() : 250;
$ze_area.css("height", editorHeight), $ze_area.contents().find("body").css("height", editorHeight - 30)
},
setDefaultToolbarOder: function() {
ZE_Init.toolbarOrder = [[["bold", "Bold (Ctrl+B)", "zei-bold"], ["italic", "Italic (Ctrl+I)", "zei-italic"], ["underline", "Underline (Ctrl+U)", "zei-underline"], ["strikethrough", "Strikethrough", "zei-strike"]], [["fontfamily", "Font", "zei-fontfamily"]], [["fontsize", "Font Size", "zei-arrow"]], [["forecolor", "Font color", "zei-textclr"], ["backcolor", "Background Color", "zei-bgclr"]], [["alignoptions", "Fontstyle Options", "zei-textleft"], ["listoptions", "List Options", "zei-unorder"], ["indentoptions", "Indent Options", "zei-outdent"]], [["superscript", "superScript", "zei-superScript"]], [["subscript", "subScript", "zei-subScript"]], [["quote", "Insert Quote", "zei-quote"]], [["removeformat", "Remove Formatting", "zei-removeformat"]], [["link", "Insert Link", "zei-link"], ["edithtml", "editHtml", "zei-editHtml"], ["tableGrid", "Insert Table", "zei-table"], ["inserthorizontalrule", "Insert Horizontal Rule", "zei-line"], ["image", "Insert Image", "zei-image"]], [["spellcheck", "Check Spelling", "zei-spellCheck"]], [["otheroptions", "Plain Text", "zei-arrow ze-big"]]]
},
getEditorDetail: function(type) {
var editorObj = ZRCommonUtil.getEditorDetailAsJson(type),
contentId = document.getElementById("textarea_" + type);
contentId && void 0 != contentId && (contentId.value = editorObj.content);
var templateTypeId = document.getElementById("input_" + type);
templateTypeId && void 0 != templateTypeId && (templateTypeId.value = editorObj.type), void 0 == contentId || void 0 != contentId.value && null != contentId.value && "" != contentId.value.trim() || (contentId.value = "<br>", templateTypeId.value = "1")
},
getEditorDetailAsJson: function(type) {
var editorObj = {},
templateType = "1",
content = "",
editor = window[type],
contentMode = "richtext";
return "undefined" != typeof editor && (contentMode = editor.mode), null !== contentMode && "plaintext" === contentMode && (templateType = "2"), "undefined" != typeof editor && (content = editor.getContent()), editorObj.content = content, editorObj.type = templateType, editorObj
},
checkLength: function(fieldId, maxCount, message, errDiv) {
var tempBodyLen = $(fieldId).val().length;
message = message.replace("$maxcount", maxCount);
var errDivClass = "colGR",
remDivClass = "colR";
return tempBodyLen >= maxCount ? (errDivClass = "colR", remDivClass = "colGR", message = message.replace("$count", maxCount)) : message = message.replace("$count", tempBodyLen), $(errDiv).removeClass(remDivClass), $(errDiv).addClass(errDivClass).html(message), !1
},
entityActivityView: function(entityID, sIndex, module, resumeId, popupActivity, afterScroll) {
var userActivityUrl = "/recruit/DetailPageActivity.do",
params = {};
params.activityIndex = sIndex, params.entityId = entityID, params.module = module, ZRCommonUtil.ajaxGetMethod(userActivityUrl, params, !0, "json", void 0, function(resp) {
if (resp = null === resp || void 0 === resp ? {} : resp, resp.noRecords = !1, (void 0 === resp.activitiesArr || 0 === resp.activitiesArr.length) && (resp.noRecords = !0), afterScroll) {
var activityLogBlock = $("#EntityActivitiesBlock");
resp.afterScroll = !0;
var rtTemplate = Handlebars.getTemplate("right_panel", "RecruitTimeline"),
resText = rtTemplate(resp);
"0" == sIndex ? (activityLogBlock.html(""), activityLogBlock.html(resText)) : (activityLogBlock = $("#appendActivitiesDiv"), activityLogBlock.html(activityLogBlock.html() + resText), $("#activitiescntcheck").val("0"))
} else {
var divId = $("#timelineDiv");
if (void 0 != divId && 0 != divId.length) {
var timelineObj = $("#timeLineContainerDV"),
rtTemplate = Handlebars.getTemplate("right_panel", "RecruitTimeline"),
htmlText = rtTemplate(resp);
timelineObj.html(htmlText).show(), $("#newHistoryDiv").css("overflow", "auto");
var divheight = $(window).height() - 70;
$("#EntityActivitiesBlock").css({
height: divheight - 33
}), $("#newHistoryDiv").show()
}
}
void 0 !== timelineObj && timelineObj.perfectScrollbar("destroy"), ZRCommonUtil.fetchScrollData($(".activityScrollDiv"))
}, function(xhr) {
var divId = $("#timelineDiv");
xhr && "object" == typeof xhr && xhr.responseJSON && "Unauthorized" === xhr.responseJSON.Error ? ZRComponent.openAlertMessage({
type: "failure",
msg: I18n.getMsg("crm.security.error")
}) : void 0 != divId && 0 != divId.length && crmui.showMsgBand("error", I18n.getMsg("zr.timeline.error.occurred"), 5e3)
})
},
showbulkaudit: function(auditid) {
ZRCommonUtil.ajaxGetMethod("/recruit/ShowBulkAudit.do", "auditid=" + auditid, !0, "json", void 0, function(json) {
var comments = "";
json && ($.each(json, function(i, item) {
comments += item
}), $("#setupAudit_" + auditid).html(comments).toggle())
}, function() {
crmui.showMsgBand("error", I18n.getMsg("crm.feedback.failureMessage"), 5e3)
})
},
showbulkactivity: function(pkid, module, page) {
var constructval;
if ("setup" == page) {
if ("block" == document.getElementById("setupcomment_" + pkid).style.display)
return void (document.getElementById("setupcomment_" + pkid).style.display = "none")
} else if ("block" == document.getElementById("activitynote_" + pkid).style.display)
return void (document.getElementById("activitynote_" + pkid).style.display = "none");
ZRCommonUtil.ajaxGetMethod("/recruit/ShowBulkActivity.do", "activityid=" + pkid + "&module=" + module, !0, "json", void 0, function(json) {
json && $.each(json, function(i, item) {
var id = item.id,
value = item.value,
link = "";
link = "setup" == page ? "<a href='/recruit/EntityInfo.do?module=" + module + "&id=" + id + "' target='_blank'>" + value + "</a>" : "<a href='/recruit/EntityInfo.do?module=" + module + "&id=" + id + "' data-cid='detailView' data-params='{\"module\":\"" + module + '","id":"' + id + '","pfrom":"rel","lookback":"true"}\'>' + value + "</a>", null == constructval ? constructval = link : constructval += ", " + link
}), "setup" == page ? $("#setupnote_" + pkid).html(constructval).toggle() : $("#activitynote_" + pkid).html(constructval).toggle()
}, function() {})
},
recentcomments: function(id, page) {
"setup" == page ? $("#setupcomment_" + id).toggle() : $("#activitycomment_" + id).toggle()
},
setCheckboxValue: function(target) {
var tgt = $(target);
tgt.val(tgt.is(":checked") ? "true" : "false")
},
unlockandqualifypopup: function(event) {
var tgt = $(event.target),
pkid = tgt.data("pkid"),
listview = tgt.data("listview"),
assPopOutView = tgt.data("asspopview"),
module = tgt.data("module");
listview || (listview = !1), assPopOutView || (assPopOutView = !1);
var title,
type,
arrowclass = "qcRight";
tgt.is("a.icon-disq") || tgt.is("a.icon-disq-active") ? (title = I18n.getMsg("crm.leads.qualify"), type = "disq", arrowclass = "qcLeft") : tgt.is("a.icon-lock") || tgt.is("a.icon-lock-active") ? (title = I18n.getMsg("crm.leads.unlock"), type = "lock", arrowclass = "qcLeft") : tgt.is("input#Follow_btn.fbtn") || tgt.is("input#Follow_btn_asspop.fbtn") || tgt.is("input#Follow_btn_asspop") ? (title = tgt.val(), type = tgt.data("type"), arrowclass = "qcRight") : tgt.is("input#Follow_btn") && (title = tgt.val(), type = tgt.data("type"), arrowclass = "qcRight"), $(".notes-block").remove();
var cancelFun = function() {
$(".notes-block").remove()
},
createElem = Utils.createHTML({
name: "div",
attr: {
"class": "notes-block"
},
child: [{
name: "div",
attr: {
"class": "qcpopuparrow " + arrowclass
}
}, {
name: "h6",
attr: {
"class": "cmnt-heading"
},
html: title
}, {
name: "textarea",
attr: {
placeholder: I18n.getMsg("crm.potential.associate.popout.entercomments"),
"class": "textareachk",
"data-textarea": '{"maxlength": 6000, "minlength": 100, "method": "after"}',
id: "hot-comment",
value: ""
},
html: ""
}, {
name: "input",
attr: {
type: "button",
"class": "btn mR10",
"data-pkid": pkid,
"data-module": module,
"data-listview": listview,
"data-asspopview": assPopOutView,
"data-type": type,
value: I18n.getMsg("crm.button.add")
},
events: [{
name: "click",
fn: "ZRCommonUtil.unlockandqualifyajax"
}]
}, {
name: "a",
attr: {
"class": "fbllink",
href: "javascript:void(0);"
},
events: [{
name: "click",
fn: cancelFun
}],
html: I18n.getMsg("crm.button.cancel")
}]
});
$("body").append(createElem);
var pasteDiv = $(".notes-block"),
pos = tgt ? ZRCommonUtil.getPopoverPosition(tgt) : {};
pos && (pasteDiv.css({
top: pos.top + "px",
left: pos.left + "px"
}), pasteDiv.children("." + arrowclass).css(listview ? {
top: pos.arrowPos + "px",
left: "-12px"
} : {
top: pos.arrowPos + "px",
right: "-12px"
}))
},
unlockandqualifyajax: function(event) {
var status,
typeid,
tgt = $(event.target),
type = tgt.data("type"),
module = tgt.data("module");
"Leads" === module ? "lock" === type ? (status = "Hired", typeid = "#icon-lock-") : "disq" === type && (status = "Qualified", typeid = "#icon-disq-") : "Potentials" === module && "lock" === type && (status = "In-progress", typeid = "#icon-lock-");
var pkid = tgt.data("pkid") + "",
textarea = document.getElementById("hot-comment").value,
listview = tgt.data("listview"),
assPopOutView = tgt.data("asspopview"),
urlData = {
module: module,
entityId: pkid,
comments: textarea,
status: status,
listview: listview,
action: "open"
};
ZRCommonUtil.ajaxPostMethod("/recruit/UpdateResumeStatus.do", urlData, !1, "html", void 0, function(json) {
if (json = ZRCommonUtil.convertStringToJson(json), json && json.message && "success" == json.message) {
if ($("#change-status-popup, .notes-block").hide(), assPopOutView) {
$(typeid + pkid).remove();
var jobId = $("input#Follow_btn_asspop").data("jobid");
ZRAssociateUtil.loadAssociateDetail(jobId, pkid)
} else if (listview) {
var name = $("#listView_" + pkid).html(),
tdElem = $(typeid + pkid).parent();
tdElem.html('<input type="checkbox" value="' + pkid + "&&||" + name + '" name="chk">')
} else {
var url = "/recruit/ShowEntityInfo.do?id=" + getObj("id").value + "&module=" + getObj("module").value + "&cvid=" + getObj("cvid").value + "&recordNum=" + getObj("recordNum").value;
doAjaxUpdate("show", url)
}
ZRCommonUtil.showSuccessMessage(I18n.getMsg("crm.label.success.status")), crmTab.deleteFromCache(module)
}
}, function(xhr) {
var json = xhr.responseText;
json = ZRCommonUtil.convertStringToJson(json), json && json.message && "failure" === json.message ? alert(I18n.getMsg("crm.error.changestatus")) : json && json.message && "FLEEMessageIAR" === json.message ? alert(I18n.getMsg(json.fmtkey_fleeMessage, [json.edition, json.featureLimitCount, json.featureType])) : json && json.message && "INVALID_NUMBER_OF_POSITIONS" === json.message && (alert(I18n.getMsg("errors.potentials.numberofpositions")), $("#number_of_positions").focus())
})
},
recentstatuseditoverload: function(event, tgt, isRowExist, status) {
ZRCommonUtil.recentstatusedit(event.target, isRowExist, status)
},
removeCandidateActions: function(pkid, module, type, value) {
var tdElem = $("#status_lock_spn").parent();
tdElem.html('<span id="status_lock_spn" class="dB"><input type="hidden" value="true" id="isCandidatesLocked"/><input type="button" data-positiondata=\'{"modal":".notes-block", "placement":"left"}\' class="newgraybtn" id="Follow_btn" data-pkid=' + pkid + " data-type=" + type + ' data-listview="false" data-module=' + module + ' name="Follow_btn" value="' + value + '" onclick="ZRStatusUtil.recentstatusedit(this)"> </span>'), $("#add-new-iw-link, #add-new-jo-link, #add-existing-jo-link").hide(), $("input[data-cid=convert], td.tableData div a.sl, span.sep, #detailddMenu a[name=mailmerge], #detailddMenu a[name=Duplicate2], #singleGenerateFormattedResumeId, #candidateInvitationStatusId, div#relLink, #detail-tag-list div div a, a#createlink, div.normalDropDown, #detail_status_link").remove(), $("#detail-tag-list div div.tagsBlock span").attr("style", "padding:0 13px 0 13px;");
var linkElem = $("a.rellistNew");
linkElem = ZRCommonUtil.allowCandidateActions(linkElem), $.each(linkElem, function(i, item) {
void 0 != item && void 0 != item.id && "note_desktop" != item.id && $(item).remove()
})
},
allowCandidateActions: function(linkElem) {
var linkRelElem = [],
persStrObj = getAccessibleObj("personalityArr"),
listRel = [];
if (persStrObj) {
var arrVal = persStrObj.value,
persArrObj = arrVal.split("||"),
attachIndex = void 0,
attachParent = void 0;
persArrObj.length > 0 && (attachIndex = $.inArray(!0, $.map(persArrObj, function(item) {
return item.indexOf("attachmentspersonality") > -1
})), attachParent = attachIndex > -1 ? function(attachInd) {
var listRelId = persArrObj[attachInd].split("_")[1];
listRel.push("ract_" + listRelId), listRel.push("ra_" + listRelId), listRel.push("norec_" + listRelId)
} : void 0, void 0 != attachParent && attachParent(attachIndex), attachIndex = $.inArray(!0, $.map(persArrObj, function(item) {
return item.indexOf("emailspersonality") > -1
})), attachParent = attachIndex > -1 ? function(attachInd) {
var listRelId = persArrObj[attachInd].split("_")[1];
listRel.push("ract_" + listRelId), listRel.push("ra_" + listRelId), listRel.push("norec_" + listRelId)
} : void 0, void 0 != attachParent && attachParent(attachIndex))
}
return listRel.push("putMailOpt"), listRel.push("getMailOpt"), $.each(linkElem, function(i, item) {
var itemParent = $(item).parent().attr("id"),
index = listRel.indexOf(itemParent);
-1 == index && linkRelElem.push(item)
}), linkRelElem
},
pasteDocumentUploadFile: function() {
var value = $("#pasteresumearea").val();
if (0 == value.length)
return crmui.showMsgBand("error", I18n.getMsg("crm.leads.pasteresume.error"), 5e3), !1;
for (var liElem = $("ul#selectedTagsList>li"), tagIdStr = "", i = 0; i < liElem.length; i++) {
var elem = $(liElem[i]),
tagLabel = elem.data("taglabel");
tagIdStr = tagLabel && 0 != tagLabel.length ? tagLabel + ";" + tagIdStr : tagIdStr
}
if ($("#layoutId").length > 0 && "none" == $("#layoutId").val())
return crmui.showMsgBand("error", I18n.getMsg("crm.label.choose.layout.alert"), 5e3), !1;
var inpElem = $("#ass-cand-tag-text"),
tagName = inpElem.val();
tagIdStr = tagName && 0 != tagName.length ? tagName + ";" + tagIdStr : tagIdStr, tagIdStr.length > 0 && (document.pasteresumefile.taglist.value = tagIdStr);
var callbacks = {
success: function(data) {
if ($("#ajax_load_tab").hide(), data = ZRCommonUtil.convertStringToJson(data), window.leadid = data.leadid, window.importstatus = data.status, window.action = data.action, void 0 != data.isPREnabled && "true" === data.isPREnabled) {
var parserPage = document.createElement("parser-intermediate-page");
parserPage.setAttribute("id", "parser-intermediate-page-comp"), parserPage.setData({
fieldValData: data.resObj,
joId: data.assojoId,
tagList: data.tagListStr,
parserSource: data.parserSource,
filePath: data.filePath,
dupEntId: data.dupEntId,
fileName: data.fileName,
isApproved: data.isApproved,
fileFormat: data.fileFormat,
larId: data.larId,
optOutCand: data.optOutCand,
onDup: data.onDup,
saveAndNew: data.saveAndNew,
modifiedFilename: data.modifiedFilename
}), $("#pasteResume_panel").html(parserPage)
} else
ZRCommonUtil.resumeparser("Leads", "", "", "", data.action)
},
fail: function(data) {
var errorJson = ZRCommonUtil.convertStringToJson(data);
ZRCommonUtil.createInfoBox("FLEEMessageIAR" == errorJson.message & "Standard" == errorJson.licenseName ? {
title: I18n.getMsg("zr.parser.limit.exceed.title"),
content: I18n.getMsg("zr.parser.limit.exceed.standard"),
saveclass: "primarybtn"
} : "FLEEMessageIAR" == errorJson.message & "Professional" == errorJson.licenseName ? {
title: I18n.getMsg("zr.parser.limit.exceed.title"),
content: I18n.getMsg("zr.parser.limit.exceed.professional"),
saveclass: "primarybtn"
} : {
title: I18n.getMsg("crm.livedesk.error"),
content: I18n.getMsg("crm.security.error.add.user"),
saveclass: "primarybtn"
})
}
};
ZRCommonUtil.getAssociateJOForImport("#Crm_Import_Leads_POTENTIALID", "[name=associdatedjo]");
var formData = ZRCommonUtil.formData2Query(document.pasteresumefile);
return ZRCommonUtil.ajaxUpload("/recruit/PasteResumeUpload.do", formData, callbacks, "json", !1, !1), !1
},
resumeParserUploadStatus: function(status, statusof) {
var actualurl = window.location;
if (actualurl && (actualurl = String(actualurl)), actualurl.indexOf("ImportParser") > -1 || actualurl.indexOf("generateFormattedResume") > -1 || actualurl.indexOf("BulkParser") > -1) {
if (void 0 != status && "false" == status) {
var state = History.getState().hash;
state.indexOf("ImportParser") > -1 || state.indexOf("BulkParser") > -1 ? setTimeout(ajaxNew("/recruit/ImportFromDocument.do?module=Leads&type=importfromdocument"), time) : "FormattedResume" == statusof && setTimeout(ajaxNew("/recruit/getFormattedResumeStatus.do?module=Leads&type=importfromdocument"), time)
}
} else
$("#resume_parser_notes").is(":visible") && "FormattedResume" == statusof && setTimeout(ajaxNew("/recruit/getFormattedResumeStatus.do?module=Leads&type=importfromdocument&source=formattedResume"), time)
},
resumeparser: function(module, parserBusy, statusof, total, action) {
if (void 0 != action && "trialexpired" == action)
return void alert("To continue upload please upgrade");
if (void 0 != action && "singleparser" == action) {
var leadidstr = window.leadid,
status = window.importstatus;
if (3 === status) {
var savefn = function(ev, target) {
ZRCommonUtil.closeDialog(ev, target, "#modal-block"), Crm.addToHistory(void 0, void 0, {
clickId: "detailView",
module: module,
id: leadidstr
})
},
cancelfn = function(ev, target) {
$(".fileNameInIFD").remove();
var importButton = $("#resume_parser_import_id");
importButton.val(I18n.getMsg("crm.lead.resume.ImportResumes")), importButton.attr("disabled", !1), ZRCommonUtil.closeDialog(ev, target, "#modal-block")
};
return void ZRCommonUtil.openConfirmationAlert({
isNew: !0,
messageType: "warning",
content: I18n.getMsg("crm.import.duplicate.error"),
savebtn: I18n.getMsg("crm.import.duplicate.view"),
nobutton: I18n.getMsg("crm.import.duplicate.continue")
}, savefn, void 0, cancelfn, void 0)
}
if (10 === status) {
var msg = I18n.getMsg("zr.import.parser.coverletter.noemail.skip");
alert(msg);
var state = History.getState().hash;
return void ajaxNew(state.indexOf("PasteParser") > -1 ? "/recruit/ImportFromDocument.do?module=Leads&toolTip=Leads&paste=pasteparser" : "/recruit/ImportFromDocument.do?module=Leads&type=importfromdocument")
}
return void (void 0 == leadidstr || null == leadidstr || "null" == leadidstr ? (alert("Please try agin"), ajaxNew("/recruit/ImportFromDocument.do?module=Leads&type=importfromdocument")) : document.location.href = "/recruit/EntityInfo.do?module=" + ZRCommonUtil.ZCMODULEMAP[module] + "&id=" + leadidstr)
}
void 0 != action && "pastedata" == action && ajaxNew("/recruit/ImportFromDocument.do?module=Leads&paste=pasteparser"), void 0 != action && "limitExceeded" == action && ($("#spaceExceeded").attr("style", ""), $("#dslimit").html(window.dslimitStr), $("#resume_parser_import_id").attr("value", I18n.getMsg("crm.lead.resume.ImportResumes")), $("#resume_parser_import_id").removeAttr("disabled")), void 0 != action && "parseddata" == action && ajaxNew("/recruit/ImportFromDocument.do?module=Leads&type=importfromdocument"), void 0 != action && "uploadExceeded" == action && ($("#resume_parser_import_id").attr("value", I18n.getMsg("crm.lead.resume.ImportResumes")), $("#resume_parser_import_id").removeAttr("disabled")), time = 6 >= total ? 5e3 : 1e4, setTimeout(function() {
ZRCommonUtil.resumeParserUploadStatus(parserBusy, statusof)
}, time)
},
getParserValues: function(val) {
$("#parser_test_result").hide(), $("#parserfilelist").html(""), "true" == val ? ($("#resumeparsermapping").hide(), $("#parser_user_test_doc").show()) : ($("#parser_user_test_doc").hide(), $("#resumeparsermapping").show(), $("#testfilename").text(I18n.getMsg("crm.setup.parsersettings.test.tobrowsefile"))), document.body.scrollTop = 0
},
parsermappingstatus: function() {
var action = window.action;
if (void 0 != action && "parsermapping" == action) {
var message = I18n.getMsg("crm.setup.resumeparsermapping.changessuccessfullyupdated");
crmui.showMsgBand("success", message, 4e3)
} else if (void 0 != action && "emptymapping" == action) {
var message = I18n.getMsg("crm.setup.resumeparsermapping.emptymappingnotallowed");
crmui.showMsgBand("warning", message, 4e3)
} else if (void 0 != action && "parsertest" == action) {
var iframe = getElemById("parsermappingframe"),
iframeElem = Utils.getIFrameDoc(iframe),
iframeContent = $(iframeElem).find("body").html();
$("#parser_test_result").html(iframeContent).show()
}
},
refreshRelatedList: function(personalityname, emailist) {
reloadPersonality(personalityname, emailist)
},
publishInWebsite: function(elem, fieldId) {
var enable = "false";
$(elem).is(":checked") && (enable = "true");
var urlData = {};
urlData.fieldid = fieldId, urlData.isenable = enable, ZRCommonUtil.ajaxPostMethod("/recruit/PublishInWebsite.do", urlData, !1, "json", void 0, function(json) {
json = ZRCommonUtil.convertStringToJson(json), json && json.message && "success" === json.message ? "true" == enable ? $(elem).attr("checked", "true") : $(elem).removeAttr("checked") : "true" == enable ? $(elem).removeAttr("checked") : $(elem).attr("checked", "true")
}, function() {
alert(I18n.getMsg("crm.security.error.add.user"))
})
},
htmlEscape: function(value) {
return value && null != value && "null" != value && (value = value.replace(/"/g, "&quot;"), value = value.replace(/'/g, "&#39;"), value = value.replace(/</g, "&lt;"), value = value.replace(/>/g, "&gt;")), value
},
getStaffingType: function() {
var accModName = ZRCommonUtil.ZCMODULEMAP.Accounts;
return "Departments" == accModName ? 1 : 2
},
initiateSocialDataFetch: function() {
var alreadyFetched = ZRCommonUtil.ISSOCIALNOTIFIED;
if (!alreadyFetched) {
var urlData = {};
urlData.action = "initiate_data_fetch", urlData.notifysocial = "true", ZRCommonUtil.ajaxGetMethod("/recruit/SocialSettings.do", urlData, void 0, void 0, void 0, function(resp) {
resp && "true" === resp && (ZRCommonUtil.ISSOCIALNOTIFIED = !0)
}, void 0)
}
},
loadMigrationRequestForm: function() {
ZRCommonUtil.ajaxPostMethod("/recruit/MigrationRequestForm.do", "", !1, "html", void 0, function(data) {
ZRCommonUtil.createModal({
title: I18n.getMsg("crm.submit.migration.request"),
content: data,
savefn: "ZRCommonUtil.validateMigrationRequestForm",
savebtn: I18n.getMsg("crm.button.submit")
})
}, function() {})
},
createEditThanksMessage: function(module) {
var templatemessage = $("#templatemessage").val(),
editormode = $("#editormode").val();
ZRCommonUtil.ajaxGetMethod("/recruit/WebFormConfirmationMessage.do", "operation=thanksmessage&module=" + module, !1, "html", void 0, function(data) {
ZRCommonUtil.createModal({
modalclass: "zindex zr-submessage",
title: I18n.getMsg("zr.webform.editor.submission.message"),
content: data,
savefn: "ZRCommonUtil.saveMessage",
cancelfn: "ZRCommonUtil.cancelMessage",
savebtn: I18n.getMsg("crm.button.submit"),
callback: function() {
(null == templatemessage || "null" == templatemessage || "" == templatemessage || void 0 == templatemessage || "undefined" == templatemessage) && (templatemessage = I18n.getMsg("zr.webform.editor.thanks.message")), ZRCommonUtil.createEditor("editor", {
id: "emailEditor",
toolbar: [[["bold", "Bold (Ctrl+B)", "zei-bold"], ["italic", "Italic (Ctrl+I)", "zei-italic"], ["underline", "Underline (Ctrl+U)", "zei-underline"], ["strikethrough", "Strikethrough", "zei-strike"]], [["fontfamily", "Font", "zei-fontfamily"]], [["fontsize", "Font Size", "zei-arrow"]], [["forecolor", "Font color", "zei-textclr"], ["backcolor", "Background Color", "zei-bgclr"]], [["alignoptions", "Fontstyle Options", "zei-textleft"], ["listoptions", "List Options", "zei-unorder"], ["indentoptions", "Indent Options", "zei-outdent"]], [["quote", "Insert Quote", "zei-quote"]], [["removeformat", "Remove Formatting", "zei-removeformat"]], [["spellcheck", "Check Spelling", "zei-spellCheck"]], [["otheroptions", "Plain Text", "zei-arrow ze-big"]]],
content: templatemessage,
mode: editormode,
removefreeze: "true",
editorHeight: 250
})
}
}), Utils.bindChosen($(".zr-submessage").find("select"))
}, function(xhr) {
var json = xhr.responseText;
json = ZRCommonUtil.convertStringToJson(json), json && json.message && "failure" === json.message && alert(I18n.getMsg("crm.error.changestatus"))
})
},
saveMessage: function() {
var editorObj = ZRCommonUtil.getEditorDetailAsJson("editor"),
content = editorObj.content,
editormode = editorObj.type;
$("#editormode").val(editormode);
var htmlremovedcontent = content.replace(/<(?:.|\n)*?>/gi, "").replace(/&nbsp;/gi, " ");
if (htmlremovedcontent.length > 2e3)
alert(I18n.getMsg("zr.webform.editor.lenthcheck"));
else if (htmlremovedcontent.trim().length < 1)
alert(I18n.getMsg("zr.webform.editor.submitmessage.emptycheck"));
else {
if (null != content && "null" != content && "" != content && void 0 != content && "undefined" != content) {
var modField = $("#jsonForMergefields").data("mergeFieldsData"),
msgUnsupportedList = CrmConvertMergeFields.getUnsupportedFieldsList(content, modField);
if (msgUnsupportedList.length > 0)
return ZRCommonUtil.showUnsupportedFieldsList(void 0, msgUnsupportedList, void 0, editormode), !1;
$("#templatemessage").val(content), htmlremovedcontent.length > 90 && (htmlremovedcontent = htmlremovedcontent.substring(0, 91) + "..."), $("#htmlremovedtemplatemessage").text($("<div/>").html(htmlremovedcontent).text())
}
ZRCommonUtil.closeDialog(void 0, void 0, "#modal-block")
}
},
cancelMessage: function() {
ZRCommonUtil.closeDialog(void 0, void 0, "#modal-block")
},
submitdetailsmandatecheck: function() {
var submitmessage = $("#submitmessage").prop("checked"),
landingpage = $("#landingpage").prop("checked");
submitmessage || landingpage ? $("#applicantConfirmDetailsAlert").css("visibility", "hidden") : (alert(I18n.getMsg("zr.webform.editor.confirmationdetails.mandatorycheck")), $("#applicantConfirmDetailsAlert").css("visibility", "visible"))
},
validateMigrationRequestForm: function() {
var name = $("#mig_name"),
email = $("#mig_email");
if ("" == email.val() || email.val() == email.attr("placeholder"))
return alert(I18n.getMsg("crm.migration.request.form.alert.email")), email.focus(), !1;
var phone = $("#mig_phone"),
company = $("#mig_company"),
country = $($("#mig_country")),
vendor = $("#mig_vendor");
if ("" == vendor.val() || vendor.val() == vendor.attr("placeholder"))
return alert(I18n.getMsg("crm.migration.request.form.alert.vendor")), vendor.focus(), !1;
var users = $("#mig_users");
if ("" == users.val() || users.val() == users.attr("placeholder"))
return alert(I18n.getMsg("crm.migration.request.form.alert.users")), users.focus(), !1;
var expected = $("#mig_expectedtime"),
desc = $("#mig_description"),
urlData = {};
urlData.mig_name = name.val(), urlData.mig_email = email.val(), urlData.mig_phone = phone.val(), urlData.mig_company = company.val(), urlData.mig_country = country.val(), urlData.mig_vendor = vendor.val(), urlData.mig_users = users.val(), urlData.mig_expected = expected.val(), urlData.mig_desc = desc.val(), ZRCommonUtil.ajaxPostMethod("/recruit/SubmitMigrationRequestForm.do", urlData, !1, "html", void 0, function() {
ZRCommonUtil.closeDialog(void 0, void 0, "#modal-block"), ZRCommonUtil.showSuccessMessage(I18n.getMsg("crm.migration.request.form.alert.success"))
}, function() {
alert(I18n.getMsg("crm.migration.request.form.alert.failure"))
})
},
setStartDateTime: function(calenderNode) {
if ($(calenderNode).is($("input[name='property(Start DateTime)']")) && $("input[name='property(End DateTime)']").length > 0) {
var time = $("input[id='Start DateTimedateTime']").val();
"hh:mm a" === Crm.userDetails.TIME_FORMAT && (time += " " + $("input[name='property(Start DateTimeampm)']").val());
var date = $(calenderNode).val();
ZRCommonUtil.setEndDateAndTime(date + " " + time)
}
},
setEndDateAndTime: function(startdate) {
var is24HrsFormat = !1;
"HH:mm" === Crm.userDetails.TIME_FORMAT && (is24HrsFormat = !0);
var dtObj = new Date(crmCalendar.getDateObjectFromGivenDateString(startdate)),
hr = trimBoth($("input[id='Start DateTimedateTime']").val().split(" ")[0]);
if (dtObj) {
var meridiem = is24HrsFormat ? "" : $('input[name="property(Start DateTimeampm)"]').val().toUpperCase();
dtObj.setHours(is24HrsFormat ? parseInt(hr.split(":")[0], 10) : Utils.convertTimeTo24HoursFormat(parseInt(hr.split(":")[0], 10), meridiem)), dtObj.setMinutes(parseInt(hr.split(":")[1], 10) + 60)
}
if (is24HrsFormat)
$("input[id='End DateTimedateTime']").val(Utils.formatTimeVal(dtObj.getHours()) + ":" + Utils.formatTimeVal(dtObj.getMinutes())), $("input[name='property(End DateTimehour)']").val(Utils.formatTimeVal(dtObj.getHours())), $("input[name='property(End DateTimeminute)']").val(Utils.formatTimeVal(dtObj.getMinutes()));
else {
var timeObj = Utils.convertTo12HoursFormatTimeObj(dtObj);
$("input[id='End DateTimedateTime']").val(timeObj.hrs + ":" + timeObj.mins), $("input[name='property(End DateTimehour)']").val(timeObj.hrs), $("input[name='property(End DateTimeminute)']").val(timeObj.mins), $("input[name='property(End DateTimeampm)']").val(timeObj.meridiem.toUpperCase()), $("input[name='property(End DateTimeampm)']").next().html(I18n.getMsg(timeObj.meridiem.toUpperCase()))
}
$("input[name='property(End DateTime)']").val(crmCalendar.convertToUserDatePattern(dtObj.getDate() + " " + dtObj.getMonth() + " " + dtObj.getFullYear())), $("input[name='property(End DateTime)']").data("dateObj", dtObj)
},
getPartialTemplate: function(folderName, templateName) {
return templateName ? ZRCommonUtil.getTemplateContent(folderName, templateName) : void 0
},
getTemplateContent: function(folderName, templateName) {
return templateName && null != templateName ? Handlebars.getTemplate(folderName, templateName) : void 0
},
replaceTemplateData: function(data, templateName, folderName) {
if (data && templateName) {
var template = ZRCommonUtil.getTemplateContent(folderName, templateName);
return template(data)
}
},
saveCompanyLogo: function() {
if ($("#companyLogo:visible").length > 0 && "" === $("#companyLogo").val())
return ZRCommonUtil.displayErrorMsg("gSErrorMsg", I18n.getMsg("crm.gs.logo.select.logo")), !1;
var formData = formData2QueryString(document.uploadLogo),
postData = Utils.splitStringToObj(formData);
return $(".zrc-btns-block").find(".zrc-btn-primary").val(I18n.getMsg("crm.saving")), ZRCommonUtil.ajaxFormSubmit("/recruit/updateCompanyLogo.do?actionName=updateOrgLogo", postData, document.uploadLogo, void 0, !1), !1
},
changeCompanyLogo: function() {
$("#companyLogo").toggle(), "change" === $("#changeImage").data("oper") ? ($("#changeImage").html(I18n.getMsg("crm.button.mass.hide")), $("#changeImage").data("oper", "hide"), $("#cl .zrc-btn-primary").show()) : "hide" === $("#changeImage").data("oper") && ($("#changeImage").html(I18n.getMsg("crm.label.change.image")), $("#changeImage").data("oper", "change"), $("#cl .zrc-btn-primary").hide())
},
getCompanyLogoUpdateForm: function() {
var callBackFun = {
successFunc: function(data) {
$("#alert-message").length > 0 && $("#alert-message").remove(), $("#cl").show(), "success" === data.status ? (ZRCommonUtil.openModal("#cl"), $('input[name="orgId"]').val(data.orgId), $('input[name="orgName"]').val(data.orgName), -1 != data.logoFileId && "null" !== data.logoFileId && "" !== data.logoFileId ? ($("#getStartImageId").prop("src", "/recruit/viewCompanyLogo?fileId=" + data.logoFileId).show(), $("#companyLogo").hide(), $("#changeImage").show()) : ($("#companyLogo").show(), $("#changeImage").hide(), $("#getStartImageId").hide(), $("#cl .zrc-btn-primary").show())) : "error" === data.status && ZRCommonUtil.displayErrorMsg("gSErrorMsg", I18n.getMsg("crm.customfromaddress.save.failed"))
},
failureFunc: function() {
ZRCommonUtil.displayErrorMsg("gSErrorMsg", I18n.getMsg("crm.customfromaddress.save.failed"))
}
};
return ZRCommonUtil.ajaxGetMethod("/recruit/getCompanyLogoUpdateForm.do", void 0, !0, "json", void 0, callBackFun.successFunc, callBackFun.failureFunc), !1
},
displayErrorMsg: function(elementId, message) {
ZRComponent.openAlertMessage({
msg: I18n.getMsg(message),
display: "inline",
type: "failure",
noCloseIcon: !0,
displayId: elementId
})
},
changeProfile: function(ev, spaceId) {
if (window.confirm("Do you want to change the profile of this user?")) {
var urlData = {};
urlData.actionName = "upgradeUserFromTool";
var userid = $(ev.target).parent().siblings().eq(1).html();
urlData.userIdToChange = userid, urlData.spaceId = spaceId, urlData.profileid = $(ev.target).val(), ZRCommonUtil.ajaxPostMethod("/recruit/Security.do", urlData, !0, "json", void 0, function(data) {
data && alert("Profile changed sucessfully")
})
}
},
confirmVersionChange: function() {
var confirmButtonFun = function() {
var urlData = {};
urlData.actionName = "convertToHR", ZRCommonUtil.ajaxPostMethod("/recruit/Security.do", urlData, !0, "json", void 0, function(data) {
data && (ZRJobBoardsUtil.closeJBIPopUp("#staffConvConfirm"), location.reload())
}, function() {
ZRCommonUtil.displayErrorMsg("gSErrorMsg", I18n.getMsg("crm.fr.unknown"))
})
},
cancelButtonFun = function() {
ZRJobBoardsUtil.closeJBIPopUp("#staffConvConfirm")
},
createElem = Utils.createHTML({
name: "div",
attr: {
id: "staffConvConfirm",
"class": "pbr-modal pb-animate-modal pb-save-modal md-show"
},
child: [{
name: "div",
attr: {
"class": "pbr-modal-container pb-wid600",
style: "width:500px"
},
child: [{
name: "div",
attr: {
"class": "p30 pT20 pB20"
},
child: [{
name: "p",
attr: {
"class": "marT20 f18 texAC"
},
html: I18n.getMsg("crm.switching.confirm.message")
}, {
name: "div",
attr: {
"class": "pb-center mT30"
},
child: [{
name: "input",
attr: {
id: "boostFieldBut",
type: "button",
"class": "primarybtn pb-close",
value: I18n.getMsg("crm.jobboards.job.publish.proceed")
},
events: [{
name: "click",
fn: confirmButtonFun
}]
}, {
name: "input",
attr: {
id: "cancelJBBoost",
type: "button",
"class": "newgraybtn mL10",
value: I18n.getMsg("crm.button.cancel")
},
events: [{
name: "click",
fn: cancelButtonFun
}]
}]
}]
}]
}]
});
ZRCommonUtil.createFreeze(), $("body").append(createElem)
},
toggleUserStatus: function(ev, spaceId, status) {
var args = {},
elem = $(ev.target),
parentElem = elem.parent();
args.content = "Do you really want to Activate/Deactivate user?", args.confirmButtonLabel = I18n.getMsg("Yes"), args.confirmBtnClass = 2, args.confirmButtonFun = function() {
var urlData = {};
urlData.actionName = "activateDeactivateUser", urlData.userIdToChange = parentElem.data("userid"), urlData.spaceId = spaceId, urlData.currentStatus = status, urlData.userZUID = parentElem.data("zuid"), ZRCommonUtil.ajaxPostMethod("/recruit/Security.do", urlData, !0, "json", void 0, function(data) {
data ? (alert("success"), "ACTIVE" == status ? (parentElem.removeClass("on"), parentElem.find(".onoffswitch-switch").css({
left: "0px",
right: "25px"
}), parentElem.find("#onofftext").css({
"margin-right": "4px",
"float": "right"
}), elem.attr("onclick", "ZRCommonUtil.toggleUserStatus(event, '" + spaceId + "', 'DISABLED')")) : (parentElem.addClass("on"), parentElem.find(".onoffswitch-switch").css({
right: "0px",
left: "25px"
}), parentElem.find("#onofftext").css({
"margin-left": "4px",
"float": "left"
}), elem.attr("onclick", "ZRCommonUtil.toggleUserStatus(event, '" + spaceId + "', 'ACTIVE')"))) : alert("failure")
}, function() {
ZRCommonUtil.displayErrorMsg("gSErrorMsg", I18n.getMsg("crm.fr.unknown"))
}), ZRComponent.hideModalBox("zrc-modal-box-0")
}, ZRComponent.createConfirmDialog(args)
},
closeVersionChange: function() {
document.cookie = "switchOption=false;", $(".sw-internal").hide()
},
isSwitchVersonEnabled: function() {
var allcookies = document.cookie;
cookiearray = allcookies.split(";");
for (var i = 0; i < cookiearray.length; i++)
if (name = cookiearray[i].split("=")[0].trim(), value = cookiearray[i].split("=")[1].trim(), "switchOption" === name && "false" === value)
return !1;
return !0
},
sendBannerClickMail: function() {
var urlData = {};
urlData.actionType = "sendBannerClickMail", $.ajax({
type: "GET",
url: "/recruit/License.do",
data: urlData,
async: !1
})
},
openInterviewFB: function(params) {
ZRCommonUtil.createInfoBox({
modalclass: "w600",
title: I18n.getMsg("zr.interviewreview.title.new", I18n.getMsg(Crm.moduleInfo.Products[0])),
content: "<div style='word-wrap:break-word;'>" + params + "</div>",
saveclass: "primarybtn"
})
},
updateJobDetails: function(mode, zgid) {
var tpName = $("#threadPoolName").text().trim(),
jobId = $("#schedulerJobId").text().trim(),
args = {};
args.content = "Do you really want to update this scheduler?", args.confirmButtonLabel = I18n.getMsg("Confirm"), args.confirmBtnClass = 2, args.confirmButtonFun = function() {
var urlData = {};
urlData.action = "jobsInfo", urlData.mode = mode, urlData.zgId = zgid, urlData.threadPoolName = tpName, urlData.jobId = jobId, urlData.step = "updateJob", ZRCommonUtil.ajaxGetMethod("/recruit/ZCRMAdminTools.do", urlData, !0, "json", void 0, function(data) {
data && alert("success")
}, function() {
ZRCommonUtil.displayErrorMsg("gSErrorMsg", I18n.getMsg("crm.fr.unknown"))
}), ZRComponent.hideModalBox("zrc-modal-box-0")
}, ZRComponent.createConfirmDialog(args)
},
showImportOptions: function() {
$("#importSpreadsheetZCRMDiv").slideToggle()
},
handleAjaxError: function(url, jqXHR) {
if ("/recruit/ResumeInboxSettings.do" === url && jqXHR.status === ZRResumeInbox.mailNotConfiguredError)
ZRResumeInbox.showMailAddonConfigureAlert();
else if ("/recruit/GetJOList.do" === url && jqXHR.status === ZRQuickView.notAuthorizedError)
$("#qv-associatedjo-tab") && $("#qv-associatedjo-tab").remove();
else {
if ("/recruit/GetQVInfo.do" === url && jqXHR.status === ZRQuickView.notAuthorizedError)
return ZRComponent.openAlertMessage({
type: "failure-modal",
displayId: "",
msg: I18n.getMsg("crm.record.not.accessible.message2")
}), void (ZRQuickView.loadingCompleted = !0);
if ("/recruit/addQVNote.do" === url && jqXHR.status === ZRQuickView.notAuthorizedError)
return void ZRComponent.openAlertMessage({
type: "failure-modal",
displayId: "",
msg: I18n.getMsg("crm.record.not.accessible.message2")
})
}
},
getFilterComponent: function() {
var createElem = Utils.createHTML({
name: "div",
attr: {
id: "filterSec"
},
child: [{
name: "div",
attr: {
"class": "pT20 pB20 pL100 pR10 bdr1px pR whiteBg",
id: "filterBeforeMainDiv"
},
child: [{
name: "div",
attr: {
id: "filterBefore"
},
child: [{
name: "div",
attr: {
"class": "fL mT25 mL30 pL5",
id: "filterbyid"
},
child: [{
name: "b",
attr: {
"class": "mR10 pL100 mL50 gT4"
},
html: I18n.getMsg("candidates.filter.by")
}]
}, {
name: "div",
attr: {
id: "assJob",
"class": "fL mL15 gT7"
}
}, {
name: "div",
attr: {
id: "cand_filter",
"class": "fL mL15 gT7"
}
}, {
name: "div",
attr: {
"class": "fL mL20 mT10 pT12"
},
child: [{
name: "input",
attr: {
type: "button",
value: I18n.getMsg("crm.button.find"),
"class": "zrc-btn-primary btn-x mR5 pL10 pR10 padT7 pB7"
},
events: [{
name: "click",
fn: "ZRCommonUtil.getFilterComponentResults",
args: ["jobfilter"]
}]
}, {
name: "input",
attr: {
type: "button",
value: I18n.getMsg("crm.button.cancel"),
"class": "zrc-btn-normal btn-x padT7 pB7"
},
events: [{
name: "click",
fn: "ZRCommonUtil.removeFilterComponent"
}]
}]
}, {
name: "div",
attr: {
"class": "clearB"
}
}]
}]
}]
});
$("#filterMainDiv").append(createElem)
},
getJobFilter: function(jobObj) {
if (jobObj) {
if (jobObjArr = jobObj && jobObj.jobObjArr ? jobObj.jobObjArr : [], jobObjArr && jobObjArr.length > 0) {
var createElem = Utils.createHTML({
name: "div",
child: [{
name: "b",
html: I18n.getMsg("candidates.filter.associated.job.opening")
}, {
name: "div",
attr: {
id: "job-holder"
},
child: [{
name: "select",
attr: {
id: "ass-job-opening"
}
}]
}]
});
$("#assJob").append(createElem);
var assJobOpening = $("#ass-job-opening");
assJobOpening.append(Utils.createHTML({
name: "option",
attr: {
tabindex: "-1",
value: "Unassociated"
},
html: "Unassociated"
}));
for (var j = 0; j < jobObjArr.length; j++) {
var jobId = jobObjArr[j].value;
assJobOpening.append(Utils.createHTML({
name: "option",
attr: {
tabindex: "-1",
value: jobId + ""
},
child: [{
name: "text",
html: jobObjArr[j].label
}]
}))
}
assJobOpening.hide();
var issearch = jobObj && jobObj.showNext ? jobObj.showNext : !1,
scrollObj = {};
issearch && (scrollObj = {
toindex: "10",
fromindex: "11",
shownext: "true",
module: "Potentials",
callee: "ZRCommonUtil.loadFilterData",
mode: "filterJobList",
url: "/recruit/GetJoList.do"
}), ZRComponent.customSelect(assJobOpening, {
id: "ass-job-opening",
minlength: 3,
issearch: issearch,
url: "/recruit/FilterAction.do",
urldata: {
searchmodule: "Potentials",
searchcolumn: "postingtitle"
},
selectclass: "w240 ac-bdr2 mT5",
isScroll: issearch,
scrollObj: scrollObj,
tooltipchar: 25
})
}
} else
$("#assJob").remove()
},
getCandStatusFilter: function(statusObj) {
if (statusObj && statusObj.length > 0) {
var createElem = Utils.createHTML({
name: "div",
child: [{
name: "b",
html: I18n.getMsg("candidates.filter.cand.status")
}, {
name: "div",
attr: {
id: "status-holder"
},
child: [{
name: "select",
attr: {
id: "cand_status",
multiple: "multiple"
}
}]
}]
});
$("#cand_filter").append(createElem);
for (var objsize = statusObj.length > 10 ? statusObj.length - 1 : statusObj.length, candStatusSel = $("#cand_status"), j = 0; objsize > j; j++)
candStatusSel.append(Utils.createHTML({
name: "option",
attr: {
tabindex: "-1",
value: statusObj[j]
},
child: [{
name: "text",
html: statusObj[j]
}]
}));
candStatusSel.hide();
var issearch = statusObj.length > 10 ? !0 : !1,
scrollObj = {};
issearch && (scrollObj = {
toindex: "10",
fromindex: "11",
shownext: "true",
module: "Leads",
callee: "ZRCommonUtil.loadFilterData",
mode: "list",
url: "/recruit/ShowStatusInfo.do"
}), ZRComponent.customSelect(candStatusSel, {
id: "cand_status",
minlength: 3,
ismultiple: !0,
restrictOptions: !0,
issearch: issearch,
url: "/recruit/FilterAction.do",
urldata: {
searchmodule: "Leads",
searchcolumn: "statuslist"
},
selectclass: "w240 ac-bdr2 mT5",
isScroll: issearch,
scrollObj: scrollObj,
tooltipchar: 25
})
} else
$("#cand_filter").remove()
},
loadCandFilter: function(isToggle) {
ZRCommonUtil.ajaxPostMethod("/recruit/FilterAction.do", {
moduleList: "Potentials;Leads"
}, !0, "json", void 0, function(data) {
var dataObj = data;
if (void 0 == dataObj.jobObj && void 0 == dataObj.statusObj)
alert(I18n.getMsg("crm.security.error.add.user"));
else if (ZRCommonUtil.getFilterComponent(), ZRCommonUtil.getJobFilter(dataObj.jobObj), ZRCommonUtil.getCandStatusFilter(dataObj.statusObj), isToggle && ZRCommonUtil.getToggleAction(), "jobfilter" == ZRCommonUtil.FILTERRECORDS) {
if (void 0 != ZRCommonUtil.FILTERJOBID && void 0 != ZRCommonUtil.FILTERJOBNAME && "" != ZRCommonUtil.FILTERJOBID && "" != ZRCommonUtil.FILTERJOBNAME) {
var assJobDiv = $("#custom-select-placeholder-ass-job-opening");
if (assJobDiv.length > 0) {
var dotValObj = ZRCommonUtil.getDotVal(ZRCommonUtil.FILTERJOBNAME, 25);
assJobDiv.text(dotValObj.dotVal), assJobDiv.attr("title", dotValObj.title), assJobDiv.append(Utils.createHTML({
name: "input",
attr: {
id: "custom-select-placeholder-value-ass-job-opening",
type: "hidden",
value: ZRCommonUtil.FILTERJOBID,
"data-dlabel": ZRCommonUtil.FILTERJOBNAME
}
}))
}
}
if (void 0 != ZRCommonUtil.FILTERCANDSTATUS && "" != ZRCommonUtil.FILTERCANDSTATUS) {
var candStatusDiv = $("#custom-select-placeholder-cand_status");
if (candStatusDiv.length > 0) {
var dotValObj = ZRCommonUtil.getDotVal(ZRCommonUtil.FILTERCANDSTATUS, 25);
candStatusDiv.text(dotValObj.dotVal), candStatusDiv.attr("title", dotValObj.title), candStatusDiv.append(Utils.createHTML({
name: "input",
attr: {
id: "custom-select-placeholder-value-cand_status",
type: "hidden",
value: ZRCommonUtil.FILTERCANDSTATUS,
"data-dlabel": ZRCommonUtil.FILTERCANDSTATUS
}
}))
}
}
}
$("#filteredWordDiv").remove()
}, function() {
alert(I18n.getMsg("crm.security.error.add.user"))
})
},
getUserFilter: function(module) {
var selMailVar = $("#selectMails");
if (selMailVar.length && 0 === $("#custom-select-container-selectMails").length) {
var createElem = Utils.createHTML({
name: "div",
child: [{
name: "div",
attr: {
id: "user-holder",
"class": "usercont-holder-blk"
},
child: [{
name: "select",
attr: {
id: "selectMails1"
}
}]
}]
});
$("#userDiv").append(createElem);
var userSelect = $("#selectMails1");
userSelect.append(selMailVar.html()), $("#selectMails1 option").each(function() {
$(this).attr("tabindex", "-1")
}), selMailVar.remove(), $("#selectMails1").attr("id", "selectMails"), selMailVar = $("#selectMails"), selMailVar.change(function() {
"Accounts" === module ? showMailsList("" + $("#firstContact").val(), "", "", "" + $("#mailListRelId").val(), "-10", "next", "", "true", CURRMODULE, "true") : showMailsList("" + $("#entityId").val(), "", "", "" + $("#mailListRelId").val(), "-10", "next", "", "true", module, "true")
}), selMailVar.hide();
var changefn = function(target, params) {
var liVal = $(target).data("customval");
$("#selectMails").val(liVal), ZRComponent.onChangeAction(target, params), selMailVar.change()
};
ZRComponent.customSelect(userSelect, {
id: "selectMails",
changefn: changefn,
isselect: !1,
selectclass: "w240 ac-bdr2 mT5",
isScroll: !1,
scrollObj: !1,
tooltipchar: 25
}), ZRCommonUtil.resetUserFilter()
}
$("#usersMainDiv").show()
},
resetUserFilter: function() {
var userVal = $("#selectMails").val();
$("#custom-select-list-selectMails").find("li").each(function() {
var liVal = $(this).data("customval") + "";
if (userVal === liVal) {
$(this).attr("class", "active");
var val = $(this).text(),
placeHldr = $("#custom-select-placeholder-value-selectMails");
placeHldr.attr("data-dlabel", $(this).data("dlabel")), placeHldr.val(liVal);
var custPlaceHolder = $("#custom-select-placeholder-selectMails");
custPlaceHolder.empty(), custPlaceHolder.append(val), custPlaceHolder.append(placeHldr)
}
})
},
loadVendorFilter: function() {
ZRCommonUtil.ajaxPostMethod("/recruit/FilterAction.do", {
moduleList: "Vendors"
}, !0, "json", void 0, function(data) {
var dataObj = data;
void 0 != dataObj.contObj ? ZRCommonUtil.getVendorFilter(dataObj.contObj) : crmui.showMsgBand("error", I18n.getMsg("crm.label.recordNotAvailable"), "infinity")
})
},
getVendorFilter: function(contObj) {
if (contObj && (contObjArr = contObj && contObj.contObjArr ? contObj.contObjArr : [], contObjArr && contObjArr.length > 0)) {
var createElem = Utils.createHTML({
name: "div",
attr: {
id: "ass-vendor-holder"
},
child: [{
name: "div",
attr: {
id: "vendor-holder"
},
child: [{
name: "select",
attr: {
id: "ass-vendor-names"
}
}]
}]
});
$("#assvendor").append(createElem);
for (var contList = $("#ass-vendor-names"), j = 0; j < contObjArr.length; j++) {
var contId = contObjArr[j].value;
contList.append(Utils.createHTML({
name: "option",
attr: {
tabindex: "-1",
value: contId + ""
},
text: contObjArr[j].label
}))
}
contList.hide();
var issearch = contObj && contObj.showNext ? contObj.showNext : !1,
scrollObj = {};
issearch && (scrollObj = {
toindex: "10",
fromindex: "11",
shownext: "true",
module: "Vendors",
callee: "ZRCommonUtil.loadFilterData",
mode: "filterJobList",
url: "/recruit/GetJoList.do"
});
var cancelfn = function(target, params) {
var selId = params && params.id ? "-" + params.id : "";
"-ass-vendor-names" === selId && crmListView.bindPerfectScrollbar(), ZRComponent.defaultCancel(target, params)
},
changefn = function(target, params) {
var selId = params && params.id ? "-" + params.id : "",
tgtlabel = $(target).data("dlabel"),
tgtval = $(target).data("customval") + "";
if ("-ass-vendor-names" === selId) {
crmListView.bindPerfectScrollbar();
var ipEle = $("#assVendorVal");
ipEle.val(tgtval + ":" + tgtlabel)
}
ZRComponent.onChangeAction(target, params)
},
customclick = function(target, params) {
target = void 0 != target && "object" == typeof target ? target : {}, target.afterClose = function() {
$("#lv_filter_scroll").perfectScrollbar()
}, target.afterOpen = function() {
$("#lv_filter_scroll").perfectScrollbar("destroy")
}, ZRComponent.customClick(target, params)
};
ZRComponent.customSelect(contList, {
id: "ass-vendor-names",
minlength: 3,
issearch: issearch,
url: "/recruit/FilterAction.do",
urldata: {
searchmodule: "Vendors",
searchcolumn: "vendorname"
},
selectclass: "w150 ac-bdr2 mT5",
isScroll: issearch,
scrollObj: scrollObj,
tooltipchar: 25,
cancelfn: cancelfn,
changefn: changefn,
customclick: customclick,
ulclass: "maxH150 ",
reswidth: "200"
})
}
},
getContFilter: function(contObj) {
if (contObj && (contObjArr = contObj && contObj.contObjArr ? contObj.contObjArr : [], contObjArr && contObjArr.length > 0)) {
var createElem = Utils.createHTML({
name: "div",
child: [{
name: "div",
attr: {
id: "cont-holder",
"class": "usercont-holder-blk"
},
child: [{
name: "select",
attr: {
id: "cont-list"
}
}]
}]
});
$("#contactsDiv").append(createElem);
var contList = $("#cont-list");
contList.append(Utils.createHTML({
name: "option",
attr: {
tabindex: "-1",
value: $("#firstContact").val() + ""
},
html: "--" + I18n.getMsg("crm.label.all") + "--"
}));
for (var j = 0; j < contObjArr.length; j++) {
var contId = contObjArr[j].value;
contList.append(Utils.createHTML({
name: "option",
attr: {
tabindex: "-1",
value: contId + ""
},
html: contObjArr[j].label
}))
}
contList.hide();
var issearch = contObj && contObj.showNext ? contObj.showNext : !1,
scrollObj = {},
entId = $("#entityId").val();
issearch && (scrollObj = {
toindex: "10",
fromindex: "11",
shownext: "true",
module: "Contacts",
callee: "ZRCommonUtil.loadFilterData",
mode: "filterContList",
url: "/recruit/GetModuleRecords.do",
entityId: entId
});
var changefn = function(target, params) {
var liVal = $(target).data("customval"),
liLab = $(target).data("dlabel");
$("#firstContact").val(liVal);
var personId = $("#mailListRelId").val();
ZRComponent.onChangeAction(target, params), CURRMODULE = liLab === "--" + I18n.getMsg("crm.label.all") + "--" ? "Accounts" : "Contacts", showMailsList("" + liVal, "", "", "" + personId, "-10", "next", "", "true", CURRMODULE, "true")
};
CURRMODULE = "Accounts", ZRComponent.customSelect(contList, {
id: "cont-list",
changefn: changefn,
isselect: !1,
minlength: 3,
issearch: issearch,
url: "/recruit/FilterAction.do",
urldata: {
searchmodule: "Contacts",
searchcolumn: "FULLNAME"
},
selectclass: "w240 ac-bdr2 mT5",
isScroll: issearch,
scrollObj: scrollObj,
tooltipchar: 25
}), showMailsList("" + $("#firstContact").val(), "", "", "" + $("#mailListRelId").val(), "-10", "next", "", "true", "Accounts", "true"), $("#contactsMainDiv").show()
}
},
loadContFilter: function(module) {
if ("Accounts" === module && 0 === $("#cont-list").length) {
var entId = $("#entityId").val();
ZRCommonUtil.ajaxPostMethod("/recruit/FilterAction.do", {
moduleList: "Contacts",
entityId: entId
}, !0, "json", void 0, function(data) {
var dataObj = data;
void 0 != dataObj.contObj ? ZRCommonUtil.getContFilter(dataObj.contObj) : ($("#contactsDiv").remove(), $("#usersMainDiv").remove(), showMailsList("" + $("#firstContact").val(), "", "", "" + $("#mailListRelId").val(), "-10", "next", "", "true", "Accounts", "true"))
})
}
},
getContentForFilter: function() {
"jobfilter" == ZRCommonUtil.FILTERRECORDS ? $("#filterBeforeMainDiv").length <= 0 ? ZRCommonUtil.loadCandFilter(!1) : ZRCommonUtil.getToggleAction() : $("#filterSec").length <= 0 ? ZRCommonUtil.loadCandFilter(!0) : ZRCommonUtil.getToggleAction()
},
getToggleAction: function() {
var filterMainDiv = $("#filterMainDiv"),
arowbx = $("#arowbx");
filterMainDiv.length > 0 && filterMainDiv.is(":visible") ? arowbx.hide() : arowbx.show(), filterMainDiv.slideToggle(), $("#filterIc").toggleClass("filterIcSel")
},
getFilterResultDisplay: function() {
var createElem = Utils.createHTML({
name: "div",
attr: {
"class": "pT20 pB10 pL20 pR10 bdr1px pR whiteBg tac maxH60 oveA",
id: "filteredWordDiv"
},
child: [{
name: "a",
attr: {
href: "javascript:void(0)",
"class": "pA rig10 top5 f16"
},
html: "&times;",
events: [{
name: "click",
fn: "ZRCommonUtil.removeFilterComponent"
}]
}, {
name: "ul",
attr: {
id: "filteredWord",
"class": "pB10 filteredTxt dIB"
}
}]
});
$("#filterMainDiv").append(createElem), $("#filterMainDiv").attr("class", "dB");
var dotValObj = void 0;
if ("jobfilter" == ZRCommonUtil.FILTERRECORDS && ZRCommonUtil.FILTERJOBID && "" != ZRCommonUtil.FILTERJOBID && (dotValObj = ZRCommonUtil.getDotVal(ZRCommonUtil.FILTERJOBNAME, 20), $("#filteredWord").append(Utils.createHTML({
name: "li",
attr: {
tabindex: "-1",
"data-seljob": ZRCommonUtil.FILTERJOBID,
title: dotValObj.title
},
html: dotValObj.dotVal,
child: [{
name: "i",
attr: {
"class": "fa fa-times"
},
events: [{
name: "click",
fn: "ZRCommonUtil.updateFilterComponentResults"
}]
}]
}))), ZRCommonUtil.FILTERCANDSTATUS && "" != ZRCommonUtil.FILTERCANDSTATUS)
for (var tempstatus = ZRCommonUtil.FILTERCANDSTATUS.split(";"), i = 0; i < tempstatus.length; i++)
dotValObj = ZRCommonUtil.getDotVal(tempstatus[i], 20), $("#filteredWord").append(Utils.createHTML({
name: "li",
attr: {
tabindex: "-1",
"data-candstatus": tempstatus[i],
title: dotValObj.title
},
child: [{
name: "text",
html: dotValObj.dotVal
}, {
name: "i",
attr: {
"class": "fa fa-times"
},
events: [{
name: "click",
fn: "ZRCommonUtil.updateFilterComponentResults"
}]
}]
}));
$("#arowbx").show()
},
getFilterComponentResults: function(event, target, checkType) {
if (checkType && "" != checkType) {
if ("jobfilter" == checkType) {
var assJobDiv = $("#custom-select-placeholder-value-ass-job-opening"),
candStatusDiv = $("#custom-select-placeholder-value-cand_status");
if (!(assJobDiv.length > 0 || candStatusDiv.length > 0))
return;
$(target).attr("disabled", !0);
var selJobId = void 0,
selJobName = void 0,
selCandStatus = void 0;
assJobDiv.length > 0 && (selJobId = assJobDiv.val(), selJobName = assJobDiv.data("dlabel")), ZRCommonUtil.FILTERJOBID = selJobId && "" != selJobId ? selJobId : "", ZRCommonUtil.FILTERJOBNAME = selJobName && "" != selJobName ? selJobName : "", ZRCommonUtil.FILTERRECORDS = "jobfilter", candStatusDiv.length > 0 && (selCandStatus = candStatusDiv.val()), ZRCommonUtil.FILTERCANDSTATUS = selCandStatus && "" != selCandStatus ? selCandStatus : ""
}
if ("jobfilter" == ZRCommonUtil.FILTERRECORDS || "asspopout" == ZRCommonUtil.FILTERRECORDS) {
var urlData = {};
urlData.jobtitle = ZRCommonUtil.FILTERJOBNAME, urlData.jobId = ZRCommonUtil.FILTERJOBID, urlData.module = "Leads", urlData.cvid = $("#cvid").val(), urlData.searchletter = $("input[name=searchletter]").val(), urlData.isload = !0, urlData.filterrecords = ZRCommonUtil.FILTERRECORDS, urlData.status = ZRCommonUtil.FILTERCANDSTATUS, ZRCommonUtil.ajaxPostMethod("/recruit/ShowDetails.do", urlData, !0, "json", void 0, function(obj) {
crmListView.createTemplate(ZRCommonUtil.convertStringToJson(obj)), crmNavig.parseCurrentListView();
var refreshParams = {
clickId: "tab",
calleeObj: "crmDummy",
module: "Leads",
orgCalleeObj: "crmTab"
};
"" != ZRCommonUtil.FILTERJOBID && (refreshParams.jobId = ZRCommonUtil.FILTERJOBID), Crm.addToHistory(void 0, void 0, refreshParams)
}, function() {
alert(I18n.getMsg("crm.security.error.add.user"))
})
}
}
},
updateFilterComponentResults: function(event, tgt) {
var currentSel = void 0,
mainObj = {};
if ("jobfilter" == ZRCommonUtil.FILTERRECORDS && $(tgt.parentNode).data("seljob"))
currentSel = $(tgt.parentNode).data("seljob"), mainObj = CUSTOMSELECTOBJARR["custom-select-placeholder-ass-job-opening"], void 0 != mainObj && mainObj.length > 0 && (mainObj = $.grep(mainObj, function(obbbj) {
return obbbj.value != currentSel
}), CUSTOMSELECTOBJARR["custom-select-placeholder-ass-job-opening"] = mainObj);
else if ($(tgt.parentNode).data("candstatus")) {
currentSel = $(tgt.parentNode).data("candstatus");
var objkey = void 0;
"jobfilter" == ZRCommonUtil.FILTERRECORDS ? objkey = "custom-select-placeholder-cand_status" : "asspopout" == ZRCommonUtil.FILTERRECORDS && (objkey = "custom-select-placeholder-ass_cand_status"), mainObj = CUSTOMSELECTOBJARR[objkey], void 0 != mainObj && mainObj.length > 0 && (mainObj = $.grep(mainObj, function(obbbj) {
return obbbj.value != currentSel
}), CUSTOMSELECTOBJARR[objkey] = mainObj)
}
var selJobId = "",
selCandStatus = "",
selJobName = "",
filteredList = $("#filteredWord").find("li");
if ($.each(filteredList, function(j, item) {
var current = $(item);
"jobfilter" == ZRCommonUtil.FILTERRECORDS && current.data("seljob") && current.data("seljob") != currentSel && (selJobId = current.data("seljob"), selJobName = current.text()), current.data("candstatus") && current.data("candstatus") != currentSel && (selCandStatus = void 0 == selCandStatus || "" == selCandStatus ? current.data("candstatus") : selCandStatus + ";" + current.data("candstatus"))
}), "jobfilter" == ZRCommonUtil.FILTERRECORDS && (ZRCommonUtil.FILTERJOBID = selJobId, ZRCommonUtil.FILTERJOBNAME = selJobName), ZRCommonUtil.FILTERCANDSTATUS = selCandStatus, selJobId && "" != selJobId || selCandStatus && "" != selCandStatus) {
var parentUl = $(tgt).closest("ul");
parentUl.find($(tgt).parent()).remove();
var urlData = {};
urlData.jobtitle = ZRCommonUtil.FILTERJOBNAME, urlData.jobId = ZRCommonUtil.FILTERJOBID, urlData.module = "Leads", urlData.cvid = $("#cvid").val(), urlData.searchletter = $("input[name=searchletter]").val(), urlData.isload = !0, urlData.filterrecords = ZRCommonUtil.FILTERRECORDS, urlData.status = ZRCommonUtil.FILTERCANDSTATUS, ZRCommonUtil.ajaxPostMethod("/recruit/ShowDetails.do", urlData, !0, "html", void 0, function(obj) {
crmListView.createTemplate(ZRCommonUtil.convertStringToJson(obj)), crmNavig.parseCurrentListView();
var refreshParams = {
clickId: "tab",
calleeObj: "crmDummy",
module: module,
orgCalleeObj: "crmTab"
};
"" != ZRCommonUtil.FILTERJOBID && (refreshParams.jobId = ZRCommonUtil.FILTERJOBID), Crm.addToHistory(void 0, void 0, refreshParams)
}, function() {
alert(I18n.getMsg("crm.security.error.add.user"))
})
} else
ZRCommonUtil.removeFilterComponent(event, tgt)
},
refreshList: function(event, target, params) {
var state = History.getState();
void 0 == params && (params = {});
var paramsFilter = state.data,
isAssoList = $("[name=isAssoList]").val();
"true" === isAssoList && (params.action = "assoTab"), $("#assoFilterPattern").length && void 0 != $("#assoFilterPattern").val() && (params.assoFilterPattern = $("#assoFilterPattern").val());
var assoEntId = $("[name=assoEntId]").val();
void 0 !== assoEntId && (params.assoEntId = assoEntId);
var candId = $("[name=candId]").val();
if (void 0 !== candId && (params.candId = candId), void 0 != paramsFilter && "true" == paramsFilter.isSearch)
for (var key in paramsFilter)
params.hasOwnProperty(key) || (params[key] = decodeURIComponent(paramsFilter[key]));
else
params.module = customViewObject.module, params.cvid = customViewObject.cvId, params.fromIndex = customViewObject.fromIndex, params.toIndex = customViewObject.toIndex, params.currentOption = customViewObject.currentOption, params.refresh = !0, params.clickId = "refreshTab", params.calleeObj = "crmTab";
crmTab.open(event, target, void 0, params)
},
removeFilterComponent: function(event, target) {
if (CUSTOMSELECTOBJARR = {}, "jobfilter" == ZRCommonUtil.FILTERRECORDS)
ZRCommonUtil.FILTERRECORDS = "", ZRCommonUtil.FILTERJOBID = "", ZRCommonUtil.FILTERCANDSTATUS = "", ZRCommonUtil.FILTERJOBNAME = "", ZRCommonUtil.refreshList(event, target);
else if ("asspopout" == ZRCommonUtil.FILTERRECORDS)
ZRCommonUtil.FILTERCANDSTATUS = "", ZRCommonUtil.refreshList(event, target);
else {
$("#filterMainDiv").hide();
var arowbx = $("#arowbx"),
checkPresence = arowbx.length > 0 ? !0 : !1;
checkPresence && (arowbx.is(":visible") ? arowbx.hide() : arowbx.show()), $("#filterSec").remove()
}
},
candBulkChangeStatus: function(module, jobId) {
var filterJobId = "";
null != jobId && void 0 != jobId && "" != jobId && (filterJobId = jobId);
var noofrows = crmTab.getFromCache(module).body.length;
if (0 == noofrows && (noofrows = crmTab.getFromCache(module).address.address_jsonarrayObj.length), checked = crmTab.getFromCache(module).selectedIds.length, 0 == checked) {
var str = I18n.getMsg("crm.alert.select.one");
return alert(str), !1
}
var append_ids = crmTab.getFromCache(module).selectedIds.join(";");
ZRStatusUtil.loadChangeStatus({}, function(json) {
if (json && json.message && "success" === json.message) {
var liStr = "",
statusList = json.statusList,
fromIndex = json.fromIndex,
toIndex = json.toIndex,
startlimit = parseInt(fromIndex) + parseInt(toIndex);
jobStyle = "" == ZRCommonUtil.FILTERJOBNAME || "Unassociated" == ZRCommonUtil.FILTERJOBNAME ? "display:none" : "display:block";
for (var i = 0; i < statusList.length; i++) {
var statusObj = statusList[i];
liStr = liStr + "<li class='statuseach' data-status='" + statusObj.label + "' data-actualstatus='" + statusObj.label + "'>" + statusObj.label + "</li>"
}
var closeFun = function() {
$("#bg-light").hide(), $(".bulk-update-block").remove()
},
createElem = Utils.createHTML({
name: "div",
attr: {
"class": "bulk-update-block"
},
child: [{
name: "a",
attr: {
"class": "btn-close-asso",
href: "javascript:void(0)"
},
events: [{
name: "click",
fn: closeFun
}]
}, {
name: "h4",
html: I18n.getMsg("crm.potential.relatedlist.changestatus")
}, {
name: "div",
attr: {
"class": "content",
style: "max-height:360px"
},
child: [{
name: "div",
attr: {
"class": "bulk-field-block"
},
child: [{
name: "label",
html: I18n.getMsg("crm.workflow.task.status")
}, {
name: "p",
attr: {
"class": "cs",
id: "change-status-select",
"class": "change-status-select mB20"
},
child: [{
name: "span"
}],
html: "-" + I18n.getMsg("None") + "-"
}, {
name: "ul",
attr: {
"class": "change-status-list",
id: "change-status-list",
style: "display:none"
},
html: liStr
}, {
name: "label",
attr: {
style: jobStyle
},
html: I18n.getMsg("Potential")
}, {
name: "input",
attr: {
type: "text",
"class": "pd w350 inpt mB20",
value: ZRCommonUtil.FILTERJOBNAME,
style: jobStyle,
readonly: "readonly"
}
}, {
name: "label",
html: I18n.getMsg("crm.potential.associate.popout.entercomments")
}, {
name: "textarea",
attr: {
placeholder: I18n.getMsg("crm.potential.associate.popout.entercomments"),
"class": "textareachk",
"data-textarea": '{"maxlength": 6000, "minlength": 100, "method": "after"}',
id: "change-status-comment",
value: ""
},
html: ""
}]
}, {
name: "div",
attr: {
"class": "cB mB10",
id: "unqualify-checkbox",
style: "margin:10px 0 0 0px; !important; display:none;"
},
child: [{
name: "label",
attr: {
"class": "gray2"
},
child: [{
name: "input",
attr: {
type: "checkbox",
id: "unqualify-checkbox-boolean",
name: "isCandLocked"
}
}, {
name: "span",
attr: {
id: "unqualify-checkbox-value"
},
html: I18n.getMsg("crm.status.lockoption")
}]
}]
}, {
name: "div",
attr: {
"class": "mT20 fL"
},
child: [{
name: "input",
attr: {
"class": "primarybtn mR10",
type: "button",
"data-pkid": append_ids,
"data-jobid": filterJobId,
"data-module": "Leads",
"data-action": "bulk",
id: "change-filter-status-btn",
value: I18n.getMsg("crm.button.update")
},
events: [{
name: "click",
fn: "ZRCommonUtil.updateBulkCandStatus"
}]
}, {
name: "input",
attr: {
type: "button",
"class": "newgraybtn",
value: I18n.getMsg("crm.button.cancel")
},
events: [{
name: "click",
fn: closeFun
}]
}]
}]
}]
});
$("body").append(createElem), ZRCommonUtil.openDialog(".bulk-update-block"), $("#bg-light").css({
"z-index": "1022"
}), $("#change-status-select").data("status", "-None-");
var ulElem = $("#change-status-list");
ulElem.data("scrolldata", '{"toindex": "' + toIndex + '", "fromindex":"' + startlimit + '", "shownext":"' + json.showNext + '", "module":"' + json.module + '", "mode":"' + json.mode + '", "pastediv":"#change-status-list", "callee":"ZRStatusUtil"}'), ZRCommonUtil.fetchScrollData(ulElem)
}
}, function(json) {
json && json.message && "failure" === json.message && alert(I18n.getMsg("crm.security.error.add.user"))
})
},
updateBulkCandStatus: function(event) {
var tgt = $(event.target),
resumeId = tgt.data("pkid"),
jobopeningId = tgt.data("jobid"),
action = tgt.data("action");
action = action && null !== action ? action : "single";
var isunqal = $("#unqualify-checkbox-boolean").is(":checked"),
params = {};
return params.resumeid = resumeId, "Unassociated" != jobopeningId && (params.jobid = jobopeningId), params.module = tgt.data("module"), params.mode = "change", params.description = $("#change-status-comment").val(), params.status = $("#change-status-select").data("status"), params.actualStatus = $("#change-status-select").data("actualstatus"), params.action = action, params.fromindex = $("#fromIndex").val(), params.toindex = $("#toIndex").val(), params.ischecked = isunqal ? !0 : !1, void 0 === params.actualStatus || "-None-" === params.actualStatus ? (alert(I18n.getMsg("crm.potential.associatepopoutpage.changestatus.emptycheck")), !1) : (ZRStatusUtil.updateChangeStatus(params, function(json) {
json && json.message && "success" === json.message && (!params.action || "bulk" !== params.action && "all" !== params.action || setTimeout(function() {
$("#bg-light").hide(), $(".bulk-update-block,.notes-block").remove(), ZRCommonUtil.showSuccessMessage(I18n.getMsg("crm.label.success.status"))
}, 200))
}, function(json) {
json && json.message && "failure" === json.message && alert(I18n.getMsg("crm.security.error.add.user"))
}), void ZRCommonUtil.refreshList(event, tgt))
},
loadFilterData: function(params, callbackFun) {
var fromindex = params.fromindex ? params.fromindex : "1",
toindex = params.toindex ? params.toindex : "5",
module = params && params.module ? params.module : "Leads",
minlength = params && params ? params.minlength : 3,
mode = params && params.mode ? params.mode : "list",
isMultiple = params && params.ismultiple ? params.ismultiple : !1,
url = params && params.url ? params.url : "",
restrictOptions = params && params.restrictOptions ? params.restrictOptions : !1,
selId = params && params.id ? params.id : "",
searchtxt = params && params.searchtxt ? params.searchtxt : "",
pasteDiv = $(params.pastediv),
entityId = params && params.entityId ? params.entityId : "",
placeHolder = params && params.placeholder ? params.placeholder : I18n.getMsg("crm.select"),
tooltipchar = params && params.tooltipchar ? params.tooltipchar : 25,
restrictMsg = params && params.restrictMsg ? params.restrictMsg : I18n.getMsg("custom.select.component.restrict.message"),
urlData = {};
urlData.module = module, urlData.fromindex = fromindex, urlData.toindex = toindex, urlData.mode = mode, urlData.searchtxt = searchtxt, urlData.prevLoadImg = !0, params && params.urldata && "object" == typeof params.urldata && $(Object.keys(params.urldata)).each(function() {
urlData[this.toString()] = params.urldata[this]
}), "" !== entityId && (urlData.entityId = entityId);
var loadingImg = $("#loadingimg-" + selId);
loadingImg.show(), ZRCommonUtil.ajaxPostMethod(url, urlData, !0, "html", pasteDiv, function(obj, pasteDiv) {
if (loadingImg.hide(), json = ZRCommonUtil.convertStringToJson(obj), json && json.message && "success" === json.message) {
var currOpn = [],
currOpnVal = [];
$(params.pastediv + "> li").each(function(i, item) {
var liText = $(item).data("dlabel");
currOpn.push(liText), currOpnVal.push($(item).data("customval") + "")
});
var resList = void 0;
"Potentials" == module ? resList = json.potentialList : "Leads" == module ? resList = json.statusList : "Contacts" == module ? resList = json.autoList : "Questionnaires" == module && (resList = json.results ? json.results : []);
var fromIndex = json.fromIndex,
toIndex = json.toIndex,
startlimit = parseInt(fromIndex) + parseInt(toIndex);
loadingImg.remove();
for (var i = 0; i < resList.length; i++) {
var resObj = {};
if ("Potentials" == module ? resObj = {
label: resList[i].potentialName,
value: resList[i].potentialId
} : "Leads" == module ? (resObj = resList[i], resObj.value = resObj.label) : "Contacts" == module ? resObj = {
label: resList[i].label,
value: resList[i].value
} : "Questionnaires" == module && (resObj = {
label: resList[i].label,
value: "" + resList[i].value
}), currOpn.indexOf(resObj.label) > -1 && currOpnVal.indexOf(resObj.value) > -1 && "-None-" != resObj.label) {
var dotValObj = ZRCommonUtil.getDotVal(resObj.label, tooltipchar);
pasteDiv.append(isMultiple ? Utils.createHTML({
name: "li",
attr: {
tabindex: "-1",
"data-customval": resObj.value,
title: dotValObj.title,
style: "display:none",
"data-dlabel": resObj.label
},
child: [{
name: "input",
attr: {
type: "checkbox",
value: resObj.value
},
events: [{
name: "change",
fn: "ZRComponent.checkRestrictOptions",
args: [params]
}]
}, {
name: "text",
html: dotValObj.dotVal
}]
}) : Utils.createHTML({
name: "li",
attr: {
tabindex: "-1",
"data-customval": resObj.value,
title: dotValObj.title,
style: "display:none",
"data-dlabel": resObj.label
},
html: dotValObj.dotVal
}))
} else
pasteDiv.append(ZRComponent.formatResult(resObj, params))
}
pasteDiv.append(Utils.createHTML({
name: "li",
attr: {
"class": "ldg",
id: "loadingimg-" + selId
},
child: [{
name: "img",
attr: {
src: "//img.zohostatic.com/recruit/ZR_V5_Jun_26_2019/images/loading.gif",
alt: "Loading"
}
}]
})), $("#loadingimg-" + selId).hide();
var dataobjstring = '{"toindex": "' + toIndex + '","mode":"' + json.mode + '","fromindex":"' + startlimit + '", "shownext":"' + json.showNext + '", "module":"' + json.module + '", "pastediv":"' + params.pastediv + '", "callee":"ZRCommonUtil.loadFilterData","ismultiple":' + isMultiple + ',"url":"' + url + '","id":"' + selId + '","restrictOptions":"' + restrictOptions + '","placeHolder":"' + placeHolder + '","searchtxt":"' + searchtxt + '","tooltipchar":' + tooltipchar + ',"restrictMsg":"' + restrictMsg + '","minlength":"' + minlength + '"}',
dataobj = JSON.parse(dataobjstring);
params && params.urldata && "object" == typeof params.urldata && (dataobj.urldata = params.urldata), pasteDiv.data("scrolldata", JSON.stringify(dataobj)), callbackFun && callbackFun()
}
}, function(xhr) {
var json = xhr.responseText;
json = ZRCommonUtil.convertStringToJson(json), errorFun && errorFun(json)
})
},
assPopOutStatusFilter: function() {
var arowbx = $("#arowbx"),
restrictMsg = I18n.getMsg("custom.select.component.restrict.message");
if (0 == $("#ass_cand_status").length)
ZRCommonUtil.ajaxPostMethod("/recruit/FilterAction.do", {
moduleList: "Leads"
}, !0, "json", void 0, function(data) {
var dataObj = data;
if ("success" == dataObj.message && dataObj.statusObj && dataObj.statusObj.length > 0) {
var statusObj = dataObj.statusObj,
filterElemObj = $("#filterIc"),
positiondataobj = {
modal: "#custom-select-container-ass_cand_status",
placement: "bottom"
};
filterElemObj.data("positiondata", JSON.stringify(positiondataobj)), filterElemObj.after(Utils.createHTML({
name: "select",
attr: {
id: "ass_cand_status",
multiple: "multiple"
}
}));
for (var objsize = statusObj.length > 10 ? statusObj.length - 1 : statusObj.length, candStatusElt = $("#ass_cand_status"), j = 0; objsize > j; j++)
candStatusElt.append(Utils.createHTML({
name: "option",
attr: {
tabindex: "-1",
value: statusObj[j]
},
child: [{
name: "text",
html: statusObj[j]
}]
}));
candStatusElt.hide();
var issearch = statusObj.length > 10 ? !0 : !1,
scrollObj = {};
issearch && (scrollObj = {
toindex: "10",
fromindex: "11",
shownext: "true",
module: "Leads",
callee: "ZRCommonUtil.loadFilterData",
mode: "list",
url: "/recruit/ShowStatusInfo.do"
}), ZRComponent.customSelect($("#ass_cand_status"), {
id: "ass_cand_status",
minlength: 3,
ismultiple: !0,
restrictOptions: !0,
restrictMsg: restrictMsg,
issearch: issearch,
url: "/recruit/FilterAction.do",
urldata: {
searchmodule: "Leads",
searchcolumn: "statuslist"
},
selectclass: "w240 ac-bdr mT5",
isScroll: issearch,
scrollObj: scrollObj,
tooltipchar: 25,
okfn: ZRCommonUtil.assPopOutOkFun,
ispopover: !0,
popoverelem: filterElemObj,
cancelfn: ZRCommonUtil.assPopOutCancelFun
});
var containerObj = $("#custom-select-container-ass_cand_status");
if (containerObj.css("position", "absolute"), containerObj.css({
top: 93
}), $("#custom-select-placeholder-container-ass_cand_status").hide(), void 0 != ZRCommonUtil.FILTERCANDSTATUS && "" != ZRCommonUtil.FILTERCANDSTATUS) {
var candStatusDiv = $("#custom-select-placeholder-ass_cand_status");
if (candStatusDiv.length > 0) {
var dotValObj = ZRCommonUtil.getDotVal(ZRCommonUtil.FILTERCANDSTATUS, 25);
candStatusDiv.text(dotValObj.dotVal), candStatusDiv.attr("title", dotValObj.title), candStatusDiv.append(Utils.createHTML({
name: "input",
attr: {
id: "custom-select-placeholder-value-ass_cand_status",
type: "hidden",
value: ZRCommonUtil.FILTERCANDSTATUS,
"data-dlabel": ZRCommonUtil.FILTERCANDSTATUS
}
}))
}
}
ZRComponent.customClick({
id: "ass_cand_status",
placeHolder: I18n.getMsg("crm.select"),
ismultiple: !0,
selectopntxt: I18n.getMsg("crm.select"),
restrictOptions: !0,
tooltipchar: 25,
restrictMsg: restrictMsg,
formatResult: ZRComponent.formatResult
}), arowbx.show()
}
}, function() {
alert(I18n.getMsg("crm.security.error.add.user"))
});
else {
ZRComponent.customClick({
id: "ass_cand_status",
placeHolder: I18n.getMsg("crm.select"),
ismultiple: !0,
selectopntxt: I18n.getMsg("crm.select"),
restrictOptions: !0,
tooltipchar: 25,
restrictMsg: restrictMsg,
formatResult: ZRComponent.formatResult
});
var restrictMsgDiv = $("#custom-restrict-res-ass_cand_status");
restrictMsgDiv.length > 0 && restrictMsgDiv.is(":visible") && (restrictMsgDiv.hide(), $("#custom-select-option-ass_cand_status").slideToggle()), arowbx.is(":visible") && 0 == $("#filteredWordDiv").length ? arowbx.hide() : arowbx.show()
}
},
assPopOutOkFun: function(params) {
var hideElem = params && params.id ? "-" + params.id : "",
selectedDataVal = (params && params.placeholder ? params.placeholder : I18n.getMsg("crm.select"), params && params.ismultiple ? params.ismultiple : !1, params && params.selectopntxt ? params.selectopntxt : I18n.getMsg("crm.select"), params && params.restrictOptions ? params.restrictOptions : !1, params && params.tooltipchar ? params.tooltipchar : 25, params && params.restrictMsg ? params.restrictMsg : I18n.getMsg("custom.select.component.restrict.message"), void 0),
statusVal = $("#custom-select-placeholder-value" + hideElem);
statusVal && (selectedDataVal = statusVal.val()), void 0 == selectedDataVal ? $("#custom-restrict-res-ass_cand_status").html(I18n.getMsg("crm.potential.associate.popout.select.status")).show() : (ZRCommonUtil.FILTERCANDSTATUS = selectedDataVal, $("#custom-select-option" + hideElem).slideToggle(400, function() {
$("#arowbx").hide(), ZRCommonUtil.getFilterComponentResults("", "", "asspopout"), $("#custom-select-container" + hideElem).remove()
}))
},
assPopOutCancelFun: function(target, params) {
var selId = params && params.id ? "-" + params.id : "",
arowbx = $("#arowbx");
$("#custom-select-option" + selId).slideToggle(), arowbx.is(":visible") && 0 == $("#filteredWordDiv").length ? arowbx.hide() : arowbx.show()
},
bulkUnassociateCand: function(module, jobId, candId) {
var noofrows = crmTab.getFromCache(module).body.length;
0 == noofrows && (noofrows = crmTab.getFromCache(module).address.address_jsonarrayObj.length);
var append_ids = crmTab.getFromCache(module).selectedIds.join(";"),
filterJobId = "";
null != jobId && void 0 != jobId && "" != jobId && (filterJobId = jobId), "Potentials" !== module && "Leads" !== module || void 0 === candId || (append_ids = candId);
var closeFun = function() {
$("#bg-light").hide(), $(".bulk-update-block").remove()
},
createElem = Utils.createHTML({
name: "div",
attr: {
"class": "bulk-update-block"
},
child: [{
name: "a",
attr: {
"class": "btn-close-asso",
href: "javascript:void(0)"
},
events: [{
name: "click",
fn: closeFun
}]
}, {
name: "h4",
html: I18n.getMsg("Leads" === module ? "crm.potential.associate.popout.unassociatecandidate" : "crm.potential.associate.popout.unassociate")
}, {
name: "div",
attr: {
"class": "content"
},
child: [{
name: "div",
attr: {
"class": "bulk-field-block"
},
child: [{
name: "label",
html: I18n.getMsg("crm.potential.associate.popout.entercomments")
}, {
name: "textarea",
attr: {
placeholder: I18n.getMsg("crm.potential.associate.popout.entercomments"),
"class": "textareachk",
"data-textarea": '{"maxlength": 6000, "minlength": 100, "method": "after"}',
id: "unassociate-comment",
value: ""
},
html: ""
}]
}, {
name: "div",
attr: {
"class": "mT20 fL"
},
child: [{
name: "input",
attr: {
"class": "primarybtn",
type: "button",
"data-pkid": append_ids,
"data-jobid": jobId,
"data-module": module,
value: I18n.getMsg("crm.potential.associate.popout.unassociate")
},
events: [{
name: "click",
fn: "ZRCommonUtil.unassociateCand"
}]
}, {
name: "a",
attr: {
href: "javascript:void(0)",
"class": "newgraybtn"
},
events: [{
name: "click",
fn: closeFun
}],
html: I18n.getMsg("crm.button.cancel")
}]
}]
}]
});
$("body").append(createElem), ZRCommonUtil.openDialog(".bulk-update-block"), $("#bg-light").css({
"z-index": "1022"
})
},
unassociateCand: function(event, target) {
var pkidStr = $(target).data("pkid"),
jobopeningId = $(target).data("jobid");
if (pkidStr && 0 === pkidStr.length)
return alert(I18n.getMsg("crm.alert.select.one")), !1;
var params = {};
params.module = $(target).data("module");
var module = params.module,
candId = $("#candId").length ? $("#candId").val() : void 0 != $("#id").val() ? $("#id").val() : void 0;
"Leads" === module && (pkidStr = void 0 != candId && "" != candId ? candId : pkidStr);
var action = $(target).data("action");
action = action && null !== action ? action : "single", params.mode = "unassociate", params.resumeid = pkidStr, params.jobid = jobopeningId, params.description = $("#unassociate-comment").val(), params.action = action;
var module = params.module;
ZRCommonUtil.ajaxPostMethod("/recruit/UnassociateData.do", params, !1, "html", void 0, function(json) {
json = ZRCommonUtil.convertStringToJson(json), json && json.message && "success" === json.message && ($("#bg-light").hide(), $(".bulk-update-block, .notes-block").remove(), ZRCommonUtil.showSuccessMessage(I18n.getMsg("crm.label.success.unassociate")), crmTab.deleteFromCache(module), crmTab.deleteFromCache("Potentials"), void 0 == $("#id").val() && ZRCommonUtil.refreshList(event, target, {
afterUnAss: !0
}))
}, function(xhr) {
var json = ZRCommonUtil.convertStringToJson(xhr.responseText);
json && json.message && "failure" === json.message && alert(I18n.getMsg("crm.security.error.add.user"))
})
},
showHideSearchPopOver: function(obj, allKeyWordSearch) {
var ZRSEARCHMODULES = Crm.searchModules,
module = crmTab.selectedTab;
(void 0 == module || "" === module.trim() || -1 === ZRSEARCHMODULES.indexOf(module)) && (module = "AllEntities");
var moduleDrop = $("#modulenamedrop");
moduleDrop.val(module), $("#modulenamedrop").selectBox("destory").selectBox({
box: !1,
callback: function(a, b) {
if ("create" === a)
$(b._dropdown).css({
"border-radius": "10px",
"box-shadow": "0 1px 3px 0 rgba(63,63,68,.15)"
});
else if ("open" === a) {
var pos = $(b._dropdown).position();
$(b._dropdown).css({
top: pos.top + 10 + "px",
left: pos.left - 14 + "px"
})
}
}
}).on("change", function() {
var module = $(this).val(),
textBox = $("#gsearchTextBox");
textBox.val("").focus(), "Contacts" === module || "Leads" === module ? textBox.attr("placeholder", I18n.getMsg("crm.ss.candidates.placeholder", Handlebars.helpers.getCrmModuleInfo(module))) : "Accounts" === module ? textBox.attr("placeholder", I18n.getMsg("crm.ss.clients.placeholder", Handlebars.helpers.getCrmModuleInfo(module))) : "Potentials" === module ? textBox.attr("placeholder", I18n.getMsg("crm.ss.jobopenings.placeholder", Handlebars.helpers.getCrmModuleInfo(module))) : "AllEntities" === module ? textBox.attr("placeholder", I18n.getMsg("crm.ss.common.placeholder", [Handlebars.helpers.getCrmModuleInfo("Leads"), Handlebars.helpers.getCrmModuleInfo("Potentials"), Handlebars.helpers.getCrmModuleInfo("Accounts"), Handlebars.helpers.getCrmModuleInfo("Contacts")])) : textBox.attr("placeholder", I18n.getMsg("crm.ss.search.module", Handlebars.helpers.getCrmModuleInfo(module)))
});
var textBox = $("#gsearchTextBox");
textBox.val(""), textBox.data().uiAutocomplete.term = null, "Contacts" === module || "Leads" === module ? textBox.attr("placeholder", I18n.getMsg("crm.ss.candidates.placeholder", Handlebars.helpers.getCrmModuleInfo(module))) : "Accounts" === module ? textBox.attr("placeholder", I18n.getMsg("crm.ss.clients.placeholder", Handlebars.helpers.getCrmModuleInfo(module))) : "Potentials" === module ? textBox.attr("placeholder", I18n.getMsg("crm.ss.jobopenings.placeholder", Handlebars.helpers.getCrmModuleInfo(module))) : "AllEntities" === module ? textBox.attr("placeholder", I18n.getMsg("crm.ss.common.placeholder", [Handlebars.helpers.getCrmModuleInfo("Leads"), Handlebars.helpers.getCrmModuleInfo("Potentials"), Handlebars.helpers.getCrmModuleInfo("Accounts"), Handlebars.helpers.getCrmModuleInfo("Contacts")])) : textBox.attr("placeholder", I18n.getMsg("crm.ss.search.module", Handlebars.helpers.getCrmModuleInfo(module))), void 0 != allKeyWordSearch && "" != allKeyWordSearch && textBox.val(allKeyWordSearch);
var advSearchUrl = "/recruit/CreateCV.do?module=" + module + "&isSearch=true";
if (advSearchUrl = ZRCommonUtil.zrModChangeUrl(advSearchUrl), $("#CreateCustomView").attr("href", advSearchUrl), "asspopout" == ZRCommonUtil.FILTERRECORDS) {
var modulenamedrop = moduleDrop;
modulenamedrop.val("Leads"), modulenamedrop.prop("disabled", "disabled")
} else
moduleDrop.removeAttr("disabled");
$(".ss-sugguest-block").hide().find(".ss-sugguest-block").html(""), $(".new-simple-search").css({
top: $("#tabLayer").position().top + "px"
}).show().find(".ss-no-result").hide().html(""), $("#modulenamedrop-sbox").show(), $(".newSearchIcon").toggleClass("newSearchIconH"), textBox.focus(), $("#newSearchContainer").is(":visible") ? $(".results-bar .se").hide() : $(".results-bar .se").show()
},
showHideSearchCriteria: function() {
$(".showHideCriteria").slideToggle()
},
searchFromBar: function() {
var module = $("#modulenamedrop").val(),
searchString = $("#gsearchTextBox").val();
if ("" === searchString.trim())
return crmui.showMsgBand("error", I18n.getMsg("crm.search.letters.check"), 2e3), !1;
"Activities" === module && (module = "Events");
var postData = "module=" + module + "&moduleName=" + module + "&allKeywordSearch=" + encodeURIComponent(searchString) + "&isSearch=true&actionName=create&allFields=1&notesOnly=1&searchType=2&isSearchBar=true";
("Leads" === module || "Candidates" === module) && (postData += "&resumeOnly=1&otherAttachments=0", "asspopout" == ZRCommonUtil.FILTERRECORDS && (postData = postData + "&filterrecords=" + ZRCommonUtil.FILTERRECORDS + "&jobId=" + ZRCommonUtil.FILTERJOBID + "&jobtitle=" + ZRCommonUtil.FILTERJOBNAME, ZRCommonUtil.FILTERCANDSTATUS = "")), postData = postData + "&" + Territory.csrf();
var resObj = Utils.splitStringToObj(postData);
return resObj.clickId = "tab", resObj.calleeObj = "crmTab", Crm.addToHistory(void 0, void 0, resObj), crmTab.updateTabContent(module), !1
},
changeAdvanceSearchFormSubmit: function(module) {
var searchFormObj = $("form[name=searchForm]");
"AllEntities" === module || "Documents" === module ? searchFormObj.attr("action", "").attr("onSubmit", "ajaxGSearch('gsearchTextBox');return false;") : searchFormObj.attr("action", "/recruit/ShowTab.do").attr("onSubmit", "return ZRCommonUtil.searchFromBar();")
},
showFreeTrialPopUp: function(edition, imgStaticUrl) {
var context = {
edition: edition,
imgStaticUrl: imgStaticUrl
},
htmlData = ZRCommonUtil.replaceTemplateData(context, "ExtraScoop", "common"),
oFreezeLayer = document.createElement("div");
oFreezeLayer.id = "bg-light", oFreezeLayer.className = "bg-light", $("body").append(oFreezeLayer), $("body").append(htmlData), $("#spread-word").css("z-index", "1000"), $(".socialDialog").show(), $("#closeTrialPopUp,#goToSubTab").click(function() {
$(oFreezeLayer).remove(), $("#spread-word").remove(), $.ajax({
type: "GET",
url: "/recruit/FreeTrialOptOut.do",
async: !1
})
})
},
sendReviewLinkMail: function(site) {
var urlData = {};
urlData.actionType = "sendReviewLinkMail", urlData.reviewSite = site, $.ajax({
type: "GET",
url: "/recruit/License.do",
data: urlData,
async: !1
})
},
constructISForm: function(e, zuid, dispName, dispEmail, userCnt, imgURL, contNo, country) {
var context = {
userCnt: userCnt,
dispName: dispName,
dispEmail: dispEmail,
zuid: zuid,
imgURL: imgURL,
contNo: contNo,
country: country
},
htmlData = ZRCommonUtil.replaceTemplateData(context, "InstantSupport", "Support");
$("body").append(htmlData);
var id = $("#modal-popup");
$("#main-cont").css($("body").height() > $(window).height() ? {
opacity: "0.8",
height: $("body").height()
} : {
opacity: "0.8",
height: $(window).height()
});
var win = $(window);
id.css({
position: "fixed"
});
var left = (win.width() - id.outerWidth()) / 2 + win.scrollLeft();
id.css("left", left);
var top = (win.height() - id.outerHeight()) / 2 + win.scrollTop();
id.css("top", top);
var height = win.height() - 310;
$(".scroll").height(height), $("#bg-light").remove();
var oFreezeLayer = document.createElement("div");
oFreezeLayer.id = "bg-light", oFreezeLayer.className = "bg-light", document.body.appendChild(oFreezeLayer), $("#main-cont").fadeIn();
var contList = $("#countList");
ZRComponent.customSelect(contList, {
id: "countList",
isselect: !0,
minlength: 1,
issearch: !0,
selectclass: "w240 ac-bdr2 mT5",
tooltipchar: 40
}), $("#custom-select-container-countList").prop("class", "recruit-ac ac-bdr2 w100per"), hideMenu(), $("#custom-select-option-countList, #timeDd2, #timeDd").mouseleave(function() {
$(this).slideUp()
}), $("#succOkBut").click(function() {
$("#InstantSupportDiv").remove(), $("#main-cont").remove(), $(oFreezeLayer).remove(), location.reload(!0)
}), $("#timeBx").click(function() {
$("#timeDd").slideToggle()
}), $("#timeBx2").click(function() {
$("#timeDd2").slideToggle()
}), $("#dTmUL1 li").click(function() {
var anchEle = $(this).html(),
timeVal = $(anchEle).html();
$("#timeBx").val(timeVal), $("#timeDd").hide()
}), $("#dTmUL2 li").click(function() {
var anchEle = $(this).html(),
timeVal = $(anchEle).html();
$("#timeBx2").val(timeVal), $("#timeDd2").hide()
}), $(".closeIS").click(function() {
$("#InstantSupportDiv").remove(), $("#main-cont").remove(), $(oFreezeLayer).remove()
}), $("#isTmSlot1, #isTmSlot2").bind("click", function() {
showCalen(this.id), $("#Calendar").css("z-index", "100003"), $("#calenDiv").mouseleave(function() {
$("#Calendar").hide()
})
}), $("#submitISForm").bind("click", function() {
var params = {};
if (params.contact = $("#isCnctNo").val(), void 0 == params.contact || "" === params.contact.trim() || RegExp("[a-zA-z ].*").test(params.contact) || params.contact.length < 5)
return void ZRCommonUtil.handleISValPop(I18n.getMsg("crm.tpi.ctiapi.msg.alert.notvalidphno"));
if (params.noOfUsers = $("#isNoOfUsers").val(), void 0 == params.noOfUsers || "" === params.noOfUsers.trim() || !RegExp("^[0-9]*$").test(params.noOfUsers))
return void ZRCommonUtil.handleISValPop(I18n.getMsg("invalid.no.of.users"));
if (params.country = $("#custom-select-placeholder-value-countList").val(), void 0 == params.country || "" === params.country.trim() || "Select" === params.country)
return void ZRCommonUtil.handleISValPop(I18n.getMsg("crm.nsocial.pop.location.enter"));
var slot1 = $("#isTmSlot1").val() + " " + $("#timeBx").val();
if (params.slot1 = "", void 0 != slot1 && 19 === slot1.length) {
var mm = slot1.substring(0, 2),
dd = slot1.substring(3, 5);
params.slot1 = dd + "/" + mm + slot1.substring(5, slot1.length)
}
if (void 0 == params.slot1 || "" === params.slot1.trim())
return void ZRCommonUtil.handleISValPop(I18n.getMsg("invalid.is.datetime"));
var slot2 = $("#isTmSlot2").val() + " " + $("#timeBx2").val();
if (params.slot2 = "", void 0 != slot2 && 19 === slot2.length) {
var mm = slot2.substring(0, 2),
dd = slot2.substring(3, 5);
params.slot2 = dd + "/" + mm + slot2.substring(5, slot2.length)
}
return void 0 == params.slot2 || "" === params.slot2.trim() ? void ZRCommonUtil.handleISValPop(I18n.getMsg("invalid.is.datetime")) : (params.timeline = $("#isTTI").val(), void 0 == params.timeline || params.timeline.length > 500 ? void ZRCommonUtil.handleISValPop(I18n.getMsg("invalid.is.timeline")) : (params.req = $("#isRequi").val(), void 0 == params.req || "" === params.req.trim() || params.req.length > 500 ? void ZRCommonUtil.handleISValPop(I18n.getMsg("invalid.is.req")) : (params.zuid = zuid, params.crmContNo = $("#isCnctNoCRM").val(), params.crmCountry = $("#isCountryCRM").val(), void ZRCommonUtil.ajaxPostMethod("/recruit/InstantSupport.do", params, !1, "html", void 0, function(data) {
data = data ? JSON.parse(data) : data, data && data.hasOwnProperty("success") && "Submitted" === data.success ? ($("#popContent,#buttGroup").hide(), $("#succPop").slideDown()) : data && data.hasOwnProperty("error") && ("Already Submitted" === data.error ? ZRCommonUtil.handleISValPop(I18n.getMsg("is.submitted")) : "Time Check" === data.error && ZRCommonUtil.handleISValPop(I18n.getMsg("is.message11")))
}, function() {
ZRCommonUtil.handleISValPop(I18n.getMsg("crm.fr.unknown"))
}))))
})
},
handleISValPop: function(value) {
var params = {};
params.savefn = function() {
$(".bg-dark").css("z-index", "950");
var closeDiv = $(target).parents(".zcrm-modal").attr("id");
ZRCommonUtil.closeDialog(ev, target, "#" + closeDiv)
}, ZRCommonUtil.createInfoBox({
titleclass: "til warning",
title: I18n.getMsg("crm.formula.alert"),
content: value,
savebtn: I18n.getMsg("crm.button.ok")
}), $("#modal-block").css("z-index", "100003"), $(".bg-dark").css("z-index", "100002")
},
constructFeedbackForm: function(e, zuid, name, isCNBuild) {
void 0 == zuid && (zuid = Crm.userDetails.ZUID, name = Crm.userDetails.DISPLAY_NAME);
var workingUrl = window.location.href,
color = $("#tabLayer .newMenuTable").css("background-color"),
context = {
name: name,
zuid: zuid,
workingUrl: workingUrl,
color: color,
isCNBuild: "true" == isCNBuild ? !0 : !1
},
htmlData = ZRCommonUtil.replaceTemplateData(context, "FeedBackForm", "Support");
$("body").append(htmlData);
var elem = $("#feedbackform");
$("#bg-light").remove();
var oFreezeLayer = document.createElement("div");
oFreezeLayer.id = "bg-light", oFreezeLayer.className = "zrc-freeze", document.body.appendChild(oFreezeLayer), $("#bg-light").css("z-index", "101"), $("#uploadFileButton2").click(function() {
$("#uploadFileButton").click()
});
var sTop = document.documentElement.scrollTop || document.body.scrollTop,
sLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
if ($(window).height() > elem.height())
elem.css({
display: "block",
position: "absolute",
left: "50%",
top: "50%",
"margin-left": -(elem.width() / 2) + sLeft,
"margin-top": -(elem.height() / 2) + sTop
});
else {
var tP = sTop + 10;
elem.css({
display: "block",
position: "absolute",
left: "50%",
top: tP,
"margin-left": -(elem.width() / 2) + sLeft,
"margin-top": "0px"
})
}
$("#feedbackform").hide().slideDown("fast"), hideMenu()
},
simpleSearchFromResult: function(startIndex, rangeValue) {
var module = $("#modulenamedrop").val(),
searchString = $("#gsearchTextBox").val(),
startLimit = $("input[name = 'fromIndex']").val(),
range = $("input[name = 'rangeValue']").val(),
sortColumnString = $("input[name = 'sortColumnString']").val(),
sortOrderString = $("input[name = 'sortOrderString']").val();
if (range = void 0 != range ? range : "10", void 0 != startIndex && "" != startIndex && "undefined" != startIndex && (startLimit = startIndex), void 0 != rangeValue && "" != rangeValue && "undefined" != rangeValue && (range = rangeValue), sortColumnString = void 0 != sortColumnString ? sortColumnString : "", sortOrderString = void 0 != sortOrderString ? sortOrderString : "", void 0 != searchString && "" != searchString) {
var postData = "moduleName=" + module + "&allKeywordSearch=" + encodeURIComponent(searchString) + "&isSearch=true&actionName=create&allFields=1&notesOnly=1&searchType=2&isSearchBar=true&startLimit=" + startLimit + "&range=" + range + "&sortColumnString=" + sortColumnString + "&sortOrderString=" + sortOrderString;
("Leads" === module || "Candidates" === module) && (postData += "&resumeOnly=1&otherAttachments=0", "asspopout" == ZRCommonUtil.FILTERRECORDS && (postData = postData + "&filterrecords=" + ZRCommonUtil.FILTERRECORDS + "&jobId=" + ZRCommonUtil.FILTERJOBID + "&jobtitle=" + ZRCommonUtil.FILTERJOBNAME, ZRCommonUtil.FILTERCANDSTATUS = "")), postData = postData + "&" + Territory.csrf();
var resObj = Utils.splitStringToObj(postData);
resObj.clickId = "tab", resObj.calleeObj = "crmTab", resObj.isSearch = "true", resObj.clearCache = "true", Crm.addToHistory(void 0, void 0, resObj)
}
return !1
},
delegateClickEventForAttachPerm: function(event) {
var tgt = $(event.target);
tgt.is("#saveBtn") && ZRFileUtil.permissionSetQuery(!0)
},
delegateChangeEventForAttachPerm: function(ev) {
var tgt = $(ev.target);
tgt.is("input[type=checkbox]") ? ZRFileUtil.permissionChange(tgt) : (tgt.is("#profileSelect") || tgt.is("#moduleSelect")) && ZRFileUtil.permissionSetQuery(!1)
},
changeRole: function(ev, spaceId) {
if (window.confirm("Do you want to change the role of this user?")) {
var urlData = {};
urlData.actionName = "upgradeUserFromTool";
var userid = $(ev.target).parent().siblings().eq(1).html();
urlData.userIdToChange = userid, urlData.spaceId = spaceId, urlData.roleid = $(ev.target).val(), ZRCommonUtil.ajaxPostMethod("/recruit/Security.do", urlData, !0, "json", void 0, function(data) {
data && alert("Role changed sucessfully")
})
}
},
getDefaultSearchBarModule: function() {
var defSearchModule = void 0,
url = "/recruit/GetDefaultSearchBarModule.do";
return ZRCommonUtil.ajaxGetMethod(url, void 0, !1, "json", void 0, function(jsonData) {
defSearchModule = jsonData.defSearchModule
}, function() {}), defSearchModule
},
setDefaultSearchBarModule: function(defSearchModule) {
var status = "success",
params = {
defSearchModule: defSearchModule
},
url = "/recruit/SetDefaultSearchBarModule.do";
return ZRCommonUtil.ajaxPostMethod(url, params, !1, "json", void 0, function(jsonData, undefined) {
if ("success" == jsonData.successMessage) {
ZRCommonUtil.SEARCHDEFAULT = defSearchModule;
var module = "Leads";
"TAB" == defSearchModule.trim() && (module = $("#module").val(), module == undefined || "" === module.trim() || "Documents" === module ? module = "Leads" : "Activities" == module && (module = "Events")), $("#modulenamedrop").val(module), $("#gsearchTextBox").focus()
} else
status = "failed"
}, function() {
status = "failed"
}), status
},
sortselectBox: function(objs, isSortNumerically) {
objs.each(function(j, select) {
var options = $(select).find("option"),
arr = options.map(function(_, o) {
return {
t: $(o).text(),
v: $(o).val()
}
}).get();
arr.sort(function(o1, o2) {
var t1 = o1.t.toLowerCase(),
t2 = o2.t.toLowerCase();
return isSortNumerically ? (t1 = t1.split(" ")[0], t2 = t2.split(" ")[0], parseInt(t1) - parseInt(t2)) : t1 > t2 ? 1 : t2 > t1 ? -1 : 0
}), options.each(function(i, o) {
o.value = arr[i].v, $(o).text(arr[i].t)
})
})
},
sortUlLiselectBox: function(objs) {
objs.each(function(j, ulElem) {
var options = $(ulElem).find("li"),
arr = options.map(function(_, o) {
return {
t: $(o).text(),
v: $(o).data("value")
}
}).get();
arr.sort(function(o1, o2) {
var t1 = o1.t.toLowerCase(),
t2 = o2.t.toLowerCase();
return t1 > t2 ? 1 : t2 > t1 ? -1 : 0
}), options.each(function(i, o) {
$(o).data("value", arr[i].v), $(o).attr("data-value", arr[i].v), $(o).text(arr[i].t)
})
})
},
getSelectedRows: function(module) {
var form = document.TransferWizardForm;
"undefined" != typeof formobj && (form = formobj[0]);
var listview = !0;
void 0 != form && (listview = !1);
var append_ids = "",
noofrows = void 0;
if (listview) {
if (noofrows = crmTab.getFromCache(module).body.length, noofrows && 0 == noofrows) {
var params = {
removefreeze: !1,
type: "failure",
baseid: "error-alert-message",
scroll: !1,
content: I18n.getMsg("crm.alert.select.one"),
display: "inline",
position: "middle"
};
return ZRComponent.createAlertDialog(params), !1
}
append_ids = crmListView.getObject().selectedIds.join(";")
} else {
var selectedRows = $("[name=chk]:checked");
if (!selectedRows)
return;
if (noofrows = selectedRows.length, void 0 != noofrows && 0 == noofrows) {
var params = {
removefreeze: !1,
type: "failure",
baseid: "error-alert-message",
scroll: !1,
content: I18n.getMsg("crm.alert.select.one"),
display: "inline",
position: "middle"
};
return ZRComponent.createAlertDialog(params), !1
}
for (var i = 0; noofrows > i; i++) {
var values = selectedRows[i].value.split("&&||"),
ids = values[0];
append_ids = ids + ";" + append_ids
}
append_ids = void 0 != append_ids && append_ids.endsWith(";") ? append_ids.substr(0, append_ids.length - 1) : append_ids
}
return append_ids
},
getTruncatedNamesList: function(recordsList) {
var recordNamesShort = "";
if (recordsList.length > 10) {
for (var i = 0; 10 > i; i++)
recordNamesShort = "" === recordNamesShort ? recordsList[i] : recordNamesShort + "," + recordsList[i];
recordNamesShort = "" !== recordNamesShort ? recordNamesShort + ",..." : ""
}
return recordNamesShort
},
loadListener: function(url) {
window.addEventListener && (ZRCommonUtil.docsUrl = url, addEventListener("message", ZRCommonUtil.docsListener, !1))
},
docsListener: function(event) {
if (event && event.origin === ZRCommonUtil.docsUrl) {
var eventOrigin = event.origin,
urlParts = eventOrigin.split("://"),
iFrameHt = (urlParts.length > 1 ? urlParts[1] : urlParts[0], $(window).height() - $("#topdivbg").height());
$("#externalIframe").height(iFrameHt)
}
},
loadCandQuickviewHtml: function(target) {
var dataObj = $(target).data("attachdetail");
"string" == typeof dataObj && (dataObj = ZRCommonUtil.convertStringToJson(dataObj));
var templateSource = Handlebars.getTemplate("Search", "CandSearchPreview");
if (dataObj) {
var windowHt = dataObj.windowHt,
attachmentId = dataObj.attachmentId,
fileId = dataObj.fileId;
if (attachmentId && "" != attachmentId.id)
if (fileId && "" != fileId && "-1" != fileId) {
var pkid = dataObj.pkid,
module = dataObj.module,
linkDocs = dataObj.linkDocs,
module = dataObj && dataObj.module ? dataObj.module : "Leads",
downLoadPermission = dataObj && dataObj.downLoadPermission ? dataObj.downLoadPermission : "false";
downLoadPermission = "true" == downLoadPermission ? !0 : !1, (void 0 == linkDocs || null == linkDocs) && (linkDocs = "false");
var originalFileName = dataObj.fileName,
simpleSearchStr = (dataObj.isList, $("#gsearchTextBox")),
searchKeyWord = "",
ua = window.navigator.userAgent,
msie = ua.indexOf("MSIE ") > 0 || ua.indexOf("Trident/") > 0 || ua.indexOf("Edge/") > 0 ? !0 : !1,
searchData = History.getState().data;
searchKeyWord = "true" === searchData.isSME ? ZRSME.getSearchStrForHighlight(searchData.smeEntityId) : void 0 != simpleSearchStr && simpleSearchStr.length > 0 && searchData && searchData.isSearchBar && "true" === searchData.isSearchBar ? simpleSearchStr.val() : void 0 != searchData && void 0 != searchData.allKeywordSearch ? decodeURIComponent(searchData.allKeywordSearch) : "", dataObj.searchKeyWord = searchKeyWord;
var mode = ZRFileUtil.getMode(originalFileName),
json = {};
if (json.isSearch = !0, json.msie = msie, json.id = pkid, json.fullName = dataObj.fullName, json.downLoadFile = downLoadPermission, json.downLoadMode = mode, json.downLoadLink = "/recruit/ViewAttachment?fileId=" + fileId + "&module=" + encodeURIComponent(module) + "&id=" + attachmentId + "&name=" + encodeURIComponent(originalFileName) + "&downLoadMode=default&linkDocs=" + linkDocs, json.windowHt = windowHt, json.message = "success", "writer" == mode) {
target.find(".qsts-footer").remove();
var url = "/recruit/CandSearchPreviewHtml.do";
void 0 != dataObj.isFromDetailView && "detailView" === dataObj.isFromDetailView ? (json.isFromDetailView = "fromDetailView", $("#candDetailquickpreview").html(templateSource(json)).show(), $(".loaderImg").css("top", windowHt / 2 - 50), ZRCommonUtil.ajaxGetMethod(url, dataObj, !0, "html", void 0, function(htmlData) {
$("#cand-res-prev-fr").html(htmlData), $("#content-m-fr img").not("#oops-img").remove(), ZRCommonUtil.hideFResumeLoadingIcon()
}, function() {
var errorContent = '<img src="' + crmConstants.imgStaticPath + '/Oops.jpg" id="oops-img" alt="' + I18n.getMsg("crm.search.highlight.error.msg") + '" style="position:absolute;left:230px;top:' + (windowHt / 2 - 120) + 'px">';
$("#candDetailquickpreview").html(templateSource(json)).show(), $("#cand-res-prev-fr").html(errorContent), $(".loaderImg").css("top", windowHt / 2 - 50), ZRCommonUtil.hideFResumeLoadingIcon()
}, !1)) : ($("#candquickpreview").html(templateSource(json)).show(), $(".loaderImg").css("top", windowHt / 2 - 50), ZRCommonUtil.ajaxGetMethod(url, dataObj, !0, "html", void 0, function(htmlData) {
$("#cand-res-prev").html(htmlData), $("#content-m img").not("#oops-img").remove(), ZRCommonUtil.hideLoadingIcon()
}, function() {
var errorContent = '<img src="' + crmConstants.imgStaticPath + '/Oops.jpg" id="oops-img" alt="' + I18n.getMsg("crm.search.highlight.error.msg") + '" style="position:absolute;left:230px;top:' + (windowHt / 2 - 120) + 'px">';
$("#candquickpreview").html(templateSource(json)).show(), $("#cand-res-prev").html(errorContent), $(".loaderImg").css("top", windowHt / 2 - 50), ZRCommonUtil.hideLoadingIcon()
}, !1))
} else if ("image" == mode || "pdfViewPlugin" == mode) {
target.find(".qsts-footer").remove();
var srcUrl = "";
"image" == mode ? (srcUrl = "/recruit/ViewAttachment?fileId=" + fileId + "&module=" + module + "&parentId=" + pkid + "&id=" + attachmentId + "&name=" + encodeURIComponent(originalFileName) + "&downLoadMode=" + mode + "&linkDocs=" + linkDocs, json.srcContent = srcUrl) : "pdfViewPlugin" == mode && (srcUrl = "/recruit/CandSearchPreviewHtml.do?fileId=" + fileId + "&module=" + module + "&pkid=" + pkid + "&attachmentId=" + attachmentId + "&fileName=" + encodeURIComponent(originalFileName) + "&searchKeyWord=" + encodeURIComponent(searchKeyWord) + "&windowHt=" + windowHt + "&linkDocs=" + linkDocs, json.srcContent = srcUrl), dataObj.isFromDetailView ? (json.isFromDetailView = "fromDetailView", $("#candDetailquickpreview").html(templateSource(json)).show()) : $("#candquickpreview").html(templateSource(json)).show(), "image" == mode && $("#content-m").slimScroll({}), $(".loaderImg").css("top", windowHt / 2 - 50)
} else {
var errorContent = '<img src="' + crmConstants.imgStaticPath + '/Oops.jpg" id="oops-img" alt="' + I18n.getMsg("crm.search.highlight.error.msg") + '" style="position:absolute;left:230px;top:' + (windowHt / 2 - 120) + 'px">';
void 0 != dataObj.isFromDetailView && "detailView" === dataObj.isFromDetailView ? (json.isFromDetailView = "fromDetailView", $("#candDetailquickpreview").html(templateSource(json)).show(), $("#cand-res-prev-fr").html(errorContent), $(".loaderImg").css("top", windowHt / 2 - 50), ZRCommonUtil.hideFResumeLoadingIcon()) : ($("#candquickpreview").html(templateSource(json)).show(), $("#cand-res-prev").html(errorContent), $(".loaderImg").css("top", windowHt / 2 - 50), ZRCommonUtil.hideLoadingIcon())
}
} else {
var errorContent = '<img src="' + crmConstants.imgStaticPath + '/Oops.jpg" id="oops-img" alt="' + I18n.getMsg("crm.search.highlight.error.msg") + '" style="position:absolute;left:230px;top:' + (windowHt / 2 - 120) + 'px">';
void 0 != dataObj.isFromDetailView && "detailView" === dataObj.isFromDetailView ? (json.isFromDetailView = "fromDetailView", $("#candDetailquickpreview").html(templateSource(json)).show(), $("#cand-res-prev-fr").html(errorContent), $(".loaderImg").css("top", windowHt / 2 - 50), ZRCommonUtil.hideFResumeLoadingIcon()) : ($("#candquickpreview").html(templateSource(json)).show(), $("#cand-res-prev").html(errorContent), $(".loaderImg").css("top", windowHt / 2 - 50), ZRCommonUtil.hideLoadingIcon())
}
} else {
var errorContent = '<img src="' + crmConstants.imgStaticPath + '/Oops.jpg" id="oops-img" alt="' + I18n.getMsg("crm.search.highlight.error.msg") + '" style="position:absolute;left:230px;top:' + (windowHt / 2 - 120) + 'px">';
target || target.selector || "#qs-tab10" !== target.selector ? ($("#candquickpreview").html(templateSource(json)).show(), $("#cand-res-prev").html(errorContent), $(".loaderImg").css("top", windowHt / 2 - 50), ZRCommonUtil.hideLoadingIcon()) : (json.isFromDetailView = "fromDetailView", $("#candDetailquickpreview").html(templateSource(json)).show(), $("#cand-res-prev-fr").html(errorContent), $(".loaderImg").css("top", windowHt / 2 - 50), ZRCommonUtil.hideFResumeLoadingIcon())
}
},
navigateDocumentView: function(currentid, action) {
var elem = $("#attachLink_" + currentid),
dataObj = $(elem).attr("data-attachdetail"),
params = dataObj ? "object" == typeof dataObj ? dataObj : JSON.parse(dataObj) : {},
recordNum = parseInt(params.recordNum);
"NavNext" === action ? recordNum = parseInt(recordNum) + 1 : "NavPrevious" === action && (recordNum = parseInt(recordNum) - 1), ZRCommonUtil.loadCandPreviewHtml($("#attachLink_" + crmNavig[crmNavig.customViewKey].recordId[recordNum].id))
},
fetchNextResumeId: function(recordNum) {
var rec = parseInt(recordNum),
key = crmNavig.customViewKey,
detailPrevious = $("#detailPrevious"),
detailNext = $("#detailNext");
if (key && crmNavig[key]) {
{
var prev = crmNavig[key].recordId[rec - 1],
nex = crmNavig[key].recordId[rec + 1];
$("#module").length > 0 ? $("#module")[0].value : ""
}
prev && "EOA" !== prev ? (detailNext.show(), detailPrevious.attr("class", "sb-prev").show()) : detailPrevious.attr("class", "sb-prev disabled").removeAttr("data-cid"), nex && "EOA" !== nex ? (detailNext.attr("class", "sb-next").show(), detailPrevious.show()) : detailNext.attr("class", "sb-next disabled"), nex && "EOA" !== nex || prev && "EOA" !== prev || (detailNext.hide(), detailPrevious.hide())
}
},
fetchNextResume: function(json) {
var startLimit = $("input[name='startLimit']").val(),
range = $("tbody#lvTred tr").length,
isSearch = json && json.isSearch ? json.isSearch : !1;
startLimit = void 0 != startLimit ? parseInt(startLimit) : void 0, range = void 0 != range ? parseInt(range) : void 0;
var pkid = json && json.id ? json.id : void 0,
prevRecord = "0",
nextRecord = "0";
if (void 0 != startLimit && void 0 != range && isSearch && void 0 != pkid) {
var toIndex = startLimit + range - 1,
naviDataArrLen = parseInt(0),
naviDataArrIter = "",
startIndex = void 0;
if (naviDataArr && "" != naviDataArr.trim() && (naviDataArrIter = naviDataArr.split(","), naviDataArrLen = naviDataArrIter.length, startIndex = naviDataArrIter.indexOf(pkid)), 0 == naviDataArrLen)
return json.prevRecord = prevRecord, void (json.nextRecord = nextRecord);
if (-1 != startIndex) {
for (var index = startIndex + 1; toIndex - 1 >= index && ("0" == nextRecord && (nextRecord = naviDataArrIter[index], nextRecord = void 0 != nextRecord && $("#attachLink_" + nextRecord).length > 0 ? nextRecord : "0"), "0" == nextRecord); index++)
;
for (var index = startIndex - 1; index >= startLimit - 1 && ("0" == prevRecord && (prevRecord = naviDataArrIter[index], prevRecord = void 0 != prevRecord && $("#attachLink_" + prevRecord).length > 0 ? prevRecord : "0"), "0" == prevRecord); index--)
;
}
}
json.nextRecord = nextRecord, json.prevRecord = prevRecord
},
hideLoadingIcon: function() {
$("#loading-img").css("display", "none"), $("#content-div").css("display", "block"), $(window).resize(function() {
var candQuickPreview = $("#candquickpreview");
if (candQuickPreview.length > 0) {
var scrollTo = $("#candquickpreview").scrollTop(),
contentElem = $(".search-modal-dialog "),
windowHeight = $(window).height(),
headerheight = $(".qs-header").outerHeight(),
tabheight = $("#qs-navigation").outerHeight(),
windowHt = windowHeight - (headerheight + tabheight);
if (scrollTo > 20 && $(contentElem).css({
position: "fixed",
right: 0,
top: "0"
}), candQuickPreview.parent(".cand-resume-section").length > 0)
return windowHt = $(".detail-cand-info").outerHeight() - 80, $(contentElem).css("height", windowHt), $("#content-m").css("height", windowHt - 39), $("#cand-res-prev").css("height", windowHt - 27), !1;
$(contentElem).css("height", windowHt + 40), $("#content-m").css("height", windowHt - 39), $("#cand-res-prev").css("height", windowHt - 27)
}
}), setTimeout(function() {
$(window).trigger("resize")
}, 200), $("#oops-img").length > 0 && ($("#print-content").closest("li").hide(), $("#download-content").closest("li").hide())
},
hideFResumeLoadingIcon: function() {
$("#loading-img-fr").css("display", "none"), $("#content-div-fr").css("display", "block"), $(window).resize(function() {
if ($("#candDetailquickpreview").length > 0) {
var scrollTo = $("#candDetailquickpreview").scrollTop(),
windowHeight = $(window).height(),
headerheight = $(".qs-header").outerHeight(),
tabheight = $("#qs-navigation").outerHeight(),
windowHt = windowHeight - (headerheight + tabheight),
contentElem = $(".search-modal-dialog ");
scrollTo > 20 && $(contentElem).css({
position: "fixed",
right: 0,
top: "0"
}), $(contentElem).css("height", windowHt + 40), $("#content-m-fr").css("height", windowHt - 39), $("#cand-fres-prev").css("height", windowHt - 27)
}
}), setTimeout(function() {
$(window).trigger("resize")
}, 200), $("#oops-img").length > 0 && ($("#print-content-fr").closest("li").hide(), $("#download-content-fr").closest("li").hide())
},
closePreview: function(divId, pkid) {
if (divId) {
var elem = $(divId);
elem && 0 !== elem.length && elem.hide()
}
pkid && ($("#" + pkid).removeClass("active"), $("#attachLink_" + pkid).removeClass("active"))
},
showHideImportDropdown: function(importBtn, permission, permissionImportResume) {
var button = $(importBtn);
if (button.hasClass("active")) {
var leadsName = Crm.moduleInfo.Leads ? Crm.moduleInfo.Leads[1] : "Candidates";
button.removeClass("active");
var dropDown = Utils.createHTML({
name: "ul",
attr: {
"class": "import-dropdown animated",
style: "display:none;"
}
});
permissionImportResume && dropDown.appendChild(Utils.createHTML({
name: "li",
child: [{
name: "a",
attr: {
href: "javascript:",
"data-cid": "parserbtn",
"data-params": '{"module":"Leads","step":"1"}',
title: I18n.getMsg("crm.importfromdocument.title")
},
html: I18n.getMsg("crm.importfromdocument.title")
}]
})), permission && dropDown.appendChild(Utils.createHTML({
name: "li",
child: [{
name: "a",
attr: {
href: "javascript:",
"data-cid": "importbtn",
"data-params": '{"module":"Leads","step":"1"}',
title: I18n.getMsg("crm.module.import", I18n.getMsg(leadsName))
},
html: I18n.getMsg("crm.module.import", I18n.getMsg(leadsName))
}]
})), $(dropDown).insertAfter(button), dropDown = $(".import-dropdown"), dropDown.addClass("slideInUp"), dropDown.removeClass("slideInDown"), dropDown.css("display", "block"), $(".candidate_leadbox").on("click", function(event) {
var tgt = $(event.target);
0 === $(".import-indeed-list").has(tgt).length && (button.addClass("active"), dropDown.remove())
})
} else
button.addClass("active"), $(".import-dropdown").remove()
},
getLimitedHTMLToolBar: function() {
var toolBar = [[["bold", "Bold (Ctrl+B)", "zei-bold"], ["italic", "Italic (Ctrl+I)", "zei-italic"], ["underline", "Underline (Ctrl+U)", "zei-underline"], ["strikethrough", "Strikethrough", "zei-strike"]], [["fontfamily", "Font", "zei-fontfamily"]], [["fontsize", "Font Size", "zei-arrow"]], [["alignoptions", "Fontstyle Options", "zei-textleft"], ["listoptions", "List Options", "zei-unorder"], ["indentoptions", "Indent Options", "zei-outdent"]], [["superscript", "superScript", "zei-superScript"]], [["subscript", "subScript", "zei-subScript"]], [["removeformat", "Remove Formatting", "zei-removeformat"]], [["link", "Insert Link", "zei-link"], ["inserthorizontalrule", "Insert Horizontal Rule", "zei-line"]], [["spellcheck", "Check Spelling", "zei-spellCheck"]], [["otheroptions", "Plain Text", "zei-arrow ze-big"]]];
return toolBar
},
splCharCheck: function(fieldValue, newSplCharArray) {
for (newSplCharArray = ZRCommonUtil.isEmpty(newSplCharArray) ? splCharArray : newSplCharArray, i = 0; i < newSplCharArray.length; i++)
if (fieldValue.indexOf(newSplCharArray[i]) >= 0)
return !1;
return !0
},
showAttachmentCategoryPopForAttachFromDetail: function(dzFiles) {
if (!$("#cate").is(":visible") && $("#atch").is(":visible")) {
var attachmentDivParent = $("#attachPopup"),
attachmentDiv = $("#atch"),
attachCatDiv = $("#cate");
attachCatDiv.show();
var pElem = "",
len = dzFiles.length;
for (i = 0; len > i; i++) {
var categories = '<select id="select_' + i + '" name="select_' + i + '" class="select fR w200" onchange="javascript:Change(this)" onfocus="javascript:focusStore(this)">' + $("#categories").html() + "</select>",
curFile = dzFiles[i],
name = curFile.name,
title = 1 === count ? "<b title='" + $ESAPI.encoder().encodeForHTMLAttribute(name) + "'>" + $ESAPI.encoder().encodeForHTML(name) + "</b>" : "<b title='" + $ESAPI.encoder().encodeForHTMLAttribute(name) + "'>" + $ESAPI.encoder().encodeForHTML(name) + "</b>",
addElem = "<p class='att-list newSelect' style='border:none;'><img width='16px' border='0' align='absmiddle' hspace='3' height='16px' class='file-icon' src='images/spacer.gif'>" + title + categories + "</p>";
pElem = "" === pElem ? addElem : pElem + addElem
}
noOfSelect = len, $("#attachList").append(pElem), attachCatDiv = $("#cate"), height = attachCatDiv.css("height");
var ht = parseInt(height.split("px")[0]),
topPos = "-" + ht / 2 + "px";
return width = attachCatDiv.css("width"), $(attachCatDiv).css("margin-top", topPos), $(attachmentDiv).css("height", height), $(attachmentDivParent).css("width", width), $(attachmentDivParent).css("overflow", "hidden"), !1
}
var list = $("#attachmentList").value;
return null != list && list.length > 0 ? !0 : void 0
},
removeActionsFromDetailPage: function() {
var linksToBeRemoved_Personalities = ZRCommonUtil.getRelatedListNameVsId(),
moreActionsToBeRemoved_Ids = ["customButtonDetails", "cutomizebcLink", "customizeRelDetails", "candidateAssociation", "cutomizeMacroLink", "newRelatedListDiv", "fullInfoNoteDiv", "convert_details", "toggleNotes > #zciFieldMap", "singleGenerateFormattedResumeId", "candidateInvitationStatus", "FindInIndeedLInk", "associatedTags li a, #associate-tagshow, a#createlink, div.normalDropDown, div#customlinkcount span", "contactInviteLink"],
moreActionsToBeRemoved_Names = ["mailmerge", "Duplicate2", "Convert2", "Clone", "Print2"],
moreActionsToBeRemoved_Class = ["notesActionbtn", "notesActionbtnDel", "notesArrowDownNew", "addNewIcP", "typeedit", "dd-sep", "calliconOuter"],
moreActionsToBeRemoved_CallIds = ["relAssociateExistingJOId", "sendEntityMailLink", "relSendSMSId", "relClientSubmissionId", "relCreateNewProductId", "requestGDPRConsent"];
ZRCommonUtil.removeRelatedListActionsByPersonalityName(linksToBeRemoved_Personalities), ZRCommonUtil.removeMoreActions(moreActionsToBeRemoved_Ids, moreActionsToBeRemoved_Names, moreActionsToBeRemoved_Class, moreActionsToBeRemoved_CallIds)
},
removeLinksFromDetailPage: function() {
var linksToBeRemoved_Personalities = ZRCommonUtil.getRelatedListNameVsId();
delete linksToBeRemoved_Personalities.attachmentspersonality;
var moreActionsToBeRemoved_Ids = ["cutomizeMacroLink", "newRelatedListDiv", "convert_details", "singleGenerateFormattedResumeId", "FindInIndeedLInk", "associatedTags li a, #associate-tagshow, a#createlink, div.normalDropDown, div#customlinkcount span"],
moreActionsToBeRemoved_Names = ["mailmerge", "Duplicate2", "Convert2"];
ZRCommonUtil.removeRelatedListActionsByPersonalityName(linksToBeRemoved_Personalities), ZRCommonUtil.removeMoreActions(moreActionsToBeRemoved_Ids, moreActionsToBeRemoved_Names)
},
getRelatedListNameVsId: function() {
for (var pNameVspId = {}, pArr = crmRelatedList.personalityArr.split("||"), j = 0; j < pArr.length; j++) {
var temp = pArr[j].split("_"),
pName = temp[0],
pId = temp[1];
pNameVspId[pName] = pId
}
return pNameVspId
},
removeRelatedListActionsByPersonalityName: function(pNameArr) {
if (pNameArr && Object.keys(pNameArr).length > 0)
for (var pName in pNameArr)
if (pNameArr.hasOwnProperty(pName)) {
var pId = pNameArr[pName];
"undefined" != typeof pId && ZRCommonUtil.removeRelatedListActionsByPersonalityId(pId, pName)
}
},
removeRelatedListActionsByPersonalityId: function(pId, pName) {
$("#norec_" + pId).find("a").remove(), $("#ract_" + pId).find("a").remove(), $("#newleft_" + pId).find("span.addNewIcP").remove(), ZRCommonUtil.removeRelatedListMouseOverActionsByPersonalityId(pId, pName)
},
removeMoreActions: function(elemIdArr, elemNameArr, elemClassArr, elemCallIds) {
if (elemIdArr && elemIdArr.length > 0)
for (var i = 0; i < elemIdArr.length; i++)
$("#" + elemIdArr[i]).remove();
if (elemNameArr && elemNameArr.length > 0)
for (var i = 0; i < elemNameArr.length; i++)
$("[name=" + elemNameArr[i] + "]").remove();
if (elemClassArr && elemClassArr.length > 0)
for (var i = 0; i < elemClassArr.length; i++)
$("." + elemClassArr[i]).remove();
if (elemCallIds && elemCallIds.length > 0)
for (var i = 0; i < elemCallIds.length; i++)
$("[data-callid=" + elemCallIds[i] + "]").remove()
},
removeRelatedListMouseOverActionsByPersonalityId: function(pId) {
$("#" + pId).find(".mainRLActionIcon").remove()
},
getRelatedListIdByName: function(pName) {
for (var listRelationId, pArr = crmRelatedList.personalityArr.split("||"), i = 0; i < pArr.length; i++) {
var temp = pArr[i].split("_");
if (temp[0] === pName) {
listRelationId = temp[1];
break
}
}
return listRelationId
},
saveEntity_SuccessCallback: function(resp, cBn, params, module, url, isNew) {
if (resp.indexOf("UNAUTHORIZED TO ASSOCIATE ACCOUNT:::") > -1)
return ZRComponent.openAlertMessage({
type: "failure",
msg: I18n.getMsg("crm.associate.accounts.authorisation")
}), void Utils.showHideLoadingDiv();
if (resp.indexOf("CRM_ERROR_PAGE_500::::EXCEPTION") > -1)
return ZRComponent.openAlertMessage({
type: "failure",
msg: I18n.getMsg("crm.iam.error.xssdetected")
}), void Utils.showHideLoadingDiv();
Utils.showHideLoadingDiv(), Crm.isRecordModified = !1;
var isErrorResp = resp && "object" == typeof resp ? Utils.checkErrorMsg(JSON.parse(resp), void 0, url) : Utils.checkErrorMsg(JSON.parse(resp), void 0, url);
if (isErrorResp)
cBn && $("#ajax_load_tab").is(":visible") && cBn(resp, isErrorResp);
else {
if (resp || "Events" !== module || (resp = {}), resp && "object" != typeof resp && (resp = JSON.parse(resp)), window[module].entityId = void 0, "Potentials" === module && resp && resp.isClientUser && isClientUser)
return crmTab.deleteFromCache(module), void Crm.addToHistory(void 0, void 0, {
module: resp.module,
calleeObj: "crmTab",
clickId: "tab"
});
if ("Consents" === module)
return Crm.requestParam = {}, crmui.showMsgBand("success", I18n.getMsg("crm.updated"), 2e3), DataPrivacy.refreshDataPrivacyView(), detailView.isDataPrivacyModified = !0, void (void 0 != detailView && void 0 != detailView.currentModule && (ZRCommonUtil.refreshRelatedList("emailspersonality"), ZRCommonUtil.refreshRelatedList("smspersonality"), crmTab.deleteFromCache(detailView.currentModule)));
if ((-1 != url.indexOf("EditCommonModule") || -1 != url.indexOf("CreateCommonModule") || -1 != url.indexOf("CloneCommonModule")) && void 0 !== resp.entityId) {
var mode = "1";
-1 != url.indexOf("EditCommonModule") && (mode = "2"), ManualTrigger.openManualTriggerDialog(resp.module, resp.entityId, mode)
}
if (document.getElementById("cmActivityBar_1") || document.getElementById("cmActivityBar")) {
var modId;
parModule = null != params["property(leContModSel)"] ? params["property(leContModSel)"] : params["property(modsel)"], modId = null != params["property(leContModId)"] ? params["property(leContModId)"] : params["property(modid)"], mapView.addOpenActivity(modId, parModule)
}
var isActivityModule = "Activities" === Crm.activityGrp[module];
isActivityModule && -1 != Activities.reminderList.indexOf(resp.entityId) && ($("#reminder_notification").text($("[id='notificationCount']").text()).show(), $(".remainder-notifi").slideUp(), $(".timericon").removeClass("footIconActive timericonAct"), $("#reminderContent").html(""), $("[name='reminderCount']").val(""), Activities.reminderList = "");
var refreshPage = "Events" === module && "clone" !== window[module].currentStatus ? !1 : !0;
if (isActivityModule && "edit" === window[module].currentStatus && updateLeftPanel(params["property(id)"], module), cBn && cBn(resp, isErrorResp), Crm.requestParam = {}, !isNew && isActivityModule && "edit" === window[module].currentStatus) {
if (ActivityMoreInfoContent = "", "true" === $("#iskanbanview").val() && $("#entitypopup").length)
return window[detailView.currentModule].currentStatus = void 0, void loadActivityDetails(void 0, $("#recordid_" + resp.entityId), {
module: module
}, resp.entityId, !0);
if ($("#rightPanel").length && $("#detailCView").length) {
window[detailView.currentModule].currentStatus = void 0, loadActivityDetails(void 0, void 0, void 0, resp.entityId, !0);
var editObj = crmHistory.historyArr.pop();
crmHistory.historyArr2.pop();
var dummyObj = {
orgCalleeObj: "crm",
clickId: "detailView",
calleeObj: "crmDummy"
};
return dummyObj.module = editObj.data.module, dummyObj.id = editObj.data.id, void Crm.addToHistory(void 0, void 0, dummyObj)
}
}
if (isNew)
resp.displayName && $("#rItemDataSubDiv").find("#recentItemImg_" + resp.entityId).find("div").text(resp.displayName), "Potentials" == module ? ZRJobBoardsUtil.showJBPublishPopUp(resp.entityId, resp.JobOpeningName, !0) : resp && "process" === resp.recSource ? Crm.addToHistory(void 0, void 0, {
clickId: "detailView",
module: "Leads",
id: resp.leadId,
pfrom: "cv",
calleeObj: "Crm"
}) : (params = {}, "Calls" === module && (module = "Tasks", params.entityid = resp.entityId, params.relmodule = "Calls", params.iskanbanview = "true"), params.module = module, params.clickId = "createbtn", params.calleeObj = "Crm", Crm.addToHistory(void 0, void 0, params));
else if (-1 != url.indexOf("EditCommonModule") && refreshPage)
if (void 0 != resp.isPRView && "resumeinboxPreview" == resp.isPRView)
$(".lyteModalClose").click(), ZRResumeInbox.showRIReports("success", "1"), crmui.showMsgBand("success", I18n.getMsg("crm.entity.update.success", I18n.getMsg("Lead")), 4e3);
else if (void 0 != resp.isPRView && "true" == resp.isPRView && "1" == resp.saveAndNew)
ajaxNew("/recruit/ImportFromDocument.do?module=Leads&paste=pasteparser");
else if ("listView" == Crm.editReqFrom) {
var pfrom = $("#pfrom").length ? $("#pfrom").val() : "cv";
Crm.addToHistory(void 0, void 0, {
clickId: "detailView",
module: resp.module,
id: resp.entityId,
recordNum: $("#recordNum").val(),
pfrom: pfrom,
lookback: !0,
step: "2",
calleeObj: "Crm"
})
} else if (historyObj = crmHistory.getPrevState()) {
var curStatus = History.getState(),
data = curStatus.data,
Historydata = historyObj.data;
Historydata.hasOwnProperty("isJobBoardsSelected") && delete Historydata.isJobBoardsSelected, data.hasOwnProperty("activityType") && (Historydata.activityType = data.activityType), crmHistory.popHistoryArr2(), Historydata.clickId = "detailView", Historydata.calleeObj = "Crm", Crm.addToHistory(void 0, void 0, Historydata, historyObj.url)
} else {
var data = crmHistory.getCurrentStateData();
Crm.addToHistory(void 0, void 0, {
clickId: "detailView",
module: data.module,
id: data.id,
calleeObj: "Crm"
})
}
else if (params.returnAnchor) {
{
params.returnAnchor
}
params.returnAnchor && (Crm.scrollToElem = params.returnAnchor), crmHistory.back()
} else if ("homePage" === Crm.editReqFrom)
Utils.triggerEvent("click", $("#tab_Home"));
else if (resp && "process" === resp.recSource) {
if (window.location.href.indexOf("Approval") > -1)
return;
Crm.addToHistory(void 0, void 0, {
clickId: "detailView",
module: "Leads",
id: resp.leadId,
pfrom: "cv",
calleeObj: "Crm"
})
} else
"Events" == resp.module && refreshPage || "Tasks" == resp.module || "Calls" == resp.module ? (Crm.addToHistory(void 0, void 0, {
clickId: "detailView",
module: resp.module,
id: resp.entityId,
pfrom: "cv",
calleeObj: "Crm"
}), Crm.trackSpotLightAction("New " + resp.module + " Added")) : refreshPage && (void 0 != resp.isPRView && "resumeinboxPreview" == resp.isPRView ? ($(".lyteModalClose").click(), ZRResumeInbox.showRIReports("success", "1"), crmui.showMsgBand("success", I18n.getMsg("crm.entity.add.success", I18n.getMsg("Lead")), 4e3)) : void 0 != resp.isPRView && "true" == resp.isPRView && "1" == resp.saveAndNew ? ajaxNew("/recruit/ImportFromDocument.do?module=Leads&paste=pasteparser") : Crm.addToHistory(void 0, void 0, {
clickId: "detailView",
module: resp.module,
id: resp.entityId,
calleeObj: "Crm"
}), ("Leads" == resp.module || "Contacts" == resp.module) && Crm.trackSpotLightAction("New " + resp.module + " Added"));
void 0 != customViewObject.isMapView && customViewObject.isMapView !== !0 && crmTab.deleteFromCache(module)
}
},
saveEntity_FailureCallback: function(xhr, url, module) {
$("#save" + module + "Btn,#save" + module + "Btn_Bottom,#cancel" + module + "Btn,#cancel" + module + "Btn_Bottom,#saveAndNew" + module + "Btn,#saveAndNew" + module + "Btn_Bottom").removeAttr("disabled"), xhr && "string" == typeof xhr && (xhr.indexOf("DUPLICATE") >= 0 || xhr.indexOf("CLIENT_LOGIN_ENABLED") >= 0 || xhr.indexOf("CANDIDATE_PORTAL_ENABLED") >= 0) ? Utils.checkErrorMsg(JSON.parse(xhr), void 0, url) : xhr && "" != xhr && null != xhr && -1 != xhr.indexOf("JOB_LIMIT_EXCEEDED") ? crmui.showMsgBand("warning", I18n.getMsg("zr.job.limit.primary.alert"), "infinity") : xhr && "string" == typeof xhr && xhr.indexOf("Unauthorised") >= 0 && crmui.showMsgBand("error", I18n.getMsg("crm.security.error"), "infinity"), Utils.showHideLoadingDiv()
},
getAssociateJOForImport: function(lookupElemSelector, formInputElemSelector) {
var joElem = $(lookupElemSelector);
if (joElem && joElem.length > 0) {
var joId = joElem.data("id");
if (joId) {
if (formInputElemSelector) {
var joFormInputElem = $(formInputElemSelector);
joFormInputElem && joFormInputElem.length > 0 && joFormInputElem.val(joId)
}
return joId
}
}
},
canvasBgImg: {
start: function(id) {
this.canvas = document.getElementById(id), this.ctx = this.canvas.getContext("2d"), this.starList = []
},
draw: function(self, alpha, width, height, r) {
self.ctx.beginPath(), self.ctx.globalAlpha = alpha, self.ctx.arc(width, height, r, 0, 2 * Math.PI, !1), self.ctx.fillStyle = "#ffffff", self.ctx.fill()
},
init: function(id) {
this.start(id);
for (var i = 0; i < this.canvas.width / 3; i++)
this.starList.push({
drawFunc: this.draw,
alpha: .5 * Math.random() + .5,
width: Math.random() * this.canvas.width,
height: Math.random() * this.canvas.height - 50,
r: 1 * Math.random() + .8,
speed: 2 * Math.random()
});
var self = this,
loop = function() {
self.ctx.clearRect(0, 0, self.canvas.width, self.canvas.width);
for (var i = 0; i < self.canvas.width / 3; i++)
self.starList[i].height = self.starList[i].height + self.starList[i].speed, self.starList[i].drawFunc(self, self.starList[i].alpha, self.starList[i].width, self.starList[i].height, self.starList[i].r), self.starList[i].height > self.canvas.height && (self.starList[i].height = 0);
requestAnimationFrame(loop)
};
requestAnimationFrame(loop)
}
},
loadTemplateCallout: function(selector, action) {
if ("rd1" === action) {
var test = $("#tabLayer"),
top = test.position().top + test.outerHeight();
$(selector).css({
top: top + "px"
}).show(), ".chrisnew" === selector && ZRCommonUtil.canvasBgImg.init("canvasSmall"), ZRCommonUtil.trackBanner("smallOpened")
} else
"rd2" === action ? (freezeBackground(), $("#FreezeLayer").removeClass("freezeLayer").addClass("zrc-freeze"), $(selector).show(), ".chrisnewbig" === selector && ZRCommonUtil.canvasBgImg.init("canvasBig"), ZRCommonUtil.trackBanner("bigOpened")) : "rd3" === action && (ZRCommonUtil.closeTempCallout("chrisnewbig", selector), ".chrisnewbig" === selector && (ZRCommonUtil.trackBanner("interested"), crmui.showMsgBand("success", "Thank you for upgrading! Please check your email for more details on this offer.", 2e4)))
},
highlightTransitionGuide: function() {
if ($(".sticky-notes-label").length > 0) {
var csrf_Token = ZRCommonUtil.getCookieValue("crmcsr"),
params = {};
csrf_Token && null != csrf_Token && (params[csrfParamName] = csrf_Token), ZRCommonUtil.ajaxPostMethod("/recruit/TransitionGuide.do", params, !1, "json", void 0)
}
$(".sticky-notes-label").removeClass("sticky-notes-label"), window.open("https://www.zoho.com/recruit/userguide/recruit-2017-transition.html")
},
trackBanner: function(step) {
ZRCommonUtil.ajaxGetMethod("/recruit/BannerTool.do?action=trackBanner", {
step: step
}, !0, "json", void 0, function() {}, function() {})
},
closeTempCallout: function(action, selector) {
$(selector).hide(), $("#FreezeLayer").remove(), "zrwhatsnew" === action ? ($("body").removeClass("oH"), $("#zr-whatsnew-container iframe").each(function() {
var src = $(this).attr("src");
$(this).attr("src", src)
}), $("#zr-whatsnew-container video").each(function() {
this.pause(), this.currentTime = 0
})) : (".chrisnewbig" === selector || ".chrisnew" === selector) && (document.cookie = "zrchristmas2018=done;", ZRCommonUtil.trackBanner("closed"))
},
getSearchParamsFromHistory: function(params) {
var state = History.getState();
if (document.CreateCustomViewForm) {
var postData = formData2QueryString(document.CreateCustomViewForm);
postData += formSelectColumnString(), postData = postData + "&" + Territory.csrf(), 10 === CustomView.maxFav && (postData += "&isNewLimit=true");
var resObj = Utils.splitStringToObj(postData);
$.extend(params, resObj)
} else {
var urlParams = state.data;
if ("true" == urlParams.isSearch && (params.module == urlParams.module || params.module != urlParams.module && ("Tasks" == urlParams.module || "Events" == urlParams.module || "Calls" == urlParams.module))) {
var removeListFilter = !0;
params.filters && (removeListFilter = !1);
var removeSearchLetter = !0;
params.searchletter && (removeSearchLetter = !1);
for (var key in urlParams)
params.hasOwnProperty(key) || (params[key] = decodeURIComponent(urlParams[key]));
removeListFilter && delete params.filters, removeSearchLetter && delete params.searchletter, params.previous_sort_order && delete params.previous_sort_order, params.previous_sort_column && delete params.previous_sort_column
}
}
},
bindSetupScrollActivity: function(elem) {
if ($("#setup_new_ContentDiv").scrollTop() > 500 ? ($("#scrollTopDiv").fadeIn(), $("#scrollTopDiv").find(".zc-scrollTop").addClass("active")) : ($("#scrollTopDiv").find(".zc-scrollTop").removeClass("active"), $("#scrollTopDiv").fadeOut()), Math.round($("#setup_new_ContentDiv").scrollTop()) == $("#result").height() - $("#setup_new_ContentDiv").height()) {
var data = elem.data("scrolldata");
data = data ? data : {}, data && "string" == typeof data && (data = JSON.parse(data)), data && data.shownext && "true" === data.shownext && window[data.callee] && !window[data.callee].ISLOADMORE ? (data.isAppend = "true", data.action = "more", window[data.callee].ISLOADMORE = !0, window[data.callee].loadMoreData(data, function() {
window[data.callee].ISLOADMORE = !1
})) : data && data.shownext && "true" === data.shownext && data.customfn && window[data.customfn].apply(this)
}
},
detailPageInterviewFeedbackForm: function(elem) {
var targetElem = $(elem),
changeStatusLink = $("#detail_status_link").find("a.cs-link");
if (changeStatusLink && changeStatusLink.length > 0) {
targetElem.data("module", detailView.currentModule).data("pkid", returnJson[detailView.currentModule].entityid).data("positiondata", {
modal: ".notes-block",
placement: "left"
}).data("from", "interviewFb");
var isRowExist = !1,
candidateStatus = $("#detail_status_area").text().trim(),
actualStatus = $("#jo-status").val(),
leadStatus = $("#leadStatus") ? $("#leadStatus").val() : void 0;
candidateStatus.indexOf(":") > -1 && (isRowExist = !0, candidateStatus = candidateStatus.split(":")[1]), ZRStatusUtil.recentstatusedit(targetElem, isRowExist, candidateStatus, actualStatus, leadStatus)
} else
targetElem.data("module", detailView.currentModule).data("feedback", !0).data("pkid", returnJson[detailView.currentModule].entityid).data("positiondata", {
modal: ".notes-block",
placement: "left"
}), ZRStatusUtil.recentstatusedit(targetElem, isRowExist, candidateStatus, actualStatus, leadStatus, void 0, !0)
},
showUnsupportedFieldsList: function(inSubject, inBody, inFooter, mode) {
$("#unsupporetdMergeFieldPopSub").html(I18n.getMsg("crm.template.email.unsupported.merge.field.msg.template")), freezeBackground(), $("#FreezeLayer").css("z-index", 999), mailsetCenter("unsupportedMergeFieldPop");
var resStr;
if (void 0 != inSubject && inSubject.length > 0) {
resStr = '<div class="mT10 f14 proximas btxt1">' + I18n.getMsg("crm.template.email.in.subject") + '</div><div class="mT10">';
for (var i = 0; i < inSubject.length; i++)
resStr = resStr + (i + 1) + ". " + $ESAPI.encoder().encodeForHTML(inSubject[i]) + "<br>";
resStr += "</div>", $("#unsupportedSubjectMergeField").html(resStr), getElemById("unsupportedSubjectMergeField").style.display = ""
}
if (void 0 != inBody && inBody.length > 0) {
resStr = '<div class="mT10 f14 proximas btxt1">' + I18n.getMsg("crm.template.email.in.body") + '</div><div class="mT10">';
for (var i = 0; i < inBody.length; i++)
inBody[i] = "1" == mode ? inBody[i] : $ESAPI.encoder().encodeForHTML(inBody[i]), resStr = resStr + (i + 1) + ". " + inBody[i] + "<br>";
resStr += "</div>", $("#unsupportedBodyMergeField").html(resStr), getElemById("unsupportedBodyMergeField").style.display = ""
}
if (void 0 != inFooter && inFooter.length > 0) {
resStr = '<div class="mT10 f14 proximas btxt1">' + I18n.getMsg("crm.template.email.in.footer") + '</div><div class="mT10">';
for (var i = 0; i < inFooter.length; i++)
resStr = resStr + (i + 1) + ". " + $ESAPI.encoder().encodeForHTML(inFooter[i]) + "<br>";
resStr += "</div>", $("#unsupportedFooterMergeField").html(resStr), getElemById("unsupportedFooterMergeField").style.display = ""
}
return $("#unsupportedMergeFieldPop").css("z-index", 1e3), $("[name='okTemplateBtn']").off("click"), $("[name='okTemplateBtn']").on("click", function() {
getObj("unsupportedMergeFieldPop").style.display = "none", getElemById("unsupportedBodyMergeField").style.display = "none", $("#unsupportedMergeFieldPop").css("z-index", 32), removeFreezeLayer()
}), !1
},
addAnnounceActions: function() {
return 0 === $(".ratStarTd").length ? void $("#announce,#cRtTTip").remove() : ($("#announce").bind("mouseover mouseout", function() {
var cRtTTip = $("#listviewHeaderRow").find("#cRtTTip");
$(cRtTTip).toggle()
}), $("#announce").click(function() {
var params = {},
template = ZRCommonUtil.getTemplateContent("common", "Tour");
template = template(params);
$("#listviewHeaderRow").find("#ratingAnnounce");
$("body").append(template), $("#tourBg,#ratingBrd,#pulseDot").show("fast"), $("#skipTempTour").click(function() {
$("#tourBg,#ratingBrd,#pulseDot").hide("fast", function() {
$(".customTour").remove()
})
}), $("#skipTempTour2").click(function() {
$("#tourBg,#tempChgRatBrd,#pulseDot").hide("fast", function() {
$(".customTour").remove()
})
}), $("#clickNextView").click(function() {
$("#tempChgRatBrd").show(), $("#ratingBrd").hide(), $("#tempChgRatBrd").css({
top: "225px",
left: "215px"
}), $("#pulseDot").css({
top: "220px",
left: "210px"
})
}), $("#chngRatNxt").click(function() {
$("#tempChgRatBrd").hide(), $("#tempFinshBrd").show()
}), $("#finishView").click(function() {
$("#tempFinshBrd,#tourBg,#pulseDot").hide("fast", function() {
$(".customTour").remove()
})
}), null === ZRCommonUtil.getCookieValue("_candRating") && (document.cookie = "_candRating=ratingTourClicked;")
}), void (null === ZRCommonUtil.getCookieValue("_candRating") && $("#announce").click()))
},
updateRatingDiv: function(rating, entityId, relatedRatingId, thisElem) {
(null === thisElem || void 0 === thisElem) && (thisElem = "#tdRatBlk_" + entityId);
var clE1 = $(thisElem).find("#starElem1_" + entityId),
clE2 = $(thisElem).find("#starElem2_" + entityId),
clE3 = $(thisElem).find("#ratingValueElem_" + entityId),
cl1 = "",
cl2 = "",
cl3 = "";
null == rating ? (cl1 = "lstStarBdr", cl2 = "grayStar fR", cl3 = "nR fL") : 0 == rating ? (cl1 = "lstStarBdr", cl2 = "grayStar fR", cl3 = "rat2_above fL") : rating > 0 && 2 > rating ? (cl1 = "lstStarBdr", cl2 = "grayBgStar fR", cl3 = "rat2_above fL") : rating >= 2 && 4 > rating ? (cl1 = "lstStarBdr rat3Bdr", cl2 = "grayBgStar fR", cl3 = "rat3_above fL") : rating >= 4 && 5 >= rating && (cl1 = "lstStarBdr rat4Bdr", cl2 = "selStar fR", cl3 = "rat4_above fL"), $(clE1).removeAttr("class"), $(clE2).removeAttr("class"), $(clE3).removeAttr("class"), $(clE1).addClass(cl1), $(clE2).addClass(cl2), $(clE3).addClass(cl3);
var ratingValues = $(thisElem).find("#ratingValues"),
existParams = $(ratingValues).data("params");
existParams = null == existParams || void 0 == existParams ? {} : existParams, existParams.rating = rating, existParams.ratingEntity = entityId, null !== relatedRatingId && void 0 !== relatedRatingId && "" !== relatedRatingId.trim() && (existParams.relatedId = relatedRatingId), $(ratingValues).data("params", existParams);
var actualRating = $(thisElem).find("#actualRating");
rating = null === rating || void 0 === rating || isNaN(rating) ? "--" : parseFloat(rating).toFixed(1), $(actualRating).html(rating)
},
toDisplayNoRating: function(thisElem) {
var actRatDiv = $(thisElem).find("#actualRating"),
actRat = $(actRatDiv).html();
"--" === actRat && zctt.showtt(I18n.getMsg("crm.rating.not.given"))
},
updateRating: function(thisElem) {
var entityId = $("#ratEntity").val(),
rating = $(".selBigStar").length,
url = "/recruit/AddRemoveStar.do",
desc = $("#ratingDesc").val();
params = {
pkid: entityId,
rating: rating,
module: "Leads",
description: desc
};
var relatedRatingId = $("#relatedIdFromDOM").val();
null !== relatedRatingId && void 0 !== relatedRatingId && "" !== relatedRatingId.trim() && (params.relatedId = relatedRatingId), $("#ajax_load_tab").show(), ZRCommonUtil.ajaxPostMethod(url, params, !1, "json", void 0, function(resp) {
$("#ajax_load_tab").hide(), "success" === resp.message ? (0 === rating && (rating = null), ZRCommonUtil.updateRatingDiv(rating, entityId, relatedRatingId, thisElem), $("#fullInfoNoteDiv").length && null != desc && void 0 != desc && "" !== desc.trim() && "Leads" === $("#note_module").val() && Notes.loadNotes(entityId, !1, "Leads")) : "invalidRating" === resp.message && ZRCommonUtil.createInfoBox({
titleclass: "til warning",
title: I18n.getMsg("crm.formula.alert"),
content: I18n.getMsg("crm.rating.invalidvalue"),
savebtn: I18n.getMsg("crm.button.ok")
})
}, function() {
ZRCommonUtil.createInfoBox({
titleclass: "til warning",
title: I18n.getMsg("crm.formula.alert"),
content: I18n.getMsg("error.database.problem"),
savebtn: I18n.getMsg("crm.button.ok")
})
})
},
toggleAnswerSheet: function() {
var closestTr = $(".previewEyeIc").closest("tr");
$(closestTr).each(function() {
$(this).unbind("mouseover").unbind("mouseout").bind("mouseover mouseout", function() {
var prevEye = $(this).find(".previewEyeIc");
"hidden" === $(prevEye).css("visibility") ? $(prevEye).css("visibility", "visible") : $(prevEye).css("visibility", "hidden")
})
})
},
getTermsAndConditionsContent: function(fieldId) {
var tcContent = "<br>";
if (fieldId) {
var url = "/recruit/CustomModule.do?operation=edit&action=getTCContent&fieldId=" + fieldId;
$.ajax({
type: "GET",
url: url,
async: !1,
success: function(res) {
var responseObj = JSON.parse(res);
tcContent = responseObj.tcContent
}
})
}
return tcContent
},
switchOlderVersion: function() {
var data = {},
switchUrl = "/recruit/SwitchToOlderVersion.do";
data[csrfParamName] = encodeURIComponent(csrfToken), ZRCommonUtil.ajaxPostMethod(switchUrl, data, !1, void 0, void 0, function() {}, function() {})
},
filterWithField: function(ev, targetElem) {
if ($("#lv_left_filter").is(":visible")) {
var filterSearchElem = $("#lv_filter_srchdiv").length ? $("#lv_filter_srchdiv").css("display") : "none";
"block" == filterSearchElem && ($("#lv_filter_search_clear").hide(), $("#lv_filter_srchdiv").hide(), $("#lv_filter_search").show(), $("#lv_filter_scroll .filterContainBox").show(), $("#lv_filter_caption").show(), $("#lv_filter_srchIcon").show(), $("#lv_filter_srch_input").val("").focus().trigger("keyup")), ZRCommonUtil.showFilterField(ev, targetElem)
} else
crmListView.showHideFilters(ev, $("#showhidefilters")), setTimeout(function() {
ZRCommonUtil.showFilterField(ev, targetElem)
}, 500)
},
showFilterField: function(ev, targetElem) {
var dataParam = $(targetElem).data("params"),
filterContainerElem = $("#lv_filter_scroll"),
fieldVal = dataParam.fieldValue;
if (void 0 != fieldVal && "" != fieldVal) {
var dataElem = $(document).find("[data-value='" + fieldVal + "']");
if (dataElem.length > 0)
if ($(dataElem).is(":checked")) {
var dataElemParams = $(dataElem).data("params");
if (void 0 != dataElemParams) {
var type = dataElemParams.searchfieldtype,
filterElem = $(dataElem).parents().closest("div.facetContainer");
if ("MPL" === type || "picklist" === type)
$(filterElem).find("input.select2-search__field").focus().click();
else if ("ACT" != type) {
var filterValElem = $(filterElem).find("input.filterValue");
$(filterValElem).length > 0 && $(filterValElem).focus().click()
}
}
} else
$(dataElem).click();
$(filterContainerElem).animate({
scrollTop: $(dataElem).offset().top - $(filterContainerElem).offset().top + $(filterContainerElem).scrollTop()
}, 500)
}
},
openURLInNewTab: function(url) {
var windOpener = window.open(url);
windOpener.opener = null
},
manageZohoForms: function(formUrl) {
var data = {};
data.redirectUrl = formUrl;
var elem = document.createElement("zoho-forms-integ");
elem.id = "zoho-forms-integ", elem.setData("zohoforms", data), $("#result").empty().html(elem).show()
},
removeAnswersFilter: function(respJson) {
var closestFacetDiv = $("#answerFilterDiv").closest(".oneFacet");
if (respJson && "Leads" === respJson.module && void 0 === respJson.assocAsmntId) {
$(closestFacetDiv).hide();
var checkEq;
customViewObject.cvFilters[0].type.length && (checkEq = customViewObject.cvFilters[0].type), checkEq && "ASSJO" == checkEq ? $($(".oneFacet.filterContainBox")[1]).addClass("filter-sep") : $($(".oneFacet.filterContainBox")[0]).addClass("filter-sep")
}
},
showHideAdvOptionImport: function(id) {
$("#importsecondaryItem").hide();
var importFileObj_Temp = document.getElementById(id);
void 0 != importFileObj_Temp && (importFileObj_Temp.onchange = function(event) {
var input = this.files[0];
input && ($("#importsecondaryItem").show(), Utils.bindChosen($("#findBy")), Utils.bindChosen(".newSelect select"), changingDesktop(void 0, $(event.target)))
})
},
showChildAccounts: function() {
if ("undefined" == typeof ZRSME.queriedObj.datamirroring)
return alert("Please search, to tranfer Candidates"), void $("#checkAll").click();
var copyFn = function() {
var field = $("#zr-copy-no-of-candidates"),
number = field.val();
if (!/[0-9]+/.test(number)) {
var fld = field.parent().parent();
return fld.find(".ms-errorMsg").remove(), fld.append('<span class="ms-errorMsg" style="top:30px;">' + I18n.getMsg("Please enter valid number") + "</span>"), field.focus(), !1
}
field.parent().parent().find(".ms-errorMsg").remove();
var email = $("#zr-copy-to-account").val(),
refineFilters = ZRSME.queriedObj.datamirroring;
"undefined" == typeof refineFilters && (refineFilters = {});
var sourcefield = $("#zr-copy-source"),
source = sourcefield.val();
if (!source || "" === source.trim()) {
var fld = sourcefield.parent().parent();
return fld.find(".ms-errorMsg").remove(), fld.append('<span class="ms-errorMsg" style="top:30px;">' + I18n.getMsg("Please give a source value") + "</span>"), sourcefield.focus(), !1
}
refineFilters.email = email, refineFilters.count = number, refineFilters.source = source, ZRSME.showMatchedRecords("Potentials", void 0, refineFilters, !0), $("#zr-partner-copy-candidates").remove(), ZRComponent.openAlertMessage({
boldMsg: "Copy of selected Resumes has been scheduled!",
msg: "",
type: "info",
display: "top",
scroll: !1,
duration: 1e4
})
},
elem = Utils.createHTML({
name: "div",
attr: {
style: "left: 38%; margin-left: -340px; display: block;",
id: "zr-partner-copy-candidates",
"class": "newPopup top0 wid950"
},
child: [{
name: "div",
attr: {
"class": "popupHeaderClass popup-model-header"
},
child: [{
name: "span",
text: "Choose Child account to transter candidates",
attr: {
"class": "newPopupTitle pL0 pT0"
}
}]
}, {
name: "div",
attr: {
"class": "popupBodyClass p30"
},
child: [{
name: "div",
attr: {
id: "main1",
"class": "sems-main-block hei200"
},
child: [{
name: "div",
attr: {
"class": "sems-sb-block newmandatory"
},
child: [{
name: "label",
text: "No. of Candidates",
attr: {
"class": "sbl"
}
}, {
name: "div",
attr: {
"class": "sems-sb-val"
},
child: [{
name: "input",
attr: {
placeholder: "1-5000",
type: "text",
id: "zr-copy-no-of-candidates",
name: "zr-copy-no-of-candidates"
}
}]
}]
}, {
name: "div",
attr: {
"class": "sems-sb-block newmandatory"
},
child: [{
name: "label",
text: "Source",
attr: {
"class": "sbl"
}
}, {
name: "div",
attr: {
"class": "sems-sb-val"
},
child: [{
name: "input",
attr: {
placeholder: "source value",
type: "text",
id: "zr-copy-source",
name: "zr-copy-source"
}
}]
}]
}, {
name: "div",
attr: {
"class": "sems-sb-block newmandatory"
},
child: [{
name: "label",
html: "Child Account",
attr: {
"class": "sbl"
}
}, {
name: "div",
attr: {
"class": "sems-sb-val top5"
},
child: [{
name: "div",
attr: {
"class": "fL"
},
child: [{
name: "input",
attr: {
type: "text",
id: "zr-copy-to-account",
name: "zr-copy-to-account",
"class": "disabld",
value: ZRSME.queriedObj.datamirroring.childaccount
}
}]
}]
}]
}, {
name: "div",
attr: {
"class": "sems-btns-block"
},
child: [{
name: "input",
attr: {
id: "zr-partner-copy-candidates-cancel",
type: "button",
"class": "zrc-btn-secondary marR5",
value: "Cancel"
},
events: [{
name: "click",
fn: function(ev) {
$(ev.target).parents("#zr-partner-copy-candidates").remove()
}
}]
}, {
name: "input",
attr: {
id: "zr-partner-copy-candidates-copy",
type: "button",
"class": "zrc-btn-primary",
value: "Copy"
},
events: [{
name: "click",
fn: copyFn
}]
}]
}]
}]
}]
});
$("#zr-partner-copy-candidates").remove(), $("body").append(elem)
},
getDisplayModuleName: function(module, singular) {
if (module) {
var modInfo = "object" == typeof Crm.userDetails.MODULE_LIST ? Crm.userDetails.MODULE_LIST : $.parseJSON(Crm.userDetails.MODULE_LIST);
return I18n.getMsg(singular ? modInfo[module][0] : modInfo[module][1])
}
},
moveElementInsideArray: function(arr, fromIndex, toIndex) {
var element = arr[fromIndex];
arr.splice(fromIndex, 1), arr.splice(toIndex, 0, element)
},
loadSelectBoxValues: function(selectObj) {
var params = {
box: !0,
searchlimit: 5,
maxlen: 35,
callback: function(type) {
"focus" === type && $(selectObj).selectBox("position"), "create" == type && ($(selectObj + "-sbox").show(), $(selectObj + "-sbox").addClass("marL30 minW200 marB20"))
}
};
$(selectObj).selectBox(params)
},
removeUnWantedErrMsg: function() {
var selectedVal = $("#webform-select").val();
0 != selectedVal && ($("#jb-alert-caselect").remove(), walkThroughs.tourVariables.isTour && walkThroughs.setPosition())
},
getSetupPasteContent: {
"/recruit/OfferTemplates.do": {
foldername: "OfferManagement",
filename: "ShowOfferTemplates",
callback: function(requestData) {
$("#defaultOfferView").find(".moreIcon").moreOption(), $("#offerFieldSelection,#contractFieldSelection").selectBox({
box: !1
}), $("#fieldconfiguration .zrc-value").show(), "getAndCreateTemplate" === requestData.params.action && setTimeout(function() {
$("#create-template").click()
}, 800)
}
}
},
getSetupPasteContentCallBack: function(requestData, elements, response) {
var template = ZRCommonUtil.getTemplateContent(elements.foldername, elements.filename);
response = ZRCommonUtil.convertStringToJson(response), response = template(response), $("#result").empty(), $("#result")[0].innerHTML = response, $("#settingInner").hide(), $("#setupshow").show(), elements.callback && elements.callback(requestData, response)
},
bindEscapeFunction: function(divId, escapefn) {
escapefn && "function" == typeof escapefn && $("#" + divId).bind("keyup", function(e) {
e.keyCode == crmConstants.keyCodes.escape && escapefn.apply(window, [e, e.target])
})
},
validateReviewParams: function(data) {
var mandQuestionDiv,
qeComLenViol = !1;
if ($("#submit-recruiter-assessment").find(".sc-qst-block").each(function(ind, obj) {
var parent = $(obj).closest(".sc-qst-block"),
cmtTxt = $(parent).find(".sc-qst-comments").val();
if ($(obj).find(".red").length > 0) {
if (data && data.candReview === !1)
var intQuestionNoViol = $(obj).find(".sc-tup").length > 0 && $(obj).find(".suc").length > 0 || $(obj).find(".sc-tdo").length > 0 && $(obj).find(".fai").length > 0;
else
var score = ZRCommonUtil.getRatingVal($(obj).find(".starElem"));
(!cmtTxt || "" === cmtTxt.trim() || 0 === cmtTxt.length || void 0 !== score && 0 === score || !intQuestionNoViol) && (mandQuestionDiv = parent)
}
cmtTxt && cmtTxt.length > 15e3 && (qeComLenViol = !0)
}), qeComLenViol)
return crmui.showMsgBand("warning", I18n.getMsg("zr.ratings.reviews.msg50", I18n.getMsg("Comments"), "15000"), 3e3), !1;
if (mandQuestionDiv)
return $(mandQuestionDiv).find(".sc-comm").click(), crmui.showMsgBand("error", I18n.getMsg($("#ratingFinalSection").length > 0 ? "crm.inter.asmnt.mand.question" : "zr.ratings.reviews.msg9"), 3e3), !1;
if ($("#ratingAndReviewSection").length || $("#overallReviewRating").length) {
var objStr = $("#overallReviewRating").length ? "#overallReviewRating" : "#ratingAndReviewSection",
score = ZRCommonUtil.getRatingVal($(objStr).find(".starElem"));
if (void 0 !== score && 0 === score)
return crmui.showMsgBand("error", I18n.getMsg("zr.ratings.reviews.msg10"), 3e3), !1
} else if ($("#ratingFinalSection").length) {
var actStatus = document.querySelector("submit-recruiter-assessment").getData("actualStatus");
if (void 0 === actStatus)
return crmui.showMsgBand("error", I18n.getMsg("crm.inter.asmnt.overall.decision"), 3e3), !1
}
var ratingReviewContent = $("#qeRatingReviewContent").length ? $("#qeRatingReviewContent").val() : $("#ratingReviewContent").val();
return void 0 !== ratingReviewContent && ratingReviewContent.length > 6e3 ? (crmui.showMsgBand("error", I18n.getMsg("zr.ratings.reviews.msg50", [I18n.getMsg("zr.ratings.reviews.msg41"), "6000"]), 3e3), !1) : !0
},
isPeoplePlus: function() {
return !ZRCommonUtil.isStaffingType && Crm.userDetails.LICENSE_TYPE === crmConstants.LICENSE_EDITION_PEOPLEPLUS
},
UpdateUserStatus: function(status, primaryUser) {
var isChecked = !1,
paid = Crm.userDetails.ISPAID_USER,
loginUser = Crm.userDetails.USER_ID,
userRowObj = getObj("row_u_" + loginUser);
if ($("#userlistview input:checked").length > 0)
for (var checkedBox = $("#userlistview input:checked"), chkLength = checkedBox.length, k = 0; chkLength > k; k++) {
var userRowObj = $(checkedBox[k]),
splitval = userRowObj.attr("id").split("_"),
data = userRowObj.data().params,
isClosed = data.isClosed,
isConfirmed = data.isConfirmed,
isActive = data.isActive,
splitUserId = splitval[1];
if (loginUser != splitUserId && "true" != isClosed && primaryUser != splitUserId) {
var idVal = splitUserId;
" " != splitUserId && "undefined" != splitUserId && "" != idVal && (userIDS[k] = idVal), isChecked = !0
}
}
if (1 == isChecked) {
if ("activate" == status)
document.viewAllUsersForm.actionName.value = "ActivateUserStatus";
else if ("deactivate" == status)
document.viewAllUsersForm.actionName.value = "DeactivateUserStatus";
else if ("delete" == status)
document.viewAllUsersForm.actionName.value = "DeleteUser";
else {
if (1 == isConfirmed && "DISABLED" == isActive)
return alert(I18n.getMsg("crm.user.confirmed.selected")), selectAllUsersCheckbox(!1), getObj("destPage").value = "", !1;
document.viewAllUsersForm.actionName.value = "resendInvite"
}
document.viewAllUsersForm.method = "post"
}
if ("deactivate" == status && isChecked)
if ($("#activateAlertDiv").hide(), $("#activatebtn").hide(), "true" == paid) {
if ($("#AttentionBelow").show(), (new IntegrationService).doValidate(), void 0 != IntegrationService.isServiceAlerted && "S" == IntegrationService.isServiceAlerted)
return freezeBackground(), mailsetCenter("updateStatusAlertDiv"), document.getElementById("updateStatusAlertDiv").style.zIndex = "33", document.getElementById("updateStatusAlertDiv").style.display = "block", !1
} else if ($("#AttentionBelow").hide(), (new IntegrationService).doValidate(), void 0 != IntegrationService.isServiceAlerted && "S" == IntegrationService.isServiceAlerted)
return freezeBackground(), mailsetCenter("updateStatusAlertDiv"), document.getElementById("updateStatusAlertDiv").style.zIndex = "30", document.getElementById("updateStatusAlertDiv").style.display = "block", !1;
if (isChecked) {
if ("activate" == status || "deactivate" == status)
return showUpdateStatusAlertMsg(status), !1;
if ("delete" == status)
return showDeleteUserAlertMsg(), !1;
for (var i = 0, l = userIDS.length; l > i; i++)
userids = userIDS[i];
var params = formData2QueryString(document.viewAllUsersForm),
url = Utils.constructUrl("/recruit/Security.do");
if ("reinvite" === status) {
var urljson = Utils.parseURLParamString(params);
for (var key in urljson)
key.startsWith("bonusUser_") && delete urljson[key];
params = $.param(urljson)
}
return mR(url, function(resp) {
showFreezeMessage(resp)
}, params), !1
}
return alert(I18n.getMsg("crm.user.noselect")), selectAllUsersCheckbox(!1), !1
},
loadEntityRating: function() {
$(".lstStarBdr").unbind("click").click(function(event) {
event.stopPropagation();
var ratVal = $(this).find("#ratingValues");
if (0 !== $(ratVal).length) {
var ratObj = $(ratVal).data("params"),
permission = ratObj.permission;
if (!permission)
return Utils.displayPermissionDenied(), void Utils.stopEvent(event);
if (!$(this).hasClass("dispRecordsRating") && !$(this).closest(".lstStarBdr").hasClass("dispRecordsRating")) {
var ratNum = ratObj.rating,
ratEntity = ratObj.ratingEntity;
ratNum = null === ratNum || void 0 === ratNum || isNaN(ratNum) ? 0 : parseFloat(ratNum).toFixed(1);
var relatedId = ratObj.hasOwnProperty("relatedId") ? ratObj.relatedId : "",
relatedName = ratObj.hasOwnProperty("relatedName") ? ratObj.relatedName : null,
joName = $("#jo-name").val();
if (void 0 === joName || null === joName || "" === joName.trim()) {
var trElem = $(event.target).parents("tr").eq(0);
joNameDiv = $(trElem).find(".joNameListView"), null !== relatedName && "" !== relatedName ? joName = relatedName : joNameDiv.length && (joName = $(joNameDiv).val())
}
var data = {
leadId: ratEntity,
ratingVal: ratNum
};
relatedId && "" !== relatedId && (data.potenId = relatedId, data.potenName = joName), ZRCommonUtil.getRecentReview(data)
}
}
})
},
getRecentReview: function(data1) {
Utils.showHideLoadingDiv(!0);
var params = {
entityId: data1.leadId
};
if (data1.potenId)
params.relEntityId = data1.potenId;
else {
var data = History.getState() ? History.getState().data : void 0;
params.relEntityId = data ? data.assoJOId : void 0
}
ZRCommonUtil.ajaxGetMethod("/recruit/getRecentReview.do", params, !0, "json", void 0, function(data) {
if (Utils.showHideLoadingDiv(!1), data && data.picklistmap && (data1.picklistmap = data.picklistmap), data && data.reviewedTime) {
if (data.rating) {
var ratNum = data.rating;
data.rating = null === ratNum || void 0 === ratNum || isNaN(ratNum) ? 0 : parseFloat(parseFloat(ratNum).toFixed(1))
}
if (data.relatedId && data.relatedName && (data1.potenId = data.relatedId, data1.potenName = data.relatedName), data.questionnaireId && data.questionnaireName && (data1.qeId = data.questionnaireId, data1.qeName = data.questionnaireName), data.submissionId && (data1.subId = data.submissionId), data.questionnaireId)
ZRQuestionnaire.showEntity({
entityId: data1.leadId,
subId: data.submissionId
}, data1);
else {
var reviewHtml = document.createElement("show-cand-review");
if (data && data.modelArr) {
var recArr = [];
data.modelArr.each(function(modelObj) {
modelObj.id === data.submissionId && recArr.push(modelObj)
}), delete data.modelArr;
var revRe = store.pushPayload("Submissions", recArr);
revRe && revRe.length > 0 && (revRe = revRe[0]);
var uservalVsSysval = {};
data.picklistmap && data.picklistmap.each(function(listValObj) {
uservalVsSysval[listValObj.uservalue] = listValObj.systemvalue
});
var metaObj = {};
revRe && revRe.reviewtype && uservalVsSysval[revRe.reviewtype] && (metaObj.reviewactualtype = uservalVsSysval[revRe.reviewtype]), Lyte.objectUtils(revRe.$, "add", "meta", metaObj);
var isCurrentUser = revRe.user ? data.currentUser === revRe.user.id : !1;
reviewHtml.setData({
record: revRe,
passedData: data1,
isCurrentUser: isCurrentUser
})
}
var title = I18n.getMsg("zr.ratings.reviews.msg37", $ESAPI.encoder().encodeForHTML(data.entityName)),
fn = function(ev, target, openData) {
$("#show-cand-review").remove(), ZRCommonUtil.openSubmitReview(openData)
};
ZRCommonUtil.createModal({
needCrossBtn: !0,
crossBtnClass: "close-modal zrc-icon-closeb top20 tranSP8",
modalid: "show-cand-review",
modalclass: "wid700 newPopup",
title: title,
content: reviewHtml,
callback: function() {
$("#show-cand-review-btn").remove();
var addBtn = Utils.createHTML({
name: "input",
events: [{
name: "click",
fn: fn,
args: [data1]
}],
attr: {
zrqa: "btn_rev_newReview",
"class": "zrc-btn-primaryadd zrc-o posA top12 rig60",
value: I18n.getMsg("zr.ratings.reviews.msg34"),
type: "button"
}
});
$("#show-cand-review").find(".popup-model-header").append(addBtn)
}
})
}
} else
ZRCommonUtil.openSubmitReview(data1)
}, function(xhr) {
ZRQuestionnaire.showErrorMessage(xhr), Utils.showHideLoadingDiv(!1)
})
},
openNewSubmitReview: function(data) {
if (!reviewPermission)
return crmui.showMsgBand("error", I18n.getMsg("crm.permission.manage.rating.no.permission"), 3e3), !1;
var submitReviewElem = document.createElement("submit-new-review");
data.assessmentsAvail = isAssessAvail, data.isEdit && (data.subId || data.editSubmissionId) ? (data.subId = data.subId || data.editSubmissionId, data.sbmsn = store.peekRecord("Submissions", data.subId)) : (!data.candQuesReview && !data.relatedId && data.potenId && data.potenName && (data.relatedId = data.potenId, data.relEntityName = data.potenName), data.sbmsn = ZRQuestionnaire.createSubmissionRecord({
entityId: data.leadId + "",
entityType: "Leads",
relEntityId: data.relatedId ? data.relatedId : void 0,
relEntityName: data.relEntityName ? data.relEntityName : void 0,
qeId: data.questionnaireId ? data.questionnaireId : void 0
})), data.ratingType = data.sbmsn && data.sbmsn.assessmententity && data.sbmsn.assessmententity.id ? "Advanced" : "Basic", submitReviewElem.setData(data);
var title = I18n.getMsg(data.isEdit ? "zr.ratings.reviews.msg3" : "zr.ratings.reviews.msg32");
ZRCommonUtil.createModal({
modalid: "submit-new-review",
modalclass: "wid700 newPopup",
title: title,
saveclass: "submitReviewBtn primarybtn",
content: submitReviewElem,
callback: function() {
var tempFn = function(ev, target, argData) {
isNaN(argData) && (argData = "https://www.zoho.com/recruit/userguide/assessments.html"), openHelp(argData + "#Assess%20Candidates")
},
addBtn1 = Utils.createHTML({
name: "a",
events: [{
name: "click",
fn: tempFn,
args: [Handlebars.helpers.getHelpUrl("help.questionnaire.ratings.reviews")]
}],
attr: {
href: "javascript:void(0);",
"class": "toplink f13 floR topM7",
id: "context-helplink"
},
html: I18n.getMsg("Help")
});
$("#submit-new-review").find(".popup-model-header").prepend(addBtn1), ZRCommonUtil.bindStarElemFunctions()
},
savefn: function(ev, target) {
var revComp = document.querySelector("submit-new-review"),
revCompData = revComp.getData();
if ("Advanced" === revCompData.ratingType) {
if (!$("#selectedReviewassessment-hidden").val() || !$("#selectedReviewassessment").val())
return void crmui.showMsgBand("error", I18n.getMsg("zr.ratings.reviews.msg24"), 3e3);
revCompData.sbmsn.$.isNew && store.unloadRecord("Submissions", revCompData.sbmsn.id), revComp.setData({}), ZRQuestionnaire.getRecIntQuestionnaireDetail(data, !0)
} else {
var jobId = $("#selectedReviewJob-hidden").val();
jobId && revCompData.sbmsn.$.set("relatedentity", {
id: jobId + ""
}), data.candQuesReview && (revCompData.sbmsn.$.set("relatedentity", {
id: data.potenId + ""
}), revCompData.sbmsn.$.set("assessmententity", {
id: data.qeId + ""
})), ZRQuestionnaire.saveNewReview(ev, target, data)
}
}
})
},
openSubmitReview: function(data) {
return ZRCommonUtil.openNewSubmitReview(data)
},
saveReview: function(ev, target, data) {
if (ZRCommonUtil.validateReviewParams(data)) {
var url = "/recruit/submitReview.do";
if (data.candReview === !1) {
url = "/recruit/UpdateResumeStatus.do";
var params = {
module: "Products",
entityId: data.interviewId,
comments: $("#qeRatingReviewContent").val()
},
existData = document.querySelector("submit-recruiter-assessment").getData();
actualStatusVal = existData.actualStatus, params.actualStatusVal = actualStatusVal;
var candStatus = existData.candActualStatus;
candStatus && $("#updateCandidateAlso").is(":checked") && (params.leadActualStatus = candStatus, params.candidateAlso = !0, ZRCommonUtil.isEmpty(params.leadActualStatus) || "Unqualified" === params.leadActualStatus && "Un-Qualified" === params.leadActualStatus && "Hired" === params.leadActualStatus || (params.isunlock = !0), params.ischecked = $("#unqualify-checkbox-boolean").is(":checked"))
} else {
data.candReview = !0;
var leadId = data.leadId,
params = {
leadId: leadId
};
if (data.subId && data.isEdit)
params = {
submissionId: data.subId
};
else {
var jobPkId = $("#selectedReviewJob-hidden").val(),
jobName = $("#selectedReviewJob").val();
jobPkId && "" !== jobPkId.trim() && jobName && jobName.length > 0 && (params.relatedId = jobPkId);
var qeId = $("#selectedReviewassessment").val();
qeId && qeId.length > 0 && (qeId = $("#selectedReviewassessment-hidden").val(), params.questionnaireId = qeId)
}
var recAsmntPresent = $("#overallReviewRating").length,
selectStr = $(".starElem");
recAsmntPresent && (selectStr = $("#overallReviewRating").find(".starElem"));
var globalRating;
params.rating = globalRating = ZRCommonUtil.getRatingVal(selectStr), params.description = recAsmntPresent ? $("#qeRatingReviewContent").val() : $("#ratingReviewContent").val();
var subTypeVal = $("#revSbmsnType").val(),
sysVal = $("#revSbmsnType :selected").data("sys-value"),
compData = document.querySelector("submit-review");
compData && compData.getData() && compData.getData().candQuesReview && (params.questionnaireId = compData.getData().qeId, params.relatedId = compData.getData().potenId), subTypeVal && "" !== subTypeVal.trim() && "-None-" !== sysVal && (params.subTypeVal = $("#revSbmsnType :selected").data("id-value"))
}
var qAndAns = [];
$("#submit-recruiter-assessment").find(".sc-qst-block").each(function(ind, obj) {
var score,
questionId = $(obj).data("qid"),
answer = $(obj).find(".sc-qst-comments").val();
if ($(".intQeAssessResult").length > 0) {
var intQeResult = $(obj).find(".intQeAssessResult");
score = $(intQeResult).find(".suc").length > 0 ? 5 : $(intQeResult).find(".fai").length > 0 ? 1 : 0
} else
score = ZRCommonUtil.getRatingVal($(obj).find(".starElem"));
qAndAns.push({
questionId: questionId + "",
answer: answer,
score: score
})
}), qAndAns.length && (params.answers = JSON.stringify(qAndAns));
var compData = document.querySelector("submit-review");
compData && compData.getData() && compData.getData().candQuesReview && (params.questionnaireId = compData.getData().qeId, params.relatedId = compData.getData().potenId);
var revTypeData;
if (compData && compData.getData() && compData.getData().currentReviewTypeObj && (revTypeData = compData.getData().currentReviewTypeObj), revTypeData) {
var subTypeVal = revTypeData.value,
sysVal = revTypeData.sysValue;
subTypeVal && "" !== subTypeVal.trim() && "-None-" !== sysVal && (params.subTypeVal = revTypeData.idValue)
}
ZRCommonUtil.ajaxPostMethod(url, params, !0, "json", void 0, function(resp) {
if (!resp || "success" !== resp.result && "success" !== resp.message) {
if (resp && resp.responseText) {
var message = "";
resp.responseText.indexOf("entRelEntNotAssociated") > -1 ? message = "zr.ratings.reviews.msg17" : resp.responseText.indexOf("CandidateQuestionnaireNotSubmitted") > -1 && (message = "zr.ratings.reviews.msg18"), crmui.showMsgBand("success", I18n.getMsg(message), 3e3)
}
} else if ("success" === resp.message)
crmui.showMsgBand("success", I18n.getMsg("crm.inter.asmnt.overall.rev.suc"), 3e3), Crm.addToHistory(void 0, void 0, {
module: "Products",
clickId: "detailView",
id: data.interviewId + "",
calleeObj: "Crm"
});
else if (resp.proceedStatusChange && $("#change-status-select").length) {
var statusChangeParams = {
module: "Leads",
entityId: params.leadId,
comments: params.description,
isunlock: !1
};
params.relatedId && (statusChangeParams.potenId = params.relatedId), statusChangeParams.status = $("#change-status-select :selected").html(), statusChangeParams.actualStatusVal = $("#change-status-select :selected").val(), statusChangeParams.ischecked = $("#unqualify-checkbox-boolean").prop("checked"), statusChangeParams.fromSubmitReview = !0, ZRCommonUtil.ajaxPostMethod("/recruit/UpdateResumeStatus.do", statusChangeParams, !0, "json", void 0, function(resp) {
resp && resp.recentJobId ? crmui.showMsgBand("success", I18n.getMsg("zr.ratings.reviews.msg12"), 5e3) : crmui.showMsgBand("success", I18n.getMsg("zr.ratings.reviews.msg13"), 3e3)
}, function() {
crmui.showMsgBand("error", I18n.getMsg("zr.ratings.reviews.msg14"), 5e3)
})
} else
crmui.showMsgBand("success", I18n.getMsg("zr.ratings.reviews.msg13"), 3e3);
ZRCommonUtil.closeDialog(ev, target, "#submit-review"), ZRCommonUtil.closeDialog(ev, target, "#submit-recruiter-assessment"), data.candReview ? ($("#ratingsreviewsrl").length && ZRCommonUtil.refreshRelatedList("ratingsreviewspersonality"), $("#CANDIDATE_RATING").length ? RefreshDetailsAction("Leads", !0) : (0 === globalRating && (globalRating = void 0), ZRCommonUtil.updateRatingDiv(globalRating, leadId))) : ZRInterviewUtil.closeKit(), setTimeout(function() {
$($(".intview-table")[0]).effect("highlight", {}, 3e3)
}, 300)
}, function(xhr) {
ZRQuestionnaire.showErrorMessage(xhr)
})
}
},
bindStarElemFunctions: function() {
var ratingHoverApply = function(data, rating, questionId) {
var comp = document.querySelector("submit-assessment"),
compData = comp.getData();
questionId += "";
var subRec = compData && compData.submissionAnswersDet ? compData.submissionAnswersDet[questionId] : void 0;
subRec && (0 === rating ? subRec.$.set("score", void 0) : subRec.$.set("score", rating + ""), Lyte.objectUtils(compData.submissionAnswersDet, "add", questionId, subRec))
};
$(".starElem").unbind("mouseover").bind("mouseover", function(ev) {
ev.stopPropagation();
var data,
ratVal = $(this).data("value");
data = $("submit-assessment").length > 0 ? document.querySelector("submit-assessment").getData() : document.querySelector("submit-new-review").getData();
var questionObj = $(this).closest(".rating-clear-div1");
questionObj.length > 0 ? ratingHoverApply(data, ratVal, $(questionObj).data("qid")) : Lyte.objectUtils(data, "add", "hoveredRating", ratVal)
}), $(".rating-clear-div,.rating-clear-div1").unbind("mouseout").bind("mouseout", function(ev) {
ev.stopPropagation();
var data;
if (data = $("submit-assessment").length > 0 ? document.querySelector("submit-assessment").getData() : document.querySelector("submit-new-review").getData(), $(this).hasClass("rating-clear-div1")) {
var questionId = $(this).data("qid");
ratingHoverApply(data, ZRQuestionnaire.GLOBAL_CURR_RATING[questionId], questionId)
} else
Lyte.objectUtils(data, "add", "hoveredRating", ZRQuestionnaire.GLOBAL_CURR_RATING.totalRating)
}), $(".rating-clear-div,.rating-clear-div1").unbind("mouseover").bind("mouseover", function(ev) {
ev.stopPropagation();
var pVal = 0;
if ($(this).find(".starElem").each(function() {
$(this).hasClass("starNormal") || pVal++
}), $(this).hasClass("rating-clear-div1")) {
var questionId = $(this).data("qid");
ZRQuestionnaire.GLOBAL_CURR_RATING[questionId] = pVal
} else
ZRQuestionnaire.GLOBAL_CURR_RATING.totalRating = pVal
}), $(".starElem").unbind("click").bind("click", function() {
var parent = $(this).closest(".starsParent"),
rating = $(this).data("value"),
starCol = "",
remark = "";
if (!$(this).data("notFromUI") && 0 === $(this).closest(".rating-clear-div").length) {
var nextElem = this;
$(parent).find(".starElem").each(function(count, obj) {
$(obj).data("value") === rating + 1 && (nextElem = obj)
});
var existRat,
questionObj = $(this).closest(".rating-clear-div1");
if (questionObj && questionObj.length > 0) {
var questionId = $(questionObj).data("qid");
existRat = ZRQuestionnaire.GLOBAL_CURR_RATING[questionId]
}
$(this).hasClass("starNormal") || nextElem !== this && !$(nextElem).hasClass("starNormal") || existRat !== rating || rating--
}
switch (rating) {
case 1:
starCol = "starRed", remark = "zr.ratings.reviews.ratingtype1";
break;
case 2:
starCol = "starRed", remark = "zr.ratings.reviews.ratingtype2";
break;
case 3:
starCol = "starYellow", remark = "zr.ratings.reviews.ratingtype3";
break;
case 4:
starCol = "starGreen", remark = "zr.ratings.reviews.ratingtype4";
break;
case 5:
starCol = "starGreen", remark = "zr.ratings.reviews.ratingtype5"
}
if ($(this).closest(".rating-clear-div").length > 0) {
var data;
data = $("submit-assessment").length > 0 ? document.querySelector("submit-assessment").getData() : document.querySelector("submit-new-review").getData(), Lyte.objectUtils(data, "add", "hoveredRating", rating), data && data.sbmsn && (data.sbmsn.rating ? parseInt(data.sbmsn.rating) != rating && data.sbmsn.$.set("rating", rating + "") : 0 != rating && data.sbmsn.$.set("rating", rating + "")), ZRQuestionnaire.GLOBAL_CURR_RATING.totalRating = rating
} else {
if (questionId) {
var compData = document.querySelector("submit-assessment");
if (compData && compData.getData("submissionAnswersDet")) {
var ansRec = compData.getData("submissionAnswersDet")[questionId];
ansRec && (ansRec.score ? parseInt(ansRec.score) != rating && ansRec.$.set("score", rating + "") : 0 != rating && ansRec.$.set("score", rating + ""))
}
}
$(parent).find(".starElem").each(function(count, obj) {
$(obj).removeClass(), $(obj).addClass(count > rating - 1 ? "starNormal" : starCol), $(obj).addClass("starElem")
});
var questionObj = $(this).closest(".rating-clear-div1");
if (questionObj && questionObj.length > 0) {
var questionId = $(questionObj).data("qid");
ZRQuestionnaire.GLOBAL_CURR_RATING[questionId] = rating
}
}
})
},
getRatingVal: function(selectionDiv) {
var rating = 0;
return $(selectionDiv).each(function(count, obj) {
$(obj).hasClass("starNormal") || rating++
}), rating
},
showHideRA: function(flag) {
flag ? ($("#ratingAndReviewSection").hide(), $(".submitReviewBtn").val(I18n.getMsg("crm.label.proceed")), $(".submitReviewBtn").data("value", "Proceed")) : ($("#ratingAndReviewSection").show(), $(".submitReviewBtn").val(I18n.getMsg("crm.button.save")), $(".submitReviewBtn").data("value", "Save"))
},
getColorAndImpression: function(rating) {
var starColor,
remark;
switch (rating) {
case 1:
starColor = "Red", remark = "zr.ratings.reviews.ratingtype1";
break;
case 2:
starColor = "Red", remark = "zr.ratings.reviews.ratingtype2";
break;
case 3:
starColor = "Yellow", remark = "zr.ratings.reviews.ratingtype3";
break;
case 4:
starColor = "Green", remark = "zr.ratings.reviews.ratingtype4";
break;
case 5:
starColor = "Green", remark = "zr.ratings.reviews.ratingtype5"
}
return {
starColor: starColor,
remark: remark
}
},
constructAddRecordSelBox: function() {
var tabLayerHeight = $("#tabLayer").height();
$("#createNew").selectBox({
callback: function(e, t, curElem) {
switch ($("#createNew-svalue").html(""), e) {
case "select":
var activeElm = $("#createNew-slist").find(".active"),
moduleName = activeElm.data().value;
$("#submenu_" + moduleName).click(), activeElm.after(activeElm.removeClass("active")), $("#gsearchparentdiv").length > 0 && void 0 != $("#gsearchparentdiv").length && $("#gsearchparentdiv").css("display", "none"), $("#createNew-slist").find(".sel").after($("#createNew-slist").find(".sel").removeClass("sel")), activeElm = null;
break;
case "open":
if ($("#createNew-slist").find(".sel").after($("#createNew-slist").find(".sel").removeClass("sel")), curElem && curElem[0] && curElem[0]._baseElem.hasClass("zrc-select-box svgIconsImg createNewIcon removeSelBoxCont")) {
var bannerEle = $("#annoncement");
curElem[0]._dropdown.css(1 == bannerEle.length && "none" != bannerEle.css("display") ? {
right: $(window).width() + $(window).scrollLeft() - ($(".qicon #createNew-sbox").offset().left + $(".qicon #createNew-sbox").outerWidth()) - 41,
left: "",
top: tabLayerHeight + bannerEle.outerHeight()
} : {
right: $(window).width() + $(window).scrollLeft() - ($(".qicon #createNew-sbox").offset().left + $(".qicon #createNew-sbox").outerWidth()) - 41,
left: "",
top: tabLayerHeight
}), curElem[0]._dropdown.find(".selbox-arrow").css({
right: "43px"
})
}
break;
case "searchCallBack":
curElem[0] && curElem.closest(".zrc-dropdown")[0] && curElem.closest(".zrc-dropdown").css({
right: $(window).width() + $(window).scrollLeft() - ($(".qicon #createNew-sbox").offset().left + $(".qicon #createNew-sbox").outerWidth()) - 41,
left: "",
top: tabLayerHeight
})
}
},
searchlimit: 7
});
var addrecordsList = $("#createNew-slist");
addrecordsList.find(".active").after(addrecordsList.find(".active").removeClass("active")), addrecordsList.find(".sel").after(addrecordsList.find(".sel").removeClass("sel")), addrecordsList.closest(".zrc-dropdown").prepend("<span class='selbox-arrow'></span>"), addrecordsList = null, $("#createNew-sbox").addClass("svgIconsImg createNewIcon removeSelBoxCont"), $("#createNew-sbox").css({
border: "0px"
})
},
constructSelBoxMenu: function() {
$("#menu_more-sbox")[0] && ($("#menu_more").selectBox("destory"), $("#menu_more").remove());
for (var anchors = $("#change_menu").children().filter("a"), selElem = Utils.createHTML({
name: "select",
attr: {
id: "menu_more",
"data-zcqa": "menu_more"
}
}), i = 0; i < crmTab.tabList.length; i++)
if (!(anchors.length > i)) {
var opt = Utils.createHTML({
name: "option",
attr: {
value: crmTab.tabList[i],
"data-Test": crmTab.tabList[i]
},
text: I18n.getMsg(Crm.moduleInfo[crmTab.tabList[i]][1])
});
selElem.append(opt), selElem = $(selElem).find("option").parents().eq(0)[0]
}
$("#showMenu").append(selElem), selElem = null, anchors = null;
var tabLayerHeight = $("#tabLayer").height(),
extraCreateOptionName = isClientUser ? void 0 : "<b>+</b> " + I18n.getMsg("crm.label.new.module");
$("#menu_more").selectBox({
extraCreateOptionName: extraCreateOptionName,
searchlimit: 7,
callback: function(e, t, curElem) {
switch ($("#menu_more-svalue").html(""), e) {
case "create":
$("#menu_more-sbox").addClass("menuMore"), $("#menu_more-sbox").css({
border: "0px"
});
break;
case "select":
var moduleName = $("#showMenu .zrc-select-box").data().selected[0].value;
$("[id='tab_" + moduleName + "']").click(), $("#menu_more-slist").find(".active").after($("#menu_more-slist").find(".active").removeClass("active"));
break;
case "open":
$("#menu_more-slist").find(".sel").after($("#menu_more-slist").find(".sel").removeClass("sel")), curElem && curElem[0] && curElem[0]._baseElem.hasClass("zrc-select-box menuMore removeSelBoxCont") && (curElem[0]._dropdown.find(".selbox-arrow").css({
left: "16px"
}), curElem[0]._dropdown.css({
left: $("#menu_more-sbox").offset().left - 15,
top: tabLayerHeight
}));
break;
case "extraCreateOpt":
Crm.addToHistoryCbn(void 0, void 0, {
showC: !0,
calleeObj: "crmSetup",
clickId: "customize_modules",
tab: "customize",
subTab: "modules"
}, void 0);
break;
case "searchCallBack":
curElem[0] && curElem.closest(".zrc-dropdown")[0] && curElem.closest(".zrc-dropdown").css({
left: $("#menu_more-sbox").offset().left - 15,
top: tabLayerHeight
})
}
}
});
var menuList = $("#menu_more-slist");
menuList.find(".active").after(menuList.find(".active").removeClass("active")), menuList.find(".sel").after(menuList.find(".sel").removeClass("sel")), menuList.closest(".zrc-dropdown").prepend("<span class='selbox-arrow'></span>"), menuList = null, $("#menu_more-sbox").addClass("removeSelBoxCont")
},
deleteFileFromZfs: function(fileName) {
var data = {};
data[csrfParamName] = encodeURIComponent(csrfToken), data.mode = "deleteFileFromZFS", data.fileName = fileName, $.ajax({
type: "POST",
url: "/recruit/getParserReviewDetails.do",
data: data
})
},
toggleParseReview: function() {
$(".zrc-switch-btn").toggleClass("on"), $(".zrc-switch-btn").find(".zrc-switch-round").toggleClass("on");
var isParserReviewEnabled = $(".zrc-switch-btn").hasClass("on") ? "true" : "false",
keyData = {};
keyData[csrfParamName] = encodeURIComponent(csrfToken), keyData.isParserReviewEnabled = isParserReviewEnabled, keyData.mode = "addKeyForPR", $.ajax({
type: "POST",
url: "/recruit/getParserReviewDetails.do",
data: keyData,
success: function() {
"true" == isParserReviewEnabled ? crmui.showMsgBand("success", I18n.getMsg("zr.rp.enable.msg"), 5e3) : crmui.showMsgBand("success", I18n.getMsg("zr.rp.disable.msg"), 5e3)
}
})
},
showInfoParserReview: function() {
$(".zrc-multi-left").show()
},
hideInfoParserReview: function() {
$(".zrc-multi-left").hide()
},
executeZohoOneLauncher: function(csrfName, csrfValue) {
window.onZDLibraryReady = function() {
0 == $(".zod-launcher-icon").length && ZDLibrary.Launcher.init({
icon: {
element: document.getElementById("zone-launcher"),
is_product_icon_available: !1,
is_hamburger_available: !1
},
menuBar: document.getElementById("tabLayer"),
csrfName: "" + csrfName,
getCsrfValue: function() {
return "" + csrfValue
}
})
}, $("body").on("click", "#zone-launcher", function() {
$("body").addClass("oH")
})
},
isClientModal: function(url) {
return /InviteContacts/.test(url) || "/recruit/portal.do" === url || "/recruit/clientportal.do" === url || "/recruit/candidatelogin.do" === url ? !0 : !1
},
loadPortalTab: function(requestData, tab, divId, subTab) {
if (void 0 !== requestData && -1 === requestData.url.indexOf("InviteContacts.do"))
"/recruit/portal.do" === requestData.url ? (requestData.params.hasOwnProperty("fromClientLoginTab") && "yes" === requestData.params.fromClientLoginTab && $("#crm-msg").remove(), store.findAll("portal").then(function(data) {
var org = store.peekAll("organisation")[0];
$("#result").empty();
var elem = Lyte.Component.render("portal-list", {
portals: ZRCommonUtil.isEmpty(data) ? {
name: null
} : data,
org: org
}, "#result");
elem.id = "portal-list", $("#settingInner").hide(), $("#setupshow").show(), Utils.showHideLoadingDiv(), crmSetup.selectSetupTab(tab, divId, subTab), crmSetup.SetHeight_setup_inner_content(), org && Utils.isEmptyString(org.portal_name) && $("#clEditCompany").click()
}, function(errorObj) {
Utils.showHideLoadingDiv(), $("#settingInner").hide(), $("#setupshow").show(), ZRCommonUtil.lyteErrorMessage(errorObj.responseText)
})) : "/recruit/clientportal.do" === requestData.url ? store.findAll("clientlogin").then(function(data) {
$("#result").empty();
var json = data[0];
Lyte.Component.render("client-login-list", {
clientlogin: json
}, "#result"), $("#settingInner").hide(), $("#setupshow").show(), Utils.showHideLoadingDiv(), crmSetup.selectSetupTab(tab, divId, subTab), crmSetup.SetHeight_setup_inner_content()
}, function(errorObj) {
Utils.showHideLoadingDiv(), $("#settingInner").hide(), $("#setupshow").show(), ZRCommonUtil.lyteErrorMessage(errorObj.responseText), Crm.addToHistoryCbn(void 0, void 0, {
module: "Setup",
clickId: "tab",
calleeObj: "crmTab"
}, void 0)
}) : "/recruit/candidatelogin.do" === requestData.url && store.findAll("candidatedetail").then(function() {
$("#result").empty();
var json = store.peekAll("candidatedetail")[0],
elem = Lyte.Component.render("candidate-login-list", {
candidatelogin: json
}, "#result");
elem.id = "candidate-login-list", $("#settingInner").hide(), $("#setupshow").show(), Utils.showHideLoadingDiv(), crmSetup.selectSetupTab(tab, divId, subTab), crmSetup.SetHeight_setup_inner_content()
}, function(errorObj) {
Utils.showHideLoadingDiv(), $("#settingInner").hide(), $("#setupshow").show(), ZRCommonUtil.lyteErrorMessage(errorObj.responseText)
});
else {
$("html").css({
overflow: "hidden"
});
var params = requestData.id ? {
type: "1",
clientid: requestData.id
} : {
type: "1"
};
store.findAll("contacts", params, void 0, !1).then(function(data) {
$("#show").empty();
var params = {
meta: data && data.meta ? data.meta : {
type: "1"
},
contacts: data && data.contacts ? data.contacts : []
};
requestData && requestData.entityName && (params.clientName = requestData.entityName), requestData && requestData.id && (params.clientId = requestData.id), data && data.blankPageDetails && (params.showBlankState = data.blankPageDetails.showBlankState, params.clientHasContact = data.blankPageDetails.clientHasContact);
var elem = Lyte.Component.render("contact-invite-list", params, "#show");
elem.id = "contact-invite-component", data && data.meta && $("#contact-invite-div").data("scrolldata", '{"loadmore": false, "type":"1", "islist":true, "toindex": "' + data.meta.toIndex + '", "fromindex":"' + data.meta.fromIndex + '", "shownext":"' + data.meta.showNext + '", "callee": "ZRClientUtil.scrollInviteContacts"}'), Utils.showHideLoadingDiv(), requestData && requestData.action && "plusBtn" === requestData.action && $("#contact-action-invite").click()
}, function(errorObj) {
Utils.showHideLoadingDiv(), ZRCommonUtil.lyteErrorMessage(errorObj.responseText)
})
}
},
lyteErrorMessage: function(errorObj) {
var errorMessage = I18n.getMsg("crm.unable.to.process.request");
if (errorObj = ZRCommonUtil.convertStringToJson(errorObj), errorObj = void 0 != errorObj && void 0 != errorObj.errorObj ? errorObj.errorObj : errorObj)
if (errorObj.errorCode) {
var errorCode = errorObj.errorCode ? errorObj.errorCode : "INTERNAL_ERROR",
maxLen = errorObj.maxLen ? errorObj.maxLen : 100,
featureName = errorObj.feature ? errorObj.feature : void 0;
if ("INTERNAL_ERROR" === errorCode)
errorMessage = I18n.getMsg("crm.unable.to.process.request");
else if ("XSS_DETECTED" === errorCode || "UNABLE_TO_PARSE_DATA_TYPE" === errorCode || "EXTRA_PARAM_FOUND" === errorCode || "MORE_THAN_MAX_OCCURANCE" === errorCode || "LESS_THAN_MIN_OCCURANCE" === errorCode)
errorMessage = I18n.getMsg("crm.iam.error.xssdetected");
else if ("MORE_THAN_MAX_LENGTH" === errorCode)
errorMessage = I18n.getMsg("crm.iam.error.morethanmaxlength", [maxLen]);
else if ("URL_RULE_NOT_CONFIGURED" === errorCode)
errorMessage = I18n.getMsg("crm.label.error.message1");
else if ("FILE_SIZE_MORE_THAN_ALLOWED_SIZE" === errorCode)
errorMessage = I18n.getMsg("zats.error.filesizeismore");
else if ("PATTERN_NOT_MATCHED" === errorCode)
errorMessage = I18n.getMsg("crm.alert.label.special.characters");
else if ("POST_ONLY_URL" === errorCode)
errorMessage = I18n.getMsg("crm.unable.to.process.request");
else if ("LESS_THAN_MIN_LENGTH" === errorCode)
errorMessage = I18n.getMsg("crm.iam.error.lessthanminlength");
else if ("UNMATCHED_FILE_CONTENT_TYPE" === errorCode)
errorMessage = I18n.getMsg("crm.label.invalid.attach.alert");
else if ("REMOTE_IP_LOCKED" === errorCode || "URL_ROLLING_THROTTLES_LIMIT_EXCEEDED" === errorCode)
errorMessage = I18n.getMsg("zr.qv.threshold.reached");
else if ("NOT_ALLOWED" === errorCode)
errorMessage = featureName ? I18n.getMsg("crm.module.not.supported", [featureName]) : I18n.getMsg("crm.FLEE.default.message");
else if ("NO_PERMISSION" === errorCode)
errorMessage = errorCode;
else {
if ("URL_IN_QUEUE" === errorCode)
return void window.console.log("Request already in pending ", errorObj.pendingURL);
if ("candidateAccountDisabled" === errorCode)
return void location.reload()
}
} else if (errorObj.code) {
var errorCode = errorObj.code ? errorObj.code : "INTERNAL_ERROR",
message = I18n.getMsg(errorObj.message ? errorObj.message : "crm.unable.to.process.request");
errorMessage = "NO_PERMISSION" === errorCode ? "NO_PERMISSION" : "NOT_ALLOWED" === errorCode || "FEATURE_NOT_AVAILABLE" === errorCode ? featureName ? I18n.getMsg("crm.module.not.supported", [featureName]) : I18n.getMsg("crm.FLEE.default.message") : "UNABLE_TO_PARSE_DATA_TYPE" === errorCode ? I18n.getMsg("crm.iam.error.xssdetected") : "DUPLICATE_PORTAL_NAME" === errorCode ? I18n.getMsg("crm.setup.portal.duplicateportal") : "INVALID_PORTAL_NAME" === errorCode ? I18n.getMsg("zr.portal.invalid.portal.name") : "TABULAR_DATA_COUNT_EXCEED" === errorCode ? I18n.getMsg("crm.module.addtabular.maxerror", [$(".cnl-detail-header h1").text(), "10"]) : "MANDATORY_FIELDS_DATA_MISSING" === errorCode ? I18n.getMsg("crm.field.nomandatory.error") : "FIELD_COUNT_EXCEPTION" === errorCode ? I18n.getMsg("zr.candidateportal.enable.fields.limit", message) : message
}
"NO_PERMISSION" === errorMessage ? Utils.displayPermissionDenied() : crmui.showMsgBand("error", errorMessage, crmConstants.failureMsgLongDelay)
},
getHeaderDetail: function(record, module) {
var data = [];
return $.each(record, function(i, section) {
var sysname = section.sysname,
isTabular = section.istabular;
"Leads" === module && isTabular && ("Educational Details" === sysname || "Experience Details" === sysname) && (data[sysname] = section.fields ? section.fields.entityData : section.fields), $.each(section.fields, function(j, field) {
var column = field.column,
value = field.value;
"Leads" === module || "Contacts" === module ? ("LASTNAME" === column && (data.lastname = value), "FIRSTNAME" === column && (data.firstname = value), "STATUS" === column && (data.status = value), "ACCOUNTID" === column && (data.accountname = value), "DESIGNATION" === column && (data.jobtitle = value), "COMPANY" === column && (data.employer = value)) : "Potentials" === module ? ("POTENTIALNAME" === column && (data.name = value), "DESCRIPTION" === column && (data.description = value), "STATUS" === column && (data.status = value), "ACCOUNTID" === column && (data.accountname = value)) : "Products" === module ? ("PRODUCTNAME" === column && (data.name = value), "POTENTIALID" === column && (data.potentialName = value), "STATUS" === column && (data.status = value), "CONTACTID" === column && (data.interviewer = value), "SALES_START_DATE" === column && (data.date = value)) : "Accounts" === module && ("ACCOUNTNAME" === column && (data.name = value), "WEBSITE" === column && (data.website = value))
})
}), data
},
getClientDetailView: function(entityId, module, assJoId) {
var reponseData = {};
Utils.showHideLoadingDiv(!0), ZRCommonUtil.loadingCompleted = !1;
var assJoId = assJoId ? "&assJoId=" + assJoId : "";
return ZRCommonUtil.ajaxGetMethod("/recruit/getClientDetailView.do", "id=" + entityId + "&module=" + module + assJoId, !1, "json", void 0, function(data) {
ZRCommonUtil.loadingCompleted = !0, ZRCommonUtil.fromClientNavigation = !1, Utils.showHideLoadingDiv(), reponseData = data
}, function(errorObj) {
ZRCommonUtil.lyteErrorMessage(errorObj.responseText)
}), reponseData
},
getStatusFromInterviewRecord: function(data, headerObj) {
data.isInterviewRecord = !0, $.each(data.record, function(i, record) {
if (record.sysname) {
var fields = record.fields;
fields && fields.length && $.each(fields, function(j, field) {
return field && "STATUS" === field.column ? void (headerObj.actStatus = field.value) : void 0
})
}
})
},
getDetailView: function(entityId, module, showNav, assJoId) {
var data = ZRCommonUtil.getClientDetailView(entityId, module, assJoId),
showNav = void 0 === showNav ? !0 : showNav;
if (ZRCommonUtil.showClientNavCtrls = showNav, !ZRCommonUtil.isEmpty(data)) {
var record = data.record,
photoId = data.PHOTOFILEID;
if (!ZRCommonUtil.isEmpty(record)) {
var headerObj = ZRCommonUtil.getHeaderDetail(record, module);
"Potentials" === module ? headerObj.submissioncount = data.count : "Leads" === module && data && data.submission ? (data.submission.hasOwnProperty("rating") && (data.submission.ratingArray = ZRCommonUtil.generateRating(data.submission.rating)), !Utils.isEmpty(data.submission) && data.submission.status ? headerObj.actStatus = data.submission.status : ZRCommonUtil.getStatusFromInterviewRecord(data, headerObj)) : "Products" === module && data && data.decision && data.decision.actualStatus && (headerObj.actualStatus = data.decision.actualStatus);
var headerTitle = ZRCommonUtil.getHeaderHtml(headerObj, photoId, entityId, module),
elemFrag = document.createDocumentFragment();
elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
id: "client-login-detail-title"
},
html: headerTitle
}));
var elem = document.createElement("client-login-detail-view");
elem.setAttribute("id", "client-login-detail-component"), elem.setData({
detail: data,
header: headerObj,
module: module,
entityid: entityId,
attachment: [],
note: []
});
var overFn = function(ev, target, content) {
Utils.showtt(content)
},
outFn = function() {
zctt.hidett()
};
ZRCommonUtil.createModal({
modalid: "client-quick-view",
modalclass: " zcrm-content wid1200",
needCrossBtn: !0,
title: elemFrag,
contentClass: "pad0 oveH",
content: elem,
callback: function() {
if ($("#client-quick-view-btn").remove(), showNav && crmTab.selectedTab && crmTab.selectedTab === module) {
var navElem = Utils.createHTML({
name: "span",
data: {
id: entityId,
module: module
},
attr: {
"class": "posA rig60 top20",
id: "client-login-detail-nav"
},
child: [{
name: "a",
attr: {
href: "javascript:;",
id: "client-login-detail-prev",
"class": "previous disIB marR20"
},
events: [{
name: "click",
fn: ZRCommonUtil.clientLoginNavigation,
args: ["prev"]
}, {
name: "mouseover",
fn: overFn,
args: [I18n.getMsg("zr.qv.navigate.previous")]
}, {
name: "mouseout",
fn: outFn
}]
}, {
name: "a",
attr: {
href: "javascript:;",
id: "client-login-detail-next",
"class": "next disIB"
},
events: [{
name: "click",
fn: ZRCommonUtil.clientLoginNavigation,
args: ["next"]
}, {
name: "mouseover",
fn: overFn,
args: [I18n.getMsg("zr.qv.navigate.next")]
}, {
name: "mouseout",
fn: outFn
}]
}]
});
$("#client-quick-view .popup-model-header").append(navElem).addClass("padT15 padB8"), ZRCommonUtil.setNavigationState(entityId)
}
},
removeElem: !0
})
}
}
},
getNameLetter: function(name) {
var imageName = void 0;
if (name && null !== name && "null" !== name && name.length > 0) {
var namesplit = name.split(" ");
namesplit.length > 0 && $.each(namesplit, function(i, item) {
var letter = item.substring(0, 1);
imageName = void 0 !== imageName ? imageName + letter : letter
})
}
return void 0 === imageName ? "" : imageName
},
getHeaderHtml: function(headerObj, photoId, entityId, module) {
var elemFrag = document.createDocumentFragment();
if ("Leads" === module) {
var fullName = headerObj.firstname && headerObj.lastname ? headerObj.firstname + " " + headerObj.lastname : headerObj.lastname ? headerObj.lastname : headerObj.firstname ? headerObj.firstname : "",
overFn = function(ev, target, content) {
Utils.showtt(content)
},
outFn = function() {
zctt.hidett()
};
if (photoId && null != photoId && "null" !== photoId && photoId.length > 0)
elemFrag.appendChild(Utils.createHTML({
name: "div",
attr: {
"class": "floL marR15"
},
child: [{
name: "img",
attr: {
src: "/recruit/EntityImageAttach.do?action_module=" + module + "&actionName=readImage&clientUser=yes&entityId=" + entityId + "&fileId=" + photoId,
"class": "dvPhotoShadow"
}
}]
}));
else {
var imageName = fullName && fullName.length > 0 ? fullName.substring(0, 1) : "";
elemFrag.appendChild(Utils.createHTML({
name: "div",
attr: {
"class": "emptyImgContainer emptyLCPhoto floL marR15",
style: "background-position: -154px 0px; font-size: 24px;"
},
text: imageName
}))
}
if (elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f18"
},
text: fullName
})), headerObj.actStatus) {
var actStatus = headerObj.hasOwnProperty("actStatus") && I18n.getMsg("Rejected by client") === headerObj.actStatus ? "Rejected" : "Approved",
colorClass = "Rejected" === actStatus ? "colR" : "colGR";
elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
id: "clCandHeaderStatus",
"class": "proRE f15 " + colorClass
},
text: " - " + headerObj.actStatus
}))
}
if (headerObj.jobtitle)
if (headerObj.employer) {
var titleObj = ZRCommonUtil.getDotVal(headerObj.jobtitle, 25);
elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f15 colG1 disB"
},
text: titleObj.dotVal,
events: [{
name: "mouseover",
fn: overFn,
args: [headerObj.jobtitle]
}, {
name: "mouseout",
fn: outFn
}],
child: [{
name: "span",
attr: {
"class": "disIB wid25 texAC proRE"
},
text: "|"
}, {
name: "span",
text: headerObj.employer
}]
}))
} else {
var titleObj = ZRCommonUtil.getDotVal(headerObj.jobtitle, 25);
elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f15 colG1 disB"
},
text: titleObj.dotVal,
events: [{
name: "mouseover",
fn: overFn,
args: [headerObj.jobtitle]
}, {
name: "mouseout",
fn: outFn
}]
}))
}
else
elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f15 colG1 disB"
},
html: "&nbsp;"
}))
} else if ("Potentials" === module) {
var overFn = function(ev, target, content) {
Utils.showtt(content)
},
outFn = function() {
zctt.hidett()
},
showSubmittedCandidates = function(ev, target, module, joId) {
if (module && joId) {
var params = {};
params.module = crmModuleConstants.Leads, params.calleeObj = "crmTab", params.clickId = "tab", params.isSearch = !1, params.filters = JSON.stringify([{
searchfieldtype: "ASSJO",
searchfield: "CrmClientSubmission:POTENTIALID",
searchModule: "Submit to client",
condition: "0",
value: joId + ":" + headerObj.name
}]), $("#client-quick-view").remove(), crmTab.deleteFromCache(crmModuleConstants.Leads), Crm.addToHistory(void 0, void 0, params)
}
},
nameObj = ZRCommonUtil.getDotVal(headerObj.name, 25);
if (elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "headervalue_Potentials_ico mR10 fL marT6 "
},
html: "&nbsp;"
})), elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f18"
},
text: nameObj.dotVal,
events: [{
name: "mouseover",
fn: overFn,
args: [headerObj.name]
}, {
name: "mouseout",
fn: outFn
}]
})), headerObj.status) {
var statuObj = ZRCommonUtil.getDotVal(headerObj.status, 15);
elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "colGR proRE f15"
},
text: " - " + statuObj.dotVal,
events: [{
name: "mouseover",
fn: overFn,
args: [headerObj.status]
}, {
name: "mouseout",
fn: outFn
}]
}))
}
var accountObj = ZRCommonUtil.getDotVal(headerObj.accountname, 25),
associatedLeadCntFn = 0 == headerObj.submissioncount ? {} : {
name: "click",
fn: showSubmittedCandidates,
args: [module, entityId]
};
elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f15 colG1 disB"
},
text: accountObj.dotVal,
events: [{
name: "mouseover",
fn: overFn,
args: [headerObj.accountname]
}, {
name: "mouseout",
fn: outFn
}],
child: [{
name: "span",
attr: {
"class": "disIB wid25 texAC proRE"
},
text: "|"
}, {
name: "a",
attr: {
href: "javascript:;",
"class": "cl-det-button" + (0 == headerObj.submissioncount ? " cD" : "")
},
text: I18n.getMsg("zr.cl.submittedcandidates", I18n.getMsg(Crm.moduleInfo.Leads[0])) + " ( " + headerObj.submissioncount + " ) ",
events: [associatedLeadCntFn]
}]
}))
} else if ("Products" === module) {
var icsFun = function(event, target, module, entityId) {
ZRCommonUtil.downloadIcs(event, module, entityId)
},
overFn = function(ev, target, content) {
Utils.showtt(content)
},
outFn = function() {
zctt.hidett()
},
name = headerObj.name ? headerObj.name : "";
if (name = headerObj.date ? name + " on " + headerObj.date : name, elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "headervalue_Products_ico mR10 floL"
},
html: "&nbsp;"
})), elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f18"
},
text: name
})), headerObj.status) {
var actSt = headerObj.actualStatus,
colorClass = actSt === crmConstants.STATUS_REJECTED || actSt === crmConstants.STATUS_STRONGREJECT ? "colR" : "colGR";
elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
id: "clIntHeaderStatus",
"class": " proRE f15 marL10 " + colorClass
},
text: headerObj.status
}))
}
elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f15 colG1 disB"
},
text: headerObj.interviewer + " (" + I18n.getMsg("crm.label.interviewers") + ")",
child: [{
name: "span",
attr: {
"class": "disIB wid25 texAC proRE"
},
text: "|"
}, {
name: "span",
attr: {
"class": "disIB marR15 texAC proRE"
},
text: headerObj.potentialName
}, {
name: "a",
attr: {
href: "javascript:;",
"class": "cl-det-button"
},
events: [{
name: "mouseover",
fn: overFn,
args: [I18n.getMsg("zr.cl.ics.file")]
}, {
name: "mouseout",
fn: outFn
}, {
name: "click",
fn: icsFun,
args: [module, entityId]
}],
text: I18n.getMsg("Calendar Invite")
}]
}))
} else if ("Contacts" === module) {
var overFn = function(ev, target, content) {
Utils.showtt(content)
},
outFn = function() {
zctt.hidett()
},
fullName = headerObj.firstname && headerObj.lastname ? headerObj.firstname + " " + headerObj.lastname : headerObj.lastname ? headerObj.lastname : headerObj.firstname ? headerObj.firstname : "",
nameObj = ZRCommonUtil.getDotVal(fullName, 25);
if (photoId && null != photoId && "null" !== photoId && photoId.length > 0)
elemFrag.appendChild(Utils.createHTML({
name: "div",
attr: {
"class": "floL marR15"
},
child: [{
name: "img",
attr: {
src: "/recruit/EntityImageAttach.do?action_module=" + module + "&actionName=readImage&clientUser=yes&entityId=" + entityId + "&fileId=" + photoId,
"class": "dvPhotoShadow"
}
}]
}));
else {
var imageName = fullName && fullName.length > 0 ? fullName.substring(0, 1) : "";
elemFrag.appendChild(Utils.createHTML({
name: "div",
attr: {
"class": "emptyImgContainer emptyLCPhoto floL marR15",
style: "background-position: -154px -55px; font-size: 24px;"
},
text: imageName
}))
}
elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f18"
},
text: nameObj.dotVal,
events: [{
name: "mouseover",
fn: overFn,
args: [fullName]
}, {
name: "mouseout",
fn: outFn
}]
}));
var accountObj = ZRCommonUtil.getDotVal(headerObj.accountname, 25);
elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f15 colG1 disB"
},
text: accountObj.dotVal,
events: [{
name: "mouseover",
fn: overFn,
args: [headerObj.accountname]
}, {
name: "mouseout",
fn: outFn
}]
}))
} else if ("Accounts" === module) {
var overFn = function(ev, target, content) {
Utils.showtt(content)
},
outFn = function() {
zctt.hidett()
},
nameObj = ZRCommonUtil.getDotVal(headerObj.name, 25);
elemFrag.appendChild(photoId && null != photoId && "null" !== photoId && photoId.length > 0 ? Utils.createHTML({
name: "div",
attr: {
"class": "emptyAccLogo floL marR15"
},
child: [{
name: "img",
attr: {
src: "/recruit/EntityImageAttach.do?action_module=" + module + "&actionName=readImage&clientUser=yes&entityId=" + entityId + "&fileId=" + photoId,
"class": "dvPhotoShadow"
}
}]
}) : Utils.createHTML({
name: "div",
attr: {
"class": "emptyAccLogo floL marR15"
},
child: [{
name: "img",
attr: {
src: "/images/companylogonew.svg"
}
}]
})), elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f18"
},
text: nameObj.dotVal,
events: [{
name: "mouseover",
fn: overFn,
args: [headerObj.name]
}, {
name: "mouseout",
fn: outFn
}]
})), headerObj.website && elemFrag.appendChild(Utils.createHTML({
name: "span",
attr: {
"class": "f15 colG1 disB"
},
child: [{
name: "a",
attr: {
"class": "link weblinkAcc",
href: headerObj.website,
target: "_blank",
rel: "noreferrer noopener"
},
text: headerObj.website
}]
}))
}
return elemFrag
},
downloadIcs: function(event, module, entityId) {
var tgt = $(event.target),
curr = document.getElementById("client-login-detail-component"),
prevData = curr.getData("attachment");
if (void 0 == prevData || 0 === prevData.length)
Utils.showHideLoadingDiv(!0), ZRCommonUtil.ajaxGetMethod("/recruit/getClientRelatedRecords.do", "id=" + entityId + "&module=" + module + "&type=Attachments&showICS=yes", !1, "json", void 0, function(data) {
if (Utils.showHideLoadingDiv(), data && !$.isEmptyObject(data.ATTACHMENTDETAILS)) {
Lyte.arrayUtils(prevData, "push", data.ATTACHMENTDETAILS);
var icsData = {};
$.each(data.ATTACHMENTDETAILS, function(i, item) {
"ICS" === item.ATTACHMENTTYPENAME && (icsData = item)
}), icsData && !$.isEmptyObject(icsData) ? (tgt.data("attachdetail", {
attachmentId: icsData.ATTACHMENTID,
pkid: icsData.ATTACHMENTPKID,
fileId: icsData.ATTACHMENTFILEID,
linkDocs: !1,
module: icsData.ATTACHMENTMODULE,
fileName: icsData.ATTACHMENTNAME,
isDownloadAttachPerm: icsData.ISDOWNLOADALLOWED
}), ZRFileUtil.downloadAttachment(event, tgt[0])) : Utils.showCustomAlert(I18n.getMsg("zr.cl.attachments.ics.notavailable"))
} else
Utils.showCustomAlert(I18n.getMsg("zr.cl.attachments.ics.notavailable"))
}, function() {
Utils.showCustomAlert(I18n.getMsg("zr.cl.attachments.ics.notavailable"))
});
else {
var icsData = {};
$.each(prevData, function(i, item) {
"ICS" === item.ATTACHMENTTYPENAME && (icsData = item)
}), icsData && !$.isEmptyObject(icsData) ? (tgt.data("attachdetail", {
attachmentId: icsData.ATTACHMENTID,
pkid: icsData.ATTACHMENTPKID,
fileId: icsData.ATTACHMENTFILEID,
linkDocs: !1,
module: icsData.ATTACHMENTMODULE,
fileName: icsData.ATTACHMENTNAME,
isDownloadAttachPerm: icsData.ISDOWNLOADALLOWED
}), ZRFileUtil.downloadAttachment(event, target)) : Utils.showCustomAlert(I18n.getMsg("zr.cl.attachments.ics.notavailable"))
}
},
setNavigationState: function(entityId) {
var nextNav = $("#client-login-detail-next"),
prevNav = $("#client-login-detail-prev"),
nextArrow = $("#advancedsearchArrowN"),
prevArrow = $("#advancedsearchArrowP");
ZRCommonUtil.isFirstElementInList(entityId) ? prevArrow.length > 0 ? prevNav.removeClass("previousDisabled").addClass("previous") : prevNav.removeClass("previous").addClass("previousDisabled") : prevNav.removeClass("previousDisabled").addClass("previous"), ZRCommonUtil.isLastElementInList(entityId) ? nextArrow.length > 0 ? nextNav.removeClass("nextDisabled").addClass("next") : nextNav.removeClass("next").addClass("nextDisabled") : nextNav.removeClass("nextDisabled").addClass("next")
},
openCliDV: function(recordToOpen) {
var listViewElement = $("#listviewtablescroll tr:not(#listviewHeaderRow)");
listViewElement && ("first" === recordToOpen ? ZRCommonUtil.renderClientDetailPage($(listViewElement[0]).attr("id"), crmTab.selectedTab) : ZRCommonUtil.renderClientDetailPage($(listViewElement[listViewElement.length - 1]).attr("id"), crmTab.selectedTab))
},
isLastElementInList: function(entityId) {
var listViewElement = $("#listviewtablescroll tr:not(#listviewHeaderRow)");
return listViewElement && listViewElement.index($("#" + entityId)) === listViewElement.length - 1 ? !0 : !1
},
isFirstElementInList: function(entityId) {
var listViewElement = $("#listviewtablescroll tr:not(#listviewHeaderRow)");
return listViewElement && 0 === listViewElement.index($("#" + entityId)) ? !0 : !1
},
clientLoginNavigation: function(ev, target, type) {
var parentElem = $(target).is("a") ? $(target).parent() : $(target).parent().parent(),
data = parentElem.data(),
entityId = data.id,
module = data.module,
listTr = $("#listviewtablescroll tr:not(#listviewHeaderRow)"),
recordArr = [];
$.each(listTr, function(i, item) {
var params = $(item).data("params"),
assoJOId = params && params.hasOwnProperty("assoJOId") ? params.assoJOId : void 0,
obj = {
id: params.id,
assoJOId: assoJOId
};
entityId === params.id && (currentRecInd = i), recordArr.push(obj)
});
var nextArrow = $("#advancedsearchArrowN"),
prevArrow = $("#advancedsearchArrowP"),
recordObj = "next" === type ? recordArr[currentRecInd + 1] : recordArr[currentRecInd - 1],
id = recordObj && recordObj.hasOwnProperty("id") ? recordObj.id : void 0,
assoJOId = recordObj && recordObj.hasOwnProperty("assoJOId") ? recordObj.assoJOId : void 0;
if (type && "next" === type && ZRCommonUtil.isLastElementInList(entityId) && 1 === nextArrow.length) {
var data = nextArrow.attr("data-params");
data || (data = {}), "string" == typeof data && (data = JSON.parse(data)), data.calleeObj = "crmTab", data.clickId = "navigate_next_listview", data.cliDVPrevOrNext = "next", data.assoJOId = assoJOId, nextArrow.attr("data-params", JSON.stringify(data)), ZRCommonUtil.fromClientNavigation = !0, Crm.addToHistory(null, nextArrow)
} else if (type && "prev" === type && ZRCommonUtil.isFirstElementInList(entityId) && 1 === prevArrow.length) {
var data = prevArrow.attr("data-params");
data || (data = {}), "string" == typeof data && (data = JSON.parse(data)), data.calleeObj = "crmTab", data.clickId = "navigate_previous_listview", data.cliDVPrevOrNext = "prev", data.assoJOId = assoJOId, prevArrow.attr("data-params", JSON.stringify(data)), ZRCommonUtil.fromClientNavigation = !0, Crm.addToHistory(null, prevArrow)
} else
ZRCommonUtil.renderClientDetailPage(id, module, assoJOId)
},
renderClientDetailPage: function(id, module, assoJOId) {
var titleElem = $("#client-login-detail-title");
if (id && module) {
var data = ZRCommonUtil.getClientDetailView(id, module, assoJOId);
if (!ZRCommonUtil.isEmpty(data)) {
var record = data.record,
photoId = data.PHOTOFILEID;
if (!ZRCommonUtil.isEmpty(record)) {
var headerObj = ZRCommonUtil.getHeaderDetail(record, module);
"Potentials" === module ? headerObj.submissioncount = data.count : "Leads" === module && data && data.submission ? (data.submission.hasOwnProperty("rating") && (data.submission.ratingArray = ZRCommonUtil.generateRating(data.submission.rating)), !Utils.isEmpty(data.submission) && data.submission.status ? headerObj.actStatus = data.submission.status : ZRCommonUtil.getStatusFromInterviewRecord(data, headerObj)) : "Products" === module && data && data.decision && data.decision.actualStatus && (headerObj.actualStatus = data.decision.actualStatus);
var headerTitle = ZRCommonUtil.getHeaderHtml(headerObj, photoId, id, module),
elem = document.createElement("client-login-detail-view");
elem.setAttribute("id", "client-login-detail-component"), elem.setData({
detail: data,
header: headerObj,
module: module,
entityid: id,
attachment: [],
note: []
});
var modelId = $("#client-quick-view .popup-model-content");
modelId.length ? ($("#client-quick-view .popup-model-content").html(elem), titleElem.html(headerTitle)) : ZRCommonUtil.getDetailView(id, module, !0, assoJOId), $("#client-login-detail-nav").data("id", id), ZRCommonUtil.setNavigationState(id)
}
}
}
},
showStatusBasedCount: function(module, obj) {
$(obj).addClass("active").siblings("a").removeClass("active"), "Potentials" === module ? $("#Leads-status-based-count, #Products-status-based-count").hide() : "Leads" === module ? $("#Potentials-status-based-count, #Products-status-based-count").hide() : "Products" === module && $("#Leads-status-based-count, #Potentials-status-based-count").hide(), $("#" + module + "-status-based-count").show()
},
loadStatusBasedFilter: function(element, module) {
var params = {};
params.module = module, params.calleeObj = "crmTab", params.from = "CLHomePageDashboard", params.clickId = "tab", params.isSearch = !1, params.filters = JSON.stringify($(element).data("params")), "Products" !== module && crmTab.checkPresenceInCache(module) && crmTab.deleteFromCache(module), Crm.addToHistory(void 0, void 0, params)
},
loadListViewPage: function(module, recordId) {
if (module && recordId) {
var params = {};
params.module = module, params.recordId = recordId, params.from = "CLHomePageDashboardRecord", params.calleeObj = "crmTab", params.clickId = "tab", "Accounts" === module ? ZRCommonUtil.getDetailView(recordId, module, !1) : Crm.addToHistory(void 0, void 0, params)
}
},
loadMyProfile: function(type, contactUserId) {
Utils.showHideLoadingDiv(!0);
var params = {};
type && "editContactUserRole" === type && (params = {
action: "editContactUserRole",
contactUserId: contactUserId
}), ZRCommonUtil.ajaxGetMethod("/recruit/getClientProfileDetail.do", params, !1, "json", void 0, function(data) {
Utils.showHideLoadingDiv();
var elem = document.createElement("client-login-my-profile"),
value = {
user: data.user,
type: "View",
meta: data.meta
},
modelBoxTitle = I18n.getMsg("My Profile"),
removecancelbtn = !1,
needCrossBtn = !0,
editProfile = function(ev, target, userData) {
$(target).hide(), Utils.showHideLoadingDiv(!0), ZRCommonUtil.editProfile(userData)
},
overFn = function(ev, target, content) {
Utils.showtt(content)
},
outFn = function() {
zctt.hidett()
},
editIcon = {
name: "a",
attr: {
href: "javascript:void(0)",
"class": "marL20 neweditIcon dIB"
},
events: [{
name: "click",
fn: editProfile,
args: [data]
}, {
name: "mouseover",
fn: overFn,
args: [I18n.getMsg("crm.button.edit")]
}, {
name: "mouseout",
fn: outFn
}]
};
type && "editContactUserRole" === type && (modelBoxTitle = I18n.getMsg("zr.cl.edit.contact.user.RoleOrProfile"), value.renderType = "editContactUserRole", editIcon = {}), isClientUser && showLocalePopupToClient && (modelBoxTitle = I18n.getMsg("crm.security.locale.informations"), value.type = "Edit", value.showLocalePopupToClient = !0, removecancelbtn = !0, needCrossBtn = !1, editIcon = {}), elem.setAttribute("id", "client-login-myprofile-component"), elem.setData(value);
var titleElem = Utils.createHTML({
name: "span",
text: modelBoxTitle,
child: [editIcon]
});
ZRCommonUtil.createModal({
modalid: "client-myprofile-view",
modalclass: "wid650 zrc-model-and-selectbox",
needCrossBtn: needCrossBtn,
removecancelbtn: removecancelbtn,
title: titleElem,
contentClass: "pad0 oveH clearfix",
content: elem,
callback: function() {
type && "editContactUserRole" === type || isClientUser && showLocalePopupToClient || $("#client-myprofile-view-btn").hide(), $("#cde").css("overflow", "hidden")
},
savefn: function() {
ZRCommonUtil.saveProfile()
},
removeElem: !0
})
}, function(errorObj) {
ZRCommonUtil.lyteErrorMessage(errorObj.responseText)
})
},
editProfile: function(data) {
var elem = document.createElement("client-login-my-profile");
elem.setData({
user: data.user,
type: "Edit",
meta: data.meta
}), $("#client-myprofile-view").find(".popup-model-content").html(elem).show(), $("#client-myprofile-view-btn").show(), ZRCommonUtil.bindCountryEvent(), Utils.showHideLoadingDiv(), $("#cde").css("overflow", "hidden")
},
bindCountryEvent: function() {
$("body").find("#countrySearch").off("keyup").on("keyup", function() {
var searchStr = $(this).val().trim();
$.each($("#selCountryList li"), function(i, li) {
var countryName = $(li).text().trim();
-1 !== countryName.toLowerCase().search(searchStr.toLowerCase()) ? $(li).show() : $(li).hide()
})
})
},
saveProfile: function() {
var params = {},
editContactUser = $("#editContactUser").val();
if (editContactUser && "editContactUserRole" === editContactUser)
params.contactUserRoleId = document.getElementById("contactUserRole").getData("ltPropSelected"), params.contactUserProfileId = document.getElementById("contactUserProfile").getData("ltPropSelected"), params.contactUserId = $("#contactUserId").val(), params.contactUserAction = "updateContactUserRole";
else if (isClientUser && showLocalePopupToClient)
params.language = document.getElementById("myprofile-language").getData("ltPropSelected"), params.userCountryLocale = $("#myprofile-country").val(), params.userTimeFormat = document.getElementById("myprofile-timeformat").getData("ltPropSelected"), params.timeZone = document.getElementById("myprofile-timezone").getData("ltPropSelected"), params.contactUserAction = "updateContactUserLocale", showLocalePopupToClient = !1;
else {
var lastName = $("#myprofile-lname").val();
if (0 == lastName.length)
return $("#myprofile-lname").parents(".zrc-form-row").addClass("errorFieldbb"), $("#errorMsg_cl_LASTNAME").show(), !1;
params.firstName = $("#myprofile-fname").val(), params.lastName = lastName, params.language = document.getElementById("myprofile-language").getData("ltPropSelected"), params.userCountryLocale = $("#myprofile-country").val(), params.userTimeFormat = document.getElementById("myprofile-timeformat").getData("ltPropSelected"), params.timeZone = document.getElementById("myprofile-timezone").getData("ltPropSelected"), params.contactUserAction = "updateContactUserDetails"
}
Utils.showHideLoadingDiv(!0), ZRCommonUtil.ajaxPostMethod("/recruit/UpdateClientProfileDetail.do", params, !1, "json", void 0, function(data) {
if (Utils.showHideLoadingDiv(), data && data.reload && data.reload === !0)
window.location.reload();
else if (data && data.message && "success" === data.message) {
if (editContactUser && "editContactUserRole" === editContactUser && params) {
var contactLVData = document.querySelector("contact-invite-list").getData();
$.each(contactLVData.contacts, function(i, contactObj) {
contactObj.userId == params.contactUserId && (Lyte.objectUtils(contactObj, "add", "profileId", params.contactUserProfileId), Lyte.objectUtils(contactObj, "add", "roleId", params.contactUserRoleId))
})
}
ZRCommonUtil.closeDialog(void 0, void 0, "#client-myprofile-view"), crmui.showMsgBand("success", I18n.getMsg("crm.zci.setup.mapping.updated.success"), 5e3)
} else
data && data.message && "NOT_CLIENT_ROLE_PROFILE" === data.message ? crmui.showMsgBand("error", I18n.getMsg("cl.portal.not.client.roleid.profileid.error"), crmConstants.failureMsgLongDelay) : data && data.message && "failure" === data.message && ZRCommonUtil.lyteErrorMessage(data)
}, function(errorObj) {
ZRCommonUtil.lyteErrorMessage(errorObj.responseText)
})
},
getDomainName: function(website) {
var domainName = "";
if (void 0 !== website && null !== website && "null" !== website && 0 !== website.length) {
website = website.toLocaleLowerCase(), website = website.startsWith("http") || website.startsWith("ftp") ? website : "https://" + website;
var parseUrl = new URL(website);
if (void 0 !== parseUrl && null !== parseUrl && "null" !== parseUrl) {
var hostName = parseUrl.hostname;
void 0 !== hostName && null !== hostName && "null" !== hostName && (hostName = hostName.startsWith("www") ? hostName.substring(3) : hostName, domainName = hostName.startsWith(".") ? hostName.substring(1) : hostName)
}
}
return domainName
},
getPortalNameFormWebsite: function(website) {
var domainName = ZRCommonUtil.getDomainName(website);
return domainName && 0 !== domainName.length && (domainName = domainName.substring(0, domainName.indexOf("."))), domainName
},
getFileTypeClass: function(fileType) {
if (void 0 != fileType && null != fileType && 0 != fileType.trim().length) {
var className = "fa fa-file-word-o";
switch (fileType) {
case "rar":
case "zip":
case "tar":
className = "fa fa-file-archive-o";
break;
case "gif":
case "jpeg":
case "jpg":
case "png":
case "bmp":
case "tiff":
case "mng":
case "svg":
className = "fa fa-file-image-o";
break;
case "xlsx":
case "xls":
case "xml":
className = "fa fa-file-excel-o";
break;
case "doc":
case "docx":
case "dotx":
className = "fa fa-file-word-o";
break;
case "pdf":
className = "fa fa-file-pdf-o"
}
return className
}
return "fa fa-file-word-o"
},
globalHideCLPopups: function() {
var clientLoginPreivew = $("#cLTempModelPop"),
clQVId = "#client-quick-view";
$(clQVId).is(":visible") && ZRCommonUtil.closeDialog(void 0, void 0, clQVId), clientLoginPreivew.is(":visible") && $("#cLTempCls").trigger("click")
},
expandTextArea: function(id) {
$("#" + id).find("textarea").each(function() {
var currElem = $(this),
spanEle = $("<span>");
spanEle.attr({
id: "span_tarea",
"class": "dIB"
}).css({
visiblity: "hidden",
"font-size": "1rem",
"overflow-y": "scroll",
"line-height": "18px"
}), $("body").append(spanEle), $("#span_tarea").text(currElem.val()), $("#span_tarea").css({
width: currElem.outerWidth(),
"word-break": "break-word"
});
var hts = 18 * parseInt($("#span_tarea").outerHeight() / 18);
hts > 361 ? ($("#span_tarea").remove(), currElem.css({
height: "360px"
})) : (hts = 0 == hts ? 18 : hts, currElem.css({
height: hts
}), $("#span_tarea").remove())
})
},
generateRating: function(rating) {
var ratingClassArray = [];
rating = rating ? rating : 0;
for (var i = 1; 5 >= i; i++)
ratingClass = 4 === rating || 5 === rating ? "starGreen" : 3 === rating ? "starYellow" : 2 === rating || 1 === rating ? "starRed" : "starNormal", ratingClassArray.push(rating >= i ? {
ratingClass: ratingClass
} : {
ratingClass: "starNormal"
});
return ratingClassArray
},
showHideCountryList: function(type, editCountryWrap) {
var myProfileModel = $("#client-myprofile-view");
"hide" === type ? (editCountryWrap.find(".zrc-dropdown").hide(), myProfileModel.attr("style", "height: auto;overflow: auto;max-height: 542px;"), myProfileModel.find(".popup-model-content, #cde").removeAttr("style")) : "show" === type && (editCountryWrap.find(".zrc-dropdown").show().css("top", "100%"), myProfileModel.attr("style", "height: auto;overflow: inherit;max-height: 542px;"), myProfileModel.find(".popup-model-content, #cde").attr("style", "overflow: inherit;"))
},
showPeoplePlusAlert: function(page, returnJson) {
if (page && "detail" === page) {
if ($("#crm-msg").remove(), returnJson && returnJson.deletedFromPeople && "1" === returnJson.deletedFromPeople) {
var msg = I18n.getMsg("zr.pp.dept.detailpage.deleted.msg", Crm.moduleInfo.Accounts[0]),
params = {
removefreeze: !1,
type: "warning",
scroll: !1,
baseid: "error-alert-message",
msg: msg,
display: "inline",
displayId: "detailViewButtonLayerDiv"
};
ZRComponent.openAlertMessage(params), $("#error-alert-message").removeClass("marT20").addClass("mar10 marB0")
}
} else if (page && "list" === page) {
var msg = I18n.getMsg("zr.pp.dept.listpage.addmodify.msg", Crm.moduleInfo.Accounts[0]);
crmui.showMsgBand("info", msg, 1e4, void 0, "noAnimation"), $("#crm-msg").css("box-shadow", "none")
}
},
deletePortalName: function() {
var elem = Utils.createHTML({
name: "div",
child: [{
name: "p",
attr: {
"class": "f15 pT10 pB10 redTxt"
},
text: "Note: Please don't do any operations in this page without proper knowledge."
}, {
name: "div",
attr: {
"class": "zrc-form-row"
},
child: [{
name: "label",
child: [{
name: "div",
attr: {
"class": "wf_requiredMark"
},
text: "Enter the reson for deleting the portal name"
}]
}, {
name: "div",
attr: {
"class": "zrc-value pB0"
},
child: [{
name: "textarea",
attr: {
id: "reason",
name: "reason",
"class": "cryTextArea cl-note-textarea",
maxlength: "600",
"data-uitype": "110"
}
}]
}]
}]
});
return ZRCommonUtil.createModal({
modalid: "deletePortalNamePopup",
modalclass: "w700 dN",
contentClass: "pB0",
title: "Delete Portal",
removefreeze: !0,
content: elem,
savebtn: I18n.getMsg("Delete"),
saveclass: "redbtn",
savefn: function(ev, target) {
var reason = $("#reason").val();
return reason.length > 3 ? ($("#delReason").val(reason), ZRCommonUtil.closeDialog(ev, target, "#deletePortalNamePopup"), document.forms.deletePortalName.submit(), void 0) : (crmui.showMsgBand("error", "Enter the reason for deleting the portal", 5e3), !1)
},
callback: function() {
$("#deletePortalNamePopup .popup-model-content").removeClass("pB0")
}
}), !1
},
showHideInterviewDet: function(thisObj) {
$(thisObj).hasClass("creatint-active-tab") || ($(".creatint-tab-review").removeClass("creatint-active-tab"), $(".creatint-tab-detail").addClass("creatint-active-tab"), $("#interviewReviewDiv").empty(), $("#viewentityformdiv").show())
},
notifyOnBoardingTeam: function(type) {
var urlData = {};
urlData.type = type, ZRCommonUtil.ajaxPostMethod("/recruit/NotifyToOnBoardingTeam.do", urlData, !1, "json", void 0, function(json) {
json = ZRCommonUtil.convertStringToJson(json), json && json.isNotified && $(".micsclose").click()
}, function(xhr, pasteDiv) {
ZRCommonUtil.failureFunction(xhr, pasteDiv)
})
},
setDefaultOutlookVerison: function(txt) {
$("#result").html(txt);
var osVersion = Browser.OSName;
"Mac" === osVersion ? $("#versionlist").val("2011").trigger("change") : "Windows" === osVersion && $("#versionlist").val("201064").trigger("change")
},
removeActionsFromDetailPageforApprovals: function() {
var linksToBeRemoved_Personalities = ZRCommonUtil.getRelatedListNameVsId();
delete linksToBeRemoved_Personalities.smspersonality, delete linksToBeRemoved_Personalities.emailspersonality;
var moreActionsToBeRemoved_Ids = ["customButtonDetails", "newleft_AssoCand", "candidateAssociation", "cutomizeMacroLink", "newRelatedListDiv", "fullInfoNoteDiv", "convert_details", "toggleNotes > #zciFieldMap", "singleGenerateFormattedResumeId", "FindInIndeedLInk", "associatedTags li a, #associate-tagshow, a#createlink, div.normalDropDown, div#customlinkcount span"],
moreActionsToBeRemoved_Names = ["mailmerge", "Duplicate2", "Convert2", "Clone", "Delete2", "restrictProcessing"],
moreActionsToBeRemoved_Class = ["notesActionbtn", "notesActionbtnDel", "notesArrowDownNew", "addNewIcP", "typeedit", "dd-sep", "calliconOuter", "relJobPublishId", "generateOfferLetter"],
moreActionsToBeRemoved_CallIds = ["relAssociateExistingJOId", "relClientSubmissionId", "relCreateNewProductId", "requestGDPRConsent"];
ZRCommonUtil.removeRelatedListActionsByPersonalityName(linksToBeRemoved_Personalities), ZRCommonUtil.removeMoreActions(moreActionsToBeRemoved_Ids, moreActionsToBeRemoved_Names, moreActionsToBeRemoved_Class, moreActionsToBeRemoved_CallIds)
},
removeLinksFromDetailPageforApprovals: function() {
var linksToBeRemoved_Personalities = ZRCommonUtil.getRelatedListNameVsId();
delete linksToBeRemoved_Personalities.smspersonality, delete linksToBeRemoved_Personalities.emailspersonality, delete linksToBeRemoved_Personalities.attachmentspersonality;
var moreActionsToBeRemoved_Ids = ["cutomizeMacroLink", "newRelatedListDiv", "convert_details", "singleGenerateFormattedResumeId", "FindInIndeedLInk", "associatedTags li a, #associate-tagshow, a#createlink, div.normalDropDown, div#customlinkcount span"],
moreActionsToBeRemoved_Names = ["mailmerge", "Duplicate2", "Convert2"];
ZRCommonUtil.removeRelatedListActionsByPersonalityName(linksToBeRemoved_Personalities), ZRCommonUtil.removeMoreActions(moreActionsToBeRemoved_Ids, moreActionsToBeRemoved_Names)
},
toggleClearLookupfield: function(mode, target) {
mode ? target.parent("div").find(".clear_lookupfield").show() : target.parent("div").find(".clear_lookupfield").hide()
},
getFormattedDateTimeInUserPattern: function(date) {
var time,
timezone,
dateObj = {};
if (date && null != date && date.indexOf("T") > -1) {
var time = date.split("T")[1];
date = date.split("T")[0];
var timezone = "";
time.indexOf("-") > -1 ? (timezone = "-" + time.split("-")[1], time = time.split("-")[0]) : time.indexOf("+") > -1 && (timezone = "+" + time.split("+")[1], time = time.split("+")[0]), time = time.substring(0, time.lastIndexOf(":")), date = Utils.getDateInUserDatePattern(new Date(date)), "hh:mm a" === Crm.userDetails.TIME_FORMAT && (time = Lyte.Component.registeredHelpers.getTimeIn12Format(time))
}
return dateObj = {
date: date,
time: time,
timezone: timezone
}
}
};
!function($) {
function getOptionObj(optElem) {
var optionObj = {},
value = optElem.val(),
label = optElem.text(),
data = optElem.data();
return optionObj.value = value, optionObj.label = label, $.isEmptyObject(data) || (data.icon ? optionObj.icon = data.icon : data.img && (optionObj.src = data.img)), optionObj
}
function getData(elem) {
var optionArr = [];
return elem.children().each(function(i, item) {
var optElem = $(item),
nodeName = $(item)[0].nodeName;
if ("OPTION" === nodeName)
optionArr.push(getOptionObj(optElem));
else if ("OPTGROUP" === nodeName) {
var groupObj = {},
groupArr = [],
label = optElem[0].label;
optElem.children().each(function(j, optItem) {
groupArr.push(getOptionObj($(optItem)))
}), groupObj[label] = groupArr, optionArr.push(groupObj)
}
}), optionArr
}
function getSelectedVal(elem) {
var optionVal = void 0;
return elem.find("option:selected").each(function(i, item) {
var val = $(item).val();
optionVal = void 0 === optionVal ? val : optionVal + ";" + val
}), optionVal
}
var Selectbox = function(element, options) {
this._listen(element, options)
};
Selectbox.prototype = {
constructor: Selectbox,
_listen: function(element, options) {
this.options = options, this.$element = $(element), this._create()
},
_getEllipsisVal: function(value, maxLen) {
var obj = {},
dotVal = value,
objLen = parseInt(maxLen),
titleStr = "";
return value && null != value && "null" != value && value.length > objLen && (dotVal = value.substring(0, objLen), dotVal += "...", titleStr = value), obj.dotVal = dotVal, obj.title = titleStr, obj
},
_getElement: function(type, item) {
var elem = void 0;
switch (type) {
case "icon":
elem = $("<i>").addClass(item.icon).data("value", item.value);
break;
case "image":
elem = $("<img>").attr("src", item.src).data("value", item.value)
}
return elem
},
_inArray: function(valArr, val) {
var index = -1;
return $.each(valArr, function(i, value) {
value.trim().toLowerCase() === val.trim().toLowerCase() && (index = i)
}), index
},
_getMenuItem: function(item) {
var menuElem = $(this.options.menu),
value = this.options.val,
valArr = value ? value.split(";") : "";
if (menuElem.data("label", item.label).data("value", item.value).data("role", "list"), this._isDefault() && this._inArray(valArr, item.value) > -1 && menuElem.addClass(this.options.disabled ? ClassName.HIDDEN : ClassName.ACTIVE), menuElem.text(this._getEllipsisVal(item.label, this.options.maxlen).dotVal), !/^(text)$/.test(this.options.type)) {
var typeElem = this._getElement(this.options.type, item);
typeElem && menuElem.prepend(typeElem)
}
return menuElem.attr("tabindex", "-1").attr("title", this._getEllipsisVal(item.label, this.options.maxlen).title), menuElem
},
_getGroupItem: function(label) {
var groupElem = $(this.options.menu);
return groupElem.addClass(ClassName.TITLE).text(this._getEllipsisVal(label, this.options.maxlen).dotVal).attr("title", this._getEllipsisVal(label, this.options.maxlen).title).data("label", label), groupElem
},
_getItem: function() {
var base = this,
frag = document.createDocumentFragment();
return $.each(this.options.item, function(i, opt) {
opt.hasOwnProperty("label") ? frag.appendChild(base._getMenuItem(opt)[0]) : $.each(opt, function(label, groupItem) {
frag.appendChild(base._getGroupItem(label)[0]), $.each(groupItem, function(index, optItem) {
frag.appendChild(base._getMenuItem(optItem)[0])
})
})
}), frag
},
_getLabel: function() {
var title = "",
base = this,
value = this.options.val,
valArr = value ? value.split(";") : "";
return $.each(this.options.item, function(i, opt) {
opt.hasOwnProperty("label") ? base._inArray(valArr, opt.value) > -1 && (title = 0 === title.length ? opt.label : opt.label + "," + title) : $.each(opt, function(label, groupItem) {
$.each(groupItem, function(index, optItem) {
base._inArray(valArr, optItem.value) > -1 && (title = 0 === title.length ? optItem.label : optItem.label + "," + title)
})
})
}), title
},
_getTitle: function() {
var item = this.options.item,
title = this._isDefault() ? this._getLabel() : "";
return title && title.length > 0 ? title : item.length > 0 ? item[0].label : ""
},
position: function() {
var base = $(this).data("selectbox");
base._getPosition()
},
_getPosition: function() {
var $this = $(this._baseElem),
$drop = $(this._dropdown),
$dropdownParent = this.options.parent,
elemPos = $this.offset(),
elemHt = $this.innerHeight(),
elemOht = $this.outerHeight();
dropDownHt = $drop.outerHeight(), dropDownWd = $drop.outerWidth(), windHt = window.innerHeight, windWd = window.innerWidth, scrollHeight = $(window).scrollTop();
var css = {
top: elemPos.top + elemOht,
left: elemPos.left
};
if (void 0 !== $dropdownParent && 0 !== $dropdownParent.length) {
var parentPos = $dropdownParent.offset();
css.top -= parentPos.top
}
elemHt + elemPos.top + dropDownHt > windHt + scrollHeight && (css.top = elemPos.top - dropDownHt), elemPos.left + dropDownWd > windWd && (css.left = elemPos.left - dropDownWd), this._dropdown.css({
top: css.top + "px",
left: css.left + "px"
})
},
_isDefault: function() {
var value = this.options.val;
return void 0 !== value && 0 !== value.trim().length ? !0 : !1
},
_removeValue: function(value) {
var elem = $(this.$element);
if ("SELECT" === elem[0].nodeName && value && 0 !== value.length) {
var valArr = value.split(";");
valArr.length > 1 ? $.each(valArr, function(i, val) {
elem.find("option[value='" + val + "']").prop("selected", !1)
}) : elem.find("option[value='" + value + "']").prop("selected", !1), elem.trigger("change")
}
},
_setValue: function(value) {
var elem = $(this.$element);
if ("SELECT" === elem[0].nodeName && value && 0 !== value.length) {
var valArr = value.split(";");
valArr.length > 1 ? $.each(valArr, function(i, val) {
elem.find("option[value='" + val + "']").prop("selected", !0)
}) : elem.find("option[value='" + value + "']").prop("selected", !0), elem.trigger("change")
}
},
_getBaseClass: function() {
return this.options.box ? ClassName.BOX : ClassName.LINE
},
_getSpanClass: function() {
return this.options.box ? "" : ClassName.SPAN
},
_clearSelect: function() {
var $element = this.$element;
$element.val(this.options.multiple ? [] : ""), $element.find("option:selected").removeProp("selected")
},
_create: function() {
var baseClass = this._getBaseClass(),
spanClass = this._getSpanClass(),
item = this._getItem(),
title = this._getTitle(),
itemLen = item.childElementCount,
id = this.$element[0].id && this.$element[0].id.length > 0 ? this.$element[0].id : this.$element[0].name,
scroll = this.options.scroll,
tabIndex = this.$element[0].tabIndex,
tabIndex = void 0 === tabIndex ? "1" : tabIndex;
this._baseElem = $(this.options.template), this._baseElem.attr("id", id + "-sbox").data("dropid", "#" + id + "-slist").addClass(baseClass).attr("tabIndex", tabIndex);
{
var child = this._baseElem.children();
child[1]
}
if (this._title = child[0], $(this._title).text(this._getEllipsisVal(title, this.options.maxlen).dotVal).addClass(spanClass).attr("title", this._getEllipsisVal(title, this.options.maxlen).title).attr("id", id + "-svalue"), this._dropdown = $(this.options.dropdown), this._dropdown.find(Selector.UL).html(item).attr("id", id + "-slist").addClass(this.options.ulclass ? this.options.ulclass : ClassName.ULCLASS), this.options.extraCreateOptionName) {
var createExtrOptEle = Utils.createHTML({
name: "div",
attr: {
"class": "cbCreateView w100p p0"
},
child: [{
name: "a",
attr: {
"class": "cP pL30 pTB6 dB padR30 extraCreateOpt"
},
html: this.options.extraCreateOptionName
}]
});
this._dropdown.find(Selector.UL).after(createExtrOptEle)
}
if (1 === itemLen) {
var $li = this._dropdown.find(Selector.LI);
this.options.val = $li.data("value"), $li.addClass(this.options.disabled ? ClassName.HIDDEN : ClassName.ACTIVE)
}
if (this.$element.is(Selector.VISIBLE) || this._baseElem.attr("style", "display:none"), this.$element.data("target", "#" + id + "-sbox").hide(), 0 !== $(this.appendto).length ? $(this.appendto).after(this._baseElem) : this.$element.after(this._baseElem), $("body").append(this._dropdown), itemLen > this.options.searchlimit && $(this._dropdown).prepend($(this.options.search).attr("id", id + "-ssearch")), this._isDefault() || this._clearSelect(), this.options.multiple && this.$element.attr("multiple", !0), this._bindEvent(), this._isDefault()) {
var $liElem = this._dropdown.find(Selector.LI),
$li = $liElem.filter(this.options.disabled ? Selector.HIDDEN : Selector.ACTIVE),
selected = [],
value = void 0;
$.each($li, function(i, elem) {
value = value ? $(elem).data("value") + ";" + value : $(elem).data("value");
var obj = {
label: $(elem).data("label"),
value: $(elem).data("value")
};
selected.push(obj)
}), this._baseElem.data("selected", selected), selected.length > 1 && this.$element.attr("multiple", !0)
}
!$.isEmptyObject(scroll) && this.isFunction(scroll.fn) && (this._dropdown.find(Selector.UL).data("scroll", scroll), this._scroll()), this._callback("create")
},
_bindEvent: function() {
var base = this;
this._baseElem.on("click.sbox", function(event) {
var tgt = $(event.target);
(tgt.is(base._baseElem) || tgt.parent().is(base._baseElem)) && (base.hide(), base.toggle())
}).on("keydown.sboxlistkey", function(event) {
var $drop = base._dropdown.is(Selector.VISIBLE) ? base._dropdown.find(Selector.LI) : base._dropdown.siblings().filter(Selector.UL).find(Selector.LI),
$selli = $drop.filter(Selector.SELECTED),
$li = 0 === $selli.length ? $drop[0] : $selli[0];
base._keypress($li, event)
}).on("focus", function(event) {
base._callback("focus", $(event.target))
}).on("blur", function(event) {
base._callback("blur", $(event.target))
}), this._dropdown.on("click.sdrop", function(event) {
var tgt = $(event.target);
tgt.is("li") && base._selectItem(event.target)
}).on("keydown.sdropkey", function(event) {
var $drop = base._dropdown.is(Selector.VISIBLE) ? base._dropdown.find(Selector.LI) : base._dropdown.siblings().filter(Selector.UL).find(Selector.LI),
$li = /input/i.test(event.target.tagName) ? $drop[0] : event.target;
base._keypress($li, event)
}).on("keyup.sinputkey", function(event) {
var tgt = $(event.target);
tgt.is("input") && (clearTimeout(base.options.userCompTimeoutId), base.options.userCompTimeoutId = setTimeout(function() {
base.search(event)
}, base.options.searchDelay))
}).on("click", ".extraCreateOpt", function(event) {
base._callback("extraCreateOpt", $(event.target))
})
},
_keypress: function($li, jEve) {
var base = this;
switch (event.keyCode) {
case 40:
base._next($li);
break;
case 38:
base._prev($li);
break;
case 32:
case 13:
$(jEve.target).is($("li")) && base._enter($li);
break;
case 27:
base._escape()
}
},
_scroll: function() {
var base = this;
this._dropdown.find(Selector.UL).unbind("scroll").bind("scroll", function() {
var $this = $(this),
data = $this.data("scroll");
data = data ? data : {}, data && "string" == typeof data && (data = JSON.parse(data));
var height = this.scrollHeight - $this.height(),
scroll = $this.scrollTop(),
isScrolledToEnd = scroll >= height - 10;
if (isScrolledToEnd && data && data.shownext) {
var args = [];
args.unshift(base), data.fn.apply(this, args)
}
})
},
autoComplete: function(data) {
var id = this.$element[0].id && this.$element[0].id.length > 0 ? this.$element[0].id : this.$element[0].name,
scroll = this._dropdown.data("scroll");
if (this._dropdown.find(Selector.UL).nextAll("[id$=sautores]").remove(), this._dropdown.find(Selector.UL).hide(), $.isEmptyObject(data)) {
var searchUl = this._dropdown.find(Selector.UL).clone().html($(this.options.menu).text(this.options.message).addClass(ClassName.ERROR));
this._dropdown.find(Selector.UL).after(searchUl.attr("id", id + "-sautores").show())
} else {
var base = this,
frag = document.createDocumentFragment();
$.each(data, function(i, opt) {
opt.hasOwnProperty("label") ? frag.appendChild(base._getMenuItem(opt)[0]) : $.each(opt, function(label, groupItem) {
frag.appendChild(base._getGroupItem(label)[0]), $.each(groupItem, function(index, optItem) {
frag.appendChild(base._getMenuItem(optItem)[0])
})
})
});
var searchUl = this._dropdown.find(Selector.UL).clone().html(frag);
this._dropdown.find(Selector.UL).after(searchUl.attr("id", id + "-sautores").show()), !$.isEmptyObject(scroll) && this.isFunction(scroll.fn) && (this._dropdown.find(Selector.UL).nextAll("[id$=sautores]").data("scroll", scroll), this._scroll())
}
this._getPosition()
},
refresh: function(data) {
var obj = getData(this.$element),
obj = obj && 0 !== obj.length ? obj : [],
value = void 0,
selected = [],
selected = this._baseElem.data("selected"),
selected = selected ? selected : [];
if (!$.isEmptyObject(data)) {
var frag = document.createDocumentFragment();
$.each(data, function(i, opt) {
var option = $("<option>"),
group = $("<optgroup>");
if (opt.hasOwnProperty("label"))
option.attr("value", opt.value).text(opt.label), frag.appendChild(option[0]), obj.push(opt);
else {
var groupObj = {},
groupArr = [];
$.each(opt, function(label, groupItem) {
group.attr("label", label), frag.appendChild(group[0]), $.each(groupItem, function(index, optItem) {
option.attr("value", optItem.value).text(optItem.label), frag.appendChild(option[0]), groupArr.push(optItem)
}), groupObj[label] = groupArr, obj.push(groupObj)
})
}
}), $(this.$element).append(frag)
}
this.options.item = obj, $.each(selected, function(i, item) {
value = void 0 === value ? item.value : item.value + ";" + value
}), this.options.val = value ? value : "", this._dropdown.find(Selector.UL).filter(Selector.VISIBLE).html(this._getItem()), this._getPosition()
},
_clearSearch: function() {
var $li = this._dropdown.find(Selector.LI);
this._dropdown.find(Selector.INPUT).val(""), $li.filter(Selector.ERROR).remove(), $li.show()
},
_callback: function(type, curElem) {
var callback = this.options.callback;
this.isFunction(callback) && callback(type, this, curElem)
},
isFunction: function(fn) {
return "function" == typeof fn ? !0 : !1
},
enable: function() {
var base = $(this).data("selectbox");
base._baseElem.removeClass(ClassName.ENABLE), base._callback("enable", base._baseElem)
},
disable: function() {
{
var base = $(this).data("selectbox");
base.options.callback
}
base._baseElem.addClass(ClassName.ENABLE), base._callback("disable", base._baseElem)
},
_openItem: function() {
this._clearSearch(), this._dropdown.find(Selector.UL).nextAll("[id$=sautores]").remove(), this._dropdown.find(Selector.UL).show(), this._dropdown.removeClass(ClassName.NONE);
var $parent = this._dropdown,
$input = $parent.find(Selector.INPUT),
$li = $parent.find(Selector.LI),
$notactive = $parent.find(Selector.NOTACTIVE),
$notactive = 0 !== $notactive.length ? $notactive.filter(Selector.NOTTITLE) : $notactive,
$nothidden = $parent.find(Selector.NOTHIDDEN),
$nothidden = 0 !== $nothidden.length ? $nothidden.filter(Selector.NOTTITLE) : $nothidden,
$hidd = $li.filter(Selector.HIDDEN),
$active = $li.filter(Selector.ACTIVE),
first = $li[0],
selected = 0 !== $hidd.length ? $hidd[0] : 0 !== $active.length ? $active[0] : $(first).hasClass(ClassName.TITLE) ? $(first).next() : first;
$li.removeClass(ClassName.SELECTED), !this.options.multiple && (this.options.disabled && 0 === $nothidden.length || 0 === $notactive.length) ? ($li.hide(), this._dropdown.find(Selector.UL).append($(this.options.menu).text(this.options.message).addClass(ClassName.ERROR))) : $(selected).addClass(ClassName.SELECTED), this._getPosition(), 0 !== $input.length ? $input.focus() : this._baseElem.focus(), this._callback("open", $(this))
},
open: function() {
var base = $(this).data("selectbox");
return base._baseElem.hasClass(ClassName.ENABLE) ? !1 : void base._openItem()
},
toggle: function() {
return this._baseElem.hasClass(ClassName.ENABLE) ? !1 : void (this._dropdown.hasClass(ClassName.NONE) ? this._openItem() : this._closeItem())
},
hide: function() {
var base = this;
$("." + base._getBaseClass()).each(function(i, element) {
var otherId = $(element).data("dropid");
base._baseElem.data("dropid") !== otherId && $(otherId).parent().addClass(ClassName.NONE)
})
},
_closeItem: function() {
this._dropdown.addClass(ClassName.NONE), this._dropdown.find(Selector.LI).removeClass(ClassName.SELECTED), this._callback("close", $(this))
},
close: function() {
var base = $(this).data("selectbox");
base._closeItem()
},
clear: function() {
var base = $(this).data("selectbox"),
title = base._getTitle(),
item = base.options.item;
base._baseElem.removeData("selected"), base._clearSelect(), title && title.length > 0 ? title : item.length > 0 ? item[0].label : "", $(base._title).text(title)
},
destory: function() {
var base = $(this).data("selectbox");
base._baseElem.remove(), base._dropdown.remove(), $(this).removeData("selectbox")
},
clearMenus: function(event) {
var tgt = $(event.target);
tgt.not(Selector.SPAN) && (tgt.parent().not(Selector.BASE) || tgt.parent().not(Selector.LINE)) && tgt.find(Selector.DROPDOWN).addClass(ClassName.NONE)
},
_getDisplayTitle: function(obj) {
var title = void 0,
base = this;
return $.each(obj, function(i, item) {
var label = item.label,
label = label ? label.trim() : "",
label = base._getPlaceHolder(label);
title = label ? title ? title + "," + label : label : ""
}), title ? title : ""
},
_removeObj: function(obj, arr) {
for (var i = 0; i < arr.length; i++) {
var item = arr[i];
obj.value.trim() === item.value.trim() && arr.splice(i, 1)
}
return arr
},
_getPlaceHolder: function(title) {
var text = void 0,
defaultTitle = this.options.placeholder ? this.options.placeholder : "",
placeholder = defaultTitle && 0 !== defaultTitle.length ? defaultTitle : "";
return title.trim().toLowerCase() !== placeholder.trim().toLowerCase() && (text = title), text
},
createSearchOption: function($this) {
var base = this,
$ul = this._dropdown.find(Selector.UL).first(),
option = $(base.$element).find("option")[0],
optgroup = $(base.$element).find("optgroup")[0],
$searchul = this._dropdown.find(Selector.UL).nextAll("[id$=sautores]"),
selectedVal = $(base.$element).find(":selected").val();
if (selectedVal = selectedVal ? selectedVal.trim() : selectedVal, 0 !== $searchul.length && $searchul.is(Selector.VISIBLE)) {
if ($this.data("value").trim() === selectedVal)
return;
$ul.find(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
var isGrouped = void 0 !== optgroup,
ttl = $this.prevUntil(Selector.TITLE);
ttl = 0 === ttl.length ? $this.prev() : ttl.prev();
var ttlPresent = !1;
if (isGrouped)
$.each($ul.find(Selector.GROUPLI), function(i, item) {
if ($(item).data("label").trim() === ttl.data("label").trim()) {
var $opt = $(item).nextUntil(Selector.TITLE);
$.each($opt, function(o, optItem) {
$(optItem).data("value").trim() !== $this.data("value").trim() && ($(optItem).after($this.clone().data("label", $this.data("label")).data("value", $this.data("value")).data("role", "search")), $(base.$element).find("optgroup[label='" + ttl.data("label") + "']").append($(option).clone().text($this.data("label")).attr("label", $this.data("label")).attr("value", $this.data("value"))))
}), ttlPresent = !0
}
}), ttlPresent || ($ul.append(ttl.clone().data("label", ttl.data("label"))), $ul.append($this.clone().data("label", $this.data("label")).data("value", $this.data("value")).data("role", "search")), $(base.$element).append($(optgroup).clone().attr("label", ttl.data("label")).html($(option).clone().text($this.data("label")).attr("label", $this.data("label")).attr("value", $this.data("value")))));
else {
var thsOption = [{
value: $this.data("value"),
label: $this.data("label")
}],
matchh = $.grep(this.options.item, function(i) {
return JSON.stringify(thsOption[0]) === JSON.stringify(i)
});
matchh.length <= 0 ? (this.options.item = $.merge(thsOption, this.options.item), $(base.$element).prepend($(option).clone().text($this.data("label")).attr("label", $this.data("label")).attr("value", $this.data("value"))), $ul.prepend($this.clone().data("label", $this.data("label")).data("value", $this.data("value")).data("role", "list"))) : $ul.find("li").filter(function() {
return $(this).data("value") === $this.data("value")
}).addClass(ClassName.ACTIVE)
}
ttlPresent || ($ul.append(ttl.clone().data("label", ttl.data("label"))), $ul.append($this.clone().data("label", $this.data("label")).data("value", $this.data("value")).data("role", "search")), $(base.$element).append($(optgroup).clone().attr("label", ttl.data("label")).html($(option).clone().text($this.data("label")).attr("label", $this.data("label")).attr("value", $this.data("value")))))
}
},
removeSearchOption: function($this) {
var base = this,
$ul = this._dropdown.find(Selector.UL).first(),
$searchul = this._dropdown.find(Selector.UL).nextAll("[id$=sautores]");
0 !== $searchul.length && $searchul.is(Selector.VISIBLE) && $.each($ul.find(Selector.NOTTITLE), function(i, item) {
if ($(item).data("label").trim() === $this.data("label").trim()) {
var resttl = $(item).prevUntil(Selector.TITLE),
resttl = 0 === resttl.length ? $(item).prev() : $(resttl[0]).prev();
$(base.$element).find("option[value='" + $(item).data("value") + "']").remove(), $(item).remove(), 0 === resttl.nextUntil(Selector.TITLE).length && ($(base.$element).find("optgroup[label='" + resttl.data("label") + "']").remove(), resttl.remove())
}
})
},
_selectItem: function(tgt) {
var $this = $(tgt),
base = this,
label = $this.data("label"),
label = label ? label.trim() : "",
value = $this.data("value"),
obj = {},
placeholder = this._getPlaceHolder(label),
display = "";
if (obj.label = label, obj.value = value, !$this.hasClass(ClassName.TITLE) && !$this.hasClass(ClassName.ERROR) && void 0 != placeholder)
if ($this.hasClass(ClassName.HIDDEN) || $this.hasClass(ClassName.ACTIVE)) {
if (this.options.multiple) {
var selected = this._baseElem.data("selected"),
selected = selected ? selected : [];
if (-1 !== this.options.maxselect && selected.length > this.options.maxselect)
return void this._callback("maxerror", $this);
$this.removeClass(this.options.disabled ? ClassName.HIDDEN : ClassName.ACTIVE), selected = this._removeObj(obj, selected), display = this._getDisplayTitle(selected), this._baseElem.data("selected", selected), $(this._title).text(this._getEllipsisVal(display, this.options.maxlen).dotVal).attr("title", this._getEllipsisVal(display, this.options.maxlen).title), this.removeSearchOption($this), this._removeValue(value), this._callback("remove", $this)
}
} else {
if (this.options.multiple) {
var selected = this._baseElem.data("selected"),
selected = selected ? selected : [];
if (-1 !== this.options.maxselect && selected.length > this.options.maxselect)
return void this._callback("maxerror", $this);
$this.addClass(this.options.disabled ? ClassName.HIDDEN : ClassName.ACTIVE), display = this._getDisplayTitle(selected), display = display ? display + "," + label : label, selected.push(obj), this._baseElem.data("selected", selected), $(this._title).text(this._getEllipsisVal(display, this.options.maxlen).dotVal).attr("title", this._getEllipsisVal(display, this.options.maxlen).title), this.createSearchOption($this), $.each(selected, function(i, item) {
var $dropli = base._dropdown.find(Selector.UL).find("li[data-value='" + item.label + "']");
0 !== $dropli.length && $dropli.addClass(this.options.disabled ? ClassName.HIDDEN : ClassName.ACTIVE)
})
} else {
var selected = [];
selected.push(obj), $this.addClass(this.options.disabled ? ClassName.HIDDEN : ClassName.ACTIVE), this._baseElem.data("selected", selected), $(this._title).text(this._getEllipsisVal(label, this.options.maxlen).dotVal).attr("title", this._getEllipsisVal(label, this.options.maxlen).title), $this.siblings().removeClass(this.options.disabled ? ClassName.HIDDEN : ClassName.ACTIVE), this.createSearchOption($this), this._closeItem()
}
this._setValue(value), this._callback("select", $this)
}
},
_nextNode: function(elem, $first) {
var $next = elem && 0 !== elem.length ? elem.hasClass(ClassName.TITLE) ? this._nextNode(elem.next()) : elem.is(Selector.VISIBLE) ? elem : this._nextNode(elem.next()) : $first;
return $next
},
_prevNode: function(elem, $last) {
var $prev = elem && 0 !== elem.length ? elem.hasClass(ClassName.TITLE) ? this._prevNode(elem.prev()) : elem.is(Selector.VISIBLE) ? elem : this._prevNode(elem.prev()) : $last;
return $prev
},
_next: function(elem) {
var $this = $(elem),
$first = $this.siblings().first(),
$first = this._nextNode($first),
$next = $this.next(),
$next = 0 !== $next.length ? this._nextNode($next, $first) : $next,
selected = $next && 0 !== $next.length ? $next : $first;
$this.removeClass(ClassName.SELECTED), $(selected).addClass(ClassName.SELECTED).focus()
},
_prev: function(elem) {
var $this = $(elem),
$last = $this.siblings().last(),
$last = this._prevNode($last),
$prev = $this.prev(),
$prev = 0 !== $prev.length ? this._prevNode($prev, $last) : $prev,
selected = $prev && 0 !== $prev.length ? $prev : $last;
$this.removeClass(ClassName.SELECTED), $(selected).addClass(ClassName.SELECTED).focus()
},
_enter: function($li) {
if (this._dropdown.hasClass(ClassName.NONE)) {
if (this._baseElem.hasClass(ClassName.ENABLE))
return !1;
this._dropdown.removeClass(ClassName.NONE), this._openItem()
} else
this._selectItem($li)
},
_escape: function() {
this._closeItem()
},
search: function(event) {
var searchFn = this.options.searchfn,
$input = $(event.target),
$li = this._dropdown.find(Selector.NOTTITLE),
value = $input.val();
if (this.isFunction(searchFn))
if (void 0 !== value && 0 !== value.length && value.length <= 25) {
var args = [];
args.unshift(this), searchFn.apply(this, args)
} else
this._dropdown.find(Selector.UL).first().show(), this._dropdown.find(Selector.UL).nextAll("[id$=sautores]").remove();
else
$li.filter(Selector.ERROR).remove(), this._dropdown.find(Selector.LI).show(), void 0 !== value && 0 !== value.length && value.length <= 25 && (value = value.toLowerCase(), $li.each(function() {
if (!$(this).hasClass(ClassName.TITLE) && !$(this).hasClass(ClassName.ERROR)) {
var name = $(this).data("label");
if (void 0 !== name && 0 !== name.length) {
if (name = name.toLowerCase(), name.indexOf(value) >= 0)
return $(this).show(), !0;
$(this).hide()
}
}
}), 0 === $li.filter(Selector.VISIBLE).length ? ($li.filter(Selector.ERROR).remove(), this._dropdown.find(Selector.GROUPLI).hide(), this._dropdown.find(Selector.UL).append($(this.options.menu).text(this.options.message).addClass(ClassName.ERROR))) : $.each(this._dropdown.find(Selector.GROUPLI), function(i, item) {
0 === $(item).nextUntil(Selector.TITLE).filter(Selector.VISIBLE).length && $(item).hide()
})), this._getPosition(), this._callback("searchCallBack", $(event.target))
},
_stopEvent: function(e) {
return e.stopPropagation(), e.preventDefault(), !1
},
selectAnOption: function() {
var base = $(this).data("selectbox"),
_dropdown = base._dropdown ? base._dropdown.find(Selector.LI) : void 0,
optVal = base.optVal,
selectedOption = base._baseElem.data("selected") ? base._baseElem.data("selected") : [];
_dropdown && optVal && (_dropdown.removeClass(base.options.disabled ? ClassName.HIDDEN : ClassName.ACTIVE), $.each(_dropdown, function(i, li) {
var optvalue = $(li).data("value"),
liData = $(li).data();
optvalue === optVal && ($(li).addClass(base.options.disabled ? ClassName.HIDDEN : ClassName.ACTIVE), base.options.multiple ? selectedOption.push(liData) : selectedOption = liData, base._baseElem.find("span").text($(li).html()), base._baseElem.data("selected", selectedOption))
}))
}
}, $.fn.selectBox = function(option) {
return this.each(function() {
var $this = $(this),
data = $this.data("selectbox"),
options = $.extend({}, $.fn.selectBox.defaults, $this.data(), "object" == typeof option && option);
if (options.item = 0 === options.item.length ? getData($this) : options.item, options.multiple = options.multiple === !1 ? $this.attr("multiple") ? !0 : !1 : options.multiple, options.val = 0 === options.val.length ? getSelectedVal($this) : options.val, data || $this.data("selectbox", data = new Selectbox(this, options)), "string" == typeof option) {
if (void 0 === data[option])
throw new Error('No method named "' + option + '"');
data[option].call(this)
}
})
};
var ClassName = {
TITLE: "ttl",
DROPUP: "selup",
DROPRIGHT: "rig0",
SELECTED: "sel",
HIDDEN: "hidd",
ACTIVE: "active",
DISABLE: "disable",
ENABLE: "inv",
ULCLASS: "maxH200",
NONE: "disN",
ERROR: "err",
BOX: "zrc-select-box",
LINE: "zrc-value zrc-selectbox",
SPAN: "zrc-select-value"
},
Message = {
NOOPTION: "No options found"
},
Selector = {
TITLE: ".ttl",
DROPDOWN: ".zrc-dropdown",
ACTIVE: ".active",
HIDDEN: ".hidd",
UL: "ul",
LI: "li",
DISPLAYSPAN: "span",
SELECTED: ".sel",
BASE: ".zrc-select-box",
LINE: ".zrc-selectbox",
SPAN: ".zrc-select-value",
NOTACTIVE: "li:not(.active)",
NOTHIDDEN: "li:not(.hidd)",
NOTTITLE: "li:not(.ttl)",
GROUPLI: "li.ttl",
INPUT: "input",
ERROR: ".err",
ENABLE: ".inv",
VISIBLE: ":visible"
};
$.fn.selectBox.defaults = {
item: [],
val: "",
scroll: {},
disabled: !1,
box: !0,
searchlimit: 10,
maxlen: 25,
maxselect: -1,
multiple: !1,
userCompTimeoutId: void 0,
searchDelay: 300,
type: "text",
placeholder: "-None-",
message: Message.NOOPTION,
menu: "<li></li>",
search: "<input type='search' maxlength='25' placeholder='Search'/>",
dropdown: "<div data-close=true class='disN zrc-dropdown'><ul class='oveA'></ul>",
template: "<div><span></span></div></div>"
}, $.fn.selectBox.Constructor = Selectbox, $(function() {
$("html").on("click", Selectbox.prototype.clearMenus)
})
}(jQuery);
var USERDATALIST = [];
!function($) {
var Userlist = function(element, options) {
this._init(element, options)
};
Userlist.prototype = {
constructor: Userlist,
_init: function(element, options) {
this.options = options, this.$element = $(element), this.isLoadMore = !1, this.storeUserData = storeUserData && storeUserData === !0 ? storeUserData : !1, this.keyName = "ZRUserList", this.tabList = [{
Users: this.options.tabs[0]
}, {
Groups: this.options.tabs[1]
}], this._hasManageUserPermission(), this._create()
},
_hasManageUserPermission: function() {
this.options.format = Crm && Crm.userDetails && Crm.userDetails.permissions && !Crm.userDetails.permissions.Crm_Implied_Manage_Users ? "Name" : this.options.format
},
_getEllipsisVal: function(value, maxLen) {
var obj = {},
dotVal = value,
objLen = parseInt(maxLen),
titleStr = "";
return value && null != value && "null" != value && value.length > objLen && (dotVal = value.substring(0, objLen), dotVal += "...", titleStr = value), obj.dotVal = dotVal, obj.title = titleStr, obj
},
_inArray: function(valArr, val) {
var index = -1;
return $.each(valArr, function(i, value) {
value.trim().toLowerCase() === val.trim().toLowerCase() && (index = i)
}), index
},
_isDefault: function() {
var value = this._convertToString(this.options.val);
return void 0 !== value && 0 !== value.trim().length ? !0 : !1
},
_convertToString: function(value) {
return value && "number" == typeof value ? value.toString() : value
},
_applyClass: function(elem, action) {
"disable" === action ? elem.addClass(ClassName.HIDDEN) : "hide" === action ? elem.addClass(ClassName.NONE) : "active" === action && elem.addClass(ClassName.ACTIVE)
},
_getMenuItem: function(item, ulType) {
var menuElem = $(this.options.menu),
format = this.options.format,
value = this._convertToString(this.options.val),
action = this.options.action,
valArr = value ? value.split(";") : "",
obj = this._getEllipsisVal(item.fullName, this.options.maxlen),
secondElem = menuElem.children();
if (menuElem.data("item", item).attr("data-id", this._convertToString(item.id)).attr("username", item.fullName), "group" === ulType)
this.options.isCustomFromAddress ? (obj = this._getEllipsisVal(item.name, this.options.maxlen), secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME).addClass(ClassName.NOPHOTO), trimEmailObj = this._getEllipsisVal(item.email, this.options.maxlen + 15), menuElem.append($("<span>").addClass(ClassName.EMAIL + ClassName.SPACE + ClassName.NOPHOTO).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title))) : (obj = this._getEllipsisVal(item.groupName, this.options.maxlen), secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME + ClassName.SPACE + ClassName.NOPHOTO + ClassName.SPACE + ClassName.NOEMAIL)), secondElem.data("item", JSON.stringify(item));
else if ("tabs" === ulType) {
menuElem = $(this.options.tabmenu);
var tabName = Object.keys(item);
obj = this._getEllipsisVal(item[tabName], this.options.maxlen), menuElem.attr("title", obj.title).data("type", tabName[0]), menuElem.children().text(obj.dotVal)
} else if ("user" === ulType) {
var trimEmailObj,
noName = item && item.fullName && item.fullName.trim().length > 0 ? !1 : !0,
noEmail = item && item.email && item.email.trim().length > 0 ? !1 : !0,
extraSpc = "Email" === format || "NameEmail" === format ? 15 : 10;
if ("AssignRecruiter" === this.options.type && item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName || item.userStatus && "DISABLED" === item.userStatus))
return !1;
if ("Confirmed" === this.options.type && item.hasOwnProperty("isConfirmed") && item.isConfirmed !== !0)
return !1;
if ("ActiveConfirmed" == this.options.type && (item.hasOwnProperty("isConfirmed") && item.isConfirmed !== !0 || item.hasOwnProperty("userStatus") && ("null" === item.userStatus || "ACTIVE" !== item.userStatus)))
return !1;
if ("Active" == this.options.type && (item.hasOwnProperty("userStatus") && "null" === item.userStatus || "ACTIVE" !== item.userStatus))
return !1;
if ("EmailRelatedList" == this.options.type && item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName))
return !1;
if ("ActiveAndDeactive" == this.options.type && "DISABLED" !== item.userStatus && "ACTIVE" !== item.userStatus)
return !1;
if ("ActivePaidProfile" === this.options.type && item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName || item.hasOwnProperty("userStatus") && ("null" === item.userStatus || "ACTIVE" !== item.userStatus)))
return !1;
if ("ActivePaidTerritory" === this.options.type && (this.options.groupUserType && "-1" !== this.options.groupUserType && item.userTerritoryId && this.options.groupUserType !== item.userTerritoryId || item.hasOwnProperty("userStatus") && "null" === item.userStatus || "ACTIVE" !== item.userStatus || item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName)))
return !1;
if ("ActiveAndRole" === this.options.type && (this.options.roleId && this.options.roleId !== item.roleId || item.hasOwnProperty("userStatus") && "null" === item.userStatus || "ACTIVE" !== item.userStatus))
return !1;
if ("AllActiveUsers" === this.options.type && (item.userStatus && "DISABLED" !== item.userStatus && "ACTIVE" !== item.userStatus || item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName)))
return !1;
if ("DeactivePaidProfile" === this.options.type && (item.userStatus && "DISABLED" !== item.userStatus || item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName)))
return !1;
if ("DeletedPaidProfile" === this.options.type && (item.hasOwnProperty("category") && (null === item.category || "2" !== item.category && "3" !== item.category) || item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName)))
return !1;
switch (this._isDefault() && this._inArray(valArr, item.id) > -1 && this._applyClass(menuElem, action), trimEmailObj = item.email && item.email.length > 0 && ("All" === format || "Email" === format || "NameEmail" === format) ? this._getEllipsisVal(item.email, this.options.maxlen + extraSpc) : {
dotVal: Message.NOEMAIL,
title: Message.NOEMAIL
}, format) {
case "All":
secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME), (noName === !0 || noEmail === !0) && menuElem.addClass(ClassName.SPACE + ClassName.HEIGHT40), menuElem.append($("<span>").addClass(ClassName.IMGSPAN).append($("<img>").attr("src", item.avatar).addClass(ClassName.IMG))).append($("<span>").addClass(ClassName.EMAIL).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title)), "ActiveAndDeactive" !== this.options.type && "AllActiveUsers" !== this.options.type || "DISABLED" !== item.userStatus || menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "Photo":
secondElem.text(obj.dotVal).attr("title", obj.title), menuElem.append($("<span>").addClass(ClassName.IMGSPAN).append($("<img>").attr("src", item.avatar).addClass(ClassName.IMG))).addClass(ClassName.SPACE + ClassName.HEIGHT30), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "Name":
var name = noName === !1 ? obj.dotVal : Message.NONAME;
secondElem.text(name).attr("title", obj.title).addClass(ClassName.NAME + ClassName.SPACE + ClassName.NOPHOTO + ClassName.SPACE + ClassName.NOEMAIL), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && secondElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "Email":
secondElem.append($("<span>").addClass(ClassName.EMAIL).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title)), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "NameEmail":
secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME).addClass(ClassName.NOPHOTO), menuElem.append($("<span>").addClass(ClassName.EMAIL + ClassName.SPACE + ClassName.NOPHOTO).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title)), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
default:
secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME), (noName === !0 || noEmail === !0) && menuElem.addClass(ClassName.SPACE + ClassName.HEIGHT40), menuElem.append($("<span>").addClass(ClassName.IMGSPAN).append($("<img>").attr("src", item.avatar).addClass(ClassName.IMG))).append($("<span>").addClass(ClassName.EMAIL).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title))
}
}
return menuElem.attr("tabindex", "-1"), menuElem
},
_getItem: function(list, ulType) {
if (list && 0 !== list.length) {
var base = this,
frag = document.createDocumentFragment();
return $.each(list, function(i, opt) {
var li = base._getMenuItem(opt, ulType);
"object" == typeof li && frag.appendChild(li[0])
}), frag
}
return this._noOption()
},
_noOption: function() {
var frag = document.createDocumentFragment(),
menuElem = $(this.options.menu);
return menuElem.text(this.options.optionmsg).addClass(ClassName.ERROR), frag.appendChild(menuElem[0]), frag
},
_getId: function() {
return this.$element[0].id && this.$element[0].id.length > 0 ? this.$element[0].id : this.$element[0].name
},
_create: function() {
var action = this.options.action,
data = this._fetchData({
group: this.options.isgroup,
customFromAddress: this.options.isCustomFromAddress
}),
item = data && "success" === data.message ? data.userList : [],
gItem = item.length > 0 && data.groupList && data.groupList.length > 0 ? data.groupList : [],
cItem = this.options.isCustomFromAddress && item.length > 0 && data.customFromAddressList && data.customFromAddressList.length > 0 ? data.customFromAddressList : [],
id = this._getId(),
tabIndex = this.$element[0].tabIndex,
tabIndex = void 0 === tabIndex ? "1" : tabIndex,
showGroup = gItem && 0 === gItem.length ? !1 : !0,
showCustomFromAddress = cItem && 0 === cItem.length ? !1 : !0;
gItem = showCustomFromAddress ? cItem : gItem, this.options.shownext = data && "success" === data.message ? data.showNext : !1, this.options.item = item, this._baseElem = $(this.options.template);
var child = this._baseElem.children();
if (this._dropdown = $(child[0]), this._baseElem.attr("id", id + "-ulist").attr("tabIndex", tabIndex), this._dropdown.html(this._getItem(this.options.item, "user")), this.options.issearch && $(this._baseElem).prepend($(this.options.search).attr("id", id + "-ulistsearch").attr("placeholder", this.options.searchmsg)), (this.options.isgroup && showGroup || this.options.isCustomFromAddress && showCustomFromAddress) && (this.options.gItem = gItem, this._groupDropdown = $(this.options.group), this._groupDropdown.html(this._getItem(this.options.gItem, "group")), this._dropdown.after(this._groupDropdown), this._tabDropdown = $(this.options.tabtemplate), this._tabDropdown.html(this._getItem(this.tabList, "tabs")), this._tabDropdown.find(Selector.LI).first().find(Selector.ANCHOR).addClass(ClassName.ACTIVE), this._baseElem.prepend(this._tabDropdown).addClass(ClassName.PADDING)), $("body").append(this._baseElem), this._bindEvent(), this._isDefault()) {
var $liElem = this._dropdown.find(Selector.LI),
$li = $liElem.filter("disable" === action ? Selector.HIDDEN : "hide" === action ? Selector.NONE : Selector.ACTIVE),
selected = [];
$.each($li, function(i, elem) {
var item = $(elem).data("item");
selected.push({
id: item.id,
item: item
})
}), this._baseElem.data("selected", selected), this._applyClassForGroupOfUser()
}
this.options.shownext && this._scroll(), this._callback("create")
},
_getPosition: function() {
var $this = this.$element,
$drop = $(this._dropdown),
$dropdownParent = this.options.parent,
elemPos = $this.offset(),
elemHt = $this.innerHeight(),
elemOht = $this.outerHeight();
dropDownHt = $drop.outerHeight(), dropDownWd = $drop.outerWidth(), windHt = window.innerHeight, windWd = window.innerWidth, scrollHeight = $(window).scrollTop();
var css = {
top: elemPos.top + elemOht,
left: elemPos.left
};
if (void 0 !== $dropdownParent && 0 !== $dropdownParent.length) {
var parentPos = $dropdownParent.offset();
css.top -= parentPos.top
}
elemHt + elemPos.top + dropDownHt > windHt + scrollHeight && (css.top = elemPos.top - dropDownHt), elemPos.left + dropDownWd > windWd && (css.left = elemPos.left - dropDownWd), this._baseElem.css({
top: css.top + "px",
left: css.left + "px"
})
},
_fetchData: function(dataObj) {
var data = [],
base = this,
forceFetch = this.options.forcefetch,
searchVal = dataObj.search,
ids = dataObj.ids,
isGroup = this.storeUserData ? !0 : dataObj.group ? dataObj.group : !1,
isCustomFromAddress = this.storeUserData ? !0 : dataObj.customFromAddress ? dataObj.customFromAddress : !1,
isdefault = dataObj.hasOwnProperty("isdefault") ? dataObj.isdefault : !0,
fetchUserInfo = dataObj.hasOwnProperty("fetchUserInfo") ? dataObj.fetchUserInfo : !1;
if (!base.isLoadMore) {
base.isLoadMore = !0;
var urlData = "type=" + (this.storeUserData && !forceFetch ? "All" : this.options.type) + "&format=" + this.options.format + "&to=" + (this.storeUserData ? 250 : this.options.to) + "&fetchGroupInfo=" + isGroup + "&fetchCustomFromAddressInfo=" + isCustomFromAddress + "&fetchUserInfo=" + fetchUserInfo,
fromIndex = base.options.from;
searchVal && 0 !== searchVal.length && (urlData = urlData + "&searchtxt=" + searchVal, fromIndex = 1), this._isDefault() && isdefault && (urlData = urlData + "&id=" + this._convertToString(this.options.val)), ids && 0 !== ids.length && (urlData = urlData + "&id=" + ids), "ActivePaidTerritory" === this.options.type && this.options.territoryId && (urlData += "&territoryId=" + this.options.territoryId), "ActiveAndRole" === this.options.type && this.options.roleId && (urlData += "&roleId=" + this.options.roleId), urlData = urlData + "&from=" + fromIndex, data = this.storeUserData && !forceFetch ? base._getStoredData() : [], data = data && "string" == typeof data ? JSON.parse(data) : [], 0 === data.length && $.ajax({
type: "GET",
url: "/recruit/getUserList.do",
dataType: "json",
async: !1,
data: urlData,
beforeSend: function() {
Utils.showHideLoadingDiv(!0)
},
success: function(resp) {
base.isLoadMore = !1, data = resp, base.storeUserData && !forceFetch && base._storeData(JSON.stringify(resp))
},
error: function() {
data = [{
error: "FAILURE",
message: Message.ERROR,
item: []
}]
},
complete: function() {
Utils.showHideLoadingDiv(!1)
}
})
}
return data
},
_storeData: function(value) {
USERDATALIST[this.keyName] = value
},
_getStoredData: function() {
var value = null;
return value = USERDATALIST[this.keyName]
},
_bindEvent: function() {
var base = this;
this._baseElem.on("click.ulistdrop", function(event) {
var tgt = $(event.target);
if (tgt.is("li") || tgt.parent().is("li") || tgt.is("img")) {
var elem = tgt.is("li") ? event.target : tgt.is("img") ? tgt.parents("li")[0] : $(tgt.parent())[0],
type = $(elem).data("type");
!type || "Users" !== type && "Groups" !== type ? (base._select(elem), base.options.multiple === !0 && base._stopEvent(event)) : base._changeTabMenu($(elem), type)
} else if (tgt.is("input"))
base._stopEvent(event);
else if (tgt.parent().is(Selector.TABBASE)) {
var elem = tgt.is("li") ? event.target : $(tgt.parent())[0],
type = elem.data("type");
base._tabDropdown.find(Selector.ACTIVE).removeClass(ClassName.ACTIVE), "Users" === type ? (base._dropdown.removeClass(ClassName.NONE), base._groupDropdown.addClass(ClassName.NONE)) : "Groups" === type && (base._dropdown.addClass(ClassName.NONE), base._groupDropdown.removeClass(ClassName.NONE)), elem.find("a").addClass(ClassName.ACTIVE), base._stopEvent(event)
}
}).on("keydown.ulistdropkey", function(event) {
var tgt = $(event.target),
$ul = base._baseElem.find(Selector.NOTABUL),
$drop = $ul.filter(Selector.VISIBLE).find(Selector.LI);
base._keyPress($drop, tgt, event)
}).on("keyup.ulistinputkey", function(event) {
var tgt = $(event.target);
tgt.is("input") && (base.storeUserData === !1 && -1 === $.inArray(event.keyCode, base.options.keyCodeList) ? (clearTimeout(base.options.userCompTimeoutId), base.options.userCompTimeoutId = setTimeout(function() {
base._search(tgt, event)
}, base.options.searchDelay)) : base._search(tgt, event), base._setFocus())
}).on("mouseover", function(event) {
var tgt = $(event.target);
tgt.hasClass("ulist-deactivated-user") && zctt.showtt(I18n.getMsg("DeactiveUser"), void 0, void 0, void 0, "false")
}).on("mouseout", function(event) {
var tgt = $(event.target);
tgt.hasClass("ulist-deactivated-user") && zctt.hidett(!0)
})
},
_keyPress: function($li, elem, event) {
var base = this;
switch (event.keyCode) {
case 40:
base._next($li);
break;
case 38:
base._prev($li);
break;
case 32:
case 13:
elem.is("input") || base._enter($li.filter(Selector.SELECTED));
break;
case 27:
base._escape()
}
},
_nextNode: function(elem, $first) {
var $next = elem && 0 !== elem.length ? elem.is(Selector.VISIBLE) ? elem : this._nextNode(elem.next()) : $first;
return $next
},
_next: function(elem) {
var $this = $(elem),
$first = $this.eq(0),
$next = this._nextNode($this.filter(Selector.SELECTED).next(), $first),
selected = $next && 0 !== $next.length ? $next : $first;
$this.removeClass(ClassName.SELECTED), $(selected).addClass(ClassName.SELECTED).focus(), this._callback("next", $(selected))
},
_prevNode: function(elem, $last) {
var $next = elem && 0 !== elem.length ? elem.is(Selector.VISIBLE) ? elem : this._prevNode(elem.prev()) : $last;
return $next
},
_prev: function(elem) {
var $this = $(elem),
len = $this.length,
$last = $this.eq(len - 1),
$prev = this._prevNode($this.filter(Selector.SELECTED).prev(), $last),
selected = $prev && 0 !== $prev.length ? $prev : $last;
$this.removeClass(ClassName.SELECTED), $(selected).addClass(ClassName.SELECTED).focus(), this._callback("prev", $(selected))
},
_enter: function($li) {
this._baseElem.hasClass(ClassName.NONE) ? this._openItem() : this._select($li)
},
_escape: function() {
this._closeItem()
},
_search: function(tgt, event) {
var showNext = this.options.shownext,
base = this,
searchVal = tgt.val(),
action = this.options.action,
selTab = base._tabDropdown ? base._tabDropdown.find(Selector.ACTIVE).parent().data("type") : "",
noOption = this._noOption(),
id = this._getId(),
selected = this._baseElem.data("selected"),
$dropUl = selTab.length > 0 && "Groups" === selTab ? base._groupDropdown : base._dropdown,
$li = $dropUl.find(Selector.LI);
if ($li.filter(Selector.ERROR).remove(), void 0 !== searchVal && searchVal.length >= base.options.minlength) {
if (searchVal = searchVal.toLowerCase(), searchVal.length <= 25)
if (showNext && "Groups" !== selTab) {
$("#" + id + "-uautores").remove(), this._dropdown.addClass(ClassName.NONE);
var data = this._fetchData({
search: searchVal
}),
item = data && "success" === data.message ? data.userList : [],
searchUl = this._dropdown.clone().html(this._getItem(item, "user"));
this._dropdown.after(searchUl.attr("id", id + "-uautores").show()), selected && 0 !== selected.length && $.each(selected, function(i, item) {
var $dropli = base._baseElem.find(Selector.UL).next().find("li[data-id='" + item.id + "']");
0 !== $dropli.length && base._applyClass($dropli, action)
})
} else
$.each($li, function(i, item) {
var data = $(item).text(),
data = data && 0 !== data.length ? data.toLowerCase() : data;
data.indexOf(searchVal) > -1 ? $(item).show() : $(item).hide()
}), 0 === $li.filter(Selector.VISIBLE).length && ($li.filter(Selector.ERROR).remove(), $dropUl.append(noOption))
} else
$dropUl.find(Selector.LI).removeAttr(Selector.STYLE), 0 === $dropUl.find(Selector.LI).filter(Selector.VISIBLE).length ? $dropUl.append(noOption) : $li.filter(Selector.ERROR).remove(), showNext && ($("#" + id + "-uautores").remove(), $dropUl.removeClass(ClassName.NONE));
this._getPosition(), this._callback("search"), this._stopEvent(event)
},
_scroll: function() {
var base = this;
this._dropdown.unbind("scroll").bind("scroll", function() {
{
var $this = $(this),
height = this.scrollHeight - $this.height(),
scroll = $this.scrollTop(),
isScrolledToEnd = scroll >= height - 50,
newItem = [];
base._baseElem.find(Selector.INPUT).val()
}
if (isScrolledToEnd && base.options.shownext) {
base.options.from = parseInt(base.options.from) + parseInt(base.options.to);
var data = base._fetchData({
group: !1,
isdefault: !1
}),
item = data && "success" === data.message ? data.userList : [],
selected = base._baseElem.data("selected"),
selected = selected ? selected : [];
0 !== selected.length ? $.each(item, function(i, liItem) {
var userIdNotPresent = !0;
$.each(selected, function(j, selUserObj) {
return liItem.id === base._convertToString(selUserObj.id) ? (userIdNotPresent = !1, !1) : void 0
}), userIdNotPresent && newItem.push(liItem)
}) : newItem = item, base.options.shownext = data && "success" === data.message ? data.showNext : !1, base._dropdown.append(base._getItem(newItem, "user")), base._callback("scroll")
}
})
},
_select: function(tgt) {
{
var $this = $(tgt),
base = this,
item = $this.data();
base.options.action
}
if (!($this.hasClass(ClassName.ACTIVE) || $this.hasClass(ClassName.HIDDEN) || $this.hasClass(ClassName.NONE) || $this.hasClass(ClassName.ERROR))) {
if (base.options.multiple) {
var selected = base._baseElem.data("selected"),
selected = selected ? selected : [],
associatedUsers = (selected.length, item && item.item && item.item.hasOwnProperty("associatedUsers") ? item.item.associatedUsers : []);
if (base._maxSelectCheck(selected.length))
return base._callback("maxerror"), void base._closeItem();
if (associatedUsers.length > 0) {
if (selected.length > 0) {
var unselectedUserIds = [];
$.each(associatedUsers, function(i, assuserId) {
var userIdNotPresent = !0;
$.each(selected, function(i, selUserObj) {
return base._convertToString(selUserObj.id) === assuserId ? (userIdNotPresent = !1, !1) : void 0
}), userIdNotPresent && unselectedUserIds.push(assuserId)
}), associatedUsers = unselectedUserIds
}
base._addUserIdToSelectedArray(associatedUsers, selected)
} else {
var userIdNotPresent = !0;
$.each(selected, function(i, selUserObj) {
return base._convertToString(selUserObj.id) === item.id ? (userIdNotPresent = !1, !1) : void 0
}), userIdNotPresent && (base._addMenuIfNotPresent(tgt, item), selected.push(item))
}
} else {
base._dropdown.find(Selector.LI).removeClass(ClassName.ACTIVE);
var selected = [];
this.options.isCustomFromAddress ? base._groupDropdown && base._groupDropdown.find(Selector.LI).removeClass(ClassName.ACTIVE) : base._addMenuIfNotPresent(tgt, item), selected.push(item), base._closeItem()
}
base._baseElem.data("selected", selected), base._applyClassForGroupOfUser(), base._setFocus(), base._getPosition(), base._callback("select", $this)
}
},
_addMenuIfNotPresent: function(li, item) {
var base = this,
$li = $(li),
newLiMenu = [],
selId = base._convertToString($li.data("id")),
ispresent = selId.length > 0 && base._dropdown.find("li[data-id=" + selId + "]").length > 0 ? !0 : !1;
ispresent === !1 && item && item.item && (newLiMenu.push(item.item), base._dropdown.prepend(base._getItem(newLiMenu, "user")))
},
_addUserIdToSelectedArray: function(associatedUsers, selected) {
var base = this,
maxCheckCount = selected.length,
userIdNotPresentArray = [];
if ($.each(associatedUsers, function(j, asUserId) {
var userIdNotPresent = !0;
base._dropdown.find(Selector.LI).each(function(k, userList) {
var data = $(userList).data();
return data.id = base._convertToString(data.id), asUserId !== data.id || base._maxSelectCheck(maxCheckCount) ? void 0 : (selected.push(data), userIdNotPresent = !1, !1)
}), userIdNotPresent && (base._maxSelectCheck(maxCheckCount) || userIdNotPresentArray.push(asUserId)), maxCheckCount++
}), userIdNotPresentArray.length > 0) {
var data = base._fetchData({
ids: userIdNotPresentArray.join(";"),
group: !1,
fetchUserInfo: !0,
isdefault: !1
}),
item = data && "success" === data.message ? data.userList : [],
newUserIdArray = [];
$.each(item, function(j, userObj) {
newUserIdArray.push({
id: userObj.id,
item: userObj
})
}), newUserIdArray.length > 0 && ($.merge(selected, newUserIdArray), base._dropdown.append(base._getItem(item, "user")))
}
},
_maxSelectCheck: function(itemSize) {
var base = this;
return -1 !== base.options.maxselect && itemSize + 1 > base.options.maxselect ? !0 : !1
},
_applyClassForGroupOfUser: function() {
var base = this,
action = base.options.action,
selected = base._baseElem.data("selected"),
selected = selected ? selected : [],
id = (base._noOption(), action === ClassName.ACTIVE ? ClassName.ACTIVE : "hide" === action ? ClassName.NONE : ClassName.HIDDEN, base._getId()),
searchDropdown = $("#" + id + "-uautores");
$.each(base._dropdown.find(Selector.LINOERROR), function(i, li) {
var liId = $(li).data("id");
$.each(selected, function(j, userObj) {
return userObj.id === liId ? (base._applyClass($(li), action), !1) : void 0
})
}), searchDropdown.length && $.each(searchDropdown.find(Selector.LINOERROR), function(i, li) {
var liId = $(li).data("id");
$.each(selected, function(j, userObj) {
return userObj.id === liId ? (base._applyClass($(li), action), !1) : void 0
})
}), base._groupDropdown && (this.options.isCustomFromAddress ? $.each(base._groupDropdown.find(Selector.LINOERROR), function(i, li) {
var liId = $(li).data("id");
$.each(selected, function(j, userObj) {
return userObj.id === liId ? (base._applyClass($(li), action), !1) : void 0
})
}) : $.each(base._groupDropdown.find(Selector.LINOERROR), function(i, gli) {
var item = $(gli).data("item"),
associatedUsers = item.hasOwnProperty("associatedUsers") ? item.associatedUsers : [],
associatedUsersCount = associatedUsers.length,
userCount = 0;
$.each(selected, function(j, userObj) {
$.each(associatedUsers, function(j, asUserId) {
return userObj.id === asUserId ? (userCount++, !1) : void 0
})
}), userCount === associatedUsersCount && base._applyClass($(gli), action)
})), base._emptyLiCheck()
},
_changeTabMenu: function($this, type) {
var base = this,
searchStr = base._baseElem.find(Selector.INPUT).val();
switch (base._clearSearch(), searchStr.length > 0 && base._search(base._baseElem.find(Selector.INPUT), event), base._tabDropdown.find(Selector.ANCHOR).removeClass(ClassName.ACTIVE), $this.find(Selector.ANCHOR).addClass(ClassName.ACTIVE), type) {
case "Users":
base._groupDropdown.addClass(ClassName.NONE), base._dropdown.removeClass(ClassName.NONE);
break;
case "Groups":
base._dropdown.addClass(ClassName.NONE), base._groupDropdown.removeClass(ClassName.NONE)
}
base._emptyLiCheck(), base._setFocus(), base._getPosition(), base._stopEvent(event)
},
_reapplyClass: function(deleteUserId) {
var base = this,
action = base.options.action,
selectorName = (base._baseElem.data("selected"), action === ClassName.ACTIVE ? ClassName.ACTIVE : "hide" === action ? ClassName.NONE : ClassName.HIDDEN),
className = action === ClassName.ACTIVE ? Selector.ACTIVE : "hide" === action ? Selector.NONE : Selector.HIDDEN,
id = base._getId(),
searchDropdown = $("#" + id + "-uautores");
$.each(base._dropdown.find(className), function(i, li) {
var liId = base._convertToString($(li).data("id"));
return liId === deleteUserId ? ($(li).removeClass(selectorName).removeClass(ClassName.SELECTED), !1) : void 0
}), searchDropdown.length && $.each(searchDropdown.find(className), function(i, li) {
var liId = base._convertToString($(li).data("id"));
return liId === deleteUserId ? ($(li).removeClass(selectorName).removeClass(ClassName.SELECTED), !1) : void 0
}), base._groupDropdown && $.each(base._groupDropdown.find(className), function(i, gli) {
var item = $(gli).data("item"),
associatedUsers = item.hasOwnProperty("associatedUsers") ? item.associatedUsers : [],
matchCount = 0;
$.each(associatedUsers, function(j, userId) {
return deleteUserId === userId ? (matchCount++, !1) : void 0
}), matchCount > 0 && $(gli).removeClass(selectorName).removeClass(ClassName.SELECTED)
}), base._emptyLiCheck()
},
_emptyLiCheck: function() {
var base = this,
action = base.options.action,
searchDropdown = $("#" + base._getId() + "-uautores");
if (base._groupDropdown) {
var $grpLi = base._groupDropdown.find(Selector.LI);
$grpLi.filter(Selector.ERROR).remove(), "hide" === action && 0 === $grpLi.filter(Selector.VISIBLE).length && base._groupDropdown.append(base._noOption())
}
var $userLi = base._dropdown.find(Selector.LI);
if ($userLi.filter(Selector.ERROR).remove(), "hide" === action && 0 === $userLi.filter(Selector.VISIBLE).length && base._dropdown.append(base._noOption()), searchDropdown.length) {
var $searchLi = searchDropdown.find(Selector.LI);
$searchLi.filter(Selector.ERROR).remove(), "hide" === action && 0 === $searchLi.filter(Selector.VISIBLE).length && searchDropdown.append(base._noOption())
}
},
isFunction: function(fn) {
return "function" == typeof fn ? !0 : !1
},
_callback: function(type, curElem) {
var callback = this.options.callback;
this.isFunction(callback) && callback(type, this, curElem)
},
toggle: function() {
this._baseElem.hasClass(ClassName.NONE) ? this._openItem() : this._closeItem()
},
_clearSearch: function() {
var base = this,
searchDropDown = $("#" + base._getId() + "-uautores"),
tabName = base._baseElem.find(Selector.TABBASE).find(Selector.ACTIVE).parent().data("type");
base._baseElem.find(Selector.INPUT).val(""), searchDropDown && searchDropDown.remove(), base._groupDropdown && "Groups" === tabName ? base._groupDropdown.find(Selector.LI).removeAttr(Selector.STYLE) : base._dropdown.removeClass(ClassName.NONE).find(Selector.LI).removeAttr(Selector.STYLE)
},
_openItem: function() {
this._clearSearch(), this._baseElem.removeClass(ClassName.NONE), this._getPosition();
var selected = (this.options.action, this._baseElem.data("selected")),
$parent = (this._noOption(), this._baseElem),
$input = $parent.find(Selector.INPUT),
$li = this._dropdown.find(Selector.LI),
$hidd = $li.filter(Selector.HIDDEN),
$active = $li.filter(Selector.ACTIVE),
$none = $li.filter(Selector.NONE),
first = $li[0],
selected = 0 !== $hidd.length ? $hidd[0] : 0 !== $active.length ? $active[0] : 0 !== $none.length ? $none[0] : first;
$li.removeClass(ClassName.SELECTED), 0 !== $li.filter(Selector.VISIBLE).length && $(selected).addClass(ClassName.SELECTED).focus(), 0 !== $input.length ? $input.focus() : this._baseElem.focus(), $("#recDetail").is(":visible") && $("#preHTMLContainer_Leads").css({
overflow: "hidden"
}), this._emptyLiCheck(), this._callback("open"), this._setFocus()
},
_setFocus: function() {
var $input = this._baseElem.find(Selector.INPUT),
$ul = this._baseElem.find(Selector.NOTABUL),
$li = $ul.filter(Selector.VISIBLE).find(Selector.LI),
$hidd = $li.filter(Selector.HIDDEN),
$active = $li.filter(Selector.ACTIVE),
$none = $li.filter(Selector.NONE),
first = $li[0],
selected = 0 !== $hidd.length ? $hidd[0] : 0 !== $active.length ? $active[0] : 0 !== $none.length ? $none[0] : first;
0 !== $input.length ? $input.focus() : $(selected).focus()
},
_closeItem: function() {
this._baseElem.addClass(ClassName.NONE), this._callback("close")
},
open: function() {
var base = $(this).data("userlist");
base._openItem()
},
close: function() {
var base = $(this).data("userlist");
base._closeItem(), $("#recDetail").is(":visible") && $("#preHTMLContainer_Leads").css({
overflow: ""
})
},
remove: function() {
var base = $(this).data("userlist"),
deleteUserId = base.deleteId ? base._convertToString(base.deleteId) : "",
selected = base._baseElem.data("selected"),
selected = selected ? selected : [];
0 !== deleteUserId.length && 0 !== selected.length && (base._reapplyClass(deleteUserId), $.each(selected, function(i, selUserObj) {
return base._convertToString(selUserObj.id) === deleteUserId ? (selected.splice(i, 1), base._baseElem.data("selected", selected), !1) : void 0
})), base._setFocus(), base._stopEvent(event)
},
destroy: function() {
var base = $(this).data("userlist");
base._baseElem.remove(), base._dropdown.remove(), $(this).removeData("userlist")
},
position: function() {
var base = $(this).data("userlist");
base._getPosition()
},
clearMenus: function(event) {
var tgt = $(event.target);
tgt.not(Selector.BASE) && tgt.parent().parent().not(Selector.BASE) && $(Selector.BASE).addClass(ClassName.NONE)
},
_stopEvent: function(e) {
return e.stopPropagation(), e.preventDefault(), !1
}
}, $.fn.userList = function(option) {
return this.each(function() {
var $this = $(this),
data = $this.data("userlist"),
options = $.extend({}, $.fn.userList.defaults, $this.data(), "object" == typeof option && option);
if (!data) {
var $id = $("#" + $this.attr("id") + "-ulist");
$id.length ? $id.remove() : "", "object" == typeof option && $this.data("userlist", data = new Userlist(this, options))
}
if ("string" == typeof option) {
if (data && void 0 === data[option])
throw new Error('No method named "' + option + '"');
data && "function" == typeof data[option] && data[option].call(this)
}
})
};
var ClassName = {
SPACE: " ",
PADDING: "padT0",
IMGSPAN: "zrc-pic32",
IMG: "zrc-pic",
EMAIL: "email",
NAME: "name",
NOPHOTO: "padL10",
NOEMAIL: "disIB hei30 linH30",
HEIGHT30: "hei30 linH30",
HIDDEN: "hidd",
ACTIVE: "active",
ENABLE: "inv",
SELECTED: "sel",
NONE: "disN",
HEIGHT40: "hei40",
ERROR: "err",
DEACTIVEUSERCLASS: "icon-cand-disq ulist-deactivated-user posA rig15 top15"
},
Selector = {
ACTIVE: ".active",
HIDDEN: ".hidd",
BASE: ".zrc-profile-list chk",
TABBASE: ".zrc-line-tab",
LI: "li",
UL: "ul",
NOTABUL: "ul:not(.zrc-line-tab)",
STYLE: "style",
ANCHOR: "a",
INPUT: "input",
SELECTED: ".sel",
NONE: ".disN",
ERROR: ".err",
LINONE: "li:not(.disN)",
LINOERROR: "li:not(.err)",
VISIBLE: ":visible"
},
Message = {
NOOPTION: I18n.getMsg("crm.label.no.options.found"),
NONAME: I18n.getMsg("zr.user.component.no.name"),
NOEMAIL: I18n.getMsg("zr.user.component.no.email"),
ERROR: I18n.getMsg("crm.security.error.add.user"),
SEARCH: I18n.getMsg("crm.globalsearch.search.title"),
GROUPS: I18n.getMsg("crm.security.groups"),
USERS: I18n.getMsg("crm.security.users")
};
$.fn.userList.defaults = {
issearch: !1,
isgroup: !1,
isCustomFromAddress: !1,
forcefetch: !1,
to: 250,
from: 1,
maxlen: 25,
minlength: 3,
multiple: !1,
maxselect: -1,
action: "active",
val: "",
searchDelay: 300,
keyCodeList: [9, 16, 17, 18, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 91, 92, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 144, 145],
userCompTimeoutId: void 0,
optionmsg: Message.NOOPTION,
searchmsg: Message.SEARCH,
tabs: [Message.USERS, Message.GROUPS],
format: "All",
type: "Active",
tabtemplate: "<ul class='zrc-line-tab padL20'></ul>",
tabmenu: "<li style='padding-left:0; border-bottom-width:0;padding-bottom:0;'><a href='javascript:;'></a></li>",
menu: "<li><span></span></li>",
search: "<input type='search' maxlength='25'/>",
group: "<ul class='disN oveA maxH250 widP100 mar0 pad0'></ul>",
template: "<div class='disN zrc-profile-list chk wid350'><ul class='oveA maxH250 widP100 mar0 pad0' data-zcqa='zruserlist-userlookup'></ul></div>"
}, $.fn.userList.Constructor = Userlist, $(function() {
$("html").on("click", Userlist.prototype.clearMenus)
})
}(jQuery), function($) {
var InterviewerList = function(element, options) {
this._init(element, options)
};
InterviewerList.prototype = {
constructor: InterviewerList,
_init: function(element, options) {
this.options = options, this.$element = $(element), this.isLoadMore = !1, this.isLoadContactsMore = !1, this.storeUserData = storeUserData && storeUserData === !0 ? storeUserData : !1, this.storeContactData = !1, this.tabList = [{
Users: this.options.tabs[0]
}], this.options.isgroup ? this.tabList.push({
Groups: this.options.tabs[1]
}) : this.options.iscontacts && this.tabList.push({
Contacts: this.options.tabs[2]
}), this._hasManageUserPermission(), this._create()
},
_hasManageUserPermission: function() {
this.options.format = Crm && Crm.userDetails && Crm.userDetails.permissions && !Crm.userDetails.permissions.Crm_Implied_Manage_Users ? "Name" : this.options.format, this.options.contactFormat = isClientUser && Crm && Crm.userDetails && Crm.userDetails.ROLE_CATEGORY && Crm.userDetails.ROLE_CATEGORY === crmConstants.CLIENT_INTERVIEWER_CATEGORY ? "Name" : this.options.contactFormat
},
_getEllipsisVal: function(value, maxLen) {
var obj = {},
dotVal = value,
objLen = parseInt(maxLen),
titleStr = "";
return value && null != value && "null" != value && value.length > objLen && (dotVal = value.substring(0, objLen), dotVal += "...", titleStr = value), obj.dotVal = dotVal, obj.title = titleStr, obj
},
_inArray: function(valArr, val) {
var index = -1;
return $.each(valArr, function(i, value) {
value.trim().toLowerCase() === val.trim().toLowerCase() && (index = i)
}), index
},
_isDefault: function() {
var value = this._convertToString(this.options.val);
return void 0 !== value && 0 !== value.trim().length ? !0 : !1
},
_convertToString: function(value) {
return value && "number" == typeof value ? value.toString() : value
},
_applyClass: function(elem, action) {
"disable" === action ? elem.addClass(ClassName.HIDDEN) : "hide" === action ? (elem.prevAll("li").not(".disN").first().hasClass("hdng") && (elem.next().hasClass("hdng") || 0 == elem.next().length) && elem.prevAll("li").not(".disN").first().addClass(ClassName.NONE), elem.addClass(ClassName.NONE)) : "active" === action && elem.addClass(ClassName.ACTIVE)
},
_getMenuItem: function(item, ulType) {
var menuElem = $(this.options.menu),
format = this.options.format,
value = this._convertToString(this.options.val),
action = this.options.action,
valArr = value ? value.split(";") : "",
obj = this._getEllipsisVal(item.fullName, this.options.maxlen),
secondElem = menuElem.children();
if ("contact" === ulType ? menuElem.data("item", item).attr("data-id", this._convertToString(item.id)).attr("contactname", item.fullName).attr("data-type", "contact") : menuElem.data("item", item).attr("data-id", this._convertToString(item.id)).attr("username", item.fullName), "group" === ulType)
this.options.isCustomFromAddress ? (obj = this._getEllipsisVal(item.name, this.options.maxlen), secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME).addClass(ClassName.NOPHOTO), trimEmailObj = this._getEllipsisVal(item.email, this.options.maxlen + 15), menuElem.append($("<span>").addClass(ClassName.EMAIL + ClassName.SPACE + ClassName.NOPHOTO).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title))) : (obj = this._getEllipsisVal(item.groupName, this.options.maxlen), secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME + ClassName.SPACE + ClassName.NOPHOTO + ClassName.SPACE + ClassName.NOEMAIL)), secondElem.data("item", JSON.stringify(item));
else if ("tabs" === ulType) {
menuElem = $(this.options.tabmenu);
var tabName = Object.keys(item);
obj = this._getEllipsisVal(item[tabName], this.options.maxlen), menuElem.attr("title", obj.title).data("type", tabName[0]), menuElem.children().text(obj.dotVal)
} else if ("user" === ulType) {
var trimEmailObj,
noName = item && item.fullName && item.fullName.trim().length > 0 ? !1 : !0,
noEmail = item && item.email && item.email.trim().length > 0 ? !1 : !0,
extraSpc = "Email" === format || "NameEmail" === format ? 15 : 10;
if ("AssignRecruiter" === this.options.type && item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName || item.userStatus && "DISABLED" === item.userStatus))
return !1;
if ("Confirmed" === this.options.type && item.hasOwnProperty("isConfirmed") && item.isConfirmed !== !0)
return !1;
if ("ActiveConfirmed" == this.options.type && (item.hasOwnProperty("isConfirmed") && item.isConfirmed !== !0 || item.hasOwnProperty("userStatus") && ("null" === item.userStatus || "ACTIVE" !== item.userStatus)))
return !1;
if ("Active" == this.options.type && (item.hasOwnProperty("userStatus") && "null" === item.userStatus || "ACTIVE" !== item.userStatus))
return !1;
if ("EmailRelatedList" == this.options.type && item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName))
return !1;
if ("ActiveAndDeactive" == this.options.type && item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName || "DISABLED" !== item.userStatus && "ACTIVE" !== item.userStatus))
return !1;
if ("ActivePaidProfile" === this.options.type && item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName || item.hasOwnProperty("userStatus") && ("null" === item.userStatus || "ACTIVE" !== item.userStatus)))
return !1;
if ("ActivePaidTerritory" === this.options.type && (this.options.groupUserType && "-1" !== this.options.groupUserType && item.userTerritoryId && this.options.groupUserType !== item.userTerritoryId || item.hasOwnProperty("userStatus") && "null" === item.userStatus || "ACTIVE" !== item.userStatus || item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName)))
return !1;
if ("ActiveAndRole" === this.options.type && (this.options.roleId && this.options.roleId !== item.roleId || item.hasOwnProperty("userStatus") && "null" === item.userStatus || "ACTIVE" !== item.userStatus))
return !1;
if ("AllActiveUsers" === this.options.type && (item.userStatus && "DISABLED" !== item.userStatus && "ACTIVE" !== item.userStatus || item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName)))
return !1;
if ("DeactivePaidProfile" === this.options.type && (item.userStatus && "DISABLED" !== item.userStatus || item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName)))
return !1;
if ("DeletedPaidProfile" === this.options.type && (item.hasOwnProperty("category") && (null === item.category || "2" !== item.category && "3" !== item.category) || item.profileName && ("Interviewer" === item.profileName || "Guest" === item.profileName)))
return !1;
switch (this._isDefault() && this._inArray(valArr, item.id) > -1 && this._applyClass(menuElem, action), trimEmailObj = item.email && item.email.length > 0 && ("All" === format || "Email" === format || "NameEmail" === format) ? this._getEllipsisVal(item.email, this.options.maxlen + extraSpc) : {
dotVal: Message.NOEMAIL,
title: Message.NOEMAIL
}, format) {
case "All":
secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME), (noName === !0 || noEmail === !0) && menuElem.addClass(ClassName.SPACE + ClassName.HEIGHT40), menuElem.append($("<span>").addClass(ClassName.IMGSPAN).append($("<img>").attr("src", item.avatar).addClass(ClassName.IMG))).append($("<span>").addClass(ClassName.EMAIL).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title)), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "Photo":
secondElem.text(obj.dotVal).attr("title", obj.title), menuElem.append($("<span>").addClass(ClassName.IMGSPAN).append($("<img>").attr("src", item.avatar).addClass(ClassName.IMG))).addClass(ClassName.SPACE + ClassName.HEIGHT30), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "Name":
var name = noName === !1 ? obj.dotVal : Message.NONAME;
secondElem.text(name).attr("title", obj.title).addClass(ClassName.NAME + ClassName.SPACE + ClassName.NOPHOTO + ClassName.SPACE + ClassName.NOEMAIL), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && secondElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "Email":
secondElem.append($("<span>").addClass(ClassName.EMAIL).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title)), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "NameEmail":
secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME).addClass(ClassName.NOPHOTO), menuElem.append($("<span>").addClass(ClassName.EMAIL + ClassName.SPACE + ClassName.NOPHOTO).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title)), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
default:
secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME), (noName === !0 || noEmail === !0) && menuElem.addClass(ClassName.SPACE + ClassName.HEIGHT40), menuElem.append($("<span>").addClass(ClassName.IMGSPAN).append($("<img>").attr("src", item.avatar).addClass(ClassName.IMG))).append($("<span>").addClass(ClassName.EMAIL).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title))
}
} else if ("contact" === ulType) {
var trimEmailObj,
noName = item && item.fullName && item.fullName.trim().length > 0 ? !1 : !0,
format = this.options.contactFormat,
noEmail = item && item.email && item.email.trim().length > 0 ? !1 : !0,
extraSpc = "Email" === format || "NameEmail" === format ? 15 : 10;
switch (this._isDefault() && this._inArray(valArr, item.id) > -1 && this._applyClass(menuElem, action), trimEmailObj = item.email && item.email.length > 0 && ("All" === format || "Email" === format || "NameEmail" === format) ? this._getEllipsisVal(item.email, this.options.maxlen + extraSpc) : {
dotVal: Message.NOEMAIL,
title: Message.NOEMAIL
}, format) {
case "All":
secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME), (noName === !0 || noEmail === !0) && menuElem.addClass(ClassName.SPACE + ClassName.HEIGHT40), menuElem.append($("<span>").addClass(ClassName.IMGSPAN).append($("<img>").attr("src", item.avatar).addClass(ClassName.IMG))).append($("<span>").addClass(ClassName.EMAIL).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title)), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "Photo":
secondElem.text(obj.dotVal).attr("title", obj.title), menuElem.append($("<span>").addClass(ClassName.IMGSPAN).append($("<img>").attr("src", item.avatar).addClass(ClassName.IMG))).addClass(ClassName.SPACE + ClassName.HEIGHT30), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "Name":
var name = noName === !1 ? obj.dotVal : Message.NONAME;
secondElem.text(name).attr("title", obj.title).addClass(ClassName.NAME + ClassName.SPACE + ClassName.NOPHOTO + ClassName.SPACE + ClassName.NOEMAIL), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && secondElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "Email":
secondElem.append($("<span>").addClass(ClassName.EMAIL).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title)), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
case "NameEmail":
secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME).addClass(ClassName.NOPHOTO), menuElem.append($("<span>").addClass(ClassName.EMAIL + ClassName.SPACE + ClassName.NOPHOTO).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title)), "ActiveAndDeactive" === this.options.type && "DISABLED" === item.userStatus && menuElem.append($("<em>").addClass(ClassName.DEACTIVEUSERCLASS));
break;
default:
secondElem.text(obj.dotVal).attr("title", obj.title).addClass(ClassName.NAME), (noName === !0 || noEmail === !0) && menuElem.addClass(ClassName.SPACE + ClassName.HEIGHT40), menuElem.append($("<span>").addClass(ClassName.IMGSPAN).append($("<img>").attr("src", item.avatar).addClass(ClassName.IMG))).append($("<span>").addClass(ClassName.EMAIL).text(trimEmailObj.dotVal).attr("title", trimEmailObj.title))
}
}
return menuElem.attr("tabindex", "-1"), menuElem
},
_getItem: function(list, ulType) {
if (list && 0 !== list.length) {
var base = this,
frag = document.createDocumentFragment(),
isARused = !1,
isOtherUsed = !1;
return $.each(list, function(i, opt) {
var joRel = opt.joRelation;
if ("HM" === joRel) {
var subMenuElem = $(base.options.submenu);
subMenuElem.text(ZRCommonUtil.isStaffingType ? I18n.getMsg("zr.lar.accountmanager") : I18n.getMsg("zr.lar.hiringmanager")), frag.append(subMenuElem[0])
}
if (!isARused && "AR" === joRel) {
var subMenuElem = $(base.options.submenu);
subMenuElem.text(I18n.getMsg("zr.lar.assignedrecruiter")), isARused = !0, frag.append(subMenuElem[0])
}
if (!isOtherUsed && "Other" === joRel) {
var subMenuElem = $(base.options.submenu);
subMenuElem.text(I18n.getMsg("crm.label.other.users")), isOtherUsed = !0, frag.append(subMenuElem[0])
}
var li = base._getMenuItem(opt, ulType);
"object" == typeof li && frag.appendChild(li[0])
}), frag
}
return this._noOption()
},
_noOption: function() {
var frag = document.createDocumentFragment(),
menuElem = $(this.options.menu);
return menuElem.text(this.options.optionmsg).addClass(ClassName.ERROR), frag.appendChild(menuElem[0]), frag
},
_getId: function() {
return this.$element[0].id && this.$element[0].id.length > 0 ? this.$element[0].id : this.$element[0].name
},
_create: function() {
var action = this.options.action,
data = this._fetchData({
group: this.options.isgroup,
customFromAddress: this.options.isCustomFromAddress
}),
item = data && "success" === data.message ? data.userList : [],
gItem = item.length > 0 && data.groupList && data.groupList.length > 0 ? data.groupList : [],
cItem = this.options.isCustomFromAddress && item.length > 0 && data.customFromAddressList && data.customFromAddressList.length > 0 ? data.customFromAddressList : [],
id = this._getId(),
tabIndex = this.$element[0].tabIndex,
tabIndex = void 0 === tabIndex ? "1" : tabIndex,
showGroup = gItem && 0 === gItem.length ? !1 : !0,
showCustomFromAddress = cItem && 0 === cItem.length ? !1 : !0;
if (gItem = showCustomFromAddress ? cItem : gItem, this.options.iscontacts)
var contactsData = this._fetchContactsData({}),
contactsItem = contactsData && "success" === contactsData.message ? contactsData.contactList : [],
showContact = contactsItem && 0 === contactsItem.length ? !1 : !0;
this.options.shownext = data && "success" === data.message ? data.showNext : !1, this.options.shownextcontacts = contactsData && "success" === contactsData.message ? contactsData.showNext : !1, this.options.item = item, this._baseElem = $(this.options.template);
var child = this._baseElem.children();
if (this._dropdown = $(child[0]), this._baseElem.attr("id", id + "-ulist").attr("tabIndex", tabIndex), this._dropdown.html(this._getItem(this.options.item, "user")), this.options.issearch && $(this._baseElem).prepend($(this.options.search).attr("id", id + "-ulistsearch").attr("placeholder", this.options.searchmsg)), (this.options.isgroup && showGroup || this.options.isCustomFromAddress && showCustomFromAddress) && (this.options.gItem = gItem, this._groupDropdown = $(this.options.group), this._groupDropdown.html(this._getItem(this.options.gItem, "group")), this._dropdown.after(this._groupDropdown), this._tabDropdown = $(this.options.tabtemplate), this._tabDropdown.html(this._getItem(this.tabList, "tabs")), this._tabDropdown.find(Selector.LI).first().find(Selector.ANCHOR).addClass(ClassName.ACTIVE), this._baseElem.prepend(this._tabDropdown).addClass(ClassName.PADDING)), this.options.iscontacts && showContact && (this.options.contactsItem = contactsItem, this._contactDropdown = $(this.options.contact), this._contactDropdown.html(this._getItem(this.options.contactsItem, "contact")), this._dropdown.after(this._contactDropdown), this._tabDropdown = $(this.options.tabtemplate), this._tabDropdown.html(this._getItem(this.tabList, "tabs")), this._tabDropdown.find(Selector.LI).first().find(Selector.ANCHOR).addClass(ClassName.ACTIVE), this._baseElem.prepend(this._tabDropdown).addClass(ClassName.PADDING)), $("body").append(this._baseElem), this._bindEvent(), this._isDefault()) {
var $liElem = this._dropdown.find(Selector.LI),
$li = $liElem.filter("disable" === action ? Selector.HIDDEN : "hide" === action ? Selector.NONE : Selector.ACTIVE),
selected = [];
if ($.each($li, function(i, elem) {
var item = $(elem).data("item");
selected.push({
id: item.id,
item: item
})
}), this.options.iscontacts && this._contactDropdown) {
var $liElem = this._contactDropdown.find(Selector.LI),
$li = $liElem.filter("disable" === action ? Selector.HIDDEN : "hide" === action ? Selector.NONE : Selector.ACTIVE);
$.each($li, function(i, elem) {
var item = $(elem).data("item");
selected.push({
id: item.id,
item: item
})
})
}
this._baseElem.data("selected", selected), this._applyClassForGroupOfUser()
}
(this.options.shownext || this.options.shownextcontacts) && this._scroll(), this._callback("create")
},
_getPosition: function() {
var $this = this.$element,
$drop = $(this._dropdown),
$dropdownParent = this.options.parent,
elemPos = $this.offset(),
elemHt = $this.innerHeight(),
elemOht = $this.outerHeight();
dropDownHt = $drop.outerHeight(), dropDownWd = $drop.outerWidth(), windHt = window.innerHeight, windWd = window.innerWidth, scrollHeight = $(window).scrollTop();
var css = {
top: elemPos.top + elemOht,
left: elemPos.left
};
if (void 0 !== $dropdownParent && 0 !== $dropdownParent.length) {
var parentPos = $dropdownParent.offset();
css.top -= parentPos.top
}
elemHt + elemPos.top + dropDownHt > windHt + scrollHeight && (css.top = elemPos.top - dropDownHt), elemPos.left + dropDownWd > windWd && (css.left = elemPos.left - dropDownWd), this._baseElem.css({
top: css.top + "px",
left: css.left + "px"
})
},
_fetchData: function(dataObj) {
var data = [],
base = this,
searchVal = (this.options.forcefetch, dataObj.search),
ids = dataObj.ids,
isGroup = this.storeUserData ? !0 : dataObj.group ? dataObj.group : !1,
isContacts = this.storeUserData ? !0 : dataObj.contact ? dataObj.contact : !1,
isCustomFromAddress = this.storeUserData ? !0 : dataObj.customFromAddress ? dataObj.customFromAddress : !1,
isdefault = dataObj.hasOwnProperty("isdefault") ? dataObj.isdefault : !0,
fetchUserInfo = dataObj.hasOwnProperty("fetchUserInfo") ? dataObj.fetchUserInfo : !1;
if (!base.isLoadMore) {
base.isLoadMore = !0;
var urlData = "type=" + (this.options.type ? this.options.type : "All") + "&format=" + this.options.format + "&to=" + (this.storeUserData ? 250 : this.options.to) + "&fetchGroupInfo=" + isGroup + "&fetchCustomFromAddressInfo=" + isCustomFromAddress + "&fetchContactInfo=" + isContacts + "&fetchUserInfo=" + fetchUserInfo,
fromIndex = base.options.from;
searchVal && 0 !== searchVal.length && (urlData = urlData + "&searchtxt=" + searchVal, fromIndex = 1), this._isDefault() && isdefault && (urlData = urlData + "&id=" + this._convertToString(this.options.val)), ids && 0 !== ids.length && (urlData = urlData + "&id=" + ids), "ActivePaidTerritory" === this.options.type && this.options.territoryId && (urlData += "&territoryId=" + this.options.territoryId), "ActiveAndRole" === this.options.type && this.options.roleId && (urlData += "&roleId=" + this.options.roleId), this.options.relatedJO && (urlData = urlData + "&joId=" + this.options.relatedJO), urlData = urlData + "&from=" + fromIndex, data = data && "string" == typeof data ? JSON.parse(data) : [], 0 === data.length && $.ajax({
type: "GET",
url: "/recruit/getUserList.do",
dataType: "json",
async: !1,
data: urlData,
beforeSend: function() {
Utils.showHideLoadingDiv(!0)
},
success: function(resp) {
base.isLoadMore = !1, data = resp
},
error: function() {
data = [{
error: "FAILURE",
message: Message.ERROR,
item: []
}]
},
complete: function() {
Utils.showHideLoadingDiv(!1)
}
})
}
return data
},
_fetchContactsData: function(dataObj) {
var data = [],
base = this,
searchVal = (this.options.forcefetch, dataObj.search),
ids = dataObj.ids,
isdefault = dataObj.hasOwnProperty("isdefault") ? dataObj.isdefault : !0;
if (!base.isLoadContactsMore) {
base.isLoadContactsMore = !0;
var urlData = "to=" + (this.storeContactData ? 250 : this.options.toContacts),
fromIndex = base.options.fromContacts;
searchVal && 0 !== searchVal.length && (urlData = urlData + "&searchtxt=" + searchVal, fromIndex = 1), this.options.relatedAcc && (urlData = urlData + "&relid=" + this.options.relatedAcc), this._isDefault() && isdefault && (urlData = urlData + "&id=" + this._convertToString(this.options.val)), ids && 0 !== ids.length && (urlData = urlData + "&id=" + ids), urlData = urlData + "&from=" + fromIndex + "&format=" + this.options.contactFormat, $.ajax({
type: "GET",
url: "/recruit/getContactsList.do",
dataType: "json",
async: !1,
data: urlData,
beforeSend: function() {
Utils.showHideLoadingDiv(!0)
},
success: function(resp) {
base.isLoadContactsMore = !1, data = resp
},
error: function() {
data = [{
error: "FAILURE",
message: Message.ERROR,
item: []
}]
},
complete: function() {
Utils.showHideLoadingDiv(!1)
}
})
}
return data
},
_bindEvent: function() {
var base = this;
this._baseElem.on("click.ulistdrop", function(event) {
var tgt = $(event.target);
if (tgt.is("li") || tgt.parent().is("li") || tgt.is("img")) {
var elem = tgt.is("li") ? event.target : tgt.is("img") ? tgt.parents("li")[0] : $(tgt.parent())[0],
type = $(elem).data("type");
!type || "Users" !== type && "Groups" !== type && "Contacts" !== type ? (base._select(elem), base.options.multiple === !0 && base._stopEvent(event)) : base._changeTabMenu($(elem), type)
} else if (tgt.is("input"))
base._stopEvent(event);
else if (tgt.parent().is(Selector.TABBASE)) {
var elem = tgt.is("li") ? event.target : $(tgt.parent())[0],
type = elem.data("type");
base._tabDropdown.find(Selector.ACTIVE).removeClass(ClassName.ACTIVE), "Users" === type ? (base._dropdown.removeClass(ClassName.NONE), this.options.isgroup && base._groupDropdown.addClass(ClassName.NONE), this.options.iscontacts && base._groupDropdown.addClass(ClassName.NONE)) : "Groups" === type ? (base._dropdown.addClass(ClassName.NONE), this.options.iscontacts && base._contactDropdown.addClass(ClassName.NONE), base._groupDropdown.removeClass(ClassName.NONE)) : "Contacts" === type && (base._dropdown.addClass(ClassName.NONE), this.options.isgroup && base._groupDropdown.addClass(ClassName.NONE), base._contactDropdown.removeClass(ClassName.NONE)), elem.find("a").addClass(ClassName.ACTIVE), base._stopEvent(event)
}
}).on("keydown.ulistdropkey", function(event) {
var tgt = $(event.target),
$ul = base._baseElem.find(Selector.NOTABUL),
$drop = $ul.filter(Selector.VISIBLE).find(Selector.LI);
base._keyPress($drop, tgt, event)
}).on("keyup.ulistinputkey", function(event) {
var tgt = $(event.target);
tgt.is("input") && (base.storeUserData === !1 && -1 === $.inArray(event.keyCode, base.options.keyCodeList) ? (clearTimeout(base.options.userCompTimeoutId), base.options.userCompTimeoutId = setTimeout(function() {
base._search(tgt, event)
}, base.options.searchDelay)) : base._search(tgt, event), base._setFocus())
}).on("mouseover", function(event) {
var tgt = $(event.target);
tgt.hasClass("ulist-deactivated-user") && zctt.showtt(I18n.getMsg("DeactiveUser"), void 0, void 0, void 0, "false")
}).on("mouseout", function(event) {
var tgt = $(event.target);
tgt.hasClass("ulist-deactivated-user") && zctt.hidett(!0)
})
},
_keyPress: function($li, elem, event) {
var base = this;
switch (event.keyCode) {
case 40:
base._next($li);
break;
case 38:
base._prev($li);
break;
case 32:
case 13:
elem.is("input") || base._enter($li.filter(Selector.SELECTED));
break;
case 27:
base._escape()
}
},
_nextNode: function(elem, $first) {
var $next = elem && 0 !== elem.length ? elem.is(Selector.VISIBLE) ? elem : this._nextNode(elem.next()) : $first;
return $next && $next.hasClass("hdng") ? $next.next() : $next
},
_next: function(elem) {
var $this = $(elem),
$first = $this.eq(0),
$next = this._nextNode($this.filter(Selector.SELECTED).next(), $first),
selected = $next && 0 !== $next.length ? $next : $first;
$this.removeClass(ClassName.SELECTED), $(selected).addClass(ClassName.SELECTED).focus(), this._callback("next", $(selected))
},
_prevNode: function(elem, $last) {
var $next = elem && 0 !== elem.length ? elem.is(Selector.VISIBLE) ? elem : this._prevNode(elem.prev()) : $last;
return $next && $next.hasClass("hdng") ? $next.prev() : $next
},
_prev: function(elem) {
var $this = $(elem),
len = $this.length,
$last = $this.eq(len - 1),
$prev = this._prevNode($this.filter(Selector.SELECTED).prev(), $last),
selected = $prev && 0 !== $prev.length ? $prev : $last;
$this.removeClass(ClassName.SELECTED), $(selected).addClass(ClassName.SELECTED).focus(), this._callback("prev", $(selected))
},
_enter: function($li) {
this._baseElem.hasClass(ClassName.NONE) ? this._openItem() : this._select($li)
},
_escape: function() {
this._closeItem()
},
_search: function(tgt, event) {
var showNext = this.options.shownext,
base = this,
searchVal = tgt.val(),
action = this.options.action,
selTab = base._tabDropdown ? base._tabDropdown.find(Selector.ACTIVE).parent().data("type") : "",
noOption = this._noOption(),
id = this._getId(),
selected = this._baseElem.data("selected"),
showNextContacts = this.options.shownextcontacts,
$dropUl = selTab.length > 0 && "Groups" === selTab ? base._groupDropdown : base._dropdown,
$li = $dropUl.find(Selector.LI);
if ($dropUl = selTab.length > 0 && "Contacts" === selTab ? base._contactDropdown : $dropUl, $li = $dropUl.find(Selector.LI), $li.filter(Selector.ERROR).remove(), void 0 !== searchVal && searchVal.length >= base.options.minlength) {
if (searchVal = searchVal.toLowerCase(), searchVal.length <= 25)
if ("Contacts" === selTab && showNextContacts && this._contactDropdown) {
$("#" + id + "-uautores").remove(), this._contactDropdown.addClass(ClassName.NONE);
var data = this._fetchContactsData({
search: searchVal
}),
item = data && "success" === data.message ? data.contactList : [],
searchUl = this._contactDropdown.clone().html(this._getItem(item, "user"));
this._contactDropdown.after(searchUl.attr("id", id + "-uautores").show()), selected && 0 !== selected.length && $.each(selected, function(i, item) {
var $dropli = base._baseElem.find(Selector.UL).next().find("li[data-id='" + item.id + "']");
0 !== $dropli.length && base._applyClass($dropli, action)
})
} else if (showNext) {
$("#" + id + "-uautores").remove(), this._dropdown.addClass(ClassName.NONE);
var data = this._fetchData({
search: searchVal
}),
item = data && "success" === data.message ? data.userList : [],
searchUl = this._dropdown.clone().html(this._getItem(item, "user"));
this._dropdown.after(searchUl.attr("id", id + "-uautores").show()), selected && 0 !== selected.length && $.each(selected, function(i, item) {
var $dropli = base._baseElem.find(Selector.UL).next().find("li[data-id='" + item.id + "']");
0 !== $dropli.length && base._applyClass($dropli, action)
})
} else
$.each($li, function(i, item) {
var data = $(item).text(),
data = data && 0 !== data.length ? data.toLowerCase() : data;
data.indexOf(searchVal) > -1 ? $(item).show() : $(item).hide()
}), 0 === $li.filter(Selector.VISIBLE).length && ($li.filter(Selector.ERROR).remove(), $dropUl.append(noOption))
} else
$dropUl.find(Selector.LI).removeAttr(Selector.STYLE), 0 === $dropUl.find(Selector.LI).filter(Selector.VISIBLE).length ? $dropUl.append(noOption) : $li.filter(Selector.ERROR).remove(), (showNext || showNextContacts) && ($("#" + id + "-uautores").remove(), $dropUl.removeClass(ClassName.NONE));
this._getPosition(), this._callback("search"), this._stopEvent(event)
},
_scroll: function() {
var base = this;
this._dropdown.unbind("scroll").bind("scroll", function() {
{
var $this = $(this),
height = this.scrollHeight - $this.height(),
scroll = $this.scrollTop(),
isScrolledToEnd = scroll >= height - 50,
newItem = [];
base._baseElem.find(Selector.INPUT).val()
}
if (isScrolledToEnd && base.options.shownext) {
base.options.from = parseInt(base.options.from) + parseInt(base.options.to);
var data = base._fetchData({
group: !1,
isdefault: !1
}),
item = data && "success" === data.message ? data.userList : [],
selected = base._baseElem.data("selected"),
selected = selected ? selected : [];
0 !== selected.length ? $.each(item, function(i, liItem) {
var userIdNotPresent = !0;
$.each(selected, function(j, selUserObj) {
return liItem.id === base._convertToString(selUserObj.id) ? (userIdNotPresent = !1, !1) : void 0
}), userIdNotPresent && newItem.push(liItem)
}) : newItem = item, base.options.shownext = data && "success" === data.message ? data.showNext : !1, base._dropdown.append(base._getItem(newItem, "user")), base._callback("scroll")
}
}), this.options.iscontacts && this._contactDropdown && this._contactDropdown.unbind("scroll").bind("scroll", function() {
{
var $this = $(this),
height = this.scrollHeight - $this.height(),
scroll = $this.scrollTop(),
isScrolledToEnd = scroll >= height - 50,
newItem = [];
base._baseElem.find(Selector.INPUT).val()
}
if (isScrolledToEnd && base.options.shownextcontacts) {
base.options.fromContacts = parseInt(base.options.fromContacts) + parseInt(base.options.toContacts);
var data = base._fetchContactsData({
isdefault: !1
}),
item = data && "success" === data.message ? data.contactList : [],
selected = base._baseElem.data("selected"),
selected = selected ? selected : [];
0 !== selected.length ? $.each(item, function(i, liItem) {
var contactIdNotPresent = !0;
$.each(selected, function(j, selContactObj) {
return liItem.id === base._convertToString(selContactObj.id) ? (contactIdNotPresent = !1, !1) : void 0
}), contactIdNotPresent && newItem.push(liItem)
}) : newItem = item, base.options.shownextcontacts = data && "success" === data.message ? data.showNext : !1, base._contactDropdown.append(base._getItem(newItem, "contact")), base._callback("scroll")
}
})
},
_select: function(tgt) {
{
var $this = $(tgt),
base = this,
item = $this.data();
base.options.action
}
if (!($this.hasClass(ClassName.ACTIVE) || $this.hasClass(ClassName.HIDDEN) || $this.hasClass(ClassName.NONE) || $this.hasClass(ClassName.ERROR) || $this.hasClass("hdng"))) {
if ("contact" === item.type)
if (base.options.multiple) {
var selected = base._baseElem.data("selected"),
selected = selected ? selected : [],
associatedContacts = (selected.length, item && item.item && item.item.hasOwnProperty("associatedContacts") ? item.item.associatedContacts : []);
if (base._maxSelectCheck(selected.length))
return base._callback("maxerror"), void base._closeItem();
if (associatedContacts.length > 0) {
if (selected.length > 0) {
var unselectedContactIds = [];
$.each(associatedContacts, function(i, asscontactId) {
var contactIdNotPresent = !0;
$.each(selected, function(i, selContactObj) {
return base._convertToString(selContactObj.id) === asscontactId ? (contactIdNotPresent = !1, !1) : void 0
}), contactIdNotPresent && unselectedContactIds.push(asscontac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment