Jump to content

MediaWiki talk:Gadget-NavFrame.js

Add topic
From mediawiki.org
Latest comment: 9 years ago by P1h3r1e3d13 in topic remove hasClass function

remove hasClass function

[edit]

and hasClass( navChild, 'NavPic' ) ) => $( navChild ).hasClass( ' NavPic' )


yeah I fall to this mess, should be...

for ( navChild = navFrame.firstChild; navChild != null; navChild = navChild.nextSibling ) {
			if ( $( navChild ).hasClass( 'NavPic' ) ) {
				navChild.style.display = 'none';
			}
			if ( $( navChild ).hasClass( 'NavContent' ) ) {
				navChild.style.display = 'none';
			}
		}
WP's actual JS has that idea, but in a single if:
/* if shown now */
    if ( NavToggle.firstChild.data === NavigationBarHide ) {
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;

    /* if hidden now */
    } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
                NavChild.style.display = 'block';
            }
        }
        NavToggle.firstChild.data = NavigationBarHide;
    }
Sorry, don't know how to indent that properly. I suggest we copy that here. I just followed the instructions on this page, then spent a couple hours troubleshooting the broken code. –P1h3r1e3d13 (talk) 00:48, 4 September 2015 (UTC)Reply