Class baidu.editor.utils
baidu.editor.utils 工具类
| Method Attributes | Method Name and Description |
|---|---|
|
为对象绑定函数
|
|
|
将css样式转换为驼峰的形式。如font-size -> fontSize
|
|
|
创建延迟执行的函数
|
|
|
遍历元素执行迭代器
|
|
|
将s对象中的属性扩展到t对象上
|
|
|
查找元素在数组中的索引, 若找不到返回-1
|
|
|
subClass继承superClass
|
|
|
判断是否为数组
|
|
|
判断是否为字符串
|
|
|
将字符串转换成hashmap
|
|
|
以obj为原型创建实例
|
|
|
移除数组中的元素
|
|
|
删除字符串首尾空格
|
|
|
将str中的html符号转义
|
Method Detail
{Function}
bind(fn, this_)
为对象绑定函数
- Parameters:
- {Function} fn
- 函数
- {Object} this_
- 对象
- Returns:
- {Function} 绑定后的函数
{String}
cssStyleToDomStyle(cssName)
将css样式转换为驼峰的形式。如font-size -> fontSize
- Parameters:
- {String} cssName
- 需要转换的样式
- Returns:
- {String} 转换后的样式
{Function}
defer(fn, delay, exclusion)
创建延迟执行的函数
- Parameters:
- {Function} fn
- 要执行的函数
- {Number} delay
- 延迟时间,单位为毫秒
- {Boolean} exclusion
- 是否互斥执行,true则执行下一次defer时会先把前一次的延迟函数删除
- Returns:
- {Function} 延迟执行的函数
each(eachable, iterator, this_)
遍历元素执行迭代器
- Parameters:
- {Array,Object} eachable
- 要迭代的对象
- {Function} iterator
- 迭代函数
- {Object} this_
- 传入对象
{Object}
extend(t, s, b)
将s对象中的属性扩展到t对象上
- Parameters:
- {Object} t
- {Object} s
- {Boolean} b
- 是否保留已有属性
- Returns:
- {Object} t 返回扩展了s对象属性的t
{Number}
indexOf(array, item, at)
查找元素在数组中的索引, 若找不到返回-1
- Parameters:
- {Array} array
- 要查找的数组
- {*} item
- 查找的元素
- {Number} at
- 开始查找的位置
- Returns:
- {Number} 返回在数组中的索引
{Object}
inherits(subClass, superClass)
subClass继承superClass
- Parameters:
- {Object} subClass
- 子类
- {Object} superClass
- 超类
- Returns:
- {Object} 扩展后的新对象
{Boolean}
isArray(array)
判断是否为数组
- Parameters:
- {Object} array
- Returns:
- {Boolean} true:为数组,false:不为数组
{Boolean}
isString(str)
判断是否为字符串
- Parameters:
- {Object} str
- Returns:
- {Boolean} true:为字符串。 false:不为字符串
{Object}
listToMap(list)
将字符串转换成hashmap
- Parameters:
- {String} list
- 字符串,以‘,’隔开
- Returns:
- {Object} 转成hashmap的对象
{Object}
makeInstance(obj)
以obj为原型创建实例
- Parameters:
- {Object} obj
- Returns:
- {Object} 返回新的对象
removeItem(array, item)
移除数组中的元素
- Parameters:
- {Array} array
- 要删除元素的数组
- {*} item
- 要删除的元素
{String}
trim(str)
删除字符串首尾空格
- Parameters:
- {String} str
- 字符串
- Returns:
- {String} str 删除空格后的字符串
{String}
unhtml(str)
将str中的html符号转义
- Parameters:
- {String} str
- 需要转义的字符串
- Returns:
- {String} 转义后的字符串