From 4398e0b62b74ce514aef57fefa24d9eac98e1fa0 Mon Sep 17 00:00:00 2001 From: Kumataro Date: Tue, 22 Oct 2024 17:57:14 +0900 Subject: [PATCH] Merge pull request #26340 from Kumataro:wa26339 doc: fix the position of toggle button #26340 Close #26339 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- doc/tutorial-utils.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/tutorial-utils.js b/doc/tutorial-utils.js index 3f08f1d2c1..9703e22779 100644 --- a/doc/tutorial-utils.js +++ b/doc/tutorial-utils.js @@ -72,12 +72,23 @@ function buttonsToAdd($elements, $heading, $type) { } function addTutorialsButtons() { - $("h1").each(function() { - var $elements = $(this).nextUntil("h1") + // See https://github.com/opencv/opencv/issues/26339 + $lastHeader = undefined + $("h1,h2,h3,div.newInnerHTML").each(function() { + if( this.tagName.startsWith("H") ) { + $lastHeader = $(this) + return true // loop-continue + } + if( $lastHeader === undefined ) { + return true // loop-continue + } + var $toggleHeader = $lastHeader.tagName + var $elements = $lastHeader.nextUntil($toggleHeader) var $lower = $elements.find("div.newInnerHTML") $elements = $elements.add($lower) $elements = $elements.filter("div.newInnerHTML") - buttonsToAdd($elements, $(this), "h1") + buttonsToAdd($elements, $lastHeader, $toggleHeader) + $lastHeader = undefined }); $(".toggleable_button").first().click(); var $clickDefault = $('.toggleable_button.label_python').first();