Skip to content

Commit

Permalink
Issue #61: Fix indentation in js and css.
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote committed Nov 27, 2024
1 parent 8695cbc commit 8b5da2e
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 76 deletions.
34 changes: 17 additions & 17 deletions css/cool.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@
}

.cool-frame__preview {
width: 100%;
height: 100%;
border: 0;
width: 100%;
height: 100%;
border: 0;
}

.cool-frame__iframe {
border: 1px solid;
width: 100%;
height: 100%;
position: absolute;
box-sizing: border-box;
border: 1px solid;
width: 100%;
height: 100%;
position: absolute;
box-sizing: border-box;
}

.cool-editor__dialog {
resize: both;
position: fixed;
top: 250px;
width: 100%;
height: calc(100% - 250px);
/* seems to be a reasonable value to be above of it all */
z-index: 501;
box-sizing: border-box;
resize: both;
position: fixed;
top: 250px;
width: 100%;
height: calc(100% - 250px);
/* seems to be a reasonable value to be above of it all */
z-index: 501;
box-sizing: border-box;
}

.cool-editor__body {
margin: 0;
margin: 0;
}
76 changes: 38 additions & 38 deletions js/cool.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,60 @@
*/

function loadDocument(wopiClient, wopiSrc, options = null) {
let hasCloseButton = false;
let wopiUrl = `${wopiClient}WOPISrc=${wopiSrc}`;
if (options && options.closebutton == true) {
wopiUrl += '&closebutton=true';
hasCloseButton = true;
}
let hasCloseButton = false;
let wopiUrl = `${wopiClient}WOPISrc=${wopiSrc}`;
if (options && options.closebutton == true) {
wopiUrl += '&closebutton=true';
hasCloseButton = true;
}

window.addEventListener("message", receiveMessage.bind(null, hasCloseButton), false);
window.addEventListener("message", receiveMessage.bind(null, hasCloseButton), false);

let formElem = document.getElementById("collabora-submit-form");
let formElem = document.getElementById("collabora-submit-form");

if (!formElem) {
console.log("error: submit form not found");
return;
}
formElem.action = wopiUrl;
formElem.submit();
if (!formElem) {
console.log("error: submit form not found");
return;
}
formElem.action = wopiUrl;
formElem.submit();
}

function postMessage(msg) {
document.getElementById("collabora-online-viewer").contentWindow.postMessage(JSON.stringify(msg), '*');
document.getElementById("collabora-online-viewer").contentWindow.postMessage(JSON.stringify(msg), '*');
}

function postReady() {
postMessage({ MessageId: "Host_PostmessageReady" });
postMessage({ MessageId: "Host_PostmessageReady" });
}

function receiveMessage(hasCloseButton, event) {
let msg = JSON.parse(event.data);
if (!msg) {
return;
}
let msg = JSON.parse(event.data);
if (!msg) {
return;
}

switch (msg.MessageId) {
switch (msg.MessageId) {

case "App_LoadingStatus":
if (msg.Values && msg.Values.Status == "Document_Loaded") {
postReady();
}
break;
if (msg.Values && msg.Values.Status == "Document_Loaded") {
postReady();
}
break;

case "UI_Close":
if (hasCloseButton) {
if (msg.Values && msg.Values.EverModified) {
let reply = { MessageId: "Action_Close" };
postMessage(reply);
}
if (window.parent.location == window.location) {
history.back();
} else {
/* we send back the UI_Close message to the parent frame. */
window.parent.postMessage(event.data);
}
if (hasCloseButton) {
if (msg.Values && msg.Values.EverModified) {
let reply = { MessageId: "Action_Close" };
postMessage(reply);
}
if (window.parent.location == window.location) {
history.back();
} else {
/* we send back the UI_Close message to the parent frame. */
window.parent.postMessage(event.data);
}
break;
}
}
break;
}
}
42 changes: 21 additions & 21 deletions js/previewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@
*/

function previewField(coolUrl) {
let iframe = document.querySelector("#cool-editor__dialog > .cool-frame__preview");
iframe.src = coolUrl;
document.querySelector("#cool-editor__dialog").show();
let iframe = document.querySelector("#cool-editor__dialog > .cool-frame__preview");
iframe.src = coolUrl;
document.querySelector("#cool-editor__dialog").show();
}

function closePreview() {
let iframe = document.querySelector("#cool-editor__dialog > .cool-frame__preview");
iframe.src = "about:blank";
document.querySelector('#cool-editor__dialog').close();
let iframe = document.querySelector("#cool-editor__dialog > .cool-frame__preview");
iframe.src = "about:blank";
document.querySelector('#cool-editor__dialog').close();
}

(function () {
function receiveMessage(event) {
let msg = JSON.parse(event.data);
if (!msg) {
return;
}
function receiveMessage(event) {
let msg = JSON.parse(event.data);
if (!msg) {
return;
}

switch (msg.MessageId) {
case "App_LoadingStatus":
if (msg.Values && msg.Values.Status == "Document_Loaded") {
postReady();
}
break;
case "UI_Close":
closePreview();
break;
switch (msg.MessageId) {
case "App_LoadingStatus":
if (msg.Values && msg.Values.Status == "Document_Loaded") {
postReady();
}
break;
case "UI_Close":
closePreview();
break;
}
}

window.addEventListener("message", receiveMessage, false);
window.addEventListener("message", receiveMessage, false);
})()

0 comments on commit 8b5da2e

Please sign in to comment.