allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [26/41] allura git commit: [#7897] ticket:814 Resize editor container immediately after render
Date Wed, 29 Jul 2015 21:10:26 GMT
[#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/a3a5b8b1
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/a3a5b8b1
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/a3a5b8b1

Branch: refs/heads/master
Commit: a3a5b8b1a4b3d1b3449d1a5e24fe62dd16615156
Parents: e1c86ca
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Jul 7 18:47:59 2015 +0300
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Mon Jul 27 14:23:55 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/a3a5b8b1/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...');


Mime
View raw message