1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 17:23:37 +00:00

Convert global module to TypeScript. (#397)

This commit is contained in:
Oscar Hinton
2017-11-25 16:04:31 +01:00
committed by Kyle Spearrin
parent f5ccc22076
commit 7c525d3f3a
11 changed files with 83 additions and 77 deletions

View File

@@ -0,0 +1,46 @@
import { UtilsService } from '../../../services/abstractions/utils.service';
export class MainController implements ng.IController {
smBody: boolean;
xsBody: boolean;
animation: string;
constructor($scope: any, $transitions: any, $state: any, authService: any, toastr: any,
i18nService: any, $analytics: any, utilsService: UtilsService, $window: any) {
this.animation = '';
this.xsBody = $window.screen.availHeight < 600;
this.smBody = !this.xsBody && $window.screen.availHeight <= 800;
$transitions.onSuccess({}, (transition: any) => {
const toParams = transition.params('to');
if (toParams.animation) {
this.animation = toParams.animation;
} else {
this.animation = '';
}
});
chrome.runtime.onMessage.addListener((msg: any, sender: any, sendResponse: any) => {
if (msg.command === 'syncCompleted') {
$scope.$broadcast('syncCompleted', msg.successfully);
} else if (msg.command === 'syncStarted') {
$scope.$broadcast('syncStarted');
} else if (msg.command === 'doneLoggingOut') {
authService.logOut(() => {
$analytics.eventTrack('Logged Out');
if (msg.expired) {
toastr.warning(i18nService.loginExpired, i18nService.loggedOut);
}
$state.go('home');
});
} else if (msg.command === 'collectPageDetailsResponse' && msg.sender === 'currentController') {
$scope.$broadcast('collectPageDetailsResponse', {
frameId: sender.frameId,
tab: msg.tab,
details: msg.details,
});
}
});
}
}