( function( api ) {

	// Extends our custom "vw-event-planner" section.
	api.sectionConstructor['vw-event-planner'] = 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: 'vw_event_planner_reset_demo_import_settings' }, function () {
            location.reload();
        });
    }

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

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


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

	// Reset options
	$('.refresh-btn').on('click', function() {
		var dataValue = $(this).attr('data-value');
		$.get( vw_event_planner_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();
		}
	}
});