BVB Source Codes

reactide Show resolution.js Source code

Return Download reactide: download resolution.js Source code - Download reactide Source code - Type:.js
  1. (function() {
  2.   var Prefixer, Resolution, n2f, regexp, split, utils,
  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.   utils = require('./utils');
  9.  
  10.   n2f = require('num2fraction');
  11.  
  12.   regexp = /(min|max)-resolution\s*:\s*\d*\.?\d+(dppx|dpi)/gi;
  13.  
  14.   split = /(min|max)-resolution(\s*:\s*)(\d*\.?\d+)(dppx|dpi)/i;
  15.  
  16.   Resolution = (function(superClass) {
  17.     extend(Resolution, superClass);
  18.  
  19.     function Resolution() {
  20.       return Resolution.__super__.constructor.apply(this, arguments);
  21.     }
  22.  
  23.     Resolution.prototype.prefixName = function(prefix, name) {
  24.       return name = prefix === '-moz-' ? name + '--moz-device-pixel-ratio' : prefix + name + '-device-pixel-ratio';
  25.     };
  26.  
  27.     Resolution.prototype.prefixQuery = function(prefix, name, colon, value, units) {
  28.       if (units === 'dpi') {
  29.         value = Number(value / 96);
  30.       }
  31.       if (prefix === '-o-') {
  32.         value = n2f(value);
  33.       }
  34.       return this.prefixName(prefix, name) + colon + value;
  35.     };
  36.  
  37.     Resolution.prototype.clean = function(rule) {
  38.       var j, len, prefix, ref;
  39.       if (!this.bad) {
  40.         this.bad = [];
  41.         ref = this.prefixes;
  42.         for (j = 0, len = ref.length; j < len; j++) {
  43.           prefix = ref[j];
  44.           this.bad.push(this.prefixName(prefix, 'min'));
  45.           this.bad.push(this.prefixName(prefix, 'max'));
  46.         }
  47.       }
  48.       return rule.params = utils.editList(rule.params, (function(_this) {
  49.         return function(queries) {
  50.           return queries.filter(function(query) {
  51.             return _this.bad.every(function(i) {
  52.               return query.indexOf(i) === -1;
  53.             });
  54.           });
  55.         };
  56.       })(this));
  57.     };
  58.  
  59.     Resolution.prototype.process = function(rule) {
  60.       var parent, prefixes;
  61.       parent = this.parentPrefix(rule);
  62.       prefixes = parent ? [parent] : this.prefixes;
  63.       return rule.params = utils.editList(rule.params, (function(_this) {
  64.         return function(origin, prefixed) {
  65.           var j, k, len, len1, prefix, processed, query;
  66.           for (j = 0, len = origin.length; j < len; j++) {
  67.             query = origin[j];
  68.             if (query.indexOf('min-resolution') === -1 && query.indexOf('max-resolution') === -1) {
  69.               prefixed.push(query);
  70.               continue;
  71.             }
  72.             for (k = 0, len1 = prefixes.length; k < len1; k++) {
  73.               prefix = prefixes[k];
  74.               if (prefix === '-moz-' && rule.params.indexOf('dpi') !== -1) {
  75.                 continue;
  76.               } else {
  77.                 processed = query.replace(regexp, function(str) {
  78.                   var parts;
  79.                   parts = str.match(split);
  80.                   return _this.prefixQuery(prefix, parts[1], parts[2], parts[3], parts[4]);
  81.                 });
  82.                 prefixed.push(processed);
  83.               }
  84.             }
  85.             prefixed.push(query);
  86.           }
  87.           return utils.uniq(prefixed);
  88.         };
  89.       })(this));
  90.     };
  91.  
  92.     return Resolution;
  93.  
  94.   })(Prefixer);
  95.  
  96.   module.exports = Resolution;
  97.  
  98. }).call(this);
  99.  
downloadresolution.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