|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
753 bytes
|
| Line | |
|---|
| 1 | var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel;
|
|---|
| 2 |
|
|---|
| 3 | var TIME_VALUE = /^(-?[\d.]+)(m?s)$/;
|
|---|
| 4 |
|
|---|
| 5 | var plugin = {
|
|---|
| 6 | level1: {
|
|---|
| 7 | value: function time(name, value, options) {
|
|---|
| 8 | if (!options.level[OptimizationLevel.One].replaceTimeUnits) {
|
|---|
| 9 | return value;
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | if (!TIME_VALUE.test(value)) {
|
|---|
| 13 | return value;
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | return value.replace(TIME_VALUE, function(match, val, unit) {
|
|---|
| 17 | var newValue;
|
|---|
| 18 |
|
|---|
| 19 | if (unit == 'ms') {
|
|---|
| 20 | newValue = parseInt(val) / 1000 + 's';
|
|---|
| 21 | } else if (unit == 's') {
|
|---|
| 22 | newValue = parseFloat(val) * 1000 + 'ms';
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | return newValue.length < match.length ? newValue : match;
|
|---|
| 26 | });
|
|---|
| 27 | }
|
|---|
| 28 | }
|
|---|
| 29 | };
|
|---|
| 30 |
|
|---|
| 31 | module.exports = plugin;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.