PageSourceSearch

https://www.mot.be/assets/blocks/imports/text/scripts/styles.js?etag=LygHa0Lrh2u

js mot.be collected 2026-10-02 10:52:03 UTC 3,872 bytes, 84 lines download raw bytes

1/*
2 * Copyright (c) 2024 Republic of Reinvention BV <[email protected]>. All Rights Reserved.
3 * This file is part of project "cinematek-filmout-site" and can not be copied and/or distributed without
4 * the express permission and written consent of the legal responsible of Republic of Reinvention BV.
5 */
6
7/**
8 * Created by bram on 8/13/15.
9 */
10
11base.plugin("blocks.core.TextStyles",
12    [
13        "blocks.imports.Commons",
14        "constants.blocks.imports.text",
15        "messages.blocks.imports.text",
16        "blocks.core.MediumEditor"
17    ],
18    function (ImportsCommons, TextConstants, TextMessages, MediumEditor)
19    {
20        // Styles is an array with objects
21        // object is of type {value:"", text""}
22        // value = "p:red" -> text before the colon is the tag, text after the colon are the classes that will be added
23        // nothing after colon will remove allm classes, nothing before colon will not touch the tag
24        // text is the text in the dropdown
25        //
26        // Example:
27        // [
28        //     {text: null, value: '<li class="dropdown-header">' + TextMessages.styles_sectionTitles + '</li>'},
29        //     {text: TextMessages.styles_h1, value: "h1:"},
30        //     {text: TextMessages.styles_h2, value: "h2:"},
31        //     {text: TextMessages.styles_h3, value: "h3:"},
32        //     {text: null, value: '<li role="separator" class="divider"></li>'},
33        //
34        //     {text: null, value: '<li class="dropdown-header">' + TextMessages.styles_sectionText + '</li>'},
35        //     {text: TextMessages.styles_p, value: "p:"},
36        //     {text: null, value: '<li role="separator" class="divider"></li>'},
37        // ]
38
39        //first, parse map to resolve the messages and so on...
40        var stylesArr = ImportsCommons.convertConstantToNameValueArray(TextConstants.STYLES_MAP_JSON_CONFIG);
41
42        //now extract (and group) the styles, based on the 'section' property
43        var stylePickerStyles = [];
44        var lastSection = null;
45        $.each(stylesArr, function (index, obj)
46        {
47            if (obj.section) {
48                if (obj.section !== lastSection) {
49                    if (lastSection != null) {
50                        stylePickerStyles.push({text: null, value: '<li role="separator" class="divider"></li>'});
51                    }
52                    stylePickerStyles.push({text: null, value: '<li class="dropdown-header">' + obj.section + '</li>'});
53                }
54
55                stylePickerStyles.push({text: obj.name, value: obj.value});
56                lastSection = obj.section;
57            }
58            else {
59                Logger.warn("Ignoring text style because it doesn't have a 'section' property set; ", obj);
60            }
61        });
62
63        //initialize with a default value if nothing was set explicitly
64        if (stylePickerStyles.length === 0) {
65            stylePickerStyles = [
66                {text: null, value: '<li class="dropdown-header">' + TextMessages.styles_sectionTitles + '</li>'},
67                {text: TextMessages.styles_h1, value: "h1:"},
68                {text: TextMessages.styles_h2, value: "h2:"},
69                {text: TextMessages.styles_h3, value: "h3:"},
70                {text: null, value: '<li role="separator" class="divider"></li>'},
71
72                {text: null, value: '<li class="dropdown-header">' + TextMessages.styles_sectionText + '</li>'},
73                {text: TextMessages.styles_p, value: "p:"},
74            ];
75        }
76
77        // it's maybe prettier to add a closing divider...
78        // Update 011123 no, not really
79        //stylePickerStyles.push({text: null, value: '<li role="separator" class="divider"></li>'});
80
81        // this is called on page load, so it kind of blindly installs the styles globally for all editors
82        MediumEditor.setStylePickerStyles(stylePickerStyles);
83    }
84);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.