MDL-40478 JavaScript: Support loading of YUI submodules in the yui-loader
[moodle.git] / lib / yui / config / moodle.js
CommitLineData
7cfe3ebb
AN
1// This file is part of Moodle - http://moodle.org/
2//
3// Moodle is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// Moodle is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
15
16// A module name should be composed of:
f320e8d0
AN
17// moodle-<component>-<module>[-<submodule>][-skin]
18var parts = me.name.replace(/^moodle-/,'').split('-'),
19 component = parts.shift(),
20 module = parts[0],
21 min = '-min';
7cfe3ebb 22
f320e8d0 23if (/-(skin|core)$/.test(me.name)) {
7cfe3ebb 24 // For these types, we need to remove the final word and set the type.
f320e8d0 25 parts.pop();
7cfe3ebb 26 me.type = 'css';
f320e8d0
AN
27
28 // CSS is not minified - clear the min option.
29 min = '';
7cfe3ebb
AN
30}
31
f320e8d0
AN
32if (module) {
33 // Determine the filename based on the remaining parts.
34 var filename = parts.join('-');
7cfe3ebb 35
f320e8d0
AN
36 // Build the first part of the filename.
37 me.path = component + '/' + module + '/' + filename + min + '.' + me.type;
38} else {
39 // This is a hangup from the old ways of writing Modules.
40 // We will start to warn about this once we have removed all core components of this form.
41 me.path = component + '/' + component + '.' + me.type;
7cfe3ebb 42}