// AJAX Functions jQuery(document).ready( function() { var j = jQuery; /**** Page Load Actions *******************************************************/ /* Activity */ if ( j('div.activity').length && !j('div.activity').hasClass('no-ajax') ) { /* If there's a hash URL, try and use it. */ if ( location.hash.length ) var scope = location.hash.substr( 1, location.hash.length - 2 ); else var scope = j.cookie('bp-activity-scope'); bp_activity_request( scope, j.cookie('bp-activity-filter') ); } /* Members */ if ( j('div.members').length ) bp_filter_request( 'members', j.cookie('bp-members-filter'), j.cookie('bp-members-scope'), 'div.members' ); /* Groups */ if ( j('div.groups').length ) bp_filter_request( 'groups', j.cookie('bp-groups-filter'), j.cookie('bp-groups-scope'), 'div.groups' ); /* Blogs */ if ( j('div.blogs').length ) bp_filter_request( 'blogs', j.cookie('bp-blogs-filter'), j.cookie('bp-blogs-scope'), 'div.blogs' ); /* Forums */ if ( j('div.forums').length ) { j('div#new-topic-post').hide(); bp_filter_request( 'forums', j.cookie('bp-forums-filter'), j.cookie('bp-forums-scope'), 'div.forums' ); } /* @message 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(); } } /**** 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'); j.post( ajaxurl, { action: 'post_update', 'cookie': encodeURIComponent(document.cookie), '_wpnonce_post_update': j("input#_wpnonce_post_update").val(), 'content': j("textarea#whats-new").val(), 'group': j("#whats-new-post-in").val() }, 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( '