]> source.dussan.org Git - jquery-ui.git/commitdiff
Fixed 2818 Display simultaneously past and current month in datepicker
authorKeith Wood <kbwood.au@gmail.com>
Fri, 25 Jul 2008 10:02:06 +0000 (10:02 +0000)
committerKeith Wood <kbwood.au@gmail.com>
Fri, 25 Jul 2008 10:02:06 +0000 (10:02 +0000)
demos/functional/templates/ui.datepicker.html
ui/ui.datepicker.js

index 2f1d5a8174f455c35b006bc4c4bc2fa0a35c7e5b..3e5b90d55d74f488818b9db1995b1b9b2263e3fe 100644 (file)
                                        {       desc: 'Highlight the hovered week',     source: '$("#misc").datepicker({highlightWeek: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true});' },
                                        {       desc: 'Show days from other months',    source: '$("#misc").datepicker({showOtherMonths: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true});' },
                                        {       desc: 'Show week of the year (ISO 8601)',       source: '$("#misc").datepicker({showWeeks: true, firstDay: 1, changeFirstDay: false, showOtherMonths: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true});' },
-                                       {       desc: 'Show a status bar with more explanation',        source: '$("#misc").datepicker({showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true});' }
+                                       {       desc: 'Show a status bar with more explanation',        source: '$("#misc").datepicker({showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true});' },
+                                       {       desc: 'Show three months at a time',    source: '$("#misc").datepicker({numberOfMonths: 3, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true});' },
+                                       {       desc: 'Show three months with current in the middle',   source: '$("#misc").datepicker({numberOfMonths: 3, showCurrentAtPos: 1, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true});' },
+                                       {       desc: 'Show three months ending at current one',        source: '$("#misc").datepicker({numberOfMonths: 3, showCurrentAtPos: 2, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true});' }
                                ]
                        },
 
                                        {       desc: '&#1344;&#1377;&#1397;&#1381;&#1408;&#1381;&#1398; (Armenian)',   source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["hy"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("Levon Zakaryan");' },
                                        {       desc: '&Iacute;slenska (Icelandic)',    source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["is"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("Haukur H. Thorsson");' },
                                        {       desc: 'Italiano (Italian)',     source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["it"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("Apaella");' },
+                                       {       desc: 'Latvie&#353;u Valoda (Latvian)', source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["lv"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("Arturas Paleicikas");' },
+                                       {       desc: 'lietuvi&#371; kalba (Lithuanian)',       source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["lt"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("Arturas Paleicikas");' },
                                        {       desc: 'Magyar (Hungarian)',     source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["hu"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("Istvan Karaszi");' },
                                        {       desc: 'Nederlands (Dutch)',     source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["nl"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("???");' },
                                        {       desc: '&#26085;&#26412;&#35486; (Japanese)',    source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["ja"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("Milly");' },
-                                       {       desc: 'Latvie&#353;u Valoda (Latvian)', source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["lv"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("Arturas Paleicikas");' },
-                                       {       desc: 'lietuvi&#371; kalba (Lithuanian)',       source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["lt"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("Arturas Paleicikas");' },
                                        {       desc: 'Norsk (Norwegian)',      source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["no"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("Naimdjon Takhirov");' },
                                        {       desc: '&#3616;&#3634;&#3625;&#3634;&#3652;&#3607;&#3618; (Thai)',       source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["th"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("pipo");' },
                                        {       desc: 'Polski (Polish)',        source: '$("#i18n").datepicker($.extend({}, $.datepicker.regional["pl"], {showStatus: true, showOn: "both", buttonImage: "templates/images/calendar.gif", buttonImageOnly: true}));$("#contrib").html("Jacek Wysocki");' },
index 01cc7fbf304c9fde0ced41ffd3cb2dd9fb2f3adb..e60b1bc18ac681036e058fc100cb252066c8bb51 100644 (file)
@@ -118,6 +118,7 @@ function Datepicker() {
                onChangeMonthYear: null, // Define a callback function when the month or year is changed
                onClose: null, // Define a callback function when the datepicker is closed
                numberOfMonths: 1, // Number of months to show at a time
+               showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
                stepMonths: 1, // Number of months to step back/forward
                stepBigMonths: 12, // Number of months to step back/forward for the big links
                rangeSelect: false, // Allows for selecting a date range on one date picker
@@ -1271,6 +1272,7 @@ $.extend(Datepicker.prototype, {
                var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
                var showBigPrevNext = this._get(inst, 'showBigPrevNext');
                var numMonths = this._getNumberOfMonths(inst);
+               var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
                var stepMonths = this._get(inst, 'stepMonths');
                var stepBigMonths = this._get(inst, 'stepBigMonths');
                var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
@@ -1278,8 +1280,12 @@ $.extend(Datepicker.prototype, {
                        new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
                var minDate = this._getMinMaxDate(inst, 'min', true);
                var maxDate = this._getMinMaxDate(inst, 'max');
-               var drawMonth = inst.drawMonth;
+               var drawMonth = inst.drawMonth - showCurrentAtPos;
                var drawYear = inst.drawYear;
+               if (drawMonth < 0) {
+                       drawMonth += 12;
+                       drawYear--;
+               }
                if (maxDate) {
                        var maxDraw = new Date(maxDate.getFullYear(),
                                maxDate.getMonth() - numMonths[1] + 1, maxDate.getDate());