From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f --- includes/js/dijit/tests/i18n/README | 4 + includes/js/dijit/tests/i18n/currency.html | 210 +++++++++++++++++++++ includes/js/dijit/tests/i18n/date.html | 155 +++++++++++++++ includes/js/dijit/tests/i18n/digit.html | 294 +++++++++++++++++++++++++++++ includes/js/dijit/tests/i18n/module.js | 18 ++ includes/js/dijit/tests/i18n/number.html | 136 +++++++++++++ includes/js/dijit/tests/i18n/test_i18n.js | 206 ++++++++++++++++++++ includes/js/dijit/tests/i18n/textbox.html | 173 +++++++++++++++++ includes/js/dijit/tests/i18n/time.html | 207 ++++++++++++++++++++ 9 files changed, 1403 insertions(+) create mode 100644 includes/js/dijit/tests/i18n/README create mode 100644 includes/js/dijit/tests/i18n/currency.html create mode 100644 includes/js/dijit/tests/i18n/date.html create mode 100644 includes/js/dijit/tests/i18n/digit.html create mode 100644 includes/js/dijit/tests/i18n/module.js create mode 100644 includes/js/dijit/tests/i18n/number.html create mode 100644 includes/js/dijit/tests/i18n/test_i18n.js create mode 100644 includes/js/dijit/tests/i18n/textbox.html create mode 100644 includes/js/dijit/tests/i18n/time.html (limited to 'includes/js/dijit/tests/i18n') diff --git a/includes/js/dijit/tests/i18n/README b/includes/js/dijit/tests/i18n/README new file mode 100644 index 0000000..a6516b6 --- /dev/null +++ b/includes/js/dijit/tests/i18n/README @@ -0,0 +1,4 @@ +Global Verification Tests (GVT) + +In order to run these tests, you will need full locale support in Dojo. Dojo only ships with a small subset by default. +See util/buildscripts/cldr for an ant-based build script. diff --git a/includes/js/dijit/tests/i18n/currency.html b/includes/js/dijit/tests/i18n/currency.html new file mode 100644 index 0000000..62108b2 --- /dev/null +++ b/includes/js/dijit/tests/i18n/currency.html @@ -0,0 +1,210 @@ + + + + + Test CurrencyTextBox + + + + + + + + + + + + +

Dijit TextBox Globalization Test for Currency

+ + +

+ Before start this test, make sure the dojo/cldr/nls 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. +

+ + + +

Issues & Comments

+

Issue #1Fixed

+

+ Some browsers like FireFox have a bug on the non-breaking space character (U+00A0,   or   or +   in HTML). + They always convert the NBSP character to a normal space (U+0020,   in HTML) automatically in the following circumstances: +

+ + +

+ You cannot read a real NBSP character from an INPUT element on these browsers. It causes issues when some formatting data in CLDR + contains an NBSP character. For example, +

+ + +

+ So Dojo may generate formatted data with NBSP characters in it but cannot read NBSP charaters from user's input in some browser. +

+ +

Issue #2Fixed: the CLDR data generator should be fixed by adding code to convert U+200F to "\u200F" in nls JS files.

+

+ 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 alert('‏'.indexOf('\u+200F')) (there is a U+200F in the empty-looking string): +

+ +

+ But if the U+200F is in some escaping form, Firefox will work as well as other browsers. + Click alert('\u200F'.indexOf('\u+200F')) to see the same result both in Firefox and IE: +

+ + +

Issue #3Fixed: added a "localeDigit" to the options

+

+ 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). +

+ + + diff --git a/includes/js/dijit/tests/i18n/date.html b/includes/js/dijit/tests/i18n/date.html new file mode 100644 index 0000000..b4aa4cd --- /dev/null +++ b/includes/js/dijit/tests/i18n/date.html @@ -0,0 +1,155 @@ + + + + + Test DateTextBox + + + + + + + + + + + + + +

Dijit TextBox Globalization Test for Date

+ + +

+ Before start this test, make sure the dojo/cldr/nls contains the data for "zh-cn", "fr-fr", "ja-jp", "ru-ru", "hi-in", "en-us" and "ar-eg". If not, convert these CLDR data and put them there. +

+ + + + diff --git a/includes/js/dijit/tests/i18n/digit.html b/includes/js/dijit/tests/i18n/digit.html new file mode 100644 index 0000000..dc3ed7a --- /dev/null +++ b/includes/js/dijit/tests/i18n/digit.html @@ -0,0 +1,294 @@ + + + + + Test Hindi/Arabic numerals + + + + + + + + + + + + + +

Dijit TextBox Globalization Test for Number

+ + +

+ Before start this test, make sure the dojo/cldr/nls contains the data for "ar-eg" and "hi-in". If not, convert these CLDR data and put them there. +

+ + + + + + + diff --git a/includes/js/dijit/tests/i18n/module.js b/includes/js/dijit/tests/i18n/module.js new file mode 100644 index 0000000..b484737 --- /dev/null +++ b/includes/js/dijit/tests/i18n/module.js @@ -0,0 +1,18 @@ +if(!dojo._hasResource["dijit.tests.i18n.module"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dijit.tests.i18n.module"] = true; +dojo.provide("dijit.tests.i18n.module"); + +try{ + if(dojo.isBrowser){ + doh.registerUrl("dijit.tests.i18n.currency", dojo.moduleUrl("dijit", "tests/i18n/currency.html")); + doh.registerUrl("dijit.tests.i18n.date", dojo.moduleUrl("dijit", "tests/i18n/date.html")); + doh.registerUrl("dijit.tests.i18n.number", dojo.moduleUrl("dijit", "tests/i18n/number.html")); + doh.registerUrl("dijit.tests.i18n.textbox", dojo.moduleUrl("dijit", "tests/i18n/textbox.html")); + doh.registerUrl("dijit.tests.i18n.time", dojo.moduleUrl("dijit", "tests/i18n/time.html")); + doh.registerUrl("dijit.tests.i18n.digit", dojo.moduleUrl("dijit", "tests/i18n/digit.html")); + } +}catch(e){ + doh.debug(e); +} + +} diff --git a/includes/js/dijit/tests/i18n/number.html b/includes/js/dijit/tests/i18n/number.html new file mode 100644 index 0000000..0a1b717 --- /dev/null +++ b/includes/js/dijit/tests/i18n/number.html @@ -0,0 +1,136 @@ + + + + + Test NumberTextBox + + + + + + + + + + + + +

Dijit TextBox Globalization Test for Number

+ + +

+ Before start this test, make sure the dojo/cldr/nls contains the data for "zh-cn", "fr-fr". If not, convert these CLDR data and put them there. +

+ + + + + + diff --git a/includes/js/dijit/tests/i18n/test_i18n.js b/includes/js/dijit/tests/i18n/test_i18n.js new file mode 100644 index 0000000..bc44e63 --- /dev/null +++ b/includes/js/dijit/tests/i18n/test_i18n.js @@ -0,0 +1,206 @@ +var validateValues = []; +var formatWidgetCount = 0; +var validateWidgetCount = 0; + +function getElementsById(id){ + var result = []; + + if(!id || typeof(id) != "string"){ + return result; + } + + var ae = document.getElementsByTagName(dojo.byId(id).tagName); + for(var i = 0; i < ae.length; i++){ + if(ae[i].id == id){ + result.push(ae[i]); + } + } + return result; +} + +function getString(n){ + return n && n.toString(); +} + +function startTest(t){ + startTestFormat(t); + startTestValidate(t); +} + +function escapeEx(s){ + var result = ""; + for(var i = 0; i < s.length; i++){ + var c = s.charAt(i); + switch (c){ + case '"': + result += '\\"'; + break; + case "'": + result += "\\'"; + break; + default: + result += escape(c); + break; + } + } + return result; +} + +function getAllTestCases(){ + var allTestCases = []; + for(var i = 0; i < formatWidgetCount; i++){ + allTestCases.push({ + name: "format-" + i, + runTest: new Function("t", "startTestFormat(" + i + ", t)") + }); + } + for(var i = 0; i < validateWidgetCount; i++){ + allTestCases.push({ + name: "validate-" + i, + runTest: new Function("t", "startTestValidate(" + i + ", t)") + }); + } + return allTestCases; +} + +function startTestFormat(i, t){ + var test_node = dojo.doc.getElementById("test_display_" + i); + var exp = dojo.doc.getElementById("test_display_expected_" + i).value; + var res_node = dojo.doc.getElementById("test_display_result_" + i); + res_node.innerHTML = test_node.value; + res_node.style.backgroundColor = (test_node.value == exp) ? "#AFA" : "#FAA"; + res_node.innerHTML += " Compare (Escaped)"; + t.is(exp, test_node.value); +} + +function startTestValidate(i, t){ + /* + * The dijit.byNode has an issue: cannot handle same id. + */ + var test_node = dojo.doc.getElementById("test_validate_" + i); + var inp_node = dojo.doc.getElementById("test_validate_input_" + i); + var exp = dojo.doc.getElementById("test_validate_expected_" + i).innerHTML; + var res_node = dojo.doc.getElementById("test_validate_result_" + i); + var val_node = dojo.doc.getElementById("test_display_value_" + i); + + test_node.value = inp_node.value; + /* + * The dijit.byNode has an issue. + */ + var widget = null; + var node = test_node; + while ((widget = dijit.byNode(node)) == null){ + node = node.parentNode; + if(!node){ + break; + } + } + + if(widget){ + widget.focus(); + + var expected = validateValues[i]; + var result = widget.getValue(); + if(validateValues[i].processValue){ + expected = validateValues[i].processValue(expected); + result = validateValues[i].processValue(result); + } + var parseCorrect = getString(expected) == getString(result); + val_node.style.backgroundColor = parseCorrect ? "#AFA" : "#FAA"; + val_node.innerHTML = getString(result) + (parseCorrect ? "" : "
Expected: " + getString(expected)); + + res_node.innerHTML = widget.isValid && !widget.isValid() ? "Wrong" : "Correct"; + res_node.style.backgroundColor = res_node.innerHTML == exp ? "#AFA" : "#FAA"; + + t.is(getString(expected), getString(result)); + } +} + +function genFormatTestCase(desc, dojoType, dojoAttrs, value, expValue, comment){ + dojo.doc.write(""); + dojo.doc.write("" + desc + ""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write("" + comment + ""); + dojo.doc.write(""); + formatWidgetCount++; +} +/* +[ + {attrs: {currency: "CNY", lang: "zh-cn"}, desc: "", value:"-123456789.46", expValue: "", comment: ""}, + ... +] +*/ +function genFormatTestCases(title, dojoType, testCases){ + dojo.doc.write("

" + title + "

"); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + + for(var i = 0; i < testCases.length; i++){ + var testCase = testCases[i]; + genFormatTestCase(testCase.desc, dojoType, testCase.attrs, testCase.value, testCase.expValue, testCase.comment); + } + + dojo.doc.write("
Test DescriptionTestExpectedResultComment
"); +} + +function genValidateTestCase(desc, dojoType, dojoAttrs, input, value, comment, isWrong){ + dojo.doc.write(""); + dojo.doc.write("" + desc + ""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write("" + (isWrong ? "Wrong" : "Correct") + ""); + dojo.doc.write(""); + dojo.doc.write("" + comment + ""); + dojo.doc.write(""); + validateValues.push(value); + validateWidgetCount++; +} +/* +[ + {attrs: {currency: "CNY", lang: "zh-cn"}, desc: "", value:false, expValue: "-123456789.46", comment: ""}, + ... +] +*/ +function genValidateTestCases(title, dojoType, testCases){ + dojo.doc.write("

" + title + "

"); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + dojo.doc.write(""); + + for(var i = 0; i < testCases.length; i++){ + var testCase = testCases[i]; + genValidateTestCase(testCase.desc, dojoType, testCase.attrs, testCase.expValue, testCase.value, testCase.comment, testCase.isWrong); + } + + dojo.doc.write("
Test DescriptionTestInputParsed ValueExpectedResultComment
"); +} diff --git a/includes/js/dijit/tests/i18n/textbox.html b/includes/js/dijit/tests/i18n/textbox.html new file mode 100644 index 0000000..573496e --- /dev/null +++ b/includes/js/dijit/tests/i18n/textbox.html @@ -0,0 +1,173 @@ + + + + + Test TextBox + + + + + + + + + + + + +

Dijit TextBox Globalization Test

+ + + + + +

Issues & Comments

+

Issue #1 Not fixed. Avoid using this function of TextBox.

+

+ Strictly speaking, all casing manipulation must use ICU case mapping rules (routine). However, the default JavaScript routines used by Dojo + do not support ICU case mapping rules in all browsers. +

+ +

Issue #2 Not fixed. Avoid using this function of TextBox.

+

+ Trimming must get rid of all Unicode characters with the white space property. However, the default JavaScript routines used by Dojo + do not support get character properties in some browsers like IE. Other browsers like Firefox might support trimming more white space + characters. +

+ + + + + diff --git a/includes/js/dijit/tests/i18n/time.html b/includes/js/dijit/tests/i18n/time.html new file mode 100644 index 0000000..0a972b9 --- /dev/null +++ b/includes/js/dijit/tests/i18n/time.html @@ -0,0 +1,207 @@ + + + + + Test TextBox for Time + + + + + + + + + + + + + +

Dijit TextBox Globalization Test for Time

+ +

Press the following button to start all test after this page is loaded.

+ +

+ Before start this test, make sure the dojo/cldr/nls contains the data for "zh-cn", "fr-fr", "ja-jp", "ru-ru", "hi-in", "en-us" and "ar-eg". If not, convert these CLDR data and put them there. +

+ + + +

Issues & Comments

+

Issue #1 Fixed

+

+ Currently Dojo do not support parsing for most "long" and "full" time format which have a timezone mark in it. +

+ +

Issue #2 Fixed: added a "localeDigit" to the options

+

+ 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). +

+ +

Issue #3 Fixed

+

+ This defect only occurs on the "zh-cn" locale. Dojo accepts "下午"(pm) in the textbox, but it automatically changes it to + "上午"(am) after the focus changed. The date value of the textbox is also changed. +

+

+ The root cause of this issue is that the parser method's code assumes am/pm symbol always appears after the hour value. + But this is not true, for example, the pattern for "zh-cn" puts am/pm field before all the other fields. +

+ + + -- cgit v1.2.3-54-g00ecf