diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/desktop.js | 28 | ||||
-rw-r--r-- | js/directeditor.js | 32 | ||||
-rw-r--r-- | js/editor.js | 151 | ||||
-rw-r--r-- | js/listener.js | 108 | ||||
-rw-r--r-- | js/main.js | 151 | ||||
-rw-r--r-- | js/settings.js | 52 | ||||
-rw-r--r-- | js/viewer.js | 36 |
7 files changed, 324 insertions, 234 deletions
diff --git a/js/desktop.js b/js/desktop.js index 5452422..d4e1e12 100644 --- a/js/desktop.js +++ b/js/desktop.js @@ -2,27 +2,17 @@ * * (c) Copyright Ascensio System SIA 2020 * - * This program is a free software product. - * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License - * (AGPL) version 3 as published by the Free Software Foundation. - * In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This program is distributed WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * http://www.apache.org/licenses/LICENSE-2.0 * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions of the Program - * must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product logo when distributing the program. - * Pursuant to Section 7(e) we decline to grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as well as technical - * writing content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International. - * See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ diff --git a/js/directeditor.js b/js/directeditor.js index 9aa95df..09f163f 100644 --- a/js/directeditor.js +++ b/js/directeditor.js @@ -2,27 +2,17 @@ * * (c) Copyright Ascensio System SIA 2020 * - * This program is a free software product. - * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License - * (AGPL) version 3 as published by the Free Software Foundation. - * In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This program is distributed WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * http://www.apache.org/licenses/LICENSE-2.0 * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions of the Program - * must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product logo when distributing the program. - * Pursuant to Section 7(e) we decline to grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as well as technical - * writing content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International. - * See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ @@ -65,10 +55,10 @@ } OCA.Onlyoffice.directEditor = { - close: function() { + close: function () { callMobileMessage("close"); }, - loaded: function() { + loaded: function () { callMobileMessage("loaded"); } }; diff --git a/js/editor.js b/js/editor.js index 2b6bf7b..50325aa 100644 --- a/js/editor.js +++ b/js/editor.js @@ -2,27 +2,17 @@ * * (c) Copyright Ascensio System SIA 2020 * - * This program is a free software product. - * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License - * (AGPL) version 3 as published by the Free Software Foundation. - * In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This program is distributed WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * http://www.apache.org/licenses/LICENSE-2.0 * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions of the Program - * must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product logo when distributing the program. - * Pursuant to Section 7(e) we decline to grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as well as technical - * writing content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International. - * See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ @@ -30,7 +20,10 @@ OCA.Onlyoffice = _.extend({ AppName: "onlyoffice", - inframe: false + inframe: false, + fileId: null, + shareToken: null, + insertImageType: null }, OCA.Onlyoffice); OCA.Onlyoffice.InitEditor = function () { @@ -40,11 +33,12 @@ }); }; - var fileId = $("#iframeEditor").data("id"); - var shareToken = $("#iframeEditor").data("sharetoken"); + OCA.Onlyoffice.fileId = $("#iframeEditor").data("id"); + OCA.Onlyoffice.shareToken = $("#iframeEditor").data("sharetoken"); + OCA.Onlyoffice.version = $("#iframeEditor").data("version"); var directToken = $("#iframeEditor").data("directtoken"); OCA.Onlyoffice.inframe = !!$("#iframeEditor").data("inframe"); - if (!fileId && !shareToken && !directToken) { + if (!OCA.Onlyoffice.fileId && !OCA.Onlyoffice.shareToken && !directToken) { displayError(t(OCA.Onlyoffice.AppName, "FileId is empty")); return; } @@ -56,7 +50,7 @@ var configUrl = OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/config/{fileId}", { - fileId: fileId || 0 + fileId: OCA.Onlyoffice.fileId || 0 }); var params = []; @@ -64,19 +58,23 @@ if (filePath) { params.push("filePath=" + encodeURIComponent(filePath)); } - if (shareToken) { - params.push("shareToken=" + encodeURIComponent(shareToken)); + if (OCA.Onlyoffice.shareToken) { + params.push("shareToken=" + encodeURIComponent(OCA.Onlyoffice.shareToken)); } if (directToken) { $("html").addClass("onlyoffice-full-page"); params.push("directToken=" + encodeURIComponent(directToken)); } + if (OCA.Onlyoffice.version > 0) { + params.push("version=" + OCA.Onlyoffice.version); + } if (OCA.Onlyoffice.inframe || directToken) { var dsVersion = DocsAPI.DocEditor.version(); var versionArray = dsVersion.split("."); if (versionArray[0] < 5 || versionArray[0] == 5 && versionArray[1] < 5) { - if (OCA.Onlyoffice.inframe) { + if (OCA.Onlyoffice.inframe + && window.parent.OCA.Onlyoffice.ShowHeaderButton) { window.parent.postMessage({ method: "editorShowHeaderButton" }, @@ -112,7 +110,7 @@ var docIsChanged = null; var docIsChangedTimeout = null; - var setPageTitle = function(event) { + var setPageTitle = function (event) { clearTimeout(docIsChangedTimeout); if (docIsChanged !== event.data) { @@ -130,17 +128,26 @@ }; setPageTitle(false); + OCA.Onlyoffice.documentType = config.documentType; + config.events = { "onDocumentStateChange": setPageTitle, + "onRequestHistory": OCA.Onlyoffice.onRequestHistory, + "onRequestHistoryData": OCA.Onlyoffice.onRequestHistoryData, + "onDocumentReady": OCA.Onlyoffice.onDocumentReady, }; + if (!OCA.Onlyoffice.version) { + config.events.onRequestHistoryClose = OCA.Onlyoffice.onRequestHistoryClose; + } + if (config.editorConfig.tenant) { - config.events.onAppReady = function() { + config.events.onAppReady = function () { OCA.Onlyoffice.docEditor.showMessage(t(OCA.Onlyoffice.AppName, "You are using public demo ONLYOFFICE Document Server. Please do not store private sensitive data.")); }; } - if (OCA.Onlyoffice.inframe && !shareToken + if (OCA.Onlyoffice.inframe && !OCA.Onlyoffice.shareToken || OC.currentUser) { config.events.onRequestSaveAs = OCA.Onlyoffice.onRequestSaveAs; config.events.onRequestInsertImage = OCA.Onlyoffice.onRequestInsertImage; @@ -153,7 +160,7 @@ } if (OCA.Onlyoffice.inframe - && config._files_sharing && !shareToken + && config._files_sharing && !OCA.Onlyoffice.shareToken && window.parent.OCA.Onlyoffice.context) { config.events.onRequestSharingSettings = OCA.Onlyoffice.onRequestSharingSettings; } @@ -173,6 +180,74 @@ }); }; + OCA.Onlyoffice.onRequestHistory = function (version) { + $.get(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/history?fileId={fileId}&shareToken={shareToken}", + { + fileId: OCA.Onlyoffice.fileId || 0, + shareToken: OCA.Onlyoffice.shareToken || "", + }), + function onSuccess(response) { + if (response.error) { + var data = {error: response.error}; + } else { + var currentVersion = 0; + $.each(response, function (i, fileVersion) { + if (fileVersion.version >= currentVersion) { + currentVersion = fileVersion.version; + } + }); + + if (version) { + currentVersion = Math.min(currentVersion, version); + } + + data = { + currentVersion: currentVersion, + history: response, + }; + } + OCA.Onlyoffice.docEditor.refreshHistory(data); + }); + }; + + OCA.Onlyoffice.onRequestHistoryData = function (event) { + var version = event.data; + + $.get(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/version?fileId={fileId}&version={version}&shareToken={shareToken}", + { + fileId: OCA.Onlyoffice.fileId || 0, + version: version, + shareToken: OCA.Onlyoffice.shareToken || "", + }), + function onSuccess(response) { + if (response.error) { + response = { + error: response.error, + version: version, + }; + } + OCA.Onlyoffice.docEditor.setHistoryData(response); + }); + }; + + OCA.Onlyoffice.onRequestHistoryClose = function () { + location.reload(true); + }; + + OCA.Onlyoffice.onDocumentReady = function() { + if (OCA.Onlyoffice.inframe) { + window.parent.postMessage({ + method: "onDocumentReady", + param: OCA.Onlyoffice.documentType + }, + "*"); + } + + if (OCA.Onlyoffice.version > 0) { + OCA.Onlyoffice.onRequestHistory(OCA.Onlyoffice.version); + } + }; + OCA.Onlyoffice.onRequestSaveAs = function (event) { var saveData = { name: event.data.title, @@ -209,7 +284,7 @@ }); }; - OCA.Onlyoffice.onRequestInsertImage = function () { + OCA.Onlyoffice.onRequestInsertImage = function (event) { var imageMimes = [ "image/bmp", "image/x-bmp", "image/x-bitmap", "application/bmp", "image/gif", @@ -217,6 +292,8 @@ "image/png", "image/x-png", "application/png", "application/x-png" ]; + OCA.Onlyoffice.insertImageType = event.data.c; + if (OCA.Onlyoffice.inframe) { window.parent.postMessage({ method: "editorRequestInsertImage", @@ -239,6 +316,10 @@ return; } + if (OCA.Onlyoffice.insertImageType) { + response.c = OCA.Onlyoffice.insertImageType; + } + OCA.Onlyoffice.docEditor.insertImage(response); }); }; @@ -286,14 +367,14 @@ "*"); }; - OCA.Onlyoffice.onRequestSharingSettings = function() { + OCA.Onlyoffice.onRequestSharingSettings = function () { window.parent.postMessage({ method: "editorRequestSharingSettings" }, "*"); }; - OCA.Onlyoffice.onRequestCompareFile = function() { + OCA.Onlyoffice.onRequestCompareFile = function () { var revisedMimes = [ "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ]; @@ -309,7 +390,7 @@ } }; - OCA.Onlyoffice.editorSetRevised = function(filePath) { + OCA.Onlyoffice.editorSetRevised = function (filePath) { $.get(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/url?filePath={filePath}", { filePath: filePath diff --git a/js/listener.js b/js/listener.js index 3f8a4d8..e56318c 100644 --- a/js/listener.js +++ b/js/listener.js @@ -2,27 +2,17 @@ * * (c) Copyright Ascensio System SIA 2020 * - * This program is a free software product. - * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License - * (AGPL) version 3 as published by the Free Software Foundation. - * In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This program is distributed WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * http://www.apache.org/licenses/LICENSE-2.0 * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions of the Program - * must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product logo when distributing the program. - * Pursuant to Section 7(e) we decline to grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as well as technical - * writing content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International. - * See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ @@ -30,65 +20,20 @@ OCA.Onlyoffice = _.extend({ AppName: "onlyoffice", - context: null, - folderUrl: null, frameSelector: null, - canExpandHeader: true, }, OCA.Onlyoffice); - OCA.Onlyoffice.ShowHeaderButton = function () { - if (!OCA.Onlyoffice.canExpandHeader) { - return; - } - - var wrapper = $("<div id='onlyofficeHeader' />") - - var btnClose = $("<a class='icon icon-close-white'></a>"); - btnClose.on("click", function() { - OCA.Onlyoffice.CloseEditor(); - }); - wrapper.prepend(btnClose); - - if (!$("#isPublic").val()) { - var btnShare = $("<a class='icon icon-shared icon-white'></a>"); - btnShare.on("click", function () { - OCA.Onlyoffice.OpenShareDialog(); - }) - wrapper.prepend(btnShare); - } - - if (!$("#header .header-right").length) { - $("#header").append("<div class='header-right'></div>"); - } - wrapper.prependTo(".header-right"); - }; - - OCA.Onlyoffice.CloseEditor = function () { - $("body").removeClass("onlyoffice-inline"); + OCA.Onlyoffice.onRequestClose = function () { $(OCA.Onlyoffice.frameSelector).remove(); - $("#onlyofficeHeader").remove(); + OCA.Onlyoffice.frameSelector = null; + if (OCA.Viewer && OCA.Viewer.close) { OCA.Viewer.close(); } - OCA.Onlyoffice.context = null; - - var url = OCA.Onlyoffice.folderUrl; - if (!!url) { - window.history.pushState(null, null, url); - OCA.Onlyoffice.folderUrl = null; - } - }; - - OCA.Onlyoffice.OpenShareDialog = function () { - if (OCA.Onlyoffice.context) { - if (!$("#app-sidebar").is(":visible")) { - OCA.Onlyoffice.context.fileList.showDetailsView(OCA.Onlyoffice.context.fileName, "shareTabView"); - OC.Apps.showAppSidebar(); - } else { - OC.Apps.hideAppSidebar(); - } + if (OCA.Onlyoffice.CloseEditor) { + OCA.Onlyoffice.CloseEditor(); } }; @@ -123,20 +68,34 @@ revisedMimes); }; - window.addEventListener("message", function(event) { + OCA.Onlyoffice.onDocumentReady = function (documentType) { + if (documentType === "text") { + if (OCA.Onlyoffice.bindVersionClick) { + OCA.Onlyoffice.bindVersionClick(); + } + } else if (OCA.Onlyoffice.unbindVersionClick) { + OCA.Onlyoffice.unbindVersionClick(); + } + }; + + window.addEventListener("message", function (event) { if ($(OCA.Onlyoffice.frameSelector)[0].contentWindow !== event.source || !event.data["method"]) { return; } switch (event.data.method) { case "editorShowHeaderButton": - OCA.Onlyoffice.ShowHeaderButton(); + if (OCA.Onlyoffice.ShowHeaderButton) { + OCA.Onlyoffice.ShowHeaderButton(); + } break; case "editorRequestClose": - OCA.Onlyoffice.CloseEditor(); + OCA.Onlyoffice.onRequestClose(); break; case "editorRequestSharingSettings": - OCA.Onlyoffice.OpenShareDialog(); + if (OCA.Onlyoffice.OpenShareDialog) { + OCA.Onlyoffice.OpenShareDialog(); + } break; case "editorRequestSaveAs": OCA.Onlyoffice.onRequestSaveAs(event.data.param); @@ -150,6 +109,9 @@ case "editorRequestCompareFile": OCA.Onlyoffice.onRequestCompareFile(event.data.param); break; + case "onDocumentReady": + OCA.Onlyoffice.onDocumentReady(event.data.param); + break; } }, false); @@ -2,27 +2,17 @@ * * (c) Copyright Ascensio System SIA 2020 * - * This program is a free software product. - * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License - * (AGPL) version 3 as published by the Free Software Foundation. - * In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This program is distributed WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * http://www.apache.org/licenses/LICENSE-2.0 * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions of the Program - * must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product logo when distributing the program. - * Pursuant to Section 7(e) we decline to grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as well as technical - * writing content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International. - * See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ @@ -41,11 +31,8 @@ var dir = fileList.getCurrentDirectory(); if (!OCA.Onlyoffice.setting.sameTab || OCA.Onlyoffice.Desktop) { - var winEditor = window.open(""); - if (winEditor) { - winEditor.document.write(t(OCA.Onlyoffice.AppName, "Loading, please wait.")); - winEditor.document.close(); - } + $loaderUrl = OCA.Onlyoffice.Desktop ? "" : OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/loader"); + var winEditor = window.open($loaderUrl); } var createData = { @@ -69,7 +56,7 @@ } fileList.add(response, { animate: true }); - OCA.Onlyoffice.OpenEditor(response.id, dir, response.name, winEditor); + OCA.Onlyoffice.OpenEditor(response.id, dir, response.name, 0, winEditor); OCA.Onlyoffice.context = { fileList: fileList }; OCA.Onlyoffice.context.fileName = response.name; @@ -79,8 +66,11 @@ ); }; - OCA.Onlyoffice.OpenEditor = function (fileId, fileDir, fileName, winEditor) { - var filePath = fileDir.replace(new RegExp("\/$"), "") + "/" + fileName; + OCA.Onlyoffice.OpenEditor = function (fileId, fileDir, fileName, version, winEditor) { + var filePath = ""; + if (fileName) { + filePath = fileDir.replace(new RegExp("\/$"), "") + "/" + fileName; + } var url = OC.generateUrl("/apps/" + OCA.Onlyoffice.AppName + "/{fileId}?filePath={filePath}", { fileId: fileId, @@ -95,6 +85,10 @@ }); } + if (version > 0) { + url += "&version=" + version; + } + if (winEditor && winEditor.location) { winEditor.location.href = url; } else if (!OCA.Onlyoffice.setting.sameTab || OCA.Onlyoffice.Desktop) { @@ -107,7 +101,14 @@ $("#app-content").append($iframe); $("body").addClass("onlyoffice-inline"); - OC.Apps.hideAppSidebar(); + + if (OCA.Files.Sidebar) { + OCA.Files.Sidebar.close(); + return; + } else { + //todo: remove. only for v17 + OC.Apps.hideAppSidebar(); + } $("html, body").scrollTop(0); @@ -116,13 +117,58 @@ } }; + OCA.Onlyoffice.ShowHeaderButton = function () { + var wrapper = $("<div id='onlyofficeHeader' />") + + var btnClose = $("<a class='icon icon-close-white'></a>"); + btnClose.on("click", function() { + OCA.Onlyoffice.CloseEditor(); + }); + wrapper.prepend(btnClose); + + if (!$("#isPublic").val()) { + var btnShare = $("<a class='icon icon-shared icon-white'></a>"); + btnShare.on("click", function () { + OCA.Onlyoffice.OpenShareDialog(); + }) + wrapper.prepend(btnShare); + } + + if (!$("#header .header-right").length) { + $("#header").append("<div class='header-right'></div>"); + } + wrapper.prependTo(".header-right"); + }; + + OCA.Onlyoffice.CloseEditor = function () { + $("body").removeClass("onlyoffice-inline"); + $("#onlyofficeHeader").remove(); + + OCA.Onlyoffice.context = null; + + var url = OCA.Onlyoffice.folderUrl; + if (!!url) { + window.history.pushState(null, null, url); + OCA.Onlyoffice.folderUrl = null; + } + + if (OCA.Versions) { + OCA.Onlyoffice.bindVersionClick(); + } + }; + OCA.Onlyoffice.OpenShareDialog = function () { if (OCA.Onlyoffice.context) { if (!$("#app-sidebar").is(":visible")) { - OCA.Onlyoffice.context.fileList.showDetailsView(OCA.Onlyoffice.context.fileName, "shareTabView"); + OCA.Onlyoffice.context.fileList.showDetailsView(OCA.Onlyoffice.context.fileName, "sharing"); OC.Apps.showAppSidebar(); } else { - OC.Apps.hideAppSidebar(); + if (OCA.Files.Sidebar) { + OCA.Files.Sidebar.close(); + } else { + //todo: remove. only for v17 + OC.Apps.hideAppSidebar(); + } } } }; @@ -187,7 +233,7 @@ return; } - var register = function() { + var register = function () { var formats = OCA.Onlyoffice.setting.formats; $.each(formats, function (ext, config) { @@ -272,12 +318,49 @@ return extension; } + OCA.Onlyoffice.openVersion = function (fileId, version) { + if (OCA.Onlyoffice.frameSelector) { + $(OCA.Onlyoffice.frameSelector)[0].contentWindow.OCA.Onlyoffice.onRequestHistory(version); + return; + } + + OCA.Onlyoffice.OpenEditor(fileId, "", "", version) + }; + + OCA.Onlyoffice.bindVersionClick = function () { + OCA.Onlyoffice.unbindVersionClick(); + $(document).on("click.onlyoffice-version", "#versionsTabView .downloadVersion", function() { + var versionNodes = $("#versionsTabView ul.versions>li"); + var versionNode = $(this).closest("#versionsTabView ul.versions>li")[0]; + + var href = $(this).attr("href"); + var search = new RegExp("\/versions\/(\\d+)\/\\d+$"); + var result = search.exec(href); + if (result && result.length > 1) { + var fileId = result[1]; + } + if (!fileId) { + return true; + } + + var versionNum = versionNodes.length - $.inArray(versionNode, versionNodes); + + OCA.Onlyoffice.openVersion(fileId, versionNum); + + return false; + }); + }; + + OCA.Onlyoffice.unbindVersionClick = function() { + $(document).off("click.onlyoffice-version", "#versionsTabView .downloadVersion"); + } + var initPage = function () { if ($("#isPublic").val() === "1" && !$("#filestable").length) { var fileName = $("#filename").val(); var extension = getFileExtension(fileName); - var initSharedButton = function() { + var initSharedButton = function () { var formats = OCA.Onlyoffice.setting.formats; var config = formats[extension]; @@ -301,6 +384,10 @@ } else { OC.Plugins.register("OCA.Files.FileList", OCA.Onlyoffice.FileList); OC.Plugins.register("OCA.Files.NewFileMenu", OCA.Onlyoffice.NewFileMenu); + + if (OCA.Versions) { + OCA.Onlyoffice.bindVersionClick(); + } } }; diff --git a/js/settings.js b/js/settings.js index adaf52f..1ac8d61 100644 --- a/js/settings.js +++ b/js/settings.js @@ -2,27 +2,17 @@ * * (c) Copyright Ascensio System SIA 2020 * - * This program is a free software product. - * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License - * (AGPL) version 3 as published by the Free Software Foundation. - * In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This program is distributed WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * http://www.apache.org/licenses/LICENSE-2.0 * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions of the Program - * must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product logo when distributing the program. - * Pursuant to Section 7(e) we decline to grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as well as technical - * writing content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International. - * See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ @@ -61,7 +51,7 @@ $("#onlyofficeGroups").click(groupListToggle); groupListToggle(); - var demoToggle = function() { + var demoToggle = function () { $("#onlyofficeAddrSettings input:not(#onlyofficeStorageUrl)").prop("disabled", $("#onlyofficeDemo").prop("checked")); }; @@ -87,14 +77,14 @@ "allTags", "linkTags", ]; - $.each(watermarkLists, function(i, watermarkList) { - var watermarkListToggle = function() { + $.each(watermarkLists, function (i, watermarkList) { + var watermarkListToggle = function () { if ($("#onlyofficeWatermark_" + watermarkList).prop("checked")) { if (watermarkList.indexOf("Group") >= 0) { OC.Settings.setupGroupsSelect($("#onlyofficeWatermark_" + watermarkList + "List")); } else { OC.SystemTags.collection.fetch({ - success: function() { + success: function () { $("#onlyofficeWatermark_" + watermarkList + "List").select2({ allowClear: true, closeOnSelect: false, @@ -102,13 +92,13 @@ separator: "|", toggleSelect: true, placeholder: t(OCA.Onlyoffice.AppName, "Select tag"), - query: _.debounce(function(query) { + query: _.debounce(function (query) { query.callback({ results: OC.SystemTags.collection.filterByName(query.term) }); }, 100, true), - initSelection: function(element, callback) { - var selection = ($(element).val() || []).split("|").map(function(tagId){ + initSelection: function (element, callback) { + var selection = ($(element).val() || []).split("|").map(function (tagId) { return OC.SystemTags.collection.get(tagId); }); callback(selection); @@ -119,8 +109,8 @@ formatSelection: function (tag) { return tag.get("name"); }, - sortResults: function(results) { - results.sort(function(a, b) { + sortResults: function (results) { + results.sort(function (a, b) { return OC.Util.naturalSortCompare(a.get("name"), b.get("name")); }); return results; @@ -149,6 +139,7 @@ var onlyofficeInternalUrl = ($("#onlyofficeInternalUrl:visible").val() || "").trim(); var onlyofficeStorageUrl = ($("#onlyofficeStorageUrl:visible").val() || "").trim(); + var onlyofficeVerifyPeerOff = $("#onlyofficeVerifyPeerOff").prop("checked"); var onlyofficeSecret = ($("#onlyofficeSecret:visible").val() || "").trim(); var demo = $("#onlyofficeDemo").prop("checked"); @@ -159,6 +150,7 @@ documentserver: onlyofficeUrl, documentserverInternal: onlyofficeInternalUrl, storageUrl: onlyofficeStorageUrl, + verifyPeerOff: onlyofficeVerifyPeerOff, secret: onlyofficeSecret, demo: demo }, @@ -188,12 +180,12 @@ $(".section-onlyoffice").addClass("icon-loading"); var defFormats = {}; - $("input[id^=\"onlyofficeDefFormat\"]").each(function() { + $("input[id^=\"onlyofficeDefFormat\"]").each(function () { defFormats[this.name] = this.checked; }); var editFormats = {}; - $("input[id^=\"onlyofficeEditFormat\"]").each(function() { + $("input[id^=\"onlyofficeEditFormat\"]").each(function () { editFormats[this.name] = this.checked; }); diff --git a/js/viewer.js b/js/viewer.js index 183a8e3..e31a6ce 100644 --- a/js/viewer.js +++ b/js/viewer.js @@ -2,27 +2,17 @@ * * (c) Copyright Ascensio System SIA 2020 * - * This program is a free software product. - * You can redistribute it and/or modify it under the terms of the GNU Affero General Public License - * (AGPL) version 3 as published by the Free Software Foundation. - * In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This program is distributed WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * http://www.apache.org/licenses/LICENSE-2.0 * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions of the Program - * must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product logo when distributing the program. - * Pursuant to Section 7(e) we decline to grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as well as technical - * writing content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International. - * See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * */ @@ -67,7 +57,7 @@ src: self.url + "&inframe=true", }, on: { - load: function() { + load: function () { self.doneLoading(); }, }, @@ -96,13 +86,11 @@ var initPage = function () { if (OCA.Viewer) { - OCA.Onlyoffice.canExpandHeader = false; - OCA.Onlyoffice.frameSelector = "#onlyofficeViewerFrame"; - OCA.Onlyoffice.GetSettings(function(){ + OCA.Onlyoffice.GetSettings(function () { - var mimes = $.map(OCA.Onlyoffice.setting.formats, function(format) { + var mimes = $.map(OCA.Onlyoffice.setting.formats, function (format) { return format.mime; }); |