Class baidu.editor.dom.domUtils

baidu.editor.dom.domUtils dom工具类

Method
Method Attributes Method Name and Description
<static>  
以node节点为中心,将该节点的父节点拆分成2块
<static>  
清除该节点左右空的inline节点
<static>  
清除冗余的inline标签
<static>  
清空节点所有的className
<static>  
查找祖先节点
<static>  
查找祖先节点
<static>  
查找祖先节点集合
<static>  
返回子节点的数量
<static>  
得到公共的祖先节点
<static>  
获取元素的样式
<static>  
封装原生的getElemensByTagName
<static>  
取得node节点在dom树上的下一个节点
<static>  
返回节点索引,zero-based
<static>  
获取两个节点的位置关系
<static>  
取得node节点在dom树上的上一个节点
<static>  
获得元素样式
<static>  
获取节点所在window对象
<static>  
获取元素相对于viewport的像素坐标
<static>  
判断元素属性中是否包含某一个classname
<static>  
往后插入节点
<static>  
检查是否为块元素
<static>  
判断是否body
<static>  
是bookmark节点
<static>  
判断节点是否为br
<static>  
检查是否是空inline节点
<static>  
判断是否为空节点
<static>  
判断是否为多余的span标签,该span没有显式定义的属性
<static>  
比较两个节点是否tagName相同且有相同的属性和属性值
<static>  
判断两个元素的style属性是不是一致
<static>  
判断是否为空白节点
<static>  
合并子节点
<static>  
合并左右兄弟节点
<static>  
将子节点合并到父节点上
<static>  
绑原生DOM事件
<static>  
阻止事件默认行为
<static>  
删除该节点
<static>  
删除元素上的属性,可以删除多个
<static>  
删除cssClass,可以支持删除多个class,需以空格分隔
<static>  
删除_moz_dirty属性
<static>  
删除元素的样式
<static>  
将显示区域滚动到显示节点的位置
<static>  
给节点添加属性
<static>  
将一个文本节点拆分成两个文本节点
<static>  
删除空白子节点
<static>  
解除原生DOM事件绑定
<static>  
使得元素及其子节点不能被选择
Method Detail
<static> baidu.editor.dom.domUtils.breakParent(node, parent)
以node节点为中心,将该节点的父节点拆分成2块
xxxxxxxxxx
==>
xxx
xx
xxx
Parameters:
{Element} node
节点
{Element} parent
要被拆分的父节点

<static> baidu.editor.dom.domUtils.clearEmptySibling(node, ingoreNext, ingorePre)
清除该节点左右空的inline节点
Parameters:
{Node} node
{Boolean} ingoreNext
默认为false清除右边为空的inline节点。true为不清除右边为空的inline节点
{Boolean} ingorePre
默认为false清除左边为空的inline节点。true为不清除左边为空的inline节点

<static> baidu.editor.dom.domUtils.clearReduent(node, tags)
清除冗余的inline标签
==>
Parameters:
node
node下的冗余子孙节点
tags
清除的节点的tagname

<static> baidu.editor.dom.domUtils.clearSelectedArr(nodes)
清空节点所有的className
Parameters:
{Array} nodes
节点数组

<static> {Node} baidu.editor.dom.domUtils.findParent(node, tester, includeSelf)
查找祖先节点
Parameters:
{Node} node
节点
{Function} tester
以函数为规律
{Boolean} includeSelf
包含自己
Returns:
{Node} 返回祖先节点

<static> {Node} baidu.editor.dom.domUtils.findParentByTagName(node, tagName, includeSelf)
查找祖先节点
Parameters:
{Node} node
节点
{String} tagName
标签名称
{Boolean} includeSelf
包含自己
Returns:
{Node} 返回祖先节点

<static> {Array} baidu.editor.dom.domUtils.findParents(node, tester, includeSelf, closerFirst)
查找祖先节点集合
Parameters:
{Node} node
节点
{Function} tester
函数
{Boolean} includeSelf
是否从自身开始找
{Boolean} closerFirst
Returns:
{Array} 祖先节点集合

<static> {Number} baidu.editor.dom.domUtils.getChildCount(node, fn)
返回子节点的数量
Parameters:
{Node} node
父节点
{Function} fn
过滤子节点的规则,若为空,则得到所有子节点的数量
Returns:
{Number} 符合条件子节点的数量

<static> {Node} baidu.editor.dom.domUtils.getCommonAncestor(nodeA, nodeB)
得到公共的祖先节点
Parameters:
{Node} nodeA
节点A
{Node} nodeB
节点B
Returns:
{Node} nodeA和nodeB的公共节点

<static> {String} baidu.editor.dom.domUtils.getComputedStyle(element, styleName)
获取元素的样式
Parameters:
{Element} element
元素
{String} styleName
样式名称
Returns:
{String} 样式值

<static> {Array} baidu.editor.dom.domUtils.getElementsByTagName(node, name)
封装原生的getElemensByTagName
Parameters:
{Node} node
根节点
{String} name
标签的tagName
Returns:
{Array} 返回符合条件的元素数组

<static> {Node} baidu.editor.dom.domUtils.getNextDomNode(node, startFromChild, fn, guard)
取得node节点在dom树上的下一个节点
Parameters:
{Node} node
节点
{Boolean} startFromChild
为true从子节点开始找
{Function} fn
fn为真的节点
guard
Returns:
{Node} 返回下一个节点

<static> {Number} baidu.editor.dom.domUtils.getNodeIndex(node)
返回节点索引,zero-based
Parameters:
{Node} node
节点
Returns:
{Number} 节点的索引

<static> {Number} baidu.editor.dom.domUtils.getPosition(nodeA, nodeB)
获取两个节点的位置关系
Parameters:
{Node} nodeA
节点A
{Node} nodeB
节点B
Returns:
{Number} 返回位置关系

<static> {Node} baidu.editor.dom.domUtils.getPreviousDomNode(node, startFromChild, fn)
取得node节点在dom树上的上一个节点
Parameters:
{Node} node
{Boolean} startFromChild
为true从子节点开始找
{Function} fn
找到fn为真的节点
Returns:
{Node} 返回上一个节点

<static> {String} baidu.editor.dom.domUtils.getStyle(element, name)
获得元素样式
Parameters:
{Element} element
元素
{String} name
样式名称
Returns:
{String} 返回元素样式值

<static> {window} baidu.editor.dom.domUtils.getWindow(node)
获取节点所在window对象
Parameters:
{Node} node
节点
Returns:
{window} 返回window对象

<static> {Object} baidu.editor.dom.domUtils.getXY(element)
获取元素相对于viewport的像素坐标
Parameters:
{Element} element
元素
Returns:
{Object} 返回坐标对象{x:left,y:top}

<static> {Boolean} baidu.editor.dom.domUtils.hasClass(element, className)
判断元素属性中是否包含某一个classname
Parameters:
{Element} element
元素
{String} className
样式名
Returns:
{Boolean} 是否包含该classname

<static> {Node} baidu.editor.dom.domUtils.insertAfter(node, nodeToInsert)
往后插入节点
Parameters:
{Node} node
基准节点
{Node} nodeToInsert
要插入的节点
Returns:
{Node} 返回node

<static> {Boolean} baidu.editor.dom.domUtils.isBlockElm(node, customNodeNames)
检查是否为块元素
Parameters:
{Element} node
元素
{String} customNodeNames
自定义的块元素的tagName
Returns:
{Boolean} 是否为块元素

<static> {Boolean} baidu.editor.dom.domUtils.isBody(节点)
判断是否body
Parameters:
{Node} 节点
Returns:
{Boolean} 是否是body节点

<static> {Boolean} baidu.editor.dom.domUtils.isBookmarkNode(node)
是bookmark节点
Parameters:
{Node} node
判断是否为书签节点
Returns:
{Boolean} 返回是否为书签节点

<static> baidu.editor.dom.domUtils.isBr(node)
判断节点是否为br
Parameters:
{Node} node
节点

<static> {Boolean} baidu.editor.dom.domUtils.isEmptyInlineElement(node)
检查是否是空inline节点
<b><i></i></b> //true
 true
<b></b> true  <b>xx<i></i></b> //false
Parameters:
{Node} node
节点
Returns:
{Boolean} 返回1为是,0为否

<static> {Boolean} baidu.editor.dom.domUtils.isEmptyNode(node)
判断是否为空节点
Parameters:
{Node} node
节点
Returns:
{Boolean} 是否为空节点

<static> {boolean} baidu.editor.dom.domUtils.isRedundantSpan(node)
判断是否为多余的span标签,该span没有显式定义的属性
如<span>hello</span>,这个span就是多余的
Parameters:
{Node} node
节点
Returns:
{boolean} 是否为多余的span标签

<static> {Boolean} baidu.editor.dom.domUtils.isSameElement(nodeA, nodeB)
比较两个节点是否tagName相同且有相同的属性和属性值
<span  style="font-size:12px">ssss</span>和<span style="font-size:12px">bbbbb</span> 相等
 <span  style="font-size:13px">ssss</span>和<span style="font-size:12px">bbbbb</span> 不相等
Parameters:
{Element} nodeA
节点A
{Element} nodeB
节点B
Returns:
{Boolean} 返回两个节点的标签,属性和属性值是否相同

<static> {boolean} baidu.editor.dom.domUtils.isSameStyle(elementA, elementB)
判断两个元素的style属性是不是一致
Parameters:
{Element} elementA
元素A
{Element} elementB
元素B
Returns:
{boolean} 返回判断结果,true为一致

<static> {Boolean} baidu.editor.dom.domUtils.isWhitespace(node)
判断是否为空白节点
Parameters:
{TextNode} node
节点
Returns:
{Boolean} 返回是否为文本节点

<static> baidu.editor.dom.domUtils.mergChild(node, tagName, attrs)
合并子节点
<span style="font-size:12px;">xx<span style="font-size:12px;">aa</span>xx</span  使用后
<span style="font-size:12px;">xxaaxx</span
Parameters:
{Node} node
节点
{String} tagName
标签
{String} attrs
属性

<static> baidu.editor.dom.domUtils.mergSibling(node, ingoreNext, ingorePre)
合并左右兄弟节点
<b>xxxx</b><b>xxx</b><b>xxxx</b> ==> <b>xxxxxxxxxxx</b>
Parameters:
{Node} node
{Boolean} ingoreNext
默认为false合并上一个兄弟节点。true为不合并上一个兄弟节点
{Boolean} ingorePre
默认为false合并下一个兄弟节点。true为不合并下一个兄弟节点

<static> baidu.editor.dom.domUtils.mergToParent(node)
将子节点合并到父节点上
<span style="color:#ff"><span style="font-size:12px">xxx</span></span> ==> <span style="color:#ff;font-size:12px">xxx</span>
Parameters:
{Element} node
节点

<static> baidu.editor.dom.domUtils.on(target, type, handler)
绑原生DOM事件
Parameters:
{Element,Window,Document} target
元素
{Array,String} type
事件类型
{Function} handler
执行函数

<static> baidu.editor.dom.domUtils.preventDefault(evt)
阻止事件默认行为
Parameters:
{Event} evt
需要组织的事件对象

<static> {Node} baidu.editor.dom.domUtils.remove(node, keepChildren)
删除该节点
Parameters:
{Node} node
要删除的节点
{Boolean} keepChildren
是否保留子节点不删除
Returns:
{Node} 返回要删除的节点

<static> baidu.editor.dom.domUtils.removeAttributes(element, attrNames)
删除元素上的属性,可以删除多个
Parameters:
{Element} element
元素
{Array} attrNames
要删除的属性数组

<static> baidu.editor.dom.domUtils.removeClasses(element, classNames)
删除cssClass,可以支持删除多个class,需以空格分隔
Parameters:
{Element} element
元素
{Array} classNames
删除的className

<static> baidu.editor.dom.domUtils.removeDirtyAttr(node)
删除_moz_dirty属性
Parameters:
{Node} node
节点

<static> baidu.editor.dom.domUtils.removeStyle(element, name)
删除元素的样式
Parameters:
{Element} element
元素
{String} name
删除的样式名称

<static> baidu.editor.dom.domUtils.scrollToView(node, win, offsetTop)
将显示区域滚动到显示节点的位置
Parameters:
{Node} node
节点
{window} win
window对象
{Number} offsetTop
距离上方的偏移量

<static> baidu.editor.dom.domUtils.setAttributes(node, attrNames)
给节点添加属性
Parameters:
{Node} node
节点
{Object} attrNames
要添加的属性名称,采用json对象存放

<static> {TextNode} baidu.editor.dom.domUtils.split(node, offset)
将一个文本节点拆分成两个文本节点
Parameters:
{TextNode} node
文本节点
{Integer} offset
拆分的位置
Returns:
{TextNode} 拆分后的后一个文本节

<static> baidu.editor.dom.domUtils.trimWhiteTextNode(node)
删除空白子节点
Parameters:
{Element} node
需要删除空白子节点的元素

<static> baidu.editor.dom.domUtils.un(obj, type, handler)
解除原生DOM事件绑定
Parameters:
{Element,Window,Document} obj
元素
{Array,String} type
事件类型
{Function} handler
执行函数

<static> baidu.editor.dom.domUtils.unselectable(node)
使得元素及其子节点不能被选择
Parameters:
{Node} node
节点

Documentation generated by JsDoc Toolkit 2.3.2 on Fri Sep 02 2011 17:22:32 GMT+0800 (CST)