OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This script includes additional resources via document.write(). Hence, it | 5 // This script loads additional scripts after initialization of task manager. |
6 // must be a separate script file loaded before other scripts which would | |
7 // reference the resources. | |
8 | |
9 var css = [ | |
10 'chrome_shared.css', | |
11 'list.css', | |
12 'table.css', | |
13 'menu.css', | |
14 'button.css', | |
15 ]; | |
16 | 6 |
17 var script = [ | 7 var script = [ |
18 'local_strings.js', | |
19 'i18n_template.js', | |
20 | |
21 'util.js', | |
22 'cr.js', | |
23 'cr/ui.js', | |
24 'cr/event_target.js', | |
25 'cr/ui/array_data_model.js', | |
26 'cr/ui/list_item.js', | |
27 'cr/ui/list_selection_model.js', | |
28 'cr/ui/list_single_selection_model.js', | |
29 'cr/ui/list_selection_controller.js', | |
30 'cr/ui/list.js', | |
31 | |
32 'cr/ui/splitter.js', | |
33 'cr/ui/table/table_splitter.js', | |
34 | |
35 'cr/ui/table/table_column.js', | |
36 'cr/ui/table/table_column_model.js', | |
37 'cr/ui/table/table_header.js', | |
38 'cr/ui/table/table_list.js', | |
39 'cr/ui/table.js', | |
40 | |
41 'cr/ui/grid.js', | |
42 | |
43 'cr/ui/command.js', | 8 'cr/ui/command.js', |
44 'cr/ui/position_util.js', | 9 'cr/ui/position_util.js', |
45 'cr/ui/menu_item.js', | 10 'cr/ui/menu_item.js', |
46 'cr/ui/menu.js', | 11 'cr/ui/menu.js', |
47 'cr/ui/context_menu_handler.js', | 12 'cr/ui/context_menu_handler.js', |
48 ]; | 13 ]; |
49 | 14 |
50 (function() { | 15 /** |
| 16 * Loads delayed scripts. |
| 17 * This function is called by TaskManager::initalize() in main.js. |
| 18 */ |
| 19 function loadDelayedIncludes(taskmanager) { |
51 // Switch to 'test harness' mode when loading from a file url. | 20 // Switch to 'test harness' mode when loading from a file url. |
52 var isHarness = document.location.protocol == 'file:'; | 21 var isHarness = document.location.protocol == 'file:'; |
53 | 22 |
54 // In test harness mode we load resources from relative dirs. | 23 // In test harness mode we load resources from relative dirs. |
55 var prefix = isHarness ? './shared/' : 'chrome://resources/'; | 24 var prefix = isHarness ? './shared/' : 'chrome://resources/'; |
56 | 25 |
57 for (var i = 0; i < css.length; ++i) { | 26 // Number of remaining scripts to load. |
58 document.write('<link href="' + prefix + 'css/' + css[i] + | 27 var remain = script.length; |
59 '" rel="stylesheet"></link>'); | 28 |
| 29 // Waits for initialization of task manager. |
| 30 for (var i = 0; i < script.length; ++i) { |
| 31 var s = document.createElement('script'); |
| 32 s.onload = function(e) { |
| 33 if (!--remain) |
| 34 taskmanager.delayedInitialize(); |
| 35 }; |
| 36 s.type = 'text/javascript'; |
| 37 s.src = prefix + 'js/' + script[i]; |
| 38 s.defer = 'defer'; |
| 39 document.body.appendChild(s); |
60 } | 40 } |
61 | 41 } |
62 for (var i = 0; i < script.length; ++i) { | |
63 document.write('<script src="' + prefix + 'js/' + script[i] + | |
64 '"><\/script>'); | |
65 } | |
66 })(); | |
OLD | NEW |