Skip to content

Commit 7992b13

Browse files
committed
自定义控件流程
1 parent 946da9e commit 7992b13

25 files changed

Lines changed: 1603 additions & 33 deletions

app/html/index.html

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,71 @@
22
<head>
33
<meta charset="utf-8">
44
<link href="../css/index.css" type="text/css" rel="stylesheet">
5-
<script src="../js/g/g.js"></script>
5+
<style type="text/css">
6+
.ui-hover-list{
7+
display: none;
8+
}
9+
.active .ui-hover-list{
10+
display: block
11+
}
12+
</style>
613
<script>
7-
G.config('baseUrl', 'http://localhost:63342/BHWebTest/');
8-
G.config('alias',{
9-
'ModuleC':'app/js/g/ModuleC.js',
10-
'$':"app/js//zepto/zepto.cmb.js"
11-
});
12-
!function(){
13-
G.use(['app/js/g/ModuleA.js','app/js/g/ModuleB.js','ModuleC'],function(A,B,C){
14-
A.alertA();
15-
B.alertB();
16-
alert(C.C);
14+
var head = document.head ||
15+
document.getElementsByTagName( 'head' )[0] ||
16+
document.documentElement;
17+
18+
var script = document.createElement( 'SCRIPT' );
19+
var done = false;
20+
script.setAttribute( 'type', "text/javascript" );
21+
script.setAttribute( 'charset', 'utf-8' );
22+
script.setAttribute( 'src', '../js/g/g.js' );
23+
script.setAttribute( 'async', true );
24+
script.onload = script.onreadystatechange = function(){
25+
if ( !done &&( !this.readyState || this.readyState === "loaded" ||this.readyState === "complete" ) ){
26+
done = true;
27+
script.onload = script.onreadystatechange = null;
28+
}
29+
G.config('baseUrl', 'http://localhost:63342/BHWebTest/');
30+
G.config('alias',{
31+
'ModuleC':'app/js/g/ModuleC.js',
32+
"_":"app/js/_/underscore.js",
33+
'$':"app/js/zepto/zepto.cmb.js"
1734
});
18-
}();
35+
!function(){
36+
G.use(['app/js/g/ModuleA.js','app/js/g/ModuleB.js','ModuleC'],function(A,B,C){
37+
console.log(A,B,C);
38+
});
39+
G.use(['app/js/widgets/widget.js','$'],function(w,$){
40+
w.initWidgets();
41+
});
42+
G.use(['$'],function($){
43+
var aa = {
44+
'aaa':function(q){
45+
alert("q:"+q);
46+
}
47+
}
48+
// var a = $.Deferred();
49+
// a.resolve(new aa.aaa("hello"));
50+
aa.aaa("123");
51+
});
52+
}();
53+
}
54+
55+
56+
head.appendChild( script );
1957
</script>
2058
</head>
2159

60+
<body>
61+
<div data-widget="app/js/widgets/WidgetTest.js#hoverWidget">
62+
<span>当前的标题</span>
63+
<ul class="ui-hover-list">
64+
<li>标题1</li>
65+
<li>标题2</li>
66+
<li>标题3</li>
67+
</ul>
68+
</div>
69+
</body>
2270
<!--<title>BHWebTest</title>-->
2371

2472
<!--<body>-->

0 commit comments

Comments
 (0)