· 6 years ago · Oct 19, 2019, 02:28 PM
1var $log = function() {
2 if ("console" in window) {
3 Array.prototype.splice.call(arguments, 0, 0, new Date().getTime() + " ");
4 try {
5 console.log.apply(console, arguments);
6 }
7 catch (e) {
8 /* tslint:disable */
9 console.log(Array.prototype.join.call(arguments, " "));
10 /* tslint:enable */
11 }
12 }
13};
14
15var bsApp,
16 BetslipApp = function () {
17 /// <summary>
18 /// SABSWA API communications class for Mobile - handles instantiation of the bet slip API
19 /// and sets up event delegates for interaction with the bet slip standalone web app.
20 /// </summary>
21
22 var scope = this, rootDomain;
23
24 // Reference to the Bet slip API controller
25 scope.bsController = null;
26
27 // Cache the Betslipwebmodule delegate
28 scope.betslipWebModule = null;
29
30 // Local store of the current bet count
31 scope.betCount = 0;
32
33 //local storeage for subscriptions
34 scope.subscriptionManager = null;
35
36 //handle all confirmation dialogs
37 scope.confirmationManger = null;
38
39 // Store the height of the betslip
40 scope.betslipHeight = 0;
41
42 // Score a reference to the receipt animation engine.
43 scope.receiptAnimation = null;
44
45 // Flag to detect if we are using any version of the ie browser.
46 scope.isIe = window.navigator.userAgent.indexOf("MSIE ") > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./);
47
48 // null until we get value from SportsUIWeb
49 scope.matchAlertsEnabled = null;
50
51 // overlay object
52 scope.overlay = null;
53 // enumerated id which represents the request host root domain
54 scope.domainId = 0;
55 scope.DomainIdEnum = {
56 "unknown": 0,
57 "it": 1,
58 "com": 2,
59 "es": 3,
60 "gr": 4,
61 "au": 5,
62 "dk": 6
63 };
64
65 scope.deviceTagType = null;
66
67 rootDomain = window.location.hostname.split(".").pop();
68 if (window.location.hostname && scope.DomainIdEnum.hasOwnProperty(rootDomain)) {
69 scope.domainId = scope.DomainIdEnum[rootDomain];
70 }
71 // JavaScript object - Mobile bet slip settings/delegates
72 scope.bsContext = {
73 LoadBetCallModule: function (betCallDelegates) {
74 /// <summary>
75 /// Calls into BetSlipWebModule to start of betcall
76 /// </summary>
77 /// <returns type=""></returns>
78 if (scope.betslipWebModule && scope.betslipWebModule.loadBetCallModule) {
79 scope.betslipWebModule.loadBetCallModule(betCallDelegates);
80 }
81 },
82 GetBetCallController: function () {
83 if (scope.betslipWebModule && scope.betslipWebModule.getBetCallController) {
84 return scope.betslipWebModule.getBetCallController();
85 }
86
87 return null;
88 },
89 RefreshBalanceOnBetCallEnd: function () {
90 if (scope.betslipWebModule && scope.betslipWebModule.refreshUserBalance) {
91 return scope.betslipWebModule.refreshUserBalance();
92 }
93 },
94 ClientEnhancedMode: function () {
95 /// <summary>
96 /// Used a test to see if the device Mobile Premium is running on has the prerequisite requirements.
97 /// </summary>
98 /// <returns type="Boolean">A flag to 'tell' the Bet Slip which UI mode to deliver.</returns>
99
100 return false;
101 },
102 ShowStakePadToolTips: function () {
103 /// <summary>
104 /// Used to test to see if the client site requires tool tips to be shown in the stake pad.
105 /// </summary>
106 /// <returns type="Boolean">A flag to 'tell' the Bet Slip which UI mode to deliver.</returns>
107
108 return false;
109 },
110 ClientBetSlipShowing: function () {
111 /// <summary>
112 /// Delegate that allows SABSWA to ask the site if the bet slip is showing.
113 /// </summary>
114 /// <returns type="Boolean">True if the bet slip is active in the UI.</returns>
115 },
116 ClientUsesSelect: function () {
117 /// <summary>
118 /// Informs SABSWA if the client has a UL select menu for selecting the bet slip type, rather than
119 /// a select drop down. This enables Tablet to carry on using the select and mobile to use a
120 /// stylised UL pop-up (which looks like a menu) to allow bet type selection, whilst keeping
121 /// SABSWA client agnostic (for the most part).
122 /// </summary>
123 return false;
124 },
125 ClientActionInProgress: function (value) {
126 /// <summary>
127 /// Delegate that allows SABSWA to tell the client when an action is in progress, in the case of
128 /// Mobile this will stop the bet slip pop-up from being closed by the user.
129 /// </summary>
130 /// <param name="value">The value to set the flag to.</param>
131 return false;
132 },
133 GetCurrencyObject: function () {
134 /// <summary>
135 /// Provides SABSWA with the current localised currency separators for use in localisation operations.
136 /// </summary>
137 /// <returns type="JavaScript Object">An object containing the decimal and thousands separators on appropriate properties.</returns>
138 if (scope.betslipWebModule && scope.betslipWebModule.getCurrencyObject) {
139 return scope.betslipWebModule.getCurrencyObject();
140 }
141 return ({
142 decimalSeparator: window.sProps.balance.currencyDecimalSeparator,
143 thousandsSeparator: window.sProps.balance.currencyGroupSeparator
144 });
145 },
146 ClientLoginDelegate: function () {
147 /// <summary>
148 /// Enables SABSWA operations to request that the client shows a login page/pop-up.
149 /// </summary>
150 if (scope.betslipWebModule && scope.betslipWebModule.showBetslipLogin) {
151 scope.betslipWebModule.showBetslipLogin();
152 }
153 },
154 ClientQuickBetLoginDelegate: function () {
155 /// <summary>
156 /// Enables SABSWA operations to request that the client shows a login page/pop-up.
157 /// </summary>
158 if (scope.betslipWebModule && scope.betslipWebModule.showBetslipLogin) {
159 var isQuickBet = true;
160 scope.betslipWebModule.showBetslipLogin(isQuickBet);
161 }
162 },
163
164 clientAddQuickBetToBetslip: function () {
165 /// <summary>
166 /// let the webmodule to move the quickbet bet to betslip
167 /// </summary>
168 if (scope.betslipWebModule && scope.betslipWebModule.addQuickBetToBetslip) {
169 scope.betslipWebModule.addQuickBetToBetslip();
170 }
171 },
172
173 ShowBetslipBreakdownDialog: function (key) {
174 /// <summary>
175 /// Enables SABSWA operations to request a bet breakdown dialog.
176 /// </summary>
177 if (scope.betslipWebModule && scope.betslipWebModule.showBetslipBreakdownDialog) {
178 scope.betslipWebModule.showBetslipBreakdownDialog(key);
179 }
180 },
181
182 ShowPitcherDetails: function(key) {
183 if (scope.betslipWebModule && scope.betslipWebModule.showPitcherDetails) {
184 scope.betslipWebModule.showPitcherDetails(key);
185 }
186 },
187
188 updateCurrenyRate: function (value) {
189 if (scope.betslipWebModule && scope.betslipWebModule.updateCurrenyRate) {
190 scope.betslipWebModule.updateCurrenyRate(value);
191 }
192 },
193 ClientContinueDelegate: function () {
194 /// <summary>
195 /// Delegate for the client to perform additional operations after the continue button is clicked on a receipt.
196 /// </summary>
197 scope.removeBets();
198 scope.refreshSlip();
199 },
200 IsReqOnBetAddedEnabled: function () {
201 /// <summary>
202 /// Tells SABWA if it should refresh the bet slip via AJAX (to its server side code) after a bet is added to the bet slip.
203 /// </summary>
204 /// <returns type="Boolean">True if there should be a refresh.</returns>
205 return false;
206 },
207 IsReqOnBetDeletedEnabled: function () {
208 /// <summary>
209 /// Tells SABWA if it should refresh the bet slip via AJAX (to its server side code) after a bet is removed from the bet slip.
210 /// </summary>
211 /// <returns type="Boolean">True if there should be a refresh.</returns>
212 return true;
213 },
214
215 KeyboardType: function () {
216 /// <summary>
217 /// The name of this setting/delegate is misleading this should be 'Input' type. This passes
218 /// either 'Number', 'Text' or 'Tel' to SABSWA. SABSWA will then alter all stake entry fields
219 /// changing their default type of 'Text' to whatever this setting passes.
220 /// The setting itself is set server side and passed down in sProps. The decision as to which
221 /// type to use is made based on device capabilities and browser/OS combination.
222 /// We are using this method to force the device to use a numeric keyboard whenever possible.
223 /// </summary>
224 /// <returns type="String">A string containing the required input type.</returns>
225 return "";
226 },
227 // Delegate to tell SABSWA if the the user logged in
228 IsAuthenticated: function() {
229 return scope.betslipWebModule ? scope.betslipWebModule.isAuthenticated() : false;
230 },
231 // Delegate to handle a click on a join now link
232 JoinNow:function() {
233 return true;
234 },
235 /// <summary>
236 /// Called by SABSWA to launch the members history popup.
237 /// </summary>
238 MembersHistory: function () {
239 if (scope.betslipWebModule && scope.betslipWebModule.launchMembersHistory){
240 scope.betslipWebModule.launchMembersHistory();
241 }
242 },
243 BetPlacementNotification : function(success) {
244 scope.betslipWebModule.betPlacementNotification(success);
245 },
246 lifetimeDepositNotification: function () {
247 scope.betslipWebModule.lifetimeDepositNotification();
248 },
249 BetSource: function () {
250 /// <summary>
251 /// The bet source is an enumerator that is used for tracking where a bet came from in management reports.
252 /// This delegate is called by SABSWA in order to ascertain the correct source based on what mode Mobile
253 /// is being viewed in.
254 /// </summary>
255 /// <returns type="String">A string containing the appropriate bet source name.</returns>
256 return "FlashInPLay";
257 },
258 DeviceType: function () {
259 if (scope.deviceTagType !== null) {
260 return scope.deviceTagType;
261 }
262 if (scope.domainId !== scope.DomainIdEnum.it) {
263 scope.deviceTagType = "";
264 return scope.deviceTagType;
265 }
266 scope.deviceTagType = "OtherDesktopApp";
267 //Device Detection Logic
268 var userAgent = navigator.userAgent.toLowerCase() || "";
269 var platform = navigator.platform.toUpperCase() || "";
270
271 var isDesktop = (typeof window.orientation !== "undefined" ? false : true);
272 var isMac = (platform.indexOf("MAC") >= 0);
273 var isWindows = (platform.indexOf("WIN") >= 0);
274 var isLinux = (platform.indexOf("LINUX") >= 0);
275 var isAndroid = userAgent.indexOf("android") > -1;
276 var isMobile = false, isTablet = false, isMobileApp = false;
277 var isIphone = (platform === "IPHONE" || userAgent.indexOf("iphone") >= 0);
278 var isIpad = (platform === "IPAD" || userAgent.indexOf("ipad") >= 0);
279 var isIpod = (platform === "IPOD" || userAgent.indexOf("ipod") >= 0);
280 var isIOS = isIphone || isIpad || isIpod;
281 var isWindowsPhone = userAgent.indexOf("windows phone") > -1 || userAgent.indexOf("microsoft build") > -1;
282 if (isAndroid) {
283 isMobile = userAgent.indexOf("mobile") >= 0;
284 if (!isMobile) {
285 isTablet = true;
286 }
287 isMobileApp = userAgent.indexOf("b365sports") > -1;
288 }
289 if (isIOS) {
290 isMobile = isIphone || isIpod;
291 if (!isMobile) {
292 isTablet = true;
293 }
294 isMobileApp = userAgent.indexOf("bet365wrapper") > -1;
295 }
296 if (isWindowsPhone) {
297 isMobile = true;
298 }
299
300 //Mapping to TagTypes
301 if (isIOS && isMobileApp) {
302 scope.deviceTagType = "iOSMobileApp";
303 }
304 if (isIOS && !isMobileApp) {
305 scope.deviceTagType = "iOSMobileBrowser";
306 }
307 if (isDesktop && !isMobileApp && isMac) {
308 scope.deviceTagType = "iOSDesktopBrowser";
309 }
310 if (isIpad && isMobileApp) {
311 scope.deviceTagType = "iOSTabletApp";
312 }
313 if (isDesktop && (isAndroid || isLinux)) {
314 scope.deviceTagType = "AndroidDesktopBrowser";
315 }
316 if (isMobile && isAndroid && isMobileApp) {
317 scope.deviceTagType = "AndroidMobileApp";
318 }
319 if (isMobile && isAndroid && !isMobileApp) {
320 scope.deviceTagType = "AndroidMobileBrowser";
321 }
322 if (isTablet && isAndroid && isMobileApp) {
323 scope.deviceTagType = "AndroidTabletApp";
324 }
325 if (isWindowsPhone) {
326 scope.deviceTagType = "WindowMobileBrowser";
327 }
328 if (!isWindowsPhone && isWindows && isDesktop && !isAndroid && !isIOS) {
329 scope.deviceTagType = "WindowsDesktopBrowser";
330 }
331 return scope.deviceTagType;
332 },
333
334 ShowStreaming: function () {
335 /// <summary>
336 /// Tells SABSWA if it should show streaming icons in the bet slip.
337 /// </summary>
338 /// <returns type="Boolean">True if streaming is enabled/supported.</returns>
339 return true;
340 },
341 ShowFullTextMode: function () {
342 /// <summary>
343 /// Tells SABSWA whether to render full text descriptions for each bet type (when and where appropriate).
344 /// Since the v6 redesign this should always be true on Mobile.
345 /// </summary>
346 /// <returns type="Boolean">True if we want full text across the board.</returns>
347 return true;
348 },
349 OnStreamingClick: function (streamingObject) {
350 /// <summary>
351 /// The bet slip can show icons to the user to allow them to watch streams. Clicking these calls this
352 /// delegate to allow the client to perform the most appropriate operation and handle the showing
353 /// of the stream to the user.
354 /// </summary>
355 /// <param name="streamingObject">An object containing the information required by the client to show the stream in question.</param>
356 },
357 ShowConfirmation: function (bsinst, confirmationObject) {
358 /// <summary>
359 /// SABSWA operations sometimes result in dialogue boxes being generated, that require the user to confirm or cancel an operation
360 /// such as referred bets for example.
361 /// This delegate allows SABSWA to pass the generated HTML content back to the client
362 /// for display using the client's preferred method.
363 /// </summary>
364 /// <param name="confirmationObject"></param>
365 if (!scope.confirmationManger) {
366 scope.confirmationManger = new BetSlipShowConfirmationHandler(bsinst);
367 }
368 scope.confirmationManger.handle(confirmationObject);
369 },
370 showSiteConfirmation: function (confirmationObject) {
371 /// <summary>
372 /// SABSWA operations sometimes result in dialogue boxes being generated, that require the user to confirm or cancel an operation
373 /// such as referred bets for example.
374 /// This delegate allows SABSWA to pass the generated HTML content back to the client
375 /// for display using the client's preferred method.
376 /// </summary>
377 /// <param name="confirmationObject"></param>
378
379 //let the web know require launcing the popup with the given details
380 scope.betslipWebModule.showBetslipSiteDialog(confirmationObject);
381 },
382 showPushbetDialog: function (pushDataObject) {
383 /// <summary>
384 /// SABSWA operations sometimes result in dialogue boxes being generated, that require the user to confirm or cancel an operation
385 /// such as push bets for example.
386 /// This delegate allows SABSWA to pass the details back to the client
387 /// for display using the client's preferred method.
388 /// </summary>
389 /// <param name="pushDataObject"></param>
390
391 //let the web know require launcing the popup with the given details
392 scope.betslipWebModule.showPushbetDialog(pushDataObject);
393 },
394 getPushPopupStatus: function(betId) {
395 return scope.betslipWebModule.currentPushBetPopupStatus(betId);
396 },
397
398 /// <summary>
399 /// When a popup is displaying this method is called to reposition it if the betslip height/width
400 /// has changed.
401 /// </summary>
402 repositionPopup: function () {
403 if (scope.betslipWebModule) {
404 scope.bsContext.additionalResizeRequired();
405 scope.betslipWebModule.repositionPopup();
406 }
407 },
408
409 /// <summary>
410 /// set the additional resize boolean to true to allow the betslip to be resized when a popup on SportsUIWeb is displaying.
411 /// </summary>
412 additionalResizeRequired: function () {
413 if (scope.betslipWebModule && scope.betslipWebModule.setAdditionalResizeRequired) {
414 scope.betslipWebModule.setAdditionalResizeRequired(true);
415 }
416 },
417
418 ShowDialog: function (dialogueObject) {
419 /// <summary>
420 /// SABSWA operations sometimes result in dialogue boxes being generated.
421 /// This delegate allows SABSWA to pass the generated HTML content back to the client
422 /// for display using the client's preferred method.
423 /// </summary>
424 /// <param name="dialogueObject">An object containing the mark-up and other information for the dialogue box.</param>
425// new BetSlipShowDialogHandler(dialogueObject).handle();
426 },
427 ShowTooltip: function (toolTipObject) {
428 /// <summary>
429 /// SABSWA operations sometimes result in a tool tip or pop-up needed to be shown to the user.
430 /// This delegate is called from SABSWA so that the content can be passed down and shown using
431 /// the client's preferred method(s).
432 /// </summary>
433 /// <param name="toolTipObject">An object containing the detail of the tooltip.</param>
434// new BetSlipShowDialogHandler({ MarkUp: "<p>" + toolTipObject.Content + "</p>" }).handle();
435 },
436 RefreshUserBalance: function () {
437 /// <summary>
438 /// Tells SABSWA to return the user balance - via its server side code. Warning turning this to true can increase database load.
439 /// </summary>
440 /// <returns type="Boolean">True if we want SABSWA to do this.</returns>
441 return false;
442 },
443 ItemsRemoved: function (betObject) {
444 /// <summary>
445 /// Delegate used by SABSWA to 'tell' the client site that a bet has been removed.
446 /// </summary>
447 /// <param name="betObject">A bet object.</param>
448 scope.itemsRemoved(betObject.Id);
449 },
450 // Determines whether returns calculations should be performed using prices truncated to 2 decimal places
451 SetupTruncated2dpPriceForReturnsCalc: function () {
452 if (scope.domainId === scope.DomainIdEnum.it) {
453 window.bs.useTruncated2dpPriceForReturnsCalc = (!window.pushedConfig || !window.pushedConfig.getIsPSQFV4Enabled());
454 } else {
455 window.bs.useTruncated2dpPriceForReturnsCalc = false;
456 }
457 },
458 StakeEntryRule: function () {
459 // Default is null, which means SABSWA will use it's default stake entry rules, which are built in to each stake entry class.
460 return null;
461 },
462 PushBetRulesUrl: function () {
463 /// <summary>
464 /// Link to the push bet rules
465 /// </summary>
466 /// <returns type=""></returns>
467 return "";
468 },
469 HighlightSelectedBets: function () {
470 /// <summary>
471 /// Highlight bets which are on the bet slip
472 /// </summary>
473 },
474 PushBetPopupAcceptedHandler: function (betId) {
475 if (scope.betslipWebModule && scope.betslipWebModule.pushBetPopupAcceptedHandler) {
476 scope.betslipWebModule.pushBetPopupAcceptedHandler(betId);
477 }
478 return null;
479 },
480 IsMatchAlertsEnabled: function () {
481 /// <summary>
482 /// Are match alert notifications enabled
483 /// </summary>
484 /// <returns type="Boolean"></returns>
485
486 if (scope.matchAlertsEnabled != null) {
487 return scope.matchAlertsEnabled;
488 };
489
490 if (scope.betslipWebModule && scope.betslipWebModule.isMatchAlertsAvailiable) {
491 // set local var so we dont need to make constant requests to SportsUIWeb
492 scope.matchAlertsEnabled = scope.betslipWebModule.isMatchAlertsAvailiable();
493 return scope.matchAlertsEnabled;
494 }
495 return false;
496 },
497 ShowSiteOverlaySpinner: function () {
498 /// <summary>
499 /// Display the site spinner on top of the overlay
500 /// </summary>
501 },
502
503 HideSiteOverlaySpinner: function () {
504 /// <summary>
505 /// Remove any existing site overlay and spinner that may currently be applied
506 /// </summary>
507 },
508 BetCallTwilioSupported: function () {
509 /// <summary>
510 /// Betcall V2 Twilio feature is enabled and supported
511 /// </summary>
512 return window.sProps && window.sProps.clickToCall && sProps.clickToCall.twiliosupported === true;
513 },
514 AppType: function () {
515 /// <summary>
516 /// Type of app used
517 /// </summary>
518 return "";
519 },
520 AppVersion: function () {
521 /// <summary>
522 /// Version of app
523 /// </summary>
524 return "";
525 },
526 //Toggle the QuickBet Help Tool Tip
527 ToggleQuickBetHelpTooltip: function (toggle) {
528 if (scope.betslipWebModule && scope.betslipWebModule.resetBetslipProgress) {
529 scope.betslipWebModule.toggleQuickBetHelpTooltip(toggle);
530 }
531 },
532 betCallConnectedDelegate: function () {
533
534 },
535 betCallDisconnectedDelegate: function () {
536
537 },
538 subscribeItem: function (topic) {
539 /// <summary>
540 /// subscribe betslip item for updates
541 /// </summary>
542 if (scope.betslipWebModule && !scope.subscriptionManager) {
543 scope.subscriptionManager = scope.betslipWebModule.getBetslipSubscriptionManager();
544 }
545 if (scope.betslipWebModule && scope.subscriptionManager) {
546 scope.subscriptionManager.subscribe(topic);
547 }
548 },
549 unsubscribeItem: function (topic) {
550 /// <summary>
551 /// unsubscribe betslip item
552 /// </summary>
553 if (scope.betslipWebModule && !scope.subscriptionManager) {
554 scope.subscriptionManager = scope.betslipWebModule.getBetslipSubscriptionManager();
555 }
556 if (scope.betslipWebModule && scope.subscriptionManager) {
557 scope.subscriptionManager.unsubscribe(topic);
558 }
559 },
560 getFormatedOdds: function (odds, decimalPlaces, oddsTypeOverride) {
561 /// <summary>
562 /// current session odds type
563 /// </summary>
564 if (scope.betslipWebModule && scope.betslipWebModule.getFormatedOdds) {
565 return scope.betslipWebModule.getFormatedOdds(odds, decimalPlaces, oddsTypeOverride);
566 }
567
568 return odds;
569 },
570 getUsersOddsType: function () {
571 /// <summary>
572 /// gets the users odd type
573 /// </summary>
574 if (scope.betslipWebModule && scope.betslipWebModule.getUsersOddsType) {
575 return scope.betslipWebModule.getUsersOddsType();
576 }
577
578 return 1;
579 },
580 setBetguid: function (betGuid) {
581 /// <summary>
582 /// update the betguid at module level incase of lotto bets to use
583 /// </summary>
584 if (scope.betslipWebModule && scope.betslipWebModule.setBetguid) {
585 scope.betslipWebModule.setBetguid(betGuid);
586 }
587 },
588 getBetguid: function () {
589 /// <summary>
590 /// gate the latest betguid
591 /// </summary>
592 if (scope.betslipWebModule && scope.betslipWebModule.getBetguid) {
593 return scope.betslipWebModule.getBetguid();
594 }
595
596 return null;
597 },
598 setTelebetBetslip: function (istelebet) {
599 /// <summary>
600 /// tell the betslip header to change over to telebet
601 /// </summary>
602 if (scope.betslipWebModule && scope.betslipWebModule.setTelebetBetslip) {
603 return scope.betslipWebModule.setTelebetBetslip(istelebet);
604 }
605 },
606 setMicrophoneAvailable: function (micAvailable) {
607 /// <summary>
608 /// tell the betslip the microphonestate
609 /// </summary>
610 if (scope.betslipWebModule && scope.betslipWebModule.setMicrophoneAvailable) {
611 return scope.betslipWebModule.setMicrophoneAvailable(micAvailable);
612 }
613 },
614 resizeBetslip: function() {
615 if (scope.resizeBetslip) {
616 scope.resizeBetslip();
617 }
618 },
619 resyncBetBank: function(betIds) {
620 if (scope.betslipWebModule && scope.betslipWebModule.resyncBetBank) {
621 scope.betslipWebModule.resyncBetBank(betIds);
622 }
623 },
624 RetainSelectionsDelegate: function() {
625 //reset the receipt animation, incase any interruptions happen by adding selection while in animation
626 if (scope.receiptAnimation) {
627 scope.receiptAnimation.animationRunning = false;
628 }
629 },
630 setQuickBetTooltipDismissed: function (quickBetToolTipDismissed) {
631 if (scope.betslipWebModule && scope.betslipWebModule.setQuickBetTooltipDismissed) {
632 scope.betslipWebModule.setQuickBetTooltipDismissed(quickBetToolTipDismissed);
633 }
634 },
635 getQuickBetTooltipDismissed: function () {
636 if (scope.betslipWebModule && scope.betslipWebModule.getQuickBetTooltipDismissed) {
637 return scope.betslipWebModule.getQuickBetTooltipDismissed();
638 }
639 },
640 setQuickBetEnabled: function (quickBetEnabled) {
641 if (scope.betslipWebModule && scope.betslipWebModule.setQuickBetEnabled) {
642 scope.betslipWebModule.setQuickBetEnabled(quickBetEnabled);
643 }
644 },
645 getQuickBetEnabled: function () {
646 if (scope.betslipWebModule && scope.betslipWebModule.getQuickBetEnabled) {
647 return scope.betslipWebModule.getQuickBetEnabled();
648 }
649 },
650 setAusMultiplesAvailable: function (ausMultiplesAvailable) {
651 if (scope.betslipWebModule && scope.betslipWebModule.setAusMultiplesAvailable) {
652 scope.betslipWebModule.setAusMultiplesAvailable(ausMultiplesAvailable);
653 }
654 },
655 getAusMultiplesAvailable: function () {
656 if (scope.betslipWebModule && scope.betslipWebModule.getAusMultiplesAvailable) {
657 return scope.betslipWebModule.getAusMultiplesAvailable();
658 }
659 },
660 setMatchAlertSubscriptionState: function (fixture) {
661 if (scope.betslipWebModule && scope.betslipWebModule.setMatchAlertSubscriptionState) {
662 scope.betslipWebModule.setMatchAlertSubscriptionState(fixture);
663 }
664 },
665 populateMatchAlerts: function (fixtures) {
666 if (scope.betslipWebModule && scope.betslipWebModule.populateMatchAlerts) {
667 scope.betslipWebModule.populateMatchAlerts(fixtures);
668 }
669 }
670 };
671
672 scope.init = function () {
673 /// <summary>
674 /// Initialise the bet slip app - connect to the app and attach listeners for events specific to the mobile premium site
675 /// </summary>
676
677 scope.betslipWebModule = getBetslipWebModule();
678 if (scope.betslipWebModule) {
679 scope.betslipWebModule.registerSABSWA(scope);
680 scope.betslipWebModule.userPrefs && scope.betslipWebModule.userPrefs.setTwilioSupported && scope.betslipWebModule.userPrefs.setTwilioSupported(scope.bsContext.BetCallTwilioSupported());
681 }
682
683 scope.bsController = new window.BetSlipController(window.bs, scope.bsContext);
684 scope.bsController.initialise();
685
686 scope.bsController.OnBetslipContentLoaded();
687
688 // Set a flag to dictate if push market checks are required - only Italy at this stage
689 scope.bsController.setPushMarketsEnabled(scope.domainId == 1);
690
691 new BetslipEventAttacher(window.bs, scope).attach();
692
693 scope.setupView();
694
695 //initalise the microphone betcall in australia only
696 scope.bsController.initialiseMicrophone();
697
698 /// Setup 2dp truncation, needs to be done after we have a push connection
699 /// This is done within here for web as we need pushed config to be available first. In Mobile this is just called inline from controller.js
700 scope.bsContext.SetupTruncated2dpPriceForReturnsCalc();
701
702 scope.bsController.refreshBetslip();
703
704 scope.subscriptionManager = scope.betslipWebModule && scope.betslipWebModule.getBetslipSubscriptionManager();
705
706 // add this call to ensure the bet bank is populating. In some instances, SUI participants call in to BetslipManager.isSelected()
707 // before we have had chance to be registered in betslipmanager resulting in selected participants failing to highlight.
708 // populating the bet bank also fires highlight events so this will ensure the highlighting is enforced. See supwui-5564
709 if (scope.betslipWebModule && scope.betslipWebModule.refershBetslipCompleted) {
710 scope.betslipWebModule.refershBetslipCompleted();
711 }
712 };
713
714 scope.register = function () {
715 //register with betslip interface
716 scope.betslipWebModule = getBetslipWebModule();
717
718 if (scope.betslipWebModule && scope.betslipWebModule.registerSABSWA) {
719 scope.betslipWebModule.registerSABSWA(scope);
720 }
721 else {
722 setTimeout(scope.register, 1000);
723 }
724 };
725
726 scope.setupView = function () {
727 /// <summary>
728 /// Ensure the view is in the correct state.
729 /// </summary>
730
731 //Listen for resize events to handle switch between normal and expanded mode
732 window.addEventListener("resize", scope.resizeHandler);
733 };
734
735 scope.resizeHandler = function () {
736 /// <summary>
737 /// Handle resize events and pass to controller
738 /// </summary>
739 scope.bsController.resizeHandler();
740 }
741
742 scope.refreshSlip = function (reqType) {
743 /// <summary>
744 /// Initiate a bet slip API bet slip refresh.
745 /// </summary>
746 scope.bsController.refreshBetslip(reqType);
747 };
748
749 scope.subscriptionHandler = function (event, type) {
750 /// <summary>
751 /// subscription handler to handle updates on betslip items
752 /// </summary>
753 scope.bsController.subscriptionHandler(event, type);
754 };
755
756 scope.addBet = function (args, element) {
757 /// <summary>
758 /// Add a bet following a selection click.
759 /// </summary>
760 /// <param name="args">Either and argument array or the construct string for the price that was clicked.</param>
761 /// <param name="element">The selected element.</param>
762 var addBetSuccessCallBack,
763 constructString = "";
764
765 //reset the receipt animation, incase any interruptions happen by adding selection while in animation
766 if (scope.receiptAnimation) {
767 scope.receiptAnimation.animationRunning = false;
768 }
769
770 //check if we have any bet in progress, then reset the addbet anot don't highlight it
771 if (scope.bsController._bsInst.locked && scope.bsController._bsInst.locked()) {
772 scope.resetBetslipProgress();
773 return;
774 }
775
776 // For cast bets construcString is an array, so don't
777 // add the media type, it will be handled in bet slip API.
778 if (typeof (args) === "string") {
779 constructString = args + scope.getMediaType(args);
780 } else {
781 if (args.ConstructString) {
782 constructString = args.ConstructString + scope.getMediaType(args);
783 } else {
784 constructString = args;
785 }
786 }
787
788 if (!constructString) {
789 return;
790 }
791
792 addBetSuccessCallBack = $.proxy(function () {
793 scope.addBetSuccessCallBack(args);
794 }, this);
795
796 scope.bsController.addBet(constructString, false, addBetSuccessCallBack);
797 };
798
799 scope.getMediaType = function (constructString) {
800 /// <summary>
801 /// Return the media type construct for the bet slip.
802 /// </summary>
803 /// <param name="constructString">The construct string for the selected price.</param>
804 /// <returns type="String">A string for stating the media type for the element in question.</returns>
805 var cpnKeyElm = document.getElementById("CpKey"),
806 key;
807
808 if (!cpnKeyElm || cpnKeyElm.value === "") {
809 return "";
810 } else {
811 key = new CouponKey(cpnKeyElm.value);
812 return key.inplay ? constructString.indexOf("TP=") > -1 ? "mt=1" : "mt=14" : "";
813 }
814 };
815
816 scope.addBetSuccessCallBack = function (args) {
817 /// <summary>
818 /// called when the bet get added successfully to the slip
819 /// </summary>
820 /// <param name="constructString"></param>
821 /// <param name="element"></param>
822
823 // let the betslip interface know the bet added successfully
824 if (scope.betslipWebModule) {
825 scope.betslipWebModule.addBetSuccess(args);
826
827 //If we've built the betcall handler we're in aus - check to see if we should show login prompt
828 if (scope.bsController.betCallHandler && scope.bsController.betCallHandler.showLoginPrompt()) {
829
830 if (scope.bsController.setTelebetBetslip) {
831 scope.bsController.setTelebetBetslip(scope.hasPhoneOnlyItemOnSlip());
832 }
833
834 scope.betslipWebModule.showBetslipLogin();
835 }
836 }
837 };
838
839 scope.deleteBet = function (constructString, element) {
840 /// <summary>
841 /// Delete a bet after removing the highlight from the selection.
842 /// </summary>
843 /// <param name="constructString">The construct string for the bet in question.</param>
844 /// <param name="element">The related DOM element.</param>
845 scope.bsController.deleteBet(constructString);
846 };
847
848 scope.deleteCastBet = function (constructString, element) {
849 /// <summary>
850 /// Delete a bet after removing the highlight from the selection.
851 /// </summary>
852 /// <param name="constructString">The construct string for the bet in question.</param>
853 /// <param name="element">The related DOM element.</param>
854 scope.bsController.deleteCastBet(constructString);
855 };
856
857 scope.phoneBet = function (constructString) {
858 /// <summary>
859 /// Trigger a phone bet request.
860 /// </summary>
861 /// <param name="constructString">The construct string for the bet in question.</param>
862 scope.bsController.initiatePhoneBetRequest(constructString);
863 };
864
865 scope.placeBet = function () {
866 /// <summary>
867 /// Attempt to place a bet.
868 /// </summary>
869
870 scope.bsController.placeBet();
871 };
872
873 scope.confirmBet = function () {
874 /// <summary>
875 /// Confirm place a bet.
876 /// </summary>
877
878 scope.bsController.confirmBet();
879 };
880
881 scope.removeBets = function () {
882 /// <summary>
883 /// Remove all bets from the bet slip.
884 /// </summary>
885 if (scope.getBetCount(scope.bsController._bsInst) > 0) {
886 scope.bsController.removeBets();
887 } else {
888 scope.bsController.itemsRemoved();
889 }
890 };
891
892 scope.checkPlaceBetStatus = function () {
893 /// <summary>
894 /// Check if the bet should be placed automatically.
895 /// For example the user may have selected 'login and place bet'.
896 /// </summary>
897 if (scope.placeBetAfterLogin()) {
898 scope.placeBet();
899 siteDataSession.setItem("loginPlaceBet", "false");
900 }
901 };
902
903 scope.placeBetAfterLogin = function () {
904 /// <summary>
905 /// Check if user has selected login and place bet.
906 /// </summary>
907 /// <returns type="Boolean">A flag which reflects the user's action.</returns>
908 return !!siteDataSession.getItem("loginPlaceBet") && (siteDataSession.getItem("loginPlaceBet") == "true" ? true : false);
909 };
910
911 scope.placeBetSuccess = function () {
912 /// <summary>
913 /// calls by sabswa when the bet get placed successfully
914 /// </summary>
915 if (scope.betslipWebModule && scope.betslipWebModule.placeBetSuccess) {
916 scope.betslipWebModule.placeBetSuccess();
917 }
918 };
919
920 scope.resetBetslipProgress = function () {
921 /// <summary>
922 /// calls by sabswa when any scenarios to reset the betslip queue
923 /// </summary>
924 if (scope.betslipWebModule && scope.betslipWebModule.resetBetslipProgress) {
925 scope.betslipWebModule.resetBetslipProgress();
926 }
927 };
928
929 scope.hideBetslip = function () {
930 /// <summary>
931 /// Hide the bet slip & show the site.
932 /// </summary>
933
934 };
935
936 scope.hasPhoneOnlyItemOnSlip = function () {
937 /// <summary>
938 /// Check if the slip contains a phone only market.
939 /// </summary>
940 /// <returns type="Boolean">Whether the slip contains a POM.</returns>
941 var items;
942 if (window.bs) {
943 items = window.bs.getBetItems();
944 for (var i = 0, length = items.length ; i < length; i++) {
945 if (items[i].getStItem("pom") === "Y") {
946 return true;
947 }
948 }
949
950 }
951 return false;
952 };
953
954 scope.showBetslip = function () {
955 /// <summary>
956 /// Show the bet slip and hide the site.
957 /// </summary>
958 var betslipContainer,
959 pageFooter,
960 pageFooterForm,
961 betslipBar,
962 navbar,
963 backToTopBigBttn,
964 backToTopBigBttnInput,
965 navbarHeight,
966 betslipBarHeight,
967 pageFooterFormHeight,
968 viewportHeight,
969 calculatedMinHeight;
970
971 $("#betslipContainer").show();
972 $("#Site").attr("data-bsmode", "on");
973 $("#Main").hide();
974 $("#betslipBar").hide();
975 viewLoaded();
976
977 if (scope.overlay) {
978 scope.overlay.remove();
979 }
980
981 if (Modernizr.inplaypush) {
982 betslipContainer = document.getElementById("betslipContainer");
983 pageFooter = document.getElementById("PageFooter");
984 pageFooterForm = pageFooter.parentNode;
985 betslipBar = document.getElementById("betslipBar");
986 navbar = document.getElementById("NavBar");
987 backToTopBigBttn = document.getElementById("BackToTopBigBttn");
988 backToTopBigBttnInput = (backToTopBigBttn ? backToTopBigBttn.childNodes[1] : null);
989 navbarHeight = (navbar ? navbar.clientHeight : 0);
990 betslipBarHeight = (betslipBar ? betslipBar.clientHeight : 0);
991 pageFooterFormHeight = (pageFooterForm ? pageFooterForm.clientHeight : 0);
992 viewportHeight = clientViewport().height;
993 calculatedMinHeight = viewportHeight - pageFooterFormHeight - navbarHeight - betslipBarHeight;
994
995 if (betslipContainer) {
996 betslipContainer.style.minHeight = calculatedMinHeight + "px";
997 if (pageFooterForm && backToTopBigBttn && backToTopBigBttnInput) {
998 if (viewportHeight > (betslipContainer.clientHeight + navbarHeight + betslipBarHeight)) {
999 backToTopBigBttnInput.setAttribute("class", "hidden");
1000 } else {
1001 backToTopBigBttnInput.setAttribute("class", "");
1002 }
1003 }
1004 }
1005 }
1006 };
1007
1008 scope.updateBetslipBar = function (betCount) {
1009 /// <summary>
1010 /// Update the bet slip bar as per the bet count. Set bet slip bar display status.
1011 /// </summary>
1012 /// <param name="betCount">The new count.</param>
1013
1014 };
1015
1016 scope.resizeBetslip = function () {
1017 /// <summary>
1018 /// Resizes the betslip frameElement
1019 /// </summary>
1020 /// <param name="slideOpen">Indicates that the popup should slide open if it needs to.</param>
1021 var height;
1022 var isReceipt = document.getElementsByClassName("betReceipt").length > 0;
1023 var runAnimation = false;
1024 var ie8 = document.documentElement.className.indexOf("ie-8") > -1;
1025 var betSlipContainer = document.getElementById("betslipContainer");
1026 var dialogMsg = document.getElementsByClassName("bs-dialogMessage");
1027 var pbButton = document.querySelectorAll(".placeBet .bs-Btn");
1028
1029
1030 if (!scope.betslipWebModule) return;
1031
1032
1033 if (isReceipt && !ie8) {
1034
1035 //Run the receipt animation and get the new height
1036 if (!scope.receiptAnimation) {
1037 scope.receiptAnimation = new b365.Ui.Betslip.ReceiptLoadAnimation();
1038 }
1039 if (scope.receiptAnimation.setup(scope.bsController, scope.betslipHeight)) {
1040 runAnimation = true;
1041 height = scope.receiptAnimation.height;
1042 }
1043
1044 }
1045
1046 // Changing the betslips height here when the betRefer popup doesn't fit inside the betslip
1047 if (dialogMsg.length > 0 && dialogMsg[0].className.indexOf("confirmDialogue") > -1) {
1048 var dialogMsgRects = dialogMsg[0].getBoundingClientRect();
1049 var newSlipHeight = (dialogMsgRects.top * 2) + (dialogMsgRects.bottom - dialogMsgRects.top);
1050 if(betSlipContainer && newSlipHeight > betSlipContainer.scrollHeight){
1051 var oldBrowser = ie8 || document.documentElement.className.indexOf("ie-9") > -1;
1052 if(oldBrowser){
1053 document.getElementsByClassName("bs-dialogOverlay")[0].style.height = newSlipHeight;
1054 }
1055 scope.betslipWebModule.resizeBetslip(height, { runAnimation: runAnimation, animStart: function () { scope.receiptAnimation.animate(); } });
1056 betSlipContainer.style.height = newSlipHeight + "px";
1057 scope.betslipHeight = newSlipHeight + "px";
1058 return;
1059 }
1060 }
1061
1062 if (!height) {
1063 //Get height if we've not already resolved it.
1064 height = document.getElementById("betslipContainer").clientHeight;
1065 }
1066
1067 // We only resize on sports ui if we've had a data change whilst a pop ups displayed or we're not displaying a popup.
1068 if (!scope.betslipWebModule.isPopupShown() || this.betslipWebModule.isAdditionalResizeRequired()) {
1069 scope.betslipWebModule.resizeBetslip(height, { runAnimation: runAnimation, animStart: function () { scope.receiptAnimation.animate(); } });
1070 if (this.betslipWebModule.isAdditionalResizeRequired()) {
1071 this.betslipWebModule.setAdditionalResizeRequired(false);
1072 }
1073 }
1074
1075 // Delay the height increase on the module if there has been a resize whilst popup open.
1076 else if (scope.betslipWebModule.isPopupShown()) {
1077 scope.betslipWebModule.resizeBetslip(height, null, true);
1078 }
1079
1080 // Check if our button height has increased (thus meaning we're wrapping) so we can add additional styles to resolve
1081 // line height changes
1082 if (pbButton[0]) {
1083 var placeBetButton = pbButton[0];
1084 var theHeight = placeBetButton.offsetHeight;
1085 // IE-8 is deciding it has an additional pixel
1086 var maxHeight = ie8 ? 32 : 31;
1087 if (theHeight > maxHeight && placeBetButton.className.indexOf(" bs-Btn-wrapped") == -1) {
1088 placeBetButton.className = placeBetButton.className + " bs-Btn-wrapped";
1089 }
1090 else if (theHeight <= maxHeight) {
1091 placeBetButton.className = placeBetButton.className.replace(" bs-Btn-wrapped", "");
1092 }
1093 }
1094
1095 scope.betslipHeight = height;
1096
1097 };
1098
1099 scope.popupShow = function (popupHeight) {
1100 /// <summary>
1101 /// Resizes the betslip frameElement to allow for popups that overflow the bottom of the betslip
1102 /// </summary>
1103 /// <param name="betCount">The popup element to be adjusted for.</param>
1104
1105 if (scope.betslipWebModule) {
1106 popupHeight += 30; //Allows a little extra for measurement issues
1107 scope.betslipWebModule.popupShow(popupHeight);
1108 }
1109 };
1110
1111 scope.popupHide = function () {
1112 /// <summary>
1113 /// Resizes the betslip frameElement to allow for popups that overflow the bottom of the betslip
1114 /// </summary>
1115 /// <param name="betCount">The popup element to be adjusted for.</param>
1116
1117 if (scope.betslipWebModule) {
1118
1119 //Call to remove the height set, resetting to the original height
1120 scope.betslipWebModule.popupHide();
1121 }
1122
1123 if (scope.bsController && scope.bsController.webPopupManager) {
1124 scope.bsController.webPopupManager.popupHide();
1125 }
1126 };
1127
1128 scope.getBetCount = function (bsInst) {
1129 /// <summary>
1130 /// Get the bet slip bet count from the bet slip instance.
1131 /// If the cookie processed flag is set then we can assume bets have been placed and we are in receipt mode i.e. bets = 0
1132 /// </summary>
1133 /// <param name="bsInst">The instantiated bet slip instance.</param>
1134
1135 bsInst = bsInst || scope.bsController._bsInst;
1136 return bsInst.getValueFromBSCookie("processed").replace("||", "") == "true" ? 0 : bsInst.numItems(false);
1137 };
1138
1139 scope.setBetslipBarDisplay = function () {
1140 /// <summary>
1141 /// Set the bet slip bar display status.
1142 /// To display:
1143 /// 1 Bets on the slip.
1144 /// 2 Bet Slip is not showing (Enhanced mode only).
1145 /// </summary>
1146 };
1147
1148 scope.addOnBetAddedReqComplete = function () {
1149 if (scope.betslipWebModule && scope.betslipWebModule.addBetCompleted) {
1150 scope.betslipWebModule.addBetCompleted();
1151 }
1152 };
1153
1154 scope.addOnRefreshReqComplete = function() {
1155 if (scope.betslipWebModule && scope.betslipWebModule.refershBetslipCompleted) {
1156 scope.betslipWebModule.refershBetslipCompleted();
1157 }
1158 };
1159
1160 scope.getBetslipItems = function() {
1161
1162 var items = window.bs.getBetItems(),
1163 bets = {},
1164 id,
1165 placeParticipant,
1166 fixtureId,
1167 partType,
1168 betid,
1169 i;
1170
1171 for (i=0; i<items.length; i++) {
1172
1173 id = items[i].getCnItem("id");
1174
1175 if (id) {
1176
1177 placeParticipant = items[i].getCnItem("pp");
1178 fixtureId = items[i].getCnItem("f");
1179 partType = items[i].getCnItem("pt");
1180 betid = id.replace("Y", "").replace("N", "");
1181
1182 if (placeParticipant && (partType === "N" || partType === "A")) {
1183 bets[betid] = {
1184 "ConstructString": items[i].toString(),
1185 "Uid": betid,
1186 "fixtureId": fixtureId,
1187 "placeParticiant": placeParticipant
1188 };
1189
1190 } else {
1191 bets[betid] = {
1192 "ConstructString": items[i].toString(),
1193 "Uid": betid
1194 };
1195
1196 }
1197 }
1198 }
1199
1200 items = window.bs.getBetItems(window.bs.itemTypeCast);
1201 for (var j = 0; j < items.length; j++) {
1202 if (items[j].getCnItem("fp")) {
1203 var castbetid = items[j].getCnItem("fp");
1204 bets[castbetid] = {
1205 "ConstructString": items[j].toString(),
1206 "Uid": castbetid
1207 };
1208 }
1209 }
1210
1211
1212 return bets;
1213 };
1214
1215 scope.getBalanceFromMarkup = function () {
1216 /// <summary>
1217 /// The balance is retrieved from the bet slip application mark-up.
1218 /// </summary>
1219 return "";
1220 };
1221
1222 scope.getStakeFromMarkup = function () {
1223 /// <summary>
1224 /// The balance is retrieved from the bet slip app mark-up.
1225 /// </summary>
1226 var balance = $("ul", "#bsDiv").attr("data-st");
1227
1228 return typeof (balance) != "undefined" ? balance : "";
1229 };
1230
1231 scope.isSelected = function (id) {
1232 /// <summary>
1233 /// Determine if a Bet Item is to be selected.
1234 /// </summary>
1235 /// <param name='id'>The identifier for the BetItem currently the ParticipantId.</param>
1236 /// <returns type='Boolean'>A flag stating if the bet item is selected or not.</returns>
1237 var bsInst = scope.bsController._bsInst;
1238 var subId = id + "Y"; //add subscription flags
1239 var nonSubId = id + "N";
1240 scope.betCount = scope.getBetCount(bsInst);
1241 return scope.betCount > 0 && (bsInst.getBetItemByCn(bsInst.betTypeNormal, "id", id) !== undefined || bsInst.getBetItemByCn(bsInst.betTypeNormal, "id", subId) !== undefined || bsInst.getBetItemByCn(bsInst.betTypeNormal, "id", nonSubId) !== undefined);
1242 };
1243
1244 scope.itemsRemoved = function (id) {
1245 /// <summary>
1246 /// Called if one or more items are removed from the bet slip.
1247 /// </summary>
1248 /// <param name="id">A bet item id or nothing.</param>
1249 if (scope.betslipWebModule) {
1250 scope.betslipWebModule.deHighlightBet(id);
1251 scope.betslipWebModule.removePushBetFromPrefs(id);
1252
1253 }
1254 };
1255
1256 scope.animateReceiptToMyBetsButton = function (betCount) {
1257 /// <summary>
1258 /// Animate the receipt then call the set My Bets count function.
1259 /// </summary>
1260 /// <param name="betCount">The number of items on the receipt.</param>
1261 var postAnimationBetCount = betCount,
1262 $receiptElement = $("#betslipContainer"),
1263 receiptClone = document.createElement("div"),
1264 receiptCloneElement,
1265 myBetsAnimationClass,
1266 pageWidth = document.body.clientWidth;
1267
1268 // Show the clone of the receipt and then hide the actual receipt.
1269 receiptClone.id = "betslipContainerMyBetsClone";
1270 receiptClone.innerHTML = "<div class='content' style='height:' + $receiptElement.height() + 'px;width:' + $receiptElement.width() + 'px; '></div>";
1271 receiptClone.setAttribute("style", $receiptElement[0].getAttribute("style") + " height:" + $receiptElement.height() + "px; left:" + (pageWidth - $receiptElement.width()) / 2 + "px;");
1272 $receiptElement[0].parentNode.insertBefore(receiptClone, $receiptElement[0]);
1273 };
1274
1275 scope.setMyBetsCount = function (betCount) {
1276 /// <summary>
1277 /// Call back function - called after the site My Bets scripts are lazy loaded.
1278 /// </summary>
1279 /// <param name="betCount">The number of items on the receipt.</param>
1280 };
1281
1282 scope.setOddsType = function(oddsType) {
1283 /// <summary>
1284 /// Initiate a bet slip API bet slip refresh, setting the new odds type
1285 /// </summary>
1286
1287 // Check to ensure we don't update odds from the slip as it puts the slip in a broken state. The odds will be updated
1288 // next time a user adds a fixture to the slip. (This matches the Flash behavior).
1289 if (document.getElementsByClassName("br-Receipt").length == 0) {
1290 scope.bsController.setOddsType(oddsType);
1291 }
1292 };
1293
1294 scope.setQuickBetState = function (state) {
1295 /// <summary>
1296 /// Set the QuickBet state
1297 /// </summary>
1298
1299 if (scope.bsController._quickBet && scope.bsController._quickBet.setSwitchAndState) {
1300 scope.bsController._quickBet.setSwitchAndState(state);
1301 }
1302 };
1303
1304 scope.toggleQuickBet = function () {
1305 /// <summary>
1306 /// Set the QuickBet state in local storage
1307 /// </summary>
1308
1309 if (scope.bsController._bsContext && scope.bsController._bsContext.ToggleQuickBet) {
1310 scope.bsController._bsContext.ToggleQuickBet();
1311 }
1312 };
1313
1314 scope.registerBetslipWebModule = function(betModule, pushedConfig) {
1315 //registers betslip interface
1316 scope.betslipWebModule = betModule;
1317
1318 //Make pushedConfig globally available
1319 window.pushedConfig = pushedConfig;
1320 };
1321
1322 scope.addOnDeleteBetReqComplete = function () {
1323 if (scope.betslipWebModule && scope.betslipWebModule.removeBetCompleted) {
1324 scope.betslipWebModule.removeBetCompleted();
1325 }
1326 };
1327
1328 scope.addOnAddBetFailed = function () {
1329 if (scope.betslipWebModule && scope.betslipWebModule.resetBetslipProgress) {
1330 scope.betslipWebModule.resetBetslipProgress();
1331 }
1332 };
1333
1334 scope.navigationChanged = function (inplay) {
1335 scope.bsController.quickBetContext.navigationChanged(inplay);
1336 //resize the slip if no items exists
1337 if (scope.getBetCount() === 0) {
1338 scope.resizeBetslip();
1339 }
1340 };
1341
1342 scope.addOnBetSlipLoaded = function () {
1343 if (scope.betslipWebModule && scope.betslipWebModule.addOnBetSlipLoaded) {
1344 scope.betslipWebModule.addOnBetSlipLoaded();
1345 scope.resizeBetslip();
1346 }
1347 };
1348
1349 scope.isQuickBetEnabled = function() {
1350 return scope.bsController.quickBetContext.canHandleBets();
1351 };
1352
1353 scope.isLocked = function () {
1354 return scope.bsController.isLocked();
1355 };
1356
1357 scope.setBetReceiptMatchAlertsState = function (fixtures) {
1358 scope.bsController.setBetReceiptMatchAlertsState(fixtures);
1359 };
1360
1361 scope.getTaxConfig = function() {
1362
1363 return $("#bsDiv > ul").attr("data-txr");
1364 };
1365
1366 scope.updateBonusBalace = function(bonusbalace) {
1367 scope.bsController.updateFreeBetBar(bonusbalace);
1368 scope.bsController._bsInst.changeBetslipHeight();
1369 };
1370
1371 /**
1372 * Expose the participant events functionality to SABSWA
1373 */
1374 scope.dispatchParticipantEvent = function (event) {
1375
1376 if (scope.betslipWebModule && scope.betslipWebModule.dispatchParticipantEvent) {
1377 scope.betslipWebModule.dispatchParticipantEvent(event);
1378 }
1379 };
1380 };