forked from PaulGuo/In
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
112 lines (84 loc) · 2.38 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
_____
|_ _|
| | _ __
| | | '_ \
_| |_| | | |
|_____|_| |_| v0.12 build 110723
About the author
---------------------
Guokai,1988-08-08
Beijing - Chaoyang
http://benben.cc/
Overview the In.js
-----------------------
Author: Guokai
Email/Gtalk: [email protected]
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>