@@ -554,25 +554,98 @@ function socialPostFlowUpdateImageOptions() {
554554 $ ( social_post_flow . status_form )
555555 ) . val ( ) ;
556556
557- // Hide additional and text to image options.
557+ // Hide additional images, limit and text to image options.
558558 $ (
559- 'tr.additional-images, tr.text-to-image' ,
559+ 'tr.additional-images, tr.additional-images-limit, tr. text-to-image' ,
560560 $ ( social_post_flow . status_form )
561561 ) . hide ( ) ;
562562
563- // Show additional and text to image options, based on the selected image option.
564- $ (
565- 'tr.additional-images, tr.text-to-image' ,
563+ switch ( selected_image_option ) {
564+ case 'featured_image' :
565+ $ (
566+ 'tr.additional-images' ,
567+ $ ( social_post_flow . status_form )
568+ ) . show ( ) ;
569+ $ (
570+ 'tr.additional-images-limit' ,
571+ $ ( social_post_flow . status_form )
572+ ) . show ( ) ;
573+ break ;
574+ case 'text_to_image' :
575+ $ ( 'tr.text-to-image' , $ ( social_post_flow . status_form ) ) . show ( ) ;
576+ break ;
577+ }
578+
579+ // Enable options based on the Post Type.
580+ const post_type = $ (
581+ 'select.post_type' ,
566582 $ ( social_post_flow . status_form )
567- ) . each ( function ( ) {
568- const conditionalValues = $ ( this )
569- . data ( 'conditional-value' )
570- . toString ( )
571- . split ( ',' ) ; // .toString() prevents errors when splitting a single integer e.g. 2.
572- if ( conditionalValues . indexOf ( selected_image_option ) !== - 1 ) {
573- $ ( this ) . show ( ) ;
574- }
575- } ) ;
583+ ) . val ( ) ;
584+ switch ( post_type ) {
585+ case 'image' :
586+ // Enable all options in Additional Images.
587+ $ (
588+ 'option' ,
589+ $ (
590+ 'select.additional-images' ,
591+ $ ( social_post_flow . status_form )
592+ )
593+ ) . attr ( 'disabled' , false ) ;
594+ break ;
595+
596+ case 'story' :
597+ case 'pin' :
598+ case 'google' :
599+ // Disable all options in Additional Images.
600+ $ (
601+ 'option' ,
602+ $ (
603+ 'select.additional-images' ,
604+ $ ( social_post_flow . status_form )
605+ )
606+ ) . attr ( 'disabled' , true ) ;
607+
608+ // Enable the "None" Additional Images option.
609+ $ (
610+ 'option[value=""]' ,
611+ $ (
612+ 'select.additional-images' ,
613+ $ ( social_post_flow . status_form )
614+ )
615+ ) . attr ( 'disabled' , false ) ;
616+
617+ // Hide the row.
618+ $ (
619+ 'tr.additional-images' ,
620+ $ ( social_post_flow . status_form )
621+ ) . hide ( ) ;
622+ $ (
623+ 'tr.additional-images-limit' ,
624+ $ ( social_post_flow . status_form )
625+ ) . hide ( ) ;
626+ break ;
627+ }
628+ } ) ( jQuery ) ;
629+ }
630+
631+ function socialPostFlowUpdateAdditionalImagesLimitOption ( ) {
632+ ( function ( $ ) {
633+ // Hide Limit option.
634+ $ ( 'tr.additional-images-limit' , $ ( social_post_flow . status_form ) ) . hide ( ) ;
635+
636+ // Show Limit option if Additional Images has more than one option that is enabled
637+ // i.e. "None" and other option(s) enabled by socialPostFlowUpdateImageOptions().
638+ if (
639+ $ (
640+ 'option:enabled' ,
641+ $ ( 'select.additional-images' , $ ( social_post_flow . status_form ) )
642+ ) . length > 1
643+ ) {
644+ $ (
645+ 'tr.additional-images-limit' ,
646+ $ ( social_post_flow . status_form )
647+ ) . show ( ) ;
648+ }
576649 } ) ( jQuery ) ;
577650}
578651
@@ -611,6 +684,25 @@ function socialPostFlowUpdatePostTypeOptions(profile) {
611684 ) . attr ( 'disabled' , false ) ;
612685 break ;
613686
687+ case 'google' :
688+ $ (
689+ 'option[value="text"]' ,
690+ $ ( 'select.post_type' , $ ( social_post_flow . status_form ) )
691+ ) . attr ( 'disabled' , false ) ;
692+ $ (
693+ 'option[value="link"]' ,
694+ $ ( 'select.post_type' , $ ( social_post_flow . status_form ) )
695+ ) . attr ( 'disabled' , false ) ;
696+ $ (
697+ 'option[value="image"]' ,
698+ $ ( 'select.post_type' , $ ( social_post_flow . status_form ) )
699+ ) . attr ( 'disabled' , false ) ;
700+ $ (
701+ 'option[value="google"]' ,
702+ $ ( 'select.post_type' , $ ( social_post_flow . status_form ) )
703+ ) . attr ( 'disabled' , false ) ;
704+ break ;
705+
614706 default :
615707 $ (
616708 'option[value="text"]' ,
@@ -669,6 +761,7 @@ function socialPostFlowUpdateStatusSections() {
669761 break ;
670762
671763 case 'pin' :
764+ case 'google' :
672765 $ ( '.link' , $ ( social_post_flow . status_form ) ) . show ( ) ;
673766 $ ( '.images' , $ ( social_post_flow . status_form ) ) . show ( ) ;
674767 break ;
@@ -753,6 +846,9 @@ function socialPostFlowEditStatus(
753846 // Update image options.
754847 socialPostFlowUpdateImageOptions ( ) ;
755848
849+ // Update additional images limit option.
850+ socialPostFlowUpdateAdditionalImagesLimitOption ( ) ;
851+
756852 // Update status sections to display, depending on the status' post type.
757853 socialPostFlowUpdateStatusSections ( ) ;
758854
@@ -1793,6 +1889,8 @@ jQuery(document).ready(function ($) {
17931889 'select.post_type' ,
17941890 function ( ) {
17951891 socialPostFlowUpdateStatusSections ( ) ;
1892+ socialPostFlowUpdateImageOptions ( ) ;
1893+ socialPostFlowUpdateAdditionalImagesLimitOption ( ) ;
17961894 }
17971895 ) ;
17981896
@@ -1816,6 +1914,15 @@ jQuery(document).ready(function ($) {
18161914 }
18171915 ) ;
18181916
1917+ // Additional Images dropdown.
1918+ $ ( social_post_flow . status_form ) . on (
1919+ 'change.' + social_post_flow . status_form ,
1920+ 'select.additional-images' ,
1921+ function ( ) {
1922+ socialPostFlowUpdateAdditionalImagesLimitOption ( ) ;
1923+ }
1924+ ) ;
1925+
18191926 /**
18201927 * Enable/Disable Profile or Action
18211928 */
0 commit comments