JavaScript树
/** 配置参数 */
function TreeConfig() {
this.showIco = true;
this.showCheckBox = false;
this.checkBoxName = "_TREE_CHECKBOX_";
this.checkBoxRelated = false;
}
/**
* 节点类
* 节点目前默认支持的属性有:
* text, url, target, cb, cbname, cbchecked, cbval, ico, icoFile, icoOpen
*/
function Node(id, parentId, attributes) {
this.id = id; // 节点自身id
this.parent = parentId || ""; // 父id
this.attributes = attributes || {}; // 节点属性
this._created = false;
this._expanded = false;
this._checked = false;
}
// 得到节点属性
Node.prototype.getAttribute = function(key) {
var attr = this.attributes[key];
return (attr==undefined || attr=="")? null : attr;
}
// 得到节点属性
Node.prototype.setAttribute = function(key, value) {
this.attributes[key] = value;
}
/** 树类 */
function TissonTree(instanceName, config) {
this.instanceName = instanceName || "tree"; // 实例名
this.nodes = {}; // 所有节点集
this.nodeArray = null; // 包含所有节点的数组
this.nodeLink = {}; // 父-子节点对应关系集
this.rootId = "-1"; // 默认根节点id
this._baseImagesPath = "/SmtCCS_tkms/images/tree/"; // 图片的基本路径
this._checkedNodes = {};
this.selectedNode = null;
this.selectedNodeId = "";
this.nextSearchIndex = 0;
this.searchText = "";
this.treeStage = null;
&
相关文档:
0.链接css文件和js文件
<link rel="stylesheet" href="../css/style.css" mce_href="css/style.css" type="text/css">
<mce:script language="javascript" src="../includes/jslib.js" mce_src="includes/jslib.js" ></mce:script>
1.关闭输入法
<input style="ime-mode ......
javascript:基础知识
1 创建脚本块
1: <script language=”javascript”>
2: javascript code goes here
3: </script>
2 隐藏脚本代码
1: <script language=”javascript”>
2: <!--
3: document.write(“Hello”);
4: // -->
5: </script>
在 ......
//第一种构造方法: new Object()
var a = new Object();
a.x = 1, a.y = 2;
//第二种构造方法: 对象直接量
var b = {x:1,y:b};
//第三种构造方法: 定义类型
function Point(x,y)
{
......
JavaScript文档对象(DOM)
navigator
screen
window
history
location
frames[]; Frame
document
anchors[]; links[]; Link
applets[]
embeds[]
forms[]; Form
Button
Checkbox
elements[]; Element
Hidden
Password
Radio
Reset
Select
options[]; Option
Submit
Text
......
链式调用是一个语法招数.包含两个部分:
1.一个创建HTML元素的对象的工厂
2.对这个HTML元素执行的操作的方法
[个人理解:将HTML元素包装成对象,在对象上添加方法(重点在return this)]
构造器
(function(){
//Use a private class
function _$(els){
this.elements = [];
for(var i=0; i<els.length; ......