Last active
August 29, 2015 14:05
-
-
Save oscardelama/d6a35cf3d5908a7f8f55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MenuHandler.prototype.buildMenu = function(menuObj, MaxLevels, currLevel, basePath) { | |
var menu = "", menuItem, className, extraTitle; | |
for (var childMenuKey in menuObj) { | |
menuItem = ''; | |
className = ''; | |
extraTitle = ""; | |
if ( !/[^\-—–\s]/.test( menuObj[childMenuKey].menu ) ) | |
menuItem = '---'; | |
else { | |
if (childMenuKey == this.currMenuInfo.nextChildMenuKey) { | |
menuItem = '<a class="$class" href="#" title="$title">$menu</a>'; | |
// className = (this.currMenuInfo.nextChildMenuKind == endPath) ? 'ui-state-disabled endPath':'inPath'; | |
if (this.currMenuInfo.nextChildMenuKind == endPath) { | |
className = 'ui-state-disabled endPath' ; | |
extraTitle = ' (current page)'; | |
} | |
else | |
className = 'inPath' ; | |
menuItem = menuItem.replace("$class", className); | |
} | |
else | |
menuItem = '<a href="$href" title="$title">$menu</a>'; | |
//var menuItemPath = basePath + menuObj[childMenuKey].href + '/'; | |
var menuItemPath = menuObj[childMenuKey].href; | |
menuItem = menuItem.replace("$href", menuItemPath); | |
menuItem = menuItem.replace("$title", menuObj[childMenuKey].title + extraTitle); | |
menuItem = menuItem.replace("$menu", menuObj[childMenuKey].menu); | |
if (menuObj[childMenuKey].children && currLevel > 0) { | |
var subMenu = this.buildMenu(menuObj[childMenuKey].children, | |
MaxLevels, | |
currLevel - 1, | |
menuItemPath ); | |
menuItem += '<ul>' + subMenu + '</ul>'; | |
} | |
} | |
menu += '<li>' + menuItem + '</li>'; | |
} | |
return menu; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment