Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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
 * Helper module for manipulating the current page title
18
 *
19
 * @module      core/page_title
20
 * @copyright   2025 Paul Holden <paulh@moodle.com>
21
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
 
24
let pageTitleRoot = document.title;
25
let pageTitleSeparator = '|';
26
 
27
/**
28
 * Set the current page title
29
 *
30
 * @param {String} pageTitle
31
 */
32
export const setPageTitle = (pageTitle) => {
33
    document.title = pageTitle;
34
};
35
 
36
/**
37
 * Prepend value to the page title root, and set as the current page title
38
 *
39
 * @param {String} pageTitlePrepend
40
 */
41
export const prependPageTitle = (pageTitlePrepend) =>
42
    setPageTitle(`${pageTitlePrepend} ${pageTitleSeparator} ${pageTitleRoot}`);
43
 
44
/**
45
 * Set the page title root, to be used later when prepending to the title
46
 *
47
 * By default, the page title root is the document title
48
 *
49
 * @param {String} titleRoot
50
 */
51
export const setPageTitleRoot = (titleRoot) => {
52
    pageTitleRoot = titleRoot;
53
};
54
 
55
/**
56
 * Set the page title separator
57
 *
58
 * By default, the page title separator is the pipe character
59
 *
60
 * @param {String} titleSeparator
61
 */
62
export const setPageTitleSeparator = (titleSeparator) => {
63
    pageTitleSeparator = titleSeparator;
64
};