/**
 * tff-customizer-icons-control.js
 *
 * @package MatrixAddons
 * @subpackage DgLib
 * @version 1.0.0
 * @since 1.0.0
 *
 * Contains handlers to make Theme Customizer image options
 */
 ( function( $, customize ) {
    'use strict';
    var trainify_framework_document = $(document);
    var trainify_framework_window = $(window);
    var IMAGE_OPTION_CONTROL = {
        Snipits: {
            ImageOptions: function(){
                var wrapper_obj = $(this).closest('.tff-imageoption-wrapper');
                var settings_object = wrapper_obj.find('.trainify-framework-imageoption-checkbox');
                var settings_value_obj = wrapper_obj.find('.trainify-framework-imageoption-value');
                var value_data = [];
                settings_object.each(function(){
                    if($(this).is(':checked')){
                        value_data.push($(this).val());     
                    }
                });
                var value_json = JSON.stringify(value_data);
                settings_value_obj.val(value_json);
                settings_value_obj.trigger('change');
            },
        },

        Events: function(){
            var __this = IMAGE_OPTION_CONTROL;
            var snipits = __this.Snipits;
            var imageoptions = snipits.ImageOptions;
            trainify_framework_document.on('change', '.tff-imageoption-wrapper .trainify-framework-imageoption-checkbox', imageoptions);
        },

        Ready: function(){
            var __this = IMAGE_OPTION_CONTROL;
            var snipits = __this.Snipits;
            __this.Events();
        },

        Load: function(){
        },

        Resize: function(){
        },

        Scroll: function(){
        },

        Init: function(){
            var __this = IMAGE_OPTION_CONTROL;
            var load, ready, resize, scroll;
            ready = __this.Ready;
            load = __this.Load;
            resize = __this.Resize;
            scroll = __this.Scroll;
            trainify_framework_document.ready(ready);
            /*trainify_framework_window.load(load);
            trainify_framework_window.resize(resize);
            trainify_framework_window.scroll(scroll);*/

        },
    };
    IMAGE_OPTION_CONTROL.Init();
 } )( jQuery, wp.customize );
