mirror of
https://github.com/openstf/stf
synced 2025-10-05 02:29:26 +02:00
- New nav menu.
- Polishing device list.
This commit is contained in:
parent
8ed3ae1784
commit
593e14a80a
12 changed files with 115 additions and 10 deletions
39
res/app/components/stf/nav-menu/nav-menu-directive.js
Normal file
39
res/app/components/stf/nav-menu/nav-menu-directive.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
module.exports = function ($location) {
|
||||
return function (scope, element, attrs) {
|
||||
var links = element.find('a')
|
||||
var onClass = attrs.navMenu || 'current'
|
||||
var routePattern
|
||||
var link
|
||||
var url
|
||||
var currentLink
|
||||
var urlMap = {}
|
||||
var i
|
||||
|
||||
if (!$location.$$html5) {
|
||||
routePattern = /^#[^/]*/
|
||||
}
|
||||
|
||||
for (i = 0; i < links.length; i++) {
|
||||
link = angular.element(links[i])
|
||||
url = link.attr('href')
|
||||
|
||||
if ($location.$$html5) {
|
||||
urlMap[url] = link
|
||||
} else {
|
||||
urlMap[url.replace(routePattern, '')] = link
|
||||
}
|
||||
}
|
||||
|
||||
scope.$on('$routeChangeStart', function () {
|
||||
var pathLink = urlMap[$location.path()]
|
||||
|
||||
if (pathLink) {
|
||||
if (currentLink) {
|
||||
currentLink.removeClass(onClass);
|
||||
}
|
||||
currentLink = pathLink;
|
||||
currentLink.addClass(onClass);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue