<?xml version="1.0" encoding="UTF-8" standalone="no"?><addon xmlns="http://icplayer.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Heading" xsi:schemaLocation="http://icplayer.com ../../tools/addon.xsd">
    <model>
        <property name="Heading" nameLabel="Heading_property_heading" type="{h1, h2, h3, h4, h5, h6}"/>
        <property isDefault="true" isLocalized="true" name="Content" nameLabel="Heading_property_content" type="html"/>
        <property displayName="Lang attribute" name="langAttribute" nameLabel="Heading_property_lang_attribute" type="string"/>
        <property name="printable" nameLabel="printable_name_label" type="{No, Don't randomize, Randomize}"/>
        <property name="isSection" nameLabel="printable_is_section" type="boolean"/>
        <property name="isSplitInPrintBlocked" nameLabel="printable_block_split_label" type="boolean"/>
    </model>
<css/><view/><preview/><presenter>function AddonHeading_create () {

    function getErrorObject (ec) { return { isValid: false, errorCode: ec }; }

    var isVisibleByDefault = true;
    var isWCAGOn = false;
    var playerController = null;
    var printableController = null;
    var textParser = null;

    var presenter = function () {};

    presenter.ERROR_CODES = {
        C01: 'Property content cannot be empty.'
    };

    presenter.HEADINGS = {
        'h1': 'H1',
        'h2': 'H2',
        'h3': 'H3',
        'h4': 'H4',
        'h5': 'H5',
        'h6': 'H6',
        DEFAULT: 'h1'
    };

    presenter.run = function (view, model) {
        presenter.presenterLogic(view, model, false);
    };

    presenter.createPreview = function (view, model) {
        presenter.presenterLogic(view, model, true);
    };

    presenter.presenterLogic = function (view, model, isPreview) {
        presenter.$view = $(view);

        model = presenter.upgradeModel(model);
        presenter.configuration = presenter.validateModel(model);
        if (!presenter.configuration.isValid) {
            DOMOperationsUtils.showErrorMessage(view, presenter.ERROR_CODES, presenter.configuration.errorCode);
            return;
        }

        const headingString = '&lt;[tag]&gt;&lt;/[tag]]&gt;'.replace('[tag]', presenter.configuration.heading);
        const $heading = $(headingString);

        const parsedContent = textParser.parseAltTexts(presenter.configuration.content);
        $heading.html(parsedContent);

        if (presenter.configuration.isTabindexEnabled) {
            $heading.attr("tabindex", "0");
        }

        presenter.$view.append($heading);
    };

    presenter.upgradeModel = function (model) {
        return presenter.upgradeFrom_01(model);
    };

    presenter.upgradeFrom_01 = function (model) {
        var upgradedModel = {};
        $.extend(true, upgradedModel, model); // Deep copy of model object

        if (!upgradedModel["langAttribute"]) {
            upgradedModel["langAttribute"] = "";
        }

        return upgradedModel;
    };

    presenter.validateModel = function (model) {
        if (ModelValidationUtils.isStringEmpty(model.Content)) {
            return getErrorObject('C01');
        }

        return {
            heading: ModelValidationUtils.validateOption(presenter.HEADINGS, model['Heading']).toLowerCase(),
            content: model.Content,

            ID: model.ID,
            isValid: true,
            isVisible: ModelValidationUtils.validateBoolean(model['Is Visible']),
            isTabindexEnabled: ModelValidationUtils.validateBoolean(model['Is Tabindex Enabled']),
            langTag: model['langAttribute']
        };
    };

    presenter.executeCommand = function (name, params) {
        if (!presenter.configuration.isValid) {
            return;
        }

        isVisibleByDefault = presenter.configuration.isVisible;

        var commands = {
            'show': presenter.show,
            'hide': presenter.hide
        };

        Commands.dispatch(commands, name, params, presenter);
    };

    presenter.setVisibility = function (isVisible) {
        presenter.configuration.isVisible = isVisible;
        presenter.$view.css("visibility", isVisible ? "visible" : "hidden");
    };

    presenter.show = function () {
        presenter.setVisibility(true);
    };

    presenter.hide = function () {
        presenter.setVisibility(false);
    };

    presenter.reset = function () {
        presenter.setVisibility(isVisibleByDefault);
    };

    presenter.getState = function () {
        return JSON.stringify({
            isVisible: presenter.configuration.isVisible
        });
    };

    presenter.setState = function (state) {
        if (ModelValidationUtils.isStringEmpty(state)) return;

        var parsed = JSON.parse(state);
        var isVisible = parsed.isVisible;
        presenter.setVisibility(isVisible);
    };

    presenter.setPlayerController = function (controller) {
        playerController = controller;

        textParser = new TextParserProxy(controller.getTextParser());
    };

    presenter.setPreviewTextParser = function (getTextParser) {
        textParser = new TextParserProxy(getTextParser());
    };

    presenter.getTextToSpeechOrNull = function (playerController) {
        if (playerController) {
            return playerController.getModule('Text_To_Speech1');
        }

        return null;
    };

    presenter.setWCAGStatus = function (isOn) {
        isWCAGOn = isOn;
    };

    presenter.keyboardController = function(keyCode, isShift, event) {
        event.preventDefault();
        if (keyCode == window.KeyboardControllerKeys.ENTER || keyCode == window.KeyboardControllerKeys.SPACE) {
            presenter.readContent();
        }
    };

    function speak (data) {
        var tts = presenter.getTextToSpeechOrNull(playerController);

        if (tts &amp;&amp; isWCAGOn) {
            tts.speak(data);
        }
    }

    presenter.readContent = function() {
        var ttr = window.TTSUtils.getTextVoiceArrayFromElement(presenter.$view,presenter.configuration.langTag);
        speak(ttr);
    };

    presenter.isEnterable = function(){ return false;};

    presenter.setPrintableController = function (controller) {
        printableController = controller;
        textParser = new TextParserProxy(printableController.getTextParser());
    };

    presenter.getPrintableHTML = function (model, showAnswers) {
        var model = presenter.upgradeModel(model);
        var configuration = presenter.validateModel(model);

        var $root = $('&lt;div&gt;&lt;/div&gt;');
        $root.attr('id',configuration.ID);
        $root.addClass('printable_addon_Heading');
        $root.css("max-width", model["Width"]+"px");
        $root.css("min-height", model["Height"]+"px");

        var $heading = $('&lt;[tag]&gt;&lt;/[tag]]&gt;'.replace('[tag]', configuration.heading));
        var parsedContent = configuration.content;
        parsedContent = textParser.parseAltTexts(parsedContent);
        $heading.html(parsedContent);
        $root.append($heading);

        return $root[0].outerHTML;
    };

    return presenter;
}
</presenter></addon>