<?php
/**
 * Created by mr2app.
 * User: Hani
 * Date: 4/24/2019
 * Time: 5:56 PM
 */
?>
<h3 class="background-color-e5e5e5 padding-7px">
    <?php _e('Default Setting', 'woo2app'); ?>
</h3>
<table class="form-table">
	<tr valign="top" class="" >
		<th scope="row" class="titledesc">
            <?php _e('Menu', 'woo2app'); ?>
		</th>
		<td class="forminp">
            <button type="button" class="button float-right margin-left-10px" onclick="reset('1','add_default_menu')">
                <?php _e('Set Default', 'woo2app'); ?>
			</button>
			<img class="img_25 hide" id="img_load1"  src="<?php echo WP_PLUGIN_URL."/".dirname( plugin_basename( __FILE__ ) ).'/../files/img/load.gif' ?>">
			<img class="img_25 hide" id="img_tick1"  src="<?php echo WP_PLUGIN_URL."/".dirname( plugin_basename( __FILE__ ) ).'/../files/img/checkmark.png' ?>">
		</td>
	</tr>
	<tr valign="top" class="" >
		<th scope="row" class="titledesc">
            <?php _e('Slider', 'woo2app'); ?>
		</th>
		<td>
            <button type="button" class="button float-right margin-left-10px" onclick="reset('2','add_default_slider')">
                <?php _e('Set Default', 'woo2app'); ?>
			</button>
			<img class="img_25 hide" id="img_load2"  src="<?php echo WP_PLUGIN_URL."/".dirname( plugin_basename( __FILE__ ) ).'/../files/img/load.gif' ?>">
			<img class="img_25 hide" id="img_tick2"  src="<?php echo WP_PLUGIN_URL."/".dirname( plugin_basename( __FILE__ ) ).'/../files/img/checkmark.png' ?>">
		</td>
	</tr>
	<tr valign="top" class="" >
		<th scope="row" class="titledesc">
            <?php _e('Home Page', 'woo2app'); ?>
		</th>
		<td>
            <button type="button" class="button float-right margin-left-10px"
                    onclick="reset('3','add_default_mainpage')">
                <?php _e('Set Default', 'woo2app'); ?>
			</button>
			<img class="img_25 hide" id="img_load3"  src="<?php echo WP_PLUGIN_URL."/".dirname( plugin_basename( __FILE__ ) ).'/../files/img/load.gif' ?>">
			<img class="img_25 hide" id="img_tick3"  src="<?php echo WP_PLUGIN_URL."/".dirname( plugin_basename( __FILE__ ) ).'/../files/img/checkmark.png' ?>">
		</td>
	</tr>
</table>
<script>
	function reset( id , func ) {
	    if(confirm("Are you sure? ")){
            jQuery("#img_tick"+id).removeClass("show");
            jQuery("#img_tick"+id).addClass("hide");
            jQuery("#img_load"+id).addClass("show");
            jQuery.ajax({
                url: ajaxurl,
                data: {
                    action: "set_default_setting",
                    param : func
                },
                success:function(data) {
                    console.log(data);
                    jQuery("#img_load"+id).removeClass("show");
                    jQuery("#img_load"+id).addClass("hide");
                    jQuery("#img_tick"+id).addClass("show");
                }
            });
	    }
    }
</script>
