Updated
This commit is contained in:
211
master/examples/currency.html
Normal file
211
master/examples/currency.html
Normal file
@@ -0,0 +1,211 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Test CurrencyTextBox</title>
|
||||
|
||||
<script type="text/javascript" src="../../../dojo/dojo.js"
|
||||
djConfig="isDebug: true, extraLocale: ['zh-cn','fr-fr','ja-jp']"></script>
|
||||
<script type="text/javascript" src="../../../dojo/currency.js"></script>
|
||||
<script type="text/javascript" src="../../../dojo/number.js"></script>
|
||||
<script type="text/javascript">
|
||||
dojo.require("dijit.dijit"); // optimize: load dijit layer
|
||||
dojo.require("dijit.form.NumberTextBox");
|
||||
dojo.require("dijit.form.CurrencyTextBox");
|
||||
dojo.require("dijit.form.DateTextBox");
|
||||
dojo.require("dijit.form.ValidationTextBox");
|
||||
dojo.require("dojo.date.locale");
|
||||
dojo.require("dojo.date.stamp");
|
||||
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
|
||||
dojo.require("doh.runner");
|
||||
</script>
|
||||
<script src="test_i18n.js"></script>
|
||||
<script type="text/javascript">
|
||||
dojo.ready(function(){
|
||||
doh.register("t", getAllTestCases());
|
||||
doh.run();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
@import "../../themes/claro/document.css";
|
||||
@import "../../themes/claro/claro.css";
|
||||
@import "../css/dijitTests.css";
|
||||
|
||||
.title {
|
||||
background-color:#ddd;
|
||||
}
|
||||
|
||||
.hint {
|
||||
background-color:#eee;
|
||||
}
|
||||
|
||||
.testExample {
|
||||
background-color:#fbfbfb;
|
||||
padding:1em;
|
||||
margin-bottom:1em;
|
||||
border:1px solid #bfbfbf;
|
||||
}
|
||||
|
||||
.dojoTitlePaneLabel label {
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
td {white-space:nowrap}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="claro">
|
||||
<h1 class="testTitle">Dijit TextBox Globalization Test for Currency</h1>
|
||||
|
||||
<!-- <h2 class="testTitle">Press the following button to start all test after this page is loaded.</h2>
|
||||
<button id="startButton" onclick="startTest()">Start Test</button> -->
|
||||
<p>
|
||||
Before start this test, make sure the <b>dojo/cldr/nls</b> contains the data for "zh-cn", "fr-fr", and "ja-jp"
|
||||
and currencies CNY, EGP, EUR, JPY. If not, convert these CLDR data and put them there.
|
||||
</p>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
genFormatTestCases("Currency Format", "dijit.form.CurrencyTextBox", [
|
||||
|
||||
{ attrs: {Currency: "CNY", lang: "zh-cn"},
|
||||
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>",
|
||||
value: "123456789.46",
|
||||
expValue: "¥123,456,789.46",
|
||||
comment: ""
|
||||
},
|
||||
{ attrs: {Currency: "CNY", lang: "zh-cn"},
|
||||
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>",
|
||||
value: "-123456789.46",
|
||||
expValue: "-¥123,456,789.46",
|
||||
comment: ""
|
||||
},
|
||||
|
||||
{ attrs: {Currency: "EUR", lang: "fr-fr"},
|
||||
desc: "Locale: <b>fr_FR</b> Currency: <b>EUR</b>",
|
||||
value: "123456789.46",
|
||||
expValue: "123 456 789,46 €",
|
||||
comment: ""
|
||||
},
|
||||
{ attrs: {Currency: "EUR", lang: "fr-fr"},
|
||||
desc: "Locale: <b>zh_CN</b> Currency: <b>EUR</b>",
|
||||
value: "-123456789.46",
|
||||
expValue: "-123 456 789,46 €",
|
||||
comment: ""
|
||||
},
|
||||
|
||||
{ attrs: {Currency: "JPY", lang: "ja-jp"},
|
||||
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>",
|
||||
value: "123456789.46",
|
||||
expValue: "¥123,456,789",
|
||||
comment: ""
|
||||
},
|
||||
{ attrs: {Currency: "JPY", lang: "ja-jp"},
|
||||
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>",
|
||||
value: "-123456789.46",
|
||||
expValue: "-¥123,456,789",
|
||||
comment: ""
|
||||
}
|
||||
]);
|
||||
|
||||
genValidateTestCases("Currency Validate", "dijit.form.CurrencyTextBox", [
|
||||
|
||||
{ attrs: {Currency: "CNY", lang: "zh-cn"},
|
||||
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>",
|
||||
value: 123456789.46,
|
||||
expValue: "¥123,456,789.46",
|
||||
comment: ""
|
||||
},
|
||||
{ attrs: {Currency: "CNY", lang: "zh-cn"},
|
||||
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>",
|
||||
value: -123456789.46,
|
||||
expValue: "-¥123,456,789.46",
|
||||
comment: ""
|
||||
},
|
||||
|
||||
{ attrs: {Currency: "EUR", lang: "fr-fr"},
|
||||
desc: "Locale: <b>fr_FR</b> Currency: <b>EUR</b>",
|
||||
value: 123456789.46,
|
||||
expValue: "123 456 789,46 €",
|
||||
comment: ""
|
||||
},
|
||||
{ attrs: {Currency: "EUR", lang: "fr-fr"},
|
||||
desc: "Locale: <b>zh_CN</b> Currency: <b>EUR</b>",
|
||||
value: -123456789.46,
|
||||
expValue: "-123 456 789,46 €",
|
||||
comment: ""
|
||||
},
|
||||
|
||||
{ attrs: {Currency: "JPY", lang: "ja-jp"},
|
||||
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>",
|
||||
value: 123456789,
|
||||
expValue: "¥123,456,789",
|
||||
comment: ""
|
||||
},
|
||||
{ attrs: {Currency: "JPY", lang: "ja-jp"},
|
||||
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>",
|
||||
value: -123456789,
|
||||
expValue: "-¥123,456,789",
|
||||
comment: ""
|
||||
}
|
||||
]);
|
||||
|
||||
dojo.parser.parse();
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<h2 class="testTitle">Issues & Comments</h2>
|
||||
<h3 class="testTitle"><a name="cmt_1">Issue #1<sup style="color:blue">Fixed</sup></a></h3>
|
||||
<p>
|
||||
Some browsers like FireFox have a bug on the non-breaking space character (U+00A0, <b>&nbsp;</b> or <b>&#160;</b> or
|
||||
<b>&#xA0;</b> in HTML).
|
||||
They always convert the NBSP character to a normal space (U+0020, <b>&#x20;</b> in HTML) automatically in the following circumstances:
|
||||
</p>
|
||||
<ul>
|
||||
<li>Copy text from the page</li>
|
||||
<li>Use <b>innerHTML</b> to get the content of a certain element</li>
|
||||
<li>Use <b>value</b> to get an <b>INPUT</b> element's value</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
You cannot read a real NBSP character from an <b>INPUT</b> element on these browsers. It causes issues when some formatting data in CLDR
|
||||
contains an NBSP character. For example,
|
||||
</p>
|
||||
<ul>
|
||||
<li>Many locales like French use an NBSP character as a group separator in numbers</li>
|
||||
<li>French and Finnish use NBSP characters in their percentage and currency format patterns respectively</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
So Dojo may generate formatted data with NBSP characters in it but cannot read NBSP charaters from user's input in some browser.
|
||||
</p>
|
||||
|
||||
<h3 class="testTitle"><a name="cmt_2">Issue #2<sup style="color:blue">Fixed: the CLDR data generator should be fixed by adding code to convert U+200F to "\u200F" in nls JS files.</sup></a></h3>
|
||||
<p>
|
||||
Most Bidi currency symbols contain an LTR-MARK (U+200F) character at the very beginning.
|
||||
But Firefox ignores it when it is not in any escaping form. This should be a bug of Firefox.
|
||||
For example, click <a href="javascript:alert(''.indexOf('\u200F'))"><code>alert(''.indexOf('\u+200F'))</code></a> (there is a U+200F in the empty-looking string):
|
||||
</p>
|
||||
<ul>
|
||||
<li>In Firefox, shows "-1" -- no U+200F found</li>
|
||||
<li>In IE & Opera, shows "0" -- the U+200F is found</li>
|
||||
</ul>
|
||||
<p>
|
||||
But if the U+200F is in some escaping form, Firefox will work as well as other browsers.
|
||||
Click <a href="javascript:alert('\u200F'.indexOf('\u200F'))"><code>alert('\u200F'.indexOf('\u+200F'))</code></a> to see the same result both in Firefox and IE:
|
||||
</p>
|
||||
|
||||
|
||||
<h3 class="testTitle"><a name="cmt_3">Issue #3<sup style="color:blue">Fixed: added a "localeDigit" to the options</sup></a></h3>
|
||||
<p>
|
||||
Strictly speaking, the data conversion must support non-European number characters in some locales like Arabic and Hindi.
|
||||
For example, ICU formats a number data into Indic number characters by default in the Arabic locale.
|
||||
However, currently Dojo does not support this feature (Dojo uses the default number conversion of the browser).
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user