Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CSS.translate = function(value) {
- var found, whitespace, result = [], scope = result;
- var regex = x(CSS.value);
- var names = regex.names;
- while (found = regex.exec(value)) {
- var length = result.length;
- if (found[names.comma] && !length) continue //throw "comma in the beginning?"
- var number = found[names.number]
- if (number) {
- var unit = found[names.unit]
- scope.push(unit ? {unit: unit, number: number} : number)
- continue;
- }
- if (found[names.whitespace] && !whitespace) {
- whitespace = true;
- scope = [result[length - 1]];
- result.splice(length - 1, 1, scope)
- continue;
- }
- if (found[names.comma]) {
- whitespace = false;
- scope = result;
- continue;
- }
- var func = found[names.func];
- if (func) {
- var obj = {};
- obj[func] = CSS.translate(found[names._arguments])
- scope.push(obj)
- continue
- }
- var hex = found[names.hex];
- if (hex) {
- scope.push(hex);
- continue
- }
- var text = found[names.text];
- if (text) {
- scope.push(text);
- continue
- }
- }
- return result.length == 1 ? result[0] : result;
- }
Add Comment
Please, Sign In to add comment