From fa7d3a651a18415d4e7ee8845825a9f1ed99dbf5 Mon Sep 17 00:00:00 2001 From: PatrickJS Date: Fri, 21 Mar 2014 21:12:33 -0700 Subject: [PATCH] chore($LocationDecorator): out of global scope Closes #867 --- .../src/service/decorators/location.js | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/js/ext/angular/src/service/decorators/location.js b/js/ext/angular/src/service/decorators/location.js index ebd23b4c57..53d25acc53 100644 --- a/js/ext/angular/src/service/decorators/location.js +++ b/js/ext/angular/src/service/decorators/location.js @@ -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; -}