|
319 | 319 | this.calendarButton.disabled = isDisabled;
|
320 | 320 | };
|
321 | 321 |
|
322 |
| - /** |
323 |
| - * Resizes the input element based on the size of its content. |
324 |
| - */ |
| 322 | + /** Resizes the input element based on the size of its content. */ |
325 | 323 | DatePickerCtrl.prototype.resizeInputElement = function() {
|
326 | 324 | this.inputElement.size = this.inputElement.value.length + EXTRA_INPUT_SIZE;
|
327 | 325 | };
|
|
354 | 352 | /** Position and attach the floating calendar to the document. */
|
355 | 353 | DatePickerCtrl.prototype.attachCalendarPane = function() {
|
356 | 354 | var calendarPane = this.calendarPane;
|
| 355 | + calendarPane.style.transform = ''; |
357 | 356 | this.$element.addClass('md-datepicker-open');
|
358 | 357 |
|
359 | 358 | var elementRect = this.inputContainer.getBoundingClientRect();
|
|
365 | 364 | var paneLeft = elementRect.left - bodyRect.left;
|
366 | 365 |
|
367 | 366 | // If the right edge of the pane would be off the screen and shifting it left by the
|
368 |
| - // difference would not go past the left edge of the screen. |
| 367 | + // difference would not go past the left edge of the screen. If the calendar pane is too |
| 368 | + // big to fit on the screen at all, move it to the left of the screen and scale the entire |
| 369 | + // element down to fit. |
| 370 | + if (paneLeft + CALENDAR_PANE_WIDTH > bodyRect.right) { |
| 371 | + if (bodyRect.right - CALENDAR_PANE_WIDTH > 0) { |
| 372 | + paneLeft = bodyRect.right - CALENDAR_PANE_WIDTH; |
| 373 | + } else { |
| 374 | + paneLeft = 0; |
| 375 | + var scale = bodyRect.width / CALENDAR_PANE_WIDTH; |
| 376 | + calendarPane.style.transform = 'scale(' + scale + ')'; |
| 377 | + } |
| 378 | + |
| 379 | + calendarPane.classList.add('md-datepicker-pos-adjusted'); |
| 380 | + } |
| 381 | + |
| 382 | + |
369 | 383 | if (paneLeft + CALENDAR_PANE_WIDTH > bodyRect.right &&
|
370 | 384 | bodyRect.right - CALENDAR_PANE_WIDTH > 0) {
|
371 | 385 | paneLeft = bodyRect.right - CALENDAR_PANE_WIDTH;
|
|
382 | 396 |
|
383 | 397 | calendarPane.style.left = paneLeft + 'px';
|
384 | 398 | calendarPane.style.top = paneTop + 'px';
|
385 |
| - document.body.appendChild(this.calendarPane); |
| 399 | + document.body.appendChild(calendarPane); |
386 | 400 |
|
387 | 401 | // The top of the calendar pane is a transparent box that shows the text input underneath.
|
388 | 402 | // Since the pane is floating, though, the page underneath the pane *adjacent* to the input is
|
|
0 commit comments