diff --git src/bp-templates/bp-nouveau/includes/messages/functions.php src/bp-templates/bp-nouveau/includes/messages/functions.php
index 191a85381..cbc9a00a4 100644
|
|
|
function bp_nouveau_messages_enqueue_scripts() { |
| 77 | 77 | add_filter( 'tiny_mce_before_init', 'bp_nouveau_messages_at_on_tinymce_init', 10, 2 ); |
| 78 | 78 | } |
| 79 | 79 | |
| | 80 | /** |
| | 81 | * Should the Private Messages UI be used as a Single Page Application? |
| | 82 | * |
| | 83 | * @since 3.0.1 |
| | 84 | * |
| | 85 | * @return boolean True to use as a SPA. False otherwise. |
| | 86 | */ |
| | 87 | function bp_nouveau_messages_is_spa() { |
| | 88 | /** |
| | 89 | * Filter here to use Private messages as a Single Page Application |
| | 90 | * by returning true. |
| | 91 | * |
| | 92 | * Some plugins functionality may not work as expected in this case. |
| | 93 | * |
| | 94 | * @param boolean $value True to use as a SPA. False otherwise. |
| | 95 | * Default false. |
| | 96 | */ |
| | 97 | return (bool) apply_filters( 'bp_nouveau_messages_is_spa', false ); |
| | 98 | } |
| | 99 | |
| 80 | 100 | /** |
| 81 | 101 | * Localize the strings needed for the messages UI |
| 82 | 102 | * |
| … |
… |
function bp_nouveau_messages_localize_scripts( $params = array() ) { |
| 114 | 134 | 'one' => __( '(and 1 other)', 'buddypress' ), |
| 115 | 135 | 'more' => __( '(and %d others)', 'buddypress' ), |
| 116 | 136 | ), |
| | 137 | 'isSpa' => bp_nouveau_messages_is_spa(), |
| | 138 | 'rootUrl' => trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() ), |
| 117 | 139 | ); |
| 118 | 140 | |
| 119 | 141 | // Star private messages. |
| … |
… |
function bp_nouveau_messages_adjust_nav() { |
| 179 | 201 | if ( 'notices' === $secondary_nav_item->slug ) { |
| 180 | 202 | bp_core_remove_subnav_item( bp_get_messages_slug(), $secondary_nav_item->slug, 'members' ); |
| 181 | 203 | } else { |
| 182 | | $params = array( 'link' => '#' . $secondary_nav_item->slug ); |
| | 204 | if ( bp_nouveau_messages_is_spa() ) { |
| | 205 | $params = array( 'link' => '#' . $secondary_nav_item->slug ); |
| | 206 | } else { |
| | 207 | $params = array( 'link' => $secondary_nav_item->link . '#' . $secondary_nav_item->slug ); |
| | 208 | } |
| 183 | 209 | |
| 184 | 210 | // Make sure Admins won't write a messages from the user's account. |
| 185 | 211 | if ( 'compose' === $secondary_nav_item->slug ) { |
| … |
… |
function bp_nouveau_messages_adjust_admin_nav( $admin_nav ) { |
| 208 | 234 | if ( 'notices' === $nav_id ) { |
| 209 | 235 | $admin_nav[ $nav_iterator ]['href'] = esc_url( add_query_arg( array( 'page' => 'bp-notices' ), bp_get_admin_url( 'users.php' ) ) ); |
| 210 | 236 | } else { |
| 211 | | $admin_nav[ $nav_iterator ]['href'] = $user_messages_link . '#' . trim( $nav_id ); |
| | 237 | if ( bp_nouveau_messages_is_spa() ) { |
| | 238 | $admin_nav[ $nav_iterator ]['href'] = $user_messages_link . '#' . trim( $nav_id ); |
| | 239 | } else { |
| | 240 | $admin_nav[ $nav_iterator ]['href'] .= '#' . trim( $nav_id ); |
| | 241 | } |
| 212 | 242 | } |
| 213 | 243 | } |
| 214 | 244 | } |
diff --git src/bp-templates/bp-nouveau/js/buddypress-messages.js src/bp-templates/bp-nouveau/js/buddypress-messages.js
index 7c1ad32d4..0d113225e 100644
|
|
|
window.bp = window.bp || {}; |
| 73 | 73 | |
| 74 | 74 | // Otherwise load it |
| 75 | 75 | } else { |
| 76 | | self.router.navigate( 'compose', { trigger: true } ); |
| | 76 | self.routeUrl( 'compose' ); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // Other views are classic. |
| … |
… |
window.bp = window.bp || {}; |
| 82 | 82 | if ( self.box !== view_id || ! _.isUndefined( self.views.get( 'compose' ) ) ) { |
| 83 | 83 | self.clearViews(); |
| 84 | 84 | |
| 85 | | self.router.navigate( view_id, { trigger: true } ); |
| | 85 | self.routeUrl( view_id ); |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | } ); |
| … |
… |
window.bp = window.bp || {}; |
| 215 | 215 | this.views.add( { id: 'single', view: single_thread } ); |
| 216 | 216 | |
| 217 | 217 | single_thread.inject( '.bp-messages-content' ); |
| | 218 | }, |
| | 219 | |
| | 220 | /** |
| | 221 | * Uses the Single Page Application route or opens an URL. |
| | 222 | * |
| | 223 | * @param {string} slug The URL slug to root the User to. |
| | 224 | * @return {void} |
| | 225 | */ |
| | 226 | routeUrl: function( slug ) { |
| | 227 | if ( BP_Nouveau.messages.isSpa ) { |
| | 228 | this.router.navigate( slug, { trigger: true } ); |
| | 229 | } else { |
| | 230 | window.location.href = BP_Nouveau.messages.rootUrl + slug + '/#' + slug; |
| | 231 | } |
| 218 | 232 | } |
| 219 | 233 | }; |
| 220 | 234 | |
| … |
… |
window.bp = window.bp || {}; |
| 616 | 630 | form.get( 'view' ).remove(); |
| 617 | 631 | bp.Nouveau.Messages.views.remove( { id: 'compose', view: form } ); |
| 618 | 632 | |
| 619 | | bp.Nouveau.Messages.router.navigate( 'sentbox', { trigger: true } ); |
| | 633 | bp.Nouveau.Messages.routeUrl( 'sentbox' ); |
| 620 | 634 | } ).fail( function( response ) { |
| 621 | 635 | if ( response.feedback ) { |
| 622 | 636 | bp.Nouveau.Messages.displayFeedback( response.feedback, response.type ); |
| … |
… |
window.bp = window.bp || {}; |
| 726 | 740 | loadSingleView: function( event ) { |
| 727 | 741 | event.preventDefault(); |
| 728 | 742 | |
| 729 | | bp.Nouveau.Messages.router.navigate( |
| 730 | | 'view/' + $( event.currentTarget ).closest( '.thread-content' ).data( 'thread-id' ), |
| 731 | | { trigger: true } |
| | 743 | bp.Nouveau.Messages.routeUrl( |
| | 744 | 'view/' + $( event.currentTarget ).closest( '.thread-content' ).data( 'thread-id' ) |
| 732 | 745 | ); |
| 733 | 746 | } |
| 734 | 747 | } ); |