Skip to content

Commit

Permalink
refactor: update to jquery 3.7.1 (closes tjcsl#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarushtools committed Jul 3, 2024
1 parent 1d1ff53 commit 1d2735c
Show file tree
Hide file tree
Showing 80 changed files with 212 additions and 233 deletions.
2 changes: 1 addition & 1 deletion intranet/static/js/about.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global $ */
$(function() {
$(".logo").click(function() {
$(".logo").on("click", function() {
location.href = '/';
});

Expand Down
4 changes: 2 additions & 2 deletions intranet/static/js/announcement.form.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $(function() {
maxItems: 2
});

$("form#announcement_form").bind("submit", function (e) {
$("form#announcement_form").on("submit", function (e) {
if($("#id_notify_email_all").prop("checked")) {
if(!confirm("This will send an email to ALL users who can see this post. If you have not selected a group, this will email the entire school. Are you sure you want to do this?")) {
e.preventDefault();
Expand All @@ -32,7 +32,7 @@ $(function() {
}

var button = $("button#submit_announcement");
button.click(function(ev) { ev.preventDefault(); })
button.on("click", function(ev) { ev.preventDefault(); })
button.append(" <i class=\"fas fa-spinner fa-spin\" aria-hidden=\"true\"></i>");

if ($("input#id_title").val() === "") {
Expand Down
6 changes: 3 additions & 3 deletions intranet/static/js/bus-afternoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ $(function() {
});

if(isAdmin) {
$(".bus-announcement-save").click(function() {
$(".bus-announcement-save").on("click", function() {
bus.sendUpdate({
announcement: $(".bus-announcement").text()
});
Expand All @@ -709,7 +709,7 @@ $(function() {
$(".bus-announcement-save").text("Save").css("color", "");
}, 1500);
});
$(".bus-announcement-clear").click(function() {
$(".bus-announcement-clear").on("click", function() {
$(".bus-announcement").text("");
bus.sendUpdate({
announcement: "",
Expand All @@ -734,7 +734,7 @@ $(function() {
let socket = getSocket(base_url, location, document, window, 'afternoon');

if (enableBusDriver) {
$(window).unload(function () {
$(window).on("unload", function () {
alert('hello');
alert(`You drove ${window.appView.mapView.busDriverBus.elapsedTime} milliseconds!`);
Backbone.trigger('recordScore', e);
Expand Down
10 changes: 5 additions & 5 deletions intranet/static/js/bus-morning.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ $(function() {
let base_url = window.location.host;
let socket = getSocket(base_url, location, document, window, "morning");

$("#a-button").click(function() {sendMorningUpdate({"status":"a"}, socket); });
$("#o-button").click(function() {sendMorningUpdate({"status":"o"}, socket); });
$("#d-button").click(function() {sendMorningUpdate({"status":"d"}, socket); });
$("#a-button").on("click", function() {sendMorningUpdate({"status":"a"}, socket); });
$("#o-button").on("click", function() {sendMorningUpdate({"status":"o"}, socket); });
$("#d-button").on("click", function() {sendMorningUpdate({"status":"d"}, socket); });

$("select").selectize({
create: false,
sortField: "text"
});

if(isAdmin) {
$(".bus-announcement-save").click(function() {
$(".bus-announcement-save").on("click", function() {
sendMorningUpdate({
announcement: $(".bus-announcement").text()
}, socket);
Expand All @@ -23,7 +23,7 @@ $(function() {
$(".bus-announcement-save").text("Save").css("color", "");
}, 1500);
});
$(".bus-announcement-clear").click(function() {
$(".bus-announcement-clear").on("click", function() {
$(".bus-announcement").text("");
sendMorningUpdate({
announcement: "",
Expand Down
20 changes: 10 additions & 10 deletions intranet/static/js/common.header.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ $(function() {
}

var clickOutside = function(e) {
if ($(e.target).parents().andSelf().hasClass("dropdown-allow")) return;
if ($(e.target).parents().addBack().hasClass("dropdown-allow")) return;

if (!$(e.target).parents().andSelf().hasClass("dropdown-item-wrapper")) {
if (!$(e.target).parents().addBack().hasClass("dropdown-item-wrapper")) {
closeMenu($(".dropdown-open .dropdown-menu"), true);
$(".has-dropdown").removeClass("dropdown-open");
}
Expand All @@ -33,8 +33,8 @@ $(function() {
opacity: 1
}, time, "easeInQuart", function() {
if (bindEvents) {
$(document).bind("click tap", clickOutside);
$(".dropdown-menu").bind("click", clickInside);
$(document).on("click tap", clickOutside);
$(".dropdown-menu").on("click", clickInside);
}
});
}
Expand All @@ -47,13 +47,13 @@ $(function() {
menu.hide();

if (unbindEvents) {
$(".dropdown-menu").unbind("click", clickInside);
$(document).unbind("click tap", clickOutside);
$(".dropdown-menu").off("click", clickInside);
$(document).off("click tap", clickOutside);
}
});
}

$(".has-dropdown").click(function(event) {
$(".has-dropdown").on("click", function(event) {
var menu_clicked = $(this).children(".dropdown-menu");
var already_open = $(".dropdown-open .dropdown-menu")
var clicked_subgroups = menu_clicked.children(".has-dropdown-subgroup");
Expand All @@ -65,8 +65,8 @@ $(function() {
clicked_subgroups.children("a.subgroup-arrow-parent").children("i.subgroup-arrow").addClass("fa-caret-down");
clicked_subgroups.children("a.subgroup-arrow-parent").children("i.subgroup-arrow").removeClass("fa-caret-left");

$(document).unbind("click tap", clickOutside);
$(".dropdown-menu").unbind("click", clickInside);
$(document).off("click tap", clickOutside);
$(".dropdown-menu").off("click", clickInside);
$(".has-dropdown").removeClass("dropdown-open");
} else if (already_open.length === 0) {
// All menus closed, opening one of them
Expand All @@ -81,7 +81,7 @@ $(function() {
}
});

$(".has-dropdown-subgroup").click(function(event) {
$(".has-dropdown-subgroup").on("click", function(event) {
var subgroup = $(this).children(".dropdown-subgroup");
var arrow = $(this).children("a.subgroup-arrow-parent").children("i.subgroup-arrow");
subgroup.toggle();
Expand Down
12 changes: 6 additions & 6 deletions intranet/static/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $.ajaxSetup({
// UI Stuff
function initUIElementBehavior() {
// Call this function whenever relevant UI elements are dynamically added to the page
$("button, .button, input[type='button'], input[type='submit'], input[type='reset']").mouseup(function() {
$("button, .button, input[type='button'], input[type='submit'], input[type='reset']").on("mouseup", function() {
$(this).blur();
});
}
Expand All @@ -29,25 +29,25 @@ function showWaitScreen() {
$(function() {
initUIElementBehavior();

$(".nav a").click(function(event) {
$(".nav a").on("click", function(event) {
if (event.metaKey) return;
$(".nav .selected").removeClass("selected");
$(this).parent().addClass("selected");
});

$(".header h1").click(function() {
$(".header h1").on("click", function() {
if (event.metaKey) return;
$(".nav .selected").removeClass("selected");
$(".nav li").slice(0, 1).addClass("selected");
});

// On sortable tables, use the data-auto-sort parameter to
// automatically sort by that field.
$("table[data-sortable] thead th[data-auto-sort]").click();
$("table[data-sortable] thead th[data-auto-sort]").trigger("click");


let collapseWarning = $.cookie("collapseWarning") === "true";
$(".warning-title").click(function() {
$(".warning-title").on("click", function() {
$(".warning-content").slideToggle();
$(".warning-toggle-icon").toggleClass("fa-chevron-down fa-chevron-up");
$.cookie("collapseWarning", !collapseWarning, {path: "/", expires: 14})
Expand Down Expand Up @@ -152,7 +152,7 @@ try {
};
return udlr
})(window.creffettMode = function() {
$("body").addClass("fire").click(function() {
$("body").addClass("fire").on("click", function() {
$("iframe#udlr").remove();
$("body").removeClass('fire');
});
Expand Down
4 changes: 2 additions & 2 deletions intranet/static/js/common.nav.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global $ */
$(function() {
$.extend($.expr[":"], {
horizontallyscrollable(element) {
$.extend($.expr.pseudos, {
horizontallyscrollable: function(element) {
var e = $(element);
return (e.css("overflow") === "scroll" || e.css("overflowX") === "scroll" || e.css("overflow") === "auto" || e.css("overflowX") === "auto");
}
Expand Down
10 changes: 5 additions & 5 deletions intranet/static/js/dashboard/announcements.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $(document).ready(function() {
var content = $(this).find(".announcement-content");
if(content.height() > 200) {
$(this).addClass("partially-hidden");
content.click(function() {
content.on("click", function() {
announcementToggle.call($(this).closest(".announcement"));
});
}
Expand All @@ -35,7 +35,7 @@ $(document).ready(function() {
});
}
updatePartiallyHidden();
$(window).resize(function() {setTimeout(updatePartiallyHidden, 0);});
$(window).on("resize", function() {setTimeout(updatePartiallyHidden, 0);});

function announcementToggle() {
var announcement = $(this).closest(".announcement");
Expand Down Expand Up @@ -101,18 +101,18 @@ $(document).ready(function() {
}
};

$(".announcement[data-id] h3").click(function(e) {
$(".announcement[data-id] h3").on("click", function(e) {
if (e.target !== this) return;
var btn = $(".announcement-toggle", $(this));
announcementToggle.call(btn);
});

$(".announcement[data-id] h3 .announcement-toggle").click(function(e) {
$(".announcement[data-id] h3 .announcement-toggle").on("click", function(e) {
e.preventDefault();
announcementToggle.call($(this));
});

$(".announcement[data-id] h3 .dashboard-item-icon").click(function(e) {
$(".announcement[data-id] h3 .dashboard-item-icon").on("click", function(e) {
e.preventDefault();
var btn = $(".announcement-toggle", $(this).parent());
announcementToggle.call(btn);
Expand Down
4 changes: 2 additions & 2 deletions intranet/static/js/dashboard/common.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* global $ */
$(function() {
$('.widget.extra-widgets-show').click(function() {
$('.widget.extra-widgets-show').on("click", function() {
$('body').addClass('show-extra-widgets');
});

$(".new-feature-close").click(function(e) {
$(".new-feature-close").on("click", function(e) {
$(e.target).closest(".new-feature").hide("slow");
});

Expand Down
8 changes: 4 additions & 4 deletions intranet/static/js/dashboard/eighth-widget.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* global $ */
$(function() {
$(".eighth-widget .block-header").click(function() {
$(".eighth-widget .block-header").on("click", function() {
var link = $("a", $(this));
if (link.length > 0) location.href = link.attr("href");
});

$(".sponsor-widget .block-header").click(function() {
$(".sponsor-widget .block-header").on("click", function() {
var link = $("a", $(this));
if (link.length > 0) location.href = link.attr("href");
});
Expand All @@ -32,13 +32,13 @@ $(function() {
}

sponsor_schedule_bind = function() {
$(".sponsor-widget #eighth-sponsor-left").click(function() {
$(".sponsor-widget #eighth-sponsor-left").on("click", function() {
var date = $(".sponsor-widget").attr("data-prev-date");
sponsor_schedule_jump(date);
sponsor_schedule_pushstate(date);
});

$(".sponsor-widget #eighth-sponsor-right").click(function() {
$(".sponsor-widget #eighth-sponsor-right").on("click", function() {
var date = $(".sponsor-widget").attr("data-next-date");
sponsor_schedule_jump(date);
sponsor_schedule_pushstate(date);
Expand Down
6 changes: 3 additions & 3 deletions intranet/static/js/dashboard/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ $(function() {
}
}

$(".event[data-id] h3").click(function(e) {
$(".event[data-id] h3").on("click", function(e) {
if (e.target !== this) return;
var btn = $(".event-toggle", $(this));
eventToggle.call(btn);
});

$(".event[data-id] h3 .event-toggle").click(function(e) {
$(".event[data-id] h3 .event-toggle").on("click", function(e) {
e.preventDefault();
eventToggle.call($(this));
});

$(".event[data-id] h3 .dashboard-item-icon").click(function(e) {
$(".event[data-id] h3 .dashboard-item-icon").on("click", function(e) {
e.preventDefault();
var btn = $(".event-toggle", $(this).parent());
eventToggle.call(btn);
Expand Down
14 changes: 7 additions & 7 deletions intranet/static/js/eighth/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ $(function() {
} catch (e) {}
}

$selectAllBlocksCheckbox.click(updateBlockCheckboxes);
$blockCheckboxes.click(updateSelectAllCheckbox);
$selectAllBlocksCheckbox.on("click", updateBlockCheckboxes);
$blockCheckboxes.on("click", updateSelectAllCheckbox);
updateSelectAllCheckbox();

// Set up select blocks popover
$(".select-blocks-popover-toggle").click(function() {
$(".select-blocks-popover-toggle").on("click", function() {
var $popover = $(".select-blocks-popover"),
$toggle = $(".select-blocks-popover-toggle");

Expand All @@ -106,7 +106,7 @@ $(function() {
};
};

$(".select-blocks-popover a.block-type").click(function() {
$(".select-blocks-popover a.block-type").on("click", function() {
var blockType = $(this).text();

var blockTypeFilter = blockTypeRowFilter(blockType);
Expand Down Expand Up @@ -149,17 +149,17 @@ $(function() {
var select = $("#id_users_blacklisted").parent("td").find("select")[0].selectize.enable();
}

$("#id_restricted").click(updateRestrictedFormFields);
$("#id_restricted").on("click", updateRestrictedFormFields);

if ($("#id_restricted").length > 0) {
updateRestrictedFormFields();
}

$("#only-show-overbooked").click(function() {
$("#only-show-overbooked").on("click", function() {
$("tr.underbooked").toggle();
});

$("#hide-administrative").click(function() {
$("#hide-administrative").on("click", function() {
$("tr.administrative").toggle();
});
});
6 changes: 3 additions & 3 deletions intranet/static/js/eighth/attendance.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ $(function() {
$membersCheckboxes.prop("checked", $(this).prop("checked"));
}

$selectAllMembersCheckbox.click(updateBlockCheckboxes);
$membersCheckboxes.click(updateSelectAllCheckbox);
$selectAllMembersCheckbox.on("click", updateBlockCheckboxes);
$membersCheckboxes.on("click", updateSelectAllCheckbox);
updateSelectAllCheckbox();

// Set up accept pass links
$(".pass-form-submit-link").click(function() {
$(".pass-form-submit-link").on("click", function() {
var form = document.forms[$(this).data("form")];
form.status.value = $(this).data("status");

Expand Down
6 changes: 3 additions & 3 deletions intranet/static/js/eighth/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ $(function() {
var $inp = $memb.find("input[name='search']");
var $clear = $memb.find("a#clear");
var $searchStu = $memb.find("#search_students");
$searchStu.click(function() {
$searchStu.on("click", function() {
var noparam = window.location.href.split("?")[0];
window.location = noparam + "?q=" + encodeURIComponent($inp.val());
});
$inp.on("keydown", function(event) {
if(event.which === 13) {
$searchStu.click();
$searchStu.trigger("click");
}
});

// Error prone
var dec = window.location.href.split("?q=")[1];
if(dec) { $inp.val(decodeURIComponent(dec)); }
$clear.click(function() {
$clear.on("click", function() {
window.location = window.location.href.split("?")[0];
});
});
Loading

0 comments on commit 1d2735c

Please sign in to comment.