2015-12-09 04:35:05 +01:00
|
|
|
angular
|
|
|
|
.module('bit.global')
|
|
|
|
|
|
|
|
.controller('mainController', function ($scope, $state, authService, appSettings, toastr) {
|
|
|
|
var vm = this;
|
|
|
|
vm.bodyClass = '';
|
|
|
|
vm.searchVaultText = null;
|
|
|
|
vm.version = appSettings.version;
|
|
|
|
|
|
|
|
$scope.currentYear = new Date().getFullYear();
|
|
|
|
|
|
|
|
$scope.$on('$viewContentLoaded', function () {
|
2017-03-25 15:43:19 +01:00
|
|
|
authService.getUserProfile().then(function (profile) {
|
|
|
|
vm.userProfile = profile;
|
|
|
|
});
|
2017-03-07 06:36:27 +01:00
|
|
|
|
2015-12-09 04:35:05 +01:00
|
|
|
if ($.AdminLTE) {
|
|
|
|
if ($.AdminLTE.layout) {
|
|
|
|
$.AdminLTE.layout.fix();
|
|
|
|
$.AdminLTE.layout.fixSidebar();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($.AdminLTE.pushMenu) {
|
|
|
|
$.AdminLTE.pushMenu.expandOnHover();
|
|
|
|
}
|
2017-02-23 06:45:54 +01:00
|
|
|
|
|
|
|
$(document).off('click', '.sidebar li a');
|
2015-12-09 04:35:05 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
|
|
|
|
vm.searchVaultText = null;
|
|
|
|
|
|
|
|
if (toState.data.bodyClass) {
|
|
|
|
vm.bodyClass = toState.data.bodyClass;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
vm.bodyClass = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.searchVault = function () {
|
2017-03-02 04:47:24 +01:00
|
|
|
$state.go('backend.user.vault');
|
2015-12-09 04:35:05 +01:00
|
|
|
};
|
|
|
|
|
2017-01-03 04:26:32 +01:00
|
|
|
$scope.addLogin = function () {
|
|
|
|
$scope.$broadcast('vaultAddLogin');
|
2015-12-09 04:35:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.addFolder = function () {
|
|
|
|
$scope.$broadcast('vaultAddFolder');
|
|
|
|
};
|
2017-04-15 04:49:51 +02:00
|
|
|
|
|
|
|
// Append dropdown menus to body
|
|
|
|
var bodyScrollbarWidth;
|
|
|
|
var bodyDropdownMenu;
|
|
|
|
var dropdownHelpers = {
|
|
|
|
scrollParent: function (elem, includeHidden, includeSelf) {
|
|
|
|
var overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
|
|
|
|
var documentEl = $(document).documentElement;
|
|
|
|
var elemStyle = window.getComputedStyle(elem);
|
|
|
|
|
|
|
|
if (includeSelf && overflowRegex.test(elemStyle.overflow + elemStyle.overflowY + elemStyle.overflowX)) {
|
|
|
|
return elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
var excludeStatic = elemStyle.position === 'absolute';
|
|
|
|
var scrollParent = elem.parentElement || documentEl;
|
|
|
|
|
|
|
|
if (scrollParent === documentEl || elemStyle.position === 'fixed') {
|
|
|
|
return documentEl;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (scrollParent.parentElement && scrollParent !== documentEl) {
|
|
|
|
var spStyle = window.getComputedStyle(scrollParent);
|
|
|
|
if (excludeStatic && spStyle.position !== 'static') {
|
|
|
|
excludeStatic = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!excludeStatic && overflowRegex.test(spStyle.overflow + spStyle.overflowY + spStyle.overflowX)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
scrollParent = scrollParent.parentElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
return scrollParent;
|
|
|
|
},
|
|
|
|
scrollbarWidth: function () {
|
|
|
|
if (!bodyScrollbarWidth) {
|
|
|
|
var bodyElem = $('body');
|
|
|
|
bodyElem.addClass('bit-position-body-scrollbar-measure');
|
|
|
|
bodyScrollbarWidth = window.innerWidth - bodyElem[0].clientWidth;
|
|
|
|
bodyScrollbarWidth = isFinite(bodyScrollbarWidth) ? bodyScrollbarWidth : 0;
|
|
|
|
bodyElem.removeClass('bit-position-body-scrollbar-measure');
|
|
|
|
}
|
|
|
|
|
|
|
|
return bodyScrollbarWidth;
|
|
|
|
},
|
|
|
|
scrollbarPadding: function (elem) {
|
|
|
|
elem = elem[0];
|
|
|
|
var scrollParent = dropdownHelpers.scrollParent(elem, false, true);
|
|
|
|
var scrollbarWidth = dropdownHelpers.scrollbarWidth();
|
|
|
|
|
|
|
|
return {
|
|
|
|
scrollbarWidth: scrollbarWidth,
|
|
|
|
widthOverflow: scrollParent.scrollWidth > scrollParent.clientWidth,
|
|
|
|
heightOverflow: scrollParent.scrollHeight > scrollParent.clientHeight
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$('.dropdown-menu-body').on('show.bs.dropdown', function (e) {
|
|
|
|
bodyScrollbarWidth = $(e.target).find('.dropdown-menu');
|
|
|
|
var body = $('body');
|
|
|
|
body.append(bodyScrollbarWidth.detach());
|
|
|
|
|
|
|
|
var eOffset = $(e.target).offset();
|
|
|
|
var css = {
|
|
|
|
display: 'block',
|
|
|
|
top: eOffset.top + $(e.target).outerHeight()
|
|
|
|
};
|
|
|
|
|
|
|
|
if (bodyScrollbarWidth.hasClass('dropdown-menu-right')) {
|
|
|
|
var scrollbarPadding = dropdownHelpers.scrollbarPadding(body);
|
|
|
|
var scrollbarWidth = 0;
|
|
|
|
if (scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {
|
|
|
|
scrollbarWidth = scrollbarPadding.scrollbarWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
css.right = window.innerWidth - scrollbarWidth -
|
|
|
|
(eOffset.left + $(e.target).prop('offsetWidth')) + 'px';
|
|
|
|
css.left = 'auto';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
css.left = eOffset.left + 'px';
|
|
|
|
css.right = 'auto';
|
|
|
|
}
|
|
|
|
|
|
|
|
bodyScrollbarWidth.css(css);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.dropdown-menu-body').on('hide.bs.dropdown', function (e) {
|
|
|
|
$(e.target).append(bodyScrollbarWidth.detach());
|
|
|
|
bodyScrollbarWidth.hide();
|
|
|
|
});
|
2015-12-09 04:35:05 +01:00
|
|
|
});
|