⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 expand_collapse.js

📁 Web标准的创造力-Web.Standards.Creativity.pdf
💻 JS
字号:

addLoadListener(initExpandCollapse);




function initExpandCollapse()
{
	var modules = [document.getElementById("modules1"), document.getElementById("modules2")];
	
	for (var i in modules)
	{
		var h2s = modules[i].getElementsByTagName("h2");

		for (var i = 0; i < h2s.length; i++)
		{
			var newA = document.createElement("a");
			newA.setAttribute("href", "#");
			newA.setAttribute("title", "Expand/Collapse");
			attachEventListener(newA, "mousedown", mousedownExpandCollapse, false);
			newA.onclick = clickExpandCollapse;
			
				var newImg = document.createElement("img");
				newImg.setAttribute("src", "images/expand_collapse.gif");
				newImg.setAttribute("alt", "Expand/Collapse");
				newA.appendChild(newImg);
				
			h2s[i].appendChild(newA);
		}
	}
	
	return true;
};




function mousedownExpandCollapse(event)
{
	if (typeof event == "undefined")
	{
		event = window.event;
	}
	
	if (typeof event.stopPropagation != "undefined")
	{
		event.stopPropagation();
	}
	else
	{
		event.cancelBubble = true;
	}
	
	return true;
};




function clickExpandCollapse()
{
	if (!hasClass(this.parentNode.parentNode, "collapsed"))
	{
		addClass(this.parentNode.parentNode, "collapsed");
	}
	else
	{
		removeClass(this.parentNode.parentNode, "collapsed");
	}
	
	return false;
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -