summaryrefslogtreecommitdiff
path: root/plugins/note/note.js
blob: fec7b04bec352880acf64cd7ed67eaed5efc8c54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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();

		const dialog = new dijit.Dialog({
			id: "editNoteDlg",
			title: __("Edit article note"),
			execute: function () {
				if (this.validate()) {
					Notify.progress("Saving article note...", true);

					xhrJson("backend.php", this.attr('value'), (reply) => {
						Notify.close();
						dialog.hide();

						if (reply) {
							const elem = $("POSTNOTE-" + id);

							if (elem) {
								elem.innerHTML = reply.note;

								if (reply.raw_length != 0)
									Element.show(elem);
								else
									Element.hide(elem);
							}
						}
					});
				}
			},
			href: query,
		});

		dialog.show();
	}
};