var CF = CF || {};
CF.CFEContextHelp = function() {
    var init = function() {
        $(document).on('click','.CFE-context-help',function() {

            var $element = $(this);
            var key = $element.attr('data-key') || null;
            var heading = $element.attr('data-title') || 'Help';
            if (key)
            {
                    var $modal = $('<div class="modal  hide" id="context-help-modal" tabindex="-1">'+
                        '<div class="modal-header">'+
                            '<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="bi bi-x"></i></button>'+
                            '<h2>'+heading+'</h2>'+
                        '</div>'+
                        '<div class="modal-body"></div>'+
                        '<div class="modal-footer"><button type="button" class="btn btn-large btn-primary" data-dismiss="modal" aria-hidden="true">Ok</button></div>'+
                        '</div>');
                var options = {
                    'remote':MP_SITE_URL+'/context_help/show/'+key
                };
                $modal.modal(options);

                // remove modal from DOM on close
                $modal.on('hidden', function () {
                    $modal.remove();
                });
            }
        });
    }
    return {
        init:init
    }
}();

export default CF;
