}
this.setInterface();
+ // Insert Chapters submenus
if (this.chaptersMenuHTML != '') {
$('#chapters').parent().append(this.chaptersMenuHTML);
}
+
+ // Remove unwanted links from chapters menu
+ // For any items that have a submenu, we want to remove the page link
+ // from the parent item to make it easier to open the submenu
+ $('#chapterList li a').each(function() { // Process all links in the chapters submenu
+ if ($(this).siblings('ul').length > 0) { // Check if any have a <ul> element beside them (indicates a submenu)
+ // MMenu requires non-link elements to be wrapped in a <span>
+ // so we need to first wrap the contents of the link in a span before removing the wrapping <a>
+ $(this).contents().wrap('<span></span>').parent().unwrap('a');
+ }
+ });
+
$('#menu').append('<div id="menuSearchResults" class="Panel"></div>');
$('#menu').append('<div id="menuSearchHints" class="Panel"></div>');
+
+ // If the chapters menu is not cascading, wrap submenu lists in <div>s so that MMenu will show them in the same panel
+ if (!this.fluidbook.datas.chaptersCascade) {
+
+ // Create a single panel around the chapters
+ $('#chapterList').wrap('<div id="chaptersPanel" class="Panel"></div>');
+
+ // Tell MMenu not to render any child lists as subpanels (ref: https://github.com/FrDH/jQuery.mmenu/issues/499#issuecomment-170649868)
+ $('#chaptersPanel ul').addClass('mm-nopanel');
+
+ $('#chapters').wrap('<a href="#chaptersPanel"></a>'); // Link to
+
+ //console.log($('#menuList').parent().html());
+ }
+
this.initMenu();
$(this.fluidbook).trigger('fluidbooknavready');
var currentLevel = 0,
loopIndex = 0,
- html = '<ul>';
+ html = '<ul id="chapterList">';
// Loop through all chapters and build new ULs based on level/depth
chapters.forEach(function(chapter) {
var page = (this.fluidbook.virtualToPhysical(chapter.page));
- html += '<li><a href="#/page/' + page + '">' + chapter.label + '</a>';
+ html += '<li><a href="#/page/' + page + '" class="level-' + chapter.level + '">' + chapter.label + '</a>';
});
html += '</li></ul>';