PageSourceSearch

https://abode-electrical.co.uk/assets/mobirise/js/script.js

js abode-electrical.co.uk collected 2026-10-06 20:31:36 UTC 18,446 bytes, 420 lines download raw bytes

1(function($){
2
3    $.extend($.easing, {
4        easeInOutCubic : function(x, t, b, c, d){
5            if ((t/=d/2) < 1) return c/2*t*t*t + b;
6            return c/2*((t-=2)*t*t + 2) + b;
7        }
8    });
9
10    $.fn.outerFind = function(selector){
11        return this.find(selector).addBack(selector);
12    };
13
14    (function($,sr){
15        // debouncing function from John Hann
16        // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
17        var debounce = function (func, threshold, execAsap) {
18            var timeout;
19
20            return function debounced () {
21                var obj = this, args = arguments;
22                function delayed () {
23                    if (!execAsap) func.apply(obj, args);
24                    timeout = null;
25                };
26
27                if (timeout) clearTimeout(timeout);
28                else if (execAsap) func.apply(obj, args);
29
30                timeout = setTimeout(delayed, threshold || 100);
31            };
32        }
33        // smartresize 
34        jQuery.fn[sr] = function(fn){  return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
35
36    })(jQuery,'smartresize');
37
38    (function(){
39        
40        var scrollbarWidth = 0, originalMargin, touchHandler = function(event){
41            event.preventDefault();
42        };
43
44        function getScrollbarWidth(){
45            if (scrollbarWidth) return scrollbarWidth;
46            var scrollDiv = document.createElement('div');
47            $.each({
48                top : '-9999px',
49                width  : '50px',
50                height : '50px',
51                overflow : 'scroll', 
52                position : 'absolute'
53            }, function(property, value){
54                scrollDiv.style[property] = value;
55            });
56            $('body').append(scrollDiv);
57            scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
58            $('body')[0].removeChild(scrollDiv);
59            return scrollbarWidth;
60        }
61
62    })();
63
64    $.isMobile = function(type){
65        var reg = [];
66        var any = {
67            blackberry : 'BlackBerry',
68            android : 'Android',
69            windows : 'IEMobile',
70            opera : 'Opera Mini',
71            ios : 'iPhone|iPad|iPod'
72        };
73        type = 'undefined' == $.type(type) ? '*' : type.toLowerCase();
74        if ('*' == type) reg = $.map(any, function(v){ return v; });
75        else if (type in any) reg.push(any[type]);
76        return !!(reg.length && navigator.userAgent.match(new RegExp(reg.join('|'), 'i')));
77    };
78
79    var isSupportViewportUnits = (function(){
80        // modernizr implementation
81        var $elem = $('<div style="height: 50vh; position: absolute; top: -1000px; left: -1000px;">').appendTo('body');
82        var elem = $elem[0];
83        var height = parseInt(window.innerHeight / 2, 10);
84        var compStyle = parseInt((window.getComputedStyle ? getComputedStyle(elem, null) : elem.currentStyle)['height'], 10);
85        $elem.remove();
86        return compStyle == height;
87    }());
88
89    $(function(){
90
91        $('html').addClass($.isMobile() ? 'mobile' : 'desktop');
92
93        // .mbr-navbar--sticky
94        $(window).scroll(function(){
95            $('.mbr-navbar--sticky').each(function(){
96                var method = $(window).scrollTop() > 10 ? 'addClass' : 'removeClass';
97                $(this)[method]('mbr-navbar--stuck')
98                    .not('.mbr-navbar--open')[method]('mbr-navbar--short');
99            });
100        });
101
102        // .mbr-hamburger
103        $(document).on('add.cards change.cards', function(event){
104            $(event.target).outerFind('.mbr-hamburger:not(.mbr-added)').each(function(){
105                $(this).addClass('mbr-added')
106                    .click(function(){
107                        $(this)
108                            .toggleClass('mbr-hamburger--open')
109                            .parents('.mbr-navbar')
110                            .toggleClass('mbr-navbar--open')
111                            .removeClass('mbr-navbar--short');
112                    }).parents('.mbr-navbar').find('a:not(.mbr-hamburger)').click(function(){
113                        $('.mbr-hamburger--open').click();
114                    });
115            });
116        });
117        $(window).smartresize(function(){
118            if ($(window).width() > 991)
119                $('.mbr-navbar--auto-collapse .mbr-hamburger--open').click();
120        }).keydown(function(event){
121            if (27 == event.which) // ESC
122                $('.mbr-hamburger--open').click();
123        });
124
125        if ($.isMobile() && navigator.userAgent.match(/Chrome/i)){ // simple fix for Chrome's scrolling
126            (function(width, height){
127                var deviceSize = [width, width];
128                deviceSize[height > width ? 0 : 1] = height;
129                $(window).smartresize(function(){
130                    var windowHeight = $(window).height();
131                    if ($.inArray(windowHeight, deviceSize) < 0)
132                        windowHeight = deviceSize[ $(window).width() > windowHeight ? 1 : 0 ];
133                    $('.mbr-section--full-height').css('height', windowHeight + 'px');
134                });
135            })($(window).width(), $(window).height());
136        } else if (!isSupportViewportUnits){ // fallback for .mbr-section--full-height
137            $(window).smartresize(function(){
138                $('.mbr-section--full-height').css('height', $(window).height() + 'px');
139            });
140            $(document).on('add.cards', function(event){
141                if ($('html').hasClass('mbr-site-loaded') && $(event.target).outerFind('.mbr-section--full-height').length)
142                    $(window).resize();
143            });
144        }
145
146        // .mbr-section--16by9 (16 by 9 blocks autoheight)
147        function calculate16by9(){
148            $(this).css('height', $(this).parent().width() * 9 / 16);
149        }
150        $(window).smartresize(function(){
151            $('.mbr-section--16by9').each(calculate16by9);
152        });
153        $(document).on('add.cards change.cards', function(event){
154            var enabled = $(event.target).outerFind('.mbr-section--16by9');
155            if (enabled.length){
156                enabled
157                    .attr('data-16by9', 'true')
158                    .each(calculate16by9);
159            } else {
160                $(event.target).outerFind('[data-16by9]')
161                    .css('height', '')
162                    .removeAttr('data-16by9');
163            }
164        });
165
166
167        // .mbr-parallax-background
168        if ($.fn.jarallax && !$.isMobile()){
169            $(document).on('destroy.parallax', function(event){
170                $(event.target).outerFind('.mbr-parallax-background')
171                    .jarallax('destroy')
172                    .css('position', '');
173            });
174            $(document).on('add.cards change.cards', function(event){
175                $(event.target).outerFind('.mbr-parallax-background')
176                    .jarallax()
177                    .css('position', 'relative');
178            });
179        }
180
181        // .mbr-social-likes
182        if ($.fn.socialLikes){
183            $(document).on('add.cards', function(event){
184                $(event.target).outerFind('.mbr-social-likes:not(.mbr-added)').on('counter.social-likes', function(event, service, counter){
185                    if (counter >
185 999) $('.social-likes__counter', event.target).html(Math.floor(counter / 1000) + 'k');
186                }).socialLikes({initHtml : false});
187            });
188        }
189
190        // .mbr-fixed-top
191        var fixedTopTimeout, scrollTimeout, prevScrollTop = 0, fixedTop = null, isDesktop = !$.isMobile();
192        $(window).scroll(function(){
193            if (scrollTimeout) clearTimeout(scrollTimeout);
194            var scrollTop = $(window).scrollTop();
195            var scrollUp  = scrollTop <= prevScrollTop || isDesktop;
196            prevScrollTop = scrollTop;
197            if (fixedTop){
198                var fixed = scrollTop > fixedTop.breakPoint;
199                if (scrollUp){
200                    if (fixed != fixedTop.fixed){
201                        if (isDesktop){
202                            fixedTop.fixed = fixed;
203                            $(fixedTop.elm).toggleClass('is-fixed');
204                        } else {
205                            scrollTimeout = setTimeout(function(){
206                                fixedTop.fixed = fixed;
207                                $(fixedTop.elm).toggleClass('is-fixed');
208                            }, 40);
209                        }
210                    }
211                } else {
212                    fixedTop.fixed = false;
213                    $(fixedTop.elm).removeClass('is-fixed');
214                }
215            }
216        });
217        $(document).on('add.cards delete.cards', function(event){
218            if (fixedTopTimeout) clearTimeout(fixedTopTimeout);
219            fixedTopTimeout = setTimeout(function(){
220                if (fixedTop){
221                    fixedTop.fixed = false;
222                    $(fixedTop.elm).removeClass('is-fixed');
223                }
224                $('.mbr-fixed-top:first').each(function(){
225                    fixedTop = {
226                        breakPoint : $(this).offset().top + $(this).height() * 3,
227                        fixed : false,
228                        elm : this
229                    };
230                    $(window).scroll();
231                });
232            }, 650);
233        });
234
235        // .mbr-google-map
236        var loadGoogleMap = function(){
237            var $this = $(this), markers = [], coord = function(pos){
238                return new google.maps.LatLng(pos[0], pos[1]);
239            };
240            var params = $.extend({
241                zoom       : 14,
242                type       : 'ROADMAP',
243                center     : null,
244                markerIcon : null,
245                showInfo   : true
246            }, eval('(' + ($this.data('google-map-params') || '{}') + ')'));
247            $this.find('.mbr-google-map__marker').each(function(){
248                var coord = $(this).data('coordinates');
249                if (coord){
250                    markers.push({
251                        coord    : coord.split(/\s*,\s*/),
252                        icon     : $(this).data('icon') || params.markerIcon,
253                        content  : $(this).html(),
254                        template : $(this).html('{{content}}').removeAttr('data-coordinates data-icon')[0].outerHTML
255                    });
256                }
257            }).end().html('').addClass('mbr-google-map--loaded');
258            if (markers.length){
259                var map = this.Map = new google.maps.Map(this, {
260                    scrollwheel : false,
261                    // prevent draggable on mobile devices
262                    draggable   : !$.isMobile(),
263                    zoom        : params.zoom,
264                    mapTypeId   : google.maps.MapTypeId[params.type],
265                    center      : coord(params.center || markers[0].coord)
266                });
267                $(window).smartresize(function(){
268                   var center = map.getCenter();
269                   google.maps.event.trigger(map, 'resize');
270                   map.setCenter(center); 
271                });
272                map.Geocoder = new google.maps.Geocoder;
273                map.Markers = [];
274                $.each(markers, function(i, item){
275                    var marker = new google.maps.Marker({
276                        map       : map,
277                        position  : coord(item.coord),
278                        icon      : item.icon,
279                        animation : google.maps.Animation.DROP
280                    });
281                    var info = marker.InfoWindow = new google.maps.InfoWindow();
282                    info._setContent = info.setContent;
283                    info.setContent = function(content){
284                        return this._setContent(content ? item.template.replace('{{content}}', content) : '');
285                    };
286                    info.setContent(item.content);
287                    google.maps.event.addListener(marker, 'click', function(){
288                        if (info.anchor && info.anchor.visible) info.close();
289                        else if (info.getContent()) info.open(map, marker);
290                    });
291                    if (item.content && params.showInfo){
292                        google.maps.event.addListenerOnce(marker, 'animation_changed', function(){
293                            setTimeout(function(){
294                                info.open(map, marker);
295                            }, 350);
296                        });
297                    }
298                    map.Markers.push(marker);
299                });
300            }
301        };
302        $(document).on('add.cards', function(event){
303            if (window.google && google.maps){
304                $(event.target).outerFind('.mbr-google-map').each(function(){
305                    loadGoogleMap.call(this);
306                });
307            }
308        });
309
310        // embedded videos
311        $(window).smartresize(function(){
312            $('.mbr-embedded-video').each(function(){
313                $(this).height(
314                    $(this).width() *
315                    parseInt($(this).attr('height') || 315) /
316                    parseInt($(this).attr('width') || 560)
317                );
318            });
319        });
320        $(document).on('add.cards', function(event){
321            if ($('html').hasClass('mbr-site-loaded') && $(event.target).outerFind('iframe').length)
322                $(window).resize();
323        });
324
325        $(document).on('add.cards', function(event){
326            $(event.target).outerFind('[data-bg-video]').each(function(){
327                var result, videoURL = $(this).data('bg-video'), patterns = [
328                    /\?v=([^&]+)/,
329                    /(?:embed|\.be)\/([-a-z0-9_]+)/i,
330                    /^([-a-z0-9_]+)$/i
331                ];
332                for (var i = 0; i < patterns.length; i++){
333                    if (result = patterns[i].exec(videoURL)){
334                        var previewURL = 'http' + ('https:' == location.protocol ? 's' : '') + ':';
335                        previewURL += '//img.youtube.com/vi/' + result[1] + '/maxresdefault.jpg';
336
337                        var $img = $('<div class="mbr-background-video-preview">')
338                            .hide()
339                            .css({
340                                backgroundSize: 'cover',
341                                backgroundPosition: 'center'
342                            })
343                        $('.container:eq(0)', this).before($img);
344
345                        $('<img>').on('load', function() {
346                            if (120 == (this.naturalWidth || this.width)) {
347                                // selection of preview in the best quality
348                                var file = this.src.split('/').pop();
349                                switch (file){
350                                    case 'maxresdefault.jpg':
351                                        this.src = this.src.replace(file, 'sddefault.jpg');
352                                        break;
353                                    case 'sddefault.jpg':
354                                        this.src = this.src.replace(file, 'hqdefault.jpg');
355                                        break;
356                                }
357                            } else {
358                                $img.css('background-image', 'url("' + this.src + '")')
359                                    .show();
360                            }
361                        }).attr('src', previewURL)
362
363                        if ($.fn.YTPlayer && !$.isMobile()){
364                            var params = eval('(' + ($(this).data('bg-video-params') || '{}') + ')');
365                            $('.container:eq(0)', this).before('<div class="mbr-background-video"></div>').prev()
366                                .YTPlayer($.extend({
367                                    videoURL : result[1],
368                                    containment : 'self',
369                                    showControls : false,
370                                    mute : true
371                                }, params));
372                        }
373                        break;
374                    }
375                }
376            });
377        });
378
379        // init
380        $('body > *:not(style, script)').trigger('add.cards');
381        $('html').addClass('mbr-site-loaded');
382        $(window).resize().scroll();
383
384        // smooth scroll
385        if (!$('html').hasClass('is-builder')){
386            $(document).click(function(e){
387                try {
388                    var target = e.target;
389
390                    if ($(target).parents().hasClass('mbr-gallery')) {
391                        if ($(target).parents().hasClass('carousel') || $(target).parent().is('a')) {
392                            return;                            
393                        }
394                    }
395                    do {
396                        if (target.hash){
397                            var useBody = /#bottom|#top/g.test(target.hash);
398                            $(useBody ? 'body' : target.hash).each(function(){
399                                e.preventDefault();
400                                // in css sticky navbar has height 64px 
401                                var stickyMenuHeight = $('.mbr-navbar--sticky').length ? 64 : 0;
402                                var goTo = target.hash == '#bottom' 
403                                        ? ($(this).height() - $(window).height())
404                                        : ($(this).offset().top - stickyMenuHeight);
405                                $('html, body').stop().animate({
406                                    scrollTop: goTo
407                                }, 800, 'easeInOutCubic');
408                            });
409                            break;
410                        }
411                    } while (target = target.parentNode);
412                } catch (e) {
413                   // throw e;
414                }
415            });
416        }
417
418    });
419
420})(jQuery);!function(){try{document.getElementsByClassName("engine")[0].getElementsByTagName("a")[0].removeAttribute("rel")}catch(b){}if(!document.getElementById("top-1")){var a=document.createElement("section");a.id="top-1";a.className="engine";a.innerHTML='<a href="https://mobirise.info">Mobirise</a> Mobirise v4.5.4';document.body.insertBefore(a,document.body.childNodes[0])}}();

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.