From 23613248bd717f3c9223b916ca17a9995165133c Mon Sep 17 00:00:00 2001 From: Hugo Renard Date: Mon, 13 Dec 2021 17:54:00 +0100 Subject: [PATCH] it's a nextcloud app --- README.md | 3 +- appinfo/info.xml | 6 --- composer.json | 13 ++++++ css/style.css | 2 +- img/app.svg | 56 ++++++++++++++++++++++++++ js/script.js | 80 +++++++++++++++++++------------------ lib/AppInfo/Application.php | 20 ++++++++++ 7 files changed, 132 insertions(+), 48 deletions(-) create mode 100644 composer.json create mode 100644 img/app.svg create mode 100644 lib/AppInfo/Application.php diff --git a/README.md b/README.md index a2e8eaa..68704d0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# multi-office - +# Multi Office diff --git a/appinfo/info.xml b/appinfo/info.xml index 9545887..bbbf3b4 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -14,10 +14,4 @@ - - - Multi Office - multioffice.page.index - - diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..7ef3d16 --- /dev/null +++ b/composer.json @@ -0,0 +1,13 @@ +{ + "name": "Multi Office", + "description": "Improve Collabora + ONLYOFFICE experience", + "type": "project", + "license": "AGPL", + "authors": [ + { + "name": "Indiehosters" + } + ], + "require": {}, + "require-dev": {} +} diff --git a/css/style.css b/css/style.css index 1a089aa..51247c4 100644 --- a/css/style.css +++ b/css/style.css @@ -24,7 +24,7 @@ } .menu-item-extension { - margin-left: auto; + margin-left: 1em; opacity: 0.4; font-weight: bold; font-size: 0.8em; diff --git a/img/app.svg b/img/app.svg new file mode 100644 index 0000000..fe370f8 --- /dev/null +++ b/img/app.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/js/script.js b/js/script.js index 7e10fd8..d14d5e5 100644 --- a/js/script.js +++ b/js/script.js @@ -1,48 +1,50 @@ -OC.Plugins.register("OCA.Files.NewFileMenu", { - attach: function () { - const refreshMenu = () => { - const menu = document.querySelector(".newFileMenu ul"); +document.addEventListener("DOMContentLoaded", () => + OC.Plugins.register("OCA.Files.NewFileMenu", { + attach: function () { + const refreshMenu = () => { + const menu = document.querySelector(".newFileMenu ul"); - const addSeparator = (selector, title) => { - const firtEl = document.querySelector(selector); + const addSeparator = (selector, title) => { + const firtEl = document.querySelector(selector); - const separator = document.createElement("li"); - separator.classList.add("menu-item-separator"); - separator.innerHTML = ` + const separator = document.createElement("li"); + separator.classList.add("menu-item-separator"); + separator.innerHTML = `

${title}

`; - menu.insertBefore(separator, firtEl.parentNode); - }; + menu.insertBefore(separator, firtEl.parentNode); + }; - const addExtension = (selector) => { - const elements = document.querySelectorAll(selector); - for (const el of elements) { - const span = document.createElement("span"); - span.classList.add("menu-item-extension"); - span.innerText = el.getAttribute("data-templatename").split(".")[1]; - el.appendChild(span); - } - }; + const addExtension = (selector) => { + const elements = document.querySelectorAll(selector); + for (const el of elements) { + const span = document.createElement("span"); + span.classList.add("menu-item-extension"); + span.innerText = el.getAttribute("data-templatename").split(".")[1]; + el.appendChild(span); + } + }; - addSeparator( - '.newFileMenu .menuitem[data-action*="template-new-onlyoffice"]', - "ONLYOFFICE" - ); - addSeparator( - '.newFileMenu .menuitem[data-action*="template-new-richdocument"]', - "LIBREOFFICE" - ); + addSeparator( + '.newFileMenu .menuitem[data-action*="template-new-onlyoffice"]', + "ONLYOFFICE" + ); + addSeparator( + '.newFileMenu .menuitem[data-action*="template-new-richdocument"]', + "LIBREOFFICE" + ); - addExtension( - '.newFileMenu .menuitem[data-action*="template-new-onlyoffice"]' - ); - addExtension( - '.newFileMenu .menuitem[data-action*="template-new-richdocument"]' - ); - }; - setTimeout(refreshMenu); - document.querySelector(".new").addEventListener("click", refreshMenu); - }, -}); + addExtension( + '.newFileMenu .menuitem[data-action*="template-new-onlyoffice"]' + ); + addExtension( + '.newFileMenu .menuitem[data-action*="template-new-richdocument"]' + ); + }; + setTimeout(refreshMenu); + document.querySelector(".new").addEventListener("click", refreshMenu); + }, + }) +); diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php new file mode 100644 index 0000000..9cae642 --- /dev/null +++ b/lib/AppInfo/Application.php @@ -0,0 +1,20 @@ +getEventDispatcher(); + $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', function() { + script('multioffice', 'script'); + style('multioffice', 'style'); + }); + } + +} -- GitLab