Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/javascript/binary/pages/bet/bet_price.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ var BetPrice = function() {
e.preventDefault();
}
var target = $(e.target);
that.hide_buy_buttons();
var button = target.parents('a[class^="spread"]');
that.spread.disable(button);
var form = $(e.target).parents('form');
that.buy_bet(form);
return false;
Expand All @@ -110,9 +111,6 @@ var BetPrice = function() {
timeout : timeout,
success : function (resp, resp_status, jqXHR) { that.on_buy_bet_success(form, resp, resp_status, jqXHR); },
error : function (jqXHR, resp_status, exp) { that.on_buy_bet_error(form, jqXHR, resp_status, exp); },
complete: function () {
that.order_form.show_buy_button();
}
}));
$('.price_box').fadeTo(200, 0.6);
},
Expand Down Expand Up @@ -142,6 +140,7 @@ var BetPrice = function() {
}
$('.price_box').fadeTo(0, 1);
BetPrice.order_form.enable_buy_buttons();
this.display_buy_buttons();
},
on_buy_bet_error: function (form, jqXHR, resp_status, exp) {
var details = '' + exp;
Expand All @@ -156,6 +155,7 @@ var BetPrice = function() {
this.display_buy_error('<div style="width: ' + width + 'px;"><h3>Error</h3><p>' + details + ' </p></div>', 1);
$('.price_box').fadeTo(0, 1);
BetPrice.order_form.enable_buy_buttons();
this.display_buy_buttons();
},
buy_response_container: function () {
if (!_buy_response_container) {
Expand Down Expand Up @@ -207,6 +207,10 @@ var BetPrice = function() {

return new_value;
},
disable: function(target) {
var that = this;
target.unbind('click');
},
on_sell: function(form) {
var that = this;
$('button.close_position').on('click', function (e) {
Expand Down Expand Up @@ -270,7 +274,7 @@ var BetPrice = function() {
}
},
paint_it: function(value, target) {
var color = parseInt(value) > 0 ? 'profit' : 'loss';
var color = value > 0 ? 'profit' : 'loss';
$(target).removeClass().addClass(color);
},
stream: function(channel) {
Expand Down Expand Up @@ -507,6 +511,10 @@ var BetPrice = function() {
this.deregister();
this.order_form.hide_buy_button();
},
display_buy_buttons: function() {
this.on_buy();
this.order_form.show_buy_button();
},
show_loading: function() {
var image_link = page.settings.get('image_link');
var loading_html = '<p id="loading-price">'+text.localize('loading...')+'<br /><img src="'+image_link['hourglass']+'" /></p>';
Expand Down Expand Up @@ -575,20 +583,16 @@ var BetPrice = function() {
return (display_id && display_id.val() == id);
},
hide_buy_button: function() {
$('button[name^="btn_buybet"]').parent().hide();
$('a[class^="spread_"]').hide();
return $('button[name^="btn_buybet"]').parent().hide();
},
show_buy_button: function() {
$('button[name^="btn_buybet"]').parent().show();
$('a[class^="spread_"]').show();
return $('button[name^="btn_buybet"]').parent().show();
},
disable_buy_buttons: function() {
$('button[name^="btn_buybet"]').attr('disabled','disabled');
// unbind click event for spread since it is not a button
$('a[class^="spread_"]').unbind('click');
},
enable_buy_buttons: function() {
// nothing to enable for spreads since it is not a button
$('a[id^="spread"]').removeAttr('disabled');
$('button[name^="btn_buybet"]').removeAttr('disabled');
},
update_from_stream: function(stream) {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/toolkit/bet/explanation.html.tt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
flash.staysinout = static_url.copy.append("flash/betguide-staysinout.swf")
flash.endsinout = static_url.copy.append("flash/betguide-endsinout.swf")
flash.updown = static_url.copy.append("flash/betguide-updown.swf")
image.spreads = [ request.url_for('images/pages/get-started/spreadbet-long.png'),request.url_for('images/pages/get-started/spreadbet-short.png') ]
image.spreads = [ request.url_for('images/pages/get-started/spreadbet-long.png'),request.url_for('images/pages/get-started/spreadbet-long.png') ]
%]

<div class='grd-grid-12 grd-parent'>
Expand Down