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>2018-03-20 12:34:42 +0300
committerSergey Linnik <sergey.linnik@onlyoffice.com>2018-03-20 13:30:44 +0300
commite281427122dedfb197ab9214f5ed5e58d28e6cae (patch)
tree1c0f22cb4a99b584d9bf1c9ef3b911cda3026581 /js
parent9f7cc47323293c862602e8807fdbb2460ce33a83 (diff)
request settings one time
Diffstat (limited to 'js')
-rw-r--r--js/main.js71
1 files changed, 45 insertions, 26 deletions
diff --git a/js/main.js b/js/main.js
index 14c4f9f..4ab19cc 100644
--- a/js/main.js
+++ b/js/main.js
@@ -129,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);
}
};
@@ -206,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);