diff options
author | Sergey Linnik <sergey.linnik@onlyoffice.com> | 2017-05-05 15:26:56 +0300 |
---|---|---|
committer | Sergey Linnik <sergey.linnik@onlyoffice.com> | 2017-05-05 15:26:56 +0300 |
commit | 8f7147fe66c56a42e0eaaa38f97a14e6a8bbaee0 (patch) | |
tree | ba840cb987d638544c8e229a276061923197a8b0 /js | |
parent | 59362f8c8017468588deb938b683f21cab6c41f3 (diff) |
open file editor in same tab (Issue #48)
Diffstat (limited to 'js')
-rw-r--r-- | js/main.js | 23 | ||||
-rw-r--r-- | js/settings.js | 5 |
2 files changed, 20 insertions, 8 deletions
@@ -32,13 +32,17 @@ }; } + OCA.Onlyoffice.setting = {}; + OCA.Onlyoffice.CreateFile = function (name, fileList) { var dir = fileList.getCurrentDirectory(); - var winEditor = window.open(""); - if (winEditor) { - winEditor.document.write(t(OCA.Onlyoffice.AppName, "Loading, please wait.")); - winEditor.document.close(); + if (!OCA.Onlyoffice.setting.sameTab) { + var winEditor = window.open(""); + if (winEditor) { + winEditor.document.write(t(OCA.Onlyoffice.AppName, "Loading, please wait.")); + winEditor.document.close(); + } } $.post(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/new"), @@ -48,7 +52,9 @@ }, function onSuccess(response) { if (response.error) { - winEditor.close(); + if (winEditor) { + winEditor.close(); + } var row = OC.Notification.show(response.error); setTimeout(function () { OC.Notification.hide(row); @@ -75,8 +81,10 @@ if (winEditor && winEditor.location) { winEditor.location.href = url; - } else { + } else if (!OCA.Onlyoffice.setting.sameTab) { winEditor = window.open(url, "_blank"); + } else { + location.href = url; } }; @@ -128,7 +136,8 @@ $.get(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/settings"), function onSuccess(settings) { - var mimes = settings.formats; + OCA.Onlyoffice.setting = settings; + var mimes = OCA.Onlyoffice.setting.formats; OCA.Onlyoffice.mimes = mimes; $.each(mimes, function (ext, attr) { diff --git a/js/settings.js b/js/settings.js index 9e7f39d..b068590 100644 --- a/js/settings.js +++ b/js/settings.js @@ -64,6 +64,8 @@ defFormats[this.name] = this.checked; }); + var sameTab = $("#onlyofficeSameTab").is(":checked"); + $.ajax({ method: "PUT", url: OC.generateUrl("apps/onlyoffice/ajax/settings"), @@ -72,7 +74,8 @@ documentserverInternal: onlyofficeInternalUrl, storageUrl: onlyofficeStorageUrl, secret: onlyofficeSecret, - defFormats: defFormats + defFormats: defFormats, + sameTab: sameTab }, success: function onSuccess(response) { $(".section-onlyoffice").removeClass("icon-loading"); |