NEW Can select several fields to personalize list before submit.

This commit is contained in:
Laurent Destailleur
2020-02-23 21:38:24 +01:00
parent 0d474b2ec9
commit 76e33058a8
5 changed files with 68 additions and 32 deletions

View File

@@ -81,13 +81,31 @@ print "});\n";
// Wrapper to manage dropdown
if (! defined('JS_JQUERY_DISABLE_DROPDOWN'))
{
print "\n/* JS CODE TO ENABLE dropdown */\n";
print "\n/* JS CODE TO ENABLE dropdown (hamburger, linkto, ...) */\n";
print '
jQuery(document).ready(function () {
$(".dropdown dt a").on(\'click\', function () {
console.log("We click on dropdown");
//console.log($(this).parent().parent().find(\'dd ul\'));
$(this).parent().parent().find(\'dd ul\').slideToggle(\'fast\');
jQuery(document).ready(function () {
var lastopendropdown = null;
// Click onto the link "link to" or "hamburger", toggle dropdown
$(".dropdown dt a").on(\'click\', function () {
console.log("toggle dropdown dt a");
//$(this).parent().parent().find(\'dd ul\').slideToggle(\'fast\');
$(this).parent().parent().find(\'dd ul\').toggleClass("open");
if ($(this).parent().parent().find(\'dd ul\').hasClass("open")) {
lastopendropdown = $(this).parent().parent().find(\'dd ul\');
//console.log(lastopendropdown);
} else {
// We closed the dropdown for hamburger selectfields
if ($("input:hidden[name=formfilteraction]").val() == "listafterchangingselectedfields") {
console.log("resubmit the form saved into lastopendropdown after clicking on hamburger");
//$(".dropdown dt a").parents(\'form:first\').submit();
//$(".dropdown dt a").closest("form").submit();
lastopendropdown.closest("form").submit();
}
}
// Note: Did not find a way to get exact height (value is update at exit) so i calculate a generic from nb of lines
heigthofcontent = 21 * $(this).parent().parent().find(\'dd div ul li\').length;
if (heigthofcontent > 300) heigthofcontent = 300; // limited by max-height on css .dropdown dd ul
@@ -101,19 +119,32 @@ if (! defined('JS_JQUERY_DISABLE_DROPDOWN'))
console.log("We reposition top by "+pix);
$(this).parent().parent().find(\'dd\').css("top", pix);
}
// $(".dropdown dd ul").slideToggle(\'fast\');
});
$(".dropdowncloseonclick").on(\'click\', function () {
console.log("Link has class dropdowncloseonclick, so we close/hide the popup ul");
$(this).parent().parent().hide();
});
$(document).bind(\'click\', function (e) {
//console.log("We click outside of dropdown, so we close it.");
var $clicked = $(e.target);
if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide();
// Click on a link into the popup "link to" or other dropdown that ask to close drop down on element click, so close dropdown
$(".dropdowncloseonclick").on(\'click\', function () {
console.log("Link has class dropdowncloseonclick, so we close/hide the popup ul");
//$(this).parent().parent().hide(); // $(this).parent().parent() is ul
$(this).parent().parent().removeClass("open"); // $(this).parent().parent() is ul
});
});
// Click outside of any dropdown
$(document).bind(\'click\', function (e) {
var $clicked = $(e.target); // This is element we click on
if (!$clicked.parents().hasClass("dropdown")) {
console.log("close dropdown dd ul - we click outside");
//$(".dropdown dd ul").hide();
$(".dropdown dd ul").removeClass("open");
if ($("input:hidden[name=formfilteraction]").val() == "listafterchangingselectedfields") {
console.log("resubmit form saved into lastopendropdown after clicking outside of dropdown and having change selectlist from selectlist field of hamburger dropdown");
//$(".dropdown dt a").parents(\'form:first\').submit();
//$(".dropdown dt a").closest("form").submit();
lastopendropdown.closest("form").submit();
}
}
});
});
';
}