;( function() { jQuery( document ).ready( function( $ ) { if ( $( '#pen_configuration' ).length ) { var pen_has_AreYouSure = typeof areYouSure; if ( pen_has_AreYouSure !== 'undefined' && pen_has_AreYouSure !== undefined && pen_has_AreYouSure !== null ) { $( '#pen_configuration' ).areYouSure( { message: pen_backend_js.text.unsaved_changes } ); } } else { var $post_meta = $( '#pen_post_meta' ); $( '#pen_post_meta_hint' ).hide(); $( '#pen_meta_box h2' ).prepend( '' + pen_backend_js.text.pen_theme + '' ) .find( '.pen_only' ).attr( 'title', $( '#pen_post_meta_hint' ).text() ); $post_meta.find( '.postbox select' ).each( function() { var $select = $( this ); pen_post_meta_select( $select ); $select.on( 'change', function() { pen_post_meta_select( $select ); $select.closest( '.pen_post_meta_container' ).slideDown( 'fast' ).removeClass( 'closed' ).attr( 'aria-expanded', true ) .closest( '.pen_post_meta_options' ).removeClass( 'closed' ); } ); } ); function pen_post_meta_select( $select ) { var id = $select.attr( 'id' ), value_current = $select.val(); if ( $( '#apply_' + id ).length ) { var value_new = $( '#apply_' + id ).val(); if ( value_new != value_current ) { var $option = $( '#apply_' + id ); $option.prop( 'disabled', false ) .closest( 'tr' ).find( '.button' ).removeClass( 'disabled' ); } } if ( value_current === 'no' ) { $select.parent().addClass( 'pen_post_meta_disable' ).removeClass( 'pen_post_meta_enable' ); if ( id === 'pen_content_thumbnail_display_override' || id === 'pen_list_thumbnail_display_override' ) { $select.closest( '.pen_wrap' ).siblings( '.pen_wrap' ).filter( ':not(:first-of-type)' ).animate( { opacity: 0.3 }, { queue: false, duration: 300 } ); if ( id === 'pen_list_thumbnail_display_override' ) { $( '#pen_list_thumbnail_animation_reveal_override' ).closest( '.pen_wrap' ).animate( { opacity: 0.3 }, { queue: false, duration: 300 } ); } if ( id === 'pen_content_thumbnail_display_override' ) { $( '#pen_content_thumbnail_animation_reveal_override' ).closest( '.pen_wrap' ).animate( { opacity: 0.3 }, { queue: false, duration: 300 } ); } } else if ( id === 'pen_content_header_display_override' ) { $( '#pen_content_title_display_override' ).closest( '.pen_wrap' ).animate( { opacity: 0.3 }, { queue: false, duration: 300 } ); } else if ( id === 'pen_list_header_display_override' ) { $( '#pen_list_title_display_override' ).closest( '.pen_wrap' ).animate( { opacity: 0.3 }, { queue: false, duration: 300 } ); } else if ( id === 'pen_content_header_alignment_override' ) { $( '#pen_content_title_alignment_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } else if ( id === 'pen_list_post_header_alignment_override' ) { $( '#pen_list_title_alignment_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } } else if ( value_current === 'yes' || value_current != 'default' ) { $select.parent().removeClass( 'pen_post_meta_disable' ).addClass( 'pen_post_meta_enable' ); if ( id === 'pen_content_thumbnail_display_override' || id === 'pen_list_thumbnail_display_override' ) { $select.closest( '.pen_wrap' ).siblings( '.pen_wrap' ).filter( ':not(:first-of-type)' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); if ( id === 'pen_list_thumbnail_display_override' ) { $( '#pen_list_thumbnail_animation_reveal_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } if ( id === 'pen_content_thumbnail_display_override' ) { $( '#pen_content_thumbnail_animation_reveal_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } } else if ( id === 'pen_content_header_display_override' ) { $( '#pen_content_title_display_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } else if ( id === 'pen_list_header_display_override' ) { $( '#pen_list_title_display_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } else if ( id === 'pen_content_header_alignment_override' ) { $( '#pen_content_title_alignment_override' ).closest( '.pen_wrap' ).animate( { opacity: 0.3 }, { queue: false, duration: 300 } ); } else if ( id === 'pen_list_post_header_alignment_override' ) { $( '#pen_list_title_alignment_override' ).closest( '.pen_wrap' ).animate( { opacity: 0.3 }, { queue: false, duration: 300 } ); } } else { $select.parent().removeClass( 'pen_post_meta_enable pen_post_meta_disable' ); if ( id === 'pen_content_thumbnail_display_override' || id === 'pen_list_thumbnail_display_override' ) { $select.closest( '.pen_wrap' ).siblings( '.pen_wrap' ).filter( ':not(:first-of-type)' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); if ( id === 'pen_list_thumbnail_display_override' ) { $( '#pen_list_thumbnail_animation_reveal_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } if ( id === 'pen_content_thumbnail_display_override' ) { $( '#pen_content_thumbnail_animation_reveal_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } } else if ( id === 'pen_content_header_display_override' ) { $( '#pen_content_title_display_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } else if ( id === 'pen_list_header_display_override' ) { $( '#pen_list_title_display_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } else if ( id === 'pen_content_header_alignment_override' ) { $( '#pen_content_title_alignment_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } else if ( id === 'pen_list_post_header_alignment_override' ) { $( '#pen_list_title_alignment_override' ).closest( '.pen_wrap' ).animate( { opacity: 1 }, { queue: false, duration: 300 } ); } } } $post_meta.find( '.pen_sidebars input' ).each( function() { var $checkbox = $( this ); pen_post_meta_sidebars( $checkbox ); $checkbox.on( 'change', function() { pen_post_meta_sidebars( $checkbox ); $checkbox.closest( '.pen_post_meta_container' ).slideDown( 'fast' ).removeClass( 'closed' ).attr( 'aria-expanded', true ) .closest( '.pen_post_meta_options' ).removeClass( 'closed' ); } ); } ); function pen_post_meta_sidebars( $checkbox ) { var $option = $( '#apply_' + $checkbox.attr( 'id' ) ), $button = $option.closest( 'tr' ).find( '.button' ); if ( $checkbox.is( ':checked' ) ) { $checkbox.parent().addClass( 'pen_post_meta_disable' ); $option.prop( 'disabled', true ).removeAttr( 'checked' ).prop( 'checked', false ).trigger( 'change' ); $button.addClass( 'disabled' ); } else { $checkbox.parent().removeClass( 'pen_post_meta_disable' ); $option.prop( 'disabled', false ); $button.removeClass( 'disabled' ); } } $post_meta.find( 'h3' ).each( function() { var $h3 = $( this ), $container = $h3.next( '.pen_post_meta_container' ); $h3.append( '' ); if ( ! $container.find( '.pen_post_meta_enable,.pen_post_meta_disable' ).length ) { $container.slideUp( 'fast' ).addClass( 'closed' ).attr( 'aria-expanded', false ) .closest( '.pen_post_meta_options' ).addClass( 'closed' ); } $h3.on( 'click', function() { var $container = $( this ).closest( '.pen_post_meta_options' ).find( '.pen_post_meta_container' ); pen_options_expanded( $container ); } ); } ); function pen_options_expanded( $container ) { if ( $container.hasClass( 'closed' ) ) { $container.slideDown( 'fast' ).removeClass( 'closed' ).closest( '.pen_post_meta_options' ).removeClass( 'closed' ) .prev( 'h3' ).find( '.handlediv' ).attr( 'aria-expanded', 'true' ); } else { $container.slideUp( 'fast' ).addClass( 'closed' ).closest( '.pen_post_meta_options' ).addClass( 'closed' ) .prev( 'h3' ).find( '.handlediv' ).attr( 'aria-expanded', 'false' ); } } } } ); } )( jQuery );