BVB Source Codes

reactide Show value.js Source code

Return Download reactide: download value.js Source code - Download reactide Source code - Type:.js
  1. (function() {
  2.   var OldValue, Prefixer, Value, utils, vendor,
  3.     extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  4.     hasProp = {}.hasOwnProperty;
  5.  
  6.   Prefixer = require('./prefixer');
  7.  
  8.   OldValue = require('./old-value');
  9.  
  10.   utils = require('./utils');
  11.  
  12.   vendor = require('postcss/lib/vendor');
  13.  
  14.   Value = (function(superClass) {
  15.     extend(Value, superClass);
  16.  
  17.     function Value() {
  18.       return Value.__super__.constructor.apply(this, arguments);
  19.     }
  20.  
  21.     Value.save = function(prefixes, decl) {
  22.       var already, cloned, prefix, prefixed, prop, propPrefix, ref, results, rule, trimmed, value;
  23.       prop = decl.prop;
  24.       ref = decl._autoprefixerValues;
  25.       results = [];
  26.       for (prefix in ref) {
  27.         value = ref[prefix];
  28.         if (value === decl.value) {
  29.           continue;
  30.         }
  31.         propPrefix = vendor.prefix(prop);
  32.         if (propPrefix === prefix) {
  33.           results.push(decl.value = value);
  34.         } else if (propPrefix === '-pie-') {
  35.           continue;
  36.         } else {
  37.           prefixed = prefixes.prefixed(prop, prefix);
  38.           rule = decl.parent;
  39.           if (rule.every(function(i) {
  40.             return i.prop !== prefixed;
  41.           })) {
  42.             trimmed = value.replace(/\s+/, ' ');
  43.             already = rule.some(function(i) {
  44.               return i.prop === decl.prop && i.value.replace(/\s+/, ' ') === trimmed;
  45.             });
  46.             if (!already) {
  47.               cloned = this.clone(decl, {
  48.                 value: value
  49.               });
  50.               results.push(decl.parent.insertBefore(decl, cloned));
  51.             } else {
  52.               results.push(void 0);
  53.             }
  54.           } else {
  55.             results.push(void 0);
  56.           }
  57.         }
  58.       }
  59.       return results;
  60.     };
  61.  
  62.     Value.prototype.check = function(decl) {
  63.       var value;
  64.       value = decl.value;
  65.       if (value.indexOf(this.name) !== -1) {
  66.         return !!value.match(this.regexp());
  67.       } else {
  68.         return false;
  69.       }
  70.     };
  71.  
  72.     Value.prototype.regexp = function() {
  73.       return this.regexpCache || (this.regexpCache = utils.regexp(this.name));
  74.     };
  75.  
  76.     Value.prototype.replace = function(string, prefix) {
  77.       return string.replace(this.regexp(), '$1' + prefix + '$2');
  78.     };
  79.  
  80.     Value.prototype.value = function(decl) {
  81.       if (decl.raws.value && decl.raws.value.value === decl.value) {
  82.         return decl.raws.value.raw;
  83.       } else {
  84.         return decl.value;
  85.       }
  86.     };
  87.  
  88.     Value.prototype.add = function(decl, prefix) {
  89.       var value;
  90.       decl._autoprefixerValues || (decl._autoprefixerValues = {});
  91.       value = decl._autoprefixerValues[prefix] || this.value(decl);
  92.       value = this.replace(value, prefix);
  93.       if (value) {
  94.         return decl._autoprefixerValues[prefix] = value;
  95.       }
  96.     };
  97.  
  98.     Value.prototype.old = function(prefix) {
  99.       return new OldValue(this.name, prefix + this.name);
  100.     };
  101.  
  102.     return Value;
  103.  
  104.   })(Prefixer);
  105.  
  106.   module.exports = Value;
  107.  
  108. }).call(this);
  109.  
downloadvalue.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top