a zip code crypto-currency system good for red ONLY

can-override.js 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. var understandable = require('./properties/understandable');
  2. function animationIterationCount(validator, value1, value2) {
  3. if (!understandable(validator, value1, value2, 0, true) && !(validator.isAnimationIterationCountKeyword(value2) || validator.isPositiveNumber(value2))) {
  4. return false;
  5. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  6. return true;
  7. }
  8. return validator.isAnimationIterationCountKeyword(value2) || validator.isPositiveNumber(value2);
  9. }
  10. function animationName(validator, value1, value2) {
  11. if (!understandable(validator, value1, value2, 0, true) && !(validator.isAnimationNameKeyword(value2) || validator.isIdentifier(value2))) {
  12. return false;
  13. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  14. return true;
  15. }
  16. return validator.isAnimationNameKeyword(value2) || validator.isIdentifier(value2);
  17. }
  18. function animationTimingFunction(validator, value1, value2) {
  19. if (!understandable(validator, value1, value2, 0, true) && !(validator.isAnimationTimingFunction(value2) || validator.isGlobal(value2))) {
  20. return false;
  21. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  22. return true;
  23. }
  24. return validator.isAnimationTimingFunction(value2) || validator.isGlobal(value2);
  25. }
  26. function areSameFunction(validator, value1, value2) {
  27. if (!validator.isFunction(value1) || !validator.isFunction(value2)) {
  28. return false;
  29. }
  30. var function1Name = value1.substring(0, value1.indexOf('('));
  31. var function2Name = value2.substring(0, value2.indexOf('('));
  32. return function1Name === function2Name;
  33. }
  34. function backgroundPosition(validator, value1, value2) {
  35. if (!understandable(validator, value1, value2, 0, true) && !(validator.isBackgroundPositionKeyword(value2) || validator.isGlobal(value2))) {
  36. return false;
  37. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  38. return true;
  39. } else if (validator.isBackgroundPositionKeyword(value2) || validator.isGlobal(value2)) {
  40. return true;
  41. }
  42. return unit(validator, value1, value2);
  43. }
  44. function backgroundSize(validator, value1, value2) {
  45. if (!understandable(validator, value1, value2, 0, true) && !(validator.isBackgroundSizeKeyword(value2) || validator.isGlobal(value2))) {
  46. return false;
  47. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  48. return true;
  49. } else if (validator.isBackgroundSizeKeyword(value2) || validator.isGlobal(value2)) {
  50. return true;
  51. }
  52. return unit(validator, value1, value2);
  53. }
  54. function color(validator, value1, value2) {
  55. if (!understandable(validator, value1, value2, 0, true) && !validator.isColor(value2)) {
  56. return false;
  57. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  58. return true;
  59. } else if (!validator.colorOpacity && (validator.isRgbColor(value1) || validator.isHslColor(value1))) {
  60. return false;
  61. } else if (!validator.colorOpacity && (validator.isRgbColor(value2) || validator.isHslColor(value2))) {
  62. return false;
  63. } else if (validator.isColor(value1) && validator.isColor(value2)) {
  64. return true;
  65. }
  66. return sameFunctionOrValue(validator, value1, value2);
  67. }
  68. function components(overrideCheckers) {
  69. return function (validator, value1, value2, position) {
  70. return overrideCheckers[position](validator, value1, value2);
  71. };
  72. }
  73. function fontFamily(validator, value1, value2) {
  74. return understandable(validator, value1, value2, 0, true);
  75. }
  76. function image(validator, value1, value2) {
  77. if (!understandable(validator, value1, value2, 0, true) && !validator.isImage(value2)) {
  78. return false;
  79. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  80. return true;
  81. } else if (validator.isImage(value2)) {
  82. return true;
  83. } else if (validator.isImage(value1)) {
  84. return false;
  85. }
  86. return sameFunctionOrValue(validator, value1, value2);
  87. }
  88. function keyword(propertyName) {
  89. return function(validator, value1, value2) {
  90. if (!understandable(validator, value1, value2, 0, true) && !validator.isKeyword(propertyName)(value2)) {
  91. return false;
  92. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  93. return true;
  94. }
  95. return validator.isKeyword(propertyName)(value2);
  96. };
  97. }
  98. function keywordWithGlobal(propertyName) {
  99. return function(validator, value1, value2) {
  100. if (!understandable(validator, value1, value2, 0, true) && !(validator.isKeyword(propertyName)(value2) || validator.isGlobal(value2))) {
  101. return false;
  102. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  103. return true;
  104. }
  105. return validator.isKeyword(propertyName)(value2) || validator.isGlobal(value2);
  106. };
  107. }
  108. function sameFunctionOrValue(validator, value1, value2) {
  109. return areSameFunction(validator, value1, value2) ?
  110. true :
  111. value1 === value2;
  112. }
  113. function textShadow(validator, value1, value2) {
  114. if (!understandable(validator, value1, value2, 0, true) && !(validator.isUnit(value2) || validator.isColor(value2) || validator.isGlobal(value2))) {
  115. return false;
  116. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  117. return true;
  118. }
  119. return validator.isUnit(value2) || validator.isColor(value2) || validator.isGlobal(value2);
  120. }
  121. function time(validator, value1, value2) {
  122. if (!understandable(validator, value1, value2, 0, true) && !validator.isTime(value2)) {
  123. return false;
  124. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  125. return true;
  126. } else if (validator.isTime(value1) && !validator.isTime(value2)) {
  127. return false;
  128. } else if (validator.isTime(value2)) {
  129. return true;
  130. } else if (validator.isTime(value1)) {
  131. return false;
  132. } else if (validator.isFunction(value1) && !validator.isPrefixed(value1) && validator.isFunction(value2) && !validator.isPrefixed(value2)) {
  133. return true;
  134. }
  135. return sameFunctionOrValue(validator, value1, value2);
  136. }
  137. function unit(validator, value1, value2) {
  138. if (!understandable(validator, value1, value2, 0, true) && !validator.isUnit(value2)) {
  139. return false;
  140. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  141. return true;
  142. } else if (validator.isUnit(value1) && !validator.isUnit(value2)) {
  143. return false;
  144. } else if (validator.isUnit(value2)) {
  145. return true;
  146. } else if (validator.isUnit(value1)) {
  147. return false;
  148. } else if (validator.isFunction(value1) && !validator.isPrefixed(value1) && validator.isFunction(value2) && !validator.isPrefixed(value2)) {
  149. return true;
  150. }
  151. return sameFunctionOrValue(validator, value1, value2);
  152. }
  153. function unitOrKeywordWithGlobal(propertyName) {
  154. var byKeyword = keywordWithGlobal(propertyName);
  155. return function(validator, value1, value2) {
  156. return unit(validator, value1, value2) || byKeyword(validator, value1, value2);
  157. };
  158. }
  159. function unitOrNumber(validator, value1, value2) {
  160. if (!understandable(validator, value1, value2, 0, true) && !(validator.isUnit(value2) || validator.isNumber(value2))) {
  161. return false;
  162. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  163. return true;
  164. } else if ((validator.isUnit(value1) || validator.isNumber(value1)) && !(validator.isUnit(value2) || validator.isNumber(value2))) {
  165. return false;
  166. } else if (validator.isUnit(value2) || validator.isNumber(value2)) {
  167. return true;
  168. } else if (validator.isUnit(value1) || validator.isNumber(value1)) {
  169. return false;
  170. } else if (validator.isFunction(value1) && !validator.isPrefixed(value1) && validator.isFunction(value2) && !validator.isPrefixed(value2)) {
  171. return true;
  172. }
  173. return sameFunctionOrValue(validator, value1, value2);
  174. }
  175. function zIndex(validator, value1, value2) {
  176. if (!understandable(validator, value1, value2, 0, true) && !validator.isZIndex(value2)) {
  177. return false;
  178. } else if (validator.isVariable(value1) && validator.isVariable(value2)) {
  179. return true;
  180. }
  181. return validator.isZIndex(value2);
  182. }
  183. module.exports = {
  184. generic: {
  185. color: color,
  186. components: components,
  187. image: image,
  188. time: time,
  189. unit: unit,
  190. unitOrNumber: unitOrNumber
  191. },
  192. property: {
  193. animationDirection: keywordWithGlobal('animation-direction'),
  194. animationFillMode: keyword('animation-fill-mode'),
  195. animationIterationCount: animationIterationCount,
  196. animationName: animationName,
  197. animationPlayState: keywordWithGlobal('animation-play-state'),
  198. animationTimingFunction: animationTimingFunction,
  199. backgroundAttachment: keyword('background-attachment'),
  200. backgroundClip: keywordWithGlobal('background-clip'),
  201. backgroundOrigin: keyword('background-origin'),
  202. backgroundPosition: backgroundPosition,
  203. backgroundRepeat: keyword('background-repeat'),
  204. backgroundSize: backgroundSize,
  205. bottom: unitOrKeywordWithGlobal('bottom'),
  206. borderCollapse: keyword('border-collapse'),
  207. borderStyle: keywordWithGlobal('*-style'),
  208. clear: keywordWithGlobal('clear'),
  209. cursor: keywordWithGlobal('cursor'),
  210. display: keywordWithGlobal('display'),
  211. float: keywordWithGlobal('float'),
  212. left: unitOrKeywordWithGlobal('left'),
  213. fontFamily: fontFamily,
  214. fontStretch: keywordWithGlobal('font-stretch'),
  215. fontStyle: keywordWithGlobal('font-style'),
  216. fontVariant: keywordWithGlobal('font-variant'),
  217. fontWeight: keywordWithGlobal('font-weight'),
  218. listStyleType: keywordWithGlobal('list-style-type'),
  219. listStylePosition: keywordWithGlobal('list-style-position'),
  220. outlineStyle: keywordWithGlobal('*-style'),
  221. overflow: keywordWithGlobal('overflow'),
  222. position: keywordWithGlobal('position'),
  223. right: unitOrKeywordWithGlobal('right'),
  224. textAlign: keywordWithGlobal('text-align'),
  225. textDecoration: keywordWithGlobal('text-decoration'),
  226. textOverflow: keywordWithGlobal('text-overflow'),
  227. textShadow: textShadow,
  228. top: unitOrKeywordWithGlobal('top'),
  229. transform: sameFunctionOrValue,
  230. verticalAlign: unitOrKeywordWithGlobal('vertical-align'),
  231. visibility: keywordWithGlobal('visibility'),
  232. whiteSpace: keywordWithGlobal('white-space'),
  233. zIndex: zIndex
  234. }
  235. };