summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2012-11-10 13:22:29 -0800
committerArun Persaud <arun@nubati.net>2012-11-10 13:22:29 -0800
commitd7acf9450bd2b064160d8794a49e1608efe74bb2 (patch)
treec4c22a513651f3d7d3b6963ae158dd19bfb79249
parente9dd5689bdfe5800c9d0f5ee4d39c90dd1d0e116 (diff)
downloadphoto-tags-d7acf9450bd2b064160d8794a49e1608efe74bb2.tar.gz
photo-tags-d7acf9450bd2b064160d8794a49e1608efe74bb2.tar.bz2
photo-tags-d7acf9450bd2b064160d8794a49e1608efe74bb2.zip
fixed tag display and clicking on a tag button now removes the tag
-rw-r--r--js/photo-tags.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/js/photo-tags.js b/js/photo-tags.js
index 4918421..e41272f 100644
--- a/js/photo-tags.js
+++ b/js/photo-tags.js
@@ -15,17 +15,32 @@ function init()
d3.select('form').attr("action",webbase+"/tag/"+document.getElementById('MyTagsInput').value.replace(" ","+"));
});
- d3.select("#currenttags").select("button").remove();
+ d3.select("#currenttags").select("a").remove();
if (T!="")
{
var mycurrenttags = T.split(",");
- d3.select("#currenttags").selectAll("button")
+ d3.select("#currenttags").selectAll("a")
.data(mycurrenttags).enter()
- .append("button").attr("class","btn btn-small").text( function(d) {return d;} );
+ .append("a").attr("class","btn btn-small").text( function(d) {return d;} )
+ .on("mouseover", function(d){ d3.select(this).classed("btn-danger",true)})
+ .on("mouseout", function(d){ d3.select(this).classed("btn-danger",false)})
+ .attr("href", function(d) { return removeTag(T.split(","),d) });
};
}
+function removeTag(alltags,removetag)
+{
+ /* return a link to a page with 'removetag' removed from the array of tags*/
+ var index = alltags.indexOf(removetag);
+ alltags.splice(index, 1);
+ if (alltags.length)
+ return webbase+'/tag/'+alltags.join(",");
+ else
+ return webbase;
+}
+
+
function load_content() {
// d3.select(".debug").text("T,P,N = *"+T+"* *"+page+"* *"+N+"*");