Changeset 114356 in webkit
- Timestamp:
- Apr 17, 2012 12:30:46 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r114304 r114356 1 2012-04-17 Kent Tamura <tkent@chromium.org> 2 3 Calendar Picker: Support RTL layout 4 https://bugs.webkit.org/show_bug.cgi?id=83668 5 6 Reviewed by Hajime Morita. 7 8 * ManualTests/forms/calendar-picker.html: 9 Add Arabic parameters. 10 Add <select> to select a locale. 11 1 12 2012-04-16 Dave Tu <dtu@chromium.org> 2 13 -
trunk/ManualTests/forms/calendar-picker.html
r113298 r114356 20 20 21 21 <p>This is a testbed for a calendar picker.</p> 22 <select onchange="selected(this)"> 23 <option>English</option> 24 <option>Japanese</option> 25 <option>Arabic</option> 26 </select> 22 27 23 28 <div><input type="text" id="date"></div> … … 28 33 29 34 <script> 30 var frame = document.getElementsByTagName('iframe')[0];31 var doc = frame.contentDocument;32 doc.documentElement.innerHTML = '<head></head><body><div id=main>Loading...</div></body>';33 var link = doc.createElement('link');34 link.rel = 'stylesheet';35 link.href = '../../Source/WebCore/Resources/calendarPicker.css?' + (new Date()).getTime();36 doc.head.appendChild(link);37 var script = doc.createElement('script');38 script.src = '../../Source/WebCore/Resources/calendarPicker.js?' + (new Date()).getTime();39 doc.body.appendChild(script);40 41 35 var englishArguments = { 42 36 locale: 'en-US', … … 63 57 max : '2099-03-15', 64 58 }; 65 setTimeout(function() { 66 frame.contentWindow.postMessage(JSON.stringify(englishArguments), "*"); 67 frame.contentWindow.setValueAndClosePopup = function(numValue, stringValue) { 68 window.log('number=' + numValue + ', string="' + stringValue + '"'); 69 if (numValue == 0) 70 window.document.getElementById('date').value = stringValue; 71 }; 72 }, 100); 59 var arabicArguments = { 60 locale: 'ar', 61 monthLabels : ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 62 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'], 63 dayLabels : ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], 64 todayLabel : 'اليوم', 65 clearLabel : 'مسح', 66 weekStartDay : 5, 67 step : 1, 68 max : '2020-05-15', 69 }; 73 70 71 function openCalendar(args) { 72 var frame = document.getElementsByTagName('iframe')[0]; 73 var doc = frame.contentDocument; 74 doc.documentElement.innerHTML = '<head></head><body><div id=main>Loading...</div></body>'; 75 var link = doc.createElement('link'); 76 link.rel = 'stylesheet'; 77 link.href = '../../Source/WebCore/Resources/calendarPicker.css?' + (new Date()).getTime(); 78 doc.head.appendChild(link); 79 var script = doc.createElement('script'); 80 script.src = '../../Source/WebCore/Resources/calendarPicker.js?' + (new Date()).getTime(); 81 doc.body.appendChild(script); 82 83 setTimeout(function() { 84 frame.contentWindow.postMessage(JSON.stringify(args), "*"); 85 frame.contentWindow.setValueAndClosePopup = function(numValue, stringValue) { 86 window.log('number=' + numValue + ', string="' + stringValue + '"'); 87 if (numValue == 0) 88 window.document.getElementById('date').value = stringValue; 89 }; 90 }, 100); 91 } 92 93 function selected(select) { 94 switch (select.selectedIndex) { 95 case 0: 96 openCalendar(englishArguments); 97 break; 98 case 1: 99 openCalendar(japaneseArguments); 100 break; 101 case 2: 102 openCalendar(arabicArguments); 103 break; 104 } 105 } 74 106 75 107 function log(str) { … … 78 110 document.getElementById('console').appendChild(entry); 79 111 } 112 113 openCalendar(englishArguments); 80 114 </script> 81 115 </body> -
trunk/Source/WebCore/ChangeLog
r114352 r114356 1 2012-04-17 Kent Tamura <tkent@chromium.org> 2 3 Calendar Picker: Support RTL layout 4 https://bugs.webkit.org/show_bug.cgi?id=83668 5 6 Reviewed by Hajime Morita. 7 8 Manual test: ManualTests/forms/calendar-picker.html 9 10 * Resources/calendarPicker.js: 11 (layout): If params.isRTL, add dir=rtl to the body. 12 (DaysTable.prototype._handleKey): Reverse Left and Right cursor keys if RTL. 13 * html/shadow/CalendarPickerElement.cpp: 14 (WebCore::addProperty): Add addProperty() with a bool value. 15 (WebCore::CalendarPickerElement::writeDocument): 16 Check the direction of the first character of localized January label, 17 and pass it as isRTL property. 18 1 19 2012-04-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 20 -
trunk/Source/WebCore/Resources/calendarPicker.js
r113298 r114356 31 31 32 32 // FIXME: 33 // - RTL34 33 // - Touch event 35 34 … … 317 316 318 317 function layout() { 318 if (global.params.isRTL) 319 document.body.dir = "rtl"; 319 320 var main = $("main"); 320 321 var params = global.params; … … 926 927 } 927 928 928 if (key == "Left") {929 if (key == (global.params.isRTL ? "Right" : "Left")) { 929 930 if (x == 0) { 930 931 if (y == 0) { … … 948 949 this.updateSelection(event, x, y); 949 950 950 } else if (key == "Right") {951 } else if (key == (global.params.isRTL ? "Left" : "Right")) { 951 952 if (x == 6) { 952 953 if (y == DaysTable._Weeks - 1) { -
trunk/Source/WebCore/html/shadow/CalendarPickerElement.cpp
r114211 r114356 50 50 #include <wtf/text/StringBuilder.h> 51 51 52 using namespace WTF::Unicode; 53 52 54 namespace WebCore { 53 55 … … 169 171 } 170 172 173 static void addProperty(const char* name, bool value, DocumentWriter& writer) 174 { 175 writer.addData(name, strlen(name)); 176 addLiteral(": ", writer); 177 if (value) 178 addLiteral("true", writer); 179 else 180 addLiteral("false", writer); 181 addLiteral(",\n", writer); 182 } 183 171 184 static void addProperty(const char* name, const Vector<String>& values, DocumentWriter& writer) 172 185 { … … 201 214 addProperty("max", maxString, writer); 202 215 addProperty("step", stepString, writer); 203 addProperty("required", input->required() ? "true" : "false", writer);216 addProperty("required", input->required(), writer); 204 217 addProperty("currentValue", input->value(), writer); 205 218 addProperty("locale", defaultLanguage(), writer); … … 209 222 addProperty("monthLabels", monthLabels(), writer); 210 223 addProperty("dayLabels", weekDayShortLabels(), writer); 224 Direction dir = direction(monthLabels()[0][0]); 225 addProperty("isRTL", dir == RightToLeft || dir == RightToLeftArabic, writer); 211 226 addLiteral("}\n", writer); 212 227
Note: See TracChangeset
for help on using the changeset viewer.