| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>Test CurrencyTextBox</title> |
| 7 |
|
| 8 |
<script type="text/javascript" src="../../../dojo/dojo.js" |
| 9 |
data-dojo-config="isDebug: true, extraLocale: ['zh-cn','fr-fr','ja-jp']"></script> |
| 10 |
<script type="text/javascript"> |
| 11 |
dojo.require("dijit.dijit"); // optimize: load dijit layer |
| 12 |
dojo.require("dijit.form.NumberTextBox"); |
| 13 |
dojo.require("dijit.form.CurrencyTextBox"); |
| 14 |
dojo.require("dijit.form.DateTextBox"); |
| 15 |
dojo.require("dijit.form.ValidationTextBox"); |
| 16 |
dojo.require("dojo.date.locale"); |
| 17 |
dojo.require("dojo.date.stamp"); |
| 18 |
dojo.require("dojo.parser"); // scan page for widgets and instantiate them |
| 19 |
dojo.require("doh.runner"); |
| 20 |
</script> |
| 21 |
<script src="test_i18n.js"></script> |
| 22 |
<script type="text/javascript"> |
| 23 |
dojo.ready(function(){ |
| 24 |
doh.register("parse", function(){ |
| 25 |
dojo.parser.parse(); |
| 26 |
}); |
| 27 |
doh.register("t", getAllTestCases()); |
| 28 |
doh.run(); |
| 29 |
}); |
| 30 |
</script> |
| 31 |
|
| 32 |
<style type="text/css"> |
| 33 |
@import "../../themes/claro/document.css"; |
| 34 |
@import "../../themes/claro/claro.css"; |
| 35 |
@import "../css/dijitTests.css"; |
| 36 |
|
| 37 |
.title { |
| 38 |
background-color:#ddd; |
| 39 |
} |
| 40 |
|
| 41 |
.hint { |
| 42 |
background-color:#eee; |
| 43 |
} |
| 44 |
|
| 45 |
.testExample { |
| 46 |
background-color:#fbfbfb; |
| 47 |
padding:1em; |
| 48 |
margin-bottom:1em; |
| 49 |
border:1px solid #bfbfbf; |
| 50 |
} |
| 51 |
|
| 52 |
.dojoTitlePaneLabel label { |
| 53 |
font-weight:bold; |
| 54 |
} |
| 55 |
|
| 56 |
td {white-space:nowrap} |
| 57 |
</style> |
| 58 |
</head> |
| 59 |
|
| 60 |
<body class="claro"> |
| 61 |
<h1 class="testTitle">Dijit TextBox Globalization Test for Currency</h1> |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
<p> |
| 66 |
Before start this test, make sure the <b>dojo/cldr/nls</b> contains the data for "zh-cn", "fr-fr", and "ja-jp" |
| 67 |
and currencies CNY, EGP, EUR, JPY. If not, convert these CLDR data and put them there. |
| 68 |
</p> |
| 69 |
|
| 70 |
<script> |
| 71 |
(function(){ |
| 72 |
genFormatTestCases("Currency Format", "dijit.form.CurrencyTextBox", [ |
| 73 |
|
| 74 |
{ attrs: {Currency: "CNY", lang: "zh-cn"}, |
| 75 |
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>", |
| 76 |
value: "123456789.46", |
| 77 |
expValue: "¥123,456,789.46", |
| 78 |
comment: "" |
| 79 |
}, |
| 80 |
{ attrs: {Currency: "CNY", lang: "zh-cn"}, |
| 81 |
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>", |
| 82 |
value: "-123456789.46", |
| 83 |
expValue: "-¥123,456,789.46", |
| 84 |
comment: "" |
| 85 |
}, |
| 86 |
|
| 87 |
{ attrs: {Currency: "EUR", lang: "fr-fr"}, |
| 88 |
desc: "Locale: <b>fr_FR</b> Currency: <b>EUR</b>", |
| 89 |
value: "123456789.46", |
| 90 |
expValue: "123 456 789,46 €", |
| 91 |
comment: "" |
| 92 |
}, |
| 93 |
{ attrs: {Currency: "EUR", lang: "fr-fr"}, |
| 94 |
desc: "Locale: <b>zh_CN</b> Currency: <b>EUR</b>", |
| 95 |
value: "-123456789.46", |
| 96 |
expValue: "-123 456 789,46 €", |
| 97 |
comment: "" |
| 98 |
}, |
| 99 |
|
| 100 |
{ attrs: {Currency: "JPY", lang: "ja-jp"}, |
| 101 |
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>", |
| 102 |
value: "123456789.46", |
| 103 |
expValue: "¥123,456,789", |
| 104 |
comment: "" |
| 105 |
}, |
| 106 |
{ attrs: {Currency: "JPY", lang: "ja-jp"}, |
| 107 |
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>", |
| 108 |
value: "-123456789.46", |
| 109 |
expValue: "-¥123,456,789", |
| 110 |
comment: "" |
| 111 |
} |
| 112 |
]); |
| 113 |
|
| 114 |
genValidateTestCases("Currency Validate", "dijit.form.CurrencyTextBox", [ |
| 115 |
|
| 116 |
{ attrs: {Currency: "CNY", lang: "zh-cn"}, |
| 117 |
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>", |
| 118 |
value: 123456789.46, |
| 119 |
expValue: "¥123,456,789.46", |
| 120 |
comment: "" |
| 121 |
}, |
| 122 |
{ attrs: {Currency: "CNY", lang: "zh-cn"}, |
| 123 |
desc: "Locale: <b>zh_CN</b> Currency: <b>CNY</b>", |
| 124 |
value: -123456789.46, |
| 125 |
expValue: "-¥123,456,789.46", |
| 126 |
comment: "" |
| 127 |
}, |
| 128 |
|
| 129 |
{ attrs: {Currency: "EUR", lang: "fr-fr"}, |
| 130 |
desc: "Locale: <b>fr_FR</b> Currency: <b>EUR</b>", |
| 131 |
value: 123456789.46, |
| 132 |
expValue: "123 456 789,46 €", |
| 133 |
comment: "" |
| 134 |
}, |
| 135 |
{ attrs: {Currency: "EUR", lang: "fr-fr"}, |
| 136 |
desc: "Locale: <b>zh_CN</b> Currency: <b>EUR</b>", |
| 137 |
value: -123456789.46, |
| 138 |
expValue: "-123 456 789,46 €", |
| 139 |
comment: "" |
| 140 |
}, |
| 141 |
|
| 142 |
{ attrs: {Currency: "JPY", lang: "ja-jp"}, |
| 143 |
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>", |
| 144 |
value: 123456789, |
| 145 |
expValue: "¥123,456,789", |
| 146 |
comment: "" |
| 147 |
}, |
| 148 |
{ attrs: {Currency: "JPY", lang: "ja-jp"}, |
| 149 |
desc: "Locale: <b>ja_JP</b> Currency: <b>JPY</b>", |
| 150 |
value: -123456789, |
| 151 |
expValue: "-¥123,456,789", |
| 152 |
comment: "" |
| 153 |
} |
| 154 |
]); |
| 155 |
|
| 156 |
})(); |
| 157 |
|
| 158 |
</script> |
| 159 |
|
| 160 |
<h2 class="testTitle">Issues & Comments</h2> |
| 161 |
<h3 class="testTitle"><a name="cmt_1">Issue #1<sup style="color:blue">Fixed</sup></a></h3> |
| 162 |
<p> |
| 163 |
Some browsers like FireFox have a bug on the non-breaking space character (U+00A0, <b>&nbsp;</b> or <b>&#160;</b> or |
| 164 |
<b>&#xA0;</b> in HTML). |
| 165 |
They always convert the NBSP character to a normal space (U+0020, <b>&#x20;</b> in HTML) automatically in the following circumstances: |
| 166 |
</p> |
| 167 |
<ul> |
| 168 |
<li>Copy text from the page</li> |
| 169 |
<li>Use <b>innerHTML</b> to get the content of a certain element</li> |
| 170 |
<li>Use <b>value</b> to get an <b>INPUT</b> element's value</li> |
| 171 |
</ul> |
| 172 |
|
| 173 |
<p> |
| 174 |
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 |
| 175 |
contains an NBSP character. For example, |
| 176 |
</p> |
| 177 |
<ul> |
| 178 |
<li>Many locales like French use an NBSP character as a group separator in numbers</li> |
| 179 |
<li>French and Finnish use NBSP characters in their percentage and currency format patterns respectively</li> |
| 180 |
</ul> |
| 181 |
|
| 182 |
<p> |
| 183 |
So Dojo may generate formatted data with NBSP characters in it but cannot read NBSP charaters from user's input in some browser. |
| 184 |
</p> |
| 185 |
|
| 186 |
<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> |
| 187 |
<p> |
| 188 |
Most Bidi currency symbols contain an LTR-MARK (U+200F) character at the very beginning. |
| 189 |
But Firefox ignores it when it is not in any escaping form. This should be a bug of Firefox. |
| 190 |
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): |
| 191 |
</p> |
| 192 |
<ul> |
| 193 |
<li>In Firefox, shows "-1" -- no U+200F found</li> |
| 194 |
<li>In IE & Opera, shows "0" -- the U+200F is found</li> |
| 195 |
</ul> |
| 196 |
<p> |
| 197 |
But if the U+200F is in some escaping form, Firefox will work as well as other browsers. |
| 198 |
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: |
| 199 |
</p> |
| 200 |
|
| 201 |
|
| 202 |
<h3 class="testTitle"><a name="cmt_3">Issue #3<sup style="color:blue">Fixed: added a "localeDigit" to the options</sup></a></h3> |
| 203 |
<p> |
| 204 |
Strictly speaking, the data conversion must support non-European number characters in some locales like Arabic and Hindi. |
| 205 |
For example, ICU formats a number data into Indic number characters by default in the Arabic locale. |
| 206 |
However, currently Dojo does not support this feature (Dojo uses the default number conversion of the browser). |
| 207 |
</p> |
| 208 |
|
| 209 |
</body> |
| 210 |
</html> |