|
1 | 1 | /* jshint loopfunc: true */ |
| 2 | +/* global $: false */ |
2 | 3 | /* |
3 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 5 | * you may not use this file except in compliance with the License. |
|
14 | 15 | */ |
15 | 16 | 'use strict'; |
16 | 17 |
|
17 | | -angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $route, $routeParams, $location, |
18 | | - $rootScope, $http, websocketMsgSrv, baseUrlSrv, |
19 | | - $timeout, SaveAsService) { |
| 18 | +angular.module('zeppelinWebApp').controller('NotebookCtrl', |
| 19 | + function($scope, $route, $routeParams, $location, $rootScope, $http, |
| 20 | + websocketMsgSrv, baseUrlSrv, $timeout, SaveAsService) { |
20 | 21 | $scope.note = null; |
21 | 22 | $scope.showEditor = false; |
22 | 23 | $scope.editorToggled = false; |
@@ -66,6 +67,21 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro |
66 | 67 | /** Init the new controller */ |
67 | 68 | var initNotebook = function() { |
68 | 69 | websocketMsgSrv.getNotebook($routeParams.noteId); |
| 70 | + |
| 71 | + var currentRoute = $route.current; |
| 72 | + |
| 73 | + if (currentRoute) { |
| 74 | + var routeParams = currentRoute.params; |
| 75 | + var id = '#' + routeParams.paragraph + '_container'; |
| 76 | + setTimeout( |
| 77 | + function() { |
| 78 | + // adjust for navbar |
| 79 | + var top = $(id).offset().top - 103; |
| 80 | + $('html, body').scrollTo({top: top, left: 0}); |
| 81 | + }, |
| 82 | + 1000 |
| 83 | + ); |
| 84 | + } |
69 | 85 | }; |
70 | 86 |
|
71 | 87 | initNotebook(); |
@@ -314,11 +330,11 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro |
314 | 330 | $scope.$on('insertParagraph', function(event, paragraphId, position) { |
315 | 331 | var newIndex = -1; |
316 | 332 | for (var i=0; i<$scope.note.paragraphs.length; i++) { |
317 | | - if ( $scope.note.paragraphs[i].id === paragraphId ) { |
| 333 | + if ( $scope.note.paragraphs[i].id === paragraphId ) { |
318 | 334 | //determine position of where to add new paragraph; default is below |
319 | | - if ( position === 'above' ) { |
| 335 | + if ( position === 'above' ) { |
320 | 336 | newIndex = i; |
321 | | - } else { |
| 337 | + } else { |
322 | 338 | newIndex = i+1; |
323 | 339 | } |
324 | 340 | break; |
|
0 commit comments