From f582fc8ff67ae5018432b2258b10de1301155619 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 10 Jun 2014 14:02:42 +0100 Subject: [PATCH] CRM-14353 - Comments and code cleanup --- js/Common.js | 17 +++++++++-------- js/crm.ajax.js | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/js/Common.js b/js/Common.js index 7918a9596d..454621b01e 100644 --- a/js/Common.js +++ b/js/Common.js @@ -510,16 +510,17 @@ CRM.validate = CRM.validate || { } }) .on('submit', function(e) { - // CRM-14353 - disable changes warn when submitting the form + // CRM-14353 - disable changes warn when submitting a form $('[data-warn-changes]').removeAttr('data-warn-changes'); }) - ; - - window.onbeforeunload = function() { - if (CRM.utils.initialValueChanged($('form[data-warn-changes=true]'))) { - return ts('You have unsaved changes.'); - } - }; + ; + + // CRM-14353 - Warn of unsaved changes for forms which have opted in + window.onbeforeunload = function() { + if (CRM.utils.initialValueChanged($('form[data-warn-changes=true]'))) { + return ts('You have unsaved changes.'); + } + }; /** * Function to make multiselect boxes behave as fields in small screens diff --git a/js/crm.ajax.js b/js/crm.ajax.js index e2752785ca..e018472b6b 100644 --- a/js/crm.ajax.js +++ b/js/crm.ajax.js @@ -340,6 +340,7 @@ var widget = CRM.loadPage(url, settings).off('.crmForm'); + // CRM-14353 - Warn of unsaved changes for all forms except those which have opted out function cancelAction() { var dirty = CRM.utils.initialValueChanged($('form:not([data-warn-changes=false])', widget)); widget @@ -356,7 +357,7 @@ } } if (widget.data('uiDialog')) { - // This is a bit harsh but we are removing jQuery UI's event handler from the close button and adding our own + // CRM-14353 - This is a bit harsh but we are removing jQuery UI's event handler from the close button and adding our own widget.parent().find('.ui-dialog-titlebar-close').first().off().click(cancelAction); } -- 2.25.1