From 7c3fec98d173c8a99aa9e8203586539c37f7cb64 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 9 Nov 2017 21:58:22 -0500 Subject: [PATCH] remove all jquery dependencies from popup --- .../app/accounts/accountsLoginTwoFactorController.js | 11 ++++++++--- src/popup/app/app.js | 2 -- src/popup/app/current/currentController.js | 2 +- src/popup/app/directives/fallbackSrcDirective.js | 7 +++---- src/popup/app/directives/stopClickDirective.js | 6 +++--- src/popup/app/directives/stopPropDirective.js | 8 ++++---- src/popup/app/global/mainController.js | 5 +++-- src/popup/app/tools/toolsExportController.js | 3 +-- src/popup/app/vault/vaultController.js | 2 +- src/popup/app/vault/vaultViewFolderController.js | 4 ++-- 10 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/popup/app/accounts/accountsLoginTwoFactorController.js b/src/popup/app/accounts/accountsLoginTwoFactorController.js index 96468c9133..7b04270d0b 100644 --- a/src/popup/app/accounts/accountsLoginTwoFactorController.js +++ b/src/popup/app/accounts/accountsLoginTwoFactorController.js @@ -146,7 +146,10 @@ angular u2f.cleanup(); $timeout(function () { - $('#code').focus(); + var codeInput = document.getElementById('code'); + if (codeInput) { + codeInput.focus(); + } var params; if ($scope.providerType === constants.twoFactorProvider.duo) { @@ -156,8 +159,10 @@ angular host: params.Host, sig_request: params.Signature, submit_callback: function (theForm) { - var response = $(theForm).find('input[name="sig_response"]').val(); - $scope.login(response); + var sigElement = theForm.querySelector('input[name="sig_response"]'); + if (sigElement) { + $scope.login(sigElement.value); + } } }); } diff --git a/src/popup/app/app.js b/src/popup/app/app.js index eb26f150ed..bdc80a696b 100644 --- a/src/popup/app/app.js +++ b/src/popup/app/app.js @@ -1,5 +1,3 @@ -window.$ = window.jQuery = require('jquery'); -require('bootstrap'); require('papaparse'); require('clipboard'); diff --git a/src/popup/app/current/currentController.js b/src/popup/app/current/currentController.js index cb1ece865f..e7f3dfff55 100644 --- a/src/popup/app/current/currentController.js +++ b/src/popup/app/current/currentController.js @@ -14,7 +14,7 @@ angular $scope.otherCiphers = []; $scope.loaded = false; $scope.searchText = null; - $('#search').focus(); + document.getElementById('search').focus(); $scope.$on('$viewContentLoaded', function () { $timeout(loadVault, 100); diff --git a/src/popup/app/directives/fallbackSrcDirective.js b/src/popup/app/directives/fallbackSrcDirective.js index ac93c19145..83cb78537b 100644 --- a/src/popup/app/directives/fallbackSrcDirective.js +++ b/src/popup/app/directives/fallbackSrcDirective.js @@ -1,11 +1,10 @@ -angular +angular .module('bit.directives') .directive('fallbackSrc', function () { return function (scope, element, attrs) { - var el = $(element); - el.bind('error', function (event) { - el.attr('src', attrs.fallbackSrc); + element[0].addEventListener('error', function (e) { + e.target.src = attrs.fallbackSrc; }); }; }); diff --git a/src/popup/app/directives/stopClickDirective.js b/src/popup/app/directives/stopClickDirective.js index d199828541..e6e07d4737 100644 --- a/src/popup/app/directives/stopClickDirective.js +++ b/src/popup/app/directives/stopClickDirective.js @@ -1,11 +1,11 @@ -angular +angular .module('bit.directives') // ref: https://stackoverflow.com/a/14165848/1090359 .directive('stopClick', function () { return function (scope, element, attrs) { - $(element).click(function (event) { - event.preventDefault(); + element[0].addEventListener('click', function (e) { + e.preventDefault(); }); }; }); diff --git a/src/popup/app/directives/stopPropDirective.js b/src/popup/app/directives/stopPropDirective.js index 9dc5eb0233..42c6b75b64 100644 --- a/src/popup/app/directives/stopPropDirective.js +++ b/src/popup/app/directives/stopPropDirective.js @@ -1,10 +1,10 @@ -angular +angular .module('bit.directives') .directive('stopProp', function () { return function (scope, element, attrs) { - $(element).click(function (event) { - event.stopPropagation(); + element[0].addEventListener('click', function (e) { + e.stopPropagation(); }); }; - }); \ No newline at end of file + }); diff --git a/src/popup/app/global/mainController.js b/src/popup/app/global/mainController.js index b222448a4f..eead3f0ca8 100644 --- a/src/popup/app/global/mainController.js +++ b/src/popup/app/global/mainController.js @@ -43,11 +43,12 @@ angular href = hrefParts[0] + '?uilocation=popout' + (hrefParts.length > 0 ? '#' + hrefParts[1] : ''); } + var bodyRect = document.querySelector('body').getBoundingClientRect(); chrome.windows.create({ url: href, type: 'popup', - width: $('body').width() + 60, - height: $('body').height() + width: bodyRect.width + 60, + height: bodyRect.height }); if (utilsService.inPopup($window)) { diff --git a/src/popup/app/tools/toolsExportController.js b/src/popup/app/tools/toolsExportController.js index 5a366596ec..ebe36beec4 100644 --- a/src/popup/app/tools/toolsExportController.js +++ b/src/popup/app/tools/toolsExportController.js @@ -4,8 +4,7 @@ angular .controller('toolsExportController', function ($scope, $state, toastr, $q, $analytics, i18nService, cryptoService, userService, folderService, cipherService, $window, constantsService) { $scope.i18n = i18nService; - - $('#master-password').focus(); + document.getElementById('master-password').focus(); $scope.submitPromise = null; $scope.submit = function () { diff --git a/src/popup/app/vault/vaultController.js b/src/popup/app/vault/vaultController.js index 267520fdb1..8d62c9e4ef 100644 --- a/src/popup/app/vault/vaultController.js +++ b/src/popup/app/vault/vaultController.js @@ -9,7 +9,7 @@ angular $scope.i18n = i18nService; $scope.showFolderCounts = !utilsService.isEdge(); $scope.showOnlyFolderView = utilsService.isEdge(); - $('#search').focus(); + document.getElementById('search').focus(); var syncOnLoad = $stateParams.syncOnLoad; if (syncOnLoad) { diff --git a/src/popup/app/vault/vaultViewFolderController.js b/src/popup/app/vault/vaultViewFolderController.js index b09e135c1e..9221e5aab3 100644 --- a/src/popup/app/vault/vaultViewFolderController.js +++ b/src/popup/app/vault/vaultViewFolderController.js @@ -1,4 +1,4 @@ -angular +angular .module('bit.vault') .controller('vaultViewFolderController', function ($scope, cipherService, folderService, $q, $state, $stateParams, toastr, @@ -17,7 +17,7 @@ name: i18nService.noneFolder }; $scope.i18n = i18nService; - $('#search').focus(); + document.getElementById('search').focus(); $scope.loaded = false; $scope.vaultCiphers = [];