Skip to content

Commit

Permalink
working on load stash method
Browse files Browse the repository at this point in the history
  • Loading branch information
collin committed Apr 10, 2013
1 parent 06b4331 commit 2e898ac
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/assets/javascripts/alpha_simprini/stacker/index.js.coffee
Expand Up @@ -3,7 +3,7 @@
window.Stacker = {}

Stacker.Repo = new Backbone.Collection
Stacker.alloc = (klass, attrs) -> @Repo.add item = new klass(attrs); item
Stacker.alloc = (klass, args...) -> @Repo.add item = new klass(args...); item
Stacker.get = (id) -> @Repo.get(id)
Stacker.flush = -> @Repo.set [], silent:true

Expand All @@ -22,9 +22,10 @@ class Stacker.Card extends Backbone.Model
console.log "Stacker.Card#fromJSON", data
stackId = data.stackId
data.stackId = undefined
data.stack = repository.get(stackId)
stack = data.stack = repository.get(stackId) || Stacker.alloc(Stacker.Cards, [], id:stackId)
card = Stacker.alloc Stacker.Card, data
Stacker.updateCardFromHtml(card, data.html)
stack.add card
card

toJSON: ->
Expand All @@ -38,10 +39,10 @@ class Stacker.Card extends Backbone.Model
class Stacker.Cards extends Backbone.Collection
model: Stacker.Card

constructor: ->
constructor: (models=[], options={}) ->
super
@cid = _.uniqueId('c')
@id ||= _.uniqueId('id-')
@id ||= options.id || _.uniqueId('id-')

@fromJSON: (data) ->
cards = Stacker.alloc(this)
Expand Down Expand Up @@ -278,7 +279,7 @@ class Stacker.App
options.history ||= window.history
options.storage ||= window.sessionStorage

@networkController = Stacker.NetworkController
@networkController = new Stacker.NetworkController
@historyStack = Stacker.alloc(Stacker.Cards)
@historyController = new Stacker.HistoryController(
@historyStack, options.history, options.storage
Expand Down

0 comments on commit 2e898ac

Please sign in to comment.