fix (app): pages didn't return to the top after changing tabs

Close#56
pull/112/merge
tibing 2016-06-24 15:01:13 +03:00 committed by Vladimir Lugovsky
parent 29bf20bf48
commit fd17c834c3
9 changed files with 25 additions and 8 deletions

View File

@ -19,7 +19,7 @@
.state('charts', { .state('charts', {
url: '/charts', url: '/charts',
abstract: true, abstract: true,
template: '<div ui-view></div>', template: '<div ui-view autoscroll="true" autoscroll-body-top></div>',
title: 'Charts', title: 'Charts',
sidebarMeta: { sidebarMeta: {
icon: 'ion-stats-bars', icon: 'ion-stats-bars',

View File

@ -17,7 +17,7 @@
$stateProvider $stateProvider
.state('components', { .state('components', {
url: '/components', url: '/components',
template : '<ui-view></ui-view>', template : '<ui-view autoscroll="true" autoscroll-body-top></ui-view>',
abstract: true, abstract: true,
title: 'Components', title: 'Components',
sidebarMeta: { sidebarMeta: {

View File

@ -13,7 +13,7 @@
$stateProvider $stateProvider
.state('form', { .state('form', {
url: '/form', url: '/form',
template : '<ui-view></ui-view>', template : '<ui-view autoscroll="true" autoscroll-body-top></ui-view>',
abstract: true, abstract: true,
title: 'Form Elements', title: 'Form Elements',
sidebarMeta: { sidebarMeta: {

View File

@ -1,7 +1,7 @@
<div class="widgets"> <div class="widgets">
<div class="row"> <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>
</div> </div>

View File

@ -13,7 +13,7 @@
$stateProvider $stateProvider
.state('tables', { .state('tables', {
url: '/tables', url: '/tables',
template : '<ui-view></ui-view>', template : '<ui-view autoscroll="true" autoscroll-body-top></ui-view>',
abstract: true, abstract: true,
controller: 'TablesPageCtrl', controller: 'TablesPageCtrl',
title: 'Tables', title: 'Tables',

View File

@ -25,7 +25,7 @@
$stateProvider $stateProvider
.state('ui', { .state('ui', {
url: '/ui', url: '/ui',
template : '<ui-view></ui-view>', template : '<ui-view autoscroll="true" autoscroll-body-top></ui-view>',
abstract: true, abstract: true,
title: 'UI Features', title: 'UI Features',
sidebarMeta: { sidebarMeta: {

View File

@ -27,6 +27,11 @@
var g = parseInt( hex.slice(3,5), 16 ); var g = parseInt( hex.slice(3,5), 16 );
var b = parseInt( hex.slice(5,7), 16 ); var b = parseInt( hex.slice(5,7), 16 );
return 'rgba(' + r + ', ' + g + ', ' + b + ', ' + alpha + ')'; return 'rgba(' + r + ', ' + g + ', ' + b + ', ' + alpha + ')';
};
this.hasAttr = function (elem, attrName) {
var attr = $(elem).attr(attrName);
return (typeof attr !== typeof undefined && attr !== false);
} }
} }
})(); })();

View File

@ -9,7 +9,8 @@
.config(config); .config(config);
/** @ngInject */ /** @ngInject */
function config(baConfigProvider, colorHelper) { function config(baConfigProvider, colorHelper, $provide) {
$provide.decorator('$uiViewScroll', uiViewScrollDecorator);
//baConfigProvider.changeTheme({blur: true}); //baConfigProvider.changeTheme({blur: true});
// //
//baConfigProvider.changeColors({ //baConfigProvider.changeColors({
@ -20,4 +21,15 @@
// }, // },
//}); //});
} }
/** @ngInject */
function uiViewScrollDecorator($delegate, $anchorScroll, baUtil) {
return function (uiViewElement) {
if (baUtil.hasAttr(uiViewElement, "autoscroll-body-top")) {
$anchorScroll();
} else {
$delegate(uiViewElement);
}
};
}
})(); })();

View File

@ -34,7 +34,7 @@
<div class="al-main"> <div class="al-main">
<div class="al-content"> <div class="al-content">
<content-top></content-top> <content-top></content-top>
<div ui-view></div> <div ui-view autoscroll="true" autoscroll-body-top></div>
</div> </div>
</div> </div>