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 initialize 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 |
15 var isLoading = script.length; | |
mazda
2011/11/30 12:05:54
It's better to rename the variable to something th
| |
16 | |
50 (function() { | 17 (function() { |
51 // Switch to 'test harness' mode when loading from a file url. | 18 // Switch to 'test harness' mode when loading from a file url. |
52 var isHarness = document.location.protocol == 'file:'; | 19 var isHarness = document.location.protocol == 'file:'; |
53 | 20 |
54 // In test harness mode we load resources from relative dirs. | 21 // In test harness mode we load resources from relative dirs. |
55 var prefix = isHarness ? './shared/' : 'chrome://resources/'; | 22 var prefix = isHarness ? './shared/' : 'chrome://resources/'; |
56 | 23 |
57 for (var i = 0; i < css.length; ++i) { | 24 // Waits for initialize of task manager. |
mazda
2011/11/30 12:05:54
initialize -> initialization
Please add a comment
yoshiki
2011/12/01 16:18:25
Done.
| |
58 document.write('<link href="' + prefix + 'css/' + css[i] + | 25 var loadDelayedScripts = function() { |
59 '" rel="stylesheet"></link>'); | 26 if (taskmanager !== undefined && taskmanager.initialized_) { |
60 } | 27 for (var i = 0; i < script.length; ++i) { |
61 | 28 var src = prefix + 'js/' + script[i]; |
mazda
2011/11/30 12:05:54
It's better to assign the value directly to s.src
| |
62 for (var i = 0; i < script.length; ++i) { | 29 var s = document.createElement('script'); |
63 document.write('<script src="' + prefix + 'js/' + script[i] + | 30 s.onLoad = function(e) { |
64 '"><\/script>'); | 31 isLoading--; if(isLoading == 0) taskmanager.delayedInitialize(); |
mazda
2011/11/30 12:05:54
Please add line breaks.
Also need a space after 'i
| |
65 } | 32 console.log("aaa" + e.target.src); |
mazda
2011/11/30 12:05:54
Remove this.
| |
33 }; | |
34 s.type = 'text/javascript'; | |
35 s.src = src; | |
36 s.defer = 'defer'; | |
37 document.body.appendChild(s); | |
38 console.log("hogehoge" + src); | |
mazda
2011/11/30 12:05:54
Remove this.
| |
39 } | |
40 } else { | |
41 window.setTimeout(loadDelayedScripts, 100); | |
mazda
2011/11/30 12:05:54
Please make a constant variable for 100.
| |
42 } | |
43 }; | |
44 window.setTimeout(loadDelayedScripts, 100); | |
mazda
2011/11/30 12:05:54
Ditto.
| |
66 })(); | 45 })(); |
OLD | NEW |