PageSourceSearch

http://www.ashemergency.com/themes/common/javascripts/smb/bxslider.js?v.90c14f

js ashemergency.com collected 2026-09-26 15:30:28 UTC 7,164 bytes, 251 lines download raw bytes

1+function ($) { "use strict";
2
3	var BXSlider = function(element, options) {
4        var lazyLoadImg = false;
5        $('.lazyLoadImg').length ? lazyLoadImg = true : lazyLoadImg = false;
6
7        function triggerScroll() {
8            setTimeout(function () { $(window).trigger("scroll"); }, 100);
9        }
10
11        this.$element = $(element);
12        this.options = this.parseTrueFalseOptions(options);
13
14        var self = this;
15        self.options.autoplay = self.options.auto;
16        self.options.auto = false;
17
18        var callbacksJSON = {
19            onSlideAfter: function() {
20                if(self.options.auto){
21                    self.$element.stopAuto();
22                    self.$element.startAuto();
23                }
24                if (lazyLoadImg) triggerScroll();
25            },
26            onSliderLoad: function () {
27                if(self.options.easing == '')
28                    self.options.easing = null;
29
30                if(self.options.controlsHover){
31                    var $wrapper = self.$element.closest('.bx-wrapper');
32
33                    $(".bx-controls-direction", $wrapper).hide();
34                    $wrapper.hover(
35                        function () { $(".bx-controls-direction", $(this)).fadeIn(300); },
36                        function () { $(".bx-controls-direction", $(this)).fadeOut(300); }
37                    );
38                }
39
40                if(self.options.autoHover){
41                    var $wrapper = self.$element.closest('.bx-wrapper');
42
43                    $wrapper.hover(
44                        function () {
45                            if(self.options.auto){
46                                self.$element.stopAuto();
47                            }
48                        },
49                        function () {
50                            console.log(self.options.auto);
51                            if(self.options.auto){
52                                self.$element.startAuto();
53                            }
54                        }
55                    );
56                }
57
58                if(self.options.easing != null){
59                    self.options.useCSS = false;
60                }
61
62                if(self.options.autoplay){
63                    self.makePauseSlideshowButton();
64                    var wait = self.options.autoDelay;
65                    setTimeout(function(){
66                        self.$element.startAuto();
67                        self.options.auto = true;
68                    }, wait);
69                }
70
71                // wrap bx-slider buttons controls
72                self.$element.closest('.bx-wrapper').find('.bx-controls').wrapAll("<div class='wrap__bx-controls' />");
73                self.$element.closest('.bx-wrapper').find(".wrap_on-off, .wrap_pause-play, .bx-pager " ).wrapAll( "<div class='bx-controls-buttons' />");
74
75                self.attachEvents();
76            },
77            onSlideNext: function() {
78                if (lazyLoadImg) triggerScroll();
79            },
80            onSlidePrev: function() {
81                if (lazyLoadImg) triggerScroll();
82            }
83        };
84
85        $.extend(this.options, callbacksJSON);
86        this.run();
87    }
88
89    BXSlider.prototype.attachEvents = function(){
90        var self = this;
91
92        var $viewport = self.$element.closest('.bx-wrapper').find('.bx-controls');
93
94        $viewport.on('click', '.pause-slideshow', function(e, data){
95            $(this).hide();
96            self.$element.stopAuto();
97            self.options.auto = false;
98            $viewport.find('.play-slideshow').fadeIn("slow", function(){
99                if(typeof data != "undefined"){
100                    $(this).focus();
101                }
102            });
103        });
104
105        $viewport.on('click', '.play-slideshow', function(e, data){
106            $(this).hide();
107            self.$element.startAuto();
108            self.options.auto = true;
109            $viewport.find('.pause-slideshow').fadeIn("slow", function(){
110                if(typeof data != "undefined"){
111                    $(this).focus();
112                }
113            });
114        });
115
116        $('body').keypress(function(e){
117            var key = e.which;
118            if(key == 13){
119                if($viewport.find('.play-slideshow').is(':focus')){
120                    $viewport.find('.play-slideshow').trigger('click', { kb: true});
121                }
122
123                if($viewport.find('.pause-slideshow').is(':focus')){
124                    $viewport.find('.pause-slideshow').trigger('click', { kb: true});
125                }
126            }
127        });
128    }
129
130    BXSlider.prototype.makePauseSlideshowButton = function(){
131        var self = this;
132
133        var $htmlPauseSlideshow = [
134            '<div class="wrap_pause-play">',
135                '<div class="pause-slideshow" aria-label="icon pause" title="Pause slideshow" tabindex="0">',
136                    '<span class="icon icon-pause"></span>',
137                '</div>',
138                '<div class="play-slideshow" aria-label="icon play" style="display: none" title="Play slideshow" tabindex="0">',
139                    '<span class="icon icon-play"></span>',
140                '</div>',
141            '</div>'
142        ];
143
144        self.$element.closest('.bx-wrapper').find('.bx-controls').append($htmlPauseSlideshow.join(''));
145
146    }
147
148    BXSlider.prototype.parseTrueFalseOptions = function(options, skip){
149        for (var key in options) {
150          if (options.hasOwnProperty(key) && BXSlider.BOOLEANS.indexOf(key) != -1) {
151            options[key] = !!options[key];
152          }
153        }
154
155	  	return options;
156    }
157
158    BXSlider.prototype.run = function(){
159        var self = this;
160
161        $(window).load(function() {
162            self.$bxSlider = self.$element.bxSlider(self.options);
163            self.$bxSlider.redrawSlider();
164        });
165    }
166
167    BXSlider.DEFAULTS = {
168    	pager: true,
169    	controls: true,
170    	autoControls: false,
171        auto: true,
172        infiniteLoop: true,
173        randomStart: false,
174        controlsHover: false,
175        responsive: false,
176        mode: 'horizontal',
177        speed: 500,
178        pause: 4000,
179        autoDelay: 0,
180        easing: null,
181        useCSS: false
182    }
183
184    BXSlider.BOOLEANS = [
185        'pager',
186        'controls',
187        'autoControls',
188        'auto',
189        'infiniteLoop',
190        'randomStart',
191        'controlsHover',
192        'responsive',
193    ]
194
195    var old = $.fn.BXSlider;
196
197    $.fn.BXSlider = function(option) {
198        var args = arguments,
199            result;
200
201        this.each(function() {
202            var $this = $(this);
203
204            var options = $.extend({}, BXSlider.DEFAULTS, $this.data(), typeof option == 'object' && option);
205            var data = '';
206
207            $this.data('bxslider', (data = new BXSlider(this, options)));
208
209            if (typeof result != 'undefined') return false;
210        });
211
212        return result ? result : this;
213    };
214
215    $.fn.BXSlider.Constructor = BXSlider
216
217    $.fn.BXSlider.noConflict = function () {
218        $.fn.BXSlider = old
219        return this
220    }
221
222    $(function(){
223    	$('[data-control="bx-slider"]').BXSlider();
224    });
225}(window.jQuery);
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251

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.