<?php
/**
 * Webkul Software.
 *
 * @category  Webkul
 * @package   Webkul_Agorae
 * @author    Webkul
 * @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html
 */

/**
 * Agorae sliderimages js Admin Template
 */
$AgoraeViewModel = $block->getAgoraeViewModel();
$helper = $AgoraeViewModel->gethelper();
$allowedExtensions = $helper->getAllowedExtensions(true);
?>
<script>
    require([
        'jquery',
        'mage/adminhtml/grid',
        'prototype'
    ], function(jQuery) {
        jQuery(document).ready(function() {
            var allowedExtensions = [<?=  /* @noEscape */ implode(",", $allowedExtensions); ?>];
            if (jQuery(".delete-image").length) {
                // jQuery(".delete-image").remove();
            } else {
                // jQuery("#sliderimages_image").addClass("required-entry");
            }
            jQuery("#sliderimages_filename").on("change", function(){
                var fileName = jQuery(this).val();
                var ext = fileName.split('.').pop().toLowerCase();
                if(jQuery.inArray(ext, allowedExtensions) == -1) {
                    alert('Image type not allowed!');
                    jQuery(this).val('');
                }
            });
        });
    });
</script>