( function( api ) {

	// Extends our custom "factory-lite" section.
	api.sectionConstructor['factory-lite'] = api.Section.extend( {

		// No events for this type of section.
		attachEvents: function () {},

		// Always make the section active.
		isContextuallyActive: function () {
			return true;
		}
	} );

} )( wp.customize );

// reset setting
(function ($) {
    function ResetDemoSettings() {
        if (!confirm("Are you sure you want to reset demo import settings?")) return;

        $.post(ajaxurl, { action: 'factory_lite_reset_demo_import_settings' }, function () {
            location.reload();
        });
    }

    // Remove any previous handlers and bind click
    $(document).off('click', '#factory-lite-reset-btn').on('click', '#factory-lite-reset-btn', function () {
        ResetDemoSettings();
    });

    window.ResetDemoSettings = ResetDemoSettings;
})(jQuery);


jQuery( document ).ready(function($) {
	var this_obj = factory_lite_customizer_params;
  	var api = wp.customize;

	// Reset options
	$('.refresh-btn').on('click', function() {
		var dataValue = $(this).attr('data-value');
		$.get( factory_lite_customizer_params.ajaxurl + '?action=' + dataValue, function( data ) {
	  		window.location.reload();
		});
	});

	$('.reset-button').on('click', function() {
		var $this = $(this);
		$this.closest('.customize-control').find('.kt-modal').show();
	});

	$('.close').on('click', function() {
		$(this).closest('.kt-modal').hide();
	});

	// When the user clicks anywhere outside of the modal, close it
	window.onclick = function(event) {
		if ($(event.target).hasClass('kt-modal')) {
		  $('.kt-modal').hide();
		}
	}
});