mirror of https://github.com/akveo/blur-admin
refactor(js): mainCtrl removed
parent
a96f81557e
commit
81adb6fd2f
|
@ -4,7 +4,7 @@ var blurAdminApp = angular.module('BlurAdmin', [
|
||||||
'ui.sortable',
|
'ui.sortable',
|
||||||
'ngRoute',
|
'ngRoute',
|
||||||
'ngTouch',
|
'ngTouch',
|
||||||
'BlurAdmin.layout',
|
'BlurAdmin.theme',
|
||||||
'BlurAdmin.dashboard',
|
'BlurAdmin.dashboard',
|
||||||
'BlurAdmin.buttonsPage',
|
'BlurAdmin.buttonsPage',
|
||||||
'BlurAdmin.chartsPage',
|
'BlurAdmin.chartsPage',
|
||||||
|
@ -19,20 +19,6 @@ var blurAdminApp = angular.module('BlurAdmin', [
|
||||||
'toastr',
|
'toastr',
|
||||||
'smart-table',
|
'smart-table',
|
||||||
'ui.slimscroll'
|
'ui.slimscroll'
|
||||||
]).config(['$routeProvider', 'toastrConfig', function ($routeProvider, toastrConfig) {
|
]).config(['$routeProvider', function ($routeProvider) {
|
||||||
$routeProvider.otherwise({redirectTo: '/dashboard'});
|
$routeProvider.otherwise({redirectTo: '/dashboard'});
|
||||||
|
|
||||||
angular.extend(toastrConfig, {
|
|
||||||
closeButton: true,
|
|
||||||
closeHtml: '<button>×</button>',
|
|
||||||
timeOut: 5000,
|
|
||||||
autoDismiss: false,
|
|
||||||
containerId: 'toast-container',
|
|
||||||
maxOpened: 0,
|
|
||||||
newestOnTop: true,
|
|
||||||
positionClass: 'toast-top-right',
|
|
||||||
preventDuplicates: false,
|
|
||||||
preventOpenDuplicates: false,
|
|
||||||
target: 'body'
|
|
||||||
});
|
|
||||||
}]);
|
}]);
|
|
@ -1,13 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
blurAdminApp.controller('mainCtrl', ['$scope', '$timeout', function ($scope, $timeout) {
|
|
||||||
$timeout(function () {
|
|
||||||
$scope.finishLoading = true;
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
$timeout(function () {
|
|
||||||
pageLoaded = true;
|
|
||||||
}, 4000);
|
|
||||||
|
|
||||||
$scope.isMenuCollapsed = window.innerWidth <= resWidthCollapseSidebar;
|
|
||||||
}]);
|
|
|
@ -4,13 +4,13 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
blurAdminApp.directive('zoomIn', ['$timeout', function ($timeout) {
|
blurAdminApp.directive('zoomIn', ['$timeout', '$rootScope', function ($timeout, $rootScope) {
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
link: function ($scope, elem) {
|
link: function ($scope, elem) {
|
||||||
var delay = 1000;
|
var delay = 1000;
|
||||||
|
|
||||||
if (pageLoaded) {
|
if ($rootScope.$pageLoaded) {
|
||||||
delay = 100;
|
delay = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div class="page-top clearfix" scroll-position="scrolled" max-height="50" ng-class="{'scrolled': scrolled}">
|
<div class="page-top clearfix" scroll-position="scrolled" max-height="50" ng-class="{'scrolled': scrolled}">
|
||||||
<a href="#/dashboard" class="al-logo clearfix"><span>Blur</span>Admin</a>
|
<a href="#/dashboard" class="al-logo clearfix"><span>Blur</span>Admin</a>
|
||||||
<a href class="collapse-menu-link ion-navicon" ng-click="isMenuCollapsed=!isMenuCollapsed"></a>
|
<a href class="collapse-menu-link ion-navicon" ng-click="$isMenuCollapsed=!$isMenuCollapsed"></a>
|
||||||
|
|
||||||
<div class="search">
|
<div class="search">
|
||||||
<i class="ion-ios-search-strong" ng-click="startSearch()"></i>
|
<i class="ion-ios-search-strong" ng-click="startSearch()"></i>
|
||||||
|
|
|
@ -4,10 +4,7 @@ blurAdminApp.directive('sidebar', function () {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
templateUrl: 'app/components/sidebar/sidebar.html',
|
templateUrl: 'app/components/sidebar/sidebar.html',
|
||||||
scope: {
|
controller: ['$scope', '$element', '$window', '$timeout', '$location', '$rootScope', 'layoutSizes', function ($scope, $element, $window, $timeout, $location, $rootScope, layoutSizes) {
|
||||||
isMenuCollapsed: '='
|
|
||||||
},
|
|
||||||
controller: ['$scope', '$element', '$window', '$timeout', '$location', function ($scope, $element, $window, $timeout, $location) {
|
|
||||||
$scope.menuItems = [
|
$scope.menuItems = [
|
||||||
{
|
{
|
||||||
title: 'Dashboard',
|
title: 'Dashboard',
|
||||||
|
@ -133,14 +130,14 @@ blurAdminApp.directive('sidebar', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.menuExpand = function () {
|
$scope.menuExpand = function () {
|
||||||
$scope.isMenuCollapsed = false;
|
$rootScope.$isMenuCollapsed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.menuCollapse = function () {
|
$scope.menuCollapse = function () {
|
||||||
$scope.isMenuCollapsed = true;
|
$rootScope.$isMenuCollapsed = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$watch('isMenuCollapsed', function(newValue) {
|
$rootScope.$watch('$isMenuCollapsed', function(newValue) {
|
||||||
if (!newValue && !$scope.selectElemTop) {
|
if (!newValue && !$scope.selectElemTop) {
|
||||||
changeSelectElemTopValue();
|
changeSelectElemTopValue();
|
||||||
}
|
}
|
||||||
|
@ -148,10 +145,10 @@ blurAdminApp.directive('sidebar', function () {
|
||||||
|
|
||||||
// watch window resize to change menu collapsed state if needed
|
// watch window resize to change menu collapsed state if needed
|
||||||
$(window).resize(function () {
|
$(window).resize(function () {
|
||||||
var isMenuShouldCollapsed = $(window).width() <= resWidthCollapseSidebar;
|
var isMenuShouldCollapsed = $(window).width() <= layoutSizes.resWidthCollapseSidebar;
|
||||||
if ($scope.isMenuShouldCollapsed !== isMenuShouldCollapsed) {
|
if ($scope.isMenuShouldCollapsed !== isMenuShouldCollapsed) {
|
||||||
$scope.$apply(function () {
|
$scope.$apply(function () {
|
||||||
$scope.isMenuCollapsed = isMenuShouldCollapsed;
|
$rootScope.$isMenuCollapsed = isMenuShouldCollapsed;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$scope.isMenuShouldCollapsed = isMenuShouldCollapsed;
|
$scope.isMenuShouldCollapsed = isMenuShouldCollapsed;
|
||||||
|
@ -160,7 +157,7 @@ blurAdminApp.directive('sidebar', function () {
|
||||||
$scope.toggleSubMenu = function ($event, item) {
|
$scope.toggleSubMenu = function ($event, item) {
|
||||||
var submenu = $($event.currentTarget).next();
|
var submenu = $($event.currentTarget).next();
|
||||||
|
|
||||||
if ($scope.isMenuCollapsed) {
|
if (isMenuCollapsed.$isMenuCollapsed) {
|
||||||
if (!item.slideRight) {
|
if (!item.slideRight) {
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
item.slideRight = true;
|
item.slideRight = true;
|
||||||
|
@ -193,8 +190,8 @@ blurAdminApp.directive('sidebar', function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.collapseSidebarIfSmallRes = function () {
|
$scope.collapseSidebarIfSmallRes = function () {
|
||||||
if (window.innerWidth <= resWidthCollapseSidebar) {
|
if (window.innerWidth <= layoutSizes.resWidthCollapseSidebar) {
|
||||||
$scope.isMenuCollapsed = true;
|
$rootScope.$isMenuCollapsed = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}]
|
}]
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('BlurAdmin.layout')
|
angular.module('BlurAdmin.theme')
|
||||||
.config(amChartConfig);
|
.config(amChartConfig);
|
||||||
|
|
||||||
/** @ngInject */
|
/** @ngInject */
|
|
@ -5,7 +5,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('BlurAdmin.layout')
|
angular.module('BlurAdmin.theme')
|
||||||
.constant('layoutColors', {
|
.constant('layoutColors', {
|
||||||
primary: '#41bee9',
|
primary: '#41bee9',
|
||||||
info: '#5bc0de',
|
info: '#5bc0de',
|
|
@ -5,6 +5,8 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('BlurAdmin.layout', []);
|
angular.module('BlurAdmin.theme', [
|
||||||
|
'toastr'
|
||||||
|
]);
|
||||||
|
|
||||||
})();
|
})();
|
|
@ -0,0 +1,24 @@
|
||||||
|
/**
|
||||||
|
* @author v.lugovksy
|
||||||
|
* created on 15.12.2015
|
||||||
|
*/
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('BlurAdmin.theme')
|
||||||
|
.run(themeRun);
|
||||||
|
|
||||||
|
/** @ngInject */
|
||||||
|
function themeRun($timeout, $rootScope, layoutSizes) {
|
||||||
|
$timeout(function () {
|
||||||
|
$rootScope.$pageFinishedLoading = true;
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
$timeout(function () {
|
||||||
|
$rootScope.$pageLoaded = true;
|
||||||
|
}, 4000);
|
||||||
|
|
||||||
|
$rootScope.$isMenuCollapsed = window.innerWidth <= layoutSizes.resWidthCollapseSidebar;
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
|
@ -0,0 +1,27 @@
|
||||||
|
/**
|
||||||
|
* @author v.lugovksy
|
||||||
|
* created on 15.12.2015
|
||||||
|
*/
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('BlurAdmin.theme')
|
||||||
|
.config(toastrLibConfig);
|
||||||
|
|
||||||
|
/** @ngInject */
|
||||||
|
function toastrLibConfig(toastrConfig) {
|
||||||
|
angular.extend(toastrConfig, {
|
||||||
|
closeButton: true,
|
||||||
|
closeHtml: '<button>×</button>',
|
||||||
|
timeOut: 5000,
|
||||||
|
autoDismiss: false,
|
||||||
|
containerId: 'toast-container',
|
||||||
|
maxOpened: 0,
|
||||||
|
newestOnTop: true,
|
||||||
|
positionClass: 'toast-top-right',
|
||||||
|
preventDuplicates: false,
|
||||||
|
preventOpenDuplicates: false,
|
||||||
|
target: 'body'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
|
@ -24,11 +24,11 @@
|
||||||
<!-- endinject -->
|
<!-- endinject -->
|
||||||
<!-- endbuild -->
|
<!-- endbuild -->
|
||||||
</head>
|
</head>
|
||||||
<body ng-controller="mainCtrl">
|
<body>
|
||||||
|
|
||||||
<main ng-if="finishLoading" ng-class="{ 'menu-collapsed': isMenuCollapsed }">
|
<main ng-if="$pageFinishedLoading" ng-class="{ 'menu-collapsed': $isMenuCollapsed }">
|
||||||
|
|
||||||
<sidebar is-menu-collapsed="isMenuCollapsed"></sidebar>
|
<sidebar></sidebar>
|
||||||
<page-top></page-top>
|
<page-top></page-top>
|
||||||
|
|
||||||
<div class="al-main">
|
<div class="al-main">
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
<back-top></back-top>
|
<back-top></back-top>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<div id="preloader" ng-show="!finishLoading">
|
<div id="preloader" ng-show="!$pageFinishedLoading">
|
||||||
<div></div>
|
<div></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue