Tagger 20071002 1144

git-svn-id: file:///home/shish/svn/shimmie2/trunk@508 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
Artanis 2007-10-02 18:44:29 +00:00
parent 49606dad70
commit 4716ebe79d
3 changed files with 86 additions and 36 deletions

View file

@ -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')) {

View file

@ -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';
}
}
}

View file

@ -32,13 +32,12 @@ class taggerTheme extends Themelet {
$html = "
<img src='$base_href/ext/tagger/onload.gif' style='display:none;'
onload='taggerInit();' />
<span style='font-size:0.7em;'>
<div style='font-size:0.7em;'>
Collapse this block to hide Tagger
</span>
<br/>
<a onclick='taggerResetPos();' class='tagger_js'>Default Location</a>
</div>
<a href='$url_about'>About Tagger</a>
<hr/>
<a href='$url_about'>About Tagger</a>".
<button onclick='taggerResetPos();' class='tagger_js'>Default Location</button>".
// Tagger Floater
"<div id='tagger_window'>
<div id='tagger_titlebar' title='Drag to move'>Tagger</div>
@ -136,7 +135,26 @@ class taggerTheme extends Themelet {
"Artanis (Erik Youngren &lt;artanis.00@gmail.com&gt;)","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="<table>";
$html .= "<tr><th>Set Name</th><th>Tags</th></tr>";
foreach($presets as $keyname => $tags) {
$html .= "<tr><td>$keyname</td><td>$tags</td></tr>";
}
$html .= "</table>";
$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.