Skip to content
This repository was archived by the owner on Oct 18, 2018. It is now read-only.

Commit a3a2147

Browse files
committed
Move selectedFile to $rootScope
1 parent 1e50d0b commit a3a2147

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

src/main/webapp/app.components.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,53 +19,49 @@
1919
return {
2020
list: function () {
2121
return fileList;
22-
},
23-
selectedFile: fileList[0]
24-
22+
}
2523
};
2624
}
2725

28-
function DocumentInfoFactory($resource, FilesFactory) {
26+
function DocumentInfoFactory($rootScope, $resource) {
2927
return $resource('/document/info?file=:filename', {}, {
3028
get: {
3129
method: 'GET',
3230
params: {
33-
filename: FilesFactory.selectedFile
31+
filename: $rootScope.selectedFile
3432
}
3533
}
3634
});
3735
}
3836

39-
function AnnotationListFactory($resource, FilesFactory) {
37+
function AnnotationListFactory($rootScope, $resource) {
4038
return $resource('/annotation/list?file=:filename', {}, {
4139
query: {
4240
method: 'GET',
4341
params: {
44-
filename: FilesFactory.selectedFile
42+
filename: $rootScope.selectedFile
4543
},
4644
isArray: true
4745
}
4846
});
4947
}
5048

51-
function AnnotationAddFactory($resource, FilesFactory) {
49+
function AnnotationAddFactory($rootScope, $resource) {
5250
return $resource('/annotation/add?file=:filename', {}, {
5351
save: {
5452
method: 'POST',
5553
params: {
56-
filename: FilesFactory.selectedFile
54+
filename: $rootScope.selectedFile
5755
}
5856
}
5957
});
6058
}
6159

6260
function AvailableFilesController($scope, FilesFactory) {
6361
$scope.list = FilesFactory.list();
64-
$scope.selectedFile = FilesFactory.selectedFile;
6562
}
6663

67-
function ToolbarController($scope, $mdToast, FilesFactory) {
68-
$scope.selectedFile = FilesFactory.selectedFile;
64+
function ToolbarController($scope, $mdToast) {
6965

7066
$scope.$on('annotation-added', function (event, args) {
7167
$mdToast.show(

src/main/webapp/app.controller.pageCanvas.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
(function () {
22
'use strict';
33

4-
function main($rootScope, $scope, AnnotationListFactory, FilesFactory, DocumentInfoFactory) {
4+
function main($rootScope, $scope, AnnotationListFactory, DocumentInfoFactory) {
55

66
$rootScope.docInfo = DocumentInfoFactory.get();
7-
$scope.selectedFile = FilesFactory.selectedFile;
87
$scope.annotationsList = AnnotationListFactory.query();
98
$rootScope.selectedDrawingTool = 'select';
109
}

src/main/webapp/app.run.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(function () {
2+
'use strict';
3+
4+
function main($rootScope) {
5+
$rootScope.selectedFile = '';
6+
}
7+
8+
angular.module('GroupDocsAnnotationApp').run(main);
9+
10+
})();
11+

src/main/webapp/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<script src="app.controller.thread.js"></script>
3131
<script src="app.controller.tools.js"></script>
3232
<script src="app.config.js"></script>
33+
<script src="app.run.js"></script>
3334
</head>
3435
<body ng-cloak>
3536

@@ -39,12 +40,12 @@
3940
</md-button>
4041
<h1>GroupDocs.Annotation for Java</h1>
4142
<span flex></span>
42-
<md-button class="md-icon-button" ng-href="/download/annotated?file={{ selectedFile }}" target="_blank">
43+
<md-button class="md-icon-button" ng-href="/download/annotated?file={{ $root.selectedFile }}" target="_blank">
4344
<md-icon>file_download</md-icon>
4445
<md-tooltip>Download the annotated file</md-tooltip>
4546
</md-button>
4647
<div ng-controller="AvailableFilesController">
47-
<md-select ng-model="selectedFile" aria-label="Files" ng-disabled="true">
48+
<md-select ng-model="$root.selectedFile" aria-label="Files" ng-disabled="true">
4849
<md-option ng-value="item" ng-repeat="item in list">{{ item }}</md-option>
4950
</md-select>
5051
</div>
@@ -92,7 +93,7 @@ <h1>GroupDocs.Annotation for Java</h1>
9293
<md-content flex id="content" ng-controller="PageCanvasController">
9394
<md-card ng-repeat="pageInfo in docInfo.pages">
9495
<gdx-anno-page
95-
file="{{ selectedFile }}"
96+
file="{{ $root.selectedFile }}"
9697
number="{{ pageInfo.number }}"
9798
width="{{ pageInfo.width }}"
9899
height="{{ pageInfo.height }}"

0 commit comments

Comments
 (0)