Skip to:
Content

BuddyPress.org

Ticket #7731: 7731.04.patch

File 7731.04.patch, 14.0 KB (added by imath, 8 years ago)
  • src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php

    diff --git src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php
    index 5e877b442..6695e4d6e 100644
     
    122122<script type="text/html" id="tmpl-bp-messages-thread">
    123123        <div class="thread-cb">
    124124                <input class="message-check" type="checkbox" name="message_ids[]" id="bp-message-thread-{{data.id}}" value="{{data.id}}">
    125                 <label for="bp-message-thread-{{data.id}}" class="bp-screen-reader-text"><?php esc_html_e( 'Select this message', 'buddypress' ); ?></label>
    126         </div>
    127         <div class="thread-from">
    128                 <a class="user-link" href="{{data.sender_link}}">
    129                         <img class="avatar" src="{{data.sender_avatar}}" alt="" />
    130                         <span class="user-name">{{data.sender_name}}</span>
    131                 </a>
     125                <label for="bp-message-thread-{{data.id}}" class="bp-screen-reader-text"><?php esc_html_e( 'Select message:', 'buddypress' ); ?> {{data.subject}}</label>
    132126        </div>
     127
     128        <# if ( ! data.recipientsCount ) { #>
     129                <div class="thread-from">
     130                        <a class="user-link" href="{{data.sender_link}}">
     131                                <img class="avatar" src="{{data.sender_avatar}}" alt="" />
     132                                <span class="bp-screen-reader-text"><?php esc_html_e( 'From:', 'buddypress' ); ?></span>
     133                                <span class="user-name">{{data.sender_name}}</span>
     134                        </a>
     135                </div>
     136        <# } else {
     137                var recipient = _.first( data.recipients );
     138                #>
     139                <div class="thread-to">
     140                        <a class="user-link" href="{{recipient.user_link}}">
     141                                <img class="avatar" src="{{recipient.avatar}}" alt="" />
     142                                <span class="bp-screen-reader-text"><?php esc_html_e( 'To:', 'buddypress' ); ?></span>
     143                                <span class="user-name">{{recipient.user_name}}</span>
     144                        </a>
     145
     146                        <# if ( data.toOthers ) { #>
     147                                <span class="num-recipients">{{data.toOthers}}</span>
     148                        <# } #>
     149                </div>
     150        <# } #>
     151
    133152        <div class="thread-content" data-thread-id="{{data.id}}">
    134153                <div class="thread-subject">
    135154                        <span class="thread-count">({{data.count}})</span>
    136                         <span class="subject"><# print( data.subject ); #></span>
     155                        <a class="subject" href="#view/{{data.id}}">
     156                                {{data.subject}}
     157                                <span class="bp-screen-reader-text"><?php esc_html_e( 'Press Enter to view the full conversation.', 'buddypress' ); ?></span>
     158                        </a>
    137159                </div>
    138                 <p class="excerpt"><# print( data.excerpt ); #></p>
     160                <p class="excerpt">{{data.excerpt}}</p>
    139161        </div>
    140162        <div class="thread-date">
    141163                <time datetime="{{data.date.toISOString()}}">{{data.display_date}}</time>
  • src/bp-templates/bp-nouveau/css/buddypress-rtl.css

    diff --git src/bp-templates/bp-nouveau/css/buddypress-rtl.css src/bp-templates/bp-nouveau/css/buddypress-rtl.css
    index 74646f88a..668214e3c 100644
    body.register .buddypress-wrap .page ul { 
    29622962        flex: 1 2 5%;
    29632963}
    29642964
    2965 #message-threads li .thread-from {
     2965#message-threads li .thread-from,
     2966#message-threads li .thread-to {
    29662967        -webkit-flex: 1 2 20%;
    29672968        -moz-flex: 1 2 20%;
    29682969        -ms-flex: 1 2 20%;
    body.register .buddypress-wrap .page ul { 
    29702971        flex: 1 2 20%;
    29712972}
    29722973
    2973 #message-threads li .thread-from img.avatar {
     2974#message-threads li .thread-from img.avatar,
     2975#message-threads li .thread-to img.avatar {
    29742976        float: right;
    29752977        margin: 0 0 0 10px;
    29762978}
    29772979
    2978 #message-threads li .thread-from .user-name {
     2980#message-threads li .thread-from .user-name,
     2981#message-threads li .thread-to .user-name {
    29792982        display: inline-block;
    29802983        line-height: 1.1;
    29812984}
    29822985
     2986#message-threads li .thread-from .num-recipients,
     2987#message-threads li .thread-to .num-recipients {
     2988        color: #737373;
     2989        font-weight: 400;
     2990        font-size: 12px;
     2991        margin: 0;
     2992}
     2993
    29832994#message-threads li .thread-content {
    29842995        -webkit-flex: 1 2 60%;
    29852996        -moz-flex: 1 2 60%;
    body.register .buddypress-wrap .page ul { 
    30003011        background-color: #fafafa;
    30013012}
    30023013
     3014#message-threads li.unread {
     3015        font-weight: 700;
     3016}
     3017
    30033018#message-threads li.selected .thread-subject .subject {
    30043019        color: #5087e5;
    30053020}
    body.register .buddypress-wrap .page ul { 
    30153030}
    30163031
    30173032#message-threads li .thread-content .thread-from,
     3033#message-threads li .thread-content .thread-to,
    30183034#message-threads li .thread-content .thread-subject {
    30193035        font-size: 13px;
    30203036}
    30213037
    30223038@media screen and (min-width: 46.8em) {
    30233039        #message-threads li .thread-content .thread-from,
     3040        #message-threads li .thread-content .thread-to,
    30243041        #message-threads li .thread-content .thread-subject {
    30253042                font-size: 16px;
    30263043        }
  • src/bp-templates/bp-nouveau/css/buddypress.css

    diff --git src/bp-templates/bp-nouveau/css/buddypress.css src/bp-templates/bp-nouveau/css/buddypress.css
    index a98a5ad8c..857b29a00 100644
    body.register .buddypress-wrap .page ul { 
    29622962        flex: 1 2 5%;
    29632963}
    29642964
    2965 #message-threads li .thread-from {
     2965#message-threads li .thread-from,
     2966#message-threads li .thread-to {
    29662967        -webkit-flex: 1 2 20%;
    29672968        -moz-flex: 1 2 20%;
    29682969        -ms-flex: 1 2 20%;
    body.register .buddypress-wrap .page ul { 
    29702971        flex: 1 2 20%;
    29712972}
    29722973
    2973 #message-threads li .thread-from img.avatar {
     2974#message-threads li .thread-from img.avatar,
     2975#message-threads li .thread-to img.avatar {
    29742976        float: left;
    29752977        margin: 0 10px 0 0;
    29762978}
    29772979
    2978 #message-threads li .thread-from .user-name {
     2980#message-threads li .thread-from .user-name,
     2981#message-threads li .thread-to .user-name {
    29792982        display: inline-block;
    29802983        line-height: 1.1;
    29812984}
    29822985
     2986#message-threads li .thread-from .num-recipients,
     2987#message-threads li .thread-to .num-recipients {
     2988        color: #737373;
     2989        font-weight: 400;
     2990        font-size: 12px;
     2991        margin: 0;
     2992}
     2993
    29832994#message-threads li .thread-content {
    29842995        -webkit-flex: 1 2 60%;
    29852996        -moz-flex: 1 2 60%;
    body.register .buddypress-wrap .page ul { 
    30003011        background-color: #fafafa;
    30013012}
    30023013
     3014#message-threads li.unread {
     3015        font-weight: 700;
     3016}
     3017
    30033018#message-threads li.selected .thread-subject .subject {
    30043019        color: #5087e5;
    30053020}
    body.register .buddypress-wrap .page ul { 
    30083023        cursor: pointer;
    30093024}
    30103025
    3011 #message-threads li .thread-content .excerpt {
     3026#message-threads li .thread-content .excerpt,
     3027#message-threads li .thread-content .num-recipients {
    30123028        color: #737373;
    30133029        font-size: 12px;
    30143030        margin: 0;
    30153031}
    30163032
    30173033#message-threads li .thread-content .thread-from,
     3034#message-threads li .thread-content .thread-to,
    30183035#message-threads li .thread-content .thread-subject {
    30193036        font-size: 13px;
    30203037}
    30213038
    30223039@media screen and (min-width: 46.8em) {
    30233040        #message-threads li .thread-content .thread-from,
     3041        #message-threads li .thread-content .thread-to,
    30243042        #message-threads li .thread-content .thread-subject {
    30253043                font-size: 16px;
    30263044        }
  • src/bp-templates/bp-nouveau/includes/messages/functions.php

    diff --git src/bp-templates/bp-nouveau/includes/messages/functions.php src/bp-templates/bp-nouveau/includes/messages/functions.php
    index 5eebdc077..b7519e93e 100644
    function bp_nouveau_messages_localize_scripts( $params = array() ) { 
    9898                'nonces' => array(
    9999                        'send' => wp_create_nonce( 'messages_send_message' ),
    100100                ),
    101                 'loading' => __( 'Loading messages. Please wait.', 'buddypress' ),
     101                'loading'      => __( 'Loading messages. Please wait.', 'buddypress' ),
    102102                'bulk_actions' => bp_nouveau_messages_get_bulk_actions(),
     103                'howto'        => __( 'Click on the message title to preview it in the Active conversation box. Double click on the message title to open the full conversation.', 'buddypress' ),
     104                'howtoBulk'    => __( 'Use the select box to define your bulk action and click on the &#10003; button to apply.', 'buddypress' ),
     105                'toOthers'     => array(
     106                        'one'  => __( '(and 1 other)', 'buddypress' ),
     107                        'more' => __( '(and %d others)', 'buddypress' ),
     108                ),
    103109        );
    104110
    105111        // Star private messages.
  • src/bp-templates/bp-nouveau/js/buddypress-messages.js

    diff --git src/bp-templates/bp-nouveau/js/buddypress-messages.js src/bp-templates/bp-nouveau/js/buddypress-messages.js
    index 9ec7218ef..c4aadeabb 100644
    window.bp = window.bp || {}; 
    634634                tagName   : 'div',
    635635
    636636                events: {
    637                         'click .thread-content'       : 'changePreview',
    638                         'dblclick .thread-content'    : 'loadSingleView'
     637                        'click .thread-content'    : 'changePreview',
     638                        'dblclick .thread-content' : 'loadSingleView',
     639                        'focus .thread-item'       : 'focusIn',
     640                        'keydown .subject'         : 'keyDown'
    639641                },
    640642
    641643                initialize: function() {
    window.bp = window.bp || {}; 
    666668
    667669                threadsFetched: function() {
    668670                        bp.Nouveau.Messages.removeFeedback();
     671
     672                        // Inform the user about how to use the UI.
     673                        bp.Nouveau.Messages.displayFeedback( BP_Nouveau.messages.howto, 'info' );
    669674                },
    670675
    671676                threadsFetchError: function( collection, response ) {
    window.bp = window.bp || {}; 
    688693                        this.views.add( '#message-threads', new bp.Views.userThread( { model: thread } ) );
    689694                },
    690695
     696                getActiveThread: function() {
     697                        var activeThread = this.collection.findWhere( { active: true } );
     698
     699                        if ( ! activeThread.get( 'id' ) ) {
     700                                return false;
     701                        }
     702
     703                        return activeThread;
     704                },
     705
     706                setActiveThread: function( active ) {
     707                        if ( ! active ) {
     708                                return;
     709                        }
     710
     711                        _.each( this.collection.models, function( thread ) {
     712                                if ( thread.id === active ) {
     713                                        thread.set( 'active', true );
     714                                } else {
     715                                         thread.unset( 'active' );
     716                                }
     717                        }, this );
     718                },
     719
    691720                changePreview: function( event ) {
    692721                        var target = $( event.currentTarget );
    693722
    window.bp = window.bp || {}; 
    696725                        }
    697726
    698727                        event.preventDefault();
     728                        bp.Nouveau.Messages.removeFeedback();
    699729
    700730                        if ( target.parent( 'li' ).hasClass( 'selected' ) ) {
    701731                                return;
    702732                        }
    703733
    704                         var selected = target.data( 'thread-id' );
    705 
    706                         _.each( this.collection.models, function( thread ) {
    707                                 if ( thread.id === selected ) {
    708                                         thread.set( 'active', true );
    709                                 } else {
    710                                         thread.unset( 'active' );
    711                                 }
    712                         }, this );
     734                        this.setActiveThread( target.data( 'thread-id' ) );
    713735                },
    714736
    715737                loadSingleView: function( event ) {
    window.bp = window.bp || {}; 
    724746                        var id = target.data( 'thread-id' );
    725747
    726748                        bp.Nouveau.Messages.router.navigate( 'view/' + id, { trigger: true } );
     749                },
     750
     751                focusIn: function( event ) {
     752                        if ( ! $( event.currentTarget ).hasClass( 'thread-item' ) || $( event.currentTarget ).hasClass( 'selected' ) ) {
     753                                return;
     754                        }
     755
     756                        var threadId = $( event.currentTarget ).find( '.thread-content' ).first().data( 'thread-id' );
     757
     758                        if ( threadId ) {
     759                                bp.Nouveau.Messages.removeFeedback();
     760                                this.setActiveThread( threadId );
     761                        }
     762                },
     763
     764                keyDown: function( event ) {
     765                        if ( ! $( event.currentTarget ).closest( '.thread-item' ).hasClass( 'selected' ) ) {
     766                                return;
     767                        }
     768
     769                        // Catch enter and space events
     770                        if ( 'keydown' === event.type && 13 !== event.keyCode && 32 !== event.keyCode ) {
     771                                return;
     772                        }
     773
     774                        event.preventDefault();
     775
     776                        var thread = this.getActiveThread();
     777
     778                        if ( ! _.isNumber( thread.get( 'id' ) ) ) {
     779                                return;
     780                        }
     781
     782                        bp.Nouveau.Messages.router.navigate( 'view/' + thread.get( 'id' ), { trigger: true } );
    727783                }
    728784        } );
    729785
    window.bp = window.bp || {}; 
    732788                template  : bp.template( 'bp-messages-thread' ),
    733789                className : 'thread-item',
    734790
     791                attributes: {
     792                        'tabIndex': 0
     793                },
     794
    735795                events: {
    736796                        'click .message-check' : 'singleSelect'
    737797                },
    window.bp = window.bp || {}; 
    745805                                this.el.className += ' unread';
    746806                        }
    747807
     808                        if ( 'sentbox' === bp.Nouveau.Messages.box ) {
     809                                var recipientsCount = this.model.get( 'recipients' ).length, toOthers = '';
     810
     811                                if ( 2 === recipientsCount ) {
     812                                        toOthers = BP_Nouveau.messages.toOthers.one;
     813                                } else if ( 2 < recipientsCount ) {
     814                                        toOthers = BP_Nouveau.messages.toOthers.more.replace( '%d', Number( recipientsCount - 1 ) );
     815                                }
     816
     817                                this.model.set( {
     818                                        recipientsCount: recipientsCount,
     819                                        toOthers: toOthers
     820                                }, { silent: true } )
     821                        } else if ( this.model.get( 'recipientsCount' )  ) {
     822                                this.model.unset( 'recipientsCount', { silent: true } );
     823                        }
     824
    748825                        this.model.on( 'change:active', this.toggleClass, this );
    749826                        this.model.on( 'change:unread', this.updateReadState, this );
    750827                        this.model.on( 'change:checked', this.bulkSelect, this );
    window.bp = window.bp || {}; 
    789866
    790867                        if ( hasChecked ) {
    791868                                $( '#user-messages-bulk-actions' ).closest( '.bulk-actions-wrap' ).removeClass( 'bp-hide' );
     869
     870                                // Inform the user about how to use the bulk actions.
     871                                bp.Nouveau.Messages.displayFeedback( BP_Nouveau.messages.howtoBulk, 'info' );
    792872                        } else {
    793873                                $( '#user-messages-bulk-actions' ).closest( '.bulk-actions-wrap' ).addClass( 'bp-hide' );
     874
     875                                bp.Nouveau.Messages.removeFeedback();
    794876                        }
    795877                },
    796878
    window.bp = window.bp || {}; 
    9201002
    9211003                        if ( isChecked ) {
    9221004                                $( this.el ).find( '.bulk-actions-wrap' ).removeClass( 'bp-hide' ).addClass( 'bp-show' );
     1005
     1006                                // Inform the user about how to use the bulk actions.
     1007                                bp.Nouveau.Messages.displayFeedback( BP_Nouveau.messages.howtoBulk, 'info' );
    9231008                        } else {
    9241009                                $( this.el ).find( '.bulk-actions-wrap' ).addClass( 'bp-hide' );
     1010
     1011                                bp.Nouveau.Messages.removeFeedback();
    9251012                        }
    9261013
    9271014                        _.each( this.collection.models, function( model ) {
  • src/bp-templates/bp-nouveau/sass/_nouveau_messages.scss

    diff --git src/bp-templates/bp-nouveau/sass/_nouveau_messages.scss src/bp-templates/bp-nouveau/sass/_nouveau_messages.scss
    index a9a44a599..213f7ebea 100644
     
    9696                        @include box-item-size(1, 2, 5%);
    9797                }
    9898
    99                 .thread-from {
     99                .thread-from,
     100                .thread-to {
    100101
    101102                        @include box-item-size(1, 2, 20%);
    102103
     
    109110                                display: inline-block;
    110111                                line-height: 1.1;
    111112                        }
     113
     114                        .num-recipients {
     115                                color: $meta-text;
     116                                font-weight: 400;
     117                                @include font-size(12);
     118                                margin: 0;
     119                        }
    112120                }
    113121
    114122                .thread-content {
     
    133141                        }
    134142                }
    135143
     144                // the unread parent li
     145                &.unread {
     146                        font-weight: 700;
     147                }
     148
    136149                .thread-content {
    137150                        cursor: pointer;
    138151
     
    144157                        }
    145158
    146159                        .thread-from,
     160                        .thread-to,
    147161                        .thread-subject {
    148162
    149163                                @include responsive-font(16);