diff --git a/contrib/tagger/main.php b/contrib/tagger/main.php index 54456cf1..8fa492d0 100644 --- a/contrib/tagger/main.php +++ b/contrib/tagger/main.php @@ -43,11 +43,21 @@ class tagger extends Extension { $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,"PageRequestEvent")) { + if($event->page_name == "about" && $event->get_arg(0) == "tagger") { + global $page; + $this->theme->show_about($page); + } + if($event->page_name == "tagger") { + global $page; +// $this->theme->configTagger($page); + } + } + + if(is_a($event, 'UserBlockBuildingEvent')) { + if($event->user->is_admin()) { +// $event->add_link("Tagger Config", make_link("tagger")); + } } if(is_a($event, 'SetupBuildingEvent')) { diff --git a/contrib/tagger/script.js b/contrib/tagger/script.js index f5787e23..f75f20ce 100644 --- a/contrib/tagger/script.js +++ b/contrib/tagger/script.js @@ -17,26 +17,40 @@ var set_button = false; function taggerInit() { // get imgdata hooks - tags_field = (byId('tags') || getTagsField()); + tags_field = getTagsField(); set_button = getSetButton(); // Set up Tagger - taggerResetPos(); + // Get last position + c = getCookie('shimmie-tagger-position'); + c = c ? c.replace(/px/g,"").split(" ") : new Array(null,null); + taggerResetPos(c[0],c[1]); + tagger_tagIndicators() DragHandler.attach(byId("tagger_titlebar")); remove_tagme = byId('tagme'); + + // save position cookie on unload. + window.onunload = function(e) { + taggerSavePosition(); + }; } -function taggerResetPos() { +function taggerResetPos(x,y) { tagger = byId("tagger_window"); - - tagger.style.top=""; - tagger.style.left=""; - tagger.style.right="25px"; - tagger.style.bottom="25px"; - - // get location in (left,top) terms - pos = findPos(tagger); + + var pos = new Array(); + if(!x || !y) { + tagger.style.top=""; + tagger.style.left=""; + tagger.style.right="25px"; + tagger.style.bottom="25px"; + // get location in (left,top) terms + pos = findPos(tagger); + } else { + pos[0] = x; + pos[1] = y; + } tagger.style.top = pos[1]+"px"; tagger.style.left = pos[0]+"px"; @@ -44,6 +58,16 @@ function taggerResetPos() { tagger.style.bottom=""; } +function taggerSavePosition() { + tw = byId('tagger_window'); + if (tw) { + xy = tw.style.left +" "+ tw.style.top + setCookie('shimmie-tagger-position',xy); + return true; + } + return false; +} + function tagger_tagIndicators() { tags = byId("tags"); arObjTags = getElementsByTagNames('a',byId('tagger_body')); @@ -111,21 +135,19 @@ function tagExists(objTag) { \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ function tagger_filter() { - if(tagger_filter_focus) { - var filter = byId('tagger_new-tag'); - var arObjTags = getElementsByTagNames('a',byId('tagger_body')); - var prepend = filter.value.length<2? " ":"_"; - var search = prepend + reescape(filter.value); - - for(i in arObjTags) { - objTag = arObjTags[i]; - tag = prepend + objTag.getAttribute('tag'); + var filter = byId('tagger_new-tag'); + var arObjTags = getElementsByTagNames('a',byId('tagger_body')); + var prepend = filter.value.length<2? " ":"_"; + var search = prepend + reescape(filter.value); + + for(i in arObjTags) { + objTag = arObjTags[i]; + tag = prepend + objTag.getAttribute('tag'); - if(tag.match(search) && taggerFilterMode(objTag)) { - objTag.style.display=''; - } else { - objTag.style.display='none'; - } + if(tag.match(search) && taggerFilterMode(objTag)) { + objTag.style.display=''; + } else { + objTag.style.display='none'; } } } diff --git a/contrib/tagger/theme.php b/contrib/tagger/theme.php index 3500d84f..bee561a9 100644 --- a/contrib/tagger/theme.php +++ b/contrib/tagger/theme.php @@ -32,13 +32,12 @@ class taggerTheme extends Themelet { $html = " - +
Collapse this block to hide Tagger - -
- Default Location +
+ About Tagger
- About Tagger". + ". // Tagger Floater "
Tagger
@@ -136,7 +135,26 @@ class taggerTheme extends Themelet { "Artanis (Erik Youngren <artanis.00@gmail.com>)","main",0)); $page->add_block( new Block("Use", $html,"main",1)); } - + + function configTagger($page/*,$presets*/) { + $presets = array( + 'test_set_01' => 'tag set 01', + 'test_set_02' => 'tag set 02', + 'tsuryuya' => 'tsuryuya hair_green eyes_yellow suzumiya_haruhi_no_yuutsu', + 'suzumiya_haruhi' => 'suzumiya_haruhi hair_brown eyes_brown suzumiya_haruhi_no_yuutsu'); + + $html=""; + $html .= ""; + foreach($presets as $keyname => $tags) { + $html .= ""; + } + $html .= "
Set NameTags
$keyname$tags
"; + + + $page->set_title("Shimmie / Configure / Tagger"); + $page->set_heading("Configure / Tagger"); + $page->add_block( new Block("Tag Presets",$html,'main',0)); + } final function tag_to_html ($tag) { // Important for script.js, no override. You can CSS this, though.