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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/README.md +66 -0
- data/Rakefile +1 -0
- data/app/assets/fonts/merriweather-bold-webfont.eot +0 -0
- data/app/assets/fonts/merriweather-bold-webfont.svg +294 -0
- data/app/assets/fonts/merriweather-bold-webfont.ttf +0 -0
- data/app/assets/fonts/merriweather-bold-webfont.woff +0 -0
- data/app/assets/fonts/merriweather-bold-webfont.woff2 +0 -0
- data/app/assets/fonts/merriweather-italic-webfont.eot +0 -0
- data/app/assets/fonts/merriweather-italic-webfont.svg +283 -0
- data/app/assets/fonts/merriweather-italic-webfont.ttf +0 -0
- data/app/assets/fonts/merriweather-italic-webfont.woff +0 -0
- data/app/assets/fonts/merriweather-italic-webfont.woff2 +0 -0
- data/app/assets/fonts/merriweather-light-webfont.eot +0 -0
- data/app/assets/fonts/merriweather-light-webfont.svg +299 -0
- data/app/assets/fonts/merriweather-light-webfont.ttf +0 -0
- data/app/assets/fonts/merriweather-light-webfont.woff +0 -0
- data/app/assets/fonts/merriweather-light-webfont.woff2 +0 -0
- data/app/assets/fonts/merriweather-regular-webfont.eot +0 -0
- data/app/assets/fonts/merriweather-regular-webfont.svg +294 -0
- data/app/assets/fonts/merriweather-regular-webfont.ttf +0 -0
- data/app/assets/fonts/merriweather-regular-webfont.woff +0 -0
- data/app/assets/fonts/merriweather-regular-webfont.woff2 +0 -0
- data/app/assets/fonts/sourcesanspro-bold-webfont.eot +0 -0
- data/app/assets/fonts/sourcesanspro-bold-webfont.svg +965 -0
- data/app/assets/fonts/sourcesanspro-bold-webfont.ttf +0 -0
- data/app/assets/fonts/sourcesanspro-bold-webfont.woff +0 -0
- data/app/assets/fonts/sourcesanspro-bold-webfont.woff2 +0 -0
- data/app/assets/fonts/sourcesanspro-italic-webfont.eot +0 -0
- data/app/assets/fonts/sourcesanspro-italic-webfont.svg +853 -0
- data/app/assets/fonts/sourcesanspro-italic-webfont.ttf +0 -0
- data/app/assets/fonts/sourcesanspro-italic-webfont.woff +0 -0
- data/app/assets/fonts/sourcesanspro-italic-webfont.woff2 +0 -0
- data/app/assets/fonts/sourcesanspro-light-webfont.eot +0 -0
- data/app/assets/fonts/sourcesanspro-light-webfont.svg +915 -0
- data/app/assets/fonts/sourcesanspro-light-webfont.ttf +0 -0
- data/app/assets/fonts/sourcesanspro-light-webfont.woff +0 -0
- data/app/assets/fonts/sourcesanspro-light-webfont.woff2 +0 -0
- data/app/assets/fonts/sourcesanspro-regular-webfont.eot +0 -0
- data/app/assets/fonts/sourcesanspro-regular-webfont.svg +989 -0
- data/app/assets/fonts/sourcesanspro-regular-webfont.ttf +0 -0
- data/app/assets/fonts/sourcesanspro-regular-webfont.woff +0 -0
- data/app/assets/fonts/sourcesanspro-regular-webfont.woff2 +0 -0
- data/app/assets/images/design/background/thread.png +0 -0
- data/app/assets/images/design/logo/logo-alt-hover.png +0 -0
- data/app/assets/images/design/logo/logo-alt.png +0 -0
- data/app/assets/images/design/logo/logo-hover.png +0 -0
- data/app/assets/images/design/logo/logo-small.png +0 -0
- data/app/assets/images/design/logo/logo.png +0 -0
- data/app/assets/images/design/logo/og-image.jpg +0 -0
- data/app/assets/images/design/seal/seal-footer.png +0 -0
- data/app/assets/images/design/seal/seal-footer.svg +1 -0
- data/app/assets/images/design/seal/seal.png +0 -0
- data/app/assets/images/design/seal/stars.png +0 -0
- data/app/assets/images/icons/apple-touch-icon-114x114.png +0 -0
- data/app/assets/images/icons/apple-touch-icon-152x152.png +0 -0
- data/app/assets/images/icons/apple-touch-icon-72x72.png +0 -0
- data/app/assets/images/icons/apple-touch-icon.png +0 -0
- data/app/assets/images/icons/favicon.ico +0 -0
- data/app/assets/images/icons/va.png +0 -0
- data/app/assets/images/icons/watermark.png +0 -0
- data/app/assets/images/icons/wrench.png +0 -0
- data/app/assets/images/social-icons/png/facebook25.png +0 -0
- data/app/assets/images/social-icons/png/rss25.png +0 -0
- data/app/assets/images/social-icons/png/twitter16.png +0 -0
- data/app/assets/images/social-icons/png/youtube15.png +0 -0
- data/app/assets/images/social-icons/svg/facebook25.svg +11 -0
- data/app/assets/images/social-icons/svg/rss25.svg +1 -0
- data/app/assets/images/social-icons/svg/twitter16.svg +15 -0
- data/app/assets/images/social-icons/svg/youtube15.svg +1 -0
- data/app/assets/js/components.js +376 -0
- data/app/assets/js/foundation/foundation.abide.js +408 -0
- data/app/assets/js/foundation/foundation.accordion.js +88 -0
- data/app/assets/js/foundation/foundation.alert.js +43 -0
- data/app/assets/js/foundation/foundation.clearing.js +586 -0
- data/app/assets/js/foundation/foundation.dropdown.js +463 -0
- data/app/assets/js/foundation/foundation.equalizer.js +104 -0
- data/app/assets/js/foundation/foundation.interchange.js +359 -0
- data/app/assets/js/foundation/foundation.joyride.js +932 -0
- data/app/assets/js/foundation/foundation.js +725 -0
- data/app/assets/js/foundation/foundation.magellan.js +215 -0
- data/app/assets/js/foundation/foundation.offcanvas.js +152 -0
- data/app/assets/js/foundation/foundation.orbit.js +476 -0
- data/app/assets/js/foundation/foundation.reveal.js +498 -0
- data/app/assets/js/foundation/foundation.slider.js +281 -0
- data/app/assets/js/foundation/foundation.tab.js +249 -0
- data/app/assets/js/foundation/foundation.tooltip.js +339 -0
- data/app/assets/js/foundation/foundation.topbar.js +458 -0
- data/app/assets/js/foundation.min.js +6376 -0
- data/app/assets/js/scripts-no-touch.js +33 -0
- data/app/assets/js/scripts-touch.js +33 -0
- data/app/assets/js/va_common_main.js +1 -0
- data/app/assets/js/vendor/classie.js +80 -0
- data/app/assets/js/vendor/html5shiv.js +8 -0
- data/app/assets/js/vendor/jquery-1.11.0.min.js +4 -0
- data/app/assets/js/vendor/jquery.js +9789 -0
- data/app/assets/js/vendor/jquery.smooth-scroll.js +255 -0
- data/app/assets/js/vendor/jquery.stellar.js +651 -0
- data/app/assets/js/vendor/jquery.tipsy.js +258 -0
- data/app/assets/js/vendor/menu.js +40 -0
- data/app/assets/js/vendor/modernizr.custom.js +4 -0
- data/app/assets/js/vendor/nwmatcher-1.2.5-min.js +7 -0
- data/app/assets/js/vendor/respond.min.js +6 -0
- data/app/assets/js/vendor/scroll-settings.js +3 -0
- data/app/assets/js/vendor/selectivizr-1.0.3b.js +560 -0
- data/app/assets/js/vendor/stellar-settings.js +8 -0
- data/app/assets/js/vendor/svg-injector.js +450 -0
- data/app/assets/js/vendor/tota11y.min.js +28 -0
- data/app/assets/js/vendor/wow.min.js +2 -0
- data/app/assets/stylesheets/_va.scss +2377 -0
- data/app/assets/stylesheets/components/_accordions.scss +98 -0
- data/app/assets/stylesheets/core/_base.scss +20 -0
- data/app/assets/stylesheets/core/_defaults.scss +92 -0
- data/app/assets/stylesheets/core/_grid-settings.scss +10 -0
- data/app/assets/stylesheets/core/_grid.scss +116 -0
- data/app/assets/stylesheets/core/_utilities.scss +105 -0
- data/app/assets/stylesheets/core/_variables.scss +88 -0
- data/app/assets/stylesheets/elements/_buttons.scss +189 -0
- data/app/assets/stylesheets/elements/_figure.scss +9 -0
- data/app/assets/stylesheets/elements/_inputs.scss +328 -0
- data/app/assets/stylesheets/elements/_labels.scss +39 -0
- data/app/assets/stylesheets/elements/_list.scss +82 -0
- data/app/assets/stylesheets/elements/_table.scss +39 -0
- data/app/assets/stylesheets/elements/_typography.scss +220 -0
- data/app/assets/stylesheets/foundation/_functions.scss +146 -0
- data/app/assets/stylesheets/foundation/_settings.scss +1467 -0
- data/app/assets/stylesheets/foundation/_variables.scss +1286 -0
- data/app/assets/stylesheets/foundation/components/_accordion.scss +157 -0
- data/app/assets/stylesheets/foundation/components/_alert-boxes.scss +128 -0
- data/app/assets/stylesheets/foundation/components/_block-grid.scss +132 -0
- data/app/assets/stylesheets/foundation/components/_breadcrumbs.scss +132 -0
- data/app/assets/stylesheets/foundation/components/_button-groups.scss +200 -0
- data/app/assets/stylesheets/foundation/components/_buttons.scss +259 -0
- data/app/assets/stylesheets/foundation/components/_clearing.scss +256 -0
- data/app/assets/stylesheets/foundation/components/_dropdown-buttons.scss +131 -0
- data/app/assets/stylesheets/foundation/components/_dropdown.scss +262 -0
- data/app/assets/stylesheets/foundation/components/_flex-video.scss +51 -0
- data/app/assets/stylesheets/foundation/components/_forms.scss +570 -0
- data/app/assets/stylesheets/foundation/components/_global.scss +481 -0
- data/app/assets/stylesheets/foundation/components/_grid.scss +289 -0
- data/app/assets/stylesheets/foundation/components/_icon-bar.scss +358 -0
- data/app/assets/stylesheets/foundation/components/_inline-lists.scss +57 -0
- data/app/assets/stylesheets/foundation/components/_joyride.scss +222 -0
- data/app/assets/stylesheets/foundation/components/_keystrokes.scss +61 -0
- data/app/assets/stylesheets/foundation/components/_labels.scss +106 -0
- data/app/assets/stylesheets/foundation/components/_magellan.scss +34 -0
- data/app/assets/stylesheets/foundation/components/_offcanvas.scss +515 -0
- data/app/assets/stylesheets/foundation/components/_orbit.scss +368 -0
- data/app/assets/stylesheets/foundation/components/_pagination.scss +162 -0
- data/app/assets/stylesheets/foundation/components/_panels.scss +101 -0
- data/app/assets/stylesheets/foundation/components/_pricing-tables.scss +150 -0
- data/app/assets/stylesheets/foundation/components/_progress-bars.scss +79 -0
- data/app/assets/stylesheets/foundation/components/_range-slider.scss +169 -0
- data/app/assets/stylesheets/foundation/components/_reveal.scss +202 -0
- data/app/assets/stylesheets/foundation/components/_side-nav.scss +116 -0
- data/app/assets/stylesheets/foundation/components/_split-buttons.scss +199 -0
- data/app/assets/stylesheets/foundation/components/_sub-nav.scss +123 -0
- data/app/assets/stylesheets/foundation/components/_switches.scss +238 -0
- data/app/assets/stylesheets/foundation/components/_tables.scss +135 -0
- data/app/assets/stylesheets/foundation/components/_tabs.scss +123 -0
- data/app/assets/stylesheets/foundation/components/_thumbs.scss +66 -0
- data/app/assets/stylesheets/foundation/components/_toolbar.scss +70 -0
- data/app/assets/stylesheets/foundation/components/_tooltips.scss +142 -0
- data/app/assets/stylesheets/foundation/components/_top-bar.scss +691 -0
- data/app/assets/stylesheets/foundation/components/_type.scss +525 -0
- data/app/assets/stylesheets/foundation/components/_visibility.scss +408 -0
- data/app/assets/stylesheets/functions/_new-breakpoint.scss +49 -0
- data/app/assets/stylesheets/functions/_private.scss +114 -0
- data/app/assets/stylesheets/lib/_normalize.scss +427 -0
- data/app/assets/stylesheets/lib/bourbon/_bourbon-deprecated-upcoming.scss +411 -0
- data/app/assets/stylesheets/lib/bourbon/_bourbon.scss +87 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_border-color.scss +26 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_border-radius.scss +48 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_border-style.scss +25 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_border-width.scss +25 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_buttons.scss +64 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_clearfix.scss +25 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_ellipsis.scss +30 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_font-stacks.scss +31 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_hide-text.scss +27 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_margin.scss +26 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_padding.scss +26 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_position.scss +48 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_prefixer.scss +66 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_retina-image.scss +25 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_size.scss +51 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_text-inputs.scss +112 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_timing-functions.scss +34 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_triangle.scss +63 -0
- data/app/assets/stylesheets/lib/bourbon/addons/_word-wrap.scss +29 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_animation.scss +43 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_appearance.scss +3 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_backface-visibility.scss +3 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_background-image.scss +42 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_background.scss +55 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_border-image.scss +59 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_calc.scss +4 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_columns.scss +47 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_filter.scss +4 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_flex-box.scss +287 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_font-face.scss +24 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_font-feature-settings.scss +4 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_hidpi-media-query.scss +10 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_hyphens.scss +4 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_image-rendering.scss +14 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_keyframes.scss +36 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_linear-gradient.scss +38 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_perspective.scss +8 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_placeholder.scss +8 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_radial-gradient.scss +39 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_selection.scss +42 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_text-decoration.scss +19 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_transform.scss +15 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_transition.scss +71 -0
- data/app/assets/stylesheets/lib/bourbon/css3/_user-select.scss +3 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_assign-inputs.scss +11 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_contains-falsy.scss +20 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_contains.scss +26 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_is-length.scss +11 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_is-light.scss +21 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_is-number.scss +11 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_is-size.scss +13 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_modular-scale.scss +69 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_px-to-em.scss +13 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_px-to-rem.scss +15 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_shade.scss +24 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_strip-units.scss +17 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_tint.scss +24 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_transition-property-name.scss +22 -0
- data/app/assets/stylesheets/lib/bourbon/functions/_unpack.scss +27 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_convert-units.scss +21 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_directional-values.scss +96 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_font-source-declaration.scss +43 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_gradient-positions-parser.scss +13 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_linear-angle-parser.scss +25 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_linear-gradient-parser.scss +41 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_linear-positions-parser.scss +61 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_linear-side-corner-parser.scss +31 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_radial-arg-parser.scss +69 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_radial-gradient-parser.scss +50 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_radial-positions-parser.scss +18 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_render-gradients.scss +26 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_shape-size-stripper.scss +10 -0
- data/app/assets/stylesheets/lib/bourbon/helpers/_str-to-num.scss +50 -0
- data/app/assets/stylesheets/lib/bourbon/settings/_asset-pipeline.scss +7 -0
- data/app/assets/stylesheets/lib/bourbon/settings/_prefixer.scss +9 -0
- data/app/assets/stylesheets/lib/bourbon/settings/_px-to-em.scss +1 -0
- data/app/assets/stylesheets/lib/neat/_neat-helpers.scss +8 -0
- data/app/assets/stylesheets/lib/neat/_neat.scss +23 -0
- data/app/assets/stylesheets/lib/neat/functions/_new-breakpoint.scss +49 -0
- data/app/assets/stylesheets/lib/neat/functions/_private.scss +114 -0
- data/app/assets/stylesheets/lib/neat/grid/_box-sizing.scss +15 -0
- data/app/assets/stylesheets/lib/neat/grid/_direction-context.scss +33 -0
- data/app/assets/stylesheets/lib/neat/grid/_display-context.scss +28 -0
- data/app/assets/stylesheets/lib/neat/grid/_fill-parent.scss +22 -0
- data/app/assets/stylesheets/lib/neat/grid/_media.scss +92 -0
- data/app/assets/stylesheets/lib/neat/grid/_omega.scss +87 -0
- data/app/assets/stylesheets/lib/neat/grid/_outer-container.scss +38 -0
- data/app/assets/stylesheets/lib/neat/grid/_pad.scss +25 -0
- data/app/assets/stylesheets/lib/neat/grid/_private.scss +35 -0
- data/app/assets/stylesheets/lib/neat/grid/_row.scss +52 -0
- data/app/assets/stylesheets/lib/neat/grid/_shift.scss +50 -0
- data/app/assets/stylesheets/lib/neat/grid/_span-columns.scss +94 -0
- data/app/assets/stylesheets/lib/neat/grid/_to-deprecate.scss +97 -0
- data/app/assets/stylesheets/lib/neat/grid/_visual-grid.scss +42 -0
- data/app/assets/stylesheets/lib/neat/settings/_disable-warnings.scss +13 -0
- data/app/assets/stylesheets/lib/neat/settings/_grid.scss +51 -0
- data/app/assets/stylesheets/lib/neat/settings/_visual-grid.scss +27 -0
- data/app/assets/stylesheets/va_common_main.css.scss +18 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/generators/files/_footer.html.erb +89 -0
- data/lib/generators/files/_header.html.erb +7 -0
- data/lib/generators/va_common_generator.rb +6 -0
- data/lib/generators/va_footer_generator.rb +7 -0
- data/lib/generators/va_header_generator.rb +7 -0
- data/lib/va_common/engine.rb +4 -0
- data/lib/va_common/version.rb +3 -0
- data/lib/va_common.rb +2 -0
- data/va_common.gemspec +22 -0
- 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));
|