Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/07/2011 04:08:23 PM (12 years ago)
Author:
boonebgorges
Message:

Fixes activity update UI for noscript. Enables no-js body tag for noscript CSS support. Fixes #3611. Props r-a-y for tweaks.

File:
1 edited

Legend:

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

    r5170 r5219  
    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.