Skip to:
Content

BuddyPress.org

Ticket #7794: 7794.messagesUI.feedback.patch

File 7794.messagesUI.feedback.patch, 7.9 KB (added by imath, 18 months 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 8fa9753e8..a5eade58f 100644
     
    1313<div class="bp-messages-feedback"></div>
    1414<div class="bp-messages-content"></div>
    1515
     16<script type="text/html" id="tmpl-bp-messages-feedback">
     17        <div class="bp-feedback {{data.type}}">
     18                <span class="bp-icon" aria-hidden="true"></span>
     19                <p>{{{data.message}}}</p>
     20        </div>
     21</script>
     22
    1623<script type="text/html" id="tmpl-bp-messages-form">
    1724        <?php bp_nouveau_messages_hook( 'before', 'compose_content' ); ?>
    1825
  • src/bp-templates/bp-nouveau/includes/messages/ajax.php

    diff --git src/bp-templates/bp-nouveau/includes/messages/ajax.php src/bp-templates/bp-nouveau/includes/messages/ajax.php
    index c66c40ba6..1151501ee 100644
    function bp_nouveau_ajax_messages_send_message() { 
    107107 */
    108108function bp_nouveau_ajax_messages_send_reply() {
    109109        $response = array(
    110                 'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'There was a problem sending your reply. Please try again.', 'buddypress' ) . '</p></div>',
     110                'feedback' => __( 'There was a problem sending your reply. Please try again.', 'buddypress' ),
    111111                'type'     => 'error',
    112112        );
    113113
    function bp_nouveau_ajax_messages_send_reply() { 
    186186
    187187        wp_send_json_success( array(
    188188                'messages' => array( $reply ),
    189                 'feedback' => '<div class="bp-feedback success"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Your reply was sent successfully', 'buddypress' ) . '</p></div>',
     189                'feedback' => __( 'Your reply was sent successfully', 'buddypress' ),
    190190                'type'     => 'success',
    191191        ) );
    192192}
    function bp_nouveau_ajax_get_user_message_threads() { 
    199199
    200200        if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'bp_nouveau_messages' ) ) {
    201201                wp_send_json_error( array(
    202                         'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Unauthorized request.', 'buddypress' ) . '</p></div>',
     202                        'feedback' => __( 'Unauthorized request.', 'buddypress' ),
    203203                        'type'     => 'error'
    204204                ) );
    205205        }
    function bp_nouveau_ajax_get_user_message_threads() { 
    214214        // Simulate the loop.
    215215        if ( ! bp_has_message_threads( bp_ajax_querystring( 'messages' ) ) ) {
    216216                wp_send_json_error( array(
    217                         'feedback' => '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Sorry, no messages were found.', 'buddypress' ) . '</p></div>',
     217                        'feedback' => __( 'Sorry, no messages were found.', 'buddypress' ),
    218218                        'type'     => 'info'
    219219                ) );
    220220        }
    function bp_nouveau_ajax_get_thread_messages() { 
    341341
    342342        if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'bp_nouveau_messages' ) ) {
    343343                wp_send_json_error( array(
    344                         'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Unauthorized request.', 'buddypress' ) . '</p></div>',
     344                        'feedback' => __( 'Unauthorized request.', 'buddypress' ),
    345345                        'type'     => 'error'
    346346                ) );
    347347        }
    348348
    349349        $response = array(
    350                 'feedback' => '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Sorry, no messages were found.', 'buddypress' ) . '</p></div>',
     350                'feedback' => __( 'Sorry, no messages were found.', 'buddypress' ),
    351351                'type'     => 'info'
    352352        );
    353353
    function bp_nouveau_ajax_get_thread_messages() { 
    434434 */
    435435function bp_nouveau_ajax_delete_thread_messages() {
    436436        $response = array(
    437                 'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'There was a problem deleting your message(s). Please try again.', 'buddypress' ) . '</p></div>',
     437                'feedback' => __( 'There was a problem deleting your message(s). Please try again.', 'buddypress' ),
    438438                'type'     => 'error',
    439439        );
    440440
    function bp_nouveau_ajax_delete_thread_messages() { 
    457457        }
    458458
    459459        wp_send_json_success( array(
    460                 'feedback' => '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Message(s) deleted', 'buddypress' ) . '</p></div>',
     460                'feedback' => __( 'Message(s) deleted', 'buddypress' ),
    461461                'type'     => 'success',
    462462        ) );
    463463}
    function bp_nouveau_ajax_star_thread_messages() { 
    479479        }
    480480
    481481        $response = array(
    482                 'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . esc_html( $error_message ) . '</p></div>',
     482                'feedback' => esc_html( $error_message ),
    483483                'type'     => 'error',
    484484        );
    485485
    function bp_nouveau_ajax_star_thread_messages() { 
    555555        }
    556556
    557557        wp_send_json_success( array(
    558                 'feedback' => '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . esc_html( $success_message ) . '</p></div>',
     558                'feedback' => esc_html( $success_message ),
    559559                'type'     => 'success',
    560560                'messages' => $messages,
    561561        ) );
    function bp_nouveau_ajax_readunread_thread_messages() { 
    578578
    579579        if ( 'unread' === $action ) {
    580580                $response = array(
    581                         'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'There was a problem marking your message(s) as unread. Please try again.', 'buddypress' ) . '</p></div>',
     581                        'feedback' => __( 'There was a problem marking your message(s) as unread. Please try again.', 'buddypress' ),
    582582                        'type'     => 'error',
    583583                );
    584584        }
    function bp_nouveau_ajax_readunread_thread_messages() { 
    596596        $response['messages'] = array();
    597597
    598598        if ( 'unread' === $action ) {
    599                 $response['feedback'] = '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Message(s) marked as unread.', 'buddypress' ) . '</p></div>';
     599                $response['feedback'] = __( 'Message(s) marked as unread.', 'buddypress' );
    600600        } else {
    601                 $response['feedback'] = '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Message(s) marked as read.', 'buddypress' ) . '</p></div>';
     601                $response['feedback'] = __( 'Message(s) marked as read.', 'buddypress' );
    602602        }
    603603
    604604        foreach ( $thread_ids as $thread_id ) {
  • 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 693e5e51e..852637084 100644
    function bp_nouveau_messages_localize_scripts( $params = array() ) { 
    9898                'nonces' => array(
    9999                        'send' => wp_create_nonce( 'messages_send_message' ),
    100100                ),
    101                 'loading' => '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Loading messages. Please wait.', 'buddypress' ) . '</p></div>',
     101                'loading' => __( 'Loading messages. Please wait.', 'buddypress' ),
    102102                'bulk_actions' => bp_nouveau_messages_get_bulk_actions(),
    103103        );
    104104
  • 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 e706a69f7..efc9e989b 100644
    window.bp = window.bp || {}; 
    452452        bp.Views.Feedback = bp.Nouveau.Messages.View.extend( {
    453453                tagName: 'div',
    454454                className: 'bp-messages bp-user-messages-feedback',
     455                template  : bp.template( 'bp-messages-feedback' ),
    455456
    456457                initialize: function() {
    457                         this.value = this.options.value;
    458 
    459                         if ( this.options.type ) {
    460                                 this.el.className += ' ' + this.options.type;
    461                         }
    462                 },
    463 
    464                 render: function() {
    465                         this.$el.html( this.value );
    466                         return this;
     458                        this.model = new Backbone.Model( {
     459                                type: this.options.type || 'info',
     460                                message: this.options.value,
     461                        } );
    467462                }
    468463        } );
    469464