From 0a716a008e9e0d36f9eec7a37015fb17f08f7ced Mon Sep 17 00:00:00 2001 From: Ca-Phun Ung Date: Sat, 20 Dec 2008 20:20:33 +0000 Subject: Datepicker #3647: fixed RTL support for new UI markup. --- ui/ui.datepicker.js | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'ui') diff --git a/ui/ui.datepicker.js b/ui/ui.datepicker.js index bf607250e..66d71f00f 100644 --- a/ui/ui.datepicker.js +++ b/ui/ui.datepicker.js @@ -1343,7 +1343,7 @@ $.extend(Datepicker.prototype, { this._getFormatConfig(inst))); var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ? '' + prevText + '' : + ' title="' + prevText + '">' + prevText + '' : (hideIfNoPrevNext ? '' : '')); var nextText = this._get(inst, 'nextText'); nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText, @@ -1351,7 +1351,7 @@ $.extend(Datepicker.prototype, { this._getFormatConfig(inst))); var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ? '' + nextText + '' : + ' title="' + nextText + '">' + nextText + '' : (hideIfNoPrevNext ? '' : '')); var currentText = this._get(inst, 'currentText'); var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today); @@ -1375,31 +1375,34 @@ $.extend(Datepicker.prototype, { var defaultDate = this._getDefaultDate(inst); var html = ''; for (var row = 0; row < numMonths[0]; row++) { + var group = ''; for (var col = 0; col < numMonths[1]; col++) { var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay)); var cornerClass = ' ui-corner-all'; + var calender = ''; if (isMultiMonth) { - html += '
' + + calender += '
' + (/all|left/.test(cornerClass) ? (isRTL ? next : prev) : '') + (/all|right/.test(cornerClass) ? (isRTL ? prev : next) : '') + this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate, selectedDate, row > 0 || col > 0, monthNames) + // draw month headers '
' + ''; + var thead = ''; for (var dow = 0; dow < 7; dow++) { // days of the week var day = (dow + firstDay) % 7; - html += '= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' + - '' + dayNamesMin[day] + ''; + thead = (isRTL ? '' : thead) + '= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' + + '' + dayNamesMin[day] + '' + (isRTL ? thead : ''); } - html += ''; + calender += thead + ''; var daysInMonth = this._getDaysInMonth(drawYear, drawMonth); if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth) inst.selectedDay = Math.min(inst.selectedDay, daysInMonth); @@ -1407,14 +1410,15 @@ $.extend(Datepicker.prototype, { var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays)); for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows - html += ''; + calender += ''; + var tbody = ''; for (var dow = 0; dow < 7; dow++) { // create date picker days var daySettings = (beforeShowDay ? beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']); var otherMonth = (printDate.getMonth() != drawMonth); var unselectable = otherMonth || !daySettings[0] || (minDate && printDate < minDate) || (maxDate && printDate > maxDate); - html += ''; // display for this month + '" href="#">' + printDate.getDate() + '')) + '' + // display for this month + (isRTL ? tbody : ''); printDate.setDate(printDate.getDate() + 1); printDate = this._daylightSavingAdjust(printDate); } - html += ''; + calender += tbody + ''; } drawMonth++; if (drawMonth > 11) { drawMonth = 0; drawYear++; } - html += '
= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key @@ -1434,19 +1438,22 @@ $.extend(Datepicker.prototype, { (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') + (printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range ' ui-state-active' : '') + // highlight selected day - '" href="#">' + printDate.getDate() + '')) + '
' + (isMultiMonth ? '
' : ''); + calender += '' + (isMultiMonth ? '' : ''); + group = (isRTL ? calender + group : group + calender ); } + html += group; } html += (!inst.inline ? buttonPanel : '') + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ? -- cgit v1.2.3