PageSourceSearch

https://aviationspottersonline.com/wp-content/plugins/nextgen-gall…/Galleria/ngg_galleria.js?ver=3.31.3

js aviationspottersonline.com collected 2026-10-02 13:40:13 UTC 8,712 bytes, 219 lines download raw bytes

1/*! GetDevicePixelRatio | Author: Tyson Matanich, 2012 | License: MIT */
2(function (window) {
3    window.getDevicePixelRatio = function() {
4        var ratio = 1;
5        // To account for zoom, change to use deviceXDPI instead of systemXDPI
6        if (window.screen.systemXDPI !== undefined
7        &&  window.screen.logicalXDPI !== undefined
8        &&  window.screen.systemXDPI > window.screen.logicalXDPI) {
9            // Only allow for values > 1
10            ratio = window.screen.systemXDPI / window.screen.logicalXDPI;
11        } else if (window.devicePixelRatio !== undefined) {
12            ratio = window.devicePixelRatio;
13        }
14        return ratio;
15    };
16})(this);
17
18(function ($) {
19    "use strict";
20
21    window.ngg_galleria = {
22        gallery_selector: '.ngg-galleria-parent',
23        gallery_target_selector: '.ngg-galleria',
24
25        start: function(themename) {
26            const self     = this;
27            const selector = this.gallery_selector + '.' + themename;
28
29            // Galleria has issues initializing in hidden containers or off-screen
30            $(selector).each(function(ndx, gallery_parent) {
31                const observer = new IntersectionObserver(
32                    function(entries) {
33                        entries.forEach(function (entry) {
34                                // This gallery is now visible
35                                if (1 === entry.intersectionRatio) {
36                                    self.create(gallery_parent, themename);
37                                }
38                            }
39                        );
40                    }
41                );
42                observer.observe(gallery_parent);
43            });
44        },
45
46        get_gallery_from_id: function (gallery_id) {
47            var retval = null;
48
49            if ('undefined' == typeof window.galleries) {
50                return retval;
51            }
52
53            $.each(window.galleries, function(index, gallery) {
54                if (gallery.ID == gallery_id) {
55                    retval = gallery;
56                }
57            });
58
59            return $.extend({}, retval);
60        },
61
62        get_setting: function(gallery, name, def) {
63            if (typeof gallery != 'object') {
64                gallery = this.get_gallery_from_id(gallery);
65            }
66
67            var settings = gallery.display_settings;
68            var tmp = '';
69
70            if (typeof settings !== 'undefined'
71            &&  typeof settings[name] !== 'undefined'
72            &&  settings[name] !== '') {
73                tmp = settings[name];
74            } else {
75                tmp = def;
76            }
77
78            if (tmp == 1)   tmp = true;
79            if (tmp == 0)   tmp = false;
80            if (tmp == '1') tmp = true;
81            if (tmp == '0') tmp = false;
82            return tmp;
83        },
84
85        create: function(gallery_parent, themename) {
86            var gallery_id = $(gallery_parent).data('id');
87            var gallery = $.extend({}, this.get_gallery_from_id(gallery_id));
88            var target = $(gallery_parent).find(this.gallery_target_selector).first();
89
90            this.configure_galleria(gallery_parent, target, gallery);
91
92            var images = gallery.images_list;
93
94            // Massage our data for High-DPI screens
95            if (window.getDevicePixelRatio() > 1) {
96                $(images).each(function(ndx, image) {
97                    if (image.use_hdpi) {
98                        image.image = image.srcsets.hdpi;
99                    }
100                });
101            }
102
103            // Galleria is very picky about the data type provided to the imageMargin option
104            var border_margin = this.get_setting(gallery, 'border_size', '0');
105            if (typeof border_margin == 'boolean') {
106                if (border_margin)  border_margin = 1;
107                if (!border_margin) border_margin = 0;
108            }
109            border_margin = parseInt(border_margin);
110
111            var settings = {
112                theme:         themename,
113                responsive:    true,
114                debug:         true,
115                maxScaleRatio: 1,
116                dataSource:    images,
117
118                showInfo:    this.get_setting(gallery, 'show_captions', false),
119                imagePan:    this.get_setting(gallery, 'image_pan',     false),
120                imageCrop:   this.get_setting(gallery, 'image_crop',    false),
121                transition:  this.get_setting(gallery, 'transition',   'fade'),
122                imageMargin: border_margin,
123
124                transitionSpeed: this.get_setting(gallery, 'transition_speed', 1) * 1000,
125
126                _nggGalleryID:     gallery_id,
127                _nggGalleryParent: gallery_parent,
128                _nggCaptionClass:         this.get_setting(gallery, 'caption_class',          'caption_overlay_bottom'),
129                _nggCaptionHeight:        this.get_setting(gallery, 'caption_height',         52),
130                _nggShowPlaybackControls: this.get_setting(gallery, 'show_playback_controls', true),
131                _nggImageCrop:            this.get_setting(gallery, 'image_crop',             false),
132                _nggBorderSize:           border_margin,
133                _nggBorderColor:          this.get_setting(gallery, 'border_color',           '#ffffff'),
134                _nggSlideshowSpeed:       this.get_setting(gallery, 'slideshow_speed',        5) * 1000
135            };
136
137            Galleria.run(target, settings);
138        },
139
140        configure_galleria: function(gallery_parent, target, gallery) {
141            // NOTE: .extend() is important! 'settings = displayed_gallery.settings' will
142            // create a 'pointer' -- changes to this 'settings' var will alter the
143            // displayed gallery settings. This causes havoc with fields like transition
144            // and slideshow speed.
145            gallery_parent = $(gallery_parent);
146            var self = this;
147            var settings = $.extend({}, gallery.display_settings);
148            for (var index in settings) {
149                var numeric_val = Number(settings[index]);
150                if (!isNaN(numeric_val)) {
151                    settings[index] = numeric_val;
152                }
153                if (numeric_val == 0 || numeric_val == 1 && !index.match(/width|size|height|dimensions|percent/)) {
154                    settings[index] = numeric_val ? true : false;
155                }
156            }
157
158            this.adjust_size(gallery_parent, target, settings);
159
160            $(window).on('resize orientationchange onfullscreenchange onmozfullscreenchange onwebkitfullscreenchange', function() {
161                self.adjust_size(gallery_parent, target, settings);
162            });
163        },
164
165        adjust_size: function(gallery_parent, target, settings) {
166            var parent_width = gallery_parent.width();
167            var width = settings.width;
168
169            if (settings.width_unit == '%') {
170                width = Math.round(parent_width * (settings.width / 100));
171            }
172
173            if (parent_width > 0 && parent_width < width) {
174                width = parent_width;
175            }
176
177            target.width(width);
178
179            // Calculate height using aspect ratio of device/browser
180            var aspect_ratio = gallery_parent.width() / gallery_parent.height();
181            if (typeof(settings.aspect_ratio) != 'undefined' && settings.aspect_ratio != 0) {
182                aspect_ratio = settings.aspect_ratio;
183                if (!parseFloat(aspect_ratio)) {
184                    if (settings.aspect_ratio_computed && parseFloat(settings.aspect_ratio_computed)) {
185                        aspect_ratio = settings.aspect_ratio_computed;
186                    } else {
187                        aspect_ratio = 1.5;
188                    }
189                } else {
190                    aspect_ratio = parseFloat(aspect_ratio);
191                }
192            }
193
194            var frame_height = ((width - 20) / aspect_ratio);
195
196            if (typeof(settings.thumbnail_height) != 'undefined') {
197                var thumb_height = settings.thumbnail_height;
198                if (typeof(thumb_height) === 'string') {
199                    thumb_height = parseFloat(thumb_height);
200                }
201                frame_height += thumb_height;
202            }
203
204            frame_height += 20;
205
206            var caption = settings.caption_class;
207            if (caption == 'caption_above_stage' || caption == 'caption_below_stage') {
208                frame_height += 52;
209            }
210
211            gallery_parent.height(frame_height);
212        }
213    };
214
215    $(window).on('ngg.galleria.themeadded', function(event, themename) {
216        ngg_galleria.start(themename);
217    });
218
219})(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.