/AppLanding/js/vendor/lesshat/mixins/selection/selection.js

https://gitlab.com/webocalypse/themes · JavaScript · 68 lines · 39 code · 13 blank · 16 comment · 14 complexity · c2ba94203c7dc35484d74b57ac95a64e MD5 · raw file

  1. /**
  2. * Selection mixin
  3. */
  4. var selection = function selection(value) {
  5. // States
  6. // 1 - all
  7. // 2 - w3c
  8. // 3 - moz
  9. value = value || 08121991;
  10. var state = '@{state}';
  11. var value_temp = value;
  12. if (value == 08121991) {
  13. return value;
  14. }
  15. switch (state) {
  16. case '1':
  17. syntax('start', '::selection');
  18. syntax('end', '::-moz-selection');
  19. break;
  20. case '2':
  21. syntax('startend', '::selection');
  22. break;
  23. case '3':
  24. syntax('startend', '::-moz-selection');
  25. break;
  26. }
  27. function syntax(start, selector) {
  28. var end = '}\n';
  29. var definition = value_temp.split(',');
  30. var syntax = (definition[1] || '') + selector + '{' + definition[0] + end;
  31. if (start == 'start') {
  32. value = '0; } \n' + syntax;
  33. } else if (start == 'startend') {
  34. value = '0; } \n' + syntax.replace(end, '');
  35. } else if (start == 'end') {
  36. value = value + syntax.replace(end, '');
  37. } else {
  38. value = value + syntax;
  39. }
  40. }
  41. value = value.replace(/;$/g,'');
  42. return value;
  43. };
  44. /**
  45. * We want totally custom result definition, because selection mixin is tricky one (not recommended, it's not testable)
  46. */
  47. selection.result = 'result.less';
  48. /**
  49. * For which browsers is this mixin specified
  50. */
  51. selection.vendors = ['moz'];
  52. /**
  53. * Export mixin
  54. */
  55. module.exports = selection;