Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07c38baa83 | |||
| ed669a88be | |||
| 71ad991ba7 | |||
| 05128a997e | |||
| 92a816b9ae |
@@ -47,7 +47,7 @@ INSTALLED_APPS = (
|
||||
## Optional themes
|
||||
This package ships with optional themes as fixtures, they can be installed using the [loaddata admin command](https://docs.djangoproject.com/en/1.11/ref/django-admin/#django-admin-loaddata). Optional themes are activated on installation.
|
||||
|
||||
##### Django theme (default):
|
||||
##### [Django](https://www.djangoproject.com/) theme (default):
|
||||
Run ``python manage.py loaddata admin_interface_theme_django.json``
|
||||
|
||||
##### [Bootstrap](http://getbootstrap.com/) theme:
|
||||
|
||||
@@ -22,13 +22,23 @@
|
||||
var initData = JSON.parse(document.getElementById('django-admin-popup-response-constants').dataset.popupResponse);
|
||||
switch(initData.action){
|
||||
case 'change':
|
||||
openerRef.dismissChangeRelatedObjectPopup(modalRef, initData.value, initData.obj, initData.new_value);
|
||||
if( typeof(openerRef.dismissChangeRelatedObjectPopup) == 'function' ){
|
||||
openerRef.dismissChangeRelatedObjectPopup(modalRef, initData.value, initData.obj, initData.new_value);
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
openerRef.dismissDeleteRelatedObjectPopup(modalRef, initData.value);
|
||||
if( typeof(openerRef.dismissDeleteRelatedObjectPopup) == 'function' ){
|
||||
openerRef.dismissDeleteRelatedObjectPopup(modalRef, initData.value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
openerRef.dismissAddRelatedObjectPopup(modalRef, initData.value, initData.obj);
|
||||
if( typeof(openerRef.dismissAddRelatedObjectPopup) == 'function' ){
|
||||
openerRef.dismissAddRelatedObjectPopup(modalRef, initData.value, initData.obj);
|
||||
}
|
||||
else if( typeof(openerRef.dismissAddAnotherPopup) == 'function' ){
|
||||
// django 1.7 compatibility
|
||||
openerRef.dismissAddAnotherPopup(modalRef, initData.value, initData.obj);
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -7,18 +7,23 @@ if(typeof django !== 'undefined' && typeof django.jQuery !== 'undefined' )
|
||||
// create the function that will close the modal
|
||||
function dismissRelatedObjectModal()
|
||||
{
|
||||
// close the popup
|
||||
// close the popup as modal
|
||||
$.magnificPopup.close();
|
||||
}
|
||||
|
||||
// assign the function to a global variable
|
||||
window.dismissRelatedObjectModal = dismissRelatedObjectModal;
|
||||
|
||||
// listen click events on related links
|
||||
// (:link prevents to listen click event if href is not defined)
|
||||
$('a.related-widget-wrapper-link:link').click(function(e){
|
||||
function presentRelatedObjectModal(e)
|
||||
{
|
||||
var href = ($(this).attr('href') || '');
|
||||
if( href == '' ){
|
||||
return;
|
||||
}
|
||||
|
||||
// open the popup as modal
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
// remove focus from clicked link
|
||||
$(this).blur();
|
||||
@@ -26,16 +31,23 @@ if(typeof django !== 'undefined' && typeof django.jQuery !== 'undefined' )
|
||||
// use the clicked link id as iframe name
|
||||
// it will be available as window.name in the loaded iframe
|
||||
var iframeName = $(this).attr('id');
|
||||
//var iframeName = String(window.name + '____' + $(this).attr('id'));
|
||||
//console.log('open modal with name: "' + iframeName + '"');
|
||||
// var iframeName = String(window.name + '____' + $(this).attr('id'));
|
||||
// console.log('open modal with name: "' + iframeName + '"');
|
||||
|
||||
// browsers stop loading nested iframes having the same src url
|
||||
// create a random parameter and append it to the src url to prevent it
|
||||
var iframeSrcRandom = String(Math.round(Math.random() * 999999));
|
||||
var iframeSrc = $(this).attr('href') + '&_modal=' + iframeSrcRandom;
|
||||
var iframeSrc = href;
|
||||
|
||||
// fix for django 1.7
|
||||
if( iframeSrc.indexOf('_popup=1') == -1 ){
|
||||
iframeSrc += '&_popup=1';
|
||||
}
|
||||
|
||||
iframeSrc += '&_modal=' + iframeSrcRandom;
|
||||
|
||||
// build the iframe html
|
||||
//var iframeHTML = '<iframe id="related-modal" name="' + iframeName + '" src="' + iframeSrc + '"></iframe>';
|
||||
// var iframeHTML = '<iframe id="related-modal" name="' + iframeName + '" src="' + iframeSrc + '"></iframe>';
|
||||
var iframeHTML = '<iframe id="related-modal-iframe" name="' + iframeName + '" src="' + iframeSrc + '"></iframe>';
|
||||
|
||||
// create the iframe jquery element
|
||||
@@ -61,7 +73,16 @@ if(typeof django !== 'undefined' && typeof django.jQuery !== 'undefined' )
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// listen click events on related links
|
||||
|
||||
// django 1.7 compatibility
|
||||
$('a.add-another').removeAttr('onclick');
|
||||
$('a.add-another').click( presentRelatedObjectModal );
|
||||
|
||||
// django 1.8 and above
|
||||
$('a.related-widget-wrapper-link').click( presentRelatedObjectModal );
|
||||
});
|
||||
|
||||
})(django.jQuery);
|
||||
|
||||
@@ -8,8 +8,12 @@
|
||||
|
||||
{% block extrastyle %}
|
||||
{% get_admin_interface_theme as theme %}
|
||||
{% get_admin_interface_version as version %}
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
django-admin-interface {{ version }}
|
||||
https://github.com/fabiocaccamo/django-admin-interface
|
||||
*/
|
||||
{% include "admin_interface/css/admin-interface.css" %}
|
||||
{% include "admin_interface/css/admin-interface-fix.css" %}
|
||||
{% include "admin_interface/css/list-filter-dropdown.css" %}
|
||||
@@ -29,14 +33,15 @@
|
||||
|
||||
{% block blockbots %}
|
||||
{{ block.super }}
|
||||
{% get_admin_interface_theme as theme %}
|
||||
{% get_admin_interface_version as version %}
|
||||
{# https://github.com/elky/django-flat-responsive#important-note #}
|
||||
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'admin/css/responsive.css' %}" />
|
||||
{% get_admin_interface_theme as theme %}
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'admin/css/responsive.css' %}?v={{ version }}" />
|
||||
{% if theme.related_modal_active %}
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'admin_interface/magnific-popup/magnific-popup.css' %}" />
|
||||
<script type="text/javascript" src="{% static 'admin_interface/magnific-popup/jquery.magnific-popup.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'admin_interface/related-modal/related-modal.js' %}"></script>
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'admin_interface/magnific-popup/magnific-popup.css' %}?v={{ version }}" />
|
||||
<script type="text/javascript" src="{% static 'admin_interface/magnific-popup/jquery.magnific-popup.js' %}?v={{ version }}"></script>
|
||||
<script type="text/javascript" src="{% static 'admin_interface/related-modal/related-modal.js' %}?v={{ version }}"></script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
{% load i18n static %}<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>{% trans 'Popup closing...' %}</title></head>
|
||||
<body>
|
||||
<script type="text/javascript"
|
||||
id="django-admin-popup-response-constants"
|
||||
src="{% static "admin/js/popup_response.js" %}"
|
||||
{% if popup_response_data %}
|
||||
data-popup-response="{{ popup_response_data }}"
|
||||
{% else %}
|
||||
data-popup-response='{"action":"{{ action|escape }}","value":"{{ value|escape }}","obj":"{{ obj|escape }}","new_value":"{{ new_value|escape }}"}'
|
||||
{% endif %}>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -3,7 +3,7 @@
|
||||
from django import template
|
||||
|
||||
from admin_interface.models import Theme
|
||||
|
||||
from admin_interface.version import __version__
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@@ -30,3 +30,8 @@ def get_admin_interface_theme(context):
|
||||
|
||||
return theme
|
||||
|
||||
|
||||
@assignment_tag(takes_context = True)
|
||||
def get_admin_interface_version(context):
|
||||
return __version__
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
__version__ = '0.5.0'
|
||||
__version__ = '0.5.1'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user