No Description

info.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. (function() {
  2. var capitalize, names, prefix;
  3. capitalize = function(str) {
  4. return str.slice(0, 1).toUpperCase() + str.slice(1);
  5. };
  6. names = {
  7. ie: 'IE',
  8. ie_mob: 'IE Mobile',
  9. ios_saf: 'iOS',
  10. op_mini: 'Opera Mini',
  11. op_mob: 'Opera Mobile',
  12. and_chr: 'Chrome for Android',
  13. and_ff: 'Firefox for Android',
  14. and_uc: 'UC for Android'
  15. };
  16. prefix = function(name, transition, prefixes) {
  17. var out;
  18. out = ' ' + name + (transition ? '*' : '') + ': ';
  19. out += prefixes.map(function(i) {
  20. return i.replace(/^-(.*)-$/g, '$1');
  21. }).join(', ');
  22. out += "\n";
  23. return out;
  24. };
  25. module.exports = function(prefixes) {
  26. 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;
  27. if (prefixes.browsers.selected.length === 0) {
  28. return "No browsers selected";
  29. }
  30. versions = [];
  31. ref = prefixes.browsers.selected;
  32. for (j = 0, len = ref.length; j < len; j++) {
  33. browser = ref[j];
  34. ref1 = browser.split(' '), name = ref1[0], version = ref1[1];
  35. name = names[name] || capitalize(name);
  36. if (versions[name]) {
  37. versions[name].push(version);
  38. } else {
  39. versions[name] = [version];
  40. }
  41. }
  42. out = "Browsers:\n";
  43. for (browser in versions) {
  44. list = versions[browser];
  45. list = list.sort(function(a, b) {
  46. return parseFloat(b) - parseFloat(a);
  47. });
  48. out += ' ' + browser + ': ' + list.join(', ') + "\n";
  49. }
  50. atrules = '';
  51. ref2 = prefixes.add;
  52. for (name in ref2) {
  53. data = ref2[name];
  54. if (name[0] === '@' && data.prefixes) {
  55. atrules += prefix(name, false, data.prefixes);
  56. }
  57. }
  58. if (atrules !== '') {
  59. out += "\nAt-Rules:\n" + atrules;
  60. }
  61. selectors = '';
  62. ref3 = prefixes.add.selectors;
  63. for (k = 0, len1 = ref3.length; k < len1; k++) {
  64. selector = ref3[k];
  65. if (selector.prefixes) {
  66. selectors += prefix(selector.name, false, selector.prefixes);
  67. }
  68. }
  69. if (selectors !== '') {
  70. out += "\nSelectors:\n" + selectors;
  71. }
  72. values = '';
  73. props = '';
  74. useTransition = false;
  75. needTransition = (ref4 = prefixes.add.transition) != null ? ref4.prefixes : void 0;
  76. ref5 = prefixes.add;
  77. for (name in ref5) {
  78. data = ref5[name];
  79. if (name[0] !== '@' && data.prefixes) {
  80. transitionProp = needTransition && prefixes.data[name].transition;
  81. if (transitionProp) {
  82. useTransition = true;
  83. }
  84. props += prefix(name, transitionProp, data.prefixes);
  85. }
  86. if (!data.values) {
  87. continue;
  88. }
  89. if (prefixes.transitionProps.some(function(i) {
  90. return i === name;
  91. })) {
  92. continue;
  93. }
  94. ref6 = data.values;
  95. for (l = 0, len2 = ref6.length; l < len2; l++) {
  96. value = ref6[l];
  97. string = prefix(value.name, false, value.prefixes);
  98. if (values.indexOf(string) === -1) {
  99. values += string;
  100. }
  101. }
  102. }
  103. if (useTransition) {
  104. props += " * - can be used in transition\n";
  105. }
  106. if (props !== '') {
  107. out += "\nProperties:\n" + props;
  108. }
  109. if (values !== '') {
  110. out += "\nValues:\n" + values;
  111. }
  112. if (atrules === '' && selectors === '' && props === '' && values === '') {
  113. out += '\nAwesome! Your browsers don\'t require any vendor prefixes.' + '\nNow you can remove Autoprefixer from build steps.';
  114. }
  115. return out;
  116. };
  117. }).call(this);