|
@@ -12,8 +12,9 @@ var $dialogWrapper, |
|
@@ -12,8 +12,9 @@ var $dialogWrapper, |
12
|
dialogTpl,
|
12
|
dialogTpl,
|
13
|
dialogTemplate;
|
13
|
dialogTemplate;
|
14
|
|
14
|
|
15
|
-
|
|
|
16
|
-dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
|
15
|
+function getInstance() {
|
|
|
16
|
+ if (dialogTpl === undefined) {
|
|
|
17
|
+ dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
|
17
|
'<div class="dialog-box">' +
|
18
|
'<div class="dialog-box">' +
|
18
|
'{{# hasHeader}}' +
|
19
|
'{{# hasHeader}}' +
|
19
|
'{{/ hasHeader}}' +
|
20
|
'{{/ hasHeader}}' +
|
|
@@ -31,11 +32,15 @@ dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' + |
|
@@ -31,11 +32,15 @@ dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' + |
31
|
'</div>' +
|
32
|
'</div>' +
|
32
|
'</div>';
|
33
|
'</div>';
|
33
|
|
34
|
|
34
|
-dialogTemplate = Handlebars.compile(dialogTpl);
|
35
|
+ dialogTemplate = Handlebars.compile(dialogTpl);
|
|
|
36
|
+ }
|
|
|
37
|
+ return dialogTemplate;
|
|
|
38
|
+}
|
35
|
|
39
|
|
36
|
exports.showDialog = function(data, callback, callbackForLeft) {
|
40
|
exports.showDialog = function(data, callback, callbackForLeft) {
|
37
|
|
41
|
|
38
|
- var dialogStr = dialogTemplate(data),
|
42
|
+ var dialogTemplate = getInstance(),
|
|
|
43
|
+ dialogStr = dialogTemplate(data),
|
39
|
$dialogBox,
|
44
|
$dialogBox,
|
40
|
defaultHideDuraton,
|
45
|
defaultHideDuraton,
|
41
|
dialogWrapperHammer;
|
46
|
dialogWrapperHammer;
|
|
@@ -73,6 +78,11 @@ exports.showDialog = function(data, callback, callbackForLeft) { |
|
@@ -73,6 +78,11 @@ exports.showDialog = function(data, callback, callbackForLeft) { |
73
|
}, defaultHideDuraton);
|
78
|
}, defaultHideDuraton);
|
74
|
}
|
79
|
}
|
75
|
|
80
|
|
|
|
81
|
+ //禁止在dialog上可以上下滚动
|
|
|
82
|
+ $dialogWrapper.on('touchmove', function() {
|
|
|
83
|
+ return false;
|
|
|
84
|
+ });
|
|
|
85
|
+
|
76
|
dialogWrapperHammer.on('tap', function(event) {
|
86
|
dialogWrapperHammer.on('tap', function(event) {
|
77
|
|
87
|
|
78
|
if ($(event.target).hasClass('dialog-left-btn')) {
|
88
|
if ($(event.target).hasClass('dialog-left-btn')) {
|
|
@@ -84,6 +94,7 @@ exports.showDialog = function(data, callback, callbackForLeft) { |
|
@@ -84,6 +94,7 @@ exports.showDialog = function(data, callback, callbackForLeft) { |
84
|
callback();
|
94
|
callback();
|
85
|
}
|
95
|
}
|
86
|
|
96
|
|
|
|
97
|
+ // 防止出现点透问题
|
87
|
event.preventDefault();
|
98
|
event.preventDefault();
|
88
|
event.srcEvent.stopPropagation();
|
99
|
event.srcEvent.stopPropagation();
|
89
|
});
|
100
|
});
|