Skip to content

Commit

Permalink
Merge pull request #192 from Tencent/develop
Browse files Browse the repository at this point in the history
v1.1.3
  • Loading branch information
progrape authored Nov 9, 2017
2 parents 7682695 + d3ef31a commit 5f3bdff
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 223 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#### v1.1.3 (2017-11-08)

- 【优化】 `picker``actionSheet` 增加`onClose`



#### v1.1.2 (2017-06-28)

- 【修复】 hide的回调在事件响应中报错的问题
Expand Down
17 changes: 17 additions & 0 deletions __tests__/actionsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,21 @@ describe('actionsheet', function(){
done();
}, closeDur);
});

it('test onClose', (done) => {
let called = false;
const actionSheet = weui.actionSheet([], [], {
onClose: function(){
called = true;
}
});
$('.weui-mask').click();

setTimeout(() => {
assert($('.weui-actionsheet').length === 0);
assert(called);

done();
}, closeDur);
});
});
19 changes: 19 additions & 0 deletions __tests__/picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,23 @@ describe('picker', function () {
done();
}, closeDur);
});

it('test onClose', (done) => {
let called = false;
const picker = weui.datePicker({
start: 1990,
end: 2000,
onClose: function(){
called = true;
}
});
$('.weui-mask').click();

setTimeout(() => {
assert($('.weui-picker').length === 0);
assert(called);

done();
}, closeDur);
});
});
25 changes: 20 additions & 5 deletions dist/example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@
console.log('取消');
}
}], {
className: "custom-classname"
className: "custom-classname",
onClose: function onClose() {
console.log('关闭');
}
});
});

Expand Down Expand Up @@ -240,7 +243,10 @@
onConfirm: function onConfirm(result) {
console.log(result);
},
id: 'multiPickerBtn'
id: 'multiPickerBtn',
onClose: function onClose() {
console.log('onClose');
}
});
});

Expand Down Expand Up @@ -2623,6 +2629,7 @@
*
* @param {object=} options 配置项
* @param {string=} options.className 自定义类名
* @param {function=} [options.onClose] actionSheet关闭后的回调
*
* @example
* weui.actionSheet([
Expand Down Expand Up @@ -2650,7 +2657,10 @@
* }
* }
* ], {
* className: 'custom-classname'
* className: 'custom-classname',
* onClose: function(){
* console.log('关闭');
* }
* });
*/
function actionSheet() {
Expand All @@ -2665,7 +2675,8 @@
menus: menus,
actions: actions,
className: '',
isAndroid: isAndroid
isAndroid: isAndroid,
onClose: _util2.default.noop
}, options);
var $actionSheetWrap = (0, _util2.default)(_util2.default.render(_actionSheet2.default, options));
var $actionSheet = $actionSheetWrap.find('.weui-actionsheet');
Expand All @@ -2678,6 +2689,7 @@
$actionSheetMask.addClass('weui-animate-fade-out').on('animationend webkitAnimationEnd', function () {
$actionSheetWrap.remove();
_sington = false;
options.onClose();
callback && callback();
});
}
Expand Down Expand Up @@ -4090,6 +4102,7 @@
* @param {array=} [options.defaultValue] 默认选项的value数组
* @param {function=} [options.onChange] 在picker选中的值发生变化的时候回调
* @param {function=} [options.onConfirm] 在点击"确定"之后的回调。回调返回选中的结果(Array),数组长度依赖于picker的层级。
* @param {function=} [options.onClose] picker关闭后的回调
*
* @example
* // 单列picker
Expand Down Expand Up @@ -4232,7 +4245,8 @@
className: '',
container: 'body',
onChange: _util2.default.noop,
onConfirm: _util2.default.noop
onConfirm: _util2.default.noop,
onClose: _util2.default.noop
}, options);

// 数据处理
Expand Down Expand Up @@ -4274,6 +4288,7 @@
$picker.find('.weui-picker').addClass('weui-animate-slide-down').on('animationend webkitAnimationEnd', function () {
$picker.remove();
_sington = false;
defaults.onClose();
callback && callback();
});
}
Expand Down
15 changes: 12 additions & 3 deletions dist/weui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,7 @@ return /******/ (function(modules) { // webpackBootstrap
*
* @param {object=} options 配置项
* @param {string=} options.className 自定义类名
* @param {function=} [options.onClose] actionSheet关闭后的回调
*
* @example
* weui.actionSheet([
Expand Down Expand Up @@ -1323,7 +1324,10 @@ return /******/ (function(modules) { // webpackBootstrap
* }
* }
* ], {
* className: 'custom-classname'
* className: 'custom-classname',
* onClose: function(){
* console.log('关闭');
* }
* });
*/
function actionSheet() {
Expand All @@ -1338,7 +1342,8 @@ return /******/ (function(modules) { // webpackBootstrap
menus: menus,
actions: actions,
className: '',
isAndroid: isAndroid
isAndroid: isAndroid,
onClose: _util2.default.noop
}, options);
var $actionSheetWrap = (0, _util2.default)(_util2.default.render(_actionSheet2.default, options));
var $actionSheet = $actionSheetWrap.find('.weui-actionsheet');
Expand All @@ -1351,6 +1356,7 @@ return /******/ (function(modules) { // webpackBootstrap
$actionSheetMask.addClass('weui-animate-fade-out').on('animationend webkitAnimationEnd', function () {
$actionSheetWrap.remove();
_sington = false;
options.onClose();
callback && callback();
});
}
Expand Down Expand Up @@ -2763,6 +2769,7 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {array=} [options.defaultValue] 默认选项的value数组
* @param {function=} [options.onChange] 在picker选中的值发生变化的时候回调
* @param {function=} [options.onConfirm] 在点击"确定"之后的回调。回调返回选中的结果(Array),数组长度依赖于picker的层级。
* @param {function=} [options.onClose] picker关闭后的回调
*
* @example
* // 单列picker
Expand Down Expand Up @@ -2905,7 +2912,8 @@ return /******/ (function(modules) { // webpackBootstrap
className: '',
container: 'body',
onChange: _util2.default.noop,
onConfirm: _util2.default.noop
onConfirm: _util2.default.noop,
onClose: _util2.default.noop
}, options);

// 数据处理
Expand Down Expand Up @@ -2947,6 +2955,7 @@ return /******/ (function(modules) { // webpackBootstrap
$picker.find('.weui-picker').addClass('weui-animate-slide-down').on('animationend webkitAnimationEnd', function () {
$picker.remove();
_sington = false;
defaults.onClose();
callback && callback();
});
}
Expand Down
4 changes: 2 additions & 2 deletions dist/weui.min.js

Large diffs are not rendered by default.

29 changes: 2 additions & 27 deletions docs/component/actionSheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,9 @@ actionsheet 弹出式菜单
| actions[].onClick | <code>function</code> | 选项点击时的回调 |
| [options] | <code>object</code> | 配置项 |
| [options.className] | <code>string</code> | 自定义类名 |
| [options.onClose] | <code>function</code> | actionSheet关闭后的回调 |

**Example**
```js
weui.actionSheet([
{
label: '拍照',
onClick: function () {
console.log('拍照');
}
}, {
label: '从相册选择',
onClick: function () {
console.log('从相册选择');
}
}, {
label: '其他',
onClick: function () {
console.log('其他');
}
}
], [
{
label: '取消',
onClick: function () {
console.log('取消');
}
}
], {
className: 'custom-classname'
});
weui.actionSheet([ { label: '拍照', onClick: function () { console.log('拍照'); } }, { label: '从相册选择', onClick: function () { console.log('从相册选择'); } }, { label: '其他', onClick: function () { console.log('其他'); } }], [ { label: '取消', onClick: function () { console.log('取消'); } }], { className: 'custom-classname', onClose: function(){ console.log('关闭'); }});
```
Expand Down
Loading

0 comments on commit 5f3bdff

Please sign in to comment.