Skip to content

Instantly share code, notes, and snippets.

@inossidabile
Created May 28, 2012 15:25
Show Gist options
  • Save inossidabile/2819730 to your computer and use it in GitHub Desktop.
Save inossidabile/2819730 to your computer and use it in GitHub Desktop.
Joosy / Blog / Elements, Events and Filters
# layouts/application.js.coffee
class @ApplicationLayout extends Joosy.Layout
@view 'application'
elements:
'navigationBar': '.navbar'
'clocks': '.navbar .pull-right a'
events:
'mouseenter $navigationBar': 'showClocks'
'mouseleave $navigationBar': 'hideClocks'
showClocks: -> @clocks.show()
hideClocks: -> @clocks.hide()
# layouts/application.js.coffee
class @ApplicationLayout extends Joosy.Layout
@view 'application'
elements:
'navigationBar': '.navbar'
'clocks': '.navbar .pull-right a'
events:
'mouseenter $navigationBar': -> @clocks.show()
'mouseleave $navigationBar': -> @clocks.hide()
@afterLoad ->
updateClocks = =>
@clocks.html new Date().format('{dd} {Mon} {yyyy}, {hh}:{mm}:{ss}')
updateClocks()
@setInterval 1000, updateClocks
@beforeLoad ->
@navigate('/') && return false unless window.currentUser
true
.navbar.navbar-fixed-top
.navbar-inner
.container
%ul.nav.pull-right
%li
%a
24 May 2012, 19:24:00
%a.brand{:href => '#!/'}
Joosy Blog
%ul.nav
%li.divider-vertical
%li
%a{:href => '#!/posts/new'} Write something
.container{:id => @yield()}
@explainer
Copy link

Sorry, the indentation disappeared in the coffeescript code above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment