Slowly modernizing the tutorial.

Fixed autoreload and Makefile to be more, um, relative.
This commit is contained in:
Elf M. Sternberg 2016-04-15 15:43:05 -07:00
parent 2b09593ec7
commit fdf2b4367d
3 changed files with 14 additions and 10 deletions

View File

@ -1,4 +1,4 @@
.PHONY: setup store
.PHONY: setup store serve
NOTANGLE= notangle
NOWEAVE= noweave
@ -12,6 +12,11 @@ LIBS:= htdocs/lib/underscore.js htdocs/lib/jquery.js htdocs/lib/backbone.js
all: htdocs/index.html htdocs/store.js htdocs/jsonstore.css htdocs/data/items.json
@if [ ! -e "./htdocs/lib" ]; then echo "Please do 'make setup' before continuing"; fi
serve: all
$(COFFEE) ./bin/autoreload
store: all
htdocs/lib:
mkdir -p htdocs/lib

View File

@ -1,4 +1,4 @@
#!/usr/bin/env coffee
#!/bin/env coffee
fs = require 'fs'
Inotify = require('inotify').Inotify
@ -13,7 +13,7 @@ monitor = new Inotify()
reBuild = ->
maker = spawn 'make', ['store']
make.stdout.on 'data', spew
maker.stdout.on 'data', spew
monitor.addWatch
path: "./src/backbonestore.nw"

View File

@ -391,7 +391,7 @@ class ProductListView extends _BaseView
@collection.bind 'reset', _.bind(@render, @)
render: () ->
@el.html(_.template(@template, {'products': @collection.toJSON()}))
@el.html(_.template(@template)({'products': @collection.toJSON()}))
@
@
@ -442,7 +442,6 @@ class ProductView extends _BaseView
initialize: (options) ->
_BaseView.prototype.initialize.apply @, [options]
@itemcollection = options.itemcollection
@item = @itemcollection.getOrCreateItemForProduct @model
@
%$
@ -491,11 +490,10 @@ helps clarify what it is you're looking for.
<<product detail view>>=
update: (e) ->
e.preventDefault()
@item.update parseInt(@$('.uqf').val())
@itemcollection.update @model, parseInt(@$('.uqf').val())
updateOnEnter: (e) ->
if (e.keyCode == 13)
@update e
@update(e) if e.keyCode == 13
@
%$
@ -504,7 +502,7 @@ The render is straightforward:
<<product detail view>>=
render: () ->
@el.html(_.template(@template, @model.toJSON()));
@el.html(_.template(@template)(@model.toJSON()));
@
@
@ -562,9 +560,10 @@ show that it did changed:
<<cart widget>>=
render: () ->
tel = @el.html _.template @template,
tel = @el.html _.template(@template)({
'count': @collection.getTotalCount()
'cost': @collection.getTotalCost()
})
tel.animate({paddingTop: '30px'}).animate({paddingTop: '10px'})
@