mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-15 03:43:55 +00:00
Made DOM navigation in CategoryTree.js resilient to text nodes injected by tidy et.al.
This commit is contained in:
parent
0fda41e704
commit
8a665bde57
|
@ -9,8 +9,18 @@
|
|||
* @licence GNU General Public Licence 2.0 or later
|
||||
*/
|
||||
|
||||
function categoryTreeNextDiv(e) {
|
||||
n= e.nextSibling;
|
||||
while ( n && ( n.nodeType != 1 || n.nodeName != 'DIV') ) {
|
||||
//alert('nodeType: ' + n.nodeType + '; nodeName: ' + n.nodeName);
|
||||
n= n.nextSibling;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
function categoryTreeExpandNode(cat, mode, lnk) {
|
||||
var div= lnk.parentNode.parentNode.nextSibling;
|
||||
var div= categoryTreeNextDiv( lnk.parentNode.parentNode );
|
||||
|
||||
div.style.display= 'block';
|
||||
lnk.innerHTML= '–';
|
||||
|
@ -23,7 +33,7 @@
|
|||
}
|
||||
|
||||
function categoryTreeCollapseNode(cat, mode, lnk) {
|
||||
var div= lnk.parentNode.parentNode.nextSibling;
|
||||
var div= categoryTreeNextDiv( lnk.parentNode.parentNode );
|
||||
|
||||
div.style.display= 'none';
|
||||
lnk.innerHTML= '+';
|
||||
|
|
|
@ -234,9 +234,9 @@ function efCategoryTreeRenderNode( &$title, $mode = CT_MODE_CATEGORIES, $childre
|
|||
|
||||
$s = '';
|
||||
|
||||
#NOTE: things in CategoryTree.js rely on the exact order of tags and absense of text nodes!
|
||||
# Specifically, to get from the a tag in the bullet to the CategoryTreeChildren div,
|
||||
# the following is used: div= lnk.parentNode.parentNode.nextSibling
|
||||
#NOTE: things in CategoryTree.js rely on the exact order of tags!
|
||||
# Specifically, the CategoryTreeChildren div must be the first
|
||||
# sibling with nodeName = DIV of the grandparent of the expland link.
|
||||
|
||||
$s .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeSection' ) );
|
||||
$s .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeItem' ) );
|
||||
|
@ -248,7 +248,7 @@ function efCategoryTreeRenderNode( &$title, $mode = CT_MODE_CATEGORIES, $childre
|
|||
|
||||
$s .= wfOpenElement( 'a', array( 'class' => $labelClass, 'href' => $wikiLink ) ) . $label . wfCloseElement( 'a' );
|
||||
$s .= wfCloseElement( 'div' );
|
||||
|
||||
$s .= "\n\t\t";
|
||||
$s .= wfOpenElement( 'div', array( 'class' => 'CategoryTreeChildren', 'style' => $children ? "display:block" : "display:none" ) );
|
||||
if ( $children ) $s .= efCategoryTreeRenderChildren( $title, $mode );
|
||||
$s .= wfCloseElement( 'div' );
|
||||
|
|
Loading…
Reference in a new issue