Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ecommerce
Commits
30f3cb03
Commit
30f3cb03
authored
Oct 25, 2017
by
jaebradley
Committed by
Jae Bradley
Oct 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrap disclaimer text
actually wrap in gettext
parent
0006cad8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
ecommerce/static/js/pages/basket_page.js
+22
-9
ecommerce/static/js/test/specs/pages/basket_page_spec.js
+2
-2
No files found.
ecommerce/static/js/pages/basket_page.js
View file @
30f3cb03
...
...
@@ -242,14 +242,16 @@ define([
addPriceDisclaimer
:
function
()
{
var
price
=
$
(
'#basket-total'
).
find
(
'> .price'
).
text
(),
countryData
=
Cookies
.
getJSON
(
'edx-price-l10n'
);
countryData
=
Cookies
.
getJSON
(
'edx-price-l10n'
),
disclaimerPrefix
;
// when the price value has a USD prefix, replace it with a $
price
=
price
.
replace
(
'USD'
,
'$'
);
disclaimerPrefix
=
'* This total contains an approximate conversion. You will be charged '
;
if
(
BasketPage
.
isValidLocalCurrencyCookie
(
countryData
)
&&
countryData
.
countryCode
!==
'USA'
)
{
$
(
'<span>'
).
attr
(
'class'
,
'price-disclaimer'
)
.
text
(
'* This total contains an approximate conversion. You will be charged '
+
price
+
' USD.'
)
.
text
(
gettext
(
disclaimerPrefix
)
+
price
+
' USD.'
)
.
appendTo
(
'div[aria-labelledby="order-details-region"]'
);
}
},
...
...
@@ -267,16 +269,27 @@ define([
},
generateLocalPriceText
:
function
(
usdPriceText
)
{
var
localPriceText
=
usdPriceText
;
// Assumes price value is in USDab.cd or $ab.cd format with optional sign
localPriceText
=
localPriceText
.
replace
(
/
\$
|USD/
,
''
);
if
(
$
.
isNumeric
(
localPriceText
))
{
return
BasketPage
.
formatToLocalPrice
(
localPriceText
);
var
localPriceText
=
usdPriceText
,
prefixMatch
=
localPriceText
.
match
(
/
(\$
|USD
)[
0-9
]
+
\.[
0-9
]
+/
),
entireMatch
,
groupMatch
,
startIndex
,
priceValue
;
if
(
prefixMatch
)
{
entireMatch
=
prefixMatch
[
0
];
groupMatch
=
prefixMatch
[
1
];
startIndex
=
prefixMatch
.
index
;
priceValue
=
localPriceText
.
substring
(
startIndex
+
groupMatch
.
length
);
if
(
$
.
isNumeric
(
priceValue
))
{
localPriceText
=
localPriceText
.
replace
(
entireMatch
,
BasketPage
.
formatToLocalPrice
(
priceValue
));
}
}
return
usd
PriceText
;
return
local
PriceText
;
},
replaceElementText
:
function
(
element
,
text
)
{
...
...
ecommerce/static/js/test/specs/pages/basket_page_spec.js
View file @
30f3cb03
...
...
@@ -631,9 +631,9 @@ define([
it
(
'should replace negative values'
,
function
()
{
spyOn
(
BasketPage
,
'formatToLocalPrice'
).
and
.
returnValue
(
'foo'
);
expect
(
'foo'
)
expect
(
'
-
foo'
)
.
toEqual
(
BasketPage
.
generateLocalPriceText
(
'-$12.34'
));
expect
(
BasketPage
.
formatToLocalPrice
).
toHaveBeenCalledWith
(
'
-
12.34'
);
expect
(
BasketPage
.
formatToLocalPrice
).
toHaveBeenCalledWith
(
'12.34'
);
});
it
(
'should not replace text without USD values'
,
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment