[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 /* global bpHelloStrings */ 2 /** 3 * Loads for BuddyPress Hello in wp-admin for query string `hello=buddypress`. 4 * 5 * @since 3.0.0 6 */ 7 (function( $, bp ) { 8 // Bail if not set 9 if ( typeof bpHelloStrings === 'undefined' ) { 10 return; 11 } 12 13 /** 14 * Open the BuddyPress Hello modal. 15 */ 16 var bpHelloOpenModal = function() { 17 if ( 'function' !== typeof window.tb_show ) { 18 return false; 19 } 20 21 window.tb_show( 'BuddyPress', '#TB_inline?inlineId=bp-hello-container' ); 22 23 $( '#TB_window' ).attr( { 24 'role': 'dialog', 25 'aria-label': bpHelloStrings.modalLabel 26 } ) 27 .addClass( 'plugin-details-modal' ) 28 .removeClass( 'thickbox-loading' ); 29 30 $( '#TB_ajaxContent' ).prop( 'style', 'height: 100%; width: auto; padding: 0; border: none;' ); 31 32 var tabbables = $( ':tabbable', '#TB_ajaxContent' ), lastTabbable = tabbables.last(); 33 34 // Move the focus to the Modal's close button once the last Hello link was tabbed out. 35 $( '#TB_window' ).on( 'keydown', function( event ) { 36 if ( 9 === event.keyCode && ! event.shiftKey && $( lastTabbable ).prop( 'classList' ).value === $( event.target ).prop( 'classList' ).value ) { 37 event.preventDefault(); 38 39 $( '#TB_closeWindowButton' ).focus(); 40 } 41 42 if ( 9 === event.keyCode && event.shiftKey && 'TB_closeWindowButton' === $( event.target ).prop( 'id' ) ) { 43 event.preventDefault(); 44 45 $( lastTabbable ).focus(); 46 } 47 } ); 48 }; 49 50 /** 51 * Prints an error message. 52 * 53 * @param {string} message The error message to display. 54 */ 55 var printErrorMessage = function( message ) { 56 if ( ! message ) { 57 message = bpHelloStrings.pageNotFound; 58 } 59 60 $( '#dynamic-content' ).html( 61 $('<div></div>' ).prop( 'id', 'message' ) 62 .addClass( 'notice notice-error error' ) 63 .html( 64 $( '<p></p>' ).html( message ) 65 ) 66 ); 67 }; 68 69 // Listen to Tab Menu clicks to display the different screens. 70 $( '#plugin-information-tabs').on( 'click', 'a', function( event ) { 71 event.preventDefault(); 72 73 var anchor = $( event.currentTarget ), target = $( '#dynamic-content' ); 74 75 if ( anchor.hasClass( 'dynamic' ) ) { 76 $( '#top-features' ).hide(); 77 target.html( '' ); 78 target.addClass( 'show' ); 79 80 $( '#TB_window' ).addClass( 'thickbox-loading' ); 81 82 bp.apiRequest( { 83 url: anchor.data( 'endpoint' ), 84 type: 'GET', 85 beforeSend: function( xhr, settings ) { 86 settings.url = settings.url.replace( '&_wpnonce=none', '' ); 87 }, 88 data: { 89 context: 'view', 90 slug: anchor.data( 'slug' ), 91 _wpnonce: 'none' 92 } 93 } ).done( function( data ) { 94 var page = _.first( data ); 95 96 if ( page && page.content ) { 97 target.html( page.content.rendered ); 98 } else { 99 printErrorMessage(); 100 } 101 102 } ).fail( function( error ) { 103 if ( ! error || ! error.message ) { 104 return false; 105 } 106 107 printErrorMessage( error.message ); 108 109 } ).always( function() { 110 $( '#TB_window' ).removeClass( 'thickbox-loading' ); 111 } ); 112 113 } else { 114 $( '#top-features' ).show(); 115 target.html( '' ); 116 target.removeClass( 'show' ); 117 } 118 } ); 119 120 // Init modal after the screen's loaded. 121 $( document ).ready( function() { 122 bpHelloOpenModal(); 123 } ); 124 125 }( jQuery, window.bp || {} ) );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Jan 25 01:01:33 2021 | Cross-referenced by PHPXref 0.7.1 |