Skip to content

Commit

Permalink
Fixes deprecated jquery usages
Browse files Browse the repository at this point in the history
  • Loading branch information
iccole committed Jan 16, 2025
1 parent 85db542 commit 8410e01
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
28 changes: 14 additions & 14 deletions pn-site/js/guidesearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ $(document).ready(

if(val == "text"){

$("#beta-on, #caps, #marks").removeAttr("disabled", "disabled");
$("#beta-on, #caps, #marks").prop("disabled", false);
hic.checkBetacode();

}
else{

$("#beta-on").removeAttr("checked");
$("#beta-on").attr("disabled", "disabled");
$("#caps").attr("checked", "checked");
$("#caps").attr("disabled", "disabled");
$("#marks").attr("checked", "checked");
$("#marks").attr("disabled", "disabled");
$("#beta-on").prop("checked", false);
$("#beta-on").prop("disabled", true);
$("#caps").prop("checked", true);
$("#caps").prop("disabled", true);
$("#marks").prop("checked", true);
$("#marks").prop("disabled", true);

}

Expand Down Expand Up @@ -313,7 +313,7 @@ $(document).ready(

var keyword = $(stringcontrols[i]).find(".keyword").val();
var searchString = keyword.replace(/(\s+)/g, " ");
searchString = $.trim(searchString);
searchString = searchString.trim();
if(searchString.length == 0) continue;
searchString = "(" + searchString + ")";
if(keyword.match(proxRegExp)){
Expand Down Expand Up @@ -377,16 +377,16 @@ $(document).ready(

colonFound = true;
$(".stringsearch-section input:radio").attr("disabled", "disabled");
$(".stringsearch-section input:checkbox").removeAttr("disabled");
$(".stringsearch-section input:checkbox").prop("disabled", false);
selectedRadios = $(".stringsearch-section input:radio:checked");
$(".stringsearch-section input:radio:checked").removeAttr("checked");
$(".stringsearch-section input:radio:checked").prop("checked", false);

}
// check to make sure user hasn't deleted a previously-entered colon char
else if(!val.match(":") && colonFound){

colonFound = false;
$(".stringsearch-section input:radio").removeAttr("disabled");
$(".stringsearch-section input:radio").prop("disabled", false);
for(var i = 0; i < selectedRadios.length; i++){

selectedRadios[i].trigger('click');
Expand Down Expand Up @@ -651,7 +651,7 @@ $(document).ready(
// turning betacode on/off selects text input
$("#beta-on").on("change", () => {

$(".stringsearch-top-controls:last .keyword").focus();
$(".stringsearch-top-controls:last .keyword").trigger('focus');
var beta = $(this).is(":checked") ? "beta-on" : "beta-off";
$.cookie(hic.BETA_COOKIE, beta);

Expand Down Expand Up @@ -730,13 +730,13 @@ $(document).ready(

$("input[name=DATE_START]").on("click", (evt) => {

$("input:radio[name=after-era]").removeAttr("disabled");
$("input:radio[name=after-era]").prop("disabled", false);

});

$("input[name=DATE_END]").on("click", (evt) => {

$("input:radio[name=before-era]").removeAttr("disabled");
$("input:radio[name=before-era]").prop("disabled", false);

});

Expand Down
6 changes: 5 additions & 1 deletion pn-site/js/jquery.cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ jQuery.cookie = function(name, value, options) {
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Modified from original code to trim the cookie value using native String.prototype.trim
let cookie = cookies[i];
if (typeof cookie === 'string') {
cookie = cookie.trim();
}
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
Expand Down
28 changes: 14 additions & 14 deletions pn-site/js/stringsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{
return this.each(function()
{
$(this).focus()
$(this).trigger('focus');

// If this function exists...
if (this.setSelectionRange)
Expand Down Expand Up @@ -272,7 +272,7 @@ $(document).ready(

if(boxval.match(proxRegExp)){

$(controls).find(".prxcount").removeAttr("disabled");
$(controls).find(".prxcount").prop("disabled", false);
$(controls).find(".within").css("color", "#000");

}
Expand All @@ -295,7 +295,7 @@ $(document).ready(
if(boxval.match(proxCountRegExp)){

var prxunit = $($(controls).find(".prxunit"));
prxunit.removeAttr("disabled");
prxunit.prop("disabled", false);
if(prxunit.val() != "words" && prxunit.val() != "chars") prxunit.val("chars");

}
Expand Down Expand Up @@ -345,7 +345,7 @@ $(document).ready(

hic.activateButton = function(button){

$(button).removeAttr("disabled");
$(button).prop("disabled", false);
$(button).removeClass("ui-state-disabled");
$(button).css("background", "#C0D3BC url(css/custom-theme/images/ui-bg_glass_75_c0d3bc_1x400.png) 50% 50% repeat-x");

Expand All @@ -367,7 +367,7 @@ $(document).ready(
var input = $(parent).find(".keyword");
var val = input.val();
var newVal = (hic.needsSpace(val, keyword) ? val + " " : val) + keyword;
input.focus();
input.trigger('focus');
input.val(newVal);
hic.doButtonActivationCheck(input.val(), parent);
hic.doProxControlsActivationCheck(input.val(), parent);
Expand Down Expand Up @@ -398,7 +398,7 @@ $(document).ready(
var input = $(parent).find(".keyword");
var val = input.val();
var newVal = val + mark;
input.focus();
input.trigger('focus');
input.val(newVal);
hic.doButtonActivationCheck(input.val(), parent);
hic.doProxControlsActivationCheck(input.val(), parent);
Expand All @@ -418,8 +418,8 @@ $(document).ready(
mtr.after(searchHTML.clone());
var displayVal = val == "+" ? "" : val.toUpperCase() + " ";
var textbox = $(lastTopSelector + " .keyword");
textbox.removeAttr("disabled");
textbox.focus();
textbox.prop("disabled", false);
textbox.trigger('focus');
textbox.val(displayVal);
hic.doButtonActivationCheck("", $(lastTopSelector));
hic.doProxControlsActivationCheck("", $(lastTopSelector));
Expand Down Expand Up @@ -449,7 +449,7 @@ $(document).ready(
$(this).parents(topSelector).find(".str-operator").text("");
hic.clearProxValues(this);
hic.doButtonActivationCheck("", $(topSelector));
$(textbox).focus();
$(textbox).trigger('focus');

}

Expand Down Expand Up @@ -487,8 +487,8 @@ $(document).ready(
var searchbits = hic.trimRecoveredStringSearches(nowsearch);
hic.addReqdSearchBoxes(searchbits);
hic.removeSearchFromStack(stringbits);
$(topSelector + ":last .keyword").removeAttr("disabled");
$(topSelector + ":last .keyword").focus();
$(topSelector + ":last .keyword").prop("disabled", false);
$(topSelector + ":last .keyword").trigger('focus');
$(topSelector + ":last .keyword").putCursorAtEnd();

}
Expand Down Expand Up @@ -572,12 +572,12 @@ $(document).ready(
var buttonBar = $(this).parent().clone();
$(this).parent().parent().remove();
$(lastTopSelector).append(buttonBar);
$(lastTopSelector).find(".keyword").removeAttr("disabled");
$(lastTopSelector).find(".keyword").focus();
$(lastTopSelector).find(".keyword").prop("disabled", false);
$(lastTopSelector).find(".keyword").trigger('focus');
var prxcount = $(lastTopSelector + " input.prxcount");
if(prxcount.val().length > 0){

$(lastTopSelector + " .prx *").removeAttr("disabled");
$(lastTopSelector + " .prx *").prop("disabled", false);

}
hic.doButtonActivationCheck($(lastTopSelector).find(".keyword").val(), $(lastTopSelector));
Expand Down

0 comments on commit 8410e01

Please sign in to comment.