Files
openfoodnetwork/app/assets/javascripts/darkswarm/services/navigation.js.coffee
Maikel Linke d510df5236 Remove obsolete goWithoutHashFragments
It was introduced, because `Navigation.go` perserved hash fragments. We
actually don't need that behaviour and it has been corrected.

`goWithoutHashFragments` also didn't deal with absolute URLs. And it used
`location.origin` which is not supported by Internet Explorer. That is
fixed by our use of Modernizr though.
2018-06-21 10:29:32 +10:00

26 lines
602 B
CoffeeScript

Darkswarm.factory 'Navigation', ($location, $window) ->
new class Navigation
path: null
isActive: (path)->
$location.path() == path
navigate: (path)=>
@path = path
$location.path(@path)
toggle: (path = false)=>
@path = path || @path
if $location.path() == @path
$location.path("/")
else
@navigate(path)
go: (path)->
# The browser treats this like clicking on a link.
# It works for absolute paths, relative paths and URLs alike.
$window.location.href = path
reload: ->
$window.location.reload()