sportsbet-mobile
Version:
Sportsbet mobile
76 lines (62 loc) • 1.74 kB
text/typescript
interface Templates {
sportsLiveEventRow: Template;
}
Template.sportsLiveEventRow.helpers({
listSelections: function() {
var tpl = Template.instance();
var market = Betting.Market.db.findOne({event: this, live: true});
if (!market) {
return;
}
var selections = market.selections.fetch({}, {sort: {orderNr: 1}});
tpl.setVar('selectionCount', selections.length);
return selections;
},
listMarket: function() {
var event = <Betting.Event>this;
var isLive = event.live && event.active;
if (!event) {
return;
}
var listMarkets = event.listMarkets({live: isLive, limit: 1});
if (_.isEmpty(listMarkets)) {
return;
}
var market: Betting.Market = listMarkets.fetch()[0];
if (!market) {
return;
}
var templateHandle = (market.live ? 'live' : 'prelive') + '_' + (+market.details.subType || market.details.typeId);
return <any>{
name: market.name,
markets: [market],
template: Betting.getMarketTpl(templateHandle),
handle: templateHandle
};
},
playedMinutes: function () {
if (!(<any>this).sport || !(<any>this).results || !(<any>this).results.matchMinute) {
return;
}
return (<any>this).results.matchMinute + `'`;
},
showLiveBadge: function() {
var event = <Betting.Event>this;
return event.live && (Betting.nonLiveStatuses.indexOf(event.matchStatus) === -1);
}
});
Template.sportsLiveEventRow.events({
'click .result': function(e: MeteorTemplateEvent) {
e.preventDefault();
e.stopPropagation();
Pages.go(`/sports/live/${this.makeSeoString()}/event/${this._id}`);
},
'click .selection': function(e: MeteorTemplateEvent) {
e.preventDefault();
e.stopPropagation();
if (this.suspended()) {
return;
}
Betting.toggleBet(this);
}
});