diff options
author | Sergey Linnik <sergey.linnik@onlyoffice.com> | 2018-03-20 12:34:42 +0300 |
---|---|---|
committer | Sergey Linnik <sergey.linnik@onlyoffice.com> | 2018-03-20 13:30:44 +0300 |
commit | e281427122dedfb197ab9214f5ed5e58d28e6cae (patch) | |
tree | 1c0f22cb4a99b584d9bf1c9ef3b911cda3026581 /js | |
parent | 9f7cc47323293c862602e8807fdbb2460ce33a83 (diff) |
request settings one time
Diffstat (limited to 'js')
-rw-r--r-- | js/main.js | 71 |
1 files changed, 45 insertions, 26 deletions
@@ -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); |