Skip to content

Commit

Permalink
Frontend Editor: Continuation of #55.
Browse files Browse the repository at this point in the history
This should fix up the problems from commit cfcdcfc.
  • Loading branch information
r-a-y committed Nov 6, 2016
1 parent 9db4e19 commit 1b0fcdb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 35 deletions.
64 changes: 29 additions & 35 deletions assets/js/group-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,52 @@ jQuery(function($){
bpeoToggle = function() {
var notice = bpeoSubmit.find('.updated');

if ( false === $.isEmptyObject( bpeoSelect.val() ) ) {
bpeoToggleFlag = true;

if ( bpeoIsPrivate ) {
$("#visibility-radio-private" ).prop("checked", true);
$('#post-status-display').fadeOut('fast').text( postL10n.privatelyPublished ).fadeIn('fast');
$('#post-visibility-display').fadeOut('fast').text( postL10n.private ).fadeIn('fast');
} else {
$("#visibility-radio-public" ).prop("checked", true);
$('#post-status-display').fadeOut('fast').text( postL10n.published ).fadeIn('fast');
$('#post-visibility-display').fadeOut('fast').text( postL10n.public ).fadeIn('fast');
}
bpeoGroupMsg = BpEventOrganiserSettings.group_privacy_message;

if ( true === $.isEmptyObject( bpeoSelect.val() ) ) {
$('.misc-pub-post-status, .misc-pub-visibility').show();
$('.edit-post-status').show();
$('#save-post').show();
$('#submitdiv .inside .error').hide();
notice.fadeOut();
} else {
$('.misc-pub-post-status, .misc-pub-visibility').hide();
$('#save-post').hide();
$('#submitdiv .inside .error').show();

if ( ! notice.length && typeof adminpage === 'undefined' ) {
bpeoSubmit.prepend('<div class="updated"><p>' + bpeoGroupMsg + '</p></div>');
} else {
notice.fadeOut('fast');
notice.find('p').html( bpeoGroupMsg );
notice.fadeIn('fast');
}
if ( bpeoPublicFlag > 0 ) {
bpeoGroupMsg = BpEventOrganiserSettings.group_public_message;

} else if ( bpeoPublicFlag === 0 && bpeoToggleFlag === true ) {
bpeoToggleFlag = false;
$("#visibility-radio-public" ).prop("checked", true);
$('#post-status-display').fadeOut('fast').text( postL10n.published ).fadeIn('fast');
$('#post-visibility-display').fadeOut('fast').text( postL10n.public ).fadeIn('fast');
} else {
bpeoGroupMsg = BpEventOrganiserSettings.group_privacy_message;

if ( bpeoIsPrivate ) {
$("#visibility-radio-private" ).prop("checked", true);
$('#post-status-display').fadeOut('fast').text( postL10n.privatelyPublished ).fadeIn('fast');
$('#post-visibility-display').fadeOut('fast').text( postL10n.private ).fadeIn('fast');
} else {
$("#visibility-radio-public" ).prop("checked", true);
$('#post-status-display').fadeOut('fast').text( postL10n.published ).fadeIn('fast');
$('#post-visibility-display').fadeOut('fast').text( postL10n.public ).fadeIn('fast');
}
bpeoGroupMsg = BpEventOrganiserSettings.group_privacy_message;

$('.misc-pub-post-status, .misc-pub-visibility').show();
$('.edit-post-status').show();
$('#save-post').show();
$('#submitdiv .inside .error').hide();

if ( notice.length ) {
bpeoToggleFlag = false;

notice.fadeOut('fast');
notice.find('p').html( bpeoGroupMsg );
notice.fadeIn();
} else {
bpeoSubmit.prepend('<div class="updated"><p>' + bpeoGroupMsg + '</p></div>');
}

}
}

bpeoToggle();
$('#post-status-select, #post-visibility-select, #timestampdiv').hide();

if ( ! $( 'body' ).hasClass( 'bp-user' ) ) {
if ( ! bpeoSubmit.find('.updated').length && typeof adminpage === 'undefined' ) {
bpeoSubmit.prepend('<div class="updated"><p>' + bpeoGroupMsg + '</p></div>');
}
bpeoToggle();
}

// do not show "Save Draft" button for public groups when clicking on the
// "Cancel" button when toggled from the "Publish immediately" option
Expand Down Expand Up @@ -141,6 +134,7 @@ jQuery(function($){
});

bpeoSelect.on("select2:unselect select2:select", function (e) {
bpeoToggleFlag = true;
bpeoToggle();
});

Expand Down
4 changes: 4 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ function bpeo_enqueue_assets() {

wp_localize_script( 'bpeo-group-select', 'BpEventOrganiserSettings', array(
'group_privacy_message' => __( 'You have added a group to this event. Since groups have their own privacy settings, we have removed the ability to set the status for this event.', 'bp-event-organiser' ),
'group_public_message' => sprintf( __( 'You have added a %1$s to this event. Since the added group is %2$s, be aware that your event will also be publicized on the sitewide event calendar.', 'bp-event-organiser' ),
'<strong>' . __( 'public group', 'bp-event-organiser' ) . '</strong>',
'<strong>' . __( 'public', 'bp-event-organiser' ) . '</strong>'
),
) );
}

Expand Down

0 comments on commit 1b0fcdb

Please sign in to comment.