-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.html
68 lines (62 loc) · 3.03 KB
/
index.html
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Amd plugin demo</title>
<!--
@require "/modules/libs/jquery-ui/themes/base/core.css"
@require "/modules/libs/jquery-ui/themes/base/tabs.css"
@require "/modules/libs/jquery-ui/themes/base/datepicker.css"
@require "/modules/libs/jquery-ui/themes/base/theme.css"
-->
<style type="text/css">
.invisible {
display: none;
}
</style>
<!--STYLE_PLACEHOLDER-->
</head>
<body>
<link rel="import" href="partials/_nav.html?__inline">
<h1>jQuery UI+AMD Sample Page</h1>
<!-- Tabs are initially invisible, until the jQuery UI widget
instantiates itself. -->
<div id="tabs" class="invisible">
<ul>
<li><a href="#tabs1">Intro</a></li>
<li><a href="tab2.html">Date Picker</a></li>
</ul>
<div id="tabs1">
<p>This is an example of using the <a href="http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition" target="_blank">AMD API proposal</a> for formatting jQuery UI files as modules that express their dependencies.</p>
<p>This approach can be useful if you use an AMD-based loader like <a href="http://requirejs.org" target="_blank">RequireJS</a>, and you want to use different parts of jQuery UI on different pages or dynamically load parts of jQuery UI as part of the response to user actions.</p>
<p>This example dynamically loads the Datepicker jQuery UI widget with its French localization when the <b>Date Picker</b> tab is clicked.</p>
<p>This example also includes <a href="scripts/app.build.js" target="_blank">a RequireJS optimizer build profile</a> to automatically combine jQuery UI scripts used in this page into one script to fetch. The Datepicker and its French localization is still loaded on demand after running the optimizer.</p>
<p>See the <a href="scripts/main.js" target="_blank">main.js</a> file to see the app setup.</p>
</div>
</div>
<script type="text/javascript" src="lib/require.js"></script>
<!--SCRIPT_PLACEHOLDER-->
<!--RESOURCEMAP_PLACEHOLDER-->
<script type="text/javascript">
require(['jquery', 'jqueryui/tabs'], function ($) {
// 创建 tabs
$('#tabs')
.tabs({
load: function (event, ui) {
// 当第二个 tab 加载完成后,动态初始化日历控件
if (ui.tab.index() === 1) {
// 通过注释关键字显式的指定异步加载 `fis async`
require(['jqueryui/datepicker', 'jqueryui/i18n/datepicker-zh-CN'],
function () {
$('#datepicker').datepicker();
}
);
}
}
})
// Make the tabs visible now that the widget has been instantiated.
.removeClass('invisible');
});
</script>
</body>
</html>