post_data = $.extend( {
action: 'youzify_post_update',
'cookie': bp_get_cookies(),
'_youzify_wpnonce_post_update': $( '#_youzify_wpnonce_post_update' ).val(),
'content': content,
'hastag': positiveArr,
'object': object,
'item_id': item_id,
'since': last_date_recorded,
'_bp_as_nonce': $( '#_bp_as_nonce' ).val() || ''
}, inputs );
console.log('post_data');
console.log(post_data);
$.post( ajaxurl, post_data, function( response ) {
form.find( '*' ).each( function() {
if ( $.nodeName( this, 'textarea' ) || $.nodeName( this, 'input' ) ) {
$( this ).prop( 'disabled', false );
}
});
if ( form.find( '.youzify-wall-textarea' ).get( 0 ).Youzify_emojioneArea ) {
form.find( '.youzify-wall-textarea' ).data( 'Youzify_emojioneArea' ).enable();
}
// Get Response Data.
console.log('response');
console.log(response);
console.log('response.success');
console.log(response.success);
if ( response.success == false ) {
$.youzify_DialogMsg( 'error', response.data.error );
} else {
// Show Check .
button.html( '<i class="fas fa-check"></i>' ).hide().fadeIn( 'slow' );
form.find( '.youzify-delete-attachment' ).trigger( 'click' );
if ( 0 === $('ul.activity-list').length ) {
$( 'div.error' ).slideUp( 100 ).remove();
$( '#message' ).slideUp( 100 ).remove();
$( 'div.activity').append( '<ul id="activity-stream" class="activity-list item-list">' );
}
if ( firstrow.hasClass( 'load-newest' ) ) {
firstrow.remove();
}
$( '#activity-stream' ).prepend( response );
if ( ! last_date_recorded ) {
$( '#activity-stream li:first' ).addClass( 'new-update just-posted' );
}
// Scroll To Added Post.
if ( $( response ).get( 0 ) ) {
$( 'body,html' ).animate({
scrollTop: $( '#' + $( response ).attr( 'id') ).offset().top - 65 + 'px'
}, 1000 );
}
if ( 0 !== $( '#latest-update' ).length ) {
var l = $( '#activity-stream li.new-update .activity-content .activity-inner p' ).html(),
v = $( '#activity-stream li.new-update .activity-content .activity-header p a.view' ).attr('href'),
ltext = $( '#activity-stream li.new-update .activity-content .activity-inner p' ).text(),
u = '';
if ( ltext !== '' ) {
u = l + ' ';
}
u += '<a href="' + v + '" rel="nofollow">' + BP_DTheme.view + '</a>';
$( '#latest-update' ).slideUp( 300,function() {
$( '#latest-update' ).html( u );
$( '#latest-update' ).slideDown( 300 );
});
}
$( 'li.new-update' ).hide().slideDown( 300 );
$( 'li.new-update' ).removeClass( 'new-update' );
$( '#whats-new' ).val( '' );
// Init Slider.
if ( inputs.post_type == 'activity_slideshow' ) {
$.youzify_sliders_init();
}
// Reset Form.
form.get( 0 ).reset();
// Reset Text Form.
if ( form.find( '.youzify-wall-textarea' ).get( 0 ).Youzify_emojioneArea ) {
form.find( '.youzify-wall-textarea' ).get( 0 ).Youzify_emojioneArea.setText( '' );
}
// Reset Tagged Users Form.
form.find( '.youzify-tagged-user .youzify-tagusers-delete-user, .youzify-list-delete-item, .youzify-list-close-icon' ).trigger( 'click' );
// Select First Element.
form.find( 'div.youzify-activity-privacy' ).find( '.list div' ).first().trigger( 'click' );
form.find( '#whats-new-post-in' ).find( 'option' ).first().trigger( 'click' );
// Update Nice Select.
if ( ! window.hasOwnProperty( 'youzify_disable_niceselect' ) ) {
form.find( '#whats-new-post-in' ).niceSelect( 'update' );
}
// Update Post in field.
$( '#whats-new-post-in' ).trigger( 'change' );
form.find( '.youzify-wall-options input:radio[name="post_type"]' ).first().trigger( 'change' );
form.find( '.youzify-lp-prepost .lp-button-cancel' ).trigger( 'click' );
if ( inputs.post_type == 'activity_giphy' ) {
form.find( '.youzify-delete-giphy-item' ).trigger( 'click' );
form.find( '.youzify-giphy-submit-search' ).val( '' ).trigger( 'click' );
}
// reset vars to get newest activities
newest_activities = '';
activity_last_recorded = 0;
}