Swaminarayan Temple Sydney « visit
This is my Source Code and I don't want to show it here
View Source Code only (as overlay)
// That code snippet belongs to Swaminarayan Temple Sydney - http://sydneytemple.org
var linksXML; //the linksXML tree structure
var menuItems; //all the descendants of the menu
$(function(){
$("#menuSearchBox").defaultText();
$.ajax({
url:"links.xml",
dataType:"xml",
success:function(xml){
linksXML = $(xml).find("links > link")[0];
menuItems = $(xml).find("link");
var linkParent = findLinkParent(linksXML);
loadElems(linkParent,true);
//console.debug(document.location.search);
}
});
});
function findLinkParent(links){
var search = window.location.search;
for(var i=0; i < menuItems.length; i++){
if($(menuItems[i]).attr("href")==search){
return menuItems[i].parentNode;
}
}
return links;
}
function loadElems(links,nextAnimate){
var childs = $('#childs');
childs.empty();//empty the children
loadHeads(links);
//console.debug(links);
$(links).children("link").each(function(index){
var name = $(this).attr("name");
var href = $(this).attr("href");
var child;
var nextArrow;
var curElem = this;
if(href){
child = $("<li class='link'><a href=\"" + href + "\">" +name+"</a></li>");
}else{
child = $("<li>"+name+"</li>");
child.click(function(){
loadElems(curElem,true);
});
}
childs.append(child);
child.css({position:"relative",opacity:0});
if(nextAnimate){
child.css({left:50}).animate({opacity:1,left:0},500);
}else{
child.css({left:-50}).animate({opacity:1,left:0},500);
}
//console.debug(name);
});
}
function loadHeads(links){
var heads = $("#heads");
var currentElem = $("<li class='parent'>"+$(links).attr("name")+"</li>");
heads.empty().prepend(currentElem);
while( links!=linksXML){
links = links.parentNode;
currentElem = $("<li>"+$(links).attr("name")+"</li>");
currentElem[0].link = links;
currentElem.click(function(){
//console.debug(this);
loadElems(this.link,false);
});
heads.prepend(currentElem);
}
}
function searchMenu(searchStr){
searchStr = searchStr.toLowerCase();
$menuSearchResults = $("#menuSearchResults");
$menuSearchResults.empty();
if(!searchStr) return;//nothing to search
var count = 0;
menuItems.each(function(){
$this = $(this);
var link = this;
var name = $this.attr("name").toLowerCase();//case insensitive
var index = name.indexOf(searchStr);
if(index != -1 && (index == 0 || name.charAt(index-1) == ' ')){//word boundary or first letter
var href = $this.attr('href');
if(href){
child = $("<li class='link'><a href=\"" + href + "\">" +$this.attr("name")+"</a></li>");
}else{
child = $("<li>"+$this.attr("name")+"</li>");
child.click(function(){
loadElems(link,false);
});
}
$menuSearchResults.append(child);
if(++count >=10) return false;//load max 10 results
}
});
}
Syndicate
Categories
Statistics
There are 330 Sites with 745 Links of Interest in 18 Categories. The latest Site was added 4 months ago.
About
This is a project by Sebastian Senf, for his part jQuery user and lover too. Follow me.