@@ -631,7 +631,7 @@ def play_introjs_tour(
631
631
time .sleep (0.1 )
632
632
633
633
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 ):
635
635
""" Exports a tour as a JS file.
636
636
It will include necessary resources as well, such as jQuery.
637
637
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"):
642
642
raise Exception ("Tour {%s} does not exist!" % name )
643
643
if not filename .endswith ('.js' ):
644
644
raise Exception ('Tour file must end in ".js"!' )
645
+ if not url :
646
+ url = "data:,"
645
647
646
648
tour_type = None
647
649
if "Bootstrap" in tour_steps [name ][0 ]:
@@ -656,6 +658,10 @@ def export_tour(tour_steps, name=None, filename="my_tour.js"):
656
658
raise Exception ('Unknown tour type!' )
657
659
658
660
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 '''
659
665
'''//////// Resources ////////\n \n '''
660
666
'''function injectCSS(css_link) {'''
661
667
'''var head = document.getElementsByTagName("head")[0];'''
@@ -682,7 +688,7 @@ def export_tour(tour_steps, name=None, filename="my_tour.js"):
682
688
'''style.type = "text/css";'''
683
689
'''style.appendChild(document.createTextNode(css));'''
684
690
'''head.appendChild(style);'''
685
- '''};\n ''' )
691
+ '''};\n ''' % ( url , url ) )
686
692
687
693
if tour_type == "bootstrap" :
688
694
jquery_js = constants .JQuery .MIN_JS
@@ -752,16 +758,14 @@ def export_tour(tour_steps, name=None, filename="my_tour.js"):
752
758
// Start the tour
753
759
tour.start();
754
760
$tour = tour;
755
- $tour.restart();\n
756
- """ )
761
+ $tour.restart();\n """ )
757
762
elif tour_type == "hopscotch" :
758
763
instructions += (
759
764
"""]
760
765
};
761
766
// Start the tour!
762
767
hopscotch.startTour(tour);
763
- $tour = hopscotch;\n
764
- """ )
768
+ $tour = hopscotch;\n """ )
765
769
elif tour_type == "introjs" :
766
770
instructions += (
767
771
"""]
@@ -777,14 +781,12 @@ def export_tour(tour_steps, name=None, filename="my_tour.js"):
777
781
intro.start();
778
782
$tour = intro;
779
783
};
780
- startIntro();\n
781
- """ )
784
+ startIntro();\n """ )
782
785
elif tour_type == "shepherd" :
783
786
instructions += (
784
787
"""
785
788
tour.start();
786
- $tour = tour;\n
787
- """ )
789
+ $tour = tour;\n """ )
788
790
else :
789
791
pass
790
792
0 commit comments