Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ONLYOFFICE/onlyoffice-nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorSergey Linnik <sergey.linnik@onlyoffice.com>2020-06-23 17:17:25 +0300
committerSergey Linnik <sergey.linnik@onlyoffice.com>2020-06-23 17:17:25 +0300
commitd96fa34014289246ff8ba73e90332dd098648096 (patch)
tree4597a5e08c700828c8c54f5dd7a974fd2d5092da /js
parent3d2b9a101e1f87afe60a7177adb811c82278789e (diff)
parentea7699f52555da07ad6d406ec001be2082c1db02 (diff)
Merge remote-tracking branch 'remotes/origin/feature/viewer' into develop
Diffstat (limited to 'js')
-rw-r--r--js/editor.js4
-rw-r--r--js/listener.js10
-rw-r--r--js/viewer.js121
3 files changed, 133 insertions, 2 deletions
diff --git a/js/editor.js b/js/editor.js
index 841104a..2b6bf7b 100644
--- a/js/editor.js
+++ b/js/editor.js
@@ -152,7 +152,9 @@
config.events.onRequestClose = OCA.Onlyoffice.onRequestClose;
}
- if (OCA.Onlyoffice.inframe && config._files_sharing && !shareToken) {
+ if (OCA.Onlyoffice.inframe
+ && config._files_sharing && !shareToken
+ && window.parent.OCA.Onlyoffice.context) {
config.events.onRequestSharingSettings = OCA.Onlyoffice.onRequestSharingSettings;
}
diff --git a/js/listener.js b/js/listener.js
index b8d2915..3f8a4d8 100644
--- a/js/listener.js
+++ b/js/listener.js
@@ -32,10 +32,15 @@
AppName: "onlyoffice",
context: null,
folderUrl: null,
- frameSelector: 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>");
@@ -63,6 +68,9 @@
$(OCA.Onlyoffice.frameSelector).remove();
$("#onlyofficeHeader").remove();
+ if (OCA.Viewer && OCA.Viewer.close) {
+ OCA.Viewer.close();
+ }
OCA.Onlyoffice.context = null;
diff --git a/js/viewer.js b/js/viewer.js
new file mode 100644
index 0000000..183a8e3
--- /dev/null
+++ b/js/viewer.js
@@ -0,0 +1,121 @@
+/**
+ *
+ * (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.
+ *
+ * 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
+ *
+ * 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
+ *
+ */
+
+(function (OCA) {
+ if (OCA.Onlyoffice) {
+ return;
+ }
+
+ OCA.Onlyoffice = {
+ AppName: "onlyoffice",
+ frameSelector: null,
+ setting: {},
+ };
+
+ OCA.Onlyoffice.GetSettings = function (callbackSettings) {
+ if (OCA.Onlyoffice.setting.formats) {
+
+ callbackSettings();
+
+ } else {
+
+ $.get(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/settings"),
+ function onSuccess(settings) {
+ OCA.Onlyoffice.setting = settings;
+
+ callbackSettings();
+ }
+ );
+
+ }
+ };
+
+ var OnlyofficeViewerVue = {
+ name: "OnlyofficeViewerVue",
+ render: function (createElement) {
+ var self = this;
+
+ return createElement("iframe", {
+ attrs: {
+ id: "onlyofficeViewerFrame",
+ scrolling: "no",
+ src: self.url + "&inframe=true",
+ },
+ on: {
+ load: function() {
+ self.doneLoading();
+ },
+ },
+ })
+ },
+ props: {
+ filename: {
+ type: String,
+ default: null
+ },
+ fileid: {
+ type: Number,
+ default: null
+ }
+ },
+ data: function () {
+ return {
+ url: OC.generateUrl("/apps/" + OCA.Onlyoffice.AppName + "/{fileId}?filePath={filePath}",
+ {
+ fileId: this.fileid,
+ filePath: this.filename
+ })
+ }
+ }
+ };
+
+ var initPage = function () {
+ if (OCA.Viewer) {
+ OCA.Onlyoffice.canExpandHeader = false;
+
+ OCA.Onlyoffice.frameSelector = "#onlyofficeViewerFrame";
+
+ OCA.Onlyoffice.GetSettings(function(){
+
+ var mimes = $.map(OCA.Onlyoffice.setting.formats, function(format) {
+ return format.mime;
+ });
+
+ OCA.Viewer.registerHandler({
+ id: OCA.Onlyoffice.AppName,
+ group: "documents",
+ mimes: mimes,
+ component: OnlyofficeViewerVue
+ })
+ });
+ }
+ };
+
+ $(document).ready(initPage)
+
+})(OCA);