@@ -10,39 +10,40 @@ __webpack_public_path__ = require('../modules/get-dist-path')('bundle.forms.apph
10
10
// #############################################################################
11
11
// APP HOOK SELECT
12
12
require . ensure ( [ ] , function ( require ) {
13
- var $ = require ( 'jquery' ) ;
14
- var apphookData = {
13
+ const $ = require ( 'jquery' ) ;
14
+ let apphookData = {
15
15
apphooks_configuration : { } ,
16
16
apphooks_configuration_value : undefined ,
17
17
apphooks_configuration_url : { }
18
18
} ;
19
- var dataElement = document . querySelector ( 'script[data-cms-widget-applicationconfigselect]' ) ;
20
-
21
- if ( dataElement ) {
22
- apphookData = JSON . parse ( dataElement . querySelector ( 'script' ) . textContent ) ;
23
- }
24
-
25
- var apphooks_configuration = apphookData . apphooks_configuration || { } ;
26
19
27
20
// shorthand for jQuery(document).ready();
28
21
$ ( function ( ) {
29
- var appHooks = $ ( '#application_urls, #id_application_urls' ) ;
30
- var selected = appHooks . find ( 'option:selected' ) ;
31
- var appNsRow = $ ( '.form-row.application_namespace, .form-row.field-application_namespace' ) ;
32
- var appNs = appNsRow . find ( '#application_namespace, #id_application_namespace' ) ;
33
- var appCfgsRow = $ ( '.form-row.application_configs, .form-row.field-application_configs' ) ;
34
- var appCfgs = appCfgsRow . find ( '#application_configs, #id_application_configs' ) ;
35
- var appCfgsAdd = appCfgsRow . find ( '#add_application_configs' ) ;
36
- var original_ns = appNs . val ( ) ;
22
+ const dataElement = document . querySelector ( 'div[data-cms-widget-applicationconfigselect]' ) ;
23
+
24
+ if ( dataElement ) {
25
+ apphookData = JSON . parse ( dataElement . querySelector ( 'script' ) . textContent ) ;
26
+ }
27
+
28
+ const apphooks_configuration = apphookData . apphooks_configuration || { } ;
29
+
30
+ const appHooks = $ ( '#application_urls, #id_application_urls' ) ;
31
+ const selected = appHooks . find ( 'option:selected' ) ;
32
+ const appNsRow = $ ( '.form-row.application_namespace, .form-row.field-application_namespace' ) ;
33
+ const appNs = appNsRow . find ( '#application_namespace, #id_application_namespace' ) ;
34
+ const appCfgsRow = $ ( '.form-row.application_configs, .form-row.field-application_configs' ) ;
35
+ const appCfgs = appCfgsRow . find ( '#application_configs, #id_application_configs' ) ;
36
+ const appCfgsAdd = appCfgsRow . find ( '#add_application_configs' ) ;
37
+ const original_ns = appNs . val ( ) ;
37
38
38
39
// Shows / hides namespace / config selection widgets depending on the user input
39
40
appHooks . setupNamespaces = function ( ) {
40
- var opt = $ ( this ) . find ( 'option:selected' ) ;
41
+ const opt = $ ( this ) . find ( 'option:selected' ) ;
41
42
42
43
if ( $ ( appCfgs ) . length > 0 && apphooks_configuration [ opt . val ( ) ] ) {
43
44
appCfgs . html ( '' ) ;
44
- for ( var i = 0 ; i < apphooks_configuration [ opt . val ( ) ] . length ; i ++ ) {
45
- var selectedCfgs = '' ;
45
+ for ( let i = 0 ; i < apphooks_configuration [ opt . val ( ) ] . length ; i ++ ) {
46
+ let selectedCfgs = '' ;
46
47
47
48
if ( apphooks_configuration [ opt . val ( ) ] [ i ] [ 0 ] === apphookData . apphooks_configuration_value ) {
48
49
selectedCfgs = 'selected="selected"' ;
@@ -58,7 +59,8 @@ require.ensure([], function (require) {
58
59
// exists, and if it does - we add `_popup` ourselves, because otherwise the popup with
59
60
// apphook creation form will not be dismissed correctly
60
61
( window . showRelatedObjectPopup ? '?_popup=1' : '' ) ) ;
61
- appCfgsAdd . on ( 'click' , function ( ) {
62
+ appCfgsAdd . on ( 'click' , function ( ev ) {
63
+ ev . preventDefault ( ) ;
62
64
window . showAddAnotherPopup ( this ) ;
63
65
} ) ;
64
66
appCfgsRow . removeClass ( 'hidden' ) ;
0 commit comments