1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

load add fields with current tab info

This commit is contained in:
Kyle Spearrin 2016-09-14 22:44:04 -04:00
parent 0a201ef887
commit 6bb8b28517
4 changed files with 40 additions and 12 deletions

View File

@ -89,7 +89,7 @@
templateUrl: "app/vault/views/vaultAddSite.html", templateUrl: "app/vault/views/vaultAddSite.html",
controller: 'vaultAddSiteController', controller: 'vaultAddSiteController',
data: { authorize: true }, data: { authorize: true },
params: { animation: null, returnScrollY: 0, returnSearchText: null } params: { animation: null, returnScrollY: 0, returnSearchText: null, name: null, uri: null }
}) })
.state('editSite', { .state('editSite', {
url: "/edit-site?siteId", url: "/edit-site?siteId",

View File

@ -1,13 +1,15 @@
angular angular
.module('bit.current') .module('bit.current')
.controller('currentController', function ($scope, siteService, cipherService, tldjs, toastr, $q, $window) { .controller('currentController', function ($scope, siteService, cipherService, tldjs, toastr, $q, $window, $state) {
var pageDetails = null, var pageDetails = null,
tabId = null; tabId = null,
url = null,
domain = null;
$scope.canAutofill = false; $scope.canAutofill = false;
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var url = null;
if (tabs.length > 0) { if (tabs.length > 0) {
url = tabs[0].url; url = tabs[0].url;
tabId = tabs[0].id; tabId = tabs[0].id;
@ -16,7 +18,7 @@ angular
return; return;
} }
var domain = tldjs.getDomain(url); domain = tldjs.getDomain(url);
$scope.sites = []; $scope.sites = [];
if (!domain) { if (!domain) {
return; return;
@ -85,6 +87,14 @@ angular
}); });
}); });
$scope.addSite = function () {
$state.go('addSite', {
animation: 'in-slide-up',
name: domain,
uri: url
});
};
$scope.fillSite = function (site) { $scope.fillSite = function (site) {
var fillScript = null; var fillScript = null;
if (site && $scope.canAutofill && pageDetails) { if (site && $scope.canAutofill && pageDetails) {

View File

@ -1,4 +1,7 @@
<div class="header"> <div class="header">
<div class="right">
<a href="" ng-click="addSite()"><i class="fa fa-plus fa-lg"></i></a>
</div>
<div class="title">Current Tab Sites</div> <div class="title">Current Tab Sites</div>
</div> </div>
<div class="content content-tabs"> <div class="content content-tabs">

View File

@ -4,12 +4,20 @@
.controller('vaultAddSiteController', function ($scope, $state, $stateParams, siteService, folderService, cipherService, $q) { .controller('vaultAddSiteController', function ($scope, $state, $stateParams, siteService, folderService, cipherService, $q) {
var returnScrollY = $stateParams.returnScrollY; var returnScrollY = $stateParams.returnScrollY;
var returnSearchText = $stateParams.returnSearchText; var returnSearchText = $stateParams.returnSearchText;
var fromCurrent = $stateParams.uri !== null;
$scope.site = { $scope.site = {
folderId: null folderId: null,
name: $stateParams.name,
uri: $stateParams.uri
}; };
$('#name').focus(); if ($scope.site.name && $scope.site.uri) {
$('#username').focus();
}
else {
$('#name').focus();
}
popupUtils.initListSectionItemListeners(); popupUtils.initListSectionItemListeners();
var promises = []; var promises = [];
@ -50,11 +58,18 @@
}; };
$scope.close = function () { $scope.close = function () {
$state.go('tabs.vault', { if (fromCurrent) {
animation: 'out-slide-down', $state.go('tabs.current', {
scrollY: returnScrollY || 0, animation: 'out-slide-down'
searchText: returnSearchText });
}); }
else {
$state.go('tabs.vault', {
animation: 'out-slide-down',
scrollY: returnScrollY || 0,
searchText: returnSearchText
});
}
}; };
function saveSite(site) { function saveSite(site) {