Unverified Commit 2e28ac32 authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #832 from hypothesis/update-angular

Update AngularJS to 1.7.x
parents 6a03f91e c29e31e3
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
"repository": "hypothesis/client", "repository": "hypothesis/client",
"devDependencies": { "devDependencies": {
"@octokit/rest": "^15.13.0", "@octokit/rest": "^15.13.0",
"angular": "^1.6.9", "angular": "^1.7.5",
"angular-mocks": "^1.6.9", "angular-mocks": "^1.7.5",
"angular-route": "^1.6.9", "angular-route": "^1.7.5",
"angular-sanitize": "^1.6.9", "angular-sanitize": "^1.7.5",
"angular-toastr": "^1.7.0", "angular-toastr": "^1.7.0",
"angulartics": "0.17.2", "angulartics": "0.17.2",
"autofill-event": "0.0.1", "autofill-event": "0.0.1",
......
...@@ -33,8 +33,10 @@ function AnnotationViewerContentController ( ...@@ -33,8 +33,10 @@ function AnnotationViewerContentController (
const id = $routeParams.id; const id = $routeParams.id;
this.search.update = function (query) { this.$onInit = () => {
$location.path('/stream').search('q', query); this.search.update = function (query) {
$location.path('/stream').search('q', query);
};
}; };
store.subscribe(function () { store.subscribe(function () {
......
...@@ -99,7 +99,7 @@ function AnnotationController( ...@@ -99,7 +99,7 @@ function AnnotationController(
* All initialization code except for assigning the controller instance's * All initialization code except for assigning the controller instance's
* methods goes here. * methods goes here.
*/ */
function init() { this.$onInit = () => {
/** Determines whether controls to expand/collapse the annotation body /** Determines whether controls to expand/collapse the annotation body
* are displayed adjacent to the tags field. * are displayed adjacent to the tags field.
*/ */
...@@ -156,7 +156,7 @@ function AnnotationController( ...@@ -156,7 +156,7 @@ function AnnotationController(
self.edit(); self.edit();
} }
} }
} };
/** Save this annotation if it's a new highlight. /** Save this annotation if it's a new highlight.
* *
...@@ -569,8 +569,6 @@ function AnnotationController( ...@@ -569,8 +569,6 @@ function AnnotationController(
} }
return self.group().type !== 'private'; return self.group().type !== 'private';
}; };
init();
} }
module.exports = { module.exports = {
......
...@@ -202,10 +202,12 @@ function SidebarContentController( ...@@ -202,10 +202,12 @@ function SidebarContentController(
streamer.connect(); streamer.connect();
}); });
// If the user is logged in, we connect nevertheless this.$onInit = () => {
if (this.auth.status === 'logged-in') { // If the user is logged in, we connect nevertheless
streamer.connect(); if (this.auth.status === 'logged-in') {
} streamer.connect();
}
};
$scope.$on(events.USER_CHANGED, function () { $scope.$on(events.USER_CHANGED, function () {
streamer.reconnect(); streamer.reconnect();
......
...@@ -52,15 +52,6 @@ function StreamContentController( ...@@ -52,15 +52,6 @@ function StreamContentController(
store.setForceVisible(id, true); store.setForceVisible(id, true);
}; };
Object.assign(this.search, {
query: function () {
return $routeParams.q || '';
},
update: function (q) {
$location.search({q: q});
},
});
store.subscribe(function () { store.subscribe(function () {
self.rootThread = rootThread.thread(store.getState()); self.rootThread = rootThread.thread(store.getState());
}); });
...@@ -69,6 +60,11 @@ function StreamContentController( ...@@ -69,6 +60,11 @@ function StreamContentController(
store.setSortKey('Newest'); store.setSortKey('Newest');
this.loadMore = fetch; this.loadMore = fetch;
this.$onInit = () => {
this.search.query = () => $routeParams.q || '';
this.search.update = q => $location.search({ q });
};
} }
module.exports = { module.exports = {
......
...@@ -16,10 +16,12 @@ const icons = { ...@@ -16,10 +16,12 @@ const icons = {
// @ngInject // @ngInject
function SvgIconController($element) { function SvgIconController($element) {
if (!icons[this.name]) { this.$onInit = () => {
throw new Error('Unknown icon: ' + this.name); if (!icons[this.name]) {
} throw new Error('Unknown icon: ' + this.name);
$element[0].innerHTML = icons[this.name]; }
$element[0].innerHTML = icons[this.name];
};
} }
module.exports = { module.exports = {
......
...@@ -151,8 +151,7 @@ describe('annotation', function() { ...@@ -151,8 +151,7 @@ describe('annotation', function() {
}) })
.component('markdown', { .component('markdown', {
bindings: require('../markdown').bindings, bindings: require('../markdown').bindings,
}) });
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
}); });
beforeEach(angular.mock.module('h')); beforeEach(angular.mock.module('h'));
......
...@@ -35,8 +35,7 @@ describe('annotationViewerContent', function () { ...@@ -35,8 +35,7 @@ describe('annotationViewerContent', function () {
before(function () { before(function () {
angular.module('h', []) angular.module('h', [])
.component('annotationViewerContent', .component('annotationViewerContent',
require('../annotation-viewer-content')) require('../annotation-viewer-content'));
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
}); });
beforeEach(angular.mock.module('h')); beforeEach(angular.mock.module('h'));
......
...@@ -57,8 +57,7 @@ describe('sidebar.components.hypothesis-app', function () { ...@@ -57,8 +57,7 @@ describe('sidebar.components.hypothesis-app', function () {
})); }));
angular.module('h', []) angular.module('h', [])
.component('hypothesisApp', component) .component('hypothesisApp', component);
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
}); });
beforeEach(angular.mock.module('h')); beforeEach(angular.mock.module('h'));
......
...@@ -67,8 +67,7 @@ describe('sidebar.components.sidebar-content', function () { ...@@ -67,8 +67,7 @@ describe('sidebar.components.sidebar-content', function () {
angular: angular, angular: angular,
'../search-client': FakeSearchClient, '../search-client': FakeSearchClient,
}) })
)) ));
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
}); });
beforeEach(angular.mock.module('h')); beforeEach(angular.mock.module('h'));
......
...@@ -26,8 +26,7 @@ describe('StreamContentController', function () { ...@@ -26,8 +26,7 @@ describe('StreamContentController', function () {
before(function () { before(function () {
angular.module('h', []) angular.module('h', [])
.component('streamContent', require('../stream-content')) .component('streamContent', require('../stream-content'));
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
}); });
beforeEach(function () { beforeEach(function () {
......
...@@ -7,8 +7,7 @@ const util = require('../../directive/test/util'); ...@@ -7,8 +7,7 @@ const util = require('../../directive/test/util');
describe('svgIcon', function () { describe('svgIcon', function () {
before(function () { before(function () {
angular.module('app', []) angular.module('app', [])
.component('svgIcon', require('../svg-icon')) .component('svgIcon', require('../svg-icon'));
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
}); });
beforeEach(function () { beforeEach(function () {
......
...@@ -115,8 +115,7 @@ describe('threadList', function () { ...@@ -115,8 +115,7 @@ describe('threadList', function () {
before(function () { before(function () {
angular.module('app', []) angular.module('app', [])
.component('threadList', threadList) .component('threadList', threadList);
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
}); });
beforeEach(function () { beforeEach(function () {
......
...@@ -70,26 +70,29 @@ function ThreadListController($element, $scope, settings, VirtualThreadList) { ...@@ -70,26 +70,29 @@ function ThreadListController($element, $scope, settings, VirtualThreadList) {
const options = Object.assign({ const options = Object.assign({
scrollRoot: this.scrollRoot, scrollRoot: this.scrollRoot,
}, virtualThreadOptions); }, virtualThreadOptions);
let visibleThreads;
const visibleThreads = new VirtualThreadList($scope, window, this.thread, options);
visibleThreads.on('changed', function (state) { this.$onInit = () => {
self.virtualThreadList = { visibleThreads = new VirtualThreadList($scope, window, this.thread, options);
visibleThreads: state.visibleThreads, visibleThreads.on('changed', function (state) {
invisibleThreads: state.invisibleThreads, self.virtualThreadList = {
offscreenUpperHeight: state.offscreenUpperHeight + 'px', visibleThreads: state.visibleThreads,
offscreenLowerHeight: state.offscreenLowerHeight + 'px', invisibleThreads: state.invisibleThreads,
}; offscreenUpperHeight: state.offscreenUpperHeight + 'px',
offscreenLowerHeight: state.offscreenLowerHeight + 'px',
scopeTimeout($scope, function () { };
state.visibleThreads.forEach(function (thread) {
const height = getThreadHeight(thread.id); scopeTimeout($scope, function () {
if (!height) { state.visibleThreads.forEach(function (thread) {
return; const height = getThreadHeight(thread.id);
} if (!height) {
visibleThreads.setThreadHeight(thread.id, height); return;
}); }
}, 50); visibleThreads.setThreadHeight(thread.id, height);
}); });
}, 50);
});
};
/** /**
* Return the vertical scroll offset for the document in order to position the * Return the vertical scroll offset for the document in order to position the
...@@ -134,7 +137,7 @@ function ThreadListController($element, $scope, settings, VirtualThreadList) { ...@@ -134,7 +137,7 @@ function ThreadListController($element, $scope, settings, VirtualThreadList) {
}); });
this.$onChanges = function (changes) { this.$onChanges = function (changes) {
if (changes.thread) { if (changes.thread && visibleThreads) {
visibleThreads.setRootThread(changes.thread.currentValue); visibleThreads.setRootThread(changes.thread.currentValue);
} }
}; };
......
...@@ -95,19 +95,6 @@ function configureToastr(toastrConfig) { ...@@ -95,19 +95,6 @@ function configureToastr(toastrConfig) {
}); });
} }
// @ngInject
function configureCompile($compileProvider) {
// Make component bindings available in controller constructor. When
// pre-assigned bindings is off, as it is by default in Angular >= 1.6.0,
// bindings are only available during and after the controller's `$onInit`
// method.
//
// This migration helper is being removed in Angular 1.7.0. To see which
// components need updating, look for uses of `preAssignBindingsEnabled` in
// tests.
$compileProvider.preAssignBindingsEnabled(true);
}
// @ngInject // @ngInject
function setupHttp($http, streamer) { function setupHttp($http, streamer) {
$http.defaults.headers.common['X-Client-Id'] = streamer.clientId; $http.defaults.headers.common['X-Client-Id'] = streamer.clientId;
...@@ -213,7 +200,6 @@ function startAngularApp(config) { ...@@ -213,7 +200,6 @@ function startAngularApp(config) {
.value('time', require('./util/time')) .value('time', require('./util/time'))
.value('urlEncodeFilter', require('./filter/url').encode) .value('urlEncodeFilter', require('./filter/url').encode)
.config(configureCompile)
.config(configureLocation) .config(configureLocation)
.config(configureRoutes) .config(configureRoutes)
.config(configureToastr) .config(configureToastr)
......
...@@ -169,30 +169,30 @@ ancestors@0.0.3: ...@@ -169,30 +169,30 @@ ancestors@0.0.3:
resolved "https://registry.yarnpkg.com/ancestors/-/ancestors-0.0.3.tgz#124eb944447d68b302057047d15d077a9da5179d" resolved "https://registry.yarnpkg.com/ancestors/-/ancestors-0.0.3.tgz#124eb944447d68b302057047d15d077a9da5179d"
integrity sha1-Ek65RER9aLMCBXBH0V0Hep2lF50= integrity sha1-Ek65RER9aLMCBXBH0V0Hep2lF50=
angular-mocks@^1.6.9: angular-mocks@^1.7.5:
version "1.6.10" version "1.7.5"
resolved "https://registry.yarnpkg.com/angular-mocks/-/angular-mocks-1.6.10.tgz#6a139e43c461d0c9a5a1acebc91e63db16031176" resolved "https://registry.yarnpkg.com/angular-mocks/-/angular-mocks-1.7.5.tgz#c8baba5a06ed60b934697026b492169626af384b"
integrity sha512-1865/NmqHNogibNoglY1MGBjx882iu2hI46BBhYDWyz0C4TDM5ER8H8SnYwQKUUG4RXMDsJizszEQ2BEoYKV9w== integrity sha512-I+Ue2Bkx6R9W5178DYrNvzjIdGh4wKKoCWsgz8dc7ysH4mA70Q3M9v5xRF0RUu7r+2CZj+nDeUecvh2paxcYvg==
angular-route@^1.6.9: angular-route@^1.7.5:
version "1.6.10" version "1.7.5"
resolved "https://registry.yarnpkg.com/angular-route/-/angular-route-1.6.10.tgz#4247a32eab19495624623e96c1626dfba17ebf21" resolved "https://registry.yarnpkg.com/angular-route/-/angular-route-1.7.5.tgz#34a3648c407a14a030d075cf485318e33ba23f0e"
integrity sha512-BxjrjQNCbVqQKyB3nHjNI8zSUwhnQWFZnSBv5BZ336VbMKhWu74ad5xpFx5VMk6WyHlmMGDoRagzB6AKkRcvKA== integrity sha512-7KfyEVVOWTI+jTY/j5rUNCIHGRyeCOx7YqZI/Ci3IbDK7GIsy6xH+hS5ai0Xi0sLjzDZ0PUDO4gBn+K0dVtlOg==
angular-sanitize@^1.6.9: angular-sanitize@^1.7.5:
version "1.6.10" version "1.7.5"
resolved "https://registry.yarnpkg.com/angular-sanitize/-/angular-sanitize-1.6.10.tgz#635a362afb2dd040179f17d3a5455962b2c1918f" resolved "https://registry.yarnpkg.com/angular-sanitize/-/angular-sanitize-1.7.5.tgz#75d49e15071ca9c70581e76d20940f26372e24d2"
integrity sha512-01i1Xoq9ykUrsoYQMSB6dWZmPp9Df5hfCqMAGGzJBWZ7L2WY0OtUphdI0YvR8ZF9lAsWtGNtsEFilObjq5nTgQ== integrity sha512-wjKCJOIwrkEvfD0keTnKGi6We13gtoCAQIHcdoqyoo3gwvcgNfYymVQIS3+iCGVcjfWz0jHuS3KgB4ysRWsTTA==
angular-toastr@^1.7.0: angular-toastr@^1.7.0:
version "1.7.0" version "1.7.0"
resolved "https://registry.yarnpkg.com/angular-toastr/-/angular-toastr-1.7.0.tgz#7fdf9ef61cb4abee7a8818eb3d9798c057d4eb7f" resolved "https://registry.yarnpkg.com/angular-toastr/-/angular-toastr-1.7.0.tgz#7fdf9ef61cb4abee7a8818eb3d9798c057d4eb7f"
integrity sha1-f9+e9hy0q+56iBjrPZeYwFfU638= integrity sha1-f9+e9hy0q+56iBjrPZeYwFfU638=
angular@^1.6.9: angular@^1.7.5:
version "1.6.10" version "1.7.5"
resolved "https://registry.yarnpkg.com/angular/-/angular-1.6.10.tgz#eed3080a34d29d0f681ff119b18ce294e3f74826" resolved "https://registry.yarnpkg.com/angular/-/angular-1.7.5.tgz#d1c1c01c6f5dc835638f3f9aa51012857bdac49e"
integrity sha512-PCZ5/hVdvPQiYyH0VwsPjrErPHRcITnaXxhksceOXgtJeesKHLA7KDu4X/yvcAi+1zdGgGF+9pDxkJvghXI9Wg== integrity sha512-760183yxtGzni740IBTieNuWLtPNAoMqvmC0Z62UoU0I3nqk+VJuO3JbQAXOyvo3Oy/ZsdNQwrSTh/B0OQZjNw==
angulartics@0.17.2: angulartics@0.17.2:
version "0.17.2" version "0.17.2"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment