PageSourceSearch

https://www.gbrsf.com/Events/JS/widgets/ExcitingEventsCarousel.js?sv=8.6.4.4

js gbrsf.com collected 2026-10-07 22:55:53 UTC 17,419 bytes, 418 lines download raw bytes

1/*ExcitingEventCarousel Widget*/
2
3
4(function ($) {
5
6    //Data service for the widget
7    function widgetDataService() {
8
9        this.getWidgetData = function (servicePath, widgetModuleItemID, successCallback, errorCallback) {
10            $.ajax({
11                type: "POST",
12                url: servicePath,
13                data: "{'widgetModuleItemID':" + widgetModuleItemID + "}",
14                contentType: "application/json; charset=utf-8",
15                dataType: "json",
16                success: successCallback,
17                error: errorCallback
18            });
19        };
20    };
21
22    //Global variable for the widget function
23    var widgetModuleItemID = 0;
24    var widgetData = null;
25    var widgetContainer = null;
26    var contentContainer = null;
27    var textContentContainer = null;
28    var titleContentContainer = null;
29    var descriptionContentContainer = null;
30    var w = $('.carouselImage').css('height');
31    var fh, sh, fw, sw, ft, sl, st, fl, tl, tt, th, tw, fz, sz, tz;
32    var currentSlideIndex = 0
33    var carouselInt;
34    var waitInt;
35    var executingAnimation = false;
36    var hnm = location.hostname;
37    hnm = hnm.replace('www.', '');
38    var detectIpad = false;
39    var musicPlayerText = '';
40    var slideTitle;
41    var autoScrolling = false;
42    var carouselLoaded = function(){};
43    var useCropbox = true;
44
45    //Constructor for the wiget
46    $.fn.ExcitingEventsCarousel = function (options) {
47
48        var opts = $.extend({}, $.fn.ExcitingEventsCarousel.defaultOptions, options);
49
50        widgetContainer = this;
51        widgetModuleItemID = opts.currentWidgetModuleItemID;
52        contentContainer = widgetContainer.find('.carouselContainer');
53        textContentContainer = widgetContainer.find('#excitingEventsTextContent');
54        titleContentContainer = textContentContainer.find('#excitingEventsTitleContent');
55        descriptionContentContainer = textContentContainer.find('#excitingEventsDescriptionContent');
56        detectIpad = opts.detectIpad;
57        autoScrolling = opts.autoScrolling;
58        carouselLoaded = opts.carouselLoaded;
59        useCropbox = opts.useCropbox;
60
61        var widgetDataAdapter = new widgetDataService();
62
63        widgetDataAdapter.getWidgetData(opts.scriptPath, opts.currentWidgetModuleItemID, getWidgetDataSuccess, getWidgetDataError);
64
65    };
66
67    //Default options for the constructor to be merged with send constructor data
68    $.fn.ExcitingEventsCarousel.defaultOptions = {
69        scriptPath: "services/eventsservice.asmx"
70        , currentWidgetModuleItemID: 0
71        , detectIpad: false
72        , autoScrolling: false
73        , carouselLoaded: function(){}
74        , useCropbox: true
75    };
76
77    //service call worked
78    var getWidgetDataSuccess = function (data) {
79
80        widgetData = data.d;
81        initialize();
82    };
83
84    //service call has failed
85    var getWidgetDataError = function (data) {
86
87        console.log('Exciting Events Carousel failed to load'
88        , '\n' + 'Status: ' + data.status + ' ' + data.statusText
89        , '\n' + data.responseText);
90
91    };
92
93
94
95    //set up the ui
96    function initialize() {
97        $('#excitingEventsCarousel').prepend('<h1 class="homepageh1">More Exciting Events</h1>');
98
99        $('#excitingEventsCarouselLeft').click(function () { carouselLeft() });
100        $('#excitingEventsCarouselRight').click(function () { carouselRight() });
101        $('.excitingEventsCarousel .leftRight').click(function () { stopAutomaticScrolling(); });
102
103       $('#excitingEventsCarousel').on("swipeleft",function(){
104            if (isResponsive) {
105                $('#excitingEventsCarouselRight').click();
106            }
107        });
108        $('#excitingEventsCarousel').on("swiperight",function(){
109            if(isResponsive){
110                $('#excitingEventsCarouselLeft').click();
111            }
112        });
113
114        if (widgetData.Slides.length > 0) {
115            var slideIndex = resolveSlideIndex(-2);
116            for (i = 0; i <= 4; i++) {
117                contentContainer.append(getImageHTML(slideIndex))
118                slideIndex++
119                if (slideIndex >= widgetData.Slides.length) {
120                    slideIndex = 0
121                }
122            }
123            loadCurrentContent();
124        }
125
126        labelCarousel();
127        fh = $('.carouselImage.firstCarouselImage').css('height'); // first image height
128        fw = $('.carouselImage.firstCarouselImage').css('width'); // first image width
129        ft = $('.carouselImage.firstCarouselImage').css('top'); // first image position-top
130        fl = $('.carouselImage.firstCarouselImage').css('left'); // first image position-left
131        fz = $('.carouselImage.firstCarouselImage').css('zIndex'); // first image z-index
132        sh = $('.carouselImage.secondCarouselImage').css('height'); // second (featured) image height
133        sw = $('.carouselImage.secondCarouselImage').css('width'); // second (featured) image width
134        st = $('.carouselImage.secondCarouselImage').css('top'); // second position-top
135        sl = $('.carouselImage.secondCarouselImage').css('left'); // second position-top
136        sz = $('.carouselImage.secondCarouselImage').css('zIndex'); // second image z-index
137        th = $('.carouselImage.thirdCarouselImage').css('height'); // third (featured) image height
138        tw = $('.carouselImage.thirdCarouselImage').css('width'); // third (featured) image width
139        tt = $('.carouselImage.thirdCarouselImage').css('top'); // third position-top
140        tl = $('.carouselImage.thirdCarouselImage').css('left'); // third position-top
141        tz = $('.carouselImage.thirdCarouselImage').css('zIndex'); // third image z-index
142        
143        if(autoScrolling){
144            startAutomaticScrolling();
145        }
146        moveToFront();
147        carouselLoaded();
148    }
149
150    function leftCarouselClick() {
151        carouselRight();
152    }
153
154    function setTarget() {
155
156    }
157
158    function getImageHTML(slideIndex) {
159        var wda = widgetData.Slides[slideIndex].URL;
160        var targ, anc, curs;
161        if (wda != null) {
162            curs = '';
163            targ = wda.search(hnm);
164            if (targ < 0) {
165                targ = "target='_blank'";
166            } else {
167                targ = "";
168            }
169            anc = widgetData.Slides[slideIndex].URL;
170        } else {
171            anc = 'javascript:void(0);'
172            curs = 'class="defaultCursor"';
173        }
174
175
176        return '<span class="carouselImage" style="display:block;"><a href="' + anc + '" ' + targ + ' ' + curs + '><img src="' + getImageSrc(slideIndex) + '" alt="' + getImageAltText(slideIndex) + '" style="width:100%" /></a></span>'
177    }
178
179    function getImageSrc(slideIndex) {
180        if(useCropbox){
181            return widgetData.Slides[slideIndex].ImageWithPath + '&h=200&w=200&cropbox=1&cropboxhpos=center&c=1&q=80';
182        } else {
183            return widgetData.Slides[slideIndex].ImageWithPath;
184        }
185    }
186
187    function getImageURL(slideIndex) {
188        return widgetData.Slides[slideIndex].URL
189    }
190
191    function getImageAltText(slideIndex) {
192        return widgetData.Slides[slideIndex].ImageAlternateText
193    }
194
195    function loadCurrentContent() {
196        var currentContentDescription;
197        var currentContentTitle;
198        if(widgetData.Slides[currentSlideIndex].Description != null && widgetData.Slides[currentSlideIndex].Description != undefined){
199            currentContentDescription = widgetData.Slides[currentSlideIndex].Description
200        } else {
201            currentContentDescription = '';
202        }
203
204        if(widgetData.Slides[currentSlideIndex].Title != null && widgetData.Slides[currentSlideIndex].Title != undefined){
205            currentContentTitle = widgetData.Slides[currentSlideIndex].Title
206        } else {
207            currentContentTitle = '';
208        }
209        
210        
211        if (widgetData.Slides[currentSlideIndex].AudioFileWithPath != null && widgetData.Slides[currentSlideIndex].AudioFileWithPath != ''  && detectIpad == false){
212            slideTitle = widgetData.Slides[currentSlideIndex].Title;        
213            slideTitle = escape(slideTitle);
214            var singleSong = widgetData.Slides[currentSlideIndex].AudioFileWithPath;
215            singleSong = escape(singleSong);
216            musicPlayerText = "<div id='eventCarouselMusicLink'><a href='javascript:void(0)' onclick='openSinglePlayer(\""+singleSong+"\", \""+slideTitle+"\")' class='carouselListenButton button'>Listen</a></div>";
217        } else {musicPlayerText='';}
218        $('#eventCarouselMusicLink').remove();  
219        titleContentContainer.text(currentContentTitle);
220        descriptionContentContainer.text(currentContentDescription);
221        $('.carouselLearnMore').remove();
222        $('.carouselBuyNow').remove();
223
224        //Purchase and register button
225        var purchaseURL = widgetData.Slides[currentSlideIndex].PurchaseURL;
226
227        if (purchaseURL != null && purchaseURL != '') {
228
229            var purchaseTarget = '_self';
230            var purchaseOnClick = '';
231
232            if (widgetData.Slides[currentSlideIndex].PurchaseLinkOpenInANewWindow) {
233                purchaseTarget = '_blank';
234            }
235
236            if (widgetData.Slides[currentSlideIndex].PurchaseLinkOnClick != null && widgetData.Slides[currentSlideIndex].PurchaseLinkOnClick != '') {
237                purchaseOnClick = widgetData.Slides[currentSlideIndex].PurchaseLinkOnClick
238            }
239
240            $('#excitingEventsTextContent').prepend('<a class="carouselBuyNow button buyNowButton" href="' + purchaseURL + '" onclick="' + purchaseOnClick + '" target="' + purchaseTarget + '">
240' + widgetData.Slides[currentSlideIndex].PurchaseLinkText + '</a>');
241
242
243        }
244
245
246        //More info Button
247        var thisURL = getImageURL(resolveSlideIndex(currentSlideIndex));
248        var carouselLinkTextDescription; 
249        if (thisURL != null) {
250            if (widgetData.Slides[currentSlideIndex].DetailLinkText != null && widgetData.Slides[currentSlideIndex].DetailLinkText != undefined){
251                carouselLinkTextDescription = widgetData.Slides[currentSlideIndex].DetailLinkText;
252            } else {
253                carouselLinkTextDescription = '';
254            }
255            var thisTarget = '_self';
256
257            if (widgetData.Slides[currentSlideIndex].URLOpenInANewWindow) {
258                thisTarget = '_blank';
259            }
260
261            $('#excitingEventsTextContent>div').wrapInner('<a href="' + thisURL + '" class="carouselTextAnchor"  target="' + thisTarget + '" />');
262            $('#excitingEventsTextContent').prepend('<a class="carouselLearnMore button" href="' + thisURL + '" target="' + thisTarget + '">' + carouselLinkTextDescription + '</a>');
263            
264            var targT = thisURL.search(hnm);
265            if (targT < 0) {
266                $(".carouselTextAnchor").attr('target', '_blank');
267                $(".carouselLearnMore").attr('target', '_blank');
268            } else {
269                $(".carouselTextAnchor").removeAttr('target');
270                $(".carouselLearnMore").removeAttr('target');
271            }
272        }
273
274        
275
276        $('#excitingEventsTextContent').prepend(musicPlayerText);
277        $('#excitingEventsTextContent').fadeIn(800);
278    }
279
280    function resolveSlideIndex(theoreticalIndex) {
281        var direction = theoreticalIndex / Math.abs(theoreticalIndex);
282        var returnIndex = 0
283        var span = Math.abs(theoreticalIndex)
284
285        for (i = 0; i < span; i++) {
286            returnIndex += direction
287            if (returnIndex < 0) {
288                returnIndex = widgetData.Slides.length - 1;
289            }
290            if (returnIndex > (widgetData.Slides.length - 1)) {
291                returnIndex = 0
292            }
293        }
294
295        return returnIndex;
296
297    }
298
299    function labelCarousel() {
300        var l = $('.carouselImage').length;
301
302        var i = 0;
303        $('.carouselImage').each(function () {
304            if (i == 0) {
305                $(this).addClass('leftCarouselImageHidden');
306            } else if (i == 1) {
307                $(this).addClass('firstCarouselImage');
308                $('a', this).removeClass('defaultCursor');
309                $('a', this).removeAttr('href').removeAttr('target');
310            } else if (i == 2) {
311                $(this).addClass('secondCarouselImage');
312            } else if (i == 3) {
313                $(this).addClass('thirdCarouselImage');
314                $('a', this).removeClass('defaultCursor');
315                $('a', this).removeAttr('href').removeAttr('target');
316            } else if (i == 4) {
317                $(this).addClass('rightCarouselImageHidden');
318            }
319            i++
320        });
321
322    }
323
324    function moveToFront() {
325        $('.carouselImage').click(function () {
326            var fci = $(this).hasClass('firstCarouselImage');
327            var tci = $(this).hasClass('thirdCarouselImage');
328            if (fci) {
329                carouselLeft();
330            }
331            if (tci) {
332                carouselRight();
333            }
334        });
335    }
336
337    function carouselLeft() {
338        if (!executingAnimation) {
339            executingAnimation = true;
340            currentSlideIndex = resolveSlideIndex(currentSlideIndex - 1)
341            var cw = $('.carouselContainer').width();
342            $('.rightCarouselImageHidden').css({ left: cw + 100 + 'px', top: ft, height: fh, width: fw, zIndex: fz }, 200);
343            $('.thirdCarouselImage').animate({ left: cw + 100 + 'px', top: tt, height: th, width: tw, zIndex: tz }, 200);
344            $('.secondCarouselImage').delay(300).animate({ left: tl, top: tt, height: th, width: tw, zIndex: tz }, 150);
345            $('.firstCarouselImage').delay(250).animate({ left: sl, top: st, width: sw, height: sh, zIndex: sz }, 200);
346            $('.leftCarouselImageHidden').delay(550).animate({ left: fl, top: ft, height: fh, width: fw, zIndex: fz }, 200, function () {
347                $('.rightCarouselImageHidden').prependTo('.carouselContainer').css('left', '-1000px'); //THIS WILL BE REPLACED WHEN THE ARRAY IS IN PLACE
348                $('.carouselContainer span').removeClass('firstCarouselImage secondCarouselImage thirdCarouselImage leftCarouselImageHidden rightCarouselImageHidden');
349                // AMIMATION/SEQUENCE COMPLETE 
350                labelCarousel();
351                loadCurrentContent();
352                LoadHiddenImages();
353                executingAnimation = false;
354            });
355        }
356    }
357
358    function carouselRight() {
359        if (!executingAnimation) {
360            executingAnimation = true;
361            currentSlideIndex = resolveSlideIndex(currentSlideIndex + 1)
362            $('.leftCarouselImageHidden').css({ left: '-100px', top: ft, height: fh, width: fw, zIndex: tz }, 200);
363            $('.firstCarouselImage').animate({ left: '-100px', top: ft, width: fw, height: fh, zIndex: fz }, 200);
364            $('.secondCarouselImage').delay(300).animate({ left: fl, top: ft, height: fh, width: fw, zIndex: fz }, 150);
365            $('.thirdCarouselImage').delay(250).animate({ left: sl, top: st, height: sh, width: sw, zIndex: sz }, 200);
366            $('.rightCarouselImageHidden').delay(550).animate({ left: tl, top: tt, height: th, width: tw, zIndex: tz }, 200, function () {
367                $('.leftCarouselImageHidden').appendTo('.carouselContainer').css('left', '1000px'); //THIS WILL BE REPLACED WHEN THE ARRAY IS IN PLACE
368                $('.carouselContainer span').removeClass('firstCarouselImage secondCarouselImage thirdCarouselImage leftCarouselImageHidden rightCarouselImageHidden');
369                // AMIMATION/SEQUENCE COMPLETE 
370                labelCarousel();
371                loadCurrentContent();
372                LoadHiddenImages();
373                executingAnimation = false;
374            });
375        }
376
377    }
378
379    function LoadHiddenImages() {
380
381        var targ;
382        var URL = getImageURL(resolveSlideIndex(currentSlideIndex));
383
384
385        $('.leftCarouselImageHidden img').attr('src', getImageSrc(resolveSlideIndex(currentSlideIndex - 2)));
386        $('.rightCarouselImageHidden img').attr('src', getImageSrc(resolveSlideIndex(currentSlideIndex + 2)));
387
388        if (URL != null) {
389            $('.secondCarouselImage a').attr('href', URL);
390            targ = URL.search(hnm);
391            if (targ < 0) {
392                $('.secondCarouselImage a').attr('target', '_blank').removeClass('defaultCursor');
393            } else {
394                $('.secondCarouselImage a').removeAttr('target').removeClass('defaultCursor');
395            }
396
397        } else {
398            $('.secondCarouselImage a').removeAttr('href').addClass('defaultCursor').removeAttr('target');
399        }
400
401    }
402
403    function stopAutomaticScrolling() {
404        clearTimeout(waitInt)
405        clearInterval(carouselInt)
406        if(autoScrolling){
407            setInterval(function () { startAutomaticScrolling(); }, 10000);
408        }
409    }
410
411    function startAutomaticScrolling() {
412        clearInterval(carouselInt)
413        carouselInt = setInterval(leftCarouselClick, 5500);
414
415    }
416
417
418})(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.