|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var parseMeasurement = require('../parsers').parseMeasurement;
|
|---|
| 4 |
|
|---|
| 5 | var shape_regex = /^rect\((.*)\)$/i;
|
|---|
| 6 |
|
|---|
| 7 | var parse = function(val) {
|
|---|
| 8 | if (val === '' || val === null) {
|
|---|
| 9 | return val;
|
|---|
| 10 | }
|
|---|
| 11 | if (typeof val !== 'string') {
|
|---|
| 12 | return undefined;
|
|---|
| 13 | }
|
|---|
| 14 | val = val.toLowerCase();
|
|---|
| 15 | if (val === 'auto' || val === 'inherit') {
|
|---|
| 16 | return val;
|
|---|
| 17 | }
|
|---|
| 18 | var matches = val.match(shape_regex);
|
|---|
| 19 | if (!matches) {
|
|---|
| 20 | return undefined;
|
|---|
| 21 | }
|
|---|
| 22 | var parts = matches[1].split(/\s*,\s*/);
|
|---|
| 23 | if (parts.length !== 4) {
|
|---|
| 24 | return undefined;
|
|---|
| 25 | }
|
|---|
| 26 | var valid = parts.every(function(part, index) {
|
|---|
| 27 | var measurement = parseMeasurement(part);
|
|---|
| 28 | parts[index] = measurement;
|
|---|
| 29 | return measurement !== undefined;
|
|---|
| 30 | });
|
|---|
| 31 | if (!valid) {
|
|---|
| 32 | return undefined;
|
|---|
| 33 | }
|
|---|
| 34 | parts = parts.join(', ');
|
|---|
| 35 | return val.replace(matches[1], parts);
|
|---|
| 36 | };
|
|---|
| 37 |
|
|---|
| 38 | module.exports.definition = {
|
|---|
| 39 | set: function(v) {
|
|---|
| 40 | this._setProperty('clip', parse(v));
|
|---|
| 41 | },
|
|---|
| 42 | get: function() {
|
|---|
| 43 | return this.getPropertyValue('clip');
|
|---|
| 44 | },
|
|---|
| 45 | enumerable: true,
|
|---|
| 46 | configurable: true,
|
|---|
| 47 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.