Skip to:
Content

BuddyPress.org

Ticket #4890: 4890-improved.diff

File 4890-improved.diff, 2.0 KB (added by imath, 12 years ago)
  • bp-templates/bp-legacy/buddypress-functions.php

     
    102102                add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts'  ) ); // Enqueue theme JS
    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 ***********************************************************/
    107110
     
    296299
    297300        <?php
    298301        }
     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 );
     319        }
    299320
    300321        /**
    301322         * Load localizations for topic script
  • bp-templates/bp-legacy/js/buddypress.js

     
    12271227                        } );
    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
    12321237/* Setup activity scope and filter based on the current cookie settings. */