WIP - add extractor, generate snippet_data
This commit is contained in:
65
node_modules/renderkid/lib/renderKid/styles/rule/DeclarationBlock.js
generated
vendored
Normal file
65
node_modules/renderkid/lib/renderKid/styles/rule/DeclarationBlock.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var Arbitrary, DeclarationBlock, declarationClasses;
|
||||
|
||||
module.exports = DeclarationBlock = (function() {
|
||||
var self;
|
||||
|
||||
self = DeclarationBlock;
|
||||
|
||||
function DeclarationBlock() {
|
||||
this._declarations = {};
|
||||
}
|
||||
|
||||
DeclarationBlock.prototype.set = function(prop, value) {
|
||||
var key, val;
|
||||
if (typeof prop === 'object') {
|
||||
for (key in prop) {
|
||||
val = prop[key];
|
||||
this.set(key, val);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
prop = self.sanitizeProp(prop);
|
||||
this._getDeclarationClass(prop).setOnto(this._declarations, prop, value);
|
||||
return this;
|
||||
};
|
||||
|
||||
DeclarationBlock.prototype._getDeclarationClass = function(prop) {
|
||||
var cls;
|
||||
if (prop[0] === '_') {
|
||||
return Arbitrary;
|
||||
}
|
||||
if (!(cls = declarationClasses[prop])) {
|
||||
throw Error("Unknown property `" + prop + "`. Write it as `_" + prop + "` if you're defining a custom property");
|
||||
}
|
||||
return cls;
|
||||
};
|
||||
|
||||
DeclarationBlock.sanitizeProp = function(prop) {
|
||||
return String(prop).trim();
|
||||
};
|
||||
|
||||
return DeclarationBlock;
|
||||
|
||||
})();
|
||||
|
||||
Arbitrary = require('./declarationBlock/Arbitrary');
|
||||
|
||||
declarationClasses = {
|
||||
color: require('./declarationBlock/Color'),
|
||||
background: require('./declarationBlock/Background'),
|
||||
width: require('./declarationBlock/Width'),
|
||||
height: require('./declarationBlock/Height'),
|
||||
bullet: require('./declarationBlock/Bullet'),
|
||||
display: require('./declarationBlock/Display'),
|
||||
margin: require('./declarationBlock/Margin'),
|
||||
marginTop: require('./declarationBlock/MarginTop'),
|
||||
marginLeft: require('./declarationBlock/MarginLeft'),
|
||||
marginRight: require('./declarationBlock/MarginRight'),
|
||||
marginBottom: require('./declarationBlock/MarginBottom'),
|
||||
padding: require('./declarationBlock/Padding'),
|
||||
paddingTop: require('./declarationBlock/PaddingTop'),
|
||||
paddingLeft: require('./declarationBlock/PaddingLeft'),
|
||||
paddingRight: require('./declarationBlock/PaddingRight'),
|
||||
paddingBottom: require('./declarationBlock/PaddingBottom')
|
||||
};
|
||||
78
node_modules/renderkid/lib/renderKid/styles/rule/MixedDeclarationSet.js
generated
vendored
Normal file
78
node_modules/renderkid/lib/renderKid/styles/rule/MixedDeclarationSet.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var MixedDeclarationSet,
|
||||
slice = [].slice;
|
||||
|
||||
module.exports = MixedDeclarationSet = (function() {
|
||||
var self;
|
||||
|
||||
self = MixedDeclarationSet;
|
||||
|
||||
MixedDeclarationSet.mix = function() {
|
||||
var i, len, mixed, ruleSets, rules;
|
||||
ruleSets = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
mixed = new self;
|
||||
for (i = 0, len = ruleSets.length; i < len; i++) {
|
||||
rules = ruleSets[i];
|
||||
mixed.mixWithList(rules);
|
||||
}
|
||||
return mixed;
|
||||
};
|
||||
|
||||
function MixedDeclarationSet() {
|
||||
this._declarations = {};
|
||||
}
|
||||
|
||||
MixedDeclarationSet.prototype.mixWithList = function(rules) {
|
||||
var i, len, rule;
|
||||
rules.sort(function(a, b) {
|
||||
return a.selector.priority > b.selector.priority;
|
||||
});
|
||||
for (i = 0, len = rules.length; i < len; i++) {
|
||||
rule = rules[i];
|
||||
this._mixWithRule(rule);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
MixedDeclarationSet.prototype._mixWithRule = function(rule) {
|
||||
var dec, prop, ref;
|
||||
ref = rule.styles._declarations;
|
||||
for (prop in ref) {
|
||||
dec = ref[prop];
|
||||
this._mixWithDeclaration(dec);
|
||||
}
|
||||
};
|
||||
|
||||
MixedDeclarationSet.prototype._mixWithDeclaration = function(dec) {
|
||||
var cur;
|
||||
cur = this._declarations[dec.prop];
|
||||
if ((cur != null) && cur.important && !dec.important) {
|
||||
return;
|
||||
}
|
||||
this._declarations[dec.prop] = dec;
|
||||
};
|
||||
|
||||
MixedDeclarationSet.prototype.get = function(prop) {
|
||||
if (prop == null) {
|
||||
return this._declarations;
|
||||
}
|
||||
if (this._declarations[prop] == null) {
|
||||
return null;
|
||||
}
|
||||
return this._declarations[prop].val;
|
||||
};
|
||||
|
||||
MixedDeclarationSet.prototype.toObject = function() {
|
||||
var dec, obj, prop, ref;
|
||||
obj = {};
|
||||
ref = this._declarations;
|
||||
for (prop in ref) {
|
||||
dec = ref[prop];
|
||||
obj[prop] = dec.val;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
return MixedDeclarationSet;
|
||||
|
||||
})();
|
||||
38
node_modules/renderkid/lib/renderKid/styles/rule/Selector.js
generated
vendored
Normal file
38
node_modules/renderkid/lib/renderKid/styles/rule/Selector.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var CSSSelect, Selector;
|
||||
|
||||
CSSSelect = require('css-select');
|
||||
|
||||
module.exports = Selector = (function() {
|
||||
var self;
|
||||
|
||||
self = Selector;
|
||||
|
||||
function Selector(text1) {
|
||||
this.text = text1;
|
||||
this._fn = CSSSelect.compile(this.text);
|
||||
this.priority = self.calculatePriority(this.text);
|
||||
}
|
||||
|
||||
Selector.prototype.matches = function(elem) {
|
||||
return CSSSelect.is(elem, this._fn);
|
||||
};
|
||||
|
||||
Selector.calculatePriority = function(text) {
|
||||
var n, priotrity;
|
||||
priotrity = 0;
|
||||
if (n = text.match(/[\#]{1}/g)) {
|
||||
priotrity += 100 * n.length;
|
||||
}
|
||||
if (n = text.match(/[a-zA-Z]+/g)) {
|
||||
priotrity += 2 * n.length;
|
||||
}
|
||||
if (n = text.match(/\*/g)) {
|
||||
priotrity += 1 * n.length;
|
||||
}
|
||||
return priotrity;
|
||||
};
|
||||
|
||||
return Selector;
|
||||
|
||||
})();
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Arbitrary.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Arbitrary.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var Arbitrary, _Declaration,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Declaration = require('./_Declaration');
|
||||
|
||||
module.exports = Arbitrary = (function(superClass) {
|
||||
extend(Arbitrary, superClass);
|
||||
|
||||
function Arbitrary() {
|
||||
return Arbitrary.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return Arbitrary;
|
||||
|
||||
})(_Declaration);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Background.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Background.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var Background, _Declaration,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Declaration = require('./_Declaration');
|
||||
|
||||
module.exports = Background = (function(superClass) {
|
||||
extend(Background, superClass);
|
||||
|
||||
function Background() {
|
||||
return Background.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return Background;
|
||||
|
||||
})(_Declaration);
|
||||
63
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Bullet.js
generated
vendored
Normal file
63
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Bullet.js
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var Bullet, _Declaration,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Declaration = require('./_Declaration');
|
||||
|
||||
module.exports = Bullet = (function(superClass) {
|
||||
var self;
|
||||
|
||||
extend(Bullet, superClass);
|
||||
|
||||
function Bullet() {
|
||||
return Bullet.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
self = Bullet;
|
||||
|
||||
Bullet.prototype._set = function(val) {
|
||||
var alignment, bg, char, color, enabled, m, original;
|
||||
val = String(val);
|
||||
original = val;
|
||||
char = null;
|
||||
enabled = false;
|
||||
color = 'none';
|
||||
bg = 'none';
|
||||
if (m = val.match(/\"([^"]+)\"/) || (m = val.match(/\'([^']+)\'/))) {
|
||||
char = m[1];
|
||||
val = val.replace(m[0], '');
|
||||
enabled = true;
|
||||
}
|
||||
if (m = val.match(/(none|left|right|center)/)) {
|
||||
alignment = m[1];
|
||||
val = val.replace(m[0], '');
|
||||
} else {
|
||||
alignment = 'left';
|
||||
}
|
||||
if (alignment === 'none') {
|
||||
enabled = false;
|
||||
}
|
||||
if (m = val.match(/color\:([\w\-]+)/)) {
|
||||
color = m[1];
|
||||
val = val.replace(m[0], '');
|
||||
}
|
||||
if (m = val.match(/bg\:([\w\-]+)/)) {
|
||||
bg = m[1];
|
||||
val = val.replace(m[0], '');
|
||||
}
|
||||
if (val.trim() !== '') {
|
||||
throw Error("Unrecognizable value `" + original + "` for `" + this.prop + "`");
|
||||
}
|
||||
return this.val = {
|
||||
enabled: enabled,
|
||||
char: char,
|
||||
alignment: alignment,
|
||||
background: bg,
|
||||
color: color
|
||||
};
|
||||
};
|
||||
|
||||
return Bullet;
|
||||
|
||||
})(_Declaration);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Color.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Color.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var Color, _Declaration,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Declaration = require('./_Declaration');
|
||||
|
||||
module.exports = Color = (function(superClass) {
|
||||
extend(Color, superClass);
|
||||
|
||||
function Color() {
|
||||
return Color.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return Color;
|
||||
|
||||
})(_Declaration);
|
||||
32
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Display.js
generated
vendored
Normal file
32
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Display.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var Display, _Declaration,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
_Declaration = require('./_Declaration');
|
||||
|
||||
module.exports = Display = (function(superClass) {
|
||||
var self;
|
||||
|
||||
extend(Display, superClass);
|
||||
|
||||
function Display() {
|
||||
return Display.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
self = Display;
|
||||
|
||||
Display._allowed = ['inline', 'block', 'none'];
|
||||
|
||||
Display.prototype._set = function(val) {
|
||||
val = String(val).toLowerCase();
|
||||
if (indexOf.call(self._allowed, val) < 0) {
|
||||
throw Error("Unrecognizable value `" + val + "` for `" + this.prop + "`");
|
||||
}
|
||||
return this.val = val;
|
||||
};
|
||||
|
||||
return Display;
|
||||
|
||||
})(_Declaration);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Height.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Height.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var Height, _Length,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Length = require('./_Length');
|
||||
|
||||
module.exports = Height = (function(superClass) {
|
||||
extend(Height, superClass);
|
||||
|
||||
function Height() {
|
||||
return Height.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return Height;
|
||||
|
||||
})(_Length);
|
||||
64
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Margin.js
generated
vendored
Normal file
64
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Margin.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var Margin, MarginBottom, MarginLeft, MarginRight, MarginTop, _Declaration,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Declaration = require('./_Declaration');
|
||||
|
||||
MarginTop = require('./MarginTop');
|
||||
|
||||
MarginLeft = require('./MarginLeft');
|
||||
|
||||
MarginRight = require('./MarginRight');
|
||||
|
||||
MarginBottom = require('./MarginBottom');
|
||||
|
||||
module.exports = Margin = (function(superClass) {
|
||||
var self;
|
||||
|
||||
extend(Margin, superClass);
|
||||
|
||||
function Margin() {
|
||||
return Margin.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
self = Margin;
|
||||
|
||||
Margin.setOnto = function(declarations, prop, originalValue) {
|
||||
var append, val, vals;
|
||||
append = '';
|
||||
val = _Declaration.sanitizeValue(originalValue);
|
||||
if (_Declaration.importantClauseRx.test(String(val))) {
|
||||
append = ' !important';
|
||||
val = val.replace(_Declaration.importantClauseRx, '');
|
||||
}
|
||||
val = val.trim();
|
||||
if (val.length === 0) {
|
||||
return self._setAllDirections(declarations, append, append, append, append);
|
||||
}
|
||||
vals = val.split(" ").map(function(val) {
|
||||
return val + append;
|
||||
});
|
||||
if (vals.length === 1) {
|
||||
return self._setAllDirections(declarations, vals[0], vals[0], vals[0], vals[0]);
|
||||
} else if (vals.length === 2) {
|
||||
return self._setAllDirections(declarations, vals[0], vals[1], vals[0], vals[1]);
|
||||
} else if (vals.length === 3) {
|
||||
return self._setAllDirections(declarations, vals[0], vals[1], vals[2], vals[1]);
|
||||
} else if (vals.length === 4) {
|
||||
return self._setAllDirections(declarations, vals[0], vals[1], vals[2], vals[3]);
|
||||
} else {
|
||||
throw Error("Can't understand value for margin: `" + originalValue + "`");
|
||||
}
|
||||
};
|
||||
|
||||
Margin._setAllDirections = function(declarations, top, right, bottom, left) {
|
||||
MarginTop.setOnto(declarations, 'marginTop', top);
|
||||
MarginTop.setOnto(declarations, 'marginRight', right);
|
||||
MarginTop.setOnto(declarations, 'marginBottom', bottom);
|
||||
MarginTop.setOnto(declarations, 'marginLeft', left);
|
||||
};
|
||||
|
||||
return Margin;
|
||||
|
||||
})(_Declaration);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/MarginBottom.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/MarginBottom.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var MarginBottom, _Length,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Length = require('./_Length');
|
||||
|
||||
module.exports = MarginBottom = (function(superClass) {
|
||||
extend(MarginBottom, superClass);
|
||||
|
||||
function MarginBottom() {
|
||||
return MarginBottom.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return MarginBottom;
|
||||
|
||||
})(_Length);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/MarginLeft.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/MarginLeft.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var MarginLeft, _Length,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Length = require('./_Length');
|
||||
|
||||
module.exports = MarginLeft = (function(superClass) {
|
||||
extend(MarginLeft, superClass);
|
||||
|
||||
function MarginLeft() {
|
||||
return MarginLeft.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return MarginLeft;
|
||||
|
||||
})(_Length);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/MarginRight.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/MarginRight.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var MarginRight, _Length,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Length = require('./_Length');
|
||||
|
||||
module.exports = MarginRight = (function(superClass) {
|
||||
extend(MarginRight, superClass);
|
||||
|
||||
function MarginRight() {
|
||||
return MarginRight.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return MarginRight;
|
||||
|
||||
})(_Length);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/MarginTop.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/MarginTop.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var MarginTop, _Length,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Length = require('./_Length');
|
||||
|
||||
module.exports = MarginTop = (function(superClass) {
|
||||
extend(MarginTop, superClass);
|
||||
|
||||
function MarginTop() {
|
||||
return MarginTop.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return MarginTop;
|
||||
|
||||
})(_Length);
|
||||
64
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Padding.js
generated
vendored
Normal file
64
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Padding.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var Padding, PaddingBottom, PaddingLeft, PaddingRight, PaddingTop, _Declaration,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Declaration = require('./_Declaration');
|
||||
|
||||
PaddingTop = require('./PaddingTop');
|
||||
|
||||
PaddingLeft = require('./PaddingLeft');
|
||||
|
||||
PaddingRight = require('./PaddingRight');
|
||||
|
||||
PaddingBottom = require('./PaddingBottom');
|
||||
|
||||
module.exports = Padding = (function(superClass) {
|
||||
var self;
|
||||
|
||||
extend(Padding, superClass);
|
||||
|
||||
function Padding() {
|
||||
return Padding.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
self = Padding;
|
||||
|
||||
Padding.setOnto = function(declarations, prop, originalValue) {
|
||||
var append, val, vals;
|
||||
append = '';
|
||||
val = _Declaration.sanitizeValue(originalValue);
|
||||
if (_Declaration.importantClauseRx.test(String(val))) {
|
||||
append = ' !important';
|
||||
val = val.replace(_Declaration.importantClauseRx, '');
|
||||
}
|
||||
val = val.trim();
|
||||
if (val.length === 0) {
|
||||
return self._setAllDirections(declarations, append, append, append, append);
|
||||
}
|
||||
vals = val.split(" ").map(function(val) {
|
||||
return val + append;
|
||||
});
|
||||
if (vals.length === 1) {
|
||||
return self._setAllDirections(declarations, vals[0], vals[0], vals[0], vals[0]);
|
||||
} else if (vals.length === 2) {
|
||||
return self._setAllDirections(declarations, vals[0], vals[1], vals[0], vals[1]);
|
||||
} else if (vals.length === 3) {
|
||||
return self._setAllDirections(declarations, vals[0], vals[1], vals[2], vals[1]);
|
||||
} else if (vals.length === 4) {
|
||||
return self._setAllDirections(declarations, vals[0], vals[1], vals[2], vals[3]);
|
||||
} else {
|
||||
throw Error("Can't understand value for padding: `" + originalValue + "`");
|
||||
}
|
||||
};
|
||||
|
||||
Padding._setAllDirections = function(declarations, top, right, bottom, left) {
|
||||
PaddingTop.setOnto(declarations, 'paddingTop', top);
|
||||
PaddingTop.setOnto(declarations, 'paddingRight', right);
|
||||
PaddingTop.setOnto(declarations, 'paddingBottom', bottom);
|
||||
PaddingTop.setOnto(declarations, 'paddingLeft', left);
|
||||
};
|
||||
|
||||
return Padding;
|
||||
|
||||
})(_Declaration);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/PaddingBottom.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/PaddingBottom.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var PaddingBottom, _Length,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Length = require('./_Length');
|
||||
|
||||
module.exports = PaddingBottom = (function(superClass) {
|
||||
extend(PaddingBottom, superClass);
|
||||
|
||||
function PaddingBottom() {
|
||||
return PaddingBottom.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return PaddingBottom;
|
||||
|
||||
})(_Length);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/PaddingLeft.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/PaddingLeft.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var PaddingLeft, _Length,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Length = require('./_Length');
|
||||
|
||||
module.exports = PaddingLeft = (function(superClass) {
|
||||
extend(PaddingLeft, superClass);
|
||||
|
||||
function PaddingLeft() {
|
||||
return PaddingLeft.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return PaddingLeft;
|
||||
|
||||
})(_Length);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/PaddingRight.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/PaddingRight.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var PaddingRight, _Length,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Length = require('./_Length');
|
||||
|
||||
module.exports = PaddingRight = (function(superClass) {
|
||||
extend(PaddingRight, superClass);
|
||||
|
||||
function PaddingRight() {
|
||||
return PaddingRight.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return PaddingRight;
|
||||
|
||||
})(_Length);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/PaddingTop.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/PaddingTop.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var PaddingTop, _Length,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Length = require('./_Length');
|
||||
|
||||
module.exports = PaddingTop = (function(superClass) {
|
||||
extend(PaddingTop, superClass);
|
||||
|
||||
function PaddingTop() {
|
||||
return PaddingTop.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return PaddingTop;
|
||||
|
||||
})(_Length);
|
||||
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Width.js
generated
vendored
Normal file
17
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/Width.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var Width, _Length,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Length = require('./_Length');
|
||||
|
||||
module.exports = Width = (function(superClass) {
|
||||
extend(Width, superClass);
|
||||
|
||||
function Width() {
|
||||
return Width.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
return Width;
|
||||
|
||||
})(_Length);
|
||||
84
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/_Declaration.js
generated
vendored
Normal file
84
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/_Declaration.js
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var _Declaration;
|
||||
|
||||
module.exports = _Declaration = (function() {
|
||||
var self;
|
||||
|
||||
self = _Declaration;
|
||||
|
||||
_Declaration.importantClauseRx = /(\s\!important)$/;
|
||||
|
||||
_Declaration.setOnto = function(declarations, prop, val) {
|
||||
var dec;
|
||||
if (!(dec = declarations[prop])) {
|
||||
return declarations[prop] = new this(prop, val);
|
||||
} else {
|
||||
return dec.set(val);
|
||||
}
|
||||
};
|
||||
|
||||
_Declaration.sanitizeValue = function(val) {
|
||||
return String(val).trim().replace(/[\s]+/g, ' ');
|
||||
};
|
||||
|
||||
_Declaration.inheritAllowed = false;
|
||||
|
||||
function _Declaration(prop1, val) {
|
||||
this.prop = prop1;
|
||||
this.important = false;
|
||||
this.set(val);
|
||||
}
|
||||
|
||||
_Declaration.prototype.get = function() {
|
||||
return this._get();
|
||||
};
|
||||
|
||||
_Declaration.prototype._get = function() {
|
||||
return this.val;
|
||||
};
|
||||
|
||||
_Declaration.prototype._pickImportantClause = function(val) {
|
||||
if (self.importantClauseRx.test(String(val))) {
|
||||
this.important = true;
|
||||
return val.replace(self.importantClauseRx, '');
|
||||
} else {
|
||||
this.important = false;
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
_Declaration.prototype.set = function(val) {
|
||||
val = self.sanitizeValue(val);
|
||||
val = this._pickImportantClause(val);
|
||||
val = val.trim();
|
||||
if (this._handleNullOrInherit(val)) {
|
||||
return this;
|
||||
}
|
||||
this._set(val);
|
||||
return this;
|
||||
};
|
||||
|
||||
_Declaration.prototype._set = function(val) {
|
||||
return this.val = val;
|
||||
};
|
||||
|
||||
_Declaration.prototype._handleNullOrInherit = function(val) {
|
||||
if (val === '') {
|
||||
this.val = '';
|
||||
return true;
|
||||
}
|
||||
if (val === 'inherit') {
|
||||
if (this.constructor.inheritAllowed) {
|
||||
this.val = 'inherit';
|
||||
} else {
|
||||
throw Error("Inherit is not allowed for `" + this.prop + "`");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
return _Declaration;
|
||||
|
||||
})();
|
||||
24
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/_Length.js
generated
vendored
Normal file
24
node_modules/renderkid/lib/renderKid/styles/rule/declarationBlock/_Length.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
var _Declaration, _Length,
|
||||
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; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
_Declaration = require('./_Declaration');
|
||||
|
||||
module.exports = _Length = (function(superClass) {
|
||||
extend(_Length, superClass);
|
||||
|
||||
function _Length() {
|
||||
return _Length.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
_Length.prototype._set = function(val) {
|
||||
if (!/^[0-9]+$/.test(String(val))) {
|
||||
throw Error("`" + this.prop + "` only takes an integer for value");
|
||||
}
|
||||
return this.val = parseInt(val);
|
||||
};
|
||||
|
||||
return _Length;
|
||||
|
||||
})(_Declaration);
|
||||
Reference in New Issue
Block a user