From 0fc783e2b350b8ac6ff275fd9b201674cbcf2c16 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 22:07:37 +0300 Subject: cleanup markup in some plugins, make nsfw generate dijit widgets --- plugins/nsfw/init.js | 13 +++++--- plugins/nsfw/init.php | 84 +++++++++++++++++++++++---------------------------- 2 files changed, 46 insertions(+), 51 deletions(-) (limited to 'plugins/nsfw') diff --git a/plugins/nsfw/init.js b/plugins/nsfw/init.js index adb6d43c0..4bc2443e8 100644 --- a/plugins/nsfw/init.js +++ b/plugins/nsfw/init.js @@ -1,7 +1,12 @@ -function nsfwShow(elem) { - let content = elem.parentNode.getElementsBySelector("div.nswf.content")[0]; +/* global Plugins */ - if (content) { - Element.toggle(content); +Plugins.NSFW = { + toggle: function(elem) { + const content = elem.domNode.parentNode.querySelector(".nswf.content"); + + if (content) { + Element.toggle(content); + } } } + diff --git a/plugins/nsfw/init.php b/plugins/nsfw/init.php index 1b27cc017..fecbc62af 100644 --- a/plugins/nsfw/init.php +++ b/plugins/nsfw/init.php @@ -27,74 +27,64 @@ class NSFW extends Plugin { $a_tags = array_map("trim", explode(",", $article["tag_cache"])); if (count(array_intersect($tags, $a_tags)) > 0) { - $article["content"] = "
-
"; + $article["content"] = "
". + \Controls\button_tag(__("Not work safe (click to toggle)"), '', ['onclick' => 'Plugins.NSFW.toggle(this)']). + " +
"; } return $article; } function hook_render_article_cdm($article) { - $tags = array_map("trim", explode(",", $this->host->get($this, "tags"))); - $a_tags = array_map("trim", explode(",", $article["tag_cache"])); - - if (count(array_intersect($tags, $a_tags)) > 0) { - $article["content"] = "
-
"; - } - - return $article; + return $this->hook_render_article($article); } function hook_prefs_tab($args) { if ($args != "prefPrefs") return; - print "
extension ".__("NSFW Plugin")."\">"; - - print "
"; - $tags = $this->host->get($this, "tags"); - print "
"; - - print ""; - - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("method", "save"); - print \Controls\hidden_tag("plugin", "nsfw"); - - print ""; - - print ""; - print ""; + - print "
".__("Tags to consider NSFW (comma-separated)")."
"; +
- print "

"; +

+ +
- print "
"; +
- print "
"; #pane + + + + host->set($this, "tags", $tags); -- cgit v1.2.3-54-g00ecf