public static NodeNaviTreeItem CreateNavigationBarItem(bool isDisplay, bool selected, int parentsCount, bool hasChildren, string text, string linkUrl, string target, bool enabled, string iconUrl) { var item = new NodeNaviTreeItem(); item._isDisplay = isDisplay; item._selected = selected; item._parentsCount = parentsCount; item._hasChildren = hasChildren; item._text = text; item._linkUrl = linkUrl; item._target = target; item._enabled = enabled; item._isClickChange = true; item._isNodeTree = false; if (!string.IsNullOrEmpty(iconUrl)) { item._iconFolderUrl = PageUtils.ParseNavigationUrl(iconUrl); } else { if (hasChildren) { item._iconFolderUrl = SiteServerAssets.GetIconUrl("menu/itemContainer.png"); } else { item._iconFolderUrl = SiteServerAssets.GetIconUrl("menu/item.png"); } } item._iconOpenedFolderUrl = item._iconFolderUrl; return(item); }
public static NodeNaviTreeItem CreateNodeTreeItem(bool isDisplay, bool selected, int parentsCount, bool hasChildren, string text, string linkUrl, string onClickUrl, string target, bool enabled, bool isClickChange, int publishmentSystemId, int nodeId, int contentNum) { var item = new NodeNaviTreeItem(); item._isDisplay = isDisplay; item._selected = selected; item._parentsCount = parentsCount; item._hasChildren = hasChildren; item._text = text; item._linkUrl = linkUrl; item._onClickUrl = onClickUrl; item._target = target; item._enabled = enabled; item._isClickChange = isClickChange; item._isNodeTree = true; item._publishmentSystemId = publishmentSystemId; item._nodeId = nodeId; item._contentNum = contentNum; return(item); }
private static string GetScript(bool isNodeTree) { var script = @" <script language=""JavaScript""> //取得Tree的级别,1为第一级 function getTreeLevel(e) { var length = 0; if (!isNull(e)){ if (e.tagName == 'TR') { length = parseInt(e.getAttribute('treeItemLevel')); } } return length; } function closeAllFolder(element){ $(element).closest('table').find('td').removeClass('active'); } function openFolderByA(element){ closeAllFolder(element); if (isNull(element) || element.tagName != 'A') return; $(element).parent().addClass('active'); if (isNodeTree){ for (element = element.previousSibling;;){ if (element != null && element.tagName == 'A'){ element = element.firstChild; } if (element != null && element.tagName == 'IMG'){ if (element.getAttribute('src') == '{iconFolderUrl}') break; break; }else{ element = element.previousSibling; } } if (!isNull(element)){ element.setAttribute('src', '{iconOpenedFolderUrl}'); } } } function getTrElement(element){ if (isNull(element)) return; for (element = element.parentNode;;){ if (element != null && element.tagName == 'TR'){ break; }else{ element = element.parentNode; } } return element; } function getImgClickableElementByTr(element){ if (isNull(element) || element.tagName != 'TR') return; var img = null; if (!isNull(element.childNodes)){ var imgCol = element.getElementsByTagName('IMG'); if (!isNull(imgCol)){ for (x=0;x<imgCol.length;x++){ if (!isNull(imgCol.item(x).getAttribute('isOpen'))){ img = imgCol.item(x); break; } } } } return img; } //显示、隐藏下级目录 function displayChildren(element){ if (isNull(element)) return; var tr = getTrElement(element); var img = getImgClickableElementByTr(tr);//需要变换的加减图标 if (!isNull(img) && img.getAttribute('isOpen') != null){ if (img.getAttribute('isOpen') == 'false'){ img.setAttribute('isOpen', 'true'); img.setAttribute('src', '{iconMinusUrl}'); }else{ img.setAttribute('isOpen', 'false'); img.setAttribute('src', '{iconPlusUrl}'); } } var level = getTreeLevel(tr);//点击项菜单的级别 var collection = new Array(); var index = 0; for ( var e = tr.nextSibling; !isNull(e) ; e = e.nextSibling) { if (!isNull(e) && !isNull(e.tagName) && e.tagName == 'TR'){ var currentLevel = getTreeLevel(e); if (currentLevel <= level) break; if(e.style.display == '') { e.style.display = 'none'; }else{//展开 if (currentLevel != level + 1) continue; e.style.display = ''; var imgClickable = getImgClickableElementByTr(e); if (!isNull(imgClickable)){ if (!isNull(imgClickable.getAttribute('isOpen')) && imgClickable.getAttribute('isOpen') =='true'){ imgClickable.setAttribute('isOpen', 'false'); imgClickable.setAttribute('src', '{iconPlusUrl}'); collection[index] = imgClickable; index++; } } } } } if (index > 0){ for (i=0;i<=index;i++){ displayChildren(collection[i]); } } } var isNodeTree = {isNodeTree}; </script> "; var item = new NodeNaviTreeItem(); script = script.Replace("{iconEmptyUrl}", item._iconEmptyUrl); script = script.Replace("{iconFolderUrl}", item._iconFolderUrl); script = script.Replace("{iconMinusUrl}", item._iconMinusUrl); script = script.Replace("{iconOpenedFolderUrl}", item._iconOpenedFolderUrl); script = script.Replace("{iconPlusUrl}", item._iconPlusUrl); script = script.Replace("{isNodeTree}", (isNodeTree) ? "true" : "false"); return(script); }