<?xml version="1.0" encoding="UTF-8"?>
<root>
    <default>
        <includes>
            <!--
                Path to css and js files into plugins folder.
                If your files are not in plugins folder, use absolute paths.
            -->
            <css>
                <file>icheck/skins/%theme%/%color%.min.css</file>
            </css>
            <js>
                <file>icheck/icheck.min.js</file>
            </js>
        </includes>
        <js_code><![CDATA[   if ($('form.bulma-form')[0] || $('form.foundation-form')[0]) {
        $("%selector%").each(function() {
            if ($(this).is(':radio') || $(this).is(':checkbox')) {
                if ($('form.bulma-form')[0]) {
                $(this).parent().parent().prepend($(this));
                }
                $(this).parent().parent().addClass('has-icheck');
            }
        });
    }
    $("%selector%").icheck({
        checkboxClass: 'icheckbox_%theme%-%color%',
        radioClass: 'iradio_%theme%-%color%',
        increaseArea: '20%' // optional
    });
    $("%selector%").on("ifChanged", function(e) {
        var formId = $(this).closest('form').attr('id');
        var form   = forms[formId];
        if (typeof(form.fv) == 'object' && this.name in form.fv.elements) {
            form.fv.revalidateField(this.name);
        }
    });
    // bs4 invalid feedback
    if ($('.invalid-feedback')[0] && $('.invalid-feedback').closest('.form-group')[0]) {
        $('.invalid-feedback').closest('.form-group').addClass('has-error');
    }]]>
        </js_code>
    </default>
    <theme>
        <!-- futurico and polaris theme -->
        <includes>
            <css>
                <file>icheck/skins/%theme%/%theme%.min.css</file>
            </css>
        </includes>
        <js_code><![CDATA[   if ($('form.bulma-form')[0] || $('form.foundation-form')[0]) {
        $("%selector%").each(function() {
            if ($(this).is(':radio') || $(this).is(':checkbox')) {
                if ($('form.bulma-form')[0]) {
                $(this).parent().parent().prepend($(this));
                }
                $(this).parent().parent().addClass('has-icheck');
            }
        });
    }
    $("%selector%").icheck({
        checkboxClass: 'icheckbox_%theme%',
        radioClass: 'iradio_%theme%'
        // increaseArea: '20%' // optional
    });
    $("%selector%").on("ifChanged", function() {
        var formId = $(this).closest('form').attr('id');
        var form   = forms[formId];
        if (typeof(form.fv) == 'object' && this.name in form.fv.elements) {
            form.fv.revalidateField(this.name);
        }
    });
    if ($('.invalid-feedback')[0] && $('.invalid-feedback').closest('.form-group')[0]) {
        $('.invalid-feedback').closest('.form-group').addClass('has-error');
    }]]>
        </js_code>
    </theme>
    <line>
        <!-- line theme
            IMPORTANT:
            set Form wrapCheckboxesIntoLabels and wrapRadiobtnsIntoLabels options to false if you use line theme
        -->
        <includes>
            <css>
                <file>icheck/skins/line/%color%.min.css</file>
            </css>
            <js>
                <file>icheck/icheck.min.js</file>
            </js>
        </includes>
        <js_code><![CDATA[   if ($('form.bulma-form')[0] || $('form.foundation-form')[0]) {
        $("%selector%").each(function() {
            if ($(this).is(':radio') || $(this).is(':checkbox')) {
                if ($('form.bulma-form')[0]) {
                $(this).parent().parent().prepend($(this));
                }
                $(this).parent().parent().addClass('has-icheck');
            }
        });
    }
    $("%selector%").each(function(){
        var self = $(this),
            label = self.next(),
            label_text = label.text();

        label.remove();
        self.icheck({
            checkboxClass: 'icheckbox_line-%color%',
            radioClass: 'iradio_line-%color%',
            insert: '<div class="icheck_line-icon"></div>' + label_text
        });
    });
    $("%selector%").on("ifChanged", function() {
        var formId = $(this).closest('form').attr('id');
        var form   = forms[formId];
        if (typeof(form.fv) == 'object' && this.name in form.fv.elements) {
            form.fv.revalidateField(this.name);
        }
    });
    if ($('.invalid-feedback')[0] && $('.invalid-feedback').closest('.form-group')[0]) {
        $('.invalid-feedback').closest('.form-group').addClass('has-error');
    }]]>
        </js_code>
    </line>
</root>
