Skip to:
Content

BuddyPress.org

Changeset 6850


Ignore:
Timestamp:
03/22/2013 06:30:18 PM (12 years ago)
Author:
djpaul
Message:

Add no-js body class when in theme compat. Fixes #4890, props imath

The absence of this class is used by the JS and CSS to style UI elements appropriately if the user has chosen to disable JavaScript.
This change resolves a regression from the behaviour in BP-Default.

Location:
trunk/bp-templates/bp-legacy
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-templates/bp-legacy/buddypress-functions.php

    r6829 r6850  
    103103        add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization
    104104        add_action( 'bp_head',            array( $this, 'head_scripts'     ) ); // Output some extra JS in the <head>
     105       
     106        /** Body no-js Class ********************************************************/
     107        add_filter( 'body_class', array( $this, 'add_nojs_body_class' ), 20, 1 );
    105108
    106109        /** Buttons ***********************************************************/
     
    296299
    297300    <?php
     301    }
     302   
     303    /**
     304     * Adds the no-js class to the body tag.
     305     *
     306     * This function ensures that the <body> element will have the 'no-js' class by default. If you're
     307     * using JavaScript for some visual functionality in your theme, and you want to provide noscript
     308     * support, apply those styles to body.no-js.
     309     *
     310     * The no-js class is removed by the JavaScript created in buddypress.js.
     311     *
     312     * @since BuddyPress (1.7)
     313     */
     314    public function add_nojs_body_class( $classes ) {
     315        if ( ! in_array( 'no-js', $classes ) )
     316            $classes[] = 'no-js';
     317           
     318        return array_unique( $classes );
    298319    }
    299320
  • trunk/bp-templates/bp-legacy/js/buddypress.js

    r6838 r6850  
    12281228        });
    12291229    });
     1230   
     1231    /* if js is enabled then replace the no-js class by a js one */
     1232    if( jq('body').hasClass('no-js') )
     1233        jq('body').attr('class', jq('body').attr('class').replace( /no-js/,'js' ) );
     1234       
    12301235});
    12311236
Note: See TracChangeset for help on using the changeset viewer.