Skip to content

Commit

Permalink
Merge pull request #6666 from ChurchCRM/js-minor-cleanup
Browse files Browse the repository at this point in the history
Js minor cleanup
  • Loading branch information
DawoudIO authored Nov 14, 2023
2 parents 4d39792 + e62926d commit 49021c9
Show file tree
Hide file tree
Showing 18 changed files with 93 additions and 95 deletions.
14 changes: 7 additions & 7 deletions src/Include/domLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

// browsers
var domLib_userAgent = navigator.userAgent.toLowerCase();
var domLib_isOpera = domLib_userAgent.indexOf("opera 7") != -1 ? 1 : 0;
var domLib_isKonq = domLib_userAgent.indexOf("konq") != -1 ? 1 : 0;
var domLib_isOpera = domLib_userAgent.indexOf("opera 7") !== -1 ? 1 : 0;
var domLib_isKonq = domLib_userAgent.indexOf("konq") !== -1 ? 1 : 0;
var domLib_isIE =
!domLib_isKonq &&
!domLib_isOpera &&
(domLib_userAgent.indexOf("msie 5") != -1 ||
domLib_userAgent.indexOf("msie 6") != -1);
(domLib_userAgent.indexOf("msie 5") !== -1 ||
domLib_userAgent.indexOf("msie 6") !== -1);
var domLib_isIE5up = domLib_isIE;
var domLib_isIE50 = domLib_isIE && domLib_userAgent.indexOf("msie 5.0") != -1;
var domLib_isIE55 = domLib_isIE && domLib_userAgent.indexOf("msie 5.5") != -1;
var domLib_isIE50 = domLib_isIE && domLib_userAgent.indexOf("msie 5.0") !== -1;
var domLib_isIE55 = domLib_isIE && domLib_userAgent.indexOf("msie 5.5") !== -1;
var domLib_isIE5 = domLib_isIE50 || domLib_isIE55;
var domLib_isIE55up = domLib_isIE5up && !domLib_isIE50;
var domLib_isIE6up = domLib_isIE55up && !domLib_isIE55;
var domLib_isGecko = domLib_userAgent.indexOf("gecko") != -1 ? 1 : 0;
var domLib_isGecko = domLib_userAgent.indexOf("gecko") !== -1 ? 1 : 0;

// abilities
var domLib_useLibrary =
Expand Down
16 changes: 8 additions & 8 deletions src/Include/domMenu-IE.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,17 @@ domMenu_settings.setItem(
* @var domMenu_is{Browser}
*/
var domMenu_userAgent = navigator.userAgent.toLowerCase();
var domMenu_isOpera = domMenu_userAgent.indexOf("opera 7") != -1 ? 1 : 0;
var domMenu_isKonq = domMenu_userAgent.indexOf("konq") != -1 ? 1 : 0;
var domMenu_isOpera = domMenu_userAgent.indexOf("opera 7") !== -1 ? 1 : 0;
var domMenu_isKonq = domMenu_userAgent.indexOf("konq") !== -1 ? 1 : 0;
var domMenu_isIE = !domMenu_isKonq && !domMenu_isOpera && document.all ? 1 : 0;
var domMenu_isIE50 =
domMenu_isIE && domMenu_userAgent.indexOf("msie 5.0") != -1;
domMenu_isIE && domMenu_userAgent.indexOf("msie 5.0") !== -1;
var domMenu_isIE55 =
domMenu_isIE && domMenu_userAgent.indexOf("msie 5.5") != -1;
domMenu_isIE && domMenu_userAgent.indexOf("msie 5.5") !== -1;
var domMenu_isIE5 = domMenu_isIE50 || domMenu_isIE55;
var domMenu_isSafari = domMenu_userAgent.indexOf("safari") != -1 ? 1 : 0;
var domMenu_isSafari = domMenu_userAgent.indexOf("safari") !== -1 ? 1 : 0;
var domMenu_isGecko =
!domMenu_isSafari && domMenu_userAgent.indexOf("gecko") != -1 ? 1 : 0;
!domMenu_isSafari && domMenu_userAgent.indexOf("gecko") !== -1 ? 1 : 0;

/**
* Passport to use the menu system, checked before performing menu manipulation
Expand Down Expand Up @@ -279,7 +279,7 @@ function domMenu_Hash() {
}

for (var tmp_key in this.items) {
if (this.items[tmp_key] != in_hash.items[tmp_key]) {
if (this.items[tmp_key] !== in_hash.items[tmp_key]) {
return false;
}
}
Expand Down Expand Up @@ -890,7 +890,7 @@ function domMenu_openEvent(in_this, in_event, in_openDelay) {

// if we are moving amongst children of the same element, just ignore event
if (
eventObj.type != "mousedown" &&
eventObj.type !== "mousedown" &&
domMenu_getElement(eventObj[domMenu_eventFrom], basename) ==
currentTarget
) {
Expand Down
16 changes: 8 additions & 8 deletions src/Include/domMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,17 @@ domMenu_settings.setItem(
* @var domMenu_is{Browser}
*/
var domMenu_userAgent = navigator.userAgent.toLowerCase();
var domMenu_isOpera = domMenu_userAgent.indexOf("opera 7") != -1 ? 1 : 0;
var domMenu_isKonq = domMenu_userAgent.indexOf("konq") != -1 ? 1 : 0;
var domMenu_isOpera = domMenu_userAgent.indexOf("opera 7") !== -1 ? 1 : 0;
var domMenu_isKonq = domMenu_userAgent.indexOf("konq") !== -1 ? 1 : 0;
var domMenu_isIE = !domMenu_isKonq && !domMenu_isOpera && document.all ? 1 : 0;
var domMenu_isIE50 =
domMenu_isIE && domMenu_userAgent.indexOf("msie 5.0") != -1;
domMenu_isIE && domMenu_userAgent.indexOf("msie 5.0") !== -1;
var domMenu_isIE55 =
domMenu_isIE && domMenu_userAgent.indexOf("msie 5.5") != -1;
domMenu_isIE && domMenu_userAgent.indexOf("msie 5.5") !== -1;
var domMenu_isIE5 = domMenu_isIE50 || domMenu_isIE55;
var domMenu_isSafari = domMenu_userAgent.indexOf("safari") != -1 ? 1 : 0;
var domMenu_isSafari = domMenu_userAgent.indexOf("safari") !== -1 ? 1 : 0;
var domMenu_isGecko =
!domMenu_isSafari && domMenu_userAgent.indexOf("gecko") != -1 ? 1 : 0;
!domMenu_isSafari && domMenu_userAgent.indexOf("gecko") !== -1 ? 1 : 0;

/**
* Passport to use the menu system, checked before performing menu manipulation
Expand Down Expand Up @@ -274,7 +274,7 @@ function domMenu_Hash() {
};

this.compare = function (in_hash) {
if (this.length != in_hash.length) {
if (this.length !== in_hash.length) {
return false;
}

Expand Down Expand Up @@ -890,7 +890,7 @@ function domMenu_openEvent(in_this, in_event, in_openDelay) {

// if we are moving amongst children of the same element, just ignore event
if (
eventObj.type != "mousedown" &&
eventObj.type !== "mousedown" &&
domMenu_getElement(eventObj[domMenu_eventFrom], basename) ==
currentTarget
) {
Expand Down
66 changes: 33 additions & 33 deletions src/Include/domTT.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ function domTT_activate(in_this, in_event) {
var tooltip = domTT_tooltips.get(owner.id);
if (tooltip) {
if (tooltip.get("eventType") != in_event.type) {
if (tooltip.get("type") == "greasy") {
if (tooltip.get("type") === "greasy") {
tooltip.set("closeAction", "destroy");
domTT_deactivate(owner.id);
} else if (tooltip.get("status") != "inactive") {
} else if (tooltip.get("status") !== "inactive") {
return owner.id;
}
} else {
if (tooltip.get("status") == "inactive") {
if (tooltip.get("status") === "inactive") {
tooltip.set("status", "pending");
tooltip.set(
"activateTimeout",
Expand Down Expand Up @@ -210,7 +210,7 @@ function domTT_activate(in_this, in_event) {
// load in the options from the function call
for (var i = 2; i < arguments.length; i += 2) {
// load in predefined
if (arguments[i] == "predefined") {
if (arguments[i] === "predefined") {
var predefinedOptions = domTT_predefined.get(arguments[i + 1]);
for (var j in predefinedOptions.elementData) {
options.set(j, predefinedOptions.get(j));
Expand Down Expand Up @@ -285,7 +285,7 @@ function domTT_create(in_options) {

if (
in_options.get("caption") ||
(in_options.get("type") == "sticky" &&
(in_options.get("type") === "sticky" &&
in_options.get("caption") !== false)
) {
// layout the tip with a hidden formatting table
Expand All @@ -312,7 +312,7 @@ function domTT_create(in_options) {
caption.style.height = "100%";
caption.appendChild(document.createTextNode(in_options.get("caption")));

if (in_options.get("type") == "sticky") {
if (in_options.get("type") === "sticky") {
var numCaptionCells = 2;
var closeLinkCell = captionRow.appendChild(
document.createElement("td"),
Expand Down Expand Up @@ -404,7 +404,7 @@ function domTT_create(in_options) {

// tooltip floats
if (
in_options.get("position") == "absolute" &&
in_options.get("position") === "absolute" &&
!(in_options.has("x") && in_options.has("y"))
) {
// determine the offset relative to the pointer
Expand Down Expand Up @@ -439,7 +439,7 @@ function domTT_create(in_options) {
in_options.set("offsetWidth", tipObj.offsetWidth);
in_options.set("offsetHeight", tipObj.offsetHeight);
if (domLib_canFade && typeof alphaAPI == "function") {
if (in_options.get("fade") != "neither") {
if (in_options.get("fade") !== "neither") {
var fadeHandler = new alphaAPI(tipObj, 50, 50, 100, 0, null, 10);
fadeHandler.setAlpha(0);
in_options.set("fadeHandler", fadeHandler);
Expand All @@ -461,8 +461,8 @@ function domTT_create(in_options) {
};
}

if (in_options.get("type") == "sticky") {
if (in_options.get("position") == "absolute" && domTT_dragStickyTips) {
if (in_options.get("type") === "sticky") {
if (in_options.get("position") === "absolute" && domTT_dragStickyTips) {
if (domLib_isIE) {
captionRow.onselectstart = function () {
return false;
Expand All @@ -480,7 +480,7 @@ function domTT_create(in_options) {
domTT_dragStop();
};
}
} else if (in_options.get("type") == "velcro") {
} else if (in_options.get("type") === "velcro") {
tipObj.onmouseout = function (in_event) {
if (typeof in_event == "undefined") {
in_event = event;
Expand All @@ -491,7 +491,7 @@ function domTT_create(in_options) {
};
}

if (in_options.get("position") == "relative") {
if (in_options.get("position") === "relative") {
tipObj.style.position = "relative";
}

Expand All @@ -512,13 +512,13 @@ function domTT_show(in_ownerId, in_event) {
var status = tooltip.get("status");
var tipObj = tooltip.get("node");

if (tooltip.get("position") == "absolute") {
if (tooltip.get("position") === "absolute") {
if (tooltip.has("x") && tooltip.has("y")) {
var mouse_x = tooltip.get("x");
var mouse_y = tooltip.get("y");
} else if (
!domTT_useGlobalMousePosition ||
status == "active" ||
status === "active" ||
tooltip.get("delay") == 0
) {
var eventPosition = domLib_getEventPosition(in_event);
Expand All @@ -534,8 +534,8 @@ function domTT_show(in_ownerId, in_event) {
// if this is not a mousemove event or it is a mousemove event on an active tip and
// the movement is bigger than the grid
if (
in_event.type != "mousemove" ||
(status == "active" &&
in_event.type !== "mousemove" ||
(status === "active" &&
(Math.abs(tooltip.get("lastX") - mouse_x) >
tooltip.get("grid") ||
Math.abs(tooltip.get("lastY") - mouse_y) >
Expand Down Expand Up @@ -573,28 +573,28 @@ function domTT_show(in_ownerId, in_event) {
}

// if tip is not active, active it now and check for a fade in
if (status == "pending") {
if (status === "pending") {
// unhide the tooltip
tooltip.set("status", "active");
tipObj.style.display = "";
tipObj.style.visibility = "visible";

var fade = tooltip.get("fade");
if (fade != "neither") {
if (fade !== "neither") {
var fadeHandler = tooltip.get("fadeHandler");
if (fade == "out" || fade == "both") {
if (fade === "out" || fade === "both") {
fadeHandler.pause();
if (fade == "out") {
if (fade === "out") {
fadeHandler.reset();
}
}

if (fade == "in" || fade == "both") {
if (fade === "in" || fade === "both") {
fadeHandler.fadeIn();
}
}

if (tooltip.get("type") == "greasy" && tooltip.get("lifetime") != 0) {
if (tooltip.get("type") === "greasy" && tooltip.get("lifetime") != 0) {
tooltip.set(
"lifetimeTimeout",
domLib_setTimeout(
Expand All @@ -608,7 +608,7 @@ function domTT_show(in_ownerId, in_event) {
}
}

if (tooltip.get("position") == "absolute") {
if (tooltip.get("position") === "absolute") {
domLib_detectCollisions(tipObj);
}
}
Expand All @@ -620,21 +620,21 @@ function domTT_deactivate(in_ownerId) {
var tooltip = domTT_tooltips.get(in_ownerId);
if (tooltip) {
var status = tooltip.get("status");
if (status == "pending") {
if (status === "pending") {
// cancel the creation of this tip if it is still pending
domLib_clearTimeout(tooltip.get("activateTimeout"));
tooltip.set("status", "inactive");
} else if (status == "active") {
} else if (status === "active") {
if (tooltip.get("lifetime")) {
domLib_clearTimeout(tooltip.get("lifetimeTimeout"));
}

var tipObj = tooltip.get("node");
if (tooltip.get("closeAction") == "hide") {
if (tooltip.get("closeAction") === "hide") {
var fade = tooltip.get("fade");
if (fade != "neither") {
if (fade !== "neither") {
var fadeHandler = tooltip.get("fadeHandler");
if (fade == "out" || fade == "both") {
if (fade === "out" || fade === "both") {
fadeHandler.pause();
fadeHandler.fadeOut();
} else {
Expand Down Expand Up @@ -671,7 +671,7 @@ function domTT_mouseout(in_owner, in_event) {
var tooltip = domTT_tooltips.get(in_owner.id);
if (
tooltip &&
(tooltip.get("type") == "greasy" || tooltip.get("status") != "active")
(tooltip.get("type") === "greasy" || tooltip.get("status") !== "active")
) {
// deactivate tip if exists and we moved away from the owner
if (!toChild) {
Expand All @@ -697,7 +697,7 @@ function domTT_mousemove(in_owner, in_event) {
}

var tooltip = domTT_tooltips.get(in_owner.id);
if (tooltip && tooltip.get("trail") && tooltip.get("status") == "active") {
if (tooltip && tooltip.get("trail") && tooltip.get("status") === "active") {
domTT_show(in_owner.id, in_event);
}
}
Expand Down Expand Up @@ -772,7 +772,7 @@ function domTT_correctEdgeBleed(
in_height -
(pageHeight - domTT_screenEdgePadding)) > 0
) {
if (in_type == "sticky") {
if (in_type === "sticky") {
in_y -= bleedBottom;
} else {
in_y -= in_height + 2 * in_offsetY + domTT_mouseHeight;
Expand All @@ -782,7 +782,7 @@ function domTT_correctEdgeBleed(
// if we are bleeding off the top, flip to south
// we don't want an 'else if' here, because if we just can't fit it, bleed off the bottom
if (in_y - pageYOffset < domTT_screenEdgePadding) {
if (in_type == "sticky") {
if (in_type === "sticky") {
in_y = domTT_screenEdgePadding + pageYOffset;
} else {
in_y += in_height + 2 * in_offsetY + domTT_mouseHeight;
Expand All @@ -797,7 +797,7 @@ function domTT_correctEdgeBleed(

function domTT_isActive(in_ownerId) {
var tooltip = domTT_tooltips.get(in_ownerId);
if (!tooltip || tooltip.get("status") != "active") {
if (!tooltip || tooltip.get("status") !== "active") {
return false;
} else {
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/skin/js/CRMJSOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ window.CRM.system = {
var errortext = textStatus + " " + errorThrown;
}

if (!(textStatus == "abort" || suppressErrorDialog)) {
if (!(textStatus === "abort" || suppressErrorDialog)) {
if (CRMResponse) {
window.CRM.DisplayErrorMessage(jqXHR.url, CRMResponse);
} else {
Expand Down Expand Up @@ -578,7 +578,7 @@ window.CRM.dashboard = {
$("#translationInfo").html(
data.name + " [" + window.CRM.locale + "]",
);
if (data.countryFlagCode != "us" && data.poPerComplete < 90) {
if (data.countryFlagCode !== "us" && data.poPerComplete < 90) {
$("#translationPer").html(data.poPerComplete + "%");
$("#localePer").removeClass("hidden");
}
Expand Down
2 changes: 1 addition & 1 deletion src/skin/js/DepositSlipEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function initPaymentTable() {
},
];

if (depositType == "CreditCard") {
if (depositType === "CreditCard") {
colDef.push({
width: "auto",
title: i18next.t("Details"),
Expand Down
8 changes: 4 additions & 4 deletions src/skin/js/FamilyRegister.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ $(document).ready(function () {
}).done(function (data) {
let familyCountry = $("#familyCountry");
$.each(data, function (idx, country) {
let selected = familyCountry.data("system-default") == country.name;
let selected = familyCountry.data("system-default") === country.name;
familyCountry.append(
new Option(country.name, country.code, selected, selected),
);
Expand Down Expand Up @@ -215,11 +215,11 @@ $(document).ready(function () {

let phoneType = $("#memberPhoneType-" + i).val();
let phoneNumber = $("#memberPhone-" + i).val();
if (phoneType == "mobile") {
if (phoneType === "mobile") {
person["cellPhone"] = phoneNumber;
} else if (phoneType == "work") {
} else if (phoneType === "work") {
person["workPhone"] = phoneNumber;
} else if (phoneType == "home") {
} else if (phoneType === "home") {
person["homePhone"] = phoneNumber;
}
family["people"].push(person);
Expand Down
Loading

0 comments on commit 49021c9

Please sign in to comment.