PageSourceSearch

https://grove.bank/bower_components/jquery-svg-to-inline/dist/js/jquery-svg-to-inline.js

js grove.bank collected 2026-10-09 05:22:50 UTC 2,372 bytes, 70 lines download raw bytes

1/*! jQuery SVG to Inline v0.1.4
2*   https://github.com/tiagoporto/jquery-svg-to-inline
3*   Copyright (c) 2016-2017 Tiago Porto (tiagoporto.com)
4*   Released under the MIT license
5*/
6
7'use strict';
8
9$.fn.svgToInline = function (options) {
10    'use strict';
11
12    var trigger = {
13        class: function() {
14            if(jQuery.fn.jquery.match(/^(1|2)/)) {
15                return this.selector.replace('.', '');
16            } else {
17                return $(this).attr('class');
18            }
19        },
20        useClass: options && options.useTriggerClass || false
21    };
22
23    this.each(function () {
24        var svg = {
25            currency: $(this),
26            oldClass: '',
27            newClass: '',
28            path: $(this).attr('data') || $(this).attr('src')
29        },
30            request = {
31            element: '',
32            svgTag: '',
33            svgTagWithoutClass: ''
34        },
35            inputClass = $(this).attr('class').split(' '),
36            inputClassLength = inputClass.length;
37
38        if (inputClassLength > 0) {
39            for (var i = 0; i < inputClassLength; ++i) {
40                var space = '';
41
42                if (inputClass[i] === trigger.class && !trigger.useClass) {
43                    continue;
44                }
45
46                i !== inputClass.length - 1 && (space = ' ');
47                inputClass[i] && (svg.newClass += inputClass[i] + space);
48            }
49        }
50
51        $.ajax({
52            url: svg.path,
53            dataType: 'text',
54            success: function success(response) {
55                request.element = response.replace(/<[?!][^>]*>/g, ''), request.svgTag = request.element.match(/<svg[^>]*>/g);
56                request.svgTagWithoutClass = request.svgTag[0].replace(/class=\"[^"]*\"/, '');
57                svg.oldClass = request.svgTag[0].match(/class=\"(.*?)\"/);
58
59                // If exist class in svg add to svg.newClass
60                svg.oldClass && svg.oldClass[1] && svg.newClass && (svg.newClass = svg.oldClass[1] + ' ' + svg.newClass);
61
62                svg.newClass !== '' && (svg.newClass = 'class="' + svg.newClass + '"');
63
64                request.svgTagWithoutClass = request.svgTagWithoutClass.replace('>', ' ' + svg.newClass + '>');
65
66                svg.currency.replaceWith(request.element.replace(/<svg[^>]*>/g, request.svgTagWithoutClass));
67            }
68        });
69    });
70};

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.