moved popup utils to utilsService
This commit is contained in:
parent
107c480913
commit
a59f7a4afc
|
@ -1,10 +1,10 @@
|
|||
angular
|
||||
.module('bit.accounts')
|
||||
|
||||
.controller('accountsHintController', function ($scope, $state, apiService, toastr, $q) {
|
||||
.controller('accountsHintController', function ($scope, $state, apiService, toastr, $q, utilsService) {
|
||||
$scope.model = {};
|
||||
|
||||
popupUtils.initListSectionItemListeners();
|
||||
utilsService.initListSectionItemListeners($(document));
|
||||
$('#email').focus();
|
||||
|
||||
$scope.submitPromise = null;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
angular
|
||||
.module('bit.accounts')
|
||||
|
||||
.controller('accountsLoginController', function ($scope, $state, $stateParams, loginService, userService, toastr) {
|
||||
popupUtils.initListSectionItemListeners();
|
||||
.controller('accountsLoginController', function ($scope, $state, $stateParams, loginService, userService, toastr,
|
||||
utilsService) {
|
||||
utilsService.initListSectionItemListeners($(document));
|
||||
|
||||
if ($stateParams.email) {
|
||||
$('#master-password').focus();
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
angular
|
||||
.module('bit.accounts')
|
||||
|
||||
.controller('accountsLoginTwoFactorController', function ($scope, $state, loginService, toastr) {
|
||||
.controller('accountsLoginTwoFactorController', function ($scope, $state, loginService, toastr, utilsService) {
|
||||
$scope.model = {};
|
||||
popupUtils.initListSectionItemListeners();
|
||||
utilsService.initListSectionItemListeners($(document));
|
||||
$('#code').focus();
|
||||
|
||||
$scope.loginPromise = null;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
angular
|
||||
.module('bit.accounts')
|
||||
|
||||
.controller('accountsRegisterController', function ($scope, $state, cryptoService, toastr, $q, apiService) {
|
||||
.controller('accountsRegisterController', function ($scope, $state, cryptoService, toastr, $q, apiService, utilsService) {
|
||||
$scope.model = {};
|
||||
popupUtils.initListSectionItemListeners();
|
||||
utilsService.initListSectionItemListeners($(document));
|
||||
$('#email').focus();
|
||||
|
||||
$scope.submitPromise = null;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
angular
|
||||
.module('bit.settings')
|
||||
|
||||
.controller('settingsAddFolderController', function ($scope, $q, folderService, $state, toastr) {
|
||||
.controller('settingsAddFolderController', function ($scope, $q, folderService, $state, toastr, utilsService) {
|
||||
$scope.folder = {};
|
||||
popupUtils.initListSectionItemListeners();
|
||||
utilsService.initListSectionItemListeners($(document));
|
||||
$('#name').focus();
|
||||
|
||||
$scope.savePromise = null;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
angular
|
||||
.module('bit.settings')
|
||||
|
||||
.controller('settingsEditFolderController', function ($scope, $stateParams, folderService, toastr, $q, $state, SweetAlert) {
|
||||
.controller('settingsEditFolderController', function ($scope, $stateParams, folderService, toastr, $q, $state, SweetAlert,
|
||||
utilsService) {
|
||||
$scope.folder = {};
|
||||
var folderId = $stateParams.folderId;
|
||||
|
||||
|
@ -11,7 +12,7 @@
|
|||
});
|
||||
});
|
||||
|
||||
popupUtils.initListSectionItemListeners();
|
||||
utilsService.initListSectionItemListeners($(document));
|
||||
|
||||
$scope.savePromise = null;
|
||||
$scope.save = function (model) {
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
.module('bit.tools')
|
||||
|
||||
.controller('toolsPasswordGeneratorController', function ($scope, $state, $stateParams, passwordGenerationService,
|
||||
toastr, $q) {
|
||||
toastr, $q, utilsService) {
|
||||
var addState = $stateParams.addState,
|
||||
editState = $stateParams.editState;
|
||||
|
||||
$scope.showSelect = $stateParams.addState || $stateParams.editState;
|
||||
|
||||
popupUtils.initListSectionItemListeners();
|
||||
utilsService.initListSectionItemListeners($(document));
|
||||
$scope.password = '-';
|
||||
|
||||
$scope.slider = {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
.module('bit.vault')
|
||||
|
||||
.controller('vaultAddSiteController', function ($scope, $state, $stateParams, siteService, folderService,
|
||||
cryptoService, $q, toastr) {
|
||||
cryptoService, $q, toastr, utilsService) {
|
||||
var returnScrollY = $stateParams.returnScrollY;
|
||||
var returnSearchText = $stateParams.returnSearchText;
|
||||
var fromCurrent = $stateParams.fromCurrent || $stateParams.uri !== null;
|
||||
|
@ -23,7 +23,7 @@
|
|||
else {
|
||||
$('#name').focus();
|
||||
}
|
||||
popupUtils.initListSectionItemListeners();
|
||||
utilsService.initListSectionItemListeners($(document));
|
||||
|
||||
$q.when(folderService.getAllDecrypted()).then(function (folders) {
|
||||
$scope.folders = folders;
|
||||
|
|
|
@ -2,7 +2,7 @@ angular
|
|||
.module('bit.vault')
|
||||
|
||||
.controller('vaultEditSiteController', function ($scope, $state, $stateParams, siteService, folderService,
|
||||
cryptoService, $q, toastr, SweetAlert) {
|
||||
cryptoService, $q, toastr, SweetAlert, utilsService) {
|
||||
var returnScrollY = $stateParams.returnScrollY;
|
||||
var returnSearchText = $stateParams.returnSearchText;
|
||||
var siteId = $stateParams.siteId;
|
||||
|
@ -27,7 +27,7 @@ angular
|
|||
$scope.folders = folders;
|
||||
});
|
||||
|
||||
popupUtils.initListSectionItemListeners();
|
||||
utilsService.initListSectionItemListeners($(document));
|
||||
|
||||
$scope.savePromise = null;
|
||||
$scope.save = function (model) {
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
|
||||
<script src="../lib/jquery/jquery.js"></script>
|
||||
<script src="../lib/bootstrap/js/bootstrap.js"></script>
|
||||
|
||||
<script src="scripts/popup.js"></script>
|
||||
<script src="../lib/clipboard/clipboard.js"></script>
|
||||
|
||||
<script src="../lib/angular/angular.js"></script>
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
var popupUtils = function () {
|
||||
var self = this;
|
||||
|
||||
self.initListSectionItemListeners = function () {
|
||||
$('.list-section-item').click(function (e) {
|
||||
var text = $(this).find('input, textarea').not('input[type="checkbox"], input[type="radio"], input[type="hidden"]');
|
||||
var checkbox = $(this).find('input[type="checkbox"]');
|
||||
var select = $(this).find('select');
|
||||
|
||||
if (text.length > 0 && e.target === text[0]) {
|
||||
return;
|
||||
}
|
||||
if (checkbox.length > 0 && e.target === checkbox[0]) {
|
||||
return;
|
||||
}
|
||||
if (select.length > 0 && e.target === select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if (text.length > 0) {
|
||||
text.focus();
|
||||
}
|
||||
else if (checkbox.length > 0) {
|
||||
checkbox.prop('checked', !checkbox.is(':checked'));
|
||||
if (angular) {
|
||||
angular.element(checkbox[0]).triggerHandler('click');
|
||||
}
|
||||
}
|
||||
else if (select.length > 0) {
|
||||
select.focus();
|
||||
}
|
||||
});
|
||||
|
||||
$('.list-section-item input, .list-section-item select, .list-section-item textarea').focus(function (e) {
|
||||
$(this).parent().addClass('active');
|
||||
}).blur(function (e) {
|
||||
$(this).parent().removeClass('active');
|
||||
});
|
||||
}
|
||||
|
||||
return self;
|
||||
}();
|
|
@ -41,4 +41,48 @@ function initUtilsService() {
|
|||
UtilsService.prototype.isOpera = function () {
|
||||
return this.getBrowser() === 'opera';
|
||||
}
|
||||
|
||||
UtilsService.prototype.initListSectionItemListeners = function (doc) {
|
||||
if (!doc) {
|
||||
throw 'doc parameter required';
|
||||
}
|
||||
|
||||
doc.on('click', '.list-section-item', function (e) {
|
||||
var text = $(this).find('input, textarea').not('input[type="checkbox"], input[type="radio"], input[type="hidden"]');
|
||||
var checkbox = $(this).find('input[type="checkbox"]');
|
||||
var select = $(this).find('select');
|
||||
|
||||
if (text.length > 0 && e.target === text[0]) {
|
||||
return;
|
||||
}
|
||||
if (checkbox.length > 0 && e.target === checkbox[0]) {
|
||||
return;
|
||||
}
|
||||
if (select.length > 0 && e.target === select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if (text.length > 0) {
|
||||
text.focus();
|
||||
}
|
||||
else if (checkbox.length > 0) {
|
||||
checkbox.prop('checked', !checkbox.is(':checked'));
|
||||
if (angular) {
|
||||
angular.element(checkbox[0]).triggerHandler('click');
|
||||
}
|
||||
}
|
||||
else if (select.length > 0) {
|
||||
select.focus();
|
||||
}
|
||||
});
|
||||
|
||||
doc.on('focus', '.list-section-item input, .list-section-item select, .list-section-item textarea', function (e) {
|
||||
$(this).parent().addClass('active');
|
||||
});
|
||||
doc.on('blur', '.list-section-item input, .list-section-item select, .list-section-item textarea', function (e) {
|
||||
$(this).parent().removeClass('active');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue