Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conversion of epub2/ncx TOCs to <ol> form #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chine
Copy link
Contributor

@chine chine commented Apr 14, 2015

Re: Issue 97

@rkwright
Copy link
Contributor

Defer for now. It targets master and we need a reproducible case.

@rkwright rkwright removed bug labels May 13, 2016
@danielweck
Copy link
Member

This PR indeed targets the master branch instead of develop. Furthermore, the file epub-modules/epub/src/models/package_document.js now resides at js/epub-model/package_document.js (since a significant refactoring).
However, the fix itself is obviously still valid, and should be reviewed appropriately.
Here is a direct link to the new code location:
https://github.com/readium/readium-js/blob/master/js/epub-model/package_document.js#L178

        // Description: Constructs an html representation of NCX navPoints, based on an object of navPoint information
        // Rationale: This is a recursive method, as NCX navPoint elements can nest 0 or more of themselves as children
        function addNavPointElements($navPointDOM, $ol) {

            // Add the current navPoint element to the TOC html
            var navText = $navPointDOM.children("navLabel").text().trim();
            var navHref = $navPointDOM.children("content").attr("src");
            var $navPointLi = $('<li class="nav-elem"></li>').append(
                $('<a></a>', { href: navHref, text: navText })
            );

            // Append nav point info
            $ol.append($navPointLi);

            // Append ordered list of nav points
            if ($navPointDOM.children("navPoint").length > 0 ) {

                var $newLi = $("<li></li>");
                var $newOl = $("<ol></ol>");
                $.each($navPointDOM.children("navPoint"), function (navIndex, navPoint) {
                    $newOl.append(addNavPointElements($(navPoint), $newOl));
                });

                $newLi.append($newOl);
                $ol.append($newLi);
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants