1$(document).ready(function () { 2 3 var editorIsOpen = false; 4 5 function handleMessage(event) { 6 console.log("Received a message from " + event.origin + "."); 7 8 // When one window sends a message, or data, to another window via 9 // `parent.postMessage()`, the message (the first argument) in the 10 // `parent.postMessage()` call is accessible via `event.data` here. 11 var messageFromSender = event.data; 12 13 // Do something with the data. 14 console.log(messageFromSender); 15 16 if (messageFromSender.close_editor === true) { 17 $('.editorWrapper').remove(); 18 editorIsOpen = false; 19 CbUx.showLoader(); 20 window.location.reload(); 21 } 22 23 if (messageFromSender.remove_editor === true) { 24 $('.editorContainer').remove(); 25 editorIsOpen = false; 26 } 27 } 28 29 function registerEventListener() { 30 setTimeout(function () { 31 if (window.addEventListener) { 32 window.addEventListener("message", handleMessage); 33 } else { 34 window.attachEvent("onmessage", handleMessage); 35 } 36 }, 500); 37 } 38 39 40 41 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;">' + 42 '<div class="__EditorWindowDraggableButton draggable-handler" title=""></div>' + 43 '<iframe width="560" height="349" src="%s" frameborder="0" allowfullscreen style="position: absolute;top: 0px;left: 0;width: 100%;height: calc(100% - 0px);"></iframe>' + 44 '</div>' + 45 '</div>'; 46 47 $("body").on('click', '.cb-flex-editor-button:not(.article-delete-button), .event-editor-button', function (e) { 48 if (editorIsOpen === false && ENV.auth) { 49 editorIsOpen = true; 50 var editorButton = $(this); 51 $("body").addClass('editor-open'); 52 53 var itemId = $(editorButton).attr('data-article-id'); 54 55 var isBlogEditor = $(editorButton).hasClass("blog-edit-button"); 56 var isPixEditor = $(editorButton).hasClass("pix-edit-button") || $(editorButton).hasClass("pix-edit-buttonKulturschaffende"); 57 var isEventEditor = $(editorButton).hasClass("event-editor-button"); 58 var isEventEditor = $(editorButton).hasClass("event-editor-button"); 59 60 var editorContainerClass = null; 61 if ($(editorButton).attr('data-editor-container')) { 62 editorContainerClass = $(editorButton).attr('data-editor-container'); 63 } 64 65 function openEditor() { 66 var body = { 67 m: 'get_cb_flex_editor_auth_token' 68 }; 69 CbUx.showLoader(); 70 var domain = /:\/\/([^\/]+)/.exec(window.location.href)[1]; 71 $.get('https://' + domain + ENV.document_root + '/de_DE/auth.json', body, function (token) { 72// if (token) { 73 var url = $(editorButton).attr('data-url') + '&account=' + ENV.auth.account + '&token=' + token; 74 75 var newiFrameEditorCode = iFrameEditorCode; 76 newiFrameEditorCode = newiFrameEditorCode.replace(/%s/, url); 77 78 if (editorContainerClass !== null) { 79 $(editorContainerClass).html(newiFrameEditorCode); 80 } else { 81 $(editorButton).after(newiFrameEditorCode); 82 } 83 84 $(".draggable").draggable({scroll: false}); 85 86 $(window).scrollTop(0); 87 88 registerEventListener(); 89 CbUx.hideLoader(); 90// } 91 }); 92 } 93 94 if ($(editorButton).hasClass("comments-config-edit-button") && commentsConfigId == "") { 95 var body = { 96 m: 'new_comments_config', 97 page_id: $(editorButton).data('page-id'), 98 film_id: $(editorButton).data('film-id'), 99 language_id: ENV.id_language 100 }; 101 CbUx.showLoader(); 102 $.get('https://' + ENV.server_url + ENV.document_root + '/de_DE/page.json', body, function (data) { 103 $(editorButton).attr('data-url', ($(editorButton).data('url') + data.comments_config_id)); 104 openEditor(); 105 }); 106 } else if (itemId == "" && !isBlogEditor && !isPixEditor && !isEventEditor) { 107 var body = { 108 m: 'new_article', 109 page_id: $(editorButton).data('page-id'), 110 language_id: ENV.id_language 111 }; 112 CbUx.showLoader(); 113 114 if (ENV.is_staging_server) { 115 $.get('https://staging.kulturserver-nrw.de/de_DE/page.json', body, function (data) { 116 $(editorButton).attr('data-url', ($(editorButton).data('url') + data.article_id)); 117 openEditor(); 118 }); 119 } else { 120 $.get('https://' + ENV.server_url + ENV.document_root + '/de_DE/page.json', body, function (data) { 121 $(editorButton).attr('data-url', ($(editorButton).data('url') + data.article_id)); 122 openEditor(); 123 }); 124 } 125 126 127 } else { 128 openEditor(); 129 } 130 131 132 133 } 134 }); 135 136 $('.btn-post-entry').on('click', function () { 137 if (ENV.auth && $(this).hasClass('is-blog-author')) { 138 $('#page-window, #page-window-layer').addClass('show'); 139 } else { 140 openRegisterLoginLayer(); 141 } 142 }); 143 144 $('#page-window .close-button').on('click', function () { 145 $('#page-window, #page-window-layer').removeClass('show'); 146 }); 147 148 $('#page-window .create-page-button').on('click', function () { 149 150 if ($('#page-window #input-field-title').val() != "" && $("select.new-page-select").val() !== null) { 151 var body = { 152 m: 'new_article_and_blog_item', 153 language_id: ENV.id_language, 154 title: $('#page-window #input-field-title').val(), 155 tag_id: $("select.new-page-select").val(), 156 tag_group_id: 3 157 }; 158 159 CbUx.showLoader(); 160 $.get(ENV.link_root + '/page.json', body, function (data) { 161 window.location.href = data.page_url; 162 }); 163 } else { 164 CbUx.showMessage('page_window_error_text', 'page_window_error_text_headline'); 165 } 166 167 168 169 }); 170 171 $('.cb-flex-editor-button.article-delete-button').unbind('click').on('click', function (e) { 172 var article_id = $(this).data('article-id');
173 CbUx.confirm("delete_article_confirm_header", "delete_article_confirm_text", function () { 174 var body = { 175 m: 'delete_article_and_blog_item', 176 article_id: article_id 177 }; 178 179 CbUx.showLoader(); 180 $.get(ENV.link_root + '/page.json', body, function (data) { 181 window.location.href = ENV.link_root + '/blog'; 182 }); 183 }); 184 185 }); 186 187 var hash = window.location.hash; 188 if (hash === "#openeditor") { 189 $('.cb-flex-editor-button.article-editor-button').first().click(); 190 window.location.hash = ''; 191 } 192});
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.