OLD | NEW |
1 "use strict"; | 1 "use strict"; |
2 /* | 2 /* |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 function fixWindowSize() { | 303 function fixWindowSize() { |
304 var yearMonthRightElement = document.getElementsByClassName(ClassNames.YearM
onthButtonRight)[0]; | 304 var yearMonthRightElement = document.getElementsByClassName(ClassNames.YearM
onthButtonRight)[0]; |
305 var daysAreaElement = document.getElementsByClassName(ClassNames.DaysArea)[0
]; | 305 var daysAreaElement = document.getElementsByClassName(ClassNames.DaysArea)[0
]; |
306 var headers = daysAreaElement.getElementsByClassName(ClassNames.DayLabel); | 306 var headers = daysAreaElement.getElementsByClassName(ClassNames.DayLabel); |
307 var maxCellWidth = 0; | 307 var maxCellWidth = 0; |
308 for (var i = 0; i < headers.length; ++i) { | 308 for (var i = 0; i < headers.length; ++i) { |
309 if (maxCellWidth < headers[i].offsetWidth) | 309 if (maxCellWidth < headers[i].offsetWidth) |
310 maxCellWidth = headers[i].offsetWidth; | 310 maxCellWidth = headers[i].offsetWidth; |
311 } | 311 } |
312 var DaysAreaContainerBorder = 1; | 312 var DaysAreaContainerBorder = 1; |
313 var maxRight = Math.max(yearMonthRightElement.offsetLeft + yearMonthRightEle
ment.offsetWidth, | 313 var main = $("main"); |
314 daysAreaElement.offsetLeft + maxCellWidth * 7 + Days
AreaContainerBorder); | 314 var yearMonthEnd; |
| 315 var daysAreaEnd; |
| 316 if (global.params.isRTL) { |
| 317 var startOffset = main.offsetLeft + main.offsetWidth; |
| 318 yearMonthEnd = startOffset - yearMonthRightElement.offsetLeft; |
| 319 daysAreaEnd = startOffset - (daysAreaElement.offsetLeft + daysAreaElemen
t.offsetWidth) + maxCellWidth * 7 + DaysAreaContainerBorder; |
| 320 } else { |
| 321 yearMonthEnd = yearMonthRightElement.offsetLeft + yearMonthRightElement.
offsetWidth; |
| 322 daysAreaEnd = daysAreaElement.offsetLeft + maxCellWidth * 7 + DaysAreaCo
ntainerBorder; |
| 323 } |
| 324 |
| 325 var maxEnd = Math.max(yearMonthEnd, daysAreaEnd); |
315 var MainPadding = 6; | 326 var MainPadding = 6; |
316 var MainBorder = 1; | 327 var MainBorder = 1; |
317 var desiredBodyWidth = maxRight + MainPadding + MainBorder; | 328 var desiredBodyWidth = maxEnd + MainPadding + MainBorder; |
318 | 329 |
319 var main = $("main"); | |
320 var mainHeight = main.offsetHeight; | 330 var mainHeight = main.offsetHeight; |
321 main.style.width = "auto"; | 331 main.style.width = "auto"; |
322 daysAreaElement.style.width = "100%"; | 332 daysAreaElement.style.width = "100%"; |
323 daysAreaElement.style.tableLayout = "fixed"; | 333 daysAreaElement.style.tableLayout = "fixed"; |
324 document.getElementsByClassName(ClassNames.YearMonthUpper)[0].style.display
= "-webkit-box"; | 334 document.getElementsByClassName(ClassNames.YearMonthUpper)[0].style.display
= "-webkit-box"; |
325 document.getElementsByClassName(ClassNames.MonthSelectorBox)[0].style.displa
y = "block"; | 335 document.getElementsByClassName(ClassNames.MonthSelectorBox)[0].style.displa
y = "block"; |
326 main.style.webkitTransition = "opacity 0.1s ease"; | 336 main.style.webkitTransition = "opacity 0.1s ease"; |
327 main.style.opacity = "1"; | 337 main.style.opacity = "1"; |
328 if (window.frameElement) { | 338 if (window.frameElement) { |
329 window.frameElement.style.width = desiredBodyWidth + "px"; | 339 window.frameElement.style.width = desiredBodyWidth + "px"; |
(...skipping 18 matching lines...) Expand all Loading... |
348 // We assume params.max is a valid date. | 358 // We assume params.max is a valid date. |
349 global.maximumDate = parseDateString(global.params.max); | 359 global.maximumDate = parseDateString(global.params.max); |
350 } | 360 } |
351 if (global.params.step) | 361 if (global.params.step) |
352 global.step *= global.params.step; | 362 global.step *= global.params.step; |
353 } | 363 } |
354 | 364 |
355 function layout() { | 365 function layout() { |
356 if (global.params.isRTL) | 366 if (global.params.isRTL) |
357 document.body.dir = "rtl"; | 367 document.body.dir = "rtl"; |
| 368 else |
| 369 document.body.dir = "ltr"; |
358 var main = $("main"); | 370 var main = $("main"); |
359 var params = global.params; | 371 var params = global.params; |
360 main.removeChild(main.firstChild); | 372 main.removeChild(main.firstChild); |
361 document.body.addEventListener("keydown", handleGlobalKey, false); | 373 document.body.addEventListener("keydown", handleGlobalKey, false); |
362 | 374 |
363 global.yearMonthController = new YearMonthController(); | 375 global.yearMonthController = new YearMonthController(); |
364 global.yearMonthController.attachTo(main); | 376 global.yearMonthController.attachTo(main); |
365 global.daysTable = new DaysTable(); | 377 global.daysTable = new DaysTable(); |
366 global.daysTable.attachTo(main); | 378 global.daysTable.attachTo(main); |
367 layoutButtons(main); | 379 layoutButtons(main); |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 global.hadKeyEvent = true; | 1131 global.hadKeyEvent = true; |
1120 $("main").classList.remove(ClassNames.NoFocusRing); | 1132 $("main").classList.remove(ClassNames.NoFocusRing); |
1121 } | 1133 } |
1122 | 1134 |
1123 if (window.dialogArguments) { | 1135 if (window.dialogArguments) { |
1124 initialize(dialogArguments); | 1136 initialize(dialogArguments); |
1125 } else { | 1137 } else { |
1126 window.addEventListener("message", handleMessage, false); | 1138 window.addEventListener("message", handleMessage, false); |
1127 window.setTimeout(handleArgumentsTimeout, 1000); | 1139 window.setTimeout(handleArgumentsTimeout, 1000); |
1128 } | 1140 } |
OLD | NEW |