Created
May 28, 2012 15:25
-
-
Save inossidabile/2819730 to your computer and use it in GitHub Desktop.
Joosy / Blog / Elements, Events and Filters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@afterLoad -> | |
updateClocks = => | |
@clocks.html new Date().format('{dd} {Mon} {yyyy}, {hh}:{mm}:{ss}') | |
updateClocks() | |
@setInterval 1000, updateClocks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@beforeLoad -> | |
@navigate('/') && return false unless window.currentUser | |
true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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()} |
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
There is a problem with @beforeload, here is mylayouts/application.js.coffee:
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'
@afterLoad ->
updateClocks = =>
@clocks.html new Date().format('{dd} {Mon} {yyyy}, {hh}:{mm}:{ss}')
@beforeload ->
@Navigate('/') && return false unless window.currentUser
true
Here is my browser contents:
ExecJS::RuntimeError in Blog#index
Showing /home/kenb/development/joosy-blog/app/views/layouts/blog.html.erb where line #8 raised:
SyntaxError: cannot use a pure statement in an expression.
(in /home/kenb/development/joosy-blog/app/assets/javascripts/blog/layouts/application.js.coffee)
Extracted source (around line #8):
5:
6: <script type="text/javascript">
7: window.joosy = {
8: libraries: <%= extract_sources_and_sizes_from_include_tag('blog') %>,
9: environment: '<%= Rails.env.to_s %>'
10: };
11: </script>
Rails.root: /home/kenb/development/joosy-blog
Application Trace | Framework Trace | Full Trace
app/views/layouts/blog.html.erb:8:in
_app_views_layouts_blog_html_erb___1034374548_74862460' app/controllers/blog_controller.rb:5:in
index'Request
Parameters:
None
Show session dump
Show env dump
Response
Headers:
None
I can make things work by commenting out the @beforeload function. Please explain what is happening.