PageSourceSearch

https://roofingalliance.net/Content/lib/front/assets/js/components/hs.svg-injector.js

js roofingalliance.net collected 2026-09-24 12:07:17 UTC 2,037 bytes, 85 lines download raw bytes

1/**
2 * SVG Injector wrapper.
3 *
4 * @author Htmlstream
5 * @version 1.0
6 *
7 */
8;(function ($) {
9  'use strict';
10  $.HSCore.components.HSSVGIngector = {
11    /**
12     *
13     *
14     * @var Object _baseConfig
15     */
16    _baseConfig: {},
17
18    /**
19     *
20     *
21     * @var jQuery pageCollection
22     */
23    pageCollection: $(),
24
25    /**
26     * Initialization of Go To wrapper.
27     *
28     * @param String selector (optional)
29     * @param Object config (optional)
30     *
31     * @return jQuery pageCollection - collection of initialized items.
32     */
33
34    init: function (selector, config) {
35      this.collection = selector && $(selector).length ? $(selector) : $();
36      if (!$(selector).length) return;
37
38      this.config = config && $.isPlainObject(config) ?
39        $.extend({}, this._baseConfig, config) : this._baseConfig;
40
41      this.config.itemSelector = selector;
42
43      this.initSVGInjector();
44
45      return this.pageCollection;
46    },
47
48    initSVGInjector: function () {
49      //Variables
50      var $self = this,
51        collection = $self.pageCollection;
52
53      //Actions
54      this.collection.each(function (i, el) {
55        //Variables
56        var $this = $(el),
57          array = JSON.parse(el.getAttribute('data-img-paths')),
58          arrayLength = array ? array.length : 0,
59          $parent = $($this.data('parent')),
60          targetId,
61          newPath;
62
63        $parent.css('height', $parent.outerHeight());
64
65        SVGInjector($this, {
66          each: function (svg) {
67            if (arrayLength > 0) {
68              for (i = 0; i < arrayLength; i++) {
69                targetId = array[i].targetId;
70                newPath = array[i].newPath;
71
72                $(svg).find(targetId).attr('xlink:href', newPath);
73              }
74            }
75
76            $parent.removeClass('svg-preloader').css('height', '');
77          }
78        });
79
80        //Actions
81        collection = collection.add($this);
82      });
83    }
84  };
85})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.