123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- (function() {
- var capitalize, names, prefix;
-
- capitalize = function(str) {
- return str.slice(0, 1).toUpperCase() + str.slice(1);
- };
-
- names = {
- ie: 'IE',
- ie_mob: 'IE Mobile',
- ios_saf: 'iOS',
- op_mini: 'Opera Mini',
- op_mob: 'Opera Mobile',
- and_chr: 'Chrome for Android',
- and_ff: 'Firefox for Android',
- and_uc: 'UC for Android'
- };
-
- prefix = function(name, transition, prefixes) {
- var out;
- out = ' ' + name + (transition ? '*' : '') + ': ';
- out += prefixes.map(function(i) {
- return i.replace(/^-(.*)-$/g, '$1');
- }).join(', ');
- out += "\n";
- return out;
- };
-
- module.exports = function(prefixes) {
- var atrules, browser, data, j, k, l, len, len1, len2, list, name, needTransition, out, props, ref, ref1, ref2, ref3, ref4, ref5, ref6, selector, selectors, string, transitionProp, useTransition, value, values, version, versions;
- if (prefixes.browsers.selected.length === 0) {
- return "No browsers selected";
- }
- versions = [];
- ref = prefixes.browsers.selected;
- for (j = 0, len = ref.length; j < len; j++) {
- browser = ref[j];
- ref1 = browser.split(' '), name = ref1[0], version = ref1[1];
- name = names[name] || capitalize(name);
- if (versions[name]) {
- versions[name].push(version);
- } else {
- versions[name] = [version];
- }
- }
- out = "Browsers:\n";
- for (browser in versions) {
- list = versions[browser];
- list = list.sort(function(a, b) {
- return parseFloat(b) - parseFloat(a);
- });
- out += ' ' + browser + ': ' + list.join(', ') + "\n";
- }
- atrules = '';
- ref2 = prefixes.add;
- for (name in ref2) {
- data = ref2[name];
- if (name[0] === '@' && data.prefixes) {
- atrules += prefix(name, false, data.prefixes);
- }
- }
- if (atrules !== '') {
- out += "\nAt-Rules:\n" + atrules;
- }
- selectors = '';
- ref3 = prefixes.add.selectors;
- for (k = 0, len1 = ref3.length; k < len1; k++) {
- selector = ref3[k];
- if (selector.prefixes) {
- selectors += prefix(selector.name, false, selector.prefixes);
- }
- }
- if (selectors !== '') {
- out += "\nSelectors:\n" + selectors;
- }
- values = '';
- props = '';
- useTransition = false;
- needTransition = (ref4 = prefixes.add.transition) != null ? ref4.prefixes : void 0;
- ref5 = prefixes.add;
- for (name in ref5) {
- data = ref5[name];
- if (name[0] !== '@' && data.prefixes) {
- transitionProp = needTransition && prefixes.data[name].transition;
- if (transitionProp) {
- useTransition = true;
- }
- props += prefix(name, transitionProp, data.prefixes);
- }
- if (!data.values) {
- continue;
- }
- if (prefixes.transitionProps.some(function(i) {
- return i === name;
- })) {
- continue;
- }
- ref6 = data.values;
- for (l = 0, len2 = ref6.length; l < len2; l++) {
- value = ref6[l];
- string = prefix(value.name, false, value.prefixes);
- if (values.indexOf(string) === -1) {
- values += string;
- }
- }
- }
- if (useTransition) {
- props += " * - can be used in transition\n";
- }
- if (props !== '') {
- out += "\nProperties:\n" + props;
- }
- if (values !== '') {
- out += "\nValues:\n" + values;
- }
- if (atrules === '' && selectors === '' && props === '' && values === '') {
- out += '\nAwesome! Your browsers don\'t require any vendor prefixes.' + '\nNow you can remove Autoprefixer from build steps.';
- }
- return out;
- };
-
- }).call(this);
|