[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 /* 2 YUI 3.17.2 (build 9c3c78e) 3 Copyright 2014 Yahoo! Inc. All rights reserved. 4 Licensed under the BSD License. 5 http://yuilibrary.com/license/ 6 */ 7 8 YUI.add('loader-rollup', function (Y, NAME) { 9 10 /** 11 * Optional automatic rollup logic for reducing http connections 12 * when not using a combo service. 13 * @module loader 14 * @submodule rollup 15 */ 16 17 /** 18 * Look for rollup packages to determine if all of the modules a 19 * rollup supersedes are required. If so, include the rollup to 20 * help reduce the total number of connections required. Called 21 * by calculate(). This is an optional feature, and requires the 22 * appropriate submodule to function. 23 * @method _rollup 24 * @for Loader 25 * @private 26 */ 27 Y.Loader.prototype._rollup = function() { 28 var i, j, m, s, r = this.required, roll, 29 info = this.moduleInfo, rolled, c, smod; 30 31 // find and cache rollup modules 32 if (this.dirty || !this.rollups) { 33 this.rollups = {}; 34 for (i in info) { 35 if (info.hasOwnProperty(i)) { 36 m = this.getModule(i); 37 // if (m && m.rollup && m.supersedes) { 38 if (m && m.rollup) { 39 this.rollups[i] = m; 40 } 41 } 42 } 43 } 44 45 // make as many passes as needed to pick up rollup rollups 46 for (;;) { 47 rolled = false; 48 49 // go through the rollup candidates 50 for (i in this.rollups) { 51 if (this.rollups.hasOwnProperty(i)) { 52 // there can be only one, unless forced 53 if (!r[i] && ((!this.loaded[i]) || this.forceMap[i])) { 54 m = this.getModule(i); 55 s = m.supersedes || []; 56 roll = false; 57 58 // @TODO remove continue 59 if (!m.rollup) { 60 continue; 61 } 62 63 c = 0; 64 65 // check the threshold 66 for (j = 0; j < s.length; j++) { 67 smod = info[s[j]]; 68 69 // if the superseded module is loaded, we can't 70 // load the rollup unless it has been forced. 71 if (this.loaded[s[j]] && !this.forceMap[s[j]]) { 72 roll = false; 73 break; 74 // increment the counter if this module is required. 75 // if we are beyond the rollup threshold, we will 76 // use the rollup module 77 } else if (r[s[j]] && m.type === smod.type) { 78 c++; 79 // Y.log("adding to thresh: " + c + ", " + s[j]); 80 roll = (c >= m.rollup); 81 if (roll) { 82 // Y.log("over thresh " + c + ", " + s[j]); 83 break; 84 } 85 } 86 } 87 88 if (roll) { 89 // Y.log("adding rollup: " + i); 90 // add the rollup 91 r[i] = true; 92 rolled = true; 93 94 // expand the rollup's dependencies 95 this.getRequires(m); 96 } 97 } 98 } 99 } 100 101 // if we made it here w/o rolling up something, we are done 102 if (!rolled) { 103 break; 104 } 105 } 106 }; 107 108 109 }, '3.17.2', {"requires": ["loader-base"]});
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |