@@ -536,45 +536,40 @@ const Plugin = () => {
536
536
var h = parseInt ( item . getAttribute ( 'data-slide-h' ) ) ;
537
537
var v = parseInt ( item . getAttribute ( 'data-slide-v' ) ) ;
538
538
var theme = item . getAttribute ( 'data-theme' ) ;
539
+ var highlightTheme = item . getAttribute ( 'data-highlight-theme' ) ;
539
540
var transition = item . getAttribute ( 'data-transition' ) ;
541
+
540
542
if ( ! isNaN ( h ) && ! isNaN ( v ) ) {
541
543
deck . slide ( h , v ) ;
542
- closeMenu ( ) ;
543
- } else if ( theme ) {
544
- // take note of the previous theme and remove it, then create a new stylesheet reference and insert it
545
- // this is required to force a load event so we can change the menu style to match the new style
546
- var stylesheet = select ( 'link#theme' ) ;
547
- var parent = stylesheet . parentElement ;
548
- var sibling = stylesheet . nextElementSibling ;
549
- stylesheet . remove ( ) ;
550
-
551
- var newStylesheet = stylesheet . cloneNode ( ) ;
552
- newStylesheet . setAttribute ( 'href' , theme ) ;
553
- newStylesheet . onload = function ( ) {
554
- matchRevealStyle ( ) ;
555
- } ;
556
- parent . insertBefore ( newStylesheet , sibling ) ;
544
+ }
545
+
546
+ if ( theme ) {
547
+ changeStylesheet ( 'theme' , theme ) ;
548
+ }
549
+
550
+ if ( highlightTheme ) {
551
+ changeStylesheet ( 'highlight-theme' , highlightTheme ) ;
552
+ }
557
553
558
- closeMenu ( ) ;
559
- } else if ( transition ) {
554
+ if ( transition ) {
560
555
deck . configure ( { transition : transition } ) ;
561
- closeMenu ( ) ;
562
- } else {
563
- var link = select ( 'a' , item ) ;
564
- if ( link ) {
565
- if (
566
- force ||
567
- ! options . sticky ||
568
- ( options . autoOpen && link . href . startsWith ( '#' ) ) ||
569
- link . href . startsWith (
570
- window . location . origin + window . location . pathname + '#'
571
- )
572
- ) {
573
- link . click ( ) ;
574
- }
556
+ }
557
+
558
+ var link = select ( 'a' , item ) ;
559
+ if ( link ) {
560
+ if (
561
+ force ||
562
+ ! options . sticky ||
563
+ ( options . autoOpen && link . href . startsWith ( '#' ) ) ||
564
+ link . href . startsWith (
565
+ window . location . origin + window . location . pathname + '#'
566
+ )
567
+ ) {
568
+ link . click ( ) ;
575
569
}
576
- closeMenu ( ) ;
577
570
}
571
+
572
+ closeMenu ( ) ;
578
573
}
579
574
580
575
function clicked ( event ) {
@@ -950,15 +945,17 @@ const Plugin = () => {
950
945
var menu = create ( 'ul' , { class : 'slide-menu-items' } ) ;
951
946
panel . appendChild ( menu ) ;
952
947
options . themes . forEach ( function ( t , i ) {
953
- var item = create (
954
- 'li' ,
955
- {
956
- class : 'slide-menu-item' ,
957
- 'data-theme' : t . theme ,
958
- 'data-item' : '' + ( i + 1 )
959
- } ,
960
- t . name
961
- ) ;
948
+ var attrs = {
949
+ class : 'slide-menu-item' ,
950
+ 'data-item' : '' + ( i + 1 )
951
+ } ;
952
+ if ( t . theme ) {
953
+ attrs [ 'data-theme' ] = t . theme ;
954
+ }
955
+ if ( t . highlightTheme ) {
956
+ attrs [ 'data-highlight-theme' ] = t . highlightTheme ;
957
+ }
958
+ var item = create ( 'li' , attrs , t . name ) ;
962
959
menu . appendChild ( item ) ;
963
960
item . onclick = clicked ;
964
961
} ) ;
@@ -1136,6 +1133,22 @@ const Plugin = () => {
1136
1133
return el ;
1137
1134
}
1138
1135
1136
+ function changeStylesheet ( id , href ) {
1137
+ // take note of the previous theme and remove it, then create a new stylesheet reference and insert it
1138
+ // this is required to force a load event so we can change the menu style to match the new style
1139
+ var stylesheet = select ( 'link#' + id ) ;
1140
+ var parent = stylesheet . parentElement ;
1141
+ var sibling = stylesheet . nextElementSibling ;
1142
+ stylesheet . remove ( ) ;
1143
+
1144
+ var newStylesheet = stylesheet . cloneNode ( ) ;
1145
+ newStylesheet . setAttribute ( 'href' , href ) ;
1146
+ newStylesheet . onload = function ( ) {
1147
+ matchRevealStyle ( ) ;
1148
+ } ;
1149
+ parent . insertBefore ( newStylesheet , sibling ) ;
1150
+ }
1151
+
1139
1152
// modified from math plugin
1140
1153
function loadResource ( url , type , callback ) {
1141
1154
var head = document . querySelector ( 'head' ) ;
0 commit comments