'use strict';

jQuery( document ).ready(function( $ ) {
	$( 'body' ).on( 'check_dependencies', function() {
		set_redux_logos();
	});

	function set_redux_logos() {
		var $logo_normal_field    = $('#shrk_theme_options-site_logo');
		var $logo_transp_field    = $('#shrk_theme_options-transp_site_logo');
		var $logo_sidepanel_field = $('#shrk_theme_options-sidepanel_left_logo');

		$logo_normal_field.find('.screenshot .redux-option-image').attr('src', $logo_normal_field.find( 'input.upload').val() ); //[name="shrk_theme_options[site_logo][url]
		$logo_transp_field.find('.screenshot .redux-option-image').attr('src', $logo_transp_field.find( 'input.upload').val() );
		$logo_sidepanel_field.find('.screenshot .redux-option-image').attr('src', $logo_sidepanel_field.find( 'input.upload').val() );

		if ( $('#header_logo_max_width').length ) {
			$logo_normal_field.find('.screenshot .redux-option-image').css({ 'max-width': ($('#header_logo_max_width').val()+'px') });
		}

		if ( $('#header_logo_transp_max_width').length ) {
			$logo_transp_field.find('.screenshot .redux-option-image').css({ 'max-width': ($('#header_logo_transp_max_width').val()+'px') });
		}

		if ( $('#sidepanel_left_logo_max_width').length ) {
			$logo_sidepanel_field.find('.screenshot .redux-option-image').css({ 'max-width': ($('#sidepanel_left_logo_max_width').val()+'px') });
		}
	}
	set_redux_logos();
});