{*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <contact@prestashop.com>
*  @copyright  2007-2017 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
<script type="text/javascript">
    var clearCacheTxt = '{$clearCacheTxt|escape:'quotes':'UTF-8'}';
    var clearCacheAlertTxt = '{$clearCacheAlertTxt|escape:'quotes':'UTF-8'}';
    var clearCacheLink = '{$clearCacheLink|escape:'quotes':'UTF-8'}';
    {literal}
        $(document).ready(function(){
            if($('input[name="YBC_BLOCKSEARCH_CACHE"]').parents('.col-lg-9').length > 0)
            {
                $('input[name="YBC_BLOCKSEARCH_CACHE"]').parents('.col-lg-9').eq(0).append('<br/><span style="display: none; color: #2eacce; font-style: italic; cursor: pointer;" id="ybc_search_clear_cache">'+clearCacheTxt+'</span><div id="ybc_search_clear_cache_alert" class="alert alert-success" style="display: none;">'+clearCacheAlertTxt+'</div>');
                if(parseInt($('input[name="YBC_BLOCKSEARCH_CACHE"]:checked').val()) == 1)
                    $('#ybc_search_clear_cache').show();
                else
                    $('#ybc_search_clear_cache').hide();
                $(document).on('change','input[name="YBC_BLOCKSEARCH_CACHE"]',function(){                    
                    if(parseInt($(this).val())==1)
                        $('#ybc_search_clear_cache').show();
                    else
                        $('#ybc_search_clear_cache').hide();
                });
                $(document).on('click','#ybc_search_clear_cache',function(){
                    if(!$(this).hasClass('active'))
                    {
                        $(this).addClass('active');
                        $(this).css('opacity','0.3');
                        $.ajax({
                            url: clearCacheLink,
                            type: 'post',
                            dataType: 'json',
                            success: function(json)
                            {
                                $('#ybc_search_clear_cache').removeClass('active');
                                $('#ybc_search_clear_cache').css('opacity','1');
                                $('#ybc_search_clear_cache_alert').fadeIn().delay(5000).fadeOut();
                            },
                            error: function(json)
                            {
                                $('#ybc_search_clear_cache').removeClass('active');
                                $('#ybc_search_clear_cache').css('opacity','1');
                            }
                        });
                    }
                    return false;
                });
            }            
        });
    {/literal}
</script>