Skip to content
This repository was archived by the owner on Dec 8, 2019. It is now read-only.

Commit 44944eb

Browse files
author
Ashwin Hegde
committed
Merge pull request #16 from hegdeashwin/develop
Develop
2 parents 07e4204 + 8cab7a4 commit 44944eb

15 files changed

Lines changed: 138 additions & 36 deletions

File tree

kit/example-2/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ <h1>JavaScript Module Loading using Require.js</h1>
1212
<p class="lead">How to run this example.</p>
1313

1414
<ol>
15-
<li>Open Example-1.html in browser using any HTTP-SERVER.</li>
15+
<li>Open Example-2.html in browser using any HTTP-SERVER.</li>
1616
<li>Press F12, go to console tab.</li>
1717
<li>See the message get displayed on that console tab.</li>
1818
</ol>
1919

20-
<script type="text/javascript" src="app/module1.js"></script>
21-
<script type="text/javascript" src="app/module2.js"></script>
20+
<script type="text/javascript" src="app/module1.js" async="true"></script>
21+
<script type="text/javascript" src="app/module2.js" async="true"></script>
2222
<script type="text/javascript" src="app/print.js"></script>
2323
<script type="text/javascript" src="app/init.js"></script>
2424
</body>

kit/example-3/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ <h1>JavaScript Module Loading using Require.js</h1>
1717
<li>See the message get displayed on that console tab.</li>
1818
</ol>
1919

20+
<!--
21+
Specifing single entry point to our application;
22+
Loading require.js as the first script dependency file with configration options set in main
23+
for other files dependency loading and application execution.
24+
-->
2025
<script type="text/javascript" src="libs/require.js" data-main="main"></script>
2126
</body>
2227
</html>

kit/example-3/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/**
22
* require is global now, thus can be accessed by window.require;
33
* Require.js config API, takes require.js configuration object.
4+
*
5+
* @config-options:
6+
-> paths: Specify the path for js files; It is relative to the baseUrl;
7+
if baseUrl is not provided then by default baseUrl path will become the path where the require.js main file reference.
48
*/
59
requirejs.config({
610
paths: {

kit/example-4/main.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* require is global now, thus can be accessed by window.require;
3+
* Require.js config API, takes require.js configuration object.
4+
*
5+
* @config-options:
6+
-> baseUrl: Specify the baseUrl Url, As baseUrl is specify the path for js files will change and will be relative to this baseUrl;
7+
*/
18
requirejs.config({
29
baseUrl: "libs",
310

@@ -7,6 +14,9 @@ requirejs.config({
714
}
815
});
916

17+
/**
18+
* Require.js onError method to handle Async timeout error.
19+
*/
1020
requirejs.onError = function(err) {
1121
if (err.requireType === 'timeout') {
1222
alert("error: " + err);

kit/example-5/main.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* require is global now, thus can be accessed by window.require;
3+
* Require.js config API, takes require.js configuration object.
4+
*
5+
* @config-options:
6+
-> shim (deps): Help to manage dependencies loading
7+
*/
18
requirejs.config({
29
baseUrl: "libs",
310

@@ -14,12 +21,15 @@ requirejs.config({
1421
}
1522
});
1623

24+
/**
25+
* Require.js onError method to handle Async timeout error.
26+
*/
1727
requirejs.onError = function(err) {
18-
if (err.requireType === 'timeout') {
19-
alert("error: " + err);
20-
} else {
21-
throw err;
22-
}
28+
if (err.requireType === 'timeout') {
29+
alert("error: " + err);
30+
} else {
31+
throw err;
32+
}
2333
};
2434

2535
require(['app/init']);

kit/example-6/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h1>JavaScript Module Loading using Require.js</h1>
1212
<p class="lead">How to run this example.</p>
1313

1414
<ol>
15-
<li>Open Example-5.html in browser using any HTTP-SERVER.</li>
15+
<li>Open Example-6.html in browser using any HTTP-SERVER.</li>
1616
<li>Press F12, go to console tab.</li>
1717
<li>See the message get displayed on that console tab.</li>
1818
</ol>

kit/example-6/main.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* require is global now, thus can be accessed by window.require;
3+
* Require.js config API, takes require.js configuration object.
4+
*
5+
* @config-options:
6+
-> shim (exports): Help to check it the provided library is AMD supported.
7+
*/
18
requirejs.config({
29
baseUrl: "libs",
310

@@ -13,12 +20,15 @@ requirejs.config({
1320
}
1421
});
1522

23+
/**
24+
* Require.js onError method to handle Async timeout error.
25+
*/
1626
requirejs.onError = function(err) {
17-
if (err.requireType === 'timeout') {
18-
alert("error: " + err);
19-
} else {
20-
throw err;
21-
}
27+
if (err.requireType === 'timeout') {
28+
alert("error: " + err);
29+
} else {
30+
throw err;
31+
}
2232
};
2333

2434
require(['app/init']);

kit/example-7/app/init.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
/**
2+
* The goal of this file is to provide the basic understanding:
3+
* -> How to global object store
4+
*
5+
* How to run this example.
6+
* 1. Open Example-7.html in browser.
7+
* 2. Press F12, go to console tab.
8+
* 3. See the message get displayed on that console tab.
9+
*/
10+
111
define(["config"], function(config) {
212

313
"use strict";
414

515
var url = config.url;
6-
7-
console.log(url);
8-
16+
console.log("Global Url: ", url);
917

1018
});

kit/example-7/config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @module: Global object; use to store global application setting.
3+
*/
4+
15
define([], function() {
26

37
"use strict";
@@ -6,5 +10,4 @@ define([], function() {
610
url: "http://www.google.com"
711
};
812

9-
1013
});

kit/example-7/index.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
<!doctype html>
22
<html>
33
<head>
4-
<title>Example 6</title>
4+
<meta charset="utf-8">
5+
<title>Example 7</title>
6+
<link rel="stylesheet" type="text/css" href="../styles.css">
57
</head>
68
<body>
79

8-
<h1>Require.js Integration.</h1>
10+
<h1>JavaScript Module Loading using Require.js</h1>
11+
12+
<p class="lead">How to run this example.</p>
13+
14+
<ol>
15+
<li>Open Example-7.html in browser using any HTTP-SERVER.</li>
16+
<li>Press F12, go to console tab.</li>
17+
<li>See the message get displayed on that console tab.</li>
18+
</ol>
19+
920
<script src="libs/require.js" data-main="main"></script>
1021
</body>
1122
</html>

0 commit comments

Comments
 (0)