chore($LocationDecorator): out of global scope

Closes #867
This commit is contained in:
PatrickJS
2014-03-21 21:12:33 -07:00
committed by Andy Joslin
parent 5e5ce9e208
commit fa7d3a651a

View File

@@ -4,25 +4,25 @@ angular.module('ionic.decorator.location', [])
* @private
*/
.config(['$provide', function($provide) {
function $LocationDecorator($location, $timeout) {
$location.__hash = $location.hash;
//Fix: when window.location.hash is set, the scrollable area
//found nearest to body's scrollTop is set to scroll to an element
//with that ID.
$location.hash = function(value) {
if (angular.isDefined(value)) {
$timeout(function() {
var scroll = document.querySelector('.scroll-content');
if (scroll)
scroll.scrollTop = 0;
}, 0, false);
}
return $location.__hash(value);
};
return $location;
}
$provide.decorator('$location', ['$delegate', '$timeout', $LocationDecorator]);
}]);
function $LocationDecorator($location, $timeout) {
$location.__hash = $location.hash;
//Fix: when window.location.hash is set, the scrollable area
//found nearest to body's scrollTop is set to scroll to an element
//with that ID.
$location.hash = function(value) {
if (angular.isDefined(value)) {
$timeout(function() {
var scroll = document.querySelector('.scroll-content');
if (scroll)
scroll.scrollTop = 0;
}, 0, false);
}
return $location.__hash(value);
};
return $location;
}