metabox.js
202 lines
| 1 | ( function( $ ) { |
| 2 | "use strict"; |
| 3 | |
| 4 | $( function() { |
| 5 | |
| 6 | // Show/hide both sidebars options |
| 7 | var bothSidebarsField = $( '#butterbean-control-ocean_post_layout select' ), |
| 8 | bothSidebarsFieldVal = bothSidebarsField.val(), |
| 9 | bothSidebarsSetting = $( '#butterbean-control-ocean_both_sidebars_style, #butterbean-control-ocean_both_sidebars_content_width, #butterbean-control-ocean_both_sidebars_sidebars_width, #butterbean-control-ocean_second_sidebar' ); |
| 10 | |
| 11 | bothSidebarsSetting.hide(); |
| 12 | |
| 13 | if ( bothSidebarsFieldVal === 'both-sidebars' ) { |
| 14 | bothSidebarsSetting.show(); |
| 15 | } |
| 16 | |
| 17 | bothSidebarsField.change( function () { |
| 18 | |
| 19 | bothSidebarsSetting.hide(); |
| 20 | |
| 21 | if ( $( this ).val() == 'both-sidebars' ) { |
| 22 | bothSidebarsSetting.show(); |
| 23 | } |
| 24 | |
| 25 | } ); |
| 26 | |
| 27 | // Show/hide header options |
| 28 | var headerField = $( '#butterbean-control-ocean_display_header .buttonset-input' ), |
| 29 | headerMainSettings = $( '#butterbean-control-ocean_header_style' ); |
| 30 | |
| 31 | if ( $( '#butterbean-control-ocean_display_header #butterbean_oceanwp_mb_settings_setting_ocean_display_header_off' ).is( ':checked' ) ) { |
| 32 | headerMainSettings.hide(); |
| 33 | } else { |
| 34 | headerMainSettings.show(); |
| 35 | } |
| 36 | |
| 37 | headerField.change( function () { |
| 38 | |
| 39 | if ( $( this ).val() === 'off' ) { |
| 40 | headerMainSettings.hide(); |
| 41 | } else { |
| 42 | headerMainSettings.show(); |
| 43 | } |
| 44 | |
| 45 | } ); |
| 46 | |
| 47 | // Show/hide custom header template field |
| 48 | var headerStyleField = $( '#butterbean-control-ocean_header_style select' ), |
| 49 | headerStyleFieldVal = headerStyleField.val(), |
| 50 | customHeaderSetting = $( '#butterbean-control-ocean_custom_header_template' ); |
| 51 | |
| 52 | customHeaderSetting.hide(); |
| 53 | |
| 54 | if ( headerStyleFieldVal === 'custom' ) { |
| 55 | customHeaderSetting.show(); |
| 56 | } |
| 57 | |
| 58 | if ( $( '#butterbean-control-ocean_display_header #butterbean_oceanwp_mb_settings_setting_ocean_display_header_off' ).is( ':checked' ) ) { |
| 59 | customHeaderSetting.hide(); |
| 60 | } |
| 61 | |
| 62 | headerField.change( function () { |
| 63 | |
| 64 | if ( $( this ).val() === 'off' ) { |
| 65 | customHeaderSetting.hide(); |
| 66 | } else { |
| 67 | var headerStyleFieldVal = headerStyleField.val(); |
| 68 | |
| 69 | if ( headerStyleFieldVal === 'custom' ) { |
| 70 | customHeaderSetting.show(); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | } ); |
| 75 | |
| 76 | headerStyleField.change( function () { |
| 77 | |
| 78 | customHeaderSetting.hide(); |
| 79 | |
| 80 | if ( $( this ).val() == 'custom' ) { |
| 81 | customHeaderSetting.show(); |
| 82 | } |
| 83 | |
| 84 | } ); |
| 85 | |
| 86 | // Show/hide left menu for center header style |
| 87 | var leftMenuSetting = $( '#butterbean-control-ocean_center_header_left_menu' ); |
| 88 | |
| 89 | leftMenuSetting.hide(); |
| 90 | |
| 91 | if ( headerStyleFieldVal === 'center' ) { |
| 92 | leftMenuSetting.show(); |
| 93 | } |
| 94 | |
| 95 | if ( $( '#butterbean-control-ocean_display_header #butterbean_oceanwp_mb_settings_setting_ocean_display_header_off' ).is( ':checked' ) ) { |
| 96 | leftMenuSetting.hide(); |
| 97 | } |
| 98 | |
| 99 | headerField.change( function () { |
| 100 | |
| 101 | if ( $( this ).val() === 'off' ) { |
| 102 | leftMenuSetting.hide(); |
| 103 | } else { |
| 104 | var headerStyleFieldVal = headerStyleField.val(); |
| 105 | |
| 106 | if ( headerStyleFieldVal === 'center' ) { |
| 107 | leftMenuSetting.show(); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | } ); |
| 112 | |
| 113 | headerStyleField.change( function () { |
| 114 | |
| 115 | leftMenuSetting.hide(); |
| 116 | |
| 117 | if ( $( this ).val() == 'center' ) { |
| 118 | leftMenuSetting.show(); |
| 119 | } |
| 120 | |
| 121 | } ); |
| 122 | |
| 123 | // Show/hide title options |
| 124 | var titleField = $( '#butterbean-control-ocean_disable_title .buttonset-input' ), |
| 125 | titleMainSettings = $( '#butterbean-control-ocean_disable_heading, #butterbean-control-ocean_post_title, #butterbean-control-ocean_post_subheading, #butterbean-control-ocean_post_title_style' ), |
| 126 | titleStyleField = $( '#butterbean-control-ocean_post_title_style select' ), |
| 127 | titleStyleFieldVal = titleStyleField.val(), |
| 128 | pageTitleBgSettings = $( '#butterbean-control-ocean_post_title_background, #butterbean-control-ocean_post_title_bg_image_position, #butterbean-control-ocean_post_title_bg_image_attachment, #butterbean-control-ocean_post_title_bg_image_repeat, #butterbean-control-ocean_post_title_bg_image_size, #butterbean-control-ocean_post_title_height, #butterbean-control-ocean_post_title_bg_overlay, #butterbean-control-ocean_post_title_bg_overlay_color' ), |
| 129 | solidColorElements = $( '#butterbean-control-ocean_post_title_background_color' ); |
| 130 | |
| 131 | pageTitleBgSettings.hide(); |
| 132 | solidColorElements.hide(); |
| 133 | |
| 134 | if ( titleStyleFieldVal === 'background-image' ) { |
| 135 | pageTitleBgSettings.show(); |
| 136 | } else if ( titleStyleFieldVal === 'solid-color' ) { |
| 137 | solidColorElements.show(); |
| 138 | } |
| 139 | |
| 140 | if ( $( '#butterbean-control-ocean_disable_title #butterbean_oceanwp_mb_settings_setting_ocean_disable_title_on' ).is( ':checked' ) ) { |
| 141 | titleMainSettings.hide(); |
| 142 | pageTitleBgSettings.hide(); |
| 143 | solidColorElements.hide(); |
| 144 | } else { |
| 145 | titleMainSettings.show(); |
| 146 | } |
| 147 | |
| 148 | titleField.change( function () { |
| 149 | |
| 150 | if ( $( this ).val() === 'on' ) { |
| 151 | titleMainSettings.hide(); |
| 152 | pageTitleBgSettings.hide(); |
| 153 | solidColorElements.hide(); |
| 154 | } else { |
| 155 | titleMainSettings.show(); |
| 156 | var titleStyleFieldVal = titleStyleField.val(); |
| 157 | |
| 158 | if ( titleStyleFieldVal === 'background-image' ) { |
| 159 | pageTitleBgSettings.show(); |
| 160 | } else if ( titleStyleFieldVal === 'solid-color' ) { |
| 161 | solidColorElements.show(); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | } ); |
| 166 | |
| 167 | titleStyleField.change( function () { |
| 168 | |
| 169 | pageTitleBgSettings.hide(); |
| 170 | solidColorElements.hide(); |
| 171 | |
| 172 | if ( $( this ).val() == 'background-image' ) { |
| 173 | pageTitleBgSettings.show(); |
| 174 | } else if ( $( this ).val() === 'solid-color' ) { |
| 175 | solidColorElements.show(); |
| 176 | } |
| 177 | |
| 178 | } ); |
| 179 | |
| 180 | // Show/hide breadcrumbs options |
| 181 | var breadcrumbsField = $( '#butterbean-control-ocean_disable_breadcrumbs .buttonset-input' ), |
| 182 | breadcrumbsSettings = $( '#butterbean-control-ocean_breadcrumbs_color, #butterbean-control-ocean_breadcrumbs_separator_color, #butterbean-control-ocean_breadcrumbs_links_color, #butterbean-control-ocean_breadcrumbs_links_hover_color' ); |
| 183 | |
| 184 | if ( $( '#butterbean-control-ocean_disable_breadcrumbs #butterbean_oceanwp_mb_settings_setting_ocean_disable_breadcrumbs_off' ).is( ':checked' ) ) { |
| 185 | breadcrumbsSettings.hide(); |
| 186 | } else { |
| 187 | breadcrumbsSettings.show(); |
| 188 | } |
| 189 | |
| 190 | breadcrumbsField.change( function () { |
| 191 | |
| 192 | if ( $( this ).val() === 'off' ) { |
| 193 | breadcrumbsSettings.hide(); |
| 194 | } else { |
| 195 | breadcrumbsSettings.show(); |
| 196 | } |
| 197 | |
| 198 | } ); |
| 199 | |
| 200 | } ); |
| 201 | |
| 202 | } ) ( jQuery ); |