From 5161564f3d70d1434bc6f7469217de45bb272ff8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 6 Mar 2009 13:40:59 +0300 Subject: add support for adding syndicated notes to published articles --- viewfeed.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) (limited to 'viewfeed.js') diff --git a/viewfeed.js b/viewfeed.js index be1a442e0..d21e3e623 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -15,6 +15,39 @@ var post_under_pointer = false; var last_requested_article = false; +function toggle_published_callback(transport) { + try { + if (transport.responseXML) { + + all_counters_callback2(transport); + + var note = transport.responseXML.getElementsByTagName("note")[0]; + + if (note) { + var note_id = note.getAttribute("id"); + var note_size = note.getAttribute("size"); + var note_content = note.firstChild.nodeValue; + + var container = $('POSTNOTE-' + note_id); + + cache_invalidate(note_id); + + if (container) { + if (note_size == "0") { + Element.hide(container); + } else { + container.innerHTML = note_content; + Element.show(container); + } + } + } + } + + } catch (e) { + exception_error("toggle_published_callback", e, transport); + } +} + function catchup_callback2(transport, callback) { try { debug("catchup_callback2 " + transport + ", " + callback); @@ -592,13 +625,19 @@ function toggleMark(id, client_only, no_effects) { } } -function togglePub(id, client_only, no_effects) { +function togglePub(id, client_only, no_effects, note) { try { var query = "backend.php?op=rpc&id=" + id + "&subop=publ"; query = query + "&afid=" + getActiveFeedId(); + + if (note != undefined) { + query = query + "¬e=" + param_escape(note); + } else { + query = query + "¬e=undefined"; + } if (tagsAreDisplayed()) { query = query + "&omode=tl"; @@ -613,11 +652,10 @@ function togglePub(id, client_only, no_effects) { var vfeedu = $("FEEDU--2"); var crow = $("RROW-" + id); - if (mark_img.src.match("pub_unset")) { + if (mark_img.src.match("pub_unset") || note != undefined) { mark_img.src = mark_img.src.replace("pub_unset", "pub_set"); mark_img.alt = __("Unpublish article"); query = query + "&pub=1"; - } else { //mark_img.src = "images/pub_unset.png"; @@ -635,7 +673,7 @@ function togglePub(id, client_only, no_effects) { if (!client_only) { new Ajax.Request(query, { onComplete: function(transport) { - all_counters_callback2(transport); + toggle_published_callback(transport); } }); } @@ -2147,3 +2185,18 @@ function toggleHeadlineActions() { exception_error("toggleHeadlineActions", e); } } + +function publishWithNote(id, def_note) { + try { + if (!def_note) def_note = ''; + + var note = prompt(__("Please enter a note for this article:"), def_note); + + if (note != undefined) { + togglePub(id, false, false, note); + } + + } catch (e) { + exception_error("publishWithNote", e); + } +} -- cgit v1.2.3