Skip to content

Commit

Permalink
replace deprecated/removed $stateChange* with transitionService method
Browse files Browse the repository at this point in the history
  • Loading branch information
hackmod committed May 29, 2018
1 parent ba0564b commit 105b117
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions public/js/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ GLobal Directives
***/

// Route State Load Spinner(used on page or content load)
BlocksApp.directive('ngSpinnerBar', ['$rootScope',
function($rootScope) {
BlocksApp.directive('ngSpinnerBar', ['$rootScope', '$transitions',
function($rootScope, $transitions) {
return {
link: function(scope, element, attrs) {
// by defult hide the spinner bar
element.addClass('hide'); // hide spinner bar by default

// display the spinner bar whenever the route changes(the content part started loading)
$rootScope.$on('$stateChangeStart', function() {
$transitions.onStart({}, function(trans) {
element.removeClass('hide'); // show spinner bar
Layout.closeMainMenu();
});

// hide the spinner bar on rounte change success(after the content loaded)
$rootScope.$on('$stateChangeSuccess', function() {
$transitions.onSuccess({}, function(trans) {
element.addClass('hide'); // hide spinner bar
$('body').removeClass('page-on-load'); // remove page loading indicator
Layout.setMainMenuActiveLink('match'); // activate selected link in the sidebar menu
Expand All @@ -29,12 +29,7 @@ BlocksApp.directive('ngSpinnerBar', ['$rootScope',
});

// handle errors
$rootScope.$on('$stateNotFound', function() {
element.addClass('hide'); // hide spinner bar
});

// handle errors
$rootScope.$on('$stateChangeError', function() {
$transitions.onError({}, function() {
element.addClass('hide'); // hide spinner bar
});
}
Expand Down
2 changes: 1 addition & 1 deletion views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<!-- END THEME STYLES -->
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body ng-controller="MainController" class="page-header-fixed" ng-class="{'page-content-white': settings.layout.pageContentWhite,'page-container-bg-solid': settings.layout.pageBodySolid}">
<body ng-controller="MainController" class="page-header-fixed page-on-load" ng-class="{'page-content-white': settings.layout.pageContentWhite,'page-container-bg-solid': settings.layout.pageBodySolid}">
<!-- BEGIN PAGE SPINNER -->
<div ng-spinner-bar class="page-spinner-bar">
<img src="/img/loading.gif">
Expand Down

0 comments on commit 105b117

Please sign in to comment.