You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2015/11/09 13:32:23 UTC

incubator-zeppelin git commit: ZEPPELIN-402 Adjust editor height with consideration of line wrap

Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master d5e8b2201 -> d9ddceb3a


ZEPPELIN-402 Adjust editor height with consideration of line wrap

This PR addresses https://issues.apache.org/jira/browse/ZEPPELIN-402

Now it adjust height correctly with line wrap

* When notebook is loaded
* When editor change it's contents
* When browser window resizes

Author: Lee moon soo <mo...@apache.org>

Closes #399 from Leemoonsoo/ZEPPELIN-402 and squashes the following commits:

4e5e868 [Lee moon soo] Take care linewrap when loading notebook and resizing window


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

Branch: refs/heads/master
Commit: d9ddceb3a697f6eb255dbdaef1de146d5ad99178
Parents: d5e8b22
Author: Lee moon soo <mo...@apache.org>
Authored: Sat Nov 7 21:22:07 2015 +0900
Committer: Lee moon soo <mo...@apache.org>
Committed: Mon Nov 9 21:32:30 2015 +0900

----------------------------------------------------------------------
 .../notebook/paragraph/paragraph.controller.js  | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/d9ddceb3/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
index 52fe339..63c30c4 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -449,12 +449,15 @@ angular.module('zeppelinWebApp')
       $scope.editor.setShowFoldWidgets(false);
       $scope.editor.setHighlightActiveLine(false);
       $scope.editor.setHighlightGutterLine(false);
+      $scope.editor.getSession().setUseWrapMode(true);
       $scope.editor.setTheme('ace/theme/chrome');
       $scope.editor.focus();
-      var height = $scope.editor.getSession().getScreenLength() * $scope.editor.renderer.lineHeight + $scope.editor.renderer.scrollBar.getWidth();
-      setEditorHeight(_editor.container.id, height);
 
-      $scope.editor.getSession().setUseWrapMode(true);
+      autoAdjustEditorHeight(_editor.container.id);
+      $(window).resize(function(){
+        autoAdjustEditorHeight(_editor.container.id);
+      });
+
       if (navigator.appVersion.indexOf('Mac') !== -1 ) {
         $scope.editor.setKeyboardHandler('ace/keyboard/emacs');
       } else if (navigator.appVersion.indexOf('Win') !== -1 ||
@@ -542,11 +545,8 @@ angular.module('zeppelinWebApp')
         $scope.handleFocus(false);
       });
 
-
       $scope.editor.getSession().on('change', function(e, editSession) {
-        height = editSession.getScreenLength() * $scope.editor.renderer.lineHeight + $scope.editor.renderer.scrollBar.getWidth();
-        setEditorHeight(_editor.container.id, height);
-        $scope.editor.resize();
+        autoAdjustEditorHeight(_editor.container.id);
       });
 
       $scope.setParagraphMode($scope.editor.getSession(), $scope.editor.getSession().getValue());
@@ -607,8 +607,12 @@ angular.module('zeppelinWebApp')
     }
   };
 
-  var setEditorHeight = function(id, height) {
+  var autoAdjustEditorHeight = function(id) {
+    var editor = $scope.editor;
+    var height = editor.getSession().getScreenLength() * editor.renderer.lineHeight + editor.renderer.scrollBar.getWidth();
+
     $('#' + id).height(height.toString() + 'px');
+    editor.resize();
   };
 
   $scope.getEditorValue = function() {