From 6bb8b285172222517430b184ca71b1a813888936 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 14 Sep 2016 22:44:04 -0400 Subject: [PATCH] load add fields with current tab info --- src/popup/app/config.js | 2 +- src/popup/app/current/currentController.js | 18 +++++++++--- src/popup/app/current/views/current.html | 3 ++ src/popup/app/vault/vaultAddSiteController.js | 29 ++++++++++++++----- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/popup/app/config.js b/src/popup/app/config.js index 4948dddbee..0a3e36c79a 100644 --- a/src/popup/app/config.js +++ b/src/popup/app/config.js @@ -89,7 +89,7 @@ templateUrl: "app/vault/views/vaultAddSite.html", controller: 'vaultAddSiteController', data: { authorize: true }, - params: { animation: null, returnScrollY: 0, returnSearchText: null } + params: { animation: null, returnScrollY: 0, returnSearchText: null, name: null, uri: null } }) .state('editSite', { url: "/edit-site?siteId", diff --git a/src/popup/app/current/currentController.js b/src/popup/app/current/currentController.js index 6bf8fc179b..7dd0c89108 100644 --- a/src/popup/app/current/currentController.js +++ b/src/popup/app/current/currentController.js @@ -1,13 +1,15 @@ angular .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, - tabId = null; + tabId = null, + url = null, + domain = null; + $scope.canAutofill = false; chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { - var url = null; if (tabs.length > 0) { url = tabs[0].url; tabId = tabs[0].id; @@ -16,7 +18,7 @@ angular return; } - var domain = tldjs.getDomain(url); + domain = tldjs.getDomain(url); $scope.sites = []; if (!domain) { return; @@ -85,6 +87,14 @@ angular }); }); + $scope.addSite = function () { + $state.go('addSite', { + animation: 'in-slide-up', + name: domain, + uri: url + }); + }; + $scope.fillSite = function (site) { var fillScript = null; if (site && $scope.canAutofill && pageDetails) { diff --git a/src/popup/app/current/views/current.html b/src/popup/app/current/views/current.html index d85b154ab8..0e52c536a0 100644 --- a/src/popup/app/current/views/current.html +++ b/src/popup/app/current/views/current.html @@ -1,4 +1,7 @@ 
+
+ +
Current Tab Sites
diff --git a/src/popup/app/vault/vaultAddSiteController.js b/src/popup/app/vault/vaultAddSiteController.js index f6cc1da9b6..7547b66984 100644 --- a/src/popup/app/vault/vaultAddSiteController.js +++ b/src/popup/app/vault/vaultAddSiteController.js @@ -4,12 +4,20 @@ .controller('vaultAddSiteController', function ($scope, $state, $stateParams, siteService, folderService, cipherService, $q) { var returnScrollY = $stateParams.returnScrollY; var returnSearchText = $stateParams.returnSearchText; + var fromCurrent = $stateParams.uri !== null; $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(); var promises = []; @@ -50,11 +58,18 @@ }; $scope.close = function () { - $state.go('tabs.vault', { - animation: 'out-slide-down', - scrollY: returnScrollY || 0, - searchText: returnSearchText - }); + if (fromCurrent) { + $state.go('tabs.current', { + animation: 'out-slide-down' + }); + } + else { + $state.go('tabs.vault', { + animation: 'out-slide-down', + scrollY: returnScrollY || 0, + searchText: returnSearchText + }); + } }; function saveSite(site) {