Select specific tag add-on to JaS
A friend of mine using JaS said that he sometimes had the scenario that he wanted to load all the images but then preload a certain tag, hence initially hiding all the pictures that doesn’t match that criteria. I though it was a simple task so I created an add-on script for those interested.
Since I want to keep the core functionality of JaS as small and lightweight as possible, I wanted to introduce the concept of add-ons to JaS. Basically, you create an external JavaScript file and put your add-on methods in it. To use the add-on I’ve created for JaS, do the following:
Download the JaSSelectCertainTag JavaScript file.
Include it in your web page:
<script type="text/javascript" src="js/JaSSelectCertainTag.js"></script>
Then you just call it like this, with a string parameter for the value you want the tag to have:
JaS.selectCertainTag("Texas Capitol");
If you automatically want to call this when the page has loaded, you just need to add this line to your code:
addEvent(window, "load", function(){JaS.selectCertainTag("Texas Capitol");}, false);
addEvent(window, "load", selectCertainTagWithJaS, false);
var oJaSTimer;
function selectCertainTagWithJaS(){
if(JaS.thumbnailContainer){
clearTimeout(oJaSTimer);
JaS.selectCertainTag("Texas Capitol");
}
else{
oJaSTimer = setTimeout("selectCertainTagWithJaS()", 100);
}
}
The code
If you’re interested in the code or how it should look when you want to create your own add-on, here goes:
JaS.selectCertainTag = function (strValue){
var oCheckBox;
var bNotAllSelected = false;
for(var i=0; i<this.tagsCheckboxes.length; i++){
oCheckBox = this.tagsCheckboxes[i];
oCheckBox.checked = (oCheckBox.value.search(strValue) != -1)? true : false;
if(!bNotAllSelected && !oCheckBox.checked){
bNotAllSelected = true;
this.tagsSelectAll.checked = false;
}
}
this.applyTagFilter();
};


