[79a0317] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
---|
| 4 |
|
---|
| 5 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
---|
| 6 |
|
---|
| 7 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
---|
| 8 |
|
---|
| 9 | // Generated by CoffeeScript 2.5.1
|
---|
| 10 | var MixedDeclarationSet, StyleSheet, Styles, terminalWidth;
|
---|
| 11 | StyleSheet = require('./styles/StyleSheet');
|
---|
| 12 | MixedDeclarationSet = require('./styles/rule/MixedDeclarationSet');
|
---|
| 13 | terminalWidth = require('../tools').getCols();
|
---|
| 14 |
|
---|
| 15 | module.exports = Styles = function () {
|
---|
| 16 | var self;
|
---|
| 17 |
|
---|
| 18 | var Styles = /*#__PURE__*/function () {
|
---|
| 19 | function Styles() {
|
---|
| 20 | _classCallCheck(this, Styles);
|
---|
| 21 |
|
---|
| 22 | this._defaultStyles = new StyleSheet();
|
---|
| 23 | this._userStyles = new StyleSheet();
|
---|
| 24 |
|
---|
| 25 | this._setDefaultStyles();
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | _createClass(Styles, [{
|
---|
| 29 | key: "_setDefaultStyles",
|
---|
| 30 | value: function _setDefaultStyles() {
|
---|
| 31 | this._defaultStyles.setRule(self.defaultRules);
|
---|
| 32 | }
|
---|
| 33 | }, {
|
---|
| 34 | key: "setRule",
|
---|
| 35 | value: function setRule(selector, rules) {
|
---|
| 36 | this._userStyles.setRule.apply(this._userStyles, arguments);
|
---|
| 37 |
|
---|
| 38 | return this;
|
---|
| 39 | }
|
---|
| 40 | }, {
|
---|
| 41 | key: "getStyleFor",
|
---|
| 42 | value: function getStyleFor(el) {
|
---|
| 43 | var styles;
|
---|
| 44 | styles = el.styles;
|
---|
| 45 |
|
---|
| 46 | if (styles == null) {
|
---|
| 47 | el.styles = styles = this._getComputedStyleFor(el);
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | return styles;
|
---|
| 51 | }
|
---|
| 52 | }, {
|
---|
| 53 | key: "_getRawStyleFor",
|
---|
| 54 | value: function _getRawStyleFor(el) {
|
---|
| 55 | var def, user;
|
---|
| 56 | def = this._defaultStyles.getRulesFor(el);
|
---|
| 57 | user = this._userStyles.getRulesFor(el);
|
---|
| 58 | return MixedDeclarationSet.mix(def, user).toObject();
|
---|
| 59 | }
|
---|
| 60 | }, {
|
---|
| 61 | key: "_getComputedStyleFor",
|
---|
| 62 | value: function _getComputedStyleFor(el) {
|
---|
| 63 | var decs, parent, prop, ref, val;
|
---|
| 64 | decs = {};
|
---|
| 65 | parent = el.parent;
|
---|
| 66 | ref = this._getRawStyleFor(el);
|
---|
| 67 |
|
---|
| 68 | for (prop in ref) {
|
---|
| 69 | val = ref[prop];
|
---|
| 70 |
|
---|
| 71 | if (val !== 'inherit') {
|
---|
| 72 | decs[prop] = val;
|
---|
| 73 | } else {
|
---|
| 74 | throw Error("Inherited styles are not supported yet.");
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | return decs;
|
---|
| 79 | }
|
---|
| 80 | }]);
|
---|
| 81 |
|
---|
| 82 | return Styles;
|
---|
| 83 | }();
|
---|
| 84 |
|
---|
| 85 | ;
|
---|
| 86 | self = Styles;
|
---|
| 87 | Styles.defaultRules = {
|
---|
| 88 | '*': {
|
---|
| 89 | display: 'inline'
|
---|
| 90 | },
|
---|
| 91 | 'body': {
|
---|
| 92 | background: 'none',
|
---|
| 93 | color: 'white',
|
---|
| 94 | display: 'block',
|
---|
| 95 | width: terminalWidth + ' !important'
|
---|
| 96 | }
|
---|
| 97 | };
|
---|
| 98 | return Styles;
|
---|
| 99 | }.call(void 0); |
---|