@@ -1410,10 +1410,7 @@ Docs at http://horizontal-timeline.ycodetech.co.uk
14101410
14111411 // Function to add required js and css files dynamically
14121412 // (CDN URL of the plugin, file type JS or CSS, callback function)
1413- Timeline . prototype . _addFile = function ( url , type , callback ) {
1414- // Check if callback is a function, if it is then set a variable as the callback to be called.
1415- if ( typeof callback === "function" ) var callback = callback ( this ) ;
1416-
1413+ Timeline . prototype . _addFile = function ( url , type , callback ) {
14171414 // If addRequiredFile is true...
14181415 if ( this . settings . addRequiredFile == true ) {
14191416 // Set loadedFile variable as body data of the loadedfile array, to check against later
@@ -1451,7 +1448,8 @@ Docs at http://horizontal-timeline.ycodetech.co.uk
14511448 $ . getScript ( url )
14521449 . done ( function ( script , textStatus ) {
14531450 // Then execute it via the callback option
1454- callback ;
1451+ // Check if callback is a function, if it is then set a variable as the callback to be called.
1452+ if ( typeof callback === "function" ) callback ( this ) ;
14551453 } )
14561454 . fail ( function ( jqxhr , settings , exception ) {
14571455 console . error ( "Failed to get " + url + "\n" + jqxhr + "\n" + this . settings + "\n" + exception ) ;
@@ -1480,7 +1478,8 @@ Docs at http://horizontal-timeline.ycodetech.co.uk
14801478 if ( js ) {
14811479 console . log ( name + ' has already been loaded by a <script> tag in the document, no need to load it again. Timeline instance:' , this . $element ) ;
14821480 // Execute the plugin via the callback option.
1483- callback ;
1481+ // Check if callback is a function, if it is then set a variable as the callback to be called.
1482+ if ( typeof callback === "function" ) callback ( this ) ;
14841483 }
14851484 // Push/add the url to the loadedFile array to check against.
14861485 loadedFile . push ( url ) ;
@@ -1490,7 +1489,8 @@ Docs at http://horizontal-timeline.ycodetech.co.uk
14901489 if ( js ) {
14911490 console . log ( name + ' has already been loaded, no need to load it again. Timeline instance:' , this . $element ) ;
14921491 // Execute the plugin via the callback option.
1493- callback ;
1492+ // Check if callback is a function, if it is then set a variable as the callback to be called.
1493+ if ( typeof callback === "function" ) callback ( this ) ;
14941494 }
14951495 }
14961496
@@ -1501,7 +1501,10 @@ Docs at http://horizontal-timeline.ycodetech.co.uk
15011501 $ ( 'body' ) . data ( 'plugin_' + this . _name + '_loadedFile' , loadedFile ) ;
15021502 } // End if addRequiredFile statement.
15031503 // If addRequiredFile is false we just need to execute the plugin via the callback option.
1504- else callback ;
1504+ else {
1505+ // Check if callback is a function, if it is then set a variable as the callback to be called.
1506+ if ( typeof callback === "function" ) callback ( this ) ;
1507+ }
15051508 } // End addFile function
15061509
15071510 // A really lightweight plugin wrapper around the constructor,
0 commit comments