PageSourceSearch

https://staatstheater-hannover.de/media/scripts/cb_flex_editor.js

js staatstheater-hannover.de collected 2026-09-24 09:42:49 UTC 5,605 bytes, 137 lines download raw bytes

1$(document).ready(function () {
2
3    var editorIsOpen = false;
4    function handleMessage(event) {
5        console.log("Received a message from " + event.origin + ".");
6
7        // When one window sends a message, or data, to another window via
8        // `parent.postMessage()`, the message (the first argument) in the
9        // `parent.postMessage()` call is accessible via `event.data` here.
10        var messageFromSender = event.data;
11
12        console.log(messageFromSender);
13        if (messageFromSender.close_editor === true) {
14            $('.editorWrapper').remove();
15            editorIsOpen = false;
16            CbUx.showLoader();
17            window.location.reload();
18        }
19
20        if (messageFromSender.remove_editor === true) {
21            $('.editorContainer').remove();
22//            if (messageFromSender.editor_id === "43") {
23            window.location.reload();
24        }
25//        }
26    }
27
28    function registerEventListener() {
29        setTimeout(function () {
30            if (window.addEventListener) {
31                window.addEventListener("message", handleMessage);
32            } else {
33                window.attachEvent("onmessage", handleMessage);
34            }
35        }, 500);
36    }
37
38
39
40    var iFrameEditorCode = '<div class="editorContainer">' + '<div class="editorWrapper resizable draggable" style="position: absolute;left: auto;top: auto;z-index: 99999;height: auto;min-height: 600px;width: 930px;max-width: 930px;">' +
41            '<div class="__EditorWindowDraggableButton draggable-handler" title=""></div>' +
42            '<iframe width="560" height="349" src="%s" frameborder="0" allowfullscreen style="position: absolute;top: 0px;left: 0;width: 100%;height: calc(100% - 0px);"></iframe>' +
43            '</div>' +
44            '</div>';
45
46    $('.cb-flex-editor-button, .cb-flex-editor-edit-doc-btn').unbind('click').on('click', function (e) {
47        if (editorIsOpen === false && ENV.auth) {
48            editorIsOpen = true;
49            var editorButton = $(this);
50            $("body").addClass('editor-open');
51
52            var articleId = $(editorButton).attr('data-article-id');
53
54            var isBlogEditor = $(editorButton).hasClass("blog-edit-button");
55            var isPixEditor = $(editorButton).hasClass("pix-edit-button");
56
57            var editorContainerClass = null;
58            if ($(editorButton).attr('data-editor-container')) {
59                editorContainerClass = $(editorButton).attr('data-editor-container');
60            }
61
62// LGO: old, throw an error if  you open the pix editor, i dont know why
63//            function openEditor() {
64//                var body = {
65//                    m: 'get_cb_flex_editor_auth_token'
66//                };
67//                CbUx.showLoader();
68//                var domain = /:\/\/([^\/]+)/.exec(window.location.href)[1];
69//                $.get('https://' + domain + ENV.document_root + '/de_DE/auth.json', body, function (token) {
70////                if (token) {
71//                    var url = $(editorButton).attr('data-url') + '&account=' + ENV.auth.account + '&token=' + token;
72//                    var newiFrameEditorCode = iFrameEditorCode;
73//                    newiFrameEditorCode = newiFrameEditorCode.replace(/%s/, url);
74//                    $(editorButton).after(newiFrameEditorCode);
75//                    if ($(editorButton).hasClass("cb-flex-editor-button pix-edit-button")) {
76//                        $('.pix-editor-container').html(newiFrameEditorCode);
77//                    }
78//                    $(".draggable").draggable({scroll: false});
79//                    $(window).scrollTop(0);
80//                    registerEventListener();
81//                    CbUx.hideLoader();
82////                }
83//                });
84//            }
85
86            // LGO: copied from ks-nrw, works fine
87            function openEditor() {
88                var body = {
89                    m: 'get_cb_flex_editor_auth_token'
90                };
91                CbUx.showLoader();
92                var domain = /:\/\/([^\/]+)/.exec(window.location.href)[1];
93                $.get('https://' + domain + ENV.document_root + '/de_DE/auth.json', body, function (token) {
94//                if (token) {
95                    var url = $(editorButton).attr('data-url') + '&account=' + ENV.auth.account + '&token=' 
95+ token;
96
97                    var newiFrameEditorCode = iFrameEditorCode;
98                    newiFrameEditorCode = newiFrameEditorCode.replace(/%s/, url);
99
100                    if (editorContainerClass !== null) {
101                        $(editorContainerClass).html(newiFrameEditorCode);
102                    } else {
103                        $(editorButton).after(newiFrameEditorCode);
104                    }
105
106                    $(".draggable").draggable({scroll: false});
107
108                    $(window).scrollTop(0);
109
110                    registerEventListener();
111                    CbUx.hideLoader();
112//                }
113                });
114            }
115
116            if (articleId == "") {
117                var body = {
118                    m: 'new_article',
119                    page_id: $(editorButton).data('page-id'),
120                    language_id: ENV.id_language
121                };
122                CbUx.showLoader();
123                $.get('https://' + ENV.server_url + ENV.document_root + '/de_DE/page.json', body, function (data) {
124                    $(editorButton).attr('data-url', ($(editorButton).data('url') + data.article_id));
125                    openEditor();
126                });
127            } else {
128                openEditor();
129            }
130
131
132
133        }
134    });
135
136
137});

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.