Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
梁志锋
9 years ago
Commit
1f5028df92d37492448ebacf4a9ea8aaf343e0c4
1 parent
d80cba33
dialog 模版的操作改成单例
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
19 deletions
static/js/me/dialog.js
static/js/me/dialog.js
View file @
1f5028d
...
...
@@ -12,30 +12,35 @@ var $dialogWrapper,
dialogTpl
,
dialogTemplate
;
dialogTpl
=
'<div id="dialog-wrapper" class="dialog-wrapper">'
+
'<div class="dialog-box">'
+
'{{# hasHeader}}'
+
'{{/ hasHeader}}'
+
'<div class="dialog-content">{{dialogText}}</div>'
+
'{{# hasFooter}}'
+
'<div class="dialog-footer">'
+
'{{# leftBtnText}}'
+
'<span class="dialog-left-btn">{{.}}</span>'
+
'{{/ leftBtnText}}'
+
'{{# rightBtnText}}'
+
'<span class="dialog-right-btn">{{.}}</span>'
+
'{{/ rightBtnText}}'
+
'</div>'
+
'{{/ hasFooter}}'
+
'</div>'
+
function
getInstance
()
{
if
(
dialogTpl
===
undefined
)
{
dialogTpl
=
'<div id="dialog-wrapper" class="dialog-wrapper">'
+
'<div class="dialog-box">'
+
'{{# hasHeader}}'
+
'{{/ hasHeader}}'
+
'<div class="dialog-content">{{dialogText}}</div>'
+
'{{# hasFooter}}'
+
'<div class="dialog-footer">'
+
'{{# leftBtnText}}'
+
'<span class="dialog-left-btn">{{.}}</span>'
+
'{{/ leftBtnText}}'
+
'{{# rightBtnText}}'
+
'<span class="dialog-right-btn">{{.}}</span>'
+
'{{/ rightBtnText}}'
+
'</div>'
+
'{{/ hasFooter}}'
+
'</div>'
+
'</div>'
;
dialogTemplate
=
Handlebars
.
compile
(
dialogTpl
);
dialogTemplate
=
Handlebars
.
compile
(
dialogTpl
);
}
return
dialogTemplate
;
}
exports
.
showDialog
=
function
(
data
,
callback
,
callbackForLeft
)
{
var
dialogStr
=
dialogTemplate
(
data
),
var
dialogTemplate
=
getInstance
(),
dialogStr
=
dialogTemplate
(
data
),
$dialogBox
,
defaultHideDuraton
,
dialogWrapperHammer
;
...
...
@@ -73,6 +78,11 @@ exports.showDialog = function(data, callback, callbackForLeft) {
},
defaultHideDuraton
);
}
//禁止在dialog上可以上下滚动
$dialogWrapper
.
on
(
'touchmove'
,
function
()
{
return
false
;
});
dialogWrapperHammer
.
on
(
'tap'
,
function
(
event
)
{
if
(
$
(
event
.
target
).
hasClass
(
'dialog-left-btn'
))
{
...
...
@@ -84,6 +94,7 @@ exports.showDialog = function(data, callback, callbackForLeft) {
callback
();
}
// 防止出现点透问题
event
.
preventDefault
();
event
.
srcEvent
.
stopPropagation
();
});
...
...
Please
register
or
login
to post a comment