-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
111 lines (99 loc) · 3.6 KB
/
index.html
File metadata and controls
111 lines (99 loc) · 3.6 KB
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
<!DOCTYPE HTML>
<html>
<head>
<title>jQuery.requireModule</title>
<style>
/******************************************
* Extra stuff used just in this demo page
******************************************/
body {
margin: 50px auto;
width : 720px;
}
.require-test, .dependency-test {
font-size: 12px;
color: red;
}
</style>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="src/jQuery.requireModule.js"></script>
<script src="src/jQuery.registerModule.js"></script>
</head>
<body>
<h1>jQuery.requireModule()</h1>
<h5>Simple Test</h5>
<div>
<div class="require-test"></div>
<button onclick="loadModule(['script1','script1','script2'], '.require-test')">loadModule(['script1','script1','script2'])</button>
<pre>
function loadModule(name) {
jQuery.requireModule(name)
.done(function(){
$(arguments).each(function() {
$(ele).append("<div>" + this + " loaded</div>");
});
})
.fail(function() {
$(arguments).each(function() {
$(ele).append("<div>" + this + " failed</div>");
});
});
}
</pre>
</div>
<h5>Test with module/dependency loading</h5>
<div>
<div class="dependency-test"></div>
<button onclick="loadModule('my.module', '.dependency-test')">loadModule('my.module', '.dependency-test')</button><br />
<button onclick="runModule('.dependency-test')">runModule('.dependency-test')</button>
<br /><br />
<button onclick="loadModule('your.module', '.dependency-test')">loadModule('your.module', '.dependency-test')</button><br />
<button onclick="runModule('.dependency-test')">runModule('.dependency-test')</button>
<pre>
function loadModule(name, ele) {
jQuery.requireModule(name)
.done(function(){
$(arguments).each(function() {
$(ele).append("<div>" + this + " loaded</div>");
});
})
.fail(function() {
$(arguments).each(function() {
$(ele).append("<div>" + this + " failed</div>");
});
});
}
function runModule(ele) {
try {
$(ele).append("<div>" + myNameSpace.test.utilities.doStuff() + "</div>");
} catch (e) {
$(ele).append("<div>" + e + "</div>");
}
}
</pre>
</div>
<a href="https://github.com/itechnology/requireModule">Source on Github</a>
<script>
function loadModule(name, ele) {
jQuery.requireModule(name)
.done(function(){
$(arguments).each(function() {
$(ele).append("<div>" + this + " loaded</div>");
});
})
.fail(function() {
$(arguments).each(function() {
$(ele).append("<div>" + this + " failed</div>");
});
});
}
function runModule(ele) {
try {
$(ele).append("<div>" + myNameSpace.test.utilities.doStuff() + "</div>");
} catch (e) {
$(ele).append("<div>" + e + "</div>");
}
}
</script>
</body>
</html>