// AJAX Functions var j = jQuery; // Global variable to prevent multiple AJAX requests var bp_ajax_request = null; j(document).ready( function() { /**** Page Load Actions *******************************************************/ /* Hide Forums Post Form */ if ( j('div.forums').length ) j('div#new-topic-post').hide(); /* Show threaded reply links */ if ( j('span.acomment-replylink').length ) j('span.acomment-replylink').show(); /* Activity filter and scope set */ bp_init_activity(); /* Object filter and scope set. */ var objects = [ 'members', 'groups', 'blogs', 'forums' ]; bp_init_objects( objects ); /* @mention Compose Scrolling */ if ( j.query.get('r') ) { if ( j('textarea#whats-new').length ) { j.scrollTo( j('textarea#whats-new'), 500, { offset:-125, easing:'easeout' } ); j('textarea#whats-new').focus(); } } /* @mention username help button display */ if ( j( 'span.highlight span' ).length ) j( 'span.highlight span' ).toggle(); /**** Activity Posting ********************************************************/ /* New posts */ j("input#aw-whats-new-submit").click( function() { var button = j(this); var form = button.parent().parent().parent().parent(); form.children().each( function() { if ( j.nodeName(this, "textarea") || j.nodeName(this, "input") ) j(this).attr( 'disabled', 'disabled' ); }); j( 'form#' + form.attr('id') + ' span.ajax-loader' ).show(); /* Remove any errors */ j('div.error').remove(); button.attr('disabled','disabled'); /* Default POST values */ var object = ''; var item_id = j("#whats-new-post-in").val(); var content = j("textarea#whats-new").val(); /* Set object for non-profile posts */ if ( item_id > 0 ) { object = j("#whats-new-post-object").val(); } j.post( ajaxurl, { action: 'post_update', 'cookie': encodeURIComponent(document.cookie), '_wpnonce_post_update': j("input#_wpnonce_post_update").val(), 'content': content, 'object': object, 'item_id': item_id }, function(response) { j( 'form#' + form.attr('id') + ' span.ajax-loader' ).hide(); form.children().each( function() { if ( j.nodeName(this, "textarea") || j.nodeName(this, "input") ) j(this).attr( 'disabled', '' ); }); /* Check for errors and append if found. */ if ( response[0] + response[1] == '-1' ) { form.prepend( response.substr( 2, response.length ) ); j( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 ); button.attr("disabled", ''); } else { if ( 0 == j("ul.activity-list").length ) { j("div.error").slideUp(100).remove(); j("div#message").slideUp(100).remove(); j("div.activity").append( '