From 9e3936b151b707fa18e6cbae189507b1298a71e4 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 26 Jan 2025 14:32:14 -0500 Subject: [PATCH 1/2] Fix code style in itemFiler() --- view/templates/jot-header.tpl | 24 +++++++++++------------- view/theme/frio/templates/jot-header.tpl | 23 ++++++++++++----------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/view/templates/jot-header.tpl b/view/templates/jot-header.tpl index ca3867e9fc..5276bf5d5e 100644 --- a/view/templates/jot-header.tpl +++ b/view/templates/jot-header.tpl @@ -199,22 +199,21 @@ function enableOnUser(){ } function itemFiler(id) { + const bordercolor = $("input").css("border-color"); - var bordercolor = $("input").css("border-color"); - - $.get('filer/', function(data){ - $.colorbox({html:data}); - $("#id_term").keypress(function(){ - $(this).css("border-color",bordercolor); + $.get('filer/', function (data) { + $.colorbox({html: data}); + $("#id_term").keypress(function () { + $(this).css("border-color", bordercolor); }) - $("#select_term").change(function(){ - $("#id_term").css("border-color",bordercolor); + $("#select_term").change(function () { + $("#id_term").css("border-color", bordercolor); }) - $("#filer_save").click(function(e){ + $("#filer_save").click(function (e) { e.preventDefault(); - reply = $("#id_term").val(); - if(reply && reply.length) { + const reply = $("#id_term").val(); + if (reply && reply.length) { commentBusy = true; $('body').css('cursor', 'wait'); $.get('filer/' + id + '?term=' + reply, NavUpdate); @@ -224,12 +223,11 @@ function enableOnUser(){ force_update = true; $.colorbox.close(); } else { - $("#id_term").css("border-color","#FF0000"); + $("#id_term").css("border-color", "#FF0000"); } return false; }); }); - } function jotClearLocation() { diff --git a/view/theme/frio/templates/jot-header.tpl b/view/theme/frio/templates/jot-header.tpl index e882fdf0c1..d1fdc3dee0 100644 --- a/view/theme/frio/templates/jot-header.tpl +++ b/view/theme/frio/templates/jot-header.tpl @@ -296,21 +296,21 @@ } function itemFiler(id) { - var bordercolor = $("input").css("border-color"); + const bordercolor = $("input").css("border-color"); - $.get('filer/', function(data){ - $.colorbox({html:data}); - $("#id_term").keypress(function(){ - $(this).css("border-color",bordercolor); + $.get('filer/', function (data) { + $.colorbox({html: data}); + $("#id_term").keypress(function () { + $(this).css("border-color", bordercolor); }) - $("#select_term").change(function(){ - $("#id_term").css("border-color",bordercolor); + $("#select_term").change(function () { + $("#id_term").css("border-color", bordercolor); }) - $("#filer_save").click(function(e){ + $("#filer_save").click(function (e) { e.preventDefault(); - reply = $("#id_term").val(); - if(reply && reply.length) { + const reply = $("#id_term").val(); + if (reply && reply.length) { commentBusy = true; $('body').css('cursor', 'wait'); $.get('filer/' + id + '?term=' + reply, NavUpdate); @@ -321,8 +321,9 @@ $.colorbox.close(); formModified = true; // Mark the form as modified } else { - $("#id_term").css("border-color","#FF0000"); + $("#id_term").css("border-color", "#FF0000"); } + return false; }); }); From 1f8ea3073537aab4d95626a0c7d6d18048364198 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 26 Jan 2025 14:42:21 -0500 Subject: [PATCH 2/2] Fix itemFiler() callback - Remove page exit alert - Update filed post display on success - Reset cursor appearance always --- view/templates/jot-header.tpl | 19 +++++++++++++------ view/theme/frio/templates/jot-header.tpl | 19 ++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/view/templates/jot-header.tpl b/view/templates/jot-header.tpl index 5276bf5d5e..10d3ce450f 100644 --- a/view/templates/jot-header.tpl +++ b/view/templates/jot-header.tpl @@ -215,16 +215,23 @@ function enableOnUser(){ const reply = $("#id_term").val(); if (reply && reply.length) { commentBusy = true; + formModified = true; $('body').css('cursor', 'wait'); - $.get('filer/' + id + '?term=' + reply, NavUpdate); -// if(timer) clearTimeout(timer); -// timer = setTimeout(NavUpdate,3000); - liking = 1; - force_update = true; - $.colorbox.close(); + $.get('filer/' + id + '?term=' + reply) + .done(function () { + $.colorbox.close(); + resetFormModifiedFlag(); + }) + .always(function () { + liking = 1; + force_update = true; + update_item = id; + NavUpdate(); + }); } else { $("#id_term").css("border-color", "#FF0000"); } + return false; }); }); diff --git a/view/theme/frio/templates/jot-header.tpl b/view/theme/frio/templates/jot-header.tpl index d1fdc3dee0..9afb2ac559 100644 --- a/view/theme/frio/templates/jot-header.tpl +++ b/view/theme/frio/templates/jot-header.tpl @@ -312,14 +312,19 @@ const reply = $("#id_term").val(); if (reply && reply.length) { commentBusy = true; + formModified = true; $('body').css('cursor', 'wait'); - $.get('filer/' + id + '?term=' + reply, NavUpdate); -// if(timer) clearTimeout(timer); -// timer = setTimeout(NavUpdate,3000); - liking = 1; - force_update = true; - $.colorbox.close(); - formModified = true; // Mark the form as modified + $.get('filer/' + id + '?term=' + reply) + .done(function () { + $.colorbox.close(); + resetFormModifiedFlag(); + }) + .always(function () { + liking = 1; + force_update = true; + update_item = id; + NavUpdate(); + }); } else { $("#id_term").css("border-color", "#FF0000"); }