OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
6 * @fileoverview Deferred resource loader for OOBE/Login screens. | 6 * @fileoverview Deferred resource loader for OOBE/Login screens. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('cr.ui.login.ResourceLoader', function() { | 9 cr.define('cr.ui.login.ResourceLoader', function() { |
10 'use strict'; | 10 'use strict'; |
11 | 11 |
12 // Deferred assets. | 12 // Deferred assets. |
13 var ASSETS = {}; | 13 var ASSETS = {}; |
14 | 14 |
15 /** | 15 /** |
16 * Register assets for deferred loading. When the bundle is loaded | 16 * Register assets for deferred loading. When the bundle is loaded |
17 * assets will be added to the current page's DOM: <link> and <script> | 17 * assets will be added to the current page's DOM: <link> and <script> |
18 * tags pointing to the CSS and JavaScript will be added to the | 18 * tags pointing to the CSS and JavaScript will be added to the |
19 * <head>, and HTML will be appended to a specified element. | 19 * <head>, and HTML will be appended to a specified element. |
20 * | 20 * |
21 * @param {Object} desc Descriptor for the asset bundle | 21 * @param {Object} desc Descriptor for the asset bundle |
22 * @param {string} desc.id Unique identifier for the asset bundle. | 22 * @param {string} desc.id Unique identifier for the asset bundle. |
23 * @param {Array=} desc.js URLs containing JavaScript sources. | 23 * @param {Array=} desc.js URLs containing JavaScript sources. |
24 * @param {Array=} desc.css URLs containing CSS rules. | 24 * @param {Array=} desc.css URLs containing CSS rules. |
25 * @param {Array.<Object>=} desc.html Descriptors for HTML fragments, | 25 * @param {Array<Object>=} desc.html Descriptors for HTML fragments, |
26 * each of which has a 'url' property and a 'targetID' property that | 26 * each of which has a 'url' property and a 'targetID' property that |
27 * specifies the node under which the HTML should be appended. | 27 * specifies the node under which the HTML should be appended. |
28 * | 28 * |
29 * Example: | 29 * Example: |
30 * ResourceLoader.registerAssets({ | 30 * ResourceLoader.registerAssets({ |
31 * id: 'bundle123', | 31 * id: 'bundle123', |
32 * js: ['//foo.com/src.js', '//bar.com/lib.js'], | 32 * js: ['//foo.com/src.js', '//bar.com/lib.js'], |
33 * css: ['//foo.com/style.css'], | 33 * css: ['//foo.com/style.css'], |
34 * html: [{ url: '//foo.com/tmpls.html' targetID: 'tmpls'}] | 34 * html: [{ url: '//foo.com/tmpls.html' targetID: 'tmpls'}] |
35 * }); | 35 * }); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 return { | 184 return { |
185 alreadyLoadedAssets: alreadyLoadedAssets, | 185 alreadyLoadedAssets: alreadyLoadedAssets, |
186 hasDeferredAssets: hasDeferredAssets, | 186 hasDeferredAssets: hasDeferredAssets, |
187 loadAssets: loadAssets, | 187 loadAssets: loadAssets, |
188 registerAssets: registerAssets | 188 registerAssets: registerAssets |
189 }; | 189 }; |
190 }); | 190 }); |
OLD | NEW |