diff --git a/django/contrib/admin/static/admin/js/SelectBox.js b/django/contrib/admin/static/admin/js/SelectBox.js index 37aa702963..68e29d5828 100644 --- a/django/contrib/admin/static/admin/js/SelectBox.js +++ b/django/contrib/admin/static/admin/js/SelectBox.js @@ -25,7 +25,7 @@ if (node.displayed) { var new_option = new Option(node.text, node.value, false, false); // Shows a tooltip when hovering over the option - new_option.setAttribute("title", node.text); + new_option.title = node.text; box.appendChild(new_option); } } diff --git a/django/contrib/admin/static/admin/js/SelectFilter2.js b/django/contrib/admin/static/admin/js/SelectFilter2.js index 46056b8d23..9541da13d1 100644 --- a/django/contrib/admin/static/admin/js/SelectFilter2.js +++ b/django/contrib/admin/static/admin/js/SelectFilter2.js @@ -103,12 +103,12 @@ Requires jQuery, core.js, and SelectBox.js. ) ); - var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name')); + var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.name); to_box.className = 'filtered'; var clear_all = quickElement('a', selector_chosen, gettext('Remove all'), 'title', interpolate(gettext('Click to remove all chosen %s at once.'), [field_name]), 'href', '#', 'id', field_id + '_remove_all_link'); clear_all.className = 'selector-clearall'; - from_box.setAttribute('name', from_box.getAttribute('name') + '_old'); + from_box.name = from_box.name + '_old'; // Set up the JavaScript event handlers for the select box filter interface var move_selection = function(e, elem, move_func, from, to) { diff --git a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js index f80352330c..a2ef721ee5 100644 --- a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js +++ b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js @@ -29,7 +29,7 @@ timezoneOffset: 0, init: function() { var body = document.getElementsByTagName('body')[0]; - var serverOffset = body.getAttribute('data-admin-utc-offset'); + var serverOffset = body.dataset.adminUtcOffset; if (serverOffset) { var localOffset = new Date().getTimezoneOffset() * -60; DateTimeShortcuts.timezoneOffset = localOffset - serverOffset; @@ -38,11 +38,11 @@ var inputs = document.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i++) { var inp = inputs[i]; - if (inp.getAttribute('type') === 'text' && inp.className.match(/vTimeField/)) { + if (inp.type === 'text' && inp.className.match(/vTimeField/)) { DateTimeShortcuts.addClock(inp); DateTimeShortcuts.addTimezoneWarning(inp); } - else if (inp.getAttribute('type') === 'text' && inp.className.match(/vDateField/)) { + else if (inp.type === 'text' && inp.className.match(/vDateField/)) { DateTimeShortcuts.addCalendar(inp); DateTimeShortcuts.addTimezoneWarning(inp); } @@ -51,7 +51,7 @@ // Return the current time while accounting for the server timezone. now: function() { var body = document.getElementsByTagName('body')[0]; - var serverOffset = body.getAttribute('data-admin-utc-offset'); + var serverOffset = body.dataset.adminUtcOffset; if (serverOffset) { var localNow = new Date(); var localOffset = localNow.getTimezoneOffset() * -60; @@ -111,14 +111,14 @@ shortcuts_span.className = DateTimeShortcuts.shortCutsClass; inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling); var now_link = document.createElement('a'); - now_link.setAttribute('href', "#"); + now_link.href = "#"; now_link.textContent = gettext('Now'); now_link.addEventListener('click', function(e) { e.preventDefault(); DateTimeShortcuts.handleClockQuicklink(num, -1); }); var clock_link = document.createElement('a'); - clock_link.setAttribute('href', '#'); + clock_link.href = '#'; clock_link.id = DateTimeShortcuts.clockLinkName + num; clock_link.addEventListener('click', function(e) { e.preventDefault(); @@ -156,7 +156,7 @@ clock_box.style.display = 'none'; clock_box.style.position = 'absolute'; clock_box.className = 'clockbox module'; - clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num); + clock_box.id = DateTimeShortcuts.clockDivName + num; document.body.appendChild(clock_box); clock_box.addEventListener('click', function(e) { e.stopPropagation(); }); @@ -241,14 +241,14 @@ shortcuts_span.className = DateTimeShortcuts.shortCutsClass; inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling); var today_link = document.createElement('a'); - today_link.setAttribute('href', '#'); + today_link.href = '#'; today_link.appendChild(document.createTextNode(gettext('Today'))); today_link.addEventListener('click', function(e) { e.preventDefault(); DateTimeShortcuts.handleCalendarQuickLink(num, 0); }); var cal_link = document.createElement('a'); - cal_link.setAttribute('href', '#'); + cal_link.href = '#'; cal_link.id = DateTimeShortcuts.calendarLinkName + num; cal_link.addEventListener('click', function(e) { e.preventDefault(); @@ -287,7 +287,7 @@ cal_box.style.display = 'none'; cal_box.style.position = 'absolute'; cal_box.className = 'calendarbox module'; - cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num); + cal_box.id = DateTimeShortcuts.calendarDivName1 + num; document.body.appendChild(cal_box); cal_box.addEventListener('click', function(e) { e.stopPropagation(); }); diff --git a/django/contrib/admin/static/admin/js/collapse.js b/django/contrib/admin/static/admin/js/collapse.js index 20e7030e7e..c40dcc2ee1 100644 --- a/django/contrib/admin/static/admin/js/collapse.js +++ b/django/contrib/admin/static/admin/js/collapse.js @@ -21,9 +21,9 @@ elem.classList.add('collapsed'); var h2 = elem.querySelector('h2'); var link = document.createElement('a'); - link.setAttribute('id', 'fieldsetcollapser' + i); - link.setAttribute('class', 'collapse-toggle'); - link.setAttribute('href', '#'); + link.id = 'fieldsetcollapser' + i; + link.className = 'collapse-toggle'; + link.href = '#'; link.textContent = gettext('Show'); h2.appendChild(document.createTextNode(' (')); h2.appendChild(link); diff --git a/django/contrib/admin/static/admin/js/collapse.min.js b/django/contrib/admin/static/admin/js/collapse.min.js index 9e16a21eb9..03f74e7f5a 100644 --- a/django/contrib/admin/static/admin/js/collapse.min.js +++ b/django/contrib/admin/static/admin/js/collapse.min.js @@ -1,3 +1,3 @@ -(function(){var e=function(b,a){return b.nodeName===a.toUpperCase()?b:"BODY"===b.parentNode.nodeName?null:b.parentNode&&e(b.parentNode,a)};window.addEventListener("load",function(){for(var b=document.querySelectorAll("fieldset.collapse"),a=0;a