Proposal:
1. Provide a setting to change default popup size
2. Use some global Javascript variable for storing popup size so we could
override per page
Sample application:
{{{
#!python
# models.py
class Author(models.Model):
name = models.CharField(max_length=100)
class Book(models.Model):
author = models.ForeignKey(Author)
name = models.CharField(max_length=100)
# admin.py
@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
pass
@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
raw_id_fields = ('author',)
}}}
Source code:
{{{
#!javascript
// RelatedObjectLookups.js
function showAdminPopup(triggeringLink, name_regexp, add_popup) {
var name = triggeringLink.id.replace(name_regexp, '');
name = id_to_windowname(name);
var href = triggeringLink.href;
if (add_popup) {
if (href.indexOf('?') === -1) {
href += '?_popup=1';
} else {
href += '&_popup=1';
}
}
var win = window.open(href, name,
'height=500,width=800,resizable=yes,scrollbars=yes');
win.focus();
return false;
}
//-----------------------------------------^ here it is
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28068>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by tonnzor):
It is the workaround I had to add via base.html (does not work well with
Firefox and not smooth):
{{{
#!javascript
function resize_for_popup() {
if(/[?&]_popup=1(&|$)/.test(location.href)) {
// In Firefox you may need to set (via about:config):
dom.disable_window_move_resize = false
var reference = window.opener || screen;
var width = parseInt(reference.outerWidth * 2 / 3);
var height = parseInt(reference.outerHeight * 2 / 3);
window.resizeTo(width, height);
}
}
resize_for_popup();
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28068#comment:1>
Comment (by Tim Graham):
Could you elaborate on "does not always match user expectations"? Maybe it
makes sense to change the default since monitor resolution has increased
over the years. I'm not sure if adding a setting for this is really
needed.
--
Ticket URL: <https://code.djangoproject.com/ticket/28068#comment:2>
Comment (by tonnzor):
Users expect something bigger than 800x500. It is hard to suggest a single
resolution for everyone -- some users have 1280x768, others have 1920x1080
monitors.
Another alternative is to calculate popup size in runtime by JavaScript
according to user screen size. We could reuse parts of my workaround (it
generates 2/3 of size of source window or screen).
--
Ticket URL: <https://code.djangoproject.com/ticket/28068#comment:3>
* stage: Unreviewed => Someday/Maybe
Comment:
Maybe you could raise the idea on the DevelopersMailingList and ask for
ideas.
--
Ticket URL: <https://code.djangoproject.com/ticket/28068#comment:4>
Comment (by oko-x):
Pretty simple is also to leave the browser to open it in new tab. Full
size of the browser is usually good sizing in admin as the user is not
taken out of context by popup.
{{{
var win = window.open(href, name);
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28068#comment:5>