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/08 11:58:55 UTC

[20/21] allura git commit: [#7897] ticket:814 Resize editor container immediately after render

[#7897] ticket:814 Resize editor container immediately after render


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

Branch: refs/heads/ib/7897
Commit: f6dae2688cd0bcb20c23dea1e7c561d0f00851e6
Parents: da510f2
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Jul 7 18:47:59 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Jul 7 18:47:59 2015 +0300

----------------------------------------------------------------------
 .../allura/lib/widgets/resources/js/sf_markitup.js  | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/f6dae268/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 f3466bc..91d63ca 100644
--- a/Allura/allura/lib/widgets/resources/js/sf_markitup.js
+++ b/Allura/allura/lib/widgets/resources/js/sf_markitup.js
@@ -51,17 +51,21 @@ $(window).load(function() {
               toolbar: toolbar
             });
             var cm = editor.codemirror;
-            cm.on('viewportChange', function(cm, from, to) {
+            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);
-            });
-            editor.render();
-
-            // focus editor by clicking anywhere on it, not only on the first few lines
-            $('.CodeMirror').click(function () { this.CodeMirror.focus(); });
+            }
 
             function show_help(editor) {
               $help_contents.html('Loading...');