Changeset 10053
- Timestamp:
- 08/18/2015 10:49:31 PM (9 years ago)
- Location:
- branches/2.3/src/bp-activity
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.3/src/bp-activity/bp-activity-cssjs.php
r9819 r10053 42 42 } 43 43 44 // If the script has been enqueued, let's attach our mentions TinyMCE init callback. 45 add_filter( 'tiny_mce_before_init', 'bp_add_mentions_on_tinymce_init', 10, 2 ); 46 44 47 /** 45 48 * Fires at the end of the Activity Mentions script. … … 54 57 add_action( 'bp_enqueue_scripts', 'bp_activity_mentions_script' ); 55 58 add_action( 'bp_admin_enqueue_scripts', 'bp_activity_mentions_script' ); 59 60 /** 61 * Bind the mentions listener to a wp_editor instance when TinyMCE initializes. 62 * 63 * @since BuddyPress (2.3.3) 64 * 65 * @param array $settings An array with TinyMCE config. 66 * @param string $editor_id Unique editor identifier, e.g. 'content'. 67 * 68 * @return array $mceInit An array with TinyMCE config. 69 */ 70 function bp_add_mentions_on_tinymce_init( $settings, $editor_id ) { 71 // We only apply the mentions init to the visual post editor in the WP dashboard. 72 if ( 'content' === $editor_id ) { 73 $settings['init_instance_callback'] = 'window.bp.mentions.tinyMCEinit'; 74 } 75 76 return $settings; 77 } -
branches/2.3/src/bp-activity/js/mentions.js
r9819 r10053 1 (function( $, undefined ) { 1 /* global bp */ 2 3 window.bp = window.bp || {}; 4 5 ( function( bp, $, undefined ) { 2 6 var mentionsQueryCache = [], 3 7 mentionsItem; 8 9 bp.mentions = bp.mentions || {}; 10 bp.mentions.users = window.bp.mentions.users || []; 11 12 if ( typeof window.BP_Suggestions === 'object' ) { 13 bp.mentions.users = window.BP_Suggestions.friends || bp.mentions.users; 14 } 4 15 5 16 /** … … 229 240 230 241 $( document ).ready(function() { 231 var loadMentionsInTinyMCE, 232 loadAttempts = 0, 233 users = []; 234 235 if ( typeof window.BP_Suggestions === 'object' ) { 236 users = window.BP_Suggestions.friends || users; 237 } 238 239 // Dashboard post 'visual' editor. 240 loadMentionsInTinyMCE = function() { 241 if ( loadAttempts < 4 || ! $( 'body' ).hasClass( 'wp-admin' ) ) { 242 loadAttempts++; 243 244 if ( typeof window.tinyMCE === 'undefined' || window.tinyMCE.activeEditor === null || typeof window.tinyMCE.activeEditor === 'undefined' ) { 245 setTimeout( loadMentionsInTinyMCE, 500 ); 246 return; 247 } 248 } 249 242 // Activity/reply, post comments, dashboard post 'text' editor. 243 $( '.bp-suggestions, #comments form textarea, .wp-editor-area' ).bp_mentions( bp.mentions.users ); 244 }); 245 246 bp.mentions.tinyMCEinit = function() { 247 if ( typeof window.tinyMCE === 'undefined' || window.tinyMCE.activeEditor === null || typeof window.tinyMCE.activeEditor === 'undefined' ) { 248 return; 249 } else { 250 250 $( window.tinyMCE.activeEditor.contentDocument.activeElement ) 251 251 .atwho( 'setIframe', $( '#content_ifr' )[0] ) 252 .bp_mentions( users ); 253 }; 254 255 // Activity/reply, post comments, dashboard post 'text' editor. 256 $( '.bp-suggestions, #comments form textarea, .wp-editor-area' ).bp_mentions( users ); 257 258 // Dashboard post 'visual' editor. 259 loadMentionsInTinyMCE(); 260 }); 261 })( jQuery ); 252 .bp_mentions( bp.mentions.users ); 253 } 254 }; 255 })( bp, jQuery );
Note: See TracChangeset
for help on using the changeset viewer.