Skip to:
Content

BuddyPress.org


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.5/bp-themes/bp-default/functions.php

    r5170 r5241  
    140140function bp_dtheme_enqueue_scripts() {
    141141    // Bump this when changes are made to bust cache
    142     $version = '20110921';
     142    $version = '20111013';
    143143
    144144    // Enqueue the global JS - Ajax will not work without it
     
    180180function bp_dtheme_enqueue_styles() {
    181181    // Bump this when changes are made to bust cache
    182     $version = '20110921';
     182    $version = '20111013';
    183183
    184184    // Register our main stylesheet
     
    732732}
    733733endif;
     734
     735/**
     736 * Adds the no-js class to the body tag.
     737 *
     738 * This function ensures that the <body> element will have the 'no-js' class by default. If you're
     739 * using JavaScript for some visual functionality in your theme, and you want to provide noscript
     740 * support, apply those styles to body.no-js.
     741 *
     742 * The no-js class is removed by the JavaScript created in bp_dtheme_remove_nojs_body_class().
     743 *
     744 * @package BuddyPress
     745 * @since 1.5.1
     746 * @see bp_dtheme_remove_nojs_body_class()
     747 */
     748function bp_dtheme_add_nojs_body_class( $classes ) {
     749    $classes[] = 'no-js';
     750    return array_unique( $classes );
     751}
     752add_filter( 'bp_get_the_body_class', 'bp_dtheme_add_nojs_body_class' );
     753
     754/**
     755 * Dynamically removes the no-js class from the <body> element.
     756 *
     757 * By default, the no-js class is added to the body (see bp_dtheme_add_no_js_body_class()). The
     758 * JavaScript in this function is loaded into the <body> element immediately after the <body> tag
     759 * (note that it's hooked to bp_before_header), and uses JavaScript to switch the 'no-js' body class
     760 * to 'js'. If your theme has styles that should only apply for JavaScript-enabled users, apply them
     761 * to body.js.
     762 *
     763 * This technique is borrowed from WordPress, wp-admin/admin-header.php.
     764 *
     765 * @package BuddyPress
     766 * @since 1.5.1
     767 * @see bp_dtheme_add_nojs_body_class()
     768 */
     769function bp_dtheme_remove_nojs_body_class() {
     770?><script type="text/javascript">//<![CDATA[
     771(function(){var c=document.body.className;c=c.replace(/no-js/,'js');document.body.className=c;})();
     772//]]></script>
     773<?php
     774}
     775add_action( 'bp_before_header', 'bp_dtheme_remove_nojs_body_class' );
     776
    734777?>
Note: See TracChangeset for help on using the changeset viewer.