/*
** Scripts within the customizer controls window.
*/

(function( $ ) {
	wp.customize.bind( 'ready', function() {

	/*
	** Reusable Functions
	*/
		var optPrefix = '#customize-control-audio_player_options-';
		
		// Label
		function audio_player_customizer_label( id, title ) {

			// Site Identity

			if ( id === 'custom_logo' || id === 'site_icon' ) {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// General Setting

			if ( id === 'audio_player_scroll_hide' || id === 'audio_player_preloader_hide' || id === 'audio_player_sticky_header' || id === 'audio_player_products_per_row')  {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// Woocommerce product sale Setting

			if ( id === 'audio_player_woocommerce_product_sale' || id === 'audio_player_woo_product_border_radius') {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// Topbar Option

			if ( id === 'audio_player_topbar_register_button' )  {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// Colors

			if ( id === 'audio_player_theme_color' || id === 'background_color' || id === 'background_image' ) {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// Header Image

			if ( id === 'header_image' ) {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// Social Icon

			if ( id === 'audio_player_facebook_icon' || id === 'audio_player_twitter_icon' || id === 'audio_player_intagram_icon' || id === 'audio_player_linkedin_icon' || id === 'audio_player_pintrest_icon') {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			//  Header

			if ( id === 'audio_player_header_location_button' || id === 'audio_player_topbar_phone_text' ) {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}


			// Slider

			if ( id === 'audio_player_top_slider_setting' ) {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// Feature

			if ( id === 'audio_player_feature_long_heading'  ) {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// Footer

			if ( id === 'audio_player_show_hide_footer' || id === 'audio_player_show_hide_copyright') {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// Post Setting

			if ( id === 'audio_player_post_page_title' ) {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// Single Post Setting

			if ( id === 'audio_player_single_post_thumb' ) {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// Single Post Comment Setting

			if ( id === 'audio_player_single_post_comment_title' ) {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}

			// Page Setting

			if ( id === 'audio_player_single_page_title' ) {
				$( '#customize-control-'+ id ).before('<li class="tab-title customize-control">'+ title  +'</li>');
			} else {
				$( '#customize-control-audio_player_options-'+ id ).before('<li class="tab-title customize-control">'+ title +'</li>');
			}
			
		}


	/*
	** Tabs
	*/

		// General Setting
		audio_player_customizer_label( 'audio_player_preloader_hide', 'Preloader' );
		audio_player_customizer_label( 'audio_player_scroll_hide', 'Scroll To Top' );
		audio_player_customizer_label( 'audio_player_products_per_row', 'woocommerce Setting' );
		audio_player_customizer_label( 'audio_player_woocommerce_product_sale', 'Woocommerce Product Sale' );
		audio_player_customizer_label( 'audio_player_woo_product_border_radius', 'Woocommerce Product Border Radius' );

	    // Site Identity
		audio_player_customizer_label( 'custom_logo', 'Logo Setup' );
		audio_player_customizer_label( 'site_icon', 'Favicon' );

		// Topbar Option
		audio_player_customizer_label( 'audio_player_topbar_register_button', 'Register Button' );

		// Colors
		audio_player_customizer_label( 'audio_player_theme_color', 'Theme Color' );
		audio_player_customizer_label( 'background_color', 'Colors' );
		audio_player_customizer_label( 'background_image', 'Image' );

		//Header Image
		audio_player_customizer_label( 'header_image', 'Header Image' );

		// Social Icon 
		audio_player_customizer_label( 'audio_player_facebook_icon', 'Facebook' );
		audio_player_customizer_label( 'audio_player_twitter_icon', 'Twitter' );
		audio_player_customizer_label( 'audio_player_intagram_icon', 'Intagram' );
		audio_player_customizer_label( 'audio_player_linkedin_icon', 'Linkedin' );
		audio_player_customizer_label( 'audio_player_pintrest_icon', 'Pinterest' );

		// Header
		audio_player_customizer_label( 'audio_player_header_location_button', 'Location' );
		audio_player_customizer_label( 'audio_player_topbar_phone_text', 'Phone Number' );

		//Slider
		audio_player_customizer_label( 'audio_player_top_slider_setting', 'Slider' );
		
		// Feature
		audio_player_customizer_label( 'audio_player_feature_long_heading', 'Feature' );

		//Footer
		audio_player_customizer_label( 'audio_player_show_hide_footer', 'Footer' );
		audio_player_customizer_label( 'audio_player_show_hide_copyright', 'Copyright' );

		//Single Post Setting
		audio_player_customizer_label( 'audio_player_single_post_thumb', 'Single Post Setting' );
		audio_player_customizer_label( 'audio_player_single_post_comment_title', 'Single Post Comment' );

		// Post Setting
		audio_player_customizer_label( 'audio_player_post_page_title', 'Post Setting' );

		// Page Setting
		audio_player_customizer_label( 'audio_player_single_page_title', 'Page Setting' );
	

	}); // wp.customize ready

})( jQuery );
