Code

Ticket #2889: cal_prev_and_next_year.2.diff

File cal_prev_and_next_year.2.diff, 5.0 KB (added by Robert Bunting, 8 years ago)

Provides a last/next year link in the popup calendar (second version of patch rooted in proper django root dir; please ignore the first version)

Line 
1Index: django/contrib/admin/media/css/widgets.css
2===================================================================
3--- django/contrib/admin/media/css/widgets.css  (revision 3754)
4+++ django/contrib/admin/media/css/widgets.css  (working copy)
5@@ -58,10 +58,12 @@
6 .calendarnav { font-size:10px; text-align: center; color:#ccc; margin:0; padding:1px 3px; }
7 .calendarnav a:link, #calendarnav a:visited, #calendarnav a:hover { color: #999; }
8 .calendar-shortcuts { background:white; font-size:10px; line-height:11px; border-top:1px solid #eee; padding:3px 0 4px; color:#ccc; }
9-.calendarbox .calendarnav-previous, .calendarbox .calendarnav-next { display:block; position:absolute; font-weight:bold; font-size:12px; background:#C9DBED url(../img/admin/default-bg.gif) bottom left repeat-x; padding:1px 4px 2px 4px; color:white; }
10-.calendarnav-previous:hover, .calendarnav-next:hover { background:#036; }
11-.calendarnav-previous { top:0; left:0; }
12-.calendarnav-next { top:0; right:0; }
13+.calendarbox .calendarnav-previous-year, .calendarbox .calendarnav-next-year, .calendarbox .calendarnav-previous-month, .calendarbox .calendarnav-next-month { display:block; position:absolute; font-weight:bold; font-size:9px; background:#C9DBED url(../img/admin/default-bg.gif) bottom left repeat-x; padding:3px 2px 4px 2px; color:white; }
14+.calendarnav-previous-year:hover, .calendarnav-next-year:hover, .calendarnav-previous-month:hover, .calendarnav-next-month:hover { background:#036; }
15+.calendarnav-previous-year { top:0; left:0; }
16+.calendarnav-previous-month { top:0; left:20px; }
17+.calendarnav-next-month { top:0; right:20px; }
18+.calendarnav-next-year { top:0; right:0; }
19 .calendar-cancel { margin:0 !important; padding:0; font-size:10px; background:#e1e1e1 url(../img/admin/nav-bg.gif) 0 50% repeat-x;  border-top:1px solid #ddd; }
20 .calendar-cancel a { padding:2px; color:#999; }
21 ul.timelist, .timelist li { list-style-type:none; margin:0; padding:0; }
22@@ -98,4 +100,4 @@
23 .editinline-stacked .inline-object { margin-left:210px; background:white; }
24 .editinline-stacked .inline-source { float:left; width:200px; background:#f8f8f8;  }
25 .editinline-stacked .inline-splitter { float:left; width:9px; background:#f8f8f8 url(../img/admin/inline-splitter-bg.gif) 50% 50% no-repeat; border-right:1px solid #ccc; }
26-.editinline-stacked .controls { clear:both; background:#e1e1e1 url(../img/admin/nav-bg.gif) top left repeat-x; padding:3px 4px; font-size:11px; border-top:1px solid #ddd; }
27\ No newline at end of file
28+.editinline-stacked .controls { clear:both; background:#e1e1e1 url(../img/admin/nav-bg.gif) top left repeat-x; padding:3px 4px; font-size:11px; border-top:1px solid #ddd; }
29Index: django/contrib/admin/media/js/admin/DateTimeShortcuts.js
30===================================================================
31--- django/contrib/admin/media/js/admin/DateTimeShortcuts.js    (revision 3754)
32+++ django/contrib/admin/media/js/admin/DateTimeShortcuts.js    (working copy)
33@@ -167,10 +167,14 @@
34 
35         // next-prev links
36         var cal_nav = quickElement('div', cal_box, '');
37-        var cal_nav_prev = quickElement('a', cal_nav, '<', 'href', 'javascript:DateTimeShortcuts.drawPrev('+num+');');
38-        cal_nav_prev.className = 'calendarnav-previous';
39-        var cal_nav_next = quickElement('a', cal_nav, '>', 'href', 'javascript:DateTimeShortcuts.drawNext('+num+');');
40-        cal_nav_next.className = 'calendarnav-next';
41+        var cal_nav_prev_year = quickElement('a', cal_nav, '<<', 'href', 'javascript:DateTimeShortcuts.drawPrevYear('+num+');');
42+        cal_nav_prev_year.className = 'calendarnav-previous-year';
43+        var cal_nav_prev_month = quickElement('a', cal_nav, '<', 'href', 'javascript:DateTimeShortcuts.drawPrevMonth('+num+');');
44+        cal_nav_prev_month.className = 'calendarnav-previous-month';
45+        var cal_nav_next_month = quickElement('a', cal_nav, '>', 'href', 'javascript:DateTimeShortcuts.drawNextMonth('+num+');');
46+        cal_nav_next_month.className = 'calendarnav-next-month';
47+        var cal_nav_next_year = quickElement('a', cal_nav, '>>', 'href', 'javascript:DateTimeShortcuts.drawNextYear('+num+');');
48+        cal_nav_next_year.className = 'calendarnav-next-year';
49         cal_box.appendChild(cal_nav);
50 
51         // main box
52@@ -217,12 +221,18 @@
53     dismissCalendar: function(num) {
54         document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'none';
55     },
56-    drawPrev: function(num) {
57+    drawPrevMonth: function(num) {
58         DateTimeShortcuts.calendars[num].drawPreviousMonth();
59     },
60-    drawNext: function(num) {
61+    drawNextMonth: function(num) {
62         DateTimeShortcuts.calendars[num].drawNextMonth();
63     },
64+    drawPrevYear: function(num) {
65+        DateTimeShortcuts.calendars[num].drawPreviousYear();
66+    },
67+    drawNextYear: function(num) {
68+        DateTimeShortcuts.calendars[num].drawNextYear();
69+    },
70     handleCalendarCallback: function(num) {
71         return "function(y, m, d) { DateTimeShortcuts.calendarInputs["+num+"].value = y+'-'+m+'-'+d; document.getElementById(DateTimeShortcuts.calendarDivName1+"+num+").style.display='none';}";
72     },