"use strict";
(function ($) {
    $.field_bookingstyle = function (element, options) {
        var defaults = {
            input_name:'',
            value:''
        }
        var plugin = this;
        plugin.settings = {}
        var $element = $(element), 
            element = element;    
        
        plugin.init = function () {
            plugin.settings = $.extend({}, defaults, options);
            let value = plugin.settings.value;
            $element.find(`input[name="${plugin.settings.input_name}"]`).val(value);
            $element.find('.list-bookingstyle').select2();
            $element.find('.list-bookingstyle').on('change', function (e) {
                let val = $(this).val();
                $element.find(`input[name="${plugin.settings.input_name}"]`).val(val);
            });

        };
        plugin.example_function = function () {
        };
        plugin.init();
    }
    
    $.fn.field_bookingstyle = function (options) {
        
        return this.each(function () {
            
            if (undefined == $(this).data('field_bookingstyle')) {
                var plugin = new $.field_bookingstyle(this, options);
                $(this).data('field_bookingstyle', plugin);
            }
        });
    }
})(jQuery);