From 98d01eb19e5824b6fd457f8d0876447cc8c87583 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 11 Jul 2013 14:03:40 +0400 Subject: allow unsharing specific articles / creating new share key --- plugins/share/share.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'plugins/share/share.js') diff --git a/plugins/share/share.js b/plugins/share/share.js index 6752189ea..bbfb553d5 100644 --- a/plugins/share/share.js +++ b/plugins/share/share.js @@ -9,12 +9,69 @@ function shareArticle(id) { id: "shareArticleDlg", title: __("Share article by URL"), style: "width: 600px", + newurl: function() { + + var ok = confirm(__("Generate new share URL for this article?")); + + if (ok) { + + notify_progress("Trying to change URL...", true); + + var query = "op=pluginhandler&plugin=share&method=newkey&id=" + param_escape(id); + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + var reply = JSON.parse(transport.responseText); + var new_link = reply.link; + + var e = $('gen_article_url'); + + if (new_link) { + + e.innerHTML = e.innerHTML.replace(/\&key=.*$/, + "&key=" + new_link); + + e.href = e.href.replace(/\&key=.*$/, + "&key=" + new_link); + + new Effect.Highlight(e); + + notify(''); + + } else { + notify_error("Could not change URL."); + } + } }); + + } + + }, + unshare: function() { + + var ok = confirm(__("Remove sharing for this article?")); + + if (ok) { + + notify_progress("Trying to unshare...", true); + + var query = "op=pluginhandler&plugin=share&method=unshare&id=" + param_escape(id); + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + notify("Article unshared."); + dialog.hide(); + } }); + } + + }, href: query}); dialog.show(); } catch (e) { - exception_error("emailArticle", e); + exception_error("shareArticle", e); } } -- cgit v1.2.3 From abb04b76a51eb871a45011da55efb222924d50ee Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 11 Jul 2013 16:20:24 +0400 Subject: share: indicate whether article is shared or not using the icon --- plugins/share/share.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'plugins/share/share.js') diff --git a/plugins/share/share.js b/plugins/share/share.js index bbfb553d5..09c973ed8 100644 --- a/plugins/share/share.js +++ b/plugins/share/share.js @@ -37,6 +37,9 @@ function shareArticle(id) { new Effect.Highlight(e); + var img = $("SHARE-IMG-" + id); + if (img) img.src = img.src.replace("notshared.png", "share.png"); + notify(''); } else { @@ -61,6 +64,10 @@ function shareArticle(id) { parameters: query, onComplete: function(transport) { notify("Article unshared."); + + var img = $("SHARE-IMG-" + id); + if (img) img.src = img.src.replace("share.png", "notshared.png"); + dialog.hide(); } }); } @@ -70,6 +77,9 @@ function shareArticle(id) { dialog.show(); + var img = $("SHARE-IMG-" + id); + if (img) img.src = img.src.replace("notshared.png", "share.png"); + } catch (e) { exception_error("shareArticle", e); } -- cgit v1.2.3