vendor/assets/javascripts/pullentity-backbone/app/views/main.js.coffee in pullentity-backbone-0.0.4 vs vendor/assets/javascripts/pullentity-backbone/app/views/main.js.coffee in pullentity-backbone-0.0.5
- old
+ new
@@ -11,10 +11,13 @@
@site.on("change", @initModels )
@site.fetch()
initModels: ()=>
#console.log("init models")
+
+ @theme_templates = $(".pullentity-themes")
+
@sections = new Pullentity.Collections.Sections(@site.get('sections'))
@projects = new Pullentity.Collections.Projects(@site.get('projects'))
#debugger
#console.log("Site Loaded!")
#console.log @sections
@@ -30,10 +33,11 @@
setTitle: ()=>
#console.log @site.get("name")
document.title = "#{@site.get("name")} pullentity site"
initRouter: ()=>
+
@app_router = new Pullentity.Routers.main
@app_router.on 'route:defaultRoute', (actions)=>
#console.log(actions) # See more at: http://backbonetutorials.com/what-is-a-router
#console.log("init routes")
@@ -43,20 +47,24 @@
#console.log("get project #{id}")
@find_project_by_id(id)
@app_router.on 'route:getSection', (id)=>
#console.log("get section #{id}")
+ #console.log @theme_templates
@find_in_section(id)
+ @app_router.on 'route:getBlog', (id)=>
+ #console.log("get section #{id}")
+ @get_blog(id)
+
Backbone.history.start(pushState: true)
render: ()=>
#console.info("should render layout")
source = $("#layout").html()
@theme_templates = $(".pullentity-themes")
@layout = Handlebars.compile(source)
- #console.log(@site.attributes)
$("body").html(@layout(@site.attributes))
@initRouter()
render_home_project: ()=>
@current_project = @projects.findWhere({home: true })
@@ -98,10 +106,13 @@
render_project: ()=>
@render_handlebars()
$("#content").html(@current_template(@current_project.attributes))
+ get_blog: ()=>
+ console.log("blog!!")
+
find_theme_for_project: ()=>
@current_theme_obj = _.find @theme_templates, (num)=>
if $(num).attr("id") == @current_project.get("theme_template").name
num
console.error "theme \"#{@current_project.get("theme_template").name}\" does not exist" unless @current_theme_obj
@@ -123,11 +134,12 @@
$("#content").html("<pre>CouldnĀ“t find template #{name} in /source/views/themes</pre>")
console.warn "CouldnĀ“t find projects in #{name} yet"
render_handlebars: ()=>
try
- @current_template = Handlebars.compile($(@current_theme_obj).html())
+ #console.log "(try to render) #{@current_theme_obj.text} "
+ @current_template = Handlebars.compile(@current_theme_obj.text)
catch e
#console.error "error while creating Handlebars script out of template for [", $(@current_theme_obj), e
throw e
setupLinks: ()=>
@@ -150,6 +162,6 @@
# Instruct Backbone to trigger routing events
@app_router.navigate url, { trigger: true }
return false
-layout = new Pullentity.Views.Commons.Main
+Pullentity.App = new Pullentity.Views.Commons.Main