-
-
Save netpro2k/7bd7d37b056562eb9962 to your computer and use it in GitHub Desktop.
This file contains 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
createStreamTableRow: function(checkin, grouped, isMainStream){ | |
var row = new TableViewRow({ | |
height: 'auto', | |
className: grouped ? 'streamItem' : 'stremItem gradientRow' | |
}); | |
var displayName = GlueMobile.Helpers.Utils.getDisplayName(checkin), | |
title = checkin.title ? checkin.title : !checkin.interactions ? '' : checkin.interactions.interaction ? checkin.interactions.interaction.title : checkin.interactions[0].title, | |
objectKey = checkin.objectKey ? checkin.objectKey : !checkin.interactions ? '' : checkin.interactions.interaction ? checkin.interactions.interaction.objectKey : checkin.interactions[0].objectKey, | |
comment = checkin.comment ? GlueMobile.Helpers.Utils.removeNewlines(GlueMobile.Helpers.Utils.html_entity_decode(checkin.comment)) : false; | |
var actionText = ''; | |
row.interaction = checkin; | |
row.userId = checkin.userId; | |
switch(checkin.recordType || 'i') { | |
case 'st': | |
row.action = 'showSticker'; | |
actionText = 'earned the ' + checkin.title + ' sticker'; | |
checkin.canonicalName = checkin.stickerName; | |
checkin.level = checkin.stickerLevel; | |
row.sticker = checkin; | |
break; | |
case 'mi': | |
case 'i': | |
row.action = checkin.count > 1 ? 'showMulti' : 'showInteraction'; | |
var verb = checkin.verb ? checkin.verb : !checkin.interactions ? false : checkin.interactions.interaction ? checkin.interactions.interaction.verb : checkin.interactions[0].verb, | |
displayVerb = checkin.verb ? checkin.displayVerb : !checkin.interactions ? false : checkin.interactions.interaction ? checkin.interactions.interaction.displayVerb : checkin.interactions[0].displayVerb; | |
if(checkin.source == 'twitter'){ | |
checkin.action = 'tweet'; | |
} | |
actionText = checkin.action == 'Checkin' && checkin.count > 1 ? ('Checked-in to ' + title): | |
GlueMobile.Helpers.Objects.getActionText(checkin.action, GlueMobile.Helpers.Objects.getCategoryFromObjectKey(objectKey), checkin.comment, checkin.userId, verb, displayVerb) + ' ' + title; | |
if(checkin.count > 1){ | |
actionText += ' and ' + (checkin.count - 1) + ' other thing' + (checkin.count > 2 ? 's':'') | |
} | |
break; | |
case 'r': | |
row.action = 'showSourceInteraction'; | |
actionText = 'Replied to ' + GlueMobile.Helpers.Utils.getSourceDisplayName(checkin) + ' about ' + title; | |
break; | |
case 'v': | |
row.action = 'showSourceInteraction'; | |
var sourceDisplayName = GlueMobile.Helpers.Utils.getSourceDisplayName(checkin), | |
sourceDisplayNamepossessive = sourceDisplayName == 'You' ? 'Your' : sourceDisplayName + "'s"; | |
switch(checkin.vote) { | |
case 'funny': | |
actionText = 'Thinks ' + sourceDisplayNamepossessive + ' ' + (checkin.replySource ? 'reply' : 'comment') + ' about ' + title + ' is funny'; | |
break; | |
case 'agree': | |
actionText = (displayName == 'You' ? 'agree':'agrees') + ' with ' + sourceDisplayNamepossessive + ' ' + (checkin.replySource ? 'reply' : 'comment') + ' about ' + title; | |
break; | |
case 'cool': | |
actionText = 'Thinks ' + sourceDisplayNamepossessive + ' ' + (checkin.replySource ? 'reply' : 'comment') + ' about ' + title + ' is cool'; | |
break; | |
} | |
actionText = GlueMobile.Helpers.Utils.truncate(actionText, 80); | |
break; | |
case 'l': | |
row.action = 'showList'; | |
actionText = 'Rated ' + (checkin.numItems ? checkin.numItems + ' ' : '') + GlueMobile.Helpers.Objects.getItemsName(GlueMobile.Helpers.Objects.getCategoryFromObjectKey(objectKey), 2) + ' from ' + title + '. How many can you rate?'; | |
break; | |
case 'su': | |
case 'sum': | |
row.action = 'showSourceUser'; | |
actionText = 'followed ' + GlueMobile.Helpers.Utils.getSourceDisplayName(checkin); | |
break; | |
case 'm': | |
return GlueMobile.Helpers.UI.createGenericMessageTableRow(checkin, grouped); | |
break; | |
case 'r': | |
actionText = 'replied about ' + checkin.title; | |
break; | |
case 'g': | |
row.action = 'showInteraction'; | |
if(checkin.source) { | |
actionText = 'took over the Guru title for ' + checkin.title + ' from ' + GlueMobile.Helpers.Utils.getSourceDisplayName(checkin); | |
} else { | |
actionText = 'are now the Guru of ' + checkin.title; | |
} | |
break; | |
case 'gw': | |
displayName = GlueMobile.Helpers.Utils.getSourceDisplayName(checkin); | |
row.userId = checkin.source; | |
actionText = 'would love to be the Guru of ' + checkin.title; | |
break; | |
case 'sh': | |
actionText = 'shared a ' + GlueMobile.Helpers.Objects.getItemsName(GlueMobile.Helpers.Objects.getCategoryFromObjectKey(checkin.objectKey), 1) + ' with you'; | |
break; | |
case 'fc': | |
actionText = 'is also ' + (checkin.displayVerb ? checkin.displayVerb : checkin.verb) + ' ' + checkin.title; | |
break; | |
default: | |
return null; | |
} | |
var avatar = new View({ | |
className: 'streamAvatarShadow' | |
}); | |
avatar.add(new ImageView({ | |
className: 'streamAvatarImg', | |
image: checkin.source == 'twitter' ? 'http://api.twitter.com/1/users/profile_image?screen_name=' + row.userId + "&size=bigger": | |
'http://s3.amazonaws.com/' + GlueMobile.Properties.avatarBucket + '/' + row.userId + '/avatar.png' | |
})); | |
var centerCol = new View({className: 'streamItem_centerCol'}); | |
var usernameLbl = new Label({ | |
className: 'streamItem_usernameLbl', | |
text: (checkin.source == 'twitter' ? '@' : '') + displayName | |
}); | |
if(checkin.source == 'twitter') { | |
row.className += 'twitter'; | |
row.add(new View({className: 'tweetIcon'})) | |
} | |
if(isMainStream){ | |
if(comment) { | |
row.className += 'comment'; | |
row.add(new View({className: 'streamItem_chicklet commentChicklet'})) | |
} else if(checkin.action == 'Checkin') { | |
row.className += 'checkin'; | |
row.add(new View({className: 'streamItem_chicklet checkinChicklet'})) | |
} | |
} | |
if(checkin.guru) { | |
row.className += 'guru'; | |
var guruPill = new View({className: 'streamItem_pill', right: isMainStream ? 23 : 8}); | |
guruPill.add(new Label({className: 'streamItem_pill_lbl', text: 'GURU'})); | |
row.add(guruPill); | |
} else if(checkin.type) { | |
row.className += 'type'; | |
var fanPill = new View({className: 'streamItem_pill', right: isMainStream ? 23 : 8}); | |
fanPill.add(new Label({className: 'streamItem_pill_lbl', text: checkin.type.toUpperCase()})); | |
row.add(fanPill); | |
} | |
var commentLblText = ''; | |
if( isMainStream ) { | |
commentLblText = actionText + (comment ? (': “' + comment + '”') : ''); | |
} else { | |
commentLblText = actionText = (comment ? ('“' + comment + '”') : ' ') | |
} | |
var commentLbl = new Label({ | |
text: commentLblText, | |
height: GlueMobile.NativeUtils.getTextHeight( commentLblText, 246, 70, 13), | |
className: 'streamItem_commentLbl' | |
}); | |
centerCol.add(usernameLbl); | |
centerCol.add(commentLbl); | |
var footer = new View({className: 'streamItem_footer'}); | |
footer.add(new Label({className: 'streamItem_footer_timestamp', text: GlueMobile.Helpers.Utils.relative_time(checkin.millistamp || checkin.timestamp)})); | |
if(!checkin.numReplies && checkin.interactions ) { | |
if(checkin.interactions.interaction && checkin.interactions.interaction.numReplies) { | |
checkin.numReplies = checkin.interactions.interaction.numReplies; | |
} else if(checkin.interactions.length > 0 && checkin.interactions[0].numReplies) { | |
checkin.numReplies = checkin.interactions[0].numReplies; | |
} | |
} | |
var footerLbl = new Label({ className: 'streamItem_footer_replies', text: (checkin.numReplies > 0 ? checkin.numReplies + (checkin.numReplies >1 ? ' REPLIES' : ' REPLY') : '')}), | |
voteTotal = (checkin.funny || 0) + (checkin.cool || 0) + ( checkin.agree || 0 ); | |
if(voteTotal) { | |
footerLbl.text += (checkin.numReplies > 0 ? ' • ' : '') + voteTotal + ' VOTE' + ( voteTotal > 1 ? 'S' : '' ); | |
} | |
footer.add(footerLbl); | |
if(checkin.venueName && checkin.venueName != '') { | |
row.className += 'location'; | |
centerCol.add(new Label({className: 'streamItem_locationLbl', text: checkin.venueName + (checkin.venueCity ? ' • ' + checkin.venueCity : '')})); | |
} | |
centerCol.add(footer); | |
row.add(avatar); | |
row.add(centerCol); | |
return row; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment