mirror of
https://github.com/bitwarden/browser
synced 2026-01-06 10:33:57 +00:00
action buttons component
This commit is contained in:
@@ -1,18 +1,41 @@
|
||||
angular
|
||||
.module('bit.components')
|
||||
|
||||
.component('actionButtonsComponent', {
|
||||
.component('actionButtons', {
|
||||
bindings: {
|
||||
uri: '<'
|
||||
cipher: '<',
|
||||
showView: '<',
|
||||
onView: '&'
|
||||
},
|
||||
template: '',
|
||||
controller: function (stateService) {
|
||||
this.$onInit = (function () {
|
||||
|
||||
}).bind(this);
|
||||
templateUrl: 'app/components/views/actionButtons.html',
|
||||
controller: function (i18nService, $analytics, constantsService, toastr, $timeout, $window, utilsService) {
|
||||
var ctrl = this;
|
||||
|
||||
this.$onChanges = (function () {
|
||||
|
||||
}).bind(this);
|
||||
ctrl.$onInit = function () {
|
||||
ctrl.i18n = i18nService;
|
||||
ctrl.constants = constantsService;
|
||||
|
||||
ctrl.launch = function () {
|
||||
$timeout(function () {
|
||||
if (ctrl.cipher.login.uri.startsWith('http://') || ctrl.cipher.login.uri.startsWith('https://')) {
|
||||
$analytics.eventTrack('Launched Website From Listing');
|
||||
chrome.tabs.create({ url: ctrl.cipher.login.uri });
|
||||
if (utilsService.inPopup($window)) {
|
||||
$window.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ctrl.clipboardError = function (e) {
|
||||
toastr.info(i18n.browserNotSupportClipboard);
|
||||
};
|
||||
|
||||
ctrl.clipboardSuccess = function (e, type, aType) {
|
||||
e.clearSelection();
|
||||
$analytics.eventTrack('Copied ' + aType);
|
||||
toastr.info(type + i18nService.valueCopied);
|
||||
};
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
38
src/popup/app/components/views/actionButtons.html
Normal file
38
src/popup/app/components/views/actionButtons.html
Normal file
@@ -0,0 +1,38 @@
|
||||
<div class="action-buttons">
|
||||
<div ng-if="$ctrl.cipher.type === $ctrl.constants.cipherType.login">
|
||||
<span class="btn-list" stop-prop stop-click title="{{$ctrl.i18n.launchWebsite}}" ng-click="$ctrl.launch()"
|
||||
ng-if="$ctrl.cipher.login.uri && !$ctrl.showView">
|
||||
<i class="fa fa-lg fa-share-square-o"></i>
|
||||
</span>
|
||||
<span class="btn-list" ng-click="$ctrl.onView($ctrl.cipher)" stop-prop stop-click title="{{i18n.view}}"
|
||||
ng-if="$ctrl.showView">
|
||||
<i class="fa fa-lg fa-eye"></i>
|
||||
</span>
|
||||
<span class="btn-list" stop-prop stop-click title="{{$ctrl.i18n.copyUsername}}" ngclipboard
|
||||
ngclipboard-error="$ctrl.clipboardError(e)"
|
||||
ngclipboard-success="$ctrl.clipboardSuccess(e, $ctrl.i18n.username, 'Username')"
|
||||
data-clipboard-text="{{$ctrl.cipher.login.username}}" ng-if="$ctrl.cipher.login.username">
|
||||
<i class="fa fa-lg fa-user"></i>
|
||||
</span>
|
||||
<span class="btn-list" stop-prop stop-click title="{{$ctrl.i18n.copyPassword}}" ngclipboard
|
||||
ngclipboard-error="$ctrl.clipboardError(e)"
|
||||
ngclipboard-success="$ctrl.clipboardSuccess(e, $ctrl.i18n.password, 'Password')"
|
||||
data-clipboard-text="{{$ctrl.cipher.login.password}}" ng-if="$ctrl.cipher.login.password">
|
||||
<i class="fa fa-lg fa-key"></i>
|
||||
</span>
|
||||
</div>
|
||||
<div ng-if="$ctrl.cipher.type === $ctrl.constants.cipherType.card">
|
||||
<span class="btn-list" stop-prop stop-click title="{{$ctrl.i18n.copyNumber}}" ngclipboard
|
||||
ngclipboard-error="$ctrl.clipboardError(e)"
|
||||
ngclipboard-success="$ctrl.clipboardSuccess(e, $ctrl.i18n.number, 'Card Number')"
|
||||
data-clipboard-text="{{$ctrl.cipher.card.number}}" ng-if="$ctrl.cipher.card.number">
|
||||
<i class="fa fa-lg fa-hashtag"></i>
|
||||
</span>
|
||||
<span class="btn-list" stop-prop stop-click title="{{$ctrl.i18n.copySecurityCode}}" ngclipboard
|
||||
ngclipboard-error="$ctrl.clipboardError(e)"
|
||||
ngclipboard-success="$ctrl.clipboardSuccess(e, $ctrl.i18n.securityCode, 'Security Code')"
|
||||
data-clipboard-text="{{$ctrl.cipher.card.code}}" ng-if="$ctrl.cipher.card.code">
|
||||
<i class="fa fa-lg fa-key"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user