Skip to content

Instantly share code, notes, and snippets.

@inossidabile
Created January 30, 2012 19:13
Show Gist options
  • Save inossidabile/1706064 to your computer and use it in GitHub Desktop.
Save inossidabile/1706064 to your computer and use it in GitHub Desktop.
class @BreadcrumbsWidget extends Joosy.Widget
@breadcrumbs: Joosy.Resource.Generic.create(all: [])
@rewindOrPush: (page) ->
url = location.hash
url = '#!/' if url.isBlank()
title = page.title
index = @breadcrumbs('all').findIndex (item) -> item.url == url
if index >= 0
result = @breadcrumbs('all').to index + 1
else
result = @breadcrumbs('all').add url: url, title: title
@breadcrumbs 'all', result
@view ->
@render 'breadcrumbs', breadcrumbs: @constructor.breadcrumbs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment