Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zui
提交
f2646b3e
Z
zui
项目概览
易企天创
/
zui
11 个月 前同步成功
通知
6
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
37
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
37
Issue
37
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f2646b3e
编写于
8月 22, 2016
作者:
C
Catouse
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* support display multiple messagers.
上级
9176ee01
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
77 addition
and
52 deletion
+77
-52
src/js/messager.js
src/js/messager.js
+14
-17
src/less/modules/messager.less
src/less/modules/messager.less
+63
-35
未找到文件。
src/js/messager.js
浏览文件 @
f2646b3e
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
'
use strict
'
;
'
use strict
'
;
var
id
=
0
;
var
id
=
0
;
var
template
=
'
<div class="messager messager-{type} {placement}" id="messager{id}"
style="display:none"><div class="messager-actions"></div><div class="messager-content
"></div></div>
'
;
var
template
=
'
<div class="messager messager-{type} {placement}" id="messager{id}"
><div class="messager-content"></div><div class="messager-actions
"></div></div>
'
;
var
defaultOptions
=
{
var
defaultOptions
=
{
type
:
'
default
'
,
type
:
'
default
'
,
placement
:
'
top
'
,
placement
:
'
top
'
,
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
fade
:
true
,
fade
:
true
,
scale
:
true
scale
:
true
};
};
var
lastMessager
;
var
all
=
{}
;
var
Messager
=
function
(
message
,
options
)
{
var
Messager
=
function
(
message
,
options
)
{
var
that
=
this
;
var
that
=
this
;
...
@@ -100,14 +100,6 @@
...
@@ -100,14 +100,6 @@
var
that
=
this
,
var
that
=
this
,
options
=
this
.
options
;
options
=
this
.
options
;
if
(
lastMessager
)
{
if
(
lastMessager
.
id
==
that
.
id
)
{
that
.
$
.
removeClass
(
'
in
'
);
}
else
if
(
lastMessager
.
isShow
)
{
lastMessager
.
hide
();
}
}
if
(
that
.
hiding
)
{
if
(
that
.
hiding
)
{
clearTimeout
(
that
.
hiding
);
clearTimeout
(
that
.
hiding
);
that
.
hiding
=
null
;
that
.
hiding
=
null
;
...
@@ -118,14 +110,18 @@
...
@@ -118,14 +110,18 @@
that
.
$
.
find
(
'
.messager-content
'
).
html
(
that
.
message
);
that
.
$
.
find
(
'
.messager-content
'
).
html
(
that
.
message
);
}
}
that
.
$
.
appendTo
(
options
.
parent
).
show
()
;
if
(
that
.
isShow
)
return
;
if
(
options
.
placement
===
'
top
'
||
options
.
placement
===
'
bottom
'
||
options
.
placement
===
'
center
'
)
{
var
placement
=
options
.
placement
;
that
.
$
.
css
(
'
left
'
,
(
$
(
window
).
width
()
-
that
.
$
.
width
())
/
2
);
var
$parent
=
$
(
options
.
parent
);
var
$holder
=
$parent
.
children
(
'
.messagers-holder.
'
+
placement
);
if
(
!
$holder
.
length
)
{
$holder
=
$
(
'
<div/>
'
).
attr
(
'
class
'
,
'
messagers-holder
'
+
placement
).
appendTo
(
$parent
);
}
}
$holder
.
append
(
that
.
$
);
if
(
options
.
placement
===
'
left
'
||
options
.
placement
===
'
right
'
||
options
.
placement
===
'
center
'
)
{
if
(
placement
===
'
center
'
)
{
that
.
$
.
css
(
'
top
'
,
(
$
(
window
).
height
()
-
that
.
$
.
height
())
/
2
);
var
offset
=
$
(
window
).
height
()
-
$holder
.
height
();
$holder
.
css
(
'
top
'
,
Math
.
max
(
-
offset
,
offset
/
2
));
}
}
that
.
$
.
addClass
(
'
in
'
);
that
.
$
.
addClass
(
'
in
'
);
...
@@ -137,7 +133,6 @@
...
@@ -137,7 +133,6 @@
}
}
that
.
isShow
=
true
;
that
.
isShow
=
true
;
lastMessager
=
that
;
};
};
Messager
.
prototype
.
hide
=
function
()
{
Messager
.
prototype
.
hide
=
function
()
{
...
@@ -145,7 +140,9 @@
...
@@ -145,7 +140,9 @@
if
(
that
.
$
.
hasClass
(
'
in
'
))
{
if
(
that
.
$
.
hasClass
(
'
in
'
))
{
that
.
$
.
removeClass
(
'
in
'
);
that
.
$
.
removeClass
(
'
in
'
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
var
$parent
=
that
.
$
.
parent
();
that
.
$
.
remove
();
that
.
$
.
remove
();
if
(
!
$parent
.
children
().
length
)
$parent
.
remove
();
},
200
);
},
200
);
}
}
...
...
src/less/modules/messager.less
浏览文件 @
f2646b3e
...
@@ -9,47 +9,19 @@
...
@@ -9,47 +9,19 @@
// Messager style for module messager.js
// Messager style for module messager.js
.messager {
.messager {
position: fixed
;
display: table
;
color: @color-light;
color: @color-light;
background-color: @color-dark;
background-color: @color-dark;
background-color: rgba(0, 0, 0, 0.8);
background-color: rgba(0, 0, 0, 0.8);
border-radius: @messager-radius;
border-radius: @messager-radius;
max-width: 80%;
margin: 10px;
z-index: 99999;
pointer-events: auto;
&:extend(.clearfix all);
&.top {
top: 20px;
}
&.top-left {
top: 20px;
left: 20px;
}
&.top-right {
top: 20px;
right: 20px;
}
&.bottom {
bottom: 20px;
}
&.bottom-left {
bottom: 20px;
left: 20px;
}
&.bottom-right {
bottom: 20px;
right: 20px;
}
}
}
.messager-content {
.messager-content {
padding: 10px 20px;
padding: 10px 15px;
float: left;
display: table-cell;
vertical-align: top;
> [class^='icon-'] {
> [class^='icon-'] {
display: inline-block;
display: inline-block;
...
@@ -58,7 +30,8 @@
...
@@ -58,7 +30,8 @@
}
}
.messager-actions {
.messager-actions {
float: right;
display: table-cell;
vertical-align: top;
> .action {
> .action {
color: #fafafa;
color: #fafafa;
...
@@ -87,6 +60,61 @@
...
@@ -87,6 +60,61 @@
.action-icon + .action-text {margin-left: 8px;}
.action-icon + .action-text {margin-left: 8px;}
}
}
.messagers-holder {
z-index: 99999;
position: fixed;
padding: 10px;
pointer-events: none;
.transition-fast(top);
&.top {
top: 0;
}
&.top-left {
top: 0;
left: 0;
}
&.top-right {
top: 0;
right: 0;
}
&.bottom {
bottom: 0;
}
&.bottom-left {
bottom: 0;
left: 0;
}
&.bottom-right {
bottom: 0;
right: 0;
}
&.top-right,
&.bottom-right {
.messager { margin-left: auto; }
}
&.center {
top: 0;
}
&.top,
&.bottom,
&.center {
left: 0;
right: 0;
.messager { margin: 10px auto; }
}
}
.messager-primary {
.messager-primary {
background-color: @state-primary-inverse-bg;
background-color: @state-primary-inverse-bg;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录