Tagger v2

git-svn-id: file:///home/shish/svn/shimmie2/trunk@571 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
Artanis 2007-10-26 02:55:40 +00:00
parent 1cacc2d247
commit 3aaf13887b
4 changed files with 108 additions and 67 deletions

View File

@ -19,7 +19,7 @@ class Tagger extends Extension {
$this->theme->build_tagger($page,$event);
}
}
} if(isset($_GET['debug'])) add_event_listener( new tagger());
} add_event_listener( new tagger());
// Tagger AJAX back-end
class TaggerXML extends Extension {

View File

@ -24,6 +24,8 @@ function Tagger() {
this.submit = submit;
this.getPosition = function () { return findPos(this.t_parent); };
this.setPosition = setPosition;
this.setSavedPosition = setSavedPosition;
this.getSavedPosition = getSavedPosition;
this.tagSearch = tagSearch;
this.searchRequest = searchRequest;
this.searchReceive = searchReceive;
@ -40,27 +42,28 @@ function Tagger() {
// definitions
function initialize () {
// components
this.t_parent = document.getElementById("tagger_parent");
this.t_title = document.getElementById("tagger_titlebar");
this.t_toolbar = document.getElementById("tagger_toolbar");
this.t_menu = document.getElementById("tagger_p-menu");
this.t_body = document.getElementById("tagger_body");
this.t_tags = document.getElementById("tagger_tags");
this.t_parent = byId("tagger_parent");
this.t_title = byId("tagger_titlebar");
this.t_toolbar = byId("tagger_toolbar");
this.t_menu = byId("tagger_p-menu");
this.t_body = byId("tagger_body");
this.t_tags = byId("tagger_tags");
this.t_form = this.t_tags.parentNode;
this.t_status = document.getElementById("tagger_statusbar");
this.t_status = byId("tagger_statusbar");
//pages
//this.buildPages();
// initial data
ajaxXML(query+"/"+image_id,tagListReceive);
// reveal
this.t_parent.style.display = "";
// dragging
DragHandler.attach(this.t_title);
// set position
// TODO: Apply cookie-based position saving
var pos = Tagger.getPosition();
var pos = ( Tagger.getSavedPosition() || Tagger.getPosition() );
setPosition(pos[0],pos[1]);
// events
window.onunload = function () {Tagger.setSavedPosition(); };
}
function submit() {
this.t_tags.value = Tagger.tagsToString(Tagger.appliedTags);
@ -84,6 +87,22 @@ function Tagger() {
bottom="";
}
}
function setSavedPosition(x,y) {
if (!x || !y) {
var p = Tagger.getPosition();
x = p[0];
y = p[1];
}
setCookie("shimmie_tagger-position",x+" "+y,14);
}
function getSavedPosition() {
var p = getCookie("shimmie_tagger-position");
if(p) {
return p.split(" ");
} else {
return false;
}
}
function tagSearch(s,ms) {
clearTimeout(tagger_filter_timer);
tagger_filter_timer = setTimeout("Tagger.searchRequest('"+s+"')",ms);
@ -130,10 +149,10 @@ function Tagger() {
}
function searchReceive(xml) {
Tagger.searchTags = document.importNode(xml.getElementsByTagName("list")[0],true);
tagPublish(Tagger.searchTags,document.getElementById("tagger_p-search"));
tagPublish(Tagger.searchTags,byId("tagger_p-search"));
if(Tagger.searchTags.getAttribute("max")) {
Tagger.setAlert("maxout","Limited to "+Tagger.searchTags.getAttribute("rows")+" of "+Tagger.searchTags.getAttribute("max")+" tags");
Tagger.setAlert("maxout","Showing "+Tagger.searchTags.getAttribute("rows")+" of "+Tagger.searchTags.getAttribute("max")+" tags");
} else {
Tagger.setAlert("maxout",false);
}
@ -141,7 +160,7 @@ function Tagger() {
function tagListReceive(xml) {
Tagger.appliedTags = document.importNode(xml.getElementsByTagName("list")[0],true);
tagPublish(Tagger.appliedTags,document.getElementById("tagger_p-applied"));
tagPublish(Tagger.appliedTags,byId("tagger_p-applied"));
}
function tagPublish(tag_list,page) {
page.innerHTML = "";
@ -153,8 +172,8 @@ function Tagger() {
for(var i=0; i<len;i++) {
var tag = tag_list.childNodes[i];
tag.onclick = function() { toggleTag(this); document.getElementById("tagger_filter").select(); };
tag.style.display="block";
tag.onclick = function() { toggleTag(this); byId("tagger_filter").select(); };
//tag.style.display="block";
tag.setAttribute("title",tag.getAttribute("count")+" uses");
}
}
@ -163,13 +182,15 @@ function Tagger() {
var tag = document.createElement("tag");
tag.setAttribute("count","0");
tag.setAttribute("id","newTag_"+tag_name);
tag.setAttribute("count",1);
tag.setAttribute("title","New");
tag.onclick = function() { toggleTag(this); };
tag.appendChild(document.createTextNode(tag_name));
Tagger.appliedTags.appendChild(tag);
}
}
function buildPages () {
var pages = getElementsByTagNames("div",document.getElementById("tagger_body"));
var pages = getElementsByTagNames("div",byId("tagger_body"));
var len = pages.length;
for(var i=0; i<len; i++) {
this.t_menu.innerHTML += "<li onclick='Tagger.togglePages("+
@ -193,7 +214,7 @@ function Tagger() {
}
}
function setAlert(type,arg) {
var alert = document.getElementById("tagger_alert_"+type);
var alert = byId("tagger_alert_"+type);
if (alert) {
if (arg==false) {
//remove existing
@ -228,7 +249,7 @@ function ajaxXML(url, callback) {
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Quirksmode
// http://www.quirksmode.org/dom/getElementsByTagNames.htmlgetElementdocument.getElementById
// http://www.quirksmode.org/dom/getElementsByTagNames.htmlgetElementbyId
function getElementsByTagNames(list,obj) {
if (!obj) var obj = document;
var tagNames = list.split(',');

View File

@ -4,13 +4,10 @@
* Do not remove this notice. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#Tagger {
text-align:left;
}
#tagger_parent {
text-align:left;
position:fixed;
/*width:250px;*/
max-width:300px;
}
#tagger_parent * {
@ -28,12 +25,12 @@
}
#tagger_toolbar, #tagger_body {
padding:.25em;
padding:2px 2px 0 2px;
border-style:solid;
border-width: 0px 2px 0px 2px;
}
#tagger_body {
max-height:250px;
max-height:175px;
overflow:auto;
overflow-x:hidden;
overflow-y:auto;
@ -43,46 +40,69 @@
background-color:#ddd;
border:2px solid;
font-weight: bold;
min-height:16px;
-moz-border-radius:0 0 5px 5px;
padding:.25em;
} #tagger_statusbar * { background-color:#ddd; }
#tagger_body div {
padding-bottom:.125em;
margin-bottom:.125em;
padding-top:2px;
margin-top:2px;
border-top:1px solid;
}
/* Tagger Styling
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#Tagger form {
#tagger_parent form {
display:inline;
}
#Tagger input {
#tagger_parent input {
width:auto;
}
#Tagger input[type=text] {
#tagger_parent input[type=text] {
background-color:white;
}
/* Custom Element Base Styles
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
list {
display:inherit;
#tagger_parent list {
display: block;
}
tag {
#tagger_parent tag {
font-size:1.25em;
display:block;
}
tag:hover {
#tagger_parent list[id=image] tag:before {
font-family: monospace;
content:"[ ]";
}
#tagger_parent list[id=search] tag:before {
font-family: monospace;
content:"[ ]";
}
/* Hovering */
#tagger_parent tag:hover {
cursor:pointer;
font-weight: bold;
background-color:#ddd;
}
list[id=image] tag:hover {
#tagger_parent list[id=image] tag:hover {
background-color:#faa;
}
list[id=search] tag:hover {
#tagger_parent list[id=search] tag:hover {
background-color:#afa;
}
#tagger_parent list[id=image] tag:hover:before {
font-family: monospace;
content:"[\00d7]";
}
#tagger_parent list[id=search] tag:hover:before {
font-family: monospace;
content:"[+]";
}

View File

@ -23,7 +23,7 @@ class taggerTheme extends Themelet {
// Tagger block
$page->add_block( new Block(
"Tagger",
null,
$this->html($event->get_image()),
"main"));
}