From 467faff29298b02ffa6d800fbf82e56cb61348f3 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 21 Jun 2024 18:45:44 +0800 Subject: [PATCH] fix --- web_src/js/features/common-form.js | 2 ++ web_src/js/vendor/jquery.are-you-sure.js | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/web_src/js/features/common-form.js b/web_src/js/features/common-form.js index 02c54056490a5..96ba06ff80ad2 100644 --- a/web_src/js/features/common-form.js +++ b/web_src/js/features/common-form.js @@ -1,7 +1,9 @@ import $ from 'jquery'; +import {initAreYouSure} from '../vendor/jquery.are-you-sure.js'; import {handleGlobalEnterQuickSubmit} from './comp/QuickSubmit.js'; export function initGlobalFormDirtyLeaveConfirm() { + initAreYouSure(window.jQuery); // Warn users that try to leave a page after entering data into a form. // Except on sign-in pages, and for forms marked as 'ignore-dirty'. if (!$('.user.signin').length) { diff --git a/web_src/js/vendor/jquery.are-you-sure.js b/web_src/js/vendor/jquery.are-you-sure.js index e06da39fc9319..e7bb203c5a92f 100644 --- a/web_src/js/vendor/jquery.are-you-sure.js +++ b/web_src/js/vendor/jquery.are-you-sure.js @@ -1,5 +1,6 @@ -// Fork of the upstream module. The only changes are the addition of `const` on -// lines 93 and 161 to make it strict mode compatible. +// Fork of the upstream module. The only changes are: +// * use export to make it work with ES6 modules. +// * the addition of `const` to make it strict mode compatible. /*! * jQuery Plugin: Are-You-Sure (Dirty Form Detection) @@ -13,7 +14,7 @@ * Version: 1.9.0 * Date: 13th August 2014 */ -(function($) { +export function initAreYouSure($) { $.fn.areYouSure = function(options) { @@ -192,4 +193,4 @@ initForm($form); }); }; -})(jQuery); +}