summaryrefslogtreecommitdiff
path: root/js/note_button.js
blob: c9347ab1972c9a0a340bf77d36d1771451b39604 (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
40
41
42
43
44
45
46
47
48
49
50
51
function editArticleNote(id) {
	try {

		var query = "backend.php?op=rpc&method=buttonPlugin&plugin=note&plugin_method=edit&param=" + param_escape(id);

		if (dijit.byId("editNoteDlg"))
			dijit.byId("editNoteDlg").destroyRecursive();

		dialog = new dijit.Dialog({
			id: "editNoteDlg",
			title: __("Edit article note"),
			style: "width: 600px",
			execute: function() {
				if (this.validate()) {
					var query = dojo.objectToQuery(this.attr('value'));

					notify_progress("Saving article note...", true);

					new Ajax.Request("backend.php",	{
					parameters: query,
					onComplete: function(transport) {
						notify('');
						dialog.hide();

						var reply = JSON.parse(transport.responseText);

						cache_delete("article:" + id);

						var elem = $("POSTNOTE-" + id);

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

							if (reply.raw_length != 0)
								new Effect.Appear(elem);
						}

					}});
				}
			},
			href: query,
		});

		dialog.show();

	} catch (e) {
		exception_error("editArticleNote", e);
	}
}