Esempio n. 1
0
        public static NavigationTreeItem CreateNavigationBarItem(bool isDisplay, bool selected, int parentsCount, bool hasChildren, bool openWindow, string text, string linkUrl, string target, bool enabled, string iconUrl)
        {
            var item = new NavigationTreeItem();

            item._isDisplay     = isDisplay;
            item._selected      = selected;
            item._parentsCount  = parentsCount;
            item._hasChildren   = hasChildren;
            item._openWindow    = openWindow;
            item._text          = text;
            item._linkUrl       = linkUrl;
            item._target        = target;
            item._enabled       = enabled;
            item._isClickChange = true;
            if (!string.IsNullOrEmpty(iconUrl))
            {
                if (!iconUrl.StartsWith("../"))
                {
                    item._iconFolderUrl = SiteServerAssets.GetIconUrl(iconUrl);
                }
                else
                {
                    item._iconFolderUrl = iconUrl;
                }
            }
            else
            {
                item._iconFolderUrl = SiteServerAssets.GetIconUrl(hasChildren ? "menu/itemContainer.png" : "menu/item.png");
            }

            item._iconOpenedFolderUrl = item._iconFolderUrl;
            return(item);
        }
Esempio n. 2
0
        public static NavigationTreeItem CreateNodeTreeItem(bool isDisplay, bool selected, int parentsCount, bool hasChildren, bool openWindow, string text, string linkUrl, string onClickUrl, string target, bool enabled, bool isClickChange)
        {
            var item = new NavigationTreeItem
            {
                _isDisplay     = isDisplay,
                _selected      = selected,
                _parentsCount  = parentsCount,
                _hasChildren   = hasChildren,
                _openWindow    = openWindow,
                _text          = text,
                _linkUrl       = linkUrl,
                _onClickUrl    = onClickUrl,
                _target        = target,
                _enabled       = enabled,
                _isClickChange = isClickChange
            };

            return(item);
        }
Esempio n. 3
0
        public static NavigationTreeItem CreateNavigationBarItem(bool isDisplay, bool selected, int parentsCount, bool hasChildren, bool openWindow, string text, string linkUrl, string target, bool enabled, string iconUrl)
        {
            var item = new NavigationTreeItem
            {
                _isDisplay     = isDisplay,
                _selected      = selected,
                _parentsCount  = parentsCount,
                _hasChildren   = hasChildren,
                _openWindow    = openWindow,
                _text          = text,
                _linkUrl       = linkUrl,
                _target        = target,
                _enabled       = enabled,
                _isClickChange = true,
                _iconFolderUrl =
                    !string.IsNullOrEmpty(iconUrl)
                                ? SiteServerAssets.GetIconUrl(iconUrl)
                                : SiteServerAssets.GetIconUrl(hasChildren ? "menu/itemContainer.png" : "menu/item.png")
            };

            item._iconOpenedFolderUrl = item._iconFolderUrl;
            return(item);
        }
Esempio n. 4
0
        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 NavigationTreeItem();

            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);
        }