Created
May 25, 2015 15:54
-
-
Save stephencroberts/3ecb0a316480058f3205 to your computer and use it in GitHub Desktop.
Angular object literal proto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
reviewProto = { | |
getTitle: -> | |
@fields.title if @fields and @fields.title | |
getAlias: -> | |
@fields.alias if @fields and @fields.alias | |
getSuperLabel: -> | |
@fields.category if @fields and @fields.category | |
getShortDescription: -> | |
@fields.shortDescription if @fields and @fields.shortDescription | |
getRatingClass: -> | |
@fields.mpaaRating.toLowerCase() if @fields and @fields.mpaaRating | |
getImage: -> | |
return unless @fields | |
if @fields.reviewImage | |
return { | |
src: @fields.reviewImage.fields.file.url | |
alt: @fields.reviewImage.fields.file.title | |
} | |
getContentType: -> | |
@fields.contentType if @fields.contentType | |
getIconClass: -> | |
return @fields.isThisASingleTrackOrAnAlbum.toLowerCase() if @fields.isThisASingleTrackOrAnAlbum | |
return 'dvd' if @fields.category == 'On DVD' | |
@getContentType() | |
} | |
reviewProto.$inject = ['contentfulConfig'] | |
angular | |
.module('app.data') | |
.constant('reviewProto', reviewProto) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment