@@ -700,11 +700,16 @@ def export_tour(tour_steps, name=None, filename="my_tour.js", url=None):
700700 backdrop_style = style_sheet .bt_backdrop_style
701701 backdrop_style = backdrop_style .replace ('\n ' , '' )
702702 backdrop_style = js_utils .escape_quotes_if_needed (backdrop_style )
703- instructions += 'injectJS("%s");' % jquery_js
704- instructions += '\n \n //////// Resources - Load 2 ////////\n \n '
703+ instructions += 'injectJS("%s");\n ' % jquery_js
704+ instructions += '\n '
705+ instructions += 'function loadResources() { '
706+ instructions += 'if ( typeof jQuery !== "undefined" ) {\n '
705707 instructions += 'injectCSS("%s");\n ' % bootstrap_tour_css
706708 instructions += 'injectStyle("%s");\n ' % backdrop_style
707709 instructions += 'injectJS("%s");' % bootstrap_tour_js
710+ instructions += '} else { window.setTimeout("loadResources();",100); '
711+ instructions += '} }\n '
712+ instructions += 'loadResources()'
708713
709714 elif tour_type == "hopscotch" :
710715 hopscotch_css = constants .Hopscotch .MIN_CSS
@@ -738,18 +743,36 @@ def export_tour(tour_steps, name=None, filename="my_tour.js", url=None):
738743 backdrop_style = js_utils .escape_quotes_if_needed (backdrop_style )
739744 instructions += 'injectCSS("%s");\n ' % spinner_css
740745 instructions += 'injectJS("%s");\n ' % jquery_js
741- instructions += 'injectJS("%s");' % tether_js
742- instructions += '\n \n //////// Resources - Load 2 ////////\n \n '
746+ instructions += 'injectJS("%s");\n ' % tether_js
747+ instructions += '\n '
748+ instructions += 'function loadResources() { '
749+ instructions += 'if ( typeof jQuery !== "undefined" ) {\n '
743750 instructions += 'injectCSS("%s");' % sh_theme_arrows_css
744751 instructions += 'injectCSS("%s");' % sh_theme_arrows_fix_css
745752 instructions += 'injectCSS("%s");' % sh_theme_default_css
746753 instructions += 'injectCSS("%s");' % sh_theme_dark_css
747754 instructions += 'injectCSS("%s");' % sh_theme_sq_css
748755 instructions += 'injectCSS("%s");\n ' % sh_theme_sq_dark_css
749756 instructions += 'injectStyle("%s");\n ' % backdrop_style
750- instructions += 'injectJS("%s");' % shepherd_js
757+ instructions += 'injectJS("%s");\n ' % shepherd_js
758+ instructions += '} else { window.setTimeout("loadResources();",100); '
759+ instructions += '} }\n '
760+ instructions += 'loadResources()'
751761
752762 instructions += '\n \n //////// Tour Code ////////\n \n '
763+ if tour_type == "bootstrap" :
764+ instructions += 'function loadTour() { '
765+ instructions += 'if ( typeof Tour !== "undefined" ) {\n '
766+ elif tour_type == "hopscotch" :
767+ instructions += 'function loadTour() { '
768+ instructions += 'if ( typeof hopscotch !== "undefined" ) {\n '
769+ elif tour_type == "introjs" :
770+ instructions += 'function loadTour() { '
771+ instructions += 'if ( typeof introJs !== "undefined" ) {\n '
772+ elif tour_type == "shepherd" :
773+ instructions += 'function loadTour() { '
774+ instructions += 'if ( typeof Shepherd !== "undefined" ) {\n '
775+
753776 for tour_step in tour_steps [name ]:
754777 instructions += tour_step
755778
@@ -792,6 +815,9 @@ def export_tour(tour_steps, name=None, filename="my_tour.js", url=None):
792815 $tour = tour;\n """ )
793816 else :
794817 pass
818+ instructions += '\n } else { window.setTimeout("loadTour();",100); } '
819+ instructions += '}\n '
820+ instructions += 'loadTour()\n '
795821
796822 exported_tours_folder = EXPORTED_TOURS_FOLDER
797823 if exported_tours_folder .endswith ("/" ):
0 commit comments