////////////////////////////////////
//
// Locale switcher menu plugin
//
////////////////////////////////////
;(function ( $, window, document ) {
"use strict";
var pluginName = "languageMenu";
function Plugin ( element, language ) {
this.element = element;
this._name = pluginName;
this.menu = $(this.element).children('ul');
this.activeLanguage = $(this.element).attr('data-active-lang');
this.languages = this.menu.find('[data-lang]').get().map(function(value) {
return $(value).attr('data-lang');
});
this.init();
this.setLanguage((typeof language === 'string' ? language : this.activeLanguage));
}
$.extend(Plugin.prototype, {
init: function () {
this.menu.hide();
$(this.element).on('click.langDropdown', 'a:first-child', function(e) {
e.preventDefault;
this.menu.toggle();
}.bind(this)).
on('click.langDropdown', 'ul a', function(e) {
e.preventDefault;
e.stopPropagation();
if (!this.setLanguage($(e.target).parent().attr('data-lang'))) return;
this.menu.hide();
if ($(e.target).is('a') && typeof $(this).attr('href') === 'string') window.location = e.target.href;
}.bind(this));
$(document).off('.langDropdown').on('click.langDropdown', function(e) {
if ($.contains(this.element, e.target)) return;
this.menu.hide();
}.bind(this));
},
setLanguage: function(lang) {
if (this.languages.indexOf(lang) < 0) return false;
this.setActiveLang(lang);
var activeMenuItem = this.menu.find('li[data-lang="' + this.activeLanguage + '"]');
activeMenuItem.hide().siblings('li').not('[data-lang="' + this.activeLanguage + '"]').show();
$(this.element).children('a').find('span').html(activeMenuItem.find('a').html());
return true;
},
setActiveLang: function(lang) {
this.activeLanguage = lang;
$(this.element).attr('data-active-lang', lang);
}
});
$.fn[ pluginName ] = function () {
return this.each(function() {
if ( !$.data( this, "plugin_" + pluginName ) ) {
$.data( this, "plugin_" + pluginName, new Plugin( this ) );
}
});
};
})( jQuery, window, document );
////////////////////////////////////
//
// Form input plugin
//
////////////////////////////////////
;(function ( $, window, document ) {
'use strict';
var pluginName = 'setInputValues';
function Plugin ( element ) {
this.element = element;
this.init();
}
$.extend(Plugin.prototype, {
init: function () {
var inputs = $(this.element)
.find('.form-group.validate')
.find('input[type="text"], input[type="email"], input[type="password"]')
.on('keyup blur', function(e) {
$(this).attr('value', $(this).val());
});
inputs.each(function() {
if ($(this).val().length == 0) {
$(this).attr('value', '');
}
});
}
});
$.fn[ pluginName ] = function () {
return this.each(function () {
if ( !$.data( this, 'plugin_' + pluginName ) ) {
$.data( this, 'plugin_' + pluginName, new Plugin( this ) );
}
});
};
})( jQuery, window, document );
;(function ( $, window, document ) {
'use strict';
var pluginName = 'inputErrorDisplay';
function Plugin ( element, errors ) {
this.errors = {};
if (typeof errors === 'object') {
this.errors = errors;
}
this.element = element;
this.init();
}
$.extend(Plugin.prototype, {
init: function () {
var groups = $(this.element)
.find('.form-group.validate')
.find('input[type="text"], input[type="email"], input[type="password"]');
var self = this;
groups.each(function () {
var name = $(this).parent().attr('data-name');
if (self.errors[name]) {
$(this).after('
' + self.errors[name] + '
');
}
});
}
});
$.fn[ pluginName ] = function (errors) {
return this.each(function() {
if ( !$.data( this, 'plugin_' + pluginName ) ) {
$.data( this, 'plugin_' + pluginName, new Plugin( this, errors ) );
}
});
};
})( jQuery, window, document );
////////////////////////////////////
//
// Form response display plugin
//
////////////////////////////////////
;(function ( $, window, document ) {
'use strict';
var pluginName = 'formResponseDisplay';
var defaults = {
position: 'before',
classes: ['bg-beige-light']
};
function Plugin ( element, messages, options ) {
this.messages = {};
if (typeof messages === 'object') {
this.messages = messages;
}
this.options = defaults;
if (typeof options === 'object') {
this.options = $.extend({}, defaults, options);
}
this.element = element;
this.display = null;
this.init();
}
$.extend(Plugin.prototype, {
init: function () {
var html = ''
switch (this.options.position) {
case 'before':
$(this.element).before(html);
break;
case 'after':
$(this.element).after(html);
break;
default:
$(this.element).before(html);
break;
}
this.display = $(this.element).siblings('.request-result');
this.display.addClass(this.options.classes.join(' '));
},
clear: function () {
this.display.children('ul').children().remove();
return this;
},
show: function(messages, data) {
var displayMessages = this.compileMessages(data);
messages.forEach(function (value, index) {
if (displayMessages[value]) {
this.display.children('ul').append('' + displayMessages[value] + '');
}
}.bind(this));
this.display.toggleClass('show');
return this;
},
hide: function() {
if (!this.display.hasClass('show')) {
return this;
}
this.display.toggleClass('show');
return this;
},
compileMessages: function(data) {
var obj = {};
Object.keys(this.messages).forEach(function (msgKey, index) {
obj[msgKey] = this.messages[msgKey];
Object.keys(data).forEach(function (dataKey, index) {
var newStr = obj[msgKey].replace(new RegExp('(%' + dataKey + '%)', 'g'), ''+data[dataKey]);
obj[msgKey] = newStr;
});
}.bind(this));
return obj;
}
});
$.fn[ pluginName ] = function (messages, options) {
return this.each(function() {
if ( !$.data( this, 'plugin_' + pluginName ) ) {
$.data( this, 'plugin_' + pluginName, new Plugin( this, messages, options ) );
}
});
};
})( jQuery, window, document );
////////////////////////////////////
//
// Load on first scroll plugin
//
////////////////////////////////////
;(function ( $, window, document ) {
'use strict';
var pluginName = 'onFirstScroll';
function Plugin ( element, callback ) {
this.element = element;
this.eventNs = '';
this.callback = function () {
};
if (typeof callback === 'function') {
this.callback = callback;
}
this.init();
}
$.extend(Plugin.prototype, {
init: function () {
var eventNs = $(this.element).attr('data-first-scroll')
this.eventNs = (eventNs) ? '.' + eventNs : '.first-scroll';
if (this.inViewport()) {
this.callback.call($(this.element)[0], null);
return;
}
$(window).on('scroll' + this.eventNs, function(e) {
this.callback.call($(this.element)[0], e);
$(window).off(this.eventNs);
}.bind(this));
},
inViewport: function () {
if (Math.ceil($(this.element)[0].getBoundingClientRect().top) < $(window).height()) {
return true;
}
return false;
}
});
$.fn[ pluginName ] = function (callback) {
return this.each(function() {
if ( !$.data( this, 'plugin_' + pluginName ) ) {
$.data( this, 'plugin_' + pluginName, new Plugin( this, callback ) );
}
});
};
})( jQuery, window, document );
////////////////////////////////////
//
// Init page
//
////////////////////////////////////
$(function() {
$('header').find('li.language-switch').languageMenu();
$('.acceptCookie').find('a.btn.cookieConsent').click(function(e){
e.preventDefault();
var date = new Date();
date.setTime(date.getTime() + (1825*24*60*60*1000)); // 5 years = 1825 days
document.cookie = "acceptCookies=accepted; expires=" + date.toGMTString() + "; domain=.dll-files.com; path=/;";
$('.acceptCookie').fadeOut(function () {
$(this).remove();
});
location.reload();
});
$('section.client-video').find('img').onFirstScroll(function (e) {
$(this).attr('src', '/assets/img/client-animation-47.gif');
});
$('a[href^="#"]').click(function(e) {
e.preventDefault();
var dest = $(this).attr('href');
if (dest.length < 2) return;
$('html,body').animate({
scrollTop: $(dest).offset().top
}, 'slow');
});
});
////////////////////////////////////
//
// Preferred Language
//
////////////////////////////////////
(function ( $, window, document ) {
$(document).ready(function () {
if (document.cookie.indexOf('preferredLanguage=') < 0){
$(window).scroll(function () {
if ($(window).scrollTop() > 1) {
if($(window).width() < 700){
if($("#lang-suggestion .lgs-vertical-space").length < 1){
$("#lang-suggestion .lgs-text").after("");
}
}
$("#lang-suggestion .lgs-suggestion").show();
}
if ($(window).scrollTop() < 1) {
$("#lang-suggestion .lgs-suggestion").hide();
}
});
}
$("#lang-suggestion .lgs-icon").on("click", function(){
var date = new Date();
date.setTime(date.getTime() + (30*24*60*60*1000));
document.cookie = "preferredLanguage=accepted; expires=" + date.toGMTString() + "; domain=.dll-files.com; path=/;";
$("#lang-suggestion").fadeOut(function () {
$(this).remove();
});
});
});
})( jQuery, window, document );
(function ($) {
$(document).ready(function () {
$("button.tlfbtn").click(function(e){
if($("#tlfnav.tlfcollapse").get(0)){
$("#tlfnav").removeClass("tlfcollapse");
}else{
$("#tlfnav").addClass("tlfcollapse");
}
});
});
})(jQuery);