CRM-16354 style fixes
authorTyrell Cook <tyrell@aghstrategies.com>
Sun, 26 Apr 2015 20:45:32 +0000 (16:45 -0400)
committerTyrell Cook <tyrell@aghstrategies.com>
Sun, 26 Apr 2015 20:45:32 +0000 (16:45 -0400)
js/Common.js
js/wysiwyg/crm.ckeditor.js
js/wysiwyg/crm.textarea.js [new file with mode: 0644]

index a8595fee49a919a0800c9ac03e71130575321e2c..1f0b3a126218ace3fdf3b280c283cb96b2f66652 100644 (file)
@@ -839,7 +839,7 @@ CRM.strings = CRM.strings || {};
           CRM.wysiwyg.create(this);
         }
       })
-    })
+    });
     .on('dialogopen', function(e) {
       var $el = $(e.target);
       // Modal dialogs should disable scrollbars
index f7f86ad431a9b1bf521b45627aaf25e5dc544eb0..05a69d5097b490c0d192a303298a21ac857afcfa 100644 (file)
@@ -5,7 +5,7 @@
     return CKEDITOR.instances[name];
   }
 
-  CRM.wysiwyg['supportsFileUploads'] =  true;
+  CRM.wysiwyg.supportsFileUploads =  true;
   CRM.wysiwyg.create =  function(item) {
     //var browseUrl = CRM.config.userFrameworkResourceUrl + "packages/kcfinder/browse.php";
     var browseUrl = CRM.config.userFrameworkResourceURL + "packages/kcfinder/browse.php";
diff --git a/js/wysiwyg/crm.textarea.js b/js/wysiwyg/crm.textarea.js
new file mode 100644 (file)
index 0000000..2810253
--- /dev/null
@@ -0,0 +1,34 @@
+// https://civicrm.org/licensing
+(function($, _) {
+  function openWysiwyg(item) {
+    $(item).show();
+    $(item).next('.replace-plain').hide();
+    CRM.wysiwyg.create(item);
+    $(item).on( 'blur', function( e ) {
+      CRM.wysiwyg.updateElement(item);
+      CRM.wysiwyg.destroy(item);
+      $(item).hide().next('.replace-plain').show().html($(item).val());
+    });
+  }
+  CRM.wysiwyg = {};
+  CRM.wysiwyg.supportsFileUploads =  false;
+  CRM.wysiwyg.create = _.noop;
+  CRM.wysiwyg.destroy = _.noop;
+  CRM.wysiwyg.updateElement = _.noop;
+  CRM.wysiwyg.val = function(item) {
+    return $(item).val();
+  };
+  CRM.wysiwyg.insertText = _.noop;
+  CRM.wysiwyg.insertHTML = _.noop;
+  CRM.wysiwyg.createPlain = function(item) {
+    $(item)
+      .hide()
+      .after('<div class="replace-plain" tabindex="0" title="Click to edit"></div>');
+    $(item).next('.replace-plain').click(function(){
+      openWysiwyg(item);
+    });
+    $(item).next('.replace-plain').keypress(function(){
+      openWysiwyg(item);
+    });
+  };
+})(CRM.$, CRM._);