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 loads additional scripts after initialization of task manager. | 5 // This script includes additional resources via document.write(). Hence, it |
| 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 ]; |
6 | 16 |
7 var script = [ | 17 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 |
8 'cr/ui/command.js', | 43 'cr/ui/command.js', |
9 'cr/ui/position_util.js', | 44 'cr/ui/position_util.js', |
10 'cr/ui/menu_item.js', | 45 'cr/ui/menu_item.js', |
11 'cr/ui/menu.js', | 46 'cr/ui/menu.js', |
12 'cr/ui/context_menu_handler.js', | 47 'cr/ui/context_menu_handler.js', |
13 ]; | 48 ]; |
14 | 49 |
15 /** | 50 (function() { |
16 * Loads delayed scripts. | |
17 * This function is called by TaskManager::initalize() in main.js. | |
18 */ | |
19 function loadDelayedIncludes(taskmanager) { | |
20 // Switch to 'test harness' mode when loading from a file url. | 51 // Switch to 'test harness' mode when loading from a file url. |
21 var isHarness = document.location.protocol == 'file:'; | 52 var isHarness = document.location.protocol == 'file:'; |
22 | 53 |
23 // In test harness mode we load resources from relative dirs. | 54 // In test harness mode we load resources from relative dirs. |
24 var prefix = isHarness ? './shared/' : 'chrome://resources/'; | 55 var prefix = isHarness ? './shared/' : 'chrome://resources/'; |
25 | 56 |
26 // Number of remaining scripts to load. | 57 for (var i = 0; i < css.length; ++i) { |
27 var remain = script.length; | 58 document.write('<link href="' + prefix + 'css/' + css[i] + |
| 59 '" rel="stylesheet"></link>'); |
| 60 } |
28 | 61 |
29 // Waits for initialization of task manager. | |
30 for (var i = 0; i < script.length; ++i) { | 62 for (var i = 0; i < script.length; ++i) { |
31 var s = document.createElement('script'); | 63 document.write('<script src="' + prefix + 'js/' + script[i] + |
32 s.onload = function(e) { | 64 '"><\/script>'); |
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); | |
40 } | 65 } |
41 } | 66 })(); |
OLD | NEW |