Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/29/2015 10:42:56 PM (11 years ago)
Author:
imath
Message:

Introduce functions to register and enqueue the Cover Images Javascript and Css

  • Add the cover-image.js Javascript and register it inside Core Common Scripts
  • Make sure to enqueue Cover Images script only when needed ("change-cover-image" screens)
  • Create a new function to attach an the inline css specified inside the Cover Image feature settings
  • Create the inline css for BP Legacy.
  • Adjust our main css file (buddypress.css) and the companion stylesheets
  • Add the Cover Images Backbone template into bp-legacy/buddypress/assets/_attachments

Props r-a-y

See #6570

File:
1 edited

Legend:

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

    r10150 r10155  
    17181718        die();
    17191719}
     1720
     1721/**
     1722 * BP Legacy's callback for the cover image feature
     1723 *
     1724 * @since  2.4.0
     1725 *
     1726 * @param  array  $params the current component's feature parameters
     1727 * @return array          an array to inform about the css handle to attach the css rules to
     1728 */
     1729function bp_legacy_theme_cover_image( $params = array() ) {
     1730        if ( empty( $params ) ) {
     1731                return;
     1732        }
     1733
     1734        // avatar height - padding - 1/2 avatar height
     1735        $avatar_offset = $params['height'] - 5 - round( (int) bp_core_avatar_full_height() / 2 );
     1736
     1737        // header content offset + spacing
     1738        $top_offset  = bp_core_avatar_full_height() - 10;
     1739        $left_offset = bp_core_avatar_full_width() + 20;
     1740
     1741        $cover_image = isset( $params['cover_image'] ) ? 'background-image: url(' . $params['cover_image'] . ');' : '';
     1742
     1743        $hide_avatar_style = '';
     1744
     1745        // Adjust the cover image header, in case avatars are completely disabled
     1746        if ( ! buddypress()->avatar->show_avatars ) {
     1747                $hide_avatar_style = '
     1748                        #buddypress #item-header-cover-image #item-header-avatar {
     1749                                display:  none;
     1750                        }
     1751                ';
     1752
     1753                if ( bp_is_user() ) {
     1754                        $hide_avatar_style = '
     1755                                #buddypress #item-header-cover-image #item-header-avatar a {
     1756                                        display: block;
     1757                                        height: ' . $top_offset . 'px;
     1758                                        margin: 0 15px 19px 0;
     1759                                }
     1760
     1761                                #buddypress div#item-header #item-header-cover-image #item-header-content {
     1762                                        margin-left:auto;
     1763                                }
     1764                        ';
     1765                }
     1766        }
     1767
     1768        return '
     1769                /* Cover image */
     1770                #buddypress #header-cover-image {
     1771                        height: ' . $params["height"] . 'px;
     1772                        ' . $cover_image . '
     1773                }
     1774
     1775                #buddypress #create-group-form #header-cover-image {
     1776                        position: relative;
     1777                        margin: 1em 0;
     1778                }
     1779
     1780                .bp-user #buddypress #item-header {
     1781                        padding-top: 0;
     1782                }
     1783
     1784                #buddypress #item-header-cover-image #item-header-avatar {
     1785                        margin-top: '. $avatar_offset .'px;
     1786                        float: left;
     1787                        overflow: visible;
     1788                        width:auto;
     1789                }
     1790
     1791                #buddypress div#item-header #item-header-cover-image #item-header-content {
     1792                        clear: both;
     1793                        float: left;
     1794                        margin-left: ' . $left_offset . 'px;
     1795                        margin-top: -' . $top_offset . 'px;
     1796                        width:auto;
     1797                }
     1798
     1799                body.single-item.groups #buddypress div#item-header #item-header-cover-image #item-header-content,
     1800                body.single-item.groups #buddypress div#item-header #item-header-cover-image #item-actions {
     1801                        margin-top: ' . $params["height"] . 'px;
     1802                        margin-left: 0;
     1803                        clear: none;
     1804                        max-width: 50%;
     1805                }
     1806
     1807                body.single-item.groups #buddypress div#item-header #item-header-cover-image #item-actions {
     1808                        padding-top: 20px;
     1809                        max-width: 20%;
     1810                }
     1811
     1812                ' . $hide_avatar_style . '
     1813
     1814                #buddypress div#item-header-cover-image h2 a,
     1815                #buddypress div#item-header-cover-image h2 {
     1816                        color: #FFF;
     1817                        text-rendering: optimizelegibility;
     1818                        text-shadow: 0px 0px 3px rgba( 0, 0, 0, 0.8 );
     1819                        margin: 0;
     1820                        font-size:200%;
     1821                }
     1822
     1823                #buddypress #item-header-cover-image #item-header-avatar img.avatar {
     1824                        border: solid 2px #FFF;
     1825                        background: rgba( 255, 255, 255, 0.8 );
     1826                }
     1827
     1828                #buddypress #item-header-cover-image #item-header-avatar a {
     1829                        border: none;
     1830                        text-decoration: none;
     1831                }
     1832
     1833                #buddypress #item-header-cover-image #item-buttons {
     1834                        overflow:hidden;
     1835                        margin: 20px 0 10px;
     1836                        padding: 0 0 5px;
     1837                }
     1838
     1839                #buddypress #item-header-cover-image #item-buttons:before {
     1840                        content:"\00a0";
     1841                }
     1842
     1843                @media screen and (max-width: 782px) {
     1844                        #buddypress #item-header-cover-image #item-header-avatar,
     1845                        .bp-user #buddypress #item-header #item-header-cover-image #item-header-avatar,
     1846                        #buddypress div#item-header #item-header-cover-image #item-header-content {
     1847                                width:100%;
     1848                                text-align:center;
     1849                        }
     1850
     1851                        #buddypress #item-header-cover-image #item-header-avatar a {
     1852                                display:inline-block;
     1853                        }
     1854
     1855                        #buddypress #item-header-cover-image #item-header-avatar img {
     1856                                margin:0;
     1857                        }
     1858
     1859                        #buddypress div#item-header #item-header-cover-image #item-header-content,
     1860                        body.single-item.groups #buddypress div#item-header #item-header-cover-image #item-header-content,
     1861                        body.single-item.groups #buddypress div#item-header #item-header-cover-image #item-actions {
     1862                                margin:0;
     1863                        }
     1864
     1865                        body.single-item.groups #buddypress div#item-header #item-header-cover-image #item-header-content,
     1866                        body.single-item.groups #buddypress div#item-header #item-header-cover-image #item-actions {
     1867                                max-width: 100%;
     1868                        }
     1869
     1870                        #buddypress div#item-header-cover-image h2 a,
     1871                        #buddypress div#item-header-cover-image h2 {
     1872                                color: inherit;
     1873                                text-shadow: none;
     1874                                margin:25px 0 0;
     1875                                font-size:200%;
     1876                        }
     1877
     1878                        #buddypress #item-header-cover-image #item-buttons div {
     1879                                float:none;
     1880                                display:inline-block;
     1881                        }
     1882
     1883                        #buddypress #item-header-cover-image #item-buttons:before {
     1884                                content:"";
     1885                        }
     1886
     1887                        #buddypress #item-header-cover-image #item-buttons {
     1888                                margin: 5px 0;
     1889                        }
     1890                }
     1891        ';
     1892}
Note: See TracChangeset for help on using the changeset viewer.