Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
wenjiekong
9 years ago
Commit
a74cf25d79e3d73e54e539020b5361ab142495c2
1 parent
13201798
更新dialog和PHP的文件同步
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
5 deletions
public/js/common/dialog.js
public/js/common/dialog.js
View file @
a74cf25
...
...
@@ -9,7 +9,8 @@ var $ = require('yoho-jquery'),
var
defaultOptions
=
{
mask
:
true
,
closeIcon
:
true
closeIcon
:
true
,
refreshOnClose
:
false
};
var
tpl
=
...
...
@@ -53,12 +54,21 @@ function createDialog(data) {
return
$
(
'.yoho-dialog'
);
}
function
cerateSubContent
(
text
)
{
var
$yohoDialog
=
$
(
'.yoho-dialog'
),
subContent
=
'<p class="sub-content">'
+
text
+
'</p>'
;
if
(
$yohoDialog
&&
$yohoDialog
.
length
>
0
)
{
$yohoDialog
.
find
(
'.content'
).
after
(
subContent
);
}
}
function
Dialog
(
options
)
{
var
opt
=
$
.
extend
({},
defaultOptions
,
options
);
var
that
=
this
,
i
;
//
实现继承时,只返回实例,不生成html
//实现继承时,只返回实例,不生成html
if
(
opt
.
inherit
)
{
return
this
;
}
...
...
@@ -66,11 +76,31 @@ function Dialog(options) {
if
(
opt
.
mask
)
{
that
.
$mask
=
createMask
();
}
that
.
$el
=
createDialog
(
opt
);
// 绑定x关闭事件
if
(
opt
.
subContent
)
{
cerateSubContent
(
opt
.
subContent
);
}
if
(
opt
.
subContents
)
{
for
(
i
=
opt
.
subContents
.
length
-
1
;
i
>=
0
;
i
--
)
{
cerateSubContent
(
opt
.
subContents
[
i
]);
}
}
//绑定x关闭事件
that
.
$el
.
find
(
'.close'
).
click
(
function
()
{
that
.
close
();
if
(
options
.
refreshOnClose
)
{
window
.
location
.
reload
();
}
});
//绑定btn关闭事件
that
.
$el
.
find
(
'.btn-close'
).
click
(
function
()
{
that
.
close
();
});
function
bindBtnEvt
(
index
)
{
...
...
@@ -79,8 +109,8 @@ function Dialog(options) {
});
}
// 绑定按钮事件
if
(
opt
.
btns
)
{
//绑定按钮事件
if
(
!!
opt
.
btns
)
{
for
(
i
=
0
;
i
<
opt
.
btns
.
length
;
i
++
)
{
bindBtnEvt
(
i
);
}
...
...
Please
register
or
login
to post a comment