-
Notifications
You must be signed in to change notification settings - Fork 50
/
README
231 lines (169 loc) · 5.3 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
_____
|_ _|
| | _ __
| | | '_ \
_| |_| | | |
|_____|_| |_| v0.1.8 build 110428120728
About the author
---------------------
Guokai,1988-08-08
Beijing - Chaoyang
[Benben Blog](http://benben.cc/)
Overview the In.js
-----------------------
Author: Guokai
Email/Gtalk: badkaikai@gmail.com
Create Datetime: 2011-04-28
Last Update: 2012-07-28
Namespace: window.In
Description: this a light framework that can manage dependency of the modules,
most important,you can load them on-demand,asynchronous and multi-threaded...
License: Apache License,Version 2.0
Usage:
-----------
In.add('mod1',{path:'url',type:'js',charset:'utf-8',rely:['mod2','mod3']});
In.use('mod1','mod2','mod3',function() {});
In('mod1','mod2','mod3',function() {}); -> short for In.use()
In.ready('mod1','mod2','mod3',function() {});
In.later(3000,'mod1','mod2','mod3',function() {});
In.css(inline-css);
In.config(name,value);
Release:
-------------
Version: 0.2.0
Build: 110428120728
Examples:
--------------
*1、import In.js to your webpage*
例如:底层框架为jQuery 1.5.2-min.js,并引用in时自动加载。
<script type="text/javascript" src="in.js" autoload="true" core="jquery 1.5.2-min.js"></script>
*2、In.add()*
加载三个待执行的javascript模块,分别为mod1、mod2、mod3,其中mod2依赖于mod3.
<script type="text/javascript">
In.add('mod1',{path:'mod1.js',type:'js',charset:'utf-8'});
In.add('mod2',{path:'mod2.js',type:'js',charset:'utf-8',rely:['mod3']});
In.add('mod3',{path:'mod3.js',type:'js',charset:'utf-8'});
</script>
*3、In() or In.use()*
旧版本队列内为顺序加载,如需向后兼容,请事先配置In.config('serial',true)更换为默认串行加载,新版本的队列默认为并行执行,队列中最后一个函数被视为回调函数,下面的代码会并行加载mod1,mod2,function,并立即执行,三者均加载完毕后执行回调函数。
<script type="text/javascript">
//真正的加载顺序为 mod1 || mod2 || function -> function[callback]
var demo=In('mod1','mod2',function() {
console.log('我跟mod1和mod2是并行的关系');
},function() {
console.log('我是回调函数,他们都加载完毕才会触发我');
});
</script>
*4、In.ready()*
domReady之后加载队列
<script type="text/javascript">
In.ready('mod1','mod2',function() {
console.log($);
});
</script>
*5、In.later()*
延迟加载队列
<script type="text/javascript">
//延迟3秒加载队列
In.later(3000,'mod1','mod2',function() {
console.log($);
});
</script>
*6、In.css()*
动态注入CSS
<script type="text/javascript">
In.css('body {background:yellow}');
</script>
*7、In.config()*
配置函数
<script type="text/javascript">
//设置为串行加载模式,兼容旧的写法
In.config('serial',true);
//设置核心库,核心库会被所有模块依赖
In.config('core','jquery 1.5.2-min.js');
</script>
--------------------历史文档--------------------
_____
|_ _|
| | _ __
| | | '_ \
_| |_| | | |
|_____|_| |_| v0.12 build 110723
About the author
---------------------
Guokai,1988-08-08
Beijing - Chaoyang
http://benben.cc/
Overview the In.js
-----------------------
Author: Guokai
Email/Gtalk: badkaikai@gmail.com
Create Datetime: 2011-04-28
Namespace: window.In
Description: this a light framework that can manage dependency of the modules,
most important,you can load them on-demand,asynchronous and multi-threaded...
License: Apache License,Version 2.0
Usage:
-----------
In.add('name',{path:'url here',type:'js',charset:'utf-8',rely:['a','b']});
In.exe('name','a','b',function() {...});
In('name','a','b',function() {...}); -> recommended usage equivalent to In.exe()
In.ready('name','a','b',function() {...});
In.watch(o,'p',function(prop,old,new) {...});
In.unwatch(o,'p');
Release:
-------------
Version: 0.12
Build: 110723
**************************************************************************
使用示例:
--------------
1、import In.js to your webpage
例如:底层框架为jQuery 1.5.2-min.js,并引用in时自动加载。
<script type="text/javascript" src="in.js" autoload="true" core="jquery 1.5.2-min.js"></script>
*2、In.add()*
加载三个待执行的javascript模块,分别为mod1、mod2、mod3,其中mod2依赖于mod3.
<script type="text/javascript">
In.add('mod1',{path:'mod1.js',type:'js',charset:'utf-8'});
In.add('mod2',{path:'mod2.js',type:'js',charset:'utf-8',rely:['mod3']});
In.add('mod3',{path:'mod3.js',type:'js',charset:'utf-8'});
</script>
*3、In() or In.exe()*
顺序执行mod1,mod2,function,立即执行
<script type="text/javascript">
//真正的加载顺序为 mod1 -> mod2 -> mod3 -> function -> function
var demo=In('mod1','mod2',function() {
alert('no return value');
},function() {
alert($);
return 'hello';
});
//demo={returns:[undefined,'hello'],complete:true}
</script>
*4、In.ready()*
domReady之后加载队列
<script type="text/javascript">
In.ready('mod1','mod2',function() {
alert($);
});
</script>
*5、In.watch()*
监视某一变量值
<script type="text/javascript">
var o={p:1};
In.watch(o,'p',function(prop,old,new) {
console.log(prop);
console.log(old);
console.log(new);
});
o.p=2;
-----console-----
>'p'
>1
>2
</script>
*6、In.unwatch()*
取消对某一变量的监视
<script type="text/javascript">
In.watch(o,'p');
</script>