safari api implementations. hide popout

This commit is contained in:
Kyle Spearrin 2018-01-12 20:57:25 -05:00
parent 4fc21767be
commit 7467c220e1
11 changed files with 33 additions and 13 deletions

View File

@ -129,17 +129,24 @@ class BrowserApi {
if (BrowserApi.isChromeApi) {
return chrome.extension.getViews({ type: 'popup' }).length > 0;
} else if (BrowserApi.isSafariApi) {
return true; // TODO
return safari.extension.popovers && safari.extension.popovers.length &&
safari.extension.popovers[0].visible;
} else {
return null;
}
}
static createNewTab(url: string): void {
static createNewTab(url: string, extensionPage: boolean = false): void {
if (BrowserApi.isChromeApi) {
chrome.tabs.create({ url: url });
} else if (BrowserApi.isSafariApi) {
return; // TODO
if (extensionPage && url.indexOf('/') === 0) {
url = BrowserApi.getAssetUrl(url);
}
const tab = safari.application.activeBrowserWindow.browserWindow.openTab();
if (tab) {
tab.url = url;
}
} else {
return;
}
@ -149,7 +156,10 @@ class BrowserApi {
if (BrowserApi.isChromeApi) {
return chrome.extension.getURL(path);
} else if (BrowserApi.isSafariApi) {
return './' + path; // TODO?
if (path.indexOf('/') === 0) {
path = path.substr(1);
}
return safari.extension.baseURI + path;
} else {
return null;
}

View File

@ -183,8 +183,9 @@ angular
params = providers[constants.twoFactorProvider.email];
$scope.twoFactorEmail = params.Email;
if (BrowserApi.isPopupOpen() && !popupUtilsService.inSidebar($window) &&
!popupUtilsService.inTab($window) && !popupUtilsService.inPopout($window)) {
if (!platformUtilsService.isSafari() && BrowserApi.isPopupOpen() &&
!popupUtilsService.inSidebar($window) && !popupUtilsService.inTab($window) &&
!popupUtilsService.inPopout($window)) {
SweetAlert.swal({
title: i18nService.twoStepLogin,
text: i18nService.popup2faCloseMessage,
@ -193,7 +194,7 @@ angular
cancelButtonText: i18nService.no
}, function (confirmed) {
if (confirmed) {
BrowserApi.createNewTab('/popup/index.html?uilocation=tab#!/login');
BrowserApi.createNewTab('/popup/index.html?uilocation=tab#!/login', true);
return;
}
else if (Object.keys(providers).length > 1) {

View File

@ -1,5 +1,7 @@
import * as template from './pop-out.component.html';
import { BrowserApi } from '../../../browser/browserApi';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import PopupUtilsService from '../services/popupUtils.service';
@ -52,7 +54,7 @@ export class PopOutController implements ng.IController {
url: href,
});
} else if ((typeof safari !== 'undefined')) {
// TODO?
// Safari can't open popup in full page tab :(
}
}
}

View File

@ -1,5 +1,5 @@
<div class="header header-search">
<pop-out ng-if="!$ctrl.inSidebar" class="left"></pop-out>
<pop-out ng-if="$ctrl.showPopout" class="left"></pop-out>
<div class="left" ng-if="$ctrl.inSidebar">
<a href="" ng-click="$ctrl.refresh()" title="{{::$ctrl.i18n.refresh}}"><i class="fa fa-refresh fa-lg"></i></a>
</div>

View File

@ -24,6 +24,7 @@ export class CurrentController {
canAutofill: boolean = false;
searchText: string = null;
inSidebar: boolean = false;
showPopout: boolean = true;
disableSearch: boolean = false;
constructor($scope: any, private cipherService: CipherService, private platformUtilsService: PlatformUtilsService,
@ -32,6 +33,7 @@ export class CurrentController {
private $analytics: any, private i18nService: any, private $filter: ng.IFilterService) {
this.i18n = i18nService;
this.inSidebar = PopupUtilsService.inSidebar($window);
this.showPopout = !this.inSidebar && !platformUtilsService.isSafari();
this.disableSearch = platformUtilsService.isEdge();
$scope.$on('syncCompleted', (event: any, successfully: boolean) => {

View File

@ -1,5 +1,5 @@
<div class="header">
<pop-out class="left"></pop-out>
<pop-out ng-if="$ctrl.showPopout" class="left"></pop-out>
<div class="title">{{$ctrl.i18n.settings}}</div>
</div>
<div class="content content-tabs">

View File

@ -27,13 +27,14 @@ const RateUrls = {
[DeviceType.Vivaldi]:
'https://chrome.google.com/webstore/detail/bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb/reviews',
[DeviceType.Safari]:
'https://itunes.com', // TODO
'https://itunes.apple.com/app/bitwarden-password-manager/id1137397744',
};
export class SettingsController {
lockOption = '';
i18n: any;
showOnLocked: boolean;
showPopout: boolean = true;
constructor(private $state: any, private SweetAlert: any,
private platformUtilsService: PlatformUtilsService, private $analytics: any,
@ -42,6 +43,7 @@ export class SettingsController {
private storageService: StorageService, public messagingService: MessagingService,
private $timeout: ng.ITimeoutService) {
this.i18n = i18nService;
this.showPopout = !platformUtilsService.isSafari();
$timeout(() => {
PopupUtilsService.initListSectionItemListeners(document, angular);

View File

@ -1,5 +1,5 @@
<div class="header">
<pop-out class="left"></pop-out>
<pop-out ng-if="$ctrl.showPopout" class="left"></pop-out>
<div class="title">{{$ctrl.i18n.tools}}</div>
</div>
<div class="content content-tabs">

View File

@ -7,6 +7,7 @@ import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
export class ToolsController {
showExport: boolean;
showPopout: boolean = true;
i18n: any;
private webVaultBaseUrl: string = 'https://vault.bitwarden.com';
@ -15,6 +16,7 @@ export class ToolsController {
private environmentService: EnvironmentService) {
this.i18n = i18nService;
this.showExport = !platformUtilsService.isEdge();
this.showPopout = !platformUtilsService.isSafari();
if (environmentService.baseUrl) {
this.webVaultBaseUrl = environmentService.baseUrl;
} else if (environmentService.webVaultUrl) {

View File

@ -10,6 +10,7 @@ angular
$scope.i18n = i18nService;
$scope.showGroupingCounts = !platformUtilsService.isEdge();
$scope.disableSearch = platformUtilsService.isEdge();
$scope.showPopout = !platformUtilsService.isSafari();
document.getElementById('search').focus();
var syncOnLoad = $stateParams.syncOnLoad;

View File

@ -1,5 +1,5 @@
<div class="header header-search">
<pop-out class="left"></pop-out>
<pop-out ng-if="showPopout" class="left"></pop-out>
<div class="search" ng-style="{'visibility': disableSearch ? 'hidden' : 'visible'}">
<input type="search" placeholder="{{::i18n.searchVault}}" id="search" ng-model="searchText" />
<i class="fa fa-search"></i>