[Rt-commit] rt branch, 4.4/all-recipients-call-ajax-once, repushed
? sunnavy
sunnavy at bestpractical.com
Tue Mar 23 13:46:15 EDT 2021
The branch 4.4/all-recipients-call-ajax-once was deleted and repushed:
was 365d374f781aa71d096a2f2ca6f7c53b0e944ce2
now 9b34a0f8e1f476606d43dce8775ca40fd40fe268
1: 365d374f78 ! 1: 06224a80eb Trigger UpdateCc/UpdateBcc input change only once when clicking "All recipients"
@@ -2,8 +2,8 @@
Trigger UpdateCc/UpdateBcc input change only once when clicking "All recipients"
- Clicking "All recipients" will check/uncheck all the suggested Cc/Bcc
- address checkboxes, and each address checkbox change will trigger the
+ Clicking "All recipients" checks/unchecks all the suggested Cc/Bcc
+ address checkboxes, and each address checkbox change would trigger the
UpdateCc/UpdateBcc input change accordingly.
It's not just unnecessary to trigger UpdateCc/UpdateBcc input change
@@ -62,26 +62,29 @@
+function checkboxesToInput(target,checkboxes) {
+ var tar = jQuery('#' + escapeCssSelector(target));
+
++ var emails = jQuery.grep(tar.val().split(/,\s*/), function(email) {
++ return email.match(/\S/) ? true : false;
++ });
++
+ jQuery(checkboxes).each(function(index, checkbox) {
+ var val = jQuery(checkbox).attr('data-address');
+ if(jQuery(checkbox).prop('checked')){
-+ if (tar.val()==''){
-+ tar.val(val);
-+ }
-+ else{
-+ tar.val(val+', '+ tar.val());
++ if ( emails.indexOf(val) == -1 ) {
++ emails.unshift(val);
+ }
+ }
+ else{
-+ tar.val(tar.val().replace(val+', ',''));
-+ tar.val(tar.val().replace(val,''));
++ emails = jQuery.grep(emails, function(email) {
++ return email != val;
++ });
+ }
+ });
+
+ jQuery('#UpdateIgnoreAddressCheckboxes').val(true);
-+ tar.change();
++ tar.val(emails.join(', ')).change();
+}
+
// ahah for back compatibility as plugins may still use it
function ahah( url, id ) {
jQuery('#'+id).load(url);
+
-: ------- > 2: 9b34a0f8e1 Sync one-time checkboxes to text inputs in a consistent way
More information about the rt-commit
mailing list