Skip to content

Commit 619cba3

Browse files
committed
v2
1 parent 8d1b76f commit 619cba3

19 files changed

+3079
-650
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Folder
2+
_[a-z0-9]*/
3+
node_modules/
4+
5+
# File
6+
_[a-z0-9]*.*
7+
*.zip
8+
*.rar
9+
10+
# Windows System File
11+
Thumbs.db
12+
Desktop.ini
13+
14+
# Mac System File
15+
*.DS_Store

README.md

Lines changed: 78 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,115 @@
11
# cxDialog
22

3-
cxDialog 是基于 jQuery 的对话框插件,支持自定义外观样式,同时兼容 Zepto,方便在移动端使用。
4-
5-
**版本:**
6-
* jQuery v1.9+ || Zepto 1.1+
7-
* cxDialog v1.3.0
3+
cxDialog 是基于 JavaScript 的对话框插件,支持自定义外观样式。
84

95
Demo: https://ciaoca.github.io/cxDialog/
106

11-
## 使用方法
7+
>从 v2.0 开始,已移除 jQuery 的依赖,如果需要使用旧版,可查看 [v1 分支](https://github.com/ciaoca/cxDialog/tree/v1)
8+
9+
10+
11+
## 安装方法
1212

13-
### 载入 CSS 文件
13+
### 浏览器端引入
1414

1515
```html
16-
<link rel="stylesheet" href="jquery.cxdialog.css">
16+
<link rel="stylesheet" href="cxdialog.css">
17+
<script src="cxdialog.js"></script>
1718
```
1819

19-
### 载入 JavaScript 文件
2020

21-
```html
22-
<script src="jquery.js"></script>
23-
<script src="jquery.cxdialog.js"></script>
21+
22+
### 从 NPM 安装,作为模块引入
23+
24+
```shell
25+
npm install cxdialog
26+
```
27+
28+
```javascript
29+
import 'cxdialog.css';
30+
import cxDialog from 'cxdialog';
2431
```
2532

26-
### 调用 cxDialog
33+
34+
35+
### 使用
2736

2837
```javascript
29-
$.cxDialog('内容');
38+
// 简易的方式
39+
cxDialog('内容');
3040

31-
$.cxDialog('内容', function(){
41+
cxDialog('内容', () => {
3242
// click ok callback
33-
}, function(){
43+
}, () => {
3444
// click no callback
3545
});
3646

37-
$.cxDialog({
47+
// 传入参数
48+
cxDialog({
3849
title: '标题',
3950
info: '内容',
40-
ok: function(){
41-
// code
42-
},
43-
no: function(){}
51+
ok: () => {},
52+
no: () => {}
4453
});
4554
```
4655

47-
### 设置全局默认值
56+
57+
58+
### 设置默认参数
4859

4960
``` javascript
50-
$.cxDialog.defaults.title = '提示';
61+
cxDialog.defaults.title = '提示';
5162
```
5263

64+
65+
5366
## 参数说明
54-
名称|默认值|说明
67+
68+
名称|类型|默认值|说明
69+
---|---|---|---
70+
title|string|''|标题
71+
info|string<br />element|''|内容,可设置为文本内容,或 DOM 元素
72+
ok|function|undefined|确认按钮回调函数<br />※ 值为 `function` 类型时,才会显示对应按钮
73+
no|function|undefined|取消按钮回调函数
74+
okText|string|'确 定'|确认按钮文字
75+
noText|string|'取 消'|取消按钮文字
76+
buttons|array|[]|自定义按钮
77+
baseClass|string|''|追加样式名称,不会覆盖默认的 class
78+
maskClose|boolean|true|是否允许点击遮罩层关闭对话框
79+
80+
81+
82+
### buttons 参数
83+
84+
```javascript
85+
cxDialog({
86+
info: '内容',
87+
buttons: [
88+
{
89+
text:'按钮1',
90+
callback: () => {}
91+
},
92+
{
93+
text:'按钮2',
94+
callback: () => {}
95+
}
96+
]
97+
});
98+
```
99+
100+
名称|类型|说明
55101
---|---|---
56-
title|''|标题
57-
info|''|内容,可设置为文本内容,或 DOM 元素
58-
ok|null|确认按钮回调函数
59-
okText|'确 定'|确认按钮文字
60-
no|null|取消按钮回调函数
61-
noText|'取 消'|取消按钮文字
62-
buttons|[]|自定义按钮
63-
baseClass|''|增加自定义 class,不会覆盖默认的 class
64-
maskClose|true|背景遮罩是否可以关闭对话框
65-
66-
## buttons 参数
102+
text|string|按钮文字
103+
callback|function|回调函数
104+
67105

68-
名称|说明
69-
---|---
70-
text|按钮文字
71-
callback|回调函数
72106

73107
## API 接口
74108

109+
```javascript
110+
cxDialog.close();
111+
```
112+
75113
名称|说明
76114
---|---
77-
$.cxDialog.close()|关闭对话框
115+
close|关闭对话框

css/demo.css

Lines changed: 0 additions & 34 deletions
This file was deleted.

css/jquery.cxdialog.css

Lines changed: 0 additions & 129 deletions
This file was deleted.

0 commit comments

Comments
 (0)