Ticket #17064: 17064.improved-date-time-picker-ux.diff

File 17064.improved-date-time-picker-ux.diff, 3.7 KB (added by Julien Phalip, 13 years ago)
  • django/contrib/admin/static/admin/css/widgets.css

    diff --git a/django/contrib/admin/static/admin/css/widgets.css b/django/contrib/admin/static/admin/css/widgets.css
    index 3b5c31c..2989f2f 100644
    a b span.clearable-file-input label {  
    379379
    380380.calendar-cancel {
    381381    margin: 0 !important;
    382     padding: 0;
     382    padding: 0 !important;
    383383    font-size: 10px;
    384384    background: #e1e1e1 url(../img/nav-bg.gif) 0 50% repeat-x;
    385385    border-top: 1px solid #ddd;
    386386}
    387387
     388.calendar-cancel:hover {
     389    background: #e1e1e1 url(../img/nav-bg-reverse.gif) 0 50% repeat-x;
     390}
     391
    388392.calendar-cancel a {
    389     padding: 2px;
    390     color: #999;
     393    color: black;
     394    display: block;
    391395}
    392396
    393397ul.timelist, .timelist li {
  • django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js

    diff --git a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js
    index f22cc7a..3ecc06f 100644
    a b var DateTimeShortcuts = {  
    7979        addEvent(clock_box, 'click', DateTimeShortcuts.cancelEventPropagation);
    8080
    8181        quickElement('h2', clock_box, gettext('Choose a time'));
    82         time_list = quickElement('ul', clock_box, '');
     82        var time_list = quickElement('ul', clock_box, '');
    8383        time_list.className = 'timelist';
    84         time_format = get_format('TIME_INPUT_FORMATS')[0];
     84        var time_format = get_format('TIME_INPUT_FORMATS')[0];
    8585        quickElement("a", quickElement("li", time_list, ""), gettext("Now"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", new Date().strftime('" + time_format + "'));");
    8686        quickElement("a", quickElement("li", time_list, ""), gettext("Midnight"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", new Date(1970,1,1,0,0,0,0).strftime('" + time_format + "'));");
    8787        quickElement("a", quickElement("li", time_list, ""), gettext("6 a.m."), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", new Date(1970,1,1,6,0,0,0).strftime('" + time_format + "'));");
    8888        quickElement("a", quickElement("li", time_list, ""), gettext("Noon"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", new Date(1970,1,1,12,0,0,0).strftime('" + time_format + "'));");
    8989
    90         cancel_p = quickElement('p', clock_box, '');
     90        var cancel_p = quickElement('p', clock_box, '');
    9191        cancel_p.className = 'calendar-cancel';
    9292        quickElement('a', cancel_p, gettext('Cancel'), 'href', 'javascript:DateTimeShortcuts.dismissClock(' + num + ');');
     93        django.jQuery(document).bind('keyup', function(event) {
     94            if (event.which == 27) {
     95                // ESC key closes popup
     96                DateTimeShortcuts.dismissClock(num);
     97                event.preventDefault();
     98            }
     99        });
    93100    },
    94101    openClock: function(num) {
    95102        var clock_box = document.getElementById(DateTimeShortcuts.clockDivName+num)
    var DateTimeShortcuts = {  
    195202        var cancel_p = quickElement('p', cal_box, '');
    196203        cancel_p.className = 'calendar-cancel';
    197204        quickElement('a', cancel_p, gettext('Cancel'), 'href', 'javascript:DateTimeShortcuts.dismissCalendar(' + num + ');');
     205        django.jQuery(document).bind('keyup', function(event) {
     206            if (event.which == 27) {
     207                // ESC key closes popup
     208                DateTimeShortcuts.dismissCalendar(num);
     209                event.preventDefault();
     210            }
     211        });
    198212    },
    199213    openCalendar: function(num) {
    200214        var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1+num)
Back to Top