sportsbet-mobile
Version:
Sportsbet mobile
100 lines (73 loc) • 2.27 kB
text/typescript
interface Templates {
sportsBetSlipBet: Template;
}
Template.sportsBetSlipBet.onRendered(function() {
if (Session.get('acceptOddsChanges')) {
Betting.acceptOdds(this.data.selection);
}
});
Template.sportsBetSlipBet.helpers({
isMulti: Betting.isMultibet,
millis: function(value) {
return +(value * 1000).toFixed(2);
},
confirmBet: function() {
return Session.get('confirmBet');
},
acceptOddsChanges: function() {
return Session.get('acceptOddsChanges');
},
clearState: function(){
var self = <Betting.BetSlipBet> this;
Betting.acceptOdds(self.selection);
},
});
Template.sportsBetSlipBet.events({
'keydown input, change input': function(e: MeteorTemplateEvent) {
Session.set('betSlipError', false);
var self = this;
var num = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57];
var numpad = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105];
var operational = [8, 16, 17, 18, 35, 36, 37, 39, 46, 91, 92, 93, 110, 188, 190];
if (num.indexOf(e.which) === -1 && numpad.indexOf(e.which) === -1 && operational.indexOf(e.which) === -1) {
e.preventDefault();
e.stopPropagation();
}
Meteor.setTimeout(function () {
Betting.setBetStake(self.selection, +$(e.target).val().replace(',', '.') || 0);
}, 0);
},
'click .right, click .decline-odds': function() {
Session.set('betSlipError', false);
Betting.closeBet(this.selection);
},
'click .accept-odds': function() {
Betting.acceptOdds(this.selection);
},
'click .inc-stake-10': function() {
Session.set('betSlipError', false);
Betting.setBetStake(this.selection, this.stake ? ((this.stake * 1000) + 10) : 10);
},
'click .dec-stake-10': function() {
Session.set('betSlipError', false);
if (this.stake <= 0) {
return;
}
Betting.setBetStake(this.selection, this.stake ? ((this.stake * 1000) - 10) : 0);
},
'click .inc-stake-50': function() {
Session.set('betSlipError', false);
Betting.setBetStake(this.selection, this.stake ? ((this.stake * 1000) + 50) : 50);
},
'click .dec-stake-50': function() {
Session.set('betSlipError', false);
if (this.stake <= 0) {
return;
}
var stake = (this.stake * 1000) - 50;
if (stake < 0) {
stake = 0;
}
Betting.setBetStake(this.selection, this.stake ? stake : 0);
}
});