BVB Source Codes

reactide Show grid-template.js Source code

Return Download reactide: download grid-template.js Source code - Download reactide Source code - Type:.js
  1. (function() {
  2.   var Declaration, GridTemplate, parser,
  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.   parser = require('postcss-value-parser');
  7.  
  8.   Declaration = require('../declaration');
  9.  
  10.   GridTemplate = (function(superClass) {
  11.     extend(GridTemplate, superClass);
  12.  
  13.     function GridTemplate() {
  14.       return GridTemplate.__super__.constructor.apply(this, arguments);
  15.     }
  16.  
  17.     GridTemplate.names = ['grid-template-rows', 'grid-template-columns', 'grid-rows', 'grid-columns'];
  18.  
  19.     GridTemplate.prototype.prefixed = function(prop, prefix) {
  20.       if (prefix === '-ms-') {
  21.         return prefix + prop.replace('template-', '');
  22.       } else {
  23.         return GridTemplate.__super__.prefixed.call(this, prop, prefix);
  24.       }
  25.     };
  26.  
  27.     GridTemplate.prototype.normalize = function(prop) {
  28.       return prop.replace(/^grid-(rows|columns)/, 'grid-template-$1');
  29.     };
  30.  
  31.     GridTemplate.prototype.walkRepeat = function(node) {
  32.       var count, first, fixed, i, j, len, ref;
  33.       fixed = [];
  34.       ref = node.nodes;
  35.       for (j = 0, len = ref.length; j < len; j++) {
  36.         i = ref[j];
  37.         if (i.nodes) {
  38.           this.walkRepeat(i);
  39.         }
  40.         fixed.push(i);
  41.         if (i.type === 'function' && i.value === 'repeat') {
  42.           first = i.nodes.shift();
  43.           if (first) {
  44.             count = first.value;
  45.             i.nodes.shift();
  46.             i.value = '';
  47.             fixed.push({
  48.               type: 'word',
  49.               value: "[" + count + "]"
  50.             });
  51.           }
  52.         }
  53.       }
  54.       return node.nodes = fixed;
  55.     };
  56.  
  57.     GridTemplate.prototype.changeRepeat = function(value) {
  58.       var ast;
  59.       ast = parser(value);
  60.       this.walkRepeat(ast);
  61.       return ast.toString();
  62.     };
  63.  
  64.     GridTemplate.prototype.set = function(decl, prefix) {
  65.       if (prefix === '-ms-' && decl.value.indexOf('repeat(') !== -1) {
  66.         decl.value = this.changeRepeat(decl.value);
  67.       }
  68.       return GridTemplate.__super__.set.call(this, decl, prefix);
  69.     };
  70.  
  71.     return GridTemplate;
  72.  
  73.   })(Declaration);
  74.  
  75.   module.exports = GridTemplate;
  76.  
  77. }).call(this);
  78.  
downloadgrid-template.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