{{!
    This file is part of Moodle - https://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template file/atto/lib

    Atto plugin lib.php file.

    Context variables required for this template:
    * component
    * copyright

    Example context (json):
    {
        "component": "local_test",
        "copyright": "2021 David Mudrák <david@moodle.com>"
    }
}}
{{< common/lib }}
{{/ common/lib }}
{{# self.has_strings_for_js }}

/**
 * Initializes the js strings required for this module.
 *
 * This allows the plugin to initialize the strings that it will use in its user interface.
 * The plugin name is loaded automatically.
 */
function {{ component }}_strings_for_js() {
    global $PAGE;

    $PAGE->requires_strings_for_js(array(
        {{# atto_features.strings_for_js }}
        '{{ .id }}',
        {{/ atto_features.strings_for_js }}
    ));
}
{{/ self.has_strings_for_js }}
{{# self.has_params_for_js }}

/**
 * Returns the javascript parameters required for this module.
 *
 * These parameters are passed to the javascript init function for {{ component_name }}.
 *
 * @param string $elementid The id of the element.
 * @param stdClass $options The options for the editor, including the context.
 * @param stdClass $foptions.
 * @return array().
 */
function {{ component }}_params_for_js($elementid, $options, $foptions) {
    return array(
        {{# atto_features.params_for_js }}
        '{{ .name }}' => '{{ .value }}',
        {{/ atto_features.params_for_js }}
    );
}
{{/ self.has_params_for_js }}
