Commit b5343578 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

debug next/previous button

parent 3bdb9b83
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -122,13 +122,21 @@ class MaxTEI extends AbstractMax {
    bindNavigationTool() {
        //local function : find next or previous nav link
        let nextOrPrevious = function (step) {
            let current = $("#navigation-tool").find('button').attr("data-target").replace("selected-", "");//remove 'selected' prefix
            //let current = $("#navigation-tool").find('button').attr("data-target").replace("selected-", "");//remove 'selected' prefix
            let current = document.getElementById("navigation-tool").querySelector('button').getAttribute("data-target").replace("selected-", "");//remove 'selected' prefix
            let newCurrent = current.replaceAll(".", "\\.")
            let links = $('#dropdown-navigation').find('li');
            let position = links.index(document.querySelector('li[data-target='+newCurrent+']'));
            console.log(position);
            let nextOrPrevious = links.get(position + step);
            window.location.href = $(nextOrPrevious).find('a').attr("href");
            let links = document.getElementById('dropdown-navigation').querySelectorAll('li');
            console.log(links);
            let position = -1;
            links.forEach((link, index) => {
                if(link.dataset.target === newCurrent){
                    position = index;
                }
            })
            //links.indexOf(document.querySelector('li[data-target='+newCurrent+']'));
            //console.log(position);
            let nextOrPrevious = links[position + step];
            window.location.href = nextOrPrevious.querySelector('a').getAttribute("href");
        };

        let navPrev = document.getElementById('nav_previous');