PageSourceSearch

https://envitely.com/wp-content/themes/softek/assets/js/retina.js?ver=1790259178

js envitely.com collected 2026-09-24 14:14:27 UTC 5,700 bytes, 183 lines download raw bytes

1/*!
2 * Retina.js v1.3.0
3 *
4 * Copyright 2014 Imulus, LLC
5 * Released under the MIT license
6 *
7 * Retina.js is an open source script that makes it easy to serve
8 * high-resolution images to devices with retina displays.
9 */
10
11(function() {
12    "use strict";
13    var root = (typeof exports === 'undefined' ? window : exports);
14    var config = {
15        // An option to choose a suffix for 2x images
16        retinaImageSuffix : '@2x',
17
18        // Ensure Content-Type is an image before trying to load @2x image
19        // https://github.com/imulus/retinajs/pull/45)
20        check_mime_type: true,
21
22        // Resize high-resolution images to original image's pixel dimensions
23        // https://github.com/imulus/retinajs/issues/8
24        force_original_dimensions: true
25    };
26
27    function Retina() {}
28
29    root.Retina = Retina;
30
31    Retina.configure = function(options) {
32        if (options === null) {
33            options = {};
34        }
35
36        for (var prop in options) {
37            if (options.hasOwnProperty(prop)) {
38                config[prop] = options[prop];
39            }
40        }
41    };
42
43    Retina.init = function(context) {
44        if (context === null) {
45            context = root;
46        }
47
48        var existing_onload = context.onload || function(){};
49
50        context.onload = function() {
51            var images = document.getElementsByTagName('img'), retinaImages = [], i, image;
52            for (i = 0; i < images.length; i += 1) {
53                image = images[i];
54                if (!!!image.getAttributeNode('data-no-retina')) {
55                    retinaImages.push(new RetinaImage(image));
56                }
57            }
58            existing_onload();
59        };
60    };
61
62    Retina.isRetina = function(){
63        var mediaQuery = '(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)';
64
65        if (root.devicePixelRatio > 1) {
66            return true;
67        }
68
69        if (root.matchMedia && root.matchMedia(mediaQuery).matches) {
70            return true;
71        }
72
73        return false;
74    };
75
76
77    var regexMatch = /\.\w+$/;
78    function suffixReplace (match) {
79        return config.retinaImageSuffix + match;
80    }
81
82    function RetinaImagePath(path, at_2x_path) {
83        this.path = path || '';
84        if (typeof at_2x_path !== 'undefined' && at_2x_path !== null) {
85            this.at_2x_path = at_2x_path;
86            this.perform_check = false;
87        } else {
88            if (undefined !== document.createElement) {
89                var locationObject = document.createElement('a');
90                locationObject.href = this.path;
91                locationObject.pathname = locationObject.pathname.replace(regexMatch, suffixReplace);
92                this.at_2x_path = locationObject.href;
93            } else {
94                var parts = this.path.split('?');
95                parts[0] = parts[0].replace(regexMatch, suffixReplace);
96                this.at_2x_path = parts.join('?');
97            }
98            this.perform_check = true;
99        }
100    }
101
102    root.RetinaImagePath = RetinaImagePath;
103
104    RetinaImagePath.confirmed_paths = [];
105
106    RetinaImagePath.prototype.is_external = function() {
107        return !!(this.path.match(/^https?\:/i) && !this.path.match('//' + document.domain) );
108    };
109
110    RetinaImagePath.prototype.check_2x_variant = function(callback) {
111        var http, that = this;
112        if (this.is_external()) {
113            return callback(false);
114        } else if (!this.perform_check && typeof this.at_2x_path !== 'undefined' && this.at_2x_path !== null) {
115            return callback(true);
116        } else if (this.at_2x_path in RetinaImagePath.confirmed_paths) {
117            return callback(true);
118        } else {
119            http = new XMLHttpRequest();
120            http.open('HEAD', this.at_2x_path);
121            http.onreadystatechange = function() {
122                if (http.readyState !== 4) {
123                    return callback(false);
124                }
125
126                if (http.status >= 200 && http.status <= 399) {
127                    if (config.check_mime_type) {
128                        var type = http.getResponseHeader('Content-Type');
129                        if (type === null || !type.match(/^image/i)) {
130                            return callback(false);
131                        }
132                    }
133
134                    RetinaImagePath.confirmed_paths.push(that.at_2x_path);
135                    return callback(true);
136                } else {
137                    return callback(false);
138                }
139            };
140            http.send();
141        }
142    };
143
144
145    function RetinaImage(el) {
146        this.el = el;
147        this.path = new RetinaImagePath(this.el.getAttribute('src'), this.el.getAttribute('data-at2x'));
148        var that = this;
149        this.path.check_2x_variant(function(hasVariant) {
150            if (hasVariant) {
151                that.swap();
152            }
153        });
154    }
155
156    root.RetinaImage = RetinaImage;
157
158    RetinaImage.prototype.swap = function(path) {
159        if (typeof path === 'undefined') {
160            path = this.path.at_2x_path;
161        }
162
163        var that = this;
164        function load() {
165            if (! that.el.complete) {
166                setTimeout(load, 5);
167            } else {
168                if (config.force_original_dimensions) {
169                    that.el.setAttribute('width', that.el.offsetWidth);
170                    that.el.setAttribute('height', that.el.offsetHeight);
171                }
172
173                that.el.setAttribute('src', path);
174            }
175        }
176        load();
177    };
178
179
180    if (Retina.isRetina()) {
181        Retina.init(root);
182    }
183})();

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.