remove some plugin JS code out of global context
This commit is contained in:
parent
84affc7b1d
commit
78cc470193
|
@ -907,8 +907,8 @@ class Article extends Handler_Protected {
|
||||||
|
|
||||||
static function format_article_note($id, $note, $allow_edit = true) {
|
static function format_article_note($id, $note, $allow_edit = true) {
|
||||||
|
|
||||||
$str = "<div class='articleNote' onclick=\"editArticleNote($id)\">
|
$str = "<div class='articleNote' onclick=\"Plugins.Note.edit($id)\">
|
||||||
<div class='noteEdit' onclick=\"editArticleNote($id)\">".
|
<div class='noteEdit' onclick=\"Plugins.Note.edit($id)\">".
|
||||||
($allow_edit ? __('(edit note)') : "")."</div>$note</div>";
|
($allow_edit ? __('(edit note)') : "")."</div>$note</div>";
|
||||||
|
|
||||||
return $str;
|
return $str;
|
||||||
|
|
|
@ -7,6 +7,8 @@ let Filters;
|
||||||
let Users;
|
let Users;
|
||||||
let Prefs;
|
let Prefs;
|
||||||
|
|
||||||
|
const Plugins = {};
|
||||||
|
|
||||||
require(["dojo/_base/kernel",
|
require(["dojo/_base/kernel",
|
||||||
"dojo/_base/declare",
|
"dojo/_base/declare",
|
||||||
"dojo/ready",
|
"dojo/ready",
|
||||||
|
|
|
@ -10,6 +10,8 @@ let Article;
|
||||||
let ArticleCache;
|
let ArticleCache;
|
||||||
let PluginHost;
|
let PluginHost;
|
||||||
|
|
||||||
|
const Plugins = {};
|
||||||
|
|
||||||
require(["dojo/_base/kernel",
|
require(["dojo/_base/kernel",
|
||||||
"dojo/_base/declare",
|
"dojo/_base/declare",
|
||||||
"dojo/ready",
|
"dojo/ready",
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
function showTrgmRelated(id) {
|
Plugins.Psql_Trgm = {
|
||||||
try {
|
showRelated: function (id) {
|
||||||
|
|
||||||
const query = "backend.php?op=pluginhandler&plugin=af_psql_trgm&method=showrelated¶m=" + encodeURIComponent(id);
|
const query = "backend.php?op=pluginhandler&plugin=af_psql_trgm&method=showrelated¶m=" + encodeURIComponent(id);
|
||||||
|
|
||||||
if (dijit.byId("trgmRelatedDlg"))
|
if (dijit.byId("trgmRelatedDlg"))
|
||||||
|
@ -10,16 +9,13 @@ function showTrgmRelated(id) {
|
||||||
id: "trgmRelatedDlg",
|
id: "trgmRelatedDlg",
|
||||||
title: __("Related articles"),
|
title: __("Related articles"),
|
||||||
style: "width: 600px",
|
style: "width: 600px",
|
||||||
execute: function() {
|
execute: function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
href: query,
|
href: query,
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
exception_error("showTrgmRelated", e);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ class Af_Psql_Trgm extends Plugin {
|
||||||
function hook_article_button($line) {
|
function hook_article_button($line) {
|
||||||
return "<img src=\"plugins/af_psql_trgm/button.png\"
|
return "<img src=\"plugins/af_psql_trgm/button.png\"
|
||||||
style=\"cursor : pointer\" style=\"cursor : pointer\"
|
style=\"cursor : pointer\" style=\"cursor : pointer\"
|
||||||
onclick=\"showTrgmRelated(".$line["id"].")\"
|
onclick=\"Plugins.Psql_Trgm.showRelated(".$line["id"].")\"
|
||||||
class='tagsPic' title='".__('Show related articles')."'>";
|
class='tagsPic' title='".__('Show related articles')."'>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Note extends Plugin {
|
||||||
function hook_article_button($line) {
|
function hook_article_button($line) {
|
||||||
return "<img src=\"plugins/note/note.png\"
|
return "<img src=\"plugins/note/note.png\"
|
||||||
style=\"cursor : pointer\" style=\"cursor : pointer\"
|
style=\"cursor : pointer\" style=\"cursor : pointer\"
|
||||||
onclick=\"editArticleNote(".$line["id"].")\"
|
onclick=\"Plugins.Note.edit(".$line["id"].")\"
|
||||||
class='tagsPic' title='".__('Edit article note')."'>";
|
class='tagsPic' title='".__('Edit article note')."'>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,46 +1,41 @@
|
||||||
function editArticleNote(id) {
|
Plugins.Note = {
|
||||||
try {
|
edit: function(id) {
|
||||||
|
const query = "backend.php?op=pluginhandler&plugin=note&method=edit¶m=" + encodeURIComponent(id);
|
||||||
var query = "backend.php?op=pluginhandler&plugin=note&method=edit¶m=" + encodeURIComponent(id);
|
|
||||||
|
|
||||||
if (dijit.byId("editNoteDlg"))
|
if (dijit.byId("editNoteDlg"))
|
||||||
dijit.byId("editNoteDlg").destroyRecursive();
|
dijit.byId("editNoteDlg").destroyRecursive();
|
||||||
|
|
||||||
dialog = new dijit.Dialog({
|
const dialog = new dijit.Dialog({
|
||||||
id: "editNoteDlg",
|
id: "editNoteDlg",
|
||||||
title: __("Edit article note"),
|
title: __("Edit article note"),
|
||||||
style: "width: 600px",
|
style: "width: 600px",
|
||||||
execute: function() {
|
execute: function () {
|
||||||
if (this.validate()) {
|
if (this.validate()) {
|
||||||
Notify.progress("Saving article note...", true);
|
Notify.progress("Saving article note...", true);
|
||||||
|
|
||||||
xhrJson("backend.php", this.attr('value'), (reply) => {
|
xhrJson("backend.php", this.attr('value'), (reply) => {
|
||||||
Notify.close();
|
Notify.close();
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
|
|
||||||
if (reply) {
|
if (reply) {
|
||||||
ArticleCache.del(id);
|
ArticleCache.del(id);
|
||||||
|
|
||||||
var elem = $("POSTNOTE-" + id);
|
var elem = $("POSTNOTE-" + id);
|
||||||
|
|
||||||
if (elem) {
|
if (elem) {
|
||||||
Element.hide(elem);
|
Element.hide(elem);
|
||||||
elem.innerHTML = reply.note;
|
elem.innerHTML = reply.note;
|
||||||
|
|
||||||
if (reply.raw_length != 0)
|
if (reply.raw_length != 0)
|
||||||
new Effect.Appear(elem);
|
new Effect.Appear(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
href: query,
|
href: query,
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
exception_error("editArticleNote", e);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -40,7 +40,7 @@ class Share extends Plugin {
|
||||||
|
|
||||||
print "<p>" . __("You can disable all articles shared by unique URLs here.") . "</p>";
|
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> ";
|
__('Unshare all articles')."</button> ";
|
||||||
|
|
||||||
print "</p>";
|
print "</p>";
|
||||||
|
@ -74,7 +74,7 @@ class Share extends Plugin {
|
||||||
|
|
||||||
return "<img id='SHARE-IMG-".$line['int_id']."' src=\"plugins/share/$img\"
|
return "<img id='SHARE-IMG-".$line['int_id']."' src=\"plugins/share/$img\"
|
||||||
class='tagsPic' style=\"cursor : pointer\"
|
class='tagsPic' style=\"cursor : pointer\"
|
||||||
onclick=\"shareArticle(".$line['int_id'].")\"
|
onclick=\"Plugins.Share.shareArticle(".$line['int_id'].")\"
|
||||||
title='".__('Share by URL')."'>";
|
title='".__('Share by URL')."'>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
function shareArticle(id) {
|
Plugins.Share = {
|
||||||
try {
|
shareArticle: function(id) {
|
||||||
if (dijit.byId("shareArticleDlg"))
|
if (dijit.byId("shareArticleDlg"))
|
||||||
dijit.byId("shareArticleDlg").destroyRecursive();
|
dijit.byId("shareArticleDlg").destroyRecursive();
|
||||||
|
|
||||||
var query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle¶m=" + encodeURIComponent(id);
|
const query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle¶m=" + encodeURIComponent(id);
|
||||||
|
|
||||||
dialog = new dijit.Dialog({
|
const dialog = new dijit.Dialog({
|
||||||
id: "shareArticleDlg",
|
id: "shareArticleDlg",
|
||||||
title: __("Share article by URL"),
|
title: __("Share article by URL"),
|
||||||
style: "width: 600px",
|
style: "width: 600px",
|
||||||
newurl: function() {
|
newurl: function () {
|
||||||
if (confirm(__("Generate new share URL for this article?"))) {
|
if (confirm(__("Generate new share URL for this article?"))) {
|
||||||
|
|
||||||
Notify.progress("Trying to change URL...", true);
|
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) => {
|
xhrJson("backend.php", query, (reply) => {
|
||||||
if (reply) {
|
if (reply) {
|
||||||
|
@ -44,12 +44,12 @@ function shareArticle(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
unshare: function() {
|
unshare: function () {
|
||||||
if (confirm(__("Remove sharing for this article?"))) {
|
if (confirm(__("Remove sharing for this article?"))) {
|
||||||
|
|
||||||
Notify.progress("Trying to unshare...", true);
|
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, () => {
|
xhrPost("backend.php", query, () => {
|
||||||
notify("Article unshared.");
|
notify("Article unshared.");
|
||||||
|
@ -62,16 +62,15 @@ function shareArticle(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
href: query});
|
href: query
|
||||||
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
const img = $("SHARE-IMG-" + id);
|
const img = $("SHARE-IMG-" + id);
|
||||||
if (img) img.src = img.src.replace("notshared.png", "share.png");
|
if (img) img.src = img.src.replace("notshared.png", "share.png");
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
exception_error("shareArticle", e);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
function clearArticleAccessKeys() {
|
Plugins.Share = {
|
||||||
if (confirm(__("This will invalidate all previously shared article URLs. Continue?"))) {
|
clearKeys: function() {
|
||||||
Notify.progress("Clearing URLs...");
|
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, () => {
|
xhrPost("backend.php", query, () => {
|
||||||
Notify.info("Shared URLs cleared.");
|
Notify.info("Shared URLs cleared.");
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue