(function($){ $.extend($.easing, { easeInOutCubic : function(x, t, b, c, d){ if ((t/=d/2) < 1) return c/2*t*t*t + b; return c/2*((t-=2)*t*t + 2) + b; } }); $.fn.outerFind = function(selector){ return this.find(selector).addBack(selector); }; (function($,sr){ // debouncing function from John Hann // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ var debounce = function (func, threshold, execAsap) { var timeout; return function debounced () { var obj = this, args = arguments; function delayed () { if (!execAsap) func.apply(obj, args); timeout = null; }; if (timeout) clearTimeout(timeout); else if (execAsap) func.apply(obj, args); timeout = setTimeout(delayed, threshold || 100); }; } // smartresize jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; })(jQuery,'smartresize'); (function(){ var scrollbarWidth = 0, originalMargin, touchHandler = function(event){ event.preventDefault(); }; function getScrollbarWidth(){ if (scrollbarWidth) return scrollbarWidth; var scrollDiv = document.createElement('div'); $.each({ top : '-9999px', width : '50px', height : '50px', overflow : 'scroll', position : 'absolute' }, function(property, value){ scrollDiv.style[property] = value; }); $('body').append(scrollDiv); scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; $('body')[0].removeChild(scrollDiv); return scrollbarWidth; } })(); $.isMobile = function(type){ var reg = []; var any = { blackberry : 'BlackBerry', android : 'Android', windows : 'IEMobile', opera : 'Opera Mini', ios : 'iPhone|iPad|iPod' }; type = 'undefined' == $.type(type) ? '*' : type.toLowerCase(); if ('*' == type) reg = $.map(any, function(v){ return v; }); else if (type in any) reg.push(any[type]); return !!(reg.length && navigator.userAgent.match(new RegExp(reg.join('|'), 'i'))); }; var isSupportViewportUnits = (function(){ // modernizr implementation var $elem = $('
').appendTo('body'); var elem = $elem[0]; var height = parseInt(window.innerHeight / 2, 10); var compStyle = parseInt((window.getComputedStyle ? getComputedStyle(elem, null) : elem.currentStyle)['height'], 10); $elem.remove(); return compStyle == height; }()); $(function(){ $('html').addClass($.isMobile() ? 'mobile' : 'desktop'); // .was-website-admin-navbar-sticky $(window).scroll(function(){ $('.was-website-admin-navbar-sticky').each(function(){ var method = $(window).scrollTop() > 10 ? 'addClass' : 'removeClass'; $(this)[method]('was-website-admin-navbar-stuck') .not('.was-website-admin-navbar-open')[method]('was-website-admin-navbar-short'); }); }); // .was-website-admin-hamburger $(document).on('add.cards change.cards', function(event){ $(event.target).outerFind('.was-website-admin-hamburger:not(.was-website-admin-added)').each(function(){ $(this).addClass('was-website-admin-added') .click(function(){ $(this) .toggleClass('was-website-admin-hamburger-open') .parents('.was-website-admin-navbar') .toggleClass('was-website-admin-navbar-open') .removeClass('was-website-admin-navbar-short'); }).parents('.was-website-admin-navbar').find('a:not(.was-website-admin-hamburger)').click(function(){ $('.was-website-admin-hamburger-open').click(); }); }); }); $(window).smartresize(function(){ if ($(window).width() > 991) $('.was-website-admin-navbar-auto-collapse .was-website-admin-hamburger-open').click(); }).keydown(function(event){ if (27 == event.which) // ESC $('.was-website-admin-hamburger-open').click(); }); if ($.isMobile() && navigator.userAgent.match(/Chrome/i)){ // simple fix for Chrome's scrolling (function(width, height){ var deviceSize = [width, width]; deviceSize[height > width ? 0 : 1] = height; $(window).smartresize(function(){ var windowHeight = $(window).height(); if ($.inArray(windowHeight, deviceSize) < 0) windowHeight = deviceSize[ $(window).width() > windowHeight ? 1 : 0 ]; $('.was-website-admin-section-full-height').css('height', windowHeight + 'px'); }); })($(window).width(), $(window).height()); } else if (!isSupportViewportUnits){ // fallback for .was-website-admin-section-full-height $(window).smartresize(function(){ $('.was-website-admin-section-full-height').css('height', $(window).height() + 'px'); }); $(document).on('add.cards', function(event){ if ($('html').hasClass('was-website-admin-site-loaded') && $(event.target).outerFind('.was-website-admin-section-full-height').length) $(window).resize(); }); } // .was-website-admin-section-16by9 (16 by 9 blocks autoheight) function calculate16by9(){ $(this).css('height', $(this).parent().width() * 9 / 16); } $(window).smartresize(function(){ $('.was-website-admin-section-16by9').each(calculate16by9); }); $(document).on('add.cards change.cards', function(event){ var enabled = $(event.target).outerFind('.was-website-admin-section-16by9'); if (enabled.length){ enabled .attr('data-16by9', 'true') .each(calculate16by9); } else { $(event.target).outerFind('[data-16by9]') .css('height', '') .removeAttr('data-16by9'); } }); // .was-website-admin-parallax-background if ($.fn.jarallax && !$.isMobile()){ $(document).on('destroy.parallax', function(event){ $(event.target).outerFind('.was-website-admin-parallax-background') .jarallax('destroy') .css('position', ''); }); $(document).on('add.cards change.cards', function(event){ $(event.target).outerFind('.was-website-admin-parallax-background') .jarallax() .css('position', 'relative'); }); } // .was-website-admin-social-likes if ($.fn.socialLikes){ $(document).on('add.cards', function(event){ $(event.target).outerFind('.was-website-admin-social-likes:not(.was-website-admin-added)').on('counter.social-likes', function(event, service, counter){ if (counter > 999) $('.social-likes-counter', event.target).html(Math.floor(counter / 1000) + 'k'); }).socialLikes({initHtml : false}); }); } // .was-website-admin-fixed-top var fixedTopTimeout, scrollTimeout, prevScrollTop = 0, fixedTop = null, isDesktop = !$.isMobile(); $(window).scroll(function(){ if (scrollTimeout) clearTimeout(scrollTimeout); var scrollTop = $(window).scrollTop(); var scrollUp = scrollTop <= prevScrollTop || isDesktop; prevScrollTop = scrollTop; if (fixedTop){ var fixed = scrollTop > fixedTop.breakPoint; if (scrollUp){ if (fixed != fixedTop.fixed){ if (isDesktop){ fixedTop.fixed = fixed; $(fixedTop.elm).toggleClass('is-fixed'); } else { scrollTimeout = setTimeout(function(){ fixedTop.fixed = fixed; $(fixedTop.elm).toggleClass('is-fixed'); }, 40); } } } else { fixedTop.fixed = false; $(fixedTop.elm).removeClass('is-fixed'); } } }); $(document).on('add.cards delete.cards', function(event){ if (fixedTopTimeout) clearTimeout(fixedTopTimeout); fixedTopTimeout = setTimeout(function(){ if (fixedTop){ fixedTop.fixed = false; $(fixedTop.elm).removeClass('is-fixed'); } $('.was-website-admin-fixed-top:first').each(function(){ fixedTop = { breakPoint : $(this).offset().top + $(this).height() * 3, fixed : false, elm : this }; $(window).scroll(); }); }, 650); }); // .was-website-admin-google-map var loadGoogleMap = function(){ var $this = $(this), markers = [], coord = function(pos){ return new google.maps.LatLng(pos[0], pos[1]); }; var params = $.extend({ zoom : 14, type : 'ROADMAP', center : null, markerIcon : null, showInfo : true }, eval('(' + ($this.data('google-map-params') || '{}') + ')')); $this.find('.was-website-admin-google-map-marker').each(function(){ var coord = $(this).data('coordinates'); if (coord){ markers.push({ coord : coord.split(/\s*,\s*/), icon : $(this).data('icon') || params.markerIcon, content : $(this).html(), template : $(this).html('{{content}}').removeAttr('data-coordinates data-icon')[0].outerHTML }); } }).end().html('').addClass('was-website-admin-google-map-loaded'); if (markers.length){ var map = this.Map = new google.maps.Map(this, { scrollwheel : false, // prevent draggable on mobile devices draggable : !$.isMobile(), zoom : params.zoom, mapTypeId : google.maps.MapTypeId[params.type], center : coord(params.center || markers[0].coord) }); $(window).smartresize(function(){ var center = map.getCenter(); google.maps.event.trigger(map, 'resize'); map.setCenter(center); }); map.Geocoder = new google.maps.Geocoder; map.Markers = []; $.each(markers, function(i, item){ var marker = new google.maps.Marker({ map : map, position : coord(item.coord), icon : item.icon, animation : google.maps.Animation.DROP }); var info = marker.InfoWindow = new google.maps.InfoWindow(); info._setContent = info.setContent; info.setContent = function(content){ return this._setContent(content ? item.template.replace('{{content}}', content) : ''); }; info.setContent(item.content); google.maps.event.addListener(marker, 'click', function(){ if (info.anchor && info.anchor.visible) info.close(); else if (info.getContent()) info.open(map, marker); }); if (item.content && params.showInfo){ google.maps.event.addListenerOnce(marker, 'animation_changed', function(){ setTimeout(function(){ info.open(map, marker); }, 350); }); } map.Markers.push(marker); }); } }; $(document).on('add.cards', function(event){ if (window.google && google.maps){ $(event.target).outerFind('.was-website-admin-google-map').each(function(){ loadGoogleMap.call(this); }); } }); // embedded videos $(window).smartresize(function(){ $('.was-website-admin-embedded-video').each(function(){ $(this).height( $(this).width() * parseInt($(this).attr('height') || 315) / parseInt($(this).attr('width') || 560) ); }); }); $(document).on('add.cards', function(event){ if ($('html').hasClass('was-website-admin-site-loaded') && $(event.target).outerFind('iframe').length) $(window).resize(); }); $(document).on('add.cards', function(event){ $(event.target).outerFind('[data-bg-video]').each(function(){ var result, videoURL = $(this).data('bg-video'), patterns = [ /\?v=([^&]+)/, /(?:embed|\.be)\/([-a-z0-9_]+)/i, /^([-a-z0-9_]+)$/i ]; for (var i = 0; i < patterns.length; i++){ if (result = patterns[i].exec(videoURL)){ var previewURL = 'http' + ('https:' == location.protocol ? 's' : '') + ':'; previewURL += '//img.youtube.com/vi/' + result[1] + '/maxresdefault.jpg'; var $img = $('
') .hide() .css({ backgroundSize: 'cover', backgroundPosition: 'center' }) $('.container:eq(0)', this).before($img); $('').on('load', function() { if (120 == (this.naturalWidth || this.width)) { // selection of preview in the best quality var file = this.src.split('/').pop(); switch (file){ case 'maxresdefault.jpg': this.src = this.src.replace(file, 'sddefault.jpg'); break; case 'sddefault.jpg': this.src = this.src.replace(file, 'hqdefault.jpg'); break; } } else { $img.css('background-image', 'url("' + this.src + '")') .show(); } }).attr('src', previewURL) if ($.fn.YTPlayer && !$.isMobile()){ var params = eval('(' + ($(this).data('bg-video-params') || '{}') + ')'); $('.container:eq(0)', this).before('
').prev() .YTPlayer($.extend({ videoURL : result[1], containment : 'self', showControls : false, mute : true }, params)); } break; } } }); }); // init $('body > *:not(style, script)').trigger('add.cards'); $('html').addClass('was-website-admin-site-loaded'); $(window).resize().scroll(); // smooth scroll if (!$('html').hasClass('is-builder')){ $(document).click(function(e){ try { var target = e.target; do { if (target.hash){ var useBody = /#bottom|#top/g.test(target.hash); $(useBody ? 'body' : target.hash).each(function(){ e.preventDefault(); var goTo = target.hash == '#bottom' ? ($(this).height() - $(window).height()) : $(this).offset().top; $('html, body').stop().animate({ scrollTop: goTo }, 800, 'easeInOutCubic'); }); break; } } while (target = target.parentNode); } catch (e) { // throw e; } }); } }); })(jQuery); /* source: https://github.com/avinoamr/bootstrap-carousel-swipe with alterations by Mobirise | WAS Website Administration Services */ +function ($) { 'use strict'; if ( !$.fn.carousel ) { return } // CAROUSEL CLASS DEFINITION // ========================= var CarouselSwipe = function(element) { this.$element = $(element) this.carousel = this.$element.data('bs.carousel') this.options = $.extend({}, CarouselSwipe.DEFAULTS, this.carousel.options) this.startX = this.startY = this.startTime = this.cycling = this.$active = this.$items = this.$next = this.$prev = this.dx = null this.$element .on('touchstart', $.proxy(this.touchstart,this)) .on('touchmove', $.proxy(this.touchmove,this)) .on('touchend', $.proxy(this.touchend,this)) } CarouselSwipe.DEFAULTS = { swipe: 50 // percent per second } CarouselSwipe.prototype.touchstart = function(e) { if (!this.options.swipe) return; var touch = e.originalEvent.touches ? e.originalEvent.touches[0] : e this.dx = 0 this.startX = touch.pageX this.startY = touch.pageY this.cycling = null this.width = this.$element.width() this.startTime = e.timeStamp } CarouselSwipe.prototype.touchmove = function(e) { if (!this.options.swipe) return; var touch = e.originalEvent.touches ? e.originalEvent.touches[0] : e var dx = touch.pageX - this.startX var dy = touch.pageY - this.startY if (Math.abs(dx) < Math.abs(dy)) return; // vertical scroll if ( this.cycling === null ) { this.cycling = !!this.carousel.interval this.cycling && this.carousel.pause() } e.preventDefault() this.dx = dx / (this.width || 1) * 100 this.swipe(this.dx) } CarouselSwipe.prototype.touchend = function(e) { if (!this.options.swipe) return; if (!this.$active) return; // nothing moved var all = $() .add(this.$active).add(this.$prev).add(this.$next) .carousel_transition(true) var dt = (e.timeStamp - this.startTime) / 1000 var speed = Math.abs(this.dx / dt) // percent-per-second if (this.dx > 40 || (this.dx > 0 && speed > this.options.swipe)) { this.carousel.prev() } else if (this.dx < -40 || (this.dx < 0 && speed > this.options.swipe)) { this.carousel.next(); } else { this.$active .one($.support.transition.end, function () { all.removeClass('prev next') }) .emulateTransitionEnd(this.$active.css('transition-duration').slice(0, -1) * 1000) } all.carousel_offset(false); this.cycling && this.carousel.cycle() this.$active = null // reset the active element } CarouselSwipe.prototype.swipe = function(percent) { var $active = this.$active || this.getActive() if (percent < 0) { this.$prev .carousel_offset(false) .removeClass('prev') .carousel_transition(true) if (!this.$next.length || this.$next.hasClass('active')) return this.$next .carousel_transition(false) .addClass('next') .carousel_offset(percent + 100) } else { this.$next .carousel_offset(false) .removeClass('next') .carousel_transition(true) if (!this.$prev.length || this.$prev.hasClass('active')) return this.$prev .carousel_transition(false) .addClass('prev') .carousel_offset(percent - 100) } $active .carousel_transition(false) .carousel_offset(percent) } CarouselSwipe.prototype.getActive = function() { this.$active = this.$element.find('.item.active') this.$items = this.$active.parent().children() this.$next = this.$active.next() if (!this.$next.length && this.options.wrap) { this.$next = this.$items.first(); } this.$prev = this.$active.prev() if (!this.$prev.length && this.options.wrap) { this.$prev = this.$items.last(); } return this.$active; } // CAROUSEL PLUGIN DEFINITION // ========================== var old = $.fn.carousel $.fn.carousel = function() { old.apply(this, arguments); return this.each(function () { var $this = $(this) var data = $this.data('bs.carousel.swipe') if (!data) $this.data('bs.carousel.swipe', new CarouselSwipe(this)) }) } $.extend($.fn.carousel,old); $.fn.carousel_transition = function(enable) { enable = enable ? '' : 'none'; return this.each(function() { $(this) .css('-webkit-transition', enable) .css('transition', enable) }) }; var support3dtransform = (function() { if (!window.getComputedStyle) { return false; } var el = document.createElement('p'), has3d, transforms = { 'webkitTransform':'-webkit-transform', 'OTransform':'-o-transform', 'msTransform':'-ms-transform', 'MozTransform':'-moz-transform', 'transform':'transform' }; // Add it to the body to get the computed style. document.body.insertBefore(el, null); for (var t in transforms) { if (el.style[t] !== undefined) { el.style[t] = "translate3d(1px,1px,1px)"; has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]); } } document.body.removeChild(el); return (has3d !== undefined && has3d.length > 0 && has3d !== "none"); }()); $.fn.carousel_offset = function(value) { return this.each(function() { if(value) { if(support3dtransform) { $(this).css('transform', 'translate3d(' + value + '%, 0, 0)') } else { $(this).css('left', value + '%') } } else { $(this).css({ transform: '', left: '' }) } }) }; // init carousels $('.carousel').carousel(); }(jQuery);/* source: https://github.com/avinoamr/bootstrap-carousel-swipe with alterations by Mobirise | WAS Website Administration Services */ +function ($) { 'use strict'; if ( !$.fn.carousel ) { return } // CAROUSEL CLASS DEFINITION // ========================= var CarouselSwipe = function(element) { this.$element = $(element) this.carousel = this.$element.data('bs.carousel') this.options = $.extend({}, CarouselSwipe.DEFAULTS, this.carousel.options) this.startX = this.startY = this.startTime = this.cycling = this.$active = this.$items = this.$next = this.$prev = this.dx = null this.$element .on('touchstart', $.proxy(this.touchstart,this)) .on('touchmove', $.proxy(this.touchmove,this)) .on('touchend', $.proxy(this.touchend,this)) } CarouselSwipe.DEFAULTS = { swipe: 50 // percent per second } CarouselSwipe.prototype.touchstart = function(e) { if (!this.options.swipe) return; var touch = e.originalEvent.touches ? e.originalEvent.touches[0] : e this.dx = 0 this.startX = touch.pageX this.startY = touch.pageY this.cycling = null this.width = this.$element.width() this.startTime = e.timeStamp } CarouselSwipe.prototype.touchmove = function(e) { if (!this.options.swipe) return; var touch = e.originalEvent.touches ? e.originalEvent.touches[0] : e var dx = touch.pageX - this.startX var dy = touch.pageY - this.startY if (Math.abs(dx) < Math.abs(dy)) return; // vertical scroll if ( this.cycling === null ) { this.cycling = !!this.carousel.interval this.cycling && this.carousel.pause() } e.preventDefault() this.dx = dx / (this.width || 1) * 100 this.swipe(this.dx) } CarouselSwipe.prototype.touchend = function(e) { if (!this.options.swipe) return; if (!this.$active) return; // nothing moved var all = $() .add(this.$active).add(this.$prev).add(this.$next) .carousel_transition(true) var dt = (e.timeStamp - this.startTime) / 1000 var speed = Math.abs(this.dx / dt) // percent-per-second if (this.dx > 40 || (this.dx > 0 && speed > this.options.swipe)) { this.carousel.prev() } else if (this.dx < -40 || (this.dx < 0 && speed > this.options.swipe)) { this.carousel.next(); } else { this.$active .one($.support.transition.end, function () { all.removeClass('prev next') }) .emulateTransitionEnd(this.$active.css('transition-duration').slice(0, -1) * 1000) } all.carousel_offset(false); this.cycling && this.carousel.cycle() this.$active = null // reset the active element } CarouselSwipe.prototype.swipe = function(percent) { var $active = this.$active || this.getActive() if (percent < 0) { this.$prev .carousel_offset(false) .removeClass('prev') .carousel_transition(true) if (!this.$next.length || this.$next.hasClass('active')) return this.$next .carousel_transition(false) .addClass('next') .carousel_offset(percent + 100) } else { this.$next .carousel_offset(false) .removeClass('next') .carousel_transition(true) if (!this.$prev.length || this.$prev.hasClass('active')) return this.$prev .carousel_transition(false) .addClass('prev') .carousel_offset(percent - 100) } $active .carousel_transition(false) .carousel_offset(percent) } CarouselSwipe.prototype.getActive = function() { this.$active = this.$element.find('.item.active') this.$items = this.$active.parent().children() this.$next = this.$active.next() if (!this.$next.length && this.options.wrap) { this.$next = this.$items.first(); } this.$prev = this.$active.prev() if (!this.$prev.length && this.options.wrap) { this.$prev = this.$items.last(); } return this.$active; } // CAROUSEL PLUGIN DEFINITION // ========================== var old = $.fn.carousel $.fn.carousel = function() { old.apply(this, arguments); return this.each(function () { var $this = $(this) var data = $this.data('bs.carousel.swipe') if (!data) $this.data('bs.carousel.swipe', new CarouselSwipe(this)) }) } $.extend($.fn.carousel,old); $.fn.carousel_transition = function(enable) { enable = enable ? '' : 'none'; return this.each(function() { $(this) .css('-webkit-transition', enable) .css('transition', enable) }) }; var support3dtransform = (function() { if (!window.getComputedStyle) { return false; } var el = document.createElement('p'), has3d, transforms = { 'webkitTransform':'-webkit-transform', 'OTransform':'-o-transform', 'msTransform':'-ms-transform', 'MozTransform':'-moz-transform', 'transform':'transform' }; // Add it to the body to get the computed style. document.body.insertBefore(el, null); for (var t in transforms) { if (el.style[t] !== undefined) { el.style[t] = "translate3d(1px,1px,1px)"; has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]); } } document.body.removeChild(el); return (has3d !== undefined && has3d.length > 0 && has3d !== "none"); }()); $.fn.carousel_offset = function(value) { return this.each(function() { if(value) { if(support3dtransform) { $(this).css('transform', 'translate3d(' + value + '%, 0, 0)') } else { $(this).css('left', value + '%') } } else { $(this).css({ transform: '', left: '' }) } }) }; // init carousels $('.carousel').carousel(); }(jQuery);