Skip to content

Commit

Permalink
Fix keyboard arrow navigation on study selection page. (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorfs authored Sep 8, 2021
1 parent 1df5909 commit 43d244f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
function isScrolledIntoView(elem) {
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
const docViewTop = $(window).scrollTop();
const docViewBottom = docViewTop + $(window).height();

var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
const elemTop = $(elem).offset().top;
const elemBottom = elemTop + $(elem).height();

return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}

$(function () {


$("body").on("click", ".js-start-upload", function () {
$(this).siblings("input[type='file']").click();
});
Expand Down Expand Up @@ -177,8 +176,6 @@ $(function () {
});

function move(step) {
var row = $(".source-articles tbody tr.active");

var active = $(".source-articles tbody tr.active").index();
var old_active = active;
var size = $(".source-articles tbody tr").length;
Expand All @@ -190,6 +187,8 @@ $(function () {
$(".source-articles tbody tr").removeClass("active");
$(next).addClass("active");

var row = $(".source-articles tbody tr.active");

if (!isScrolledIntoView(row)) {
if (active > old_active)
$('html, body').animate({scrollTop: $(row).offset().top}, 2000);
Expand Down Expand Up @@ -262,7 +261,7 @@ $(function () {
});

function filter_articles(status) {
if (status == "ALL") {
if (status === "ALL") {
$(".source-articles table tbody tr").show();
}
else {
Expand Down Expand Up @@ -378,7 +377,7 @@ $(function () {
$(".source-tab-content").on("click", "table tbody tr td input[type=checkbox]", function () {
var total = $(".source-articles table tbody tr td input[type='checkbox']:visible").length;
var checked = $(".source-articles table tbody tr td input[type='checkbox']:checked").length;
if (checked == total) {
if (checked === total) {
$("#ck-all-articles").prop("checked", true);
}
else {
Expand Down Expand Up @@ -447,7 +446,7 @@ $(function () {
var duplicates = $("#modal-duplicates .modal-body tr[duplicate=" + duplicate + "]");
var duplicates_resolved = $("#modal-duplicates .modal-body tr[duplicate=" + duplicate + "][resolved=true]");

if (duplicates.length - duplicates_resolved.length == 1) {
if (duplicates.length - duplicates_resolved.length === 1) {
var btn_resolved = $("#modal-duplicates .modal-body tr[duplicate=" + duplicate + "][resolved=false] button");
$(btn_resolved).text("Resolved");
$(btn_resolved).prop("disabled", true);
Expand Down Expand Up @@ -481,7 +480,7 @@ $(function () {
$(btn).text("Resolving...");
},
success: function (data) {
if (data != "") {
if (data !== "") {
var btn_modal = $("#modal-duplicates table tbody tr td button");
$(btn_modal).prop("disabled", true);
$(btn_modal).text("Resolved");
Expand All @@ -490,7 +489,7 @@ $(function () {
var article_row = $(".source-tab-content .source-articles tr[oid=" + ids[i] + "]");
$(article_row).attr("article-status", "D");
$("span", article_row).replaceWith("<span class=\"label label-warning\">Duplicated</span>");
};
}
}
},
complete: function () {
Expand All @@ -503,7 +502,7 @@ $(function () {
// On page load

if ($("ul#source-tab li").length > 0) {
if($("ul#source-tab li.active").length == 0) {
if($("ul#source-tab li.active").length === 0) {
$("ul#source-tab li:eq(0)").addClass("active");
}
$("#source-tab li.active a").click();
Expand Down
1 change: 1 addition & 0 deletions parsifal/newsfragments/71.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix keyboard arrow navigation on study selection page.
10 changes: 5 additions & 5 deletions parsifal/static/js/parsifal.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

$.fn.ajaxEnable = function (callback) {
callback = callback || function () {};

var btn = $(this);
$(this).prop("disabled", false);
$("span[class^='btn-ajax-']", this).hide();
Expand All @@ -81,7 +81,7 @@

$.fn.ajaxEnableError = function (callback) {
callback = callback || function () {};

var btn = $(this);
$(this).prop("disabled", false);
$("span[class^='btn-ajax-']", this).hide();
Expand Down Expand Up @@ -137,7 +137,7 @@
});

};

},

uuid: function () {
Expand Down Expand Up @@ -197,7 +197,7 @@ var UP_ARROW_KEY = 38;
var DOWN_ARROW_KEY = 40;
var ENTER_KEY = 13;
var ESCAPE_KEY = 27;
var LOADING = "<table class='loading'><tr><td><img src='/static/img/loading.gif'></td></tr></table>";
var LOADING = "<table class='loading'><tr><td><img src='/static/img/loading.gif' alt='Loading...'></td></tr></table>";

// Loading functions

Expand All @@ -208,4 +208,4 @@ $.fn.loading = function () {

$.fn.stopLoading = function () {
$(this).removeClass("loading-state");
};
};

0 comments on commit 43d244f

Please sign in to comment.