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,12 +43,22 @@ class tagger extends Extension {
$this->theme->build($page, $tags); $this->theme->build($page, $tags);
} }
if(is_a($event,"PageRequestEvent") && $event->page_name == "about" if(is_a($event,"PageRequestEvent")) {
&& $event->get_arg(0) == "tagger") if($event->page_name == "about" && $event->get_arg(0) == "tagger") {
{
global $page; global $page;
$this->theme->show_about($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')) { if(is_a($event, 'SetupBuildingEvent')) {
$sb = new SetupBlock("Tagger - Power Tagging"); $sb = new SetupBlock("Tagger - Power Tagging");

View file

@ -17,26 +17,40 @@ var set_button = false;
function taggerInit() { function taggerInit() {
// get imgdata hooks // get imgdata hooks
tags_field = (byId('tags') || getTagsField()); tags_field = getTagsField();
set_button = getSetButton(); set_button = getSetButton();
// Set up Tagger // 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() tagger_tagIndicators()
DragHandler.attach(byId("tagger_titlebar")); DragHandler.attach(byId("tagger_titlebar"));
remove_tagme = byId('tagme'); 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 = byId("tagger_window");
var pos = new Array();
if(!x || !y) {
tagger.style.top=""; tagger.style.top="";
tagger.style.left=""; tagger.style.left="";
tagger.style.right="25px"; tagger.style.right="25px";
tagger.style.bottom="25px"; tagger.style.bottom="25px";
// get location in (left,top) terms // get location in (left,top) terms
pos = findPos(tagger); pos = findPos(tagger);
} else {
pos[0] = x;
pos[1] = y;
}
tagger.style.top = pos[1]+"px"; tagger.style.top = pos[1]+"px";
tagger.style.left = pos[0]+"px"; tagger.style.left = pos[0]+"px";
@ -44,6 +58,16 @@ function taggerResetPos() {
tagger.style.bottom=""; 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() { function tagger_tagIndicators() {
tags = byId("tags"); tags = byId("tags");
arObjTags = getElementsByTagNames('a',byId('tagger_body')); arObjTags = getElementsByTagNames('a',byId('tagger_body'));
@ -111,7 +135,6 @@ function tagExists(objTag) {
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
function tagger_filter() { function tagger_filter() {
if(tagger_filter_focus) {
var filter = byId('tagger_new-tag'); var filter = byId('tagger_new-tag');
var arObjTags = getElementsByTagNames('a',byId('tagger_body')); var arObjTags = getElementsByTagNames('a',byId('tagger_body'));
var prepend = filter.value.length<2? " ":"_"; var prepend = filter.value.length<2? " ":"_";
@ -127,7 +150,6 @@ function tagger_filter() {
objTag.style.display='none'; objTag.style.display='none';
} }
} }
}
} }
function taggerToggleMode() { function taggerToggleMode() {
var obj = byId('tagger_mode'); var obj = byId('tagger_mode');

View file

@ -32,13 +32,12 @@ class taggerTheme extends Themelet {
$html = " $html = "
<img src='$base_href/ext/tagger/onload.gif' style='display:none;' <img src='$base_href/ext/tagger/onload.gif' style='display:none;'
onload='taggerInit();' /> onload='taggerInit();' />
<span style='font-size:0.7em;'> <div style='font-size:0.7em;'>
Collapse this block to hide Tagger Collapse this block to hide Tagger
</span> </div>
<br/> <a href='$url_about'>About Tagger</a>
<a onclick='taggerResetPos();' class='tagger_js'>Default Location</a>
<hr/> <hr/>
<a href='$url_about'>About Tagger</a>". <button onclick='taggerResetPos();' class='tagger_js'>Default Location</button>".
// Tagger Floater // Tagger Floater
"<div id='tagger_window'> "<div id='tagger_window'>
<div id='tagger_titlebar' title='Drag to move'>Tagger</div> <div id='tagger_titlebar' title='Drag to move'>Tagger</div>
@ -137,6 +136,25 @@ class taggerTheme extends Themelet {
$page->add_block( new Block("Use", $html,"main",1)); $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) { final function tag_to_html ($tag) {
// Important for script.js, no override. You can CSS this, though. // Important for script.js, no override. You can CSS this, though.