3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.Loader"></div>/**
18 * Simple class to help load JavaScript files on demand
20 Ext.Loader = Ext.apply({}, {
21 <div id="method-Ext.Loader-load"></div>/**
22 * Loads a given set of .js files. Calls the callback function when all files have been loaded
23 * Set preserveOrder to true to ensure non-parallel loading of files if load order is important
24 * @param {Array} fileList Array of all files to load
25 * @param {Function} callback Callback to call after all files have been loaded
26 * @param {Object} scope The scope to call the callback in
27 * @param {Boolean} preserveOrder True to make files load in serial, one after the other (defaults to false)
29 load: function(fileList, callback, scope, preserveOrder) {
30 var scope = scope || this,
31 head = document.getElementsByTagName("head")[0],
32 fragment = document.createDocumentFragment(),
33 numFiles = fileList.length,
37 <div id="prop-Ext.Loader-var"></div>/**
38 * Loads a particular file from the fileList by index. This is used when preserving order
40 var loadFileIndex = function(index) {
42 me.buildScriptTag(fileList[index], onFileLoaded)
46 <div id="prop-Ext.Loader-var"></div>/**
47 * Callback function which is called after each file has been loaded. This calls the callback
48 * passed to load once the final file in the fileList has been loaded
50 var onFileLoaded = function() {
53 //if this was the last file, call the callback, otherwise load the next file
54 if (numFiles == loadedFiles && typeof callback == 'function') {
57 if (preserveOrder === true) {
58 loadFileIndex(loadedFiles);
63 if (preserveOrder === true) {
64 loadFileIndex.call(this, 0);
66 //load each file (most browsers will do this in parallel)
67 Ext.each(fileList, function(file, index) {
69 this.buildScriptTag(file, onFileLoaded)
73 head.appendChild(fragment);
79 * Creates and returns a script tag, but does not place it into the document. If a callback function
80 * is passed, this is called when the script has been loaded
81 * @param {String} filename The name of the file to create a script tag for
82 * @param {Function} callback Optional callback, which is called when the script has been loaded
83 * @return {Element} The new script ta
85 buildScriptTag: function(filename, callback) {
86 var script = document.createElement('script');
87 script.type = "text/javascript";
88 script.src = filename;
90 //IE has a different way of handling <script> loads, so we need to check for it here
91 if (script.readyState) {
92 script.onreadystatechange = function() {
93 if (script.readyState == "loaded" || script.readyState == "complete") {
94 script.onreadystatechange = null;
99 script.onload = callback;