Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Bug page_y url #32119

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions htdocs/core/js/lib_foot.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,38 +242,34 @@
// Code to manage reposition
print "\n/* JS CODE TO ENABLE reposition management (does not work if a redirect is done after action of submission) */\n";
print '
jQuery(document).ready(function() {
/* If page_y set, we set scrollbar with it */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing all the comments that help to understand the code ?

page_y=getParameterByName(\'page_y\', 0); /* search in GET parameter */
if (page_y == 0) page_y = jQuery("#page_y").text(); /* search in POST parameter that is filed at bottom of page */
if (page_y > 0)
{
console.log("page_y found is "+page_y);
Copy link
Member

@eldy eldy Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question for console.logthat are necessary to debug.
A bug fix must always have the minimal footprint.

$(\'html, body\').scrollTop(page_y);
}

/* Set handler to add page_y param on output (click on href links or submit button) */
jQuery(".reposition").click(function() {
var page_y = $(document).scrollTop();

if (page_y > 0)
{
if (this.href)
{
console.log("We click on tag with .reposition class. this.ref was "+this.href);
var hrefarray = this.href.split("#", 2);
hrefarray[0]=hrefarray[0].replace(/&page_y=(\d+)/, \'\'); /* remove page_y param if already present */
this.href=hrefarray[0]+\'&page_y=\'+page_y;
console.log("We click on tag with .reposition class. this.ref is now "+this.href);
}
else
{
console.log("We click on tag with .reposition class but element is not an <a> html tag, so we try to update input form field with name=page_y with value "+page_y);
jQuery("input[type=hidden][name=page_y]").val(page_y);
}
}
});
});'."\n";
jQuery(document).ready(function() {
/* If page_y set, we set scrollbar with it */
page_y = getParameterByName("page_y", 0); /* search in GET parameter */
if (page_y == 0) page_y = jQuery("#page_y").text(); /* search in POST parameter that is filed at bottom of page */
if (page_y > 0) {
console.log("page_y found is "+page_y);
jQuery("html, body").scrollTop(page_y);
}

/* Set handler to add page_y param on output (click on href links or submit button) */
jQuery(".reposition").click(function(event) {
var page_y = jQuery(document).scrollTop();
if (page_y > 0) {
if (this.href) {
console.log("We click on tag with .reposition class. this.ref was "+this.href);
var url = new URL(this.href, window.location.origin);
url.searchParams.delete("page_y"); /* remove page_y param if already present */
url.searchParams.set("page_y", page_y);
this.href = url.toString();
console.log("We click on tag with .reposition class. this.ref is now "+this.href);
} else {
console.log("We click on tag with .reposition class but element is not an <a> html tag, so we try to update input form field with name=page_y with value "+page_y);
jQuery("input[type=hidden][name=page_y]").val(page_y);
}
}
});
});
' . "\n";

// Code to manage Copy To Clipboard click
print "\n/* JS CODE TO ENABLE ClipBoard copy paste */\n";
Expand Down
Loading