zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject zeppelin git commit: [Optimization] Code editor key binding event optimization.
Date Sat, 06 Aug 2016 15:03:11 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master 8fe914b5d -> ea76ca9f3


[Optimization] Code editor key binding event optimization.

### What is this PR for?
zeppelin custom key binding event optimization for Ace Code editor

### What type of PR is it?
Improvement

### Todos
- [x] optimization for key binding and check logic

### How should this be tested?
For many in the code editor and typing quickly.
The effect is greater when there are many Paragraph.

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: CloverHearts <cloverheartsdev@gmail.com>

Closes #1287 from cloverhearts/dev/codeditorKeyBindOptimization and squashes the following
commits:

76cd284 [CloverHearts] paragraph move jum bug fixed.
27f7146 [CloverHearts] Modify the style syntax for code editor
e4c37b1 [CloverHearts] move to original key bind function for codeeditor optimiza
6a9edbe [CloverHearts] change access type $scope access member to local variable and add last
row check logic
8cc63b7 [CloverHearts] fixed syntax error for editor key binding optimization.
b37788d [CloverHearts] Code editor key binding event optimization.


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

Branch: refs/heads/master
Commit: ea76ca9f3f4fe98da45adcb81d7611801b11e1e4
Parents: 8fe914b
Author: CloverHearts <cloverheartsdev@gmail.com>
Authored: Fri Aug 5 23:18:02 2016 +0900
Committer: Lee moon soo <moon@apache.org>
Committed: Sat Aug 6 08:03:00 2016 -0700

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


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea76ca9f/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 5e8e2fe..2925c47 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -665,6 +665,19 @@ angular.module('zeppelinWebApp').controller('ParagraphCtrl', function($scope,
$r
       $scope.editor.commands.bindKey('ctrl-.', 'startAutocomplete');
       $scope.editor.commands.bindKey('ctrl-space', null);
 
+      var keyBindingEditorFocusAction = function(scrollValue) {
+        var numRows = $scope.editor.getSession().getLength();
+        var currentRow = $scope.editor.getCursorPosition().row;
+        if (currentRow === 0 && scrollValue <= 0) {
+          // move focus to previous paragraph
+          $scope.$emit('moveFocusToPreviousParagraph', $scope.paragraph.id);
+        } else if (currentRow === numRows - 1 && scrollValue >= 0) {
+          $scope.$emit('moveFocusToNextParagraph', $scope.paragraph.id);
+        } else {
+          $scope.scrollToCursor($scope.paragraph.id, scrollValue);
+        }
+      };
+
       // handle cursor moves
       $scope.editor.keyBinding.origOnCommandKey = $scope.editor.keyBinding.onCommandKey;
       $scope.editor.keyBinding.onCommandKey = function(e, hashId, keyCode) {
@@ -678,27 +691,26 @@ angular.module('zeppelinWebApp').controller('ParagraphCtrl', function($scope,
$r
             angular.element('#' + $scope.paragraph.id + '_editor > textarea').css('top',
cursorPos.top);
           }
 
-          var numRows;
-          var currentRow;
+          var ROW_UP = -1;
+          var ROW_DOWN = 1;
 
-          if (keyCode === 38 || (keyCode === 80 && e.ctrlKey && !e.altKey))
{  // UP
-            numRows = $scope.editor.getSession().getLength();
-            currentRow = $scope.editor.getCursorPosition().row;
-            if (currentRow === 0) {
-              // move focus to previous paragraph
-              $scope.$emit('moveFocusToPreviousParagraph', $scope.paragraph.id);
-            } else {
-              $scope.scrollToCursor($scope.paragraph.id, -1);
-            }
-          } else if (keyCode === 40 || (keyCode === 78 && e.ctrlKey && !e.altKey))
{  // DOWN
-            numRows = $scope.editor.getSession().getLength();
-            currentRow = $scope.editor.getCursorPosition().row;
-            if (currentRow === numRows - 1) {
-              // move focus to next paragraph
-              $scope.$emit('moveFocusToNextParagraph', $scope.paragraph.id);
-            } else {
-              $scope.scrollToCursor($scope.paragraph.id, 1);
-            }
+          switch (keyCode) {
+            case 38:
+              keyBindingEditorFocusAction(ROW_UP);
+              break;
+            case 80:
+              if (e.ctrlKey && !e.altKey) {
+                keyBindingEditorFocusAction(ROW_UP);
+              }
+              break;
+            case 40:
+              keyBindingEditorFocusAction(ROW_DOWN);
+              break;
+            case 78:
+              if (e.ctrlKey && !e.altKey) {
+                keyBindingEditorFocusAction(ROW_DOWN);
+              }
+              break;
           }
         }
         this.origOnCommandKey(e, hashId, keyCode);


Mime
View raw message