var rutaAdaptJS = 'https://bisionbymycar.es/';var isResponsive = true; var ADAPT_CONFIG = { dynamic: true, range: [ '0px to 760px = ' + rutaAdaptJS + 'css/pluginsOverride/mobile.css', '760px to 980px = ' + rutaAdaptJS + 'css/pluginsOverride/tablet.css', '980px = ' + rutaAdaptJS + 'css/pluginsOverride/desktop.css' ] //callback: DNA.init }; DNA = new Array(); DNA.init = function(){ if(!isResponsive){ this.addInitFunction(function(){ $('body').css('min-width', '1200px'); }); ADAPT_CONFIG.range[0] = '0px to 1px = ' + rutaAdaptJS + 'css/pluginsOverride/mobile.css'; ADAPT_CONFIG.range[1] = '1px to 2px = ' + rutaAdaptJS + 'css/pluginsOverride/tablet.css'; ADAPT_CONFIG.range[2] = '3px = ' + rutaAdaptJS + 'css/pluginsOverride/desktop.css'; } // $(".reescalable").each(function(){ // DNA.hashFor($(this).getID()); // }); $(window).resize(function(){ DNA.rescale(); }); this.addInitFunction(function(){ DNA.setCovers(); }); } DNA.addInitFunction = function(f){ jQuery(document).ready(f); } DNA.mostrarGuias = function (){ jQuery(document).ready(function(){ var height = jQuery(document).height(); var inicio = (jQuery(document).width() - 1200)/2; for(var i = inicio; i < jQuery(document).width(); i+=10){ if((((i - inicio)+10)%100 == 0 || (i-inicio)%100 == 0 || ((i-inicio)-10)%100 == 0) && i < 1200 + inicio + 10) jQuery('body').append('
'); } }); } DNA.objetivizeForm = function(formID){ var form = jQuery('#'+ formID); var result = new Array(); for(var i = 0; i < form[0].length; i++){ var str = form[0][i].name; if(form[0][i].type == 'checkbox') result[str] = form[0][i].checked; else result[str] = form[0][i].value; } return result; } DNA.esEmailValido = function(email) { expr = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; return expr.test(email); } DNA.stopBubble = function(e){ ev = window.event || e; ev.stopPropagation(); } DNA.loadJS = function(js, avoidCache){ var id = $.md5(js); var rand = ''; if(avoidCache != 'undefined'){ if(avoidCache) var rand = '?' + Math.random(); } if(!$.existsID(id)) $('head').append(''); } DNA.loadCSS = function(css, avoidCache){ var id = $.md5(css); if(avoidCache != 'undefined'){ if(avoidCache) var rand = '?' + Math.random(); } if(!$.existsID(id)) $('head').append(''); } DNA.cancelEvent = function(e) { e.originalEvent.stopPropagation(); e.originalEvent.preventDefault(); } DNA.getRandom = function(endNumber, initNumber){ if(typeof initNumber === 'undefined'){ initNumber = 1; } if(typeof endNumber === 'undefined'){ endNumber = 9999999999; } return Math.floor((Math.random() * endNumber) + initNumber); }; DNA.md5 = function(str){ return $.md5(str); } DNA.hashFor = function(divElement){ if(DNA.isUndefined(DNA.Sesion)){ DNA.Sesion = new Array(); } var hash = $(divElement).attr('uid'); if(DNA.isUndefined(hash)){ var rand = DNA.getRandom(); hash = DNA.md5(rand); $(divElement).attr('uid', hash); } if(DNA.isUndefined(DNA.Sesion[hash])){ DNA.Sesion[hash] = new Array(); } return DNA.Sesion[hash]; } DNA.isUndefined = function(value){ return (typeof value === 'undefined') || (value === null); } DNA.responsiveCSS = function(divElementId, byHeight, normalWidth){ if(DNA.isUndefined(byHeight)){ byHeight = true; } if(DNA.isUndefined(normalWidth)){ normalWidth = 1200; } var divElement = '#'+divElementId; var divHeight = $(divElement).height(); var divWidth = $(divElement).width(); if(byHeight){ var divAspectRatio = divHeight / divWidth; var divRealHeight = normalWidth * divAspectRatio; } else{ var divAspectRatio = divWidth / divHeight; var divRealHeight = normalWidth / divAspectRatio; } var elem = DNA.hashFor(divElement); if(!elem.height){ elem.height = divRealHeight; } var proporcion = elem.height / $(divElement).height(); for (var i = 3; i < arguments.length; i+=3){ DNA.reescale(divElement+' '+arguments[i], arguments[i+1], arguments[i+2], proporcion); } }; DNA.responsiveCSSbyHeight = function(divElementId, normalHeight){ if(DNA.isUndefined(normalHeight)){ normalHeight = 1200; } var divElement = '#'+divElementId; var divHeight = $(divElement).height(); var divWidth = $(divElement).width(); var divAspectRatio = divHeight / normalHeight; var divRealHeight = normalHeight * divAspectRatio; var elem = DNA.hashFor(divElement); if(!elem.height){ elem.height = normalHeight; } var proporcion = $(divElement).height() / elem.height; for (var i = 2; i < arguments.length; i+=3){ DNA.reescale(divElement+' '+arguments[i], arguments[i+1], arguments[i+2], proporcion); } }; DNA.responsiveCSSbyWidth = function(divElementId, normalWidth){ if(DNA.isUndefined(normalWidth)){ normalWidth = 100; } var divElement = '#'+divElementId; var divHeight = $(divElement).height(); var divWidth = $(divElement).width(); var divAspectRatio = divWidth / normalWidth; var divRealWidth = normalWidth * divAspectRatio; var elem = DNA.hashFor(divElement); if(!elem.width){ elem.width = normalWidth; } var proporcion = $(divElement).width() / elem.width; for (var i = 2; i < arguments.length; i+=3){ DNA.reescale(divElement+' '+arguments[i], arguments[i+1], arguments[i+2], proporcion); } }; DNA.reescale = function(element, style, multiplier, ratio){ var hash = $(element).attr('uid'); if(typeof hash === 'undefined'){ var rand = DNA.getRandom(); var hash = DNA.md5(rand); $(element).attr('uid', hash); } if(typeof DNA.Sesion[hash] === 'undefined'){ DNA.Sesion[hash] = new Array(); } var elem = DNA.Sesion[hash]; if(typeof elem[style] === 'undefined'){ elem[style] = $(element).css(style).replace('px', ''); } if(isNaN(elem[style])){ $(element).css(style, 'auto'); return; } var multiplicador = 1; if(multiplier){ multiplicador = multiplier; } if(multiplicador < 1){ multiplicador = (multiplicador); } var newValue = elem[style] - (elem[style] * ratio); if(newValue < 0){ newValue = elem[style]; } else if(Math.ceil(newValue) < elem[style] && multiplicador != 1) newValue = elem[style] - (newValue * Math.abs(multiplicador)); else newValue = elem[style] - newValue; newValue = (newValue > elem[style]) ? elem[style] : newValue; $(element).css(style, newValue+'px'); } DNA.setCovers = function(){ $('.overCovered').each(function(){ $(this).children().first().before('
'); var cover = $(this).find('.overCover'); $(cover).css('position', 'absolute'); $(cover).css('width', '100%'); $(cover).css('height', '100%'); $(cover).css('background-color', $(this).attr('coverColor')); $(cover).css('opacity', $(this).attr('coverOpacity')/100); }); }; DNA.rescale = function(){ }; DNA.setScalables = function(){ $('.scalable').each(function(){ if($(this).attr('scaleBy') == 'width'){ var aux = $(this); $(window).resize(function(aux){ DNA.responsiveCSSbyWidth($(aux).parent().getID(), $(aux).parent().width(), '.'+$(aux).getClass(), 'width', $(aux).attr('scaleProportion')); }); } }); }; DNA.init();