@@ -631,7 +631,7 @@ def play_introjs_tour(
631631 time .sleep (0.1 )
632632
633633
634- def export_tour (tour_steps , name = None , filename = "my_tour.js" ):
634+ def export_tour (tour_steps , name = None , filename = "my_tour.js" , url = None ):
635635 """ Exports a tour as a JS file.
636636 It will include necessary resources as well, such as jQuery.
637637 You'll be able to copy the tour directly into the Console of
@@ -642,6 +642,8 @@ def export_tour(tour_steps, name=None, filename="my_tour.js"):
642642 raise Exception ("Tour {%s} does not exist!" % name )
643643 if not filename .endswith ('.js' ):
644644 raise Exception ('Tour file must end in ".js"!' )
645+ if not url :
646+ url = "data:,"
645647
646648 tour_type = None
647649 if "Bootstrap" in tour_steps [name ][0 ]:
@@ -656,6 +658,10 @@ def export_tour(tour_steps, name=None, filename="my_tour.js"):
656658 raise Exception ('Unknown tour type!' )
657659
658660 instructions = (
661+ '''//////// Load Tour Start Page (if not there now) ////////\n \n '''
662+ '''if (window.location.href != "%s") {\n '''
663+ ''' window.location.href="%s";\n '''
664+ '''}\n \n '''
659665 '''//////// Resources ////////\n \n '''
660666 '''function injectCSS(css_link) {'''
661667 '''var head = document.getElementsByTagName("head")[0];'''
@@ -682,7 +688,7 @@ def export_tour(tour_steps, name=None, filename="my_tour.js"):
682688 '''style.type = "text/css";'''
683689 '''style.appendChild(document.createTextNode(css));'''
684690 '''head.appendChild(style);'''
685- '''};\n ''' )
691+ '''};\n ''' % ( url , url ) )
686692
687693 if tour_type == "bootstrap" :
688694 jquery_js = constants .JQuery .MIN_JS
@@ -752,16 +758,14 @@ def export_tour(tour_steps, name=None, filename="my_tour.js"):
752758 // Start the tour
753759 tour.start();
754760 $tour = tour;
755- $tour.restart();\n
756- """ )
761+ $tour.restart();\n """ )
757762 elif tour_type == "hopscotch" :
758763 instructions += (
759764 """]
760765 };
761766 // Start the tour!
762767 hopscotch.startTour(tour);
763- $tour = hopscotch;\n
764- """ )
768+ $tour = hopscotch;\n """ )
765769 elif tour_type == "introjs" :
766770 instructions += (
767771 """]
@@ -777,14 +781,12 @@ def export_tour(tour_steps, name=None, filename="my_tour.js"):
777781 intro.start();
778782 $tour = intro;
779783 };
780- startIntro();\n
781- """ )
784+ startIntro();\n """ )
782785 elif tour_type == "shepherd" :
783786 instructions += (
784787 """
785788 tour.start();
786- $tour = tour;\n
787- """ )
789+ $tour = tour;\n """ )
788790 else :
789791 pass
790792
0 commit comments