admin: Fix query parameter manipulation in showAddAnotherPopup.

This should fix the bug in, i.e., adding tags from the blog entry admin
page.
This commit is contained in:
Brett Smith 2017-05-23 12:13:04 -04:00
parent 7cb314b2f0
commit 6d7e96b4c8

View file

@ -1,21 +1,21 @@
// Handles related-objects functionality: lookup link for raw_id_admin=True // Handles related-objects functionality: lookup link for raw_id_admin=True
// and Add Another links. // and Add Another links.
function showRelatedObjectLookupPopup(triggeringLink) { function showPopupFromLink(elem, nameTrimRegexp, popupParamName) {
var name = triggeringLink.id.replace(/^lookup_/, ''); var name = elem.id.replace(nameTrimRegexp, '');
// IE doesn't like periods in the window name, so convert temporarily. // IE doesn't like periods in the window name, so convert temporarily.
name = name.replace(/\./g, '___'); name = name.replace(/\./g, '___');
var href; var url = new URL(elem.href);
if (triggeringLink.href.search(/\?/) >= 0) { url.searchParams.set(popupParamName, '1');
href = triggeringLink.href + '&pop=1'; var win = window.open(url.toString(), name, 'height=500,width=800,resizable=yes,scrollbars=yes');
} else {
href = triggeringLink.href + '?pop=1';
}
var win = window.open(href, name, 'height=500,width=740,resizable=yes,scrollbars=yes');
win.focus(); win.focus();
return false; return false;
} }
function showRelatedObjectLookupPopup(triggeringLink) {
return showPopupFromLink(triggeringLink, /^lookup_/, 'pop');
}
function dismissRelatedLookupPopup(win, chosenId) { function dismissRelatedLookupPopup(win, chosenId) {
var name = win.name.replace(/___/g, '.'); var name = win.name.replace(/___/g, '.');
var elem = document.getElementById(name); var elem = document.getElementById(name);
@ -28,11 +28,7 @@ function dismissRelatedLookupPopup(win, chosenId) {
} }
function showAddAnotherPopup(triggeringLink) { function showAddAnotherPopup(triggeringLink) {
var name = triggeringLink.id.replace(/^add_/, ''); return showPopupFromLink(triggeringLink, /^add_/, '_popup');
name = name.replace(/\./g, '___');
var win = window.open(triggeringLink.href + '?_popup=1', name, 'height=500,width=800,resizable=yes,scrollbars=yes');
win.focus();
return false;
} }
function dismissAddAnotherPopup(win, newId, newRepr) { function dismissAddAnotherPopup(win, newId, newRepr) {