You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/09/18 02:53:00 UTC

[05/25] allura git commit: [#7955] Integration with SimpleMDE preview customization.

[#7955] Integration with SimpleMDE preview customization.

Remove preview handling of editor elements since we don't have a way to run
toggleClass('preview-active') any more.  Its hard to maintain that custom CSS
too - already scrolling wasn't right in preview mode.


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/dddf3f99
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/dddf3f99
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/dddf3f99

Branch: refs/heads/db/7957
Commit: dddf3f99ddf666e58d9c1de75241dd892524c130
Parents: 94885fd
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Sep 2 20:06:48 2015 +0000
Committer: Heith Seewald <hs...@hsmb.local>
Committed: Thu Sep 17 15:22:37 2015 -0400

----------------------------------------------------------------------
 .../lib/widgets/resources/css/markitup_sf.css   | 21 --------
 .../lib/widgets/resources/js/sf_markitup.js     | 55 ++------------------
 2 files changed, 5 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/dddf3f99/Allura/allura/lib/widgets/resources/css/markitup_sf.css
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/css/markitup_sf.css b/Allura/allura/lib/widgets/resources/css/markitup_sf.css
index 5682ffd..9ee994d 100644
--- a/Allura/allura/lib/widgets/resources/css/markitup_sf.css
+++ b/Allura/allura/lib/widgets/resources/css/markitup_sf.css
@@ -50,27 +50,6 @@
 .markdown_edit .editor-preview pre {
   font-family: monospace;
 }
-.markdown_edit .editor-preview-active {
-  background-color: transparent;
-  position: relative;
-  padding: 0;
-}
-.markdown_edit.preview-active {
-  background-color: transparent;
-}
-.markdown_edit.preview-active .CodeMirror:not(.CodeMirror-fullscreen),
-.markdown_edit.preview-active .editor-toolbar:not(.fullscreen) {
-  background-color: transparent;
-  border: 0;
-}
-.markdown_edit.preview-active .CodeMirror-scroll,
-.markdown_edit.preview-active .editor-statusbar,
-span.arw.preview-active {
-  display: none;
-}
-.markdown_edit.preview-active .editor-toolbar.disabled-for-preview a {
-  background-color: transparent;
-}
 
 .CodeMirror .CodeMirror-code .cm-comment {
   font-family: monospace;

http://git-wip-us.apache.org/repos/asf/allura/blob/dddf3f99/Allura/allura/lib/widgets/resources/js/sf_markitup.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/sf_markitup.js b/Allura/allura/lib/widgets/resources/js/sf_markitup.js
index 46b4046..424bbad 100644
--- a/Allura/allura/lib/widgets/resources/js/sf_markitup.js
+++ b/Allura/allura/lib/widgets/resources/js/sf_markitup.js
@@ -39,12 +39,7 @@ $(window).load(function() {
               },
               "horizontal-rule", "|",
               "link", "image", "|",
-              {
-                  name: 'preview',
-                  action: show_preview,
-                  className: 'fa fa-eye',
-                  title: 'Preview'
-              },
+              "preview",
               //"side-by-side",
               "fullscreen",
               tool = {
@@ -61,7 +56,8 @@ $(window).load(function() {
               spellChecker: false, // https://forge-allura.apache.org/p/allura/tickets/7954/
               indentWithTabs: false,
               tabSize: 4,
-              toolbar: toolbar
+              toolbar: toolbar,
+              previewRender: previewRender,
             });
             editor.render();
 
@@ -94,49 +90,7 @@ $(window).load(function() {
               $help_area.lightbox_me();
             }
 
-            function show_preview(editor) {
-              /*
-               * This is pretty much the same as original SimpleMDE.togglePreview,
-               * but rendered text is fetched from the server (see the comment bellow)
-               * https://github.com/NextStepWebs/simplemde-markdown-editor/blob/1.2.1/source%20files/markdownify.js#L218-L249
-               */
-              var cm = editor.codemirror;
-              var wrapper = cm.getWrapperElement();
-              var toolbar_div = wrapper.previousSibling;
-              var toolbar = editor.toolbarElements.preview;
-              var parse = editor.constructor.markdown;
-              var preview = wrapper.lastChild;
-              if(!/editor-preview/.test(preview.className)) {
-                preview = document.createElement('div');
-                preview.className = 'editor-preview';
-                wrapper.appendChild(preview);
-              }
-              if(/editor-preview-active/.test(preview.className)) {
-                preview.className = preview.className.replace(
-                  /\s*editor-preview-active\s*/g, ''
-                );
-                toolbar.className = toolbar.className.replace(/\s*active\s*/g, '');
-                toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview\s*/g, '');
-              } else {
-                /* When the preview button is clicked for the first time,
-                 * give some time for the transition from editor.css to fire and the view to slide from right to left,
-                 * instead of just appearing.
-                 */
-                setTimeout(function() {
-                  preview.className += ' editor-preview-active';
-                }, 1);
-                toolbar.className += ' active';
-                toolbar_div.className += ' disabled-for-preview';
-                /* Code modified by Allura is here */
-                var text = cm.getValue();
-                get_rendered_text(preview, text);
-              }
-              $container.toggleClass('preview-active');
-              $container.siblings('span.arw').toggleClass('preview-active');
-            }
-
-            function get_rendered_text(preview, text) {
-              preview.innerHTML = 'Loading...';
+            function previewRender(text, preview) {
               var cval = $.cookie('_session_id');
               $.post('/nf/markdown_to_html', {
                 markdown: text,
@@ -148,6 +102,7 @@ $(window).load(function() {
               function(resp) {
                 preview.innerHTML = resp;
               });
+              return 'Loading...';
             }
 
             $('.close', $help_area).bind('click', function() {