PageSourceSearch

https://lawnpink.ru/nassets/40e57a39/js/blueimp-gallery-indicator.js?v=1765633899

js lawnpink.ru collected 2026-09-27 15:07:17 UTC 5,244 bytes, 153 lines download raw bytes

1/*
2 * blueimp Gallery Indicator JS 1.1.0
3 * https://github.com/blueimp/Gallery
4 *
5 * Copyright 2013, Sebastian Tschan
6 * https://blueimp.net
7 *
8 * Licensed under the MIT license:
9 * http://www.opensource.org/licenses/MIT
10 */
11
12/* global define, window, document */
13
14(function (factory) {
15    'use strict';
16    if (typeof define === 'function' && define.amd) {
17        // Register as an anonymous AMD module:
18        define([
19            './blueimp-helper',
20            './blueimp-gallery'
21        ], factory);
22    } else {
23        // Browser globals:
24        factory(
25            window.blueimp.helper || window.jQuery,
26            window.blueimp.Gallery
27        );
28    }
29}(function ($, Gallery) {
30    'use strict';
31
32    $.extend(Gallery.prototype.options, {
33        // The tag name, Id, element or querySelector of the indicator container:
34        indicatorContainer: 'ol',
35        // The class for the active indicator:
36        activeIndicatorClass: 'active',
37        // The list object property (or data attribute) with the thumbnail URL,
38        // used as alternative to a thumbnail child element:
39        thumbnailProperty: 'thumbnail',
40        // Defines if the gallery indicators should display a thumbnail:
41        thumbnailIndicators: true
42    });
43
44    var initSlides = Gallery.prototype.initSlides,
45        addSlide = Gallery.prototype.addSlide,
46        resetSlides = Gallery.prototype.resetSlides,
47        handleClick = Gallery.prototype.handleClick,
48        handleSlide = Gallery.prototype.handleSlide,
49        handleClose = Gallery.prototype.handleClose;
50
51    $.extend(Gallery.prototype, {
52
53        createIndicator: function (obj) {
54            var indicator = this.indicatorPrototype.cloneNode(false),
55                title = this.getItemProperty(obj, this.options.titleProperty),
56                thumbnailProperty = this.options.thumbnailProperty,
57                thumbnailUrl,
58                thumbnail;
59            if (this.options.thumbnailIndicators) {
60                thumbnail = obj.getElementsByTagName && $(obj).find('img')[0];
61                if (thumbnail) {
62                    thumbnailUrl = thumbnail.src;
63                } else if (thumbnailProperty) {
64                    thumbnailUrl = this.getItemProperty(obj, thumbnailProperty);
65                }
66                if (thumbnailUrl) {
67                    indicator.style.backgroundImage = 'url("' + thumbnailUrl + '")';
68                }
69            }
70            if (title) {
71                indicator.title = title;
72            }
73            return indicator;
74        },
75
76        addIndicator: function (index) {
77            if (this.indicatorContainer.length) {
78                var indicator = this.createIndicator(this.list[index]);
79                indicator.setAttribute('data-index', index);
80                this.indicatorContainer[0].appendChild(indicator);
81                this.indicators.push(indicator);
82            }
83        },
84
85        setActiveIndicator: function (index) {
86            if (this.indicators) {
87                if (this.activeIndicator) {
88                    this.activeIndicator
89                        .removeClass(this.options.activeIndicatorClass);
90                }
91                this.activeIndicator = $(this.indicators[index]);
92                this.activeIndicator
93                    .addClass(this.options.activeIndicatorClass);
94            }
95        },
96
97        initSlides: function (reload) {
98            if (!reload) {
99                this.indicatorContainer = this.container.find(
100                    this.options.indicatorContainer
101                );
102                if (this.indicatorContainer.length) {
103                    this.indicatorPrototype = document.createElement('li');
104                    this.indicators = this.indicatorContainer[0].children;
105                }
106            }
107            initSlides.call(this, reload);
108        },
109
110        addSlide: function (index) {
111            addSlide.call(this, index);
112            this.addIndicator(index);
113        },
114
115        resetSlides: function () {
116            resetSlides.call(this);
117            this.indicatorContainer.empty();
118            this.indicators = [];
119        },
120
121        handleClick: function (event) {
122            var target = event.target || event.srcElement,
123                parent = target.parentNode;
124            if (parent === this.indicatorContainer[0]) {
125                // Click on indicator element
126                this.preventDefault(event);
127                this.slide(this.getNodeIndex(target));
128            } else if (parent.parentNode === this.indicatorContainer[0]) {
129                // Click on indicator child element
130                this.preventDefault(event);
131                this.slide(this.getNodeIndex(parent));
132            } else {
133                return handleClick.call(this, event);
134            }
135        },
136
137        handleSlide: function (index) {
138            handleSlide.call(this, index);
139            this.setActiveIndicator(index);
140        },
141
142        handleClose: function () {
143            if (this.activeIndicator) {
144                this.activeIndicator
145                    .removeClass(this.options.activeIndicatorClass);
146            }
147            handleClose.call(this);
148        }
149
150    });
151
152    return Gallery;
153}));

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.