console-api |
log |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21231)
Message:
JQMIGRATE: Migrate is installed with logging active, version 1.4.1
|
console-api |
debug |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 16080)
Message:
Assigning value to moduleName SelectPlusField [object Object]
|
console-api |
debug |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 16080)
Message:
Assigning value to moduleName Lib function Lib(init) {
// see if instantiation should return global instance
if (init && init.getGlobalInstance && window.top._lib) {
return window.top._lib;
} // check for and set global instance
if (!window.top._lib) {
window.top._lib = this;
} // It's not good form, but these locals are used to help with staged lookup.
var isActiveDirectory = init.isActiveDirectory; // <%= (companyRecord.get("AUTH_URL") != null) %>;
var companyId = init.companyId; // <% out.println("'" + companyId + "'" + ";"); %>
var sessionId = init.sessionId; // '<%= key %>'
var onLoadCallback = init.onLoad || function () {}; // function to call when Lib instance has been assembled
this.isDevMode = configuration.developmentMode; // flag indicating if all JS components have been loaded...affects behavior of error reporting
this.loaded = false;
var _this = this; // collection of nodes used in setParent() and assureChildrenMatch()
var parents = []; // collection of nodes used in setParent() and assureParentSelected()
var kids = []; // collection used in initPageCollapse() and pageCollapse()
var hiddenDivs = {}; // collection used in getCheckboxElement() and setCheckboxElements()
var checkboxElements = [];
var jqueryUniversalChangeSupportedTags = ":input[type!=hidden]";
var jqueryUniversalChangeSupportedEvents = ["change", "select", "click", "blur"]; // cached result of call to perform_cookie_test()
var cookie_test = false;
/**
* Selector string used to serve as context for calls to addDependentField. If null, will use document
* as context (is used to search for a field ONLY in context of modal content).
*
* @type {string}
*/
var dependentFieldCtx = null;
/**
* Simple function used to log message strings and Error instances to the console, if the console object
* is available (may not be in older browser environments). Will only log if isDevMode is true.
*
* @param {string|Error} message
* @param {boolean} [override] if present and true, will log whether or not in dev mode
*/
var _log = function log(message, override) {
return logger.log(message);
}; // init accessNextPage and loading flags
setGlobalData("Lib.accessNextPage", true);
setGlobalData("Lib.loading", false); // internal helper functions
/**
* Sets a global attribute value. Will log and ignore if unable to do so (i.e. window.top is disposed).
*
* @param key
* @param value
*/
function setGlobalData(key, value) {
_log("Setting '".concat(key, "' attribute to value '").concat(value, "'"));
try {
if (window && window.top) {
$(window.top).data(key, value);
} else {
_log("Can not set '".concat(key, "' attribute with value '").concat(value, "', top window is not available."));
}
} catch (e) {
// getting 'Can't execute code from a freed script' errors in IE...just log and return
_log(new Error("Can not set '".concat(key, "' attribute with value '").concat(value, "': ").concat(e.message)));
}
}
/**
* Gets a global attribute value. Will log and return null if unable to do so (i.e. window.top is disposed).
*
* @param key
* @returns {*}
*/
function getGlobalData(key) {
_log("Getting '".concat(key, "' attribute value."));
try {
if (window && window.top) {
var value = $(window.top).data(key);
_log("Attribute '".concat(key, "' has value '").concat(value, "'"));
return value;
} else {
_log("Can not get '".concat(key, "' attribute value, top window is not available."));
return null;
}
} catch (e) {
// getting 'Can't execute code from a freed script' errors in IE...just log and return null
_log(new Error("Can not get '".concat(key, "' attribute value: ").concat(e.message)));
return null;
}
}
/**
* Ensures that needed jQuery plugins have been loaded. Performs synchronous loading if not found.
* Returns reference to $.
*
* @param {Window} win context window
* @param {jQuery} jq the jQuery object being examined
* @returns {jQuery}
*/
function checkJQuery(win, jq) {
return jq || win.$ || $;
}
/**
* Obtains the Modal instance for the given window namespace.
*
* @param win
* @returns {Modal}
*/
function getModal(win) {
return win.document.thismodal;
}
/**
* Is called to create and open a new Modal instance using a set of default properties. The init object will
* override any defaults. An additional optional boolean may be provided to specify if instance should
* be assigned to the global modal variable (i.e. make new instance retrievable in call to {@link getModal()}.
*
* @param {Window} win the context Window
* @param {Object} init object used to initialize Modal (may contain 'attributes' property that is iterated
* through and each added to Modal attributes)
* @param {boolean} [makeGlobal] optional flag indicating if this instance should be set as global instance (default is false)
*
* @returns {Modal}
*/
function createModal(win, init, makeGlobal) {
// is called to perform style fixes on modal after it is opened
function fixDisplay(modal) {
doModalContentFix(win, modal);
}
function resizeHandler(e) {
_log("Doing resize!!!");
triggerResize(win, false);
}
init = init || {};
init.paddingTop = 80;
init.onOpen = mergeFunctions(init.onOpen, function (modal) {
$(win).on("resize", resizeHandler);
fixDisplay(modal);
});
init.onClose = mergeFunctions(init.onClose, function () {
return $(win).off("resize", resizeHandler);
});
init.openOnCreate = false; // do NOT allow for creation before setting global instance
init.context = win;
var modal = Modal.createModal(init);
if (modal) {
if (makeGlobal) {
win.document.thismodal = modal;
}
modal.open();
}
return modal;
}
/**
* Performs style/behavior fixes on Modal and content.
*
* @param win
* @param modal
*/
function doModalContentFix(win, modal) {
var content = $(modal.getContent(true));
var $content = $(content);
$content.closest(".vex").css("padding-top", "40px");
$content.closest(".vex").find(".vex-dialog-input").css("overflow", "auto"); // also, remove PageParagraphContainer/PageMainContainer ids to remove static CSS widths
$content.find("#PageParagraphContainer").removeAttr("id");
$content.find("#PageMainContainer").removeAttr("id"); // give buttons same LnF as Modal buttons
$content.find("input[type=\"submit\"], input[type=\"reset\"], input[type=\"file\"]").addClass("vex-dialog-button vex-dialog-button-primary ss-modal-ok").css({
"margin-top": "5px",
"float": "none"
}); // Prevent submit button from being clicked multiple times
$content.find("input[type=\"submit\"]").click(function () {
var $footContainer = $content.find("#footContainer");
var $pagebuttons = $footContainer.find(".pagebuttons");
$pagebuttons.hide();
$footContainer.append($("<img src=\"https://cdn.searchsoft.net/images/loading.gif\" class=\"preventMultipleSubmitButtonClickSpinner\" />"));
});
$content.find("input[type=\"button\"]").addClass("vex-dialog-button vex-dialog-button-secondary ss-modal-cancel").css({
"margin-top": "5px",
"float": "none"
});
$(".linkbutton, .wizardlink").click(function () {
return win.setTimeout(function () {
doModalContentFix(win, modal);
triggerResize(win, false);
}, 15);
});
}
/**
* Is called to do an operation with the current Modal instance, if it is non-null and only if its open,
* if the ifOpen flag is true. The callback will be provided the Modal instance and reference to the Modal
* content (as a jQuery object) as args (i.e. function(modal, jq) { // do something } ).
*
* @param win
* @param ifOpen
* @param fn
*/
function doModalOp(win, ifOpen, fn) {
var modal = getModal(win);
if (!modal) {
return;
}
if (!modal.isOpen() && ifOpen) {
return;
}
try {
fn(modal, modal.getContent(true));
} catch (e) {
// this could POTENTIALLY be called on a modal in a frame that has expired...catch, log and continue
_log(e);
}
}
/**
* Is called to trigger events and handle common behavior when content has changed such that re-flow or
* resizing of content should occur.
*
* @param win
* @param {boolean} [doTrigger] optional boolean flag indicating if 'resize' event should be triggered (default is true)
* @param {boolean} [keepWidth] optional boolean flag indicating if resizing should constrain width (default is false)
*/
function triggerResize(win, doTrigger, keepWidth) {
doTrigger = doTrigger !== false;
if (doTrigger) {
$(win).triggerHandler("resize");
}
keepWidth = keepWidth === true;
doModalOp(win, true, function (modal, content) {
var queue = win["_triggerResizeQueue"] || {
/**
* @type {number}
*/
"timeoutId": null
};
win["_triggerResizeQueue"] = queue;
if (queue.timeoutId !== null) {
window.clearTimeout(queue.timeoutId);
}
queue.timeoutId = window.setTimeout(function () {
try {
modal.resizeContent(keepWidth);
} catch (e) {
// as this being called in a timeout, modal may be contained in an expired frame...
_log(e);
}
}, 15);
});
}
function isChecked(win, id) {
var elem = getCheckboxElement(win, id);
return elem.checked;
}
function getCheckboxElement(win, id) {
return checkboxElements[id];
}
function checkCheckBox(win, id, val, doParent) {
var elem = getCheckboxElement(win, id);
if (elem) {
elem.checked = val;
if (doParent) {
lib.assureParentSelected(win, id);
}
}
return true;
}
function emailCheck(emailStr, win, field) {
/* The following pattern is used to check if the entered e-mail address
fits the user@domain format. It also is used to separate the username
from the domain. */
var emailPat = /^\s*(.+)@(.+)$/;
/* The following represents chars _not_ allowed in an local part of an address
These characters include ( ) < > @ , ; : \ " . [ ] Where . is later allowed
back in. */
var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
/* The following string represents the range of characters allowed in a
username or domainname. It really states which chars aren't allowed.*/
var validChars = "[^\\s".concat(specialChars, "]");
/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes). E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */
var quotedUser = "(\"[^\"]*\")";
/* The following string represents an atom (basically a series of non-special characters.) */
var atom = "".concat(validChars, "+");
/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */
var word = "(".concat(atom, "|").concat(quotedUser, ")"); // The following pattern describes the structure of the user
var userPat = new RegExp("^".concat(word, "(\\.").concat(word, ")*$"));
/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. Domain atom must be two or
more chars and not start or end with a '-' */
var domainAtom = "[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9]+)*";
var domainPat = new RegExp("^".concat(domainAtom, "(\\.").concat(domainAtom, ")+\\s*$"));
/* The following pattern applies for domains that are IP addresses,
rather than symbolic nam es. E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */
var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
/* Finally, let's start trying to figure out if the supplied address is valid. */
/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */
var matchArray = emailStr.match(emailPat);
if (matchArray == null) {
/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */
invalidField(win, field, "The email address seems incorrect (check @ and .'s)");
return false;
}
var user = matchArray[1];
var domain = matchArray[2]; // Start by checking that only basic ASCII characters are in the strings (0-127).
for (var i = 0; i < user.length; i++) {
if (user.charCodeAt(i) > 127) {
invalidField(win, field, "The email username contains invalid characters.");
return false;
}
} // See if "user" is valid
if (user.match(userPat) == null) {
// user is not valid
invalidField(win, field, "The email username doesn't seem to be valid.");
return false;
}
/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */
var IPArray = domain.match(ipDomainPat);
if (IPArray != null) {
// this is an IP address
for (var _i = 1; _i <= 4; _i++) {
if (IPArray[_i] > 255) {
invalidField(win, field, "Email destination IP address is invalid!");
return false;
}
} // the remain tests are not valid
return true;
} // Domain is symbolic name. Check if it's valid.
var domArr = domain.match(domainPat);
if (domArr == null) {
invalidField(win, field, "The email domain name does not seem to be valid.");
return false;
} // confirm that tld is two more more, note sub-group is always assigned last match
if (!(domArr[1].length > 2)) {
invalidField(win, field, "The email address has an invalid tld domain. Are you missing .com?");
return false;
} // Confirm domain is not overly long
if (domain.length > 255) {
invalidField(win, field, "The email address has to long a domain name.");
return false;
} // Confirm peices of domain are not indivuial to long
for (var _i2 = 0; _i2 < domArr.length - 1; _i2++) {
if (domArr[_i2].length > 63) {
invalidField(win, field, "The email address domain name is to long.");
return false;
}
} // If we've gotten this far, everything's valid!
return true;
}
function getFieldValue(win, field) {
// Passing win as an argument to fix "Permission denied" error in IE
// SSOFT-5666
var $ = win.$;
var value = "";
var type = field.type || $(field).attr("type");
if (type) {
if (type.indexOf("select-") >= 0) {
if (field.selectedIndex >= 0) {
value = field.options[field.selectedIndex].value;
}
} else if (type.indexOf("check") >= 0 || type.indexOf("radio") >= 0) {
if (field.checked) {
value = field.value;
}
if (field.length) {
for (var j = 0; j < field.length; j++) {
if (field[j].checked) {
value = field[j].value;
}
}
}
} else {
value = field.value;
}
} else if (field.length) {
// I think this code is making an assumption
// that if there is no 'type' then it must be a
// checkbox.
for (var _j = 0; _j < field.length; _j++) {
if (field[_j].checked) {
value = field[_j].value;
}
}
}
if (value == null) {
value = "";
}
return value;
}
/**
* Replaces a old Field's listeners' with a pointer to the new field.
**/
function reassignFieldListeners(oldField, newField) {
// find the form, assume all fields are in the same form
var form;
if (oldField.length) {
form = oldField[0].form;
} else {
form = oldField.form;
} // if we couldn't find the form, give up. This means were using an oldField
// not in a form anymore. This should never happen.
if (!form) {
return;
}
for (var i = 0; i < form.validatorFields.length; i++) {
if (form.validatorFields[i] == oldField) {
form.validatorFields[i] = newField;
}
}
for (var _i3 = 0; _i3 < form.maskValidatorFields.length; _i3++) {
if (form.maskValidatorFields[_i3] == oldField) {
form.maskValidatorFields[_i3] = newField;
}
}
}
/**
* Checks newField against the listeners of oldField.
**/
function validNewField(win, oldField, newField) {
// Hack that fixes https://peopleadmin.atlassian.net/browse/SSOFT-5354?focusedCommentId=231565&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-231565
if (newField[0] === undefined) {
newField[0] = oldField[0];
} // find the form
var form;
if (oldField.length) {
form = oldField[0].form;
} else {
form = oldField.form;
} // if we couldn't find the form, say its valid. This means were validating
// against a field not in a form anymore. This should never happen.
if (!form) {
return true;
} // run over all validation function and run them against the new field
for (var i = 0; i < form.validatorFields.length; i++) {
if (form.validatorFields[i] == oldField) {
if (!form.validatorFunctions[i](win, newField)) {
return false;
}
}
}
for (var _i4 = 0; _i4 < form.maskValidatorFields.length; _i4++) {
if (form.maskValidatorFields[_i4] == oldField) {
if (!form.maskValidatorFunctions[_i4](win, newField, form.maskValidatorMasks[_i4])) {
return false;
}
}
}
return true;
}
/**
* Run all validator functions for a specified form.
**/
function validFields(win, form) {
win.runningValidFields = true;
for (var i = 0; i < form.validatorFunctions.length; i += 1) {
// if the field is not in the checking form anymore ignore it
if (!fieldInForm(form, form.validatorFields[i])) {
continue;
} // run the listeners
if (!form.validatorFunctions[i](win, form.validatorFields[i])) {
win.runningValidFields = false;
return false;
}
}
for (var j = 0; j < form.maskValidatorFunctions.length; j += 1) {
// if the field is not in the checking form anymore ignore it
if (!fieldInForm(form, form.maskValidatorFields[j])) {
continue;
} // run the listeners
if (!form.maskValidatorFunctions[j](win, form.maskValidatorFields[j], form.maskValidatorMasks[j])) {
invalidField(win, form.maskValidatorFields[j], "".concat(form.maskValidatorFields[j].value, " is not in the correct format."));
win.runningValidFields = false;
return false;
}
}
win.runningValidFields = false;
return true;
}
/**
* Test if a field is in a given form (wrapper).
**/
function fieldInForm(form, field) {
// defines a private function to do the real work
function fieldInFormReal(field) {
for (var i = 0; i < form.elements.length; i++) {
if (form.elements[i] == field) {
return true;
}
}
return false;
} // if field is not defined, claim it exists
if (!!!field) {
return true;
} // if array test for each
// if it has a length and not a type
if (field.length && !field.type) {
// when less than 500 check all fields
if (field.length < 500) {
for (var i = 0; i < field.length; i++) {
if (!fieldInFormReal(field[i])) {
return false;
}
}
} // performance hack for IE, if one exists all exist
else {
if (!fieldInFormReal(field[0])) {
return false;
}
}
return true;
} // field is defined check that it is in the form
return fieldInFormReal(field);
}
function getMultiNumberChecked(win, fields) {
var numberChecked = 0; // array of check-box, radio, option, or select
if (fields.length) {
for (var i = 0; i < fields.length; i++) {
// check-box, radio
if (fields[i].checked) {
numberChecked++;
} // option
else {
if (fields[i].selected) {
numberChecked++;
} // select
else {
if (fields[i].options) {
numberChecked += getMultiNumberChecked(win, fields[i].options);
}
}
}
}
} // select object
else if (fields.options && fields.options.length > 0) {
numberChecked = getMultiNumberChecked(win, fields.options);
} // single field
else if (fields.checked || fields.selected) {
numberChecked = 1;
}
return numberChecked;
}
/**
* Returns array of form objects that have an element that matches
* fieldName.
**/
function getFormObjects(win, fieldName) {
var result = [];
var forms = win.document.forms;
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
if (form.elements[fieldName]) {
result.push(form);
}
}
return result;
}
function stripSymbols(field) {
var value = field.value;
if (value !== undefined) {
field.value = value.replace(/(\$|\,|\(|\)|\&)/g, "");
}
}
function getFormattedDate(field, shortDate) {
var date = field.value.replace("-", "/");
var li = date.lastIndexOf("/");
if (date.length - li == 3) {
var cent = "20";
var yr = date.substring(li + 1, li + 3);
if (yr > "30") {
cent = "19";
}
date = date.substring(0, li + 1) + cent + yr;
}
return date;
}
function isValidDate(value, shortDate) {
var month;
var day;
var year;
var date;
var i;
for (i = 1; i < value.length; i++) {
var testValue = value.substring(i, i + 1);
if (isNaN(testValue) && testValue != "/" && testValue != "-" && testValue == " ") {
return false;
}
}
date = value;
if (date != "") {
i = date.indexOf("/");
if (i < 1) {
return false;
}
month = date.substring(0, i);
if (month.length < 1 || month.length > 2 || month.charAt(0) > "9" || month == 0 && i == 1) {
// || month.charAt(0)<'0'
return false;
}
if (month.substring(0, 1) == "0") {
month = month.substring(1, 2);
}
month = parseInt(month);
if (!shortDate) {
date = date.substring(i + 1);
i = date.indexOf("/");
if (i < 1) {
return false;
}
day = date.substring(0, i);
if (day.length < 1 || day.length > 2 || day.charAt(0) > "9") {
// || day.charAt(0)<'0'
return false;
}
if (day.substring(0, 1) == "0") {
day = day.substring(1, 2);
}
day = parseInt(day);
}
year = date.substring(i + 1);
if (year.length != 4 || year.charAt(0) < "0" || year.charAt(0) > "9") {
return false;
}
year = parseInt(year);
if (month < 1 || month > 12 || day < 1 || day > 31 || year < 1900 || year > 2299 || month == 2 && day > 29 || month == 2 && day == 29 && year % 4 != 0 || month == 4 && day > 30 || month == 6 && day > 30 || month == 9 && day > 30 || month == 11 && day > 30) {
return false;
}
}
return true;
}
function isValidBirthDate(field, shortdate, young, old) {
var result = true;
var birthValue = field.value;
if (shortdate) {
birthValue = birthValue.replace(/\//, "/01/");
}
var birthDate = new Date(birthValue);
var lowDate = new Date();
var highDate = new Date();
lowDate.setFullYear(lowDate.getFullYear() - old);
highDate.setFullYear(highDate.getFullYear() - young);
result = birthDate >= lowDate && birthDate <= highDate;
return result;
}
function isValidDateTime(field) {
var thisFieldValue = field.value;
var splitDate = thisFieldValue.split(" ");
if (splitDate.length != 3) {
return false;
}
if (!isValidDate(splitDate[0]), false) {
return false;
}
if (!isValidStandardTime(splitDate)) {
return false;
}
return true;
}
function isValidStandardTime(timeString) {
// We are expecting a 3-part date, time, and am/pm array
if (timeString.length != 3) {
return false;
}
if (timeString[1].length != 5) {
return false;
}
if (timeString[2].length != 2) {
return false;
}
var testValue = timeString[1].substring(0, 2);
if (isNaN(testValue)) {
return false;
}
if (timeString[1].charAt(2) != ":") {
return false;
}
var testValue = timeString[1].substring(3, 5);
if (isNaN(testValue)) {
return false;
}
if (timeString[2].toLowerCase() != "am" && timeString[2].toLowerCase() != "pm") {
return false;
}
return true;
}
function isValidNumber(num) {
var i;
var dc;
if (num.value != "") {
i = 0;
if (num.charAt(0) == "-") {
i = 1;
if (num.length == 1) {
return false;
}
}
dc = 0;
for (; i < num.length; i++) {
if (num.charAt(i) == ".") {
if (dc > 0 || i == num.length - 1) {
return false;
}
dc++;
} else if (num.charAt(i) < "0" || num.charAt(i) > "9") {
return false;
}
}
}
return true;
}
/**
* Adds fun (function) to element with an apporiate on change listener
*
* @param elem is dom
**/
function jqueryUniversalChange(win, elem, fun) {
var $ = win.$;
$(elem).bind(jqueryUniversalTriggerType(win, elem), fun);
}
function jqueryUniversalTriggerType(win, elem) {
// For SSOFT-5625
// In Internet Explorer 11/Edge, the attr call below was causing a "Permission denied" error
var $ = win.$;
var triggerType;
switch (elem.tagName.toUpperCase()) {
case "INPUT":
switch ($(elem).attr("type").toUpperCase()) {
case "RADIO":
case "CHECKBOX":
case "BUTTON":
triggerType = "click change";
break;
case "PASSWORD":
case "TEXT":
triggerType = "blur change";
break;
case "FILE":
triggerType = "change";
break;
default:
triggerType = "change select click blur";
break;
}
break;
case "TEXTAREA":
triggerType = "blur change";
break;
case "SELECT":
triggerType = "blur change";
break;
default:
triggerType = "change select click blur";
break;
}
return triggerType;
}
/**
* Is called to ensure that username conforms to rules and standards.
*
* @param win
* @param username
* @param password
* @returns {boolean}
*/
function checkFormatting(win, username, password) {
var p = password;
var u = username;
var message = "";
var result = true;
var low = 6;
if (companyId != "00008698" && !isActiveDirectory && win.document.location.href.indexOf("employee_form") < 0) {
// Account Information Page (Applicants can change just their username)
if ((p == null || p.value == "") && u != null && u.value != "") {
u = u.value;
if (u.length < low) {
message = "The username is invalid. Usernames must be at least ".concat(low, " characters in length, should not include spaces, and must not be identical to the password.");
invalidField(win, username, message);
result = false;
}
}
}
return result;
}
function makeTestCookie() {
document.cookie = "cookietest=yes;path=/";
}
function findTestCookie() {
if (document.cookie.length > 0 && window.navigator.cookieEnabled) {
var test = document.cookie.indexOf("cookietest=");
if (test !== -1) {
return true;
}
}
return false;
}
/**
* Toolbox, binds pop-up to a select box.
**/
function toolboxRegisterSelection(win, uid) {
var $ = win.$;
var actionSelect = $("#".concat(uid, "_action_select"));
var myForm = actionSelect.closest("form"); // add a content section if one does not exist
if (!myForm.find("#inlineContent").length) {
myForm.append("<div id=\"inlineContent\" style=\"height: 30ex\"></div>");
}
var onDefaultActionOrUndo = function onDefaultActionOrUndo() {
$("#inlineContent").html("").css("height", "30ex"); // Reactivate button-based tools
win.toolbox[uid]._parent.append(win.toolbox[uid]);
}; // HE-3345 (https://jira.powerschool.com/browse/HE-3345?focusedCommentId=2294798&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-2294798)
// Whenever undo button is clicked, removes the fields related to the previous selected value on Workflow Forms
$("form input:reset[name=\"undo\"]").click(function () {
return onDefaultActionOrUndo();
});
actionSelect.change(function () {
// what item is selected
var item = $("#".concat(uid, "_action_select option:selected")).attr("value");
var autoSubmit = false; // bail if default
if (item == "default") {
onDefaultActionOrUndo();
return false;
} else {
// Deactivate button-based tools
win.toolbox = win.toolbox || {};
win.toolbox[uid] = win.toolbox[uid] || $("#toolbox_".concat(uid));
win.toolbox[uid]._parent = win.toolbox[uid]._parent || win.toolbox[uid].parent();
$("#toolbox_".concat(uid)).remove();
} // is there a hidden div
if ($("#".concat(item)).length) {
// get content
var content = $("#".concat(item)).clone();
content.attr("class", content.attr("id"));
content.attr("id", "");
$("#inlineContent").html(" ").append(content);
content.show();
} // if no hidden content auto-submit
else {
autoSubmit = true;
}
toolboxRunFunction(win, item);
if (autoSubmit) {
// if no hidden content
win.document.forms[0].submit();
}
});
}
/**
* Toolbox, bind pop-up to "Go" button.
**/
function toolboxRegisterActionGo(win, uid) {
var $ = win.$; // bind to click of button
$("#".concat(uid, "_go")).click(function () {
var $ = win.$; // what item is selected
var item = $("#".concat(uid, "_action_select option:selected")).attr("value");
var autoSubmit = false; // bail on default action
if (item === "default") {
win.alert("Please select an action to perform.");
return false;
}
var allRecordsInTheListAllPagesSelected = $("select[name=\"ACTION_TYPE\"]").val() === "all";
if (allRecordsInTheListAllPagesSelected) {
// "Assign Document(s)" action
if (item === "RA00000002") {
win.alert("At most 100 recipients can be assigned eForms at a time. Please select no more than 100 recipients and try again.");
return false;
}
} else if ($("div.rs tbody :checkbox:checked").length === 0) {
// when no items selected bail
win.alert("Please select the records on which to perform the action.");
return false;
} // is there a hidden div
if ($("#".concat(item)).length) {
lib.showPopup(win, item);
} // if no hidden content auto-submit
else {
autoSubmit = true; // run action's funciton if exists
if (!toolboxRunFunction(win, item)) {
// no function add a hidden input option=option (as we are autosubmiting)
lib.addHiddenField(win, item, item);
}
}
if (autoSubmit) {
// if no hidden content
win.document.forms[0].submit();
}
});
}
function closePopupFirst(win, fun) {
Modal.closeAll(win, function () {
return fun(win);
});
}
/**
* Toolbox utilty, run function tied to a option. If the function is not
* defined return false.
**/
function toolboxRunFunction(win, fun) {
// confirm we have functions and this function is defined
if (!win.toolboxFunctions || !win.toolboxFunctions[fun]) {
return false;
} // run the function
try {
win.toolboxFunctions[fun]();
triggerResize(win);
} catch (e) {
return false;
}
return true;
}
/**
* Toolbox utility, add and enable a cancel button to popups
**/
function toolboxAddCancel(win, item) {
doModalOp(win, true, function (modal, content) {
modal.enableCancel(true); // need to ensure that all 'Cancel' button just close Modal (and not do history-back behavior)
$(content).find("input[name='cancel']").attr("onclick", "").click(function (e) {
e.preventDefault();
modal.close();
return false;
});
});
}
/**
* Returns true if the provided url and request data are valid for making an Ajax call to server. This is
* needed to overcome issues where library.js adds unintended behavior to elements, such that spurious
* Ajax calls are made.
*
* @param url url of Ajax call
* @param data query string or post data to be sent in request
* @return {boolean} true if the call can be made, false if it is not valid
*/
function canMakeAjaxCall(url, data) {
if (url == "#") {
_log("NOT making Ajax call, no valid URL provided (url is '#').");
return false;
} // put additional checks here as needed
return true;
}
/**
* Toolbox utility, fill-in a popup with data.
*
* @param win window object do operate in
* @param id of div to opeerate on in pop-up
* @param url of page to fetch and display
* @param hijack if to capture submit and then close pop-up
* @param hijackStayOpen if when capturing submit to dispaly the result
**/
function ajaxFillinPopup(win, id, url, sdata, hijack, hijackStayOpen, devmode) {
if (!canMakeAjaxCall(url, sdata)) {
return;
}
var $ = win.$; // add ajax notification for server
if (sdata == null) {
sdata = "ajax=y";
} else if (sdata.indexOf("ajax=") == -1) {
sdata += "&ajax=y";
} // avoid get length limit in IE
var method = "get";
if (sdata.length + url.length > 2000) {
sdata += "&fake_post=Y";
method = "post";
} // handle error
$(win.document).ajaxError(function (event, request, settings) {
return _log("Server error: ".concat(request.status, " url: ").concat(settings.url));
}); // if a popup
var modal = getModal(win);
if (modal && modal.isOpen()) {
dependentFieldCtx = ".searchsoft-modal"; // get content
$[method](url, sdata, function (data, rstatus) {
if (rstatus == "success") {
var modalContent = $(modal.getContent(true));
var selector = "div#inlineContent";
var content = $(modalContent).find("div#inlineContent");
if (!content.length) {
content = $(modalContent).find("div#".concat(id));
selector = content.length ? "div#".concat(id) : null;
}
modal.setContent(data, selector);
content = $(modal.getContent(true)); // will return a reference to content
afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode);
} else {
throw "AJAX error getting content";
}
}, "text").always(function () {
// reset after each call
dependentFieldCtx = null;
});
} // inline
else {
// get content
$.get(url, sdata, function (data, rstatus) {
if (rstatus == "success") {
var content = $("#inlineContent div.".concat(id)).html(data);
$("#inlineContent").css("height", "auto");
afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode); // initilize forms
lib.initForms(win);
} else {
throw "AJAX error getting content";
}
}, "text");
}
}
function afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode) {
var $ = win.$; // initilize forms
lib.initForms(win); // add what applicants to effect
lib.addCheckboxApplicants(win, id); // add/enable cancel
toolboxAddCancel(win, id); // add redirect if one does not exist
addMissingPopupRedirect(win, id); // for is_changed
alwaysIsChanged(win, id); // move buttons to top of devmenu items
if (devmode) {// TODO: #modal
/*
$("#simplemodal-container div#" + id + " div.pagebuttons").css({
'position': 'absolute',
'left': '50px',
'top': '-20px'});
*/
}
if (_this.isDevMode) {
// cause menu links to open in same window
content.find(".devmenulink, .wizardpopup").addClass("wizardlink").removeClass("wizardpopup");
content.find("div.rs a[href!='#ConfirmDelete'], div.rsrange a[href!='#ConfirmDelete']").addClass("wizardlink");
devmode = true;
} // hijack submit
if (hijack) {
// allows for fancy wizard stuff
hijackPopupSubmit(win, id, sdata, hijack, hijackStayOpen, devmode);
} else {
// simply provide a spinner
popUpFormSpinner(win);
}
var modal = getModal(win);
if (modal) {
doModalContentFix(win, modal);
} // wizard links
content.find(".wizardlink").click(function (e) {
var target = $(this).attr("href"); // do check for valid call BEFORE calling preventDefault and hiding form content
if (!canMakeAjaxCall(target, null)) {
return;
}
e.preventDefault();
if (modal) {
var _content = modal.getContent(true);
$(_content).find("form").hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
ajaxFillinPopup(win, id, target, null, hijack, hijackStayOpen, devmode);
return false;
});
if (hijackStayOpen) {
var button = content.find(".linkbutton");
button.each(function () {
this.onclick = function () {
return true;
};
$(this).click(function (e) {
var target = $(this).attr("href"); // do check for valid call BEFORE calling preventDefault and hiding form content
if (!canMakeAjaxCall(target, sdata)) {
return;
}
e.preventDefault();
if (modal) {
var _content2 = modal.getContent(true);
$(_content2).find("form").hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
ajaxFillinPopup(win, id, target, sdata, hijack, hijackStayOpen, devmode);
return false;
});
});
} // normal form styles
if (modal) {
lib.addStyleClasses(win, modal.getContent(true));
}
lib.addStyleClasses(win, "#inlineContent .".concat(id));
triggerResize(win);
}
/**
* Toolbox utility; adds a redirect parameter to a form if one does not exist on the page.
**/
function addMissingPopupRedirect(win, id) {
var $ = win.$;
if (!$("input[name='searchpage']").length) {
var loc = win.location;
doModalOp(win, true, function (modal, content) {
return $(content).find("form").append("<input type=\"hidden\" name=\"searchpage\" value=\"".concat(loc.pathname).concat(loc.search, "\" />"));
});
}
}
/**
* All pop-ups always submit
**/
function alwaysIsChanged(win, id) {
var $ = win.$;
doModalOp(win, true, function (modal, content) {
return $(content).find("input[name='is_changed']").val("true");
});
}
function popUpFormSpinner(win) {
var $ = win.$; // stops double submits for slow pages
doModalOp(win, false, function (modal, content) {
return $(content).closest("form").submit(function (e) {
// test that form is valid
var form = $(this);
var formObj = form.get(0);
var checkScript = formObj.onsubmit;
var result = !checkScript || checkScript.apply(formObj);
if (!(result === false)) {
if (form.attr("target") && form.attr("action").lastIndexOf("/servlet/jasper", 0) === 0) {
// there is a "target" outside of our frame; show a message with a "back to form" link
form.hide().after("<div id='reportmessage'><p>Your report will be downloaded shortly." + " This could take up to several minutes." + " Feel free to close this window.</p>" + "<p>If your report does not download shortly, please go back and try again.</p>" + "<p><a href='#' id='submitshowformagain'> Go Back to Form </a></p></div>");
$("#submitshowformagain").click(function (e) {
e.preventDefault();
form.next("#reportmessage").remove();
form.show();
return false;
});
} else {
form.hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
} else {
e.preventDefault();
}
return result;
});
});
}
/**
* Toolbox utility; hijacks submit of a pop-up and sends with AJAX.
*
* Useful for:
* recursive submitting pop-ups (aka Wizard)
* pages that return JavaScript (aka JSON)
*
* @param win window object to operate in
* @param id of div that gets ajax
**/
function hijackPopupSubmit(win, id, sdata, hijack, stayOpen, devmode) {
var $ = win.$;
doModalOp(win, false, function (modal, content) {
return $(content).find("form:not([target])").submit(function (event) {
// stop default
event.preventDefault(); // test that form is valid
var checkScript = $(this).prop("onsubmit");
if (checkScript && !checkScript.apply(this)) {
return;
} // useful nodes
// what data and to where
var data = $(this).serialize();
data += "&ajax=y";
var actionUri = $(this).attr("action"); // is this a searching form (method=GET)
var method = $(this).attr("method");
if (method == null || method.toUpperCase() == "GET") {
method = "get";
} else {
method = "post";
} // show loading text
var div = $("<div><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>").attr("id", id);
modal.setContent(div); // AJAX submit
$[method](actionUri, data, function (rdata, rstatus) {
if (rstatus == "success") {
if (stayOpen) {
var _content3 = div.html(rdata);
afterAjaxPopProcess(win, id, _content3, sdata, hijack, stayOpen, devmode);
} else {
if (/error has occured/.test(rdata) && devmode) {
div.html("<h1> Failure </h1>");
div.append("<p>CAUTION: Developer <a id='hijackretry' href='#'>Retry</a>. Will not provide success or failure message! Check your console</p>");
div.append("<xmp> ".concat(rdata, "</xmp>"));
$("#hijackretry").click(function () {
return $.post(actionUri, data);
});
} else if (/ajaxerror/.test(rdata)) {
div.html(rdata);
} else {
div.html("<h1> Success </h1>");
modal.close();
}
}
} else {
throw new Error("AJAX error");
}
}); // stop form submit
return false;
});
});
}
/**
* Utility for missed field pop-up.
* May be removed when classic is gone.
**/
function invalidField(win, field, message) {
// Fixes HE-3875
var $vexDialogInput = $(field).closest(".vex-dialog-input");
$vexDialogInput.find(".pagebuttons").show();
$vexDialogInput.find(".preventMultipleSubmitButtonClickSpinner").remove();
if (win.fieldPrompt) {
win.fieldPrompt(field, message);
} else {
win.alert(message);
}
}
/**
* Utility function to normalized an array.
* Returns the normalized array
**/
function trimArray(arrayToTrim) {
var result = [];
var zeroCount = 0;
for (var i = 0; i < arrayToTrim.length; i++) {
result[zeroCount++] = arrayToTrim[i];
}
return result;
}
function getNextUrlFromNavigationPulldown(win, backward) {
var pulldownFrame = win.parent.frames[0];
var pdf$ = pulldownFrame.$;
var dir = backward ? "prev" : "next";
var option = pdf$("select[name=navchoice] option:selected")[dir]();
if (option.length == 0) {
return;
}
var nextValue = option.val(); // FORMAT: sss_sub_content,/ats/application/detail/language,op=edit&APPLICANT_ID=VA00000059
var nextUrl = nextValue.substring(nextValue.indexOf(",") + 1, nextValue.lastIndexOf(","));
var qs = nextValue.substring(nextValue.lastIndexOf(",") + 1);
nextUrl += "?".concat(qs);
var location = win.location;
return nextUrl;
}
/**
* Returns a truncated toString of given function.
* @param fn
* @return {string}
*/
function displayFn(fn) {
if (!fn) {
return "null function";
}
return "".concat(fn.toString().replace(/[\s]+/gim, " ").substr(0, 50), "...");
}
/**
* Performs a synchronous retrieval of the JS source file provided. Returns the script as a string.
*/
function loadJsSource(src) {
var ajaxObj = $.ajax({
"url": src,
"dataType": "text",
"async": false
});
return ajaxObj.responseText;
} // member functions
var lib = {
// This is an array of page listeners. A page listener is defined in another
// page and has methods that can be called by functions in this library file.
// When some event happens, library will call a method belonging to the page
// listeners.
"pageListeners": [],
/**
* Simple function used to log message strings and Error instances to the console, if the console object
* is available (may not be in older browser environments). Will only log if isDevMode is true.
*
* @param {string|Error} message
* @param {boolean} [override] if present and true, will log whether or not in dev mode
*
* @deprecated Should call Utils.log() directly.
*/
"log": function log(msg, override) {
_log("Call to deprecated Lib.log() function (should call Utils.log() directly)", true);
_log(msg, override);
},
/**
* Gets value for the cookie with the given name. Returns null if none found.
*
* @param name
* @returns {*}
*/
"getCookie": function getCookie(name) {
var vals = document.cookie.split(/\s*;\s*/);
var val = null;
$.each(vals, function (i, cookie) {
var nv = cookie.split("=");
if (nv[0] == name) {
val = nv[1];
return false;
}
});
return val;
},
/**
* Gets value for given param; returns null if not present.
*
* @param param
* @returns {String}
*/
"getParam": function getParam(param) {
var qry = location.href;
var index = qry.indexOf("?");
if (index < 0) {
return null;
}
qry = qry.substr(index + 1);
var nvps = qry.split("&");
var val = null;
$.each(nvps, function (i, v) {
var nv = v.split("=");
if (nv.length != 2) {
return;
}
var n = nv[0];
if (param == n) {
val = nv[1];
return false;
}
});
return val;
},
/**
* Provides access to the Modal object (used to create and manipulate dialogs, spinners, etc.).
*
* @returns {Modal}
*/
"getModal": function getModal() {
return Modal;
},
/**
* Is called to do an Ajax load of body, putting up spinner graphic while waiting for load.
*
* @param win the context Window
* @param url the URL to fetch content from
*/
"doSlowPageLoad": function doSlowPageLoad(win, url) {
// helper function used to do loggin for onReady functions
function doFnLog(w) {
var fns = w["onReadyFunctions"];
var len = fns ? fns.length : 0;
_log("In doSlowPageLoad(".concat(url, "), win.onReadyFunctions.length=").concat(len));
}
var $ = win.$;
win.spinnerOn = true;
$(win.document).ready(function () {
doFnLog(win);
$("#slowpageloading").fadeIn(400);
_log("Doing doSlowPageLoad(".concat(url, ")"));
window.setTimeout(function () {
doFnLog(win);
$("body").load(url, function () {
win.spinnerOn = false;
var onReadyFunctions = win.onReadyFunctions || [];
doFnLog(win);
for (var i = 0; i < onReadyFunctions.length; i++) {
try {
var fn = onReadyFunctions[i];
var str = displayFn(fn);
_log("Running onReadyFunction:\n".concat(str));
fn(win);
} catch (e) {
_log(e);
}
}
});
}, 1000); // do timeout for load() call to allow spinner to display for a moment
});
},
/**
* Is called to create and render a new HierCheckboxModel instance.
*
* @param win the ccntext Window
* @param scriptId the id of the SCRIPT tag containing call to this method
* @param json the JSON node data payload
*/
"renderHierCheckboxModel": function renderHierCheckboxModel(win, scriptId, json) {
var model = new HierCheckboxModel(win, scriptId, json);
model.render();
},
"openNode": function openNode(win, id) {
return (// Do nothing. We don't need to open the children when you click a parent
true
);
},
"toggleNode": function toggleNode(win, id, hasImg) {
hasImg = hasImg == undefined || hasImg === true; // hasImg is true if not provided or if explicitly true
var img;
if (hasImg) {
img = win.document.getElementById("".concat(id, "_img"));
}
var elem = win.document.getElementById(id);
if (elem.style.display == "none") {
elem.style.display = "";
if (hasImg) {
img.src = "/ats/images/minus.gif";
}
} else {
elem.style.display = "none";
if (hasImg) {
img.src = "/ats/images/plus.gif";
}
}
},
"assureChildrenMatch": function assureChildrenMatch(win, id) {
var children = parents[id];
if (children) {
var checked = isChecked(win, id);
var length = children.length;
for (var i = 0; i < length; i++) {
var child = children[i];
checkCheckBox(win, child, checked, false);
lib.assureChildrenMatch(win, child);
}
}
return true;
},
"assureParentSelected": function assureParentSelected(win, id) {
var parent = kids[id];
if (parent) {
checkCheckBox(win, parent, true, true);
}
return true;
},
"setCheckboxElements": function setCheckboxElements(win) {
checkboxElements = [];
for (var i = 0; i < win.document.forms[0].elements.length; i++) {
var elem = win.document.forms[0].elements[i];
if (elem && elem.type == "checkbox") {
var value = elem.value;
checkboxElements[value] = elem;
}
}
},
"rmimg": function rmimg(win, companyId) {
if (!win.document.getElementById(companyId)) {
win.document.getElementById("".concat(companyId, "_img")).style.display = "none";
}
},
"setParent": function setParent(win, id, parentId) {
kids[id] = parentId;
var list = parents[parentId];
if (!list) {
list = [];
}
list = list.concat(id);
parents[parentId] = list;
},
"initPageCollapse": function initPageCollapse(doc) {
for (var guiPageId in hiddenDivs) {
lib.pageCollapse(doc, guiPageId);
}
},
"pageCollapse": function pageCollapse(doc, guiPageId) {
var button = doc.getElementById("".concat(guiPageId, "-collapse-button"));
var div = doc.getElementById(guiPageId);
if (!!div && !!button) {
var visible = div.style.display;
if (visible == "none") {
div.style.display = "";
delete hiddenDivs[guiPageId];
button.src = "/ats/images/minus.gif";
} else {
div.style.display = "none";
if (!hiddenDivs[guiPageId]) {
hiddenDivs[guiPageId] = true;
}
button.src = "/ats/images/plus.gif";
}
}
},
"pageCollapseAtsSearchMultiPage": function pageCollapseAtsSearchMultiPage(win, guiPageId) {
var $ = win.$;
var hiddenClass = "subPageContentHidden";
var clickedDivSelector = "#".concat(guiPageId, "-nonWrapper");
$(".subPageContent").not(clickedDivSelector).addClass(hiddenClass);
$(clickedDivSelector).toggleClass(hiddenClass);
setTimeout(function () {
// https://stackoverflow.com/questions/2905867/how-to-scroll-to-specific-item-using-jquery/14490167#14490167
// $(win).scrollTop($("#" + guiPageId + "-wrapper").offset().top);
$("html, body").animate({
"scrollTop": $("#".concat(guiPageId, "-wrapper")).offset().top
}, 350);
}, 350 + 1);
},
"checkSessionId": function checkSessionId(value) {
if (sessionId == null || value == null || sessionId == "" || value == "" || sessionId == "null" || value == "null") {
return true;
} else if (value == sessionId) {
return true;
} else {
// do check for session cookie first
var temp = _this.getCookie("SSS_SESSION_ID");
if (value == temp) {
// update session id first
sessionId = temp;
return true;
}
return false;
}
},
"helpLink": function helpLink(win, message) {
win.alert(message);
return false;
},
"removeFileUpload": function removeFileUpload(win, field) {
var $ = win.$;
var fieldId = "#".concat(field);
var removeLinkId = "".concat(fieldId, "_remove");
var viewLinkId = "".concat(fieldId, "_view");
var hiddenFieldId = "".concat(fieldId, "_hidden_remove");
$(removeLinkId).click(function () {
$(this).css("display", "none");
$(viewLinkId).css("display", "none");
$(hiddenFieldId).val($(fieldId).attr("value"));
$(fieldId).prop("value", " ");
$(this).closest("td").find("input[type=button]").val("Upload a File");
});
},
"checkEmail": function checkEmail(win, field) {
var validEmail = true;
var emailValue = field.value;
var emailLength = emailValue.length;
if (emailLength > 0) {
validEmail = emailCheck(emailValue, win, field);
}
return validEmail;
},
/**
* Is called to fetch company_id of the location/school selected on Request to Hire form.
*
* @param win the context Window
*/
"selectLocation": function selectLocation(win) {
var $ = win.$; // SSOFT-5225 : Set COMPANY_ID as the initially selected location/school
var $selectNameCompanyId = $("select[name='COMPANY_ID']");
var updateCookie = function updateCookie() {
return document.cookie = "COMPANY_ID=".concat($selectNameCompanyId.val(), "; path=/");
};
updateCookie();
$selectNameCompanyId.change(function () {
$("select[name='action']").val("default");
updateCookie();
$("#inlineContent").html(" ");
});
},
/**
* Is called to compare EMAIL and CONFIRM_EMAIL
*
* @param win the context Window
*/
"checkConfirmEmail": function checkConfirmEmail(win, field) {
var $ = win.$;
var email = $("#EMAIL").val().trim().toLowerCase();
var confirmEmail;
confirmEmail = field.value.trim().toLowerCase();
if (email != confirmEmail) {
invalidField(win, field, "Confirm Email should match Email.");
return false;
} else if (email == confirmEmail) {
return true;
}
},
"checkRequiredRadio": function checkRequiredRadio(win, field) {
var radioSelected = false;
var $ = win.$;
var row = $("#".concat($(field).attr("name"), "_ROW"));
if (row.css("display") == "none") {
return true;
}
if (field.length) {
for (var i = 0; i < field.length; i++) {
if (field[i].checked) {
radioSelected = true;
}
}
} else if (field.checked) {
radioSelected = true;
}
if (radioSelected) {
return true;
} else {
invalidField(win, field, "You have not filled out all required answers on this page.");
return false;
}
},
/**
* Create arrays for form validation listeners.
**/
"initForms": function initForms(win) {
function doInitForm(form) {
if (!form.initialized) {
form.validatorFunctions = new Array(0);
form.validatorFields = new Array(0);
form.maskValidatorFields = new Array(0);
form.maskValidatorFunctions = new Array(0);
form.maskValidatorMasks = new Array(0);
form.initialized = true;
}
}
var forms = win.document.forms;
if (forms) {
for (var i = 0; i < forms.length; i += 1) {
var form = forms[i];
doInitForm(form);
}
} else {
$("form").whenExists(function () {
doInitForm(this);
});
}
},
/**
* run: function to check that a given field is filled out.
* It checks if {name}_ROW is a table row.
*/
"checkRequired": function checkRequired(win, field) {
var $ = win.$;
var $field = $(field);
var name = $field.attr("name"); // TODO - come back and fix to work MA000623 & 00013612
// var parentRow = $("#" + name).closest('tr');
// if (getFieldValue(field) == '' && (row.is(":visible") || parentRow.is(":visible"))){
var $row = $("#".concat(name, "_ROW")); // https://jira.powerschool.com/browse/HE-3687
// $row.length will be 0 if this field is wrapped in a grouping sss.gui.MultiFieldField (see gui_field_field table)
// This is the case for the phone number and extension fields in gui_page 00001017 (the applicant add reference page)
// The :visible check fails because the row has a different name (e.g. PHONE_GROUP_ROW instead of PHONE_ROW)
// Falling back to the closest parent <tr> element should fix this problem
var $rowOrClosestTr = $row.length > 0 ? $row : // Could probably always use this value, but minimizing changes to prevent breaking things
$field.parents("tr").eq(0);
if ($rowOrClosestTr.is(":visible") && getFieldValue(win, field) == "") {
var nameOrId = name ? name : $field.attr("id");
logger.log("## checkRequired - INVALID (".concat(nameOrId, ")"));
logger.log(field);
var $customMessageField = $("input[name=\"customValidationMessage\"]");
var customValidationMessage = $customMessageField.length > 0 && $customMessageField.val() != "" ? $customMessageField.val() : "You have not filled out all required fields on this page.";
invalidField(win, field, customValidationMessage);
return false;
} else {
return true;
}
},
/**
* Wrapper for validFields that checks if the form can be validated from
* the table name.
**/
"validForm": function validForm(win, form, tableName) {
if (!lib.checkAccess()) {
return false;
} // flip validation switch since we are checking fields... it's stupid
win.runningValidFields = true;
if (tableName != "applicant.view" && tableName != "dbuser.pwd_no_libraryjsp" && (tableName.match("dbuser") || tableName.match("applicant") && !tableName.match("applicant_type")) && !checkFormatting(win, form.elements["NAME"], form.elements["PWD"])) {
win.runningValidFields = false;
return false;
}
win.runningValidFields = false;
return validFields(win, form);
},
/**
* Utility to strip down the query string size by removing blank inputs for very
* large search forms. IE has a 2048 character limit on query string size and
* even with an empty form putting every input in the query string can explode that
* on the Applicant search page.
*
* We use jQuery's $.serialize to create the query string.
**/
"compressFormQuery": function compressFormQuery(win, form, tableName) {
if (!lib.checkAccess()) {
return false;
}
var $ = win.$;
var qs = $(form).find(":input").filter(function () {
return $(this).val() != "";
}).serialize();
var requestUrl = "".concat($(form).attr("action"), "?").concat(qs);
win.location.href = requestUrl;
return false;
},
/**
* Adds a func to validation listeners on fieldName.
**/
"appendMulti": function appendMulti(win, fieldName, func) {
lib.initForms(win);
var forms = getFormObjects(win, fieldName);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var newFunctions = new Array(func);
var newFields = form.elements[fieldName];
form.validatorFunctions = form.validatorFunctions.concat(newFunctions);
form.validatorFields = form.validatorFields.concat(newFields);
}
},
"multiCheck": function multiCheck(win, fields) {
var numberChecked = getMultiNumberChecked(win, fields);
var $ = win.$;
var id = "".concat($(fields).attr("name"), "_ROW"); // HE-3875
// Hack to look for newest/last element with ID (closing modal doesn't delete the elements from the DOM, and clicking "Go!" again creates a new modal)
var $row = $("[id='".concat(id, "']")).last();
if ($row.is(":visible") && numberChecked < 1) {
invalidField(win, fields, "You have not filled out all required answers on this page.");
return false;
} else {
return true;
}
},
"reqAllMultiCheck": function reqAllMultiCheck(win, fields) {
var numberChecked = getMultiNumberChecked(win, fields);
var numberOfCheckboxes = Array.from(fields).filter(function (x) {
return x.type === "checkbox";
}).length;
var $ = win.$;
var id = "".concat($(fields).attr("name"), "_ROW"); // HE-3875 was fixed by the change in multiCheck (above), but presumably the fix should be applied here too
// Hack to look for newest/last element with ID (closing modal doesn't delete the elements from the DOM, and clicking "Go!" again creates a new modal)
var $row = $("[id='".concat(id, "']")).last();
if ($row.is(":visible") && numberChecked < numberOfCheckboxes) {
invalidField(win, fields, "You have not filled out all required answers on this page.");
return false;
} else {
return true;
}
},
/**
* Add a check mask function to a field.
**/
"appendMask": function appendMask(win, f, func) {
lib.initForms(win);
var fname = f;
var x;
if (f.indexOf(":::") != -1) {
fname = f.substring(0, f.indexOf(":::"));
f = f.substring(f.indexOf(":::") + 3);
if (f.indexOf(":::") != -1) {
x = f.substring(0, f.indexOf(":::"));
}
}
var forms = getFormObjects(win, fname);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var field = form.elements[fname];
var newFunctions = new Array(func);
var newFields = new Array(field);
var expr = new Array(x);
form.maskValidatorFunctions = form.maskValidatorFunctions.concat(newFunctions);
form.maskValidatorFields = form.maskValidatorFields.concat(newFields);
form.maskValidatorMasks = form.maskValidatorMasks.concat(expr);
}
},
/**
* Adds a fieldName and function to listerners. Functions run when checking for
* form completion.
**/
"append": function append(win, fieldName, func) {
lib.initForms(win);
var forms = getFormObjects(win, fieldName);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var field = form.elements[fieldName];
var newFunctions = new Array(func);
var newFields = new Array(field);
form.validatorFunctions = form.validatorFunctions.concat(newFunctions);
form.validatorFields = form.validatorFields.concat(newFields);
}
},
"checkSize": function checkSize(field, fsize) {
if (fsize > 0 && field.value.length > fsize) {
field.value = field.value.substring(0, fsize);
alert("You have reached the maximum size for this field");
}
},
"checkSearchNumber": function checkSearchNumber(win, field) {
stripSymbols(field);
var value = field.value; // when we don't have a value evrything is fine
if (value === undefined) {
return true;
} // check to see if the first character is a > or <
if (value.indexOf(">") > 0 || value.indexOf("<") > 0) {
invalidField(win, field, "An invalid number was entered in this field. If you are using > or <, please make sure it is the first symbol in the field.");
return false;
} else {
var num = value;
if (num.indexOf(">") == 0 || num.indexOf("<") == 0) {
num = value.substr(1);
}
if (!isValidNumber(num)) {
invalidField(win, field, "An invalid number was entered in this field.");
return false;
}
}
return true;
},
"checkNumber": function checkNumber(win, field) {
stripSymbols(field);
if (!isValidNumber(field.value)) {
invalidField(win, field, "An invalid number was entered in this field. This field cannot contain any symbols ($, %, #, etc).");
return false;
} else {
return true;
}
},
"checkZeroInterval": function checkZeroInterval(win, field) {
stripSymbols(field);
var value = field.value;
if (value === 0) {
invalidField(win, field, "Interval cannot be zero");
return false;
} else {
return true;
}
},
"confirmDelete": function confirmDelete(page, href) {
if (confirm("Are you sure you want to delete this record?")) {
if (href.indexOf("redirect=") < 0) {
href = "".concat(href, "&redirect=").concat(escape(page.location.href));
} else {
var i = href.indexOf("&redirect=");
var j = href.indexOf("%");
if (i >= 0 && j < 0) {
var sl = "&redirect=".length;
href = href.substring(0, i + sl) + escape(href.substring(i + sl));
}
}
page.location.href = href;
}
},
"handleImpersonation": function handleImpersonation(window, href, impersonationMode) {
var userId = href.split("?")[1].substr("USER_ID=".length);
$.get("/servlet/support/login/impersonation", {
"companyId": companyId,
"userId": userId,
"impersonationMode": impersonationMode
}, function (data) {
if (data.success) {
if (data.accountType == "EMPLOYER") {
top.document.location.replace("/ats/employer/v51_employer_frame");
}
} else {
window.alert(data.errorMessage);
}
}, "json");
return false;
},
"checkTime": function checkTime(win, field) {
var isValidTime = true;
var thisFieldValue = field.value;
if (thisFieldValue.length == 0) {
return true;
}
if (thisFieldValue.length != 5) {
isValidTime = false;
} else {
var middle = thisFieldValue.substring(2, 3);
if (middle != ":") {
isValidTime = false;
} else {
var hour = thisFieldValue.substring(0, 2);
var minute = thisFieldValue.substring(3, 5);
if (hour.charAt(0) > 2 || hour.charAt(1) > 9 || minute.charAt(0) > 5 || minute.charAt(1) > 9 || hour.charAt(0) == 2 && hour.charAt(1) > 3) {
isValidTime = false;
} else {
var hourInt = parseInt(hour);
var minuteInt = parseInt(minute);
var hour1 = parseInt(hour.substring(0, 1));
var hour2 = parseInt(hour.substring(1, 2));
var minute1 = parseInt(minute.substring(0, 1));
var minute2 = parseInt(minute.substring(1, 2));
if (hourInt > 23 || hourInt < 0 || minuteInt > 59 || minuteInt < 0 || isNaN(hourInt) || isNaN(minuteInt) || isNaN(hour1) || isNaN(hour2) || isNaN(minute1) || isNaN(minute2)) {
isValidTime = false;
}
}
}
}
if (!isValidTime) {
invalidField(win, field, "An invalid time was entered. Use Military Time Format: 00:00 to 23:59");
}
return isValidTime;
},
"checkDate": function checkDate(win, field) {
var thisFieldValue = getFormattedDate(field);
if (!isValidDate(thisFieldValue, false)) {
invalidField(win, field, "An invalid date was entered. Use Month Date Year Format MM/DD/YYYY.");
return false;
} else {
field.value = thisFieldValue;
return true;
}
},
"checkBirthDate": function checkBirthDate(win, field) {
if (!isValidBirthDate(field, false, 10, 110)) {
invalidField(win, field, "An invalid birth date was entered.");
return false;
}
return true;
},
"checkShortDate": function checkShortDate(win, field) {
var thisFieldValue = getFormattedDate(field);
if (!isValidDate(thisFieldValue, true)) {
invalidField(win, field, "An invalid date was entered. Use Month Date Year Format MM/YYYY.");
return false;
} else {
field.value = thisFieldValue;
return true;
}
},
/**
* It is expected that the input text field has a sibling hidden input field.
* @param field A jquery wrapped text field.
*/
"storeShortDateToFullDate": function storeShortDateToFullDate(win, field) {
/**
* Converts MM/yyyy to MM/dd/yyyy
* @param date date string
* @returns {string} full date
*/
function createFullDate(date) {
var separatorIndex = date.lastIndexOf("/");
var month = date.substring(0, separatorIndex);
var year = date.substring(separatorIndex);
return "".concat(month, "/01").concat(year);
}
var value = field.val();
var id = $(field).attr("id");
var row = $("#".concat(id, "_ROW")); // when the value is not valid the hidden field is set to empty to ensure
// the validator to catch the error on the field
if (!isValidDate(value, true) || value == "" && row.css("display") != "none") {
field.next().val("");
return false;
}
var fullDate = createFullDate(value);
field.next().val(fullDate);
return true;
},
"checkDateTime": function checkDateTime(win, field) {
if (!isValidDateTime(field)) {
invalidField(win, field, "An invalid date was entered. Use Format MM/DD/YYYY HH:MM am/pm.");
} else {
return true;
}
},
"toggleSelectAllCheckboxes": function toggleSelectAllCheckboxes(checkbox, win) {
var isChecked = !!$(checkbox).attr("checked");
if (isChecked) {
lib.selectAllCheckboxes(win, false);
} else {
lib.deselectAllCheckboxes(win, false);
}
},
"selectAllCheckboxes": function selectAllCheckboxes(win, lockAccess) {
if (lockAccess) {
lib.setAccess(win, false);
}
var i = 0;
for (i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].type == "checkbox") {
win.document.forms[0].elements[i].checked = true;
}
}
},
/**
* Submit an eform document through AJAX. This also handles saving as draft.
* It displays a message in modal dialogue in the process of submitting the document.
* The function also handles responses from the server in a modal dialogue.
* This is designed to be called on form onsubmit.
* @param {window} win The window object passed where the function is called. This
* is used as the context for jquery.
* @param {jquery object} form The jquery object of the form document this function is going to submit.
* @param {string} divId The id of the div that will be used for the modal dialogue.
* @return {boolean} This should return false to disable the default form submit.
*/
"documentSubmit": function documentSubmit(win, form, tableName, divId) {
setTimeout(function () {
var $ = win.$;
lib.setAccessNextPage(true);
var saveAsDraft = !!$("input[name='save_as_draft']").length;
var ignoreRequiredFields = $("input[name='IGNORE_REQUIRED_FIELDS']").val() === "Y";
var formIsValid = ignoreRequiredFields;
if (!saveAsDraft && !ignoreRequiredFields) {
formIsValid = lib.validForm.call(form[0], win, form[0], tableName);
}
if (saveAsDraft || formIsValid) {
var doneSubmit = false;
createModal(win, {
"content": "#".concat(divId),
// TODO: clone this?
"attributes": {
"useCloseX": true
},
"onOpen": function onOpen(modal) {
var content = modal.getContent(true);
$(content).css("height", "auto");
$(content).css("width", "auto");
modal.enableOk({
"enable": false
});
modal.setContent("<h3>Submitting...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
var formdata = "".concat(form.serialize(), "&ajax=Y");
if (saveAsDraft) {
formdata += "&save_as_draft=Save+as+Draft";
}
$.post(form.attr("action"), formdata, function (data) {
doneSubmit = true;
modal.setContent(data);
if (saveAsDraft) {
setTimeout(function () {
return modal.close();
}, 500);
}
});
},
"onClose": function onClose(modal) {
if (doneSubmit) {
modal.enableOk({
"enable": true
});
}
}
});
}
}, 500);
return false;
},
"unfollow": function unfollow(win, aTag) {
var $ = win.$;
var link = $(aTag);
$.post(link.attr("href"), function (data) {
if (data == "Success!") {
var evenRows = link.closest("tr").nextAll("tr.even");
link.closest("tr").nextAll("tr.odd").removeClass("odd").addClass("even");
evenRows.removeClass("even").addClass("odd");
link.closest("tr").remove();
} else {
win.alert(data);
}
});
return false;
},
"deselectAllCheckboxes": function deselectAllCheckboxes(win, lock) {
if (lock) {
lib.setAccess(win, false);
}
var i = 0;
for (i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].type == "checkbox") {
win.document.forms[0].elements[i].checked = false;
}
}
},
"daysSince": function daysSince(win, field) {
var fieldName;
var daysSince = field.value;
var time = new Date(new Date().getTime());
var d = new Date(time - daysSince * 24 * 60 * 60 * 1000);
var s = "".concat(d.getMonth(), "1/").concat(d.getDate(), "/").concat(d.getFullYear());
var index = field.name.lastIndexOf("_DAYSSINCE");
if (index > 0) {
fieldName = field.name.substring(0, index);
}
if (daysSince > 0 && daysSince != null) {
for (var i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].name == fieldName) {
win.document.forms[0].elements[i].value = s;
}
}
} else {
for (var _i5 = 0; _i5 < win.document.forms[0].elements.length; _i5++) {
if (win.document.forms[0].elements[_i5].name == fieldName) {
win.document.forms[0].elements[_i5].value = "";
}
}
}
},
// Scoring Worksheet functions
"setAvgField": function setAvgField(win, fieldName) {
return win.avgField = fieldName;
},
"setTotalField": function setTotalField(win, fieldName) {
win.totalField = fieldName;
win.document.forms[0].elements[fieldName].enabled = false;
},
"appendScore": function appendScore(win, fieldName) {
// var field = win.document.forms[0].elements[fieldName];
// win.scores = win.scores.concat(field);
win.scores = win.scores.concat(fieldName);
},
"calculateScore": function calculateScore(win) {
var totalScore = 0;
var removeFromTotal = 0;
for (var i = 0; i < win.scores.length; i++) {
var field = win.document.forms[0].elements[win.scores[i]];
var fieldValue = parseInt(getFieldValue(win, field));
if (!fieldValue > 0) {
fieldValue = 0;
removeFromTotal++;
}
totalScore = totalScore + fieldValue;
}
var avgScore = totalScore / (win.scores.length - removeFromTotal); // round to the nearest integer by adding .5 to avgScore
avgScore = parseInt(avgScore + 0.5);
if (win.totalField && totalScore == parseInt(totalScore)) {
// There are 2 fields which need to be populated, one hidden and one html disabled
win.document.forms[0].elements[win.totalField][0].value = totalScore;
win.document.forms[0].elements[win.totalField][1].value = totalScore;
}
if (win.avgField && avgScore == parseFloat(avgScore)) {
// There are 2 fields which need to be populated, one hidden and one html disabled
win.document.forms[0].elements[win.avgField][0].value = avgScore;
win.document.forms[0].elements[win.avgField][1].value = avgScore;
}
return true;
},
// End Scoring Worksheet functions
// BEGIN PAGE LISTENER FUNCTIONS
"clearListeners": function clearListeners() {
return lib.pageListeners = [];
},
/**
* Is here so that a selection field (select box, checkboxes, etc)
* can cause events to happen when its value changes. This function is called
* in an onChange event listener contained in the field. The field itself
* is passed in so that its attributes can be determined and used.
**/
"updatePage": function updatePage(win, field) {
// The values in the field must follow the following format:
// target,uri,querystring
// Parse it to find out those 3 values.
var value = field.options[field.selectedIndex].value;
var target = null;
var url = null;
if (value.indexOf(",") >= 0) {
target = value.substring(0, value.indexOf(","));
url = value.substring(value.indexOf(",") + 1);
if (url.indexOf(",") >= 0) {
var uri = url.substring(0, url.indexOf(","));
var qs = url.substring(url.indexOf(",") + 1);
var linkUrl = uri;
if (qs != null) {
var qsBegin = "?";
if (linkUrl.indexOf("?") >= 0) {
qsBegin = "&";
}
linkUrl = linkUrl + qsBegin + qs;
}
}
}
if (lib.checkAccess()) {
lib.loadingPage(true);
if (url.indexOf(",") >= 0) {
win.parent.frames[target].location.href = linkUrl;
win.parent.frames[target].focus();
}
} else {
win.alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
var size = field.options.length;
var currentPage = win.parent.frames[target].location.pathname;
for (var i = 0; i < size; i++) {
var optionVal = field.options[i].value;
if (optionVal.indexOf(currentPage) >= 0) {
field.selectedIndex = i;
break;
}
}
}
},
/**
* These functions and variables are for the next/previous applicant links.
* Loading will be set to true at the top of the page and then false as the
* last think on the page.
**/
"loadingPage": function loadingPage(bool) {
setGlobalData("Lib.loading", bool);
if (bool == true) {
lib.setAccessNextPage(true);
}
return true;
},
"isLoadingPage": function isLoadingPage() {
var loading = getGlobalData("Lib.loading");
return loading;
},
/**
* Is called at the bottom of every ResultPage and FormPage
* It iterates through all of the active page listeners and calls the
* method to let the page listeners know that the page has been updated.
*
* Called by the page, notifies page listeners
**/
"pageUpdated": function pageUpdated(uri) {
for (var i = 0; i < _this.pageListeners.length; i++) {
var listener = _this.pageListeners[i];
var f = void 0;
try {
f = listener.pageUpdated;
if (f) {
f(uri);
}
} catch (err) {}
}
},
// END OF PAGE LISTENER FUNCTIONS
/**
* Sets flag for accessing next page, can be retrieved from checkAccess(). This MUST occur on the global
* instance or results will not be consistent.
*
* @param value
* @returns {boolean}
*/
"setAccessNextPage": function setAccessNextPage(value) {
var canAccess = lib.checkAccess();
_log("accessNextPage: ".concat(canAccess));
setGlobalData("Lib.accessNextPage", value);
return true;
},
"setAccess": function setAccess(win, value) {
_this.setAccessNextPage(value);
if (win && win.document && win.document.forms && win.document.forms[0] && win.document.forms[0].elements && win.document.forms[0].elements["is_changed"] && !win.document.forms[0].elements["force_is_changed"]) {
win.document.forms[0].elements["is_changed"].value = !value;
}
return true;
},
/**
* Retrieves flag indicating if next page can be accessed. This MUST occur on the global
* instance or results will not be consistent.
*
* @returns {boolean}
*/
"checkAccess": function checkAccess() {
return getGlobalData("Lib.accessNextPage");
},
"checkLinkAccess": function checkLinkAccess() {
if (_this.checkAccess()) {
return true;
} else {
alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
return false;
}
},
/**
* Add a listener to parentField to show targetField when parentField.value
* equals showValue.
**/
"addDependentField": function addDependentField(win, rawParentFieldIds, targetField, rawShowValues) {
var $ = win.$; // TODO: this flag will be kept here as it may be desirable to use the 'keepWidth' feature for individual dialogs in the future
var keepWidth = false; // wait until the document is ready because "reset" and parent may not
// be present yet
$(win.document).ready(function () {
// separate out the fields and values into groups end result is array parentOrFields
var parentOrFields = [];
var parentOrFieldIds = rawParentFieldIds.split("|");
var parentOrValues = rawShowValues ? rawShowValues.split("|") : [];
for (var i = 0; i < parentOrValues.length; i++) {
parentOrValues[i] = parentOrValues ? parentOrValues[i].split("&") : [];
}
for (var _i6 = 0; _i6 < parentOrFieldIds.length; _i6++) {
var parentInnerAnd = [];
var parentInnerAndFieldIds = parentOrFieldIds[_i6].split("&");
for (var j = 0; j < parentInnerAndFieldIds.length; j++) {
var nameId = parentInnerAndFieldIds[j];
var negative = nameId.substr(-4) === "_NOT";
if (negative) {
nameId = nameId.substr(0, nameId.length - 4);
} // look to see if this will be rendered in Modal
var parentField = void 0;
if (dependentFieldCtx) {
parentField = $(dependentFieldCtx).find("[name='".concat(nameId, "']")).not(":disabled");
} else {
parentField = $("[name='".concat(nameId, "']")).not(":disabled");
}
parentField.data("negative", negative);
parentInnerAnd[j] = {
"fields": parentField,
"values": parentOrValues[_i6] ? parentOrValues[_i6][j] ? parentOrValues[_i6][j] : "" : ""
};
}
parentOrFields[_i6] = parentInnerAnd;
} // combine all fields into one jquery object for binding
var parentFields;
$.each(parentOrFields, function (i, innerAnd) {
return $.each(innerAnd, function (j, field) {
return parentFields = parentFields ? parentFields.add(field.fields) : field.fields;
});
}); // look to see if this will be rendered in Modal
var row;
if (dependentFieldCtx) {
row = $(dependentFieldCtx).find("#".concat(targetField, "_ROW"));
} else {
row = $("#".concat(targetField, "_ROW"));
}
if (parentFields && parentFields.length) {
var showHide = function showHide(dontAnimate) {
var foundPassingInnerAnd = false;
for (var _i7 = 0; _i7 < parentOrFields.length && !foundPassingInnerAnd; _i7++) {
var _parentInnerAnd = parentOrFields[_i7];
var innerAndResult = true; // for each field
var _loop = function _loop(_j2) {
var field = _parentInnerAnd[_j2]; // values are always the same for a field
var showOnValue = field.values.split(",");
var showOnAnyValue = field.values === ""; // for each input (of field)
var fieldResult = false;
for (var k = 0; k < field.fields.length && !fieldResult; k++) {
var input = field.fields.eq(k);
var value = input.val();
var _negative = input.data("negative"); // if ( input.attr("type") == "hidden" )
// this should already be handled server side; but we allow test anyway
// if this is an unchecked radio/check fake no value
if (input.is(":radio,:checkbox") && !input.is(":checked")) {
value = null;
}
var hasValue = false;
if (value !== null) {
value = $.makeArray(value);
$.each(value, function (i, v) {
if (v != "" && $.inArray(v, showOnValue) >= 0) {
hasValue = true;
}
});
} // set result and stop iteration when negative
fieldResult = hasValue || value && value != "" && showOnAnyValue;
if (_negative) {
fieldResult = !fieldResult;
}
}
innerAndResult = fieldResult;
};
for (var _j2 = 0; _j2 < _parentInnerAnd.length && innerAndResult; _j2++) {
_loop(_j2);
}
foundPassingInnerAnd = innerAndResult;
}
if (foundPassingInnerAnd) {
if (dontAnimate) {
row.show();
triggerResize(win, true, keepWidth);
} else {
// only animate when it is not already shown; display="auto"
if ("none" == row.css("display")) {
row.css("display", "");
row.css("opacity", "0");
row.animate({
"opacity": "1"
}, 500, "swing", function () {
return triggerResize(win, true, keepWidth);
});
}
}
} else {
if (dontAnimate) {
row.hide();
triggerResize(win, true, keepWidth);
} else {
row.fadeOut({
"complete": function complete() {
return triggerResize(win, true, keepWidth);
}
});
}
}
}; // on reset of form trigger change event for all fields
$(":reset").click(function () {
$(this).get(0).form.reset();
showHide(true);
}); // add event triggers to parent field
parentFields.each(function (i, elem) {
var $element = $(elem);
if ($element.hasClass("select-plus") && !$element.hasClass("select-plus-initialized")) {
SelectPlus.registerChangeListener($element, showHide);
} else {
jqueryUniversalChange(win, elem, function () {
return showHide();
});
}
});
showHide(true);
}
});
},
"setLocation": function setLocation(win, url) {
if (_this.checkAccess()) {
win.document.location.href = url;
} else {
win.alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
}
},
"historyGo": function historyGo(win, e) {
if (_this.checkAccess()) {
win.$("body").trigger("ss-event-page-cancel");
win.history.go(-1);
} else {
var e = win.event || e;
var targetValue = e.target || e.srcElement;
var msgForDisplay = $(targetValue).parents("ul").find("input[type=submit]");
win.alert("You must first click the \"".concat(msgForDisplay.val(), "\" or \"Undo\" buttons before exiting this page."));
}
},
"maskFormat": function maskFormat(win, field, expr) {
var v = field.value;
if (v == "") {
return true;
}
var re = new RegExp(expr);
if (re.exec(v)) {
return true;
} else {
return false;
}
},
/**
* Not even able to be called. Overriden by function autoFormat(x,y,z)
**/
"autoFormat": function autoFormat(field, expr, withstr) {
var v = field.value;
if (v == "") {
return;
}
var re = new RegExp(expr);
if (re.exec(v)) {
field.value = v.replace(re, withstr);
} else {
alert("".concat(v, " is not in the correct format."));
}
},
"AppLoginStepFillIn": function AppLoginStepFillIn(win) {
var $ = win.$; // copy create account button
var create_account_button = $(".pagebuttons ul :has([value='Create New Account'])");
create_account_button.css("display", "block");
if ($("div.create_account")) {
$("div.create_account").html(create_account_button.html());
create_account_button.css("display", "none");
} // move preview links
if ($("#step2_links")) {
$("#preview").hide();
$("#step2_links").html($("#preview").html());
} else {
$("#preview").show();
}
},
/**
* Adds functionality and style to the current content page in win.
**/
"addStyleClasses": function addStyleClasses(win, forSelector) {
// is a named function to aid in logging
var $ = win.$;
if (!$) {
_log(new Error("Can not call addStyleClasses; jQuery is not available."));
return;
}
forSelector = forSelector || "body";
_log("addStyleClasses for ".concat(forSelector));
var jq = $(forSelector);
setFormClass();
fillEmptyTD();
removeCheckboxsWhenAll();
fileFieldReset();
var classFunctions = {
".embedded_field": function embedded_field(obj) {
// firefox; clicking embedded input can't type
obj.closest("label").find(":radio, :checkbox").click(function () {
return $(obj).children(":text").focus();
}); // IE; clicking embedded input doesn't select check/radio
obj.closest("label").find(":text").click(function () {
$(this).closest("label").find(":radio, :checkbox").attr("checked", "checked");
});
},
// Lookup Editor
"a.wizardpopup": handleWizardPopupWithReload,
"a.wizardpopupNoReload": handleWizardPopup,
// modal pop-up links
"a.modalpopuplink": function aModalpopuplink(obj) {
return obj.click(function (e) {
e.preventDefault();
var popupId = "modalpopuplink";
if (!$("#".concat(popupId)).length) {
$("body").append("<div id='".concat(popupId, "' style='display:none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>"));
}
_this.addToolboxFunction(win, popupId, function () {
return ajaxFillinPopup(win, popupId, obj.attr("href"));
});
_this.showPopup(win, popupId);
return false;
});
},
// suggest search
"input.suggestsearch": handleSuggestSearch,
// file upload
"input.file_upload_field[type='button']": function inputFile_upload_fieldTypeButton(obj) {
$(obj).click(function (e) {
_log("Doing input.file_upload_field[type='button'].click()...");
var field = this; // Hack for SSOFT-5459. Multiple instances of the file upload popup are being created for some reason (when closing and reopening the popup).
$(field).parents().last().find("[id=upload_field]:hidden").remove();
closePopupFirst(win, function () {
_log("Doing fileUploadPopup - popups have been closed.");
fileUploadPopup(field, win);
});
});
},
// nctq
".nctq_hoverable": function nctq_hoverable(obj) {
obj.mouseenter(function (e) {
moveFloatingDivWithMouse(win, $(this).next("div"), e, 20, 20);
$(this).next("div").removeClass("nctq_scores_hidden");
$(this).next("div").addClass("nctq_scores_visible");
});
obj.mouseleave(function (e) {
$(this).next("div").removeClass("nctq_scores_visible");
$(this).next("div").addClass("nctq_scores_hidden");
});
obj.mousemove(function (e) {
moveFloatingDivWithMouse(win, $(this).next("div"), e, 20, 20);
});
obj.click(function (e) {
return e.preventDefault();
});
}
};
handleClassFunctions();
/**
* win - the window object (because of frames)
* div - the floating div jquery object
* e - event
* down - y offset from the mouse from the top right corner of the div
* left - x offset from the mouse from the top right corner of the div
*/
function moveFloatingDivWithMouse(win, div, e, down, left) {
var $ = win.$;
var width = div.width();
var height = div.height();
div.css({
"top": Math.min(e.pageY + down, $(win).height() - height + $(win).scrollTop()),
"left": e.pageX - width - left
});
}
function handleWizardPopupWithReload(obj) {
handleWizardPopup(obj, true);
}
function handleWizardPopup(obj, reloadPageOnDone) {
obj.click(function (e) {
e.preventDefault();
var popupId = obj.attr("name") ? obj.attr("name") : "awizardpopup";
if (!$("#".concat(popupId)).length) {
$("body").append("<div id='".concat(popupId, "' style='display:none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>"));
}
closePopupFirst(win, function () {
_this.addToolboxFunction(win, popupId, function () {
// hijack submit and stay open
ajaxFillinPopup(win, popupId, obj.attr("href"), null, true, true);
});
if (reloadPageOnDone) {
_this.addToolboxFunction(win, "".concat(popupId, "_close"), function () {
$("body").html("<h3 class='pageTitleCaption'>Please Wait... Loading</h3>"); // add refresh=Y to url
var curLoc = win.location.href;
var isOldUi = top.frames[0] && top.frames[0].name === "sss_script";
if (curLoc.indexOf("refresh") == -1) {
var newUrl = curLoc;
if (newUrl.indexOf("?") > -1) {
newUrl += "&refresh=Y";
} // if ( newUrl.indexOf("?") )
else {
newUrl += "?refresh=Y";
}
if (isOldUi) {
win.location.replace(newUrl);
} else {
win.$("body").trigger("ss-event-page-reload");
}
} else {
if (isOldUi) {
win.location.reload();
} else {
win.$("body").trigger("ss-event-page-reload");
}
}
});
}
_this.showPopup(win, popupId);
});
return false;
});
}
function handleSuggestSearch(obj) {
var suggestionId = "".concat(obj.attr("id") || obj.attr("name"), "_sug"); // url
var url = obj.attr("href"); // add jscallback to URL
if (url.indexOf("?") < 0) {
url += "?";
} else {
url += "&";
}
url += "jscallback=?"; // get suggestion
var lastTimeout = -1;
obj.keyup(function (e) {
if (lastTimeout != -1) {
win.clearTimeout(lastTimeout);
}
lastTimeout = win.setTimeout(function () {
// suggest from
var value = obj.val();
if (value == "") {
return;
}
value = {
"suggest": value,
"ajax": "y"
};
var data = $.param(value);
$.getJSON(url, data, handleSuggestsions);
}, 500);
}); // fillout suggestion
function handleSuggestsions(suggestions) {
removeSuggestionBox();
createSuggestionBox();
for (var suggestion in suggestions) {
// IE behaves funny when chaining
var id = suggestionId + suggestions[suggestion];
$("#".concat(suggestionId)).append("<div id='".concat(id, "' class='suggest_link'>").concat(suggestion, "</div>"));
var jsug = $("#".concat(id));
jsug.hover(hoverOver, hoverOut);
jsug.click(function () {
obj.val($(this).html());
removeSuggestionBox();
});
}
} // remove suggestion
obj.blur(removeSuggestionBox); // utiltity
function hoverOver() {
$(this).addClass("suggest_link_over");
obj.unbind("blur");
}
function hoverOut() {
$(this).removeClass("suggest_link_over");
obj.blur(removeSuggestionBox);
}
function createSuggestionBox() {
if (!$("#".concat(suggestionId, "_con")).length) {
obj.after("<div id='".concat(suggestionId, "_con'><div id='").concat(suggestionId, "' class='search_suggest'></div></div>"));
}
}
function removeSuggestionBox() {
$("#".concat(suggestionId, "_con")).remove();
}
}
function setFormClass() {
jq.find(":text").addClass("textfield");
jq.find(":password").addClass("passwordfield");
jq.find(":text, :password").focus(function () {
$(this).addClass("textfieldfocus");
});
jq.find(":text, :password").blur(function () {
$(this).removeClass("textfieldfocus");
});
} // Hack to fix rendering bug in IE.
function fillEmptyTD() {
jq.find("td:empty").html(" ");
}
function removeCheckboxsWhenAll() {
// Additionally can do ,:button[name='select_all'],:button[name='deselect_all']
var $selectNameActionType = jq.find("select[name=\"ACTION_TYPE\"]");
$selectNameActionType.change(function () {
var $checkboxes = jq.find(".rs :checkbox");
if ($selectNameActionType.val() === "all") {
$checkboxes.prop("disabled", "disabled").hide();
} else {
$checkboxes.prop("disabled", "").show();
}
});
}
function handleClassFunctions() {
var selectorString = "";
var first = true;
for (var selector in classFunctions) {
if (!first) {
selectorString += ",";
}
selectorString += selector;
first = false;
}
var $elements = jq.find(selectorString);
$elements.each(function () {
var me = $(this);
for (var _selector in classFunctions) {
if (me.is(_selector)) {
classFunctions[_selector].call(this, me);
}
}
});
}
/**
* Pop-up for upload_field
**/
var uploadFieldId = "upload_field";
function fileUploadPopup(field, win) {
var $ = win.$; // error on any existing pop-up
var modal = getModal(win);
if (modal && modal.isOpen()) {
alert("ERROR: cannot have a fileupload field within another pop-up");
return;
} // get real content
var fieldName = $(field).attr("hiddenname");
var uploadParams = "FIELD_NAME=".concat(fieldName, "&COMPANY_ID=").concat(companyId); // waiting text
if (!$("#".concat(uploadFieldId)).length) {
var loading = "<div id=\"".concat(uploadFieldId, "\" style=\"display: none\"><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>");
$("body").append(loading);
} // if to remove ext enforcement
var uploadPageQs = "";
if ($(field).is(".noextcheck")) {
uploadPageQs = "?noextcheck=Y";
} // on open
_this.addToolboxFunction(win, uploadFieldId, function () {
// fill in with real content
ajaxFillinPopup(win, uploadFieldId, "/ats/upload_field.jsp".concat(uploadPageQs), uploadParams);
}); // on close
_this.addToolboxFunction(win, "".concat(uploadFieldId, "_close"), function () {
// if the upload was a success
if (win.fileuploads && win.fileuploads[fieldName]) {
var fileupload = win.fileuploads[fieldName];
if (fileupload.id && fileupload.url) {
// update the hidden field
$("#".concat(fieldName)).val(fileupload.id); // update the link
$(".".concat(fieldName, "_link")).attr("href", fileupload.url).fadeIn();
$(".".concat(fieldName, "_remove")).attr("href", "#").fadeIn(); // change button label
$("#".concat(fieldName, "_button")).attr("value", "Replace File"); // warn on page change
_this.setAccess(win, false);
}
}
});
_this.showPopup(win, uploadFieldId);
}
function fileFieldReset() {
jq.find(":reset").click(function (e) {
// change hiddens back to original value
$(".file_upload_field[type='hidden']").each(function (i) {
var orgValue = $(this).attr("original");
$(this).val(orgValue); // update links
var link = $("#".concat($(this).attr("name"), "_link"));
link.attr("href", orgValue);
if (orgValue == "") {
link.fadeOut();
}
});
});
}
},
/**
* Called when an upload is complete
**/
"fileUploadComplete": function fileUploadComplete(win, fieldName, msg) {
var $ = win.$;
$(".inlineHelp").remove();
$(".searchsoft-modal #file_upload_content").html(msg);
$(".searchsoft-modal #file_upload_waiting").stop().hide();
$(".searchsoft-modal #file_upload_content").fadeIn(); // since we don't know what caused the fileupload (wizard or field) process the message for all cases
// Note regarding HE-3374: Content parameter was previously
// $("#" + fieldName)
// but "Continue" buttons with redirects weren't working
// See
// if (hijackStayOpen) {
// var button = content.find(".linkbutton");
// button.each(function () {
// in afterAjaxPopProcess
// Also see changes in upload_field.jsp (new div element with class starting with file-upload-complete-wrapper-)
afterAjaxPopProcess(win, fieldName, $(".file-upload-complete-wrapper-".concat(fieldName)), null, true, true);
triggerResize(win);
},
/**
* Called when an upload is starting
**/
"fileUploadStart": function fileUploadStart(win) {
var $ = win.$;
$(".inlineHelp").remove();
$(".searchsoft-modal #file_upload_waiting").fadeIn();
$(".searchsoft-modal #file_upload_content").hide();
return true;
},
// lib: JQUERY
"onReady": function onReady(win, fun) {
win.$ = checkJQuery(win, win.$);
if (!win.$) {
_log(new Error("Can not call onReady; jQuery is not available."));
return;
}
var onReady = function onReady() {
_log("win.document.readyState: ".concat(win.document.readyState)); // we need full CSS; chrome/safari parallel load
if (win.document.readyState != "complete") {
// FF jumps the gun on 'complete' state...causes issues with onReady functions
// when doing slow page load...so, do longer wait before executing
var deferTime = $.browser && $.browser.mozilla ? 1000 : 350;
_log("Deferring call to onReady for ".concat(deferTime, " ms..."));
win.setTimeout(onReady, deferTime);
return;
}
_log("Calling onReady() for:".concat(displayFn(fun)));
if (win.spinnerOn) {
win.onReadyFunctions = win.onReadyFunctions || [];
win.onReadyFunctions.push(fun);
_log("Adding function to win.onReadyFunctions (length=".concat(win.onReadyFunctions.length, "), NOT calling function."));
} else {
try {
_log("Executing onReady() function..."); // send in current context Window, and execute with Lib instance as function context
fun.call(_this, win);
} catch (e) {
_log("Error occurred executing onReady function...");
_log(e);
}
}
};
win.$(win.document).ready(onReady);
},
// Perform the new cookie test
"perform_cookie_test": function perform_cookie_test() {
makeTestCookie();
cookie_test = findTestCookie();
return cookie_test;
},
/**
* Called on pages that use the Action Toolbox.
*
* lib: JQUERY
* It will bind to the go button / select and correctly populate the pop-up.
*
**/
"ready_modal_popup": function ready_modal_popup(win, inline, uid) {
var $ = win.$;
$(win.document).ready(function () {
if (!inline) {
toolboxRegisterActionGo(win, uid);
} else {
toolboxRegisterSelection(win, uid);
}
if (!win.toolboxFunctions) {
win.toolboxFunctions = new Array(0);
}
});
},
/**
* Adds a function to list of current toolbox functions.
**/
"addToolboxFunction": function addToolboxFunction(win, funName, fun) {
if (!win.toolboxFunctions) {
win.toolboxFunctions = new Array(0);
}
win.toolboxFunctions[funName] = fun;
},
/**
* Toolbox, client function for AJAX popup.
**/
"ajaxPopupOp": function ajaxPopupOp(win, id, url, op, includeSelect) {
var $ = win.$;
var data = null;
if (op != null || "" == op) {
data = "op=".concat(op);
}
if (includeSelect) {
data = "".concat(data == null ? "" : data + "&").concat($("form").serialize());
}
var tableName = $("[name=table_name]").val();
if (tableName != null && "" != tableName && (data == null || data.indexOf("table_name") == -1)) {
data = "".concat(data ? data + "&" : "", "table_name=").concat(tableName);
}
ajaxFillinPopup(win, id, url, data);
},
/**
* Toolbox, client function for AJAX popup.
**/
"ajaxPopup": function ajaxPopup(win, id, url) {
return _this.ajaxPopupOp(win, id, url, null);
},
/**
* Creates a Modal and displays it, using the content contained in HTML element with given item id.
*
* @param {Window} win context window
* @param {string} item id of HTML content for modal
* @param {Object} [atts] optional map of attributes used to init Modal
*/
"showPopup": function showPopup(win, item, atts) {
var $ = win.$; // TODO: until a further non-trivial refactoring is done, need to pull 'Ok' button text from
// modal content, from the buttons rendered via ui.properties, and also need to remove
// pagebuttons from content before providing to modal
var text = $("#".concat(item)).find("input[name=".concat(item, "]")).val();
if (!text && item.indexOf("_results") > 0) {
// it may be that the Ok button does not follow convention of having same name as item (i.e. 'email_results' and 'email')
var btnName = item.replace("_results", "");
text = $("#".concat(item)).find("input[name=" + btnName + "]").val();
}
var parent = $("#".concat(item)).parent();
var content = $("#".concat(item)).find(".pagebuttons").hide().end();
$(content).css("display", ""); // default Modal attributes
var defaultAtts = {
"useCloseX": true
};
if (atts) {
atts = $.extend({}, defaultAtts, atts);
} else {
atts = defaultAtts;
} // do Ok/Cancel need to be enabled for Modal (or will content contain buttons?)
var enableCancelOk = !text;
var modalInit = {
"id": item,
"attributes": atts,
"content": content,
"onOpen": function onOpen() {
// Important hack for HE-4062 and related issues (e.g. HE-3875, which was already fixed with an even worse hack)
// Closing modals doesn't actually remove them from the DOM, it only hides them, causing lots of issues
// Now instead of hiding old modals when the same modal is opened again, we are removing them from the DOM (i.e. remove() instead of hide())
// Old comment:
// if content from previous Modal is still in DOM, remove before opening this instance
$("[id=\"".concat(item, "\"]")).toArray().slice(0, -1).forEach(function (el) {
return $(el).remove();
});
if (enableCancelOk) {
toolboxAddCancel(win, item);
toolboxRunFunction(win, item);
}
},
"onClose": function onClose(modal) {
// insert the (possibly) modified data back into the DOM
var content = $(modal.getContent(true));
content = $(content).children(); // must get kids (not include the Modal content wrapper)
$(parent).append(content.hide());
toolboxRunFunction(win, "".concat(item, "_close"));
$(".inlineHelp").remove();
win.document.thismodal = null;
}
}; // if this is a non-Ajax populated instance, configure w/ buttons
if (!enableCancelOk) {
modalInit.buttons = [{
"text": text,
"type": "ok",
"callback": function callback(modal) {
return toolboxRunFunction(win, item);
}
}, {
"text": "Cancel",
"type": "cancel"
}];
} // otherwise, this will be populated via ajaxPopup() call
else {
modalInit.showOk = false;
modalInit.showCancel = false;
}
createModal(win, modalInit, true); // will assign to global variable
},
/**
* Toolbox utility, add a hidden field to main form.
**/
"addHiddenField": function addHiddenField(win, name, value) {
var $ = win.$;
$("form").append("<input type=\"hidden\" name=\"".concat(name, "\" value=\"").concat(value, "\" />"));
},
/**
* Utility function that adds all currently checked applicants to the popup.
**/
"addCheckboxApplicants": function addCheckboxApplicants(win, id) {
var $ = win.$;
doModalOp(win, false, function (modal, content) {
var form = $(content).find("form"); // for some reason doing this as inline calls breaks IE6
var apps = $("div.rs :checkbox:checked").clone();
apps.attr("checked", "checked"); // apps.attr("type", "hidden"); // breaks IE6
apps.attr("remove", "yes");
apps.hide();
form.append(apps); // add what to effect; "All applicants in list"
var actionTypeField = $("select[name='ACTION_TYPE']");
if (actionTypeField.length) {
form.append("<input type=\"hidden\" name=\"ACTION_TYPE\" value=\"".concat(actionTypeField.val(), "\" />"));
} // confirm that the checkboxes have been checked [IE6]
if ($(form).find(":checkbox:checked").length == 0) {
// check hidden checkboxes
$(form).find(":hidden:checkbox").attr("checked", "checked");
}
});
},
/**
* Utility function that remove added checked applicants to popup.
**/
"removeCheckboxApplicants": function removeCheckboxApplicants(win, id) {
var $ = win.$;
$("div#".concat(id, " :checkbox[remove='yes']")).remove();
},
/**
* Function that adds window.superConfirm
**/
"addSuperConfirm": function addSuperConfirm(win) {
var $ = win.$;
win.superConfirm = function (text, _callback) {
return createModal(win, {
"content": text,
"attributes": {
"useCloseX": false
},
"buttons": [{
"text": "Yes",
"type": "ok",
"callback": function callback(modal) {
if ($.isFunction(_callback)) {
_callback.apply();
}
triggerResize(win);
}
}, {
"text": "Cancel",
"type": "cancel",
"callback": function callback(modal) {
return $(".inlineHelp").remove();
}
}]
});
};
},
/**
* Function that overrides window.alert() when another function comes in we add
* its text to the top of the current window.
**/
"replaceAlert": function replaceAlert(win) {
var $ = win.$;
win.alert = function (text) {
text = text.replace(/\r\n|\n/g, "<br />");
var popupsOpen = Modal.anyShowing(win);
if (popupsOpen) {
// add the content to the bottom in red
var content = $("<div class='red inlineHelp' />").html(text);
var message; // is there a current alert
if ($(".inlineHelp").length) {
// change text and reset timeout
message = $(".inlineHelp").html(text);
win.clearTimeout(win.helpTimeout);
} else {
// add to bottom and set a timeout
Modal.getCurrent(win).addContent(content);
message = $(".inlineHelp").css("opacity", "0").animate({
"opacity": "1"
}, 500, "linear", function () {
// force resize event
triggerResize(win);
});
}
win.helpTimeout = win.setTimeout(function () {
return message.animate({
"opacity": "0"
}, 500, "linear", function () {
message.remove();
triggerResize(win);
});
}, 15000); // force resize event
triggerResize(win);
} else {
// create a new popup
text = $("<p class='help_popup' />").html(text);
createModal(win, {
"content": text,
"attributes": {
"useCloseX": false
},
"buttons": [{
"text": "Close",
"type": "ok",
"callback": function callback(modal) {
return $(".inlineHelp").remove();
}
}]
});
}
};
},
/**
* Utility for adding fieldPrompt() the window variable.
**/
"addFieldPrompt": function addFieldPrompt(win) {
var $ = win.$;
/**
* Private utility function.
* Default functionality for when pop-up is unavailable.
**/
function defaultPrompt(win, field, message) {
win.alert(message);
}
/**
* Displays a pop-up for a incorrect field.
* Call with field and message: fieldPrompt(<field dom object>, "This field is invalid");
*
* @param fields
* array of fields to be prompted for
* @param message
* message to display about why field is invalid
* @param sumbitOnClose
* (internal) default to use for if to submit the form on successful validation
* @param notryagain
* (internal) if to wait if there is currently a pop-up
**/
function fieldPrompt(fields, message, submitOnClose, notryagain) {
// save for when we call "classic" functions
var passedIn = fields;
var isPassedInArray = !(fields.name || fields.id || fields.type) && fields.length; // force fields is an array
if (!isPassedInArray) {
fields = [];
fields[0] = passedIn;
} // force submitOnClose to be boolean (safety)
if (submitOnClose) {
submitOnClose = true;
} else {
submitOnClose = false;
} // submit when called from validate fields
if (win.runningValidFields) {
submitOnClose = true;
} // if we already have a pop-up just show the extra message
var popupsShowing = Modal.anyShowing(win);
if (popupsShowing) {
// if timeout waiting to spawn pop-up
if (notryagain) {
return defaultPrompt(win, passedIn, message);
} // if we are in a chain of pop-ups
if (!submitOnClose) {
return defaultPrompt(win, passedIn, message);
} else {
// last pop-up in chain is animating, try again soon
return win.setTimeout(function () {
return fieldPrompt(passedIn, message, submitOnClose, true);
}, 550);
}
} // Special Case for GridField validation
try {
if ($(".gridfield").length > 0) {
var gridFields = $(".gridfield");
for (var i = 0; i < gridFields.length; i++) {
if ($.contains(gridFields[i], fields[0])) {
return defaultPrompt(win, passedIn, message);
}
}
}
} catch (e) {}
/* Can safely ignore errors - means we're not in a gridfield*/
// what the fields and caption are contained within
var fieldDelimiter = win.fieldDelimiter || "tr"; // get the parent containing field
var fieldParent = null;
for (var _i8 = 0; _i8 < fields.length; _i8++) {
if (!fieldParent) {
fieldParent = $(fields[_i8]).closest(fieldDelimiter);
} else {
fieldParent = fieldParent.add($(fields[_i8]).closest(fieldDelimiter).eq(0));
}
} // If we could not find the field and its caption
if (!fieldParent.length) {
return defaultPrompt(win, passedIn, message);
} // Get a copy of the fields to display in the pop-up
var isDatefield = $(fieldParent).find(".hasDatepicker").length != 0;
var parentCopy = $(fieldParent).clone(!isDatefield); // clone handlers too (if not a date field)
$(parentCopy).find("*").addBack().each(function () {
var id = $(this).attr("id");
if (id) {
$(this).attr("id", "".concat(id, "_COPY"));
}
}); // remove any nodes marked as do-not-copy (i.e. injected widgets)
$(parentCopy).find(".do-not-copy").remove(); // find matching DOM copies of the field
var fieldCopy = [];
var duplicates = false;
parentCopy.find("*").each(function (index) {
for (var _i9 = 0; _i9 < fields.length; _i9++) {
var result = true;
var field = fields[_i9];
var id = $(field).attr("id");
var copyId = $(this).attr("id");
if ("".concat(id, "_COPY") != copyId) {
result = false;
}
if ($(field).attr("name") != $(this).attr("name")) {
result = false;
}
if ($(field).attr("value") != $(this).attr("value") && $(field).attr("type") != "select-one") {
result = false;
}
if ($(field).attr("type") != $(this).attr("type")) {
result = false;
}
if (result) {
// duplicate of already recorded field, bail
if (fieldCopy[_i9]) {
duplicates = true;
} // record the field in the copy
fieldCopy[_i9] = $(this).get(0);
}
}
}); // if duplicates bail
if (duplicates) {
return defaultPrompt(win, passedIn, message);
} // confirm copy and pass-in have same amount of elements
if (fields.length != fieldCopy.length) {
return defaultPrompt(win, passedIn, message);
} // normalize the two arrays
fields = trimArray(fields);
fieldCopy = trimArray(fieldCopy); // actually show the pop-up
var changeOnClose = false; // build content
var content = $("<div class='invalid'>".concat(message, "</div>")); // place field
$(content).append(parentCopy); // contain field in appropriate html trappings for styling
switch (fieldDelimiter) {
case "tr":
parentCopy.wrap("<table class=\"frmpfields\"></table>");
break;
case "td":
parentCopy.wrap("<table class=\"frmpfields\"><tr></tr></table>");
break;
case "li":
parentCopy.wrap("<ul></ul>");
break;
default:
parentCopy.wrap("<div class=\"fieldprompt\"></div>");
break;
}
createModal(win, {
"content": content,
"attributes": {
"useCloseX": true
},
"showOk": true,
"showCancel": true,
// callback is fired when 'Ok' button is clicked
"callback": function callback(modal) {
// TODO Need to find a better workaround, for some reason fieldCopy doesn't store the value of the field. Same code works in the old V1 architecture.
fieldCopy.filter(function (x) {
return x !== undefined;
}).forEach(function (x) {
var element = $("#".concat(x.id))[0];
x.checked = element.checked;
x.value = element.value;
}); // handle if pass-in was single field
var checkField;
if (isPassedInArray) {
checkField = fieldCopy;
} else {
checkField = fieldCopy[0];
} // check that field is valid
if (!validNewField(win, passedIn, checkField)) {
return false; // this will prevent closing
} // set to resubmit the form
changeOnClose = true;
},
"onOpen": function onOpen() {
if (isDatefield) {
var dfCopy = $(parentCopy).find(".hasDatepicker");
$(dfCopy).removeClass("hasDatepicker");
$(dfCopy).datepicker({
"showOtherMonths": true,
"selectOtherMonths": true,
"showAnim": "slideDown",
"changeYear": true
});
}
triggerResize(win); // HE-2143
$("#".concat(fieldCopy[0].id)).focus();
},
// onClose is fired no matter how modal is closed
"onClose": function onClose() {
$(".inlineHelp").remove();
if (changeOnClose) {
// handle if pass-in was single field
var newField;
if (isPassedInArray) {
newField = fieldCopy;
} else {
newField = fieldCopy[0];
} // re-add field to listeners
reassignFieldListeners(passedIn, newField); // push back data
for (var _i10 = 0; _i10 < fields.length; _i10++) {
// find if ie hack is needed for radio button's state
var ieHack = false;
if (fieldCopy[_i10].checked) {
ieHack = true;
} // actually replace data
$(fields[_i10]).replaceWith(fieldCopy[_i10]);
var id = $(fieldCopy[_i10]).attr("id") || "";
id = id.replace("_COPY", "");
if (id) {
$(fieldCopy[_i10]).attr("id", id);
}
if (isDatefield) {
$(fieldCopy[_i10]).removeClass("hasDatepicker");
$(fieldCopy[_i10]).datepicker({
"showOtherMonths": true,
"selectOtherMonths": true,
"showAnim": "slideDown",
"changeYear": true
});
} // use ie hack
if (ieHack) {
$(fieldCopy[_i10]).attr("checked", "checked");
}
} // notify the field change
_this.setAccess(win, false); // if was triggered by form submission, re-trigger
if (submitOnClose) {
$("[name='submit_button']").trigger("click");
}
}
}
});
} // set fieldPrompt() on the win object
win.fieldPrompt = fieldPrompt;
},
/**
* Initializes a formPage
**/
"initFormPage": function initFormPage(win) {
win.scores = new Array(0);
win.avgField = null;
win.totalField = null;
},
"multiRecordField": function multiRecordField(_window, id, url, fetchNow) {
var $ = _window.$;
function refreshResultPage() {
// "Caching" this selector fixes HE-3707 (Internet Explorer issue)
var $id = $("#".concat(id));
$id.html("<h3>Loading...</h3> <p><img src=\"https://cdn.searchsoft.net/images/loading.gif\" />Please Wait</p>"); // get content
$.get(url, // add ajax notification for server
"ajax=Y&refresh=Y", function (data, textStatus) {
if (textStatus === "success") {
// This is where Internet Explorer requires a "cached" selector. Maybe "$" is getting hijacked by the time the AJAX call finishes?
// populate the result
$id.html(data);
registerResultPageAjaxLinks();
} else {
throw "AJAX error getting content";
}
}, "text");
}
this.refreshResultPage = refreshResultPage; // when page has .resultpageajaxlinks show links in a pop-up; refreshing the
// "source" page when the pop-up is closed
function registerResultPageAjaxLinks() {
// when page has .resultpageajaxlinks show links in a pop-up
if ($("#".concat(id, " .resultpageajaxlinks")).length) {
var popId = "".concat(id, "_popup");
$("#".concat(id, " a:not([class~=\"resultlink\"])")).click(function (eventObject) {
var $this = $(this); // what was clicked on
var href = $this.attr("href"); // is delete link
if ($this.hasClass("delete")) {
_window.superConfirm("Are you sure you want to delete this record?", function () {
return $.post(href, null, function (data, textStatus) {
if (textStatus === "success") {
refreshResultPage();
} else {
throw "AJAX error";
}
});
});
} else {
// ajax to fill in pop-up
_this.addToolboxFunction(_window, popId, function () {
return ajaxFillinPopup(_window, popId, href, null, true);
}); // refresh the result page on close
_this.addToolboxFunction(_window, "".concat(popId, "_close"), function () {
return refreshResultPage();
}); // show a pop-up
_this.showPopup(_window, popId);
} // stop browser from following link
eventObject.preventDefault();
return false;
});
}
}
if (fetchNow) {
refreshResultPage();
} else {
registerResultPageAjaxLinks();
}
},
/**
* Register a JSExpression field
**/
"jsExpression": function jsExpression(win, target, expression, defaults) {
var $ = win.$; // varaiables
var varRegExp = new RegExp("\\b[A-Za-z][A-Za-z0-9_]+\\b", "g"); // create listener for "onchange" of each variable
var variable;
while ((variable = varRegExp.exec(expression)) != null) {
// listener for onchange
var elem = $("[name='".concat(variable, "']"));
if (elem.length) {
elem.unbind(jqueryUniversalChangeSupportedEvents.join(","), runExpression);
jqueryUniversalChange(win, elem.get(0), runExpression);
}
} // utility to run the function
function runExpression() {
// this call will never propagate an exception...
var expr = buildRawExpression();
try {
// change the value of target
var value = eval(expr);
var targetField = $("#".concat(target, "_display"));
var targetHidden = $("#".concat(target));
if (value != targetHidden.val()) {
targetField.val(value);
targetField.trigger("change");
targetHidden.val(value);
targetHidden.trigger("change");
}
} catch (ex) {
lib.replaceAlert(win);
var msg = "<span style='font-size: 1em; font-style: normal; font-weight: normal'>It appears that there is an unresolved variable in the JS Expression string provided:</span><br /><br /><span style='font-size: .8em; font-style: italic; font-weight: bold'>".concat(expr, "</span><br /><br /><span style='font-size: 1em; font-style: normal; font-weight: normal'>Check the unresolved field name and ensure that it corresponds with an input on the page.</span>");
win.alert(msg);
$("#".concat(target, "_display")).val("###");
}
} // utility that returns expression with all variables replaced with their real values
function buildRawExpression() {
var result = expression;
try {
// replace all variables in the string
var _variable;
while ((_variable = varRegExp.exec(expression)) != null) {
// value in the form
var value = null;
var variableField = $("[name='".concat(_variable, "']"));
if (variableField.length != 0 && "###" != variableField.val()) {
value = Number(variableField.val());
} // use the default
else if (defaults[_variable] != null) {
value = Number(defaults[_variable]);
} // don't replace this one
else {
continue;
} // use zero if field had nonsense value
if (!isFinite(value)) {
value = Number(0);
} // replace the value
result = result.replace(new RegExp("\\b".concat(_variable, "\\b"), "g"), value);
}
result = "( ".concat(result, " )");
} catch (e) {
_log(e);
}
return result;
} // run it for the first time
runExpression();
},
"reloadNewMcrelYear": function reloadNewMcrelYear(win, mcrelYearDropDownDomName) {
var $ = win.$; // domReady doesn't work reliably here
$(function () {
var $select = $("select[name=\"".concat(mcrelYearDropDownDomName, "\"]"));
$select.change(function () {
var val = $select.val();
if (val !== "") {
var currentLocation = $("form").prop("action");
var newLocation = URI(currentLocation).setQuery("MCREL_YEAR_ID", val).toString();
win.location.href = newLocation;
}
});
});
},
"reloadTeamMemberDashboard": function reloadTeamMemberDashboard(win) {
var $ = win.$;
_this.onReady(win, function () {
return $("select[name='TEAM_MEMBER_USER_ID']").change(function (e) {
var curLocation = win.location.href;
var url;
if (/TEAM_LED_ID=[^&]*/.test(curLocation)) {
url = curLocation.replace(/TEAM_LED_ID=[^&]*/, "TEAM_LED_ID=".concat($("select[name='TEAM_LED_ID']").val()));
} else {
url = "".concat(curLocation, "&TEAM_LED_ID=").concat($("select[name='TEAM_LED_ID']").val());
}
if (/TEAM_MEMBER_USER_ID=[^&]*/.test(curLocation)) {
url = url.replace(/TEAM_MEMBER_USER_ID=[^&]*/, "TEAM_MEMBER_USER_ID=".concat($(this).val()));
} else {
url = "".concat(url, "&TEAM_MEMBER_USER_ID=").concat($(this).val());
}
var regex = /TEAM_MEMBER_USER_ID=([^&]*)/g;
var match = regex.exec(curLocation);
if (match != null && match[1] == $(this).val()) {
return;
} else {
win.location.href = url;
}
});
});
},
"addReloadOnSelectChange": function addReloadOnSelectChange(win, selectName) {
var $ = win.$;
_this.onReady(win, function () {
return $("select[name='".concat(selectName, "']")).change(function (e) {
var curLocation = win.location.href;
var url;
var urlParamRegex = new RegExp("".concat(selectName, "=[^&]*"));
if (urlParamRegex.test(curLocation)) {
url = curLocation.replace(urlParamRegex, "".concat(selectName, "=").concat($(this).val()));
} else {
url = "".concat(curLocation, "&").concat(selectName, "=").concat($(this).val());
}
var regex = new RegExp("".concat(selectName, "=([^&]*)"), "g");
var match = regex.exec(curLocation);
if (match != null && match[1] == $(this).val()) {
return;
} else {
win.location.href = url;
}
});
});
},
"activatePreview": function activatePreview(win, openNewWindow, inputId, buttonId, lookup) {
var $ = win.$;
$("#".concat(buttonId)).click(function () {
var input = $("[name=".concat(inputId, "]"));
if (!input.length) {
return win.alert("No input field to preview");
}
var value = input.val();
if (value == "" || value == null) {
return win.alert("No input currently selected");
}
var url = lookup[value];
if (url == "" || url == null) {
return win.alert("No preview page for that selection");
}
if (!openNewWindow) {
var div = "".concat(buttonId, "_div");
_this.addToolboxFunction(win, div, function () {
return ajaxFillinPopup(win, div, url, null);
});
_this.showPopup(win, div);
} else {
win.open(url);
}
});
},
/**
* Registers a staged select field
**/
"registerStageSelect": function registerStageSelect(win, fieldId, dbFieldId, parentId, value, multi, required) {
_this.onReady(win, function () {
// JQuery
var $ = win.$; // create the two types of fields we can be
var selectField = $("[name='".concat(fieldId, "']"));
var singleValueId = "singleValue_".concat(fieldId);
if (!selectField.length) {
_log("StagedSelectField is not present!");
return;
} // find the parent
var parentField = $("[name='".concat(parentId, "']"));
if (!parentField.length) {
_log("StagedSelectField parent field is not present: ".concat(parentId));
return;
}
var addWildcard = parentField.attr("type") == "text";
function stageChangeEvent(e) {
// get parent value
var me = $(this);
var parentValue = me.val();
if (addWildcard) {
parentValue += "*";
} // make best faith to encode
if (encodeURIComponent) {
parentValue = encodeURIComponent(parentValue);
} else {
if (escape) {
parentValue = escape(parentValue);
}
} // only proceed for selected checkboxes and radio buttons
var type = me.attr("type");
var checkable = type == "radio" || type == "checkbox";
var selected = me.attr("checked");
if (checkable && !selected) {
return;
} // actually get the results; JSONP request
if (parentValue != "" && parentValue != null) {
var url = "/ats/stage_field_lookup?GUI_FIELD_ID=".concat(dbFieldId, "&parentvalue=").concat(parentValue, "&ajax=Y&jscallback=?");
$.getJSON(url, addLookups);
} else {
nukeChoice();
}
} // add the lookups to the select field
var addOnChange = true;
function addLookups(lookups) {
// error check
if (!lookups) {
_log("lookups null");
return;
} // find length
var length = lookups.length; // support collapsing single values
var showSingleValue = length == 1 && required;
var selectedCaptions = ""; // clear out all current entries
selectField.html("");
$("#".concat(singleValueId)).remove();
if (!showSingleValue) {
selectField.show();
} // final choices
var options = "";
var hasSelected = false; // populate the new ones
$.each(lookups, function (index, obj) {
var lookupValue = obj["value"]; // skip empty string (dummy value)
if (lookupValue == "") {
return;
} // Locate caption
var lookupCaption = obj["caption"]; // if this is our original value mark slected
var selected = "";
if ($.inArray(lookupValue, value) != -1 || showSingleValue) {
selectedCaptions += lookupCaption;
selected = " selected='selected' ";
hasSelected = true;
} // add the value
options += "<option value='".concat(lookupValue, "'").concat(selected, ">").concat(lookupCaption, "</option>");
}); // empty option
if (!(multi || showSingleValue)) {
options = "<option value=''".concat(hasSelected ? "" : " selected='selected' ", "></option>").concat(options);
}
selectField.append(options); // support single value
if (showSingleValue) {
selectField.hide();
var captions = "<div id='".concat(singleValueId, "'>").concat(selectedCaptions, "</div>");
selectField.after(captions);
}
selectField.triggerHandler("change");
if (addOnChange) {
addOnChange = false;
selectField.change(function () {
return _this.setAccess(win, false);
});
}
} // add the lookups to the select field
function nukeChoice() {
// clear out all current entries
selectField.html("").show();
$("#".concat(singleValueId)).remove();
if (!multi) {
selectField.append("<option value='' selected='selected'></option>");
}
selectField.triggerHandler("change");
} // bind to changes on the parent
parentField.bind("change", stageChangeEvent); // trigger initial population
stageChangeEvent.apply(parentField.get(0));
});
},
/**
* Registers a staged text field
**/
"registerStageText": function registerStageText(win, fieldId, dbFieldId, parentId, multi, required) {
_this.onReady(win, function () {
// JQuery
var $ = win.$; // create the two types of fields we can be
var textField = $("[name='".concat(fieldId, "']"));
if (!textField.length) {
alert("StageTextField is not present!");
return;
} // find the parent
var parentField = $("[name='".concat(parentId, "']"));
if (!parentField.length) {
alert("StageTextField parent field is not present: ".concat(parentId));
return;
}
function stageChangeEvent(e) {
// get parent value
var me = $(this);
var parentValue = me.val(); // make best faith to encode
if (encodeURIComponent) {
parentValue = encodeURIComponent(parentValue);
} else {
if (escape) {
parentValue = escape(parentValue);
}
} // only proceed for selected checkboxes and radio buttons
var type = me.attr("type");
var checkable = type == "radio" || type == "checkbox";
var selected = me.attr("checked");
if (checkable && !selected) {
return;
} // actually get the results; JSONP request
if (parentValue != "" && parentValue != null) {
var url = "/ats/stage_field_lookup?GUI_FIELD_ID=".concat(dbFieldId, "&parentvalue=").concat(parentValue, "&ajax=Y&jscallback=?");
$.getJSON(url, addLookups);
}
} // add the lookups to the select field
var addOnChange = true;
function addLookups(lookups) {
// error check
if (!lookups) {
alert("lookups null");
return;
} // error check
if (lookups.length != 1) {
alert("lookup must have one value");
return;
}
var newValue = lookups[0]["value"];
textField.val(newValue); // Hack that fixes SSOFT-5469
// https://stackoverflow.com/questions/11793368/set-textarea-value-with-javascript-after-tinymce-initializing/11793478#11793478
if (win !== null && win.tinymce !== null) {
var tinymceEditor = win.tinymce.get(textField.attr("id"));
if (tinymceEditor !== null) {
tinymceEditor.setContent(newValue);
}
}
textField.triggerHandler("change");
if (addOnChange) {
addOnChange = false;
textField.change(function () {
return _this.setAccess(win, false);
});
}
} // bind to changes on the parent
parentField.bind("change", stageChangeEvent); // trigger initial population
stageChangeEvent.apply(parentField.get(0));
function getFirstKey(data) {
for (var elem in data) {
return elem;
}
}
});
},
"registerMoveToSelect": function registerMoveToSelect(win, domId) {
function alphaSort(doma, domb) {
var a = doma.innerHTML;
var b = domb.innerHTML;
var va = a === null ? "" : "".concat(a);
var vb = b === null ? "" : "".concat(b);
return va > vb ? 1 : va === vb ? 0 : -1;
}
function moveTo($from, $to) {
// move to other side
var $fromdetached = $from.find(":selected");
$fromdetached.detach();
$to.append($fromdetached); // sort result
var $toDetach = $to.children();
$toDetach.detach();
$to.append($toDetach.get().sort(alphaSort));
}
var $ = win.$;
var $dst = $("#".concat(domId));
var $src = $("#".concat(domId, "_src"));
$("#".concat(domId, "_addbtn")).click(function () {
_this.setAccess(win, false);
$dst.children().prop("selected", false);
moveTo($src, $dst);
});
$("#".concat(domId, "_rmvbtn")).click(function () {
_this.setAccess(win, false);
$src.children().prop("selected", false);
moveTo($dst, $src);
});
$("form").on("click", "input:submit", function () {
$src.children().prop("selected", false);
$dst.children().prop("selected", true);
});
},
"browseToNextUrlFromNavigationPulldown": function browseToNextUrlFromNavigationPulldown(win, backward) {
var nextUrl = getNextUrlFromNavigationPulldown(win, backward);
if (nextUrl) {
win.location.href = nextUrl;
} else {
alert("Already at the end or beginning of the list.");
}
},
"writeRedirectFromNav": function writeRedirectFromNav(win) {
return win.$("form").append("<input type=\"hidden\" name=\"redirect\" value=\"".concat(getNextUrlFromNavigationPulldown(win, false), "\">"));
},
"handlePreviousNavButton": function handlePreviousNavButton(win) {
var nextUrl = getNextUrlFromNavigationPulldown(win, true);
if (!nextUrl) {
win.$(":button[value=Previous]").remove();
}
},
"registerQuickSelectGoButton": function registerQuickSelectGoButton(win, id) {
return _this.onReady(win, function () {
var $ = win.$;
$("#".concat(id, "_go")).click(function () {
var selectName = "[name='".concat(id, "']");
var select = $(selectName);
var href = select.val();
if (href != "") {
win.location.href = href;
}
});
});
},
/**
* Tie together an expanding multivalue field (edit only)
**/
"registerExpandingMultiValue": function registerExpandingMultiValue(win, fieldName, showRemove, rangeExtra) {
var $ = win.$;
_this.onReady(win, multiValueField);
function multiValueField() {
// find needed elements
var row;
var org;
var container;
var size;
var maxSize;
var template;
init(); // undo support
$(":reset").click(function (e) {
row.html(org);
init();
});
function init() {
row = $("#".concat(fieldName, "_ROW"));
row.find("script").remove();
org = row.html();
container = $("#".concat(fieldName, "_TABLE_CONTAINER tbody"));
size = row.find("#".concat(fieldName, "_SIZE"));
maxSize = parseFloat(size.val());
template = row.find("#".concat(fieldName, "_TEMPLATE")); // min value
if (rangeExtra) {
addAllMin();
} // auto remove
if (rangeExtra) {
addAllRangeExtra();
} // remove links
if (showRemove) {
addAllRemove();
} // add link
var addMoreId = "".concat(fieldName, "_addmore");
if (!container.parent().find("#".concat(addMoreId)).length) {
var addMoreA = $("<a class=\"addMoreA\"></a>").attr({
"id": addMoreId,
"href": "#"
}).html("<img src=\"/ats/css-base/add.png\" class=\"addMoreImg\"/>Add More").click(function (e) {
e.preventDefault();
_this.setAccess(win, false);
addEmptyRow();
return false;
});
container.closest("table").after(addMoreA);
}
if (parseFloat(size.val()) < 1) {
// first row shouldn't prevent leaving page
addEmptyRow();
}
}
function addEmptyRow() {
// add one to size
var curSize = parseFloat(size.val());
size.val(curSize + 1);
maxSize += 1;
var newRecord = "<tr class=\"subrecord_container ".concat(fieldName, "_subrecord_container\" id=\"").concat(fieldName, "_").concat(maxSize - 1, "\">").concat(template.html().replace(/_TEMPLATE/g, "_SUBRECORD_" + (maxSize - 1)), "</tr>"); // insert new content to html
container.append(newRecord);
var newElem = $("#".concat(fieldName, "_").concat(maxSize - 1)); // add remove
if (showRemove) {
addRemove(newElem);
} // add min
if (rangeExtra) {
addMin(newElem);
} // range extra
if (rangeExtra) {
addRangeExtra(newElem);
}
addRemoveTrigger(newElem); // allow any boxes to resize
triggerResize(win);
}
function addAllRangeExtra() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addRangeExtra(subRecords);
}
function addRangeExtra(jq) {
jq.each(function () {
var me = $(this);
var min = me.find(".subrecord_min");
var field = me.find(jqueryUniversalChangeSupportedTags).get(0);
jqueryUniversalChange(win, field, function () {
rangeExtraTrigger(field, min);
return true;
});
});
function rangeExtraTrigger(field, min) {
var cur = $(field);
var minVal = parseFloat(min.html());
var curVal = parseFloat(cur.val());
if (isNaN(curVal) || minVal >= curVal) {
cur.val(minVal + 1);
}
}
}
function addAllMin() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addMin(subRecords);
}
function addMin(jq) {
// jq object
jq.find(".remove_container").append(" greater than <span class=\"subrecord_min\"></span>");
addMinTrigger(jq);
}
function addMinTrigger(jq) {
jq.each(function () {
var me = $(this);
var prev = me.prev(".".concat(fieldName, "_subrecord_container"));
var min = me.find(".subrecord_min");
if (prev.length) {
var cur = me.find(jqueryUniversalChangeSupportedTags).filter(":first");
var field = prev.find(jqueryUniversalChangeSupportedTags).filter(":first").get(0);
jqueryUniversalChange(win, field, function () {
minTrigger(field, cur, min);
return true;
});
minTrigger(field, cur, min);
} else {
// nothing exists show "min" text
min.html("0");
}
});
function minTrigger(field, cur, min) {
var minVal = parseFloat($(field).val());
var curVal = parseFloat(cur.val());
min.html(minVal);
if (!isNaN(curVal) && minVal >= curVal) {
cur.val(minVal + 1);
cur.trigger("change");
}
}
}
function addAllRemove() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addRemove(subRecords);
addRemoveTrigger(subRecords);
}
function addRemove(jq) {
// jq object
jq.find(".remove_container").prepend("<a class=\"subrecord_remove\"><img title=\"Remove\" alt=\"remove\" src=\"/ats/css-base/remove.png\" /></a>");
}
function addRemoveTrigger(jq) {
jq.find(".subrecord_remove").click(function (e) {
_this.setAccess(win, false);
size.val(parseFloat(size.val()) - 1);
var me = $(this).closest(".subrecord_container");
var next = me.next(".subrecord_container");
me.remove();
if (rangeExtra) {
addMinTrigger(next);
}
});
}
}
},
"disableSubmitButtons": function disableSubmitButtons(win) {
win.$("input[type='submit']").attr("disabled", "disabled");
return true;
},
"eformOptionalEventHideFields": function eformOptionalEventHideFields(win, checkboxId) {
/**
* Helper function used to enable/disable a set of elements. Will set/remove 'disabled' attribute
* for all form fields, and will show/hide all elements iterated through.
*
* @param field an HTMLElement or jQuery object
* @param doEnable boolean flag indicating if item should be enabled/disabled
*/
function enable(field, doEnable) {
var formFields = $(field).find("input,select,textarea");
$(formFields).each(function (i, kid) {
if (doEnable) {
$(kid).prop("disabled", false);
} else {
$(kid).prop("disabled", true);
}
});
if (doEnable) {
$(field).show();
} else {
$(field).hide();
}
}
_this.onReady(win, function () {
var $ = win.$;
var checkbox = $("#".concat(checkboxId));
var topRow = checkbox.closest("tr");
var fieldsForEvent = topRow.nextUntil("tr.endEformEvent");
checkbox.change(function () {
var isChecked = checkbox.is(":checked");
enable(fieldsForEvent, isChecked);
});
checkbox.trigger("change");
});
}
};
if (_this.isDevMode) {
/**
* This method is called to initialize and return a DevLinks instance, which exposes
* methods used to interact with and alter behavior of dev links on page. Only one instance per context
* will be created (subsequent calls to this method will return cached instance).
*
* @param {Window} win the context Window
*/
_this.initDevLinks = function () {
function DevLinks(win) {
/**
* Flag indicating if base records should be interacted with (if true) or if alt records should
* be interacted with (if false).
*
* @private
*/
this._useBase; // use for referencing instance in inner/non-member functions
var _devLinks = this; // member functions
/**
* Is called to set the flag indicating whether alt records or base records should be interacted
* with when using dev tools. Each call to this method will also ensure that proper click
* handlers are in place for current page dev tools. The default state is to interact with
* alt records, unless a value of true for useBase is provided.
*
* @param {boolean} [useBase] (optional) if present and true, will interact with base records, and will interact with alt records otherwise
*/
this.setToolAltOption = function (useBase) {
if (_devLinks._useBase === void 0) {
_devLinks._useBase = useBase === true;
} else if (useBase !== void 0) {
_devLinks._useBase = useBase === true;
}
/**
* Is called to enable dev tools to interact with alt records (this is the default behavior).
*/
function enableAlts() {
// will now use alts
_devLinks._useBase = false;
$("div.devmenu a").css({
"background": "#eee"
});
$("div.devmenu a.alttool").each(function () {
var me = $(this);
var href = me.attr("href");
href = href.replace("&usealt=N", "");
me.attr("href", href);
});
}
/**
* Is called to enable dev tools to interact with base records (this is the NON-default behavior,
* and should be treated as potentially risky).
*/
function enableBase() {
// will now use base
_devLinks._useBase = true;
$("div.devmenu a").css({
"background": "orange"
});
$("div.devmenu a.alttool").each(function () {
var me = $(this);
var href = me.attr("href"); // ensure that param has not already been set
href = href.replace("&usealt=N", "");
href = href + "&usealt=N";
me.attr("href", href);
});
}
$("a.dragalt").unbind("click.devtools").bind("click.devtools", function () {
enableAlts();
win.alert("Tools will modify the alt record (default behavior).");
});
$("a.dragbase").unbind("click.devtools").bind("click.devtools", function () {
enableBase();
win.alert("Tools will now modify the base records (for all companies)! \n" + "Danger, this will effect all pages until you log-out or set it back to alt!");
});
if (_devLinks._useBase) {
enableBase();
} else {
enableAlts();
}
}; // initialization and non-member-function definitions
var $ = checkJQuery(win, win.$);
var devDivId = "devdivid"; // cached value of window scroll value used in initDevLinks
var yOffset = 0;
$.extend($.fn.disableTextSelect = function () {
return this.each(function () {// if ($.browser.mozilla) {//Firefox
// $(this).css('MozUserSelect', 'none');
// } else if ($.browser.msie) {//IE
// $(this).bind('selectstart', function () {
// return false;
// });
// } else {//Opera, etc.
// $(this).mousedown(function () {
// return false;
// });
// }
});
}); // after clicking a link scroll back down (but not in the pop-up)
if (yOffset && yOffset != win.yOffset) {
_this.onReady(win, function () {
win.scrollTo(0, yOffset); // only do this once (after clicking a link)
yOffset = 0;
});
}
function addDevDivPopupLoading() {
// add the content
var devDiv = "<div id=\"" + devDivId + "\" style='display: none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>";
$("body").children(":last").after(devDiv); // refresh the page on close
_this.addToolboxFunction(win, devDivId + "_close", function () {
win.yOffset = typeof win.pageYOffset == "number" ? win.pageYOffset : win.document.documentElement ? win.document.documentElement.scrollTop : win.document.body.scrollTop;
yOffset = win.yOffset;
$("body").html("<h1>Reloading...</h1>");
win.location.reload();
});
}
this.activateDevLink = function () {
var me = $(this);
var href = me.attr("href");
if (href) {
if (!me.hasClass("newwindow")) {
var sdata = null;
var hijack = true;
var hijackStayOpen = true;
var devmode = true; // ajax to fill in pop-up
var fullHijack = me.hasClass("wizarddevlink");
var noHijack = me.hasClass("search");
_this.addToolboxFunction(win, devDivId, function () {
// display the result of submitting in the pop-up?
if (fullHijack) {
// wizard
ajaxFillinPopup(win, devDivId, href, sdata, hijack, hijackStayOpen, devmode);
} else {
if (!noHijack) {
// submit and done
ajaxFillinPopup(win, devDivId, href, sdata, hijack, false, devmode);
} // submit to another page
else {
ajaxFillinPopup(win, devDivId, href, sdata, false, false, devmode);
}
}
}); // show a pop-up
_this.showPopup(win, devDivId);
return false;
}
}
return true;
};
function devPopups() {
$("a.devmenulink").each(function () {
this.onclick = _devLinks.activateDevLink;
});
}
function posArrows() {
// what is currently being dragged
var effectWhatFieldId = null; // reset drag if outside
win.document.body.onmouseup = function () {
return effectWhatFieldId = null;
}; // side-by-side
if (win.fieldDelimiter == "td") {
$("div.devfieldmenu").each(function () {
var me = $(this).closest("td");
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var width = me.width();
var height = me.height() - 5;
var demHor = "width: 10px; height: " + height + "px;";
var demVer = "width: " + width + "px; height: 10px;";
var styleDivVer = "style=\"position: absolute;" + demVer + "text-align: center;float: left;clear: both;\"";
var styleDivHor = "style=\"position: absolute;" + demHor + "\"";
var styleLinkVer = "style=\"display: block;" + demVer + "\"";
var styleLinkHor = "style=\"display: block;" + demHor + "overflow: hidden;\"";
var styleImgHor = "style=\"border: 0; padding-top: " + (height / 2 - 30) + "px;\"";
var classStr = ".uparrow,.rightcon,.leftarrow,.downcon";
var upLeftRight = "<div class=\"uparrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/up.png\"/></a></div><div class=\"leftarrow\" " + styleDivHor + "><a " + styleLinkHor + " href=\"\"><img " + styleImgHor + " src=\"/ats/css-base/left.png\"/></a></div><div class=\"rightcon\" style=\"left: " + (width - 5) + "px; position: relative;\"> <div class=\"rightarrow\" " + styleDivHor + "><a " + styleLinkHor + " href=\"\"><img " + styleImgHor + " src=\"/ats/css-base/right.png\"/></a></div></div>"; // IE needs the extra div because position: absolute elements don't display: block (like they should)
var down = "<div class=\"downcon\"><div class=\"downarrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/down.png\"/></a></div></div>"; // register start of drag
var menu = $(this);
menu.disableTextSelect();
menu.get(0).onmousedown = function () {
return effectWhatFieldId = myGuiFieldId;
}; // handle drag end
var endhref = "/ats/admin/drag_move_field.jsp?end_field_id=" + myGuiFieldId; // show links on hover
// lazy register me.hover() b/c IE is slow to register
me.get(0).onmouseover = function (e) {
// derigester on first hit
me.get(0).onmouseover = null; // real event
me.hover(function (e) {
// only when active drag
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
me.prepend(upLeftRight);
me.append(down); // trigger end of drag
me.children(classStr).mouseup(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
var href = endhref + "&start_field_id=" + effectWhatFieldId + "&dir=" + $(this).attr("class").replace(/arrow/, "") + "&usealt=" + (_devLinks._useBase ? "N" : "Y"); // ajax to fill in pop-up
_this.addToolboxFunction(win, devDivId, function () {
return ajaxFillinPopup(win, devDivId, href);
});
_this.showPopup(win, devDivId);
}
});
}
}, function () {
// clear arrows on leaving
me.find(classStr).remove();
});
me.trigger("mouseover");
};
});
} else {
// regular formpage
$("div.devfieldmenu").each(function () {
var me = $(this).closest("tr");
var th = me.find("th");
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first");
if (myGuiFieldId.length) {
myGuiFieldId = myGuiFieldId.eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
} else {
return;
}
var demVer = "width: " + th.width() + "px; height: 1.5em; left: 0;";
var styleDivVer = "style=\"position: absolute;text-align: center;" + demVer + "\"";
var styleLinkVer = "style=\"" + demVer + "display: block;\"";
var classStr = ".uparrow,.downcon";
var up = "<div class=\"uparrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/up.png\"/></a></div>";
var down = "<div class=\"downcon\"><div class=\"downarrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/down.png\"/></a></div></div>"; // register start of drag
var menu = me.find("div.devmenu");
menu.disableTextSelect();
menu.get(0).onmousedown = function () {
return effectWhatFieldId = myGuiFieldId;
}; // register end of drag
var endhref = "/ats/admin/drag_move_field.jsp?end_field_id=" + myGuiFieldId; // show links on hover
// lazy register me.hover() b/c IE is slow to register
me.get(0).onmouseover = function (e) {
// derigester on first hit
me.get(0).onmouseover = null; // use jquery to make it easy
me.hover(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
th.prepend(up);
th.append(down); // trigger events
me.find(classStr).mouseup(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
// href
var href = endhref + "&start_field_id=" + effectWhatFieldId + "&dir=" + $(this).attr("class").replace(/arrow/, "") + "&usealt=" + (_devLinks._useBase ? "N" : "Y"); // ajax to fill in pop-up
_this.addToolboxFunction(win, devDivId, function () {
return ajaxFillinPopup(win, devDivId, href);
}); // show a pop-up
_this.showPopup(win, devDivId);
}
});
}
}, function () {
return me.find(classStr).remove();
});
me.trigger("mouseover");
};
});
} // regular form page
}
function dependTool() {
// for all depend links on fields`
$("a.dependtool").unbind().click(function () {
var mymenu = $(this).closest("div.devfieldmenu");
var parentGuiFieldId = $(this).closest("div.devmenu").find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var dependValue = win.prompt("For what value?"); // orignating make a refresh stop link
mymenu.replaceWith("<a onclick='window.location.reload()'>Stop</a>"); // replace all field menus on page with "make depend" link
$("div.devfieldmenu").replaceWith(function () {
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var result = "<a class='makedependlink'" + " href='/ats/admin/field_make_depend.jsp" + "?PARENT_GUI_FIELD_ID=" + parentGuiFieldId + "&GUI_FIELD_ID=" + myGuiFieldId + "&value=" + encodeURIComponent(dependValue) + "&ajax=Y" + "&usealt=" + (_devLinks._useBase ? "N" : "Y") + "' >" + " Make Dependant</a>";
return result;
}); // silently go to page
$("a.makedependlink").unbind().click(function (e) {
var me = $(this);
e.preventDefault();
var url = $(this).attr("href");
$.get(url, null, function (data, rstatus) {
if (rstatus == "success") {
me.remove();
} else {
win.alert("failed to make dependant, check your console and get a developer");
}
});
return false;
});
});
}
function hideDevLinks() {
$("a.hidedev").click(function (e) {
e.preventDefault();
hideDevLinks();
});
function hideDevLinks() {
$(".debug,.devmenu").fadeOut();
}
}
function showHiddenLinks(win) {
$(".showhidden").click(function (e) {
e.preventDefault();
if (win.location.search == "") {
win.location.search = "?showhidden=Y";
} else {
if (win.location.search.match(/showhidden=Y/)) {
win.location.search = win.location.search.replace(/[\?\&]showhidden=Y/, "");
} else {
win.location.search += "&showhidden=Y";
}
}
});
}
function autoAltCompanyId() {
var alt = $("select[name='ALT_COMPANY_ID']");
if (alt.length && !alt.val()) {
alt.val("<%=companyId%>");
}
}
function showFieldNames() {
$("a.showFieldNames").click(function () {
return $("span.fieldName").show();
});
}
_this.onReady(win, function () {
if (!win.devDone) {
addDevDivPopupLoading();
_devLinks.setToolAltOption();
showFieldNames();
posArrows();
dependTool();
devPopups();
hideDevLinks();
showHiddenLinks(win);
autoAltCompanyId();
} else {// if ($.browser.msie && $.browser.version < 9) {
// //TODO: #modal
// //$("#simplemodal-container .devmenu").hide();
// }
}
win.devDone = true;
});
}
return function (win) {
if (!win._ss_devLinks) {
win._ss_devLinks = new DevLinks(win);
}
return win._ss_devLinks;
};
}();
}
/**
* Class used to construct and render a hierarchical set of checkboxes with cascading click functionality.
*
* @param win
* @param scriptId
* @param json
* @constructor
*/
function HierCheckboxModel(win, scriptId, json) {
var $ = win.$;
/**
* The root node object containing node hierarchy.
* @type {{children: Array}}
* @private
*/
this._rootNode = {
"children": []
};
/**
* Collection of ALL node instances.
* @type {Array}
* @private
*/
this._allNodes = [];
/**
* Counter used to generate unique index for all nodes.
* @type {number}
* @private
*/
this._counter = 0;
var _this = this;
function cascadeChecks(field, index) {
function cascadeNodeChecks(node) {
var children = node.children;
for (var i = 0; i < children.length; i++) {
children[i].field.checked = node.field.checked;
cascadeNodeChecks(children[i]);
}
}
lib.setAccess(win, false);
var node = _this._allNodes[index];
cascadeNodeChecks(node);
if (node.field.checked) {
var parent = node.parent;
while (parent != null && parent.field != null) {
parent.field.checked = node.field.checked;
parent = parent.parent;
}
}
}
/**
* Renders node, recursing through all kids, if present, and appending HTML to parent provided.
*
* @param parent parent HTML element to append generated HTML to
* @param parentNode parent node object
* @param json JSON containing node data
* @private
*/
function _doRender(parent, parentNode, json) {
var node = json.node;
var kids = json.children;
parentNode = _renderListItem(node, _this._counter++, parentNode);
$(parent).append(parentNode.html);
if (kids.length > 0) {
var html = $("<ul></ul>");
$(parentNode.html).append(html);
$.each(kids, function (i, kid) {
return _doRender(html, parentNode, kid);
});
}
}
/**
* Is called to generate LI tag containing checkbox and caption (or a link, if a URL is present in
* node JSON).
*
* @param node the JSON object containing info used to render checkbox
* @param index the unique counter value for this instance
* @param rootNode the parent node for this instance
* @param [imgSrc] optional - if present, renders an image link
* @param [expandAction] optional - if present, is Lib funnction to call on click
*
* @returns {{html: (*|jQuery|HTMLElement), field: *, children: Array, parent: *}} new node object
* @private
*/
function _renderListItem(node, index, rootNode, imgSrc, expandAction) {
var name = node.name;
var value = node.value;
var checked = node.isChecked;
var caption = node.caption;
var url = node.url; // ensure values are null rather than undefined if not provided (unsure if any explicit null-checks occur below)
imgSrc = imgSrc === void 0 || imgSrc == "null" ? null : imgSrc;
expandAction = expandAction === void 0 || expandAction == "null" ? null : expandAction;
var listItem = $("<li></li>"); // the list item content item
var item;
if (imgSrc != null && expandAction != null) {
item = $("<a></a>").attr("href", "#".concat(value));
$(item).click(function (event) {
try {
return lib[expandAction](win, value, index);
} catch (e) {
_log(e);
}
});
var img = $("<img />").attr("border", "0").attr("src", imgSrc);
$(item).append(img);
} else if (imgSrc != null) {
item = $("<img />").attr("src", imgSrc).attr("border", "0");
}
if (item) {
$(listItem).append(item);
}
var input = $("<input />").attr("type", "checkbox").attr("name", name).attr("value", value);
if (checked) {
$(input).attr("checked", "checked");
}
$(input).click(function (event) {
cascadeChecks(this, index);
});
$(listItem).append(input);
if (!url) {
$(listItem).append(win.document.createTextNode(caption));
} else {
url = url.indexOf("http://") == 0 ? url : "http://" + url;
var a = $("<a></a>").attr("target", "_blank").attr("href", url).text(caption);
$(listItem).append(a);
}
var newNode = {
"html": listItem,
"field": input[0],
"children": [],
"parent": rootNode
};
newNode.parent.children.push(newNode);
_this._allNodes.push(newNode);
return newNode;
}
/**
* Is called to assemble checkboxes and inject into DOM.
*/
this.render = function () {
var script = $("script#".concat(scriptId));
json = $.parseJSON(json);
var ul = $("<ul></ul>");
_doRender(ul, _this._rootNode, json);
$(ul).insertAfter(script);
};
}
/**
* Default globaal error handler - redirects to error.jsp.
*
* @param msg
* @param url
* @param ln
*/
function handleError(msg, url, ln) {
_log(new Error(msg), true); // if (top.frames.length > 1 && top.frames[1].name == 'sss_dynomite') {
// top.sss_dynomite.window.document.location.replace(
// '/ats/jserror.jsp?msg=' + escape(msg) + '&url=' + escape(url) + '&line=' + ln
// );
// if (!_this.loaded) {
// top.document.location.replace(
// '/ats/error.jsp?msg=' +
// 'There+was+an+internal+error.++You+have+been+logged+out.' +
// '++Please+close+all+browsers+and+try+again.&showback=N'
// );
// self.open(
// '/ats/logout.jsp?missedlogout=Y', 'Logout',
// 'location=no,menubar=no,titlebar=no,personalbar=no,height=1,width=1');
// }
// }
// else {
// top.document.location.replace(
// '/ats/error.jsp?msg=' +
// 'There+was+an+internal+error.++You+have+been+logged+out.' +
// '++Please+close+all+browsers+and+try+again.&showback=N'
// );
// self.open('/ats/jserror.jsp?msg=' + escape(msg) + '&url=' + escape(url) + '&line=' + ln + '&closeWindow=Y', 'jserror');
// self.open('/ats/logout.jsp?missedlogout=Y', 'Logout', 'location=no,menubar=no,titlebar=no,personalbar=no,height=1,width=1');
// }
}
/**
* Error handler that reports error without redirecting user.
* @param msg
* @param url
* @param ln
*/
function displayError(msg, url, ln) {
_log(msg);
} // do NOT add window.onerror if addGlobalErrorHandler has been set to explicit false
window.onerror = init.addGlobalErrorHandler === false ? null : this.isDevMode ? displayError : handleError; // add lib properties as instance properties
$.each(lib, function (name, val) {
return _this[name] = val;
});
_this.perform_cookie_test();
onLoadCallback.call(this, this); // send in 'lib' instance as arg to onLoad
this.loaded = true;
}
|
console-api |
debug |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 16080)
Message:
Assigning value to moduleName Lib function Lib(init) {
// see if instantiation should return global instance
if (init && init.getGlobalInstance && window.top._lib) {
return window.top._lib;
} // check for and set global instance
if (!window.top._lib) {
window.top._lib = this;
} // It's not good form, but these locals are used to help with staged lookup.
var isActiveDirectory = init.isActiveDirectory; // <%= (companyRecord.get("AUTH_URL") != null) %>;
var companyId = init.companyId; // <% out.println("'" + companyId + "'" + ";"); %>
var sessionId = init.sessionId; // '<%= key %>'
var onLoadCallback = init.onLoad || function () {}; // function to call when Lib instance has been assembled
this.isDevMode = configuration.developmentMode; // flag indicating if all JS components have been loaded...affects behavior of error reporting
this.loaded = false;
var _this = this; // collection of nodes used in setParent() and assureChildrenMatch()
var parents = []; // collection of nodes used in setParent() and assureParentSelected()
var kids = []; // collection used in initPageCollapse() and pageCollapse()
var hiddenDivs = {}; // collection used in getCheckboxElement() and setCheckboxElements()
var checkboxElements = [];
var jqueryUniversalChangeSupportedTags = ":input[type!=hidden]";
var jqueryUniversalChangeSupportedEvents = ["change", "select", "click", "blur"]; // cached result of call to perform_cookie_test()
var cookie_test = false;
/**
* Selector string used to serve as context for calls to addDependentField. If null, will use document
* as context (is used to search for a field ONLY in context of modal content).
*
* @type {string}
*/
var dependentFieldCtx = null;
/**
* Simple function used to log message strings and Error instances to the console, if the console object
* is available (may not be in older browser environments). Will only log if isDevMode is true.
*
* @param {string|Error} message
* @param {boolean} [override] if present and true, will log whether or not in dev mode
*/
var _log = function log(message, override) {
return logger.log(message);
}; // init accessNextPage and loading flags
setGlobalData("Lib.accessNextPage", true);
setGlobalData("Lib.loading", false); // internal helper functions
/**
* Sets a global attribute value. Will log and ignore if unable to do so (i.e. window.top is disposed).
*
* @param key
* @param value
*/
function setGlobalData(key, value) {
_log("Setting '".concat(key, "' attribute to value '").concat(value, "'"));
try {
if (window && window.top) {
$(window.top).data(key, value);
} else {
_log("Can not set '".concat(key, "' attribute with value '").concat(value, "', top window is not available."));
}
} catch (e) {
// getting 'Can't execute code from a freed script' errors in IE...just log and return
_log(new Error("Can not set '".concat(key, "' attribute with value '").concat(value, "': ").concat(e.message)));
}
}
/**
* Gets a global attribute value. Will log and return null if unable to do so (i.e. window.top is disposed).
*
* @param key
* @returns {*}
*/
function getGlobalData(key) {
_log("Getting '".concat(key, "' attribute value."));
try {
if (window && window.top) {
var value = $(window.top).data(key);
_log("Attribute '".concat(key, "' has value '").concat(value, "'"));
return value;
} else {
_log("Can not get '".concat(key, "' attribute value, top window is not available."));
return null;
}
} catch (e) {
// getting 'Can't execute code from a freed script' errors in IE...just log and return null
_log(new Error("Can not get '".concat(key, "' attribute value: ").concat(e.message)));
return null;
}
}
/**
* Ensures that needed jQuery plugins have been loaded. Performs synchronous loading if not found.
* Returns reference to $.
*
* @param {Window} win context window
* @param {jQuery} jq the jQuery object being examined
* @returns {jQuery}
*/
function checkJQuery(win, jq) {
return jq || win.$ || $;
}
/**
* Obtains the Modal instance for the given window namespace.
*
* @param win
* @returns {Modal}
*/
function getModal(win) {
return win.document.thismodal;
}
/**
* Is called to create and open a new Modal instance using a set of default properties. The init object will
* override any defaults. An additional optional boolean may be provided to specify if instance should
* be assigned to the global modal variable (i.e. make new instance retrievable in call to {@link getModal()}.
*
* @param {Window} win the context Window
* @param {Object} init object used to initialize Modal (may contain 'attributes' property that is iterated
* through and each added to Modal attributes)
* @param {boolean} [makeGlobal] optional flag indicating if this instance should be set as global instance (default is false)
*
* @returns {Modal}
*/
function createModal(win, init, makeGlobal) {
// is called to perform style fixes on modal after it is opened
function fixDisplay(modal) {
doModalContentFix(win, modal);
}
function resizeHandler(e) {
_log("Doing resize!!!");
triggerResize(win, false);
}
init = init || {};
init.paddingTop = 80;
init.onOpen = mergeFunctions(init.onOpen, function (modal) {
$(win).on("resize", resizeHandler);
fixDisplay(modal);
});
init.onClose = mergeFunctions(init.onClose, function () {
return $(win).off("resize", resizeHandler);
});
init.openOnCreate = false; // do NOT allow for creation before setting global instance
init.context = win;
var modal = Modal.createModal(init);
if (modal) {
if (makeGlobal) {
win.document.thismodal = modal;
}
modal.open();
}
return modal;
}
/**
* Performs style/behavior fixes on Modal and content.
*
* @param win
* @param modal
*/
function doModalContentFix(win, modal) {
var content = $(modal.getContent(true));
var $content = $(content);
$content.closest(".vex").css("padding-top", "40px");
$content.closest(".vex").find(".vex-dialog-input").css("overflow", "auto"); // also, remove PageParagraphContainer/PageMainContainer ids to remove static CSS widths
$content.find("#PageParagraphContainer").removeAttr("id");
$content.find("#PageMainContainer").removeAttr("id"); // give buttons same LnF as Modal buttons
$content.find("input[type=\"submit\"], input[type=\"reset\"], input[type=\"file\"]").addClass("vex-dialog-button vex-dialog-button-primary ss-modal-ok").css({
"margin-top": "5px",
"float": "none"
}); // Prevent submit button from being clicked multiple times
$content.find("input[type=\"submit\"]").click(function () {
var $footContainer = $content.find("#footContainer");
var $pagebuttons = $footContainer.find(".pagebuttons");
$pagebuttons.hide();
$footContainer.append($("<img src=\"https://cdn.searchsoft.net/images/loading.gif\" class=\"preventMultipleSubmitButtonClickSpinner\" />"));
});
$content.find("input[type=\"button\"]").addClass("vex-dialog-button vex-dialog-button-secondary ss-modal-cancel").css({
"margin-top": "5px",
"float": "none"
});
$(".linkbutton, .wizardlink").click(function () {
return win.setTimeout(function () {
doModalContentFix(win, modal);
triggerResize(win, false);
}, 15);
});
}
/**
* Is called to do an operation with the current Modal instance, if it is non-null and only if its open,
* if the ifOpen flag is true. The callback will be provided the Modal instance and reference to the Modal
* content (as a jQuery object) as args (i.e. function(modal, jq) { // do something } ).
*
* @param win
* @param ifOpen
* @param fn
*/
function doModalOp(win, ifOpen, fn) {
var modal = getModal(win);
if (!modal) {
return;
}
if (!modal.isOpen() && ifOpen) {
return;
}
try {
fn(modal, modal.getContent(true));
} catch (e) {
// this could POTENTIALLY be called on a modal in a frame that has expired...catch, log and continue
_log(e);
}
}
/**
* Is called to trigger events and handle common behavior when content has changed such that re-flow or
* resizing of content should occur.
*
* @param win
* @param {boolean} [doTrigger] optional boolean flag indicating if 'resize' event should be triggered (default is true)
* @param {boolean} [keepWidth] optional boolean flag indicating if resizing should constrain width (default is false)
*/
function triggerResize(win, doTrigger, keepWidth) {
doTrigger = doTrigger !== false;
if (doTrigger) {
$(win).triggerHandler("resize");
}
keepWidth = keepWidth === true;
doModalOp(win, true, function (modal, content) {
var queue = win["_triggerResizeQueue"] || {
/**
* @type {number}
*/
"timeoutId": null
};
win["_triggerResizeQueue"] = queue;
if (queue.timeoutId !== null) {
window.clearTimeout(queue.timeoutId);
}
queue.timeoutId = window.setTimeout(function () {
try {
modal.resizeContent(keepWidth);
} catch (e) {
// as this being called in a timeout, modal may be contained in an expired frame...
_log(e);
}
}, 15);
});
}
function isChecked(win, id) {
var elem = getCheckboxElement(win, id);
return elem.checked;
}
function getCheckboxElement(win, id) {
return checkboxElements[id];
}
function checkCheckBox(win, id, val, doParent) {
var elem = getCheckboxElement(win, id);
if (elem) {
elem.checked = val;
if (doParent) {
lib.assureParentSelected(win, id);
}
}
return true;
}
function emailCheck(emailStr, win, field) {
/* The following pattern is used to check if the entered e-mail address
fits the user@domain format. It also is used to separate the username
from the domain. */
var emailPat = /^\s*(.+)@(.+)$/;
/* The following represents chars _not_ allowed in an local part of an address
These characters include ( ) < > @ , ; : \ " . [ ] Where . is later allowed
back in. */
var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
/* The following string represents the range of characters allowed in a
username or domainname. It really states which chars aren't allowed.*/
var validChars = "[^\\s".concat(specialChars, "]");
/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes). E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */
var quotedUser = "(\"[^\"]*\")";
/* The following string represents an atom (basically a series of non-special characters.) */
var atom = "".concat(validChars, "+");
/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */
var word = "(".concat(atom, "|").concat(quotedUser, ")"); // The following pattern describes the structure of the user
var userPat = new RegExp("^".concat(word, "(\\.").concat(word, ")*$"));
/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. Domain atom must be two or
more chars and not start or end with a '-' */
var domainAtom = "[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9]+)*";
var domainPat = new RegExp("^".concat(domainAtom, "(\\.").concat(domainAtom, ")+\\s*$"));
/* The following pattern applies for domains that are IP addresses,
rather than symbolic nam es. E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */
var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
/* Finally, let's start trying to figure out if the supplied address is valid. */
/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */
var matchArray = emailStr.match(emailPat);
if (matchArray == null) {
/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */
invalidField(win, field, "The email address seems incorrect (check @ and .'s)");
return false;
}
var user = matchArray[1];
var domain = matchArray[2]; // Start by checking that only basic ASCII characters are in the strings (0-127).
for (var i = 0; i < user.length; i++) {
if (user.charCodeAt(i) > 127) {
invalidField(win, field, "The email username contains invalid characters.");
return false;
}
} // See if "user" is valid
if (user.match(userPat) == null) {
// user is not valid
invalidField(win, field, "The email username doesn't seem to be valid.");
return false;
}
/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */
var IPArray = domain.match(ipDomainPat);
if (IPArray != null) {
// this is an IP address
for (var _i = 1; _i <= 4; _i++) {
if (IPArray[_i] > 255) {
invalidField(win, field, "Email destination IP address is invalid!");
return false;
}
} // the remain tests are not valid
return true;
} // Domain is symbolic name. Check if it's valid.
var domArr = domain.match(domainPat);
if (domArr == null) {
invalidField(win, field, "The email domain name does not seem to be valid.");
return false;
} // confirm that tld is two more more, note sub-group is always assigned last match
if (!(domArr[1].length > 2)) {
invalidField(win, field, "The email address has an invalid tld domain. Are you missing .com?");
return false;
} // Confirm domain is not overly long
if (domain.length > 255) {
invalidField(win, field, "The email address has to long a domain name.");
return false;
} // Confirm peices of domain are not indivuial to long
for (var _i2 = 0; _i2 < domArr.length - 1; _i2++) {
if (domArr[_i2].length > 63) {
invalidField(win, field, "The email address domain name is to long.");
return false;
}
} // If we've gotten this far, everything's valid!
return true;
}
function getFieldValue(win, field) {
// Passing win as an argument to fix "Permission denied" error in IE
// SSOFT-5666
var $ = win.$;
var value = "";
var type = field.type || $(field).attr("type");
if (type) {
if (type.indexOf("select-") >= 0) {
if (field.selectedIndex >= 0) {
value = field.options[field.selectedIndex].value;
}
} else if (type.indexOf("check") >= 0 || type.indexOf("radio") >= 0) {
if (field.checked) {
value = field.value;
}
if (field.length) {
for (var j = 0; j < field.length; j++) {
if (field[j].checked) {
value = field[j].value;
}
}
}
} else {
value = field.value;
}
} else if (field.length) {
// I think this code is making an assumption
// that if there is no 'type' then it must be a
// checkbox.
for (var _j = 0; _j < field.length; _j++) {
if (field[_j].checked) {
value = field[_j].value;
}
}
}
if (value == null) {
value = "";
}
return value;
}
/**
* Replaces a old Field's listeners' with a pointer to the new field.
**/
function reassignFieldListeners(oldField, newField) {
// find the form, assume all fields are in the same form
var form;
if (oldField.length) {
form = oldField[0].form;
} else {
form = oldField.form;
} // if we couldn't find the form, give up. This means were using an oldField
// not in a form anymore. This should never happen.
if (!form) {
return;
}
for (var i = 0; i < form.validatorFields.length; i++) {
if (form.validatorFields[i] == oldField) {
form.validatorFields[i] = newField;
}
}
for (var _i3 = 0; _i3 < form.maskValidatorFields.length; _i3++) {
if (form.maskValidatorFields[_i3] == oldField) {
form.maskValidatorFields[_i3] = newField;
}
}
}
/**
* Checks newField against the listeners of oldField.
**/
function validNewField(win, oldField, newField) {
// Hack that fixes https://peopleadmin.atlassian.net/browse/SSOFT-5354?focusedCommentId=231565&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-231565
if (newField[0] === undefined) {
newField[0] = oldField[0];
} // find the form
var form;
if (oldField.length) {
form = oldField[0].form;
} else {
form = oldField.form;
} // if we couldn't find the form, say its valid. This means were validating
// against a field not in a form anymore. This should never happen.
if (!form) {
return true;
} // run over all validation function and run them against the new field
for (var i = 0; i < form.validatorFields.length; i++) {
if (form.validatorFields[i] == oldField) {
if (!form.validatorFunctions[i](win, newField)) {
return false;
}
}
}
for (var _i4 = 0; _i4 < form.maskValidatorFields.length; _i4++) {
if (form.maskValidatorFields[_i4] == oldField) {
if (!form.maskValidatorFunctions[_i4](win, newField, form.maskValidatorMasks[_i4])) {
return false;
}
}
}
return true;
}
/**
* Run all validator functions for a specified form.
**/
function validFields(win, form) {
win.runningValidFields = true;
for (var i = 0; i < form.validatorFunctions.length; i += 1) {
// if the field is not in the checking form anymore ignore it
if (!fieldInForm(form, form.validatorFields[i])) {
continue;
} // run the listeners
if (!form.validatorFunctions[i](win, form.validatorFields[i])) {
win.runningValidFields = false;
return false;
}
}
for (var j = 0; j < form.maskValidatorFunctions.length; j += 1) {
// if the field is not in the checking form anymore ignore it
if (!fieldInForm(form, form.maskValidatorFields[j])) {
continue;
} // run the listeners
if (!form.maskValidatorFunctions[j](win, form.maskValidatorFields[j], form.maskValidatorMasks[j])) {
invalidField(win, form.maskValidatorFields[j], "".concat(form.maskValidatorFields[j].value, " is not in the correct format."));
win.runningValidFields = false;
return false;
}
}
win.runningValidFields = false;
return true;
}
/**
* Test if a field is in a given form (wrapper).
**/
function fieldInForm(form, field) {
// defines a private function to do the real work
function fieldInFormReal(field) {
for (var i = 0; i < form.elements.length; i++) {
if (form.elements[i] == field) {
return true;
}
}
return false;
} // if field is not defined, claim it exists
if (!!!field) {
return true;
} // if array test for each
// if it has a length and not a type
if (field.length && !field.type) {
// when less than 500 check all fields
if (field.length < 500) {
for (var i = 0; i < field.length; i++) {
if (!fieldInFormReal(field[i])) {
return false;
}
}
} // performance hack for IE, if one exists all exist
else {
if (!fieldInFormReal(field[0])) {
return false;
}
}
return true;
} // field is defined check that it is in the form
return fieldInFormReal(field);
}
function getMultiNumberChecked(win, fields) {
var numberChecked = 0; // array of check-box, radio, option, or select
if (fields.length) {
for (var i = 0; i < fields.length; i++) {
// check-box, radio
if (fields[i].checked) {
numberChecked++;
} // option
else {
if (fields[i].selected) {
numberChecked++;
} // select
else {
if (fields[i].options) {
numberChecked += getMultiNumberChecked(win, fields[i].options);
}
}
}
}
} // select object
else if (fields.options && fields.options.length > 0) {
numberChecked = getMultiNumberChecked(win, fields.options);
} // single field
else if (fields.checked || fields.selected) {
numberChecked = 1;
}
return numberChecked;
}
/**
* Returns array of form objects that have an element that matches
* fieldName.
**/
function getFormObjects(win, fieldName) {
var result = [];
var forms = win.document.forms;
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
if (form.elements[fieldName]) {
result.push(form);
}
}
return result;
}
function stripSymbols(field) {
var value = field.value;
if (value !== undefined) {
field.value = value.replace(/(\$|\,|\(|\)|\&)/g, "");
}
}
function getFormattedDate(field, shortDate) {
var date = field.value.replace("-", "/");
var li = date.lastIndexOf("/");
if (date.length - li == 3) {
var cent = "20";
var yr = date.substring(li + 1, li + 3);
if (yr > "30") {
cent = "19";
}
date = date.substring(0, li + 1) + cent + yr;
}
return date;
}
function isValidDate(value, shortDate) {
var month;
var day;
var year;
var date;
var i;
for (i = 1; i < value.length; i++) {
var testValue = value.substring(i, i + 1);
if (isNaN(testValue) && testValue != "/" && testValue != "-" && testValue == " ") {
return false;
}
}
date = value;
if (date != "") {
i = date.indexOf("/");
if (i < 1) {
return false;
}
month = date.substring(0, i);
if (month.length < 1 || month.length > 2 || month.charAt(0) > "9" || month == 0 && i == 1) {
// || month.charAt(0)<'0'
return false;
}
if (month.substring(0, 1) == "0") {
month = month.substring(1, 2);
}
month = parseInt(month);
if (!shortDate) {
date = date.substring(i + 1);
i = date.indexOf("/");
if (i < 1) {
return false;
}
day = date.substring(0, i);
if (day.length < 1 || day.length > 2 || day.charAt(0) > "9") {
// || day.charAt(0)<'0'
return false;
}
if (day.substring(0, 1) == "0") {
day = day.substring(1, 2);
}
day = parseInt(day);
}
year = date.substring(i + 1);
if (year.length != 4 || year.charAt(0) < "0" || year.charAt(0) > "9") {
return false;
}
year = parseInt(year);
if (month < 1 || month > 12 || day < 1 || day > 31 || year < 1900 || year > 2299 || month == 2 && day > 29 || month == 2 && day == 29 && year % 4 != 0 || month == 4 && day > 30 || month == 6 && day > 30 || month == 9 && day > 30 || month == 11 && day > 30) {
return false;
}
}
return true;
}
function isValidBirthDate(field, shortdate, young, old) {
var result = true;
var birthValue = field.value;
if (shortdate) {
birthValue = birthValue.replace(/\//, "/01/");
}
var birthDate = new Date(birthValue);
var lowDate = new Date();
var highDate = new Date();
lowDate.setFullYear(lowDate.getFullYear() - old);
highDate.setFullYear(highDate.getFullYear() - young);
result = birthDate >= lowDate && birthDate <= highDate;
return result;
}
function isValidDateTime(field) {
var thisFieldValue = field.value;
var splitDate = thisFieldValue.split(" ");
if (splitDate.length != 3) {
return false;
}
if (!isValidDate(splitDate[0]), false) {
return false;
}
if (!isValidStandardTime(splitDate)) {
return false;
}
return true;
}
function isValidStandardTime(timeString) {
// We are expecting a 3-part date, time, and am/pm array
if (timeString.length != 3) {
return false;
}
if (timeString[1].length != 5) {
return false;
}
if (timeString[2].length != 2) {
return false;
}
var testValue = timeString[1].substring(0, 2);
if (isNaN(testValue)) {
return false;
}
if (timeString[1].charAt(2) != ":") {
return false;
}
var testValue = timeString[1].substring(3, 5);
if (isNaN(testValue)) {
return false;
}
if (timeString[2].toLowerCase() != "am" && timeString[2].toLowerCase() != "pm") {
return false;
}
return true;
}
function isValidNumber(num) {
var i;
var dc;
if (num.value != "") {
i = 0;
if (num.charAt(0) == "-") {
i = 1;
if (num.length == 1) {
return false;
}
}
dc = 0;
for (; i < num.length; i++) {
if (num.charAt(i) == ".") {
if (dc > 0 || i == num.length - 1) {
return false;
}
dc++;
} else if (num.charAt(i) < "0" || num.charAt(i) > "9") {
return false;
}
}
}
return true;
}
/**
* Adds fun (function) to element with an apporiate on change listener
*
* @param elem is dom
**/
function jqueryUniversalChange(win, elem, fun) {
var $ = win.$;
$(elem).bind(jqueryUniversalTriggerType(win, elem), fun);
}
function jqueryUniversalTriggerType(win, elem) {
// For SSOFT-5625
// In Internet Explorer 11/Edge, the attr call below was causing a "Permission denied" error
var $ = win.$;
var triggerType;
switch (elem.tagName.toUpperCase()) {
case "INPUT":
switch ($(elem).attr("type").toUpperCase()) {
case "RADIO":
case "CHECKBOX":
case "BUTTON":
triggerType = "click change";
break;
case "PASSWORD":
case "TEXT":
triggerType = "blur change";
break;
case "FILE":
triggerType = "change";
break;
default:
triggerType = "change select click blur";
break;
}
break;
case "TEXTAREA":
triggerType = "blur change";
break;
case "SELECT":
triggerType = "blur change";
break;
default:
triggerType = "change select click blur";
break;
}
return triggerType;
}
/**
* Is called to ensure that username conforms to rules and standards.
*
* @param win
* @param username
* @param password
* @returns {boolean}
*/
function checkFormatting(win, username, password) {
var p = password;
var u = username;
var message = "";
var result = true;
var low = 6;
if (companyId != "00008698" && !isActiveDirectory && win.document.location.href.indexOf("employee_form") < 0) {
// Account Information Page (Applicants can change just their username)
if ((p == null || p.value == "") && u != null && u.value != "") {
u = u.value;
if (u.length < low) {
message = "The username is invalid. Usernames must be at least ".concat(low, " characters in length, should not include spaces, and must not be identical to the password.");
invalidField(win, username, message);
result = false;
}
}
}
return result;
}
function makeTestCookie() {
document.cookie = "cookietest=yes;path=/";
}
function findTestCookie() {
if (document.cookie.length > 0 && window.navigator.cookieEnabled) {
var test = document.cookie.indexOf("cookietest=");
if (test !== -1) {
return true;
}
}
return false;
}
/**
* Toolbox, binds pop-up to a select box.
**/
function toolboxRegisterSelection(win, uid) {
var $ = win.$;
var actionSelect = $("#".concat(uid, "_action_select"));
var myForm = actionSelect.closest("form"); // add a content section if one does not exist
if (!myForm.find("#inlineContent").length) {
myForm.append("<div id=\"inlineContent\" style=\"height: 30ex\"></div>");
}
var onDefaultActionOrUndo = function onDefaultActionOrUndo() {
$("#inlineContent").html("").css("height", "30ex"); // Reactivate button-based tools
win.toolbox[uid]._parent.append(win.toolbox[uid]);
}; // HE-3345 (https://jira.powerschool.com/browse/HE-3345?focusedCommentId=2294798&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-2294798)
// Whenever undo button is clicked, removes the fields related to the previous selected value on Workflow Forms
$("form input:reset[name=\"undo\"]").click(function () {
return onDefaultActionOrUndo();
});
actionSelect.change(function () {
// what item is selected
var item = $("#".concat(uid, "_action_select option:selected")).attr("value");
var autoSubmit = false; // bail if default
if (item == "default") {
onDefaultActionOrUndo();
return false;
} else {
// Deactivate button-based tools
win.toolbox = win.toolbox || {};
win.toolbox[uid] = win.toolbox[uid] || $("#toolbox_".concat(uid));
win.toolbox[uid]._parent = win.toolbox[uid]._parent || win.toolbox[uid].parent();
$("#toolbox_".concat(uid)).remove();
} // is there a hidden div
if ($("#".concat(item)).length) {
// get content
var content = $("#".concat(item)).clone();
content.attr("class", content.attr("id"));
content.attr("id", "");
$("#inlineContent").html(" ").append(content);
content.show();
} // if no hidden content auto-submit
else {
autoSubmit = true;
}
toolboxRunFunction(win, item);
if (autoSubmit) {
// if no hidden content
win.document.forms[0].submit();
}
});
}
/**
* Toolbox, bind pop-up to "Go" button.
**/
function toolboxRegisterActionGo(win, uid) {
var $ = win.$; // bind to click of button
$("#".concat(uid, "_go")).click(function () {
var $ = win.$; // what item is selected
var item = $("#".concat(uid, "_action_select option:selected")).attr("value");
var autoSubmit = false; // bail on default action
if (item === "default") {
win.alert("Please select an action to perform.");
return false;
}
var allRecordsInTheListAllPagesSelected = $("select[name=\"ACTION_TYPE\"]").val() === "all";
if (allRecordsInTheListAllPagesSelected) {
// "Assign Document(s)" action
if (item === "RA00000002") {
win.alert("At most 100 recipients can be assigned eForms at a time. Please select no more than 100 recipients and try again.");
return false;
}
} else if ($("div.rs tbody :checkbox:checked").length === 0) {
// when no items selected bail
win.alert("Please select the records on which to perform the action.");
return false;
} // is there a hidden div
if ($("#".concat(item)).length) {
lib.showPopup(win, item);
} // if no hidden content auto-submit
else {
autoSubmit = true; // run action's funciton if exists
if (!toolboxRunFunction(win, item)) {
// no function add a hidden input option=option (as we are autosubmiting)
lib.addHiddenField(win, item, item);
}
}
if (autoSubmit) {
// if no hidden content
win.document.forms[0].submit();
}
});
}
function closePopupFirst(win, fun) {
Modal.closeAll(win, function () {
return fun(win);
});
}
/**
* Toolbox utilty, run function tied to a option. If the function is not
* defined return false.
**/
function toolboxRunFunction(win, fun) {
// confirm we have functions and this function is defined
if (!win.toolboxFunctions || !win.toolboxFunctions[fun]) {
return false;
} // run the function
try {
win.toolboxFunctions[fun]();
triggerResize(win);
} catch (e) {
return false;
}
return true;
}
/**
* Toolbox utility, add and enable a cancel button to popups
**/
function toolboxAddCancel(win, item) {
doModalOp(win, true, function (modal, content) {
modal.enableCancel(true); // need to ensure that all 'Cancel' button just close Modal (and not do history-back behavior)
$(content).find("input[name='cancel']").attr("onclick", "").click(function (e) {
e.preventDefault();
modal.close();
return false;
});
});
}
/**
* Returns true if the provided url and request data are valid for making an Ajax call to server. This is
* needed to overcome issues where library.js adds unintended behavior to elements, such that spurious
* Ajax calls are made.
*
* @param url url of Ajax call
* @param data query string or post data to be sent in request
* @return {boolean} true if the call can be made, false if it is not valid
*/
function canMakeAjaxCall(url, data) {
if (url == "#") {
_log("NOT making Ajax call, no valid URL provided (url is '#').");
return false;
} // put additional checks here as needed
return true;
}
/**
* Toolbox utility, fill-in a popup with data.
*
* @param win window object do operate in
* @param id of div to opeerate on in pop-up
* @param url of page to fetch and display
* @param hijack if to capture submit and then close pop-up
* @param hijackStayOpen if when capturing submit to dispaly the result
**/
function ajaxFillinPopup(win, id, url, sdata, hijack, hijackStayOpen, devmode) {
if (!canMakeAjaxCall(url, sdata)) {
return;
}
var $ = win.$; // add ajax notification for server
if (sdata == null) {
sdata = "ajax=y";
} else if (sdata.indexOf("ajax=") == -1) {
sdata += "&ajax=y";
} // avoid get length limit in IE
var method = "get";
if (sdata.length + url.length > 2000) {
sdata += "&fake_post=Y";
method = "post";
} // handle error
$(win.document).ajaxError(function (event, request, settings) {
return _log("Server error: ".concat(request.status, " url: ").concat(settings.url));
}); // if a popup
var modal = getModal(win);
if (modal && modal.isOpen()) {
dependentFieldCtx = ".searchsoft-modal"; // get content
$[method](url, sdata, function (data, rstatus) {
if (rstatus == "success") {
var modalContent = $(modal.getContent(true));
var selector = "div#inlineContent";
var content = $(modalContent).find("div#inlineContent");
if (!content.length) {
content = $(modalContent).find("div#".concat(id));
selector = content.length ? "div#".concat(id) : null;
}
modal.setContent(data, selector);
content = $(modal.getContent(true)); // will return a reference to content
afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode);
} else {
throw "AJAX error getting content";
}
}, "text").always(function () {
// reset after each call
dependentFieldCtx = null;
});
} // inline
else {
// get content
$.get(url, sdata, function (data, rstatus) {
if (rstatus == "success") {
var content = $("#inlineContent div.".concat(id)).html(data);
$("#inlineContent").css("height", "auto");
afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode); // initilize forms
lib.initForms(win);
} else {
throw "AJAX error getting content";
}
}, "text");
}
}
function afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode) {
var $ = win.$; // initilize forms
lib.initForms(win); // add what applicants to effect
lib.addCheckboxApplicants(win, id); // add/enable cancel
toolboxAddCancel(win, id); // add redirect if one does not exist
addMissingPopupRedirect(win, id); // for is_changed
alwaysIsChanged(win, id); // move buttons to top of devmenu items
if (devmode) {// TODO: #modal
/*
$("#simplemodal-container div#" + id + " div.pagebuttons").css({
'position': 'absolute',
'left': '50px',
'top': '-20px'});
*/
}
if (_this.isDevMode) {
// cause menu links to open in same window
content.find(".devmenulink, .wizardpopup").addClass("wizardlink").removeClass("wizardpopup");
content.find("div.rs a[href!='#ConfirmDelete'], div.rsrange a[href!='#ConfirmDelete']").addClass("wizardlink");
devmode = true;
} // hijack submit
if (hijack) {
// allows for fancy wizard stuff
hijackPopupSubmit(win, id, sdata, hijack, hijackStayOpen, devmode);
} else {
// simply provide a spinner
popUpFormSpinner(win);
}
var modal = getModal(win);
if (modal) {
doModalContentFix(win, modal);
} // wizard links
content.find(".wizardlink").click(function (e) {
var target = $(this).attr("href"); // do check for valid call BEFORE calling preventDefault and hiding form content
if (!canMakeAjaxCall(target, null)) {
return;
}
e.preventDefault();
if (modal) {
var _content = modal.getContent(true);
$(_content).find("form").hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
ajaxFillinPopup(win, id, target, null, hijack, hijackStayOpen, devmode);
return false;
});
if (hijackStayOpen) {
var button = content.find(".linkbutton");
button.each(function () {
this.onclick = function () {
return true;
};
$(this).click(function (e) {
var target = $(this).attr("href"); // do check for valid call BEFORE calling preventDefault and hiding form content
if (!canMakeAjaxCall(target, sdata)) {
return;
}
e.preventDefault();
if (modal) {
var _content2 = modal.getContent(true);
$(_content2).find("form").hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
ajaxFillinPopup(win, id, target, sdata, hijack, hijackStayOpen, devmode);
return false;
});
});
} // normal form styles
if (modal) {
lib.addStyleClasses(win, modal.getContent(true));
}
lib.addStyleClasses(win, "#inlineContent .".concat(id));
triggerResize(win);
}
/**
* Toolbox utility; adds a redirect parameter to a form if one does not exist on the page.
**/
function addMissingPopupRedirect(win, id) {
var $ = win.$;
if (!$("input[name='searchpage']").length) {
var loc = win.location;
doModalOp(win, true, function (modal, content) {
return $(content).find("form").append("<input type=\"hidden\" name=\"searchpage\" value=\"".concat(loc.pathname).concat(loc.search, "\" />"));
});
}
}
/**
* All pop-ups always submit
**/
function alwaysIsChanged(win, id) {
var $ = win.$;
doModalOp(win, true, function (modal, content) {
return $(content).find("input[name='is_changed']").val("true");
});
}
function popUpFormSpinner(win) {
var $ = win.$; // stops double submits for slow pages
doModalOp(win, false, function (modal, content) {
return $(content).closest("form").submit(function (e) {
// test that form is valid
var form = $(this);
var formObj = form.get(0);
var checkScript = formObj.onsubmit;
var result = !checkScript || checkScript.apply(formObj);
if (!(result === false)) {
if (form.attr("target") && form.attr("action").lastIndexOf("/servlet/jasper", 0) === 0) {
// there is a "target" outside of our frame; show a message with a "back to form" link
form.hide().after("<div id='reportmessage'><p>Your report will be downloaded shortly." + " This could take up to several minutes." + " Feel free to close this window.</p>" + "<p>If your report does not download shortly, please go back and try again.</p>" + "<p><a href='#' id='submitshowformagain'> Go Back to Form </a></p></div>");
$("#submitshowformagain").click(function (e) {
e.preventDefault();
form.next("#reportmessage").remove();
form.show();
return false;
});
} else {
form.hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
} else {
e.preventDefault();
}
return result;
});
});
}
/**
* Toolbox utility; hijacks submit of a pop-up and sends with AJAX.
*
* Useful for:
* recursive submitting pop-ups (aka Wizard)
* pages that return JavaScript (aka JSON)
*
* @param win window object to operate in
* @param id of div that gets ajax
**/
function hijackPopupSubmit(win, id, sdata, hijack, stayOpen, devmode) {
var $ = win.$;
doModalOp(win, false, function (modal, content) {
return $(content).find("form:not([target])").submit(function (event) {
// stop default
event.preventDefault(); // test that form is valid
var checkScript = $(this).prop("onsubmit");
if (checkScript && !checkScript.apply(this)) {
return;
} // useful nodes
// what data and to where
var data = $(this).serialize();
data += "&ajax=y";
var actionUri = $(this).attr("action"); // is this a searching form (method=GET)
var method = $(this).attr("method");
if (method == null || method.toUpperCase() == "GET") {
method = "get";
} else {
method = "post";
} // show loading text
var div = $("<div><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>").attr("id", id);
modal.setContent(div); // AJAX submit
$[method](actionUri, data, function (rdata, rstatus) {
if (rstatus == "success") {
if (stayOpen) {
var _content3 = div.html(rdata);
afterAjaxPopProcess(win, id, _content3, sdata, hijack, stayOpen, devmode);
} else {
if (/error has occured/.test(rdata) && devmode) {
div.html("<h1> Failure </h1>");
div.append("<p>CAUTION: Developer <a id='hijackretry' href='#'>Retry</a>. Will not provide success or failure message! Check your console</p>");
div.append("<xmp> ".concat(rdata, "</xmp>"));
$("#hijackretry").click(function () {
return $.post(actionUri, data);
});
} else if (/ajaxerror/.test(rdata)) {
div.html(rdata);
} else {
div.html("<h1> Success </h1>");
modal.close();
}
}
} else {
throw new Error("AJAX error");
}
}); // stop form submit
return false;
});
});
}
/**
* Utility for missed field pop-up.
* May be removed when classic is gone.
**/
function invalidField(win, field, message) {
// Fixes HE-3875
var $vexDialogInput = $(field).closest(".vex-dialog-input");
$vexDialogInput.find(".pagebuttons").show();
$vexDialogInput.find(".preventMultipleSubmitButtonClickSpinner").remove();
if (win.fieldPrompt) {
win.fieldPrompt(field, message);
} else {
win.alert(message);
}
}
/**
* Utility function to normalized an array.
* Returns the normalized array
**/
function trimArray(arrayToTrim) {
var result = [];
var zeroCount = 0;
for (var i = 0; i < arrayToTrim.length; i++) {
result[zeroCount++] = arrayToTrim[i];
}
return result;
}
function getNextUrlFromNavigationPulldown(win, backward) {
var pulldownFrame = win.parent.frames[0];
var pdf$ = pulldownFrame.$;
var dir = backward ? "prev" : "next";
var option = pdf$("select[name=navchoice] option:selected")[dir]();
if (option.length == 0) {
return;
}
var nextValue = option.val(); // FORMAT: sss_sub_content,/ats/application/detail/language,op=edit&APPLICANT_ID=VA00000059
var nextUrl = nextValue.substring(nextValue.indexOf(",") + 1, nextValue.lastIndexOf(","));
var qs = nextValue.substring(nextValue.lastIndexOf(",") + 1);
nextUrl += "?".concat(qs);
var location = win.location;
return nextUrl;
}
/**
* Returns a truncated toString of given function.
* @param fn
* @return {string}
*/
function displayFn(fn) {
if (!fn) {
return "null function";
}
return "".concat(fn.toString().replace(/[\s]+/gim, " ").substr(0, 50), "...");
}
/**
* Performs a synchronous retrieval of the JS source file provided. Returns the script as a string.
*/
function loadJsSource(src) {
var ajaxObj = $.ajax({
"url": src,
"dataType": "text",
"async": false
});
return ajaxObj.responseText;
} // member functions
var lib = {
// This is an array of page listeners. A page listener is defined in another
// page and has methods that can be called by functions in this library file.
// When some event happens, library will call a method belonging to the page
// listeners.
"pageListeners": [],
/**
* Simple function used to log message strings and Error instances to the console, if the console object
* is available (may not be in older browser environments). Will only log if isDevMode is true.
*
* @param {string|Error} message
* @param {boolean} [override] if present and true, will log whether or not in dev mode
*
* @deprecated Should call Utils.log() directly.
*/
"log": function log(msg, override) {
_log("Call to deprecated Lib.log() function (should call Utils.log() directly)", true);
_log(msg, override);
},
/**
* Gets value for the cookie with the given name. Returns null if none found.
*
* @param name
* @returns {*}
*/
"getCookie": function getCookie(name) {
var vals = document.cookie.split(/\s*;\s*/);
var val = null;
$.each(vals, function (i, cookie) {
var nv = cookie.split("=");
if (nv[0] == name) {
val = nv[1];
return false;
}
});
return val;
},
/**
* Gets value for given param; returns null if not present.
*
* @param param
* @returns {String}
*/
"getParam": function getParam(param) {
var qry = location.href;
var index = qry.indexOf("?");
if (index < 0) {
return null;
}
qry = qry.substr(index + 1);
var nvps = qry.split("&");
var val = null;
$.each(nvps, function (i, v) {
var nv = v.split("=");
if (nv.length != 2) {
return;
}
var n = nv[0];
if (param == n) {
val = nv[1];
return false;
}
});
return val;
},
/**
* Provides access to the Modal object (used to create and manipulate dialogs, spinners, etc.).
*
* @returns {Modal}
*/
"getModal": function getModal() {
return Modal;
},
/**
* Is called to do an Ajax load of body, putting up spinner graphic while waiting for load.
*
* @param win the context Window
* @param url the URL to fetch content from
*/
"doSlowPageLoad": function doSlowPageLoad(win, url) {
// helper function used to do loggin for onReady functions
function doFnLog(w) {
var fns = w["onReadyFunctions"];
var len = fns ? fns.length : 0;
_log("In doSlowPageLoad(".concat(url, "), win.onReadyFunctions.length=").concat(len));
}
var $ = win.$;
win.spinnerOn = true;
$(win.document).ready(function () {
doFnLog(win);
$("#slowpageloading").fadeIn(400);
_log("Doing doSlowPageLoad(".concat(url, ")"));
window.setTimeout(function () {
doFnLog(win);
$("body").load(url, function () {
win.spinnerOn = false;
var onReadyFunctions = win.onReadyFunctions || [];
doFnLog(win);
for (var i = 0; i < onReadyFunctions.length; i++) {
try {
var fn = onReadyFunctions[i];
var str = displayFn(fn);
_log("Running onReadyFunction:\n".concat(str));
fn(win);
} catch (e) {
_log(e);
}
}
});
}, 1000); // do timeout for load() call to allow spinner to display for a moment
});
},
/**
* Is called to create and render a new HierCheckboxModel instance.
*
* @param win the ccntext Window
* @param scriptId the id of the SCRIPT tag containing call to this method
* @param json the JSON node data payload
*/
"renderHierCheckboxModel": function renderHierCheckboxModel(win, scriptId, json) {
var model = new HierCheckboxModel(win, scriptId, json);
model.render();
},
"openNode": function openNode(win, id) {
return (// Do nothing. We don't need to open the children when you click a parent
true
);
},
"toggleNode": function toggleNode(win, id, hasImg) {
hasImg = hasImg == undefined || hasImg === true; // hasImg is true if not provided or if explicitly true
var img;
if (hasImg) {
img = win.document.getElementById("".concat(id, "_img"));
}
var elem = win.document.getElementById(id);
if (elem.style.display == "none") {
elem.style.display = "";
if (hasImg) {
img.src = "/ats/images/minus.gif";
}
} else {
elem.style.display = "none";
if (hasImg) {
img.src = "/ats/images/plus.gif";
}
}
},
"assureChildrenMatch": function assureChildrenMatch(win, id) {
var children = parents[id];
if (children) {
var checked = isChecked(win, id);
var length = children.length;
for (var i = 0; i < length; i++) {
var child = children[i];
checkCheckBox(win, child, checked, false);
lib.assureChildrenMatch(win, child);
}
}
return true;
},
"assureParentSelected": function assureParentSelected(win, id) {
var parent = kids[id];
if (parent) {
checkCheckBox(win, parent, true, true);
}
return true;
},
"setCheckboxElements": function setCheckboxElements(win) {
checkboxElements = [];
for (var i = 0; i < win.document.forms[0].elements.length; i++) {
var elem = win.document.forms[0].elements[i];
if (elem && elem.type == "checkbox") {
var value = elem.value;
checkboxElements[value] = elem;
}
}
},
"rmimg": function rmimg(win, companyId) {
if (!win.document.getElementById(companyId)) {
win.document.getElementById("".concat(companyId, "_img")).style.display = "none";
}
},
"setParent": function setParent(win, id, parentId) {
kids[id] = parentId;
var list = parents[parentId];
if (!list) {
list = [];
}
list = list.concat(id);
parents[parentId] = list;
},
"initPageCollapse": function initPageCollapse(doc) {
for (var guiPageId in hiddenDivs) {
lib.pageCollapse(doc, guiPageId);
}
},
"pageCollapse": function pageCollapse(doc, guiPageId) {
var button = doc.getElementById("".concat(guiPageId, "-collapse-button"));
var div = doc.getElementById(guiPageId);
if (!!div && !!button) {
var visible = div.style.display;
if (visible == "none") {
div.style.display = "";
delete hiddenDivs[guiPageId];
button.src = "/ats/images/minus.gif";
} else {
div.style.display = "none";
if (!hiddenDivs[guiPageId]) {
hiddenDivs[guiPageId] = true;
}
button.src = "/ats/images/plus.gif";
}
}
},
"pageCollapseAtsSearchMultiPage": function pageCollapseAtsSearchMultiPage(win, guiPageId) {
var $ = win.$;
var hiddenClass = "subPageContentHidden";
var clickedDivSelector = "#".concat(guiPageId, "-nonWrapper");
$(".subPageContent").not(clickedDivSelector).addClass(hiddenClass);
$(clickedDivSelector).toggleClass(hiddenClass);
setTimeout(function () {
// https://stackoverflow.com/questions/2905867/how-to-scroll-to-specific-item-using-jquery/14490167#14490167
// $(win).scrollTop($("#" + guiPageId + "-wrapper").offset().top);
$("html, body").animate({
"scrollTop": $("#".concat(guiPageId, "-wrapper")).offset().top
}, 350);
}, 350 + 1);
},
"checkSessionId": function checkSessionId(value) {
if (sessionId == null || value == null || sessionId == "" || value == "" || sessionId == "null" || value == "null") {
return true;
} else if (value == sessionId) {
return true;
} else {
// do check for session cookie first
var temp = _this.getCookie("SSS_SESSION_ID");
if (value == temp) {
// update session id first
sessionId = temp;
return true;
}
return false;
}
},
"helpLink": function helpLink(win, message) {
win.alert(message);
return false;
},
"removeFileUpload": function removeFileUpload(win, field) {
var $ = win.$;
var fieldId = "#".concat(field);
var removeLinkId = "".concat(fieldId, "_remove");
var viewLinkId = "".concat(fieldId, "_view");
var hiddenFieldId = "".concat(fieldId, "_hidden_remove");
$(removeLinkId).click(function () {
$(this).css("display", "none");
$(viewLinkId).css("display", "none");
$(hiddenFieldId).val($(fieldId).attr("value"));
$(fieldId).prop("value", " ");
$(this).closest("td").find("input[type=button]").val("Upload a File");
});
},
"checkEmail": function checkEmail(win, field) {
var validEmail = true;
var emailValue = field.value;
var emailLength = emailValue.length;
if (emailLength > 0) {
validEmail = emailCheck(emailValue, win, field);
}
return validEmail;
},
/**
* Is called to fetch company_id of the location/school selected on Request to Hire form.
*
* @param win the context Window
*/
"selectLocation": function selectLocation(win) {
var $ = win.$; // SSOFT-5225 : Set COMPANY_ID as the initially selected location/school
var $selectNameCompanyId = $("select[name='COMPANY_ID']");
var updateCookie = function updateCookie() {
return document.cookie = "COMPANY_ID=".concat($selectNameCompanyId.val(), "; path=/");
};
updateCookie();
$selectNameCompanyId.change(function () {
$("select[name='action']").val("default");
updateCookie();
$("#inlineContent").html(" ");
});
},
/**
* Is called to compare EMAIL and CONFIRM_EMAIL
*
* @param win the context Window
*/
"checkConfirmEmail": function checkConfirmEmail(win, field) {
var $ = win.$;
var email = $("#EMAIL").val().trim().toLowerCase();
var confirmEmail;
confirmEmail = field.value.trim().toLowerCase();
if (email != confirmEmail) {
invalidField(win, field, "Confirm Email should match Email.");
return false;
} else if (email == confirmEmail) {
return true;
}
},
"checkRequiredRadio": function checkRequiredRadio(win, field) {
var radioSelected = false;
var $ = win.$;
var row = $("#".concat($(field).attr("name"), "_ROW"));
if (row.css("display") == "none") {
return true;
}
if (field.length) {
for (var i = 0; i < field.length; i++) {
if (field[i].checked) {
radioSelected = true;
}
}
} else if (field.checked) {
radioSelected = true;
}
if (radioSelected) {
return true;
} else {
invalidField(win, field, "You have not filled out all required answers on this page.");
return false;
}
},
/**
* Create arrays for form validation listeners.
**/
"initForms": function initForms(win) {
function doInitForm(form) {
if (!form.initialized) {
form.validatorFunctions = new Array(0);
form.validatorFields = new Array(0);
form.maskValidatorFields = new Array(0);
form.maskValidatorFunctions = new Array(0);
form.maskValidatorMasks = new Array(0);
form.initialized = true;
}
}
var forms = win.document.forms;
if (forms) {
for (var i = 0; i < forms.length; i += 1) {
var form = forms[i];
doInitForm(form);
}
} else {
$("form").whenExists(function () {
doInitForm(this);
});
}
},
/**
* run: function to check that a given field is filled out.
* It checks if {name}_ROW is a table row.
*/
"checkRequired": function checkRequired(win, field) {
var $ = win.$;
var $field = $(field);
var name = $field.attr("name"); // TODO - come back and fix to work MA000623 & 00013612
// var parentRow = $("#" + name).closest('tr');
// if (getFieldValue(field) == '' && (row.is(":visible") || parentRow.is(":visible"))){
var $row = $("#".concat(name, "_ROW")); // https://jira.powerschool.com/browse/HE-3687
// $row.length will be 0 if this field is wrapped in a grouping sss.gui.MultiFieldField (see gui_field_field table)
// This is the case for the phone number and extension fields in gui_page 00001017 (the applicant add reference page)
// The :visible check fails because the row has a different name (e.g. PHONE_GROUP_ROW instead of PHONE_ROW)
// Falling back to the closest parent <tr> element should fix this problem
var $rowOrClosestTr = $row.length > 0 ? $row : // Could probably always use this value, but minimizing changes to prevent breaking things
$field.parents("tr").eq(0);
if ($rowOrClosestTr.is(":visible") && getFieldValue(win, field) == "") {
var nameOrId = name ? name : $field.attr("id");
logger.log("## checkRequired - INVALID (".concat(nameOrId, ")"));
logger.log(field);
var $customMessageField = $("input[name=\"customValidationMessage\"]");
var customValidationMessage = $customMessageField.length > 0 && $customMessageField.val() != "" ? $customMessageField.val() : "You have not filled out all required fields on this page.";
invalidField(win, field, customValidationMessage);
return false;
} else {
return true;
}
},
/**
* Wrapper for validFields that checks if the form can be validated from
* the table name.
**/
"validForm": function validForm(win, form, tableName) {
if (!lib.checkAccess()) {
return false;
} // flip validation switch since we are checking fields... it's stupid
win.runningValidFields = true;
if (tableName != "applicant.view" && tableName != "dbuser.pwd_no_libraryjsp" && (tableName.match("dbuser") || tableName.match("applicant") && !tableName.match("applicant_type")) && !checkFormatting(win, form.elements["NAME"], form.elements["PWD"])) {
win.runningValidFields = false;
return false;
}
win.runningValidFields = false;
return validFields(win, form);
},
/**
* Utility to strip down the query string size by removing blank inputs for very
* large search forms. IE has a 2048 character limit on query string size and
* even with an empty form putting every input in the query string can explode that
* on the Applicant search page.
*
* We use jQuery's $.serialize to create the query string.
**/
"compressFormQuery": function compressFormQuery(win, form, tableName) {
if (!lib.checkAccess()) {
return false;
}
var $ = win.$;
var qs = $(form).find(":input").filter(function () {
return $(this).val() != "";
}).serialize();
var requestUrl = "".concat($(form).attr("action"), "?").concat(qs);
win.location.href = requestUrl;
return false;
},
/**
* Adds a func to validation listeners on fieldName.
**/
"appendMulti": function appendMulti(win, fieldName, func) {
lib.initForms(win);
var forms = getFormObjects(win, fieldName);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var newFunctions = new Array(func);
var newFields = form.elements[fieldName];
form.validatorFunctions = form.validatorFunctions.concat(newFunctions);
form.validatorFields = form.validatorFields.concat(newFields);
}
},
"multiCheck": function multiCheck(win, fields) {
var numberChecked = getMultiNumberChecked(win, fields);
var $ = win.$;
var id = "".concat($(fields).attr("name"), "_ROW"); // HE-3875
// Hack to look for newest/last element with ID (closing modal doesn't delete the elements from the DOM, and clicking "Go!" again creates a new modal)
var $row = $("[id='".concat(id, "']")).last();
if ($row.is(":visible") && numberChecked < 1) {
invalidField(win, fields, "You have not filled out all required answers on this page.");
return false;
} else {
return true;
}
},
"reqAllMultiCheck": function reqAllMultiCheck(win, fields) {
var numberChecked = getMultiNumberChecked(win, fields);
var numberOfCheckboxes = Array.from(fields).filter(function (x) {
return x.type === "checkbox";
}).length;
var $ = win.$;
var id = "".concat($(fields).attr("name"), "_ROW"); // HE-3875 was fixed by the change in multiCheck (above), but presumably the fix should be applied here too
// Hack to look for newest/last element with ID (closing modal doesn't delete the elements from the DOM, and clicking "Go!" again creates a new modal)
var $row = $("[id='".concat(id, "']")).last();
if ($row.is(":visible") && numberChecked < numberOfCheckboxes) {
invalidField(win, fields, "You have not filled out all required answers on this page.");
return false;
} else {
return true;
}
},
/**
* Add a check mask function to a field.
**/
"appendMask": function appendMask(win, f, func) {
lib.initForms(win);
var fname = f;
var x;
if (f.indexOf(":::") != -1) {
fname = f.substring(0, f.indexOf(":::"));
f = f.substring(f.indexOf(":::") + 3);
if (f.indexOf(":::") != -1) {
x = f.substring(0, f.indexOf(":::"));
}
}
var forms = getFormObjects(win, fname);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var field = form.elements[fname];
var newFunctions = new Array(func);
var newFields = new Array(field);
var expr = new Array(x);
form.maskValidatorFunctions = form.maskValidatorFunctions.concat(newFunctions);
form.maskValidatorFields = form.maskValidatorFields.concat(newFields);
form.maskValidatorMasks = form.maskValidatorMasks.concat(expr);
}
},
/**
* Adds a fieldName and function to listerners. Functions run when checking for
* form completion.
**/
"append": function append(win, fieldName, func) {
lib.initForms(win);
var forms = getFormObjects(win, fieldName);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var field = form.elements[fieldName];
var newFunctions = new Array(func);
var newFields = new Array(field);
form.validatorFunctions = form.validatorFunctions.concat(newFunctions);
form.validatorFields = form.validatorFields.concat(newFields);
}
},
"checkSize": function checkSize(field, fsize) {
if (fsize > 0 && field.value.length > fsize) {
field.value = field.value.substring(0, fsize);
alert("You have reached the maximum size for this field");
}
},
"checkSearchNumber": function checkSearchNumber(win, field) {
stripSymbols(field);
var value = field.value; // when we don't have a value evrything is fine
if (value === undefined) {
return true;
} // check to see if the first character is a > or <
if (value.indexOf(">") > 0 || value.indexOf("<") > 0) {
invalidField(win, field, "An invalid number was entered in this field. If you are using > or <, please make sure it is the first symbol in the field.");
return false;
} else {
var num = value;
if (num.indexOf(">") == 0 || num.indexOf("<") == 0) {
num = value.substr(1);
}
if (!isValidNumber(num)) {
invalidField(win, field, "An invalid number was entered in this field.");
return false;
}
}
return true;
},
"checkNumber": function checkNumber(win, field) {
stripSymbols(field);
if (!isValidNumber(field.value)) {
invalidField(win, field, "An invalid number was entered in this field. This field cannot contain any symbols ($, %, #, etc).");
return false;
} else {
return true;
}
},
"checkZeroInterval": function checkZeroInterval(win, field) {
stripSymbols(field);
var value = field.value;
if (value === 0) {
invalidField(win, field, "Interval cannot be zero");
return false;
} else {
return true;
}
},
"confirmDelete": function confirmDelete(page, href) {
if (confirm("Are you sure you want to delete this record?")) {
if (href.indexOf("redirect=") < 0) {
href = "".concat(href, "&redirect=").concat(escape(page.location.href));
} else {
var i = href.indexOf("&redirect=");
var j = href.indexOf("%");
if (i >= 0 && j < 0) {
var sl = "&redirect=".length;
href = href.substring(0, i + sl) + escape(href.substring(i + sl));
}
}
page.location.href = href;
}
},
"handleImpersonation": function handleImpersonation(window, href, impersonationMode) {
var userId = href.split("?")[1].substr("USER_ID=".length);
$.get("/servlet/support/login/impersonation", {
"companyId": companyId,
"userId": userId,
"impersonationMode": impersonationMode
}, function (data) {
if (data.success) {
if (data.accountType == "EMPLOYER") {
top.document.location.replace("/ats/employer/v51_employer_frame");
}
} else {
window.alert(data.errorMessage);
}
}, "json");
return false;
},
"checkTime": function checkTime(win, field) {
var isValidTime = true;
var thisFieldValue = field.value;
if (thisFieldValue.length == 0) {
return true;
}
if (thisFieldValue.length != 5) {
isValidTime = false;
} else {
var middle = thisFieldValue.substring(2, 3);
if (middle != ":") {
isValidTime = false;
} else {
var hour = thisFieldValue.substring(0, 2);
var minute = thisFieldValue.substring(3, 5);
if (hour.charAt(0) > 2 || hour.charAt(1) > 9 || minute.charAt(0) > 5 || minute.charAt(1) > 9 || hour.charAt(0) == 2 && hour.charAt(1) > 3) {
isValidTime = false;
} else {
var hourInt = parseInt(hour);
var minuteInt = parseInt(minute);
var hour1 = parseInt(hour.substring(0, 1));
var hour2 = parseInt(hour.substring(1, 2));
var minute1 = parseInt(minute.substring(0, 1));
var minute2 = parseInt(minute.substring(1, 2));
if (hourInt > 23 || hourInt < 0 || minuteInt > 59 || minuteInt < 0 || isNaN(hourInt) || isNaN(minuteInt) || isNaN(hour1) || isNaN(hour2) || isNaN(minute1) || isNaN(minute2)) {
isValidTime = false;
}
}
}
}
if (!isValidTime) {
invalidField(win, field, "An invalid time was entered. Use Military Time Format: 00:00 to 23:59");
}
return isValidTime;
},
"checkDate": function checkDate(win, field) {
var thisFieldValue = getFormattedDate(field);
if (!isValidDate(thisFieldValue, false)) {
invalidField(win, field, "An invalid date was entered. Use Month Date Year Format MM/DD/YYYY.");
return false;
} else {
field.value = thisFieldValue;
return true;
}
},
"checkBirthDate": function checkBirthDate(win, field) {
if (!isValidBirthDate(field, false, 10, 110)) {
invalidField(win, field, "An invalid birth date was entered.");
return false;
}
return true;
},
"checkShortDate": function checkShortDate(win, field) {
var thisFieldValue = getFormattedDate(field);
if (!isValidDate(thisFieldValue, true)) {
invalidField(win, field, "An invalid date was entered. Use Month Date Year Format MM/YYYY.");
return false;
} else {
field.value = thisFieldValue;
return true;
}
},
/**
* It is expected that the input text field has a sibling hidden input field.
* @param field A jquery wrapped text field.
*/
"storeShortDateToFullDate": function storeShortDateToFullDate(win, field) {
/**
* Converts MM/yyyy to MM/dd/yyyy
* @param date date string
* @returns {string} full date
*/
function createFullDate(date) {
var separatorIndex = date.lastIndexOf("/");
var month = date.substring(0, separatorIndex);
var year = date.substring(separatorIndex);
return "".concat(month, "/01").concat(year);
}
var value = field.val();
var id = $(field).attr("id");
var row = $("#".concat(id, "_ROW")); // when the value is not valid the hidden field is set to empty to ensure
// the validator to catch the error on the field
if (!isValidDate(value, true) || value == "" && row.css("display") != "none") {
field.next().val("");
return false;
}
var fullDate = createFullDate(value);
field.next().val(fullDate);
return true;
},
"checkDateTime": function checkDateTime(win, field) {
if (!isValidDateTime(field)) {
invalidField(win, field, "An invalid date was entered. Use Format MM/DD/YYYY HH:MM am/pm.");
} else {
return true;
}
},
"toggleSelectAllCheckboxes": function toggleSelectAllCheckboxes(checkbox, win) {
var isChecked = !!$(checkbox).attr("checked");
if (isChecked) {
lib.selectAllCheckboxes(win, false);
} else {
lib.deselectAllCheckboxes(win, false);
}
},
"selectAllCheckboxes": function selectAllCheckboxes(win, lockAccess) {
if (lockAccess) {
lib.setAccess(win, false);
}
var i = 0;
for (i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].type == "checkbox") {
win.document.forms[0].elements[i].checked = true;
}
}
},
/**
* Submit an eform document through AJAX. This also handles saving as draft.
* It displays a message in modal dialogue in the process of submitting the document.
* The function also handles responses from the server in a modal dialogue.
* This is designed to be called on form onsubmit.
* @param {window} win The window object passed where the function is called. This
* is used as the context for jquery.
* @param {jquery object} form The jquery object of the form document this function is going to submit.
* @param {string} divId The id of the div that will be used for the modal dialogue.
* @return {boolean} This should return false to disable the default form submit.
*/
"documentSubmit": function documentSubmit(win, form, tableName, divId) {
setTimeout(function () {
var $ = win.$;
lib.setAccessNextPage(true);
var saveAsDraft = !!$("input[name='save_as_draft']").length;
var ignoreRequiredFields = $("input[name='IGNORE_REQUIRED_FIELDS']").val() === "Y";
var formIsValid = ignoreRequiredFields;
if (!saveAsDraft && !ignoreRequiredFields) {
formIsValid = lib.validForm.call(form[0], win, form[0], tableName);
}
if (saveAsDraft || formIsValid) {
var doneSubmit = false;
createModal(win, {
"content": "#".concat(divId),
// TODO: clone this?
"attributes": {
"useCloseX": true
},
"onOpen": function onOpen(modal) {
var content = modal.getContent(true);
$(content).css("height", "auto");
$(content).css("width", "auto");
modal.enableOk({
"enable": false
});
modal.setContent("<h3>Submitting...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
var formdata = "".concat(form.serialize(), "&ajax=Y");
if (saveAsDraft) {
formdata += "&save_as_draft=Save+as+Draft";
}
$.post(form.attr("action"), formdata, function (data) {
doneSubmit = true;
modal.setContent(data);
if (saveAsDraft) {
setTimeout(function () {
return modal.close();
}, 500);
}
});
},
"onClose": function onClose(modal) {
if (doneSubmit) {
modal.enableOk({
"enable": true
});
}
}
});
}
}, 500);
return false;
},
"unfollow": function unfollow(win, aTag) {
var $ = win.$;
var link = $(aTag);
$.post(link.attr("href"), function (data) {
if (data == "Success!") {
var evenRows = link.closest("tr").nextAll("tr.even");
link.closest("tr").nextAll("tr.odd").removeClass("odd").addClass("even");
evenRows.removeClass("even").addClass("odd");
link.closest("tr").remove();
} else {
win.alert(data);
}
});
return false;
},
"deselectAllCheckboxes": function deselectAllCheckboxes(win, lock) {
if (lock) {
lib.setAccess(win, false);
}
var i = 0;
for (i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].type == "checkbox") {
win.document.forms[0].elements[i].checked = false;
}
}
},
"daysSince": function daysSince(win, field) {
var fieldName;
var daysSince = field.value;
var time = new Date(new Date().getTime());
var d = new Date(time - daysSince * 24 * 60 * 60 * 1000);
var s = "".concat(d.getMonth(), "1/").concat(d.getDate(), "/").concat(d.getFullYear());
var index = field.name.lastIndexOf("_DAYSSINCE");
if (index > 0) {
fieldName = field.name.substring(0, index);
}
if (daysSince > 0 && daysSince != null) {
for (var i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].name == fieldName) {
win.document.forms[0].elements[i].value = s;
}
}
} else {
for (var _i5 = 0; _i5 < win.document.forms[0].elements.length; _i5++) {
if (win.document.forms[0].elements[_i5].name == fieldName) {
win.document.forms[0].elements[_i5].value = "";
}
}
}
},
// Scoring Worksheet functions
"setAvgField": function setAvgField(win, fieldName) {
return win.avgField = fieldName;
},
"setTotalField": function setTotalField(win, fieldName) {
win.totalField = fieldName;
win.document.forms[0].elements[fieldName].enabled = false;
},
"appendScore": function appendScore(win, fieldName) {
// var field = win.document.forms[0].elements[fieldName];
// win.scores = win.scores.concat(field);
win.scores = win.scores.concat(fieldName);
},
"calculateScore": function calculateScore(win) {
var totalScore = 0;
var removeFromTotal = 0;
for (var i = 0; i < win.scores.length; i++) {
var field = win.document.forms[0].elements[win.scores[i]];
var fieldValue = parseInt(getFieldValue(win, field));
if (!fieldValue > 0) {
fieldValue = 0;
removeFromTotal++;
}
totalScore = totalScore + fieldValue;
}
var avgScore = totalScore / (win.scores.length - removeFromTotal); // round to the nearest integer by adding .5 to avgScore
avgScore = parseInt(avgScore + 0.5);
if (win.totalField && totalScore == parseInt(totalScore)) {
// There are 2 fields which need to be populated, one hidden and one html disabled
win.document.forms[0].elements[win.totalField][0].value = totalScore;
win.document.forms[0].elements[win.totalField][1].value = totalScore;
}
if (win.avgField && avgScore == parseFloat(avgScore)) {
// There are 2 fields which need to be populated, one hidden and one html disabled
win.document.forms[0].elements[win.avgField][0].value = avgScore;
win.document.forms[0].elements[win.avgField][1].value = avgScore;
}
return true;
},
// End Scoring Worksheet functions
// BEGIN PAGE LISTENER FUNCTIONS
"clearListeners": function clearListeners() {
return lib.pageListeners = [];
},
/**
* Is here so that a selection field (select box, checkboxes, etc)
* can cause events to happen when its value changes. This function is called
* in an onChange event listener contained in the field. The field itself
* is passed in so that its attributes can be determined and used.
**/
"updatePage": function updatePage(win, field) {
// The values in the field must follow the following format:
// target,uri,querystring
// Parse it to find out those 3 values.
var value = field.options[field.selectedIndex].value;
var target = null;
var url = null;
if (value.indexOf(",") >= 0) {
target = value.substring(0, value.indexOf(","));
url = value.substring(value.indexOf(",") + 1);
if (url.indexOf(",") >= 0) {
var uri = url.substring(0, url.indexOf(","));
var qs = url.substring(url.indexOf(",") + 1);
var linkUrl = uri;
if (qs != null) {
var qsBegin = "?";
if (linkUrl.indexOf("?") >= 0) {
qsBegin = "&";
}
linkUrl = linkUrl + qsBegin + qs;
}
}
}
if (lib.checkAccess()) {
lib.loadingPage(true);
if (url.indexOf(",") >= 0) {
win.parent.frames[target].location.href = linkUrl;
win.parent.frames[target].focus();
}
} else {
win.alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
var size = field.options.length;
var currentPage = win.parent.frames[target].location.pathname;
for (var i = 0; i < size; i++) {
var optionVal = field.options[i].value;
if (optionVal.indexOf(currentPage) >= 0) {
field.selectedIndex = i;
break;
}
}
}
},
/**
* These functions and variables are for the next/previous applicant links.
* Loading will be set to true at the top of the page and then false as the
* last think on the page.
**/
"loadingPage": function loadingPage(bool) {
setGlobalData("Lib.loading", bool);
if (bool == true) {
lib.setAccessNextPage(true);
}
return true;
},
"isLoadingPage": function isLoadingPage() {
var loading = getGlobalData("Lib.loading");
return loading;
},
/**
* Is called at the bottom of every ResultPage and FormPage
* It iterates through all of the active page listeners and calls the
* method to let the page listeners know that the page has been updated.
*
* Called by the page, notifies page listeners
**/
"pageUpdated": function pageUpdated(uri) {
for (var i = 0; i < _this.pageListeners.length; i++) {
var listener = _this.pageListeners[i];
var f = void 0;
try {
f = listener.pageUpdated;
if (f) {
f(uri);
}
} catch (err) {}
}
},
// END OF PAGE LISTENER FUNCTIONS
/**
* Sets flag for accessing next page, can be retrieved from checkAccess(). This MUST occur on the global
* instance or results will not be consistent.
*
* @param value
* @returns {boolean}
*/
"setAccessNextPage": function setAccessNextPage(value) {
var canAccess = lib.checkAccess();
_log("accessNextPage: ".concat(canAccess));
setGlobalData("Lib.accessNextPage", value);
return true;
},
"setAccess": function setAccess(win, value) {
_this.setAccessNextPage(value);
if (win && win.document && win.document.forms && win.document.forms[0] && win.document.forms[0].elements && win.document.forms[0].elements["is_changed"] && !win.document.forms[0].elements["force_is_changed"]) {
win.document.forms[0].elements["is_changed"].value = !value;
}
return true;
},
/**
* Retrieves flag indicating if next page can be accessed. This MUST occur on the global
* instance or results will not be consistent.
*
* @returns {boolean}
*/
"checkAccess": function checkAccess() {
return getGlobalData("Lib.accessNextPage");
},
"checkLinkAccess": function checkLinkAccess() {
if (_this.checkAccess()) {
return true;
} else {
alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
return false;
}
},
/**
* Add a listener to parentField to show targetField when parentField.value
* equals showValue.
**/
"addDependentField": function addDependentField(win, rawParentFieldIds, targetField, rawShowValues) {
var $ = win.$; // TODO: this flag will be kept here as it may be desirable to use the 'keepWidth' feature for individual dialogs in the future
var keepWidth = false; // wait until the document is ready because "reset" and parent may not
// be present yet
$(win.document).ready(function () {
// separate out the fields and values into groups end result is array parentOrFields
var parentOrFields = [];
var parentOrFieldIds = rawParentFieldIds.split("|");
var parentOrValues = rawShowValues ? rawShowValues.split("|") : [];
for (var i = 0; i < parentOrValues.length; i++) {
parentOrValues[i] = parentOrValues ? parentOrValues[i].split("&") : [];
}
for (var _i6 = 0; _i6 < parentOrFieldIds.length; _i6++) {
var parentInnerAnd = [];
var parentInnerAndFieldIds = parentOrFieldIds[_i6].split("&");
for (var j = 0; j < parentInnerAndFieldIds.length; j++) {
var nameId = parentInnerAndFieldIds[j];
var negative = nameId.substr(-4) === "_NOT";
if (negative) {
nameId = nameId.substr(0, nameId.length - 4);
} // look to see if this will be rendered in Modal
var parentField = void 0;
if (dependentFieldCtx) {
parentField = $(dependentFieldCtx).find("[name='".concat(nameId, "']")).not(":disabled");
} else {
parentField = $("[name='".concat(nameId, "']")).not(":disabled");
}
parentField.data("negative", negative);
parentInnerAnd[j] = {
"fields": parentField,
"values": parentOrValues[_i6] ? parentOrValues[_i6][j] ? parentOrValues[_i6][j] : "" : ""
};
}
parentOrFields[_i6] = parentInnerAnd;
} // combine all fields into one jquery object for binding
var parentFields;
$.each(parentOrFields, function (i, innerAnd) {
return $.each(innerAnd, function (j, field) {
return parentFields = parentFields ? parentFields.add(field.fields) : field.fields;
});
}); // look to see if this will be rendered in Modal
var row;
if (dependentFieldCtx) {
row = $(dependentFieldCtx).find("#".concat(targetField, "_ROW"));
} else {
row = $("#".concat(targetField, "_ROW"));
}
if (parentFields && parentFields.length) {
var showHide = function showHide(dontAnimate) {
var foundPassingInnerAnd = false;
for (var _i7 = 0; _i7 < parentOrFields.length && !foundPassingInnerAnd; _i7++) {
var _parentInnerAnd = parentOrFields[_i7];
var innerAndResult = true; // for each field
var _loop = function _loop(_j2) {
var field = _parentInnerAnd[_j2]; // values are always the same for a field
var showOnValue = field.values.split(",");
var showOnAnyValue = field.values === ""; // for each input (of field)
var fieldResult = false;
for (var k = 0; k < field.fields.length && !fieldResult; k++) {
var input = field.fields.eq(k);
var value = input.val();
var _negative = input.data("negative"); // if ( input.attr("type") == "hidden" )
// this should already be handled server side; but we allow test anyway
// if this is an unchecked radio/check fake no value
if (input.is(":radio,:checkbox") && !input.is(":checked")) {
value = null;
}
var hasValue = false;
if (value !== null) {
value = $.makeArray(value);
$.each(value, function (i, v) {
if (v != "" && $.inArray(v, showOnValue) >= 0) {
hasValue = true;
}
});
} // set result and stop iteration when negative
fieldResult = hasValue || value && value != "" && showOnAnyValue;
if (_negative) {
fieldResult = !fieldResult;
}
}
innerAndResult = fieldResult;
};
for (var _j2 = 0; _j2 < _parentInnerAnd.length && innerAndResult; _j2++) {
_loop(_j2);
}
foundPassingInnerAnd = innerAndResult;
}
if (foundPassingInnerAnd) {
if (dontAnimate) {
row.show();
triggerResize(win, true, keepWidth);
} else {
// only animate when it is not already shown; display="auto"
if ("none" == row.css("display")) {
row.css("display", "");
row.css("opacity", "0");
row.animate({
"opacity": "1"
}, 500, "swing", function () {
return triggerResize(win, true, keepWidth);
});
}
}
} else {
if (dontAnimate) {
row.hide();
triggerResize(win, true, keepWidth);
} else {
row.fadeOut({
"complete": function complete() {
return triggerResize(win, true, keepWidth);
}
});
}
}
}; // on reset of form trigger change event for all fields
$(":reset").click(function () {
$(this).get(0).form.reset();
showHide(true);
}); // add event triggers to parent field
parentFields.each(function (i, elem) {
var $element = $(elem);
if ($element.hasClass("select-plus") && !$element.hasClass("select-plus-initialized")) {
SelectPlus.registerChangeListener($element, showHide);
} else {
jqueryUniversalChange(win, elem, function () {
return showHide();
});
}
});
showHide(true);
}
});
},
"setLocation": function setLocation(win, url) {
if (_this.checkAccess()) {
win.document.location.href = url;
} else {
win.alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
}
},
"historyGo": function historyGo(win, e) {
if (_this.checkAccess()) {
win.$("body").trigger("ss-event-page-cancel");
win.history.go(-1);
} else {
var e = win.event || e;
var targetValue = e.target || e.srcElement;
var msgForDisplay = $(targetValue).parents("ul").find("input[type=submit]");
win.alert("You must first click the \"".concat(msgForDisplay.val(), "\" or \"Undo\" buttons before exiting this page."));
}
},
"maskFormat": function maskFormat(win, field, expr) {
var v = field.value;
if (v == "") {
return true;
}
var re = new RegExp(expr);
if (re.exec(v)) {
return true;
} else {
return false;
}
},
/**
* Not even able to be called. Overriden by function autoFormat(x,y,z)
**/
"autoFormat": function autoFormat(field, expr, withstr) {
var v = field.value;
if (v == "") {
return;
}
var re = new RegExp(expr);
if (re.exec(v)) {
field.value = v.replace(re, withstr);
} else {
alert("".concat(v, " is not in the correct format."));
}
},
"AppLoginStepFillIn": function AppLoginStepFillIn(win) {
var $ = win.$; // copy create account button
var create_account_button = $(".pagebuttons ul :has([value='Create New Account'])");
create_account_button.css("display", "block");
if ($("div.create_account")) {
$("div.create_account").html(create_account_button.html());
create_account_button.css("display", "none");
} // move preview links
if ($("#step2_links")) {
$("#preview").hide();
$("#step2_links").html($("#preview").html());
} else {
$("#preview").show();
}
},
/**
* Adds functionality and style to the current content page in win.
**/
"addStyleClasses": function addStyleClasses(win, forSelector) {
// is a named function to aid in logging
var $ = win.$;
if (!$) {
_log(new Error("Can not call addStyleClasses; jQuery is not available."));
return;
}
forSelector = forSelector || "body";
_log("addStyleClasses for ".concat(forSelector));
var jq = $(forSelector);
setFormClass();
fillEmptyTD();
removeCheckboxsWhenAll();
fileFieldReset();
var classFunctions = {
".embedded_field": function embedded_field(obj) {
// firefox; clicking embedded input can't type
obj.closest("label").find(":radio, :checkbox").click(function () {
return $(obj).children(":text").focus();
}); // IE; clicking embedded input doesn't select check/radio
obj.closest("label").find(":text").click(function () {
$(this).closest("label").find(":radio, :checkbox").attr("checked", "checked");
});
},
// Lookup Editor
"a.wizardpopup": handleWizardPopupWithReload,
"a.wizardpopupNoReload": handleWizardPopup,
// modal pop-up links
"a.modalpopuplink": function aModalpopuplink(obj) {
return obj.click(function (e) {
e.preventDefault();
var popupId = "modalpopuplink";
if (!$("#".concat(popupId)).length) {
$("body").append("<div id='".concat(popupId, "' style='display:none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>"));
}
_this.addToolboxFunction(win, popupId, function () {
return ajaxFillinPopup(win, popupId, obj.attr("href"));
});
_this.showPopup(win, popupId);
return false;
});
},
// suggest search
"input.suggestsearch": handleSuggestSearch,
// file upload
"input.file_upload_field[type='button']": function inputFile_upload_fieldTypeButton(obj) {
$(obj).click(function (e) {
_log("Doing input.file_upload_field[type='button'].click()...");
var field = this; // Hack for SSOFT-5459. Multiple instances of the file upload popup are being created for some reason (when closing and reopening the popup).
$(field).parents().last().find("[id=upload_field]:hidden").remove();
closePopupFirst(win, function () {
_log("Doing fileUploadPopup - popups have been closed.");
fileUploadPopup(field, win);
});
});
},
// nctq
".nctq_hoverable": function nctq_hoverable(obj) {
obj.mouseenter(function (e) {
moveFloatingDivWithMouse(win, $(this).next("div"), e, 20, 20);
$(this).next("div").removeClass("nctq_scores_hidden");
$(this).next("div").addClass("nctq_scores_visible");
});
obj.mouseleave(function (e) {
$(this).next("div").removeClass("nctq_scores_visible");
$(this).next("div").addClass("nctq_scores_hidden");
});
obj.mousemove(function (e) {
moveFloatingDivWithMouse(win, $(this).next("div"), e, 20, 20);
});
obj.click(function (e) {
return e.preventDefault();
});
}
};
handleClassFunctions();
/**
* win - the window object (because of frames)
* div - the floating div jquery object
* e - event
* down - y offset from the mouse from the top right corner of the div
* left - x offset from the mouse from the top right corner of the div
*/
function moveFloatingDivWithMouse(win, div, e, down, left) {
var $ = win.$;
var width = div.width();
var height = div.height();
div.css({
"top": Math.min(e.pageY + down, $(win).height() - height + $(win).scrollTop()),
"left": e.pageX - width - left
});
}
function handleWizardPopupWithReload(obj) {
handleWizardPopup(obj, true);
}
function handleWizardPopup(obj, reloadPageOnDone) {
obj.click(function (e) {
e.preventDefault();
var popupId = obj.attr("name") ? obj.attr("name") : "awizardpopup";
if (!$("#".concat(popupId)).length) {
$("body").append("<div id='".concat(popupId, "' style='display:none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>"));
}
closePopupFirst(win, function () {
_this.addToolboxFunction(win, popupId, function () {
// hijack submit and stay open
ajaxFillinPopup(win, popupId, obj.attr("href"), null, true, true);
});
if (reloadPageOnDone) {
_this.addToolboxFunction(win, "".concat(popupId, "_close"), function () {
$("body").html("<h3 class='pageTitleCaption'>Please Wait... Loading</h3>"); // add refresh=Y to url
var curLoc = win.location.href;
var isOldUi = top.frames[0] && top.frames[0].name === "sss_script";
if (curLoc.indexOf("refresh") == -1) {
var newUrl = curLoc;
if (newUrl.indexOf("?") > -1) {
newUrl += "&refresh=Y";
} // if ( newUrl.indexOf("?") )
else {
newUrl += "?refresh=Y";
}
if (isOldUi) {
win.location.replace(newUrl);
} else {
win.$("body").trigger("ss-event-page-reload");
}
} else {
if (isOldUi) {
win.location.reload();
} else {
win.$("body").trigger("ss-event-page-reload");
}
}
});
}
_this.showPopup(win, popupId);
});
return false;
});
}
function handleSuggestSearch(obj) {
var suggestionId = "".concat(obj.attr("id") || obj.attr("name"), "_sug"); // url
var url = obj.attr("href"); // add jscallback to URL
if (url.indexOf("?") < 0) {
url += "?";
} else {
url += "&";
}
url += "jscallback=?"; // get suggestion
var lastTimeout = -1;
obj.keyup(function (e) {
if (lastTimeout != -1) {
win.clearTimeout(lastTimeout);
}
lastTimeout = win.setTimeout(function () {
// suggest from
var value = obj.val();
if (value == "") {
return;
}
value = {
"suggest": value,
"ajax": "y"
};
var data = $.param(value);
$.getJSON(url, data, handleSuggestsions);
}, 500);
}); // fillout suggestion
function handleSuggestsions(suggestions) {
removeSuggestionBox();
createSuggestionBox();
for (var suggestion in suggestions) {
// IE behaves funny when chaining
var id = suggestionId + suggestions[suggestion];
$("#".concat(suggestionId)).append("<div id='".concat(id, "' class='suggest_link'>").concat(suggestion, "</div>"));
var jsug = $("#".concat(id));
jsug.hover(hoverOver, hoverOut);
jsug.click(function () {
obj.val($(this).html());
removeSuggestionBox();
});
}
} // remove suggestion
obj.blur(removeSuggestionBox); // utiltity
function hoverOver() {
$(this).addClass("suggest_link_over");
obj.unbind("blur");
}
function hoverOut() {
$(this).removeClass("suggest_link_over");
obj.blur(removeSuggestionBox);
}
function createSuggestionBox() {
if (!$("#".concat(suggestionId, "_con")).length) {
obj.after("<div id='".concat(suggestionId, "_con'><div id='").concat(suggestionId, "' class='search_suggest'></div></div>"));
}
}
function removeSuggestionBox() {
$("#".concat(suggestionId, "_con")).remove();
}
}
function setFormClass() {
jq.find(":text").addClass("textfield");
jq.find(":password").addClass("passwordfield");
jq.find(":text, :password").focus(function () {
$(this).addClass("textfieldfocus");
});
jq.find(":text, :password").blur(function () {
$(this).removeClass("textfieldfocus");
});
} // Hack to fix rendering bug in IE.
function fillEmptyTD() {
jq.find("td:empty").html(" ");
}
function removeCheckboxsWhenAll() {
// Additionally can do ,:button[name='select_all'],:button[name='deselect_all']
var $selectNameActionType = jq.find("select[name=\"ACTION_TYPE\"]");
$selectNameActionType.change(function () {
var $checkboxes = jq.find(".rs :checkbox");
if ($selectNameActionType.val() === "all") {
$checkboxes.prop("disabled", "disabled").hide();
} else {
$checkboxes.prop("disabled", "").show();
}
});
}
function handleClassFunctions() {
var selectorString = "";
var first = true;
for (var selector in classFunctions) {
if (!first) {
selectorString += ",";
}
selectorString += selector;
first = false;
}
var $elements = jq.find(selectorString);
$elements.each(function () {
var me = $(this);
for (var _selector in classFunctions) {
if (me.is(_selector)) {
classFunctions[_selector].call(this, me);
}
}
});
}
/**
* Pop-up for upload_field
**/
var uploadFieldId = "upload_field";
function fileUploadPopup(field, win) {
var $ = win.$; // error on any existing pop-up
var modal = getModal(win);
if (modal && modal.isOpen()) {
alert("ERROR: cannot have a fileupload field within another pop-up");
return;
} // get real content
var fieldName = $(field).attr("hiddenname");
var uploadParams = "FIELD_NAME=".concat(fieldName, "&COMPANY_ID=").concat(companyId); // waiting text
if (!$("#".concat(uploadFieldId)).length) {
var loading = "<div id=\"".concat(uploadFieldId, "\" style=\"display: none\"><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>");
$("body").append(loading);
} // if to remove ext enforcement
var uploadPageQs = "";
if ($(field).is(".noextcheck")) {
uploadPageQs = "?noextcheck=Y";
} // on open
_this.addToolboxFunction(win, uploadFieldId, function () {
// fill in with real content
ajaxFillinPopup(win, uploadFieldId, "/ats/upload_field.jsp".concat(uploadPageQs), uploadParams);
}); // on close
_this.addToolboxFunction(win, "".concat(uploadFieldId, "_close"), function () {
// if the upload was a success
if (win.fileuploads && win.fileuploads[fieldName]) {
var fileupload = win.fileuploads[fieldName];
if (fileupload.id && fileupload.url) {
// update the hidden field
$("#".concat(fieldName)).val(fileupload.id); // update the link
$(".".concat(fieldName, "_link")).attr("href", fileupload.url).fadeIn();
$(".".concat(fieldName, "_remove")).attr("href", "#").fadeIn(); // change button label
$("#".concat(fieldName, "_button")).attr("value", "Replace File"); // warn on page change
_this.setAccess(win, false);
}
}
});
_this.showPopup(win, uploadFieldId);
}
function fileFieldReset() {
jq.find(":reset").click(function (e) {
// change hiddens back to original value
$(".file_upload_field[type='hidden']").each(function (i) {
var orgValue = $(this).attr("original");
$(this).val(orgValue); // update links
var link = $("#".concat($(this).attr("name"), "_link"));
link.attr("href", orgValue);
if (orgValue == "") {
link.fadeOut();
}
});
});
}
},
/**
* Called when an upload is complete
**/
"fileUploadComplete": function fileUploadComplete(win, fieldName, msg) {
var $ = win.$;
$(".inlineHelp").remove();
$(".searchsoft-modal #file_upload_content").html(msg);
$(".searchsoft-modal #file_upload_waiting").stop().hide();
$(".searchsoft-modal #file_upload_content").fadeIn(); // since we don't know what caused the fileupload (wizard or field) process the message for all cases
// Note regarding HE-3374: Content parameter was previously
// $("#" + fieldName)
// but "Continue" buttons with redirects weren't working
// See
// if (hijackStayOpen) {
// var button = content.find(".linkbutton");
// button.each(function () {
// in afterAjaxPopProcess
// Also see changes in upload_field.jsp (new div element with class starting with file-upload-complete-wrapper-)
afterAjaxPopProcess(win, fieldName, $(".file-upload-complete-wrapper-".concat(fieldName)), null, true, true);
triggerResize(win);
},
/**
* Called when an upload is starting
**/
"fileUploadStart": function fileUploadStart(win) {
var $ = win.$;
$(".inlineHelp").remove();
$(".searchsoft-modal #file_upload_waiting").fadeIn();
$(".searchsoft-modal #file_upload_content").hide();
return true;
},
// lib: JQUERY
"onReady": function onReady(win, fun) {
win.$ = checkJQuery(win, win.$);
if (!win.$) {
_log(new Error("Can not call onReady; jQuery is not available."));
return;
}
var onReady = function onReady() {
_log("win.document.readyState: ".concat(win.document.readyState)); // we need full CSS; chrome/safari parallel load
if (win.document.readyState != "complete") {
// FF jumps the gun on 'complete' state...causes issues with onReady functions
// when doing slow page load...so, do longer wait before executing
var deferTime = $.browser && $.browser.mozilla ? 1000 : 350;
_log("Deferring call to onReady for ".concat(deferTime, " ms..."));
win.setTimeout(onReady, deferTime);
return;
}
_log("Calling onReady() for:".concat(displayFn(fun)));
if (win.spinnerOn) {
win.onReadyFunctions = win.onReadyFunctions || [];
win.onReadyFunctions.push(fun);
_log("Adding function to win.onReadyFunctions (length=".concat(win.onReadyFunctions.length, "), NOT calling function."));
} else {
try {
_log("Executing onReady() function..."); // send in current context Window, and execute with Lib instance as function context
fun.call(_this, win);
} catch (e) {
_log("Error occurred executing onReady function...");
_log(e);
}
}
};
win.$(win.document).ready(onReady);
},
// Perform the new cookie test
"perform_cookie_test": function perform_cookie_test() {
makeTestCookie();
cookie_test = findTestCookie();
return cookie_test;
},
/**
* Called on pages that use the Action Toolbox.
*
* lib: JQUERY
* It will bind to the go button / select and correctly populate the pop-up.
*
**/
"ready_modal_popup": function ready_modal_popup(win, inline, uid) {
var $ = win.$;
$(win.document).ready(function () {
if (!inline) {
toolboxRegisterActionGo(win, uid);
} else {
toolboxRegisterSelection(win, uid);
}
if (!win.toolboxFunctions) {
win.toolboxFunctions = new Array(0);
}
});
},
/**
* Adds a function to list of current toolbox functions.
**/
"addToolboxFunction": function addToolboxFunction(win, funName, fun) {
if (!win.toolboxFunctions) {
win.toolboxFunctions = new Array(0);
}
win.toolboxFunctions[funName] = fun;
},
/**
* Toolbox, client function for AJAX popup.
**/
"ajaxPopupOp": function ajaxPopupOp(win, id, url, op, includeSelect) {
var $ = win.$;
var data = null;
if (op != null || "" == op) {
data = "op=".concat(op);
}
if (includeSelect) {
data = "".concat(data == null ? "" : data + "&").concat($("form").serialize());
}
var tableName = $("[name=table_name]").val();
if (tableName != null && "" != tableName && (data == null || data.indexOf("table_name") == -1)) {
data = "".concat(data ? data + "&" : "", "table_name=").concat(tableName);
}
ajaxFillinPopup(win, id, url, data);
},
/**
* Toolbox, client function for AJAX popup.
**/
"ajaxPopup": function ajaxPopup(win, id, url) {
return _this.ajaxPopupOp(win, id, url, null);
},
/**
* Creates a Modal and displays it, using the content contained in HTML element with given item id.
*
* @param {Window} win context window
* @param {string} item id of HTML content for modal
* @param {Object} [atts] optional map of attributes used to init Modal
*/
"showPopup": function showPopup(win, item, atts) {
var $ = win.$; // TODO: until a further non-trivial refactoring is done, need to pull 'Ok' button text from
// modal content, from the buttons rendered via ui.properties, and also need to remove
// pagebuttons from content before providing to modal
var text = $("#".concat(item)).find("input[name=".concat(item, "]")).val();
if (!text && item.indexOf("_results") > 0) {
// it may be that the Ok button does not follow convention of having same name as item (i.e. 'email_results' and 'email')
var btnName = item.replace("_results", "");
text = $("#".concat(item)).find("input[name=" + btnName + "]").val();
}
var parent = $("#".concat(item)).parent();
var content = $("#".concat(item)).find(".pagebuttons").hide().end();
$(content).css("display", ""); // default Modal attributes
var defaultAtts = {
"useCloseX": true
};
if (atts) {
atts = $.extend({}, defaultAtts, atts);
} else {
atts = defaultAtts;
} // do Ok/Cancel need to be enabled for Modal (or will content contain buttons?)
var enableCancelOk = !text;
var modalInit = {
"id": item,
"attributes": atts,
"content": content,
"onOpen": function onOpen() {
// Important hack for HE-4062 and related issues (e.g. HE-3875, which was already fixed with an even worse hack)
// Closing modals doesn't actually remove them from the DOM, it only hides them, causing lots of issues
// Now instead of hiding old modals when the same modal is opened again, we are removing them from the DOM (i.e. remove() instead of hide())
// Old comment:
// if content from previous Modal is still in DOM, remove before opening this instance
$("[id=\"".concat(item, "\"]")).toArray().slice(0, -1).forEach(function (el) {
return $(el).remove();
});
if (enableCancelOk) {
toolboxAddCancel(win, item);
toolboxRunFunction(win, item);
}
},
"onClose": function onClose(modal) {
// insert the (possibly) modified data back into the DOM
var content = $(modal.getContent(true));
content = $(content).children(); // must get kids (not include the Modal content wrapper)
$(parent).append(content.hide());
toolboxRunFunction(win, "".concat(item, "_close"));
$(".inlineHelp").remove();
win.document.thismodal = null;
}
}; // if this is a non-Ajax populated instance, configure w/ buttons
if (!enableCancelOk) {
modalInit.buttons = [{
"text": text,
"type": "ok",
"callback": function callback(modal) {
return toolboxRunFunction(win, item);
}
}, {
"text": "Cancel",
"type": "cancel"
}];
} // otherwise, this will be populated via ajaxPopup() call
else {
modalInit.showOk = false;
modalInit.showCancel = false;
}
createModal(win, modalInit, true); // will assign to global variable
},
/**
* Toolbox utility, add a hidden field to main form.
**/
"addHiddenField": function addHiddenField(win, name, value) {
var $ = win.$;
$("form").append("<input type=\"hidden\" name=\"".concat(name, "\" value=\"").concat(value, "\" />"));
},
/**
* Utility function that adds all currently checked applicants to the popup.
**/
"addCheckboxApplicants": function addCheckboxApplicants(win, id) {
var $ = win.$;
doModalOp(win, false, function (modal, content) {
var form = $(content).find("form"); // for some reason doing this as inline calls breaks IE6
var apps = $("div.rs :checkbox:checked").clone();
apps.attr("checked", "checked"); // apps.attr("type", "hidden"); // breaks IE6
apps.attr("remove", "yes");
apps.hide();
form.append(apps); // add what to effect; "All applicants in list"
var actionTypeField = $("select[name='ACTION_TYPE']");
if (actionTypeField.length) {
form.append("<input type=\"hidden\" name=\"ACTION_TYPE\" value=\"".concat(actionTypeField.val(), "\" />"));
} // confirm that the checkboxes have been checked [IE6]
if ($(form).find(":checkbox:checked").length == 0) {
// check hidden checkboxes
$(form).find(":hidden:checkbox").attr("checked", "checked");
}
});
},
/**
* Utility function that remove added checked applicants to popup.
**/
"removeCheckboxApplicants": function removeCheckboxApplicants(win, id) {
var $ = win.$;
$("div#".concat(id, " :checkbox[remove='yes']")).remove();
},
/**
* Function that adds window.superConfirm
**/
"addSuperConfirm": function addSuperConfirm(win) {
var $ = win.$;
win.superConfirm = function (text, _callback) {
return createModal(win, {
"content": text,
"attributes": {
"useCloseX": false
},
"buttons": [{
"text": "Yes",
"type": "ok",
"callback": function callback(modal) {
if ($.isFunction(_callback)) {
_callback.apply();
}
triggerResize(win);
}
}, {
"text": "Cancel",
"type": "cancel",
"callback": function callback(modal) {
return $(".inlineHelp").remove();
}
}]
});
};
},
/**
* Function that overrides window.alert() when another function comes in we add
* its text to the top of the current window.
**/
"replaceAlert": function replaceAlert(win) {
var $ = win.$;
win.alert = function (text) {
text = text.replace(/\r\n|\n/g, "<br />");
var popupsOpen = Modal.anyShowing(win);
if (popupsOpen) {
// add the content to the bottom in red
var content = $("<div class='red inlineHelp' />").html(text);
var message; // is there a current alert
if ($(".inlineHelp").length) {
// change text and reset timeout
message = $(".inlineHelp").html(text);
win.clearTimeout(win.helpTimeout);
} else {
// add to bottom and set a timeout
Modal.getCurrent(win).addContent(content);
message = $(".inlineHelp").css("opacity", "0").animate({
"opacity": "1"
}, 500, "linear", function () {
// force resize event
triggerResize(win);
});
}
win.helpTimeout = win.setTimeout(function () {
return message.animate({
"opacity": "0"
}, 500, "linear", function () {
message.remove();
triggerResize(win);
});
}, 15000); // force resize event
triggerResize(win);
} else {
// create a new popup
text = $("<p class='help_popup' />").html(text);
createModal(win, {
"content": text,
"attributes": {
"useCloseX": false
},
"buttons": [{
"text": "Close",
"type": "ok",
"callback": function callback(modal) {
return $(".inlineHelp").remove();
}
}]
});
}
};
},
/**
* Utility for adding fieldPrompt() the window variable.
**/
"addFieldPrompt": function addFieldPrompt(win) {
var $ = win.$;
/**
* Private utility function.
* Default functionality for when pop-up is unavailable.
**/
function defaultPrompt(win, field, message) {
win.alert(message);
}
/**
* Displays a pop-up for a incorrect field.
* Call with field and message: fieldPrompt(<field dom object>, "This field is invalid");
*
* @param fields
* array of fields to be prompted for
* @param message
* message to display about why field is invalid
* @param sumbitOnClose
* (internal) default to use for if to submit the form on successful validation
* @param notryagain
* (internal) if to wait if there is currently a pop-up
**/
function fieldPrompt(fields, message, submitOnClose, notryagain) {
// save for when we call "classic" functions
var passedIn = fields;
var isPassedInArray = !(fields.name || fields.id || fields.type) && fields.length; // force fields is an array
if (!isPassedInArray) {
fields = [];
fields[0] = passedIn;
} // force submitOnClose to be boolean (safety)
if (submitOnClose) {
submitOnClose = true;
} else {
submitOnClose = false;
} // submit when called from validate fields
if (win.runningValidFields) {
submitOnClose = true;
} // if we already have a pop-up just show the extra message
var popupsShowing = Modal.anyShowing(win);
if (popupsShowing) {
// if timeout waiting to spawn pop-up
if (notryagain) {
return defaultPrompt(win, passedIn, message);
} // if we are in a chain of pop-ups
if (!submitOnClose) {
return defaultPrompt(win, passedIn, message);
} else {
// last pop-up in chain is animating, try again soon
return win.setTimeout(function () {
return fieldPrompt(passedIn, message, submitOnClose, true);
}, 550);
}
} // Special Case for GridField validation
try {
if ($(".gridfield").length > 0) {
var gridFields = $(".gridfield");
for (var i = 0; i < gridFields.length; i++) {
if ($.contains(gridFields[i], fields[0])) {
return defaultPrompt(win, passedIn, message);
}
}
}
} catch (e) {}
/* Can safely ignore errors - means we're not in a gridfield*/
// what the fields and caption are contained within
var fieldDelimiter = win.fieldDelimiter || "tr"; // get the parent containing field
var fieldParent = null;
for (var _i8 = 0; _i8 < fields.length; _i8++) {
if (!fieldParent) {
fieldParent = $(fields[_i8]).closest(fieldDelimiter);
} else {
fieldParent = fieldParent.add($(fields[_i8]).closest(fieldDelimiter).eq(0));
}
} // If we could not find the field and its caption
if (!fieldParent.length) {
return defaultPrompt(win, passedIn, message);
} // Get a copy of the fields to display in the pop-up
var isDatefield = $(fieldParent).find(".hasDatepicker").length != 0;
var parentCopy = $(fieldParent).clone(!isDatefield); // clone handlers too (if not a date field)
$(parentCopy).find("*").addBack().each(function () {
var id = $(this).attr("id");
if (id) {
$(this).attr("id", "".concat(id, "_COPY"));
}
}); // remove any nodes marked as do-not-copy (i.e. injected widgets)
$(parentCopy).find(".do-not-copy").remove(); // find matching DOM copies of the field
var fieldCopy = [];
var duplicates = false;
parentCopy.find("*").each(function (index) {
for (var _i9 = 0; _i9 < fields.length; _i9++) {
var result = true;
var field = fields[_i9];
var id = $(field).attr("id");
var copyId = $(this).attr("id");
if ("".concat(id, "_COPY") != copyId) {
result = false;
}
if ($(field).attr("name") != $(this).attr("name")) {
result = false;
}
if ($(field).attr("value") != $(this).attr("value") && $(field).attr("type") != "select-one") {
result = false;
}
if ($(field).attr("type") != $(this).attr("type")) {
result = false;
}
if (result) {
// duplicate of already recorded field, bail
if (fieldCopy[_i9]) {
duplicates = true;
} // record the field in the copy
fieldCopy[_i9] = $(this).get(0);
}
}
}); // if duplicates bail
if (duplicates) {
return defaultPrompt(win, passedIn, message);
} // confirm copy and pass-in have same amount of elements
if (fields.length != fieldCopy.length) {
return defaultPrompt(win, passedIn, message);
} // normalize the two arrays
fields = trimArray(fields);
fieldCopy = trimArray(fieldCopy); // actually show the pop-up
var changeOnClose = false; // build content
var content = $("<div class='invalid'>".concat(message, "</div>")); // place field
$(content).append(parentCopy); // contain field in appropriate html trappings for styling
switch (fieldDelimiter) {
case "tr":
parentCopy.wrap("<table class=\"frmpfields\"></table>");
break;
case "td":
parentCopy.wrap("<table class=\"frmpfields\"><tr></tr></table>");
break;
case "li":
parentCopy.wrap("<ul></ul>");
break;
default:
parentCopy.wrap("<div class=\"fieldprompt\"></div>");
break;
}
createModal(win, {
"content": content,
"attributes": {
"useCloseX": true
},
"showOk": true,
"showCancel": true,
// callback is fired when 'Ok' button is clicked
"callback": function callback(modal) {
// TODO Need to find a better workaround, for some reason fieldCopy doesn't store the value of the field. Same code works in the old V1 architecture.
fieldCopy.filter(function (x) {
return x !== undefined;
}).forEach(function (x) {
var element = $("#".concat(x.id))[0];
x.checked = element.checked;
x.value = element.value;
}); // handle if pass-in was single field
var checkField;
if (isPassedInArray) {
checkField = fieldCopy;
} else {
checkField = fieldCopy[0];
} // check that field is valid
if (!validNewField(win, passedIn, checkField)) {
return false; // this will prevent closing
} // set to resubmit the form
changeOnClose = true;
},
"onOpen": function onOpen() {
if (isDatefield) {
var dfCopy = $(parentCopy).find(".hasDatepicker");
$(dfCopy).removeClass("hasDatepicker");
$(dfCopy).datepicker({
"showOtherMonths": true,
"selectOtherMonths": true,
"showAnim": "slideDown",
"changeYear": true
});
}
triggerResize(win); // HE-2143
$("#".concat(fieldCopy[0].id)).focus();
},
// onClose is fired no matter how modal is closed
"onClose": function onClose() {
$(".inlineHelp").remove();
if (changeOnClose) {
// handle if pass-in was single field
var newField;
if (isPassedInArray) {
newField = fieldCopy;
} else {
newField = fieldCopy[0];
} // re-add field to listeners
reassignFieldListeners(passedIn, newField); // push back data
for (var _i10 = 0; _i10 < fields.length; _i10++) {
// find if ie hack is needed for radio button's state
var ieHack = false;
if (fieldCopy[_i10].checked) {
ieHack = true;
} // actually replace data
$(fields[_i10]).replaceWith(fieldCopy[_i10]);
var id = $(fieldCopy[_i10]).attr("id") || "";
id = id.replace("_COPY", "");
if (id) {
$(fieldCopy[_i10]).attr("id", id);
}
if (isDatefield) {
$(fieldCopy[_i10]).removeClass("hasDatepicker");
$(fieldCopy[_i10]).datepicker({
"showOtherMonths": true,
"selectOtherMonths": true,
"showAnim": "slideDown",
"changeYear": true
});
} // use ie hack
if (ieHack) {
$(fieldCopy[_i10]).attr("checked", "checked");
}
} // notify the field change
_this.setAccess(win, false); // if was triggered by form submission, re-trigger
if (submitOnClose) {
$("[name='submit_button']").trigger("click");
}
}
}
});
} // set fieldPrompt() on the win object
win.fieldPrompt = fieldPrompt;
},
/**
* Initializes a formPage
**/
"initFormPage": function initFormPage(win) {
win.scores = new Array(0);
win.avgField = null;
win.totalField = null;
},
"multiRecordField": function multiRecordField(_window, id, url, fetchNow) {
var $ = _window.$;
function refreshResultPage() {
// "Caching" this selector fixes HE-3707 (Internet Explorer issue)
var $id = $("#".concat(id));
$id.html("<h3>Loading...</h3> <p><img src=\"https://cdn.searchsoft.net/images/loading.gif\" />Please Wait</p>"); // get content
$.get(url, // add ajax notification for server
"ajax=Y&refresh=Y", function (data, textStatus) {
if (textStatus === "success") {
// This is where Internet Explorer requires a "cached" selector. Maybe "$" is getting hijacked by the time the AJAX call finishes?
// populate the result
$id.html(data);
registerResultPageAjaxLinks();
} else {
throw "AJAX error getting content";
}
}, "text");
}
this.refreshResultPage = refreshResultPage; // when page has .resultpageajaxlinks show links in a pop-up; refreshing the
// "source" page when the pop-up is closed
function registerResultPageAjaxLinks() {
// when page has .resultpageajaxlinks show links in a pop-up
if ($("#".concat(id, " .resultpageajaxlinks")).length) {
var popId = "".concat(id, "_popup");
$("#".concat(id, " a:not([class~=\"resultlink\"])")).click(function (eventObject) {
var $this = $(this); // what was clicked on
var href = $this.attr("href"); // is delete link
if ($this.hasClass("delete")) {
_window.superConfirm("Are you sure you want to delete this record?", function () {
return $.post(href, null, function (data, textStatus) {
if (textStatus === "success") {
refreshResultPage();
} else {
throw "AJAX error";
}
});
});
} else {
// ajax to fill in pop-up
_this.addToolboxFunction(_window, popId, function () {
return ajaxFillinPopup(_window, popId, href, null, true);
}); // refresh the result page on close
_this.addToolboxFunction(_window, "".concat(popId, "_close"), function () {
return refreshResultPage();
}); // show a pop-up
_this.showPopup(_window, popId);
} // stop browser from following link
eventObject.preventDefault();
return false;
});
}
}
if (fetchNow) {
refreshResultPage();
} else {
registerResultPageAjaxLinks();
}
},
/**
* Register a JSExpression field
**/
"jsExpression": function jsExpression(win, target, expression, defaults) {
var $ = win.$; // varaiables
var varRegExp = new RegExp("\\b[A-Za-z][A-Za-z0-9_]+\\b", "g"); // create listener for "onchange" of each variable
var variable;
while ((variable = varRegExp.exec(expression)) != null) {
// listener for onchange
var elem = $("[name='".concat(variable, "']"));
if (elem.length) {
elem.unbind(jqueryUniversalChangeSupportedEvents.join(","), runExpression);
jqueryUniversalChange(win, elem.get(0), runExpression);
}
} // utility to run the function
function runExpression() {
// this call will never propagate an exception...
var expr = buildRawExpression();
try {
// change the value of target
var value = eval(expr);
var targetField = $("#".concat(target, "_display"));
var targetHidden = $("#".concat(target));
if (value != targetHidden.val()) {
targetField.val(value);
targetField.trigger("change");
targetHidden.val(value);
targetHidden.trigger("change");
}
} catch (ex) {
lib.replaceAlert(win);
var msg = "<span style='font-size: 1em; font-style: normal; font-weight: normal'>It appears that there is an unresolved variable in the JS Expression string provided:</span><br /><br /><span style='font-size: .8em; font-style: italic; font-weight: bold'>".concat(expr, "</span><br /><br /><span style='font-size: 1em; font-style: normal; font-weight: normal'>Check the unresolved field name and ensure that it corresponds with an input on the page.</span>");
win.alert(msg);
$("#".concat(target, "_display")).val("###");
}
} // utility that returns expression with all variables replaced with their real values
function buildRawExpression() {
var result = expression;
try {
// replace all variables in the string
var _variable;
while ((_variable = varRegExp.exec(expression)) != null) {
// value in the form
var value = null;
var variableField = $("[name='".concat(_variable, "']"));
if (variableField.length != 0 && "###" != variableField.val()) {
value = Number(variableField.val());
} // use the default
else if (defaults[_variable] != null) {
value = Number(defaults[_variable]);
} // don't replace this one
else {
continue;
} // use zero if field had nonsense value
if (!isFinite(value)) {
value = Number(0);
} // replace the value
result = result.replace(new RegExp("\\b".concat(_variable, "\\b"), "g"), value);
}
result = "( ".concat(result, " )");
} catch (e) {
_log(e);
}
return result;
} // run it for the first time
runExpression();
},
"reloadNewMcrelYear": function reloadNewMcrelYear(win, mcrelYearDropDownDomName) {
var $ = win.$; // domReady doesn't work reliably here
$(function () {
var $select = $("select[name=\"".concat(mcrelYearDropDownDomName, "\"]"));
$select.change(function () {
var val = $select.val();
if (val !== "") {
var currentLocation = $("form").prop("action");
var newLocation = URI(currentLocation).setQuery("MCREL_YEAR_ID", val).toString();
win.location.href = newLocation;
}
});
});
},
"reloadTeamMemberDashboard": function reloadTeamMemberDashboard(win) {
var $ = win.$;
_this.onReady(win, function () {
return $("select[name='TEAM_MEMBER_USER_ID']").change(function (e) {
var curLocation = win.location.href;
var url;
if (/TEAM_LED_ID=[^&]*/.test(curLocation)) {
url = curLocation.replace(/TEAM_LED_ID=[^&]*/, "TEAM_LED_ID=".concat($("select[name='TEAM_LED_ID']").val()));
} else {
url = "".concat(curLocation, "&TEAM_LED_ID=").concat($("select[name='TEAM_LED_ID']").val());
}
if (/TEAM_MEMBER_USER_ID=[^&]*/.test(curLocation)) {
url = url.replace(/TEAM_MEMBER_USER_ID=[^&]*/, "TEAM_MEMBER_USER_ID=".concat($(this).val()));
} else {
url = "".concat(url, "&TEAM_MEMBER_USER_ID=").concat($(this).val());
}
var regex = /TEAM_MEMBER_USER_ID=([^&]*)/g;
var match = regex.exec(curLocation);
if (match != null && match[1] == $(this).val()) {
return;
} else {
win.location.href = url;
}
});
});
},
"addReloadOnSelectChange": function addReloadOnSelectChange(win, selectName) {
var $ = win.$;
_this.onReady(win, function () {
return $("select[name='".concat(selectName, "']")).change(function (e) {
var curLocation = win.location.href;
var url;
var urlParamRegex = new RegExp("".concat(selectName, "=[^&]*"));
if (urlParamRegex.test(curLocation)) {
url = curLocation.replace(urlParamRegex, "".concat(selectName, "=").concat($(this).val()));
} else {
url = "".concat(curLocation, "&").concat(selectName, "=").concat($(this).val());
}
var regex = new RegExp("".concat(selectName, "=([^&]*)"), "g");
var match = regex.exec(curLocation);
if (match != null && match[1] == $(this).val()) {
return;
} else {
win.location.href = url;
}
});
});
},
"activatePreview": function activatePreview(win, openNewWindow, inputId, buttonId, lookup) {
var $ = win.$;
$("#".concat(buttonId)).click(function () {
var input = $("[name=".concat(inputId, "]"));
if (!input.length) {
return win.alert("No input field to preview");
}
var value = input.val();
if (value == "" || value == null) {
return win.alert("No input currently selected");
}
var url = lookup[value];
if (url == "" || url == null) {
return win.alert("No preview page for that selection");
}
if (!openNewWindow) {
var div = "".concat(buttonId, "_div");
_this.addToolboxFunction(win, div, function () {
return ajaxFillinPopup(win, div, url, null);
});
_this.showPopup(win, div);
} else {
win.open(url);
}
});
},
/**
* Registers a staged select field
**/
"registerStageSelect": function registerStageSelect(win, fieldId, dbFieldId, parentId, value, multi, required) {
_this.onReady(win, function () {
// JQuery
var $ = win.$; // create the two types of fields we can be
var selectField = $("[name='".concat(fieldId, "']"));
var singleValueId = "singleValue_".concat(fieldId);
if (!selectField.length) {
_log("StagedSelectField is not present!");
return;
} // find the parent
var parentField = $("[name='".concat(parentId, "']"));
if (!parentField.length) {
_log("StagedSelectField parent field is not present: ".concat(parentId));
return;
}
var addWildcard = parentField.attr("type") == "text";
function stageChangeEvent(e) {
// get parent value
var me = $(this);
var parentValue = me.val();
if (addWildcard) {
parentValue += "*";
} // make best faith to encode
if (encodeURIComponent) {
parentValue = encodeURIComponent(parentValue);
} else {
if (escape) {
parentValue = escape(parentValue);
}
} // only proceed for selected checkboxes and radio buttons
var type = me.attr("type");
var checkable = type == "radio" || type == "checkbox";
var selected = me.attr("checked");
if (checkable && !selected) {
return;
} // actually get the results; JSONP request
if (parentValue != "" && parentValue != null) {
var url = "/ats/stage_field_lookup?GUI_FIELD_ID=".concat(dbFieldId, "&parentvalue=").concat(parentValue, "&ajax=Y&jscallback=?");
$.getJSON(url, addLookups);
} else {
nukeChoice();
}
} // add the lookups to the select field
var addOnChange = true;
function addLookups(lookups) {
// error check
if (!lookups) {
_log("lookups null");
return;
} // find length
var length = lookups.length; // support collapsing single values
var showSingleValue = length == 1 && required;
var selectedCaptions = ""; // clear out all current entries
selectField.html("");
$("#".concat(singleValueId)).remove();
if (!showSingleValue) {
selectField.show();
} // final choices
var options = "";
var hasSelected = false; // populate the new ones
$.each(lookups, function (index, obj) {
var lookupValue = obj["value"]; // skip empty string (dummy value)
if (lookupValue == "") {
return;
} // Locate caption
var lookupCaption = obj["caption"]; // if this is our original value mark slected
var selected = "";
if ($.inArray(lookupValue, value) != -1 || showSingleValue) {
selectedCaptions += lookupCaption;
selected = " selected='selected' ";
hasSelected = true;
} // add the value
options += "<option value='".concat(lookupValue, "'").concat(selected, ">").concat(lookupCaption, "</option>");
}); // empty option
if (!(multi || showSingleValue)) {
options = "<option value=''".concat(hasSelected ? "" : " selected='selected' ", "></option>").concat(options);
}
selectField.append(options); // support single value
if (showSingleValue) {
selectField.hide();
var captions = "<div id='".concat(singleValueId, "'>").concat(selectedCaptions, "</div>");
selectField.after(captions);
}
selectField.triggerHandler("change");
if (addOnChange) {
addOnChange = false;
selectField.change(function () {
return _this.setAccess(win, false);
});
}
} // add the lookups to the select field
function nukeChoice() {
// clear out all current entries
selectField.html("").show();
$("#".concat(singleValueId)).remove();
if (!multi) {
selectField.append("<option value='' selected='selected'></option>");
}
selectField.triggerHandler("change");
} // bind to changes on the parent
parentField.bind("change", stageChangeEvent); // trigger initial population
stageChangeEvent.apply(parentField.get(0));
});
},
/**
* Registers a staged text field
**/
"registerStageText": function registerStageText(win, fieldId, dbFieldId, parentId, multi, required) {
_this.onReady(win, function () {
// JQuery
var $ = win.$; // create the two types of fields we can be
var textField = $("[name='".concat(fieldId, "']"));
if (!textField.length) {
alert("StageTextField is not present!");
return;
} // find the parent
var parentField = $("[name='".concat(parentId, "']"));
if (!parentField.length) {
alert("StageTextField parent field is not present: ".concat(parentId));
return;
}
function stageChangeEvent(e) {
// get parent value
var me = $(this);
var parentValue = me.val(); // make best faith to encode
if (encodeURIComponent) {
parentValue = encodeURIComponent(parentValue);
} else {
if (escape) {
parentValue = escape(parentValue);
}
} // only proceed for selected checkboxes and radio buttons
var type = me.attr("type");
var checkable = type == "radio" || type == "checkbox";
var selected = me.attr("checked");
if (checkable && !selected) {
return;
} // actually get the results; JSONP request
if (parentValue != "" && parentValue != null) {
var url = "/ats/stage_field_lookup?GUI_FIELD_ID=".concat(dbFieldId, "&parentvalue=").concat(parentValue, "&ajax=Y&jscallback=?");
$.getJSON(url, addLookups);
}
} // add the lookups to the select field
var addOnChange = true;
function addLookups(lookups) {
// error check
if (!lookups) {
alert("lookups null");
return;
} // error check
if (lookups.length != 1) {
alert("lookup must have one value");
return;
}
var newValue = lookups[0]["value"];
textField.val(newValue); // Hack that fixes SSOFT-5469
// https://stackoverflow.com/questions/11793368/set-textarea-value-with-javascript-after-tinymce-initializing/11793478#11793478
if (win !== null && win.tinymce !== null) {
var tinymceEditor = win.tinymce.get(textField.attr("id"));
if (tinymceEditor !== null) {
tinymceEditor.setContent(newValue);
}
}
textField.triggerHandler("change");
if (addOnChange) {
addOnChange = false;
textField.change(function () {
return _this.setAccess(win, false);
});
}
} // bind to changes on the parent
parentField.bind("change", stageChangeEvent); // trigger initial population
stageChangeEvent.apply(parentField.get(0));
function getFirstKey(data) {
for (var elem in data) {
return elem;
}
}
});
},
"registerMoveToSelect": function registerMoveToSelect(win, domId) {
function alphaSort(doma, domb) {
var a = doma.innerHTML;
var b = domb.innerHTML;
var va = a === null ? "" : "".concat(a);
var vb = b === null ? "" : "".concat(b);
return va > vb ? 1 : va === vb ? 0 : -1;
}
function moveTo($from, $to) {
// move to other side
var $fromdetached = $from.find(":selected");
$fromdetached.detach();
$to.append($fromdetached); // sort result
var $toDetach = $to.children();
$toDetach.detach();
$to.append($toDetach.get().sort(alphaSort));
}
var $ = win.$;
var $dst = $("#".concat(domId));
var $src = $("#".concat(domId, "_src"));
$("#".concat(domId, "_addbtn")).click(function () {
_this.setAccess(win, false);
$dst.children().prop("selected", false);
moveTo($src, $dst);
});
$("#".concat(domId, "_rmvbtn")).click(function () {
_this.setAccess(win, false);
$src.children().prop("selected", false);
moveTo($dst, $src);
});
$("form").on("click", "input:submit", function () {
$src.children().prop("selected", false);
$dst.children().prop("selected", true);
});
},
"browseToNextUrlFromNavigationPulldown": function browseToNextUrlFromNavigationPulldown(win, backward) {
var nextUrl = getNextUrlFromNavigationPulldown(win, backward);
if (nextUrl) {
win.location.href = nextUrl;
} else {
alert("Already at the end or beginning of the list.");
}
},
"writeRedirectFromNav": function writeRedirectFromNav(win) {
return win.$("form").append("<input type=\"hidden\" name=\"redirect\" value=\"".concat(getNextUrlFromNavigationPulldown(win, false), "\">"));
},
"handlePreviousNavButton": function handlePreviousNavButton(win) {
var nextUrl = getNextUrlFromNavigationPulldown(win, true);
if (!nextUrl) {
win.$(":button[value=Previous]").remove();
}
},
"registerQuickSelectGoButton": function registerQuickSelectGoButton(win, id) {
return _this.onReady(win, function () {
var $ = win.$;
$("#".concat(id, "_go")).click(function () {
var selectName = "[name='".concat(id, "']");
var select = $(selectName);
var href = select.val();
if (href != "") {
win.location.href = href;
}
});
});
},
/**
* Tie together an expanding multivalue field (edit only)
**/
"registerExpandingMultiValue": function registerExpandingMultiValue(win, fieldName, showRemove, rangeExtra) {
var $ = win.$;
_this.onReady(win, multiValueField);
function multiValueField() {
// find needed elements
var row;
var org;
var container;
var size;
var maxSize;
var template;
init(); // undo support
$(":reset").click(function (e) {
row.html(org);
init();
});
function init() {
row = $("#".concat(fieldName, "_ROW"));
row.find("script").remove();
org = row.html();
container = $("#".concat(fieldName, "_TABLE_CONTAINER tbody"));
size = row.find("#".concat(fieldName, "_SIZE"));
maxSize = parseFloat(size.val());
template = row.find("#".concat(fieldName, "_TEMPLATE")); // min value
if (rangeExtra) {
addAllMin();
} // auto remove
if (rangeExtra) {
addAllRangeExtra();
} // remove links
if (showRemove) {
addAllRemove();
} // add link
var addMoreId = "".concat(fieldName, "_addmore");
if (!container.parent().find("#".concat(addMoreId)).length) {
var addMoreA = $("<a class=\"addMoreA\"></a>").attr({
"id": addMoreId,
"href": "#"
}).html("<img src=\"/ats/css-base/add.png\" class=\"addMoreImg\"/>Add More").click(function (e) {
e.preventDefault();
_this.setAccess(win, false);
addEmptyRow();
return false;
});
container.closest("table").after(addMoreA);
}
if (parseFloat(size.val()) < 1) {
// first row shouldn't prevent leaving page
addEmptyRow();
}
}
function addEmptyRow() {
// add one to size
var curSize = parseFloat(size.val());
size.val(curSize + 1);
maxSize += 1;
var newRecord = "<tr class=\"subrecord_container ".concat(fieldName, "_subrecord_container\" id=\"").concat(fieldName, "_").concat(maxSize - 1, "\">").concat(template.html().replace(/_TEMPLATE/g, "_SUBRECORD_" + (maxSize - 1)), "</tr>"); // insert new content to html
container.append(newRecord);
var newElem = $("#".concat(fieldName, "_").concat(maxSize - 1)); // add remove
if (showRemove) {
addRemove(newElem);
} // add min
if (rangeExtra) {
addMin(newElem);
} // range extra
if (rangeExtra) {
addRangeExtra(newElem);
}
addRemoveTrigger(newElem); // allow any boxes to resize
triggerResize(win);
}
function addAllRangeExtra() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addRangeExtra(subRecords);
}
function addRangeExtra(jq) {
jq.each(function () {
var me = $(this);
var min = me.find(".subrecord_min");
var field = me.find(jqueryUniversalChangeSupportedTags).get(0);
jqueryUniversalChange(win, field, function () {
rangeExtraTrigger(field, min);
return true;
});
});
function rangeExtraTrigger(field, min) {
var cur = $(field);
var minVal = parseFloat(min.html());
var curVal = parseFloat(cur.val());
if (isNaN(curVal) || minVal >= curVal) {
cur.val(minVal + 1);
}
}
}
function addAllMin() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addMin(subRecords);
}
function addMin(jq) {
// jq object
jq.find(".remove_container").append(" greater than <span class=\"subrecord_min\"></span>");
addMinTrigger(jq);
}
function addMinTrigger(jq) {
jq.each(function () {
var me = $(this);
var prev = me.prev(".".concat(fieldName, "_subrecord_container"));
var min = me.find(".subrecord_min");
if (prev.length) {
var cur = me.find(jqueryUniversalChangeSupportedTags).filter(":first");
var field = prev.find(jqueryUniversalChangeSupportedTags).filter(":first").get(0);
jqueryUniversalChange(win, field, function () {
minTrigger(field, cur, min);
return true;
});
minTrigger(field, cur, min);
} else {
// nothing exists show "min" text
min.html("0");
}
});
function minTrigger(field, cur, min) {
var minVal = parseFloat($(field).val());
var curVal = parseFloat(cur.val());
min.html(minVal);
if (!isNaN(curVal) && minVal >= curVal) {
cur.val(minVal + 1);
cur.trigger("change");
}
}
}
function addAllRemove() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addRemove(subRecords);
addRemoveTrigger(subRecords);
}
function addRemove(jq) {
// jq object
jq.find(".remove_container").prepend("<a class=\"subrecord_remove\"><img title=\"Remove\" alt=\"remove\" src=\"/ats/css-base/remove.png\" /></a>");
}
function addRemoveTrigger(jq) {
jq.find(".subrecord_remove").click(function (e) {
_this.setAccess(win, false);
size.val(parseFloat(size.val()) - 1);
var me = $(this).closest(".subrecord_container");
var next = me.next(".subrecord_container");
me.remove();
if (rangeExtra) {
addMinTrigger(next);
}
});
}
}
},
"disableSubmitButtons": function disableSubmitButtons(win) {
win.$("input[type='submit']").attr("disabled", "disabled");
return true;
},
"eformOptionalEventHideFields": function eformOptionalEventHideFields(win, checkboxId) {
/**
* Helper function used to enable/disable a set of elements. Will set/remove 'disabled' attribute
* for all form fields, and will show/hide all elements iterated through.
*
* @param field an HTMLElement or jQuery object
* @param doEnable boolean flag indicating if item should be enabled/disabled
*/
function enable(field, doEnable) {
var formFields = $(field).find("input,select,textarea");
$(formFields).each(function (i, kid) {
if (doEnable) {
$(kid).prop("disabled", false);
} else {
$(kid).prop("disabled", true);
}
});
if (doEnable) {
$(field).show();
} else {
$(field).hide();
}
}
_this.onReady(win, function () {
var $ = win.$;
var checkbox = $("#".concat(checkboxId));
var topRow = checkbox.closest("tr");
var fieldsForEvent = topRow.nextUntil("tr.endEformEvent");
checkbox.change(function () {
var isChecked = checkbox.is(":checked");
enable(fieldsForEvent, isChecked);
});
checkbox.trigger("change");
});
}
};
if (_this.isDevMode) {
/**
* This method is called to initialize and return a DevLinks instance, which exposes
* methods used to interact with and alter behavior of dev links on page. Only one instance per context
* will be created (subsequent calls to this method will return cached instance).
*
* @param {Window} win the context Window
*/
_this.initDevLinks = function () {
function DevLinks(win) {
/**
* Flag indicating if base records should be interacted with (if true) or if alt records should
* be interacted with (if false).
*
* @private
*/
this._useBase; // use for referencing instance in inner/non-member functions
var _devLinks = this; // member functions
/**
* Is called to set the flag indicating whether alt records or base records should be interacted
* with when using dev tools. Each call to this method will also ensure that proper click
* handlers are in place for current page dev tools. The default state is to interact with
* alt records, unless a value of true for useBase is provided.
*
* @param {boolean} [useBase] (optional) if present and true, will interact with base records, and will interact with alt records otherwise
*/
this.setToolAltOption = function (useBase) {
if (_devLinks._useBase === void 0) {
_devLinks._useBase = useBase === true;
} else if (useBase !== void 0) {
_devLinks._useBase = useBase === true;
}
/**
* Is called to enable dev tools to interact with alt records (this is the default behavior).
*/
function enableAlts() {
// will now use alts
_devLinks._useBase = false;
$("div.devmenu a").css({
"background": "#eee"
});
$("div.devmenu a.alttool").each(function () {
var me = $(this);
var href = me.attr("href");
href = href.replace("&usealt=N", "");
me.attr("href", href);
});
}
/**
* Is called to enable dev tools to interact with base records (this is the NON-default behavior,
* and should be treated as potentially risky).
*/
function enableBase() {
// will now use base
_devLinks._useBase = true;
$("div.devmenu a").css({
"background": "orange"
});
$("div.devmenu a.alttool").each(function () {
var me = $(this);
var href = me.attr("href"); // ensure that param has not already been set
href = href.replace("&usealt=N", "");
href = href + "&usealt=N";
me.attr("href", href);
});
}
$("a.dragalt").unbind("click.devtools").bind("click.devtools", function () {
enableAlts();
win.alert("Tools will modify the alt record (default behavior).");
});
$("a.dragbase").unbind("click.devtools").bind("click.devtools", function () {
enableBase();
win.alert("Tools will now modify the base records (for all companies)! \n" + "Danger, this will effect all pages until you log-out or set it back to alt!");
});
if (_devLinks._useBase) {
enableBase();
} else {
enableAlts();
}
}; // initialization and non-member-function definitions
var $ = checkJQuery(win, win.$);
var devDivId = "devdivid"; // cached value of window scroll value used in initDevLinks
var yOffset = 0;
$.extend($.fn.disableTextSelect = function () {
return this.each(function () {// if ($.browser.mozilla) {//Firefox
// $(this).css('MozUserSelect', 'none');
// } else if ($.browser.msie) {//IE
// $(this).bind('selectstart', function () {
// return false;
// });
// } else {//Opera, etc.
// $(this).mousedown(function () {
// return false;
// });
// }
});
}); // after clicking a link scroll back down (but not in the pop-up)
if (yOffset && yOffset != win.yOffset) {
_this.onReady(win, function () {
win.scrollTo(0, yOffset); // only do this once (after clicking a link)
yOffset = 0;
});
}
function addDevDivPopupLoading() {
// add the content
var devDiv = "<div id=\"" + devDivId + "\" style='display: none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>";
$("body").children(":last").after(devDiv); // refresh the page on close
_this.addToolboxFunction(win, devDivId + "_close", function () {
win.yOffset = typeof win.pageYOffset == "number" ? win.pageYOffset : win.document.documentElement ? win.document.documentElement.scrollTop : win.document.body.scrollTop;
yOffset = win.yOffset;
$("body").html("<h1>Reloading...</h1>");
win.location.reload();
});
}
this.activateDevLink = function () {
var me = $(this);
var href = me.attr("href");
if (href) {
if (!me.hasClass("newwindow")) {
var sdata = null;
var hijack = true;
var hijackStayOpen = true;
var devmode = true; // ajax to fill in pop-up
var fullHijack = me.hasClass("wizarddevlink");
var noHijack = me.hasClass("search");
_this.addToolboxFunction(win, devDivId, function () {
// display the result of submitting in the pop-up?
if (fullHijack) {
// wizard
ajaxFillinPopup(win, devDivId, href, sdata, hijack, hijackStayOpen, devmode);
} else {
if (!noHijack) {
// submit and done
ajaxFillinPopup(win, devDivId, href, sdata, hijack, false, devmode);
} // submit to another page
else {
ajaxFillinPopup(win, devDivId, href, sdata, false, false, devmode);
}
}
}); // show a pop-up
_this.showPopup(win, devDivId);
return false;
}
}
return true;
};
function devPopups() {
$("a.devmenulink").each(function () {
this.onclick = _devLinks.activateDevLink;
});
}
function posArrows() {
// what is currently being dragged
var effectWhatFieldId = null; // reset drag if outside
win.document.body.onmouseup = function () {
return effectWhatFieldId = null;
}; // side-by-side
if (win.fieldDelimiter == "td") {
$("div.devfieldmenu").each(function () {
var me = $(this).closest("td");
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var width = me.width();
var height = me.height() - 5;
var demHor = "width: 10px; height: " + height + "px;";
var demVer = "width: " + width + "px; height: 10px;";
var styleDivVer = "style=\"position: absolute;" + demVer + "text-align: center;float: left;clear: both;\"";
var styleDivHor = "style=\"position: absolute;" + demHor + "\"";
var styleLinkVer = "style=\"display: block;" + demVer + "\"";
var styleLinkHor = "style=\"display: block;" + demHor + "overflow: hidden;\"";
var styleImgHor = "style=\"border: 0; padding-top: " + (height / 2 - 30) + "px;\"";
var classStr = ".uparrow,.rightcon,.leftarrow,.downcon";
var upLeftRight = "<div class=\"uparrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/up.png\"/></a></div><div class=\"leftarrow\" " + styleDivHor + "><a " + styleLinkHor + " href=\"\"><img " + styleImgHor + " src=\"/ats/css-base/left.png\"/></a></div><div class=\"rightcon\" style=\"left: " + (width - 5) + "px; position: relative;\"> <div class=\"rightarrow\" " + styleDivHor + "><a " + styleLinkHor + " href=\"\"><img " + styleImgHor + " src=\"/ats/css-base/right.png\"/></a></div></div>"; // IE needs the extra div because position: absolute elements don't display: block (like they should)
var down = "<div class=\"downcon\"><div class=\"downarrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/down.png\"/></a></div></div>"; // register start of drag
var menu = $(this);
menu.disableTextSelect();
menu.get(0).onmousedown = function () {
return effectWhatFieldId = myGuiFieldId;
}; // handle drag end
var endhref = "/ats/admin/drag_move_field.jsp?end_field_id=" + myGuiFieldId; // show links on hover
// lazy register me.hover() b/c IE is slow to register
me.get(0).onmouseover = function (e) {
// derigester on first hit
me.get(0).onmouseover = null; // real event
me.hover(function (e) {
// only when active drag
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
me.prepend(upLeftRight);
me.append(down); // trigger end of drag
me.children(classStr).mouseup(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
var href = endhref + "&start_field_id=" + effectWhatFieldId + "&dir=" + $(this).attr("class").replace(/arrow/, "") + "&usealt=" + (_devLinks._useBase ? "N" : "Y"); // ajax to fill in pop-up
_this.addToolboxFunction(win, devDivId, function () {
return ajaxFillinPopup(win, devDivId, href);
});
_this.showPopup(win, devDivId);
}
});
}
}, function () {
// clear arrows on leaving
me.find(classStr).remove();
});
me.trigger("mouseover");
};
});
} else {
// regular formpage
$("div.devfieldmenu").each(function () {
var me = $(this).closest("tr");
var th = me.find("th");
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first");
if (myGuiFieldId.length) {
myGuiFieldId = myGuiFieldId.eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
} else {
return;
}
var demVer = "width: " + th.width() + "px; height: 1.5em; left: 0;";
var styleDivVer = "style=\"position: absolute;text-align: center;" + demVer + "\"";
var styleLinkVer = "style=\"" + demVer + "display: block;\"";
var classStr = ".uparrow,.downcon";
var up = "<div class=\"uparrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/up.png\"/></a></div>";
var down = "<div class=\"downcon\"><div class=\"downarrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/down.png\"/></a></div></div>"; // register start of drag
var menu = me.find("div.devmenu");
menu.disableTextSelect();
menu.get(0).onmousedown = function () {
return effectWhatFieldId = myGuiFieldId;
}; // register end of drag
var endhref = "/ats/admin/drag_move_field.jsp?end_field_id=" + myGuiFieldId; // show links on hover
// lazy register me.hover() b/c IE is slow to register
me.get(0).onmouseover = function (e) {
// derigester on first hit
me.get(0).onmouseover = null; // use jquery to make it easy
me.hover(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
th.prepend(up);
th.append(down); // trigger events
me.find(classStr).mouseup(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
// href
var href = endhref + "&start_field_id=" + effectWhatFieldId + "&dir=" + $(this).attr("class").replace(/arrow/, "") + "&usealt=" + (_devLinks._useBase ? "N" : "Y"); // ajax to fill in pop-up
_this.addToolboxFunction(win, devDivId, function () {
return ajaxFillinPopup(win, devDivId, href);
}); // show a pop-up
_this.showPopup(win, devDivId);
}
});
}
}, function () {
return me.find(classStr).remove();
});
me.trigger("mouseover");
};
});
} // regular form page
}
function dependTool() {
// for all depend links on fields`
$("a.dependtool").unbind().click(function () {
var mymenu = $(this).closest("div.devfieldmenu");
var parentGuiFieldId = $(this).closest("div.devmenu").find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var dependValue = win.prompt("For what value?"); // orignating make a refresh stop link
mymenu.replaceWith("<a onclick='window.location.reload()'>Stop</a>"); // replace all field menus on page with "make depend" link
$("div.devfieldmenu").replaceWith(function () {
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var result = "<a class='makedependlink'" + " href='/ats/admin/field_make_depend.jsp" + "?PARENT_GUI_FIELD_ID=" + parentGuiFieldId + "&GUI_FIELD_ID=" + myGuiFieldId + "&value=" + encodeURIComponent(dependValue) + "&ajax=Y" + "&usealt=" + (_devLinks._useBase ? "N" : "Y") + "' >" + " Make Dependant</a>";
return result;
}); // silently go to page
$("a.makedependlink").unbind().click(function (e) {
var me = $(this);
e.preventDefault();
var url = $(this).attr("href");
$.get(url, null, function (data, rstatus) {
if (rstatus == "success") {
me.remove();
} else {
win.alert("failed to make dependant, check your console and get a developer");
}
});
return false;
});
});
}
function hideDevLinks() {
$("a.hidedev").click(function (e) {
e.preventDefault();
hideDevLinks();
});
function hideDevLinks() {
$(".debug,.devmenu").fadeOut();
}
}
function showHiddenLinks(win) {
$(".showhidden").click(function (e) {
e.preventDefault();
if (win.location.search == "") {
win.location.search = "?showhidden=Y";
} else {
if (win.location.search.match(/showhidden=Y/)) {
win.location.search = win.location.search.replace(/[\?\&]showhidden=Y/, "");
} else {
win.location.search += "&showhidden=Y";
}
}
});
}
function autoAltCompanyId() {
var alt = $("select[name='ALT_COMPANY_ID']");
if (alt.length && !alt.val()) {
alt.val("<%=companyId%>");
}
}
function showFieldNames() {
$("a.showFieldNames").click(function () {
return $("span.fieldName").show();
});
}
_this.onReady(win, function () {
if (!win.devDone) {
addDevDivPopupLoading();
_devLinks.setToolAltOption();
showFieldNames();
posArrows();
dependTool();
devPopups();
hideDevLinks();
showHiddenLinks(win);
autoAltCompanyId();
} else {// if ($.browser.msie && $.browser.version < 9) {
// //TODO: #modal
// //$("#simplemodal-container .devmenu").hide();
// }
}
win.devDone = true;
});
}
return function (win) {
if (!win._ss_devLinks) {
win._ss_devLinks = new DevLinks(win);
}
return win._ss_devLinks;
};
}();
}
/**
* Class used to construct and render a hierarchical set of checkboxes with cascading click functionality.
*
* @param win
* @param scriptId
* @param json
* @constructor
*/
function HierCheckboxModel(win, scriptId, json) {
var $ = win.$;
/**
* The root node object containing node hierarchy.
* @type {{children: Array}}
* @private
*/
this._rootNode = {
"children": []
};
/**
* Collection of ALL node instances.
* @type {Array}
* @private
*/
this._allNodes = [];
/**
* Counter used to generate unique index for all nodes.
* @type {number}
* @private
*/
this._counter = 0;
var _this = this;
function cascadeChecks(field, index) {
function cascadeNodeChecks(node) {
var children = node.children;
for (var i = 0; i < children.length; i++) {
children[i].field.checked = node.field.checked;
cascadeNodeChecks(children[i]);
}
}
lib.setAccess(win, false);
var node = _this._allNodes[index];
cascadeNodeChecks(node);
if (node.field.checked) {
var parent = node.parent;
while (parent != null && parent.field != null) {
parent.field.checked = node.field.checked;
parent = parent.parent;
}
}
}
/**
* Renders node, recursing through all kids, if present, and appending HTML to parent provided.
*
* @param parent parent HTML element to append generated HTML to
* @param parentNode parent node object
* @param json JSON containing node data
* @private
*/
function _doRender(parent, parentNode, json) {
var node = json.node;
var kids = json.children;
parentNode = _renderListItem(node, _this._counter++, parentNode);
$(parent).append(parentNode.html);
if (kids.length > 0) {
var html = $("<ul></ul>");
$(parentNode.html).append(html);
$.each(kids, function (i, kid) {
return _doRender(html, parentNode, kid);
});
}
}
/**
* Is called to generate LI tag containing checkbox and caption (or a link, if a URL is present in
* node JSON).
*
* @param node the JSON object containing info used to render checkbox
* @param index the unique counter value for this instance
* @param rootNode the parent node for this instance
* @param [imgSrc] optional - if present, renders an image link
* @param [expandAction] optional - if present, is Lib funnction to call on click
*
* @returns {{html: (*|jQuery|HTMLElement), field: *, children: Array, parent: *}} new node object
* @private
*/
function _renderListItem(node, index, rootNode, imgSrc, expandAction) {
var name = node.name;
var value = node.value;
var checked = node.isChecked;
var caption = node.caption;
var url = node.url; // ensure values are null rather than undefined if not provided (unsure if any explicit null-checks occur below)
imgSrc = imgSrc === void 0 || imgSrc == "null" ? null : imgSrc;
expandAction = expandAction === void 0 || expandAction == "null" ? null : expandAction;
var listItem = $("<li></li>"); // the list item content item
var item;
if (imgSrc != null && expandAction != null) {
item = $("<a></a>").attr("href", "#".concat(value));
$(item).click(function (event) {
try {
return lib[expandAction](win, value, index);
} catch (e) {
_log(e);
}
});
var img = $("<img />").attr("border", "0").attr("src", imgSrc);
$(item).append(img);
} else if (imgSrc != null) {
item = $("<img />").attr("src", imgSrc).attr("border", "0");
}
if (item) {
$(listItem).append(item);
}
var input = $("<input />").attr("type", "checkbox").attr("name", name).attr("value", value);
if (checked) {
$(input).attr("checked", "checked");
}
$(input).click(function (event) {
cascadeChecks(this, index);
});
$(listItem).append(input);
if (!url) {
$(listItem).append(win.document.createTextNode(caption));
} else {
url = url.indexOf("http://") == 0 ? url : "http://" + url;
var a = $("<a></a>").attr("target", "_blank").attr("href", url).text(caption);
$(listItem).append(a);
}
var newNode = {
"html": listItem,
"field": input[0],
"children": [],
"parent": rootNode
};
newNode.parent.children.push(newNode);
_this._allNodes.push(newNode);
return newNode;
}
/**
* Is called to assemble checkboxes and inject into DOM.
*/
this.render = function () {
var script = $("script#".concat(scriptId));
json = $.parseJSON(json);
var ul = $("<ul></ul>");
_doRender(ul, _this._rootNode, json);
$(ul).insertAfter(script);
};
}
/**
* Default globaal error handler - redirects to error.jsp.
*
* @param msg
* @param url
* @param ln
*/
function handleError(msg, url, ln) {
_log(new Error(msg), true); // if (top.frames.length > 1 && top.frames[1].name == 'sss_dynomite') {
// top.sss_dynomite.window.document.location.replace(
// '/ats/jserror.jsp?msg=' + escape(msg) + '&url=' + escape(url) + '&line=' + ln
// );
// if (!_this.loaded) {
// top.document.location.replace(
// '/ats/error.jsp?msg=' +
// 'There+was+an+internal+error.++You+have+been+logged+out.' +
// '++Please+close+all+browsers+and+try+again.&showback=N'
// );
// self.open(
// '/ats/logout.jsp?missedlogout=Y', 'Logout',
// 'location=no,menubar=no,titlebar=no,personalbar=no,height=1,width=1');
// }
// }
// else {
// top.document.location.replace(
// '/ats/error.jsp?msg=' +
// 'There+was+an+internal+error.++You+have+been+logged+out.' +
// '++Please+close+all+browsers+and+try+again.&showback=N'
// );
// self.open('/ats/jserror.jsp?msg=' + escape(msg) + '&url=' + escape(url) + '&line=' + ln + '&closeWindow=Y', 'jserror');
// self.open('/ats/logout.jsp?missedlogout=Y', 'Logout', 'location=no,menubar=no,titlebar=no,personalbar=no,height=1,width=1');
// }
}
/**
* Error handler that reports error without redirecting user.
* @param msg
* @param url
* @param ln
*/
function displayError(msg, url, ln) {
_log(msg);
} // do NOT add window.onerror if addGlobalErrorHandler has been set to explicit false
window.onerror = init.addGlobalErrorHandler === false ? null : this.isDevMode ? displayError : handleError; // add lib properties as instance properties
$.each(lib, function (name, val) {
return _this[name] = val;
});
_this.perform_cookie_test();
onLoadCallback.call(this, this); // send in 'lib' instance as arg to onLoad
this.loaded = true;
}
|
console-api |
log |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21231)
Message:
JQMIGRATE: Migrate is installed with logging active, version 1.4.1
|
console-api |
debug |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 16080)
Message:
Assigning value to moduleName SelectPlusField [object Object]
|
console-api |
debug |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 16080)
Message:
Assigning value to moduleName Lib function Lib(init) {
// see if instantiation should return global instance
if (init && init.getGlobalInstance && window.top._lib) {
return window.top._lib;
} // check for and set global instance
if (!window.top._lib) {
window.top._lib = this;
} // It's not good form, but these locals are used to help with staged lookup.
var isActiveDirectory = init.isActiveDirectory; // <%= (companyRecord.get("AUTH_URL") != null) %>;
var companyId = init.companyId; // <% out.println("'" + companyId + "'" + ";"); %>
var sessionId = init.sessionId; // '<%= key %>'
var onLoadCallback = init.onLoad || function () {}; // function to call when Lib instance has been assembled
this.isDevMode = configuration.developmentMode; // flag indicating if all JS components have been loaded...affects behavior of error reporting
this.loaded = false;
var _this = this; // collection of nodes used in setParent() and assureChildrenMatch()
var parents = []; // collection of nodes used in setParent() and assureParentSelected()
var kids = []; // collection used in initPageCollapse() and pageCollapse()
var hiddenDivs = {}; // collection used in getCheckboxElement() and setCheckboxElements()
var checkboxElements = [];
var jqueryUniversalChangeSupportedTags = ":input[type!=hidden]";
var jqueryUniversalChangeSupportedEvents = ["change", "select", "click", "blur"]; // cached result of call to perform_cookie_test()
var cookie_test = false;
/**
* Selector string used to serve as context for calls to addDependentField. If null, will use document
* as context (is used to search for a field ONLY in context of modal content).
*
* @type {string}
*/
var dependentFieldCtx = null;
/**
* Simple function used to log message strings and Error instances to the console, if the console object
* is available (may not be in older browser environments). Will only log if isDevMode is true.
*
* @param {string|Error} message
* @param {boolean} [override] if present and true, will log whether or not in dev mode
*/
var _log = function log(message, override) {
return logger.log(message);
}; // init accessNextPage and loading flags
setGlobalData("Lib.accessNextPage", true);
setGlobalData("Lib.loading", false); // internal helper functions
/**
* Sets a global attribute value. Will log and ignore if unable to do so (i.e. window.top is disposed).
*
* @param key
* @param value
*/
function setGlobalData(key, value) {
_log("Setting '".concat(key, "' attribute to value '").concat(value, "'"));
try {
if (window && window.top) {
$(window.top).data(key, value);
} else {
_log("Can not set '".concat(key, "' attribute with value '").concat(value, "', top window is not available."));
}
} catch (e) {
// getting 'Can't execute code from a freed script' errors in IE...just log and return
_log(new Error("Can not set '".concat(key, "' attribute with value '").concat(value, "': ").concat(e.message)));
}
}
/**
* Gets a global attribute value. Will log and return null if unable to do so (i.e. window.top is disposed).
*
* @param key
* @returns {*}
*/
function getGlobalData(key) {
_log("Getting '".concat(key, "' attribute value."));
try {
if (window && window.top) {
var value = $(window.top).data(key);
_log("Attribute '".concat(key, "' has value '").concat(value, "'"));
return value;
} else {
_log("Can not get '".concat(key, "' attribute value, top window is not available."));
return null;
}
} catch (e) {
// getting 'Can't execute code from a freed script' errors in IE...just log and return null
_log(new Error("Can not get '".concat(key, "' attribute value: ").concat(e.message)));
return null;
}
}
/**
* Ensures that needed jQuery plugins have been loaded. Performs synchronous loading if not found.
* Returns reference to $.
*
* @param {Window} win context window
* @param {jQuery} jq the jQuery object being examined
* @returns {jQuery}
*/
function checkJQuery(win, jq) {
return jq || win.$ || $;
}
/**
* Obtains the Modal instance for the given window namespace.
*
* @param win
* @returns {Modal}
*/
function getModal(win) {
return win.document.thismodal;
}
/**
* Is called to create and open a new Modal instance using a set of default properties. The init object will
* override any defaults. An additional optional boolean may be provided to specify if instance should
* be assigned to the global modal variable (i.e. make new instance retrievable in call to {@link getModal()}.
*
* @param {Window} win the context Window
* @param {Object} init object used to initialize Modal (may contain 'attributes' property that is iterated
* through and each added to Modal attributes)
* @param {boolean} [makeGlobal] optional flag indicating if this instance should be set as global instance (default is false)
*
* @returns {Modal}
*/
function createModal(win, init, makeGlobal) {
// is called to perform style fixes on modal after it is opened
function fixDisplay(modal) {
doModalContentFix(win, modal);
}
function resizeHandler(e) {
_log("Doing resize!!!");
triggerResize(win, false);
}
init = init || {};
init.paddingTop = 80;
init.onOpen = mergeFunctions(init.onOpen, function (modal) {
$(win).on("resize", resizeHandler);
fixDisplay(modal);
});
init.onClose = mergeFunctions(init.onClose, function () {
return $(win).off("resize", resizeHandler);
});
init.openOnCreate = false; // do NOT allow for creation before setting global instance
init.context = win;
var modal = Modal.createModal(init);
if (modal) {
if (makeGlobal) {
win.document.thismodal = modal;
}
modal.open();
}
return modal;
}
/**
* Performs style/behavior fixes on Modal and content.
*
* @param win
* @param modal
*/
function doModalContentFix(win, modal) {
var content = $(modal.getContent(true));
var $content = $(content);
$content.closest(".vex").css("padding-top", "40px");
$content.closest(".vex").find(".vex-dialog-input").css("overflow", "auto"); // also, remove PageParagraphContainer/PageMainContainer ids to remove static CSS widths
$content.find("#PageParagraphContainer").removeAttr("id");
$content.find("#PageMainContainer").removeAttr("id"); // give buttons same LnF as Modal buttons
$content.find("input[type=\"submit\"], input[type=\"reset\"], input[type=\"file\"]").addClass("vex-dialog-button vex-dialog-button-primary ss-modal-ok").css({
"margin-top": "5px",
"float": "none"
}); // Prevent submit button from being clicked multiple times
$content.find("input[type=\"submit\"]").click(function () {
var $footContainer = $content.find("#footContainer");
var $pagebuttons = $footContainer.find(".pagebuttons");
$pagebuttons.hide();
$footContainer.append($("<img src=\"https://cdn.searchsoft.net/images/loading.gif\" class=\"preventMultipleSubmitButtonClickSpinner\" />"));
});
$content.find("input[type=\"button\"]").addClass("vex-dialog-button vex-dialog-button-secondary ss-modal-cancel").css({
"margin-top": "5px",
"float": "none"
});
$(".linkbutton, .wizardlink").click(function () {
return win.setTimeout(function () {
doModalContentFix(win, modal);
triggerResize(win, false);
}, 15);
});
}
/**
* Is called to do an operation with the current Modal instance, if it is non-null and only if its open,
* if the ifOpen flag is true. The callback will be provided the Modal instance and reference to the Modal
* content (as a jQuery object) as args (i.e. function(modal, jq) { // do something } ).
*
* @param win
* @param ifOpen
* @param fn
*/
function doModalOp(win, ifOpen, fn) {
var modal = getModal(win);
if (!modal) {
return;
}
if (!modal.isOpen() && ifOpen) {
return;
}
try {
fn(modal, modal.getContent(true));
} catch (e) {
// this could POTENTIALLY be called on a modal in a frame that has expired...catch, log and continue
_log(e);
}
}
/**
* Is called to trigger events and handle common behavior when content has changed such that re-flow or
* resizing of content should occur.
*
* @param win
* @param {boolean} [doTrigger] optional boolean flag indicating if 'resize' event should be triggered (default is true)
* @param {boolean} [keepWidth] optional boolean flag indicating if resizing should constrain width (default is false)
*/
function triggerResize(win, doTrigger, keepWidth) {
doTrigger = doTrigger !== false;
if (doTrigger) {
$(win).triggerHandler("resize");
}
keepWidth = keepWidth === true;
doModalOp(win, true, function (modal, content) {
var queue = win["_triggerResizeQueue"] || {
/**
* @type {number}
*/
"timeoutId": null
};
win["_triggerResizeQueue"] = queue;
if (queue.timeoutId !== null) {
window.clearTimeout(queue.timeoutId);
}
queue.timeoutId = window.setTimeout(function () {
try {
modal.resizeContent(keepWidth);
} catch (e) {
// as this being called in a timeout, modal may be contained in an expired frame...
_log(e);
}
}, 15);
});
}
function isChecked(win, id) {
var elem = getCheckboxElement(win, id);
return elem.checked;
}
function getCheckboxElement(win, id) {
return checkboxElements[id];
}
function checkCheckBox(win, id, val, doParent) {
var elem = getCheckboxElement(win, id);
if (elem) {
elem.checked = val;
if (doParent) {
lib.assureParentSelected(win, id);
}
}
return true;
}
function emailCheck(emailStr, win, field) {
/* The following pattern is used to check if the entered e-mail address
fits the user@domain format. It also is used to separate the username
from the domain. */
var emailPat = /^\s*(.+)@(.+)$/;
/* The following represents chars _not_ allowed in an local part of an address
These characters include ( ) < > @ , ; : \ " . [ ] Where . is later allowed
back in. */
var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
/* The following string represents the range of characters allowed in a
username or domainname. It really states which chars aren't allowed.*/
var validChars = "[^\\s".concat(specialChars, "]");
/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes). E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */
var quotedUser = "(\"[^\"]*\")";
/* The following string represents an atom (basically a series of non-special characters.) */
var atom = "".concat(validChars, "+");
/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */
var word = "(".concat(atom, "|").concat(quotedUser, ")"); // The following pattern describes the structure of the user
var userPat = new RegExp("^".concat(word, "(\\.").concat(word, ")*$"));
/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. Domain atom must be two or
more chars and not start or end with a '-' */
var domainAtom = "[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9]+)*";
var domainPat = new RegExp("^".concat(domainAtom, "(\\.").concat(domainAtom, ")+\\s*$"));
/* The following pattern applies for domains that are IP addresses,
rather than symbolic nam es. E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */
var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
/* Finally, let's start trying to figure out if the supplied address is valid. */
/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */
var matchArray = emailStr.match(emailPat);
if (matchArray == null) {
/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */
invalidField(win, field, "The email address seems incorrect (check @ and .'s)");
return false;
}
var user = matchArray[1];
var domain = matchArray[2]; // Start by checking that only basic ASCII characters are in the strings (0-127).
for (var i = 0; i < user.length; i++) {
if (user.charCodeAt(i) > 127) {
invalidField(win, field, "The email username contains invalid characters.");
return false;
}
} // See if "user" is valid
if (user.match(userPat) == null) {
// user is not valid
invalidField(win, field, "The email username doesn't seem to be valid.");
return false;
}
/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */
var IPArray = domain.match(ipDomainPat);
if (IPArray != null) {
// this is an IP address
for (var _i = 1; _i <= 4; _i++) {
if (IPArray[_i] > 255) {
invalidField(win, field, "Email destination IP address is invalid!");
return false;
}
} // the remain tests are not valid
return true;
} // Domain is symbolic name. Check if it's valid.
var domArr = domain.match(domainPat);
if (domArr == null) {
invalidField(win, field, "The email domain name does not seem to be valid.");
return false;
} // confirm that tld is two more more, note sub-group is always assigned last match
if (!(domArr[1].length > 2)) {
invalidField(win, field, "The email address has an invalid tld domain. Are you missing .com?");
return false;
} // Confirm domain is not overly long
if (domain.length > 255) {
invalidField(win, field, "The email address has to long a domain name.");
return false;
} // Confirm peices of domain are not indivuial to long
for (var _i2 = 0; _i2 < domArr.length - 1; _i2++) {
if (domArr[_i2].length > 63) {
invalidField(win, field, "The email address domain name is to long.");
return false;
}
} // If we've gotten this far, everything's valid!
return true;
}
function getFieldValue(win, field) {
// Passing win as an argument to fix "Permission denied" error in IE
// SSOFT-5666
var $ = win.$;
var value = "";
var type = field.type || $(field).attr("type");
if (type) {
if (type.indexOf("select-") >= 0) {
if (field.selectedIndex >= 0) {
value = field.options[field.selectedIndex].value;
}
} else if (type.indexOf("check") >= 0 || type.indexOf("radio") >= 0) {
if (field.checked) {
value = field.value;
}
if (field.length) {
for (var j = 0; j < field.length; j++) {
if (field[j].checked) {
value = field[j].value;
}
}
}
} else {
value = field.value;
}
} else if (field.length) {
// I think this code is making an assumption
// that if there is no 'type' then it must be a
// checkbox.
for (var _j = 0; _j < field.length; _j++) {
if (field[_j].checked) {
value = field[_j].value;
}
}
}
if (value == null) {
value = "";
}
return value;
}
/**
* Replaces a old Field's listeners' with a pointer to the new field.
**/
function reassignFieldListeners(oldField, newField) {
// find the form, assume all fields are in the same form
var form;
if (oldField.length) {
form = oldField[0].form;
} else {
form = oldField.form;
} // if we couldn't find the form, give up. This means were using an oldField
// not in a form anymore. This should never happen.
if (!form) {
return;
}
for (var i = 0; i < form.validatorFields.length; i++) {
if (form.validatorFields[i] == oldField) {
form.validatorFields[i] = newField;
}
}
for (var _i3 = 0; _i3 < form.maskValidatorFields.length; _i3++) {
if (form.maskValidatorFields[_i3] == oldField) {
form.maskValidatorFields[_i3] = newField;
}
}
}
/**
* Checks newField against the listeners of oldField.
**/
function validNewField(win, oldField, newField) {
// Hack that fixes https://peopleadmin.atlassian.net/browse/SSOFT-5354?focusedCommentId=231565&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-231565
if (newField[0] === undefined) {
newField[0] = oldField[0];
} // find the form
var form;
if (oldField.length) {
form = oldField[0].form;
} else {
form = oldField.form;
} // if we couldn't find the form, say its valid. This means were validating
// against a field not in a form anymore. This should never happen.
if (!form) {
return true;
} // run over all validation function and run them against the new field
for (var i = 0; i < form.validatorFields.length; i++) {
if (form.validatorFields[i] == oldField) {
if (!form.validatorFunctions[i](win, newField)) {
return false;
}
}
}
for (var _i4 = 0; _i4 < form.maskValidatorFields.length; _i4++) {
if (form.maskValidatorFields[_i4] == oldField) {
if (!form.maskValidatorFunctions[_i4](win, newField, form.maskValidatorMasks[_i4])) {
return false;
}
}
}
return true;
}
/**
* Run all validator functions for a specified form.
**/
function validFields(win, form) {
win.runningValidFields = true;
for (var i = 0; i < form.validatorFunctions.length; i += 1) {
// if the field is not in the checking form anymore ignore it
if (!fieldInForm(form, form.validatorFields[i])) {
continue;
} // run the listeners
if (!form.validatorFunctions[i](win, form.validatorFields[i])) {
win.runningValidFields = false;
return false;
}
}
for (var j = 0; j < form.maskValidatorFunctions.length; j += 1) {
// if the field is not in the checking form anymore ignore it
if (!fieldInForm(form, form.maskValidatorFields[j])) {
continue;
} // run the listeners
if (!form.maskValidatorFunctions[j](win, form.maskValidatorFields[j], form.maskValidatorMasks[j])) {
invalidField(win, form.maskValidatorFields[j], "".concat(form.maskValidatorFields[j].value, " is not in the correct format."));
win.runningValidFields = false;
return false;
}
}
win.runningValidFields = false;
return true;
}
/**
* Test if a field is in a given form (wrapper).
**/
function fieldInForm(form, field) {
// defines a private function to do the real work
function fieldInFormReal(field) {
for (var i = 0; i < form.elements.length; i++) {
if (form.elements[i] == field) {
return true;
}
}
return false;
} // if field is not defined, claim it exists
if (!!!field) {
return true;
} // if array test for each
// if it has a length and not a type
if (field.length && !field.type) {
// when less than 500 check all fields
if (field.length < 500) {
for (var i = 0; i < field.length; i++) {
if (!fieldInFormReal(field[i])) {
return false;
}
}
} // performance hack for IE, if one exists all exist
else {
if (!fieldInFormReal(field[0])) {
return false;
}
}
return true;
} // field is defined check that it is in the form
return fieldInFormReal(field);
}
function getMultiNumberChecked(win, fields) {
var numberChecked = 0; // array of check-box, radio, option, or select
if (fields.length) {
for (var i = 0; i < fields.length; i++) {
// check-box, radio
if (fields[i].checked) {
numberChecked++;
} // option
else {
if (fields[i].selected) {
numberChecked++;
} // select
else {
if (fields[i].options) {
numberChecked += getMultiNumberChecked(win, fields[i].options);
}
}
}
}
} // select object
else if (fields.options && fields.options.length > 0) {
numberChecked = getMultiNumberChecked(win, fields.options);
} // single field
else if (fields.checked || fields.selected) {
numberChecked = 1;
}
return numberChecked;
}
/**
* Returns array of form objects that have an element that matches
* fieldName.
**/
function getFormObjects(win, fieldName) {
var result = [];
var forms = win.document.forms;
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
if (form.elements[fieldName]) {
result.push(form);
}
}
return result;
}
function stripSymbols(field) {
var value = field.value;
if (value !== undefined) {
field.value = value.replace(/(\$|\,|\(|\)|\&)/g, "");
}
}
function getFormattedDate(field, shortDate) {
var date = field.value.replace("-", "/");
var li = date.lastIndexOf("/");
if (date.length - li == 3) {
var cent = "20";
var yr = date.substring(li + 1, li + 3);
if (yr > "30") {
cent = "19";
}
date = date.substring(0, li + 1) + cent + yr;
}
return date;
}
function isValidDate(value, shortDate) {
var month;
var day;
var year;
var date;
var i;
for (i = 1; i < value.length; i++) {
var testValue = value.substring(i, i + 1);
if (isNaN(testValue) && testValue != "/" && testValue != "-" && testValue == " ") {
return false;
}
}
date = value;
if (date != "") {
i = date.indexOf("/");
if (i < 1) {
return false;
}
month = date.substring(0, i);
if (month.length < 1 || month.length > 2 || month.charAt(0) > "9" || month == 0 && i == 1) {
// || month.charAt(0)<'0'
return false;
}
if (month.substring(0, 1) == "0") {
month = month.substring(1, 2);
}
month = parseInt(month);
if (!shortDate) {
date = date.substring(i + 1);
i = date.indexOf("/");
if (i < 1) {
return false;
}
day = date.substring(0, i);
if (day.length < 1 || day.length > 2 || day.charAt(0) > "9") {
// || day.charAt(0)<'0'
return false;
}
if (day.substring(0, 1) == "0") {
day = day.substring(1, 2);
}
day = parseInt(day);
}
year = date.substring(i + 1);
if (year.length != 4 || year.charAt(0) < "0" || year.charAt(0) > "9") {
return false;
}
year = parseInt(year);
if (month < 1 || month > 12 || day < 1 || day > 31 || year < 1900 || year > 2299 || month == 2 && day > 29 || month == 2 && day == 29 && year % 4 != 0 || month == 4 && day > 30 || month == 6 && day > 30 || month == 9 && day > 30 || month == 11 && day > 30) {
return false;
}
}
return true;
}
function isValidBirthDate(field, shortdate, young, old) {
var result = true;
var birthValue = field.value;
if (shortdate) {
birthValue = birthValue.replace(/\//, "/01/");
}
var birthDate = new Date(birthValue);
var lowDate = new Date();
var highDate = new Date();
lowDate.setFullYear(lowDate.getFullYear() - old);
highDate.setFullYear(highDate.getFullYear() - young);
result = birthDate >= lowDate && birthDate <= highDate;
return result;
}
function isValidDateTime(field) {
var thisFieldValue = field.value;
var splitDate = thisFieldValue.split(" ");
if (splitDate.length != 3) {
return false;
}
if (!isValidDate(splitDate[0]), false) {
return false;
}
if (!isValidStandardTime(splitDate)) {
return false;
}
return true;
}
function isValidStandardTime(timeString) {
// We are expecting a 3-part date, time, and am/pm array
if (timeString.length != 3) {
return false;
}
if (timeString[1].length != 5) {
return false;
}
if (timeString[2].length != 2) {
return false;
}
var testValue = timeString[1].substring(0, 2);
if (isNaN(testValue)) {
return false;
}
if (timeString[1].charAt(2) != ":") {
return false;
}
var testValue = timeString[1].substring(3, 5);
if (isNaN(testValue)) {
return false;
}
if (timeString[2].toLowerCase() != "am" && timeString[2].toLowerCase() != "pm") {
return false;
}
return true;
}
function isValidNumber(num) {
var i;
var dc;
if (num.value != "") {
i = 0;
if (num.charAt(0) == "-") {
i = 1;
if (num.length == 1) {
return false;
}
}
dc = 0;
for (; i < num.length; i++) {
if (num.charAt(i) == ".") {
if (dc > 0 || i == num.length - 1) {
return false;
}
dc++;
} else if (num.charAt(i) < "0" || num.charAt(i) > "9") {
return false;
}
}
}
return true;
}
/**
* Adds fun (function) to element with an apporiate on change listener
*
* @param elem is dom
**/
function jqueryUniversalChange(win, elem, fun) {
var $ = win.$;
$(elem).bind(jqueryUniversalTriggerType(win, elem), fun);
}
function jqueryUniversalTriggerType(win, elem) {
// For SSOFT-5625
// In Internet Explorer 11/Edge, the attr call below was causing a "Permission denied" error
var $ = win.$;
var triggerType;
switch (elem.tagName.toUpperCase()) {
case "INPUT":
switch ($(elem).attr("type").toUpperCase()) {
case "RADIO":
case "CHECKBOX":
case "BUTTON":
triggerType = "click change";
break;
case "PASSWORD":
case "TEXT":
triggerType = "blur change";
break;
case "FILE":
triggerType = "change";
break;
default:
triggerType = "change select click blur";
break;
}
break;
case "TEXTAREA":
triggerType = "blur change";
break;
case "SELECT":
triggerType = "blur change";
break;
default:
triggerType = "change select click blur";
break;
}
return triggerType;
}
/**
* Is called to ensure that username conforms to rules and standards.
*
* @param win
* @param username
* @param password
* @returns {boolean}
*/
function checkFormatting(win, username, password) {
var p = password;
var u = username;
var message = "";
var result = true;
var low = 6;
if (companyId != "00008698" && !isActiveDirectory && win.document.location.href.indexOf("employee_form") < 0) {
// Account Information Page (Applicants can change just their username)
if ((p == null || p.value == "") && u != null && u.value != "") {
u = u.value;
if (u.length < low) {
message = "The username is invalid. Usernames must be at least ".concat(low, " characters in length, should not include spaces, and must not be identical to the password.");
invalidField(win, username, message);
result = false;
}
}
}
return result;
}
function makeTestCookie() {
document.cookie = "cookietest=yes;path=/";
}
function findTestCookie() {
if (document.cookie.length > 0 && window.navigator.cookieEnabled) {
var test = document.cookie.indexOf("cookietest=");
if (test !== -1) {
return true;
}
}
return false;
}
/**
* Toolbox, binds pop-up to a select box.
**/
function toolboxRegisterSelection(win, uid) {
var $ = win.$;
var actionSelect = $("#".concat(uid, "_action_select"));
var myForm = actionSelect.closest("form"); // add a content section if one does not exist
if (!myForm.find("#inlineContent").length) {
myForm.append("<div id=\"inlineContent\" style=\"height: 30ex\"></div>");
}
var onDefaultActionOrUndo = function onDefaultActionOrUndo() {
$("#inlineContent").html("").css("height", "30ex"); // Reactivate button-based tools
win.toolbox[uid]._parent.append(win.toolbox[uid]);
}; // HE-3345 (https://jira.powerschool.com/browse/HE-3345?focusedCommentId=2294798&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-2294798)
// Whenever undo button is clicked, removes the fields related to the previous selected value on Workflow Forms
$("form input:reset[name=\"undo\"]").click(function () {
return onDefaultActionOrUndo();
});
actionSelect.change(function () {
// what item is selected
var item = $("#".concat(uid, "_action_select option:selected")).attr("value");
var autoSubmit = false; // bail if default
if (item == "default") {
onDefaultActionOrUndo();
return false;
} else {
// Deactivate button-based tools
win.toolbox = win.toolbox || {};
win.toolbox[uid] = win.toolbox[uid] || $("#toolbox_".concat(uid));
win.toolbox[uid]._parent = win.toolbox[uid]._parent || win.toolbox[uid].parent();
$("#toolbox_".concat(uid)).remove();
} // is there a hidden div
if ($("#".concat(item)).length) {
// get content
var content = $("#".concat(item)).clone();
content.attr("class", content.attr("id"));
content.attr("id", "");
$("#inlineContent").html(" ").append(content);
content.show();
} // if no hidden content auto-submit
else {
autoSubmit = true;
}
toolboxRunFunction(win, item);
if (autoSubmit) {
// if no hidden content
win.document.forms[0].submit();
}
});
}
/**
* Toolbox, bind pop-up to "Go" button.
**/
function toolboxRegisterActionGo(win, uid) {
var $ = win.$; // bind to click of button
$("#".concat(uid, "_go")).click(function () {
var $ = win.$; // what item is selected
var item = $("#".concat(uid, "_action_select option:selected")).attr("value");
var autoSubmit = false; // bail on default action
if (item === "default") {
win.alert("Please select an action to perform.");
return false;
}
var allRecordsInTheListAllPagesSelected = $("select[name=\"ACTION_TYPE\"]").val() === "all";
if (allRecordsInTheListAllPagesSelected) {
// "Assign Document(s)" action
if (item === "RA00000002") {
win.alert("At most 100 recipients can be assigned eForms at a time. Please select no more than 100 recipients and try again.");
return false;
}
} else if ($("div.rs tbody :checkbox:checked").length === 0) {
// when no items selected bail
win.alert("Please select the records on which to perform the action.");
return false;
} // is there a hidden div
if ($("#".concat(item)).length) {
lib.showPopup(win, item);
} // if no hidden content auto-submit
else {
autoSubmit = true; // run action's funciton if exists
if (!toolboxRunFunction(win, item)) {
// no function add a hidden input option=option (as we are autosubmiting)
lib.addHiddenField(win, item, item);
}
}
if (autoSubmit) {
// if no hidden content
win.document.forms[0].submit();
}
});
}
function closePopupFirst(win, fun) {
Modal.closeAll(win, function () {
return fun(win);
});
}
/**
* Toolbox utilty, run function tied to a option. If the function is not
* defined return false.
**/
function toolboxRunFunction(win, fun) {
// confirm we have functions and this function is defined
if (!win.toolboxFunctions || !win.toolboxFunctions[fun]) {
return false;
} // run the function
try {
win.toolboxFunctions[fun]();
triggerResize(win);
} catch (e) {
return false;
}
return true;
}
/**
* Toolbox utility, add and enable a cancel button to popups
**/
function toolboxAddCancel(win, item) {
doModalOp(win, true, function (modal, content) {
modal.enableCancel(true); // need to ensure that all 'Cancel' button just close Modal (and not do history-back behavior)
$(content).find("input[name='cancel']").attr("onclick", "").click(function (e) {
e.preventDefault();
modal.close();
return false;
});
});
}
/**
* Returns true if the provided url and request data are valid for making an Ajax call to server. This is
* needed to overcome issues where library.js adds unintended behavior to elements, such that spurious
* Ajax calls are made.
*
* @param url url of Ajax call
* @param data query string or post data to be sent in request
* @return {boolean} true if the call can be made, false if it is not valid
*/
function canMakeAjaxCall(url, data) {
if (url == "#") {
_log("NOT making Ajax call, no valid URL provided (url is '#').");
return false;
} // put additional checks here as needed
return true;
}
/**
* Toolbox utility, fill-in a popup with data.
*
* @param win window object do operate in
* @param id of div to opeerate on in pop-up
* @param url of page to fetch and display
* @param hijack if to capture submit and then close pop-up
* @param hijackStayOpen if when capturing submit to dispaly the result
**/
function ajaxFillinPopup(win, id, url, sdata, hijack, hijackStayOpen, devmode) {
if (!canMakeAjaxCall(url, sdata)) {
return;
}
var $ = win.$; // add ajax notification for server
if (sdata == null) {
sdata = "ajax=y";
} else if (sdata.indexOf("ajax=") == -1) {
sdata += "&ajax=y";
} // avoid get length limit in IE
var method = "get";
if (sdata.length + url.length > 2000) {
sdata += "&fake_post=Y";
method = "post";
} // handle error
$(win.document).ajaxError(function (event, request, settings) {
return _log("Server error: ".concat(request.status, " url: ").concat(settings.url));
}); // if a popup
var modal = getModal(win);
if (modal && modal.isOpen()) {
dependentFieldCtx = ".searchsoft-modal"; // get content
$[method](url, sdata, function (data, rstatus) {
if (rstatus == "success") {
var modalContent = $(modal.getContent(true));
var selector = "div#inlineContent";
var content = $(modalContent).find("div#inlineContent");
if (!content.length) {
content = $(modalContent).find("div#".concat(id));
selector = content.length ? "div#".concat(id) : null;
}
modal.setContent(data, selector);
content = $(modal.getContent(true)); // will return a reference to content
afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode);
} else {
throw "AJAX error getting content";
}
}, "text").always(function () {
// reset after each call
dependentFieldCtx = null;
});
} // inline
else {
// get content
$.get(url, sdata, function (data, rstatus) {
if (rstatus == "success") {
var content = $("#inlineContent div.".concat(id)).html(data);
$("#inlineContent").css("height", "auto");
afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode); // initilize forms
lib.initForms(win);
} else {
throw "AJAX error getting content";
}
}, "text");
}
}
function afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode) {
var $ = win.$; // initilize forms
lib.initForms(win); // add what applicants to effect
lib.addCheckboxApplicants(win, id); // add/enable cancel
toolboxAddCancel(win, id); // add redirect if one does not exist
addMissingPopupRedirect(win, id); // for is_changed
alwaysIsChanged(win, id); // move buttons to top of devmenu items
if (devmode) {// TODO: #modal
/*
$("#simplemodal-container div#" + id + " div.pagebuttons").css({
'position': 'absolute',
'left': '50px',
'top': '-20px'});
*/
}
if (_this.isDevMode) {
// cause menu links to open in same window
content.find(".devmenulink, .wizardpopup").addClass("wizardlink").removeClass("wizardpopup");
content.find("div.rs a[href!='#ConfirmDelete'], div.rsrange a[href!='#ConfirmDelete']").addClass("wizardlink");
devmode = true;
} // hijack submit
if (hijack) {
// allows for fancy wizard stuff
hijackPopupSubmit(win, id, sdata, hijack, hijackStayOpen, devmode);
} else {
// simply provide a spinner
popUpFormSpinner(win);
}
var modal = getModal(win);
if (modal) {
doModalContentFix(win, modal);
} // wizard links
content.find(".wizardlink").click(function (e) {
var target = $(this).attr("href"); // do check for valid call BEFORE calling preventDefault and hiding form content
if (!canMakeAjaxCall(target, null)) {
return;
}
e.preventDefault();
if (modal) {
var _content = modal.getContent(true);
$(_content).find("form").hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
ajaxFillinPopup(win, id, target, null, hijack, hijackStayOpen, devmode);
return false;
});
if (hijackStayOpen) {
var button = content.find(".linkbutton");
button.each(function () {
this.onclick = function () {
return true;
};
$(this).click(function (e) {
var target = $(this).attr("href"); // do check for valid call BEFORE calling preventDefault and hiding form content
if (!canMakeAjaxCall(target, sdata)) {
return;
}
e.preventDefault();
if (modal) {
var _content2 = modal.getContent(true);
$(_content2).find("form").hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
ajaxFillinPopup(win, id, target, sdata, hijack, hijackStayOpen, devmode);
return false;
});
});
} // normal form styles
if (modal) {
lib.addStyleClasses(win, modal.getContent(true));
}
lib.addStyleClasses(win, "#inlineContent .".concat(id));
triggerResize(win);
}
/**
* Toolbox utility; adds a redirect parameter to a form if one does not exist on the page.
**/
function addMissingPopupRedirect(win, id) {
var $ = win.$;
if (!$("input[name='searchpage']").length) {
var loc = win.location;
doModalOp(win, true, function (modal, content) {
return $(content).find("form").append("<input type=\"hidden\" name=\"searchpage\" value=\"".concat(loc.pathname).concat(loc.search, "\" />"));
});
}
}
/**
* All pop-ups always submit
**/
function alwaysIsChanged(win, id) {
var $ = win.$;
doModalOp(win, true, function (modal, content) {
return $(content).find("input[name='is_changed']").val("true");
});
}
function popUpFormSpinner(win) {
var $ = win.$; // stops double submits for slow pages
doModalOp(win, false, function (modal, content) {
return $(content).closest("form").submit(function (e) {
// test that form is valid
var form = $(this);
var formObj = form.get(0);
var checkScript = formObj.onsubmit;
var result = !checkScript || checkScript.apply(formObj);
if (!(result === false)) {
if (form.attr("target") && form.attr("action").lastIndexOf("/servlet/jasper", 0) === 0) {
// there is a "target" outside of our frame; show a message with a "back to form" link
form.hide().after("<div id='reportmessage'><p>Your report will be downloaded shortly." + " This could take up to several minutes." + " Feel free to close this window.</p>" + "<p>If your report does not download shortly, please go back and try again.</p>" + "<p><a href='#' id='submitshowformagain'> Go Back to Form </a></p></div>");
$("#submitshowformagain").click(function (e) {
e.preventDefault();
form.next("#reportmessage").remove();
form.show();
return false;
});
} else {
form.hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
} else {
e.preventDefault();
}
return result;
});
});
}
/**
* Toolbox utility; hijacks submit of a pop-up and sends with AJAX.
*
* Useful for:
* recursive submitting pop-ups (aka Wizard)
* pages that return JavaScript (aka JSON)
*
* @param win window object to operate in
* @param id of div that gets ajax
**/
function hijackPopupSubmit(win, id, sdata, hijack, stayOpen, devmode) {
var $ = win.$;
doModalOp(win, false, function (modal, content) {
return $(content).find("form:not([target])").submit(function (event) {
// stop default
event.preventDefault(); // test that form is valid
var checkScript = $(this).prop("onsubmit");
if (checkScript && !checkScript.apply(this)) {
return;
} // useful nodes
// what data and to where
var data = $(this).serialize();
data += "&ajax=y";
var actionUri = $(this).attr("action"); // is this a searching form (method=GET)
var method = $(this).attr("method");
if (method == null || method.toUpperCase() == "GET") {
method = "get";
} else {
method = "post";
} // show loading text
var div = $("<div><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>").attr("id", id);
modal.setContent(div); // AJAX submit
$[method](actionUri, data, function (rdata, rstatus) {
if (rstatus == "success") {
if (stayOpen) {
var _content3 = div.html(rdata);
afterAjaxPopProcess(win, id, _content3, sdata, hijack, stayOpen, devmode);
} else {
if (/error has occured/.test(rdata) && devmode) {
div.html("<h1> Failure </h1>");
div.append("<p>CAUTION: Developer <a id='hijackretry' href='#'>Retry</a>. Will not provide success or failure message! Check your console</p>");
div.append("<xmp> ".concat(rdata, "</xmp>"));
$("#hijackretry").click(function () {
return $.post(actionUri, data);
});
} else if (/ajaxerror/.test(rdata)) {
div.html(rdata);
} else {
div.html("<h1> Success </h1>");
modal.close();
}
}
} else {
throw new Error("AJAX error");
}
}); // stop form submit
return false;
});
});
}
/**
* Utility for missed field pop-up.
* May be removed when classic is gone.
**/
function invalidField(win, field, message) {
// Fixes HE-3875
var $vexDialogInput = $(field).closest(".vex-dialog-input");
$vexDialogInput.find(".pagebuttons").show();
$vexDialogInput.find(".preventMultipleSubmitButtonClickSpinner").remove();
if (win.fieldPrompt) {
win.fieldPrompt(field, message);
} else {
win.alert(message);
}
}
/**
* Utility function to normalized an array.
* Returns the normalized array
**/
function trimArray(arrayToTrim) {
var result = [];
var zeroCount = 0;
for (var i = 0; i < arrayToTrim.length; i++) {
result[zeroCount++] = arrayToTrim[i];
}
return result;
}
function getNextUrlFromNavigationPulldown(win, backward) {
var pulldownFrame = win.parent.frames[0];
var pdf$ = pulldownFrame.$;
var dir = backward ? "prev" : "next";
var option = pdf$("select[name=navchoice] option:selected")[dir]();
if (option.length == 0) {
return;
}
var nextValue = option.val(); // FORMAT: sss_sub_content,/ats/application/detail/language,op=edit&APPLICANT_ID=VA00000059
var nextUrl = nextValue.substring(nextValue.indexOf(",") + 1, nextValue.lastIndexOf(","));
var qs = nextValue.substring(nextValue.lastIndexOf(",") + 1);
nextUrl += "?".concat(qs);
var location = win.location;
return nextUrl;
}
/**
* Returns a truncated toString of given function.
* @param fn
* @return {string}
*/
function displayFn(fn) {
if (!fn) {
return "null function";
}
return "".concat(fn.toString().replace(/[\s]+/gim, " ").substr(0, 50), "...");
}
/**
* Performs a synchronous retrieval of the JS source file provided. Returns the script as a string.
*/
function loadJsSource(src) {
var ajaxObj = $.ajax({
"url": src,
"dataType": "text",
"async": false
});
return ajaxObj.responseText;
} // member functions
var lib = {
// This is an array of page listeners. A page listener is defined in another
// page and has methods that can be called by functions in this library file.
// When some event happens, library will call a method belonging to the page
// listeners.
"pageListeners": [],
/**
* Simple function used to log message strings and Error instances to the console, if the console object
* is available (may not be in older browser environments). Will only log if isDevMode is true.
*
* @param {string|Error} message
* @param {boolean} [override] if present and true, will log whether or not in dev mode
*
* @deprecated Should call Utils.log() directly.
*/
"log": function log(msg, override) {
_log("Call to deprecated Lib.log() function (should call Utils.log() directly)", true);
_log(msg, override);
},
/**
* Gets value for the cookie with the given name. Returns null if none found.
*
* @param name
* @returns {*}
*/
"getCookie": function getCookie(name) {
var vals = document.cookie.split(/\s*;\s*/);
var val = null;
$.each(vals, function (i, cookie) {
var nv = cookie.split("=");
if (nv[0] == name) {
val = nv[1];
return false;
}
});
return val;
},
/**
* Gets value for given param; returns null if not present.
*
* @param param
* @returns {String}
*/
"getParam": function getParam(param) {
var qry = location.href;
var index = qry.indexOf("?");
if (index < 0) {
return null;
}
qry = qry.substr(index + 1);
var nvps = qry.split("&");
var val = null;
$.each(nvps, function (i, v) {
var nv = v.split("=");
if (nv.length != 2) {
return;
}
var n = nv[0];
if (param == n) {
val = nv[1];
return false;
}
});
return val;
},
/**
* Provides access to the Modal object (used to create and manipulate dialogs, spinners, etc.).
*
* @returns {Modal}
*/
"getModal": function getModal() {
return Modal;
},
/**
* Is called to do an Ajax load of body, putting up spinner graphic while waiting for load.
*
* @param win the context Window
* @param url the URL to fetch content from
*/
"doSlowPageLoad": function doSlowPageLoad(win, url) {
// helper function used to do loggin for onReady functions
function doFnLog(w) {
var fns = w["onReadyFunctions"];
var len = fns ? fns.length : 0;
_log("In doSlowPageLoad(".concat(url, "), win.onReadyFunctions.length=").concat(len));
}
var $ = win.$;
win.spinnerOn = true;
$(win.document).ready(function () {
doFnLog(win);
$("#slowpageloading").fadeIn(400);
_log("Doing doSlowPageLoad(".concat(url, ")"));
window.setTimeout(function () {
doFnLog(win);
$("body").load(url, function () {
win.spinnerOn = false;
var onReadyFunctions = win.onReadyFunctions || [];
doFnLog(win);
for (var i = 0; i < onReadyFunctions.length; i++) {
try {
var fn = onReadyFunctions[i];
var str = displayFn(fn);
_log("Running onReadyFunction:\n".concat(str));
fn(win);
} catch (e) {
_log(e);
}
}
});
}, 1000); // do timeout for load() call to allow spinner to display for a moment
});
},
/**
* Is called to create and render a new HierCheckboxModel instance.
*
* @param win the ccntext Window
* @param scriptId the id of the SCRIPT tag containing call to this method
* @param json the JSON node data payload
*/
"renderHierCheckboxModel": function renderHierCheckboxModel(win, scriptId, json) {
var model = new HierCheckboxModel(win, scriptId, json);
model.render();
},
"openNode": function openNode(win, id) {
return (// Do nothing. We don't need to open the children when you click a parent
true
);
},
"toggleNode": function toggleNode(win, id, hasImg) {
hasImg = hasImg == undefined || hasImg === true; // hasImg is true if not provided or if explicitly true
var img;
if (hasImg) {
img = win.document.getElementById("".concat(id, "_img"));
}
var elem = win.document.getElementById(id);
if (elem.style.display == "none") {
elem.style.display = "";
if (hasImg) {
img.src = "/ats/images/minus.gif";
}
} else {
elem.style.display = "none";
if (hasImg) {
img.src = "/ats/images/plus.gif";
}
}
},
"assureChildrenMatch": function assureChildrenMatch(win, id) {
var children = parents[id];
if (children) {
var checked = isChecked(win, id);
var length = children.length;
for (var i = 0; i < length; i++) {
var child = children[i];
checkCheckBox(win, child, checked, false);
lib.assureChildrenMatch(win, child);
}
}
return true;
},
"assureParentSelected": function assureParentSelected(win, id) {
var parent = kids[id];
if (parent) {
checkCheckBox(win, parent, true, true);
}
return true;
},
"setCheckboxElements": function setCheckboxElements(win) {
checkboxElements = [];
for (var i = 0; i < win.document.forms[0].elements.length; i++) {
var elem = win.document.forms[0].elements[i];
if (elem && elem.type == "checkbox") {
var value = elem.value;
checkboxElements[value] = elem;
}
}
},
"rmimg": function rmimg(win, companyId) {
if (!win.document.getElementById(companyId)) {
win.document.getElementById("".concat(companyId, "_img")).style.display = "none";
}
},
"setParent": function setParent(win, id, parentId) {
kids[id] = parentId;
var list = parents[parentId];
if (!list) {
list = [];
}
list = list.concat(id);
parents[parentId] = list;
},
"initPageCollapse": function initPageCollapse(doc) {
for (var guiPageId in hiddenDivs) {
lib.pageCollapse(doc, guiPageId);
}
},
"pageCollapse": function pageCollapse(doc, guiPageId) {
var button = doc.getElementById("".concat(guiPageId, "-collapse-button"));
var div = doc.getElementById(guiPageId);
if (!!div && !!button) {
var visible = div.style.display;
if (visible == "none") {
div.style.display = "";
delete hiddenDivs[guiPageId];
button.src = "/ats/images/minus.gif";
} else {
div.style.display = "none";
if (!hiddenDivs[guiPageId]) {
hiddenDivs[guiPageId] = true;
}
button.src = "/ats/images/plus.gif";
}
}
},
"pageCollapseAtsSearchMultiPage": function pageCollapseAtsSearchMultiPage(win, guiPageId) {
var $ = win.$;
var hiddenClass = "subPageContentHidden";
var clickedDivSelector = "#".concat(guiPageId, "-nonWrapper");
$(".subPageContent").not(clickedDivSelector).addClass(hiddenClass);
$(clickedDivSelector).toggleClass(hiddenClass);
setTimeout(function () {
// https://stackoverflow.com/questions/2905867/how-to-scroll-to-specific-item-using-jquery/14490167#14490167
// $(win).scrollTop($("#" + guiPageId + "-wrapper").offset().top);
$("html, body").animate({
"scrollTop": $("#".concat(guiPageId, "-wrapper")).offset().top
}, 350);
}, 350 + 1);
},
"checkSessionId": function checkSessionId(value) {
if (sessionId == null || value == null || sessionId == "" || value == "" || sessionId == "null" || value == "null") {
return true;
} else if (value == sessionId) {
return true;
} else {
// do check for session cookie first
var temp = _this.getCookie("SSS_SESSION_ID");
if (value == temp) {
// update session id first
sessionId = temp;
return true;
}
return false;
}
},
"helpLink": function helpLink(win, message) {
win.alert(message);
return false;
},
"removeFileUpload": function removeFileUpload(win, field) {
var $ = win.$;
var fieldId = "#".concat(field);
var removeLinkId = "".concat(fieldId, "_remove");
var viewLinkId = "".concat(fieldId, "_view");
var hiddenFieldId = "".concat(fieldId, "_hidden_remove");
$(removeLinkId).click(function () {
$(this).css("display", "none");
$(viewLinkId).css("display", "none");
$(hiddenFieldId).val($(fieldId).attr("value"));
$(fieldId).prop("value", " ");
$(this).closest("td").find("input[type=button]").val("Upload a File");
});
},
"checkEmail": function checkEmail(win, field) {
var validEmail = true;
var emailValue = field.value;
var emailLength = emailValue.length;
if (emailLength > 0) {
validEmail = emailCheck(emailValue, win, field);
}
return validEmail;
},
/**
* Is called to fetch company_id of the location/school selected on Request to Hire form.
*
* @param win the context Window
*/
"selectLocation": function selectLocation(win) {
var $ = win.$; // SSOFT-5225 : Set COMPANY_ID as the initially selected location/school
var $selectNameCompanyId = $("select[name='COMPANY_ID']");
var updateCookie = function updateCookie() {
return document.cookie = "COMPANY_ID=".concat($selectNameCompanyId.val(), "; path=/");
};
updateCookie();
$selectNameCompanyId.change(function () {
$("select[name='action']").val("default");
updateCookie();
$("#inlineContent").html(" ");
});
},
/**
* Is called to compare EMAIL and CONFIRM_EMAIL
*
* @param win the context Window
*/
"checkConfirmEmail": function checkConfirmEmail(win, field) {
var $ = win.$;
var email = $("#EMAIL").val().trim().toLowerCase();
var confirmEmail;
confirmEmail = field.value.trim().toLowerCase();
if (email != confirmEmail) {
invalidField(win, field, "Confirm Email should match Email.");
return false;
} else if (email == confirmEmail) {
return true;
}
},
"checkRequiredRadio": function checkRequiredRadio(win, field) {
var radioSelected = false;
var $ = win.$;
var row = $("#".concat($(field).attr("name"), "_ROW"));
if (row.css("display") == "none") {
return true;
}
if (field.length) {
for (var i = 0; i < field.length; i++) {
if (field[i].checked) {
radioSelected = true;
}
}
} else if (field.checked) {
radioSelected = true;
}
if (radioSelected) {
return true;
} else {
invalidField(win, field, "You have not filled out all required answers on this page.");
return false;
}
},
/**
* Create arrays for form validation listeners.
**/
"initForms": function initForms(win) {
function doInitForm(form) {
if (!form.initialized) {
form.validatorFunctions = new Array(0);
form.validatorFields = new Array(0);
form.maskValidatorFields = new Array(0);
form.maskValidatorFunctions = new Array(0);
form.maskValidatorMasks = new Array(0);
form.initialized = true;
}
}
var forms = win.document.forms;
if (forms) {
for (var i = 0; i < forms.length; i += 1) {
var form = forms[i];
doInitForm(form);
}
} else {
$("form").whenExists(function () {
doInitForm(this);
});
}
},
/**
* run: function to check that a given field is filled out.
* It checks if {name}_ROW is a table row.
*/
"checkRequired": function checkRequired(win, field) {
var $ = win.$;
var $field = $(field);
var name = $field.attr("name"); // TODO - come back and fix to work MA000623 & 00013612
// var parentRow = $("#" + name).closest('tr');
// if (getFieldValue(field) == '' && (row.is(":visible") || parentRow.is(":visible"))){
var $row = $("#".concat(name, "_ROW")); // https://jira.powerschool.com/browse/HE-3687
// $row.length will be 0 if this field is wrapped in a grouping sss.gui.MultiFieldField (see gui_field_field table)
// This is the case for the phone number and extension fields in gui_page 00001017 (the applicant add reference page)
// The :visible check fails because the row has a different name (e.g. PHONE_GROUP_ROW instead of PHONE_ROW)
// Falling back to the closest parent <tr> element should fix this problem
var $rowOrClosestTr = $row.length > 0 ? $row : // Could probably always use this value, but minimizing changes to prevent breaking things
$field.parents("tr").eq(0);
if ($rowOrClosestTr.is(":visible") && getFieldValue(win, field) == "") {
var nameOrId = name ? name : $field.attr("id");
logger.log("## checkRequired - INVALID (".concat(nameOrId, ")"));
logger.log(field);
var $customMessageField = $("input[name=\"customValidationMessage\"]");
var customValidationMessage = $customMessageField.length > 0 && $customMessageField.val() != "" ? $customMessageField.val() : "You have not filled out all required fields on this page.";
invalidField(win, field, customValidationMessage);
return false;
} else {
return true;
}
},
/**
* Wrapper for validFields that checks if the form can be validated from
* the table name.
**/
"validForm": function validForm(win, form, tableName) {
if (!lib.checkAccess()) {
return false;
} // flip validation switch since we are checking fields... it's stupid
win.runningValidFields = true;
if (tableName != "applicant.view" && tableName != "dbuser.pwd_no_libraryjsp" && (tableName.match("dbuser") || tableName.match("applicant") && !tableName.match("applicant_type")) && !checkFormatting(win, form.elements["NAME"], form.elements["PWD"])) {
win.runningValidFields = false;
return false;
}
win.runningValidFields = false;
return validFields(win, form);
},
/**
* Utility to strip down the query string size by removing blank inputs for very
* large search forms. IE has a 2048 character limit on query string size and
* even with an empty form putting every input in the query string can explode that
* on the Applicant search page.
*
* We use jQuery's $.serialize to create the query string.
**/
"compressFormQuery": function compressFormQuery(win, form, tableName) {
if (!lib.checkAccess()) {
return false;
}
var $ = win.$;
var qs = $(form).find(":input").filter(function () {
return $(this).val() != "";
}).serialize();
var requestUrl = "".concat($(form).attr("action"), "?").concat(qs);
win.location.href = requestUrl;
return false;
},
/**
* Adds a func to validation listeners on fieldName.
**/
"appendMulti": function appendMulti(win, fieldName, func) {
lib.initForms(win);
var forms = getFormObjects(win, fieldName);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var newFunctions = new Array(func);
var newFields = form.elements[fieldName];
form.validatorFunctions = form.validatorFunctions.concat(newFunctions);
form.validatorFields = form.validatorFields.concat(newFields);
}
},
"multiCheck": function multiCheck(win, fields) {
var numberChecked = getMultiNumberChecked(win, fields);
var $ = win.$;
var id = "".concat($(fields).attr("name"), "_ROW"); // HE-3875
// Hack to look for newest/last element with ID (closing modal doesn't delete the elements from the DOM, and clicking "Go!" again creates a new modal)
var $row = $("[id='".concat(id, "']")).last();
if ($row.is(":visible") && numberChecked < 1) {
invalidField(win, fields, "You have not filled out all required answers on this page.");
return false;
} else {
return true;
}
},
"reqAllMultiCheck": function reqAllMultiCheck(win, fields) {
var numberChecked = getMultiNumberChecked(win, fields);
var numberOfCheckboxes = Array.from(fields).filter(function (x) {
return x.type === "checkbox";
}).length;
var $ = win.$;
var id = "".concat($(fields).attr("name"), "_ROW"); // HE-3875 was fixed by the change in multiCheck (above), but presumably the fix should be applied here too
// Hack to look for newest/last element with ID (closing modal doesn't delete the elements from the DOM, and clicking "Go!" again creates a new modal)
var $row = $("[id='".concat(id, "']")).last();
if ($row.is(":visible") && numberChecked < numberOfCheckboxes) {
invalidField(win, fields, "You have not filled out all required answers on this page.");
return false;
} else {
return true;
}
},
/**
* Add a check mask function to a field.
**/
"appendMask": function appendMask(win, f, func) {
lib.initForms(win);
var fname = f;
var x;
if (f.indexOf(":::") != -1) {
fname = f.substring(0, f.indexOf(":::"));
f = f.substring(f.indexOf(":::") + 3);
if (f.indexOf(":::") != -1) {
x = f.substring(0, f.indexOf(":::"));
}
}
var forms = getFormObjects(win, fname);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var field = form.elements[fname];
var newFunctions = new Array(func);
var newFields = new Array(field);
var expr = new Array(x);
form.maskValidatorFunctions = form.maskValidatorFunctions.concat(newFunctions);
form.maskValidatorFields = form.maskValidatorFields.concat(newFields);
form.maskValidatorMasks = form.maskValidatorMasks.concat(expr);
}
},
/**
* Adds a fieldName and function to listerners. Functions run when checking for
* form completion.
**/
"append": function append(win, fieldName, func) {
lib.initForms(win);
var forms = getFormObjects(win, fieldName);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var field = form.elements[fieldName];
var newFunctions = new Array(func);
var newFields = new Array(field);
form.validatorFunctions = form.validatorFunctions.concat(newFunctions);
form.validatorFields = form.validatorFields.concat(newFields);
}
},
"checkSize": function checkSize(field, fsize) {
if (fsize > 0 && field.value.length > fsize) {
field.value = field.value.substring(0, fsize);
alert("You have reached the maximum size for this field");
}
},
"checkSearchNumber": function checkSearchNumber(win, field) {
stripSymbols(field);
var value = field.value; // when we don't have a value evrything is fine
if (value === undefined) {
return true;
} // check to see if the first character is a > or <
if (value.indexOf(">") > 0 || value.indexOf("<") > 0) {
invalidField(win, field, "An invalid number was entered in this field. If you are using > or <, please make sure it is the first symbol in the field.");
return false;
} else {
var num = value;
if (num.indexOf(">") == 0 || num.indexOf("<") == 0) {
num = value.substr(1);
}
if (!isValidNumber(num)) {
invalidField(win, field, "An invalid number was entered in this field.");
return false;
}
}
return true;
},
"checkNumber": function checkNumber(win, field) {
stripSymbols(field);
if (!isValidNumber(field.value)) {
invalidField(win, field, "An invalid number was entered in this field. This field cannot contain any symbols ($, %, #, etc).");
return false;
} else {
return true;
}
},
"checkZeroInterval": function checkZeroInterval(win, field) {
stripSymbols(field);
var value = field.value;
if (value === 0) {
invalidField(win, field, "Interval cannot be zero");
return false;
} else {
return true;
}
},
"confirmDelete": function confirmDelete(page, href) {
if (confirm("Are you sure you want to delete this record?")) {
if (href.indexOf("redirect=") < 0) {
href = "".concat(href, "&redirect=").concat(escape(page.location.href));
} else {
var i = href.indexOf("&redirect=");
var j = href.indexOf("%");
if (i >= 0 && j < 0) {
var sl = "&redirect=".length;
href = href.substring(0, i + sl) + escape(href.substring(i + sl));
}
}
page.location.href = href;
}
},
"handleImpersonation": function handleImpersonation(window, href, impersonationMode) {
var userId = href.split("?")[1].substr("USER_ID=".length);
$.get("/servlet/support/login/impersonation", {
"companyId": companyId,
"userId": userId,
"impersonationMode": impersonationMode
}, function (data) {
if (data.success) {
if (data.accountType == "EMPLOYER") {
top.document.location.replace("/ats/employer/v51_employer_frame");
}
} else {
window.alert(data.errorMessage);
}
}, "json");
return false;
},
"checkTime": function checkTime(win, field) {
var isValidTime = true;
var thisFieldValue = field.value;
if (thisFieldValue.length == 0) {
return true;
}
if (thisFieldValue.length != 5) {
isValidTime = false;
} else {
var middle = thisFieldValue.substring(2, 3);
if (middle != ":") {
isValidTime = false;
} else {
var hour = thisFieldValue.substring(0, 2);
var minute = thisFieldValue.substring(3, 5);
if (hour.charAt(0) > 2 || hour.charAt(1) > 9 || minute.charAt(0) > 5 || minute.charAt(1) > 9 || hour.charAt(0) == 2 && hour.charAt(1) > 3) {
isValidTime = false;
} else {
var hourInt = parseInt(hour);
var minuteInt = parseInt(minute);
var hour1 = parseInt(hour.substring(0, 1));
var hour2 = parseInt(hour.substring(1, 2));
var minute1 = parseInt(minute.substring(0, 1));
var minute2 = parseInt(minute.substring(1, 2));
if (hourInt > 23 || hourInt < 0 || minuteInt > 59 || minuteInt < 0 || isNaN(hourInt) || isNaN(minuteInt) || isNaN(hour1) || isNaN(hour2) || isNaN(minute1) || isNaN(minute2)) {
isValidTime = false;
}
}
}
}
if (!isValidTime) {
invalidField(win, field, "An invalid time was entered. Use Military Time Format: 00:00 to 23:59");
}
return isValidTime;
},
"checkDate": function checkDate(win, field) {
var thisFieldValue = getFormattedDate(field);
if (!isValidDate(thisFieldValue, false)) {
invalidField(win, field, "An invalid date was entered. Use Month Date Year Format MM/DD/YYYY.");
return false;
} else {
field.value = thisFieldValue;
return true;
}
},
"checkBirthDate": function checkBirthDate(win, field) {
if (!isValidBirthDate(field, false, 10, 110)) {
invalidField(win, field, "An invalid birth date was entered.");
return false;
}
return true;
},
"checkShortDate": function checkShortDate(win, field) {
var thisFieldValue = getFormattedDate(field);
if (!isValidDate(thisFieldValue, true)) {
invalidField(win, field, "An invalid date was entered. Use Month Date Year Format MM/YYYY.");
return false;
} else {
field.value = thisFieldValue;
return true;
}
},
/**
* It is expected that the input text field has a sibling hidden input field.
* @param field A jquery wrapped text field.
*/
"storeShortDateToFullDate": function storeShortDateToFullDate(win, field) {
/**
* Converts MM/yyyy to MM/dd/yyyy
* @param date date string
* @returns {string} full date
*/
function createFullDate(date) {
var separatorIndex = date.lastIndexOf("/");
var month = date.substring(0, separatorIndex);
var year = date.substring(separatorIndex);
return "".concat(month, "/01").concat(year);
}
var value = field.val();
var id = $(field).attr("id");
var row = $("#".concat(id, "_ROW")); // when the value is not valid the hidden field is set to empty to ensure
// the validator to catch the error on the field
if (!isValidDate(value, true) || value == "" && row.css("display") != "none") {
field.next().val("");
return false;
}
var fullDate = createFullDate(value);
field.next().val(fullDate);
return true;
},
"checkDateTime": function checkDateTime(win, field) {
if (!isValidDateTime(field)) {
invalidField(win, field, "An invalid date was entered. Use Format MM/DD/YYYY HH:MM am/pm.");
} else {
return true;
}
},
"toggleSelectAllCheckboxes": function toggleSelectAllCheckboxes(checkbox, win) {
var isChecked = !!$(checkbox).attr("checked");
if (isChecked) {
lib.selectAllCheckboxes(win, false);
} else {
lib.deselectAllCheckboxes(win, false);
}
},
"selectAllCheckboxes": function selectAllCheckboxes(win, lockAccess) {
if (lockAccess) {
lib.setAccess(win, false);
}
var i = 0;
for (i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].type == "checkbox") {
win.document.forms[0].elements[i].checked = true;
}
}
},
/**
* Submit an eform document through AJAX. This also handles saving as draft.
* It displays a message in modal dialogue in the process of submitting the document.
* The function also handles responses from the server in a modal dialogue.
* This is designed to be called on form onsubmit.
* @param {window} win The window object passed where the function is called. This
* is used as the context for jquery.
* @param {jquery object} form The jquery object of the form document this function is going to submit.
* @param {string} divId The id of the div that will be used for the modal dialogue.
* @return {boolean} This should return false to disable the default form submit.
*/
"documentSubmit": function documentSubmit(win, form, tableName, divId) {
setTimeout(function () {
var $ = win.$;
lib.setAccessNextPage(true);
var saveAsDraft = !!$("input[name='save_as_draft']").length;
var ignoreRequiredFields = $("input[name='IGNORE_REQUIRED_FIELDS']").val() === "Y";
var formIsValid = ignoreRequiredFields;
if (!saveAsDraft && !ignoreRequiredFields) {
formIsValid = lib.validForm.call(form[0], win, form[0], tableName);
}
if (saveAsDraft || formIsValid) {
var doneSubmit = false;
createModal(win, {
"content": "#".concat(divId),
// TODO: clone this?
"attributes": {
"useCloseX": true
},
"onOpen": function onOpen(modal) {
var content = modal.getContent(true);
$(content).css("height", "auto");
$(content).css("width", "auto");
modal.enableOk({
"enable": false
});
modal.setContent("<h3>Submitting...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
var formdata = "".concat(form.serialize(), "&ajax=Y");
if (saveAsDraft) {
formdata += "&save_as_draft=Save+as+Draft";
}
$.post(form.attr("action"), formdata, function (data) {
doneSubmit = true;
modal.setContent(data);
if (saveAsDraft) {
setTimeout(function () {
return modal.close();
}, 500);
}
});
},
"onClose": function onClose(modal) {
if (doneSubmit) {
modal.enableOk({
"enable": true
});
}
}
});
}
}, 500);
return false;
},
"unfollow": function unfollow(win, aTag) {
var $ = win.$;
var link = $(aTag);
$.post(link.attr("href"), function (data) {
if (data == "Success!") {
var evenRows = link.closest("tr").nextAll("tr.even");
link.closest("tr").nextAll("tr.odd").removeClass("odd").addClass("even");
evenRows.removeClass("even").addClass("odd");
link.closest("tr").remove();
} else {
win.alert(data);
}
});
return false;
},
"deselectAllCheckboxes": function deselectAllCheckboxes(win, lock) {
if (lock) {
lib.setAccess(win, false);
}
var i = 0;
for (i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].type == "checkbox") {
win.document.forms[0].elements[i].checked = false;
}
}
},
"daysSince": function daysSince(win, field) {
var fieldName;
var daysSince = field.value;
var time = new Date(new Date().getTime());
var d = new Date(time - daysSince * 24 * 60 * 60 * 1000);
var s = "".concat(d.getMonth(), "1/").concat(d.getDate(), "/").concat(d.getFullYear());
var index = field.name.lastIndexOf("_DAYSSINCE");
if (index > 0) {
fieldName = field.name.substring(0, index);
}
if (daysSince > 0 && daysSince != null) {
for (var i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].name == fieldName) {
win.document.forms[0].elements[i].value = s;
}
}
} else {
for (var _i5 = 0; _i5 < win.document.forms[0].elements.length; _i5++) {
if (win.document.forms[0].elements[_i5].name == fieldName) {
win.document.forms[0].elements[_i5].value = "";
}
}
}
},
// Scoring Worksheet functions
"setAvgField": function setAvgField(win, fieldName) {
return win.avgField = fieldName;
},
"setTotalField": function setTotalField(win, fieldName) {
win.totalField = fieldName;
win.document.forms[0].elements[fieldName].enabled = false;
},
"appendScore": function appendScore(win, fieldName) {
// var field = win.document.forms[0].elements[fieldName];
// win.scores = win.scores.concat(field);
win.scores = win.scores.concat(fieldName);
},
"calculateScore": function calculateScore(win) {
var totalScore = 0;
var removeFromTotal = 0;
for (var i = 0; i < win.scores.length; i++) {
var field = win.document.forms[0].elements[win.scores[i]];
var fieldValue = parseInt(getFieldValue(win, field));
if (!fieldValue > 0) {
fieldValue = 0;
removeFromTotal++;
}
totalScore = totalScore + fieldValue;
}
var avgScore = totalScore / (win.scores.length - removeFromTotal); // round to the nearest integer by adding .5 to avgScore
avgScore = parseInt(avgScore + 0.5);
if (win.totalField && totalScore == parseInt(totalScore)) {
// There are 2 fields which need to be populated, one hidden and one html disabled
win.document.forms[0].elements[win.totalField][0].value = totalScore;
win.document.forms[0].elements[win.totalField][1].value = totalScore;
}
if (win.avgField && avgScore == parseFloat(avgScore)) {
// There are 2 fields which need to be populated, one hidden and one html disabled
win.document.forms[0].elements[win.avgField][0].value = avgScore;
win.document.forms[0].elements[win.avgField][1].value = avgScore;
}
return true;
},
// End Scoring Worksheet functions
// BEGIN PAGE LISTENER FUNCTIONS
"clearListeners": function clearListeners() {
return lib.pageListeners = [];
},
/**
* Is here so that a selection field (select box, checkboxes, etc)
* can cause events to happen when its value changes. This function is called
* in an onChange event listener contained in the field. The field itself
* is passed in so that its attributes can be determined and used.
**/
"updatePage": function updatePage(win, field) {
// The values in the field must follow the following format:
// target,uri,querystring
// Parse it to find out those 3 values.
var value = field.options[field.selectedIndex].value;
var target = null;
var url = null;
if (value.indexOf(",") >= 0) {
target = value.substring(0, value.indexOf(","));
url = value.substring(value.indexOf(",") + 1);
if (url.indexOf(",") >= 0) {
var uri = url.substring(0, url.indexOf(","));
var qs = url.substring(url.indexOf(",") + 1);
var linkUrl = uri;
if (qs != null) {
var qsBegin = "?";
if (linkUrl.indexOf("?") >= 0) {
qsBegin = "&";
}
linkUrl = linkUrl + qsBegin + qs;
}
}
}
if (lib.checkAccess()) {
lib.loadingPage(true);
if (url.indexOf(",") >= 0) {
win.parent.frames[target].location.href = linkUrl;
win.parent.frames[target].focus();
}
} else {
win.alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
var size = field.options.length;
var currentPage = win.parent.frames[target].location.pathname;
for (var i = 0; i < size; i++) {
var optionVal = field.options[i].value;
if (optionVal.indexOf(currentPage) >= 0) {
field.selectedIndex = i;
break;
}
}
}
},
/**
* These functions and variables are for the next/previous applicant links.
* Loading will be set to true at the top of the page and then false as the
* last think on the page.
**/
"loadingPage": function loadingPage(bool) {
setGlobalData("Lib.loading", bool);
if (bool == true) {
lib.setAccessNextPage(true);
}
return true;
},
"isLoadingPage": function isLoadingPage() {
var loading = getGlobalData("Lib.loading");
return loading;
},
/**
* Is called at the bottom of every ResultPage and FormPage
* It iterates through all of the active page listeners and calls the
* method to let the page listeners know that the page has been updated.
*
* Called by the page, notifies page listeners
**/
"pageUpdated": function pageUpdated(uri) {
for (var i = 0; i < _this.pageListeners.length; i++) {
var listener = _this.pageListeners[i];
var f = void 0;
try {
f = listener.pageUpdated;
if (f) {
f(uri);
}
} catch (err) {}
}
},
// END OF PAGE LISTENER FUNCTIONS
/**
* Sets flag for accessing next page, can be retrieved from checkAccess(). This MUST occur on the global
* instance or results will not be consistent.
*
* @param value
* @returns {boolean}
*/
"setAccessNextPage": function setAccessNextPage(value) {
var canAccess = lib.checkAccess();
_log("accessNextPage: ".concat(canAccess));
setGlobalData("Lib.accessNextPage", value);
return true;
},
"setAccess": function setAccess(win, value) {
_this.setAccessNextPage(value);
if (win && win.document && win.document.forms && win.document.forms[0] && win.document.forms[0].elements && win.document.forms[0].elements["is_changed"] && !win.document.forms[0].elements["force_is_changed"]) {
win.document.forms[0].elements["is_changed"].value = !value;
}
return true;
},
/**
* Retrieves flag indicating if next page can be accessed. This MUST occur on the global
* instance or results will not be consistent.
*
* @returns {boolean}
*/
"checkAccess": function checkAccess() {
return getGlobalData("Lib.accessNextPage");
},
"checkLinkAccess": function checkLinkAccess() {
if (_this.checkAccess()) {
return true;
} else {
alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
return false;
}
},
/**
* Add a listener to parentField to show targetField when parentField.value
* equals showValue.
**/
"addDependentField": function addDependentField(win, rawParentFieldIds, targetField, rawShowValues) {
var $ = win.$; // TODO: this flag will be kept here as it may be desirable to use the 'keepWidth' feature for individual dialogs in the future
var keepWidth = false; // wait until the document is ready because "reset" and parent may not
// be present yet
$(win.document).ready(function () {
// separate out the fields and values into groups end result is array parentOrFields
var parentOrFields = [];
var parentOrFieldIds = rawParentFieldIds.split("|");
var parentOrValues = rawShowValues ? rawShowValues.split("|") : [];
for (var i = 0; i < parentOrValues.length; i++) {
parentOrValues[i] = parentOrValues ? parentOrValues[i].split("&") : [];
}
for (var _i6 = 0; _i6 < parentOrFieldIds.length; _i6++) {
var parentInnerAnd = [];
var parentInnerAndFieldIds = parentOrFieldIds[_i6].split("&");
for (var j = 0; j < parentInnerAndFieldIds.length; j++) {
var nameId = parentInnerAndFieldIds[j];
var negative = nameId.substr(-4) === "_NOT";
if (negative) {
nameId = nameId.substr(0, nameId.length - 4);
} // look to see if this will be rendered in Modal
var parentField = void 0;
if (dependentFieldCtx) {
parentField = $(dependentFieldCtx).find("[name='".concat(nameId, "']")).not(":disabled");
} else {
parentField = $("[name='".concat(nameId, "']")).not(":disabled");
}
parentField.data("negative", negative);
parentInnerAnd[j] = {
"fields": parentField,
"values": parentOrValues[_i6] ? parentOrValues[_i6][j] ? parentOrValues[_i6][j] : "" : ""
};
}
parentOrFields[_i6] = parentInnerAnd;
} // combine all fields into one jquery object for binding
var parentFields;
$.each(parentOrFields, function (i, innerAnd) {
return $.each(innerAnd, function (j, field) {
return parentFields = parentFields ? parentFields.add(field.fields) : field.fields;
});
}); // look to see if this will be rendered in Modal
var row;
if (dependentFieldCtx) {
row = $(dependentFieldCtx).find("#".concat(targetField, "_ROW"));
} else {
row = $("#".concat(targetField, "_ROW"));
}
if (parentFields && parentFields.length) {
var showHide = function showHide(dontAnimate) {
var foundPassingInnerAnd = false;
for (var _i7 = 0; _i7 < parentOrFields.length && !foundPassingInnerAnd; _i7++) {
var _parentInnerAnd = parentOrFields[_i7];
var innerAndResult = true; // for each field
var _loop = function _loop(_j2) {
var field = _parentInnerAnd[_j2]; // values are always the same for a field
var showOnValue = field.values.split(",");
var showOnAnyValue = field.values === ""; // for each input (of field)
var fieldResult = false;
for (var k = 0; k < field.fields.length && !fieldResult; k++) {
var input = field.fields.eq(k);
var value = input.val();
var _negative = input.data("negative"); // if ( input.attr("type") == "hidden" )
// this should already be handled server side; but we allow test anyway
// if this is an unchecked radio/check fake no value
if (input.is(":radio,:checkbox") && !input.is(":checked")) {
value = null;
}
var hasValue = false;
if (value !== null) {
value = $.makeArray(value);
$.each(value, function (i, v) {
if (v != "" && $.inArray(v, showOnValue) >= 0) {
hasValue = true;
}
});
} // set result and stop iteration when negative
fieldResult = hasValue || value && value != "" && showOnAnyValue;
if (_negative) {
fieldResult = !fieldResult;
}
}
innerAndResult = fieldResult;
};
for (var _j2 = 0; _j2 < _parentInnerAnd.length && innerAndResult; _j2++) {
_loop(_j2);
}
foundPassingInnerAnd = innerAndResult;
}
if (foundPassingInnerAnd) {
if (dontAnimate) {
row.show();
triggerResize(win, true, keepWidth);
} else {
// only animate when it is not already shown; display="auto"
if ("none" == row.css("display")) {
row.css("display", "");
row.css("opacity", "0");
row.animate({
"opacity": "1"
}, 500, "swing", function () {
return triggerResize(win, true, keepWidth);
});
}
}
} else {
if (dontAnimate) {
row.hide();
triggerResize(win, true, keepWidth);
} else {
row.fadeOut({
"complete": function complete() {
return triggerResize(win, true, keepWidth);
}
});
}
}
}; // on reset of form trigger change event for all fields
$(":reset").click(function () {
$(this).get(0).form.reset();
showHide(true);
}); // add event triggers to parent field
parentFields.each(function (i, elem) {
var $element = $(elem);
if ($element.hasClass("select-plus") && !$element.hasClass("select-plus-initialized")) {
SelectPlus.registerChangeListener($element, showHide);
} else {
jqueryUniversalChange(win, elem, function () {
return showHide();
});
}
});
showHide(true);
}
});
},
"setLocation": function setLocation(win, url) {
if (_this.checkAccess()) {
win.document.location.href = url;
} else {
win.alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
}
},
"historyGo": function historyGo(win, e) {
if (_this.checkAccess()) {
win.$("body").trigger("ss-event-page-cancel");
win.history.go(-1);
} else {
var e = win.event || e;
var targetValue = e.target || e.srcElement;
var msgForDisplay = $(targetValue).parents("ul").find("input[type=submit]");
win.alert("You must first click the \"".concat(msgForDisplay.val(), "\" or \"Undo\" buttons before exiting this page."));
}
},
"maskFormat": function maskFormat(win, field, expr) {
var v = field.value;
if (v == "") {
return true;
}
var re = new RegExp(expr);
if (re.exec(v)) {
return true;
} else {
return false;
}
},
/**
* Not even able to be called. Overriden by function autoFormat(x,y,z)
**/
"autoFormat": function autoFormat(field, expr, withstr) {
var v = field.value;
if (v == "") {
return;
}
var re = new RegExp(expr);
if (re.exec(v)) {
field.value = v.replace(re, withstr);
} else {
alert("".concat(v, " is not in the correct format."));
}
},
"AppLoginStepFillIn": function AppLoginStepFillIn(win) {
var $ = win.$; // copy create account button
var create_account_button = $(".pagebuttons ul :has([value='Create New Account'])");
create_account_button.css("display", "block");
if ($("div.create_account")) {
$("div.create_account").html(create_account_button.html());
create_account_button.css("display", "none");
} // move preview links
if ($("#step2_links")) {
$("#preview").hide();
$("#step2_links").html($("#preview").html());
} else {
$("#preview").show();
}
},
/**
* Adds functionality and style to the current content page in win.
**/
"addStyleClasses": function addStyleClasses(win, forSelector) {
// is a named function to aid in logging
var $ = win.$;
if (!$) {
_log(new Error("Can not call addStyleClasses; jQuery is not available."));
return;
}
forSelector = forSelector || "body";
_log("addStyleClasses for ".concat(forSelector));
var jq = $(forSelector);
setFormClass();
fillEmptyTD();
removeCheckboxsWhenAll();
fileFieldReset();
var classFunctions = {
".embedded_field": function embedded_field(obj) {
// firefox; clicking embedded input can't type
obj.closest("label").find(":radio, :checkbox").click(function () {
return $(obj).children(":text").focus();
}); // IE; clicking embedded input doesn't select check/radio
obj.closest("label").find(":text").click(function () {
$(this).closest("label").find(":radio, :checkbox").attr("checked", "checked");
});
},
// Lookup Editor
"a.wizardpopup": handleWizardPopupWithReload,
"a.wizardpopupNoReload": handleWizardPopup,
// modal pop-up links
"a.modalpopuplink": function aModalpopuplink(obj) {
return obj.click(function (e) {
e.preventDefault();
var popupId = "modalpopuplink";
if (!$("#".concat(popupId)).length) {
$("body").append("<div id='".concat(popupId, "' style='display:none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>"));
}
_this.addToolboxFunction(win, popupId, function () {
return ajaxFillinPopup(win, popupId, obj.attr("href"));
});
_this.showPopup(win, popupId);
return false;
});
},
// suggest search
"input.suggestsearch": handleSuggestSearch,
// file upload
"input.file_upload_field[type='button']": function inputFile_upload_fieldTypeButton(obj) {
$(obj).click(function (e) {
_log("Doing input.file_upload_field[type='button'].click()...");
var field = this; // Hack for SSOFT-5459. Multiple instances of the file upload popup are being created for some reason (when closing and reopening the popup).
$(field).parents().last().find("[id=upload_field]:hidden").remove();
closePopupFirst(win, function () {
_log("Doing fileUploadPopup - popups have been closed.");
fileUploadPopup(field, win);
});
});
},
// nctq
".nctq_hoverable": function nctq_hoverable(obj) {
obj.mouseenter(function (e) {
moveFloatingDivWithMouse(win, $(this).next("div"), e, 20, 20);
$(this).next("div").removeClass("nctq_scores_hidden");
$(this).next("div").addClass("nctq_scores_visible");
});
obj.mouseleave(function (e) {
$(this).next("div").removeClass("nctq_scores_visible");
$(this).next("div").addClass("nctq_scores_hidden");
});
obj.mousemove(function (e) {
moveFloatingDivWithMouse(win, $(this).next("div"), e, 20, 20);
});
obj.click(function (e) {
return e.preventDefault();
});
}
};
handleClassFunctions();
/**
* win - the window object (because of frames)
* div - the floating div jquery object
* e - event
* down - y offset from the mouse from the top right corner of the div
* left - x offset from the mouse from the top right corner of the div
*/
function moveFloatingDivWithMouse(win, div, e, down, left) {
var $ = win.$;
var width = div.width();
var height = div.height();
div.css({
"top": Math.min(e.pageY + down, $(win).height() - height + $(win).scrollTop()),
"left": e.pageX - width - left
});
}
function handleWizardPopupWithReload(obj) {
handleWizardPopup(obj, true);
}
function handleWizardPopup(obj, reloadPageOnDone) {
obj.click(function (e) {
e.preventDefault();
var popupId = obj.attr("name") ? obj.attr("name") : "awizardpopup";
if (!$("#".concat(popupId)).length) {
$("body").append("<div id='".concat(popupId, "' style='display:none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>"));
}
closePopupFirst(win, function () {
_this.addToolboxFunction(win, popupId, function () {
// hijack submit and stay open
ajaxFillinPopup(win, popupId, obj.attr("href"), null, true, true);
});
if (reloadPageOnDone) {
_this.addToolboxFunction(win, "".concat(popupId, "_close"), function () {
$("body").html("<h3 class='pageTitleCaption'>Please Wait... Loading</h3>"); // add refresh=Y to url
var curLoc = win.location.href;
var isOldUi = top.frames[0] && top.frames[0].name === "sss_script";
if (curLoc.indexOf("refresh") == -1) {
var newUrl = curLoc;
if (newUrl.indexOf("?") > -1) {
newUrl += "&refresh=Y";
} // if ( newUrl.indexOf("?") )
else {
newUrl += "?refresh=Y";
}
if (isOldUi) {
win.location.replace(newUrl);
} else {
win.$("body").trigger("ss-event-page-reload");
}
} else {
if (isOldUi) {
win.location.reload();
} else {
win.$("body").trigger("ss-event-page-reload");
}
}
});
}
_this.showPopup(win, popupId);
});
return false;
});
}
function handleSuggestSearch(obj) {
var suggestionId = "".concat(obj.attr("id") || obj.attr("name"), "_sug"); // url
var url = obj.attr("href"); // add jscallback to URL
if (url.indexOf("?") < 0) {
url += "?";
} else {
url += "&";
}
url += "jscallback=?"; // get suggestion
var lastTimeout = -1;
obj.keyup(function (e) {
if (lastTimeout != -1) {
win.clearTimeout(lastTimeout);
}
lastTimeout = win.setTimeout(function () {
// suggest from
var value = obj.val();
if (value == "") {
return;
}
value = {
"suggest": value,
"ajax": "y"
};
var data = $.param(value);
$.getJSON(url, data, handleSuggestsions);
}, 500);
}); // fillout suggestion
function handleSuggestsions(suggestions) {
removeSuggestionBox();
createSuggestionBox();
for (var suggestion in suggestions) {
// IE behaves funny when chaining
var id = suggestionId + suggestions[suggestion];
$("#".concat(suggestionId)).append("<div id='".concat(id, "' class='suggest_link'>").concat(suggestion, "</div>"));
var jsug = $("#".concat(id));
jsug.hover(hoverOver, hoverOut);
jsug.click(function () {
obj.val($(this).html());
removeSuggestionBox();
});
}
} // remove suggestion
obj.blur(removeSuggestionBox); // utiltity
function hoverOver() {
$(this).addClass("suggest_link_over");
obj.unbind("blur");
}
function hoverOut() {
$(this).removeClass("suggest_link_over");
obj.blur(removeSuggestionBox);
}
function createSuggestionBox() {
if (!$("#".concat(suggestionId, "_con")).length) {
obj.after("<div id='".concat(suggestionId, "_con'><div id='").concat(suggestionId, "' class='search_suggest'></div></div>"));
}
}
function removeSuggestionBox() {
$("#".concat(suggestionId, "_con")).remove();
}
}
function setFormClass() {
jq.find(":text").addClass("textfield");
jq.find(":password").addClass("passwordfield");
jq.find(":text, :password").focus(function () {
$(this).addClass("textfieldfocus");
});
jq.find(":text, :password").blur(function () {
$(this).removeClass("textfieldfocus");
});
} // Hack to fix rendering bug in IE.
function fillEmptyTD() {
jq.find("td:empty").html(" ");
}
function removeCheckboxsWhenAll() {
// Additionally can do ,:button[name='select_all'],:button[name='deselect_all']
var $selectNameActionType = jq.find("select[name=\"ACTION_TYPE\"]");
$selectNameActionType.change(function () {
var $checkboxes = jq.find(".rs :checkbox");
if ($selectNameActionType.val() === "all") {
$checkboxes.prop("disabled", "disabled").hide();
} else {
$checkboxes.prop("disabled", "").show();
}
});
}
function handleClassFunctions() {
var selectorString = "";
var first = true;
for (var selector in classFunctions) {
if (!first) {
selectorString += ",";
}
selectorString += selector;
first = false;
}
var $elements = jq.find(selectorString);
$elements.each(function () {
var me = $(this);
for (var _selector in classFunctions) {
if (me.is(_selector)) {
classFunctions[_selector].call(this, me);
}
}
});
}
/**
* Pop-up for upload_field
**/
var uploadFieldId = "upload_field";
function fileUploadPopup(field, win) {
var $ = win.$; // error on any existing pop-up
var modal = getModal(win);
if (modal && modal.isOpen()) {
alert("ERROR: cannot have a fileupload field within another pop-up");
return;
} // get real content
var fieldName = $(field).attr("hiddenname");
var uploadParams = "FIELD_NAME=".concat(fieldName, "&COMPANY_ID=").concat(companyId); // waiting text
if (!$("#".concat(uploadFieldId)).length) {
var loading = "<div id=\"".concat(uploadFieldId, "\" style=\"display: none\"><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>");
$("body").append(loading);
} // if to remove ext enforcement
var uploadPageQs = "";
if ($(field).is(".noextcheck")) {
uploadPageQs = "?noextcheck=Y";
} // on open
_this.addToolboxFunction(win, uploadFieldId, function () {
// fill in with real content
ajaxFillinPopup(win, uploadFieldId, "/ats/upload_field.jsp".concat(uploadPageQs), uploadParams);
}); // on close
_this.addToolboxFunction(win, "".concat(uploadFieldId, "_close"), function () {
// if the upload was a success
if (win.fileuploads && win.fileuploads[fieldName]) {
var fileupload = win.fileuploads[fieldName];
if (fileupload.id && fileupload.url) {
// update the hidden field
$("#".concat(fieldName)).val(fileupload.id); // update the link
$(".".concat(fieldName, "_link")).attr("href", fileupload.url).fadeIn();
$(".".concat(fieldName, "_remove")).attr("href", "#").fadeIn(); // change button label
$("#".concat(fieldName, "_button")).attr("value", "Replace File"); // warn on page change
_this.setAccess(win, false);
}
}
});
_this.showPopup(win, uploadFieldId);
}
function fileFieldReset() {
jq.find(":reset").click(function (e) {
// change hiddens back to original value
$(".file_upload_field[type='hidden']").each(function (i) {
var orgValue = $(this).attr("original");
$(this).val(orgValue); // update links
var link = $("#".concat($(this).attr("name"), "_link"));
link.attr("href", orgValue);
if (orgValue == "") {
link.fadeOut();
}
});
});
}
},
/**
* Called when an upload is complete
**/
"fileUploadComplete": function fileUploadComplete(win, fieldName, msg) {
var $ = win.$;
$(".inlineHelp").remove();
$(".searchsoft-modal #file_upload_content").html(msg);
$(".searchsoft-modal #file_upload_waiting").stop().hide();
$(".searchsoft-modal #file_upload_content").fadeIn(); // since we don't know what caused the fileupload (wizard or field) process the message for all cases
// Note regarding HE-3374: Content parameter was previously
// $("#" + fieldName)
// but "Continue" buttons with redirects weren't working
// See
// if (hijackStayOpen) {
// var button = content.find(".linkbutton");
// button.each(function () {
// in afterAjaxPopProcess
// Also see changes in upload_field.jsp (new div element with class starting with file-upload-complete-wrapper-)
afterAjaxPopProcess(win, fieldName, $(".file-upload-complete-wrapper-".concat(fieldName)), null, true, true);
triggerResize(win);
},
/**
* Called when an upload is starting
**/
"fileUploadStart": function fileUploadStart(win) {
var $ = win.$;
$(".inlineHelp").remove();
$(".searchsoft-modal #file_upload_waiting").fadeIn();
$(".searchsoft-modal #file_upload_content").hide();
return true;
},
// lib: JQUERY
"onReady": function onReady(win, fun) {
win.$ = checkJQuery(win, win.$);
if (!win.$) {
_log(new Error("Can not call onReady; jQuery is not available."));
return;
}
var onReady = function onReady() {
_log("win.document.readyState: ".concat(win.document.readyState)); // we need full CSS; chrome/safari parallel load
if (win.document.readyState != "complete") {
// FF jumps the gun on 'complete' state...causes issues with onReady functions
// when doing slow page load...so, do longer wait before executing
var deferTime = $.browser && $.browser.mozilla ? 1000 : 350;
_log("Deferring call to onReady for ".concat(deferTime, " ms..."));
win.setTimeout(onReady, deferTime);
return;
}
_log("Calling onReady() for:".concat(displayFn(fun)));
if (win.spinnerOn) {
win.onReadyFunctions = win.onReadyFunctions || [];
win.onReadyFunctions.push(fun);
_log("Adding function to win.onReadyFunctions (length=".concat(win.onReadyFunctions.length, "), NOT calling function."));
} else {
try {
_log("Executing onReady() function..."); // send in current context Window, and execute with Lib instance as function context
fun.call(_this, win);
} catch (e) {
_log("Error occurred executing onReady function...");
_log(e);
}
}
};
win.$(win.document).ready(onReady);
},
// Perform the new cookie test
"perform_cookie_test": function perform_cookie_test() {
makeTestCookie();
cookie_test = findTestCookie();
return cookie_test;
},
/**
* Called on pages that use the Action Toolbox.
*
* lib: JQUERY
* It will bind to the go button / select and correctly populate the pop-up.
*
**/
"ready_modal_popup": function ready_modal_popup(win, inline, uid) {
var $ = win.$;
$(win.document).ready(function () {
if (!inline) {
toolboxRegisterActionGo(win, uid);
} else {
toolboxRegisterSelection(win, uid);
}
if (!win.toolboxFunctions) {
win.toolboxFunctions = new Array(0);
}
});
},
/**
* Adds a function to list of current toolbox functions.
**/
"addToolboxFunction": function addToolboxFunction(win, funName, fun) {
if (!win.toolboxFunctions) {
win.toolboxFunctions = new Array(0);
}
win.toolboxFunctions[funName] = fun;
},
/**
* Toolbox, client function for AJAX popup.
**/
"ajaxPopupOp": function ajaxPopupOp(win, id, url, op, includeSelect) {
var $ = win.$;
var data = null;
if (op != null || "" == op) {
data = "op=".concat(op);
}
if (includeSelect) {
data = "".concat(data == null ? "" : data + "&").concat($("form").serialize());
}
var tableName = $("[name=table_name]").val();
if (tableName != null && "" != tableName && (data == null || data.indexOf("table_name") == -1)) {
data = "".concat(data ? data + "&" : "", "table_name=").concat(tableName);
}
ajaxFillinPopup(win, id, url, data);
},
/**
* Toolbox, client function for AJAX popup.
**/
"ajaxPopup": function ajaxPopup(win, id, url) {
return _this.ajaxPopupOp(win, id, url, null);
},
/**
* Creates a Modal and displays it, using the content contained in HTML element with given item id.
*
* @param {Window} win context window
* @param {string} item id of HTML content for modal
* @param {Object} [atts] optional map of attributes used to init Modal
*/
"showPopup": function showPopup(win, item, atts) {
var $ = win.$; // TODO: until a further non-trivial refactoring is done, need to pull 'Ok' button text from
// modal content, from the buttons rendered via ui.properties, and also need to remove
// pagebuttons from content before providing to modal
var text = $("#".concat(item)).find("input[name=".concat(item, "]")).val();
if (!text && item.indexOf("_results") > 0) {
// it may be that the Ok button does not follow convention of having same name as item (i.e. 'email_results' and 'email')
var btnName = item.replace("_results", "");
text = $("#".concat(item)).find("input[name=" + btnName + "]").val();
}
var parent = $("#".concat(item)).parent();
var content = $("#".concat(item)).find(".pagebuttons").hide().end();
$(content).css("display", ""); // default Modal attributes
var defaultAtts = {
"useCloseX": true
};
if (atts) {
atts = $.extend({}, defaultAtts, atts);
} else {
atts = defaultAtts;
} // do Ok/Cancel need to be enabled for Modal (or will content contain buttons?)
var enableCancelOk = !text;
var modalInit = {
"id": item,
"attributes": atts,
"content": content,
"onOpen": function onOpen() {
// Important hack for HE-4062 and related issues (e.g. HE-3875, which was already fixed with an even worse hack)
// Closing modals doesn't actually remove them from the DOM, it only hides them, causing lots of issues
// Now instead of hiding old modals when the same modal is opened again, we are removing them from the DOM (i.e. remove() instead of hide())
// Old comment:
// if content from previous Modal is still in DOM, remove before opening this instance
$("[id=\"".concat(item, "\"]")).toArray().slice(0, -1).forEach(function (el) {
return $(el).remove();
});
if (enableCancelOk) {
toolboxAddCancel(win, item);
toolboxRunFunction(win, item);
}
},
"onClose": function onClose(modal) {
// insert the (possibly) modified data back into the DOM
var content = $(modal.getContent(true));
content = $(content).children(); // must get kids (not include the Modal content wrapper)
$(parent).append(content.hide());
toolboxRunFunction(win, "".concat(item, "_close"));
$(".inlineHelp").remove();
win.document.thismodal = null;
}
}; // if this is a non-Ajax populated instance, configure w/ buttons
if (!enableCancelOk) {
modalInit.buttons = [{
"text": text,
"type": "ok",
"callback": function callback(modal) {
return toolboxRunFunction(win, item);
}
}, {
"text": "Cancel",
"type": "cancel"
}];
} // otherwise, this will be populated via ajaxPopup() call
else {
modalInit.showOk = false;
modalInit.showCancel = false;
}
createModal(win, modalInit, true); // will assign to global variable
},
/**
* Toolbox utility, add a hidden field to main form.
**/
"addHiddenField": function addHiddenField(win, name, value) {
var $ = win.$;
$("form").append("<input type=\"hidden\" name=\"".concat(name, "\" value=\"").concat(value, "\" />"));
},
/**
* Utility function that adds all currently checked applicants to the popup.
**/
"addCheckboxApplicants": function addCheckboxApplicants(win, id) {
var $ = win.$;
doModalOp(win, false, function (modal, content) {
var form = $(content).find("form"); // for some reason doing this as inline calls breaks IE6
var apps = $("div.rs :checkbox:checked").clone();
apps.attr("checked", "checked"); // apps.attr("type", "hidden"); // breaks IE6
apps.attr("remove", "yes");
apps.hide();
form.append(apps); // add what to effect; "All applicants in list"
var actionTypeField = $("select[name='ACTION_TYPE']");
if (actionTypeField.length) {
form.append("<input type=\"hidden\" name=\"ACTION_TYPE\" value=\"".concat(actionTypeField.val(), "\" />"));
} // confirm that the checkboxes have been checked [IE6]
if ($(form).find(":checkbox:checked").length == 0) {
// check hidden checkboxes
$(form).find(":hidden:checkbox").attr("checked", "checked");
}
});
},
/**
* Utility function that remove added checked applicants to popup.
**/
"removeCheckboxApplicants": function removeCheckboxApplicants(win, id) {
var $ = win.$;
$("div#".concat(id, " :checkbox[remove='yes']")).remove();
},
/**
* Function that adds window.superConfirm
**/
"addSuperConfirm": function addSuperConfirm(win) {
var $ = win.$;
win.superConfirm = function (text, _callback) {
return createModal(win, {
"content": text,
"attributes": {
"useCloseX": false
},
"buttons": [{
"text": "Yes",
"type": "ok",
"callback": function callback(modal) {
if ($.isFunction(_callback)) {
_callback.apply();
}
triggerResize(win);
}
}, {
"text": "Cancel",
"type": "cancel",
"callback": function callback(modal) {
return $(".inlineHelp").remove();
}
}]
});
};
},
/**
* Function that overrides window.alert() when another function comes in we add
* its text to the top of the current window.
**/
"replaceAlert": function replaceAlert(win) {
var $ = win.$;
win.alert = function (text) {
text = text.replace(/\r\n|\n/g, "<br />");
var popupsOpen = Modal.anyShowing(win);
if (popupsOpen) {
// add the content to the bottom in red
var content = $("<div class='red inlineHelp' />").html(text);
var message; // is there a current alert
if ($(".inlineHelp").length) {
// change text and reset timeout
message = $(".inlineHelp").html(text);
win.clearTimeout(win.helpTimeout);
} else {
// add to bottom and set a timeout
Modal.getCurrent(win).addContent(content);
message = $(".inlineHelp").css("opacity", "0").animate({
"opacity": "1"
}, 500, "linear", function () {
// force resize event
triggerResize(win);
});
}
win.helpTimeout = win.setTimeout(function () {
return message.animate({
"opacity": "0"
}, 500, "linear", function () {
message.remove();
triggerResize(win);
});
}, 15000); // force resize event
triggerResize(win);
} else {
// create a new popup
text = $("<p class='help_popup' />").html(text);
createModal(win, {
"content": text,
"attributes": {
"useCloseX": false
},
"buttons": [{
"text": "Close",
"type": "ok",
"callback": function callback(modal) {
return $(".inlineHelp").remove();
}
}]
});
}
};
},
/**
* Utility for adding fieldPrompt() the window variable.
**/
"addFieldPrompt": function addFieldPrompt(win) {
var $ = win.$;
/**
* Private utility function.
* Default functionality for when pop-up is unavailable.
**/
function defaultPrompt(win, field, message) {
win.alert(message);
}
/**
* Displays a pop-up for a incorrect field.
* Call with field and message: fieldPrompt(<field dom object>, "This field is invalid");
*
* @param fields
* array of fields to be prompted for
* @param message
* message to display about why field is invalid
* @param sumbitOnClose
* (internal) default to use for if to submit the form on successful validation
* @param notryagain
* (internal) if to wait if there is currently a pop-up
**/
function fieldPrompt(fields, message, submitOnClose, notryagain) {
// save for when we call "classic" functions
var passedIn = fields;
var isPassedInArray = !(fields.name || fields.id || fields.type) && fields.length; // force fields is an array
if (!isPassedInArray) {
fields = [];
fields[0] = passedIn;
} // force submitOnClose to be boolean (safety)
if (submitOnClose) {
submitOnClose = true;
} else {
submitOnClose = false;
} // submit when called from validate fields
if (win.runningValidFields) {
submitOnClose = true;
} // if we already have a pop-up just show the extra message
var popupsShowing = Modal.anyShowing(win);
if (popupsShowing) {
// if timeout waiting to spawn pop-up
if (notryagain) {
return defaultPrompt(win, passedIn, message);
} // if we are in a chain of pop-ups
if (!submitOnClose) {
return defaultPrompt(win, passedIn, message);
} else {
// last pop-up in chain is animating, try again soon
return win.setTimeout(function () {
return fieldPrompt(passedIn, message, submitOnClose, true);
}, 550);
}
} // Special Case for GridField validation
try {
if ($(".gridfield").length > 0) {
var gridFields = $(".gridfield");
for (var i = 0; i < gridFields.length; i++) {
if ($.contains(gridFields[i], fields[0])) {
return defaultPrompt(win, passedIn, message);
}
}
}
} catch (e) {}
/* Can safely ignore errors - means we're not in a gridfield*/
// what the fields and caption are contained within
var fieldDelimiter = win.fieldDelimiter || "tr"; // get the parent containing field
var fieldParent = null;
for (var _i8 = 0; _i8 < fields.length; _i8++) {
if (!fieldParent) {
fieldParent = $(fields[_i8]).closest(fieldDelimiter);
} else {
fieldParent = fieldParent.add($(fields[_i8]).closest(fieldDelimiter).eq(0));
}
} // If we could not find the field and its caption
if (!fieldParent.length) {
return defaultPrompt(win, passedIn, message);
} // Get a copy of the fields to display in the pop-up
var isDatefield = $(fieldParent).find(".hasDatepicker").length != 0;
var parentCopy = $(fieldParent).clone(!isDatefield); // clone handlers too (if not a date field)
$(parentCopy).find("*").addBack().each(function () {
var id = $(this).attr("id");
if (id) {
$(this).attr("id", "".concat(id, "_COPY"));
}
}); // remove any nodes marked as do-not-copy (i.e. injected widgets)
$(parentCopy).find(".do-not-copy").remove(); // find matching DOM copies of the field
var fieldCopy = [];
var duplicates = false;
parentCopy.find("*").each(function (index) {
for (var _i9 = 0; _i9 < fields.length; _i9++) {
var result = true;
var field = fields[_i9];
var id = $(field).attr("id");
var copyId = $(this).attr("id");
if ("".concat(id, "_COPY") != copyId) {
result = false;
}
if ($(field).attr("name") != $(this).attr("name")) {
result = false;
}
if ($(field).attr("value") != $(this).attr("value") && $(field).attr("type") != "select-one") {
result = false;
}
if ($(field).attr("type") != $(this).attr("type")) {
result = false;
}
if (result) {
// duplicate of already recorded field, bail
if (fieldCopy[_i9]) {
duplicates = true;
} // record the field in the copy
fieldCopy[_i9] = $(this).get(0);
}
}
}); // if duplicates bail
if (duplicates) {
return defaultPrompt(win, passedIn, message);
} // confirm copy and pass-in have same amount of elements
if (fields.length != fieldCopy.length) {
return defaultPrompt(win, passedIn, message);
} // normalize the two arrays
fields = trimArray(fields);
fieldCopy = trimArray(fieldCopy); // actually show the pop-up
var changeOnClose = false; // build content
var content = $("<div class='invalid'>".concat(message, "</div>")); // place field
$(content).append(parentCopy); // contain field in appropriate html trappings for styling
switch (fieldDelimiter) {
case "tr":
parentCopy.wrap("<table class=\"frmpfields\"></table>");
break;
case "td":
parentCopy.wrap("<table class=\"frmpfields\"><tr></tr></table>");
break;
case "li":
parentCopy.wrap("<ul></ul>");
break;
default:
parentCopy.wrap("<div class=\"fieldprompt\"></div>");
break;
}
createModal(win, {
"content": content,
"attributes": {
"useCloseX": true
},
"showOk": true,
"showCancel": true,
// callback is fired when 'Ok' button is clicked
"callback": function callback(modal) {
// TODO Need to find a better workaround, for some reason fieldCopy doesn't store the value of the field. Same code works in the old V1 architecture.
fieldCopy.filter(function (x) {
return x !== undefined;
}).forEach(function (x) {
var element = $("#".concat(x.id))[0];
x.checked = element.checked;
x.value = element.value;
}); // handle if pass-in was single field
var checkField;
if (isPassedInArray) {
checkField = fieldCopy;
} else {
checkField = fieldCopy[0];
} // check that field is valid
if (!validNewField(win, passedIn, checkField)) {
return false; // this will prevent closing
} // set to resubmit the form
changeOnClose = true;
},
"onOpen": function onOpen() {
if (isDatefield) {
var dfCopy = $(parentCopy).find(".hasDatepicker");
$(dfCopy).removeClass("hasDatepicker");
$(dfCopy).datepicker({
"showOtherMonths": true,
"selectOtherMonths": true,
"showAnim": "slideDown",
"changeYear": true
});
}
triggerResize(win); // HE-2143
$("#".concat(fieldCopy[0].id)).focus();
},
// onClose is fired no matter how modal is closed
"onClose": function onClose() {
$(".inlineHelp").remove();
if (changeOnClose) {
// handle if pass-in was single field
var newField;
if (isPassedInArray) {
newField = fieldCopy;
} else {
newField = fieldCopy[0];
} // re-add field to listeners
reassignFieldListeners(passedIn, newField); // push back data
for (var _i10 = 0; _i10 < fields.length; _i10++) {
// find if ie hack is needed for radio button's state
var ieHack = false;
if (fieldCopy[_i10].checked) {
ieHack = true;
} // actually replace data
$(fields[_i10]).replaceWith(fieldCopy[_i10]);
var id = $(fieldCopy[_i10]).attr("id") || "";
id = id.replace("_COPY", "");
if (id) {
$(fieldCopy[_i10]).attr("id", id);
}
if (isDatefield) {
$(fieldCopy[_i10]).removeClass("hasDatepicker");
$(fieldCopy[_i10]).datepicker({
"showOtherMonths": true,
"selectOtherMonths": true,
"showAnim": "slideDown",
"changeYear": true
});
} // use ie hack
if (ieHack) {
$(fieldCopy[_i10]).attr("checked", "checked");
}
} // notify the field change
_this.setAccess(win, false); // if was triggered by form submission, re-trigger
if (submitOnClose) {
$("[name='submit_button']").trigger("click");
}
}
}
});
} // set fieldPrompt() on the win object
win.fieldPrompt = fieldPrompt;
},
/**
* Initializes a formPage
**/
"initFormPage": function initFormPage(win) {
win.scores = new Array(0);
win.avgField = null;
win.totalField = null;
},
"multiRecordField": function multiRecordField(_window, id, url, fetchNow) {
var $ = _window.$;
function refreshResultPage() {
// "Caching" this selector fixes HE-3707 (Internet Explorer issue)
var $id = $("#".concat(id));
$id.html("<h3>Loading...</h3> <p><img src=\"https://cdn.searchsoft.net/images/loading.gif\" />Please Wait</p>"); // get content
$.get(url, // add ajax notification for server
"ajax=Y&refresh=Y", function (data, textStatus) {
if (textStatus === "success") {
// This is where Internet Explorer requires a "cached" selector. Maybe "$" is getting hijacked by the time the AJAX call finishes?
// populate the result
$id.html(data);
registerResultPageAjaxLinks();
} else {
throw "AJAX error getting content";
}
}, "text");
}
this.refreshResultPage = refreshResultPage; // when page has .resultpageajaxlinks show links in a pop-up; refreshing the
// "source" page when the pop-up is closed
function registerResultPageAjaxLinks() {
// when page has .resultpageajaxlinks show links in a pop-up
if ($("#".concat(id, " .resultpageajaxlinks")).length) {
var popId = "".concat(id, "_popup");
$("#".concat(id, " a:not([class~=\"resultlink\"])")).click(function (eventObject) {
var $this = $(this); // what was clicked on
var href = $this.attr("href"); // is delete link
if ($this.hasClass("delete")) {
_window.superConfirm("Are you sure you want to delete this record?", function () {
return $.post(href, null, function (data, textStatus) {
if (textStatus === "success") {
refreshResultPage();
} else {
throw "AJAX error";
}
});
});
} else {
// ajax to fill in pop-up
_this.addToolboxFunction(_window, popId, function () {
return ajaxFillinPopup(_window, popId, href, null, true);
}); // refresh the result page on close
_this.addToolboxFunction(_window, "".concat(popId, "_close"), function () {
return refreshResultPage();
}); // show a pop-up
_this.showPopup(_window, popId);
} // stop browser from following link
eventObject.preventDefault();
return false;
});
}
}
if (fetchNow) {
refreshResultPage();
} else {
registerResultPageAjaxLinks();
}
},
/**
* Register a JSExpression field
**/
"jsExpression": function jsExpression(win, target, expression, defaults) {
var $ = win.$; // varaiables
var varRegExp = new RegExp("\\b[A-Za-z][A-Za-z0-9_]+\\b", "g"); // create listener for "onchange" of each variable
var variable;
while ((variable = varRegExp.exec(expression)) != null) {
// listener for onchange
var elem = $("[name='".concat(variable, "']"));
if (elem.length) {
elem.unbind(jqueryUniversalChangeSupportedEvents.join(","), runExpression);
jqueryUniversalChange(win, elem.get(0), runExpression);
}
} // utility to run the function
function runExpression() {
// this call will never propagate an exception...
var expr = buildRawExpression();
try {
// change the value of target
var value = eval(expr);
var targetField = $("#".concat(target, "_display"));
var targetHidden = $("#".concat(target));
if (value != targetHidden.val()) {
targetField.val(value);
targetField.trigger("change");
targetHidden.val(value);
targetHidden.trigger("change");
}
} catch (ex) {
lib.replaceAlert(win);
var msg = "<span style='font-size: 1em; font-style: normal; font-weight: normal'>It appears that there is an unresolved variable in the JS Expression string provided:</span><br /><br /><span style='font-size: .8em; font-style: italic; font-weight: bold'>".concat(expr, "</span><br /><br /><span style='font-size: 1em; font-style: normal; font-weight: normal'>Check the unresolved field name and ensure that it corresponds with an input on the page.</span>");
win.alert(msg);
$("#".concat(target, "_display")).val("###");
}
} // utility that returns expression with all variables replaced with their real values
function buildRawExpression() {
var result = expression;
try {
// replace all variables in the string
var _variable;
while ((_variable = varRegExp.exec(expression)) != null) {
// value in the form
var value = null;
var variableField = $("[name='".concat(_variable, "']"));
if (variableField.length != 0 && "###" != variableField.val()) {
value = Number(variableField.val());
} // use the default
else if (defaults[_variable] != null) {
value = Number(defaults[_variable]);
} // don't replace this one
else {
continue;
} // use zero if field had nonsense value
if (!isFinite(value)) {
value = Number(0);
} // replace the value
result = result.replace(new RegExp("\\b".concat(_variable, "\\b"), "g"), value);
}
result = "( ".concat(result, " )");
} catch (e) {
_log(e);
}
return result;
} // run it for the first time
runExpression();
},
"reloadNewMcrelYear": function reloadNewMcrelYear(win, mcrelYearDropDownDomName) {
var $ = win.$; // domReady doesn't work reliably here
$(function () {
var $select = $("select[name=\"".concat(mcrelYearDropDownDomName, "\"]"));
$select.change(function () {
var val = $select.val();
if (val !== "") {
var currentLocation = $("form").prop("action");
var newLocation = URI(currentLocation).setQuery("MCREL_YEAR_ID", val).toString();
win.location.href = newLocation;
}
});
});
},
"reloadTeamMemberDashboard": function reloadTeamMemberDashboard(win) {
var $ = win.$;
_this.onReady(win, function () {
return $("select[name='TEAM_MEMBER_USER_ID']").change(function (e) {
var curLocation = win.location.href;
var url;
if (/TEAM_LED_ID=[^&]*/.test(curLocation)) {
url = curLocation.replace(/TEAM_LED_ID=[^&]*/, "TEAM_LED_ID=".concat($("select[name='TEAM_LED_ID']").val()));
} else {
url = "".concat(curLocation, "&TEAM_LED_ID=").concat($("select[name='TEAM_LED_ID']").val());
}
if (/TEAM_MEMBER_USER_ID=[^&]*/.test(curLocation)) {
url = url.replace(/TEAM_MEMBER_USER_ID=[^&]*/, "TEAM_MEMBER_USER_ID=".concat($(this).val()));
} else {
url = "".concat(url, "&TEAM_MEMBER_USER_ID=").concat($(this).val());
}
var regex = /TEAM_MEMBER_USER_ID=([^&]*)/g;
var match = regex.exec(curLocation);
if (match != null && match[1] == $(this).val()) {
return;
} else {
win.location.href = url;
}
});
});
},
"addReloadOnSelectChange": function addReloadOnSelectChange(win, selectName) {
var $ = win.$;
_this.onReady(win, function () {
return $("select[name='".concat(selectName, "']")).change(function (e) {
var curLocation = win.location.href;
var url;
var urlParamRegex = new RegExp("".concat(selectName, "=[^&]*"));
if (urlParamRegex.test(curLocation)) {
url = curLocation.replace(urlParamRegex, "".concat(selectName, "=").concat($(this).val()));
} else {
url = "".concat(curLocation, "&").concat(selectName, "=").concat($(this).val());
}
var regex = new RegExp("".concat(selectName, "=([^&]*)"), "g");
var match = regex.exec(curLocation);
if (match != null && match[1] == $(this).val()) {
return;
} else {
win.location.href = url;
}
});
});
},
"activatePreview": function activatePreview(win, openNewWindow, inputId, buttonId, lookup) {
var $ = win.$;
$("#".concat(buttonId)).click(function () {
var input = $("[name=".concat(inputId, "]"));
if (!input.length) {
return win.alert("No input field to preview");
}
var value = input.val();
if (value == "" || value == null) {
return win.alert("No input currently selected");
}
var url = lookup[value];
if (url == "" || url == null) {
return win.alert("No preview page for that selection");
}
if (!openNewWindow) {
var div = "".concat(buttonId, "_div");
_this.addToolboxFunction(win, div, function () {
return ajaxFillinPopup(win, div, url, null);
});
_this.showPopup(win, div);
} else {
win.open(url);
}
});
},
/**
* Registers a staged select field
**/
"registerStageSelect": function registerStageSelect(win, fieldId, dbFieldId, parentId, value, multi, required) {
_this.onReady(win, function () {
// JQuery
var $ = win.$; // create the two types of fields we can be
var selectField = $("[name='".concat(fieldId, "']"));
var singleValueId = "singleValue_".concat(fieldId);
if (!selectField.length) {
_log("StagedSelectField is not present!");
return;
} // find the parent
var parentField = $("[name='".concat(parentId, "']"));
if (!parentField.length) {
_log("StagedSelectField parent field is not present: ".concat(parentId));
return;
}
var addWildcard = parentField.attr("type") == "text";
function stageChangeEvent(e) {
// get parent value
var me = $(this);
var parentValue = me.val();
if (addWildcard) {
parentValue += "*";
} // make best faith to encode
if (encodeURIComponent) {
parentValue = encodeURIComponent(parentValue);
} else {
if (escape) {
parentValue = escape(parentValue);
}
} // only proceed for selected checkboxes and radio buttons
var type = me.attr("type");
var checkable = type == "radio" || type == "checkbox";
var selected = me.attr("checked");
if (checkable && !selected) {
return;
} // actually get the results; JSONP request
if (parentValue != "" && parentValue != null) {
var url = "/ats/stage_field_lookup?GUI_FIELD_ID=".concat(dbFieldId, "&parentvalue=").concat(parentValue, "&ajax=Y&jscallback=?");
$.getJSON(url, addLookups);
} else {
nukeChoice();
}
} // add the lookups to the select field
var addOnChange = true;
function addLookups(lookups) {
// error check
if (!lookups) {
_log("lookups null");
return;
} // find length
var length = lookups.length; // support collapsing single values
var showSingleValue = length == 1 && required;
var selectedCaptions = ""; // clear out all current entries
selectField.html("");
$("#".concat(singleValueId)).remove();
if (!showSingleValue) {
selectField.show();
} // final choices
var options = "";
var hasSelected = false; // populate the new ones
$.each(lookups, function (index, obj) {
var lookupValue = obj["value"]; // skip empty string (dummy value)
if (lookupValue == "") {
return;
} // Locate caption
var lookupCaption = obj["caption"]; // if this is our original value mark slected
var selected = "";
if ($.inArray(lookupValue, value) != -1 || showSingleValue) {
selectedCaptions += lookupCaption;
selected = " selected='selected' ";
hasSelected = true;
} // add the value
options += "<option value='".concat(lookupValue, "'").concat(selected, ">").concat(lookupCaption, "</option>");
}); // empty option
if (!(multi || showSingleValue)) {
options = "<option value=''".concat(hasSelected ? "" : " selected='selected' ", "></option>").concat(options);
}
selectField.append(options); // support single value
if (showSingleValue) {
selectField.hide();
var captions = "<div id='".concat(singleValueId, "'>").concat(selectedCaptions, "</div>");
selectField.after(captions);
}
selectField.triggerHandler("change");
if (addOnChange) {
addOnChange = false;
selectField.change(function () {
return _this.setAccess(win, false);
});
}
} // add the lookups to the select field
function nukeChoice() {
// clear out all current entries
selectField.html("").show();
$("#".concat(singleValueId)).remove();
if (!multi) {
selectField.append("<option value='' selected='selected'></option>");
}
selectField.triggerHandler("change");
} // bind to changes on the parent
parentField.bind("change", stageChangeEvent); // trigger initial population
stageChangeEvent.apply(parentField.get(0));
});
},
/**
* Registers a staged text field
**/
"registerStageText": function registerStageText(win, fieldId, dbFieldId, parentId, multi, required) {
_this.onReady(win, function () {
// JQuery
var $ = win.$; // create the two types of fields we can be
var textField = $("[name='".concat(fieldId, "']"));
if (!textField.length) {
alert("StageTextField is not present!");
return;
} // find the parent
var parentField = $("[name='".concat(parentId, "']"));
if (!parentField.length) {
alert("StageTextField parent field is not present: ".concat(parentId));
return;
}
function stageChangeEvent(e) {
// get parent value
var me = $(this);
var parentValue = me.val(); // make best faith to encode
if (encodeURIComponent) {
parentValue = encodeURIComponent(parentValue);
} else {
if (escape) {
parentValue = escape(parentValue);
}
} // only proceed for selected checkboxes and radio buttons
var type = me.attr("type");
var checkable = type == "radio" || type == "checkbox";
var selected = me.attr("checked");
if (checkable && !selected) {
return;
} // actually get the results; JSONP request
if (parentValue != "" && parentValue != null) {
var url = "/ats/stage_field_lookup?GUI_FIELD_ID=".concat(dbFieldId, "&parentvalue=").concat(parentValue, "&ajax=Y&jscallback=?");
$.getJSON(url, addLookups);
}
} // add the lookups to the select field
var addOnChange = true;
function addLookups(lookups) {
// error check
if (!lookups) {
alert("lookups null");
return;
} // error check
if (lookups.length != 1) {
alert("lookup must have one value");
return;
}
var newValue = lookups[0]["value"];
textField.val(newValue); // Hack that fixes SSOFT-5469
// https://stackoverflow.com/questions/11793368/set-textarea-value-with-javascript-after-tinymce-initializing/11793478#11793478
if (win !== null && win.tinymce !== null) {
var tinymceEditor = win.tinymce.get(textField.attr("id"));
if (tinymceEditor !== null) {
tinymceEditor.setContent(newValue);
}
}
textField.triggerHandler("change");
if (addOnChange) {
addOnChange = false;
textField.change(function () {
return _this.setAccess(win, false);
});
}
} // bind to changes on the parent
parentField.bind("change", stageChangeEvent); // trigger initial population
stageChangeEvent.apply(parentField.get(0));
function getFirstKey(data) {
for (var elem in data) {
return elem;
}
}
});
},
"registerMoveToSelect": function registerMoveToSelect(win, domId) {
function alphaSort(doma, domb) {
var a = doma.innerHTML;
var b = domb.innerHTML;
var va = a === null ? "" : "".concat(a);
var vb = b === null ? "" : "".concat(b);
return va > vb ? 1 : va === vb ? 0 : -1;
}
function moveTo($from, $to) {
// move to other side
var $fromdetached = $from.find(":selected");
$fromdetached.detach();
$to.append($fromdetached); // sort result
var $toDetach = $to.children();
$toDetach.detach();
$to.append($toDetach.get().sort(alphaSort));
}
var $ = win.$;
var $dst = $("#".concat(domId));
var $src = $("#".concat(domId, "_src"));
$("#".concat(domId, "_addbtn")).click(function () {
_this.setAccess(win, false);
$dst.children().prop("selected", false);
moveTo($src, $dst);
});
$("#".concat(domId, "_rmvbtn")).click(function () {
_this.setAccess(win, false);
$src.children().prop("selected", false);
moveTo($dst, $src);
});
$("form").on("click", "input:submit", function () {
$src.children().prop("selected", false);
$dst.children().prop("selected", true);
});
},
"browseToNextUrlFromNavigationPulldown": function browseToNextUrlFromNavigationPulldown(win, backward) {
var nextUrl = getNextUrlFromNavigationPulldown(win, backward);
if (nextUrl) {
win.location.href = nextUrl;
} else {
alert("Already at the end or beginning of the list.");
}
},
"writeRedirectFromNav": function writeRedirectFromNav(win) {
return win.$("form").append("<input type=\"hidden\" name=\"redirect\" value=\"".concat(getNextUrlFromNavigationPulldown(win, false), "\">"));
},
"handlePreviousNavButton": function handlePreviousNavButton(win) {
var nextUrl = getNextUrlFromNavigationPulldown(win, true);
if (!nextUrl) {
win.$(":button[value=Previous]").remove();
}
},
"registerQuickSelectGoButton": function registerQuickSelectGoButton(win, id) {
return _this.onReady(win, function () {
var $ = win.$;
$("#".concat(id, "_go")).click(function () {
var selectName = "[name='".concat(id, "']");
var select = $(selectName);
var href = select.val();
if (href != "") {
win.location.href = href;
}
});
});
},
/**
* Tie together an expanding multivalue field (edit only)
**/
"registerExpandingMultiValue": function registerExpandingMultiValue(win, fieldName, showRemove, rangeExtra) {
var $ = win.$;
_this.onReady(win, multiValueField);
function multiValueField() {
// find needed elements
var row;
var org;
var container;
var size;
var maxSize;
var template;
init(); // undo support
$(":reset").click(function (e) {
row.html(org);
init();
});
function init() {
row = $("#".concat(fieldName, "_ROW"));
row.find("script").remove();
org = row.html();
container = $("#".concat(fieldName, "_TABLE_CONTAINER tbody"));
size = row.find("#".concat(fieldName, "_SIZE"));
maxSize = parseFloat(size.val());
template = row.find("#".concat(fieldName, "_TEMPLATE")); // min value
if (rangeExtra) {
addAllMin();
} // auto remove
if (rangeExtra) {
addAllRangeExtra();
} // remove links
if (showRemove) {
addAllRemove();
} // add link
var addMoreId = "".concat(fieldName, "_addmore");
if (!container.parent().find("#".concat(addMoreId)).length) {
var addMoreA = $("<a class=\"addMoreA\"></a>").attr({
"id": addMoreId,
"href": "#"
}).html("<img src=\"/ats/css-base/add.png\" class=\"addMoreImg\"/>Add More").click(function (e) {
e.preventDefault();
_this.setAccess(win, false);
addEmptyRow();
return false;
});
container.closest("table").after(addMoreA);
}
if (parseFloat(size.val()) < 1) {
// first row shouldn't prevent leaving page
addEmptyRow();
}
}
function addEmptyRow() {
// add one to size
var curSize = parseFloat(size.val());
size.val(curSize + 1);
maxSize += 1;
var newRecord = "<tr class=\"subrecord_container ".concat(fieldName, "_subrecord_container\" id=\"").concat(fieldName, "_").concat(maxSize - 1, "\">").concat(template.html().replace(/_TEMPLATE/g, "_SUBRECORD_" + (maxSize - 1)), "</tr>"); // insert new content to html
container.append(newRecord);
var newElem = $("#".concat(fieldName, "_").concat(maxSize - 1)); // add remove
if (showRemove) {
addRemove(newElem);
} // add min
if (rangeExtra) {
addMin(newElem);
} // range extra
if (rangeExtra) {
addRangeExtra(newElem);
}
addRemoveTrigger(newElem); // allow any boxes to resize
triggerResize(win);
}
function addAllRangeExtra() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addRangeExtra(subRecords);
}
function addRangeExtra(jq) {
jq.each(function () {
var me = $(this);
var min = me.find(".subrecord_min");
var field = me.find(jqueryUniversalChangeSupportedTags).get(0);
jqueryUniversalChange(win, field, function () {
rangeExtraTrigger(field, min);
return true;
});
});
function rangeExtraTrigger(field, min) {
var cur = $(field);
var minVal = parseFloat(min.html());
var curVal = parseFloat(cur.val());
if (isNaN(curVal) || minVal >= curVal) {
cur.val(minVal + 1);
}
}
}
function addAllMin() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addMin(subRecords);
}
function addMin(jq) {
// jq object
jq.find(".remove_container").append(" greater than <span class=\"subrecord_min\"></span>");
addMinTrigger(jq);
}
function addMinTrigger(jq) {
jq.each(function () {
var me = $(this);
var prev = me.prev(".".concat(fieldName, "_subrecord_container"));
var min = me.find(".subrecord_min");
if (prev.length) {
var cur = me.find(jqueryUniversalChangeSupportedTags).filter(":first");
var field = prev.find(jqueryUniversalChangeSupportedTags).filter(":first").get(0);
jqueryUniversalChange(win, field, function () {
minTrigger(field, cur, min);
return true;
});
minTrigger(field, cur, min);
} else {
// nothing exists show "min" text
min.html("0");
}
});
function minTrigger(field, cur, min) {
var minVal = parseFloat($(field).val());
var curVal = parseFloat(cur.val());
min.html(minVal);
if (!isNaN(curVal) && minVal >= curVal) {
cur.val(minVal + 1);
cur.trigger("change");
}
}
}
function addAllRemove() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addRemove(subRecords);
addRemoveTrigger(subRecords);
}
function addRemove(jq) {
// jq object
jq.find(".remove_container").prepend("<a class=\"subrecord_remove\"><img title=\"Remove\" alt=\"remove\" src=\"/ats/css-base/remove.png\" /></a>");
}
function addRemoveTrigger(jq) {
jq.find(".subrecord_remove").click(function (e) {
_this.setAccess(win, false);
size.val(parseFloat(size.val()) - 1);
var me = $(this).closest(".subrecord_container");
var next = me.next(".subrecord_container");
me.remove();
if (rangeExtra) {
addMinTrigger(next);
}
});
}
}
},
"disableSubmitButtons": function disableSubmitButtons(win) {
win.$("input[type='submit']").attr("disabled", "disabled");
return true;
},
"eformOptionalEventHideFields": function eformOptionalEventHideFields(win, checkboxId) {
/**
* Helper function used to enable/disable a set of elements. Will set/remove 'disabled' attribute
* for all form fields, and will show/hide all elements iterated through.
*
* @param field an HTMLElement or jQuery object
* @param doEnable boolean flag indicating if item should be enabled/disabled
*/
function enable(field, doEnable) {
var formFields = $(field).find("input,select,textarea");
$(formFields).each(function (i, kid) {
if (doEnable) {
$(kid).prop("disabled", false);
} else {
$(kid).prop("disabled", true);
}
});
if (doEnable) {
$(field).show();
} else {
$(field).hide();
}
}
_this.onReady(win, function () {
var $ = win.$;
var checkbox = $("#".concat(checkboxId));
var topRow = checkbox.closest("tr");
var fieldsForEvent = topRow.nextUntil("tr.endEformEvent");
checkbox.change(function () {
var isChecked = checkbox.is(":checked");
enable(fieldsForEvent, isChecked);
});
checkbox.trigger("change");
});
}
};
if (_this.isDevMode) {
/**
* This method is called to initialize and return a DevLinks instance, which exposes
* methods used to interact with and alter behavior of dev links on page. Only one instance per context
* will be created (subsequent calls to this method will return cached instance).
*
* @param {Window} win the context Window
*/
_this.initDevLinks = function () {
function DevLinks(win) {
/**
* Flag indicating if base records should be interacted with (if true) or if alt records should
* be interacted with (if false).
*
* @private
*/
this._useBase; // use for referencing instance in inner/non-member functions
var _devLinks = this; // member functions
/**
* Is called to set the flag indicating whether alt records or base records should be interacted
* with when using dev tools. Each call to this method will also ensure that proper click
* handlers are in place for current page dev tools. The default state is to interact with
* alt records, unless a value of true for useBase is provided.
*
* @param {boolean} [useBase] (optional) if present and true, will interact with base records, and will interact with alt records otherwise
*/
this.setToolAltOption = function (useBase) {
if (_devLinks._useBase === void 0) {
_devLinks._useBase = useBase === true;
} else if (useBase !== void 0) {
_devLinks._useBase = useBase === true;
}
/**
* Is called to enable dev tools to interact with alt records (this is the default behavior).
*/
function enableAlts() {
// will now use alts
_devLinks._useBase = false;
$("div.devmenu a").css({
"background": "#eee"
});
$("div.devmenu a.alttool").each(function () {
var me = $(this);
var href = me.attr("href");
href = href.replace("&usealt=N", "");
me.attr("href", href);
});
}
/**
* Is called to enable dev tools to interact with base records (this is the NON-default behavior,
* and should be treated as potentially risky).
*/
function enableBase() {
// will now use base
_devLinks._useBase = true;
$("div.devmenu a").css({
"background": "orange"
});
$("div.devmenu a.alttool").each(function () {
var me = $(this);
var href = me.attr("href"); // ensure that param has not already been set
href = href.replace("&usealt=N", "");
href = href + "&usealt=N";
me.attr("href", href);
});
}
$("a.dragalt").unbind("click.devtools").bind("click.devtools", function () {
enableAlts();
win.alert("Tools will modify the alt record (default behavior).");
});
$("a.dragbase").unbind("click.devtools").bind("click.devtools", function () {
enableBase();
win.alert("Tools will now modify the base records (for all companies)! \n" + "Danger, this will effect all pages until you log-out or set it back to alt!");
});
if (_devLinks._useBase) {
enableBase();
} else {
enableAlts();
}
}; // initialization and non-member-function definitions
var $ = checkJQuery(win, win.$);
var devDivId = "devdivid"; // cached value of window scroll value used in initDevLinks
var yOffset = 0;
$.extend($.fn.disableTextSelect = function () {
return this.each(function () {// if ($.browser.mozilla) {//Firefox
// $(this).css('MozUserSelect', 'none');
// } else if ($.browser.msie) {//IE
// $(this).bind('selectstart', function () {
// return false;
// });
// } else {//Opera, etc.
// $(this).mousedown(function () {
// return false;
// });
// }
});
}); // after clicking a link scroll back down (but not in the pop-up)
if (yOffset && yOffset != win.yOffset) {
_this.onReady(win, function () {
win.scrollTo(0, yOffset); // only do this once (after clicking a link)
yOffset = 0;
});
}
function addDevDivPopupLoading() {
// add the content
var devDiv = "<div id=\"" + devDivId + "\" style='display: none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>";
$("body").children(":last").after(devDiv); // refresh the page on close
_this.addToolboxFunction(win, devDivId + "_close", function () {
win.yOffset = typeof win.pageYOffset == "number" ? win.pageYOffset : win.document.documentElement ? win.document.documentElement.scrollTop : win.document.body.scrollTop;
yOffset = win.yOffset;
$("body").html("<h1>Reloading...</h1>");
win.location.reload();
});
}
this.activateDevLink = function () {
var me = $(this);
var href = me.attr("href");
if (href) {
if (!me.hasClass("newwindow")) {
var sdata = null;
var hijack = true;
var hijackStayOpen = true;
var devmode = true; // ajax to fill in pop-up
var fullHijack = me.hasClass("wizarddevlink");
var noHijack = me.hasClass("search");
_this.addToolboxFunction(win, devDivId, function () {
// display the result of submitting in the pop-up?
if (fullHijack) {
// wizard
ajaxFillinPopup(win, devDivId, href, sdata, hijack, hijackStayOpen, devmode);
} else {
if (!noHijack) {
// submit and done
ajaxFillinPopup(win, devDivId, href, sdata, hijack, false, devmode);
} // submit to another page
else {
ajaxFillinPopup(win, devDivId, href, sdata, false, false, devmode);
}
}
}); // show a pop-up
_this.showPopup(win, devDivId);
return false;
}
}
return true;
};
function devPopups() {
$("a.devmenulink").each(function () {
this.onclick = _devLinks.activateDevLink;
});
}
function posArrows() {
// what is currently being dragged
var effectWhatFieldId = null; // reset drag if outside
win.document.body.onmouseup = function () {
return effectWhatFieldId = null;
}; // side-by-side
if (win.fieldDelimiter == "td") {
$("div.devfieldmenu").each(function () {
var me = $(this).closest("td");
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var width = me.width();
var height = me.height() - 5;
var demHor = "width: 10px; height: " + height + "px;";
var demVer = "width: " + width + "px; height: 10px;";
var styleDivVer = "style=\"position: absolute;" + demVer + "text-align: center;float: left;clear: both;\"";
var styleDivHor = "style=\"position: absolute;" + demHor + "\"";
var styleLinkVer = "style=\"display: block;" + demVer + "\"";
var styleLinkHor = "style=\"display: block;" + demHor + "overflow: hidden;\"";
var styleImgHor = "style=\"border: 0; padding-top: " + (height / 2 - 30) + "px;\"";
var classStr = ".uparrow,.rightcon,.leftarrow,.downcon";
var upLeftRight = "<div class=\"uparrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/up.png\"/></a></div><div class=\"leftarrow\" " + styleDivHor + "><a " + styleLinkHor + " href=\"\"><img " + styleImgHor + " src=\"/ats/css-base/left.png\"/></a></div><div class=\"rightcon\" style=\"left: " + (width - 5) + "px; position: relative;\"> <div class=\"rightarrow\" " + styleDivHor + "><a " + styleLinkHor + " href=\"\"><img " + styleImgHor + " src=\"/ats/css-base/right.png\"/></a></div></div>"; // IE needs the extra div because position: absolute elements don't display: block (like they should)
var down = "<div class=\"downcon\"><div class=\"downarrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/down.png\"/></a></div></div>"; // register start of drag
var menu = $(this);
menu.disableTextSelect();
menu.get(0).onmousedown = function () {
return effectWhatFieldId = myGuiFieldId;
}; // handle drag end
var endhref = "/ats/admin/drag_move_field.jsp?end_field_id=" + myGuiFieldId; // show links on hover
// lazy register me.hover() b/c IE is slow to register
me.get(0).onmouseover = function (e) {
// derigester on first hit
me.get(0).onmouseover = null; // real event
me.hover(function (e) {
// only when active drag
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
me.prepend(upLeftRight);
me.append(down); // trigger end of drag
me.children(classStr).mouseup(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
var href = endhref + "&start_field_id=" + effectWhatFieldId + "&dir=" + $(this).attr("class").replace(/arrow/, "") + "&usealt=" + (_devLinks._useBase ? "N" : "Y"); // ajax to fill in pop-up
_this.addToolboxFunction(win, devDivId, function () {
return ajaxFillinPopup(win, devDivId, href);
});
_this.showPopup(win, devDivId);
}
});
}
}, function () {
// clear arrows on leaving
me.find(classStr).remove();
});
me.trigger("mouseover");
};
});
} else {
// regular formpage
$("div.devfieldmenu").each(function () {
var me = $(this).closest("tr");
var th = me.find("th");
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first");
if (myGuiFieldId.length) {
myGuiFieldId = myGuiFieldId.eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
} else {
return;
}
var demVer = "width: " + th.width() + "px; height: 1.5em; left: 0;";
var styleDivVer = "style=\"position: absolute;text-align: center;" + demVer + "\"";
var styleLinkVer = "style=\"" + demVer + "display: block;\"";
var classStr = ".uparrow,.downcon";
var up = "<div class=\"uparrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/up.png\"/></a></div>";
var down = "<div class=\"downcon\"><div class=\"downarrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/down.png\"/></a></div></div>"; // register start of drag
var menu = me.find("div.devmenu");
menu.disableTextSelect();
menu.get(0).onmousedown = function () {
return effectWhatFieldId = myGuiFieldId;
}; // register end of drag
var endhref = "/ats/admin/drag_move_field.jsp?end_field_id=" + myGuiFieldId; // show links on hover
// lazy register me.hover() b/c IE is slow to register
me.get(0).onmouseover = function (e) {
// derigester on first hit
me.get(0).onmouseover = null; // use jquery to make it easy
me.hover(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
th.prepend(up);
th.append(down); // trigger events
me.find(classStr).mouseup(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
// href
var href = endhref + "&start_field_id=" + effectWhatFieldId + "&dir=" + $(this).attr("class").replace(/arrow/, "") + "&usealt=" + (_devLinks._useBase ? "N" : "Y"); // ajax to fill in pop-up
_this.addToolboxFunction(win, devDivId, function () {
return ajaxFillinPopup(win, devDivId, href);
}); // show a pop-up
_this.showPopup(win, devDivId);
}
});
}
}, function () {
return me.find(classStr).remove();
});
me.trigger("mouseover");
};
});
} // regular form page
}
function dependTool() {
// for all depend links on fields`
$("a.dependtool").unbind().click(function () {
var mymenu = $(this).closest("div.devfieldmenu");
var parentGuiFieldId = $(this).closest("div.devmenu").find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var dependValue = win.prompt("For what value?"); // orignating make a refresh stop link
mymenu.replaceWith("<a onclick='window.location.reload()'>Stop</a>"); // replace all field menus on page with "make depend" link
$("div.devfieldmenu").replaceWith(function () {
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var result = "<a class='makedependlink'" + " href='/ats/admin/field_make_depend.jsp" + "?PARENT_GUI_FIELD_ID=" + parentGuiFieldId + "&GUI_FIELD_ID=" + myGuiFieldId + "&value=" + encodeURIComponent(dependValue) + "&ajax=Y" + "&usealt=" + (_devLinks._useBase ? "N" : "Y") + "' >" + " Make Dependant</a>";
return result;
}); // silently go to page
$("a.makedependlink").unbind().click(function (e) {
var me = $(this);
e.preventDefault();
var url = $(this).attr("href");
$.get(url, null, function (data, rstatus) {
if (rstatus == "success") {
me.remove();
} else {
win.alert("failed to make dependant, check your console and get a developer");
}
});
return false;
});
});
}
function hideDevLinks() {
$("a.hidedev").click(function (e) {
e.preventDefault();
hideDevLinks();
});
function hideDevLinks() {
$(".debug,.devmenu").fadeOut();
}
}
function showHiddenLinks(win) {
$(".showhidden").click(function (e) {
e.preventDefault();
if (win.location.search == "") {
win.location.search = "?showhidden=Y";
} else {
if (win.location.search.match(/showhidden=Y/)) {
win.location.search = win.location.search.replace(/[\?\&]showhidden=Y/, "");
} else {
win.location.search += "&showhidden=Y";
}
}
});
}
function autoAltCompanyId() {
var alt = $("select[name='ALT_COMPANY_ID']");
if (alt.length && !alt.val()) {
alt.val("<%=companyId%>");
}
}
function showFieldNames() {
$("a.showFieldNames").click(function () {
return $("span.fieldName").show();
});
}
_this.onReady(win, function () {
if (!win.devDone) {
addDevDivPopupLoading();
_devLinks.setToolAltOption();
showFieldNames();
posArrows();
dependTool();
devPopups();
hideDevLinks();
showHiddenLinks(win);
autoAltCompanyId();
} else {// if ($.browser.msie && $.browser.version < 9) {
// //TODO: #modal
// //$("#simplemodal-container .devmenu").hide();
// }
}
win.devDone = true;
});
}
return function (win) {
if (!win._ss_devLinks) {
win._ss_devLinks = new DevLinks(win);
}
return win._ss_devLinks;
};
}();
}
/**
* Class used to construct and render a hierarchical set of checkboxes with cascading click functionality.
*
* @param win
* @param scriptId
* @param json
* @constructor
*/
function HierCheckboxModel(win, scriptId, json) {
var $ = win.$;
/**
* The root node object containing node hierarchy.
* @type {{children: Array}}
* @private
*/
this._rootNode = {
"children": []
};
/**
* Collection of ALL node instances.
* @type {Array}
* @private
*/
this._allNodes = [];
/**
* Counter used to generate unique index for all nodes.
* @type {number}
* @private
*/
this._counter = 0;
var _this = this;
function cascadeChecks(field, index) {
function cascadeNodeChecks(node) {
var children = node.children;
for (var i = 0; i < children.length; i++) {
children[i].field.checked = node.field.checked;
cascadeNodeChecks(children[i]);
}
}
lib.setAccess(win, false);
var node = _this._allNodes[index];
cascadeNodeChecks(node);
if (node.field.checked) {
var parent = node.parent;
while (parent != null && parent.field != null) {
parent.field.checked = node.field.checked;
parent = parent.parent;
}
}
}
/**
* Renders node, recursing through all kids, if present, and appending HTML to parent provided.
*
* @param parent parent HTML element to append generated HTML to
* @param parentNode parent node object
* @param json JSON containing node data
* @private
*/
function _doRender(parent, parentNode, json) {
var node = json.node;
var kids = json.children;
parentNode = _renderListItem(node, _this._counter++, parentNode);
$(parent).append(parentNode.html);
if (kids.length > 0) {
var html = $("<ul></ul>");
$(parentNode.html).append(html);
$.each(kids, function (i, kid) {
return _doRender(html, parentNode, kid);
});
}
}
/**
* Is called to generate LI tag containing checkbox and caption (or a link, if a URL is present in
* node JSON).
*
* @param node the JSON object containing info used to render checkbox
* @param index the unique counter value for this instance
* @param rootNode the parent node for this instance
* @param [imgSrc] optional - if present, renders an image link
* @param [expandAction] optional - if present, is Lib funnction to call on click
*
* @returns {{html: (*|jQuery|HTMLElement), field: *, children: Array, parent: *}} new node object
* @private
*/
function _renderListItem(node, index, rootNode, imgSrc, expandAction) {
var name = node.name;
var value = node.value;
var checked = node.isChecked;
var caption = node.caption;
var url = node.url; // ensure values are null rather than undefined if not provided (unsure if any explicit null-checks occur below)
imgSrc = imgSrc === void 0 || imgSrc == "null" ? null : imgSrc;
expandAction = expandAction === void 0 || expandAction == "null" ? null : expandAction;
var listItem = $("<li></li>"); // the list item content item
var item;
if (imgSrc != null && expandAction != null) {
item = $("<a></a>").attr("href", "#".concat(value));
$(item).click(function (event) {
try {
return lib[expandAction](win, value, index);
} catch (e) {
_log(e);
}
});
var img = $("<img />").attr("border", "0").attr("src", imgSrc);
$(item).append(img);
} else if (imgSrc != null) {
item = $("<img />").attr("src", imgSrc).attr("border", "0");
}
if (item) {
$(listItem).append(item);
}
var input = $("<input />").attr("type", "checkbox").attr("name", name).attr("value", value);
if (checked) {
$(input).attr("checked", "checked");
}
$(input).click(function (event) {
cascadeChecks(this, index);
});
$(listItem).append(input);
if (!url) {
$(listItem).append(win.document.createTextNode(caption));
} else {
url = url.indexOf("http://") == 0 ? url : "http://" + url;
var a = $("<a></a>").attr("target", "_blank").attr("href", url).text(caption);
$(listItem).append(a);
}
var newNode = {
"html": listItem,
"field": input[0],
"children": [],
"parent": rootNode
};
newNode.parent.children.push(newNode);
_this._allNodes.push(newNode);
return newNode;
}
/**
* Is called to assemble checkboxes and inject into DOM.
*/
this.render = function () {
var script = $("script#".concat(scriptId));
json = $.parseJSON(json);
var ul = $("<ul></ul>");
_doRender(ul, _this._rootNode, json);
$(ul).insertAfter(script);
};
}
/**
* Default globaal error handler - redirects to error.jsp.
*
* @param msg
* @param url
* @param ln
*/
function handleError(msg, url, ln) {
_log(new Error(msg), true); // if (top.frames.length > 1 && top.frames[1].name == 'sss_dynomite') {
// top.sss_dynomite.window.document.location.replace(
// '/ats/jserror.jsp?msg=' + escape(msg) + '&url=' + escape(url) + '&line=' + ln
// );
// if (!_this.loaded) {
// top.document.location.replace(
// '/ats/error.jsp?msg=' +
// 'There+was+an+internal+error.++You+have+been+logged+out.' +
// '++Please+close+all+browsers+and+try+again.&showback=N'
// );
// self.open(
// '/ats/logout.jsp?missedlogout=Y', 'Logout',
// 'location=no,menubar=no,titlebar=no,personalbar=no,height=1,width=1');
// }
// }
// else {
// top.document.location.replace(
// '/ats/error.jsp?msg=' +
// 'There+was+an+internal+error.++You+have+been+logged+out.' +
// '++Please+close+all+browsers+and+try+again.&showback=N'
// );
// self.open('/ats/jserror.jsp?msg=' + escape(msg) + '&url=' + escape(url) + '&line=' + ln + '&closeWindow=Y', 'jserror');
// self.open('/ats/logout.jsp?missedlogout=Y', 'Logout', 'location=no,menubar=no,titlebar=no,personalbar=no,height=1,width=1');
// }
}
/**
* Error handler that reports error without redirecting user.
* @param msg
* @param url
* @param ln
*/
function displayError(msg, url, ln) {
_log(msg);
} // do NOT add window.onerror if addGlobalErrorHandler has been set to explicit false
window.onerror = init.addGlobalErrorHandler === false ? null : this.isDevMode ? displayError : handleError; // add lib properties as instance properties
$.each(lib, function (name, val) {
return _this[name] = val;
});
_this.perform_cookie_test();
onLoadCallback.call(this, this); // send in 'lib' instance as arg to onLoad
this.loaded = true;
}
|
console-api |
debug |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 16080)
Message:
Assigning value to moduleName Lib function Lib(init) {
// see if instantiation should return global instance
if (init && init.getGlobalInstance && window.top._lib) {
return window.top._lib;
} // check for and set global instance
if (!window.top._lib) {
window.top._lib = this;
} // It's not good form, but these locals are used to help with staged lookup.
var isActiveDirectory = init.isActiveDirectory; // <%= (companyRecord.get("AUTH_URL") != null) %>;
var companyId = init.companyId; // <% out.println("'" + companyId + "'" + ";"); %>
var sessionId = init.sessionId; // '<%= key %>'
var onLoadCallback = init.onLoad || function () {}; // function to call when Lib instance has been assembled
this.isDevMode = configuration.developmentMode; // flag indicating if all JS components have been loaded...affects behavior of error reporting
this.loaded = false;
var _this = this; // collection of nodes used in setParent() and assureChildrenMatch()
var parents = []; // collection of nodes used in setParent() and assureParentSelected()
var kids = []; // collection used in initPageCollapse() and pageCollapse()
var hiddenDivs = {}; // collection used in getCheckboxElement() and setCheckboxElements()
var checkboxElements = [];
var jqueryUniversalChangeSupportedTags = ":input[type!=hidden]";
var jqueryUniversalChangeSupportedEvents = ["change", "select", "click", "blur"]; // cached result of call to perform_cookie_test()
var cookie_test = false;
/**
* Selector string used to serve as context for calls to addDependentField. If null, will use document
* as context (is used to search for a field ONLY in context of modal content).
*
* @type {string}
*/
var dependentFieldCtx = null;
/**
* Simple function used to log message strings and Error instances to the console, if the console object
* is available (may not be in older browser environments). Will only log if isDevMode is true.
*
* @param {string|Error} message
* @param {boolean} [override] if present and true, will log whether or not in dev mode
*/
var _log = function log(message, override) {
return logger.log(message);
}; // init accessNextPage and loading flags
setGlobalData("Lib.accessNextPage", true);
setGlobalData("Lib.loading", false); // internal helper functions
/**
* Sets a global attribute value. Will log and ignore if unable to do so (i.e. window.top is disposed).
*
* @param key
* @param value
*/
function setGlobalData(key, value) {
_log("Setting '".concat(key, "' attribute to value '").concat(value, "'"));
try {
if (window && window.top) {
$(window.top).data(key, value);
} else {
_log("Can not set '".concat(key, "' attribute with value '").concat(value, "', top window is not available."));
}
} catch (e) {
// getting 'Can't execute code from a freed script' errors in IE...just log and return
_log(new Error("Can not set '".concat(key, "' attribute with value '").concat(value, "': ").concat(e.message)));
}
}
/**
* Gets a global attribute value. Will log and return null if unable to do so (i.e. window.top is disposed).
*
* @param key
* @returns {*}
*/
function getGlobalData(key) {
_log("Getting '".concat(key, "' attribute value."));
try {
if (window && window.top) {
var value = $(window.top).data(key);
_log("Attribute '".concat(key, "' has value '").concat(value, "'"));
return value;
} else {
_log("Can not get '".concat(key, "' attribute value, top window is not available."));
return null;
}
} catch (e) {
// getting 'Can't execute code from a freed script' errors in IE...just log and return null
_log(new Error("Can not get '".concat(key, "' attribute value: ").concat(e.message)));
return null;
}
}
/**
* Ensures that needed jQuery plugins have been loaded. Performs synchronous loading if not found.
* Returns reference to $.
*
* @param {Window} win context window
* @param {jQuery} jq the jQuery object being examined
* @returns {jQuery}
*/
function checkJQuery(win, jq) {
return jq || win.$ || $;
}
/**
* Obtains the Modal instance for the given window namespace.
*
* @param win
* @returns {Modal}
*/
function getModal(win) {
return win.document.thismodal;
}
/**
* Is called to create and open a new Modal instance using a set of default properties. The init object will
* override any defaults. An additional optional boolean may be provided to specify if instance should
* be assigned to the global modal variable (i.e. make new instance retrievable in call to {@link getModal()}.
*
* @param {Window} win the context Window
* @param {Object} init object used to initialize Modal (may contain 'attributes' property that is iterated
* through and each added to Modal attributes)
* @param {boolean} [makeGlobal] optional flag indicating if this instance should be set as global instance (default is false)
*
* @returns {Modal}
*/
function createModal(win, init, makeGlobal) {
// is called to perform style fixes on modal after it is opened
function fixDisplay(modal) {
doModalContentFix(win, modal);
}
function resizeHandler(e) {
_log("Doing resize!!!");
triggerResize(win, false);
}
init = init || {};
init.paddingTop = 80;
init.onOpen = mergeFunctions(init.onOpen, function (modal) {
$(win).on("resize", resizeHandler);
fixDisplay(modal);
});
init.onClose = mergeFunctions(init.onClose, function () {
return $(win).off("resize", resizeHandler);
});
init.openOnCreate = false; // do NOT allow for creation before setting global instance
init.context = win;
var modal = Modal.createModal(init);
if (modal) {
if (makeGlobal) {
win.document.thismodal = modal;
}
modal.open();
}
return modal;
}
/**
* Performs style/behavior fixes on Modal and content.
*
* @param win
* @param modal
*/
function doModalContentFix(win, modal) {
var content = $(modal.getContent(true));
var $content = $(content);
$content.closest(".vex").css("padding-top", "40px");
$content.closest(".vex").find(".vex-dialog-input").css("overflow", "auto"); // also, remove PageParagraphContainer/PageMainContainer ids to remove static CSS widths
$content.find("#PageParagraphContainer").removeAttr("id");
$content.find("#PageMainContainer").removeAttr("id"); // give buttons same LnF as Modal buttons
$content.find("input[type=\"submit\"], input[type=\"reset\"], input[type=\"file\"]").addClass("vex-dialog-button vex-dialog-button-primary ss-modal-ok").css({
"margin-top": "5px",
"float": "none"
}); // Prevent submit button from being clicked multiple times
$content.find("input[type=\"submit\"]").click(function () {
var $footContainer = $content.find("#footContainer");
var $pagebuttons = $footContainer.find(".pagebuttons");
$pagebuttons.hide();
$footContainer.append($("<img src=\"https://cdn.searchsoft.net/images/loading.gif\" class=\"preventMultipleSubmitButtonClickSpinner\" />"));
});
$content.find("input[type=\"button\"]").addClass("vex-dialog-button vex-dialog-button-secondary ss-modal-cancel").css({
"margin-top": "5px",
"float": "none"
});
$(".linkbutton, .wizardlink").click(function () {
return win.setTimeout(function () {
doModalContentFix(win, modal);
triggerResize(win, false);
}, 15);
});
}
/**
* Is called to do an operation with the current Modal instance, if it is non-null and only if its open,
* if the ifOpen flag is true. The callback will be provided the Modal instance and reference to the Modal
* content (as a jQuery object) as args (i.e. function(modal, jq) { // do something } ).
*
* @param win
* @param ifOpen
* @param fn
*/
function doModalOp(win, ifOpen, fn) {
var modal = getModal(win);
if (!modal) {
return;
}
if (!modal.isOpen() && ifOpen) {
return;
}
try {
fn(modal, modal.getContent(true));
} catch (e) {
// this could POTENTIALLY be called on a modal in a frame that has expired...catch, log and continue
_log(e);
}
}
/**
* Is called to trigger events and handle common behavior when content has changed such that re-flow or
* resizing of content should occur.
*
* @param win
* @param {boolean} [doTrigger] optional boolean flag indicating if 'resize' event should be triggered (default is true)
* @param {boolean} [keepWidth] optional boolean flag indicating if resizing should constrain width (default is false)
*/
function triggerResize(win, doTrigger, keepWidth) {
doTrigger = doTrigger !== false;
if (doTrigger) {
$(win).triggerHandler("resize");
}
keepWidth = keepWidth === true;
doModalOp(win, true, function (modal, content) {
var queue = win["_triggerResizeQueue"] || {
/**
* @type {number}
*/
"timeoutId": null
};
win["_triggerResizeQueue"] = queue;
if (queue.timeoutId !== null) {
window.clearTimeout(queue.timeoutId);
}
queue.timeoutId = window.setTimeout(function () {
try {
modal.resizeContent(keepWidth);
} catch (e) {
// as this being called in a timeout, modal may be contained in an expired frame...
_log(e);
}
}, 15);
});
}
function isChecked(win, id) {
var elem = getCheckboxElement(win, id);
return elem.checked;
}
function getCheckboxElement(win, id) {
return checkboxElements[id];
}
function checkCheckBox(win, id, val, doParent) {
var elem = getCheckboxElement(win, id);
if (elem) {
elem.checked = val;
if (doParent) {
lib.assureParentSelected(win, id);
}
}
return true;
}
function emailCheck(emailStr, win, field) {
/* The following pattern is used to check if the entered e-mail address
fits the user@domain format. It also is used to separate the username
from the domain. */
var emailPat = /^\s*(.+)@(.+)$/;
/* The following represents chars _not_ allowed in an local part of an address
These characters include ( ) < > @ , ; : \ " . [ ] Where . is later allowed
back in. */
var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
/* The following string represents the range of characters allowed in a
username or domainname. It really states which chars aren't allowed.*/
var validChars = "[^\\s".concat(specialChars, "]");
/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes). E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */
var quotedUser = "(\"[^\"]*\")";
/* The following string represents an atom (basically a series of non-special characters.) */
var atom = "".concat(validChars, "+");
/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */
var word = "(".concat(atom, "|").concat(quotedUser, ")"); // The following pattern describes the structure of the user
var userPat = new RegExp("^".concat(word, "(\\.").concat(word, ")*$"));
/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. Domain atom must be two or
more chars and not start or end with a '-' */
var domainAtom = "[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9]+)*";
var domainPat = new RegExp("^".concat(domainAtom, "(\\.").concat(domainAtom, ")+\\s*$"));
/* The following pattern applies for domains that are IP addresses,
rather than symbolic nam es. E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */
var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
/* Finally, let's start trying to figure out if the supplied address is valid. */
/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */
var matchArray = emailStr.match(emailPat);
if (matchArray == null) {
/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */
invalidField(win, field, "The email address seems incorrect (check @ and .'s)");
return false;
}
var user = matchArray[1];
var domain = matchArray[2]; // Start by checking that only basic ASCII characters are in the strings (0-127).
for (var i = 0; i < user.length; i++) {
if (user.charCodeAt(i) > 127) {
invalidField(win, field, "The email username contains invalid characters.");
return false;
}
} // See if "user" is valid
if (user.match(userPat) == null) {
// user is not valid
invalidField(win, field, "The email username doesn't seem to be valid.");
return false;
}
/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */
var IPArray = domain.match(ipDomainPat);
if (IPArray != null) {
// this is an IP address
for (var _i = 1; _i <= 4; _i++) {
if (IPArray[_i] > 255) {
invalidField(win, field, "Email destination IP address is invalid!");
return false;
}
} // the remain tests are not valid
return true;
} // Domain is symbolic name. Check if it's valid.
var domArr = domain.match(domainPat);
if (domArr == null) {
invalidField(win, field, "The email domain name does not seem to be valid.");
return false;
} // confirm that tld is two more more, note sub-group is always assigned last match
if (!(domArr[1].length > 2)) {
invalidField(win, field, "The email address has an invalid tld domain. Are you missing .com?");
return false;
} // Confirm domain is not overly long
if (domain.length > 255) {
invalidField(win, field, "The email address has to long a domain name.");
return false;
} // Confirm peices of domain are not indivuial to long
for (var _i2 = 0; _i2 < domArr.length - 1; _i2++) {
if (domArr[_i2].length > 63) {
invalidField(win, field, "The email address domain name is to long.");
return false;
}
} // If we've gotten this far, everything's valid!
return true;
}
function getFieldValue(win, field) {
// Passing win as an argument to fix "Permission denied" error in IE
// SSOFT-5666
var $ = win.$;
var value = "";
var type = field.type || $(field).attr("type");
if (type) {
if (type.indexOf("select-") >= 0) {
if (field.selectedIndex >= 0) {
value = field.options[field.selectedIndex].value;
}
} else if (type.indexOf("check") >= 0 || type.indexOf("radio") >= 0) {
if (field.checked) {
value = field.value;
}
if (field.length) {
for (var j = 0; j < field.length; j++) {
if (field[j].checked) {
value = field[j].value;
}
}
}
} else {
value = field.value;
}
} else if (field.length) {
// I think this code is making an assumption
// that if there is no 'type' then it must be a
// checkbox.
for (var _j = 0; _j < field.length; _j++) {
if (field[_j].checked) {
value = field[_j].value;
}
}
}
if (value == null) {
value = "";
}
return value;
}
/**
* Replaces a old Field's listeners' with a pointer to the new field.
**/
function reassignFieldListeners(oldField, newField) {
// find the form, assume all fields are in the same form
var form;
if (oldField.length) {
form = oldField[0].form;
} else {
form = oldField.form;
} // if we couldn't find the form, give up. This means were using an oldField
// not in a form anymore. This should never happen.
if (!form) {
return;
}
for (var i = 0; i < form.validatorFields.length; i++) {
if (form.validatorFields[i] == oldField) {
form.validatorFields[i] = newField;
}
}
for (var _i3 = 0; _i3 < form.maskValidatorFields.length; _i3++) {
if (form.maskValidatorFields[_i3] == oldField) {
form.maskValidatorFields[_i3] = newField;
}
}
}
/**
* Checks newField against the listeners of oldField.
**/
function validNewField(win, oldField, newField) {
// Hack that fixes https://peopleadmin.atlassian.net/browse/SSOFT-5354?focusedCommentId=231565&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-231565
if (newField[0] === undefined) {
newField[0] = oldField[0];
} // find the form
var form;
if (oldField.length) {
form = oldField[0].form;
} else {
form = oldField.form;
} // if we couldn't find the form, say its valid. This means were validating
// against a field not in a form anymore. This should never happen.
if (!form) {
return true;
} // run over all validation function and run them against the new field
for (var i = 0; i < form.validatorFields.length; i++) {
if (form.validatorFields[i] == oldField) {
if (!form.validatorFunctions[i](win, newField)) {
return false;
}
}
}
for (var _i4 = 0; _i4 < form.maskValidatorFields.length; _i4++) {
if (form.maskValidatorFields[_i4] == oldField) {
if (!form.maskValidatorFunctions[_i4](win, newField, form.maskValidatorMasks[_i4])) {
return false;
}
}
}
return true;
}
/**
* Run all validator functions for a specified form.
**/
function validFields(win, form) {
win.runningValidFields = true;
for (var i = 0; i < form.validatorFunctions.length; i += 1) {
// if the field is not in the checking form anymore ignore it
if (!fieldInForm(form, form.validatorFields[i])) {
continue;
} // run the listeners
if (!form.validatorFunctions[i](win, form.validatorFields[i])) {
win.runningValidFields = false;
return false;
}
}
for (var j = 0; j < form.maskValidatorFunctions.length; j += 1) {
// if the field is not in the checking form anymore ignore it
if (!fieldInForm(form, form.maskValidatorFields[j])) {
continue;
} // run the listeners
if (!form.maskValidatorFunctions[j](win, form.maskValidatorFields[j], form.maskValidatorMasks[j])) {
invalidField(win, form.maskValidatorFields[j], "".concat(form.maskValidatorFields[j].value, " is not in the correct format."));
win.runningValidFields = false;
return false;
}
}
win.runningValidFields = false;
return true;
}
/**
* Test if a field is in a given form (wrapper).
**/
function fieldInForm(form, field) {
// defines a private function to do the real work
function fieldInFormReal(field) {
for (var i = 0; i < form.elements.length; i++) {
if (form.elements[i] == field) {
return true;
}
}
return false;
} // if field is not defined, claim it exists
if (!!!field) {
return true;
} // if array test for each
// if it has a length and not a type
if (field.length && !field.type) {
// when less than 500 check all fields
if (field.length < 500) {
for (var i = 0; i < field.length; i++) {
if (!fieldInFormReal(field[i])) {
return false;
}
}
} // performance hack for IE, if one exists all exist
else {
if (!fieldInFormReal(field[0])) {
return false;
}
}
return true;
} // field is defined check that it is in the form
return fieldInFormReal(field);
}
function getMultiNumberChecked(win, fields) {
var numberChecked = 0; // array of check-box, radio, option, or select
if (fields.length) {
for (var i = 0; i < fields.length; i++) {
// check-box, radio
if (fields[i].checked) {
numberChecked++;
} // option
else {
if (fields[i].selected) {
numberChecked++;
} // select
else {
if (fields[i].options) {
numberChecked += getMultiNumberChecked(win, fields[i].options);
}
}
}
}
} // select object
else if (fields.options && fields.options.length > 0) {
numberChecked = getMultiNumberChecked(win, fields.options);
} // single field
else if (fields.checked || fields.selected) {
numberChecked = 1;
}
return numberChecked;
}
/**
* Returns array of form objects that have an element that matches
* fieldName.
**/
function getFormObjects(win, fieldName) {
var result = [];
var forms = win.document.forms;
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
if (form.elements[fieldName]) {
result.push(form);
}
}
return result;
}
function stripSymbols(field) {
var value = field.value;
if (value !== undefined) {
field.value = value.replace(/(\$|\,|\(|\)|\&)/g, "");
}
}
function getFormattedDate(field, shortDate) {
var date = field.value.replace("-", "/");
var li = date.lastIndexOf("/");
if (date.length - li == 3) {
var cent = "20";
var yr = date.substring(li + 1, li + 3);
if (yr > "30") {
cent = "19";
}
date = date.substring(0, li + 1) + cent + yr;
}
return date;
}
function isValidDate(value, shortDate) {
var month;
var day;
var year;
var date;
var i;
for (i = 1; i < value.length; i++) {
var testValue = value.substring(i, i + 1);
if (isNaN(testValue) && testValue != "/" && testValue != "-" && testValue == " ") {
return false;
}
}
date = value;
if (date != "") {
i = date.indexOf("/");
if (i < 1) {
return false;
}
month = date.substring(0, i);
if (month.length < 1 || month.length > 2 || month.charAt(0) > "9" || month == 0 && i == 1) {
// || month.charAt(0)<'0'
return false;
}
if (month.substring(0, 1) == "0") {
month = month.substring(1, 2);
}
month = parseInt(month);
if (!shortDate) {
date = date.substring(i + 1);
i = date.indexOf("/");
if (i < 1) {
return false;
}
day = date.substring(0, i);
if (day.length < 1 || day.length > 2 || day.charAt(0) > "9") {
// || day.charAt(0)<'0'
return false;
}
if (day.substring(0, 1) == "0") {
day = day.substring(1, 2);
}
day = parseInt(day);
}
year = date.substring(i + 1);
if (year.length != 4 || year.charAt(0) < "0" || year.charAt(0) > "9") {
return false;
}
year = parseInt(year);
if (month < 1 || month > 12 || day < 1 || day > 31 || year < 1900 || year > 2299 || month == 2 && day > 29 || month == 2 && day == 29 && year % 4 != 0 || month == 4 && day > 30 || month == 6 && day > 30 || month == 9 && day > 30 || month == 11 && day > 30) {
return false;
}
}
return true;
}
function isValidBirthDate(field, shortdate, young, old) {
var result = true;
var birthValue = field.value;
if (shortdate) {
birthValue = birthValue.replace(/\//, "/01/");
}
var birthDate = new Date(birthValue);
var lowDate = new Date();
var highDate = new Date();
lowDate.setFullYear(lowDate.getFullYear() - old);
highDate.setFullYear(highDate.getFullYear() - young);
result = birthDate >= lowDate && birthDate <= highDate;
return result;
}
function isValidDateTime(field) {
var thisFieldValue = field.value;
var splitDate = thisFieldValue.split(" ");
if (splitDate.length != 3) {
return false;
}
if (!isValidDate(splitDate[0]), false) {
return false;
}
if (!isValidStandardTime(splitDate)) {
return false;
}
return true;
}
function isValidStandardTime(timeString) {
// We are expecting a 3-part date, time, and am/pm array
if (timeString.length != 3) {
return false;
}
if (timeString[1].length != 5) {
return false;
}
if (timeString[2].length != 2) {
return false;
}
var testValue = timeString[1].substring(0, 2);
if (isNaN(testValue)) {
return false;
}
if (timeString[1].charAt(2) != ":") {
return false;
}
var testValue = timeString[1].substring(3, 5);
if (isNaN(testValue)) {
return false;
}
if (timeString[2].toLowerCase() != "am" && timeString[2].toLowerCase() != "pm") {
return false;
}
return true;
}
function isValidNumber(num) {
var i;
var dc;
if (num.value != "") {
i = 0;
if (num.charAt(0) == "-") {
i = 1;
if (num.length == 1) {
return false;
}
}
dc = 0;
for (; i < num.length; i++) {
if (num.charAt(i) == ".") {
if (dc > 0 || i == num.length - 1) {
return false;
}
dc++;
} else if (num.charAt(i) < "0" || num.charAt(i) > "9") {
return false;
}
}
}
return true;
}
/**
* Adds fun (function) to element with an apporiate on change listener
*
* @param elem is dom
**/
function jqueryUniversalChange(win, elem, fun) {
var $ = win.$;
$(elem).bind(jqueryUniversalTriggerType(win, elem), fun);
}
function jqueryUniversalTriggerType(win, elem) {
// For SSOFT-5625
// In Internet Explorer 11/Edge, the attr call below was causing a "Permission denied" error
var $ = win.$;
var triggerType;
switch (elem.tagName.toUpperCase()) {
case "INPUT":
switch ($(elem).attr("type").toUpperCase()) {
case "RADIO":
case "CHECKBOX":
case "BUTTON":
triggerType = "click change";
break;
case "PASSWORD":
case "TEXT":
triggerType = "blur change";
break;
case "FILE":
triggerType = "change";
break;
default:
triggerType = "change select click blur";
break;
}
break;
case "TEXTAREA":
triggerType = "blur change";
break;
case "SELECT":
triggerType = "blur change";
break;
default:
triggerType = "change select click blur";
break;
}
return triggerType;
}
/**
* Is called to ensure that username conforms to rules and standards.
*
* @param win
* @param username
* @param password
* @returns {boolean}
*/
function checkFormatting(win, username, password) {
var p = password;
var u = username;
var message = "";
var result = true;
var low = 6;
if (companyId != "00008698" && !isActiveDirectory && win.document.location.href.indexOf("employee_form") < 0) {
// Account Information Page (Applicants can change just their username)
if ((p == null || p.value == "") && u != null && u.value != "") {
u = u.value;
if (u.length < low) {
message = "The username is invalid. Usernames must be at least ".concat(low, " characters in length, should not include spaces, and must not be identical to the password.");
invalidField(win, username, message);
result = false;
}
}
}
return result;
}
function makeTestCookie() {
document.cookie = "cookietest=yes;path=/";
}
function findTestCookie() {
if (document.cookie.length > 0 && window.navigator.cookieEnabled) {
var test = document.cookie.indexOf("cookietest=");
if (test !== -1) {
return true;
}
}
return false;
}
/**
* Toolbox, binds pop-up to a select box.
**/
function toolboxRegisterSelection(win, uid) {
var $ = win.$;
var actionSelect = $("#".concat(uid, "_action_select"));
var myForm = actionSelect.closest("form"); // add a content section if one does not exist
if (!myForm.find("#inlineContent").length) {
myForm.append("<div id=\"inlineContent\" style=\"height: 30ex\"></div>");
}
var onDefaultActionOrUndo = function onDefaultActionOrUndo() {
$("#inlineContent").html("").css("height", "30ex"); // Reactivate button-based tools
win.toolbox[uid]._parent.append(win.toolbox[uid]);
}; // HE-3345 (https://jira.powerschool.com/browse/HE-3345?focusedCommentId=2294798&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-2294798)
// Whenever undo button is clicked, removes the fields related to the previous selected value on Workflow Forms
$("form input:reset[name=\"undo\"]").click(function () {
return onDefaultActionOrUndo();
});
actionSelect.change(function () {
// what item is selected
var item = $("#".concat(uid, "_action_select option:selected")).attr("value");
var autoSubmit = false; // bail if default
if (item == "default") {
onDefaultActionOrUndo();
return false;
} else {
// Deactivate button-based tools
win.toolbox = win.toolbox || {};
win.toolbox[uid] = win.toolbox[uid] || $("#toolbox_".concat(uid));
win.toolbox[uid]._parent = win.toolbox[uid]._parent || win.toolbox[uid].parent();
$("#toolbox_".concat(uid)).remove();
} // is there a hidden div
if ($("#".concat(item)).length) {
// get content
var content = $("#".concat(item)).clone();
content.attr("class", content.attr("id"));
content.attr("id", "");
$("#inlineContent").html(" ").append(content);
content.show();
} // if no hidden content auto-submit
else {
autoSubmit = true;
}
toolboxRunFunction(win, item);
if (autoSubmit) {
// if no hidden content
win.document.forms[0].submit();
}
});
}
/**
* Toolbox, bind pop-up to "Go" button.
**/
function toolboxRegisterActionGo(win, uid) {
var $ = win.$; // bind to click of button
$("#".concat(uid, "_go")).click(function () {
var $ = win.$; // what item is selected
var item = $("#".concat(uid, "_action_select option:selected")).attr("value");
var autoSubmit = false; // bail on default action
if (item === "default") {
win.alert("Please select an action to perform.");
return false;
}
var allRecordsInTheListAllPagesSelected = $("select[name=\"ACTION_TYPE\"]").val() === "all";
if (allRecordsInTheListAllPagesSelected) {
// "Assign Document(s)" action
if (item === "RA00000002") {
win.alert("At most 100 recipients can be assigned eForms at a time. Please select no more than 100 recipients and try again.");
return false;
}
} else if ($("div.rs tbody :checkbox:checked").length === 0) {
// when no items selected bail
win.alert("Please select the records on which to perform the action.");
return false;
} // is there a hidden div
if ($("#".concat(item)).length) {
lib.showPopup(win, item);
} // if no hidden content auto-submit
else {
autoSubmit = true; // run action's funciton if exists
if (!toolboxRunFunction(win, item)) {
// no function add a hidden input option=option (as we are autosubmiting)
lib.addHiddenField(win, item, item);
}
}
if (autoSubmit) {
// if no hidden content
win.document.forms[0].submit();
}
});
}
function closePopupFirst(win, fun) {
Modal.closeAll(win, function () {
return fun(win);
});
}
/**
* Toolbox utilty, run function tied to a option. If the function is not
* defined return false.
**/
function toolboxRunFunction(win, fun) {
// confirm we have functions and this function is defined
if (!win.toolboxFunctions || !win.toolboxFunctions[fun]) {
return false;
} // run the function
try {
win.toolboxFunctions[fun]();
triggerResize(win);
} catch (e) {
return false;
}
return true;
}
/**
* Toolbox utility, add and enable a cancel button to popups
**/
function toolboxAddCancel(win, item) {
doModalOp(win, true, function (modal, content) {
modal.enableCancel(true); // need to ensure that all 'Cancel' button just close Modal (and not do history-back behavior)
$(content).find("input[name='cancel']").attr("onclick", "").click(function (e) {
e.preventDefault();
modal.close();
return false;
});
});
}
/**
* Returns true if the provided url and request data are valid for making an Ajax call to server. This is
* needed to overcome issues where library.js adds unintended behavior to elements, such that spurious
* Ajax calls are made.
*
* @param url url of Ajax call
* @param data query string or post data to be sent in request
* @return {boolean} true if the call can be made, false if it is not valid
*/
function canMakeAjaxCall(url, data) {
if (url == "#") {
_log("NOT making Ajax call, no valid URL provided (url is '#').");
return false;
} // put additional checks here as needed
return true;
}
/**
* Toolbox utility, fill-in a popup with data.
*
* @param win window object do operate in
* @param id of div to opeerate on in pop-up
* @param url of page to fetch and display
* @param hijack if to capture submit and then close pop-up
* @param hijackStayOpen if when capturing submit to dispaly the result
**/
function ajaxFillinPopup(win, id, url, sdata, hijack, hijackStayOpen, devmode) {
if (!canMakeAjaxCall(url, sdata)) {
return;
}
var $ = win.$; // add ajax notification for server
if (sdata == null) {
sdata = "ajax=y";
} else if (sdata.indexOf("ajax=") == -1) {
sdata += "&ajax=y";
} // avoid get length limit in IE
var method = "get";
if (sdata.length + url.length > 2000) {
sdata += "&fake_post=Y";
method = "post";
} // handle error
$(win.document).ajaxError(function (event, request, settings) {
return _log("Server error: ".concat(request.status, " url: ").concat(settings.url));
}); // if a popup
var modal = getModal(win);
if (modal && modal.isOpen()) {
dependentFieldCtx = ".searchsoft-modal"; // get content
$[method](url, sdata, function (data, rstatus) {
if (rstatus == "success") {
var modalContent = $(modal.getContent(true));
var selector = "div#inlineContent";
var content = $(modalContent).find("div#inlineContent");
if (!content.length) {
content = $(modalContent).find("div#".concat(id));
selector = content.length ? "div#".concat(id) : null;
}
modal.setContent(data, selector);
content = $(modal.getContent(true)); // will return a reference to content
afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode);
} else {
throw "AJAX error getting content";
}
}, "text").always(function () {
// reset after each call
dependentFieldCtx = null;
});
} // inline
else {
// get content
$.get(url, sdata, function (data, rstatus) {
if (rstatus == "success") {
var content = $("#inlineContent div.".concat(id)).html(data);
$("#inlineContent").css("height", "auto");
afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode); // initilize forms
lib.initForms(win);
} else {
throw "AJAX error getting content";
}
}, "text");
}
}
function afterAjaxPopProcess(win, id, content, sdata, hijack, hijackStayOpen, devmode) {
var $ = win.$; // initilize forms
lib.initForms(win); // add what applicants to effect
lib.addCheckboxApplicants(win, id); // add/enable cancel
toolboxAddCancel(win, id); // add redirect if one does not exist
addMissingPopupRedirect(win, id); // for is_changed
alwaysIsChanged(win, id); // move buttons to top of devmenu items
if (devmode) {// TODO: #modal
/*
$("#simplemodal-container div#" + id + " div.pagebuttons").css({
'position': 'absolute',
'left': '50px',
'top': '-20px'});
*/
}
if (_this.isDevMode) {
// cause menu links to open in same window
content.find(".devmenulink, .wizardpopup").addClass("wizardlink").removeClass("wizardpopup");
content.find("div.rs a[href!='#ConfirmDelete'], div.rsrange a[href!='#ConfirmDelete']").addClass("wizardlink");
devmode = true;
} // hijack submit
if (hijack) {
// allows for fancy wizard stuff
hijackPopupSubmit(win, id, sdata, hijack, hijackStayOpen, devmode);
} else {
// simply provide a spinner
popUpFormSpinner(win);
}
var modal = getModal(win);
if (modal) {
doModalContentFix(win, modal);
} // wizard links
content.find(".wizardlink").click(function (e) {
var target = $(this).attr("href"); // do check for valid call BEFORE calling preventDefault and hiding form content
if (!canMakeAjaxCall(target, null)) {
return;
}
e.preventDefault();
if (modal) {
var _content = modal.getContent(true);
$(_content).find("form").hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
ajaxFillinPopup(win, id, target, null, hijack, hijackStayOpen, devmode);
return false;
});
if (hijackStayOpen) {
var button = content.find(".linkbutton");
button.each(function () {
this.onclick = function () {
return true;
};
$(this).click(function (e) {
var target = $(this).attr("href"); // do check for valid call BEFORE calling preventDefault and hiding form content
if (!canMakeAjaxCall(target, sdata)) {
return;
}
e.preventDefault();
if (modal) {
var _content2 = modal.getContent(true);
$(_content2).find("form").hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
ajaxFillinPopup(win, id, target, sdata, hijack, hijackStayOpen, devmode);
return false;
});
});
} // normal form styles
if (modal) {
lib.addStyleClasses(win, modal.getContent(true));
}
lib.addStyleClasses(win, "#inlineContent .".concat(id));
triggerResize(win);
}
/**
* Toolbox utility; adds a redirect parameter to a form if one does not exist on the page.
**/
function addMissingPopupRedirect(win, id) {
var $ = win.$;
if (!$("input[name='searchpage']").length) {
var loc = win.location;
doModalOp(win, true, function (modal, content) {
return $(content).find("form").append("<input type=\"hidden\" name=\"searchpage\" value=\"".concat(loc.pathname).concat(loc.search, "\" />"));
});
}
}
/**
* All pop-ups always submit
**/
function alwaysIsChanged(win, id) {
var $ = win.$;
doModalOp(win, true, function (modal, content) {
return $(content).find("input[name='is_changed']").val("true");
});
}
function popUpFormSpinner(win) {
var $ = win.$; // stops double submits for slow pages
doModalOp(win, false, function (modal, content) {
return $(content).closest("form").submit(function (e) {
// test that form is valid
var form = $(this);
var formObj = form.get(0);
var checkScript = formObj.onsubmit;
var result = !checkScript || checkScript.apply(formObj);
if (!(result === false)) {
if (form.attr("target") && form.attr("action").lastIndexOf("/servlet/jasper", 0) === 0) {
// there is a "target" outside of our frame; show a message with a "back to form" link
form.hide().after("<div id='reportmessage'><p>Your report will be downloaded shortly." + " This could take up to several minutes." + " Feel free to close this window.</p>" + "<p>If your report does not download shortly, please go back and try again.</p>" + "<p><a href='#' id='submitshowformagain'> Go Back to Form </a></p></div>");
$("#submitshowformagain").click(function (e) {
e.preventDefault();
form.next("#reportmessage").remove();
form.show();
return false;
});
} else {
form.hide().after("<h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
}
} else {
e.preventDefault();
}
return result;
});
});
}
/**
* Toolbox utility; hijacks submit of a pop-up and sends with AJAX.
*
* Useful for:
* recursive submitting pop-ups (aka Wizard)
* pages that return JavaScript (aka JSON)
*
* @param win window object to operate in
* @param id of div that gets ajax
**/
function hijackPopupSubmit(win, id, sdata, hijack, stayOpen, devmode) {
var $ = win.$;
doModalOp(win, false, function (modal, content) {
return $(content).find("form:not([target])").submit(function (event) {
// stop default
event.preventDefault(); // test that form is valid
var checkScript = $(this).prop("onsubmit");
if (checkScript && !checkScript.apply(this)) {
return;
} // useful nodes
// what data and to where
var data = $(this).serialize();
data += "&ajax=y";
var actionUri = $(this).attr("action"); // is this a searching form (method=GET)
var method = $(this).attr("method");
if (method == null || method.toUpperCase() == "GET") {
method = "get";
} else {
method = "post";
} // show loading text
var div = $("<div><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>").attr("id", id);
modal.setContent(div); // AJAX submit
$[method](actionUri, data, function (rdata, rstatus) {
if (rstatus == "success") {
if (stayOpen) {
var _content3 = div.html(rdata);
afterAjaxPopProcess(win, id, _content3, sdata, hijack, stayOpen, devmode);
} else {
if (/error has occured/.test(rdata) && devmode) {
div.html("<h1> Failure </h1>");
div.append("<p>CAUTION: Developer <a id='hijackretry' href='#'>Retry</a>. Will not provide success or failure message! Check your console</p>");
div.append("<xmp> ".concat(rdata, "</xmp>"));
$("#hijackretry").click(function () {
return $.post(actionUri, data);
});
} else if (/ajaxerror/.test(rdata)) {
div.html(rdata);
} else {
div.html("<h1> Success </h1>");
modal.close();
}
}
} else {
throw new Error("AJAX error");
}
}); // stop form submit
return false;
});
});
}
/**
* Utility for missed field pop-up.
* May be removed when classic is gone.
**/
function invalidField(win, field, message) {
// Fixes HE-3875
var $vexDialogInput = $(field).closest(".vex-dialog-input");
$vexDialogInput.find(".pagebuttons").show();
$vexDialogInput.find(".preventMultipleSubmitButtonClickSpinner").remove();
if (win.fieldPrompt) {
win.fieldPrompt(field, message);
} else {
win.alert(message);
}
}
/**
* Utility function to normalized an array.
* Returns the normalized array
**/
function trimArray(arrayToTrim) {
var result = [];
var zeroCount = 0;
for (var i = 0; i < arrayToTrim.length; i++) {
result[zeroCount++] = arrayToTrim[i];
}
return result;
}
function getNextUrlFromNavigationPulldown(win, backward) {
var pulldownFrame = win.parent.frames[0];
var pdf$ = pulldownFrame.$;
var dir = backward ? "prev" : "next";
var option = pdf$("select[name=navchoice] option:selected")[dir]();
if (option.length == 0) {
return;
}
var nextValue = option.val(); // FORMAT: sss_sub_content,/ats/application/detail/language,op=edit&APPLICANT_ID=VA00000059
var nextUrl = nextValue.substring(nextValue.indexOf(",") + 1, nextValue.lastIndexOf(","));
var qs = nextValue.substring(nextValue.lastIndexOf(",") + 1);
nextUrl += "?".concat(qs);
var location = win.location;
return nextUrl;
}
/**
* Returns a truncated toString of given function.
* @param fn
* @return {string}
*/
function displayFn(fn) {
if (!fn) {
return "null function";
}
return "".concat(fn.toString().replace(/[\s]+/gim, " ").substr(0, 50), "...");
}
/**
* Performs a synchronous retrieval of the JS source file provided. Returns the script as a string.
*/
function loadJsSource(src) {
var ajaxObj = $.ajax({
"url": src,
"dataType": "text",
"async": false
});
return ajaxObj.responseText;
} // member functions
var lib = {
// This is an array of page listeners. A page listener is defined in another
// page and has methods that can be called by functions in this library file.
// When some event happens, library will call a method belonging to the page
// listeners.
"pageListeners": [],
/**
* Simple function used to log message strings and Error instances to the console, if the console object
* is available (may not be in older browser environments). Will only log if isDevMode is true.
*
* @param {string|Error} message
* @param {boolean} [override] if present and true, will log whether or not in dev mode
*
* @deprecated Should call Utils.log() directly.
*/
"log": function log(msg, override) {
_log("Call to deprecated Lib.log() function (should call Utils.log() directly)", true);
_log(msg, override);
},
/**
* Gets value for the cookie with the given name. Returns null if none found.
*
* @param name
* @returns {*}
*/
"getCookie": function getCookie(name) {
var vals = document.cookie.split(/\s*;\s*/);
var val = null;
$.each(vals, function (i, cookie) {
var nv = cookie.split("=");
if (nv[0] == name) {
val = nv[1];
return false;
}
});
return val;
},
/**
* Gets value for given param; returns null if not present.
*
* @param param
* @returns {String}
*/
"getParam": function getParam(param) {
var qry = location.href;
var index = qry.indexOf("?");
if (index < 0) {
return null;
}
qry = qry.substr(index + 1);
var nvps = qry.split("&");
var val = null;
$.each(nvps, function (i, v) {
var nv = v.split("=");
if (nv.length != 2) {
return;
}
var n = nv[0];
if (param == n) {
val = nv[1];
return false;
}
});
return val;
},
/**
* Provides access to the Modal object (used to create and manipulate dialogs, spinners, etc.).
*
* @returns {Modal}
*/
"getModal": function getModal() {
return Modal;
},
/**
* Is called to do an Ajax load of body, putting up spinner graphic while waiting for load.
*
* @param win the context Window
* @param url the URL to fetch content from
*/
"doSlowPageLoad": function doSlowPageLoad(win, url) {
// helper function used to do loggin for onReady functions
function doFnLog(w) {
var fns = w["onReadyFunctions"];
var len = fns ? fns.length : 0;
_log("In doSlowPageLoad(".concat(url, "), win.onReadyFunctions.length=").concat(len));
}
var $ = win.$;
win.spinnerOn = true;
$(win.document).ready(function () {
doFnLog(win);
$("#slowpageloading").fadeIn(400);
_log("Doing doSlowPageLoad(".concat(url, ")"));
window.setTimeout(function () {
doFnLog(win);
$("body").load(url, function () {
win.spinnerOn = false;
var onReadyFunctions = win.onReadyFunctions || [];
doFnLog(win);
for (var i = 0; i < onReadyFunctions.length; i++) {
try {
var fn = onReadyFunctions[i];
var str = displayFn(fn);
_log("Running onReadyFunction:\n".concat(str));
fn(win);
} catch (e) {
_log(e);
}
}
});
}, 1000); // do timeout for load() call to allow spinner to display for a moment
});
},
/**
* Is called to create and render a new HierCheckboxModel instance.
*
* @param win the ccntext Window
* @param scriptId the id of the SCRIPT tag containing call to this method
* @param json the JSON node data payload
*/
"renderHierCheckboxModel": function renderHierCheckboxModel(win, scriptId, json) {
var model = new HierCheckboxModel(win, scriptId, json);
model.render();
},
"openNode": function openNode(win, id) {
return (// Do nothing. We don't need to open the children when you click a parent
true
);
},
"toggleNode": function toggleNode(win, id, hasImg) {
hasImg = hasImg == undefined || hasImg === true; // hasImg is true if not provided or if explicitly true
var img;
if (hasImg) {
img = win.document.getElementById("".concat(id, "_img"));
}
var elem = win.document.getElementById(id);
if (elem.style.display == "none") {
elem.style.display = "";
if (hasImg) {
img.src = "/ats/images/minus.gif";
}
} else {
elem.style.display = "none";
if (hasImg) {
img.src = "/ats/images/plus.gif";
}
}
},
"assureChildrenMatch": function assureChildrenMatch(win, id) {
var children = parents[id];
if (children) {
var checked = isChecked(win, id);
var length = children.length;
for (var i = 0; i < length; i++) {
var child = children[i];
checkCheckBox(win, child, checked, false);
lib.assureChildrenMatch(win, child);
}
}
return true;
},
"assureParentSelected": function assureParentSelected(win, id) {
var parent = kids[id];
if (parent) {
checkCheckBox(win, parent, true, true);
}
return true;
},
"setCheckboxElements": function setCheckboxElements(win) {
checkboxElements = [];
for (var i = 0; i < win.document.forms[0].elements.length; i++) {
var elem = win.document.forms[0].elements[i];
if (elem && elem.type == "checkbox") {
var value = elem.value;
checkboxElements[value] = elem;
}
}
},
"rmimg": function rmimg(win, companyId) {
if (!win.document.getElementById(companyId)) {
win.document.getElementById("".concat(companyId, "_img")).style.display = "none";
}
},
"setParent": function setParent(win, id, parentId) {
kids[id] = parentId;
var list = parents[parentId];
if (!list) {
list = [];
}
list = list.concat(id);
parents[parentId] = list;
},
"initPageCollapse": function initPageCollapse(doc) {
for (var guiPageId in hiddenDivs) {
lib.pageCollapse(doc, guiPageId);
}
},
"pageCollapse": function pageCollapse(doc, guiPageId) {
var button = doc.getElementById("".concat(guiPageId, "-collapse-button"));
var div = doc.getElementById(guiPageId);
if (!!div && !!button) {
var visible = div.style.display;
if (visible == "none") {
div.style.display = "";
delete hiddenDivs[guiPageId];
button.src = "/ats/images/minus.gif";
} else {
div.style.display = "none";
if (!hiddenDivs[guiPageId]) {
hiddenDivs[guiPageId] = true;
}
button.src = "/ats/images/plus.gif";
}
}
},
"pageCollapseAtsSearchMultiPage": function pageCollapseAtsSearchMultiPage(win, guiPageId) {
var $ = win.$;
var hiddenClass = "subPageContentHidden";
var clickedDivSelector = "#".concat(guiPageId, "-nonWrapper");
$(".subPageContent").not(clickedDivSelector).addClass(hiddenClass);
$(clickedDivSelector).toggleClass(hiddenClass);
setTimeout(function () {
// https://stackoverflow.com/questions/2905867/how-to-scroll-to-specific-item-using-jquery/14490167#14490167
// $(win).scrollTop($("#" + guiPageId + "-wrapper").offset().top);
$("html, body").animate({
"scrollTop": $("#".concat(guiPageId, "-wrapper")).offset().top
}, 350);
}, 350 + 1);
},
"checkSessionId": function checkSessionId(value) {
if (sessionId == null || value == null || sessionId == "" || value == "" || sessionId == "null" || value == "null") {
return true;
} else if (value == sessionId) {
return true;
} else {
// do check for session cookie first
var temp = _this.getCookie("SSS_SESSION_ID");
if (value == temp) {
// update session id first
sessionId = temp;
return true;
}
return false;
}
},
"helpLink": function helpLink(win, message) {
win.alert(message);
return false;
},
"removeFileUpload": function removeFileUpload(win, field) {
var $ = win.$;
var fieldId = "#".concat(field);
var removeLinkId = "".concat(fieldId, "_remove");
var viewLinkId = "".concat(fieldId, "_view");
var hiddenFieldId = "".concat(fieldId, "_hidden_remove");
$(removeLinkId).click(function () {
$(this).css("display", "none");
$(viewLinkId).css("display", "none");
$(hiddenFieldId).val($(fieldId).attr("value"));
$(fieldId).prop("value", " ");
$(this).closest("td").find("input[type=button]").val("Upload a File");
});
},
"checkEmail": function checkEmail(win, field) {
var validEmail = true;
var emailValue = field.value;
var emailLength = emailValue.length;
if (emailLength > 0) {
validEmail = emailCheck(emailValue, win, field);
}
return validEmail;
},
/**
* Is called to fetch company_id of the location/school selected on Request to Hire form.
*
* @param win the context Window
*/
"selectLocation": function selectLocation(win) {
var $ = win.$; // SSOFT-5225 : Set COMPANY_ID as the initially selected location/school
var $selectNameCompanyId = $("select[name='COMPANY_ID']");
var updateCookie = function updateCookie() {
return document.cookie = "COMPANY_ID=".concat($selectNameCompanyId.val(), "; path=/");
};
updateCookie();
$selectNameCompanyId.change(function () {
$("select[name='action']").val("default");
updateCookie();
$("#inlineContent").html(" ");
});
},
/**
* Is called to compare EMAIL and CONFIRM_EMAIL
*
* @param win the context Window
*/
"checkConfirmEmail": function checkConfirmEmail(win, field) {
var $ = win.$;
var email = $("#EMAIL").val().trim().toLowerCase();
var confirmEmail;
confirmEmail = field.value.trim().toLowerCase();
if (email != confirmEmail) {
invalidField(win, field, "Confirm Email should match Email.");
return false;
} else if (email == confirmEmail) {
return true;
}
},
"checkRequiredRadio": function checkRequiredRadio(win, field) {
var radioSelected = false;
var $ = win.$;
var row = $("#".concat($(field).attr("name"), "_ROW"));
if (row.css("display") == "none") {
return true;
}
if (field.length) {
for (var i = 0; i < field.length; i++) {
if (field[i].checked) {
radioSelected = true;
}
}
} else if (field.checked) {
radioSelected = true;
}
if (radioSelected) {
return true;
} else {
invalidField(win, field, "You have not filled out all required answers on this page.");
return false;
}
},
/**
* Create arrays for form validation listeners.
**/
"initForms": function initForms(win) {
function doInitForm(form) {
if (!form.initialized) {
form.validatorFunctions = new Array(0);
form.validatorFields = new Array(0);
form.maskValidatorFields = new Array(0);
form.maskValidatorFunctions = new Array(0);
form.maskValidatorMasks = new Array(0);
form.initialized = true;
}
}
var forms = win.document.forms;
if (forms) {
for (var i = 0; i < forms.length; i += 1) {
var form = forms[i];
doInitForm(form);
}
} else {
$("form").whenExists(function () {
doInitForm(this);
});
}
},
/**
* run: function to check that a given field is filled out.
* It checks if {name}_ROW is a table row.
*/
"checkRequired": function checkRequired(win, field) {
var $ = win.$;
var $field = $(field);
var name = $field.attr("name"); // TODO - come back and fix to work MA000623 & 00013612
// var parentRow = $("#" + name).closest('tr');
// if (getFieldValue(field) == '' && (row.is(":visible") || parentRow.is(":visible"))){
var $row = $("#".concat(name, "_ROW")); // https://jira.powerschool.com/browse/HE-3687
// $row.length will be 0 if this field is wrapped in a grouping sss.gui.MultiFieldField (see gui_field_field table)
// This is the case for the phone number and extension fields in gui_page 00001017 (the applicant add reference page)
// The :visible check fails because the row has a different name (e.g. PHONE_GROUP_ROW instead of PHONE_ROW)
// Falling back to the closest parent <tr> element should fix this problem
var $rowOrClosestTr = $row.length > 0 ? $row : // Could probably always use this value, but minimizing changes to prevent breaking things
$field.parents("tr").eq(0);
if ($rowOrClosestTr.is(":visible") && getFieldValue(win, field) == "") {
var nameOrId = name ? name : $field.attr("id");
logger.log("## checkRequired - INVALID (".concat(nameOrId, ")"));
logger.log(field);
var $customMessageField = $("input[name=\"customValidationMessage\"]");
var customValidationMessage = $customMessageField.length > 0 && $customMessageField.val() != "" ? $customMessageField.val() : "You have not filled out all required fields on this page.";
invalidField(win, field, customValidationMessage);
return false;
} else {
return true;
}
},
/**
* Wrapper for validFields that checks if the form can be validated from
* the table name.
**/
"validForm": function validForm(win, form, tableName) {
if (!lib.checkAccess()) {
return false;
} // flip validation switch since we are checking fields... it's stupid
win.runningValidFields = true;
if (tableName != "applicant.view" && tableName != "dbuser.pwd_no_libraryjsp" && (tableName.match("dbuser") || tableName.match("applicant") && !tableName.match("applicant_type")) && !checkFormatting(win, form.elements["NAME"], form.elements["PWD"])) {
win.runningValidFields = false;
return false;
}
win.runningValidFields = false;
return validFields(win, form);
},
/**
* Utility to strip down the query string size by removing blank inputs for very
* large search forms. IE has a 2048 character limit on query string size and
* even with an empty form putting every input in the query string can explode that
* on the Applicant search page.
*
* We use jQuery's $.serialize to create the query string.
**/
"compressFormQuery": function compressFormQuery(win, form, tableName) {
if (!lib.checkAccess()) {
return false;
}
var $ = win.$;
var qs = $(form).find(":input").filter(function () {
return $(this).val() != "";
}).serialize();
var requestUrl = "".concat($(form).attr("action"), "?").concat(qs);
win.location.href = requestUrl;
return false;
},
/**
* Adds a func to validation listeners on fieldName.
**/
"appendMulti": function appendMulti(win, fieldName, func) {
lib.initForms(win);
var forms = getFormObjects(win, fieldName);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var newFunctions = new Array(func);
var newFields = form.elements[fieldName];
form.validatorFunctions = form.validatorFunctions.concat(newFunctions);
form.validatorFields = form.validatorFields.concat(newFields);
}
},
"multiCheck": function multiCheck(win, fields) {
var numberChecked = getMultiNumberChecked(win, fields);
var $ = win.$;
var id = "".concat($(fields).attr("name"), "_ROW"); // HE-3875
// Hack to look for newest/last element with ID (closing modal doesn't delete the elements from the DOM, and clicking "Go!" again creates a new modal)
var $row = $("[id='".concat(id, "']")).last();
if ($row.is(":visible") && numberChecked < 1) {
invalidField(win, fields, "You have not filled out all required answers on this page.");
return false;
} else {
return true;
}
},
"reqAllMultiCheck": function reqAllMultiCheck(win, fields) {
var numberChecked = getMultiNumberChecked(win, fields);
var numberOfCheckboxes = Array.from(fields).filter(function (x) {
return x.type === "checkbox";
}).length;
var $ = win.$;
var id = "".concat($(fields).attr("name"), "_ROW"); // HE-3875 was fixed by the change in multiCheck (above), but presumably the fix should be applied here too
// Hack to look for newest/last element with ID (closing modal doesn't delete the elements from the DOM, and clicking "Go!" again creates a new modal)
var $row = $("[id='".concat(id, "']")).last();
if ($row.is(":visible") && numberChecked < numberOfCheckboxes) {
invalidField(win, fields, "You have not filled out all required answers on this page.");
return false;
} else {
return true;
}
},
/**
* Add a check mask function to a field.
**/
"appendMask": function appendMask(win, f, func) {
lib.initForms(win);
var fname = f;
var x;
if (f.indexOf(":::") != -1) {
fname = f.substring(0, f.indexOf(":::"));
f = f.substring(f.indexOf(":::") + 3);
if (f.indexOf(":::") != -1) {
x = f.substring(0, f.indexOf(":::"));
}
}
var forms = getFormObjects(win, fname);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var field = form.elements[fname];
var newFunctions = new Array(func);
var newFields = new Array(field);
var expr = new Array(x);
form.maskValidatorFunctions = form.maskValidatorFunctions.concat(newFunctions);
form.maskValidatorFields = form.maskValidatorFields.concat(newFields);
form.maskValidatorMasks = form.maskValidatorMasks.concat(expr);
}
},
/**
* Adds a fieldName and function to listerners. Functions run when checking for
* form completion.
**/
"append": function append(win, fieldName, func) {
lib.initForms(win);
var forms = getFormObjects(win, fieldName);
var i = 0;
for (i = 0; i < forms.length; i += 1) {
var form = forms[i];
var field = form.elements[fieldName];
var newFunctions = new Array(func);
var newFields = new Array(field);
form.validatorFunctions = form.validatorFunctions.concat(newFunctions);
form.validatorFields = form.validatorFields.concat(newFields);
}
},
"checkSize": function checkSize(field, fsize) {
if (fsize > 0 && field.value.length > fsize) {
field.value = field.value.substring(0, fsize);
alert("You have reached the maximum size for this field");
}
},
"checkSearchNumber": function checkSearchNumber(win, field) {
stripSymbols(field);
var value = field.value; // when we don't have a value evrything is fine
if (value === undefined) {
return true;
} // check to see if the first character is a > or <
if (value.indexOf(">") > 0 || value.indexOf("<") > 0) {
invalidField(win, field, "An invalid number was entered in this field. If you are using > or <, please make sure it is the first symbol in the field.");
return false;
} else {
var num = value;
if (num.indexOf(">") == 0 || num.indexOf("<") == 0) {
num = value.substr(1);
}
if (!isValidNumber(num)) {
invalidField(win, field, "An invalid number was entered in this field.");
return false;
}
}
return true;
},
"checkNumber": function checkNumber(win, field) {
stripSymbols(field);
if (!isValidNumber(field.value)) {
invalidField(win, field, "An invalid number was entered in this field. This field cannot contain any symbols ($, %, #, etc).");
return false;
} else {
return true;
}
},
"checkZeroInterval": function checkZeroInterval(win, field) {
stripSymbols(field);
var value = field.value;
if (value === 0) {
invalidField(win, field, "Interval cannot be zero");
return false;
} else {
return true;
}
},
"confirmDelete": function confirmDelete(page, href) {
if (confirm("Are you sure you want to delete this record?")) {
if (href.indexOf("redirect=") < 0) {
href = "".concat(href, "&redirect=").concat(escape(page.location.href));
} else {
var i = href.indexOf("&redirect=");
var j = href.indexOf("%");
if (i >= 0 && j < 0) {
var sl = "&redirect=".length;
href = href.substring(0, i + sl) + escape(href.substring(i + sl));
}
}
page.location.href = href;
}
},
"handleImpersonation": function handleImpersonation(window, href, impersonationMode) {
var userId = href.split("?")[1].substr("USER_ID=".length);
$.get("/servlet/support/login/impersonation", {
"companyId": companyId,
"userId": userId,
"impersonationMode": impersonationMode
}, function (data) {
if (data.success) {
if (data.accountType == "EMPLOYER") {
top.document.location.replace("/ats/employer/v51_employer_frame");
}
} else {
window.alert(data.errorMessage);
}
}, "json");
return false;
},
"checkTime": function checkTime(win, field) {
var isValidTime = true;
var thisFieldValue = field.value;
if (thisFieldValue.length == 0) {
return true;
}
if (thisFieldValue.length != 5) {
isValidTime = false;
} else {
var middle = thisFieldValue.substring(2, 3);
if (middle != ":") {
isValidTime = false;
} else {
var hour = thisFieldValue.substring(0, 2);
var minute = thisFieldValue.substring(3, 5);
if (hour.charAt(0) > 2 || hour.charAt(1) > 9 || minute.charAt(0) > 5 || minute.charAt(1) > 9 || hour.charAt(0) == 2 && hour.charAt(1) > 3) {
isValidTime = false;
} else {
var hourInt = parseInt(hour);
var minuteInt = parseInt(minute);
var hour1 = parseInt(hour.substring(0, 1));
var hour2 = parseInt(hour.substring(1, 2));
var minute1 = parseInt(minute.substring(0, 1));
var minute2 = parseInt(minute.substring(1, 2));
if (hourInt > 23 || hourInt < 0 || minuteInt > 59 || minuteInt < 0 || isNaN(hourInt) || isNaN(minuteInt) || isNaN(hour1) || isNaN(hour2) || isNaN(minute1) || isNaN(minute2)) {
isValidTime = false;
}
}
}
}
if (!isValidTime) {
invalidField(win, field, "An invalid time was entered. Use Military Time Format: 00:00 to 23:59");
}
return isValidTime;
},
"checkDate": function checkDate(win, field) {
var thisFieldValue = getFormattedDate(field);
if (!isValidDate(thisFieldValue, false)) {
invalidField(win, field, "An invalid date was entered. Use Month Date Year Format MM/DD/YYYY.");
return false;
} else {
field.value = thisFieldValue;
return true;
}
},
"checkBirthDate": function checkBirthDate(win, field) {
if (!isValidBirthDate(field, false, 10, 110)) {
invalidField(win, field, "An invalid birth date was entered.");
return false;
}
return true;
},
"checkShortDate": function checkShortDate(win, field) {
var thisFieldValue = getFormattedDate(field);
if (!isValidDate(thisFieldValue, true)) {
invalidField(win, field, "An invalid date was entered. Use Month Date Year Format MM/YYYY.");
return false;
} else {
field.value = thisFieldValue;
return true;
}
},
/**
* It is expected that the input text field has a sibling hidden input field.
* @param field A jquery wrapped text field.
*/
"storeShortDateToFullDate": function storeShortDateToFullDate(win, field) {
/**
* Converts MM/yyyy to MM/dd/yyyy
* @param date date string
* @returns {string} full date
*/
function createFullDate(date) {
var separatorIndex = date.lastIndexOf("/");
var month = date.substring(0, separatorIndex);
var year = date.substring(separatorIndex);
return "".concat(month, "/01").concat(year);
}
var value = field.val();
var id = $(field).attr("id");
var row = $("#".concat(id, "_ROW")); // when the value is not valid the hidden field is set to empty to ensure
// the validator to catch the error on the field
if (!isValidDate(value, true) || value == "" && row.css("display") != "none") {
field.next().val("");
return false;
}
var fullDate = createFullDate(value);
field.next().val(fullDate);
return true;
},
"checkDateTime": function checkDateTime(win, field) {
if (!isValidDateTime(field)) {
invalidField(win, field, "An invalid date was entered. Use Format MM/DD/YYYY HH:MM am/pm.");
} else {
return true;
}
},
"toggleSelectAllCheckboxes": function toggleSelectAllCheckboxes(checkbox, win) {
var isChecked = !!$(checkbox).attr("checked");
if (isChecked) {
lib.selectAllCheckboxes(win, false);
} else {
lib.deselectAllCheckboxes(win, false);
}
},
"selectAllCheckboxes": function selectAllCheckboxes(win, lockAccess) {
if (lockAccess) {
lib.setAccess(win, false);
}
var i = 0;
for (i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].type == "checkbox") {
win.document.forms[0].elements[i].checked = true;
}
}
},
/**
* Submit an eform document through AJAX. This also handles saving as draft.
* It displays a message in modal dialogue in the process of submitting the document.
* The function also handles responses from the server in a modal dialogue.
* This is designed to be called on form onsubmit.
* @param {window} win The window object passed where the function is called. This
* is used as the context for jquery.
* @param {jquery object} form The jquery object of the form document this function is going to submit.
* @param {string} divId The id of the div that will be used for the modal dialogue.
* @return {boolean} This should return false to disable the default form submit.
*/
"documentSubmit": function documentSubmit(win, form, tableName, divId) {
setTimeout(function () {
var $ = win.$;
lib.setAccessNextPage(true);
var saveAsDraft = !!$("input[name='save_as_draft']").length;
var ignoreRequiredFields = $("input[name='IGNORE_REQUIRED_FIELDS']").val() === "Y";
var formIsValid = ignoreRequiredFields;
if (!saveAsDraft && !ignoreRequiredFields) {
formIsValid = lib.validForm.call(form[0], win, form[0], tableName);
}
if (saveAsDraft || formIsValid) {
var doneSubmit = false;
createModal(win, {
"content": "#".concat(divId),
// TODO: clone this?
"attributes": {
"useCloseX": true
},
"onOpen": function onOpen(modal) {
var content = modal.getContent(true);
$(content).css("height", "auto");
$(content).css("width", "auto");
modal.enableOk({
"enable": false
});
modal.setContent("<h3>Submitting...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p>");
var formdata = "".concat(form.serialize(), "&ajax=Y");
if (saveAsDraft) {
formdata += "&save_as_draft=Save+as+Draft";
}
$.post(form.attr("action"), formdata, function (data) {
doneSubmit = true;
modal.setContent(data);
if (saveAsDraft) {
setTimeout(function () {
return modal.close();
}, 500);
}
});
},
"onClose": function onClose(modal) {
if (doneSubmit) {
modal.enableOk({
"enable": true
});
}
}
});
}
}, 500);
return false;
},
"unfollow": function unfollow(win, aTag) {
var $ = win.$;
var link = $(aTag);
$.post(link.attr("href"), function (data) {
if (data == "Success!") {
var evenRows = link.closest("tr").nextAll("tr.even");
link.closest("tr").nextAll("tr.odd").removeClass("odd").addClass("even");
evenRows.removeClass("even").addClass("odd");
link.closest("tr").remove();
} else {
win.alert(data);
}
});
return false;
},
"deselectAllCheckboxes": function deselectAllCheckboxes(win, lock) {
if (lock) {
lib.setAccess(win, false);
}
var i = 0;
for (i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].type == "checkbox") {
win.document.forms[0].elements[i].checked = false;
}
}
},
"daysSince": function daysSince(win, field) {
var fieldName;
var daysSince = field.value;
var time = new Date(new Date().getTime());
var d = new Date(time - daysSince * 24 * 60 * 60 * 1000);
var s = "".concat(d.getMonth(), "1/").concat(d.getDate(), "/").concat(d.getFullYear());
var index = field.name.lastIndexOf("_DAYSSINCE");
if (index > 0) {
fieldName = field.name.substring(0, index);
}
if (daysSince > 0 && daysSince != null) {
for (var i = 0; i < win.document.forms[0].elements.length; i++) {
if (win.document.forms[0].elements[i].name == fieldName) {
win.document.forms[0].elements[i].value = s;
}
}
} else {
for (var _i5 = 0; _i5 < win.document.forms[0].elements.length; _i5++) {
if (win.document.forms[0].elements[_i5].name == fieldName) {
win.document.forms[0].elements[_i5].value = "";
}
}
}
},
// Scoring Worksheet functions
"setAvgField": function setAvgField(win, fieldName) {
return win.avgField = fieldName;
},
"setTotalField": function setTotalField(win, fieldName) {
win.totalField = fieldName;
win.document.forms[0].elements[fieldName].enabled = false;
},
"appendScore": function appendScore(win, fieldName) {
// var field = win.document.forms[0].elements[fieldName];
// win.scores = win.scores.concat(field);
win.scores = win.scores.concat(fieldName);
},
"calculateScore": function calculateScore(win) {
var totalScore = 0;
var removeFromTotal = 0;
for (var i = 0; i < win.scores.length; i++) {
var field = win.document.forms[0].elements[win.scores[i]];
var fieldValue = parseInt(getFieldValue(win, field));
if (!fieldValue > 0) {
fieldValue = 0;
removeFromTotal++;
}
totalScore = totalScore + fieldValue;
}
var avgScore = totalScore / (win.scores.length - removeFromTotal); // round to the nearest integer by adding .5 to avgScore
avgScore = parseInt(avgScore + 0.5);
if (win.totalField && totalScore == parseInt(totalScore)) {
// There are 2 fields which need to be populated, one hidden and one html disabled
win.document.forms[0].elements[win.totalField][0].value = totalScore;
win.document.forms[0].elements[win.totalField][1].value = totalScore;
}
if (win.avgField && avgScore == parseFloat(avgScore)) {
// There are 2 fields which need to be populated, one hidden and one html disabled
win.document.forms[0].elements[win.avgField][0].value = avgScore;
win.document.forms[0].elements[win.avgField][1].value = avgScore;
}
return true;
},
// End Scoring Worksheet functions
// BEGIN PAGE LISTENER FUNCTIONS
"clearListeners": function clearListeners() {
return lib.pageListeners = [];
},
/**
* Is here so that a selection field (select box, checkboxes, etc)
* can cause events to happen when its value changes. This function is called
* in an onChange event listener contained in the field. The field itself
* is passed in so that its attributes can be determined and used.
**/
"updatePage": function updatePage(win, field) {
// The values in the field must follow the following format:
// target,uri,querystring
// Parse it to find out those 3 values.
var value = field.options[field.selectedIndex].value;
var target = null;
var url = null;
if (value.indexOf(",") >= 0) {
target = value.substring(0, value.indexOf(","));
url = value.substring(value.indexOf(",") + 1);
if (url.indexOf(",") >= 0) {
var uri = url.substring(0, url.indexOf(","));
var qs = url.substring(url.indexOf(",") + 1);
var linkUrl = uri;
if (qs != null) {
var qsBegin = "?";
if (linkUrl.indexOf("?") >= 0) {
qsBegin = "&";
}
linkUrl = linkUrl + qsBegin + qs;
}
}
}
if (lib.checkAccess()) {
lib.loadingPage(true);
if (url.indexOf(",") >= 0) {
win.parent.frames[target].location.href = linkUrl;
win.parent.frames[target].focus();
}
} else {
win.alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
var size = field.options.length;
var currentPage = win.parent.frames[target].location.pathname;
for (var i = 0; i < size; i++) {
var optionVal = field.options[i].value;
if (optionVal.indexOf(currentPage) >= 0) {
field.selectedIndex = i;
break;
}
}
}
},
/**
* These functions and variables are for the next/previous applicant links.
* Loading will be set to true at the top of the page and then false as the
* last think on the page.
**/
"loadingPage": function loadingPage(bool) {
setGlobalData("Lib.loading", bool);
if (bool == true) {
lib.setAccessNextPage(true);
}
return true;
},
"isLoadingPage": function isLoadingPage() {
var loading = getGlobalData("Lib.loading");
return loading;
},
/**
* Is called at the bottom of every ResultPage and FormPage
* It iterates through all of the active page listeners and calls the
* method to let the page listeners know that the page has been updated.
*
* Called by the page, notifies page listeners
**/
"pageUpdated": function pageUpdated(uri) {
for (var i = 0; i < _this.pageListeners.length; i++) {
var listener = _this.pageListeners[i];
var f = void 0;
try {
f = listener.pageUpdated;
if (f) {
f(uri);
}
} catch (err) {}
}
},
// END OF PAGE LISTENER FUNCTIONS
/**
* Sets flag for accessing next page, can be retrieved from checkAccess(). This MUST occur on the global
* instance or results will not be consistent.
*
* @param value
* @returns {boolean}
*/
"setAccessNextPage": function setAccessNextPage(value) {
var canAccess = lib.checkAccess();
_log("accessNextPage: ".concat(canAccess));
setGlobalData("Lib.accessNextPage", value);
return true;
},
"setAccess": function setAccess(win, value) {
_this.setAccessNextPage(value);
if (win && win.document && win.document.forms && win.document.forms[0] && win.document.forms[0].elements && win.document.forms[0].elements["is_changed"] && !win.document.forms[0].elements["force_is_changed"]) {
win.document.forms[0].elements["is_changed"].value = !value;
}
return true;
},
/**
* Retrieves flag indicating if next page can be accessed. This MUST occur on the global
* instance or results will not be consistent.
*
* @returns {boolean}
*/
"checkAccess": function checkAccess() {
return getGlobalData("Lib.accessNextPage");
},
"checkLinkAccess": function checkLinkAccess() {
if (_this.checkAccess()) {
return true;
} else {
alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
return false;
}
},
/**
* Add a listener to parentField to show targetField when parentField.value
* equals showValue.
**/
"addDependentField": function addDependentField(win, rawParentFieldIds, targetField, rawShowValues) {
var $ = win.$; // TODO: this flag will be kept here as it may be desirable to use the 'keepWidth' feature for individual dialogs in the future
var keepWidth = false; // wait until the document is ready because "reset" and parent may not
// be present yet
$(win.document).ready(function () {
// separate out the fields and values into groups end result is array parentOrFields
var parentOrFields = [];
var parentOrFieldIds = rawParentFieldIds.split("|");
var parentOrValues = rawShowValues ? rawShowValues.split("|") : [];
for (var i = 0; i < parentOrValues.length; i++) {
parentOrValues[i] = parentOrValues ? parentOrValues[i].split("&") : [];
}
for (var _i6 = 0; _i6 < parentOrFieldIds.length; _i6++) {
var parentInnerAnd = [];
var parentInnerAndFieldIds = parentOrFieldIds[_i6].split("&");
for (var j = 0; j < parentInnerAndFieldIds.length; j++) {
var nameId = parentInnerAndFieldIds[j];
var negative = nameId.substr(-4) === "_NOT";
if (negative) {
nameId = nameId.substr(0, nameId.length - 4);
} // look to see if this will be rendered in Modal
var parentField = void 0;
if (dependentFieldCtx) {
parentField = $(dependentFieldCtx).find("[name='".concat(nameId, "']")).not(":disabled");
} else {
parentField = $("[name='".concat(nameId, "']")).not(":disabled");
}
parentField.data("negative", negative);
parentInnerAnd[j] = {
"fields": parentField,
"values": parentOrValues[_i6] ? parentOrValues[_i6][j] ? parentOrValues[_i6][j] : "" : ""
};
}
parentOrFields[_i6] = parentInnerAnd;
} // combine all fields into one jquery object for binding
var parentFields;
$.each(parentOrFields, function (i, innerAnd) {
return $.each(innerAnd, function (j, field) {
return parentFields = parentFields ? parentFields.add(field.fields) : field.fields;
});
}); // look to see if this will be rendered in Modal
var row;
if (dependentFieldCtx) {
row = $(dependentFieldCtx).find("#".concat(targetField, "_ROW"));
} else {
row = $("#".concat(targetField, "_ROW"));
}
if (parentFields && parentFields.length) {
var showHide = function showHide(dontAnimate) {
var foundPassingInnerAnd = false;
for (var _i7 = 0; _i7 < parentOrFields.length && !foundPassingInnerAnd; _i7++) {
var _parentInnerAnd = parentOrFields[_i7];
var innerAndResult = true; // for each field
var _loop = function _loop(_j2) {
var field = _parentInnerAnd[_j2]; // values are always the same for a field
var showOnValue = field.values.split(",");
var showOnAnyValue = field.values === ""; // for each input (of field)
var fieldResult = false;
for (var k = 0; k < field.fields.length && !fieldResult; k++) {
var input = field.fields.eq(k);
var value = input.val();
var _negative = input.data("negative"); // if ( input.attr("type") == "hidden" )
// this should already be handled server side; but we allow test anyway
// if this is an unchecked radio/check fake no value
if (input.is(":radio,:checkbox") && !input.is(":checked")) {
value = null;
}
var hasValue = false;
if (value !== null) {
value = $.makeArray(value);
$.each(value, function (i, v) {
if (v != "" && $.inArray(v, showOnValue) >= 0) {
hasValue = true;
}
});
} // set result and stop iteration when negative
fieldResult = hasValue || value && value != "" && showOnAnyValue;
if (_negative) {
fieldResult = !fieldResult;
}
}
innerAndResult = fieldResult;
};
for (var _j2 = 0; _j2 < _parentInnerAnd.length && innerAndResult; _j2++) {
_loop(_j2);
}
foundPassingInnerAnd = innerAndResult;
}
if (foundPassingInnerAnd) {
if (dontAnimate) {
row.show();
triggerResize(win, true, keepWidth);
} else {
// only animate when it is not already shown; display="auto"
if ("none" == row.css("display")) {
row.css("display", "");
row.css("opacity", "0");
row.animate({
"opacity": "1"
}, 500, "swing", function () {
return triggerResize(win, true, keepWidth);
});
}
}
} else {
if (dontAnimate) {
row.hide();
triggerResize(win, true, keepWidth);
} else {
row.fadeOut({
"complete": function complete() {
return triggerResize(win, true, keepWidth);
}
});
}
}
}; // on reset of form trigger change event for all fields
$(":reset").click(function () {
$(this).get(0).form.reset();
showHide(true);
}); // add event triggers to parent field
parentFields.each(function (i, elem) {
var $element = $(elem);
if ($element.hasClass("select-plus") && !$element.hasClass("select-plus-initialized")) {
SelectPlus.registerChangeListener($element, showHide);
} else {
jqueryUniversalChange(win, elem, function () {
return showHide();
});
}
});
showHide(true);
}
});
},
"setLocation": function setLocation(win, url) {
if (_this.checkAccess()) {
win.document.location.href = url;
} else {
win.alert("You must first click the \"Save and Next\" or \"Undo\" buttons before exiting this page.");
}
},
"historyGo": function historyGo(win, e) {
if (_this.checkAccess()) {
win.$("body").trigger("ss-event-page-cancel");
win.history.go(-1);
} else {
var e = win.event || e;
var targetValue = e.target || e.srcElement;
var msgForDisplay = $(targetValue).parents("ul").find("input[type=submit]");
win.alert("You must first click the \"".concat(msgForDisplay.val(), "\" or \"Undo\" buttons before exiting this page."));
}
},
"maskFormat": function maskFormat(win, field, expr) {
var v = field.value;
if (v == "") {
return true;
}
var re = new RegExp(expr);
if (re.exec(v)) {
return true;
} else {
return false;
}
},
/**
* Not even able to be called. Overriden by function autoFormat(x,y,z)
**/
"autoFormat": function autoFormat(field, expr, withstr) {
var v = field.value;
if (v == "") {
return;
}
var re = new RegExp(expr);
if (re.exec(v)) {
field.value = v.replace(re, withstr);
} else {
alert("".concat(v, " is not in the correct format."));
}
},
"AppLoginStepFillIn": function AppLoginStepFillIn(win) {
var $ = win.$; // copy create account button
var create_account_button = $(".pagebuttons ul :has([value='Create New Account'])");
create_account_button.css("display", "block");
if ($("div.create_account")) {
$("div.create_account").html(create_account_button.html());
create_account_button.css("display", "none");
} // move preview links
if ($("#step2_links")) {
$("#preview").hide();
$("#step2_links").html($("#preview").html());
} else {
$("#preview").show();
}
},
/**
* Adds functionality and style to the current content page in win.
**/
"addStyleClasses": function addStyleClasses(win, forSelector) {
// is a named function to aid in logging
var $ = win.$;
if (!$) {
_log(new Error("Can not call addStyleClasses; jQuery is not available."));
return;
}
forSelector = forSelector || "body";
_log("addStyleClasses for ".concat(forSelector));
var jq = $(forSelector);
setFormClass();
fillEmptyTD();
removeCheckboxsWhenAll();
fileFieldReset();
var classFunctions = {
".embedded_field": function embedded_field(obj) {
// firefox; clicking embedded input can't type
obj.closest("label").find(":radio, :checkbox").click(function () {
return $(obj).children(":text").focus();
}); // IE; clicking embedded input doesn't select check/radio
obj.closest("label").find(":text").click(function () {
$(this).closest("label").find(":radio, :checkbox").attr("checked", "checked");
});
},
// Lookup Editor
"a.wizardpopup": handleWizardPopupWithReload,
"a.wizardpopupNoReload": handleWizardPopup,
// modal pop-up links
"a.modalpopuplink": function aModalpopuplink(obj) {
return obj.click(function (e) {
e.preventDefault();
var popupId = "modalpopuplink";
if (!$("#".concat(popupId)).length) {
$("body").append("<div id='".concat(popupId, "' style='display:none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>"));
}
_this.addToolboxFunction(win, popupId, function () {
return ajaxFillinPopup(win, popupId, obj.attr("href"));
});
_this.showPopup(win, popupId);
return false;
});
},
// suggest search
"input.suggestsearch": handleSuggestSearch,
// file upload
"input.file_upload_field[type='button']": function inputFile_upload_fieldTypeButton(obj) {
$(obj).click(function (e) {
_log("Doing input.file_upload_field[type='button'].click()...");
var field = this; // Hack for SSOFT-5459. Multiple instances of the file upload popup are being created for some reason (when closing and reopening the popup).
$(field).parents().last().find("[id=upload_field]:hidden").remove();
closePopupFirst(win, function () {
_log("Doing fileUploadPopup - popups have been closed.");
fileUploadPopup(field, win);
});
});
},
// nctq
".nctq_hoverable": function nctq_hoverable(obj) {
obj.mouseenter(function (e) {
moveFloatingDivWithMouse(win, $(this).next("div"), e, 20, 20);
$(this).next("div").removeClass("nctq_scores_hidden");
$(this).next("div").addClass("nctq_scores_visible");
});
obj.mouseleave(function (e) {
$(this).next("div").removeClass("nctq_scores_visible");
$(this).next("div").addClass("nctq_scores_hidden");
});
obj.mousemove(function (e) {
moveFloatingDivWithMouse(win, $(this).next("div"), e, 20, 20);
});
obj.click(function (e) {
return e.preventDefault();
});
}
};
handleClassFunctions();
/**
* win - the window object (because of frames)
* div - the floating div jquery object
* e - event
* down - y offset from the mouse from the top right corner of the div
* left - x offset from the mouse from the top right corner of the div
*/
function moveFloatingDivWithMouse(win, div, e, down, left) {
var $ = win.$;
var width = div.width();
var height = div.height();
div.css({
"top": Math.min(e.pageY + down, $(win).height() - height + $(win).scrollTop()),
"left": e.pageX - width - left
});
}
function handleWizardPopupWithReload(obj) {
handleWizardPopup(obj, true);
}
function handleWizardPopup(obj, reloadPageOnDone) {
obj.click(function (e) {
e.preventDefault();
var popupId = obj.attr("name") ? obj.attr("name") : "awizardpopup";
if (!$("#".concat(popupId)).length) {
$("body").append("<div id='".concat(popupId, "' style='display:none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>"));
}
closePopupFirst(win, function () {
_this.addToolboxFunction(win, popupId, function () {
// hijack submit and stay open
ajaxFillinPopup(win, popupId, obj.attr("href"), null, true, true);
});
if (reloadPageOnDone) {
_this.addToolboxFunction(win, "".concat(popupId, "_close"), function () {
$("body").html("<h3 class='pageTitleCaption'>Please Wait... Loading</h3>"); // add refresh=Y to url
var curLoc = win.location.href;
var isOldUi = top.frames[0] && top.frames[0].name === "sss_script";
if (curLoc.indexOf("refresh") == -1) {
var newUrl = curLoc;
if (newUrl.indexOf("?") > -1) {
newUrl += "&refresh=Y";
} // if ( newUrl.indexOf("?") )
else {
newUrl += "?refresh=Y";
}
if (isOldUi) {
win.location.replace(newUrl);
} else {
win.$("body").trigger("ss-event-page-reload");
}
} else {
if (isOldUi) {
win.location.reload();
} else {
win.$("body").trigger("ss-event-page-reload");
}
}
});
}
_this.showPopup(win, popupId);
});
return false;
});
}
function handleSuggestSearch(obj) {
var suggestionId = "".concat(obj.attr("id") || obj.attr("name"), "_sug"); // url
var url = obj.attr("href"); // add jscallback to URL
if (url.indexOf("?") < 0) {
url += "?";
} else {
url += "&";
}
url += "jscallback=?"; // get suggestion
var lastTimeout = -1;
obj.keyup(function (e) {
if (lastTimeout != -1) {
win.clearTimeout(lastTimeout);
}
lastTimeout = win.setTimeout(function () {
// suggest from
var value = obj.val();
if (value == "") {
return;
}
value = {
"suggest": value,
"ajax": "y"
};
var data = $.param(value);
$.getJSON(url, data, handleSuggestsions);
}, 500);
}); // fillout suggestion
function handleSuggestsions(suggestions) {
removeSuggestionBox();
createSuggestionBox();
for (var suggestion in suggestions) {
// IE behaves funny when chaining
var id = suggestionId + suggestions[suggestion];
$("#".concat(suggestionId)).append("<div id='".concat(id, "' class='suggest_link'>").concat(suggestion, "</div>"));
var jsug = $("#".concat(id));
jsug.hover(hoverOver, hoverOut);
jsug.click(function () {
obj.val($(this).html());
removeSuggestionBox();
});
}
} // remove suggestion
obj.blur(removeSuggestionBox); // utiltity
function hoverOver() {
$(this).addClass("suggest_link_over");
obj.unbind("blur");
}
function hoverOut() {
$(this).removeClass("suggest_link_over");
obj.blur(removeSuggestionBox);
}
function createSuggestionBox() {
if (!$("#".concat(suggestionId, "_con")).length) {
obj.after("<div id='".concat(suggestionId, "_con'><div id='").concat(suggestionId, "' class='search_suggest'></div></div>"));
}
}
function removeSuggestionBox() {
$("#".concat(suggestionId, "_con")).remove();
}
}
function setFormClass() {
jq.find(":text").addClass("textfield");
jq.find(":password").addClass("passwordfield");
jq.find(":text, :password").focus(function () {
$(this).addClass("textfieldfocus");
});
jq.find(":text, :password").blur(function () {
$(this).removeClass("textfieldfocus");
});
} // Hack to fix rendering bug in IE.
function fillEmptyTD() {
jq.find("td:empty").html(" ");
}
function removeCheckboxsWhenAll() {
// Additionally can do ,:button[name='select_all'],:button[name='deselect_all']
var $selectNameActionType = jq.find("select[name=\"ACTION_TYPE\"]");
$selectNameActionType.change(function () {
var $checkboxes = jq.find(".rs :checkbox");
if ($selectNameActionType.val() === "all") {
$checkboxes.prop("disabled", "disabled").hide();
} else {
$checkboxes.prop("disabled", "").show();
}
});
}
function handleClassFunctions() {
var selectorString = "";
var first = true;
for (var selector in classFunctions) {
if (!first) {
selectorString += ",";
}
selectorString += selector;
first = false;
}
var $elements = jq.find(selectorString);
$elements.each(function () {
var me = $(this);
for (var _selector in classFunctions) {
if (me.is(_selector)) {
classFunctions[_selector].call(this, me);
}
}
});
}
/**
* Pop-up for upload_field
**/
var uploadFieldId = "upload_field";
function fileUploadPopup(field, win) {
var $ = win.$; // error on any existing pop-up
var modal = getModal(win);
if (modal && modal.isOpen()) {
alert("ERROR: cannot have a fileupload field within another pop-up");
return;
} // get real content
var fieldName = $(field).attr("hiddenname");
var uploadParams = "FIELD_NAME=".concat(fieldName, "&COMPANY_ID=").concat(companyId); // waiting text
if (!$("#".concat(uploadFieldId)).length) {
var loading = "<div id=\"".concat(uploadFieldId, "\" style=\"display: none\"><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>");
$("body").append(loading);
} // if to remove ext enforcement
var uploadPageQs = "";
if ($(field).is(".noextcheck")) {
uploadPageQs = "?noextcheck=Y";
} // on open
_this.addToolboxFunction(win, uploadFieldId, function () {
// fill in with real content
ajaxFillinPopup(win, uploadFieldId, "/ats/upload_field.jsp".concat(uploadPageQs), uploadParams);
}); // on close
_this.addToolboxFunction(win, "".concat(uploadFieldId, "_close"), function () {
// if the upload was a success
if (win.fileuploads && win.fileuploads[fieldName]) {
var fileupload = win.fileuploads[fieldName];
if (fileupload.id && fileupload.url) {
// update the hidden field
$("#".concat(fieldName)).val(fileupload.id); // update the link
$(".".concat(fieldName, "_link")).attr("href", fileupload.url).fadeIn();
$(".".concat(fieldName, "_remove")).attr("href", "#").fadeIn(); // change button label
$("#".concat(fieldName, "_button")).attr("value", "Replace File"); // warn on page change
_this.setAccess(win, false);
}
}
});
_this.showPopup(win, uploadFieldId);
}
function fileFieldReset() {
jq.find(":reset").click(function (e) {
// change hiddens back to original value
$(".file_upload_field[type='hidden']").each(function (i) {
var orgValue = $(this).attr("original");
$(this).val(orgValue); // update links
var link = $("#".concat($(this).attr("name"), "_link"));
link.attr("href", orgValue);
if (orgValue == "") {
link.fadeOut();
}
});
});
}
},
/**
* Called when an upload is complete
**/
"fileUploadComplete": function fileUploadComplete(win, fieldName, msg) {
var $ = win.$;
$(".inlineHelp").remove();
$(".searchsoft-modal #file_upload_content").html(msg);
$(".searchsoft-modal #file_upload_waiting").stop().hide();
$(".searchsoft-modal #file_upload_content").fadeIn(); // since we don't know what caused the fileupload (wizard or field) process the message for all cases
// Note regarding HE-3374: Content parameter was previously
// $("#" + fieldName)
// but "Continue" buttons with redirects weren't working
// See
// if (hijackStayOpen) {
// var button = content.find(".linkbutton");
// button.each(function () {
// in afterAjaxPopProcess
// Also see changes in upload_field.jsp (new div element with class starting with file-upload-complete-wrapper-)
afterAjaxPopProcess(win, fieldName, $(".file-upload-complete-wrapper-".concat(fieldName)), null, true, true);
triggerResize(win);
},
/**
* Called when an upload is starting
**/
"fileUploadStart": function fileUploadStart(win) {
var $ = win.$;
$(".inlineHelp").remove();
$(".searchsoft-modal #file_upload_waiting").fadeIn();
$(".searchsoft-modal #file_upload_content").hide();
return true;
},
// lib: JQUERY
"onReady": function onReady(win, fun) {
win.$ = checkJQuery(win, win.$);
if (!win.$) {
_log(new Error("Can not call onReady; jQuery is not available."));
return;
}
var onReady = function onReady() {
_log("win.document.readyState: ".concat(win.document.readyState)); // we need full CSS; chrome/safari parallel load
if (win.document.readyState != "complete") {
// FF jumps the gun on 'complete' state...causes issues with onReady functions
// when doing slow page load...so, do longer wait before executing
var deferTime = $.browser && $.browser.mozilla ? 1000 : 350;
_log("Deferring call to onReady for ".concat(deferTime, " ms..."));
win.setTimeout(onReady, deferTime);
return;
}
_log("Calling onReady() for:".concat(displayFn(fun)));
if (win.spinnerOn) {
win.onReadyFunctions = win.onReadyFunctions || [];
win.onReadyFunctions.push(fun);
_log("Adding function to win.onReadyFunctions (length=".concat(win.onReadyFunctions.length, "), NOT calling function."));
} else {
try {
_log("Executing onReady() function..."); // send in current context Window, and execute with Lib instance as function context
fun.call(_this, win);
} catch (e) {
_log("Error occurred executing onReady function...");
_log(e);
}
}
};
win.$(win.document).ready(onReady);
},
// Perform the new cookie test
"perform_cookie_test": function perform_cookie_test() {
makeTestCookie();
cookie_test = findTestCookie();
return cookie_test;
},
/**
* Called on pages that use the Action Toolbox.
*
* lib: JQUERY
* It will bind to the go button / select and correctly populate the pop-up.
*
**/
"ready_modal_popup": function ready_modal_popup(win, inline, uid) {
var $ = win.$;
$(win.document).ready(function () {
if (!inline) {
toolboxRegisterActionGo(win, uid);
} else {
toolboxRegisterSelection(win, uid);
}
if (!win.toolboxFunctions) {
win.toolboxFunctions = new Array(0);
}
});
},
/**
* Adds a function to list of current toolbox functions.
**/
"addToolboxFunction": function addToolboxFunction(win, funName, fun) {
if (!win.toolboxFunctions) {
win.toolboxFunctions = new Array(0);
}
win.toolboxFunctions[funName] = fun;
},
/**
* Toolbox, client function for AJAX popup.
**/
"ajaxPopupOp": function ajaxPopupOp(win, id, url, op, includeSelect) {
var $ = win.$;
var data = null;
if (op != null || "" == op) {
data = "op=".concat(op);
}
if (includeSelect) {
data = "".concat(data == null ? "" : data + "&").concat($("form").serialize());
}
var tableName = $("[name=table_name]").val();
if (tableName != null && "" != tableName && (data == null || data.indexOf("table_name") == -1)) {
data = "".concat(data ? data + "&" : "", "table_name=").concat(tableName);
}
ajaxFillinPopup(win, id, url, data);
},
/**
* Toolbox, client function for AJAX popup.
**/
"ajaxPopup": function ajaxPopup(win, id, url) {
return _this.ajaxPopupOp(win, id, url, null);
},
/**
* Creates a Modal and displays it, using the content contained in HTML element with given item id.
*
* @param {Window} win context window
* @param {string} item id of HTML content for modal
* @param {Object} [atts] optional map of attributes used to init Modal
*/
"showPopup": function showPopup(win, item, atts) {
var $ = win.$; // TODO: until a further non-trivial refactoring is done, need to pull 'Ok' button text from
// modal content, from the buttons rendered via ui.properties, and also need to remove
// pagebuttons from content before providing to modal
var text = $("#".concat(item)).find("input[name=".concat(item, "]")).val();
if (!text && item.indexOf("_results") > 0) {
// it may be that the Ok button does not follow convention of having same name as item (i.e. 'email_results' and 'email')
var btnName = item.replace("_results", "");
text = $("#".concat(item)).find("input[name=" + btnName + "]").val();
}
var parent = $("#".concat(item)).parent();
var content = $("#".concat(item)).find(".pagebuttons").hide().end();
$(content).css("display", ""); // default Modal attributes
var defaultAtts = {
"useCloseX": true
};
if (atts) {
atts = $.extend({}, defaultAtts, atts);
} else {
atts = defaultAtts;
} // do Ok/Cancel need to be enabled for Modal (or will content contain buttons?)
var enableCancelOk = !text;
var modalInit = {
"id": item,
"attributes": atts,
"content": content,
"onOpen": function onOpen() {
// Important hack for HE-4062 and related issues (e.g. HE-3875, which was already fixed with an even worse hack)
// Closing modals doesn't actually remove them from the DOM, it only hides them, causing lots of issues
// Now instead of hiding old modals when the same modal is opened again, we are removing them from the DOM (i.e. remove() instead of hide())
// Old comment:
// if content from previous Modal is still in DOM, remove before opening this instance
$("[id=\"".concat(item, "\"]")).toArray().slice(0, -1).forEach(function (el) {
return $(el).remove();
});
if (enableCancelOk) {
toolboxAddCancel(win, item);
toolboxRunFunction(win, item);
}
},
"onClose": function onClose(modal) {
// insert the (possibly) modified data back into the DOM
var content = $(modal.getContent(true));
content = $(content).children(); // must get kids (not include the Modal content wrapper)
$(parent).append(content.hide());
toolboxRunFunction(win, "".concat(item, "_close"));
$(".inlineHelp").remove();
win.document.thismodal = null;
}
}; // if this is a non-Ajax populated instance, configure w/ buttons
if (!enableCancelOk) {
modalInit.buttons = [{
"text": text,
"type": "ok",
"callback": function callback(modal) {
return toolboxRunFunction(win, item);
}
}, {
"text": "Cancel",
"type": "cancel"
}];
} // otherwise, this will be populated via ajaxPopup() call
else {
modalInit.showOk = false;
modalInit.showCancel = false;
}
createModal(win, modalInit, true); // will assign to global variable
},
/**
* Toolbox utility, add a hidden field to main form.
**/
"addHiddenField": function addHiddenField(win, name, value) {
var $ = win.$;
$("form").append("<input type=\"hidden\" name=\"".concat(name, "\" value=\"").concat(value, "\" />"));
},
/**
* Utility function that adds all currently checked applicants to the popup.
**/
"addCheckboxApplicants": function addCheckboxApplicants(win, id) {
var $ = win.$;
doModalOp(win, false, function (modal, content) {
var form = $(content).find("form"); // for some reason doing this as inline calls breaks IE6
var apps = $("div.rs :checkbox:checked").clone();
apps.attr("checked", "checked"); // apps.attr("type", "hidden"); // breaks IE6
apps.attr("remove", "yes");
apps.hide();
form.append(apps); // add what to effect; "All applicants in list"
var actionTypeField = $("select[name='ACTION_TYPE']");
if (actionTypeField.length) {
form.append("<input type=\"hidden\" name=\"ACTION_TYPE\" value=\"".concat(actionTypeField.val(), "\" />"));
} // confirm that the checkboxes have been checked [IE6]
if ($(form).find(":checkbox:checked").length == 0) {
// check hidden checkboxes
$(form).find(":hidden:checkbox").attr("checked", "checked");
}
});
},
/**
* Utility function that remove added checked applicants to popup.
**/
"removeCheckboxApplicants": function removeCheckboxApplicants(win, id) {
var $ = win.$;
$("div#".concat(id, " :checkbox[remove='yes']")).remove();
},
/**
* Function that adds window.superConfirm
**/
"addSuperConfirm": function addSuperConfirm(win) {
var $ = win.$;
win.superConfirm = function (text, _callback) {
return createModal(win, {
"content": text,
"attributes": {
"useCloseX": false
},
"buttons": [{
"text": "Yes",
"type": "ok",
"callback": function callback(modal) {
if ($.isFunction(_callback)) {
_callback.apply();
}
triggerResize(win);
}
}, {
"text": "Cancel",
"type": "cancel",
"callback": function callback(modal) {
return $(".inlineHelp").remove();
}
}]
});
};
},
/**
* Function that overrides window.alert() when another function comes in we add
* its text to the top of the current window.
**/
"replaceAlert": function replaceAlert(win) {
var $ = win.$;
win.alert = function (text) {
text = text.replace(/\r\n|\n/g, "<br />");
var popupsOpen = Modal.anyShowing(win);
if (popupsOpen) {
// add the content to the bottom in red
var content = $("<div class='red inlineHelp' />").html(text);
var message; // is there a current alert
if ($(".inlineHelp").length) {
// change text and reset timeout
message = $(".inlineHelp").html(text);
win.clearTimeout(win.helpTimeout);
} else {
// add to bottom and set a timeout
Modal.getCurrent(win).addContent(content);
message = $(".inlineHelp").css("opacity", "0").animate({
"opacity": "1"
}, 500, "linear", function () {
// force resize event
triggerResize(win);
});
}
win.helpTimeout = win.setTimeout(function () {
return message.animate({
"opacity": "0"
}, 500, "linear", function () {
message.remove();
triggerResize(win);
});
}, 15000); // force resize event
triggerResize(win);
} else {
// create a new popup
text = $("<p class='help_popup' />").html(text);
createModal(win, {
"content": text,
"attributes": {
"useCloseX": false
},
"buttons": [{
"text": "Close",
"type": "ok",
"callback": function callback(modal) {
return $(".inlineHelp").remove();
}
}]
});
}
};
},
/**
* Utility for adding fieldPrompt() the window variable.
**/
"addFieldPrompt": function addFieldPrompt(win) {
var $ = win.$;
/**
* Private utility function.
* Default functionality for when pop-up is unavailable.
**/
function defaultPrompt(win, field, message) {
win.alert(message);
}
/**
* Displays a pop-up for a incorrect field.
* Call with field and message: fieldPrompt(<field dom object>, "This field is invalid");
*
* @param fields
* array of fields to be prompted for
* @param message
* message to display about why field is invalid
* @param sumbitOnClose
* (internal) default to use for if to submit the form on successful validation
* @param notryagain
* (internal) if to wait if there is currently a pop-up
**/
function fieldPrompt(fields, message, submitOnClose, notryagain) {
// save for when we call "classic" functions
var passedIn = fields;
var isPassedInArray = !(fields.name || fields.id || fields.type) && fields.length; // force fields is an array
if (!isPassedInArray) {
fields = [];
fields[0] = passedIn;
} // force submitOnClose to be boolean (safety)
if (submitOnClose) {
submitOnClose = true;
} else {
submitOnClose = false;
} // submit when called from validate fields
if (win.runningValidFields) {
submitOnClose = true;
} // if we already have a pop-up just show the extra message
var popupsShowing = Modal.anyShowing(win);
if (popupsShowing) {
// if timeout waiting to spawn pop-up
if (notryagain) {
return defaultPrompt(win, passedIn, message);
} // if we are in a chain of pop-ups
if (!submitOnClose) {
return defaultPrompt(win, passedIn, message);
} else {
// last pop-up in chain is animating, try again soon
return win.setTimeout(function () {
return fieldPrompt(passedIn, message, submitOnClose, true);
}, 550);
}
} // Special Case for GridField validation
try {
if ($(".gridfield").length > 0) {
var gridFields = $(".gridfield");
for (var i = 0; i < gridFields.length; i++) {
if ($.contains(gridFields[i], fields[0])) {
return defaultPrompt(win, passedIn, message);
}
}
}
} catch (e) {}
/* Can safely ignore errors - means we're not in a gridfield*/
// what the fields and caption are contained within
var fieldDelimiter = win.fieldDelimiter || "tr"; // get the parent containing field
var fieldParent = null;
for (var _i8 = 0; _i8 < fields.length; _i8++) {
if (!fieldParent) {
fieldParent = $(fields[_i8]).closest(fieldDelimiter);
} else {
fieldParent = fieldParent.add($(fields[_i8]).closest(fieldDelimiter).eq(0));
}
} // If we could not find the field and its caption
if (!fieldParent.length) {
return defaultPrompt(win, passedIn, message);
} // Get a copy of the fields to display in the pop-up
var isDatefield = $(fieldParent).find(".hasDatepicker").length != 0;
var parentCopy = $(fieldParent).clone(!isDatefield); // clone handlers too (if not a date field)
$(parentCopy).find("*").addBack().each(function () {
var id = $(this).attr("id");
if (id) {
$(this).attr("id", "".concat(id, "_COPY"));
}
}); // remove any nodes marked as do-not-copy (i.e. injected widgets)
$(parentCopy).find(".do-not-copy").remove(); // find matching DOM copies of the field
var fieldCopy = [];
var duplicates = false;
parentCopy.find("*").each(function (index) {
for (var _i9 = 0; _i9 < fields.length; _i9++) {
var result = true;
var field = fields[_i9];
var id = $(field).attr("id");
var copyId = $(this).attr("id");
if ("".concat(id, "_COPY") != copyId) {
result = false;
}
if ($(field).attr("name") != $(this).attr("name")) {
result = false;
}
if ($(field).attr("value") != $(this).attr("value") && $(field).attr("type") != "select-one") {
result = false;
}
if ($(field).attr("type") != $(this).attr("type")) {
result = false;
}
if (result) {
// duplicate of already recorded field, bail
if (fieldCopy[_i9]) {
duplicates = true;
} // record the field in the copy
fieldCopy[_i9] = $(this).get(0);
}
}
}); // if duplicates bail
if (duplicates) {
return defaultPrompt(win, passedIn, message);
} // confirm copy and pass-in have same amount of elements
if (fields.length != fieldCopy.length) {
return defaultPrompt(win, passedIn, message);
} // normalize the two arrays
fields = trimArray(fields);
fieldCopy = trimArray(fieldCopy); // actually show the pop-up
var changeOnClose = false; // build content
var content = $("<div class='invalid'>".concat(message, "</div>")); // place field
$(content).append(parentCopy); // contain field in appropriate html trappings for styling
switch (fieldDelimiter) {
case "tr":
parentCopy.wrap("<table class=\"frmpfields\"></table>");
break;
case "td":
parentCopy.wrap("<table class=\"frmpfields\"><tr></tr></table>");
break;
case "li":
parentCopy.wrap("<ul></ul>");
break;
default:
parentCopy.wrap("<div class=\"fieldprompt\"></div>");
break;
}
createModal(win, {
"content": content,
"attributes": {
"useCloseX": true
},
"showOk": true,
"showCancel": true,
// callback is fired when 'Ok' button is clicked
"callback": function callback(modal) {
// TODO Need to find a better workaround, for some reason fieldCopy doesn't store the value of the field. Same code works in the old V1 architecture.
fieldCopy.filter(function (x) {
return x !== undefined;
}).forEach(function (x) {
var element = $("#".concat(x.id))[0];
x.checked = element.checked;
x.value = element.value;
}); // handle if pass-in was single field
var checkField;
if (isPassedInArray) {
checkField = fieldCopy;
} else {
checkField = fieldCopy[0];
} // check that field is valid
if (!validNewField(win, passedIn, checkField)) {
return false; // this will prevent closing
} // set to resubmit the form
changeOnClose = true;
},
"onOpen": function onOpen() {
if (isDatefield) {
var dfCopy = $(parentCopy).find(".hasDatepicker");
$(dfCopy).removeClass("hasDatepicker");
$(dfCopy).datepicker({
"showOtherMonths": true,
"selectOtherMonths": true,
"showAnim": "slideDown",
"changeYear": true
});
}
triggerResize(win); // HE-2143
$("#".concat(fieldCopy[0].id)).focus();
},
// onClose is fired no matter how modal is closed
"onClose": function onClose() {
$(".inlineHelp").remove();
if (changeOnClose) {
// handle if pass-in was single field
var newField;
if (isPassedInArray) {
newField = fieldCopy;
} else {
newField = fieldCopy[0];
} // re-add field to listeners
reassignFieldListeners(passedIn, newField); // push back data
for (var _i10 = 0; _i10 < fields.length; _i10++) {
// find if ie hack is needed for radio button's state
var ieHack = false;
if (fieldCopy[_i10].checked) {
ieHack = true;
} // actually replace data
$(fields[_i10]).replaceWith(fieldCopy[_i10]);
var id = $(fieldCopy[_i10]).attr("id") || "";
id = id.replace("_COPY", "");
if (id) {
$(fieldCopy[_i10]).attr("id", id);
}
if (isDatefield) {
$(fieldCopy[_i10]).removeClass("hasDatepicker");
$(fieldCopy[_i10]).datepicker({
"showOtherMonths": true,
"selectOtherMonths": true,
"showAnim": "slideDown",
"changeYear": true
});
} // use ie hack
if (ieHack) {
$(fieldCopy[_i10]).attr("checked", "checked");
}
} // notify the field change
_this.setAccess(win, false); // if was triggered by form submission, re-trigger
if (submitOnClose) {
$("[name='submit_button']").trigger("click");
}
}
}
});
} // set fieldPrompt() on the win object
win.fieldPrompt = fieldPrompt;
},
/**
* Initializes a formPage
**/
"initFormPage": function initFormPage(win) {
win.scores = new Array(0);
win.avgField = null;
win.totalField = null;
},
"multiRecordField": function multiRecordField(_window, id, url, fetchNow) {
var $ = _window.$;
function refreshResultPage() {
// "Caching" this selector fixes HE-3707 (Internet Explorer issue)
var $id = $("#".concat(id));
$id.html("<h3>Loading...</h3> <p><img src=\"https://cdn.searchsoft.net/images/loading.gif\" />Please Wait</p>"); // get content
$.get(url, // add ajax notification for server
"ajax=Y&refresh=Y", function (data, textStatus) {
if (textStatus === "success") {
// This is where Internet Explorer requires a "cached" selector. Maybe "$" is getting hijacked by the time the AJAX call finishes?
// populate the result
$id.html(data);
registerResultPageAjaxLinks();
} else {
throw "AJAX error getting content";
}
}, "text");
}
this.refreshResultPage = refreshResultPage; // when page has .resultpageajaxlinks show links in a pop-up; refreshing the
// "source" page when the pop-up is closed
function registerResultPageAjaxLinks() {
// when page has .resultpageajaxlinks show links in a pop-up
if ($("#".concat(id, " .resultpageajaxlinks")).length) {
var popId = "".concat(id, "_popup");
$("#".concat(id, " a:not([class~=\"resultlink\"])")).click(function (eventObject) {
var $this = $(this); // what was clicked on
var href = $this.attr("href"); // is delete link
if ($this.hasClass("delete")) {
_window.superConfirm("Are you sure you want to delete this record?", function () {
return $.post(href, null, function (data, textStatus) {
if (textStatus === "success") {
refreshResultPage();
} else {
throw "AJAX error";
}
});
});
} else {
// ajax to fill in pop-up
_this.addToolboxFunction(_window, popId, function () {
return ajaxFillinPopup(_window, popId, href, null, true);
}); // refresh the result page on close
_this.addToolboxFunction(_window, "".concat(popId, "_close"), function () {
return refreshResultPage();
}); // show a pop-up
_this.showPopup(_window, popId);
} // stop browser from following link
eventObject.preventDefault();
return false;
});
}
}
if (fetchNow) {
refreshResultPage();
} else {
registerResultPageAjaxLinks();
}
},
/**
* Register a JSExpression field
**/
"jsExpression": function jsExpression(win, target, expression, defaults) {
var $ = win.$; // varaiables
var varRegExp = new RegExp("\\b[A-Za-z][A-Za-z0-9_]+\\b", "g"); // create listener for "onchange" of each variable
var variable;
while ((variable = varRegExp.exec(expression)) != null) {
// listener for onchange
var elem = $("[name='".concat(variable, "']"));
if (elem.length) {
elem.unbind(jqueryUniversalChangeSupportedEvents.join(","), runExpression);
jqueryUniversalChange(win, elem.get(0), runExpression);
}
} // utility to run the function
function runExpression() {
// this call will never propagate an exception...
var expr = buildRawExpression();
try {
// change the value of target
var value = eval(expr);
var targetField = $("#".concat(target, "_display"));
var targetHidden = $("#".concat(target));
if (value != targetHidden.val()) {
targetField.val(value);
targetField.trigger("change");
targetHidden.val(value);
targetHidden.trigger("change");
}
} catch (ex) {
lib.replaceAlert(win);
var msg = "<span style='font-size: 1em; font-style: normal; font-weight: normal'>It appears that there is an unresolved variable in the JS Expression string provided:</span><br /><br /><span style='font-size: .8em; font-style: italic; font-weight: bold'>".concat(expr, "</span><br /><br /><span style='font-size: 1em; font-style: normal; font-weight: normal'>Check the unresolved field name and ensure that it corresponds with an input on the page.</span>");
win.alert(msg);
$("#".concat(target, "_display")).val("###");
}
} // utility that returns expression with all variables replaced with their real values
function buildRawExpression() {
var result = expression;
try {
// replace all variables in the string
var _variable;
while ((_variable = varRegExp.exec(expression)) != null) {
// value in the form
var value = null;
var variableField = $("[name='".concat(_variable, "']"));
if (variableField.length != 0 && "###" != variableField.val()) {
value = Number(variableField.val());
} // use the default
else if (defaults[_variable] != null) {
value = Number(defaults[_variable]);
} // don't replace this one
else {
continue;
} // use zero if field had nonsense value
if (!isFinite(value)) {
value = Number(0);
} // replace the value
result = result.replace(new RegExp("\\b".concat(_variable, "\\b"), "g"), value);
}
result = "( ".concat(result, " )");
} catch (e) {
_log(e);
}
return result;
} // run it for the first time
runExpression();
},
"reloadNewMcrelYear": function reloadNewMcrelYear(win, mcrelYearDropDownDomName) {
var $ = win.$; // domReady doesn't work reliably here
$(function () {
var $select = $("select[name=\"".concat(mcrelYearDropDownDomName, "\"]"));
$select.change(function () {
var val = $select.val();
if (val !== "") {
var currentLocation = $("form").prop("action");
var newLocation = URI(currentLocation).setQuery("MCREL_YEAR_ID", val).toString();
win.location.href = newLocation;
}
});
});
},
"reloadTeamMemberDashboard": function reloadTeamMemberDashboard(win) {
var $ = win.$;
_this.onReady(win, function () {
return $("select[name='TEAM_MEMBER_USER_ID']").change(function (e) {
var curLocation = win.location.href;
var url;
if (/TEAM_LED_ID=[^&]*/.test(curLocation)) {
url = curLocation.replace(/TEAM_LED_ID=[^&]*/, "TEAM_LED_ID=".concat($("select[name='TEAM_LED_ID']").val()));
} else {
url = "".concat(curLocation, "&TEAM_LED_ID=").concat($("select[name='TEAM_LED_ID']").val());
}
if (/TEAM_MEMBER_USER_ID=[^&]*/.test(curLocation)) {
url = url.replace(/TEAM_MEMBER_USER_ID=[^&]*/, "TEAM_MEMBER_USER_ID=".concat($(this).val()));
} else {
url = "".concat(url, "&TEAM_MEMBER_USER_ID=").concat($(this).val());
}
var regex = /TEAM_MEMBER_USER_ID=([^&]*)/g;
var match = regex.exec(curLocation);
if (match != null && match[1] == $(this).val()) {
return;
} else {
win.location.href = url;
}
});
});
},
"addReloadOnSelectChange": function addReloadOnSelectChange(win, selectName) {
var $ = win.$;
_this.onReady(win, function () {
return $("select[name='".concat(selectName, "']")).change(function (e) {
var curLocation = win.location.href;
var url;
var urlParamRegex = new RegExp("".concat(selectName, "=[^&]*"));
if (urlParamRegex.test(curLocation)) {
url = curLocation.replace(urlParamRegex, "".concat(selectName, "=").concat($(this).val()));
} else {
url = "".concat(curLocation, "&").concat(selectName, "=").concat($(this).val());
}
var regex = new RegExp("".concat(selectName, "=([^&]*)"), "g");
var match = regex.exec(curLocation);
if (match != null && match[1] == $(this).val()) {
return;
} else {
win.location.href = url;
}
});
});
},
"activatePreview": function activatePreview(win, openNewWindow, inputId, buttonId, lookup) {
var $ = win.$;
$("#".concat(buttonId)).click(function () {
var input = $("[name=".concat(inputId, "]"));
if (!input.length) {
return win.alert("No input field to preview");
}
var value = input.val();
if (value == "" || value == null) {
return win.alert("No input currently selected");
}
var url = lookup[value];
if (url == "" || url == null) {
return win.alert("No preview page for that selection");
}
if (!openNewWindow) {
var div = "".concat(buttonId, "_div");
_this.addToolboxFunction(win, div, function () {
return ajaxFillinPopup(win, div, url, null);
});
_this.showPopup(win, div);
} else {
win.open(url);
}
});
},
/**
* Registers a staged select field
**/
"registerStageSelect": function registerStageSelect(win, fieldId, dbFieldId, parentId, value, multi, required) {
_this.onReady(win, function () {
// JQuery
var $ = win.$; // create the two types of fields we can be
var selectField = $("[name='".concat(fieldId, "']"));
var singleValueId = "singleValue_".concat(fieldId);
if (!selectField.length) {
_log("StagedSelectField is not present!");
return;
} // find the parent
var parentField = $("[name='".concat(parentId, "']"));
if (!parentField.length) {
_log("StagedSelectField parent field is not present: ".concat(parentId));
return;
}
var addWildcard = parentField.attr("type") == "text";
function stageChangeEvent(e) {
// get parent value
var me = $(this);
var parentValue = me.val();
if (addWildcard) {
parentValue += "*";
} // make best faith to encode
if (encodeURIComponent) {
parentValue = encodeURIComponent(parentValue);
} else {
if (escape) {
parentValue = escape(parentValue);
}
} // only proceed for selected checkboxes and radio buttons
var type = me.attr("type");
var checkable = type == "radio" || type == "checkbox";
var selected = me.attr("checked");
if (checkable && !selected) {
return;
} // actually get the results; JSONP request
if (parentValue != "" && parentValue != null) {
var url = "/ats/stage_field_lookup?GUI_FIELD_ID=".concat(dbFieldId, "&parentvalue=").concat(parentValue, "&ajax=Y&jscallback=?");
$.getJSON(url, addLookups);
} else {
nukeChoice();
}
} // add the lookups to the select field
var addOnChange = true;
function addLookups(lookups) {
// error check
if (!lookups) {
_log("lookups null");
return;
} // find length
var length = lookups.length; // support collapsing single values
var showSingleValue = length == 1 && required;
var selectedCaptions = ""; // clear out all current entries
selectField.html("");
$("#".concat(singleValueId)).remove();
if (!showSingleValue) {
selectField.show();
} // final choices
var options = "";
var hasSelected = false; // populate the new ones
$.each(lookups, function (index, obj) {
var lookupValue = obj["value"]; // skip empty string (dummy value)
if (lookupValue == "") {
return;
} // Locate caption
var lookupCaption = obj["caption"]; // if this is our original value mark slected
var selected = "";
if ($.inArray(lookupValue, value) != -1 || showSingleValue) {
selectedCaptions += lookupCaption;
selected = " selected='selected' ";
hasSelected = true;
} // add the value
options += "<option value='".concat(lookupValue, "'").concat(selected, ">").concat(lookupCaption, "</option>");
}); // empty option
if (!(multi || showSingleValue)) {
options = "<option value=''".concat(hasSelected ? "" : " selected='selected' ", "></option>").concat(options);
}
selectField.append(options); // support single value
if (showSingleValue) {
selectField.hide();
var captions = "<div id='".concat(singleValueId, "'>").concat(selectedCaptions, "</div>");
selectField.after(captions);
}
selectField.triggerHandler("change");
if (addOnChange) {
addOnChange = false;
selectField.change(function () {
return _this.setAccess(win, false);
});
}
} // add the lookups to the select field
function nukeChoice() {
// clear out all current entries
selectField.html("").show();
$("#".concat(singleValueId)).remove();
if (!multi) {
selectField.append("<option value='' selected='selected'></option>");
}
selectField.triggerHandler("change");
} // bind to changes on the parent
parentField.bind("change", stageChangeEvent); // trigger initial population
stageChangeEvent.apply(parentField.get(0));
});
},
/**
* Registers a staged text field
**/
"registerStageText": function registerStageText(win, fieldId, dbFieldId, parentId, multi, required) {
_this.onReady(win, function () {
// JQuery
var $ = win.$; // create the two types of fields we can be
var textField = $("[name='".concat(fieldId, "']"));
if (!textField.length) {
alert("StageTextField is not present!");
return;
} // find the parent
var parentField = $("[name='".concat(parentId, "']"));
if (!parentField.length) {
alert("StageTextField parent field is not present: ".concat(parentId));
return;
}
function stageChangeEvent(e) {
// get parent value
var me = $(this);
var parentValue = me.val(); // make best faith to encode
if (encodeURIComponent) {
parentValue = encodeURIComponent(parentValue);
} else {
if (escape) {
parentValue = escape(parentValue);
}
} // only proceed for selected checkboxes and radio buttons
var type = me.attr("type");
var checkable = type == "radio" || type == "checkbox";
var selected = me.attr("checked");
if (checkable && !selected) {
return;
} // actually get the results; JSONP request
if (parentValue != "" && parentValue != null) {
var url = "/ats/stage_field_lookup?GUI_FIELD_ID=".concat(dbFieldId, "&parentvalue=").concat(parentValue, "&ajax=Y&jscallback=?");
$.getJSON(url, addLookups);
}
} // add the lookups to the select field
var addOnChange = true;
function addLookups(lookups) {
// error check
if (!lookups) {
alert("lookups null");
return;
} // error check
if (lookups.length != 1) {
alert("lookup must have one value");
return;
}
var newValue = lookups[0]["value"];
textField.val(newValue); // Hack that fixes SSOFT-5469
// https://stackoverflow.com/questions/11793368/set-textarea-value-with-javascript-after-tinymce-initializing/11793478#11793478
if (win !== null && win.tinymce !== null) {
var tinymceEditor = win.tinymce.get(textField.attr("id"));
if (tinymceEditor !== null) {
tinymceEditor.setContent(newValue);
}
}
textField.triggerHandler("change");
if (addOnChange) {
addOnChange = false;
textField.change(function () {
return _this.setAccess(win, false);
});
}
} // bind to changes on the parent
parentField.bind("change", stageChangeEvent); // trigger initial population
stageChangeEvent.apply(parentField.get(0));
function getFirstKey(data) {
for (var elem in data) {
return elem;
}
}
});
},
"registerMoveToSelect": function registerMoveToSelect(win, domId) {
function alphaSort(doma, domb) {
var a = doma.innerHTML;
var b = domb.innerHTML;
var va = a === null ? "" : "".concat(a);
var vb = b === null ? "" : "".concat(b);
return va > vb ? 1 : va === vb ? 0 : -1;
}
function moveTo($from, $to) {
// move to other side
var $fromdetached = $from.find(":selected");
$fromdetached.detach();
$to.append($fromdetached); // sort result
var $toDetach = $to.children();
$toDetach.detach();
$to.append($toDetach.get().sort(alphaSort));
}
var $ = win.$;
var $dst = $("#".concat(domId));
var $src = $("#".concat(domId, "_src"));
$("#".concat(domId, "_addbtn")).click(function () {
_this.setAccess(win, false);
$dst.children().prop("selected", false);
moveTo($src, $dst);
});
$("#".concat(domId, "_rmvbtn")).click(function () {
_this.setAccess(win, false);
$src.children().prop("selected", false);
moveTo($dst, $src);
});
$("form").on("click", "input:submit", function () {
$src.children().prop("selected", false);
$dst.children().prop("selected", true);
});
},
"browseToNextUrlFromNavigationPulldown": function browseToNextUrlFromNavigationPulldown(win, backward) {
var nextUrl = getNextUrlFromNavigationPulldown(win, backward);
if (nextUrl) {
win.location.href = nextUrl;
} else {
alert("Already at the end or beginning of the list.");
}
},
"writeRedirectFromNav": function writeRedirectFromNav(win) {
return win.$("form").append("<input type=\"hidden\" name=\"redirect\" value=\"".concat(getNextUrlFromNavigationPulldown(win, false), "\">"));
},
"handlePreviousNavButton": function handlePreviousNavButton(win) {
var nextUrl = getNextUrlFromNavigationPulldown(win, true);
if (!nextUrl) {
win.$(":button[value=Previous]").remove();
}
},
"registerQuickSelectGoButton": function registerQuickSelectGoButton(win, id) {
return _this.onReady(win, function () {
var $ = win.$;
$("#".concat(id, "_go")).click(function () {
var selectName = "[name='".concat(id, "']");
var select = $(selectName);
var href = select.val();
if (href != "") {
win.location.href = href;
}
});
});
},
/**
* Tie together an expanding multivalue field (edit only)
**/
"registerExpandingMultiValue": function registerExpandingMultiValue(win, fieldName, showRemove, rangeExtra) {
var $ = win.$;
_this.onReady(win, multiValueField);
function multiValueField() {
// find needed elements
var row;
var org;
var container;
var size;
var maxSize;
var template;
init(); // undo support
$(":reset").click(function (e) {
row.html(org);
init();
});
function init() {
row = $("#".concat(fieldName, "_ROW"));
row.find("script").remove();
org = row.html();
container = $("#".concat(fieldName, "_TABLE_CONTAINER tbody"));
size = row.find("#".concat(fieldName, "_SIZE"));
maxSize = parseFloat(size.val());
template = row.find("#".concat(fieldName, "_TEMPLATE")); // min value
if (rangeExtra) {
addAllMin();
} // auto remove
if (rangeExtra) {
addAllRangeExtra();
} // remove links
if (showRemove) {
addAllRemove();
} // add link
var addMoreId = "".concat(fieldName, "_addmore");
if (!container.parent().find("#".concat(addMoreId)).length) {
var addMoreA = $("<a class=\"addMoreA\"></a>").attr({
"id": addMoreId,
"href": "#"
}).html("<img src=\"/ats/css-base/add.png\" class=\"addMoreImg\"/>Add More").click(function (e) {
e.preventDefault();
_this.setAccess(win, false);
addEmptyRow();
return false;
});
container.closest("table").after(addMoreA);
}
if (parseFloat(size.val()) < 1) {
// first row shouldn't prevent leaving page
addEmptyRow();
}
}
function addEmptyRow() {
// add one to size
var curSize = parseFloat(size.val());
size.val(curSize + 1);
maxSize += 1;
var newRecord = "<tr class=\"subrecord_container ".concat(fieldName, "_subrecord_container\" id=\"").concat(fieldName, "_").concat(maxSize - 1, "\">").concat(template.html().replace(/_TEMPLATE/g, "_SUBRECORD_" + (maxSize - 1)), "</tr>"); // insert new content to html
container.append(newRecord);
var newElem = $("#".concat(fieldName, "_").concat(maxSize - 1)); // add remove
if (showRemove) {
addRemove(newElem);
} // add min
if (rangeExtra) {
addMin(newElem);
} // range extra
if (rangeExtra) {
addRangeExtra(newElem);
}
addRemoveTrigger(newElem); // allow any boxes to resize
triggerResize(win);
}
function addAllRangeExtra() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addRangeExtra(subRecords);
}
function addRangeExtra(jq) {
jq.each(function () {
var me = $(this);
var min = me.find(".subrecord_min");
var field = me.find(jqueryUniversalChangeSupportedTags).get(0);
jqueryUniversalChange(win, field, function () {
rangeExtraTrigger(field, min);
return true;
});
});
function rangeExtraTrigger(field, min) {
var cur = $(field);
var minVal = parseFloat(min.html());
var curVal = parseFloat(cur.val());
if (isNaN(curVal) || minVal >= curVal) {
cur.val(minVal + 1);
}
}
}
function addAllMin() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addMin(subRecords);
}
function addMin(jq) {
// jq object
jq.find(".remove_container").append(" greater than <span class=\"subrecord_min\"></span>");
addMinTrigger(jq);
}
function addMinTrigger(jq) {
jq.each(function () {
var me = $(this);
var prev = me.prev(".".concat(fieldName, "_subrecord_container"));
var min = me.find(".subrecord_min");
if (prev.length) {
var cur = me.find(jqueryUniversalChangeSupportedTags).filter(":first");
var field = prev.find(jqueryUniversalChangeSupportedTags).filter(":first").get(0);
jqueryUniversalChange(win, field, function () {
minTrigger(field, cur, min);
return true;
});
minTrigger(field, cur, min);
} else {
// nothing exists show "min" text
min.html("0");
}
});
function minTrigger(field, cur, min) {
var minVal = parseFloat($(field).val());
var curVal = parseFloat(cur.val());
min.html(minVal);
if (!isNaN(curVal) && minVal >= curVal) {
cur.val(minVal + 1);
cur.trigger("change");
}
}
}
function addAllRemove() {
var subRecords = container.find(".".concat(fieldName, "_subrecord_container"));
addRemove(subRecords);
addRemoveTrigger(subRecords);
}
function addRemove(jq) {
// jq object
jq.find(".remove_container").prepend("<a class=\"subrecord_remove\"><img title=\"Remove\" alt=\"remove\" src=\"/ats/css-base/remove.png\" /></a>");
}
function addRemoveTrigger(jq) {
jq.find(".subrecord_remove").click(function (e) {
_this.setAccess(win, false);
size.val(parseFloat(size.val()) - 1);
var me = $(this).closest(".subrecord_container");
var next = me.next(".subrecord_container");
me.remove();
if (rangeExtra) {
addMinTrigger(next);
}
});
}
}
},
"disableSubmitButtons": function disableSubmitButtons(win) {
win.$("input[type='submit']").attr("disabled", "disabled");
return true;
},
"eformOptionalEventHideFields": function eformOptionalEventHideFields(win, checkboxId) {
/**
* Helper function used to enable/disable a set of elements. Will set/remove 'disabled' attribute
* for all form fields, and will show/hide all elements iterated through.
*
* @param field an HTMLElement or jQuery object
* @param doEnable boolean flag indicating if item should be enabled/disabled
*/
function enable(field, doEnable) {
var formFields = $(field).find("input,select,textarea");
$(formFields).each(function (i, kid) {
if (doEnable) {
$(kid).prop("disabled", false);
} else {
$(kid).prop("disabled", true);
}
});
if (doEnable) {
$(field).show();
} else {
$(field).hide();
}
}
_this.onReady(win, function () {
var $ = win.$;
var checkbox = $("#".concat(checkboxId));
var topRow = checkbox.closest("tr");
var fieldsForEvent = topRow.nextUntil("tr.endEformEvent");
checkbox.change(function () {
var isChecked = checkbox.is(":checked");
enable(fieldsForEvent, isChecked);
});
checkbox.trigger("change");
});
}
};
if (_this.isDevMode) {
/**
* This method is called to initialize and return a DevLinks instance, which exposes
* methods used to interact with and alter behavior of dev links on page. Only one instance per context
* will be created (subsequent calls to this method will return cached instance).
*
* @param {Window} win the context Window
*/
_this.initDevLinks = function () {
function DevLinks(win) {
/**
* Flag indicating if base records should be interacted with (if true) or if alt records should
* be interacted with (if false).
*
* @private
*/
this._useBase; // use for referencing instance in inner/non-member functions
var _devLinks = this; // member functions
/**
* Is called to set the flag indicating whether alt records or base records should be interacted
* with when using dev tools. Each call to this method will also ensure that proper click
* handlers are in place for current page dev tools. The default state is to interact with
* alt records, unless a value of true for useBase is provided.
*
* @param {boolean} [useBase] (optional) if present and true, will interact with base records, and will interact with alt records otherwise
*/
this.setToolAltOption = function (useBase) {
if (_devLinks._useBase === void 0) {
_devLinks._useBase = useBase === true;
} else if (useBase !== void 0) {
_devLinks._useBase = useBase === true;
}
/**
* Is called to enable dev tools to interact with alt records (this is the default behavior).
*/
function enableAlts() {
// will now use alts
_devLinks._useBase = false;
$("div.devmenu a").css({
"background": "#eee"
});
$("div.devmenu a.alttool").each(function () {
var me = $(this);
var href = me.attr("href");
href = href.replace("&usealt=N", "");
me.attr("href", href);
});
}
/**
* Is called to enable dev tools to interact with base records (this is the NON-default behavior,
* and should be treated as potentially risky).
*/
function enableBase() {
// will now use base
_devLinks._useBase = true;
$("div.devmenu a").css({
"background": "orange"
});
$("div.devmenu a.alttool").each(function () {
var me = $(this);
var href = me.attr("href"); // ensure that param has not already been set
href = href.replace("&usealt=N", "");
href = href + "&usealt=N";
me.attr("href", href);
});
}
$("a.dragalt").unbind("click.devtools").bind("click.devtools", function () {
enableAlts();
win.alert("Tools will modify the alt record (default behavior).");
});
$("a.dragbase").unbind("click.devtools").bind("click.devtools", function () {
enableBase();
win.alert("Tools will now modify the base records (for all companies)! \n" + "Danger, this will effect all pages until you log-out or set it back to alt!");
});
if (_devLinks._useBase) {
enableBase();
} else {
enableAlts();
}
}; // initialization and non-member-function definitions
var $ = checkJQuery(win, win.$);
var devDivId = "devdivid"; // cached value of window scroll value used in initDevLinks
var yOffset = 0;
$.extend($.fn.disableTextSelect = function () {
return this.each(function () {// if ($.browser.mozilla) {//Firefox
// $(this).css('MozUserSelect', 'none');
// } else if ($.browser.msie) {//IE
// $(this).bind('selectstart', function () {
// return false;
// });
// } else {//Opera, etc.
// $(this).mousedown(function () {
// return false;
// });
// }
});
}); // after clicking a link scroll back down (but not in the pop-up)
if (yOffset && yOffset != win.yOffset) {
_this.onReady(win, function () {
win.scrollTo(0, yOffset); // only do this once (after clicking a link)
yOffset = 0;
});
}
function addDevDivPopupLoading() {
// add the content
var devDiv = "<div id=\"" + devDivId + "\" style='display: none;'><h3>Loading...</h3> <p><img src='https://cdn.searchsoft.net/images/loading.gif' />Please Wait </p></div>";
$("body").children(":last").after(devDiv); // refresh the page on close
_this.addToolboxFunction(win, devDivId + "_close", function () {
win.yOffset = typeof win.pageYOffset == "number" ? win.pageYOffset : win.document.documentElement ? win.document.documentElement.scrollTop : win.document.body.scrollTop;
yOffset = win.yOffset;
$("body").html("<h1>Reloading...</h1>");
win.location.reload();
});
}
this.activateDevLink = function () {
var me = $(this);
var href = me.attr("href");
if (href) {
if (!me.hasClass("newwindow")) {
var sdata = null;
var hijack = true;
var hijackStayOpen = true;
var devmode = true; // ajax to fill in pop-up
var fullHijack = me.hasClass("wizarddevlink");
var noHijack = me.hasClass("search");
_this.addToolboxFunction(win, devDivId, function () {
// display the result of submitting in the pop-up?
if (fullHijack) {
// wizard
ajaxFillinPopup(win, devDivId, href, sdata, hijack, hijackStayOpen, devmode);
} else {
if (!noHijack) {
// submit and done
ajaxFillinPopup(win, devDivId, href, sdata, hijack, false, devmode);
} // submit to another page
else {
ajaxFillinPopup(win, devDivId, href, sdata, false, false, devmode);
}
}
}); // show a pop-up
_this.showPopup(win, devDivId);
return false;
}
}
return true;
};
function devPopups() {
$("a.devmenulink").each(function () {
this.onclick = _devLinks.activateDevLink;
});
}
function posArrows() {
// what is currently being dragged
var effectWhatFieldId = null; // reset drag if outside
win.document.body.onmouseup = function () {
return effectWhatFieldId = null;
}; // side-by-side
if (win.fieldDelimiter == "td") {
$("div.devfieldmenu").each(function () {
var me = $(this).closest("td");
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var width = me.width();
var height = me.height() - 5;
var demHor = "width: 10px; height: " + height + "px;";
var demVer = "width: " + width + "px; height: 10px;";
var styleDivVer = "style=\"position: absolute;" + demVer + "text-align: center;float: left;clear: both;\"";
var styleDivHor = "style=\"position: absolute;" + demHor + "\"";
var styleLinkVer = "style=\"display: block;" + demVer + "\"";
var styleLinkHor = "style=\"display: block;" + demHor + "overflow: hidden;\"";
var styleImgHor = "style=\"border: 0; padding-top: " + (height / 2 - 30) + "px;\"";
var classStr = ".uparrow,.rightcon,.leftarrow,.downcon";
var upLeftRight = "<div class=\"uparrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/up.png\"/></a></div><div class=\"leftarrow\" " + styleDivHor + "><a " + styleLinkHor + " href=\"\"><img " + styleImgHor + " src=\"/ats/css-base/left.png\"/></a></div><div class=\"rightcon\" style=\"left: " + (width - 5) + "px; position: relative;\"> <div class=\"rightarrow\" " + styleDivHor + "><a " + styleLinkHor + " href=\"\"><img " + styleImgHor + " src=\"/ats/css-base/right.png\"/></a></div></div>"; // IE needs the extra div because position: absolute elements don't display: block (like they should)
var down = "<div class=\"downcon\"><div class=\"downarrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/down.png\"/></a></div></div>"; // register start of drag
var menu = $(this);
menu.disableTextSelect();
menu.get(0).onmousedown = function () {
return effectWhatFieldId = myGuiFieldId;
}; // handle drag end
var endhref = "/ats/admin/drag_move_field.jsp?end_field_id=" + myGuiFieldId; // show links on hover
// lazy register me.hover() b/c IE is slow to register
me.get(0).onmouseover = function (e) {
// derigester on first hit
me.get(0).onmouseover = null; // real event
me.hover(function (e) {
// only when active drag
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
me.prepend(upLeftRight);
me.append(down); // trigger end of drag
me.children(classStr).mouseup(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
var href = endhref + "&start_field_id=" + effectWhatFieldId + "&dir=" + $(this).attr("class").replace(/arrow/, "") + "&usealt=" + (_devLinks._useBase ? "N" : "Y"); // ajax to fill in pop-up
_this.addToolboxFunction(win, devDivId, function () {
return ajaxFillinPopup(win, devDivId, href);
});
_this.showPopup(win, devDivId);
}
});
}
}, function () {
// clear arrows on leaving
me.find(classStr).remove();
});
me.trigger("mouseover");
};
});
} else {
// regular formpage
$("div.devfieldmenu").each(function () {
var me = $(this).closest("tr");
var th = me.find("th");
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first");
if (myGuiFieldId.length) {
myGuiFieldId = myGuiFieldId.eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
} else {
return;
}
var demVer = "width: " + th.width() + "px; height: 1.5em; left: 0;";
var styleDivVer = "style=\"position: absolute;text-align: center;" + demVer + "\"";
var styleLinkVer = "style=\"" + demVer + "display: block;\"";
var classStr = ".uparrow,.downcon";
var up = "<div class=\"uparrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/up.png\"/></a></div>";
var down = "<div class=\"downcon\"><div class=\"downarrow\" " + styleDivVer + "><a " + styleLinkVer + " href=\"\"><img style=\"border: 0;\" src=\"/ats/css-base/down.png\"/></a></div></div>"; // register start of drag
var menu = me.find("div.devmenu");
menu.disableTextSelect();
menu.get(0).onmousedown = function () {
return effectWhatFieldId = myGuiFieldId;
}; // register end of drag
var endhref = "/ats/admin/drag_move_field.jsp?end_field_id=" + myGuiFieldId; // show links on hover
// lazy register me.hover() b/c IE is slow to register
me.get(0).onmouseover = function (e) {
// derigester on first hit
me.get(0).onmouseover = null; // use jquery to make it easy
me.hover(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
th.prepend(up);
th.append(down); // trigger events
me.find(classStr).mouseup(function () {
if (effectWhatFieldId != null && effectWhatFieldId != myGuiFieldId) {
// href
var href = endhref + "&start_field_id=" + effectWhatFieldId + "&dir=" + $(this).attr("class").replace(/arrow/, "") + "&usealt=" + (_devLinks._useBase ? "N" : "Y"); // ajax to fill in pop-up
_this.addToolboxFunction(win, devDivId, function () {
return ajaxFillinPopup(win, devDivId, href);
}); // show a pop-up
_this.showPopup(win, devDivId);
}
});
}
}, function () {
return me.find(classStr).remove();
});
me.trigger("mouseover");
};
});
} // regular form page
}
function dependTool() {
// for all depend links on fields`
$("a.dependtool").unbind().click(function () {
var mymenu = $(this).closest("div.devfieldmenu");
var parentGuiFieldId = $(this).closest("div.devmenu").find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var dependValue = win.prompt("For what value?"); // orignating make a refresh stop link
mymenu.replaceWith("<a onclick='window.location.reload()'>Stop</a>"); // replace all field menus on page with "make depend" link
$("div.devfieldmenu").replaceWith(function () {
var myGuiFieldId = $(this).find("a[href*='GUI_FIELD_ID']:first").eq(0).attr("href").match(/GUI_FIELD_ID=\w*\d*/)[0].replace(/GUI_FIELD_ID=/, "");
var result = "<a class='makedependlink'" + " href='/ats/admin/field_make_depend.jsp" + "?PARENT_GUI_FIELD_ID=" + parentGuiFieldId + "&GUI_FIELD_ID=" + myGuiFieldId + "&value=" + encodeURIComponent(dependValue) + "&ajax=Y" + "&usealt=" + (_devLinks._useBase ? "N" : "Y") + "' >" + " Make Dependant</a>";
return result;
}); // silently go to page
$("a.makedependlink").unbind().click(function (e) {
var me = $(this);
e.preventDefault();
var url = $(this).attr("href");
$.get(url, null, function (data, rstatus) {
if (rstatus == "success") {
me.remove();
} else {
win.alert("failed to make dependant, check your console and get a developer");
}
});
return false;
});
});
}
function hideDevLinks() {
$("a.hidedev").click(function (e) {
e.preventDefault();
hideDevLinks();
});
function hideDevLinks() {
$(".debug,.devmenu").fadeOut();
}
}
function showHiddenLinks(win) {
$(".showhidden").click(function (e) {
e.preventDefault();
if (win.location.search == "") {
win.location.search = "?showhidden=Y";
} else {
if (win.location.search.match(/showhidden=Y/)) {
win.location.search = win.location.search.replace(/[\?\&]showhidden=Y/, "");
} else {
win.location.search += "&showhidden=Y";
}
}
});
}
function autoAltCompanyId() {
var alt = $("select[name='ALT_COMPANY_ID']");
if (alt.length && !alt.val()) {
alt.val("<%=companyId%>");
}
}
function showFieldNames() {
$("a.showFieldNames").click(function () {
return $("span.fieldName").show();
});
}
_this.onReady(win, function () {
if (!win.devDone) {
addDevDivPopupLoading();
_devLinks.setToolAltOption();
showFieldNames();
posArrows();
dependTool();
devPopups();
hideDevLinks();
showHiddenLinks(win);
autoAltCompanyId();
} else {// if ($.browser.msie && $.browser.version < 9) {
// //TODO: #modal
// //$("#simplemodal-container .devmenu").hide();
// }
}
win.devDone = true;
});
}
return function (win) {
if (!win._ss_devLinks) {
win._ss_devLinks = new DevLinks(win);
}
return win._ss_devLinks;
};
}();
}
/**
* Class used to construct and render a hierarchical set of checkboxes with cascading click functionality.
*
* @param win
* @param scriptId
* @param json
* @constructor
*/
function HierCheckboxModel(win, scriptId, json) {
var $ = win.$;
/**
* The root node object containing node hierarchy.
* @type {{children: Array}}
* @private
*/
this._rootNode = {
"children": []
};
/**
* Collection of ALL node instances.
* @type {Array}
* @private
*/
this._allNodes = [];
/**
* Counter used to generate unique index for all nodes.
* @type {number}
* @private
*/
this._counter = 0;
var _this = this;
function cascadeChecks(field, index) {
function cascadeNodeChecks(node) {
var children = node.children;
for (var i = 0; i < children.length; i++) {
children[i].field.checked = node.field.checked;
cascadeNodeChecks(children[i]);
}
}
lib.setAccess(win, false);
var node = _this._allNodes[index];
cascadeNodeChecks(node);
if (node.field.checked) {
var parent = node.parent;
while (parent != null && parent.field != null) {
parent.field.checked = node.field.checked;
parent = parent.parent;
}
}
}
/**
* Renders node, recursing through all kids, if present, and appending HTML to parent provided.
*
* @param parent parent HTML element to append generated HTML to
* @param parentNode parent node object
* @param json JSON containing node data
* @private
*/
function _doRender(parent, parentNode, json) {
var node = json.node;
var kids = json.children;
parentNode = _renderListItem(node, _this._counter++, parentNode);
$(parent).append(parentNode.html);
if (kids.length > 0) {
var html = $("<ul></ul>");
$(parentNode.html).append(html);
$.each(kids, function (i, kid) {
return _doRender(html, parentNode, kid);
});
}
}
/**
* Is called to generate LI tag containing checkbox and caption (or a link, if a URL is present in
* node JSON).
*
* @param node the JSON object containing info used to render checkbox
* @param index the unique counter value for this instance
* @param rootNode the parent node for this instance
* @param [imgSrc] optional - if present, renders an image link
* @param [expandAction] optional - if present, is Lib funnction to call on click
*
* @returns {{html: (*|jQuery|HTMLElement), field: *, children: Array, parent: *}} new node object
* @private
*/
function _renderListItem(node, index, rootNode, imgSrc, expandAction) {
var name = node.name;
var value = node.value;
var checked = node.isChecked;
var caption = node.caption;
var url = node.url; // ensure values are null rather than undefined if not provided (unsure if any explicit null-checks occur below)
imgSrc = imgSrc === void 0 || imgSrc == "null" ? null : imgSrc;
expandAction = expandAction === void 0 || expandAction == "null" ? null : expandAction;
var listItem = $("<li></li>"); // the list item content item
var item;
if (imgSrc != null && expandAction != null) {
item = $("<a></a>").attr("href", "#".concat(value));
$(item).click(function (event) {
try {
return lib[expandAction](win, value, index);
} catch (e) {
_log(e);
}
});
var img = $("<img />").attr("border", "0").attr("src", imgSrc);
$(item).append(img);
} else if (imgSrc != null) {
item = $("<img />").attr("src", imgSrc).attr("border", "0");
}
if (item) {
$(listItem).append(item);
}
var input = $("<input />").attr("type", "checkbox").attr("name", name).attr("value", value);
if (checked) {
$(input).attr("checked", "checked");
}
$(input).click(function (event) {
cascadeChecks(this, index);
});
$(listItem).append(input);
if (!url) {
$(listItem).append(win.document.createTextNode(caption));
} else {
url = url.indexOf("http://") == 0 ? url : "http://" + url;
var a = $("<a></a>").attr("target", "_blank").attr("href", url).text(caption);
$(listItem).append(a);
}
var newNode = {
"html": listItem,
"field": input[0],
"children": [],
"parent": rootNode
};
newNode.parent.children.push(newNode);
_this._allNodes.push(newNode);
return newNode;
}
/**
* Is called to assemble checkboxes and inject into DOM.
*/
this.render = function () {
var script = $("script#".concat(scriptId));
json = $.parseJSON(json);
var ul = $("<ul></ul>");
_doRender(ul, _this._rootNode, json);
$(ul).insertAfter(script);
};
}
/**
* Default globaal error handler - redirects to error.jsp.
*
* @param msg
* @param url
* @param ln
*/
function handleError(msg, url, ln) {
_log(new Error(msg), true); // if (top.frames.length > 1 && top.frames[1].name == 'sss_dynomite') {
// top.sss_dynomite.window.document.location.replace(
// '/ats/jserror.jsp?msg=' + escape(msg) + '&url=' + escape(url) + '&line=' + ln
// );
// if (!_this.loaded) {
// top.document.location.replace(
// '/ats/error.jsp?msg=' +
// 'There+was+an+internal+error.++You+have+been+logged+out.' +
// '++Please+close+all+browsers+and+try+again.&showback=N'
// );
// self.open(
// '/ats/logout.jsp?missedlogout=Y', 'Logout',
// 'location=no,menubar=no,titlebar=no,personalbar=no,height=1,width=1');
// }
// }
// else {
// top.document.location.replace(
// '/ats/error.jsp?msg=' +
// 'There+was+an+internal+error.++You+have+been+logged+out.' +
// '++Please+close+all+browsers+and+try+again.&showback=N'
// );
// self.open('/ats/jserror.jsp?msg=' + escape(msg) + '&url=' + escape(url) + '&line=' + ln + '&closeWindow=Y', 'jserror');
// self.open('/ats/logout.jsp?missedlogout=Y', 'Logout', 'location=no,menubar=no,titlebar=no,personalbar=no,height=1,width=1');
// }
}
/**
* Error handler that reports error without redirecting user.
* @param msg
* @param url
* @param ln
*/
function displayError(msg, url, ln) {
_log(msg);
} // do NOT add window.onerror if addGlobalErrorHandler has been set to explicit false
window.onerror = init.addGlobalErrorHandler === false ? null : this.isDevMode ? displayError : handleError; // add lib properties as instance properties
$.each(lib, function (name, val) {
return _this[name] = val;
});
_this.perform_cookie_test();
onLoadCallback.call(this, this); // send in 'lib' instance as arg to onLoad
this.loaded = true;
}
|
console-api |
log |
URL: https://www.searchsoft.net/resources/js/autosave.bundle.js?v=201909200933(Line 9948)
Message:
JQMIGRATE: Migrate is installed with logging active, version 1.4.1
|
console-api |
warning |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21253)
Message:
JQMIGRATE: jQuery.fn.size() is deprecated; use the .length property
|
console-api |
log |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21256)
Message:
console.trace
|
console-api |
warning |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21253)
Message:
JQMIGRATE: jQuery.browser is deprecated
|
console-api |
log |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21256)
Message:
console.trace
|
console-api |
warning |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21253)
Message:
JQMIGRATE: jQuery.support.boxModel is deprecated
|
console-api |
log |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21256)
Message:
console.trace
|
console-api |
warning |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21253)
Message:
JQMIGRATE: jQuery.boxModel is deprecated
|
console-api |
log |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21256)
Message:
console.trace
|
console-api |
warning |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21253)
Message:
JQMIGRATE: jQuery.browser is deprecated
|
console-api |
log |
URL: https://www.searchsoft.net/resources/js/library.bundle.js?v=201909200933(Line 21256)
Message:
console.trace
|