CRM-16354 - Replace-plain fix
authorColeman Watts <coleman@civicrm.org>
Wed, 29 Apr 2015 05:10:23 +0000 (23:10 -0600)
committerColeman Watts <coleman@civicrm.org>
Wed, 29 Apr 2015 05:10:23 +0000 (23:10 -0600)
js/wysiwyg/crm.wysiwyg.js

index 2ca137829a3820fec0867eea484ecf0533474f93..9be69a88f7a5707d8237918582af9d4760fb61ec 100644 (file)
       $(item).triggerHandler('change');
       CRM.wysiwyg.focus(item);
     },
+    // Create a "collapsed" textarea that expands into a wysiwyg when clicked
     createCollapsed: function(item) {
       $(item)
         .hide()
-        .after('<div class="replace-plain" tabindex="0"></div>')
         .on('blur', function () {
           CRM.wysiwyg.destroy(item);
           $(item).hide().next('.replace-plain').show().html($(item).val());
+        })
+        .after('<div class="replace-plain" tabindex="0"></div>');
+      $(item).next('.replace-plain')
+        .attr('title', ts('Click to edit'))
+        .html($(item).val())
+        .on('click keypress', function (e) {
+          // Stop browser from opening clicked links
+          e.preventDefault();
+          $(item).show().next('.replace-plain').hide();
+          CRM.wysiwyg.create(item);
         });
-      $(item).next('.replace-plain').attr('title', ts('Click to edit')).on('click keypress', function () {
-        $(item).show().next('.replace-plain').hide();
-        CRM.wysiwyg.create(item);
-      });
     }
   };
 })(CRM.$, CRM._);