Fix crmEditable conversion of plain text to html and vice-versa
authorColeman Watts <coleman@civicrm.org>
Sat, 7 Feb 2015 22:49:39 +0000 (17:49 -0500)
committerColeman Watts <coleman@civicrm.org>
Sat, 7 Feb 2015 22:49:39 +0000 (17:49 -0500)
js/jquery/jquery.crmeditable.js

index 459f27431721ab605e521259d910f873f9eef8ee..79fe3232b6b5e551ea6cd8b3915115b84843ea0c 100644 (file)
@@ -1,5 +1,5 @@
 // https://civicrm.org/licensing
-(function($) {
+(function($, _) {
   // TODO: We'll need a way to clear this cache if options are edited.
   // Maybe it should be stored in the CRM object so other parts of the app can use it.
   // Note that if we do move it, we should also change the format of option lists to our standard sequential arrays
@@ -68,7 +68,7 @@
             if ($i.data('refresh')) {
               CRM.refreshParent($i);
             } else {
-              value = value === '' ? settings.placeholder : value;
+              value = value === '' ? settings.placeholder : _.escape(value);
               $i.html(value);
             }
           }
             });
           }
           return formatOptions(optionsCache[hash]);
-
         }
-        return value.replace(/<(?:.|\n)*?>/gm, '');
+        // Unwrap contents then replace html special characters with plain text
+        return _.unescape(value.replace(/<(?:.|\n)*?>/gm, ''));
       }
 
       function formatOptions(options) {
     $('.crm-editable', e.target).crmEditable();
   });
 
-})(jQuery);
+})(jQuery, CRM._);