Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// This file is part of Moodle - http://moodle.org/
2
//
3
// Moodle is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// Moodle is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
/**
17
 * Tiny media plugin image helpers.
18
 *
19
 * @module      tiny_media/imagehelpers
20
 * @copyright   2024 Meirza <meirza.arson@moodle.com>
21
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
 
1441 ariadna 24
import * as Helpers from 'tiny_media/helpers';
25
import {Selectors} from './selectors';
1 efrain 26
 
27
/**
1441 ariadna 28
 * Maximum length allowed for the alt attribute.
29
 */
30
export const MAX_LENGTH_ALT = 750;
31
 
32
/**
1 efrain 33
 * Renders and inserts the body template for inserting an image into the modal.
34
 *
35
 * @param {object} templateContext - The context for rendering the template.
36
 * @param {HTMLElement} root - The root element where the template will be inserted.
37
 * @returns {Promise<void>}
1441 ariadna 38
 * @deprecated Since Moodle 5.0 See {@link module:core_editor/tiny/plugins/media/helpers.body}
1 efrain 39
 */
40
export const bodyImageInsert = async(templateContext, root) => {
1441 ariadna 41
    window.console.warn('This function is deprecated. Please use core_editor/tiny/plugins/media/helpers.body instead.');
42
 
43
    templateContext.bodyTemplate = 'tiny_media/insert_image_modal_insert';
44
    templateContext.selector = Selectors.IMAGE.type;
45
    return Helpers.body(templateContext, root);
1 efrain 46
};
47
 
48
/**
49
 * Renders and inserts the footer template for inserting an image into the modal.
50
 *
51
 * @param {object} templateContext - The context for rendering the template.
52
 * @param {HTMLElement} root - The root element where the template will be inserted.
53
 * @returns {Promise<void>}
1441 ariadna 54
 * @deprecated Since Moodle 5.0 See {@link module:core_editor/tiny/plugins/media/helpers.footer}
1 efrain 55
 */
56
export const footerImageInsert = async(templateContext, root) => {
1441 ariadna 57
    window.console.warn(`This function is deprecated.
58
        Please use core_editor/tiny/plugins/media/helpers.footer instead.`);
59
 
60
    templateContext.footerTemplate = 'tiny_media/insert_image_modal_insert_footer';
61
    templateContext.selector = Selectors.IMAGE.type;
62
    return Helpers.footer(templateContext, root);
1 efrain 63
};
64
 
65
/**
66
 * Renders and inserts the body template for displaying image details in the modal.
67
 *
68
 * @param {object} templateContext - The context for rendering the template.
69
 * @param {HTMLElement} root - The root element where the template will be inserted.
70
 * @returns {Promise<void>}
1441 ariadna 71
 * @deprecated Since Moodle 5.0 See {@link module:core_editor/tiny/plugins/media/helpers.body}
1 efrain 72
 */
73
export const bodyImageDetails = async(templateContext, root) => {
1441 ariadna 74
    window.console.warn(`This function is deprecated.
75
        Please use core_editor/tiny/plugins/media/helpers.body instead.`);
76
 
77
    templateContext.bodyTemplate = 'tiny_media/insert_image_modal_details';
78
    templateContext.selector = Selectors.IMAGE.type;
79
    return Helpers.body(templateContext, root);
1 efrain 80
};
81
 
82
/**
83
 * Renders and inserts the footer template for displaying image details in the modal.
84
 * @param {object} templateContext - The context for rendering the template.
85
 * @param {HTMLElement} root - The root element where the template will be inserted.
86
 * @returns {Promise<void>}
1441 ariadna 87
 * @deprecated Since Moodle 5.0 See {@link module:core_editor/tiny/plugins/media/helpers.footer}
1 efrain 88
 */
89
export const footerImageDetails = async(templateContext, root) => {
1441 ariadna 90
    window.console.warn(`This function is deprecated.
91
        Please use core_editor/tiny/plugins/media/helpers.footer instead.`);
92
 
93
    templateContext.footerTemplate = 'tiny_media/insert_image_modal_details_footer';
94
    templateContext.selector = Selectors.IMAGE.type;
95
    return Helpers.footer(templateContext, root);
1 efrain 96
};
97
 
98
/**
99
 * Show the element(s).
100
 *
101
 * @param {string|string[]} elements - The CSS selector for the elements to toggle.
102
 * @param {object} root - The CSS selector for the elements to toggle.
1441 ariadna 103
 * @deprecated Since Moodle 5.0 See {@link module:core_editor/tiny/plugins/media/helpers.showElements}
1 efrain 104
 */
105
export const showElements = (elements, root) => {
1441 ariadna 106
    window.console.warn(`This function is deprecated.
107
        Please use core_editor/tiny/plugins/media/helpers.showElements instead.`);
108
    Helpers.showElements(elements, root);
1 efrain 109
};
110
 
111
/**
112
 * Hide the element(s).
113
 *
114
 * @param {string|string[]} elements - The CSS selector for the elements to toggle.
115
 * @param {object} root - The CSS selector for the elements to toggle.
1441 ariadna 116
 * @deprecated Since Moodle 5.0 See {@link module:core_editor/tiny/plugins/media/helpers.hideElements}
1 efrain 117
 */
118
export const hideElements = (elements, root) => {
1441 ariadna 119
    window.console.warn(`This function is deprecated.
120
        Please use core_editor/tiny/plugins/media/helpers.hideElements instead.`);
121
    Helpers.hideElements(elements, root);
1 efrain 122
};
123
 
124
/**
125
 * Checks if the given value is a percentage value.
126
 *
127
 * @param {string} value - The value to check.
128
 * @returns {boolean} True if the value is a percentage value, false otherwise.
1441 ariadna 129
 * @deprecated Since Moodle 5.0 See {@link module:core_editor/tiny/plugins/media/helpers.isPercentageValue}
1 efrain 130
 */
131
export const isPercentageValue = (value) => {
1441 ariadna 132
    window.console.warn(`This function is deprecated.
133
        Please use core_editor/tiny/plugins/media/helpers.isPercentageValue instead.`);
134
    return Helpers.isPercentageValue(value);
1 efrain 135
};