-
Notifications
You must be signed in to change notification settings - Fork 0
api
<div class="toggle" id="toggle"></div>new Toggle("#toggle");- 两种界面风格,给div加上类名即可:
toggle-gray,toggle-white - 如果希望默认处于选中状态,则应该添加类名
checked
| 参数名 | 只读 | 数据类型 | 说明 |
|---|---|---|---|
| checked | 是 | boolean | 表明组件当前是否处于选中状态 |
可以在一个DOM节点上多次构造组件,但是第一次构造之后,其后的函数调用会忽略回调函数以外的其他参数
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| selector | 是 | string/node | 可以是选择器字符串、DOM节点、jquery对象 |
| setting | 否 | json | {onchange:function(state){}} |
将组件切换到选中状态,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|
将组件切换到未选中状态,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|
切换组件的选中状态,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|
判断组件当前是否处于选中状态,返回boolean值
| 参数名 | 必需 | 数据类型 | 说明 |
|---|
绑定回调函数,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| setting | 是 | json | 构造函数中的回调函数部分,例如:{onchange:function(state){}} |
<div class="foo" id="foo"></div>new Tips("#foo",{titleColor: "white",content: "target偏左,移動三角形指向水平正中(5)",position: "top",size:"default",});
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| selector | 是 | string/node | 可以是选择器字符串、DOM节点、jquery对象 |
| setting | 否 | json |
setting属性细节
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| title | 否 | string | |
| titleColor | 否 | string | grb/#/color name |
| content | 是 | string | |
| titleBackgroundColor | 否 | string | grb/#/color name |
| contentColor | 否 | string | grb/#/color name |
| contentBackgroundColor | 否 | string | grb/#/color name |
| position | 否 | string | top bottom left right,默认bottom |
| size | 否 | string | tiny small default large,默认default |
| pieriod | 否 | number | 毫秒 |
静态函数,用于关闭所有tips,无参数
<div class="foo">
<div class="tab-tabs">
<div class="tab-item">1</div>
<div class="tab-item">2</div>
<div class="tab-item">3</div>
</div>
<div class="tab-content">一</div>
<div class="tab-content">二</div>
<div class="tab-content">三</div>
</div> new TabView(".foo", {
defaultIndex: 1,
trigger: "mouseenter",
onchange: function(current, last) {
console.log(current + "←——" + last);
}
});| 参数名 | 只读 | 数据类型 | 说明 |
|---|
可以在一个DOM节点上多次构造组件,但是第一次构造之后,其后的函数调用会忽略回调函数以外的其他参数
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| selector | 是 | string/node | 可以是选择器字符串、DOM节点、jquery对象 |
| setting | 否 | json | {onchange:function(current,last){}} |
setting属性细节
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| title | 否 | string | |
| defaultIndex | 否 | string | 默认0 |
| trigger | 否 | string | mouseenter/click/none,默认click |
| onchange | 否 | string | 带两个参数,current、last |
导航到某个选项卡,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| index | 是 | number |
绑定回调函数,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| setting | 是 | json | 构造函数中的回调函数部分,例如:{onchange:function(current,last){}} |
给普通table元素添加额外功能
可以在一个DOM节点上多次构造组件,但是第一次构造之后,其后的函数调用会忽略回调函数以外的其他参数
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| selector | 是 | string/node | 可以是选择器字符串、DOM节点、jquery对象 |
使某个单元格处于编辑状态,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| selector | 是 | string/node | 可以是选择器字符串、DOM节点、jquery对象,指向某个单元格 |
- 模拟原生select控件
<div class="select foo">
<div class="select-holder"></div>
<div class="select-menu">
<div class="select-option" data-value="1">顺丰快递</div>
<div class="select-option" data-value="2">圆通快递</div>
</div>
</div>- 以上除了select、select-holder、select-menu、select-option等类名,data-value属性也不可少,其相当于原生option元素上的value属性
new Select(".foo", {
onchange: function(current, last) {
console.log(last + "——→" + current)
},
defaultValue: "2",
tips: "订单状态",
theme: "rrm-circular" //rrm-circular圆角,rrm-square直角
});可以在一个DOM节点上多次构造组件,但是第一次构造之后,其后的函数调用会忽略回调函数以外的其他参数
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| selector | 是 | string/node | 可以是选择器字符串、DOM节点、jquery对象 |
| setting | 否 | json |
setting属性细节
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| defaultValue | 否 | string | 默认选中项 |
| tips | 否 | string | 初始状态显示文字,如果defaultValue,则defaultValue优先 |
| theme | 否 | string | 皮肤风格 |
| onchange | 否 | function | function(current,last){} |
切换到某个选项,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| value | 是 | string |
获取或设置选中项,不带参数则是getter函数,setter函数返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| value | 否 | string |
绑定回调函数,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| setting | 是 | json | 构造函数中的回调函数部分,例如:{onchange:function(current,last){}} |
- 分页器本身不负责数据的获取与更新
- 回调函数控制数据的更新
可以在一个DOM节点上多次构造组件,但是第一次构造之后,其后的函数调用会忽略回调函数以外的其他参数
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| selector | 是 | string/node | 可以是选择器字符串、DOM节点、jquery对象 |
| setting | 否 | json |
setting属性细节
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| totalPages | 是 | number | 总页数,默认20 |
| visiblePages | 是 | number | 可视区域显示的数字个数,默认8 |
| currentPage | 否 | number | 默认1 |
| canStepOver | 否 | boolean | 是否显示上一页下一页,默认false |
| canGetEnd | 否 | boolean | 是否显示第一页最后一页,默认false |
| onchange | 否 | function | function(current,last){} |
跳到第几页,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| index | 是 | number |
获取当前处于的页数,返回number
绑定回调函数,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| setting | 是 | json | 构造函数中的回调函数部分,例如:{onchange:function(current,last){}} |
导航菜单
可以在一个DOM节点上多次构造组件,但是第一次构造之后,其后的函数调用会忽略回调函数以外的其他参数
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| selector | 是 | string/node | 可以是选择器字符串、DOM节点、jquery对象 |
| setting | 否 | json |
setting属性细节
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| data | 是 | json | |
| onchange | 否 | function | {onchange: function(hash) {window.alert("刚刚点击了:" + hash);}} |
绑定回调函数,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| setting | 是 | json | 构造函数中的回调函数部分,例如:{onchange:function(hash){}} |
LightBox
可以在一个DOM节点上多次构造组件,但是第一次构造之后,其后的函数调用会忽略回调函数以外的其他参数
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| selector | 是 | string/node | 可以是选择器字符串、DOM节点、jquery对象 |
| setting | 否 | json |
setting属性细节
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| position | 否 | string | center,top,bottom默认为center |
| onshow | 否 | function | 无参数 |
| onhide | 否 | function | 无参数 |
绑定回调函数,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| setting | 是 | json | 构造函数中的回调函数部分 |
隐藏内容,返回组件本身
显示内容,返回组件本身
- 只提供静态函数
- 只提供alert和confirm两个函数
弹出警告框
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| setting | 是 | json |
setting属性细节
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| title | 否 | string | |
| msg | 是 | string | |
| onYes | 否 | function | 无参数 |
| theme | 否 | string |
弹出确认框
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| setting | 是 | json |
setting属性细节
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| title | 否 | string | |
| msg | 是 | string | |
| onYes | 否 | function | 无参数 |
| onNo | 否 | function | 无参数 |
| theme | 否 | string |
<div id="group1" class="btn_group">
<div class="btn_group-item" data-value="man">男</div>
<div class="btn_group-item" data-value="woman">女</div>
</div>- 除了类名btn_group和btn_group-item,属性data-value也是必须的,其相当于radio和checkbox的value属性
可以在一个DOM节点上多次构造组件,但是第一次构造之后,其后的函数调用会忽略回调函数以外的其他参数
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| selector | 是 | string/node | 可以是选择器字符串、DOM节点、jquery对象 |
| setting | 是 | json |
setting属性细节
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| type | 否 | string | single multiple,默认为single |
| onchange | 否 | function | single情况下,两个参数,current和last,multiple情况下,三个参数changed, current, last |
| defaultValue | 否 | string/array | multiple情况下为数组,single情况下为string |
绑定回调函数,返回组件本身
| 参数名 | 必需 | 数据类型 | 说明 |
|---|---|---|---|
| setting | 是 | json | 构造函数中的回调函数部分 |
返回当前选中的值,single情况下,为字符串,multiple情况下,为数组