Skip to content

Commit

Permalink
Pass a page base url to the pageitems directive to allow menu link to…
Browse files Browse the repository at this point in the history
… be compatible with routing.
  • Loading branch information
Dean O'Connor committed Jun 25, 2015
1 parent ce06147 commit 983055c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
11 changes: 10 additions & 1 deletion dist/ngScrollSpy.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,14 @@ mod.directive('pageitems', function(ScrollSpy) {
return;
}
scope.spyElems = elem[0].getElementsByClassName(scope.selector); // dom items

// Prefix the page URL base URL to the id
if (angular.isDefined(scope.pageurl)) {
for (var i = 0; i < scope.spyElems.length; i++) {
scope.spyElems[i].id = scope.pageurl + '#' + scope.spyElems[i].id;
}
}

scope.spies = {}; // menu items

// this function will be called once dom is parsed and menu is created
Expand Down Expand Up @@ -425,7 +433,8 @@ mod.directive('pageitems', function(ScrollSpy) {
restrict: 'A',
scope: {
selector: '@',
topmargin: '@'
topmargin: '@',
pageurl: '@'
},
link: linkfn
};
Expand Down
11 changes: 10 additions & 1 deletion dist/ngScrollSpy.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,14 @@ mod.directive('pageitems', function(ScrollSpy) {
return;
}
scope.spyElems = elem[0].getElementsByClassName(scope.selector); // dom items

// Prefix the page URL base URL to the id
if (angular.isDefined(scope.pageurl)) {
for (var i = 0; i < scope.spyElems.length; i++) {
scope.spyElems[i].id = scope.pageurl + '#' + scope.spyElems[i].id;
}
}

scope.spies = {}; // menu items

// this function will be called once dom is parsed and menu is created
Expand Down Expand Up @@ -425,7 +433,8 @@ mod.directive('pageitems', function(ScrollSpy) {
restrict: 'A',
scope: {
selector: '@',
topmargin: '@'
topmargin: '@',
pageurl: '@'
},
link: linkfn
};
Expand Down
2 changes: 1 addition & 1 deletion dist/ngScrollSpy.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion src/pageitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ mod.directive('pageitems', function(ScrollSpy) {
return;
}
scope.spyElems = elem[0].getElementsByClassName(scope.selector); // dom items

// Prefix the page URL base URL to the id
if (angular.isDefined(scope.pageurl)) {
for (var i = 0; i < scope.spyElems.length; i++) {
scope.spyElems[i].id = scope.pageurl + '#' + scope.spyElems[i].id;
}
}

scope.spies = {}; // menu items

// this function will be called once dom is parsed and menu is created
Expand Down Expand Up @@ -77,7 +85,8 @@ mod.directive('pageitems', function(ScrollSpy) {
restrict: 'A',
scope: {
selector: '@',
topmargin: '@'
topmargin: '@',
pageurl: '@'
},
link: linkfn
};
Expand Down

0 comments on commit 983055c

Please sign in to comment.