(hash)
| 5476 | } |
| 5477 | |
| 5478 | function scroll(hash) { |
| 5479 | // Allow numeric hashes |
| 5480 | hash = isString(hash) ? hash : isNumber(hash) ? hash.toString() : $location.hash(); |
| 5481 | var elm; |
| 5482 | |
| 5483 | // empty hash, scroll to the top of the page |
| 5484 | if (!hash) scrollTo(null); |
| 5485 | |
| 5486 | // element with given id |
| 5487 | else if ((elm = document.getElementById(hash))) scrollTo(elm); |
| 5488 | |
| 5489 | // first anchor with given name :-D |
| 5490 | else if ((elm = getFirstAnchor(document.getElementsByName(hash)))) scrollTo(elm); |
| 5491 | |
| 5492 | // no element and hash === 'top', scroll to the top of the page |
| 5493 | else if (hash === 'top') scrollTo(null); |
| 5494 | } |
| 5495 | |
| 5496 | // does not scroll when user clicks on anchor link that is currently on |
| 5497 | // (no url change, no $location.hash() change), browser native does scroll |
nothing calls this directly
no test coverage detected