~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to django/contrib/admin/media/js/calendar.js

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
var CalendarNamespace = {
26
26
    monthsOfYear: gettext('January February March April May June July August September October November December').split(' '),
27
27
    daysOfWeek: gettext('S M T W T F S').split(' '),
 
28
    firstDayOfWeek: parseInt(get_format('FIRST_DAY_OF_WEEK')),
28
29
    isLeapYear: function(year) {
29
30
        return (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0));
30
31
    },
45
46
        return days;
46
47
    },
47
48
    draw: function(month, year, div_id, callback) { // month = 1-12, year = 1-9999
 
49
        var today = new Date();
 
50
        var todayDay = today.getDate();
 
51
        var todayMonth = today.getMonth()+1;
 
52
        var todayYear = today.getFullYear();
 
53
        var todayClass = '';
 
54
 
48
55
        month = parseInt(month);
49
56
        year = parseInt(year);
50
57
        var calDiv = document.getElementById(div_id);
56
63
        // Draw days-of-week header
57
64
        var tableRow = quickElement('tr', tableBody);
58
65
        for (var i = 0; i < 7; i++) {
59
 
            quickElement('th', tableRow, CalendarNamespace.daysOfWeek[i]);
 
66
            quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]);
60
67
        }
61
68
 
62
 
        var startingPos = new Date(year, month-1, 1).getDay();
 
69
        var startingPos = new Date(year, month-1, 1 - CalendarNamespace.firstDayOfWeek).getDay();
63
70
        var days = CalendarNamespace.getDaysInMonth(month, year);
64
71
 
65
72
        // Draw blanks before first of month
75
82
            if (i%7 == 0 && currentDay != 1) {
76
83
                tableRow = quickElement('tr', tableBody);
77
84
            }
78
 
            var cell = quickElement('td', tableRow, '');
 
85
            if ((currentDay==todayDay) && (month==todayMonth) && (year==todayYear)) {
 
86
                todayClass='today';
 
87
            } else {
 
88
                todayClass='';
 
89
            }
 
90
            var cell = quickElement('td', tableRow, '', 'class', todayClass);
 
91
 
79
92
            quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '('+year+','+month+','+currentDay+'));');
80
93
            currentDay++;
81
94
        }