@@ -93,56 +93,56 @@ window.wplf = {
9393 form . addEventListener ( "submit" , window . wplf . submitHandler ) ;
9494 }
9595} ;
96+ ( function ( ) {
97+ var main = function ( ) {
98+ [ ] . forEach . call ( document . querySelectorAll ( ".libre-form" ) , window . wplf . attach ) ;
99+ } ;
100+ var dependencies = [ ] ;
96101
97- var main = function ( ) {
98- [ ] . forEach . call ( document . querySelectorAll ( ".libre-form" ) , window . wplf . attach ) ;
99- } ;
100-
101- var dependencies = [ ] ;
102-
103- if ( ! window . fetch ) {
104- dependencies . push ( 'fetch' ) ;
105- }
102+ if ( ! window . fetch ) {
103+ dependencies . push ( 'fetch' ) ;
104+ }
106105
107- if ( ! window . Promise ) {
108- dependencies . push ( 'Promise' ) ;
109- }
106+ if ( ! window . Promise ) {
107+ dependencies . push ( 'Promise' ) ;
108+ }
110109
111110
112- function initialize ( dependencies , app ) {
113- var dependency_count = dependencies . length ;
114- var dependencies_loaded = 0 ;
115- var is_ready = function ( ) {
116- return dependency_count === dependencies_loaded ;
117- } ;
118- var run_when_ready = function ( ) {
119- if ( is_ready ( ) ) {
120- app ( ) ;
121- }
122- } ;
123- var get_script = function ( script ) {
124- var elmnt = document . createElement ( 'script' ) ;
125- elmnt . src = ajax_object . wplf_assets_dir + '/scripts/polyfills/' + script + '.js' ;
126-
127- return elmnt ;
128- } ;
111+ function initialize ( dependencies , app ) {
112+ var dependency_count = dependencies . length ;
113+ var dependencies_loaded = 0 ;
114+ var is_ready = function ( ) {
115+ return dependency_count === dependencies_loaded ;
116+ } ;
117+ var run_when_ready = function ( ) {
118+ if ( is_ready ( ) ) {
119+ app ( ) ;
120+ }
121+ } ;
122+ var get_script = function ( script ) {
123+ var elmnt = document . createElement ( 'script' ) ;
124+ elmnt . src = ajax_object . wplf_assets_dir + '/scripts/polyfills/' + script + '.js' ;
125+
126+ return elmnt ;
127+ } ;
128+
129+ dependencies . map ( function ( dependency ) {
130+ return dependency . toLowerCase ( ) ;
131+ } ) . map ( function ( dependency ) {
132+ return get_script ( dependency ) ;
133+ } ) . map ( function ( script ) {
134+ script . addEventListener ( 'load' , function ( ) {
135+ dependencies_loaded ++ ;
136+ run_when_ready ( ) ;
137+ } ) ;
129138
130- dependencies . map ( function ( dependency ) {
131- return dependency . toLowerCase ( ) ;
132- } ) . map ( function ( dependency ) {
133- return get_script ( dependency ) ;
134- } ) . map ( function ( script ) {
135- script . addEventListener ( 'load' , function ( ) {
136- dependencies_loaded ++ ;
137- run_when_ready ( ) ;
139+ return document . body . appendChild ( script ) ;
138140 } ) ;
139141
140- return document . body . appendChild ( script ) ;
141- } ) ;
142-
143- run_when_ready ( ) ;
144- }
142+ run_when_ready ( ) ;
143+ }
145144
146- document . addEventListener ( 'DOMContentLoaded' , function ( ) {
147- initialize ( dependencies , main ) ;
148- } ) ;
145+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
146+ initialize ( dependencies , main ) ;
147+ } ) ;
148+ } ( ) ) ;
0 commit comments