allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/8] allura git commit: [#7955] Integration with SimpleMDE preview customization.
Date Wed, 09 Sep 2015 22:06:44 GMT
Repository: allura
Updated Branches:
  refs/heads/db/7955 e4091e027 -> d42c3364f (forced update)


[#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/2466c7c3
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2466c7c3
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2466c7c3

Branch: refs/heads/db/7955
Commit: 2466c7c35e58755fffc681f32cf965510385ea37
Parents: 9c4c83f
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Wed Sep 2 20:06:48 2015 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Sep 3 20:23:31 2015 +0000

----------------------------------------------------------------------
 .../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/2466c7c3/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 bcb6ff9..97c10e7 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/2466c7c3/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 8666629..1fe1547 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,
+              preview_render: preview_render,
             });
             editor.render();
 
@@ -109,48 +105,8 @@ $(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) {
+            function preview_render(editor, preview) {
+              var text = editor.codemirror.getValue();
               preview.innerHTML = 'Loading...';
               var cval = $.cookie('_session_id');
               $.post('/nf/markdown_to_html', {
@@ -165,7 +121,6 @@ $(window).load(function() {
               });
             }
 
-
             $('.close', $help_area).bind('click', function() {
               $help_area.hide();
             });


Mime
View raw message