From 947e51f3b5f3358036f4c4faf98dbb0f7de23f9e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 14 Nov 2017 10:04:23 -0500 Subject: [PATCH] pop out component --- src/popup/app/components/components.module.ts | 2 + .../app/components/pop-out.component.html | 1 + src/popup/app/components/pop-out.component.ts | 56 +++++++++++++++++++ src/popup/app/current/views/current.html | 2 +- src/popup/app/global/mainController.js | 42 -------------- src/popup/app/settings/views/settings.html | 2 +- src/popup/app/tools/tools.component.html | 2 +- src/popup/app/vault/views/vault.html | 2 +- 8 files changed, 63 insertions(+), 46 deletions(-) create mode 100644 src/popup/app/components/pop-out.component.html create mode 100644 src/popup/app/components/pop-out.component.ts diff --git a/src/popup/app/components/components.module.ts b/src/popup/app/components/components.module.ts index a613d2bd..3505c2b5 100644 --- a/src/popup/app/components/components.module.ts +++ b/src/popup/app/components/components.module.ts @@ -2,10 +2,12 @@ import * as angular from 'angular'; import { ActionButtonsComponent } from './action-buttons.component'; import { CipherItemsComponent } from './cipher-items.component'; import { IconComponent } from './icon.component'; +import { PopOutComponent } from './pop-out.component'; export default angular .module('bit.components', []) .component('cipherItems', CipherItemsComponent) .component('icon', IconComponent) .component('actionButtons', ActionButtonsComponent) + .component('popOut', PopOutComponent) .name; diff --git a/src/popup/app/components/pop-out.component.html b/src/popup/app/components/pop-out.component.html new file mode 100644 index 00000000..1da31f8b --- /dev/null +++ b/src/popup/app/components/pop-out.component.html @@ -0,0 +1 @@ + diff --git a/src/popup/app/components/pop-out.component.ts b/src/popup/app/components/pop-out.component.ts new file mode 100644 index 00000000..af20b2e5 --- /dev/null +++ b/src/popup/app/components/pop-out.component.ts @@ -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, +}; diff --git a/src/popup/app/current/views/current.html b/src/popup/app/current/views/current.html index ce0f687f..0a00dd65 100644 --- a/src/popup/app/current/views/current.html +++ b/src/popup/app/current/views/current.html @@ -1,6 +1,6 @@