Skip to content

Commit

Permalink
fix (app): pages didn't return to the top after changing tabs
Browse files Browse the repository at this point in the history
Close#56
  • Loading branch information
tibing-old-email authored and lugovsky committed Dec 10, 2016
1 parent 29bf20b commit fd17c83
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/pages/charts/charts.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
.state('charts', {
url: '/charts',
abstract: true,
template: '<div ui-view></div>',
template: '<div ui-view autoscroll="true" autoscroll-body-top></div>',
title: 'Charts',
sidebarMeta: {
icon: 'ion-stats-bars',
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/components/components.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$stateProvider
.state('components', {
url: '/components',
template : '<ui-view></ui-view>',
template : '<ui-view autoscroll="true" autoscroll-body-top></ui-view>',
abstract: true,
title: 'Components',
sidebarMeta: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/form/form.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$stateProvider
.state('form', {
url: '/form',
template : '<ui-view></ui-view>',
template : '<ui-view autoscroll="true" autoscroll-body-top></ui-view>',
abstract: true,
title: 'Form Elements',
sidebarMeta: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/maps/maps.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="widgets">

<div class="row">
<div class="col-md-12" ui-view></div>
<div class="col-md-12" ui-view autoscroll="true" autoscroll-body-top></div>
</div>

</div>
2 changes: 1 addition & 1 deletion src/app/pages/tables/tables.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$stateProvider
.state('tables', {
url: '/tables',
template : '<ui-view></ui-view>',
template : '<ui-view autoscroll="true" autoscroll-body-top></ui-view>',
abstract: true,
controller: 'TablesPageCtrl',
title: 'Tables',
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/ui/ui.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
$stateProvider
.state('ui', {
url: '/ui',
template : '<ui-view></ui-view>',
template : '<ui-view autoscroll="true" autoscroll-body-top></ui-view>',
abstract: true,
title: 'UI Features',
sidebarMeta: {
Expand Down
5 changes: 5 additions & 0 deletions src/app/theme/services/baUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
var g = parseInt( hex.slice(3,5), 16 );
var b = parseInt( hex.slice(5,7), 16 );
return 'rgba(' + r + ', ' + g + ', ' + b + ', ' + alpha + ')';
};

this.hasAttr = function (elem, attrName) {
var attr = $(elem).attr(attrName);
return (typeof attr !== typeof undefined && attr !== false);
}
}
})();
14 changes: 13 additions & 1 deletion src/app/theme/theme.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
.config(config);

/** @ngInject */
function config(baConfigProvider, colorHelper) {
function config(baConfigProvider, colorHelper, $provide) {
$provide.decorator('$uiViewScroll', uiViewScrollDecorator);
//baConfigProvider.changeTheme({blur: true});
//
//baConfigProvider.changeColors({
Expand All @@ -20,4 +21,15 @@
// },
//});
}

/** @ngInject */
function uiViewScrollDecorator($delegate, $anchorScroll, baUtil) {
return function (uiViewElement) {
if (baUtil.hasAttr(uiViewElement, "autoscroll-body-top")) {
$anchorScroll();
} else {
$delegate(uiViewElement);
}
};
}
})();
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<div class="al-main">
<div class="al-content">
<content-top></content-top>
<div ui-view></div>
<div ui-view autoscroll="true" autoscroll-body-top></div>
</div>
</div>

Expand Down

0 comments on commit fd17c83

Please sign in to comment.