2222 {# Add the dialog content to the bottom of the content #}
2323 {% if advanced_filters %}
2424 {% with advanced_filters.fields_formset as formset %}
25- < div class ="white-popup mfp-hide " id ="advanced_filters ">
25+ < div class ="{{ formset.classes }} white-popup mfp-hide " id ="advanced_filters ">
2626 < h1 > {% trans "Create advanced filter" %}:</ h1 >
2727 < form novalidate method ="POST " id ="advanced_filters_form ">
2828 {% csrf_token %}
@@ -42,7 +42,7 @@ <h1>{% trans "Create advanced filter" %}:</h1>
4242 </ thead >
4343 < tbody >
4444 {% for form in formset %}
45- < tr class ="form-row {% cycle " row1 " "row2" %} {% if forloop.last %}empty-form{% endif %}" id="{{ formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %} ">
45+ < tr class ="form-row {% if forloop.last %}empty-form{% endif %} " id ="{{ formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %} ">
4646 {{form.non_field_errors}}
4747 {% for field in form.visible_fields %}
4848 < td {% if field.field.name %} class ="field-{{ field.field.name }} "{% endif %} >
@@ -63,31 +63,38 @@ <h1>{% trans "Create advanced filter" %}:</h1>
6363 < br />
6464 < input method ="POST " type ="submit " value ="{% trans "Save " %}">
6565 < input method ="POST " name ="_save_goto " type ="submit " value ="{% trans "Save & Filter Now! " %}">
66- < a href ="# " class ="grp-button " style ="margin:auto " onclick =" $.magnificPopup.close(); "> {% trans "Cancel" %}</ a >
66+ < a href ="# " class ="grp-button close " style ="margin:auto "> {% trans "Cancel" %}</ a >
6767 </ form >
6868
6969 {{ advanced_filters.media.js }}
7070
7171 < script type ="text/javascript " charset ="utf-8 ">
72- // using django's original jquery, initial formset
73- var FORM_MODEL = undefined ;
74- var MODEL_LABEL = '{{ app_label }}.{{ opts.model_name }}' ;
75- ( function ( $ ) {
76- $ . magnificPopup . instance . _onFocusIn = function ( e ) {
77- // Do nothing if target element is select2 input
78- if ( $ ( e . target ) . hasClass ( 'select2-input' ) ) {
79- return true ;
72+ 'use strict' ;
73+ {
74+ // using django's original jquery, initial formset
75+ const $ = django . jQuery ;
76+ var FORM_MODEL = undefined ;
77+ var MODEL_LABEL = '{{ app_label }}.{{ opts.model_name }}' ;
78+ $ ( function ( ) {
79+ $ . magnificPopup . instance . _onFocusIn = function ( e ) {
80+ // Do nothing if target element is select2 input
81+ if ( $ ( e . target ) . hasClass ( 'select2-input' ) ) {
82+ return true ;
83+ }
84+ // Else call parent method
85+ $ . magnificPopup . proto . _onFocusIn . call ( this , e ) ;
86+ } ;
87+ $ ( '.ajax-popup-link' ) . magnificPopup ( {
88+ type :'inline' ,
89+ } ) ;
90+ if ( $ ( ".errorlist" , "#advanced_filters" ) . length ) {
91+ $ ( '.ajax-popup-link' ) . magnificPopup ( 'open' ) ;
8092 }
81- // Else call parent method
82- $ . magnificPopup . proto . _onFocusIn . call ( this , e ) ;
83- } ;
84- $ ( '.ajax-popup-link' ) . magnificPopup ( {
85- type :'inline' ,
93+ $ ( "#advanced_filters_form a.close" ) . on ( "click" , function ( ) {
94+ $ . magnificPopup . close ( ) ;
95+ } )
8696 } ) ;
87- if ( $ ( ".errorlist" , "#advanced_filters" ) . length ) {
88- $ ( '.ajax-popup-link' ) . magnificPopup ( 'open' ) ;
89- }
90- } ) ( jQuery ) ;
97+ }
9198 </ script >
9299
93100 {% include "admin/common_js_init.html" with formset=formset %}
0 commit comments