Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zzx_123123
zui
提交
a224dd03
Z
zui
项目概览
zzx_123123
/
zui
与 Fork 源项目一致
Fork自
易企天创 / zui
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a224dd03
编写于
8月 30, 2016
作者:
C
Catouse
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* improve messsager.
上级
233e58ab
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
57 deletion
+53
-57
src/js/messager.js
src/js/messager.js
+53
-57
未找到文件。
src/js/messager.js
浏览文件 @
a224dd03
...
...
@@ -10,7 +10,7 @@
'
use strict
'
;
var
id
=
0
;
var
template
=
'
<div class="messager messager-{type} {placement}"
id="messager{id}"
style="display: none"><div class="messager-content"></div><div class="messager-actions"></div></div>
'
;
var
template
=
'
<div class="messager messager-{type} {placement}" style="display: none"><div class="messager-content"></div><div class="messager-actions"></div></div>
'
;
var
defaultOptions
=
{
type
:
'
default
'
,
placement
:
'
top
'
,
...
...
@@ -35,7 +35,10 @@
}
var
that
=
this
;
that
.
id
=
id
++
;
that
.
id
=
options
.
id
||
(
id
++
);
var
oldMessager
=
all
[
that
.
id
];
if
(
oldMessager
)
oldMessager
.
destory
();
all
[
that
.
id
]
=
that
;
options
=
that
.
options
=
$
.
extend
({},
defaultOptions
,
options
);
that
.
message
=
(
options
.
icon
?
'
<i class="icon-
'
+
options
.
icon
+
'
icon"></i>
'
:
''
)
+
message
;
...
...
@@ -111,8 +114,8 @@
that
.
$
.
removeClass
(
'
messager-
'
+
options
.
type
);
if
(
newOptions
)
{
options
=
$
.
extend
(
options
,
newOptions
);
that
.
$
.
addClass
(
'
messager-
'
+
options
.
type
);
}
that
.
$
.
addClass
(
'
messager-
'
+
options
.
type
);
if
(
message
)
{
that
.
message
=
(
options
.
icon
?
'
<i class="icon-
'
+
options
.
icon
+
'
icon"></i>
'
:
''
)
+
message
;
that
.
$
.
find
(
'
.messager-content
'
).
html
(
that
.
message
);
...
...
@@ -170,16 +173,22 @@
return
that
;
};
Messager
.
prototype
.
hide
=
function
(
callback
)
{
Messager
.
prototype
.
hide
=
function
(
callback
,
immediately
)
{
if
(
callback
===
true
)
{
immediately
=
true
;
callback
=
null
;
}
var
that
=
this
;
if
(
that
.
$
.
hasClass
(
'
in
'
))
{
that
.
$
.
removeClass
(
'
in
'
);
setTimeout
(
function
()
{
var
removeMessager
=
function
()
{
var
$parent
=
that
.
$
.
parent
();
that
.
$
.
detach
();
if
(
!
$parent
.
children
().
length
)
$parent
.
remove
();
callback
&&
callback
(
true
);
},
200
);
};
if
(
immediately
)
removeMessager
();
else
setTimeout
(
removeMessager
,
200
);
}
else
{
callback
&&
callback
(
false
);
}
...
...
@@ -188,8 +197,20 @@
};
Messager
.
prototype
.
destory
=
function
()
{
var
that
=
this
;
that
.
hide
(
true
);
that
.
$
.
remove
();
that
.
$
=
null
;
delete
all
[
that
.
id
];
};
Messager
.
all
=
all
;
var
hideMessage
=
function
()
{
$
(
'
.messager
'
).
each
(
function
()
{
var
msg
=
$
(
this
).
data
(
'
zui.messager
'
);
if
(
msg
&&
msg
.
hide
)
msg
.
hide
(
true
);
});
};
var
showMessage
=
function
(
message
,
options
)
{
...
...
@@ -198,70 +219,45 @@
type
:
options
};
}
var
msg
=
new
Messager
(
message
,
options
);
options
=
$
.
extend
({},
options
);
if
(
options
.
id
===
undefined
)
hideMessage
();
var
msg
=
all
[
options
.
id
]
||
new
Messager
(
message
,
options
);
msg
.
show
();
return
msg
;
};
var
hideMessage
=
function
()
{
$
(
'
.messager
'
).
each
(
function
()
{
var
msg
=
$
(
this
).
data
(
'
zui.messager
'
);
if
(
msg
&&
msg
.
hide
)
msg
.
hide
();
});
};
var
getOptions
=
function
(
options
)
{
return
(
typeof
options
===
'
string
'
)
?
{
placement
:
options
}
:
options
;
};
var
zuiMessager
=
{
show
:
showMessage
,
hide
:
hideMessage
};
$
.
each
({
primary
:
0
,
success
:
'
ok-sign
'
,
info
:
'
info-sign
'
,
warning
:
'
warning-sign
'
,
danger
:
'
exclamation-sign
'
,
important
:
0
,
special
:
0
},
function
(
name
,
icon
){
zuiMessager
[
name
]
=
function
(
message
,
options
)
{
return
showMessage
(
message
,
$
.
extend
({
type
:
name
,
icon
:
icon
||
null
},
getOptions
(
options
)));
};
});
$
.
zui
({
Messager
:
Messager
,
showMessager
:
showMessage
,
messager
:
{
show
:
showMessage
,
hide
:
hideMessage
,
primary
:
function
(
message
,
options
)
{
return
showMessage
(
message
,
$
.
extend
({
type
:
'
primary
'
},
getOptions
(
options
)));
},
success
:
function
(
message
,
options
)
{
return
showMessage
(
message
,
$
.
extend
({
type
:
'
success
'
,
icon
:
'
ok-sign
'
},
getOptions
(
options
)));
},
info
:
function
(
message
,
options
)
{
return
showMessage
(
message
,
$
.
extend
({
type
:
'
info
'
,
icon
:
'
info-sign
'
},
getOptions
(
options
)));
},
warning
:
function
(
message
,
options
)
{
return
showMessage
(
message
,
$
.
extend
({
type
:
'
warning
'
,
icon
:
'
warning-sign
'
},
getOptions
(
options
)));
},
danger
:
function
(
message
,
options
)
{
return
showMessage
(
message
,
$
.
extend
({
type
:
'
danger
'
,
icon
:
'
exclamation-sign
'
},
getOptions
(
options
)));
},
important
:
function
(
message
,
options
)
{
return
showMessage
(
message
,
$
.
extend
({
type
:
'
important
'
},
getOptions
(
options
)));
},
special
:
function
(
message
,
options
)
{
return
showMessage
(
message
,
$
.
extend
({
type
:
'
special
'
},
getOptions
(
options
)));
}
}
messager
:
zuiMessager
});
}(
jQuery
,
window
,
undefined
));
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录