diff options
author | Sergey Linnik <sergey.linnik@onlyoffice.com> | 2018-03-20 14:08:14 +0300 |
---|---|---|
committer | Sergey Linnik <sergey.linnik@onlyoffice.com> | 2018-03-20 14:08:14 +0300 |
commit | c5237c3e01c58c56daf4a1cada6521110c65a674 (patch) | |
tree | 7f59e21fb8b69d18b940ac458aa075bd20487fae /js | |
parent | cc366ce2a661cfc3dbc197671853499b7819a0ba (diff) | |
parent | a3df6a8ffcb452176d0bc6e36222fa3c39c57385 (diff) |
Merge branch 'develop' into feature/share-link
# Conflicts:
# controller/editorcontroller.php
Diffstat (limited to 'js')
-rw-r--r-- | js/editor.js | 2 | ||||
-rw-r--r-- | js/main.js | 74 |
2 files changed, 48 insertions, 28 deletions
diff --git a/js/editor.js b/js/editor.js index fa1e466..f8e77dc 100644 --- a/js/editor.js +++ b/js/editor.js @@ -66,7 +66,7 @@ if (docIsChanged !== event.data) { var titleChange = function () { - window.document.title = config.document.title + (event.data ? " *" : "") + ' - ' + oc_defaults.title; + window.document.title = config.document.title + (event.data ? " *" : "") + " - " + oc_defaults.title; docIsChanged = event.data; }; @@ -91,7 +91,7 @@ OCA.Onlyoffice.FileClick = function (fileName, context, attr) { var fileInfoModel = context.fileInfoModel || context.fileList.getModelForFile(fileName); var fileList = context.fileList; - if (!attr.conv) { + if (!attr.conv || (fileList.dirInfo.permissions & OC.PERMISSION_CREATE) !== OC.PERMISSION_CREATE) { OCA.Onlyoffice.OpenEditor(fileInfoModel.id); return; } @@ -100,6 +100,7 @@ t(OCA.Onlyoffice.AppName, "Convert and open document"), function (convert) { if (!convert) { + OCA.Onlyoffice.OpenEditor(fileInfoModel.id); return; } @@ -128,38 +129,54 @@ }); }; + 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(); + } + ); + + } + }; + OCA.Onlyoffice.FileList = { attach: function (fileList) { if (fileList.id == "trashbin") { return; } - $.get(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/settings"), - function onSuccess(settings) { - OCA.Onlyoffice.setting = settings; - var mimes = OCA.Onlyoffice.setting.formats; - - OCA.Onlyoffice.mimes = mimes; - $.each(mimes, function (ext, attr) { - fileList.fileActions.registerAction({ - name: "onlyofficeOpen", - displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"), - mime: attr.mime, - permissions: OC.PERMISSION_READ, - icon: function () { - return OC.imagePath(OCA.Onlyoffice.AppName, "app-dark"); - }, - actionHandler: function (fileName, context) { - OCA.Onlyoffice.FileClick(fileName, context, attr); - } - }); - - if (attr.def) { - fileList.fileActions.setDefault(attr.mime, "onlyofficeOpen"); + var register = function() { + var mimes = OCA.Onlyoffice.setting.formats; + + $.each(mimes, function (ext, attr) { + fileList.fileActions.registerAction({ + name: "onlyofficeOpen", + displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"), + mime: attr.mime, + permissions: OC.PERMISSION_READ, + icon: function () { + return OC.imagePath(OCA.Onlyoffice.AppName, "app-dark"); + }, + actionHandler: function (fileName, context) { + OCA.Onlyoffice.FileClick(fileName, context, attr); } }); - } - ); + + if (attr.def) { + fileList.fileActions.setDefault(attr.mime, "onlyofficeOpen"); + } + }); + } + + OCA.Onlyoffice.GetSettings(register); } }; @@ -205,7 +222,10 @@ }); } }; + + + OC.Plugins.register("OCA.Files.FileList", OCA.Onlyoffice.FileList); + OC.Plugins.register("OCA.Files.NewFileMenu", OCA.Onlyoffice.NewFileMenu); + })(OCA); -OC.Plugins.register("OCA.Files.FileList", OCA.Onlyoffice.FileList); -OC.Plugins.register("OCA.Files.NewFileMenu", OCA.Onlyoffice.NewFileMenu); |