Skip to content

Commit

Permalink
Merge pull request #1 from shenfeng/master
Browse files Browse the repository at this point in the history
make backrub work with backbone 0.5.0
  • Loading branch information
Wu Zhe committed Jul 4, 2011
2 parents 66c06d5 + 179fba7 commit 6853709
Show file tree
Hide file tree
Showing 11 changed files with 1,842 additions and 701 deletions.
848 changes: 425 additions & 423 deletions lib/backrub.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion spec/SpecRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- dependencies... -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.5/underscore-min.js"></script>
<script type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js"></script>
<script type="text/javascript" src="lib/backbone.js"></script>
<script type="text/javascript" src="lib/handlebars.js"></script>

<!--main files... -->
Expand Down
28 changes: 14 additions & 14 deletions spec/collection.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ describe "collection", ->
itemTagName = itemTag || "li"
expect($("#{colTagName}[data-bvid]").length).toEqual 1
expect($("#{colTagName} #{itemTagName}[data-bvid]").length).toEqual collection.size()

p = 0
collection.each (m)->
expect($($("#{colTagName} #{itemTagName}[data-bvid]")[p++])).toHaveText m.get("attribute")

beforeEach ->
@collection = new TestCollection

for num in [0..4]
@collection.add new TestModel( {attribute: num})

setFixtures simple_collection_template.render({collection: @collection})
simple_collection_template.makeAlive()

it "creates a span for the main collection and each items with the right content", ->
compareToCollection @collection

it "removes elements on remove events", ->
first = @collection.first()
@collection.remove first

compareToCollection @collection

it "appends elements on add events", ->
@collection.add {attribute: 10}
compareToCollection @collection

it "refresh elements on refresh events", ->
@collection.refresh {attribute: 10}
@collection.reset {attribute: 10}
compareToCollection @collection

describe "collection-advanced", ->
Expand All @@ -50,23 +50,23 @@ describe "collection", ->
#console.log t({collection: @collection})
setFixtures template.render({collection: @collection})
template.makeAlive()

it "uses colTag and attributes argument properly", ->
useTemplate coltagname_change_template
compareToCollection @collection, "ol#collection"

it "uses itemTag and attributes argument properly", ->
useTemplate itemtagname_change_template
compareToCollection @collection, "div", "span.item"

it "uses colView and attributes argument properly", ->
useTemplate colview_change_template
compareToCollection @collection, "div#simple_view", "> span"

it "uses itemView and attributes argument properly", ->
useTemplate itemview_change_template
compareToCollection @collection, "div.col", "div.simple"

it "uses itemView and colView together properly", ->
useTemplate colitemview_change_template
compareToCollection @collection, "span#simple_view", " > div.simple"
compareToCollection @collection, "span#simple_view", " > div.simple"
Loading

0 comments on commit 6853709

Please sign in to comment.