Skip to content

Commit ecd8cec

Browse files
committed
js 命名空间管理
1 parent 213930a commit ecd8cec

File tree

8 files changed

+88
-2
lines changed

8 files changed

+88
-2
lines changed

JsNameSpaceManage/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### JavaScript 命名空间管理 Demo
2+
3+
----

JsNameSpaceManage/demo/js/comfirm.js

Whitespace-only changes.

JsNameSpaceManage/demo/js/dir1/dir2/alert.js

Whitespace-only changes.

JsNameSpaceManage/demo/js/dir1/dir2/alert2.js

Whitespace-only changes.

JsNameSpaceManage/demo/test.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html >
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>测试</title>
6+
</head>
7+
<body>
8+
<script src="js/comfirm.js"></script>
9+
<script src="../js/manage.js"></script>
10+
</body>
11+
</html>

JsNameSpaceManage/js/manage.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
var Manage = (function() {
2+
var that = {};
3+
var errorList = [];
4+
var ns='data1.data2.data3'
5+
6+
that.register = function(ns, maker) {
7+
var NSList = ns.split('.');
8+
var step = that;
9+
var k = null;
10+
while (k = NSList.shift()) {
11+
if (NSList.length) {
12+
if (step[k] === undefined) {
13+
step[k] = {};
14+
}
15+
step = step[k];
16+
} else {
17+
console.log(that);
18+
if (step[k] === undefined) {
19+
try {
20+
step[k] = maker(that);
21+
} catch (exp) {
22+
errorList.push(exp);
23+
}
24+
}
25+
}
26+
}
27+
};
28+
that.register(ns);
29+
// return that;
30+
})();

JsNameSpaceManage/js/other.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
STK.register('ui.alert', function($){
2+
var TPL = '<div node-type="outer" class="tip_layer wrap_style1">'
3+
+ '<div class="tip_layer_tit" node-type="title"><%=title%></div>'
4+
+ '<div node-type="inner">'
5+
+ '<div class="tip_layer_cont">'
6+
+ '<p class="tip_layer_txt"><%=content%></p>'
7+
+ '</div>'
8+
+ '<div class="tip_layer_btn"><a href="javascript:void(0)" action-type="ok" class="btn_style1"><%=okTxt%></a></div>'
9+
+ '</div>'
10+
+ '</div>';
11+
var $T = $.template;
12+
return function(content, conf){
13+
conf = $.parseParam({
14+
ok : function(){},
15+
title : '提示',
16+
content : content || '',
17+
okTxt : '确定'
18+
}, conf);
19+
var render = $T.compile(TPL);
20+
var html = render(conf);
21+
var that = $.ui.dialog(html);
22+
that.show().setMiddle();
23+
var inner = that.getInner();
24+
var outer = that.getOuter();
25+
//阻止滚动
26+
outer.addEventListener('touchmove', function(evt){
27+
evt.preventDefault();
28+
}, false);
29+
var dEvt = $.delegatedEvent(inner);
30+
dEvt.add('ok', 'tap', function(){
31+
conf.ok();
32+
setTimeout(function(){
33+
that.hide();
34+
},500)
35+
});
36+
// setTimeout(function(){
37+
// conf.ok();
38+
// that.hide();
39+
// },2000)
40+
return that;
41+
}
42+
});

dragselect/css/paymode.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ body {
2020
position: relative;
2121
}
2222
.content {
23-
width: 320px;
23+
width: 100%;
2424
z-index: 1000;
2525
background-color:#fff;
2626
position:relative;
@@ -61,7 +61,7 @@ body {
6161
display: block;
6262
border-top: 1px solid #c7c7cc;
6363
}
64-
.paymode-list.move-currdom {
64+
.paymode-list .move-currdom {
6565
border-top: 1px solid #e6e6e6;
6666
background-color: #fff;
6767
width: 100%;

0 commit comments

Comments
 (0)