/* ------------------------------------------------------------------------------
* Author: DMCWebZone
* Author URL: https://web-zone.org
* Copyright © Airin Blog by DMCWebZone. All Rights Reserved.
* @package Airin Blog
* Description: Customizer panel
* ------------------------------------------------------------------------------ */


jQuery(document).ready(function($) {

	'use strict';

	//? ---------- Hiding minor settings when deactivating the main setting (fluently)

	// Custom width
	wp.customize('airinblog_cus_lay_max_width', function(control) {
	    control.bind(function(set) {
		  	if (set != 2) {
				$('#customize-control-airinblog_cus_lay_max_width_custom').hide(200);
			} else {
				$('#customize-control-airinblog_cus_lay_max_width_custom').show(150);
			}
	    });
	});

	// Ticker in top bar
	wp.customize('airinblog_cus_ticker', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_ticker_"], \
				[id^="customize-control-airinblog_cus_date"]').hide(200);
			} else if (set == 2) {
				$('[id^="customize-control-airinblog_cus_date"], \
				#customize-control-airinblog_cus_ticker_width, \
				#customize-control-airinblog_cus_ticker_color, \
				#customize-control-airinblog_cus_ticker_size, \
				#customize-control-airinblog_cus_ticker_up').show(150);
				$('[id^="customize-control-airinblog_cus_ticker_cat"], \
				[id^="customize-control-airinblog_cus_ticker_custom_"], \
				#customize-control-airinblog_cus_ticker_var, \
				#customize-control-airinblog_cus_ticker_speed, \
				#customize-control-airinblog_cus_ticker_infinite').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_ticker_"]').show(150);
				$('[id^="customize-control-airinblog_cus_date"]').hide(200);
				wp.customize('airinblog_cus_ticker_var', function(setting) {
					var set_chield = setting.get();
					if (set_chield == 1) {
						$('[id^="customize-control-airinblog_cus_ticker_custom_"]').hide(200);
					} else {
						$('[id^="customize-control-airinblog_cus_ticker_cat"]').hide(200);
					}
				});
			}
	    });
	});

	// Where to get the date
	wp.customize('airinblog_cus_date', function(control) {
		control.bind(function(set) {
			if (set == 2) {
				$('[id^="customize-control-airinblog_cus_date_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_date_"]').show(150);
			}
		});
	});

	// Ticker display option
	wp.customize('airinblog_cus_ticker_var', function(control) {
		control.bind(function(set) {
			if (set == 1) {
				$('[id^="customize-control-airinblog_cus_ticker_cat"]').show(150);
				$('[id^="customize-control-airinblog_cus_ticker_custom_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_ticker_custom_"]').show(150);
				$('[id^="customize-control-airinblog_cus_ticker_cat"]').hide(200);
			}
		});
	});


	// Top menu settings
	wp.customize('airinblog_cus_top_menu', function(control) {
	    control.bind(function(set) {
		  	if (set == 1) {
				$('[id^="customize-control-airinblog_cus_top_menu_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_top_menu_"]').show(150);
			}
	    });
	});

	// Logo option settings
	wp.customize('airinblog_cus_title_tagline_logo_var', function(control) {
	    control.bind(function(set) {
		  	if (set == 'fix') {
				$('#customize-control-custom_logo').show(150);
				$('#customize-control-airinblog_cus_supple_logo').hide(200);
			} else {
				$('#customize-control-airinblog_cus_supple_logo').show(150);
				$('#customize-control-custom_logo').hide(200);
			}
	    });
	});

	// Top banner
	wp.customize('airinblog_cus_banner', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_banner_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_banner_"]').show(150);
			}
	    });
	});

	// Social Links
	wp.customize('airinblog_cus_soc', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_soc_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_soc_"]').show(150);
			}
	    });
	});

	// Social link form
	wp.customize('airinblog_cus_soc_form', function(control) {
	    control.bind(function(set) {
		  	if (set == 'without-background') {
				$('#customize-control-airinblog_cus_soc_design_no_back').show(150);
				$('#customize-control-airinblog_cus_soc_design_back').hide(200);
			} else {
				$('#customize-control-airinblog_cus_soc_design_back').show(150);
				$('#customize-control-airinblog_cus_soc_design_no_back').hide(200);
			}
	    });
	});

	// Search
	wp.customize('airinblog_cus_search', function(control) {
	    control.bind(function(set) {
		  	if (set == 'off') {
				$('[id^="customize-control-airinblog_cus_search_"]').hide(200);
			} else if (set == 'top-bar') {
				$('#customize-control-airinblog_cus_search_size').show(150);
				$('#customize-control-airinblog_cus_search_soc').hide(200);
			} else {
				$('#customize-control-airinblog_cus_search_soc').show(150);
				wp.customize('airinblog_cus_search_soc', function(setting) {
					var set_chield = setting.get();
					var soc = wp.customize('airinblog_cus_soc').get();
					if (set_chield == 1 && soc == 1) {
						$('#customize-control-airinblog_cus_search_size').hide(200);
					} else {
						$('#customize-control-airinblog_cus_search_size').show(150);
					}
				});
			}
	    });
	});
	wp.customize('airinblog_cus_search_soc', function(control) {
		control.bind(function(set) {
			var soc = wp.customize('airinblog_cus_soc').get();
			if (set == 1 && soc == 1) {
				$('#customize-control-airinblog_cus_search_size').hide(200);
			} else {
				$('#customize-control-airinblog_cus_search_size').show(150);
			}
		});
	});

	// Main menu settings
	wp.customize('airinblog_cus_main_menu', function(control) {
	    control.bind(function(set) {
		  	if (set == 1) {
				$('[id^="customize-control-airinblog_cus_main_menu_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_main_menu_"]').show(150);
			}
	    });
	});

	// XL Mega menu settings
	wp.customize('airinblog_cus_xlmega_on', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_xlmega_set"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_xlmega_set"]').show(150);
			}
	    });
	});

	// "Read more" button in categories
	wp.customize('airinblog_cus_cat_style_more', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_cat_style_more_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_cat_style_more_"]').show(150);
			}
	    });
	});

	// Meta tags in categories
	wp.customize('airinblog_cus_cat_meta', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_cat_meta_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_cat_meta_"]').show(150);
			}
	    });
	});

	// Meta tags in posts
	wp.customize('airinblog_cus_post_meta', function(control) {
	    control.bind(function(conVal) {
		  	if (conVal == 0) {
				$('[id^="customize-control-airinblog_cus_post_meta_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_post_meta_"]').show(150);
			}
	    });
	});

	// Bulleted Lists
	wp.customize('airinblog_cus_post_li_mark', function(control) {
		control.bind(function(set) {
			if (set == 'v0') {
				$('#customize-control-airinblog_cus_post_li_mark_color').hide(200);
			} else {
				$('#customize-control-airinblog_cus_post_li_mark_color').show(150);
			}
		});
	});

	// Numbered Lists
	wp.customize('airinblog_cus_post_li_num', function(control) {
		control.bind(function(set) {
			if (set == 'v0') {
				$('[id^="customize-control-airinblog_cus_post_li_num_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_post_li_num_"]').show(150);
			}
		});
	});

	// Quote Blocks
	wp.customize('airinblog_cus_post_quote', function(control) {
	    control.bind(function(set) {
		  	if (set == 'v0') {
				$('[id^="customize-control-airinblog_cus_post_quote_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_post_quote_"]').show(150);
			}
	    });
	});

	// Icon for block quotes
	wp.customize('airinblog_cus_post_quote_icon', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_post_quote_icon_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_post_quote_icon_"]').show(150);
			}
	    });
	});

	// Titles H2
	wp.customize('airinblog_cus_post_h2', function(control) {
	    control.bind(function(set) {
		  	if (set == 'off') {
				$('[id^="customize-control-airinblog_cus_post_h2_"]').hide(200);
			} else if (set == 'v1' || set == 'v2') {
				$('[id^="customize-control-airinblog_cus_post_h2_"]').show(150);
				$('#customize-control-airinblog_cus_post_h2_icon_select, \
				#customize-control-airinblog_cus_post_h2_count_text, \
				#customize-control-airinblog_cus_post_h2_tag, \
				#customize-control-airinblog_cus_post_h2_icon_text_color').hide();
			} else if (set == 'v3') {
				$('[id^="customize-control-airinblog_cus_post_h2_"]').show(150);
				$('#customize-control-airinblog_cus_post_h2_icon_select, \
				#customize-control-airinblog_cus_post_h2_tag').hide();
			} else if (set == 'v4') {
				$('[id^="customize-control-airinblog_cus_post_h2_"]').show(150);
				$('#customize-control-airinblog_cus_post_h2_count_text, \
				#customize-control-airinblog_cus_post_h2_tag').hide();
			} else if (set == 'v5') {
				$('[id^="customize-control-airinblog_cus_post_h2_"]').show(150);
				$('#customize-control-airinblog_cus_post_h2_icon_select, \
				#customize-control-airinblog_cus_post_h2_count_text').hide();
			} else {
				$('[id^="customize-control-airinblog_cus_post_h2_"]').show(150);
				$('#customize-control-airinblog_cus_post_h2_icon_select, \
				#customize-control-airinblog_cus_post_h2_count_text, \
				#customize-control-airinblog_cus_post_h2_tag, \
				#customize-control-airinblog_cus_post_h2_icon_text_color, \
				#customize-control-airinblog_cus_post_h2_element_color').hide();
			}
	    });
	});

	// Titles H3 - H6
	wp.customize('airinblog_cus_post_h36', function(control) {
	    control.bind(function(set) {
		  	if (set == 'off') {
				$('[id^="customize-control-airinblog_cus_post_h36_"]').hide(200);
			} else if (set == 'v1' || set == 'v2') {
				$('[id^="customize-control-airinblog_cus_post_h36_"]').show(150);
				$('#customize-control-airinblog_cus_post_h36_icon_select, \
				#customize-control-airinblog_cus_post_h36_count_text, \
				#customize-control-airinblog_cus_post_h36_tag, \
				#customize-control-airinblog_cus_post_h36_icon_text_color').hide();
			} else if (set == 'v3') {
				$('[id^="customize-control-airinblog_cus_post_h36_"]').show(150);
				$('#customize-control-airinblog_cus_post_h36_icon_select, \
				#customize-control-airinblog_cus_post_h36_tag').hide();
			} else if (set == 'v4') {
				$('[id^="customize-control-airinblog_cus_post_h36_"]').show(150);
				$('#customize-control-airinblog_cus_post_h36_count_text, \
				#customize-control-airinblog_cus_post_h36_tag').hide();
			} else if (set == 'v5') {
				$('[id^="customize-control-airinblog_cus_post_h36_"]').show(150);
				$('#customize-control-airinblog_cus_post_h36_icon_select, \
				#customize-control-airinblog_cus_post_h36_count_text').hide();
			} else {
				$('[id^="customize-control-airinblog_cus_post_h36_"]').show(150);
				$('#customize-control-airinblog_cus_post_h36_icon_select, \
				#customize-control-airinblog_cus_post_h36_count_text, \
				#customize-control-airinblog_cus_post_h36_tag, \
				#customize-control-airinblog_cus_post_h36_icon_text_color, \
				#customize-control-airinblog_cus_post_h36_element_color').hide();
			}
	    });
	});

	// Author block
	wp.customize('airinblog_cus_post_bio', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id*="_cus_post_bio_"]').hide(200);
			} else {
				$('[id*="_cus_post_bio_"]').show(150);
			}
	    });
	});

	// Author block separator variation
	wp.customize('airinblog_cus_post_bio_design', function(control) {
	    control.bind(function(set) {
		  	if (set == 'v0' || set == 'v1' || set == 'v2') {
				$('[id^="customize-control-airinblog_cus_post_bio_design_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_post_bio_design_"]').show(150);
			}
	    });
	});

	// Author's latest posts in the author's block
	wp.customize('airinblog_cus_post_bio_related', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_post_bio_related_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_post_bio_related_"]').show(150);
			}
	    });
	});

	// Similar posts
	wp.customize('airinblog_cus_post_related', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_post_related_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_post_related_"]').show(150);
			}
	    });
	});

	

	// Enable Recent Posts Section on Homepage
	wp.customize('airinblog_cus_home_article_block', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_home_article_block_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_home_article_block_"]').show(150);
			}
	    });
	});

	

	// Activate Link "Home" in bread crumbs
	wp.customize('airinblog_cus_bread_main', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('#customize-control-airinblog_cus_bread_main_text').hide(200);
			} else {
				$('#customize-control-airinblog_cus_bread_main_text').show(150);
			}
	    });
	});

	// Fluently movement of blocks
	wp.customize('airinblog_cus_flow_block', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_flow_block_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_flow_block_"]').show(150);
			}
	    });
	});

	// Categories on the site map
	wp.customize('airinblog_cus_sitemap_cat', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_sitemap_cat_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_sitemap_cat_"]').show(150);
			}
	    });
	});

	// Posts on the site map
	wp.customize('airinblog_cus_sitemap_post', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_sitemap_post_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_sitemap_post_"]').show(150);
			}
	    });
	});

	// Pages on the site map
	wp.customize('airinblog_cus_sitemap_page', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_sitemap_page_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_sitemap_page_"]').show(150);
			}
	    });
	});

	// Up button
	wp.customize('airinblog_cus_top_scroll', function(control) {
	    control.bind(function(set) {
		  	if (set == 1) {
				$('[id^="customize-control-airinblog_cus_top_scroll_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_top_scroll_"]').show(150);
			}
	    });
	});

	

	// Underline titles of all classic widgets
	wp.customize('airinblog_cus_widget_sidebar_h_border', function(control) {
	    control.bind(function(set) {
		  	if (set == 'v0') {
				$('#customize-control-airinblog_cus_widget_sidebar_h_border_size').hide(200);
			} else {
				$('#customize-control-airinblog_cus_widget_sidebar_h_border_size').show(150);
			}
	    });
	});

	

	// Bottom part
	wp.customize('airinblog_cus_footer', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_footer_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_footer_"]').show(150);
			}
	    });
	});

	// Lower menu
	wp.customize('airinblog_cus_footer_menu', function(control) {
	    control.bind(function(set) {
		  	if (set == 0) {
				$('[id^="customize-control-airinblog_cus_footer_menu_"]').hide(200);
			} else {
				$('[id^="customize-control-airinblog_cus_footer_menu_"]').show(150);
			}
	    });
	});

	

});
