diff --git a/contrib/tagger/main.php b/contrib/tagger/main.php index 70e07736..34bdd62c 100644 --- a/contrib/tagger/main.php +++ b/contrib/tagger/main.php @@ -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 { diff --git a/contrib/tagger/script.js b/contrib/tagger/script.js index 7717d3bf..43f91885 100644 --- a/contrib/tagger/script.js +++ b/contrib/tagger/script.js @@ -8,59 +8,62 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ function Tagger() { // components - this.t_parent = null; - this.t_title = null; - this.t_toolbar = null; - this.t_menu = null; - this.t_body = null; - this.t_tags = null; - this.t_form = null; - this.t_status = null; + this.t_parent = null; + this.t_title = null; + this.t_toolbar = null; + this.t_menu = null; + this.t_body = null; + this.t_tags = null; + this.t_form = null; + this.t_status = null; // data - this.searchTags = null; - this.appliedTags = null; + this.searchTags = null; + this.appliedTags = null; // methods - this.initialize = initialize; - this.submit = submit; - this.getPosition = function () { return findPos(this.t_parent); }; - this.setPosition = setPosition; - this.tagSearch = tagSearch; - this.searchRequest = searchRequest; - this.searchReceive = searchReceive; - this.tagListReceive = tagListReceive; - this.tagPublish = tagPublish; - this.prepTags = prepTags; - this.createTag = createTag; - this.buildPages = buildPages; - this.tagsToString = tagsToString; - this.toggleTag = toggleTag; - this.setAlert = setAlert; + this.initialize = initialize; + 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; + this.tagListReceive = tagListReceive; + this.tagPublish = tagPublish; + this.prepTags = prepTags; + this.createTag = createTag; + this.buildPages = buildPages; + this.tagsToString = tagsToString; + this.toggleTag = toggleTag; + this.setAlert = setAlert; // 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(); + // set position + 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; iadd_block( new Block( - "Tagger", + null, $this->html($event->get_image()), "main")); }