mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
pop out component
This commit is contained in:
56
src/popup/app/components/pop-out.component.ts
Normal file
56
src/popup/app/components/pop-out.component.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import * as template from './pop-out.component.html';
|
||||
|
||||
import { UtilsService } from '../../../services/abstractions/utils.service';
|
||||
|
||||
class PopOutController implements ng.IController {
|
||||
constructor(private $analytics: any, private $window: any, private utilsService: UtilsService) {
|
||||
}
|
||||
|
||||
expand() {
|
||||
this.$analytics.eventTrack('Expand Vault');
|
||||
|
||||
let href = this.$window.location.href;
|
||||
if (this.utilsService.isEdge()) {
|
||||
const popupIndex = href.indexOf('/popup/');
|
||||
if (popupIndex > -1) {
|
||||
href = href.substring(popupIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (chrome.windows.create) {
|
||||
if (href.indexOf('?uilocation=') > -1) {
|
||||
href = href.replace('uilocation=popup', 'uilocation=popout')
|
||||
.replace('uilocation=tab', 'uilocation=popout')
|
||||
.replace('uilocation=sidebar', 'uilocation=popout');
|
||||
} else {
|
||||
const hrefParts = href.split('#');
|
||||
href = hrefParts[0] + '?uilocation=popout' + (hrefParts.length > 0 ? '#' + hrefParts[1] : '');
|
||||
}
|
||||
|
||||
const bodyRect = document.querySelector('body').getBoundingClientRect();
|
||||
chrome.windows.create({
|
||||
url: href,
|
||||
type: 'popup',
|
||||
width: bodyRect.width + 60,
|
||||
height: bodyRect.height,
|
||||
});
|
||||
|
||||
if (this.utilsService.inPopup(this.$window)) {
|
||||
this.$window.close();
|
||||
}
|
||||
} else {
|
||||
href = href.replace('uilocation=popup', 'uilocation=tab')
|
||||
.replace('uilocation=popout', 'uilocation=tab')
|
||||
.replace('uilocation=sidebar', 'uilocation=tab');
|
||||
chrome.tabs.create({
|
||||
url: href,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const PopOutComponent = {
|
||||
bindings: {},
|
||||
controller: PopOutController,
|
||||
template,
|
||||
};
|
||||
Reference in New Issue
Block a user