130
130
CSSBASE = 'cssbase',
131
131
CSS_AFTER = [CSSRESET, CSSFONTS, CSSGRIDS, 'cssreset-context', 'cssfonts-context', 'cssgrids-context'],
132
132
YUI_CSS = ['reset', 'fonts', 'grids', 'base'],
133
VERSION = '3.0.0pr1',
133
VERSION = '3.0.0pr2',
134
134
ROOT = VERSION + '/build/',
135
135
CONTEXT = '-context',
333
requires: ['node', 'classnamemanager'],
290
338
requires: ['yui-base']
342
requires: ['widget', 'widget-position', 'widget-position-ext', 'widget-stack', 'widget-stdmod'],
357
requires: ['widget', 'dd-constrain'],
296
364
optional: ['dump']
368
requires: ['base', 'node', 'classnamemanager'],
370
'widget-position': { },
371
'widget-position-ext': {
372
requires: ['widget-position']
299
382
// Since YUI is required for everything else, it should not be specified as
302
385
supersedes: ['yui-base', 'get', 'loader']
391
requires: ['substitute', 'node', 'json']
539
627
// this.moduleInfo = Y.merge(Y.Env.meta.moduleInfo);
540
628
this.moduleInfo = {};
631
* Provides the information used to skin the skinnable components.
632
* The following skin definition would result in 'skin1' and 'skin2'
633
* being loaded for calendar (if calendar was requested), and
634
* 'sam' for all other skinnable components:
639
* // The default skin, which is automatically applied if not
640
* // overriden by a component-specific skin definition.
641
* // Change this in to apply a different skin globally
642
* defaultSkin: 'sam',
644
* // This is combined with the loader base property to get
645
* // the default root directory for a skin. ex:
646
* // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/
647
* base: 'assets/skins/',
649
* // The name of the rollup css file for the skin
652
* // The number of skinnable components requested that are
653
* // required before using the rollup file rather than the
654
* // individual component css files
657
* // Any component-specific overrides can be specified here,
658
* // making it possible to load different skins for different
659
* // components. It is possible to load more than one skin
660
* // for a given component as well.
662
* calendar: ['skin1', 'skin2']
668
this.skin = Y.merge(Y.Env.meta.skin);
542
670
var defaults = Y.Env.meta.modules;
758
SKIN_PREFIX: "skin-",
629
760
_config: function(o) {
631
762
// apply config values
633
764
for (var i in o) {
635
765
if (o.hasOwnProperty(i)) {
636
767
if (i == 'require') {
637
768
this.require(val);
638
// support the old callback syntax
639
// } else if (i.indexOf('on') === 0) {
640
// this.subscribe(i.substr(2).toLowerCase(), o[i], o.context || this);
641
769
} else if (i == 'modules') {
642
771
// add a hash of module definitions
643
772
for (var j in val) {
644
this.addModule(val[j], j);
773
if (val.hasOwnProperty(j)) {
774
this.addModule(val[j], j);
654
786
var f = this.filter;
656
788
if (L.isString(f)) {
658
789
f = f.toUpperCase();
660
790
this.filterName = f;
662
// the logger must be available in order to use the debug
663
// versions of the library
664
// @TODO review when logreader is available
665
// if (f === "DEBUG") {
666
// this.require("log");
669
791
this.filter = this.FILTERS[f];
797
* Returns the skin module name for the specified skin name. If a
798
* module name is supplied, the returned skin module name is
799
* specific to the module passed in.
801
* @param skin {string} the name of the skin
802
* @param mod {string} optional: the name of a module to skin
803
* @return {string} the full skin module name
805
formatSkin: function(skin, mod) {
806
var s = this.SKIN_PREFIX + skin;
815
* Reverses <code>formatSkin</code>, providing the skin name and
816
* module name if the string matches the pattern for skins.
818
* @param mod {string} the module name to parse
819
* @return {skin: string, module: string} the parsed skin name
820
* and module name, or null if the supplied string does not match
823
parseSkin: function(mod) {
825
if (mod.indexOf(this.SKIN_PREFIX) === 0) {
826
var a = mod.split("-");
827
return {skin: a[1], module: a[2]};
834
* Adds the skin def to the module info
836
* @param skin {string} the name of the skin
837
* @param mod {string} the name of the module
838
* @param parent {string} parent module if this is a skin of a
839
* submodule or plugin
840
* @return {string} the module name for the skin
843
_addSkin: function(skin, mod, parent) {
845
var name = this.formatSkin(skin), info = this.moduleInfo,
846
sinf = this.skin, ext = info[mod] && info[mod].ext;
849
// Add a module definition for the skin rollup css
854
'path': sinf.base + skin + '/' + sinf.path,
857
'rollup': sinf.rollup,
863
// Add a module definition for the module-specific skin css
865
name = this.formatSkin(skin, mod);
867
var mdef = info[mod], pkg = mdef.pkg || mod;
872
'path': (parent || pkg) + '/' + sinf.base + skin + '/' + mod + '.css',
674
881
/** Add a new module to the component metadata.
676
883
* <dt>name:</dt> <dd>required, the component name</dd>
713
920
o.requires = o.requires || [];
923
this.moduleInfo[name] = o;
716
925
// Handle submodule logic
717
var subs = o.submodules;
926
var subs = o.submodules, i;
719
928
var sup = [], l=0;
721
for (var i in subs) {
723
s.path = _path(name, i, o.type);
724
this.addModule(s, i);
931
if (subs.hasOwnProperty(i)) {
933
s.path = _path(name, i, o.type);
934
this.addModule(s, i);
938
var smod = this._addSkin(this.skin.defaultSkin, i, name);
729
946
o.supersedes = sup;
730
947
o.rollup = Math.min(l-1, 4);
733
this.moduleInfo[name] = o;
950
var plugins = o.plugins;
953
if (plugins.hasOwnProperty(i)) {
954
var plug = plugins[i];
955
plug.path = _path(name, i, o.type);
956
plug.requires = plug.requires || [];
957
plug.requires.push(name);
958
this.addModule(plug, i);
960
this._addSkin(this.skin.defaultSkin, i, name);
734
966
this.dirty = true;
891
1123
var info = this.moduleInfo, name, i, j;
1125
// Create skin modules
1126
for (name in info) {
1127
if (info.hasOwnProperty(name)) {
1129
if (m && m.skinnable) {
1130
var o=this.skin.overrides, smod;
1132
for (i=0; i<o[name].length; i=i+1) {
1133
smod = this._addSkin(o[name][i], name);
1136
smod = this._addSkin(this.skin.defaultSkin, name);
1139
m.requires.push(smod);
893
1144
var l = Y.merge(this.inserted); // shallow clone
895
1146
// available modules
996
1247
// go through the rollup candidates
997
1248
for (i in rollups) {
999
// there can be only one
1000
if (!r[i] && !this.loaded[i]) {
1001
m =this.getModule(i); s = m.supersedes ||[]; roll=false;
1009
// check the threshold
1010
for (j=0;j<s.length;j=j+1) {
1012
// if the superseded module is loaded, we can't load the rollup
1013
// if (this.loaded[s[j]] && (!_Y.dupsAllowed[s[j]])) {
1014
if (this.loaded[s[j]]) {
1017
// increment the counter if this module is required. if we are
1018
// beyond the rollup threshold, we will use the rollup module
1019
} else if (r[s[j]]) {
1021
roll = (c >= m.rollup);
1250
if (rollups.hasOwnProperty(i)) {
1252
// there can be only one
1253
if (!r[i] && !this.loaded[i]) {
1254
m =this.getModule(i); s = m.supersedes ||[]; roll=false;
1262
// check the threshold
1263
for (j=0;j<s.length;j=j+1) {
1265
// if the superseded module is loaded, we can't load the rollup
1266
// if (this.loaded[s[j]] && (!_Y.dupsAllowed[s[j]])) {
1267
if (this.loaded[s[j]]) {
1270
// increment the counter if this module is required. if we are
1271
// beyond the rollup threshold, we will use the rollup module
1272
} else if (r[s[j]]) {
1274
roll = (c >= m.rollup);
1033
// expand the rollup's dependencies
1034
this.getRequires(m);
1286
// expand the rollup's dependencies
1287
this.getRequires(m);
1054
1308
var i, j, s, m, r=this.required;
1057
// remove if already loaded
1058
if (i in this.loaded) {
1061
// remove anything this module supersedes
1064
m = this.getModule(i);
1065
s = m && m.supersedes;
1067
for (j=0; j<s.length; j=j+1) {
1311
if (r.hasOwnProperty(i)) {
1313
// remove if already loaded
1314
if (i in this.loaded) {
1317
// remove anything this module supersedes
1320
m = this.getModule(i);
1321
s = m && m.supersedes;
1323
for (j=0; j<s.length; j=j+1) {
1281
1542
// flag to indicate we are done with the combo service
1282
1543
// and any additional files will need to be loaded
1283
1544
// individually
1284
this._combineComplete = false;
1545
this._combineComplete = {};
1286
1547
// keep the loadType (js, css or undefined) cached
1287
1548
this.loadType = type;
1313
var s, len, i, m, url, self=this;
1574
var s, len, i, m, url, self=this, type=this.loadType, fn;
1315
1576
// @TODO this will need to handle the two phase insert when
1316
1577
// CSS support is added
1317
if (this.loadType !== CSS && this.combine && (!this._combineComplete)) {
1578
if (this.combine && (!this._combineComplete[type])) {
1319
1580
this._combining = [];
1325
1586
m = this.getModule(s[i]);
1326
1587
// @TODO we can't combine CSS yet until we deliver files with absolute paths to the assets
1327
1588
// Do not try to combine non-yui JS
1328
if (m.type == JS && !m.ext) {
1589
if (m && m.type === this.loadType && !m.ext) {
1329
1590
url += this.root + m.path;
1330
1591
if (i < len-1) {
1436
1699
// The load type is stored to offer the possibility to load
1437
1700
// the css separately from the script.
1438
if (!this.loadType || this.loadType === m.type) {
1701
if (!type || type === m.type) {
1439
1702
this._loading = s[i];
1441
var fn=(m.type === CSS) ? Y.Get.css : Y.Get.script,
1442
onsuccess=function(o) {
1704
fn = (m.type === CSS) ? Y.Get.css : Y.Get.script;
1706
var onsuccess=function(o) {
1443
1707
self.loadNext(o.data);
1446
url=m.fullpath || this._url(m.path, s[i]);
1710
url = (m.fullpath) ? this._filter(m.fullpath) : this._url(m.path, s[i]);
1464
1729
// we are finished
1465
1730
this._loading = null;
1732
fn = this._internalCallback;
1467
1734
// internal callback for loading css first
1468
if (this._internalCallback) {
1470
var f = this._internalCallback;
1471
1736
this._internalCallback = null;
1474
1739
// } else if (this.onSuccess) {
1477
1741
// call Y.use passing this instance. Y will use the sorted
1478
1742
// dependency list.
1480
1743
this._onSuccess();
1500
* Generates the full url for a module
1502
* @param path {string} the path fragment
1503
* @return {string} the full url
1762
* Apply filter defined for this instance to a url/path
1764
* @param u {string} the string to filter
1765
* @return {string} the filtered string
1506
_url: function(path, name) {
1508
var u = (this.base || "") + path,
1768
_filter: function(u) {
1771
var f = this.filter;
1512
1774
var useFilter = true;
1514
1776
if (this.filterName == "DEBUG") {
1517
exc = self.logExclude,
1518
inc = self.logInclude;
1778
var exc = this.logExclude,
1779
inc = this.logInclude;
1519
1780
if (inc && !(name in inc)) {
1520
1781
useFilter = false;
1521
1782
} else if (exc && (name in exc)) {
1527
1788
if (useFilter) {
1528
u = u.replace(new RegExp(f.searchExp), f.replaceStr);
1789
u = u.replace(new RegExp(f.searchExp, 'g'), f.replaceStr);
1798
* Generates the full url for a module
1800
* @param path {string} the path fragment
1801
* @return {string} the full url
1804
_url: function(path, name) {
1805
return this._filter((this.base || "") + path);
1538
1810
// Y.augment(Y.Loader, Y.Event.Target);