summaryrefslogtreecommitdiff
path: root/plugins/note
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-12-03 10:51:14 +0300
committerAndrew Dolgov <[email protected]>2018-12-03 10:51:14 +0300
commit78cc470193448048759b3f315ee630e50acb064b (patch)
treedcb14ea4a2ba9c10666b7b2669bf7776bc04d6b4 /plugins/note
parent84affc7b1d71769038dfd25d74e40d6bf744e5fb (diff)
remove some plugin JS code out of global context
Diffstat (limited to 'plugins/note')
-rw-r--r--plugins/note/init.php2
-rw-r--r--plugins/note/note.js43
2 files changed, 20 insertions, 25 deletions
diff --git a/plugins/note/init.php b/plugins/note/init.php
index 354591b75..ac908a5ba 100644
--- a/plugins/note/init.php
+++ b/plugins/note/init.php
@@ -24,7 +24,7 @@ class Note extends Plugin {
function hook_article_button($line) {
return "<img src=\"plugins/note/note.png\"
style=\"cursor : pointer\" style=\"cursor : pointer\"
- onclick=\"editArticleNote(".$line["id"].")\"
+ onclick=\"Plugins.Note.edit(".$line["id"].")\"
class='tagsPic' title='".__('Edit article note')."'>";
}
diff --git a/plugins/note/note.js b/plugins/note/note.js
index 836481c40..21c1ae51e 100644
--- a/plugins/note/note.js
+++ b/plugins/note/note.js
@@ -1,46 +1,41 @@
-function editArticleNote(id) {
- try {
-
- var query = "backend.php?op=pluginhandler&plugin=note&method=edit&param=" + encodeURIComponent(id);
+Plugins.Note = {
+ edit: function(id) {
+ const query = "backend.php?op=pluginhandler&plugin=note&method=edit&param=" + encodeURIComponent(id);
if (dijit.byId("editNoteDlg"))
dijit.byId("editNoteDlg").destroyRecursive();
- dialog = new dijit.Dialog({
+ const dialog = new dijit.Dialog({
id: "editNoteDlg",
title: __("Edit article note"),
style: "width: 600px",
- execute: function() {
+ execute: function () {
if (this.validate()) {
Notify.progress("Saving article note...", true);
xhrJson("backend.php", this.attr('value'), (reply) => {
- Notify.close();
- dialog.hide();
+ Notify.close();
+ dialog.hide();
- if (reply) {
- ArticleCache.del(id);
+ if (reply) {
+ ArticleCache.del(id);
- var elem = $("POSTNOTE-" + id);
+ var elem = $("POSTNOTE-" + id);
- if (elem) {
- Element.hide(elem);
- elem.innerHTML = reply.note;
+ if (elem) {
+ Element.hide(elem);
+ elem.innerHTML = reply.note;
- if (reply.raw_length != 0)
- new Effect.Appear(elem);
- }
- }
- });
+ if (reply.raw_length != 0)
+ new Effect.Appear(elem);
+ }
+ }
+ });
}
},
href: query,
});
dialog.show();
-
- } catch (e) {
- exception_error("editArticleNote", e);
}
-}
-
+}; \ No newline at end of file