1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-25 16:59:17 +01:00

convert action buttons component to ts

This commit is contained in:
Kyle Spearrin 2017-10-31 09:17:18 -04:00
parent b3c671cca0
commit 97f65b19c8
5 changed files with 51 additions and 4 deletions

View File

@ -59,7 +59,6 @@ require('./directives/formDirective.js');
require('./directives/stopClickDirective.js');
require('./directives/stopPropDirective.js');
require('./directives/fallbackSrcDirective.js');
require('./components/actionButtonsComponent.js');
require('./services/backgroundService.js');
require('./services/authService.js');
require('./services/validationService.js');

View File

@ -0,0 +1,49 @@
import * as template from './action-buttons.component.html';
class ActionButtonsController implements ng.IController {
onView: Function;
cipher: any;
showView: boolean;
i18n: any;
constants: any;
constructor(private i18nService: any, private $analytics: any, private constantsService: any, private toastr: any,
private $timeout: any, private $window: any, private utilsService: any) {
this.i18n = i18nService;
this.constants = constantsService;
}
launch() {
const self = this;
this.$timeout(() => {
if (self.cipher.login.uri.startsWith('http://') || self.cipher.login.uri.startsWith('https://')) {
self.$analytics.eventTrack('Launched Website From Listing');
chrome.tabs.create({ url: self.cipher.login.uri });
if (self.utilsService.inPopup(self.$window)) {
self.$window.close();
}
}
});
}
clipboardError(e: any) {
this.toastr.info(this.i18nService.browserNotSupportClipboard);
}
clipboardSuccess(e: any, type: string, aType: string) {
e.clearSelection();
this.$analytics.eventTrack('Copied ' + aType);
this.toastr.info(type + this.i18nService.valueCopied);
}
}
export const ActionButtonsComponent = {
bindings: {
cipher: '<',
showView: '<',
onView: '&',
},
controller: ActionButtonsController,
template,
};

View File

@ -1,4 +1,5 @@
import * as angular from 'angular';
import { ActionButtonsComponent } from './action-buttons.component';
import { CipherItemsComponent } from './cipher-items.component';
import { IconComponent } from './icon.component';
@ -6,4 +7,5 @@ export default angular
.module('bit.components', [])
.component('cipherItems', CipherItemsComponent)
.component('icon', IconComponent)
.component('actionButtons', ActionButtonsComponent)
.name;

View File

@ -1,9 +1,6 @@
import * as template from './icon.component.html';
class IconController implements ng.IController {
onSelected: Function;
onView: Function;
cipher: any;
icon: string;
image: string;