Files
openfoodnetwork/app/assets/javascripts/darkswarm/services/navigation.js.coffee
2014-06-27 11:51:53 +10:00

24 lines
511 B
CoffeeScript

Darkswarm.factory 'Navigation', ($location, $window) ->
new class Navigation
path: null
active: (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)->
if path.match /^http/
$window.location.href = path
else
$window.location.pathname = path