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
This commit is contained in:
Kumataro 2024-10-22 17:57:14 +09:00 committed by GitHub
parent 94d5ad09ff
commit 4398e0b62b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -72,12 +72,23 @@ function buttonsToAdd($elements, $heading, $type) {
} }
function addTutorialsButtons() { function addTutorialsButtons() {
$("h1").each(function() { // See https://github.com/opencv/opencv/issues/26339
var $elements = $(this).nextUntil("h1") $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") var $lower = $elements.find("div.newInnerHTML")
$elements = $elements.add($lower) $elements = $elements.add($lower)
$elements = $elements.filter("div.newInnerHTML") $elements = $elements.filter("div.newInnerHTML")
buttonsToAdd($elements, $(this), "h1") buttonsToAdd($elements, $lastHeader, $toggleHeader)
$lastHeader = undefined
}); });
$(".toggleable_button").first().click(); $(".toggleable_button").first().click();
var $clickDefault = $('.toggleable_button.label_python').first(); var $clickDefault = $('.toggleable_button.label_python').first();