/* //////////////////////////////////////////////////////////////// // // UI JavaScript Funktionen // // Weblication CMS // erstellt durch Scholl Communications AG, 77694 Kehl, www.scholl.de // erstellt mit Weblication Content Management System, www.weblication.de // //////////////////////////////////////////////////////////////// // // // BITTE NICHT ANPASSEN! // // JS-Anpassungen können in der design.js // // durchgeführt werden. // // // //////////////////////////////////////////////////////////////// */ devicePixelRatio = window.devicePixelRatio || 1; hdLimitDpr = 2; if(document.documentElement){ document.documentElement.className = document.documentElement.className + (!/MSIE (6|7|8)/.test(navigator.appVersion) ? ' pagestatus-uiloaded' : ''); } jQuery(document).ready(function(){ wUiTmp = {}; wCssClassesToAddGlobal = typeof(wCssClassesToAddGlobal) != 'undefined' ? wCssClassesToAddGlobal : {}; wCssDataToAddGlobal = typeof(wCssDataToAddGlobal) != 'undefined' ? wCssDataToAddGlobal : {}; wCssEventsToAddGlobal = typeof(wCssEventsToAddGlobal) != 'undefined' ? wCssEventsToAddGlobal : {}; wCssJQuery = typeof(wCssJQuery) != 'undefined' ? wCssJQuery : {}; wCssDOM = typeof(wCssDOM) != 'undefined' ? wCssDOM : {}; wMediaqueriesToAddGlobal = typeof(wMediaqueriesToAddGlobal) != 'undefined' ? wMediaqueriesToAddGlobal : {}; var htmlAdditionalClasses = ''; if(navigator.appVersion.match(/MSIE (\d+\..)/)){ htmlAdditionalClasses += ' ie' + String(navigator.appVersion.match(/MSIE (\d+\..)/)[1]).replace(/\..*/, ''); } if(/mobile/i.test(navigator.userAgent)) htmlAdditionalClasses += ' mobile'; if(/iPad/i.test(navigator.userAgent)) htmlAdditionalClasses += ' ipad'; if(/iPhone/i.test(navigator.userAgent)) htmlAdditionalClasses += ' iphone'; if(/iPod/i.test(navigator.userAgent)) htmlAdditionalClasses += ' ipod'; if(/(iPod|iPhone|iPad)/i.test(navigator.userAgent)){ htmlAdditionalClasses += ' ios'; wUiTmp['isIOS'] = true; if(/CriOs/i.test(navigator.userAgent)){ htmlAdditionalClasses += ' crios'; } else if(/Safari/i.test(navigator.userAgent)){ wUiTmp['isSafari'] = true; htmlAdditionalClasses += ' saios'; } } htmlAdditionalClasses += ' viewmode-' + (/viewmode=([^&]+)/.test(location.href) ? RegExp.$1 : 'default'); htmlAdditionalClasses += (('ontouchstart' in window)|| navigator.msMaxTouchPoints || window.DocumentTouch && document instanceof DocumentTouch ? ' touch' : ' no-touch'); if(document.documentElement){ if(document.documentElement.getAttribute('lang')) htmlAdditionalClasses += ' lang-' + document.documentElement.getAttribute('lang'); document.documentElement.className = (document.documentElement.className.replace('no-js', '') + ' js' + htmlAdditionalClasses).replace(/^\s+/, ''); if(typeof(wEditor) == 'undefined'){ document.documentElement.className = document.documentElement.className.replace('weditor', '') + ' no-weditor'; } else{ document.documentElement.className = document.documentElement.className.replace('no-weditor', '') + ' weditor'; } document.documentElement.className = document.documentElement.className + (!/MSIE (6|7|8)/.test(navigator.appVersion) ? ' pagestatus-ready' : ''); if(/MSIE (6|7|8)/.test(navigator.appVersion)){ document.documentElement.className = document.documentElement.className.replace(/pagestatus-\w+/g, ''); } } if(document.cookie.indexOf('websitezoom=l') != -1){ document.body.className = document.body.className + ' zoom-l'; } for(var addClassSelector in wCssClassesToAddGlobal){ jQuery(addClassSelector).each(function(index){ var classesToAdd = wCssClassesToAddGlobal[addClassSelector]; for(var i = 0, arrayLength = classesToAdd.length; i < arrayLength; i++){ var classData = classesToAdd[i].split('='); if(classData.length == 2){ var selector = jQuery.trim(classData[0]); if(selector == '.'){ jQuery(this).addClass(jQuery.trim(classData[1])); } else if(selector == 'parent'){ jQuery(this).parent().addClass(jQuery.trim(classData[1])); } else{ jQuery(this).find(selector).addClass(jQuery.trim(classData[1])); } } else{ jQuery(this).addClass(jQuery.trim(classData[0])); } } }); } for(var addDataSelector in wCssDataToAddGlobal){ jQuery(addDataSelector).each(function(index){ var dataToAdd = wCssDataToAddGlobal[addDataSelector]; for(var i = 0, arrayLength = dataToAdd.length; i < arrayLength; i++){ var data = dataToAdd[i].split('='); jQuery(this).attr('data-' + jQuery.trim(data[0]), jQuery.trim(data[1])); } }); } jQuery('*[data-w-addclasses]').each(function(index){ var classesToAdd = jQuery(this).data('w-addclasses').split(','); jQuery(this).removeAttr('data-w-addclasses'); for(var i = 0, arrayLength = classesToAdd.length; i < arrayLength; i++){ var classData = classesToAdd[i].split('='); var selector = jQuery.trim(classData[0]); if(selector == '.'){ jQuery(this).addClass(jQuery.trim(classData[1])); } else{ jQuery(this).find(selector).addClass(jQuery.trim(classData[1])); } } }); for(var addEventSelector in wCssEventsToAddGlobal){ jQuery(addEventSelector).each(function(index){ var eventsToAdd = wCssEventsToAddGlobal[addEventSelector]; for(var i = 0, arrayLength = eventsToAdd.length; i < arrayLength; i++){ var eventData = eventsToAdd[i].split('='); if(eventData.length == 2){ var eventType = jQuery.trim(eventData[0]).replace(/^on/, ''); var eventFunction = jQuery.trim(eventData[1]); jQuery(this).bind(eventType, (new Function('event', eventFunction + '(this, event.originalEvent);'))); } } }); } for(var wCssJQueryEntry in wCssJQuery){ jQuery(wCssJQueryEntry).each(function(index){ if(!wCssJQuery[wCssJQueryEntry]['event'] || wCssJQuery[wCssJQueryEntry]['event'] == 'document.ready'){ eval(wCssJQuery[wCssJQueryEntry]['jQuery']); } }); } for(var wCssDOMEntry in wCssDOM){ jQuery(wCssDOMEntry).each(function(index){ domActions = {'prependto' : 'prependTo', 'appendto' : 'appendTo', 'insertbefore' : 'insertBefore', 'insertafter' : 'insertAfter'}; if(/^(\w+)\(/.test(wCssDOM[wCssDOMEntry]['path'])){ eval('jQuery(this).' + domActions[wCssDOM[wCssDOMEntry]['action'].toLowerCase()] + '(jQuery(this).' + wCssDOM[wCssDOMEntry]['path'].replace(/\*\/$/, '') + ');'); } else{ if(wCssDOM[wCssDOMEntry]['action'] == 'prependto'){ jQuery(this).prependTo(wCssDOM[wCssDOMEntry]['path']); } else if(wCssDOM[wCssDOMEntry]['action'] == 'appendto'){ jQuery(this).appendTo(wCssDOM[wCssDOMEntry]['path']); } else if(wCssDOM[wCssDOMEntry]['action'] == 'insertbefore'){ jQuery(this).insertBefore(wCssDOM[wCssDOMEntry]['path']); } else if(wCssDOM[wCssDOMEntry]['action'] == 'insertafter'){ jQuery(this).insertAfter(wCssDOM[wCssDOMEntry]['path']); } } }); } jQuery('body').append('
'); for(var wMediaqueryToAddGlobal in wMediaqueriesToAddGlobal){ jQuery('#wMediaqueriesTmp').append('
'); } jQuery('label').each(function(index){ var nameFor = jQuery(this).attr('for'); if(nameFor && nameFor != ''){ var currentForm = jQuery(this).closest('form').get(0); if(currentForm){ var elementFor = currentForm.elements[nameFor]; if(elementFor && typeof(elementFor.getAttribute('placeholder')) == 'string' && (elementFor.className.indexOf('wglIsInvalid') == -1 || elementFor.value == '')){ if(elementFor.getAttribute('data-showlabelifhasplaceholder') != '1' && typeof(elementFor.placeholder) != 'undefined'){ jQuery(this).css({'display' : 'none'}); } } } } }); jQuery(window).load(function(){ for(var wCssJQueryEntry in wCssJQuery){ jQuery(wCssJQueryEntry).each(function(index){ if(wCssJQuery[wCssJQueryEntry]['event'] && wCssJQuery[wCssJQueryEntry]['event'] == 'window.load'){ eval(wCssJQuery[wCssJQueryEntry]['jQuery']); } }); } wOptimizePictureSizes(); jQuery("img[data-srchover]").each(function(){ var thisElement = jQuery(this); var hoverTriggerElement = jQuery(this); var hoverTriggerPath = jQuery(this).data('hovertrigger'); if(hoverTriggerPath){ eval('hoverTriggerElement = hoverTriggerElement.' + hoverTriggerPath); } hoverTriggerElement.bind('mouseover', function (event){ thisElement.data('srcbeforehover', thisElement.attr('src')); thisElement.attr('src', thisElement.data('srchover')); }); hoverTriggerElement.bind('mouseout', function (event){ thisElement.attr('src', thisElement.data('srcbeforehover')); }); }); }); jQuery(window).bind('mousewheel DOMMouseScroll', function (event){ jQuery('body, html').stop(true, true); }); jQuery(window).bind('load resize scroll', function(event){ var winScrollTop = jQuery(window).scrollTop(); var winHeight = jQuery(window).height(); jQuery('img.wglLazyLoadInit').each(function(index){ var currentImg = jQuery(this); var offsetTop = parseInt(currentImg.offset().top); var srcMin = currentImg.data('srcmin') ? currentImg.data('srcmin') : ''; var widthCurrent = parseInt(currentImg.width()); var attrWidthCur = parseInt(typeof(currentImg.attr('width')) != 'undefined' ? currentImg.attr('width') : 0); var widthMin = parseInt(srcMin.replace(/.*@min/, '').replace(/\..*/, '')); if(offsetTop < winScrollTop + winHeight){ if(devicePixelRatio >= hdLimitDpr && typeof(currentImg.attr('data-src2x')) != 'undefined' && currentImg.attr('data-src2x') != '' && attrWidthCur < widthCurrent * 2){ currentImg.attr('src', currentImg.data('src2x')); } else if(typeof(currentImg.attr('data-srcmin')) != 'undefined' && currentImg.attr('data-srcmin') != '' && widthCurrent < widthMin && widthMin < attrWidthCur){ currentImg.attr('src', currentImg.data('srcmin')); } else if(typeof(currentImg.attr('data-src')) != 'undefined' && currentImg.attr('data-src') != ''){ currentImg.attr('src', currentImg.data('src')); } currentImg.removeClass('wglLazyLoadInit'); } }); jQuery('.wglAnimateIfVisibleOnce').each(function(index){ var currentElement = jQuery(this); var offsetTop = parseInt(currentElement.offset().top); if(offsetTop < winScrollTop + winHeight || location.href.indexOf('viewmode=print')){ currentElement.addClass('wglAnimateIfVisibleOnceVisible'); currentElement.removeClass('wglAnimateIfVisibleOnce'); } else{ } }); jQuery('.wglKeepInsideTopOnScroll').each(function(index){ var currentElement = jQuery(this); var offsetTop = parseInt(currentElement.offset().top); var diffTop = offsetTop - winScrollTop; var moveID = ''; if(diffTop < 0){ if(currentElement.attr('data-hasmoved') != '1'){ if(!jQuery('.wglContainerInsideTopOnScroll').length){ jQuery('body').prepend('
'); } currentElement.attr('data-hasmoved', '1'); moveID = String(parseInt(Math.random() * 1000000)); if(typeof(currentElement.attr('data-moveidsource')) == 'undefined'){ currentElement.attr('data-moveidsource', moveID); } else{ moveID = currentElement.attr('data-moveidsource'); } currentElement.before('
'); currentElement.removeAttr('data-moveidsource').attr('data-moveidtarget', moveID).removeClass('wglKeepInsideTopOnScroll').appendTo('.wglContainerInsideTopOnScroll'); } else{ height = jQuery(".wglContainerInsideTopOnScroll *[data-moveidtarget='" + currentElement.attr('data-moveidsource') + "']").height(); currentElement.css('height', String(height) + 'px'); } } else if(currentElement.attr('data-hasmoved') == '1'){ moveID = currentElement.attr('data-moveidsource'); currentElement.before(jQuery(".wglContainerInsideTopOnScroll *[data-moveidtarget='" + moveID + "']").addClass('wglKeepInsideTopOnScroll').removeAttr('data-hasmoved')); currentElement.remove(); } }); var idTopSection = '', titleSection = '', currentElement, nearestPositionTop = 100000, elementPositionTop = 0; var offsetTopFixed = jQuery('.wglContainerInsideTopOnScroll').outerHeight(); jQuery('.elementSection').each(function(index){ currentElement = jQuery(this); elementPositionTop = parseInt(currentElement.offset().top) - winScrollTop - offsetTopFixed; //console.log(elementPositionTop + '(' + (winHeight) + ') + ' + nearestPositionTop + ' : ' + currentElement.attr('id')); if(elementPositionTop < winHeight - 128 && (elementPositionTop >= 0 && elementPositionTop < nearestPositionTop || elementPositionTop < 0 && elementPositionTop * -1 < nearestPositionTop)){ nearestPositionTop = (elementPositionTop > 0 ? elementPositionTop : - elementPositionTop); titleSection = currentElement.attr('id'); } }); if(titleSection != '' && titleSection != wUiTmp['lastSectionSelected']){ jQuery(".elementNavigationSections li").removeClass('selected'); jQuery(".elementNavigationSections li > a[href='#" + titleSection + "']").parent().addClass('selected'); wUiTmp['lastSectionSelected'] = titleSection; } }); wAdaptParallax = function(event){ var winScrollTop = jQuery(window).scrollTop(); var winHeight = jQuery(window).height(); wUiTmp['lastEventType'] = event ? event.type : ''; if(winScrollTop == window['lastScrollTop']){ return; } else if(!window['lastScrollTop']){ wUiTmp['scrollDirection'] = winScrollTop > window['lastScrollTop'] ? 'down' : 'up'; wUiTmp['lastScrollTop'] = winScrollTop; } wUiTmp['lastScrollTop'] = winScrollTop if(typeof(wEditor) == 'undefined'){ jQuery('.wglParallaxBackground').each(function(index){ var currentElement = jQuery(this); var offsetTop = parseInt(currentElement.offset().top); var offsetHeight = parseInt(currentElement.height()); var posInsideTop = winScrollTop + winHeight - offsetTop; var posInsideBottom = offsetTop + offsetHeight - winScrollTop; if(posInsideTop > 0 && posInsideBottom > 0){ var posTopPercentage = posInsideTop / (offsetHeight + winHeight); var backgroundPositionTop = 0; var backgroundPositionLeft = 0; var direction = (currentElement.data('parallaxbackgrounddirection') ? currentElement.data('parallaxbackgrounddirection').toLowerCase() : 'bottom'); var speed = 1; try{ speed = (currentElement.data('parallaxbackgroundspeed') ? parseFloat(currentElement.data('parallaxbackgroundspeed')) : 1); } catch(e){ speed = 1; } if(direction.indexOf('right') != -1){ backgroundPositionLeft = '-' + String(Math.round(offsetHeight - posTopPercentage * offsetHeight) * speed) + 'px'; } else if(direction.indexOf('left') != -1){ backgroundPositionLeft = '-' + String(Math.round(posTopPercentage * offsetHeight) * speed) + 'px'; } if(direction.indexOf('top') != -1){ backgroundPositionTop = '-' + String(Math.round(posTopPercentage * offsetHeight) * speed) + 'px'; } else if(direction.indexOf('bottom') != -1 || direction == ''){ backgroundPositionTop = '-' + String(Math.round(offsetHeight - posTopPercentage * offsetHeight) * speed) + 'px'; } //if(wUiTmp['lastEventTypeBefore'] != wUiTmp['lastEventType']){ // wDocument.debug(wUiTmp['lastEventType'], 'a'); //} wUiTmp['lastEventTypeBefore'] = wUiTmp['lastEventType']; if(wUiTmp['isIOS']){ if(wUiTmp['lastEventType'] == 'touchmove'){ currentElement.css({'transform' : 'translate3d(0, 0, 0)', 'transition' : '', 'background-position' : backgroundPositionLeft + ' ' + backgroundPositionTop}); } else if(wUiTmp['lastEventType'] == 'touchend'){ //backgroundPositionTop = String(parseInt(backgroundPositionTop)+ (wUiTmp['scrollDirection'] == 'up' ? + 100 : - 100)) + 'px'; //currentElement.css({'transform' : 'translate3d(0, 0, 0)', 'transition' : 'background-position ease 0.6s', 'background-position-x' : backgroundPositionLeft, 'background-position-y' : backgroundPositionTop}); } else if(wUiTmp['lastEventType'] == 'scroll'){ currentElement.css({'transform' : 'translate3d(0, 0, 0)', 'transition' : 'background-position ease 0.6s', 'background-position' : backgroundPositionLeft + ' ' + backgroundPositionTop}); } } else{ currentElement.css({'background-position' : backgroundPositionLeft + ' ' + backgroundPositionTop}); } } }); jQuery('.wglParallaxContent').each(function(index){ var currentElement = jQuery(this).children().first(); var offsetTop = parseInt(currentElement.offset().top); var offsetHeight = parseInt(currentElement.height()); var posInsideTop = winScrollTop + winHeight - offsetTop; var posInsideBottom = offsetTop + offsetHeight - winScrollTop; if(posInsideTop > 0 && posInsideBottom > 0){ var posTopPercentage = posInsideTop / (offsetHeight + winHeight); var positionTop = 0; var positionLeft = 0; var direction = (currentElement.parent().data('parallaxcontentdirection') ? currentElement.parent().data('parallaxcontentdirection').toLowerCase() : 'left'); if(direction.indexOf('right') != -1){ var offsetWidth = parseInt(currentElement.width()); var parentOffsetWidth = parseInt(currentElement.parent().width()); var left = - (1 - posTopPercentage * 2) * offsetWidth; if(left > 0) left = 0; positionLeft = String(parseInt(left)) + 'px'; } else if(direction.indexOf('left') != -1){ var parentOffsetWidth = parseInt(currentElement.parent().width()); var left = (1 - posTopPercentage * 2) * parentOffsetWidth; if(left < 0) left = 0; positionLeft = String(parseInt(left)) + 'px'; } if(direction.indexOf('top') != -1){ var parentOffsetHeight = parseInt(currentElement.parent().height()); var top = (1 - posTopPercentage * 2) * parentOffsetHeight; if(top < 0) top = 0; positionTop = String(top) + 'px'; } else if(direction.indexOf('bottom') != -1 || direction == ''){ positionTop = String(posTopPercentage * offsetHeight) + 'px'; } currentElement.css({'transform' : 'translate3d(0, 0, 0)', 'margin-left' : positionLeft, 'margin-top' : positionTop}); } }); } }; window.setTimeout(function(event){ wAdaptParallax(event); }, 320); jQuery(window).bind("load resize scroll", function(event){ wAdaptParallax(event); }); jQuery('body').bind("load touchmove", function(event){ wAdaptParallax(event); }); jQuery(window).bind("touchend", function(event){ wAdaptParallax(event); }); jQuery(window).bind('load resize', function(){ var hasChangedMediaQuery = false; jQuery('#wMediaqueriesTmp > div').each(function(index){ if(window.getComputedStyle){ var computedStyle = window.getComputedStyle(jQuery(this).get(0)); var fontFamily = computedStyle.fontFamily.replace(/"/g, ''); var lastMediaQuery = jQuery(this).data('lastmediaquery') || ''; if(fontFamily != lastMediaQuery){ //console.log(fontFamily + ' != ' + lastMediaQuery + ' :' + fontFamily.indexOf('mediaquery_')); if(fontFamily.indexOf('mediaquery_') == 0){ eval('if(typeof(' + fontFamily + '_onactivate) == \'function\'){' + fontFamily + '_onactivate();}'); } else if(lastMediaQuery.indexOf('mediaquery_') == 0){ eval('if(typeof(' + lastMediaQuery + '_ondeactivate) == \'function\'){' + lastMediaQuery + '_ondeactivate();}'); } jQuery(this).data('lastmediaquery', fontFamily); hasChangedMediaQuery = true; } } }); if(hasChangedMediaQuery){ jQuery("img[data-srcmin]").each(function(){ var currentImg = jQuery(this); var widthOrig = parseInt(typeof(currentImg.attr('widthorig')) != 'undefined' ? currentImg.attr('data-widthorig') : currentImg.attr('width')); var srcMin = currentImg.data('srcmin') ? currentImg.data('srcmin') : ''; var widthCurrent = parseInt(currentImg.width()); var attrWidthCur = parseInt(typeof(currentImg.attr('width')) != 'undefined' ? currentImg.attr('width') : 0); var widthMin = parseInt(srcMin.replace(/.*@min/, '').replace(/\..*/, '')); var widthOuter = parseInt(currentImg.closest('.elementStandard').width()); var diffWidthFrame = 0; if(currentImg.parent().parent().parent().parent().hasClass('picture')){ diffWidthFrame = currentImg.parent().parent().parent().parent().outerWidth() - widthCurrent; } else if(currentImg.parent().parent().hasClass('picture')){ diffWidthFrame = currentImg.parent().parent().outerWidth() - widthCurrent; } if(widthOuter > widthOrig + diffWidthFrame + 1 && widthMin > widthOrig){ currentImg.attr('src', srcMin); if(typeof(currentImg.attr('width')) != 'undefined' && currentImg.attr('width') != ''){ currentImg.attr('data-widthorig', currentImg.attr('width')); currentImg.removeAttr('width'); currentImg.attr('height', 'auto'); } } }); } }); jQuery(window).bind('load resize', function(){ jQuery('.wglExpandToHeighestChild').each(function(index){ var currentElement = jQuery(this); var maxHeight = 0; currentElement.children('*').each(function(index){ if(jQuery(this).attr('data-adjusttoheighestchild') != 'no' && jQuery(this).outerHeight(true) > maxHeight){ maxHeight = jQuery(this).outerHeight(true); } }); if(maxHeight > 0){ currentElement.css('height', String(maxHeight) + 'px'); } }); jQuery('.wglExpandToParent').each(function(index){ var currentElement = jQuery(this); var height = jQuery(this).parent().height(); currentElement.css('height', String(height) + 'px'); }); wProcessWglAdjustHeightMax(); }); jQuery('.wglAddScrollTop').each(function(index){ var currentElement = jQuery(this); if(currentElement.context.tagName.toLowerCase() == 'body'){ currentElement.append('
200){ jQuery('#scrollTop').fadeIn(); } else{ jQuery('#scrollTop').fadeOut(); } }); }); jQuery('.wglAddFontResizer').each(function(index){ var currentElement = jQuery(this); currentElement.prepend('
AA'); } }); if(('ontouchstart' in window) || navigator.msMaxTouchPoints || window.DocumentTouch && document instanceof DocumentTouch){ jQuery('.wglNavigationOptimizeTouch li li:not(:has(ul))').each(function(index){ //jQuery(this).css({'border' : 'solid 4px blue'}); jQuery(this).bind('click touchstart', function(event){ event.stopPropagation(); }); }); jQuery('.wglNavigationOptimizeTouch li.navLevel1Open, .wglNavigationOptimizeTouch li.navLevel1OpenSelected, .wglNavigationOptimizeTouch li.navLevel1OpenDescendantSelected').each(function(index){ //jQuery(this).css({'border' : 'solid 4px red'}); jQuery(this).bind('click', function(event){ if(event.pointerType && event.pointerType == 'mouse'){ } else if(event.target.getAttribute('data-has-already-touched') == '1'){ } else{ event.preventDefault(); event.target.setAttribute('data-has-already-touched', '1'); } }); }); } } jQuery('.wglClickable').css({'cursor': 'pointer'}); jQuery(window).bind('load', function(){ if(document.documentElement && !/MSIE (6|7|8)/.test(navigator.appVersion)){ window.setTimeout(function(){ document.documentElement.className = document.documentElement.className + ' pagestatus-loaded'; }, 1000); } jQuery('.wglOverflowXTouch').each(function(index){ var currentElement = jQuery(this); var widthOuter = currentElement.width(); var widthInner = currentElement.children('*').outerWidth(); if(widthInner <= widthOuter){ return false; } else{ var lastElementInner = currentElement.children('*').children('*:last'); var offsetRightLastElementInner = lastElementInner.get(0).offsetLeft + lastElementInner.outerWidth() + parseInt(lastElementInner.css('margin-right')); currentElement.children('*').children('*').each(function(index){ jQuery(this).css('width', jQuery(this).width()); }); lastElementInner.parent().css({'width' : String(offsetRightLastElementInner) + 'px'}) } jQuery(this).find('img').attr('unselectable', 'on'); jQuery('body').bind('touchstart mousedown', function(event){ if(jQuery(event.target).closest(currentElement).length != 0){ event.preventDefault(); } }); jQuery('body').bind("touchmove mousemove", function(event){ if(jQuery('body').data('wtouchelement')){ var mouseXDiff = (event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX) - jQuery('body').data('wtouchmousex'); var mouseYDiff = (event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY) - jQuery('body').data('wtouchmousey'); jQuery('body').data('wtouchmousex', event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX); jQuery('body').data('wtouchmousey', event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY); jQuery('body').data('wtouchlastdiffx', mouseXDiff); jQuery('body').data('wtouchlastdiffy', mouseYDiff); var milliseconds = (new Date()).getTime(); var timeDiff = milliseconds - jQuery('body').data('timestamplast'); jQuery('body').data('timestampbefore', jQuery('body').data('timestamplast')); jQuery('body').data('timestamplast', milliseconds); var speedX = Math.round(100 * (mouseXDiff > 0 ? mouseXDiff : -mouseXDiff) / timeDiff) + 1; jQuery('body').data('wtouchspeedX', speedX); var touchDiffX = jQuery('body').data('wtouchmousex') - jQuery('body').data('wtouchstartmousex'); jQuery('body').data('wtouchdiffx', touchDiffX); var widthOuter = parseInt(jQuery('body').data('wtouchelement').width()); var left = parseInt(jQuery('body').data('wtouchelement').children('*').css('margin-left')); left = isNaN(left) ? 0 : left; var right = parseInt(jQuery('body').data('wtouchelement').width()) - parseInt(jQuery('body').data('wtouchelement').children('*').css('margin-left')) - jQuery('body').data('wtouchelement').children('*').width(); right = isNaN(right) ? 0 : right; if(left > 32){ jQuery('body').data('wtouchelement').children('*').animate({'margin-left' : 0}); jQuery('body').removeData('wtouchelement'); return false; } else if(right > 32){ jQuery('body').data('wtouchelement').children('*').animate({'margin-left' : String(parseInt(jQuery('body').data('wtouchelement').width()) - parseInt(jQuery('body').data('wtouchelement').children('*').width())) + 'px'}); jQuery('body').removeData('wtouchelement'); return false; } if(jQuery('body').data('wtouchelement').data('wtouchstartmarginleft') + touchDiffX < 0){ jQuery('body').data('wtouchelement').children('*').css({'margin-left' : String(jQuery('body').data('wtouchelement').data('wtouchstartmarginleft') + touchDiffX) + 'px'}); } else{ jQuery('body').data('wtouchelement').children('*').css({'margin-left' : String(jQuery('body').data('wtouchelement').data('wtouchstartmarginleft') + touchDiffX) + 'px'}); } } }); jQuery(this).bind('touchstart mousedown', function(event){ jQuery(this).children('*').stop(); jQuery('body').data('wtouchelement', jQuery(this)); jQuery(this).data('wtouchstartmarginleft', parseInt(jQuery(this).children('*').css('margin-left'))); jQuery(this).data('wtouchstartmargintop', parseInt(jQuery(this).children('*').css('margin-top'))); jQuery('body').data('wtouchstartmousex', event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX); jQuery('body').data('wtouchstartmousey', event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY); }); jQuery('body').bind("touchend mouseup", function(event){ if(jQuery('body').data('wtouchelement')){ var milliseconds = (new Date()).getTime(); var timeDiff = milliseconds - jQuery('body').data('timestamplast'); var touchDiffX = jQuery('body').data('wtouchdiffx'); var lastDiffX = jQuery('body').data('wtouchlastdiffx'); var lastDiffXn = lastDiffX >= 0 ? lastDiffX : -lastDiffX; if(lastDiffXn > 1){ var speedX = (Math.round((lastDiffXn > 0 ? lastDiffXn : -lastDiffXn) / timeDiff) + 1) * 5; if(speedX > 200){ speedX = 200; } var movingWidth = Math.round(touchDiffX * 2 * (1 + speedX / 100)); if(jQuery('body').data('wtouchdiffx') < 0){ var right = parseInt(jQuery('body').data('wtouchelement').width()) - parseInt(jQuery('body').data('wtouchelement').children('*').css('margin-left')) - jQuery('body').data('wtouchelement').children('*').width(); if(movingWidth < right){ movingWidth = right; } var duration = (movingWidth > 0 ? movingWidth : -movingWidth) * 1.5 + Math.round(100 / speedX); jQuery('body').data('wtouchelement').children('*').animate({'margin-left' : '+=' + String(movingWidth)}, {'duration' : duration, 'easing' : 'wEaseOutScroll'}); } else{ var left = parseInt(jQuery('body').data('wtouchelement').children('*').css('margin-left')); if(-movingWidth < left){ movingWidth = -left; } var duration = (movingWidth > 0 ? movingWidth : -movingWidth) * 1.5 + Math.round(100 / speedX); jQuery('body').data('wtouchelement').children('*').animate({'margin-left' : '+=' + String(movingWidth)}, {'duration' : duration, 'easing' : 'wEaseOutScroll'}); } } jQuery('body').removeData('wtouchelement'); } }); }); }); }); jQuery.extend(jQuery.easing, { wEaseOutScroll: function(x, t, b, c, d){ return (t == d) ? b + c : b + c * (-Math.pow(1.5, -20 * t / d) + 1); } }); function wScrollSmoothToTarget(element, event){ var id, href = element.getAttribute('href'), offsetTopFixed, targetName, elementTarget, scrollTop; if(/(#.*)/.test(href)){ targetName = RegExp.$1; elementTarget = jQuery(targetName); if(elementTarget.length > 0){ console.log(elementTarget); event.preventDefault(); jQuery(element).parent().parent().find('li').removeClass('selected'); jQuery(element).parent().addClass('selected'); if(history.pushState){ history.pushState(null, null, targetName); } jQuery('body, html').stop(true, true); offsetTopFixed = jQuery('.wglContainerInsideTopOnScroll').height(); jQuery('body, html').animate({scrollTop: elementTarget.offset().top - offsetTopFixed}, {complete: function(){ offsetTopFixed = jQuery('.wglContainerInsideTopOnScroll').height(); if(offsetTopFixed > 0){ jQuery('body, html').animate({scrollTop: elementTarget.offset().top - offsetTopFixed}, 400); } }}, 800); return false; } } } wOptimizePictureSizes = function(){ jQuery("img[data-src2x]:not(.wglLazyLoadInit)").each(function(){ var currentImg = jQuery(this); if(devicePixelRatio >= hdLimitDpr && typeof(currentImg.attr('data-src2x')) != 'undefined' && currentImg.attr('data-src2x') != '' && currentImg.attr('width') < currentImg.width() * 2){ currentImg.attr('src', currentImg.data('src2x')); } else if(typeof(currentImg.attr('data-src2x')) != 'undefined' && currentImg.attr('data-src2x') != '' && currentImg.attr('width') < currentImg.width()){ currentImg.attr('src', currentImg.data('src2x')); } }); }; wProcessWglAdjustHeightMax = function(){ jQuery('.wglAdjustHeightMax').each(function(index){ var currentElement = jQuery(this); var offsetLeft = 0; var maxHeight = 0; var adjust = true; var positionCol = 0; var childsToAdapt = new Array(); var numberChilds = 0; currentElement.children('*').each(function(index){ var className = jQuery(this).attr('class') || ''; if(className.toLowerCase().indexOf('clear') == -1 && className.toLowerCase().indexOf('editor') == -1){ numberChilds++; } }); currentElement.children('*').each(function(index){ var className = jQuery(this).attr('class') || ''; if(className.toLowerCase().indexOf('clear') == -1 && className.toLowerCase().indexOf('editor') == -1){ if(jQuery(this).data('wHasSetHeightToAjustHeightMax') == '1'){ jQuery(this).css({'height' : ''}); } offsetLeft = jQuery(this).get(0).offsetLeft - jQuery(this).get(0).parentNode.offsetLeft; if(index > 0 && offsetLeft == 0 && jQuery(this).css('position') != 'absolute'){ if(positionCol == 1){ childsToAdapt = new Array(); maxHeight = 0; } positionCol = 0; } positionCol++; if(numberChilds - index == 1){ maxHeight = jQuery(this).outerHeight() > maxHeight ? jQuery(this).outerHeight() : maxHeight; childsToAdapt.push(jQuery(this)); } //console.log(index + ', ' + offsetLeft + ', ' + positionCol + ', ' + numberChilds + ', ' + index + ', ' + childsToAdapt.length); //console.log(maxHeight); if(childsToAdapt.length > 1 && (index > 0 && positionCol == 1 || numberChilds - index == 1)){ //console.log(childsToAdapt); for(i = 0; i < childsToAdapt.length; i++){ childToAdapt = childsToAdapt[i]; var className = childToAdapt.attr('class') || ''; if(className.toLowerCase().indexOf('clear') == -1 && className.toLowerCase().indexOf('editor') == -1 ){ childToAdapt.css({'height' : maxHeight}); childToAdapt.data('wHasSetHeightToAjustHeightMax', '1'); } } childsToAdapt = new Array(); maxHeight = 0; } maxHeight = jQuery(this).outerHeight() > maxHeight ? jQuery(this).outerHeight() : maxHeight; childsToAdapt.push(jQuery(this)); } }); }); }; jQuery.fn.wAccordion = function(options){ var maxHeightContent = 0; jQuery.each(jQuery(this), function(){ jQuery(this).children('.accordionContent').each(function(index){ var heightContent = jQuery(this).height(); if(heightContent > maxHeightContent){ maxHeightContent = heightContent; } }); jQuery(this).children('h3').each(function(index){ if(options['collapsible']){ jQuery(this).addClass('accordionHeaderCollapsible').removeClass('accordionHeaderNoneCollapsible'); } else{ jQuery(this).addClass('accordionHeaderNoneCollapsible').removeClass('accordionHeaderCollapsible'); } if(typeof(options['active']) == 'number' && options['active'] == index){ jQuery(this).addClass('accordionHeaderVisible').removeClass('accordionHeaderHidden'); jQuery(this).next('.accordionContent').addClass('accordionContentVisible').removeClass('accordionContentHidden').show(); } else{ jQuery(this).addClass('accordionHeaderHidden').removeClass('accordionHeaderVisible'); jQuery(this).next('.accordionContent').addClass('accordionContentHidden').removeClass('accordionContentVisible').hide(); } if(options['heightStyle'] == 'auto'){ jQuery(this).next('.accordionContent').css({'height' : maxHeightContent}); } jQuery(this).bind('click', function(event){ event.preventDefault(); var headerSelected = jQuery(this); var contentSelected = jQuery(this).next('.accordionContent'); jQuery(this).parent().children('.accordionContent').each(function(index){ if(jQuery(this).get(0) == contentSelected.get(0)){ if(jQuery(this).hasClass('accordionContentVisible')){ if(options['collapsible']){ jQuery(this).parent().trigger('accordionbeforeactivate', {'newHeader' : contentSelected}); jQuery(this).prev('.accordionHeader').addClass('accordionHeaderHidden').removeClass('accordionHeaderVisible'); jQuery(this).addClass('accordionContentHidden').removeClass('accordionContentVisible').slideUp('normal', function(){ jQuery(this).parent().trigger('accordionchange', {'newHeader' : headerSelected}); }); } } else{ jQuery(this).prev('.accordionHeader').addClass('accordionHeaderVisible').removeClass('accordionHeaderHidden'); if(options['collapsible']){ jQuery(this).prev('.accordionHeader').addClass('accordionHeaderCollapsible').removeClass('accordionHeaderNoneCollapsible'); } else{ jQuery(this).prev('.accordionHeader').addClass('accordionHeaderNoneCollapsible').removeClass('accordionHeaderCollapsible'); } jQuery(this).addClass('accordionContentVisible').removeClass('accordionContentHidden').slideDown('normal', function(){ jQuery(this).parent().trigger('accordionchange', {'newHeader' : headerSelected}); }); } } else if(options['multiple'] == true){ } else{ //jQuery(this).parent().trigger('accordionbeforeactivate', {'newHeader' : headerSelected}); jQuery(this).prev('.accordionHeader').addClass('accordionHeaderHidden').removeClass('accordionHeaderVisible'); jQuery(this).addClass('accordionContentHidden').removeClass('accordionContentVisible').slideUp('normal'); } }); }); }); }); }; wLightboxClose = function(){ jQuery('.wLightbox').remove(); jQuery('body').removeClass('wglBox'); jQuery(document).unbind('keydown'); }; jQuery.fn.wLightbox = function(options){ jQuery.each(jQuery(this), function(){ jQuery(this).click(function(){ var objectCurrent = jQuery(this); var elementCurrent = objectCurrent.get(0); var widthAttrib = options['width'] ? options['width'] : '80%'; var heightAttrib = options['height'] ? options['height'] : '80%'; var lightboxClassName = 'wLightbox-' + (options['class'] ? options['class'] : 'default'); var contentWidth = 0; var contentHeight = 0; var src = jQuery(this).attr('href'); var rel = jQuery(this).attr('rel'); var elementsRel = jQuery("*[rel = '" + rel + "']"); var numberRel = elementsRel.length; var positionRel = 1; for(i = 0; i < numberRel; i++){ if(elementsRel[i] == elementCurrent){ positionRel = i + 1; break; } } var classPrev = 'wLightboxPrev' + (numberRel > 1 && positionRel > 1 ? ' wLightboxPrevAvailable' : ''); var classNext = 'wLightboxNext' + (numberRel > 1 && positionRel < numberRel ? ' wLightboxNextAvailable' : ''); if(/\.(jpg|jpeg|gif|png)$/i.test(src) || objectCurrent.attr('data-lightboxtype') == 'image'){ var image = new Image(); jQuery('.wLightbox').removeClass('wLightboxStatusLoaded').addClass('wLightboxStatusLoading'); image.onload = function(){ var imageRatio = image.width / image.height; var lightboxWidth = image.width; var lightboxHeight = image.height; var boxWasOpened = true; var titleInnerHTML = ''; if(jQuery('.wLightbox').length == 0){ jQuery('
' + titleInnerHTML + '
').appendTo('body'); jQuery(document).bind('keydown', function(e){ if(e.keyCode == 27){ wLightboxClose(); } else if(e.keyCode == 37){ jQuery(elementsRel[parseInt(jQuery('.wLightboxPrev').data('entry'))]).trigger('click'); } else if(e.keyCode == 39){ jQuery(elementsRel[parseInt(jQuery('.wLightboxNext').data('entry'))]).trigger('click'); } }); boxWasOpened = false; } if(elementCurrent.getAttribute('title') && elementCurrent.getAttribute('title') != ''){ jQuery('.wLightboxTitle').show().html(elementCurrent.getAttribute('title')); } else{ jQuery('.wLightboxTitle').hide(); } if(objectCurrent.attr('data-lightboxdownloadable') == '1'){ jQuery('.wLightboxDownload').remove(); jQuery('.wLightboxFooter').addClass('wLightboxFooterHasDownload').append('
'); jQuery('.wLightboxDownload').bind('click', function (event){ window.open(jQuery(this).data('src')); }); } else{ jQuery('.wLightboxFooter').removeClass('wLightboxFooterHasDownload'); } //var heightTitle = 0; //if(elementCurrent.getAttribute('title') && elementCurrent.getAttribute('title') != '' && elementCurrent.getAttribute('title').length){ // if(elementCurrent.getAttribute('title').length > 480){ // heightTitle = 128; // } // else{ // heightTitle = 35; // } //} heightTitle = jQuery('.wLightboxFooter').outerHeight(); var maxWidthBox = (window.innerWidth ? window.innerWidth : (document.documentElement ? document.documentElement.offsetWidth : document.body.clientWidth)) - (parseInt(jQuery('.wLightboxOuter').css('padding-left')) + parseInt(jQuery('.wLightboxInner').css('border-left-width'))) * 2; var maxHeightBox = (window.innerHeight ? window.innerHeight : (document.documentElement ? document.documentElement.offsetHeight : document.body.clientHeight)) - (parseInt(jQuery('.wLightboxOuter').css('padding-top')) + parseInt(jQuery('.wLightboxInner').css('border-top-width'))) * 2 - heightTitle; if(/^(\d+)px$/.test(options['width'])){ maxWidthBox = parseInt(RegExp.$1); } else if(/^(\d+)%$/.test(options['width'])){ maxWidthBox = parseInt(jQuery(window).width()) * RegExp.$1 / 100; } var pageRatio = maxWidthBox / maxHeightBox; if(image.width > maxWidthBox || image.height > maxHeightBox){ if(imageRatio > pageRatio){ lightboxWidth = maxWidthBox; lightboxHeight = Math.round(maxWidthBox / imageRatio) + heightTitle; } else{ lightboxWidth = Math.round(maxHeightBox * imageRatio); lightboxHeight = maxHeightBox + heightTitle; } } else{ lightboxHeight = lightboxHeight + heightTitle; } widthAttrib = String(lightboxWidth) + 'px'; heightAttrib = String(lightboxHeight) + 'px'; jQuery('.wLightboxOuter').css({'height' : heightAttrib}); jQuery('.wLightboxInner').css({'width' : widthAttrib}); jQuery('.wLightboxPrev').data('entry', positionRel - 2); jQuery('.wLightboxNext').data('entry', positionRel); if(boxWasOpened){ jQuery('.wLightboxPrev').attr('class', classPrev); jQuery('.wLightboxNext').attr('class', classNext); jQuery('.wLightboxImage').attr('src', src); jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading'); } else{ jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading'); jQuery('.wLightboxOuter, .wLightboxBackground').bind('click', function(event){ wLightboxClose() }); jQuery('.wLightboxPrev, .wLightboxNext').bind('click', function(event){ jQuery('.wLightbox').removeClass('wLightboxStatusLoaded'); jQuery(elementsRel[jQuery(this).data('entry')]).trigger('click'); event.stopPropagation(); }); } } image.src = src; } else{ var boxWasOpened = true; if(jQuery('.wLightbox').length == 0){ jQuery('
').appendTo('body'); jQuery('.wLightboxCloser, .wLightboxBackground').bind('mousedown touchstart', function(){wLightboxClose()}); jQuery(document).bind('keydown', function(e){ if(e.keyCode == 27){ wLightboxClose(); } else if(e.keyCode == 37){ jQuery(elementsRel[parseInt(jQuery('.wLightboxPrev').data('entry'))]).trigger('click'); } else if(e.keyCode == 39){ jQuery(elementsRel[parseInt(jQuery('.wLightboxNext').data('entry'))]).trigger('click'); } }); boxWasOpened = false; } var heightTitle = 0; //if(titleInnerHTML != ''){ //jQuery('.wLightboxTitle').show().html(titleInnerHTML); //} if(elementCurrent.getAttribute('title') != ''){ jQuery('.wLightboxTitle').show().html(elementCurrent.getAttribute('title')); } else{ jQuery('.wLightboxTitle').hide(); } //var heightTitle = 0; //if(elementCurrent.getAttribute('title') && elementCurrent.getAttribute('title') != '' && elementCurrent.getAttribute('title').length){ // if(elementCurrent.getAttribute('title').length > 480){ // heightTitle = 128; // } // else{ // heightTitle = 35; // } //} heightTitle = jQuery('.wLightboxTitle').outerHeight(); var maxWidthBox = (window.innerWidth ? window.innerWidth : (document.documentElement ? document.documentElement.offsetWidth : document.body.clientWidth)) - (parseInt(jQuery('.wLightboxOuter').css('padding-left')) + parseInt(jQuery('.wLightboxInner').css('border-left-width'))) * 2; var maxHeightBox = (window.innerHeight ? window.innerHeight : (document.documentElement ? document.documentElement.offsetHeight : document.body.clientHeight)) - (parseInt(jQuery('.wLightboxOuter').css('padding-top')) + parseInt(jQuery('.wLightboxInner').css('border-top-width'))) * 2 - heightTitle; if(/^(\d+)px$/.test(options['width'])){ maxWidthBox = parseInt(RegExp.$1); } else if(/^(\d+)%$/.test(options['width'])){ maxWidthBox = parseInt(jQuery(window).width()) * RegExp.$1 / 100; } if(/^(\d+)px$/.test(options['height'])){ maxHeightBox = parseInt(RegExp.$1); } else if(/^(\d+)%$/.test(options['height'])){ maxHeightBox = parseInt(jQuery(window).height()) * RegExp.$1 / 100; } if(options && options['width'] && /^\d+(.\d+)?$/.test(options['width'])){ contentWidth = options['width']; } else{ contentWidth = maxWidthBox; } if(options && options['height'] && /^\d+(.\d+)?$/.test(options['height'])){ contentHeight = options['height']; } else{ contentHeight = maxHeightBox; } var pageRatio = maxWidthBox / maxHeightBox; var contentRatio = contentWidth / contentHeight; var lightboxWidth = contentWidth; var lightboxHeight = contentHeight + heightTitle; if(contentWidth > maxWidthBox || contentHeight > maxHeightBox){ if(contentRatio > pageRatio){ lightboxWidth = maxWidthBox; lightboxHeight = Math.round(maxWidthBox / contentRatio) + heightTitle; } else{ lightboxWidth = Math.round(maxHeightBox * contentRatio); lightboxHeight = maxHeightBox + heightTitle; } } widthAttrib = String(lightboxWidth) + 'px'; heightAttrib = String(lightboxHeight) + 'px'; jQuery('.wLightboxOuter').css({'height' : heightAttrib}); jQuery('.wLightboxInner').css({'width' : widthAttrib}); jQuery('.wLightboxPrev').data('entry', positionRel - 2); jQuery('.wLightboxNext').data('entry', positionRel); if(boxWasOpened){ jQuery('.wLightboxPrev').attr('class', classPrev); jQuery('.wLightboxNext').attr('class', classNext); jQuery('.wLightboxImage').attr('src', src); jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading'); } else{ jQuery('.wLightbox').addClass('wLightboxStatusLoaded').removeClass('wLightboxStatusLoading'); jQuery('.wLightboxOuter, .wLightboxBackground').bind('click', function(){ wLightboxClose() }); jQuery('.wLightboxPrev, .wLightboxNext').bind('click', function(){ jQuery('.wLightbox').removeClass('wLightboxStatusLoaded'); jQuery(elementsRel[jQuery(this).data('entry')]).trigger('click'); event.stopPropagation(); }); } } jQuery('body').addClass('wglBox'); return false; }); }); };