artsy-backbone-mixins
Advanced tools
Comparing version 0.0.10 to 0.0.11
{ | ||
"name": "artsy-backbone-mixins", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "A library of Backbone mixins that DRY up some common domain logic and Artsy API rabbit holes..", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -132,4 +132,3 @@ # artsy-backbone-mixins | ||
````coffeescript | ||
{ Fetch } = require 'artsy-backbone-mixins' | ||
{ AToZ } = require('sharify').data | ||
{ AToZ } = require 'artsy-backbone-mixins' | ||
@@ -142,3 +141,3 @@ class Artworks extends Backbone.Collection | ||
### groupByAlpha | ||
### groupByAlpha() | ||
@@ -163,3 +162,3 @@ Sorts a collection groupped alphabetically based on the `alphaSortKey` function on the model. If there is no `alphaSortKey` function on the model it will default to `@get 'sortable_id'`. | ||
### groupByAlphaWithColumns | ||
### groupByAlphaWithColumns([numberOfColumns]) | ||
@@ -191,2 +190,33 @@ Groups collection output in a format suitable for rendering in an A-Z list with a specified number of columns. The models must implement a `href` and `displayName` method. | ||
## Image | ||
````coffeescript | ||
{ Image } = require 'artsy-backbone-mixins' | ||
class FeaturedLink extends Backbone.Model | ||
_.extend @prototype, Image | ||
```` | ||
### imageUrl([version]) | ||
The Artsy API often structures image data like `{ image_url: 'foo/bar/:version.jpg' }` this method will return a replaced string with sensible defaults. | ||
````coffeescript | ||
featuredLink.imageUrl('small') | ||
```` | ||
#### missingImageUrl() | ||
`imageUrl` uses the `missingImageUrl` on the model to know what image to show when it can't find a version of it in the data. Defaults to `/image/missing_image.png`. | ||
#### defaultImageVersion() | ||
Tell `imageUrl` which version to look for first. Defaults to the first item in the `image_versions` or `versions` attribute. | ||
#### hasImage(version) | ||
Checks the `image_versions` or `versions` attribute for the image version and returns true/false. | ||
## Contributing | ||
@@ -193,0 +223,0 @@ |
29961
21
230
225