stable
Juanfran 2014-08-12 08:34:02 +02:00
parent 5da883eca7
commit e32e3ab2c3
1 changed files with 24 additions and 15 deletions

View File

@ -70,29 +70,38 @@ NavigationUrlsDirective = ($navurls, $auth, $q, $location) ->
return [name, options] return [name, options]
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
parseNav($attrs.tgNav, $scope).then (result) -> if $el.is("a")
[name, options] = result $el.attr("href", "#")
user = $auth.getUser()
options.user = user.username if user
url = $navurls.resolve(name) $el.on "mouseenter", (event) ->
fullUrl = $navurls.formatUrl(url, options) target = $(event.currentTarget)
$el.data("fullUrl", fullUrl) if !target.data("fullUrl")
parseNav($attrs.tgNav, $scope).then (result) ->
[name, options] = result
user = $auth.getUser()
options.user = user.username if user
if $el.is("a") url = $navurls.resolve(name)
$el.attr("href", fullUrl) fullUrl = $navurls.formatUrl(url, options)
target.data("fullUrl", fullUrl)
if target.is("a")
target.attr("href", fullUrl)
$el.on "click", (event) -> $el.on "click", (event) ->
event.preventDefault() event.preventDefault()
target = $(event.currentTarget)
fullUrl = $(event.currentTarget).data('fullUrl') fullUrl = target.data("fullUrl")
if event.which != 2 switch event.which
$location.url(fullUrl) when 1
$scope.$apply() $location.url(fullUrl)
else $scope.$apply()
window.open fullUrl when 2
window.open fullUrl
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
$el.off() $el.off()