# HG changeset patch # User Thierry Florac # Date 1581589330 -3600 # Node ID 7d7ccf92d6af6403a0ced1986183e51b1ef60981 # Parent 1a0218d4faac7755f3376348dff9bce4f4ddbdd6 Added support for custom form changed callback diff -r 1a0218d4faac -r 7d7ccf92d6af src/pyams_skin/resources/js/myams-core.js --- a/src/pyams_skin/resources/js/myams-core.js Fri Nov 08 10:52:48 2019 +0100 +++ b/src/pyams_skin/resources/js/myams-core.js Thu Feb 13 11:22:10 2020 +0100 @@ -7,7 +7,7 @@ * * Custom administration and application skin tools * Released under Zope Public License ZPL 1.1 - * ©2014-2016 Thierry Florac + * ©2014-2020 Thierry Florac */ "use strict"; @@ -227,6 +227,7 @@ enableMobile: false, enableFastclick: false, warnOnFormChange: false, + formChangedCallback: null, ismobile: (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())) }; } diff -r 1a0218d4faac -r 7d7ccf92d6af src/pyams_skin/resources/js/myams-form.js --- a/src/pyams_skin/resources/js/myams-form.js Fri Nov 08 10:52:48 2019 +0100 +++ b/src/pyams_skin/resources/js/myams-form.js Thu Feb 13 11:22:10 2020 +0100 @@ -31,7 +31,9 @@ forms = $('FORM[data-ams-warn-on-change="true"]', element); } forms.each(function() { - var form = $(this); + var form = $(this), + formChangedCallback = form.data('ams-form-changed-callback') || + ams.formChangedCallback; $('INPUT[type="text"], ' + 'INPUT[type="checkbox"], ' + 'INPUT[type="radio"], ' + @@ -42,7 +44,8 @@ if (source.data('ams-ignore-change') !== true) { var event = source.data('ams-changed-event') || 'change'; source.on(event, function () { - ams.form.setChanged($(this).parents('FORM')); + ams.form.setChanged(form); + ams.executeFunctionByName(formChangedCallback, form, source); }); } }); diff -r 1a0218d4faac -r 7d7ccf92d6af src/pyams_skin/resources/js/myams-require.js --- a/src/pyams_skin/resources/js/myams-require.js Fri Nov 08 10:52:48 2019 +0100 +++ b/src/pyams_skin/resources/js/myams-require.js Thu Feb 13 11:22:10 2020 +0100 @@ -7,7 +7,7 @@ * * Custom administration and application skin tools * Released under Zope Public License ZPL 1.1 - * ©2014-2016 Thierry Florac + * ©2014-2020 Thierry Florac */ "use strict"; @@ -227,6 +227,7 @@ enableMobile: false, enableFastclick: false, warnOnFormChange: false, + formChangedCallback: null, ismobile: (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())) }; } diff -r 1a0218d4faac -r 7d7ccf92d6af src/pyams_skin/resources/js/myams.js --- a/src/pyams_skin/resources/js/myams.js Fri Nov 08 10:52:48 2019 +0100 +++ b/src/pyams_skin/resources/js/myams.js Thu Feb 13 11:22:10 2020 +0100 @@ -7,7 +7,7 @@ * * Custom administration and application skin tools * Released under Zope Public License ZPL 1.1 - * ©2014-2016 Thierry Florac + * ©2014-2020 Thierry Florac */ "use strict"; @@ -227,6 +227,7 @@ enableMobile: false, enableFastclick: false, warnOnFormChange: false, + formChangedCallback: null, ismobile: (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())) }; } @@ -1797,7 +1798,9 @@ forms = $('FORM[data-ams-warn-on-change="true"]', element); } forms.each(function() { - var form = $(this); + var form = $(this), + formChangedCallback = form.data('ams-form-changed-callback') || + ams.formChangedCallback; $('INPUT[type="text"], ' + 'INPUT[type="checkbox"], ' + 'INPUT[type="radio"], ' + @@ -1808,7 +1811,8 @@ if (source.data('ams-ignore-change') !== true) { var event = source.data('ams-changed-event') || 'change'; source.on(event, function () { - ams.form.setChanged($(this).parents('FORM')); + ams.form.setChanged(form); + ams.executeFunctionByName(formChangedCallback, form, source); }); } });