Fix compatibility with plugins using old jquery

This commit is contained in:
Laurent Destailleur 2019-07-23 13:31:00 +02:00
parent 8aaa716e33
commit 239b7d56b4

View File

@ -1862,34 +1862,38 @@ function top_menu_user(User $user, Translate $langs)
</div> </div>
</div> </div>
</div> </div>';
<!-- Code to show/hide the user drop-down -->
<script> if (! defined('JS_JQUERY_DISABLE_DROPDOWN')) // This may be set by some pages that use different jquery version to avoid errors
$( document ).ready(function() { {
$(document).on("click", function(event) { $btnUser .= '
if (!$(event.target).closest("#topmenu-login-dropdown").length) { <!-- Code to show/hide the user drop-down -->
// Hide the menus. <script>
$("#topmenu-login-dropdown").removeClass("open"); $( document ).ready(function() {
$("#dropdown-icon-down").show(); // use show/hide instead toggle for avoid conflict $(document).on("click", function(event) {
$("#dropdown-icon-up").hide(); // use show/hide instead toggle for avoid conflict if (!$(event.target).closest("#topmenu-login-dropdown").length) {
} // Hide the menus.
$("#topmenu-login-dropdown").removeClass("open");
$("#dropdown-icon-down").show(); // use show/hide instead toggle for avoid conflict
$("#dropdown-icon-up").hide(); // use show/hide instead toggle for avoid conflict
}
});
$("#topmenu-login-dropdown .dropdown-toggle").on("click", function(event) {
event.preventDefault();
$("#topmenu-login-dropdown").toggleClass("open");
$("#dropdown-icon-down").toggle();
$("#dropdown-icon-up").toggle();
});
$("#topmenuloginmoreinfo-btn").on("click", function() {
$("#topmenuloginmoreinfo").slideToggle();
});
}); });
</script>
$("#topmenu-login-dropdown .dropdown-toggle").on("click", function(event) { ';
event.preventDefault(); }
$("#topmenu-login-dropdown").toggleClass("open");
$("#dropdown-icon-down").toggle();
$("#dropdown-icon-up").toggle();
});
$("#topmenuloginmoreinfo-btn").on("click", function() {
$("#topmenuloginmoreinfo").slideToggle();
});
});
</script>
';
return $btnUser; return $btnUser;
} }