Commit 87068a9 1 parent 6d05b64 commit 87068a9 Copy full SHA for 87068a9
File tree 3 files changed +16
-18
lines changed
docs/_includes/_components
3 files changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -771,11 +771,20 @@ <h1 class="title">指示器(indicator)</h1>
771
771
772
772
< article class ="component active " id ='toast ' data-url ='toast '>
773
773
< h2 class ="component-title "> toast</ h2 >
774
- < p class ="component-description "> toast是一种轻量的提示,在页面中间显示,并且会在2秒之后自动消失 。</ p >
774
+ < p class ="component-description "> toast是一种轻量的提示,在页面中间显示,并且会在2秒(默认值,可修改)之后自动消失 。</ p >
775
775
< p > 可以用来显示一些不会打断用户操作的提示。</ p >
776
776
777
+ {% highlight html%}
778
+ /* msg{string}: toast内容
779
+ * duration{number}:toast显示时间,默认2000
780
+ * extraclass{string}:给toast根节点附加class,高度自定义属性,方便用户自行控制不同场景的样式。
781
+ * 如果使用了第三个参数,请自行在业务css里添加extraclass对应的样式
782
+ * /
783
+ {% endhighlight %}
777
784
{% highlight js %}
778
785
$.toast("操作失败");
786
+
787
+ $.toast('操作成功,正在跳转...', 2345, 'success top');
788
+
779
789
{% endhighlight %}
780
- < p > toast 组件后续会支持不同的情景,包括操作成功、操作失败等,显示出不同的颜色</ p >
781
790
</ article >
Original file line number Diff line number Diff line change 220
220
221
221
/**
222
222
* 判断是否组合型label
223
- * 夏苒添加
224
- *
225
223
* @type {Boolean }
226
224
*/
227
225
var isCompositeLabel = false ;
234
232
*/
235
233
FastClick . prototype . needsClick = function ( target ) {
236
234
237
- // 修复bug: 如果父元素中有 label
238
- // 夏苒删除
239
- /*
240
- var parent = target;
241
- while(parent && (parent.tagName.toUpperCase() !== "BODY")) {
242
- if(parent.tagName.toUpperCase() === "LABEL") return true;
243
- parent = parent.parentNode;
244
- }
245
- */
246
- // 夏苒添加start,如果label上有needsclick这个类,则用原生的点击,否则,用模拟点击
235
+ // 修复bug: 如果父元素中有 label
236
+ // 夏苒添加start,如果label上有needsclick这个类,则用原生的点击,否则,用模拟点击
247
237
var parent = target ;
248
238
while ( parent && ( parent . tagName . toUpperCase ( ) !== "BODY" ) ) {
249
239
if ( parent . tagName . toUpperCase ( ) === "LABEL" ) {
687
677
688
678
// Cancel the event
689
679
event . stopPropagation ( ) ;
690
- // event.preventDefault(); 夏苒删除
691
680
// 允许组合型label冒泡,夏苒添加start
692
681
if ( ! isCompositeLabel ) {
693
682
event . preventDefault ( ) ;
Original file line number Diff line number Diff line change 268
268
return modal [ 0 ] ;
269
269
} ;
270
270
//显示一个消息,会在2秒钟后自动消失
271
- $ . toast = function ( msg ) {
272
- var $toast = $ ( " <div class=' modal toast'>" + msg + " </div>" ) . appendTo ( document . body ) ;
271
+ $ . toast = function ( msg , duration , extraclass ) {
272
+ var $toast = $ ( ' <div class=" modal toast ' + ( extraclass || '' ) + '">' + msg + ' </div>' ) . appendTo ( document . body ) ;
273
273
$ . openModal ( $toast ) ;
274
274
setTimeout ( function ( ) {
275
275
$ . closeModal ( $toast ) ;
276
- } , 2000 ) ;
276
+ } , duration || 2000 ) ;
277
277
} ;
278
278
$ . openModal = function ( modal ) {
279
279
modal = $ ( modal ) ;
You can’t perform that action at this time.
0 commit comments