123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- ;( 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( '<span class="pen_only">' + pen_backend_js.text.pen_theme + '</span>' )
- .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( '<button type="button" class="handlediv button-link"><span class="screen-reader-text">' + pen_backend_js.text.toggle + '</span><span class="toggle-indicator" aria-hidden="true"></span></button>' );
- 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 );
|