Guest User

Untitled

a guest
Jul 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. CSS.translate = function(value) {
  2. var found, whitespace, result = [], scope = result;
  3. var regex = x(CSS.value);
  4. var names = regex.names;
  5.  
  6. while (found = regex.exec(value)) {
  7. var length = result.length;
  8. if (found[names.comma] && !length) continue //throw "comma in the beginning?"
  9.  
  10. var number = found[names.number]
  11. if (number) {
  12. var unit = found[names.unit]
  13. scope.push(unit ? {unit: unit, number: number} : number)
  14. continue;
  15. }
  16.  
  17. if (found[names.whitespace] && !whitespace) {
  18. whitespace = true;
  19. scope = [result[length - 1]];
  20. result.splice(length - 1, 1, scope)
  21. continue;
  22. }
  23.  
  24. if (found[names.comma]) {
  25. whitespace = false;
  26. scope = result;
  27. continue;
  28. }
  29. var func = found[names.func];
  30. if (func) {
  31. var obj = {};
  32. obj[func] = CSS.translate(found[names._arguments])
  33. scope.push(obj)
  34. continue
  35. }
  36.  
  37. var hex = found[names.hex];
  38. if (hex) {
  39. scope.push(hex);
  40. continue
  41. }
  42.  
  43. var text = found[names.text];
  44. if (text) {
  45. scope.push(text);
  46. continue
  47. }
  48. }
  49.  
  50. return result.length == 1 ? result[0] : result;
  51. }
Add Comment
Please, Sign In to add comment