va_common 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +4 -0
  4. data/CODE_OF_CONDUCT.md +13 -0
  5. data/Gemfile +4 -0
  6. data/README.md +66 -0
  7. data/Rakefile +1 -0
  8. data/app/assets/fonts/merriweather-bold-webfont.eot +0 -0
  9. data/app/assets/fonts/merriweather-bold-webfont.svg +294 -0
  10. data/app/assets/fonts/merriweather-bold-webfont.ttf +0 -0
  11. data/app/assets/fonts/merriweather-bold-webfont.woff +0 -0
  12. data/app/assets/fonts/merriweather-bold-webfont.woff2 +0 -0
  13. data/app/assets/fonts/merriweather-italic-webfont.eot +0 -0
  14. data/app/assets/fonts/merriweather-italic-webfont.svg +283 -0
  15. data/app/assets/fonts/merriweather-italic-webfont.ttf +0 -0
  16. data/app/assets/fonts/merriweather-italic-webfont.woff +0 -0
  17. data/app/assets/fonts/merriweather-italic-webfont.woff2 +0 -0
  18. data/app/assets/fonts/merriweather-light-webfont.eot +0 -0
  19. data/app/assets/fonts/merriweather-light-webfont.svg +299 -0
  20. data/app/assets/fonts/merriweather-light-webfont.ttf +0 -0
  21. data/app/assets/fonts/merriweather-light-webfont.woff +0 -0
  22. data/app/assets/fonts/merriweather-light-webfont.woff2 +0 -0
  23. data/app/assets/fonts/merriweather-regular-webfont.eot +0 -0
  24. data/app/assets/fonts/merriweather-regular-webfont.svg +294 -0
  25. data/app/assets/fonts/merriweather-regular-webfont.ttf +0 -0
  26. data/app/assets/fonts/merriweather-regular-webfont.woff +0 -0
  27. data/app/assets/fonts/merriweather-regular-webfont.woff2 +0 -0
  28. data/app/assets/fonts/sourcesanspro-bold-webfont.eot +0 -0
  29. data/app/assets/fonts/sourcesanspro-bold-webfont.svg +965 -0
  30. data/app/assets/fonts/sourcesanspro-bold-webfont.ttf +0 -0
  31. data/app/assets/fonts/sourcesanspro-bold-webfont.woff +0 -0
  32. data/app/assets/fonts/sourcesanspro-bold-webfont.woff2 +0 -0
  33. data/app/assets/fonts/sourcesanspro-italic-webfont.eot +0 -0
  34. data/app/assets/fonts/sourcesanspro-italic-webfont.svg +853 -0
  35. data/app/assets/fonts/sourcesanspro-italic-webfont.ttf +0 -0
  36. data/app/assets/fonts/sourcesanspro-italic-webfont.woff +0 -0
  37. data/app/assets/fonts/sourcesanspro-italic-webfont.woff2 +0 -0
  38. data/app/assets/fonts/sourcesanspro-light-webfont.eot +0 -0
  39. data/app/assets/fonts/sourcesanspro-light-webfont.svg +915 -0
  40. data/app/assets/fonts/sourcesanspro-light-webfont.ttf +0 -0
  41. data/app/assets/fonts/sourcesanspro-light-webfont.woff +0 -0
  42. data/app/assets/fonts/sourcesanspro-light-webfont.woff2 +0 -0
  43. data/app/assets/fonts/sourcesanspro-regular-webfont.eot +0 -0
  44. data/app/assets/fonts/sourcesanspro-regular-webfont.svg +989 -0
  45. data/app/assets/fonts/sourcesanspro-regular-webfont.ttf +0 -0
  46. data/app/assets/fonts/sourcesanspro-regular-webfont.woff +0 -0
  47. data/app/assets/fonts/sourcesanspro-regular-webfont.woff2 +0 -0
  48. data/app/assets/images/design/background/thread.png +0 -0
  49. data/app/assets/images/design/logo/logo-alt-hover.png +0 -0
  50. data/app/assets/images/design/logo/logo-alt.png +0 -0
  51. data/app/assets/images/design/logo/logo-hover.png +0 -0
  52. data/app/assets/images/design/logo/logo-small.png +0 -0
  53. data/app/assets/images/design/logo/logo.png +0 -0
  54. data/app/assets/images/design/logo/og-image.jpg +0 -0
  55. data/app/assets/images/design/seal/seal-footer.png +0 -0
  56. data/app/assets/images/design/seal/seal-footer.svg +1 -0
  57. data/app/assets/images/design/seal/seal.png +0 -0
  58. data/app/assets/images/design/seal/stars.png +0 -0
  59. data/app/assets/images/icons/apple-touch-icon-114x114.png +0 -0
  60. data/app/assets/images/icons/apple-touch-icon-152x152.png +0 -0
  61. data/app/assets/images/icons/apple-touch-icon-72x72.png +0 -0
  62. data/app/assets/images/icons/apple-touch-icon.png +0 -0
  63. data/app/assets/images/icons/favicon.ico +0 -0
  64. data/app/assets/images/icons/va.png +0 -0
  65. data/app/assets/images/icons/watermark.png +0 -0
  66. data/app/assets/images/icons/wrench.png +0 -0
  67. data/app/assets/images/social-icons/png/facebook25.png +0 -0
  68. data/app/assets/images/social-icons/png/rss25.png +0 -0
  69. data/app/assets/images/social-icons/png/twitter16.png +0 -0
  70. data/app/assets/images/social-icons/png/youtube15.png +0 -0
  71. data/app/assets/images/social-icons/svg/facebook25.svg +11 -0
  72. data/app/assets/images/social-icons/svg/rss25.svg +1 -0
  73. data/app/assets/images/social-icons/svg/twitter16.svg +15 -0
  74. data/app/assets/images/social-icons/svg/youtube15.svg +1 -0
  75. data/app/assets/js/components.js +376 -0
  76. data/app/assets/js/foundation/foundation.abide.js +408 -0
  77. data/app/assets/js/foundation/foundation.accordion.js +88 -0
  78. data/app/assets/js/foundation/foundation.alert.js +43 -0
  79. data/app/assets/js/foundation/foundation.clearing.js +586 -0
  80. data/app/assets/js/foundation/foundation.dropdown.js +463 -0
  81. data/app/assets/js/foundation/foundation.equalizer.js +104 -0
  82. data/app/assets/js/foundation/foundation.interchange.js +359 -0
  83. data/app/assets/js/foundation/foundation.joyride.js +932 -0
  84. data/app/assets/js/foundation/foundation.js +725 -0
  85. data/app/assets/js/foundation/foundation.magellan.js +215 -0
  86. data/app/assets/js/foundation/foundation.offcanvas.js +152 -0
  87. data/app/assets/js/foundation/foundation.orbit.js +476 -0
  88. data/app/assets/js/foundation/foundation.reveal.js +498 -0
  89. data/app/assets/js/foundation/foundation.slider.js +281 -0
  90. data/app/assets/js/foundation/foundation.tab.js +249 -0
  91. data/app/assets/js/foundation/foundation.tooltip.js +339 -0
  92. data/app/assets/js/foundation/foundation.topbar.js +458 -0
  93. data/app/assets/js/foundation.min.js +6376 -0
  94. data/app/assets/js/scripts-no-touch.js +33 -0
  95. data/app/assets/js/scripts-touch.js +33 -0
  96. data/app/assets/js/va_common_main.js +1 -0
  97. data/app/assets/js/vendor/classie.js +80 -0
  98. data/app/assets/js/vendor/html5shiv.js +8 -0
  99. data/app/assets/js/vendor/jquery-1.11.0.min.js +4 -0
  100. data/app/assets/js/vendor/jquery.js +9789 -0
  101. data/app/assets/js/vendor/jquery.smooth-scroll.js +255 -0
  102. data/app/assets/js/vendor/jquery.stellar.js +651 -0
  103. data/app/assets/js/vendor/jquery.tipsy.js +258 -0
  104. data/app/assets/js/vendor/menu.js +40 -0
  105. data/app/assets/js/vendor/modernizr.custom.js +4 -0
  106. data/app/assets/js/vendor/nwmatcher-1.2.5-min.js +7 -0
  107. data/app/assets/js/vendor/respond.min.js +6 -0
  108. data/app/assets/js/vendor/scroll-settings.js +3 -0
  109. data/app/assets/js/vendor/selectivizr-1.0.3b.js +560 -0
  110. data/app/assets/js/vendor/stellar-settings.js +8 -0
  111. data/app/assets/js/vendor/svg-injector.js +450 -0
  112. data/app/assets/js/vendor/tota11y.min.js +28 -0
  113. data/app/assets/js/vendor/wow.min.js +2 -0
  114. data/app/assets/stylesheets/_va.scss +2377 -0
  115. data/app/assets/stylesheets/components/_accordions.scss +98 -0
  116. data/app/assets/stylesheets/core/_base.scss +20 -0
  117. data/app/assets/stylesheets/core/_defaults.scss +92 -0
  118. data/app/assets/stylesheets/core/_grid-settings.scss +10 -0
  119. data/app/assets/stylesheets/core/_grid.scss +116 -0
  120. data/app/assets/stylesheets/core/_utilities.scss +105 -0
  121. data/app/assets/stylesheets/core/_variables.scss +88 -0
  122. data/app/assets/stylesheets/elements/_buttons.scss +189 -0
  123. data/app/assets/stylesheets/elements/_figure.scss +9 -0
  124. data/app/assets/stylesheets/elements/_inputs.scss +328 -0
  125. data/app/assets/stylesheets/elements/_labels.scss +39 -0
  126. data/app/assets/stylesheets/elements/_list.scss +82 -0
  127. data/app/assets/stylesheets/elements/_table.scss +39 -0
  128. data/app/assets/stylesheets/elements/_typography.scss +220 -0
  129. data/app/assets/stylesheets/foundation/_functions.scss +146 -0
  130. data/app/assets/stylesheets/foundation/_settings.scss +1467 -0
  131. data/app/assets/stylesheets/foundation/_variables.scss +1286 -0
  132. data/app/assets/stylesheets/foundation/components/_accordion.scss +157 -0
  133. data/app/assets/stylesheets/foundation/components/_alert-boxes.scss +128 -0
  134. data/app/assets/stylesheets/foundation/components/_block-grid.scss +132 -0
  135. data/app/assets/stylesheets/foundation/components/_breadcrumbs.scss +132 -0
  136. data/app/assets/stylesheets/foundation/components/_button-groups.scss +200 -0
  137. data/app/assets/stylesheets/foundation/components/_buttons.scss +259 -0
  138. data/app/assets/stylesheets/foundation/components/_clearing.scss +256 -0
  139. data/app/assets/stylesheets/foundation/components/_dropdown-buttons.scss +131 -0
  140. data/app/assets/stylesheets/foundation/components/_dropdown.scss +262 -0
  141. data/app/assets/stylesheets/foundation/components/_flex-video.scss +51 -0
  142. data/app/assets/stylesheets/foundation/components/_forms.scss +570 -0
  143. data/app/assets/stylesheets/foundation/components/_global.scss +481 -0
  144. data/app/assets/stylesheets/foundation/components/_grid.scss +289 -0
  145. data/app/assets/stylesheets/foundation/components/_icon-bar.scss +358 -0
  146. data/app/assets/stylesheets/foundation/components/_inline-lists.scss +57 -0
  147. data/app/assets/stylesheets/foundation/components/_joyride.scss +222 -0
  148. data/app/assets/stylesheets/foundation/components/_keystrokes.scss +61 -0
  149. data/app/assets/stylesheets/foundation/components/_labels.scss +106 -0
  150. data/app/assets/stylesheets/foundation/components/_magellan.scss +34 -0
  151. data/app/assets/stylesheets/foundation/components/_offcanvas.scss +515 -0
  152. data/app/assets/stylesheets/foundation/components/_orbit.scss +368 -0
  153. data/app/assets/stylesheets/foundation/components/_pagination.scss +162 -0
  154. data/app/assets/stylesheets/foundation/components/_panels.scss +101 -0
  155. data/app/assets/stylesheets/foundation/components/_pricing-tables.scss +150 -0
  156. data/app/assets/stylesheets/foundation/components/_progress-bars.scss +79 -0
  157. data/app/assets/stylesheets/foundation/components/_range-slider.scss +169 -0
  158. data/app/assets/stylesheets/foundation/components/_reveal.scss +202 -0
  159. data/app/assets/stylesheets/foundation/components/_side-nav.scss +116 -0
  160. data/app/assets/stylesheets/foundation/components/_split-buttons.scss +199 -0
  161. data/app/assets/stylesheets/foundation/components/_sub-nav.scss +123 -0
  162. data/app/assets/stylesheets/foundation/components/_switches.scss +238 -0
  163. data/app/assets/stylesheets/foundation/components/_tables.scss +135 -0
  164. data/app/assets/stylesheets/foundation/components/_tabs.scss +123 -0
  165. data/app/assets/stylesheets/foundation/components/_thumbs.scss +66 -0
  166. data/app/assets/stylesheets/foundation/components/_toolbar.scss +70 -0
  167. data/app/assets/stylesheets/foundation/components/_tooltips.scss +142 -0
  168. data/app/assets/stylesheets/foundation/components/_top-bar.scss +691 -0
  169. data/app/assets/stylesheets/foundation/components/_type.scss +525 -0
  170. data/app/assets/stylesheets/foundation/components/_visibility.scss +408 -0
  171. data/app/assets/stylesheets/functions/_new-breakpoint.scss +49 -0
  172. data/app/assets/stylesheets/functions/_private.scss +114 -0
  173. data/app/assets/stylesheets/lib/_normalize.scss +427 -0
  174. data/app/assets/stylesheets/lib/bourbon/_bourbon-deprecated-upcoming.scss +411 -0
  175. data/app/assets/stylesheets/lib/bourbon/_bourbon.scss +87 -0
  176. data/app/assets/stylesheets/lib/bourbon/addons/_border-color.scss +26 -0
  177. data/app/assets/stylesheets/lib/bourbon/addons/_border-radius.scss +48 -0
  178. data/app/assets/stylesheets/lib/bourbon/addons/_border-style.scss +25 -0
  179. data/app/assets/stylesheets/lib/bourbon/addons/_border-width.scss +25 -0
  180. data/app/assets/stylesheets/lib/bourbon/addons/_buttons.scss +64 -0
  181. data/app/assets/stylesheets/lib/bourbon/addons/_clearfix.scss +25 -0
  182. data/app/assets/stylesheets/lib/bourbon/addons/_ellipsis.scss +30 -0
  183. data/app/assets/stylesheets/lib/bourbon/addons/_font-stacks.scss +31 -0
  184. data/app/assets/stylesheets/lib/bourbon/addons/_hide-text.scss +27 -0
  185. data/app/assets/stylesheets/lib/bourbon/addons/_margin.scss +26 -0
  186. data/app/assets/stylesheets/lib/bourbon/addons/_padding.scss +26 -0
  187. data/app/assets/stylesheets/lib/bourbon/addons/_position.scss +48 -0
  188. data/app/assets/stylesheets/lib/bourbon/addons/_prefixer.scss +66 -0
  189. data/app/assets/stylesheets/lib/bourbon/addons/_retina-image.scss +25 -0
  190. data/app/assets/stylesheets/lib/bourbon/addons/_size.scss +51 -0
  191. data/app/assets/stylesheets/lib/bourbon/addons/_text-inputs.scss +112 -0
  192. data/app/assets/stylesheets/lib/bourbon/addons/_timing-functions.scss +34 -0
  193. data/app/assets/stylesheets/lib/bourbon/addons/_triangle.scss +63 -0
  194. data/app/assets/stylesheets/lib/bourbon/addons/_word-wrap.scss +29 -0
  195. data/app/assets/stylesheets/lib/bourbon/css3/_animation.scss +43 -0
  196. data/app/assets/stylesheets/lib/bourbon/css3/_appearance.scss +3 -0
  197. data/app/assets/stylesheets/lib/bourbon/css3/_backface-visibility.scss +3 -0
  198. data/app/assets/stylesheets/lib/bourbon/css3/_background-image.scss +42 -0
  199. data/app/assets/stylesheets/lib/bourbon/css3/_background.scss +55 -0
  200. data/app/assets/stylesheets/lib/bourbon/css3/_border-image.scss +59 -0
  201. data/app/assets/stylesheets/lib/bourbon/css3/_calc.scss +4 -0
  202. data/app/assets/stylesheets/lib/bourbon/css3/_columns.scss +47 -0
  203. data/app/assets/stylesheets/lib/bourbon/css3/_filter.scss +4 -0
  204. data/app/assets/stylesheets/lib/bourbon/css3/_flex-box.scss +287 -0
  205. data/app/assets/stylesheets/lib/bourbon/css3/_font-face.scss +24 -0
  206. data/app/assets/stylesheets/lib/bourbon/css3/_font-feature-settings.scss +4 -0
  207. data/app/assets/stylesheets/lib/bourbon/css3/_hidpi-media-query.scss +10 -0
  208. data/app/assets/stylesheets/lib/bourbon/css3/_hyphens.scss +4 -0
  209. data/app/assets/stylesheets/lib/bourbon/css3/_image-rendering.scss +14 -0
  210. data/app/assets/stylesheets/lib/bourbon/css3/_keyframes.scss +36 -0
  211. data/app/assets/stylesheets/lib/bourbon/css3/_linear-gradient.scss +38 -0
  212. data/app/assets/stylesheets/lib/bourbon/css3/_perspective.scss +8 -0
  213. data/app/assets/stylesheets/lib/bourbon/css3/_placeholder.scss +8 -0
  214. data/app/assets/stylesheets/lib/bourbon/css3/_radial-gradient.scss +39 -0
  215. data/app/assets/stylesheets/lib/bourbon/css3/_selection.scss +42 -0
  216. data/app/assets/stylesheets/lib/bourbon/css3/_text-decoration.scss +19 -0
  217. data/app/assets/stylesheets/lib/bourbon/css3/_transform.scss +15 -0
  218. data/app/assets/stylesheets/lib/bourbon/css3/_transition.scss +71 -0
  219. data/app/assets/stylesheets/lib/bourbon/css3/_user-select.scss +3 -0
  220. data/app/assets/stylesheets/lib/bourbon/functions/_assign-inputs.scss +11 -0
  221. data/app/assets/stylesheets/lib/bourbon/functions/_contains-falsy.scss +20 -0
  222. data/app/assets/stylesheets/lib/bourbon/functions/_contains.scss +26 -0
  223. data/app/assets/stylesheets/lib/bourbon/functions/_is-length.scss +11 -0
  224. data/app/assets/stylesheets/lib/bourbon/functions/_is-light.scss +21 -0
  225. data/app/assets/stylesheets/lib/bourbon/functions/_is-number.scss +11 -0
  226. data/app/assets/stylesheets/lib/bourbon/functions/_is-size.scss +13 -0
  227. data/app/assets/stylesheets/lib/bourbon/functions/_modular-scale.scss +69 -0
  228. data/app/assets/stylesheets/lib/bourbon/functions/_px-to-em.scss +13 -0
  229. data/app/assets/stylesheets/lib/bourbon/functions/_px-to-rem.scss +15 -0
  230. data/app/assets/stylesheets/lib/bourbon/functions/_shade.scss +24 -0
  231. data/app/assets/stylesheets/lib/bourbon/functions/_strip-units.scss +17 -0
  232. data/app/assets/stylesheets/lib/bourbon/functions/_tint.scss +24 -0
  233. data/app/assets/stylesheets/lib/bourbon/functions/_transition-property-name.scss +22 -0
  234. data/app/assets/stylesheets/lib/bourbon/functions/_unpack.scss +27 -0
  235. data/app/assets/stylesheets/lib/bourbon/helpers/_convert-units.scss +21 -0
  236. data/app/assets/stylesheets/lib/bourbon/helpers/_directional-values.scss +96 -0
  237. data/app/assets/stylesheets/lib/bourbon/helpers/_font-source-declaration.scss +43 -0
  238. data/app/assets/stylesheets/lib/bourbon/helpers/_gradient-positions-parser.scss +13 -0
  239. data/app/assets/stylesheets/lib/bourbon/helpers/_linear-angle-parser.scss +25 -0
  240. data/app/assets/stylesheets/lib/bourbon/helpers/_linear-gradient-parser.scss +41 -0
  241. data/app/assets/stylesheets/lib/bourbon/helpers/_linear-positions-parser.scss +61 -0
  242. data/app/assets/stylesheets/lib/bourbon/helpers/_linear-side-corner-parser.scss +31 -0
  243. data/app/assets/stylesheets/lib/bourbon/helpers/_radial-arg-parser.scss +69 -0
  244. data/app/assets/stylesheets/lib/bourbon/helpers/_radial-gradient-parser.scss +50 -0
  245. data/app/assets/stylesheets/lib/bourbon/helpers/_radial-positions-parser.scss +18 -0
  246. data/app/assets/stylesheets/lib/bourbon/helpers/_render-gradients.scss +26 -0
  247. data/app/assets/stylesheets/lib/bourbon/helpers/_shape-size-stripper.scss +10 -0
  248. data/app/assets/stylesheets/lib/bourbon/helpers/_str-to-num.scss +50 -0
  249. data/app/assets/stylesheets/lib/bourbon/settings/_asset-pipeline.scss +7 -0
  250. data/app/assets/stylesheets/lib/bourbon/settings/_prefixer.scss +9 -0
  251. data/app/assets/stylesheets/lib/bourbon/settings/_px-to-em.scss +1 -0
  252. data/app/assets/stylesheets/lib/neat/_neat-helpers.scss +8 -0
  253. data/app/assets/stylesheets/lib/neat/_neat.scss +23 -0
  254. data/app/assets/stylesheets/lib/neat/functions/_new-breakpoint.scss +49 -0
  255. data/app/assets/stylesheets/lib/neat/functions/_private.scss +114 -0
  256. data/app/assets/stylesheets/lib/neat/grid/_box-sizing.scss +15 -0
  257. data/app/assets/stylesheets/lib/neat/grid/_direction-context.scss +33 -0
  258. data/app/assets/stylesheets/lib/neat/grid/_display-context.scss +28 -0
  259. data/app/assets/stylesheets/lib/neat/grid/_fill-parent.scss +22 -0
  260. data/app/assets/stylesheets/lib/neat/grid/_media.scss +92 -0
  261. data/app/assets/stylesheets/lib/neat/grid/_omega.scss +87 -0
  262. data/app/assets/stylesheets/lib/neat/grid/_outer-container.scss +38 -0
  263. data/app/assets/stylesheets/lib/neat/grid/_pad.scss +25 -0
  264. data/app/assets/stylesheets/lib/neat/grid/_private.scss +35 -0
  265. data/app/assets/stylesheets/lib/neat/grid/_row.scss +52 -0
  266. data/app/assets/stylesheets/lib/neat/grid/_shift.scss +50 -0
  267. data/app/assets/stylesheets/lib/neat/grid/_span-columns.scss +94 -0
  268. data/app/assets/stylesheets/lib/neat/grid/_to-deprecate.scss +97 -0
  269. data/app/assets/stylesheets/lib/neat/grid/_visual-grid.scss +42 -0
  270. data/app/assets/stylesheets/lib/neat/settings/_disable-warnings.scss +13 -0
  271. data/app/assets/stylesheets/lib/neat/settings/_grid.scss +51 -0
  272. data/app/assets/stylesheets/lib/neat/settings/_visual-grid.scss +27 -0
  273. data/app/assets/stylesheets/va_common_main.css.scss +18 -0
  274. data/bin/console +14 -0
  275. data/bin/setup +7 -0
  276. data/lib/generators/files/_footer.html.erb +89 -0
  277. data/lib/generators/files/_header.html.erb +7 -0
  278. data/lib/generators/va_common_generator.rb +6 -0
  279. data/lib/generators/va_footer_generator.rb +7 -0
  280. data/lib/generators/va_header_generator.rb +7 -0
  281. data/lib/va_common/engine.rb +4 -0
  282. data/lib/va_common/version.rb +3 -0
  283. data/lib/va_common.rb +2 -0
  284. data/va_common.gemspec +22 -0
  285. metadata +354 -0
@@ -0,0 +1,450 @@
1
+ /**
2
+ * SVGInjector v1.1.3-RC - Fast, caching, dynamic inline SVG DOM injection library
3
+ * https://github.com/iconic/SVGInjector
4
+ *
5
+ * Copyright (c) 2014 Waybury <hello@waybury.com>
6
+ * @license MIT
7
+ */
8
+
9
+ (function (window, document) {
10
+
11
+ 'use strict';
12
+
13
+ // Environment
14
+ var isLocal = window.location.protocol === 'file:';
15
+ var hasSvgSupport = document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1');
16
+
17
+ function uniqueClasses(list) {
18
+ list = list.split(' ');
19
+
20
+ var hash = {};
21
+ var i = list.length;
22
+ var out = [];
23
+
24
+ while (i--) {
25
+ if (!hash.hasOwnProperty(list[i])) {
26
+ hash[list[i]] = 1;
27
+ out.unshift(list[i]);
28
+ }
29
+ }
30
+
31
+ return out.join(' ');
32
+ }
33
+
34
+ /**
35
+ * cache (or polyfill for <= IE8) Array.forEach()
36
+ * source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
37
+ */
38
+ var forEach = Array.prototype.forEach || function (fn, scope) {
39
+ if (this === void 0 || this === null || typeof fn !== 'function') {
40
+ throw new TypeError();
41
+ }
42
+
43
+ /* jshint bitwise: false */
44
+ var i, len = this.length >>> 0;
45
+ /* jshint bitwise: true */
46
+
47
+ for (i = 0; i < len; ++i) {
48
+ if (i in this) {
49
+ fn.call(scope, this[i], i, this);
50
+ }
51
+ }
52
+ };
53
+
54
+ // SVG Cache
55
+ var svgCache = {};
56
+
57
+ var injectCount = 0;
58
+ var injectedElements = [];
59
+
60
+ // Request Queue
61
+ var requestQueue = [];
62
+
63
+ // Script running status
64
+ var ranScripts = {};
65
+
66
+ var cloneSvg = function (sourceSvg) {
67
+ return sourceSvg.cloneNode(true);
68
+ };
69
+
70
+ var queueRequest = function (url, callback) {
71
+ requestQueue[url] = requestQueue[url] || [];
72
+ requestQueue[url].push(callback);
73
+ };
74
+
75
+ var processRequestQueue = function (url) {
76
+ for (var i = 0, len = requestQueue[url].length; i < len; i++) {
77
+ // Make these calls async so we avoid blocking the page/renderer
78
+ /* jshint loopfunc: true */
79
+ (function (index) {
80
+ setTimeout(function () {
81
+ requestQueue[url][index](cloneSvg(svgCache[url]));
82
+ }, 0);
83
+ })(i);
84
+ /* jshint loopfunc: false */
85
+ }
86
+ };
87
+
88
+ var loadSvg = function (url, callback) {
89
+ if (svgCache[url] !== undefined) {
90
+ if (svgCache[url] instanceof SVGSVGElement) {
91
+ // We already have it in cache, so use it
92
+ callback(cloneSvg(svgCache[url]));
93
+ }
94
+ else {
95
+ // We don't have it in cache yet, but we are loading it, so queue this request
96
+ queueRequest(url, callback);
97
+ }
98
+ }
99
+ else {
100
+
101
+ if (!window.XMLHttpRequest) {
102
+ callback('Browser does not support XMLHttpRequest');
103
+ return false;
104
+ }
105
+
106
+ // Seed the cache to indicate we are loading this URL already
107
+ svgCache[url] = {};
108
+ queueRequest(url, callback);
109
+
110
+ var httpRequest = new XMLHttpRequest();
111
+
112
+ httpRequest.onreadystatechange = function () {
113
+ // readyState 4 = complete
114
+ if (httpRequest.readyState === 4) {
115
+
116
+ // Handle status
117
+ if (httpRequest.status === 404 || httpRequest.responseXML === null) {
118
+ callback('Unable to load SVG file: ' + url);
119
+
120
+ if (isLocal) callback('Note: SVG injection ajax calls do not work locally without adjusting security setting in your browser. Or consider using a local webserver.');
121
+
122
+ callback();
123
+ return false;
124
+ }
125
+
126
+ // 200 success from server, or 0 when using file:// protocol locally
127
+ if (httpRequest.status === 200 || (isLocal && httpRequest.status === 0)) {
128
+
129
+ /* globals Document */
130
+ if (httpRequest.responseXML instanceof Document) {
131
+ // Cache it
132
+ svgCache[url] = httpRequest.responseXML.documentElement;
133
+ }
134
+ /* globals -Document */
135
+
136
+ // IE9 doesn't create a responseXML Document object from loaded SVG,
137
+ // and throws a "DOM Exception: HIERARCHY_REQUEST_ERR (3)" error when injected.
138
+ //
139
+ // So, we'll just create our own manually via the DOMParser using
140
+ // the the raw XML responseText.
141
+ //
142
+ // :NOTE: IE8 and older doesn't have DOMParser, but they can't do SVG either, so...
143
+ else if (DOMParser && (DOMParser instanceof Function)) {
144
+ var xmlDoc;
145
+ try {
146
+ var parser = new DOMParser();
147
+ xmlDoc = parser.parseFromString(httpRequest.responseText, 'text/xml');
148
+ }
149
+ catch (e) {
150
+ xmlDoc = undefined;
151
+ }
152
+
153
+ if (!xmlDoc || xmlDoc.getElementsByTagName('parsererror').length) {
154
+ callback('Unable to parse SVG file: ' + url);
155
+ return false;
156
+ }
157
+ else {
158
+ // Cache it
159
+ svgCache[url] = xmlDoc.documentElement;
160
+ }
161
+ }
162
+
163
+ // We've loaded a new asset, so process any requests waiting for it
164
+ processRequestQueue(url);
165
+ }
166
+ else {
167
+ callback('There was a problem injecting the SVG: ' + httpRequest.status + ' ' + httpRequest.statusText);
168
+ return false;
169
+ }
170
+ }
171
+ };
172
+
173
+ httpRequest.open('GET', url);
174
+
175
+ // Treat and parse the response as XML, even if the
176
+ // server sends us a different mimetype
177
+ if (httpRequest.overrideMimeType) httpRequest.overrideMimeType('text/xml');
178
+
179
+ httpRequest.send();
180
+ }
181
+ };
182
+
183
+ // Inject a single element
184
+ var injectElement = function (el, evalScripts, pngFallback, callback) {
185
+
186
+ // Grab the src or data-src attribute
187
+ var imgUrl = el.getAttribute('data-src') || el.getAttribute('src');
188
+
189
+ // We can only inject SVG
190
+ if (!(/\.svg/i).test(imgUrl)) {
191
+ callback('Attempted to inject a file with a non-svg extension: ' + imgUrl);
192
+ return;
193
+ }
194
+
195
+ // If we don't have SVG support try to fall back to a png,
196
+ // either defined per-element via data-fallback or data-png,
197
+ // or globally via the pngFallback directory setting
198
+ if (!hasSvgSupport) {
199
+ var perElementFallback = el.getAttribute('data-fallback') || el.getAttribute('data-png');
200
+
201
+ // Per-element specific PNG fallback defined, so use that
202
+ if (perElementFallback) {
203
+ el.setAttribute('src', perElementFallback);
204
+ callback(null);
205
+ }
206
+ // Global PNG fallback directoriy defined, use the same-named PNG
207
+ else if (pngFallback) {
208
+ el.setAttribute('src', pngFallback + '/' + imgUrl.split('/').pop().replace('.svg', '.png'));
209
+ callback(null);
210
+ }
211
+ // um...
212
+ else {
213
+ callback('This browser does not support SVG and no PNG fallback was defined.');
214
+ }
215
+
216
+ return;
217
+ }
218
+
219
+ // Make sure we aren't already in the process of injecting this element to
220
+ // avoid a race condition if multiple injections for the same element are run.
221
+ // :NOTE: Using indexOf() only _after_ we check for SVG support and bail,
222
+ // so no need for IE8 indexOf() polyfill
223
+ if (injectedElements.indexOf(el) !== -1) {
224
+ return;
225
+ }
226
+
227
+ // Remember the request to inject this element, in case other injection
228
+ // calls are also trying to replace this element before we finish
229
+ injectedElements.push(el);
230
+
231
+ // Try to avoid loading the orginal image src if possible.
232
+ el.setAttribute('src', '');
233
+
234
+ // Load it up
235
+ loadSvg(imgUrl, function (svg) {
236
+
237
+ if (typeof svg === 'undefined' || typeof svg === 'string') {
238
+ callback(svg);
239
+ return false;
240
+ }
241
+
242
+ var imgId = el.getAttribute('id');
243
+ if (imgId) {
244
+ svg.setAttribute('id', imgId);
245
+ }
246
+
247
+ var imgTitle = el.getAttribute('title');
248
+ if (imgTitle) {
249
+ svg.setAttribute('title', imgTitle);
250
+ }
251
+
252
+ // Concat the SVG classes + 'injected-svg' + the img classes
253
+ var classMerge = [].concat(svg.getAttribute('class') || [], 'injected-svg', el.getAttribute('class') || []).join(' ');
254
+ svg.setAttribute('class', uniqueClasses(classMerge));
255
+
256
+ var imgStyle = el.getAttribute('style');
257
+ if (imgStyle) {
258
+ svg.setAttribute('style', imgStyle);
259
+ }
260
+
261
+ // Copy all the data elements to the svg
262
+ var imgData = [].filter.call(el.attributes, function (at) {
263
+ return (/^data-\w[\w\-]*$/).test(at.name);
264
+ });
265
+ forEach.call(imgData, function (dataAttr) {
266
+ if (dataAttr.name && dataAttr.value) {
267
+ svg.setAttribute(dataAttr.name, dataAttr.value);
268
+ }
269
+ });
270
+
271
+ // Make sure any internally referenced clipPath ids and their
272
+ // clip-path references are unique.
273
+ //
274
+ // This addresses the issue of having multiple instances of the
275
+ // same SVG on a page and only the first clipPath id is referenced.
276
+ //
277
+ // Browsers often shortcut the SVG Spec and don't use clipPaths
278
+ // contained in parent elements that are hidden, so if you hide the first
279
+ // SVG instance on the page, then all other instances lose their clipping.
280
+ // Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=376027
281
+ var clipPaths = svg.querySelectorAll('defs clipPath[id]');
282
+ var newClipPathName;
283
+ for (var g = 0, clipPathsLen = clipPaths.length; g < clipPathsLen; g++) {
284
+ newClipPathName = clipPaths[g].id + '-' + injectCount;
285
+ // :NOTE: using a substring match attr selector here to deal with IE "adding extra quotes in url() attrs"
286
+ var usingClipPath = svg.querySelectorAll('[clip-path*="' + clipPaths[g].id + '"]');
287
+ for (var h = 0, usingClipPathLen = usingClipPath.length; h < usingClipPathLen; h++) {
288
+ usingClipPath[h].setAttribute('clip-path', 'url(#' + newClipPathName + ')');
289
+ }
290
+ clipPaths[g].id = newClipPathName;
291
+ }
292
+
293
+ // Do the same for masks
294
+ var masks = svg.querySelectorAll('defs mask[id]');
295
+ var newMaskName;
296
+ for (var i = 0, masksLen = masks.length; i < masksLen; i++) {
297
+ newMaskName = masks[i].id + '-' + injectCount;
298
+ // :NOTE: using a substring match attr selector here to deal with IE "adding extra quotes in url() attrs"
299
+ var usingMask = svg.querySelectorAll('[mask*="' + masks[i].id + '"]');
300
+ for (var j = 0, usingMaskLen = usingMask.length; j < usingMaskLen; j++) {
301
+ usingMask[j].setAttribute('mask', 'url(#' + newMaskName + ')');
302
+ }
303
+ masks[i].id = newMaskName;
304
+ }
305
+
306
+ // Remove any unwanted/invalid namespaces that might have been added by SVG editing tools
307
+ svg.removeAttribute('xmlns:a');
308
+
309
+ // Post page load injected SVGs don't automatically have their script
310
+ // elements run, so we'll need to make that happen, if requested
311
+
312
+ // Find then prune the scripts
313
+ var scripts = svg.querySelectorAll('script');
314
+ var scriptsToEval = [];
315
+ var script, scriptType;
316
+
317
+ for (var k = 0, scriptsLen = scripts.length; k < scriptsLen; k++) {
318
+ scriptType = scripts[k].getAttribute('type');
319
+
320
+ // Only process javascript types.
321
+ // SVG defaults to 'application/ecmascript' for unset types
322
+ if (!scriptType || scriptType === 'application/ecmascript' || scriptType === 'application/javascript') {
323
+
324
+ // innerText for IE, textContent for other browsers
325
+ script = scripts[k].innerText || scripts[k].textContent;
326
+
327
+ // Stash
328
+ scriptsToEval.push(script);
329
+
330
+ // Tidy up and remove the script element since we don't need it anymore
331
+ svg.removeChild(scripts[k]);
332
+ }
333
+ }
334
+
335
+ // Run/Eval the scripts if needed
336
+ if (scriptsToEval.length > 0 && (evalScripts === 'always' || (evalScripts === 'once' && !ranScripts[imgUrl]))) {
337
+ for (var l = 0, scriptsToEvalLen = scriptsToEval.length; l < scriptsToEvalLen; l++) {
338
+
339
+ // :NOTE: Yup, this is a form of eval, but it is being used to eval code
340
+ // the caller has explictely asked to be loaded, and the code is in a caller
341
+ // defined SVG file... not raw user input.
342
+ //
343
+ // Also, the code is evaluated in a closure and not in the global scope.
344
+ // If you need to put something in global scope, use 'window'
345
+ new Function(scriptsToEval[l])(window); // jshint ignore:line
346
+ }
347
+
348
+ // Remember we already ran scripts for this svg
349
+ ranScripts[imgUrl] = true;
350
+ }
351
+
352
+ // :WORKAROUND:
353
+ // IE doesn't evaluate <style> tags in SVGs that are dynamically added to the page.
354
+ // This trick will trigger IE to read and use any existing SVG <style> tags.
355
+ //
356
+ // Reference: https://github.com/iconic/SVGInjector/issues/23
357
+ var styleTags = svg.querySelectorAll('style');
358
+ forEach.call(styleTags, function (styleTag) {
359
+ styleTag.textContent += '';
360
+ });
361
+
362
+ // Replace the image with the svg
363
+ el.parentNode.replaceChild(svg, el);
364
+
365
+ // Now that we no longer need it, drop references
366
+ // to the original element so it can be GC'd
367
+ delete injectedElements[injectedElements.indexOf(el)];
368
+ el = null;
369
+
370
+ // Increment the injected count
371
+ injectCount++;
372
+
373
+ callback(svg);
374
+ });
375
+ };
376
+
377
+ /**
378
+ * SVGInjector
379
+ *
380
+ * Replace the given elements with their full inline SVG DOM elements.
381
+ *
382
+ * :NOTE: We are using get/setAttribute with SVG because the SVG DOM spec differs from HTML DOM and
383
+ * can return other unexpected object types when trying to directly access svg properties.
384
+ * ex: "className" returns a SVGAnimatedString with the class value found in the "baseVal" property,
385
+ * instead of simple string like with HTML Elements.
386
+ *
387
+ * @param {mixes} Array of or single DOM element
388
+ * @param {object} options
389
+ * @param {function} callback
390
+ * @return {object} Instance of SVGInjector
391
+ */
392
+ var SVGInjector = function (elements, options, done) {
393
+
394
+ // Options & defaults
395
+ options = options || {};
396
+
397
+ // Should we run the scripts blocks found in the SVG
398
+ // 'always' - Run them every time
399
+ // 'once' - Only run scripts once for each SVG
400
+ // [false|'never'] - Ignore scripts
401
+ var evalScripts = options.evalScripts || 'always';
402
+
403
+ // Location of fallback pngs, if desired
404
+ var pngFallback = options.pngFallback || false;
405
+
406
+ // Callback to run during each SVG injection, returning the SVG injected
407
+ var eachCallback = options.each;
408
+
409
+ // Do the injection...
410
+ if (elements.length !== undefined) {
411
+ var elementsLoaded = 0;
412
+ forEach.call(elements, function (element) {
413
+ injectElement(element, evalScripts, pngFallback, function (svg) {
414
+ if (eachCallback && typeof eachCallback === 'function') eachCallback(svg);
415
+ if (done && elements.length === ++elementsLoaded) done(elementsLoaded);
416
+ });
417
+ });
418
+ }
419
+ else {
420
+ if (elements) {
421
+ injectElement(elements, evalScripts, pngFallback, function (svg) {
422
+ if (eachCallback && typeof eachCallback === 'function') eachCallback(svg);
423
+ if (done) done(1);
424
+ elements = null;
425
+ });
426
+ }
427
+ else {
428
+ if (done) done(0);
429
+ }
430
+ }
431
+ };
432
+
433
+ /* global module, exports: true, define */
434
+ // Node.js or CommonJS
435
+ if (typeof module === 'object' && typeof module.exports === 'object') {
436
+ module.exports = exports = SVGInjector;
437
+ }
438
+ // AMD support
439
+ else if (typeof define === 'function' && define.amd) {
440
+ define(function () {
441
+ return SVGInjector;
442
+ });
443
+ }
444
+ // Otherwise, attach to window as global
445
+ else if (typeof window === 'object') {
446
+ window.SVGInjector = SVGInjector;
447
+ }
448
+ /* global -module, -exports, -define */
449
+
450
+ }(window, document));