Tagger 20071002 1144
git-svn-id: file:///home/shish/svn/shimmie2/trunk@508 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
49606dad70
commit
4716ebe79d
3 changed files with 86 additions and 36 deletions
|
@ -43,11 +43,21 @@ 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')) {
|
||||||
|
|
|
@ -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");
|
||||||
|
|
||||||
tagger.style.top="";
|
var pos = new Array();
|
||||||
tagger.style.left="";
|
if(!x || !y) {
|
||||||
tagger.style.right="25px";
|
tagger.style.top="";
|
||||||
tagger.style.bottom="25px";
|
tagger.style.left="";
|
||||||
|
tagger.style.right="25px";
|
||||||
// get location in (left,top) terms
|
tagger.style.bottom="25px";
|
||||||
pos = findPos(tagger);
|
// get location in (left,top) terms
|
||||||
|
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,21 +135,19 @@ 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? " ":"_";
|
var search = prepend + reescape(filter.value);
|
||||||
var search = prepend + reescape(filter.value);
|
|
||||||
|
for(i in arObjTags) {
|
||||||
for(i in arObjTags) {
|
objTag = arObjTags[i];
|
||||||
objTag = arObjTags[i];
|
tag = prepend + objTag.getAttribute('tag');
|
||||||
tag = prepend + objTag.getAttribute('tag');
|
|
||||||
|
|
||||||
if(tag.match(search) && taggerFilterMode(objTag)) {
|
if(tag.match(search) && taggerFilterMode(objTag)) {
|
||||||
objTag.style.display='';
|
objTag.style.display='';
|
||||||
} else {
|
} else {
|
||||||
objTag.style.display='none';
|
objTag.style.display='none';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
||||||
|
@ -136,7 +135,26 @@ class taggerTheme extends Themelet {
|
||||||
"Artanis (Erik Youngren <artanis.00@gmail.com>)","main",0));
|
"Artanis (Erik Youngren <artanis.00@gmail.com>)","main",0));
|
||||||
$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.
|
||||||
|
|
Reference in a new issue