1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 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 9var css = [ 10 'chrome_shared.css', 11 'list.css', 12 'table.css', 13 'menu.css', 14]; 15 16var script = [ 17 'load_time_data.js', 18 'i18n_template_no_process.js', 19 20 'event_tracker.js', 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 'cr/ui/touch_handler.js', 35 36 'cr/ui/table/table_column.js', 37 'cr/ui/table/table_column_model.js', 38 'cr/ui/table/table_header.js', 39 'cr/ui/table/table_list.js', 40 'cr/ui/table.js', 41 42 'cr/ui/grid.js', 43]; 44 45var scriptDelayed = [ 46 'cr/ui/command.js', 47 'cr/ui/position_util.js', 48 'cr/ui/menu_item.js', 49 'cr/ui/menu.js', 50 'cr/ui/context_menu_handler.js', 51]; 52 53var loadDelayedIncludes; 54 55(function() { 56 // Switch to 'test harness' mode when loading from a file url. 57 var isHarness = document.location.protocol == 'file:'; 58 59 // In test harness mode we load resources from relative dirs. 60 var prefix = isHarness ? './shared/' : 'chrome://resources/'; 61 62 for (var i = 0; i < css.length; i++) { 63 document.write('<link href="' + prefix + 'css/' + css[i] + 64 '" rel="stylesheet"></link>'); 65 } 66 67 for (var i = 0; i < script.length; i++) { 68 document.write('<script src="' + prefix + 'js/' + script[i] + 69 '"><\/script>'); 70 } 71 72 /** 73 * Loads delayed scripts. 74 * This function is called by TaskManager::initalize() in main.js. 75 */ 76 loadDelayedIncludes = function(taskmanager) { 77 // Number of remaining scripts to load. 78 var remain = scriptDelayed.length; 79 80 // Waits for initialization of task manager. 81 for (var i = 0; i < scriptDelayed.length; i++) { 82 var s = document.createElement('script'); 83 s.onload = function(e) { 84 if (!--remain) 85 taskmanager.delayedInitialize(); 86 }; 87 s.src = prefix + 'js/' + scriptDelayed[i]; 88 document.head.appendChild(s); 89 } 90 }; 91})(); 92