// AJAX Functions var jq = jQuery; // Global variable to prevent multiple AJAX requests var bp_ajax_request = null; jq(document).ready( function() { /**** Page Load Actions *******************************************************/ /* Hide Forums Post Form */ if ( jq('div.forums').length ) jq('div#new-topic-post').hide(); /* 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 ( jq.query.get('r') ) { if ( jq('textarea#whats-new').length ) { jq.scrollTo( jq('textarea#whats-new'), 500, { offset:-125, easing:'easeOutQuad' } ); jq('textarea#whats-new').focus(); } } /* @mention username help button display */ if ( jq( 'span.highlight span' ).length ) jq( 'span.highlight span' ).toggle(); /**** Activity Posting ********************************************************/ /* New posts */ jq("input#aw-whats-new-submit").click( function() { var button = jq(this); var form = button.parent().parent().parent().parent(); form.children().each( function() { if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") ) jq(this).prop( 'disabled', true ); }); jq( 'form#' + form.attr('id') + ' span.ajax-loader' ).show(); /* Remove any errors */ jq('div.error').remove(); button.prop('disabled', true); /* Default POST values */ var object = ''; var item_id = jq("#whats-new-post-in").val(); var content = jq("textarea#whats-new").val(); var ad_photo1 = jq("#ad_photo1").val(); var ad_audio = jq("#ad_audio").val(); var ad_video = jq("#ad_video").val(); var ad_ytubevideo = jq("#ad_ytubevideo").val(); /* Set object for non-profile posts */ if ( item_id > 0 ) { object = jq("#whats-new-post-object").val(); } jq.post( ajaxurl, { action: 'post_update', 'cookie': encodeURIComponent(document.cookie), '_wpnonce_post_update': jq("input#_wpnonce_post_update").val(), 'content': content, 'ad_photo1': ad_photo1, 'ad_audio': ad_audio, 'ad_video': ad_video, 'ad_ytubevideo': ad_ytubevideo, 'object': object, 'item_id': item_id }, function(response) { jq('#v11111').empty(); jq('#p11111').empty(); jq('#a11111').empty(); jq('#y11111').empty(); jq( 'form#' + form.attr('id') + ' span.ajax-loader' ).hide(); form.children().each( function() { if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") ) jq(this).prop( 'disabled', false ); }); /* Check for errors and append if found. */ if ( response[0] + response[1] == '-1' ) { form.prepend( response.substr( 2, response.length ) ); jq( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 ); button.prop("disabled", false); } else { if ( 0 == jq("ul.activity-list").length ) { jq("div.error").slideUp(100).remove(); jq("div#message").slideUp(100).remove(); jq("div.activity").append( '