Namespace: Control

hui. Control

基础控件类
Since:
  • 2015-06-25 10:48
Author:
  • haiyang5210
Source:

Methods

(static) appendControl(uiObj)

父控件添加子控件. 注: 将子控件加到父控件下面的容器中也可以调用appendSelfTo
Parameters:
Name Type Description
uiObj Control 子控件.
Source:

(static) create(type, options) → {hui.Control}

创建一个控件对象
Parameters:
Name Type Description
type String 控件类型
options Object 控件初始化参数
Source:
Returns:
创建的控件对象
Type
hui.Control
Example
<button hui-type="Button" id="submit">submit</button>
hui.Control.init(hui.bocument.getElementById('submit'));

(static) disposeList(list)

销毁一组控件
Parameters:
Name Type Description
list String 一组控件
Source:

(static) encode(str, decodeopt)

对特殊字符和换行符编解码
Parameters:
Name Type Attributes Description
str String 待编解码的字符串
decode String <optional>
是否是解码
Source:
Example
hui.Control.encode('%| |&|;|=|+|<|>|,');

(static) findByElem(parentElement)

回溯找到当前元素所在的控件
Parameters:
Name Type Description
parentElement Element DOM元素
Source:

(static) format(source, opts) → {String}

合并模板和数据
Parameters:
Name Type Description
source String 待格式化的字符串
opts Object | Array 要合并到字符串中的数据
Source:
Returns:
格式化之后的字符串
Type
String
Example
hui.Control.format('Hello {{user}}', {user: 'Tom'});
>> Hello Tom

(static) formatDate(date, fmt)

将Date类型解析为String类型.
Parameters:
Name Type Description
date Date 输入的日期
fmt String 输出日期格式
Source:
Example
hui.Control.formatDate(new Date(2006,0,1), 'yyyy-MM-dd HH:mm');

(static) getByFormname(formname, parentNode)

根据控件formname找到对应控件,只返回一个结果
Parameters:
Name Type Description
formname String 控件formname
parentNode Control 父控件
Source:
Example
<button hui-type="Button" hui-formname="save">Save</button>
var save = hui.Control.getByFormname('save');

(static) getByFormnameAll(formname, parentNode, all)

根据控件formname找到对应控件
Parameters:
Name Type Description
formname String 控件formname
parentNode Control 父控件
all Boolean 仅查找直接子级,默认所有子级
Source:

(static) getById(parentControlopt, id)

根据控件id找到对应控件
Parameters:
Name Type Attributes Description
parentControl Control <optional>
可不传, 默认从当前Action开始找, 如果未使用action则直接从window.cc开始找
id String 控件id
Source:

(static) init(opt_wrap, opt_propMap, parentControl) → {Object}

批量生成控件
Parameters:
Name Type Description
opt_wrap HTMLElement 渲染的区域容器元素
opt_propMap Object 控件需要用到的数据Model{@key}
parentControl Object 渲染的action,不传则默认为window对象
Source:
Returns:
控件集合
Type
Object
Example
hui.Control.init(hui.bocument.getElementById('content'));

(static) isChildControl(elem)

判断一个解析前DOM元素是否是子控件,是则跳过非父控件的hui.Control.init()
Parameters:
Name Type Description
elem String DOM元素
Source:

(static) isControlMain(elem)

判断一个解析前DOM元素是否已解析控件
Parameters:
Name Type Description
elem String DOM元素
Source:

(static) parseDate(fmt)

将String类型解析为Date类型.
Parameters:
Name Type Description
fmt String 输入的字符串格式的日期
Source:
Example
parseDate('2006-1-1') return new Date(2006,0,1)  
parseDate(' 2006-1-1 ') return new Date(2006,0,1)
parseDate('2006-1-1 15:14:16') return new Date(2006,0,1,15,14,16)
parseDate(' 2006-1-1 15:14:16 ') return new Date(2006,0,1,15,14,16);
parseDate('不正确的格式') retrun null