mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
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.
26 lines
602 B
CoffeeScript
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()
|