You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/07/22 14:31:19 UTC

[23/42] allura git commit: [#7897] ticket:820 Clean up styles for SimpleMDE

[#7897] ticket:820 Clean up styles for SimpleMDE


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

Branch: refs/heads/ib/7897
Commit: b71249f7ff2a990e270063db40504f6531aeb5ff
Parents: 1680f7f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Jul 14 13:58:22 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Jul 22 10:59:52 2015 +0300

----------------------------------------------------------------------
 Allura/allura/lib/widgets/discuss.py            |  4 +-
 .../lib/widgets/resources/css/markitup_sf.css   | 38 +++--------
 .../lib/widgets/resources/js/sf_markitup.js     | 67 ++++++++++----------
 Allura/allura/nf/allura/css/site_style.css      |  2 +-
 .../forgewiki/templates/wiki/page_edit.html     |  8 +--
 5 files changed, 46 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b71249f7/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index db9342c..ff131e8 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -157,9 +157,7 @@ class EditPost(ff.ForgeForm):
     @property
     def fields(self):
         fields = ew_core.NameList()
-        fields.append(ffw.MarkdownEdit(
-            name='text',
-            attrs={'style': 'height:7em; width:97%'}))
+        fields.append(ffw.MarkdownEdit(name='text'))
         fields.append(ew.HiddenField(name='forum', if_missing=None))
         if ew_core.widget_context.widget:
             # we are being displayed

http://git-wip-us.apache.org/repos/asf/allura/blob/b71249f7/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 5e85697..5837469 100644
--- a/Allura/allura/lib/widgets/resources/css/markitup_sf.css
+++ b/Allura/allura/lib/widgets/resources/css/markitup_sf.css
@@ -17,43 +17,23 @@
        under the License.
 */
 .markdown_edit {
-  height: 200px;
-  min-height: 200px;
   width: 95%;
-  font-family: Consolas, "Andale Mono", "Lucida Console", monospace;
-
-  -moz-border-radius: 4px;
-  -webkit-border-radius: 4px;
-  -o-border-radius: 4px;
-  -ms-border-radius: 4px;
-  -khtml-border-radius: 4px;
-  border-radius: 4px;
-  -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) inset,0 1px 0 rgba(255, 255, 255, 0.9);
-  -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) inset,0 1px 0 rgba(255, 255, 255, 0.9);
-  -o-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) inset,0 1px 0 rgba(255, 255, 255, 0.9);
-  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) inset,0 1px 0 rgba(255, 255, 255, 0.9);
-  border: medium none;
-  margin-bottom: 5px;
-  margin-left: 2px;
-  border: 1px solid #aaaaaa;
   background: white;
 }
-
 .markdown_edit .CodeMirror {
-  height: auto;
   min-height: 120px;
+  border-bottom: none;
+  border-bottom-left-radius: 0;
+  border-bottom-right-radius: 0;
 }
-
-.markdown_edit .editor-toolbar:before {
-  background: none;  /* hide toolbar's top border */
+.markdown_edit .CodeMirror-scroll {
+  min-height: 120px;
 }
-
-.markdown_edit .CodeMirror-sizer,
-.markdown_edit .editor-preview {
-  padding: 5px;
+.markdown_edit .editor-statusbar {
+  border: 1px solid #ddd;
+  border-bottom-left-radius: 4px;
+  border-bottom-right-radius: 4px;
 }
-
-
 .markdown_edit .editor-preview {
   z-index: 1001;  /* should always be under help modal */
 }

http://git-wip-us.apache.org/repos/asf/allura/blob/b71249f7/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 91d63ca..b05f698 100644
--- a/Allura/allura/lib/widgets/resources/js/sf_markitup.js
+++ b/Allura/allura/lib/widgets/resources/js/sf_markitup.js
@@ -27,46 +27,36 @@ $(window).load(function() {
             var $help_area = $('div.markdown_help', $container);
             var $help_contents = $('div.markdown_help_contents', $container);
 
+            // Add "info" tool & override action "preview" tool
             var toolbar = [];
-            // Exclude "code" tool from toolbar, since it's syntax not matching Allura's
-            // Override actions for "info" & "preview" tools
-            for (var i in Editor.toolbar) {
-              var tool = Editor.toolbar[i];
-              if (tool !== null && typeof tool === 'object') {
-                switch(tool.name) {
-                  case 'code':
-                    continue;
-                  case 'info':
-                    tool = {name: 'info', action: show_help};
-                    break;
-                  case 'preview':
-                    tool = {name: 'preview', action: show_preview};
-                    break;
-                }
+            for (var i in SimpleMDE.toolbar) {
+              var tool = SimpleMDE.toolbar[i];
+              if (tool !== null && typeof tool === 'object' && tool.name === 'preview') {
+                  toolbar.push({
+                    name: 'info',
+                    action: show_help,
+                    className: 'fa fa-info'
+                  });
+                  toolbar.push({
+                    name: 'preview',
+                    action: show_preview,
+                    className: 'fa fa-eye'
+                  });
+              } else {
+                toolbar.push(tool);
               }
-              toolbar.push(tool);
             }
-            var editor = new Editor({
+
+            var editor = new SimpleMDE({
               element: $textarea[0],
+              autofocus: false,
               toolbar: toolbar
             });
-            var cm = editor.codemirror;
-            cm.on('viewportChange', resize);
             editor.render();
-            // trigger resize to properly display editor in case of a lot of text in the textarea
-            resize(cm);
 
             // focus editor by clicking anywhere on it, not only on the first few lines
             $('.CodeMirror').click(function () { this.CodeMirror.focus(); });
 
-            function resize(cm) {
-              var toolbar_h = $('.editor-toolbar', $container).outerHeight();
-              var statusbar_h = $('.editor-statusbar', $container).outerHeight();
-              var cm_h = cm.getScrollInfo().clientHeight;
-              var h = toolbar_h + statusbar_h + cm_h;
-              $container.height(h);
-            }
-
             function show_help(editor) {
               $help_contents.html('Loading...');
               $.get($help_contents.attr('data-url'), function (data) {
@@ -89,11 +79,13 @@ $(window).load(function() {
 
             function show_preview(editor) {
               /*
-               * This is pretty much the same as original Editor.togglePreview,
+               * This is pretty much the same as original SimpleMDE.togglePreview,
                * but rendered text is fetched from the server.
-               * https://github.com/lepture/editor/blob/0f493bfdc7c3014ee7ac656f41b5b52f8955b2e9/src/intro.js#L216-L242
+               * https://github.com/NextStepWebs/simplemde-markdown-editor/blob/1.2.1/source%20files/markdownify.js#L218-L249
                */
+              var toolbar_div = document.getElementsByClassName('editor-toolbar')[0];
               var toolbar = editor.toolbar.preview;
+              var parse = editor.constructor.markdown;
               var cm = editor.codemirror;
               var wrapper = cm.getWrapperElement();
               var preview = wrapper.lastChild;
@@ -104,18 +96,23 @@ $(window).load(function() {
               }
               if (/editor-preview-active/.test(preview.className)) {
                 preview.className = preview.className.replace(
-                    /\s*editor-preview-active\s*/g, ''
-                    );
+                  /\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);
+                setTimeout(function() {
+                  preview.className += ' editor-preview-active';
+                }, 1);
                 toolbar.className += ' active';
+                toolbar_div.className += ' disabled-for-preview';
               }
-              get_rendered_text(preview, cm.getValue());
+              var text = cm.getValue();
+              get_rendered_text(preview, text);
             }
 
             function get_rendered_text(preview, text) {

http://git-wip-us.apache.org/repos/asf/allura/blob/b71249f7/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index df0b932..80081e4 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -2657,7 +2657,7 @@ div.attachment_thumb .file_type span {
   border-left: 1px solid #d7d7d7;
   position: absolute;
   top: 50px;
-  left: 86px;
+  left: 85px;
 }
 
 .edit_post_form.reply .arw {

http://git-wip-us.apache.org/repos/asf/allura/blob/b71249f7/ForgeWiki/forgewiki/templates/wiki/page_edit.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
index c9596b7..2bcb94b 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -25,13 +25,9 @@
 
 {% block extra_css %}
 <style type="text/css">
-  .markdown_edit {
-    height: 600px;
-    min-height: 600px;
-  }
   .markdown_edit .CodeMirror {
     height: auto;
-    min-height: 520px;
+    min-height: 600px;
   }
 </style>
 {% endblock %}
@@ -68,10 +64,12 @@
 	  {{c.markdown_editor.display(id='text', name='text',value=page.text)}}
 	</div>
 	<div style="clear:both;"></div>
+  <div style="margin-top: 1em;">
 	<label class="grid-4">Labels:</label>
 	<div class="grid-14" style="margin-left:0">
 		{{c.label_edit.display(id='labels', name='labels', value=page.labels)}}
 	</div>
+  </div>
   <div class="grid-19">
     <input type="submit" value="Save">
     <input type="reset" value="Cancel">