From ef0e4190cccc43f49ad9460c51b075737bca7114 Mon Sep 17 00:00:00 2001 From: Artanis Date: Fri, 28 Sep 2007 05:10:44 +0000 Subject: [PATCH] Tagger 20070927 2209 +onload.gif because I needed window.onload and core_scripts/scripts.js hogged it. Getting by with img.onload. git-svn-id: file:///home/shish/svn/shimmie2/trunk@497 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/tagger/main.php | 32 +++++++++++++++--- contrib/tagger/onload.gif | Bin 0 -> 43 bytes contrib/tagger/script.js | 69 ++++++++++++++++++++++++-------------- contrib/tagger/style.css | 7 ++-- contrib/tagger/theme.php | 25 +++++++++----- 5 files changed, 94 insertions(+), 39 deletions(-) create mode 100644 contrib/tagger/onload.gif diff --git a/contrib/tagger/main.php b/contrib/tagger/main.php index 82983a1b..3acb8bed 100644 --- a/contrib/tagger/main.php +++ b/contrib/tagger/main.php @@ -1,10 +1,26 @@ ) +// Do not remove this notice. + class tagger extends Extension { var $theme; public function receive_event ($event) { if(is_null($this->theme)) $this->theme = get_theme_object("tagger", "taggerTheme"); + + if(is_a($event,"InitExtEvent")) { + global $config; + if ($config->get_int("ext-tagger_tags-min") == -1) + $config->set_int("ext-tagger_tags-min",2); + + if ($config->get_string("ext-tagger_clear-tagme") == -1) + $config->set_bool("ext-tagger_clear-tagme",false); + + if ($config->get_string("ext-tagger_show-hidden") == -1) + $config->set_bool("ext-tagger_show-hidden",false); + } if(is_a($event,"DisplayingImageEvent")) { //show tagger box @@ -13,24 +29,32 @@ class tagger extends Extension { global $config; $base_href = $config->get_string('base_href'); + $tags_min = $config->get_int('ext-tagger_tags-min',2); + $hidden = $config->get_bool('ext-tagger_respect-hidden',true) ? "AND substring(tag,1,1) != '.' " : null; $tags = $database->Execute(" SELECT tag FROM `tags` - WHERE count > 1 AND substring(tag,1,1) != '.' - ORDER BY tag"); + WHERE count >= ? {$hidden} + ORDER BY tag",array($tags_min)); $this->theme->build($page, $tags); } - - if(is_a($event,"PageRequestEvent") && $event->page_name == "about" && $event->get_arg(0) == "tagger") { global $page; $this->theme->show_about($page); } + + if(is_a($event, 'SetupBuildingEvent')) { + $sb = new SetupBlock("Tagger - Power Tagging"); + $sb->add_bool_option("ext-tagger_show-hidden", "Show Hidden Tags"); + $sb->add_bool_option("ext-tagger_clear-tagme", "
Remove 'tagme' on use"); + $sb->add_int_option("ext-tagger_tags-min", "
Ignore tags used fewer than "); $sb->add_label("times."); + $event->panel->add_block($sb); + } } } add_event_listener( new tagger()); diff --git a/contrib/tagger/onload.gif b/contrib/tagger/onload.gif new file mode 100644 index 0000000000000000000000000000000000000000..e565824aafafe632011b281cba976baf8b3ba89a GIT binary patch literal 43 qcmZ?wbhEHbWMp7uXkcLY4+e@qSs1y10y+#p0Fq%~V)9{Rum%7ZWeN!Z literal 0 HcmV?d00001 diff --git a/contrib/tagger/script.js b/contrib/tagger/script.js index 69b1b3a1..9c200691 100644 --- a/contrib/tagger/script.js +++ b/contrib/tagger/script.js @@ -1,9 +1,11 @@ -// Tagger JS -// Original Code Author: Artanis (Erik Youngren ) +// Tagger - Advanced Tagging +// Author: Artanis (Erik Youngren ) +// Do not remove this notice. // All other code copyright by their authors, see comments for details. -// In case the drag point goes off screen. + function taggerResetPos() { + // In case the drag point goes off screen. tagger = byId("tagger_window"); // reset default position (bottom right.) @@ -36,26 +38,16 @@ function tagExists(tag) { return false; } -function toggleTag(tag) { - var tags = byId("tags"); - var tag_link = byId("tagger_tag_"+tag); +function toggleTag(tag,rTagme) { + + if (!tagExists(tag)) { - // append tag to tag box. - tags.value = tags.value +" "+ tag; - // set indicator - if(tag_link) { - tag_link.style.fontWeight = "bold"; + addTag(tag); + if(rTagme && tag != "tagme") { + remTag("tagme"); } } else { - // remove tag - tags.value=" " + tags.value + " "; // catch first and last tag, too - tags.value=tags.value.replace(" "+tag+" "," "); - // remove extra spaces. - tags.value=tags.value.replace(" "," "); - // set indicator - if(tag_link) { - tag_link.style.fontWeight = ""; - } + remTag(tag); } obj = byId("tagger_custTag"); if(obj.value) { @@ -68,12 +60,39 @@ function addTagById(id) { toggleTag(tag.value); } -function setTagIndicators() { - tagger = byId("tagger_window"); - // core.js took window.onload, so emulate it by using onclick and then - // removing the event. - tagger.setAttribute("onmousedown",""); +function addTag (tag) { + var tags = byId("tags"); + var tag_link = byId("tagger_tag_"+tag); + var delim = " "; + if(tags.value == "") { + delim=""; + } + tags.value = tags.value + delim + tag; + if(tag_link) { + tag_link.style.fontWeight = "bold"; + } +} + +function remTag (tag) { + var tags = byId("tags"); + var tag_link = byId("tagger_tag_"+tag); + + _tags = tags.value.split(" "); + + tags.value = ""; + for (i in _tags) { + _tag = _tags[i]; + if(_tag != tag) { + addTag(_tag); + } + } + if(tag_link) { + tag_link.style.fontWeight = ""; + } +} + +function setTagIndicators() { taggerResetPos(); tags = byId("tags"); diff --git a/contrib/tagger/style.css b/contrib/tagger/style.css index 1897ac4a..7b8c99b0 100644 --- a/contrib/tagger/style.css +++ b/contrib/tagger/style.css @@ -1,4 +1,7 @@ -/* Tagger Cascading Style Sheet * +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Tagger - Advanced Tagging * + * Author: Artanis (Erik Youngren ) * + * Do not remove this notice. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #tagger_window { @@ -29,7 +32,7 @@ } #tagger_body a { - font-size:1.5em; + font-size:1.25em; } #Tagger li { diff --git a/contrib/tagger/theme.php b/contrib/tagger/theme.php index 92bc4d43..da06e883 100644 --- a/contrib/tagger/theme.php +++ b/contrib/tagger/theme.php @@ -1,25 +1,34 @@ ) +// Do not remove this notice. + class taggerTheme extends Themelet { public function build ($page, $tags) { + global $config; + + $tagme = $config->get_string("ext-tagger_clear-tagme","N") == "Y" ? "true":"false"; + $base_href = $config->get_string("base_href"); $tag_html = ""; foreach ($tags as $tag) { $tag_name = $tag['tag']; - $tag_trunc = $this->trimTag($tag_name,16); + $tag_trunc = $this->trimTag($tag_name,20,"_"); $tag_html .= "
"." - ".$tag_trunc."". "
"; } $url_more = make_link("about/tagger"); $html = << Collapse this block to hide Tagger.
Default Location
About Tagger -
+
Tagger
@@ -31,16 +40,16 @@ class taggerTheme extends Themelet {
EOD; - $page->add_block( new Block("Tagger", + $page->add_block( new Block("Tagger - Advanced Tagging", "".$html, "left", 50)); } - public function trimTag($s,$len=80) { + public function trimTag($s,$len=80,$break=" ") { if(strlen($s) > $len) { $s = substr($s, 0,$len-1); - $s = substr($s,0, strrpos($s,'_'))."..."; + $s = substr($s,0, strrpos($s,$break))."..."; } return $s; } @@ -77,8 +86,8 @@ EOD; EOD; - $page->set_title("About Extension: Tagger"); - $page->set_heading("About Extension: Tagger"); + $page->set_title("About / Extension / Tagger - Advanced Tagging"); + $page->set_heading("About / Extension / Tagger - Advanced Tagging"); $page->add_block( new Block("Author", "Artanis (Erik Youngren <artanis.00@gmail.com>)","main",0)); $page->add_block( new Block("Use", $html,"main",1));