1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2026-02-05 03:37:11 +00:00

remove some plugin JS code out of global context

This commit is contained in:
Andrew Dolgov
2018-12-03 10:51:14 +03:00
parent 84affc7b1d
commit 78cc470193
10 changed files with 57 additions and 64 deletions

View File

@@ -40,7 +40,7 @@ class Share extends Plugin {
print "<p>" . __("You can disable all articles shared by unique URLs here.") . "</p>";
print "<button class=\"btn-danger\" dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">".
print "<button class=\"btn-danger\" dojoType=\"dijit.form.Button\" onclick=\"return Plugins.Share.clearKeys()\">".
__('Unshare all articles')."</button> ";
print "</p>";
@@ -74,7 +74,7 @@ class Share extends Plugin {
return "<img id='SHARE-IMG-".$line['int_id']."' src=\"plugins/share/$img\"
class='tagsPic' style=\"cursor : pointer\"
onclick=\"shareArticle(".$line['int_id'].")\"
onclick=\"Plugins.Share.shareArticle(".$line['int_id'].")\"
title='".__('Share by URL')."'>";
}

View File

@@ -1,20 +1,20 @@
function shareArticle(id) {
try {
Plugins.Share = {
shareArticle: function(id) {
if (dijit.byId("shareArticleDlg"))
dijit.byId("shareArticleDlg").destroyRecursive();
var query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle&param=" + encodeURIComponent(id);
const query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle&param=" + encodeURIComponent(id);
dialog = new dijit.Dialog({
const dialog = new dijit.Dialog({
id: "shareArticleDlg",
title: __("Share article by URL"),
style: "width: 600px",
newurl: function() {
newurl: function () {
if (confirm(__("Generate new share URL for this article?"))) {
Notify.progress("Trying to change URL...", true);
const query = { op: "pluginhandler", plugin: "share", method: "newkey", id: id };
const query = {op: "pluginhandler", plugin: "share", method: "newkey", id: id};
xhrJson("backend.php", query, (reply) => {
if (reply) {
@@ -44,12 +44,12 @@ function shareArticle(id) {
}
},
unshare: function() {
unshare: function () {
if (confirm(__("Remove sharing for this article?"))) {
Notify.progress("Trying to unshare...", true);
const query = { op: "pluginhandler", plugin: "share", method: "unshare", id: id };
const query = {op: "pluginhandler", plugin: "share", method: "unshare", id: id};
xhrPost("backend.php", query, () => {
notify("Article unshared.");
@@ -62,16 +62,15 @@ function shareArticle(id) {
}
},
href: query});
href: query
});
dialog.show();
const img = $("SHARE-IMG-" + id);
if (img) img.src = img.src.replace("notshared.png", "share.png");
} catch (e) {
exception_error("shareArticle", e);
}
}
};

View File

@@ -1,16 +1,15 @@
function clearArticleAccessKeys() {
if (confirm(__("This will invalidate all previously shared article URLs. Continue?"))) {
Notify.progress("Clearing URLs...");
Plugins.Share = {
clearKeys: function() {
if (confirm(__("This will invalidate all previously shared article URLs. Continue?"))) {
Notify.progress("Clearing URLs...");
const query = { op: "pluginhandler", plugin: "share", method: "clearArticleKeys" };
const query = {op: "pluginhandler", plugin: "share", method: "clearArticleKeys"};
xhrPost("backend.php", query, () => {
Notify.info("Shared URLs cleared.");
});
xhrPost("backend.php", query, () => {
Notify.info("Shared URLs cleared.");
});
}
return false;
}
return false;
}
};