fillView = function(options){ var tempVista; if(typeof(options.view) == 'string'){ //console.info('del js') tempVista = options.view; }else{ tempVista = options.view[0].innerHTML; //console.info('del html') } var config = jQuery.extend({ data:null, view:'

Utiliza una vista válida

', opt:null },options), regX = /[\{\{\}\}]*/g, // /[\[\]]*/g data = config.data, //tmpView = config.view, //tmpView = config.view[0].innerHTML, tmpView = tempVista, // arr = config.view.match( /\{\{([^ \{\}])+\}\}/g ), // /\[([^ \[\]\{\}])+\]/g arr = tmpView.match( /\{\{([^ \{\}])+\}\}/g ), // /\[([^ \[\]\{\}])+\]/g opt = config.opt, txt = ''; if(arr){ var length = arr.length, val; for(var i=0; i step['init'] && i >= step['init']+step['interval'] ){ if( ( i - step['init'] ) % step['interval'] === 0 ){ data[i].customClass = step['class']; } } } } html += fillView({data:data[i], view:view}); } return html; }; //- MANAGE ALERTS var Alert = ( function( ){ var _el, _opt = { }, _closeEvent = { }, _redirectEvent = { }, _target, _nameSpace = { fillMessage : function( options ){ var html = ''; if( typeof options === 'object' ){ html = fillView({ data:options, view: options.view }); } return html; }, setMessage : function( options ){ //console.info(options); var vista; if(options.view != undefined){ //console.info('hay'); vista = options.view[0].innerHTML; }else{ //console.info('no hay'); vista = _defaults[ 'view' ]; } //console.info(vista); _opt = jQuery.extend( {}, { el : options[ 'el' ] || _defaults[ 'el' ], target : options[ 'target' ] || _defaults[ 'target' ], classe : options[ 'classe' ] || _defaults[ 'classe' ], type : options[ 'type' ] || _defaults[ 'type' ], title : options[ 'title' ] || _defaults[ 'title' ], message : options[ 'message' ] || _defaults[ 'message' ], //view : options[ 'view' ] || _defaults[ 'view' ], view : vista, onComplete : null, onClose : null, redirect: null }, options ); }, showMessage : function( type ){ var element, _type = type || 'lbox'; if( typeof _opt !== 'undefined' && typeof _opt.el !== 'undefined' ){ _target = _opt.target; if( jQuery( '#'+_opt.el ).length ){ _el = jQuery( '#'+_opt.el ); }else{ _el = document.createElement( 'DIV' ); _el.id = _opt.el; _el.className = _opt.classe _el = jQuery( _el ); if( !jQuery('#'+_target).length ){ jQuery('#js').append('
' ); } jQuery( '#'+_target ).append( _el ); } _el.fadeIn( 'fast', function( e ){ if( _opt.onComplete !== null && typeof _opt.onComplete === 'function' ){ _opt.onComplete( ); } }); _closeEvent[ _opt.el ] = _opt.onClose !== null ? _opt.onClose : null; _redirectEvent[ _opt.el ] = _opt.redirect !== null ? _opt.redirect : null; _el.html( Alert.fillMessage( _opt ) ); element = jQuery( '#'+_opt.el ); element.off( 'click' ); jQuery(element.find( '.Lbox-cont' )).css({ 'margin-top': Math.round( (jQuery( element.find( '.Lbox-cont' ) ).height()+ 88 ) / -2) }); if( element.hasClass( 'Lbox' ) && type != 'modal'){ element.on( 'click', '.Lbox-overlay', function( e ){ var that = jQuery( this ); e.stopPropagation( ); Alert.close( element ); }); element.on( 'click', '.Lbox-cont', function( e ){ var that = jQuery( this ); e.stopPropagation( ); }); } element.on( 'click', '.btn-close, .lbox-close, .btn-accept, .btn-cancel', function( e ){ var that = jQuery( this ), status = that.hasClass('btn-accept')? true : false; e.stopPropagation( ); Alert.close( element, status ); }); }else{ throw 'Messages PlugIn :: Fill the data of the message... Example: {classe:[string: "error" or "success" ], title:[string], message:[string]}'; } }, close : function( element, status ){ var _id = element.attr( 'id' ); element.fadeOut('fast', function() { if( _redirectEvent[ _id ] !== null && typeof _redirectEvent[ _id ] === 'string' ){ window.location = _opt.redirect; }else{ if( _closeEvent[ _id ] !== null && typeof _closeEvent[ _id ] === 'function' ){ _closeEvent[ _id ]( status ); } } }); } }, _defaults = { el : 'messageLbox', target : 'lbox', classe : 'Lbox', type: 'error', title : 'Error', message : 'Ocurrio un Error inesperado', view : '
' + '
' + '
' + '' + '' + '

{{title}}

' + '

{{message}}

' + '
' + '
' +'
' }; return _nameSpace; })( ); var eventoClick = ''; function isiPhone(){ return ( (navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1) || (navigator.platform.indexOf("iPad") != -1) ); } var customSelect = (function(){ //- - - - - - - - - - - - - - - //- EVENTOS //- - - - - - - - - - - - - - - var _selectEvents = (function(){ //- - - - - - - - - - - - - - - //- TOGGLE ABIERTO - CERRADO if(isiPhone()){ eventoClick = 'touchstart'; }else{ eventoClick = 'click tap'; } jQuery(document).on( eventoClick, function(e){ _closeSelect( jQuery( '.customSelect' ) ); }); jQuery('body').on( eventoClick, '.customSelect', function(e){ var that = jQuery(this); if( that.hasClass('disabled') ){ return false; } if( that.hasClass('open') ){ _closeSelect( that ); }else{ if(!isiPhone()){ _closeSelect( jQuery( '.customSelect' ) ); that.addClass('open'); } that.find('select').trigger('focus'); } e.stopPropagation(); }); //- - - - - - - - - - - - - - - //- ABRE - CIERRA CON EL TABULADOR jQuery('body').on('focus', 'select, .customSelect-search', function(e){ var custom = jQuery(this).closest('.customSelect'); if(!isiPhone()){ _closeSelect( jQuery( '.customSelect' ) ); custom.addClass('open'); } }); //- - - - - - - - - - - - - - - //- SELECCIONA UNA OPCIÓN jQuery('body').on( 'click tap', '.customSelect-options label', function(e){ var that = jQuery(this), value = that.index(), options = that.parent().children( ), select = that.closest( '.customSelect' ).find( 'select' ), label = that.closest( '.customSelect' ).find( '.customSelect-label' ), multiple = that.closest( '.customSelect' ).hasClass('multiple')? true : false; e.stopPropagation(); if( !that.hasClass('selected') ){ if( !multiple ){ options.removeClass( 'selected' ); label.text( that.text() ); that.addClass( 'selected' ); _closeSelect( that.closest( '.customSelect' ) ); }else{ that.addClass( 'selected hide' ); _addTag( that ); } select.find('option').get( that.index()).selected = true; jQuery(select).trigger('change'); } }); if(isiPhone()){ jQuery('body').on('change','select',function(){ var that = jQuery(this), customS = that.parents('.customSelect'), labelS = customS.find('.customSelect-label'), txtS = that.val(); labelS.text(txtS); }) } //- - - - - - - - - - - - - - - //- NAVEGACIÓN CON FLECHAS DEL TEClADO jQuery('body').on('keydown', 'select', function(e){ var key = e.keyCode, select = jQuery(this).closest('.customSelect'), terms; switch( key ){ case 13: case 40: case 38: e.preventDefault(); _navSelect( select, key ); break; case 39: case 37: e.preventDefault(); break; case 27: _closeSelect( select ); break; } }); //- Prevenir que el formulario se envien con ENTER jQuery('body').on('keydown', '.customSelect-search', function(e){ var key = e.keyCode; if( key == 13 ){ e.preventDefault(); } }); jQuery('body').on('keyup', '.customSelect-search', function(e){ var key = e.keyCode, select = jQuery(this).closest('.customSelect'), terms = select.find('.customSelect-options label').not('.hide'); switch( key ){ case 13: case 40://Down case 38://UP e.preventDefault(); _navSelect( select, key ); break; case 39://Right case 37://Left break; default: _namespace.filter( select ); break; } }); //- - - - - - - - - - - - - - - //- FILTRO jQuery('body').on( 'click tap', '.customSelect input, .customSelect-filter',function(e){ e.stopPropagation(); }); //- - - - - - - - - - - - - - - //- SELECT MULTIPLE TAGS jQuery('body').on( 'click tap', '.customSelect-tag',function(e){ var that = jQuery(this), custom = jQuery('#' + that.closest('.customSelect-tagList').attr('id').replace( 'customTags-','custom-' )), select = jQuery(custom.find('select')), index = that.attr('data-index'); jQuery(select.find('option').get(index))[0].selected = false; jQuery(custom.find('.customSelect-options label').get(index)).removeClass('selected hide'); that.remove(); }); })(); var _navSelect = function( select, key ){ var items = select.find('.customSelect-options label').not('.hide'), current = select.find('.active'); if( key == 13 ){ if( current.length ){ try{ jQuery(current[0]).trigger('click'); }catch(err){} } } if( current.length ){ for( var i=0, lg=items.length; i'+current.text()+''; } return html; }else{ html = ''+option.text()+''; target = jQuery('#customTags-' + option.closest('.customSelect').find('select')[0].id); target.append( html ); } }; var _removeTag = function( option ){ }; //- - - - - - - - - - - - - - - //- PÚBLICO //- - - - - - - - - - - - - - - var _namespace = { update : function( element ){ var id; var init = function(){ var item, options; for( var i=0, lg=element.length; i' + _addTag( select ); +''; } html = '' + ''+ options.label + '' + ''; if( autoSelect ){ html += '' + '' +''; } html += '' + options.html +''; html += ''; wrapper[0].className = 'customSelect ' + select[0].className + ( select.is(':disabled')? ' disabled' : '' ); if( select.attr('id') !== undefined ){ wrapper[0].id = 'custom-'+ select.attr('id'); } wrapper.html( html ); select.wrap( wrapper ); jQuery(tags).insertAfter( select.closest('.customSelect') ); }; var _getOptions = function( item ){ var options = item.find('option'), select = item, html = '', classe, label, item; for( var i=0, lg=options.length; i'+item.text()+''; } return { html : html, label : label } }; init(); }, filter : function( element, term ){ var field = element.find( '.customSelect-search' ), labels = element.find('.customSelect-options label'), term = term || field.val(), item; labels.removeClass('hide active'); if( element.hasClass('multiple') ){ element.find('.selected').addClass('hide'); } if( field.val().length < 3 ){ return false; } for( i=labels.length-1; i>=0; i-- ){ item = jQuery(labels[i]); if( item.text().toLowerCase().indexOf( term ) == -1 ){ item.addClass( 'hide' ); } } }, reset : function( element ){ var item, select, option; for( var i=0, lg=element.length; i-1; i-- ){ _namespace.update( jQuery(selects[i]) ); } })(); return _namespace; })(); jQuery.fn.extend({ updateSelect : function(){ customSelect.update( jQuery(this) ); }, resetSelect : function(){ customSelect.reset( jQuery(this) ); customFields.reset( jQuery(this) ) //jQuery(this).trigger('change'); } }); //- - - - - - - - - - - - - - - //- EJEMPLO //- - - - - - - - - - - - - - - //- Update //customSelect.update( jQuery('#s3') ); //jQuery('#s3').updateSelect(); //- Reset //customSelect.reset( jQuery('#s3') ); //jQuery('#s3').resetSelect(); ( function ( ){ var inputs = jQuery( '[type=text],[type=password],[type=email], textarea' ), selectF = jQuery('select').not('.noLabel'), primerLabel = inputs.parent().hasClass( 'currentInput' )? true : false, labelVal; var init = function ( ){ if( jQuery(inputs).length || jQuery(selectF).length){ floatLabel(); } console.info( inputs.parent()); }; var floatLabel = function(){ var labelS = jQuery(selectF).parents('.customSelect'), labelT = jQuery(selectF).data('name'), inhab = jQuery('.disabled'), inputsFloat = jQuery(inputs).not('.noLabel'), wrapI; var eventosInput = (function(){ jQuery(inputsFloat).on('focus', function(){ wrapI = jQuery(this).parents('.currentInput').addClass('activo'); labelVal = jQuery(this).data('name'); jQuery(wrapI).find('label').text(labelVal); if(jQuery(wrapI).hasClass('listo')){ jQuery(this).removeClass('listo'); } if(jQuery(this).hasClass('password')){ var that = jQuery(this); jQuery(that).removeAttr("type").prop('type', 'password'); } }); jQuery(inputsFloat).on('blur', function(){ wrapI = jQuery(this).parents('.currentInput'); jQuery(wrapI).removeClass('activo').addClass('listo'); if(jQuery(this).val()== "" || jQuery(this).val() == labelVal){ jQuery(wrapI).removeClass('listo activo'); if(jQuery(this).hasClass('password')){ var that = jQuery(this); jQuery(that).removeAttr("type").prop('type', 'text'); } } }); jQuery(selectF).on('change', function(){ if(jQuery('.labelFl').text != jQuery('.customSelect-label').text()){ jQuery(this).parents('.customSelect').addClass('listo'); } }); })(); jQuery.fn.extend({ updateInput : function(){ //console.info('aqui empieza'); for(j=0; j'); jQuery(inputsFloat[j]).parent().prepend(''); } if(jQuery(inputsFloat[j]).val() != "" || jQuery(inputsFloat[j]).hasClass('disabled') ){ if(jQuery(inputsFloat[j]).val() != jQuery(inputsFloat[j]).data('name')){ //console.info('son diferentes'); jQuery(inputsFloat[j]).parent().addClass('listo'); jQuery(inputsFloat[j]).prev().text(jQuery(inputsFloat[j]).data('name')); } } } } }); jQuery.fn.extend({ updateLabelSelect : function(){ jQuery(labelS).prepend(''); if(jQuery(labelS).length){ for(s=0; s= 1 ){ holder.addClass('listo'); }else{ holder.removeClass('listo'); if(jQuery(that).hasClass('password')){ jQuery(that).removeAttr("type").prop('type', 'text'); } } holder.removeClass('activo'); }); //- - - - - - - - - - - - - - - //- .customSelect jQuery('body').on('change', 'select', function(e){ var that = jQuery(this), holder = that.closest('.currentInput'); if( that.val() !== '' ){ holder.addClass('listo'); }else{ holder.removeClass('listo'); } }); jQuery('body').on('blur', 'select', function(e){ var that = jQuery(this), holder = that.closest('.currentInput'); setTimeout( function(){ holder.removeClass('activo'); }, 200 ); }); })(); //- - - - - - - - - - - - - - - //- PÚBLICO //- - - - - - - - - - - - - - - _namespace = { update: function( element ){ var _init = function(){ var item; for( var i=0, lg=element.length; i'+label+''); }; _init(); }, reset: function( item ){ item.closest('.listo').removeClass('listo'); }, updateCheck : function(element){ var _init = function(){ var item; for( var i=0, lg=element.length; i'); }; _init(); } }; var startAll = (function(){ var inputs = jQuery('.withLabel'); //inputs = jQuery( '[type=text], [type=email], textarea, .customSelect' ).not('.noLabel'); var checks = jQuery('[type=checkbox], [type=radio]') for( var i=inputs.length-1; i>-1; i-- ){ _namespace.update( jQuery(inputs[i]) ); } for( var i=checks.length-1; i>-1; i-- ){ _namespace.updateCheck( jQuery(checks[i]) ); } jQuery.fn.extend({ updateInput : function(){ _namespace.update( jQuery(this) ); } }); })(); return _namespace; })(); //alert(123); ///- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //-NUEVO var placeholders = (function(){ //- GLOBALS var fields = '[type=text],[type=email],[type=password], textarea'; //- - - - - - - - - - - - //- PUBLIC METHODS //- - - - - - - - - - - - var init = function(){ var items = jQuery( fields ), el; for( var i=0, lg= items.length; i en el idioma "'+ui_lang+'" no esta definido.' } } if( !item.parent().hasClass('hintTip') ){ item.wrap( '' ); // item.parent().append( ''+ message +'' ); /* PROYECTO: MAS SALUD */ var fechaIco = item.parents('form').find('.hasDatepicker'), icoCal; for(d=0; d .hintTip-text').html( message ); } if( !focusItem ){ focusItem = item; item.trigger('focus'); } send = false; }; //- - - - - - - - - - - - //- PUBLIC METHODS //- - - - - - - - - - - - var _namespace = { messages : function( options ){ var _messages = ui_Form.messages; for( var key in options ){ if( _messages[ key ] == undefined ){ _messages[ key ] = options[ key ]; }else{ for( var subKey in options[ key ] ){ _messages[ key ][ subKey ] = options[ key ][ subKey ]; } } } }, class : function( options ){ for( var key in options ){ if( valueTypes[ key ] == undefined ){ valueTypes[ key ] = options[ key ]; }else{ for( var subKey in options[ key ] ){ valueTypes[ key ][ subKey ] = options[ key ][ subKey ]; } } } }, validate : function( options ){ var _opt = jQuery.extend( {}, { form : null, success: null }, options ); //- - - - - - - - - - - - //- INPUT and SUBMIT //- - - - - - - - - - - - var _startEvents = function(){ if( !_opt.form ){ throw 'Error: "form" not defined!'; return false; } //- - - - - - - - - - - - //- PREVENT NUMBERS //- - - - - - - - - - - - _opt.form.on( 'keydown', ui_Form.fields, function(e){ var item = jQuery(this); if( item.hasClass('noNumbers') ){ if( e.keyCode > 47 && e.keyCode < 58 ){ e.preventDefault(); } } if( item.hasClass('onlyNumbers') ){ //96 105 //47 58 if( e.keyCode <= 47 || e.keyCode >= 191 ){ if( e.keyCode !== 8 && e.keyCode !== 37 && e.keyCode !== 39 ){ e.preventDefault(); } } if( e.keyCode >= 58 && e.keyCode <=95 ){ e.preventDefault(); } // if( e.keyCode <= 47 || e.keyCode >= 58 ){ // if( e.keyCode !== 8 && e.keyCode !== 190 ){ // e.preventDefault(); // } // } } }); //- - - - - - - - - - - - //- CHECK FIELDS //- - - - - - - - - - - - _opt.form.on( 'keyup', ui_Form.fields, function(e){ var item = jQuery(this), valueType = _getValueType( item ); _validateFields( item ); // if( valueType.length > 0 || item.attr('data-confirm') !== undefined ){ // _validateFields( item ); // } }); //- - - - - - - - - - - - //- CUSTOM SELECT //- - - - - - - - - - - - _opt.form.on( 'change', ui_Form.selects, function(e){ var item = jQuery(this), valueType = _getValueType( item ); _validateFields( item, 'select' ); // if( valueType.length > 0 || item.attr('data-confirm') !== undefined ){ // _validateFields( item ); // } }); // jQuery(item.closest('.hintTip')).removeClass('error'); //- - - - - - - - - - - - //- CHECKBOX & RADIOS //- - - - - - - - - - - - _opt.form.on( 'change', ui_Form.checks, function(e){ var item = jQuery(this), valueType = _getValueType( item ); _validateFields( item, 'checks' ); // if( valueType.length > 0 || item.attr('data-confirm') !== undefined ){ // _validateFields( item ); // } }); //- - - - - - - - - - - - //- CHECKBOX & RADIOS GROUP INPUTS //- - - - - - - - - - - - _opt.form.on( 'change', ui_Form.groups, function(e){ var item = jQuery(this), valueType = _getValueType( item ); _validateGroups( item, 'checks' ); // if( valueType.length > 0 || item.attr('data-confirm') !== undefined ){ // _validateFields( item ); // } }); //- - - - - - - - - - - - //- CHECK FULL FORM //- - - - - - - - - - - - _opt.form.on( 'submit', function(e){ e.preventDefault(); _validateForm(); }); }; //- - - - - - - - - - - - //- Return the "class" to evaluate //- - - - - - - - - - - - var _getValueType = function( item ){ var classes = []; for( key in valueTypes ){ if( item.hasClass( key ) ){ classes.push( key ); } } return classes; }; //- - - - - - - - - - - - //- VALIDATE FIELDS //- * defined in ui_Form.fields //- - - - - - - - - - - - var _validateFields = function( item, classes ){ var str = item.val(), valueType = classes || _getValueType( item ), dataConfirm = item.attr('data-confirm'), confirmValue; if(valueType == 'select'){ if(item.val() != ''){ item.parents('.hintTip').removeClass('error'); return false; } else { item.parents('.hintTip').addClass('error'); return false; } } else if(valueType == 'checks'){ if(item.is(':checked')){ jQuery(item.closest('.hintTip')).removeClass('error'); return false; } else{ jQuery(item.closest('.hintTip')).addClass('error'); return false; } } else if( valueType.length == 0 ){ valueType = ['required']; } if( item.val() == '' && item.hasClass('required') == false ){ item.parent().removeClass('error'); return false; } if( item.hasClass('required') == true && item.val() == item.attr('data-name') ){ addMessage( item, valueType ); return false; } if( !dataConfirm ){ for( var i=0, lg= valueType.length; i 960){ $('header').removeClass('active'); } }); } /** * @description Controla el funcionamiento del formulario del header * */ function formularioHeader(){ var boton = $('#botonFormularioHeader'); boton.on('click', function(evento){ evento.preventDefault(); $('#formularioHeader').toggleClass('active'); }); } /** * @description Controla el funcionamiento para mostrar el buscador * */ function buscador(){ var boton = $('#botonDeBusqueda'); boton.on('click', function(evento){ evento.preventDefault(); $('.buscadorDownSlide.port').toggleClass('active'); }); } /** * @description Agrega clase a los elementos del menu si hay mas elementos * */ function clasesHeader(){ var itemsHeader = $('header ul li ul'); if(itemsHeader) itemsHeader.siblings('a').addClass('mas'); $('header .mas').on('click', function(evento){ evento.preventDefault(); $(this).toggleClass('active'); }) } init(); })(jQuery) /** * [[Archivo global del proyecto]] * @private * @author Rocio Ortiz */ console.log("prueba numero 11"); // Agrega el script y las llamadas para los videos de YT var map; function initMap(latlng) { if (typeof google === "object" && typeof google.maps === "object") { map = new google.maps.Map(document.getElementById("map"), { center: latlng, zoom: 8, }); } } var tag = document.createElement("script"), firstScriptTag; tag.src = "https://www.youtube.com/iframe_api"; firstScriptTag = document.getElementsByTagName("script")[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); var playerInfoList = []; // Manda a llamar la functión para crear el player de Yt function onYouTubeIframeAPIReady() { if (typeof playerInfoList === "undefined") return; jQuery(document).ready(function () { jQuery(".HTMLOut .videoYt").each(function () { playerInfoList.push({ id: jQuery(this)[0], videoId: jQuery(this).attr("data-video"), autoplay: jQuery(this).attr("data-autoplay") ? jQuery(this).attr("data-autoplay") : 0, mute: jQuery(this).attr("data-mute") ? jQuery(this).attr("data-mute") : 0, loop: jQuery(this).attr("data-loop") ? jQuery(this).attr("data-loop") : 0, }); }); for (var i = 0; i < playerInfoList.length; i++) { createPlayer(playerInfoList[i]); } }); } // Función para crear el player de YT function createPlayer(playerInfo) { return new YT.Player(playerInfo.id, { height: "100%", width: "100%", playerVars: { autoplay: playerInfo.autoplay, mute: playerInfo.mute, loop: playerInfo.loop, playlist: playerInfo.id, controls: 0, showinfo: 0, // <- This part here rel: 0, modestbranding: 0, }, videoId: playerInfo.videoId, }); } (function () { var body = document.getElementsByTagName("body")[0]; var init = function () { jQuery(".container").addClass("animator-on"); menuMobile(); // contiene la funcionalidad del menú de hamburguesa sliderPrincipal(); // Genera el slider principal // newsCarousel(); // General el carrusel para la clase .newsCarousel cifrasSlider(); // General el carrusel para la clase .cifrasSlider accordion(); // funcionalidad para los elementos de acordeón valuesSlider(); // calculateTabsOverlay(); // calcula el ancho de los botones de las tabs functionTabsOverlay(); // LLena y aparece cada una de las tabs (Ajax) scrollForm(); // aparece o desaparece el formulario del home al hacer scroll videoBanner(); // funcionalidad de cambiar el src del video al dar click en el btn searchBox(); // despliega el buscador y cambia funcionalidad por selección del radio button showVideo(); // despliega y cambia src de video por medio de btn body.onload = function () { mobileImages(); // cambia src de imágenes al cambio de tamaño de pantalla }; menuOpen(); // previene funcionalidad por default del btn if ( jQuery('[class^="wrapper-hubspot"]').length || jQuery(".wrapper-contacto-form").length || jQuery(".hbspt-form").length ) { formularioHbsp(); } // funcionalidad del formulario de hubspot home if (jQuery(".principalHeader").length) { menuStickyBar(); } // funcionalidad de stickybar if (jQuery("header.nueva-version").length) { menuStickyBarHeaderNuevo(); } // funcionalidad de stickybar if (jQuery(".principalHeader").length) { menuStickyBar(); } // funcionalidad de stickybar if (jQuery(".youtubeVideoSlider").length) { youtubeVideoSlider(); } if (jQuery(".principalSlider").length) { principalSlider(); } //Constructores Globales if (jQuery("header").length) { constructorHeader(); } if (jQuery("footer").length) { constructorFooter(); } if (jQuery("#tplVacantesLinks").length) { constructorHeaderLinks(); } if (jQuery("#tplAyudaLinks").length) { constructorAyudaLinks(); } if (jQuery("#tplSocialLink").length) { constructorSocialMenu(); } if (jQuery("#tplFooterAds").length) { constructorFooterAds(); } if (jQuery("#tplPrivacyLinks").length) { constructorPrivacyLinks(); } if (jQuery("#tplDownloadsLinks").length) { constructorDownloads(); } if (jQuery("#tplContactoLinks").length) { constructorContactLinks(); } if (jQuery('[data-dom="toSections"]').length) { constructorSectionLinks(); } if (jQuery('[data-dom="ourInformation"]').length) { constructorIdentidadLinks(); } if (jQuery('[data-dom="vinculate"]').length) { constructorVinculate(); } if (jQuery('[data-dom="agentes"]').length) { constructorAgentes(); } if (jQuery('[data-dom="allGraduated"]').length) { constructorEgresados(); eachInfoGraduatedSquare(); // despliega la información de cada egresado } if (jQuery("body").attr("data-url") || jQuery("body").attr("data-api")) { constructorInternal(); } mainNav(); if (jQuery('iframe[src*="https://www.youtube.com/embed/"]')) { stopIframeYoutube(); } if (jQuery(".interestLinksSlider").length) { sliderEnlacesDeInteres(); } if (jQuery("#newsHubspot").length) { newsHubspot(); } if (jQuery('[data-dom="mainNav"]').length) { menuprincipalConstructor(); } if (jQuery('[data-dom="secondNav"]').length) { menusecundarioConstructor(); } if (jQuery('[data-dom="footerNav"]').length) { menuFooterConstructor(); } if (jQuery('.language-switcher-language-url').length) { selectorIdioma(); } else { jQuery('.secondNav .idiomas').addClass('hidden'); } }; var selectorIdioma = function(){ var selector = jQuery('.language-switcher-language-url .links'), combo = jQuery('.secondNav .idiomas'); if (jQuery('.language-switcher-language-url').length) { combo.html(selector.html()); var items = combo.find('li'); items.map(function(elem){ var chart = items.eq(elem).find('a').attr('hreflang'); items.eq(elem).find('a').text(chart.substring(0, 2)); }) } else { combo.addClass('hidden'); } }; var menuFooterConstructor = function(){ var chunk = jQuery('[data-dom="footerNav"]'), templates = _getTemplates(chunk), url = _urlConstructor(chunk); var html = ''; var linksFooter = chunk.find('.links-footer-nav'); console.log('los templates de footerNav', templates); jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { resp.map(function(eles){ if (eles.show_item == true) { var data = {}; data['titulo'] = eles.titulo; if (jQuery(eles.enlaces_menu).length) { var htmlLink = ''; var dataLink = {}; var links = eles.enlaces_menu; links.map(function(obj){ console.log('el link interno', obj); if (obj.show_link == true) { dataLink['text'] = obj.link.text; dataLink['link'] = obj.link.url; if (obj.hasOwnProperty('imagen')) { dataLink['_img'] = function () { var tmpHtml = ""; tmpHtml += fillView({ data: { img: obj.imagen[0] }, view: templates.img.template, }); return tmpHtml; }; } htmlLink += fillView({ data: dataLink, view: templates.item.template }); console.log('el htmlLink', htmlLink); } }); data['list'] = '
    '+htmlLink+'
'; htmlLink = ''; } html += fillView({ data: data, view: templates.sectionList.template }); } }); linksFooter.html(html); }, }); }; var menusecundarioConstructor = function(){ var chunk = jQuery('[data-dom="secondNav"]'), templates = _getTemplates(chunk), url = _urlConstructor(chunk); var html = ''; var list = chunk.find('.secondNav-links'); console.log('los templates de secondNav', templates); jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { resp.map(function(eles){ console.log('el ele de secondNav', eles); if (eles.show_item == true) { html += fillView({ data: { titulo: eles.link.text, url: eles.link.url }, view: templates.secondNavItem.template }); } }); list.html(html); }, }); } var menuprincipalConstructor = function(){ var chunk = jQuery('[data-dom="mainNav"]'), templates = _getTemplates(chunk), url = _urlConstructor(chunk); var itemMenu = chunk.find('.menu-principal'); var html = ''; console.log('la url', url); console.log('templates', templates); jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { resp.map(function(eles){ console.log('el eles', eles); if (eles.show_item == true) { var enlaces = eles.enlaces_menu; var data = {}; if (eles.link != null) { data['link'] = eles.link.url; data['titulo'] = eles.link.text; } else { data['link'] = ''; data['titulo'] = eles.titulo; var sublevel = ''; enlaces.map(function(item){ if(item.show_link == true){ sublevel += fillView({ data: { img: item.imagen[0], link: item.link.url, titulo: item.link.text, position: item.hasOwnProperty('posicion_titulo') ? item.posicion_titulo : '' }, view: templates.itemSecondLevel.template }); } }); data['sublevel'] = '
    '+sublevel+'
'; } html += fillView({ data: data, view: templates.itemFirstLevel.template }); } }); itemMenu.replaceWith(html); }, }); jQuery(body).on('click', '[data-dom="mainNav"] .linkNav', function(e){ var that = jQuery(this); if (that.closest('.itemNav').find('.sublevel').length) { e.preventDefault(); // that.closest('.itemNav').toggleClass('active'); if (that.closest('.itemNav').hasClass('active')) { jQuery('[data-dom="mainNav"] .itemNav').removeClass('active'); // that.closest('.itemNav').removeClass('active'); } else { jQuery('[data-dom="mainNav"] .itemNav').removeClass('active'); that.closest('.itemNav').addClass('active'); } } }); }; var ctaBannerFaSection = function(resp){ var blkCta = jQuery('.cta-expand-form'), blkBtn = blkCta.find('.btn'); if (resp.hubspot_id != null) { blkCta.attr('data-id', resp.hubspot_id); blkCta.removeClass('hidden'); } else { blkCta.addClass('hidden'); } blkBtn.on('click', function(e){ e.preventDefault(); jQuery(this).toggleClass('active'); }); }; sliderEnlacesDeInteres = function () { if (jQuery(window).width() < 960) { menor(); } else { mayor(); } jQuery(window).on("resize", function () { if (jQuery(window).width() < 960) { menor(); } else { mayor(); } }); function menor() { jQuery(".interestLinksSlider").addClass("owl-carousel"); interestLinksSlider(); jQuery(".interestLinksSlider").owlCarousel("update"); } function mayor() { jQuery(".interestLinksSlider").trigger("destroy.owl.carousel"); jQuery(".interestLinksSlider").removeClass("owl-carousel"); } }; stopIframeYoutube = function () { jQuery(".hideDownSlide").click(function () { cerrar(); }); jQuery("body").on("click", ".itemContent, .callVideoShow", function () { cerrar(); }); function cerrar() { var video = ""; jQuery("body") .find('iframe[src*="https://www.youtube.com/embed/"]') .each(function () { video = jQuery(this).attr("src"); jQuery(this).attr("src", ""); jQuery(this).attr("src", video); }); } }; mobileDevice = function () { var user_agent = navigator.userAgent.toLowerCase(), mobile_device = user_agent.match(/(iphone|ipod|ipad|android)/), device_event = mobile_device ? "click" : "mouseover", device = mobile_device ? true : false, result; result = device_event; return result; }; var constructorTitulo = function (resp, name) { if (resp.hasOwnProperty('hubspot_id') && jQuery('.cta-expand-form').length) { ctaBannerFaSection(resp); } var html = ""; var chunk = jQuery('[data-namecontent="' + name + '"]'), templates = _getTemplates(chunk); var _breadcrumbs = function (res) { var html = ""; for (var item in res) { html += fillView({ data: { link: res[item].url, title: res[item].text, }, view: templates.breadcrumb.template, }); } return html; }; var _gallery = function (res) { var html = ""; var data = {}; var index = 1; if (typeof res != "string") { data["image"] = res[0].imagen[0]; } else { return true; } for (var item in res) { data["index"] = index == 6 ? (index = 1) : index++; html += fillView({ data: data, view: templates.itemGallery.template, }); } return html; }; var _videocta = function (res) { var html = ""; var data = {}; if (typeof res != "string") { data["videoid"] = _getYoutubeID(res[0].url); data["video_imagen"] = res[0].imagen[0]; onYouTubeIframeAPIReady(); } else { data["videoid"] = _getYoutubeID(res); onYouTubeIframeAPIReady(); } html += fillView({ data: data, view: templates.videocta.template, }); return html; }; var data = {}; if (templates.hasOwnProperty("videocta")) { if ( "video" in resp && resp.video.length && "video" in resp && resp.video.length ) { data["_videocta"] = _videocta(resp.video); } } var itemsBanner = []; var htmlBanner = ""; if ("banner" in resp && resp.banner.length) { if (resp.banner.length > 1 || resp.banner[0].hasOwnProperty("clase")) { var clase = resp.banner[0].clase; switch (clase) { case "eachSaoyCarouselItem": for (var item in resp.banner) { htmlBanner += fillView({ data: { link: resp.banner[item].link, image: resp.banner[item].imagen, descripcion: resp.banner[item].descripcion, }, view: templates.item.template, }); itemsBanner.push(htmlBanner); htmlBanner = ""; } break; } } else { data["banner_imagen"] = resp.banner[0].imagen; data["banner_imagen_mobile"] = resp.banner[0].imagen_mobile; data["banner_descripcion"] = '' + resp.banner[0].descripcion + ""; } // DATA EXCLUSIVA DE CAMPUS } else if ("clase" in resp && resp.clase.length && resp.clase == "campus") { if (jQuery('[data-dom="campusProductos"]').length) { var regExp = /page-node-\w*/g; var _getNode = function () { var node = jQuery("body").attr("class").match(regExp)[0].split("-"), nodeID = node[node.length - 1]; return nodeID; }; jQuery('[data-dom="campusProductos"]').attr( "data-node", _getNode(jQuery("body")) ); var chunkCampus = jQuery('[data-dom="campusProductos"]'), urlCampus = _urlConstructor(chunkCampus); console.log("la url de los campus", urlCampus); jQuery.ajax({ type: "GET", url: urlCampus, dataType: "json", success: function (respCampus) { jQuery('[data-dom="campusProductos"] [name="campusProductos"]').val( respCampus.concat_products ); carreras(respCampus.concat_products); }, }); } data["banner_descripcion"] = resp.descripcion; data["titulo_detalle"] = '' + resp.titulo_detalle + ""; console.log("va la respuesta: ", resp); if (resp.imagen.length > 0) { if ("imagen" in resp.imagen[0]) { data["banner_imagen"] = data["banner_imagen_mobile"] = resp.imagen[0].imagen[0]; } } if (jQuery('[data-namecontent="instalaciones"]').length) { var chunkInstalaciones = jQuery('[data-namecontent="instalaciones"]'), templatesInstalaciones = _getTemplates(chunkInstalaciones), htmlInstalaciones = ""; htmlInstalaciones += fillView({ data: { instalaciones: resp.instalaciones }, view: templatesInstalaciones.htmlout.template, }); chunkInstalaciones.find(".HTMLOut").html(htmlInstalaciones); chunkInstalaciones .find("." + templatesInstalaciones.items.parent) .addClass("owl-carousel"); newsCarouselContent(chunkInstalaciones.find(".HTMLOut .owl-carousel")); var instalaciones = resp.listado_instalaciones; var htmlFotos = ""; console.log("-------------------------------------------"); console.log("va el indice: ", instalaciones.length); console.log("-------------------------------------------"); if (instalaciones.length !== 0) { for (var x = 0; x < instalaciones.length; x++) { if (instalaciones[x].imagen.length > 0) { for (var y = 0; y < instalaciones[x].imagen.length; y++) { htmlFotos += fillView({ data: { titulo_descritivo: instalaciones[x].hasOwnProperty("titulo") ? instalaciones[x].titulo : "", posicion: instalaciones[x].hasOwnProperty("posicion_class") ? instalaciones[x].posicion_class : "", imagen: instalaciones[x].imagen[y], }, view: templatesInstalaciones.items.template, }); chunkInstalaciones .find(".HTMLOut .owl-carousel") .owlCarousel("add", htmlFotos) .owlCarousel("update"); htmlFotos = ""; } } else { htmlFotos += fillView({ data: { titulo_descritivo: instalaciones[x].hasOwnProperty("titulo") ? instalaciones[x].titulo : "", posicion: instalaciones[x].hasOwnProperty("posicion_class") ? instalaciones[x].posicion_class : "", imagen: instalaciones[x].imagen, }, view: templatesInstalaciones.items.template, }); chunkInstalaciones .find(".HTMLOut .owl-carousel") .owlCarousel("add", htmlFotos) .owlCarousel("update"); htmlFotos = ""; } } } else { chunkInstalaciones.remove(); } } if (jQuery('[data-namecontent="ubicacion"]').length) { var chunkUbicacion = jQuery('[data-namecontent="ubicacion"]'), templatesUbicacion = _getTemplates(chunkUbicacion), htmlUbicacion = "", verificarCampos = 0; htmlUbicacion += fillView({ data: { titulo: '' + resp.titulo + "", _telefono: function () { if (resp.telefono !== "") { var tmpHtml = ""; tmpHtml += fillView({ data: { telefono: resp.telefono, }, view: templatesUbicacion.telefono.template, }); return tmpHtml; } else { verificarCampos++; return ""; } }, _ubicacion: function () { if (resp.ubicacion !== "") { var tmpHtml = ""; tmpHtml += fillView({ data: { ubicacion: resp.ubicacion, }, view: templatesUbicacion.ubicacion.template, }); return tmpHtml; } else { verificarCampos++; return ""; } }, _socialMedia: function () { if (resp.redes_sociales !== []) { console.log(resp.redes_sociales); var tmpHtml = ""; for (var z = 0; z < resp.redes_sociales.length; z++) { tmpHtml += fillView({ data: { link: resp.redes_sociales[z].link.url, icon: resp.redes_sociales[z].imagen, titulo: resp.redes_sociales[z].titulo, }, view: templatesUbicacion.socialMedia.template, }); } return tmpHtml; } else { verificarCampos++; return ""; } }, }, view: templatesUbicacion.htmlout.template, }); /*if(resp.redes_sociales.length > 0){ console.log("ENTRE EN REDES SOCIALES"); if ('link' in resp.redes_sociales[0]) { data["_socialMedia"] = function(){var tmpHtml = ''; resp.redes_sociales.map(function(network){ tmpHtml += fillView({ data: { titulo: network.titulo, link: network.link.url, icon: network.imagen[0] }, view: templatesUbicacion.socialMedia.template}); }); return tmpHtml}; console.log("tiene redes sociales", data["_socialMedia"]); }else{ console.log("no tiene redes sociales"); } }else{ verificarCampos++; }*/ chunkUbicacion.find(".HTMLOut").html(htmlUbicacion); } if (resp.latitud !== "" && resp.longitud !== "") { initMap({ lat: parseFloat(resp.latitud), lng: parseFloat(resp.longitud), }); } else { verificarCampos++; } if (verificarCampos === 4) { jQuery('[data-namecontent="ubicacion"]').remove(); } } data["titulo"] = '' + resp.titulo + ""; data["descripcion"] = resp.descripcion; if (templates.hasOwnProperty("breadcrumb")) { data["_breadcrumb"] = _breadcrumbs(resp.breadcrumb); } if ( templates.hasOwnProperty("itemGallery") && "imagen" in resp && resp.imagen.length ) { data["_itemGallery"] = _gallery(resp.imagen); } console.log("el data del titulo", data); html += fillView({ data: data, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); if (templates.hasOwnProperty("item")) { chunk .find('.HTMLOut [class="' + templates.item.parent + '"]') .addClass("owl-carousel"); soyEgresadoCarousel(chunk.find(".HTMLOut .owl-carousel")); itemsBanner.forEach(function (ele) { chunk .find(".HTMLOut .owl-carousel") .owlCarousel("add", ele) .owlCarousel("update"); soyEgresadoCarousel(chunk.find(".HTMLOut .owl-carousel")); }); chunk.find(".HTMLOut .arrowButton").click(function (e) { e.preventDefault(); chunk.find(".HTMLOut .owl-carousel").trigger("next.owl.carousel"); }); chunk.find(".HTMLOut .backArrow").click(function (e) { e.preventDefault(); chunk.find(".HTMLOut .owl-carousel").trigger("prev.owl.carousel"); }); } }; _getTemplates = function (chunk) { var templates = {}; var regExpKEY = /\{\{[^\_]([^\s\{\}])+\}\}/g; var regExpTPL = /\{\{\_([^\s\{\}])+\}\}/g; var _unique = function (a) { var uniques = []; jQuery.each(a, function (i, el) { if (jQuery.inArray(el, uniques) === -1) uniques.push(el); }); return uniques; }; //OBTIENE LOS PROPS DE MI TEMPLATE var _getProps = function (template) { var props = []; var matches = _unique(template.html().match(regExpKEY)); var propsGET = []; var props = { props: propsGET, placeholders: [] }; var images = template.find("[data-src]"); // images.map(function(sec){ // jQuery(images[sec]).attr('data-placeholder', jQuery(images[sec]).attr('src')); // }); for (prop in matches) { var value = matches[prop]; if (typeof value == "string") { if (template.find("[data-src]").prop("tagName") == "IMG") { // if(value == template.find("[data-src]").attr('data-src')){ // props.placeholders = []; // var elems = template.find("[data-src]"); // var object = {}; // elems.map(function(key){ // object[jQuery(elems[key]).attr('data-src').replace(/{{|}}/g, "")] = jQuery(elems[key]).attr('data-placeholder'); // }); // props.placeholders.push(object) // } template .find("[data-src]").eq(0).attr("src", template.find("[data-src]").attr("data-src")); template.find("[data-src]").attr("alt", "Tecmilenio"); } if (template.find("[data-link]").prop("tagName") == "A") { template .find("[data-link]") .attr("href", template.find("[data-link]").attr("data-link")); } if (template.find("[data-href]").prop("tagName") == "A") { template .find("[data-href]") .attr("href", template.find("[data-href]").attr("data-href")); } if (template.find("[data-color]").length) { var block = template.find("[data-color]"); block.each(function (ele) { var key = jQuery(block[ele]).attr("data-color"); jQuery(block[ele]).attr( "data-style", "color:" + key + ";border-color:" + key + ";background-color:" + key + ";" ); }); } var propName = value.replace(/{{|}}/g, ""); propsGET.push(propName); } } return props; }; //OBTIENE TODOS LOS TEMPLATES DE MI CHUNK var _getTpls = function (chunk) { var matches = _unique(chunk.html().match(regExpTPL)); for (tpl in matches) { var value = matches[tpl]; if (typeof value == "string") { if ( chunk .find(':contains("' + value + '")') .last() .prop("tagName") == "LI" ) { var content = chunk .find(':contains("' + value + '")') .last() .html(); chunk .find(':contains("' + value + '")') .last() .parent() .html(content); } var tplName = value.replace(/{{_|}}/g, ""), locateDOM = chunk.find('[data-block="_' + tplName + '"]'); templates[tplName] = _getProps(locateDOM); var nameParentCLASS = chunk .find(':contains("' + value + '")') .parent() .children(':contains("' + value + '")') .last() .attr("class"); templates[tplName]["parent"] = nameParentCLASS; templates[tplName]["template"] = locateDOM.html(); } } }; //OBTIENE EL TEMPLATE BASE DE SALIDA DE HTMLOUT var _getHTMLOut = function (chunk) { var locateDOM = chunk.find(".HTMLOut"); templates["htmlout"] = _getProps(locateDOM); var nameParentCLASS = chunk.find(".HTMLOut").attr("class"); templates["htmlout"]["parent"] = nameParentCLASS; templates["htmlout"]["template"] = locateDOM.html(); }; _getTpls(chunk); _getHTMLOut(chunk); return templates; }; var constructorBlock = function (template, arr, name) { var html = ""; if (jQuery('[data-namecontent="' + name + '"]').length) { switch (template) { case "ourMasters": var chunk = jQuery('[data-namecontent="' + name + '"]'), templates = _getTemplates(chunk); for (var item in arr) { if (arr[item].cabecera == "1") { html += fillView({ data: { titulo_descritivo: '' + arr[item].titulo_descritivo + "", titulo: '' + arr[item].titulo + "", }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); html = ""; } else if (arr[item].clase == "imageFlexibility") { html += fillView({ data: { image: arr[item].imagen[0] }, view: templates.imageFlexibility.template, }); chunk .find(".HTMLOut ." + templates.imageFlexibility.parent) .prepend(html); html = ""; } else if (arr[item].clase == "badge") { html += fillView({ data: { imagen: arr[item].imagen[0], titulo: arr[item].titulo_descritivo, }, view: templates.badges.template, }); chunk.find(".HTMLOut ." + templates.badges.parent).prepend(html); html = ""; } else if (arr[item].clase != "badgesBenefitsListItem") { html += fillView({ data: { titulo_descritivo: arr[item].titulo_descritivo, descripcion: arr[item].descripcion, }, view: templates.item.template, }); chunk.find(".HTMLOut ." + templates.item.parent).append(html); html = ""; } else { html += fillView({ data: { image: arr[item].imagen[0], color: arr[item].color, titulo_descritivo: arr[item].titulo_descritivo, }, view: templates.badgesBenefitsListItem.template, }); chunk .find(".HTMLOut ." + templates.badgesBenefitsListItem.parent) .append(html); html = ""; } } var dataStyles = chunk.find(".HTMLOut").find("[data-style]"); dataStyles.each(function (eles) { jQuery(dataStyles) .eq(eles) .attr("style", jQuery(dataStyles).eq(eles).attr("data-style")); }); break; case "badgeElement": var chunk = jQuery('[data-namecontent="' + name + '"]'), templates = _getTemplates(chunk); chunk.find(".HTMLOut ." + templates.badge.parent).html(""); chunk.find(".HTMLOut ." + templates.item.parent).html(""); chunk.find(".HTMLOut ." + templates.imageFlexibility.parent).html(""); for (var item in arr) { if (arr[item].clase == "badgeElement") { html += fillView({ data: { descripcion: arr[item].descripcion }, view: templates.badge.template, }); chunk.find(".HTMLOut ." + templates.badge.parent).append(html); html = ""; } else if (arr[item].clase == "imageFlexibility") { html += fillView({ data: { image: arr[item].imagen[0] }, view: templates.imageFlexibility.template, }); chunk .find(".HTMLOut ." + templates.imageFlexibility.parent) .prepend(html); html = ""; } else if (arr[item].clase == "imageFlexibility") { html += fillView({ data: { image: arr[item].imagen[0] }, view: templates.imageFlexibility.template, }); chunk .find(".HTMLOut ." + templates.imageFlexibility.parent) .prepend(html); html = ""; } else { html += fillView({ data: { imagen: arr[item].imagen[0], descripcion: arr[item].descripcion, color: arr[item].color, }, view: templates.item.template, }); chunk.find(".HTMLOut ." + templates.item.parent).append(html); html = ""; } } var dataStyles = chunk.find(".HTMLOut").find("[data-style]"); dataStyles.each(function (eles) { jQuery(dataStyles) .eq(eles) .attr("style", jQuery(dataStyles).eq(eles).attr("data-style")); }); break; case "learnList": var chunk = jQuery('[data-namecontent="' + name + '"]'), templates = _getTemplates(chunk); for (var item in arr) { if (arr[item].principal == "1") { html += fillView({ data: { imagen: arr[item].imagen[0] }, view: templates.image.template, }); chunk.find(".HTMLOut ." + templates.image.parent).prepend(html); html = ""; } else if (arr[item].clase != "learn") { html += fillView({ data: { titulo: arr[item].descripcion }, view: templates.titulo.template, }); chunk.find(".HTMLOut ." + templates.titulo.parent).html(""); chunk.find(".HTMLOut ." + templates.titulo.parent).html(html); html = ""; } else { html += fillView({ data: { descripcion: arr[item].descripcion, titulo_descritivo: arr[item].titulo_descritivo, imagen: arr[item].imagen[0], }, view: templates.item.template, }); } } chunk.find(".HTMLOut ." + templates.item.parent).append(html); html = ""; break; case "certificates": var chunk = jQuery('[data-namecontent="' + name + '"]'), templates = _getTemplates(chunk); for (var item in arr) { if (arr[item].cabecera == "1" || arr[item].principal == "1") { html += fillView({ data: { imagen: arr[item].imagen[0] }, view: templates.image.template, }); chunk.find(".HTMLOut ." + templates.image.parent).prepend(html); html = ""; } else if (arr[item].clase != "certificatesList") { html += fillView({ data: { titulo: arr[item].descripcion }, view: templates.titulo.template, }); chunk.find(".HTMLOut ." + templates.titulo.parent).html(""); chunk.find(".HTMLOut ." + templates.titulo.parent).html(html); html = ""; } else { html += fillView({ data: { descripcion: arr[item].descripcion, imagen: arr[item].imagen[0], }, view: templates.item.template, }); } } chunk.find(".HTMLOut ." + templates.item.parent).append(html); // var dataStyles = chunk.find('.HTMLOut .'+templates.item.parent); // console.log('testing dataStyles', dataStyles); // dataStyles.each(function(eles){ // jQuery(dataStyles).eq(eles).attr('style', jQuery(dataStyles).eq(eles).attr('data-style')); // }); html = ""; break; case "lifePurpose": var chunk = jQuery('[data-namecontent="' + name + '"]'), templates = _getTemplates(chunk); chunk .find('.HTMLOut [class="' + templates.sliderFinal.parent + '"]') .html(""); chunk .find('.HTMLOut [class="' + templates.sliderFinal.parent + '"]') .addClass("owl-carousel"); lifePurposeSlider(chunk.find(".HTMLOut .owl-carousel")); for (var item in arr) { html += fillView({ data: { titulo_descritivo: arr[item].titulo_descritivo, descripcion: arr[item].descripcion, imagen: arr[item].imagen, }, view: templates.sliderFinal.template, }); chunk .find(".HTMLOut .owl-carousel") .owlCarousel("add", html) .owlCarousel("update"); html = ""; } chunk.find(".HTMLOut .owl-carousel").trigger("refresh.owl.carousel"); jQuery(".allDots") .find(".owl-dot") .each(function (e) { jQuery(this) .find("span") .html(e + 1); }); break; case "titleSquareSection": var chunk = jQuery('[data-namecontent="' + name + '"]'), templates = _getTemplates(chunk); for (var item in arr) { if (arr[item].cabecera == "1" || arr[item].principal == "1") { html += fillView({ data: { titulo_descritivo: arr[item].titulo_descritivo, descripcion: arr[item].descripcion, }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); html = ""; } else { html += fillView({ data: { imagen: arr[item].imagen[0], }, view: templates["imagen" + item].template, }); chunk .find( '.HTMLOut [class="' + templates["imagen" + item].parent + '"]' ) .html(html); html = ""; } } break; case "behaviors": var chunk = jQuery('[data-namecontent="' + name + '"]'), templates = _getTemplates(chunk); for (var item in arr) { if (arr[item].cabecera == "1") { html += fillView({ data: { titulo_descritivo: arr[item].titulo_descritivo, }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); chunk .find('.HTMLOut [class="' + templates.items.parent + '"]') .addClass("owl-carousel"); html = ""; } else if (arr[item].clase == "titleSquareSection") { html += fillView({ data: { titulo_descritivo: arr[item].titulo_descritivo, descripcion: arr[item].descripcion, }, view: templates.titleSquareSection.template, }); chunk .find( '.HTMLOut [class="' + templates.titleSquareSection.parent + '"]' ) .html(html); html = ""; } else { html += fillView({ data: { alt: arr[item].alt, imagen: arr[item].imagen, titulo_descritivo: arr[item].titulo_descritivo, }, view: templates.items.template, }); chunk .find(".HTMLOut .owl-carousel") .owlCarousel("add", html) .owlCarousel("update"); html = ""; } } chunk.find(".HTMLOut .owl-carousel").trigger("destroy.owl.carousel"); newsCarouselContent(chunk.find(".HTMLOut .owl-carousel")); html = ""; chunk.find(".HTMLOut .arrowButton").click(function (e) { e.preventDefault(); chunk.find(".HTMLOut .owl-carousel").trigger("next.owl.carousel"); }); break; case "purposeModel": var chunk = jQuery('[data-namecontent="' + name + '"]'), templates = _getTemplates(chunk); for (var item in arr) { if (arr[item].cabecera == "1") { html += fillView({ data: { titulo_descritivo: arr[item].titulo_descritivo, }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); chunk .find('.HTMLOut [class="' + templates.items.parent + '"]') .addClass("owl-carousel"); html = ""; } else { html += fillView({ data: { titulo_descritivo: arr[item].titulo_descritivo, descripcion: arr[item].descripcion, }, view: templates.items.template, }); chunk .find(".HTMLOut .owl-carousel") .owlCarousel("add", html) .owlCarousel("update"); html = ""; } } chunk.find(".HTMLOut .owl-carousel").trigger("destroy.owl.carousel"); uniqueCarousel(chunk.find(".HTMLOut .owl-carousel")); html = ""; break; case "ListpurposeModel": var chunk = jQuery('[data-namecontent="' + name + '"]'), templates = _getTemplates(chunk); for (var item in arr) { if (arr[item].cabecera == "1") { html += fillView({ data: { titulo_descritivo: arr[item].titulo_descritivo, descripcion: arr[item].descripcion, }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); html = ""; } else { html += fillView({ data: { imagen: arr[item].imagen[0], }, view: templates.item.template, }); } } chunk.find(".HTMLOut ." + templates.item.parent).html(html); html = ""; break; case "linkInterest": var chunk = jQuery('[data-namecontent="' + name + '"]'), templates = _getTemplates(chunk); for (var item in arr) { if (arr[item].cabecera == "1") { html += fillView({ data: { titulo: '' + arr[item].titulo + "", descripcion: '' + arr[item].descripcion + "", }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); if (jQuery(window).width() < 960) { chunk .find( '.HTMLOut [class="' + templates.interestLinksSlider.parent + '"]' ) .addClass("owl-carousel"); } html = ""; } else { var data = {}; data["link_text"] = arr[item].link.text; data["link_url"] = arr[item].link.url; data["descripcion"] = arr[item].descripcion; if (arr[item].hasOwnProperty("imagen")) { data["imagen"] = arr[item].imagen[0]; } html += fillView({ data: data, view: templates.interestLinksSlider.template, }); if (jQuery(window).width() < 960) { chunk .find(".HTMLOut .owl-carousel") .owlCarousel("add", html) .owlCarousel("update"); } else { chunk.find(".HTMLOut .interestLinksSlider").append(html); } html = ""; } } if (jQuery(window).width() < 960) { chunk .find(".HTMLOut .owl-carousel") .trigger("destroy.owl.carousel"); interestLinksSlider(); chunk.find(".HTMLOut .owl-carousel").owlCarousel("update"); } html = ""; break; case "eachChoose": var chunk = jQuery('[data-namecontent="' + name + '"]'); templates = _getTemplates(chunk); var index = 0; var parent = '[class*="' + templates.block.parent + '"]'; for (var item in arr) { if (arr[item].cabecera == "1" || arr[item].principal == "1") { html += fillView({ data: { titulo: arr[item].descripcion }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); chunk.find(".HTMLOut ." + templates.block.parent).html(""); html = ""; index++; } else { if (index == 1) { html += fillView({ data: { descripcion: arr[item].descripcion, link_url: arr[item].link.url, link_text: arr[item].link.text, }, view: templates.item.template, }); chunk .find(".HTMLOut " + parent) .append(templates.block.template); chunk .find(".HTMLOut " + parent) .find(".itemsEachChoose") .last() .append(html); index++; html = ""; } else { html += fillView({ data: { descripcion: arr[item].descripcion, link_url: arr[item].link.url, link_text: arr[item].link.text, }, view: templates.item.template, }); chunk .find(".HTMLOut " + parent) .find(".itemsEachChoose") .last() .append(html); index = 1; html = ""; } } } break; case "galleryMagnific": var chunk = jQuery('[data-namecontent="' + name + '"]'); templates = _getTemplates(chunk); var _gallery = function (res) { var html = ""; var data = {}; var index = 1; if (typeof res != "string") { data["image"] = res[0].imagen[0]; } else { return true; } for (var item in res) { data["index"] = index == 6 ? (index = 1) : index++; html += fillView({ data: data, view: templates.itemGallery.template, }); } return html; }; var index = 1; for (var item in arr) { if (arr[item].cabecera == "1" || arr[item].principal == "1") { html += fillView({ data: { titulo_descritivo: '' + arr[item].titulo_descritivo + "", }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); html = ""; } else { html += fillView({ data: { index: index == 6 ? (index = 1) : index++, image: arr[item].imagen, }, view: templates.itemGallery.template, }); } } chunk .find('.HTMLOut [class="' + templates.itemGallery.parent + '"]') .html(""); chunk .find('.HTMLOut [class="' + templates.itemGallery.parent + '"]') .html(html); html = ""; calculateGallery(); break; case "modeloPrepa": var chunk = jQuery('[data-namecontent="' + name + '"]'); (templates = _getTemplates(chunk)), (content = templates.modelSquare.template); for (var item in arr) { if (arr[item].cabecera == "1" || arr[item].principal == "1") { html += fillView({ data: { titulo: '' + arr[item].titulo + "", }, view: chunk.find(".HTMLOut").html(), }); chunk.find(".HTMLOut").html(html); html = ""; } else { html += fillView({ data: { descripcion: arr[item].descripcion, imagen: arr[item].hasOwnProperty("imagen") ? arr[item].imagen[0] : "", titulo_descritivo: arr[item].titulo_descritivo, }, view: content, }); } chunk .find('.HTMLOut [class="' + templates.modelSquare.parent + '"]') .html(html); } html = ""; break; case "learnCenterTitle": var chunk = jQuery('[data-namecontent="' + name + '"]'); var templates = _getTemplates(chunk); var roleBlock = 1; var count = 0; var grid = templates.grid.template, images = templates.imagesDataResume.template; var _grid = function (grid) { var html = ""; html += fillView({ data: { index: roleBlock }, view: templates.grid.template, }); return html; }; var _images = function (eles) { var html = ""; for (img in eles) { html += fillView({ data: { imagen: eles[img] }, view: unescape(images), }); } return html; }; for (var item in arr) { if (arr[item].cabecera == "1") { if ( chunk .find(".templates.hidden") .find(".titleSquareSection.number").length ) { chunk .find(".templates.hidden") .find(".titleSquareSection.number .contenTitleSquare") .html(arr[item].titulo_descritivo); templates.grid.template = jQuery( '[data-namecontent="' + name + '"]' ) .find('.templates.hidden [data-block="_grid"]') .html(); } html += fillView({ data: { id: name, titulo_descritivo: arr[item].titulo_descritivo, _grid: _grid(grid), }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); html = ""; roleBlock++; count++; } else if (count == 6) { count = 1; var html = ""; var content = ""; // var locateBlock = jQuery('.contentsWrappers').find('#'+name).find('[data-item="'+(roleBlock-1)+'"]'); // var tplResume = chunk.find('[data-block="resume'+count+'"]'); // html += fillView({ data: { id: name }, view: _grid(grid) }); // content += fillView({ // data: { // descripcion: arr[item].descripcion, // imagenes: _images(arr[item].imagen), // titulo_descritivo: arr[item].titulo_descritivo // }, // view: tplResume.html() // }); // locateBlock.parent().append(html); // roleBlock++; // var locateBlock = jQuery('.contentsWrappers').find('#'+name).find('[data-item="'+(roleBlock-1)+'"]'); // locateBlock.find('.leftSideColumn').append(content); count++; } else { var html = ""; var selectResume = "resume" + count; var tplResume = templates[selectResume].template; html += fillView({ data: { descripcion: arr[item].descripcion, _imagesDataResume: _images(arr[item].imagen), titulo_descritivo: arr[item].titulo_descritivo, }, view: tplResume, }); switch (count) { case 1: case 2: chunk .find( '.HTMLOut [class="' + templates[selectResume].parent + '"]' ) .append(html); break; case 3: case 4: case 5: chunk .find( '.HTMLOut [class="' + templates[selectResume].parent + '"]' ) .append(html); break; } html = ""; count++; } } html = ""; break; case "learnCenterTitleTwo": var chunk = jQuery('[data-namecontent="' + name + '"]'); var templates = _getTemplates(chunk); var index = 1; var titulo = ""; for (var item in arr) { if (arr[item].cabecera == "1") { titulo += fillView({ data: { titulo_descritivo: arr[item].titulo_descritivo, }, view: templates.titulo.template, }); chunk.find(".HTMLOut").html(templates.htmlout.template); index++; } else { if (index == 3 || index == 6) { html += fillView({ data: { image: arr[item].imagen[0], }, view: templates.item.template, }); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .find(".learnCenterTitleTwo") .last() .append(html); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .find(".learnCenterTitleTwo") .last() .find(".b-half") .last() .addClass("rightSideColumn"); html = ""; index = 5; } else if (index == 2) { html += fillView({ data: { image: arr[item].imagen[0], _resume: function () { var content = ""; content += fillView({ data: { descripcion: arr[item].descripcion, }, view: templates.resume.template, }); return content; }, }, view: templates.item.template, }); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .html(""); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .append(templates.grid.template); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .find(".learnCenterTitleTwo") .last() .html(""); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .find(".learnCenterTitleTwo") .last() .append(html); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .find(".learnCenterTitleTwo") .last() .find(".b-half") .last() .prepend(titulo); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .find(".learnCenterTitleTwo") .last() .find(".b-half") .last() .addClass("leftSideColumn"); html = ""; titulo = ""; index++; } else { html += fillView({ data: { image: arr[item].imagen[0], }, view: templates.item.template, }); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .append(templates.grid.template); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .find(".learnCenterTitleTwo") .last() .html(""); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .find(".learnCenterTitleTwo") .last() .append(html); chunk .find('.HTMLOut [class="' + templates.grid.parent + '"]') .find(".learnCenterTitleTwo") .last() .find(".b-half") .last() .addClass("leftSideColumn"); html = ""; titulo = ""; index++; } } } break; case "championship": var chunk = jQuery('[data-namecontent="' + name + '"]'); var templates = _getTemplates(chunk); console.log("los templates", templates); for (var item in arr) { if (arr[item].cabecera == "1") { html += fillView({ data: { titulo: arr[item].titulo_descritivo, }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); html = ""; } } break; case "bindCards": var chunk = jQuery('[data-namecontent="' + name + '"]'); var templates = _getTemplates(chunk); for (var item in arr) { if (arr[item].cabecera == "1" || arr[item].cabecera == "Activado") { html += fillView({ data: { titulo: '' + arr[item].titulo_descritivo + "", descripcion: '' + arr[item].descripcion + "", }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); html = ""; } else { html += fillView({ data: { titulo: arr[item].titulo_descritivo, image: arr[item].imagen[0], descripcion: arr[item].descripcion, }, view: templates.item.template, }); } } chunk .find('.HTMLOut [class="' + templates.item.parent + '"]') .html(html); html = ""; break; } } else { return true; } }; var constructorInternal = function (block) { var url = _urlConstructor(jQuery("body")); var tempResp; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { //construye titulo var _remove = function (arr) { jQuery(arr).each(function (item) { delete tempResp[arr[item]]; }); }; if (jQuery('[data-namecontent="titulo"]').length) { constructorTitulo(resp[0], "titulo"); } if (jQuery('[data-namecontent="description"]').length) { constructorTitulo(resp[0], "description"); } if (jQuery('[data-namecontent="banner"]').length) { constructorTitulo(resp[0], "banner"); } tempResp = resp[0]; _remove([ "titulo", "breadcrumb", "imagen", "banner", "video", "descripcion", ]); if (tempResp.hasOwnProperty("nivel")) { if (tempResp.nivel != null) { var nivel = tempResp.nivel; if (jQuery('[data-dom="categorias"]').length) { jQuery('[data-dom="categorias"]').attr("data-node", nivel); jQuery('[data-dom="carreras"]').attr("data-node", nivel + "/all"); } } } for (arr in tempResp) { console.log("el arr", arr); var blocks = tempResp[arr]; if (blocks && blocks.length) { console.log("testing blocks", blocks); if (blocks[0].hasOwnProperty("clase")) { constructorBlock(blocks[0].clase, blocks, arr); } else if (blocks[0].hasOwnProperty("fortalezas")) { constructorFortalezas(blocks); } } if ( arr.indexOf("api_tabs") != -1 && jQuery('[data-dom="tabsProducto"]').length ) { jQuery('[data-dom="tabsProducto"]').prepend( '' ); } if ( arr.indexOf("alianzas") != -1 && jQuery('[data-namecontent="alianzas"]').length ) { constructorAlianzas(blocks); } } }, }); }; var formularioHbsp = function () { if ( jQuery('[class^="wrapper-hubspot"]').length || jQuery(".wrapper-contacto-form").length ) { if (jQuery(".wrapper-hubspot").closest(".layout__region").length) { var parentClase = jQuery(".wrapper-hubspot") .closest(".layout__region") .attr("class") .split(" ")[1]; if ( !jQuery(".wrapper-hubspot") .closest(".layout__region") .hasClass("layout__region--content") ) { var parent = jQuery(".wrapper-hubspot") .closest("." + parentClase) .parent(), childs = parent.find(".layout__region"); childs.each(function (ele) { jQuery(childs[ele]).attr("style", "max-width:100%;flex:0 1 100%;"); }); jQuery(".wrapper-hubspot") .closest("." + parentClase) .attr("style", "max-width:0;"); } } // abre y cierra el formulario jQuery("body").on("click", ".btnAppear", function (e) { e.preventDefault(); var that = jQuery(this); that.toggleClass("minimizar"); that.closest('[class^="wrapper-hubspot"]').toggleClass("minimizar"); }); jQuery(window).on("load", function () { jQuery('[class^="wrapper-hubspot"]') .find('[rel="stylesheet"]') .remove(); jQuery(".wrapper-contacto-form").find('[rel="stylesheet"]').remove(); var dataProductoHubspot = jQuery("body").attr("data-producto-hubspot"); if (dataProductoHubspot) { if ( jQuery( '[class^="wrapper-hubspot"] select[name="listadoprofesional"]' ) ) { jQuery( '[class^="wrapper-hubspot"] select[name="listadoprofesional"] option[value = "' + dataProductoHubspot + '"]' ).prop("selected", true); } } }); var flaghide = true; jQuery(window).on("scroll", function () { if (jQuery(document).scrollTop() > 600 && flaghide) { if ( !jQuery('[class^="wrapper-hubspot"] .btnAppear').hasClass( "minimizar" ) ) { jQuery('[class^="wrapper-hubspot"] .btnAppear').addClass( "minimizar" ); } flaghide = false; } }); jQuery(window).on("resize", function () { if (jQuery(document).scrollTop() > 600 && flaghide) { if ( !jQuery('[class^="wrapper-hubspot"] .btnAppear').hasClass( "minimizar" ) ) { jQuery('[class^="wrapper-hubspot"] .btnAppear').addClass( "minimizar" ); } flaghide = false; } }); if (jQuery(document).scrollTop() > 600 && flaghide) { if ( !jQuery('[class^="wrapper-hubspot"] .btnAppear').hasClass("minimizar") ) { jQuery('[class^="wrapper-hubspot"] .btnAppear').addClass("minimizar"); } flaghide = false; } } }; var menuMobile = function () { jQuery(".nav-tgl").on(mobileDevice(), function (e) { e.preventDefault(); jQuery(".menuMobileMenu").addClass("active"); }); // oculta el menú mobile jQuery(".menuMobileMenu .hideDownSlide").click(function (e) { e.preventDefault(); jQuery(".menuMobileMenu").removeClass("active"); }); // tabs de submenú jQuery("body").on("click", ".showMenuTab", function (e) { e.preventDefault(); var that = jQuery(this), appearElement = that.next("ul"); e.preventDefault(); appearElement.toggleClass("active"); that.parents("li").siblings("li").find("ul").removeClass("active"); that .parents("li") .siblings("li") .find(".activeBtn") .removeClass("activeBtn"); jQuery(this).toggleClass("activeBtn"); }); //tabs de sub sub menú jQuery(".showSubTab").click(function (e) { var that = jQuery(this), appearElement = that.next("ul"); e.preventDefault(); appearElement.toggleClass("active"); that.parents("li").siblings("li").find("ul").removeClass("active"); that .parents("li") .siblings("li") .find(".activeBtn") .removeClass("activeBtn"); jQuery(this).toggleClass("activeBtn"); }); }; var sliderPrincipal = function () { if (jQuery(".principalSlider").length > 0) { var parent = jQuery(".principalSlider").closest(".bannerHero"); jQuery(".principalSlider").owlCarousel({ items: 1, singleItem: true, loop: true, nav: true, dotsContainer: parent.find(".allDots"), navContainer: parent.find(".navsArrows"), }); } }; var menuOpen = function () { jQuery("[data-menu-target] a").click(function (e) { e.preventDefault(); }); }; var menuStickyBar = function () { var headerTop = jQuery(".principalHeader").offset().top; jQuery(window).scroll(function (e) { if (jQuery(window).scrollTop() > headerTop) { jQuery(".topHeader").removeClass("visible"); jQuery(".principalHeader").addClass("sticky"); jQuery(".page").addClass("activeSticky"); } else { jQuery(".topHeader").addClass("visible"); jQuery(".principalHeader").removeClass("sticky"); jQuery(".page").removeClass("activeSticky"); } }); }; var menuStickyBarHeaderNuevo = function () { var header = jQuery('header.nueva-version'); var headerTop = jQuery("header.nueva-version").offset().top; jQuery(window).scroll(function (e) { if (jQuery(window).scrollTop() > headerTop) { header.find(".secundario").removeClass("visible"); header.find(".principal").addClass("sticky"); header.find(".page").addClass("activeSticky"); } else { header.find(".secundario").addClass("visible"); header.find(".principal").removeClass("sticky"); jQuery(".page").removeClass("activeSticky"); } }); }; var newsCarousel = function (slider) { var carousel = slider; if (carousel.length > 0) { carousel.owlCarousel({ items: 2, loop: true, margin: 18, merge: true, dots: false, navs: false, responsive: { 0: { items: 1, }, 900: { items: 2, }, }, }); carousel.addClass("owl-carousel"); // funcionalidad del btn next jQuery("#nextSlideb").click(function () { carousel.trigger("next.owl.carousel"); }); } }; var newsCarouselContent = function (slider) { slider.owlCarousel({ items: 2, loop: true, margin: 18, merge: true, dots: false, center: true, navs: false, responsive: { 0: { items: 1, }, 900: { items: 2, center: false, }, }, }); slider .closest(".HTMLOut") .find(".arrowButton") .on("click", function (e) { e.preventDefault(); slider.trigger("next.owl.carousel"); }); }; var cifrasSlider = function () { var slider = jQuery(".cifrasSlider"); if (slider.length > 0) { slider.owlCarousel({ items: 3, loop: false, margin: 18, dots: false, navs: false, center: true, responsive: { 0: { items: 1, autoWidth: true, }, 500: { items: 2, }, 768: { items: 3, autoWidth: false, }, 900: { items: 3, center: false, autoWidth: false, }, }, }); slider.addClass("owl-carousel"); } }; var mobileImages = function () { var imageReplace = jQuery("[data-mobile]"); // reemplaza la imagen desktop por mobile imageReplace.each(function () { var srcImage = jQuery(this).attr("data-mobile"), srcDesktopImage = jQuery(this).attr("data-desktop"); if (jQuery(window).width() < 768) { jQuery(this).attr("src", srcImage); } else { jQuery(this).attr("src", srcDesktopImage); } }); }; carouselInfoSquare = function (slider) { var itemsNumber; if (slider.length > 0) { items = slider.find(".eachInfoSquare"); itemsNumber = items.length; slider.owlCarousel({ items: itemsNumber, loop: false, margin: 18, dots: false, navs: false, center: true, responsive: { 0: { items: 2, margin: 33, }, 680: { margin: 20, }, 768: { margin: 25, }, 900: { items: 3, margin: 50, center: false, }, 1024: { margin: 65, }, }, }); } }; var interestLinksSlider = function () { var slider = jQuery(".interestLinksSlider"); slider.owlCarousel({ loop: false, autoplay: true, margin: 80, dots: false, navs: false, center: true, items: 2, navContainer: ".nose", dotsContainer: ".nose", }); slider.addClass("owl-carousel"); }; var valuesSlider = function () { var slider = jQuery(".valuesSlider"), items, itemsNumber; if (slider.length > 0) { items = slider.find(".eachValue"); itemsNumber = items.length; slider.owlCarousel({ items: itemsNumber, loop: false, margin: 18, dots: false, navs: false, center: true, responsive: { 0: { items: 2, margin: 80, }, 768: { items: 3, margin: 50, }, 900: { items: itemsNumber, center: false, }, }, }); slider.addClass("owl-carousel"); } }; var uniqueCarousel = function (slider) { items = slider.find(".eachUnique"); itemsNumber = items.length; slider.owlCarousel({ items: itemsNumber, loop: false, margin: 18, dots: false, navs: false, center: true, responsive: { 0: { items: 2, }, 900: { items: 3, center: false, }, }, }); }; var lifePurposeSlider = function (id) { id.owlCarousel({ items: 1, loop: false, margin: 0, nav: true, dotsContainer: ".allDots", navContainer: ".navsArrows", center: false, }); }; categoriesCarousel = function (slider) { slider.owlCarousel({ margin: 15, loop: false, dots: false, navs: false, responsive: { 0: { autoWidth: true, items: 1, loop: true, }, 561: { autoWidth: true, }, }, }); }; carouselRelCareers = function (slider) { slider.owlCarousel({ items: 4, loop: false, margin: 18, dots: false, navs: false, center: true, autoWidth: true, responsive: { 0: { items: 1, }, 321: { items: 2, margin: 90, }, 420: { items: 2, margin: 80, }, 560: { items: 2, margin: 18, center: false, }, 900: { items: 3, center: false, }, }, }); }; var soyEgresadoCarousel = function (slider) { slider.owlCarousel({ items: 1, singleItem: true, dotsContainer: ".carouselEgresado-custom-dots", }); }; var calculateTabsOverlay = function () { var listElements = jQuery(".overlapTabs").find("ul").children("li"); if (listElements.length > 0) { listElements.each(function () { jQuery(this).css("max-width", 100 / listElements.length + "%"); }); } }; var functionTabsOverlay = function () { jQuery("body").on("click", ".tabButton", function () { if (window.innerWidth <= 740) { var contents = jQuery(this).closest(".HTMLOut").find(".showTab"); jQuery("html, body").animate( { scrollTop: contents.offset().top - 70 }, "slow" ); } }); }; calculateGallery = function () { // var gallery = jQuery('.containerGallery'), // widthGallery = gallery.attr('data-width'); // // calcula el ancho de columnas de la galería // jQuery('.photo-zoom img').each(function(){ // var that = jQuery(this), // imageWidth = that.attr('width'), // partsof = widthGallery / imageWidth, // roundNumber = ((partsof % 1) < .6) ? Math.floor(partsof) : Math.ceil(partsof); // that.parents('.col').addClass('bparts-'+roundNumber); // }); // jQuery('.rowContainerGallery').magnificPopup({ // delegate: 'a', // type: 'image', // mainClass: 'mfp-with-zoom mfp-img-mobile', // image: { // verticalFit: true, // }, // gallery: { // enabled: true // }, // zoom: { // enabled: true, // duration: 230, // opener: function(element) { // return element.find('img'); // } // } // }); jQuery(window).on("load", function () {}); jQuery("body").on("click", ".rowContainerGallery a", function (e) { e.preventDefault(); }); }; var destroy = function (slider, elementClass) { slider.trigger("destroy.owl.carousel"); // Trigger destroy event (4*) slider = false; // Reinit slider variable jQuery(elementClass).removeClass("owl-carousel"); // Remove owl slider class (3*) }; var scrollForm = function () { if (jQuery(".sliderPrincipal").length > 0) { // detecta la posición en pantalla y dependiendo de ella muestra u oculta el formulario jQuery(window).scroll(function (e) { if ( jQuery(window).scrollTop() > jQuery(".sliderPrincipal").offset().top + jQuery(".sliderPrincipal").height() ) { jQuery(".formularioHbsp").removeClass("appearForm"); } else { jQuery(".formularioHbsp").addClass("appearForm"); } }); } }; var accordion = function () { // funcionalidad de accordion jQuery("body").on("click", ".accordionTitle", function (e) { e.preventDefault(); var that = jQuery(e.target); that .parents("li") .siblings("li") .find(".accordion") .removeClass("active"); that.parents(".accordion").toggleClass("active"); }); // funcionalidad de accordion jQuery("body").on("click", ".campus .campusItem", function (e) { e.preventDefault(); var that = jQuery(this); if (!that.hasClass("active")) { that.closest(".campus").find(".campusItem").removeClass("active"); that.addClass("active"); } else { that.closest(".campus").find(".campusItem").removeClass("active"); } }); }; testimonySlider = function (slider) { var testimonySlider = slider; var navs = slider.closest(".testimonySliderContainer").find(".arrowButton"); navs.each(function (ele) { if (jQuery(navs[ele]).hasClass("backArrow")) { jQuery(navs[ele]).click(function (e) { e.preventDefault(); testimonySlider.trigger("prev.owl.carousel"); }); } else { jQuery(navs[ele]).click(function (e) { e.preventDefault(); testimonySlider.trigger("next.owl.carousel"); }); } }); testimonySlider.owlCarousel({ items: 1, singleItem: true, dotsContainer: ".testimonyCarousel-custom-dots", }); }; var videoBanner = function () { jQuery("body").on("click", ".videoBanner a", function (e) { var video = jQuery(this).attr("data-vid"); jQuery(this).parents(".changeVideo").find("iframe").attr("src", video); }); }; var showVideo = function () { jQuery("body").on("click", ".callVideoShow", function (e) { e.preventDefault(); jQuery(".showVideo iframe").attr("src", ""); var that = jQuery(this), ideVideo = that.attr("data-video"); video = "https://www.youtube.com/embed/" + ideVideo + "?autoplay=0&controls=0&showinfo=0&rel=0&modestbranding=1&enablejsapi=1&html5=1"; setTimeout(function () { jQuery(".showVideo iframe").attr("src", video); }, 300); jQuery(".showVideo").addClass("active"); }); jQuery("body").on("click", ".hideDownSlide", function (e) { e.preventDefault(); if (jQuery(this).closest(".showVideo").hasClass("active")) { jQuery(this).closest(".showVideo").removeClass("active"); } }); }; var eachInfoGraduatedSquare = function () { jQuery("body").on("click", ".eachInfoGraduatedSquare", function (e) { e.preventDefault(); var that = jQuery(this), info = jQuery(this).find(".detailInfo").html(), image = that.find("img").attr("src"); jQuery(".infoDownSlide .hereInfo") .empty() .append( '
' + info + "
" ); jQuery(".infoDownSlide").addClass("active"); }); //oculta el detalle jQuery(".hideDownSlide").click(function (e) { e.preventDefault(); jQuery(".port").removeClass("active"); }); }; var searchBox = function () { jQuery("body").on("click", ".searchButton", function (e) { e.preventDefault(); jQuery(".buscadorDownSlide").addClass("active"); }); jQuery("body").on("click", ".buscadorDownSlide .hideDownSlide", function ( e ) { e.preventDefault(); jQuery(".buscadorDownSlide").removeClass("active"); }); jQuery('.buscadorDownSlide [type="radio"]').click(function (e) { var that = jQuery(this), thisValue = that.val(); jQuery(".contentFilters").removeClass("active"); jQuery('[data-filter="' + thisValue + '"]').addClass("active"); }); }; var flagAnimator = true; var animator = function () { jQuery("body").append('
'); var _watcher = function () { var commonDiv = jQuery(".container"), triggerPositions = jQuery(".animatorTrigger").offset().top, elements = []; for (var i = 0; i < commonDiv.length; i++) { if ( !jQuery(commonDiv[i]).closest(".generalHeader").length && !jQuery(commonDiv[i]).closest("footer").length ) { elements.push(jQuery(commonDiv[i])); if (!jQuery(commonDiv[i]).hasClass("animator-off") && flagAnimator) { jQuery(commonDiv[i]).addClass("animator-off"); } } } flagAnimator = false; elements.forEach(function (item) { var blkStepPositions = item.offset().top, blkStepHeights = blkStepPositions + item.innerHeight(), blkFooterTop = jQuery("footer").length ? jQuery("footer").offset().top : 0; if ( (triggerPositions > blkStepPositions && triggerPositions < blkStepHeights) || triggerPositions > blkStepPositions ) { if (item.hasClass("animator-off")) { item.removeClass("animator-off"); item.addClass("animator-on"); for (var r = 0; r < elements.length; r++) { jQuery(elements[r]).removeClass("animator-off"); jQuery(elements[r]).addClass("animator-on"); if (elements[r] == item) { break; } } } } }); }; jQuery(document).on("scroll", function () { _watcher(); }); jQuery(document).ready(function () { _watcher(); }); jQuery(window).on("resize", function () { _watcher(); }); }; mobileDevice = function () { var user_agent = navigator.userAgent.toLowerCase(), mobile_device = user_agent.match(/(iphone|ipod|ipad|android)/), device_event = mobile_device ? "click" : "mouseover", device = mobile_device ? true : false, result; result = device_event; return result; }; var constructorFooter = function () { var blkFooter = jQuery("#tplFooter"), blkDOM = blkFooter.attr("data-dom"), itemTPL = jQuery("#tplFooterItem").html(), url = _urlConstructor(blkFooter); var datos = {}, html = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { for (var item in resp) { datos = { link: resp[item].absolute, title: resp[item].title, target: resp[item].external ? "_blank" : "_self", }; html += fillView({ data: datos, view: itemTPL, }); } jQuery("." + blkDOM).html(""); jQuery("." + blkDOM).html(html); jQuery(".menuMobileMenu .anotherLinks").html( jQuery("." + blkDOM).html() ); }, }); }; var constructorHeaderLinks = function () { var chunk = jQuery("#tplVacantesLinks"), blkDOM = chunk.attr("data-dom"), url = _urlConstructor(chunk); var html = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { for (var item in resp) { if (resp[item].options.attributes.hasOwnProperty("class")) { datos = { link: resp[item].absolute, title: resp[item].title, }; html += fillView({ data: datos, view: chunk.html(), }); jQuery("." + blkDOM).html(""); jQuery("." + blkDOM).html(html); html = ""; jQuery("." + blkDOM) .find("a") .attr( "target", resp[item].options.hasOwnProperty("external") ? "_blank" : "_self" ); } else { var logoTop = jQuery(".logoHeader"), logoBottom = jQuery(".specialStickyLogo"), logos = [logoTop, logoBottom], link = resp[item].absolute; jQuery(logos).each(function (item) { logos[item].attr("href", link); logos[item].find("a").attr("href", link); }); logoTop .find("img") .attr("src", resp[item].options.attributes.image_url); logoBottom .find("img") .attr("src", resp[item].options.attributes.image_url_banner); } } }, }); }; var constructorAyudaLinks = function () { var chunk = jQuery("#tplAyudaLinks"), blkDOM = chunk.attr("data-dom"), url = _urlConstructor(chunk); var greeenBTN = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { jQuery("#tplAyudaLinks a img").remove(); jQuery("." + blkDOM).html(""); for (var item in resp) { if (resp[item].options.attributes.class == "btn btnHeader greenBtn") { greeenBTN += '
  • ' + resp[item].title + "
  • "; } else { jQuery(".languageMenu.lm").append(chunk.html()); jQuery(".languageMenu.lm li") .last() .find("a") .attr("href", resp[item].absolute); jQuery(".languageMenu.lm li") .last() .find("a") .html( '' ); if (resp[item].options.attributes.class == "icon icon-search") { jQuery(".languageMenu.lm li") .last() .find("a") .closest(".circleIcon") .addClass("searchButton"); } if (resp[item].options.attributes.class == "icon icon-whatsApp") { jQuery(".languageMenu.lm li") .last() .find("a") .closest(".circleIcon") .addClass("whats"); } if (resp[item].options.attributes.target) { jQuery(".languageMenu.lm li") .last() .find("a") .attr("target", resp[item].options.attributes.target); jQuery(".languageMenu.lm li") .last() .find("a") .html( '' ); } } } jQuery(".languageMenu.lm").append(greeenBTN); jQuery(".languageMenu.justMobile").append(greeenBTN); }, error: function (e) { console.error("algo salio mal: ", e); }, }); }; _urlConstructor = function (ID) { _getNode = function (ID) { var regExp = /page-node-\w*/g; if ( ID.attr("data-api").indexOf("alianzas_y_convenios") >= 0 || ID.attr("data-api").indexOf("campus_conexion") >= 0 ) { return ""; } else { var node = jQuery("body").attr("class").match(regExp)[0].split("-"), nodeID = node[node.length - 1]; return "/" + nodeID; } }; // var _getApi = function(ID){ // var api = ID.attr('data-url') ? ID.attr('data-url') : ID.attr('data-api'); // var value = (api) ? ((api.split('/').includes('[lang]') || api.split('/').includes('%')) ? api.replace(/\%|\[lang]/g, jQuery('html').attr('lang')) : api) : ''; // return value; // }; var _getApi = function (ID) { var api = ID.attr("data-url") ? ID.attr("data-url") : ID.attr("data-api"); var value = api ? api.split("/").indexOf("[lang]") >= 0 || api.split("/").indexOf("%") >= 0 ? api.replace(/\%|\[lang]/g, jQuery("html").attr("lang")) : api : ""; return value; }; var service = _getApi(ID), testingDB = ID.attr("data-db"), currentUrl = window.location.hostname, dataPath = window.location.pathname.split("/").indexOf("drupalsite") >= 0 || window.location.pathname.split("/").indexOf("front_end") >= 0 ? "Tecmilenio/Code/drupalsite/" : ""; var node = ID.attr("data-node") ? "/" + ID.attr("data-node") : ID.prop("tagName") == "BODY" ? _getNode(ID) : ""; // console.log('//'+currentUrl+'/'+dataPath+service+(node ? node : '')); if (ID.attr("id") == "newsHubspot") { return currentUrl == "localhost" ? testingDB : service + (node ? node : ""); } else { return currentUrl == "localhost" ? testingDB : "//" + currentUrl + "/" + dataPath + service + (node ? node : ""); } }; var constructorHeader = function () { var blkHeader = jQuery("#tplHeaderNavNew"), blkDOM = blkHeader.attr("data-dom"), url = _urlConstructor(blkHeader); var domMain = jQuery("." + blkDOM).find(".principalList"); var domMainMobile = jQuery(".globalUl"); var linkLists = blkHeader.find(':contains("{{links}}")').closest(".info"); linkLists.each(function (ele) { var value = jQuery(linkLists[ele]).text(); jQuery(linkLists[ele]).html(value); }); var tplMain = blkHeader.find('[data-block="principalList"]').html(); var tplMobileMain = blkHeader.find('[data-block="showMenuTab"]').html(); var tplSecondlevel = blkHeader.find('[data-block="leftSide"]').html(); var tplSecondlevelMobile = blkHeader .find('[data-block="showSubTab"]') .html(); var tplFourthlevel = blkHeader.find('[data-block="info"]').html(); var tplFourthlevelMobile = blkHeader.find('[data-block="showLink"]').html(); var navs = { mobile: { templates: [tplMobileMain, tplSecondlevelMobile, tplFourthlevelMobile], html: "", parent: domMainMobile, }, desktop: { templates: [tplMain, tplSecondlevel, tplFourthlevel], html: "", parent: domMain, }, }; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { var nav; var target = function (prop) { var valueTarget = prop == "external" ? "_blank" : "_self"; return valueTarget; }; var linksNavs = function (levelBelow, template) { if (levelBelow) { var content = ""; for (var level in levelBelow) { content += fillView({ data: { title: levelBelow[level].title, link: levelBelow[level].absolute, target: target(levelBelow[level].absolute), links: linksNavs( levelBelow[level].below, navs[nav].templates[2] ), }, view: template, }); } } return content; }; for (var item in resp) { for (nav in navs) { navs[nav].html += fillView({ data: { title: resp[item].title, link: resp[item].absolute, target: target(resp[item].external), links: linksNavs(resp[item].below, navs[nav].templates[1]), }, view: navs[nav].templates[0], }); } } for (var key in navs) { navs[key].parent.html(""); navs[key].parent.html(navs[key].html); } }, }); jQuery("body").on("click", ".showSubTab", function (e) { e.preventDefault(); jQuery(".showSubTab").removeClass("active"); if (!jQuery(this).hasClass("active")) { jQuery(this).addClass("active"); } else { jQuery(this).removeClass("active"); } }); jQuery("body").on("click", ".principalHeader .exp > a", function (e) { e.preventDefault(); }); jQuery("body").on( "click", ".principalHeader .principalList .wraps > a", function (e) { e.preventDefault(); } ); }; var constructorSocialMenu = function () { var blkSocial = jQuery("#tplSocialLink"), blkDOM = blkSocial.attr("data-dom"), url = _urlConstructor(blkSocial); var html = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { for (var item in resp) { html += fillView({ data: { title: resp[item].title, link: resp[item].absolute, target: resp[item].options.attributes.target, image: resp[item].options.attributes.imagen, }, view: blkSocial.html(), }); jQuery("." + blkDOM).html(""); jQuery("." + blkDOM).html(html); } }, }); }; var constructorFooterAds = function () { var blkAds = jQuery("#tplFooterAds"), blkDOM = blkAds.attr("data-dom"), url = _urlConstructor(blkAds); var html = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { for (var item in resp) { html += fillView({ data: { title: resp[item].title, link: resp[item].absolute, target: resp[item].options.attributes.target, image: resp[item].options.attributes.imagen, }, view: blkAds.html(), }); jQuery("." + blkDOM).html(""); jQuery("." + blkDOM).html(html); } }, }); }; var constructorPrivacyLinks = function () { var blkPrivacyLinks = jQuery("#tplPrivacyLinks"), blkDOM = blkPrivacyLinks.attr("data-dom"), url = _urlConstructor(blkPrivacyLinks); var html = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { for (var item in resp) { html += fillView({ data: { title: resp[item].title, link: resp[item].absolute, target: resp[item].target == "external" ? "_blank" : "_self", }, view: blkPrivacyLinks.html(), }); jQuery("." + blkDOM).html(""); jQuery("." + blkDOM).html(html); } }, }); }; var constructorDownloads = function () { var blkDownloadsLinks = jQuery("#tplDownloadsLinks"), blkDOM = blkDownloadsLinks.attr("data-dom"), url = _urlConstructor(blkDownloadsLinks); var html = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { for (var item in resp) { html += fillView({ data: { title: resp[item].title, link: resp[item].absolute, img: resp[item].options.attributes.imagen // target: resp[item].target == "external" ? "_blank" : "_self", }, view: blkDownloadsLinks.html(), }); jQuery("." + blkDOM).html(""); jQuery("." + blkDOM).html(html); } }, }); }; var constructorSectionLinks = function () { var chunk = jQuery('[data-dom="toSections"]'), templates = _getTemplates(chunk); var url = _urlConstructor(chunk); var html = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { chunk.find('.HTMLOut [class="' + templates.item.parent + '"]').html(""); for (var item in resp) { html += fillView({ data: { title: resp[item].titulo[0].description, link: resp[item].link[0].link.url, image: resp[item].imagen[0].imagen, description: resp[item].titulo[0].titulo_descritivo, class: resp[item].titulo[0].posicion_class, }, view: templates.item.template, }); chunk.find(".HTMLOut ." + templates.item.parent + "").append(html); html = ""; } }, }); }; var constructorContactLinks = function () { var blkContactLinks = jQuery("#tplContactoLinks"), blkDOM = blkContactLinks.attr("data-dom"), url = _urlConstructor(blkContactLinks); var html = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { for (var item in resp) { html += fillView({ data: { title: resp[item].title, link: resp[item].absolute, target: resp[item].target == "external" ? "_blank" : "_self", content: resp[item].options.attributes.subtitle, }, view: blkContactLinks.html(), }); } jQuery("." + blkDOM).html(""); jQuery("." + blkDOM).html(html); jQuery(".menuMobileMenu .contactSquare").html( jQuery("." + blkDOM) .parent() .html() ); }, }); jQuery(window).on("load", function () { var wrapsHeader = jQuery( ".principalHeader .principalList .wraps .leftSide" ); wrapsHeader.each(function (ele) { jQuery(wrapsHeader[ele]).append( jQuery(".menuMobileMenu .contactSquare").html() ); }); }); }; var constructorVinculate = function () { var chunk = jQuery('[data-dom="vinculate"]'), templates = _getTemplates(chunk); var url = _urlConstructor(chunk); var html = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { for (var item in resp) { if (resp[item].cabecera == "1") { html += fillView({ data: { titulo: '' + resp[item].titulo + "", descripcion: '' + resp[item].descripcion + "", }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(html); html = ""; } else { html += fillView({ data: { titulo: resp[item].titulo, image: resp[item].imagen[0].imagen[0], descripcion: resp[item].descripcion, }, view: templates.item.template, }); } } chunk .find('.HTMLOut [class="' + templates.item.parent + '"]') .html(html); html = ""; }, }); }; var constructorAlianzas = function (res) { console.log("la res", res); var chunk = jQuery('[data-namecontent="alianzas"]'), templates = _getTemplates(chunk); var html = "", index = 0; res.map(function (alianza) { if (alianza.hasOwnProperty("clase") && alianza.clase == "quote") { html += fillView({ data: { descripcion: alianza.descripcion }, view: templates.alianzasBlockQuote.template, }); } else { index++; html += fillView({ data: { num: index, descripcion: alianza.descripcion, imagen: alianza.imagen, _link: alianza.hasOwnProperty("link") ? function () { var lnkHtml = ""; lnkHtml += fillView({ data: { link: alianza.link.url, descripcion: alianza.link.text, }, view: templates.link.template, }); return lnkHtml; } : "", }, view: templates.alianzasBlock.template, }); } }); chunk.find(".HTMLOut ." + templates.alianzasBlock.parent).html(html); }; var constructorFortalezas = function (res) { var chunk = jQuery('[data-dom="fortalezas"]'), templates = _getTemplates(chunk); var url, html = ""; var index = 1; chunk.find(".HTMLOut ." + templates.bodyAccordionContents.parent).html(""); var _requestValues = function () { jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { var values = resp[0].contenido_1; for (var item in values) { if (values[item].cabecera != "1") { html += fillView({ data: { color: chunk .find(".HTMLOut ." + templates.item.parent) .find(".itemContent.active") .attr("data-color"), imagen: values[item].hasOwnProperty("imagen") ? values[item].imagen[0] : "", titulo_descritivo: values[item].titulo_descritivo, descripcion: values[item].descripcion, }, view: templates.itemContent.template, }); } } chunk .find(".HTMLOut ." + templates.bodyAccordionContents.parent) .append(templates.bodyAccordionContents.template); chunk .find(".HTMLOut ." + templates.bodyAccordionContents.parent) .find("." + templates.itemContent.parent) .last() .html(""); chunk .find(".HTMLOut ." + templates.bodyAccordionContents.parent) .find("." + templates.itemContent.parent) .last() .html(html); chunk .find(".HTMLOut ." + templates.itemContent.parent) .last() .addClass("active"); var dataStyles = chunk .find(".HTMLOut ." + templates.itemContent.parent) .last() .find("[data-style]"); dataStyles.each(function (eles) { jQuery(dataStyles) .eq(eles) .attr("style", jQuery(dataStyles).eq(eles).attr("data-style")); }); chunk .find(".HTMLOut ." + templates.itemContent.parent) .last() .attr( "data-id", chunk .find(".HTMLOut ." + templates.item.parent) .find(".itemContent.active") .attr("data-node") ); html = ""; jQuery(".loader").removeClass("active"); }, }); var dataColors = jQuery(".HTMLOut .itemContains"); // console.log('testing', dataColors); // dataColors.each(function(ele){ // if (!jQuery(dataColors[ele]).attr('style')) { // console.log('entra', jQuery(dataColors[ele])); // jQuery(dataColors[ele]).attr('style', jQuery(dataColors[ele]).attr('data-style')); // } // }); }; if (res) { chunk.find(".HTMLOut ." + templates.item.parent).html(""); for (var item in res) { // console.log('testing', templates.item.template); html += fillView({ data: { index: index, id: res[item].fortalezas[0], color: res[item].color, titulo: res[item].titulo, }, view: templates.item.template, }); chunk.find(".HTMLOut ." + templates.item.parent).append(html); if (index == 1) { chunk .find(".HTMLOut ." + templates.item.parent) .find(".itemContent") .last() .find(".card-container") .addClass("active"); chunk .find(".HTMLOut ." + templates.item.parent) .find(".itemContent") .last() .addClass("active"); } html = ""; index++; } var dataStyles = chunk .find(".HTMLOut ." + templates.item.parent) .find("[data-style]"); dataStyles.each(function (eles) { jQuery(dataStyles) .eq(eles) .attr("style", jQuery(dataStyles).eq(eles).attr("data-style")); }); chunk.attr("data-node", res[0].fortalezas[0]); url = _urlConstructor(chunk); _requestValues(); jQuery("body").on( "click", '[data-dom="fortalezas"] .itemContent', function (e) { e.preventDefault(); var id = jQuery(this).attr("data-node"); if (chunk.find('.HTMLOut [data-id="' + id + '"]').length) { chunk .find(".HTMLOut ." + templates.itemContent.parent) .removeClass("active"); chunk.find('.HTMLOut [data-id="' + id + '"]').addClass("active"); jQuery("." + templates.item.parent) .find(".itemContent.active .card-container") .removeClass("active"); jQuery("." + templates.item.parent) .find(".itemContent") .removeClass("active"); jQuery(this).find(".card-container").addClass("active"); jQuery(this).addClass("active"); } else { jQuery(".loader").addClass("active"); chunk .find(".HTMLOut ." + templates.itemContent.parent) .removeClass("active"); chunk.attr("data-node", jQuery(this).attr("data-node")); jQuery("." + templates.item.parent) .find(".itemContent.active .card-container") .removeClass("active"); jQuery("." + templates.item.parent) .find(".itemContent") .removeClass("active"); jQuery(this).find(".card-container").addClass("active"); jQuery(this).addClass("active"); url = _urlConstructor(chunk); _requestValues(); } } ); } }; var constructorAgentes = function () { var chunk = jQuery('[data-dom="agentes"]'), templates = _getTemplates(chunk); var url = _urlConstructor(chunk); var html = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { chunk.find(".HTMLOut").html(templates.htmlout.template); chunk .find('.HTMLOut [class="' + templates.item.parent + '"]') .addClass("owl-carousel"); chunk.find(".HTMLOut .owl-carousel").html(""); //testimonySlider(chunk.find('.HTMLOut .owl-carousel')); for (var item in resp) { html += fillView({ data: { descripcion: resp[item].descripcion, titulo: resp[item].titulo, carrera: resp[item].carrera, imagen: resp[item].imagen[0].imagen[0], }, view: templates.item.template, }); chunk .find(".HTMLOut .owl-carousel") .owlCarousel("add", html) .owlCarousel("update"); html = ""; /*chunk.find('.HTMLOut .arrowButton').click(function(e) { e.preventDefault(); chunk.find('.HTMLOut .owl-carousel').trigger('next.owl.carousel'); }); chunk.find('.HTMLOut .backArrow').click(function(e) { e.preventDefault(); chunk.find('.HTMLOut .owl-carousel').trigger('prev.owl.carousel'); });*/ } chunk.find(".HTMLOut .owl-carousel").trigger("destroy.owl.carousel"); testimonySlider(chunk.find(".HTMLOut .owl-carousel")); html = ""; /*chunk.find('.HTMLOut .arrowButton').click(function(e) { e.preventDefault(); chunk.find('.HTMLOut .owl-carousel').trigger('next.owl.carousel'); }); chunk.find('.HTMLOut .backArrow').click(function(e) { e.preventDefault(); chunk.find('.HTMLOut .owl-carousel').trigger('prev.owl.carousel'); });*/ }, }); }; var constructorEgresados = function () { var chunk = jQuery('[data-dom="allGraduated"]'), templates = _getTemplates(chunk); var url = _urlConstructor(chunk); var html = ""; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { for (var item in resp) { html += fillView({ data: { id: resp[item].id, titulo: resp[item].titulo, carrera: resp[item].carrera, descripcion: resp[item].descripcion, edad: resp[item].edad, imagen: resp[item].imagen[0].imagen ? resp[item].imagen[0].imagen[0] : "", }, view: templates.item.template, }); } chunk.find(".HTMLOut ." + templates.item.parent).html(html); html = ""; }, }); }; var constructorIdentidadLinks = function () { var chunk = jQuery('[data-dom="ourInformation"]'), templates = _getTemplates(chunk); var url = _urlConstructor(chunk); var html = "", content = "", count = 10, round = 1; (media = ""), (portada = ""); (minElements = 4), (tempArray = []); var _videolink = function (ID) { media += fillView({ data: { videoid: ID }, view: templates.videocta.template, }); return media; }; var _constructor = function (arrayItem) { if (arrayItem.portada == "1") { portada += fillView({ data: { firstCta: arrayItem.opcion_imagen_video == "Video" ? (function () { var htmlInt = ""; htmlInt += fillView({ data: { titulo_descritivo: arrayItem.titulo[0].titulo_descritivo, _videocta: templates.videocta.template, posicion: arrayItem.titulo[0].posicion_class, videoid: _getYoutubeID(arrayItem.video), imagen: arrayItem.imagen[0].imagen, }, view: templates.firstMedia.template, }); return htmlInt; })() : (function () { var htmlInt = ""; htmlInt += fillView({ data: { titulo_descritivo: arrayItem.titulo[0].titulo_descritivo, _videocta: "", posicion: arrayItem.titulo[0].posicion_class, imagen: arrayItem.imagen[0].imagen, link: arrayItem.link[0].link.url, }, view: templates.firstLink.template, }); return htmlInt; })(), }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(portada); chunk .find( '.HTMLOut [class="' + templates.boxesCarouselElement.parent + '"]' ) .addClass("owl-carousel"); carouselPrincipal( chunk.find( ".HTMLOut ." + templates.boxesCarouselElement.parent + ".owl-carousel" ) ); chunk.find(".HTMLOut .nextSlide").on("click", function (e) { e.preventDefault(); chunk.find(".HTMLOut .owl-carousel").trigger("next.owl.carousel"); }); count++; tempArray.shift(); } else { if (arrayItem.opcion_imagen_video == "Video") { html += fillView({ data: { description: arrayItem.titulo[0].titulo_descritivo, link: "", posicion: arrayItem.titulo[0].posicion_class, videoid: _getYoutubeID(arrayItem.video), image: arrayItem.imagen[0].imagen, }, view: templates.itemmedia.template, }); } else { html += fillView({ data: { description: arrayItem.titulo[0].titulo_descritivo, link: arrayItem.link[0].link.url, image: arrayItem.imagen[0].imagen, posicion: arrayItem.titulo[0].posicion_class, }, view: templates.item.template, }); } tempArray.shift(); if (round > 1) { chunk.find(".HTMLOut .nextSlide").removeClass("hidden"); } if (count == 14 || !tempArray.length) { content += fillView({ data: { _item: html, index: round }, view: templates.boxesCarouselElement.template, }); chunk .find( ".HTMLOut ." + templates.boxesCarouselElement.parent + ".owl-carousel" ) .owlCarousel("add", content) .owlCarousel("update"); count = 11; round++; html = ""; content = ""; } else { count++; } } if (tempArray.length) { _constructor(tempArray[0]); } }; jQuery.ajax({ type: "GET", url: url, dataType: "json", success: function (resp) { tempArray = resp; console.log("testing resp", resp); var resultPortada = resp.filter(function (object) { return object.portada == 1; }); if (!resultPortada.length) { portada += fillView({ data: { firstCta: resp[0].opcion_imagen_video == "Video" ? (function () { var htmlInt = ""; htmlInt += fillView({ data: { titulo_descritivo: resp[0].titulo[0].titulo_descritivo, _videocta: templates.videocta.template, posicion: resp[0].titulo[0].posicion_class, videoid: _getYoutubeID(resp[0].video), imagen: resp[0].imagen[0].imagen, }, view: templates.firstMedia.template, }); return htmlInt; })() : (function () { var htmlInt = ""; htmlInt += fillView({ data: { titulo_descritivo: resp[0].titulo[0].titulo_descritivo, _videocta: "", posicion: resp[0].titulo[0].posicion_class, imagen: resp[0].imagen[0].imagen, link: resp[0].link[0].link.url, }, view: templates.firstLink.template, }); return htmlInt; })(), }, view: templates.htmlout.template, }); chunk.find(".HTMLOut").html(portada); chunk .find( '.HTMLOut [class="' + templates.boxesCarouselElement.parent + '"]' ) .addClass("owl-carousel"); carouselPrincipal( chunk.find( ".HTMLOut ." + templates.boxesCarouselElement.parent + ".owl-carousel" ) ); chunk.find(".HTMLOut .nextSlide").on("click", function (e) { e.preventDefault(); chunk.find(".HTMLOut .owl-carousel").trigger("next.owl.carousel"); }); count++; tempArray.shift(); } _constructor(tempArray[0]); }, }); }; var mainNav = function () { var validateHeight = function (leftBlock, rightBlock) { if (rightBlock.height() >= leftBlock.height()) { leftBlock.css("height", rightBlock.height()); } }; jQuery("body").on( mobileDevice(), ".centerMenu .principalList .wraps > a", function (e) { e.preventDefault(); jQuery(this).closest(".wraps").find(".exp").eq(0).addClass("active"); var leftBlock = jQuery(this).closest(".wraps").find(".leftSide"), rightBlock = jQuery(this) .closest(".wraps") .find(".exp.active .rightSide"); validateHeight(leftBlock, rightBlock); } ); jQuery("body").on(mobileDevice(), ".openMenu .leftSide .exp > a", function ( e ) { e.preventDefault(); jQuery(this).closest(".wraps").find(".exp").removeClass("active"); }); }; var youtubeVideoSlider = function () { var blkIframeLink = jQuery(".youtubeVideoSlider"); blkIframeLink.each(function () { var regExp = /([a-zA-Z0-9\_\-]+)&?/g, url = jQuery(this).attr("data-source"), arrayUrl = url.match(regExp), ID = arrayUrl[arrayUrl.length - 1], player = jQuery(this).attr("data-player"), attrbs = jQuery(this).attr("data-parameters"); jQuery(this).attr("src", player + ID + attrbs + ID); }); }; _getYoutubeID = function (url) { // https://www.youtube.com/embed/-rAeqN-Q7x4 // https://www.youtube.com/watch?v=1B7-Ff-1Kos // https://youtu.be/1B7-Ff-1Kos // https://www.youtube.com/watch?time_continue=2&=&v=1B7-Ff-1Kos if (url) { var regExp = /(v=|\.be\/|\.com\/embed)([^&\s]+)/g; fileID = jQuery(url.match(regExp))[0].replace( /v=|\.be\/|\.com\/embed\//g, "" ); temp = fileID; return temp; } }; var principalSlider = function () { var blkBanner = jQuery("#tplBanner"), blkDOM = blkBanner.attr("data-dom"), service = _urlConstructor(blkBanner); var tplMedia, html = ""; var _getVideo = function (ele) { var fileID, temp; if (ele.url) { var demo = ele.url; // var demo = 'https://www.youtube.com/watch?v=1B7-Ff-1Kos'; // var demo = 'https://youtu.be/1B7-Ff-1Kos'; fileID = demo.split(/\=|\//g); temp = fileID[fileID.length - 1]; } else if (ele.archivo) { fileID = ele.archivo.url; temp = fileID; } else { fileID = ""; temp = ""; } return temp; }; jQuery.ajax({ type: "GET", url: window.location.hostname == "localhost" ? service : service + "/" + blkBanner.attr("data-state"), dataType: "json", success: function (resp) { for (var item in resp) { if (resp[item].es_video == 1) { tplMedia = resp[item].video[0].url ? blkBanner.find('[data-source="youtube"]') : blkBanner.find('[data-source="mp4"]'); } else { tplMedia = blkBanner.find('[data-source="picture"]'); } html += fillView({ data: { position: resp[item].titulo[0].posicion_class, title: resp[item].titulo[0].titulo_descritivo, _link: resp[item].link[0].show_link != "hidden" ? function () { var htmlLink = ""; htmlLink += fillView({ data: { link: resp[item].link[0].link.url, text: resp[item].link[0].link.text, }, view: blkBanner.find('[data-block="_link"]'), }); return htmlLink; } : "", // _link: resp[item].link[0].show_link == 'visible' ? (function(){ var htmlLink; htmlLink += fillView({ data: { link: resp[item].link[0].link.url, text: resp[item].link[0].link.text }, view: blkBanner.find('[data-block="_link"]') }); return htmlLink; }) : '', imagen_desktop: resp[item].video[0].imagen ? resp[item].video[0].imagen[0] : tplMedia.attr("data-placeholderdesktop"), imagen_mobile: resp[item].video[0].imagen_mobile ? resp[item].video[0].imagen[0] : tplMedia.attr("data-placeholdermobile"), video: _getVideo(resp[item].video[0]), }, view: unescape(tplMedia.html()), }); jQuery("." + blkDOM) .owlCarousel("add", html) .owlCarousel("update"); html = ""; } jQuery("." + blkDOM).on("changed.owl.carousel", function (event) { setTimeout(function () { var activeEls = jQuery(event.target).find(".owl-item.active"); if (activeEls.find("video").length) { activeEls.find("video")[0].load(); } }, 1); }); jQuery("." + blkDOM).trigger("refresh.owl.carousel"); // sliderPrincipal(); }, }); }; var carouselPrincipal = function (ID) { ID.owlCarousel({ items: 1, loop: true, margin: 18, merge: true, dots: false, navs: false, responsive: { 678: { mergeFit: true, }, 1000: { mergeFit: false, }, }, }); }; jQuery(window).on("load", function () { // fn(); if (jQuery(".container").length) { animator(); jQuery(".loader").removeClass("active"); } }); jQuery(window).resize(function () { mobileImages(); sliderPrincipal(); // newsCarousel(); cifrasSlider(); }); var newsHubspot = function () { var chunk = jQuery("#newsHubspot"), templates = _getTemplates(chunk), url = _urlConstructor(chunk), num = 0, html = ""; chunk.find("." + templates.item.parent).addClass("owl-carousel"); newsCarousel(chunk.find(".owl-carousel")); jQuery.ajax({ type: "GET", url: url, data: { hapikey: chunk.attr("data-api-key"), content_group_id: chunk.attr("data-content-group-id"), limit: chunk.attr("data-limit"), state: chunk.attr("data-state"), }, dataType: "json", success: function (resp) { var objects = resp.objects; objects.map(function (object) { num++; html += fillView({ data: { published_url: object.published_url, post_list_summary_featured_image: object.post_list_summary_featured_image, num: num, page_title: object.page_title, }, view: templates.item.template, }); chunk .find(".HTMLOut .owl-carousel") .owlCarousel("add", html) .owlCarousel("update"); html = ""; }); }, }); }; init(); })(); /** * [[Archivo global del proyecto]] * @private * @author Rocio Ortiz */ (function () { var body = document.getElementsByTagName("body")[0]; var init = function () { if (jQuery('body').attr('data-url') || jQuery('body').attr('data-api')) { constructorInternal();} if (jQuery('[data-dom="periodos_ingresos"]').length) { fillViewIngresos();} if (jQuery('[data-dom="preguntas"]').length) { fillViewPreguntas();} if (jQuery('[data-dom="tabsRegionTabs"]').length && jQuery('[data-dom="tabsRegionContenido"]').length) { tabsCampusRegion(); } }; var tabsCampusRegion = function(){ var chunk = jQuery('[data-dom="tabsRegionTabs"]'), chunkContainer = jQuery('[data-dom="tabsRegionContenido"]'), chunkFilterStates = jQuery('#filterState'), templates = _getTemplates(chunk), url = _urlConstructor(chunk); var page = 0; var flagFilters = false; var currentPage, totalPages, pager; var _toogleTab = function(active){ var cont = chunkContainer.find('.bodyAccordion'); var text = active.find('.front .titleBlock').text(); pager = cont.find('.itemContains[data-node="'+active.attr('data-id')+'"] .pagerBlock-pagination'); console.log('el paginador', validatePaginador); if (!pager.hasClass('hidden')) { validatePaginador = true; } cont.find('.itemContains').removeClass('active'); cont.find('.itemContains[data-node="'+active.attr('data-id')+'"]').addClass('active'); chunkContainer.find('.itemContains-title > *').text(text); if (active.attr('data-id') == 'all') { cont.find('.itemContains[data-node="'+active.attr('data-id')+'"] .onlyViewInAll').addClass('active'); chunkContainer.find('.onlyViewInAll').addClass('active'); } else { cont.find('.itemContains[data-node="'+active.attr('data-id')+'"] .onlyViewInAll').removeClass('active'); chunkContainer.find('.onlyViewInAll').removeClass('active'); } if (cont.find('.itemContains[data-node="'+active.attr('data-id')+'"] .containerPager-item[data-page="'+page+'"]').length && !cont.find('.itemContains[data-node="'+active.attr('data-id')+'"] .containerPager .containerPager-item[data-page="'+page+'"]').hasClass('active')) { cont.find('.itemContains[data-node="'+active.attr('data-id')+'"] .containerPager-item').removeClass('active'); cont.find('.itemContains[data-node="'+active.attr('data-id')+'"] .containerPager-item[data-page="'+page+'"]').addClass('active'); totalPages = pager.find('.blockPager-text .pages').text(); currentPage = chunk.attr('data-page'); } pager.find('.blockPager-text .page').text(Number(currentPage)+1); pager.find('.blockPager-text .pages').text(totalPages); active.addClass('active'); active.find('.card-container').addClass('active'); active.find('.card').addClass('active'); console.log('el pager', pager); console.log('testing pager', currentPage, ' de ' ,totalPages); // if (currentPage == 0) { // pager.find('button.prev').prop('disabled', true); // pager.find('button.next').prop('disabled', false); // } else if (currentPage == totalPages && currentPage > 0 ) { // pager.find('button.next').prop('disabled', true); // pager.find('button.prev').prop('disabled', false); // } else { // pager.find('button.prev').prop('disabled', false); // pager.find('button.next').prop('disabled', false); // } // console.log('testing pager', pager); _showHideButtons(cont.find('.itemContains[data-node="'+active.attr('data-id')+'"] .containerPager-item.active').attr('data-page')); page++; chunk.attr('data-page', page); // jQuery(".loader").removeClass("active"); }; var _toogleContent = function(active){ var input = chunk.find('.templates.hidden input[data-id="'+active.attr('data-id')+'"]'); input.attr('data-node', active.attr('data-id')); console.log('nsafsafdsafdsafdsfdsafd', input); // input.attr('data-node', that.attr('data-id')); chunk.attr('data-page', 0); page = chunk.attr('data-page'); console.log('dsadsafdfasfdsa', chunkContainer.find('.bodyAccordion .itemContains[data-node="'+active.attr('data-id')+'"]')); chunkContainer.find('.bodyAccordion .itemContains[data-node="all"]').remove(); chunk.find('.itemContent[data-id="'+active.attr('data-id')+'"]').addClass('active'); chunk.find('.itemContent[data-id="'+active.attr('data-id')+'"]').find('.card').addClass('active'); chunk.find('.itemContent[data-id="'+active.attr('data-id')+'"]').find('.card-container').addClass('active'); // chunkContainer.find('.emptyItemsMessage').addClass('hidden'); // chunkContainer.find('.onlyViewInAll').addClass('active'); _constructorContent(chunk.find('.itemContent[data-id="'+active.attr('data-id')+'"]')); chunkContainer.find('.filterState select option[value="all"]').prop('selected', true); chunkContainer.find('.filterState select').updateSelect(); }; var _showHideButtons = function(pageInput){ var txtPageTotal = Number(pager.find('.blockPager-text .pages').text())-1; console.log('pageInput', pageInput); if (pageInput == 0) { pager.find('button.prev').prop('disabled', true); pager.find('button.next').prop('disabled', false); } if (pageInput == txtPageTotal) { pager.find('button.prev').prop('disabled', false); pager.find('button.next').prop('disabled', true); } if (pageInput >= 1 && pageInput < txtPageTotal) { pager.find('button.prev').prop('disabled', false); pager.find('button.next').prop('disabled', false); } if (currentPage == 0 && txtPageTotal == 1) { pager.addClass('hidden'); pager.find('button.prev').prop('disabled', false); pager.find('button.next').prop('disabled', false); } }; var _constructorContent = function(active){ jQuery(".loader").addClass("active"); var input = chunk.find('.templates.hidden').find('[data-id="'+active.attr('data-id')+'"]'); console.log('testing input', input); jQuery.ajax({ type: 'GET', url: _urlConstructor(input), data: { page: page }, dataType: 'json', success: function(contents){ console.log('testing contents', contents.length); if (contents.length != 0) { var htmlContent = ''; var htmlCampus = ''; var htmlVirtual = ''; chunkContainer.find('.emptyItemsMessage').addClass('hidden'); for(key in contents){ if (!contents[key].hasOwnProperty('current_page')) { var block = contents[key]; if (block.region == 'Virtual') { var info = {}; info['url'] = block.tour.url; info['img'] = block.imagen[0].imagen[0]; info['icons'] = block.icono; info['titulo'] = block.titulo_detalle; info['text'] = block.tour.text; htmlVirtual += fillView({ data: info, view: templates.virtualCard.template }) } else { //CAMPUS PRESENCIAL var info = {}; info['link'] = block.link_cta[0].hasOwnProperty('link') ? block.link_cta[0].link.url : ''; info['titulo'] = block.titulo; // info['img'] = jQuery(block.imagen[0]).length ? block.imagen[0].imagen_mobile : templates.campusCard.placeholders[0]['img']; info['img'] = jQuery(block.imagen[0]).length ? block.imagen[0].imagen_mobile : ''; if (block.telefono != '') { info['_phone'] = function(){ var html = ''; html += fillView({ data: { telefono: block.telefono }, view: templates.phone.template }); return html; }; } if (block.ubicacion != '') { info['_address'] = function(){ var html = ''; html += fillView({ data: { ubicacion: block.ubicacion }, view: templates.address.template }); return html; }; } if (contents[key].link_cta[0].show_link == 'hidden') { htmlCampus += fillView({ data: info, view: templates.campusCardStatic.template }); } else { htmlCampus += fillView({ data: info, view: templates.campusCard.template }); } } validatePaginador = false; } else { validatePaginador = true; var block = contents[key]; currentPage = block.current_page, totalPages = block.total_pages; } } if (!chunkContainer.find('.HTMLOut .bodyAccordion .itemContains[data-node="'+active.attr('data-id')+'"]').length) { htmlContent += fillView({ data: { id: active.attr('data-id'), page: page, _campusCard: htmlCampus, _virtualCard: htmlVirtual }, view: templates.bodyAccordionContents.template }); console.log('el padre', chunkContainer.find('.HTMLOut .'+templates.bodyAccordionContents.parent)); chunkContainer.find('.HTMLOut .'+templates.bodyAccordionContents.parent).append(htmlContent); htmlContent = ''; htmlCampus = ''; htmlVirtual = ''; chunkContainer.find('.HTMLOut .'+templates.bodyAccordionContents.parent).find('[data-node="'+active.attr('data-id')+'"]').addClass('active'); chunkContainer.find('.HTMLOut .'+templates.bodyAccordionContents.parent).find('[data-node="'+active.attr('data-id')+'"] [data-page="'+page+'"]').addClass('active'); } else { htmlContent += fillView({ data: { page: page, _campusCard: htmlCampus, _virtualCard: htmlVirtual }, view: templates.containerPager.template }); chunkContainer.find('.HTMLOut .bodyAccordion .itemContains.active .containerPager').append(htmlContent); htmlContent = ''; htmlCampus = ''; htmlVirtual = ''; chunkContainer.find('.HTMLOut .'+templates.bodyAccordionContents.parent).find('[data-node="'+active.attr('data-id')+'"] .containerPager-item').removeClass('active'); chunkContainer.find('.HTMLOut .'+templates.bodyAccordionContents.parent).find('[data-node="'+active.attr('data-id')+'"] [data-page="'+page+'"]').addClass('active'); } pager = chunkContainer.find('.HTMLOut .'+templates.bodyAccordionContents.parent).find('[data-node="'+active.attr('data-id')+'"] .pagerBlock-pagination') if (validatePaginador == false) { console.log('el pager', pager); pager.addClass('hidden'); } console.log('safdsafdsafdsafdsaf', pager.find('.blockPager-text .pages')); pager.find('.blockPager-text .pages').text(totalPages++); _toogleTab(active); if (flagFilters == false) { _contructorFilterState(); flagFilters = true; } } else { chunkContainer.find('.emptyItemsMessage').removeClass('hidden'); chunkContainer.find('.onlyViewInAll').addClass('active'); } jQuery(".loader").removeClass("active"); } }); }; var _constructorTabs = function(){ jQuery.ajax({ type: 'GET', url: url, dataType: 'json', success: function(resp){ var data = {}; var html = ''; resp.map(function(ele){ data['descripcion'] = ele.descripcion; data['img'] = ele.imagen[0].imagen; console.log('ele.all_campus', ele.all_campus); var id = (ele.hasOwnProperty('all_campus') && ele.all_campus) ? 'all' : ele.id; console.log('el id', id); data['id'] = id; data['titulo'] = ele.titulo; if (ele.hasOwnProperty('json')) { data['json'] = ele.json; } data['api'] = ele.data_api; if (ele.show_tab == true) { html += fillView({ data: data, view: templates.item.template }); if (ele.titulo == 'Virtual') { chunk.find('.templates.hidden').prepend(''); } else { if (id == 'all') { chunk.find('.templates.hidden').prepend(''); } else { chunk.find('.templates.hidden').prepend(''); } } data = {}; } }); chunk.find('.HTMLOut .'+templates.item.parent).html(html); var items = chunk.find('.HTMLOut .'+templates.item.parent+' .itemContent'); console.log('el hash <<<<<<<<<<<<<<<<', window.location.hash ); console.log('el hash <<<<<<<<<<<<<<<<',chunk.find('[data-titulo="'+window.location.hash.replace('#', '')+'"]').length ); if (window.location.hash == '' || !chunk.find('[data-titulo="'+window.location.hash.replace('#', '')+'"]').length) { items.eq(0).addClass('active'); items.eq(0).find('.card').addClass('active'); items.eq(0).find('.card-container').addClass('active'); _constructorContent(items.eq(0)); } else { var index = chunk.find('[data-titulo="'+window.location.hash.replace('#', '')+'"]').index(); items.eq(index).addClass('active'); items.eq(index).find('.card').addClass('active'); items.eq(index).find('.card-container').addClass('active'); _constructorContent(items.eq(index)); } } }); }; var _contructorFilterState = function(){ var urlStates = _urlConstructor(chunkFilterStates), select = chunkContainer.find('.filterState select'); console.log('select', select); console.log('urlStates', urlStates); jQuery(".loader").addClass("active"); jQuery.ajax({ type: 'GET', url: urlStates, // data: { page: page }, dataType: 'json', success: function(resp){ resp.map(function(state){ if (state.show_state == true) { select.append(''); } }); select.updateSelect(); jQuery(".loader").removeClass("active"); } }); }; _constructorTabs(); jQuery(document).on('click', '.itemContent', function(e){ e.preventDefault(); chunk.attr('data-page', 0); page = chunk.attr('data-page'); var that = jQuery(this); var items = chunk.find('.HTMLOut').find('.itemContent'); chunkContainer.find('.emptyItemsMessage').addClass('hidden'); if (!that.hasClass('active')) { items.map(function(ele){ jQuery(items[ele]).removeClass('active'); jQuery(items[ele]).find('.card-container').removeClass('active'); jQuery(items[ele]).find('.card').removeClass('active'); }); if (chunkContainer.find('.itemContains[data-node="'+that.attr('data-id')+'"]').length) { console.log('entra 11111'); if (that.attr('data-id') != 'all') { console.log('entra 1.1'); // chunkContainer.find('.onlyViewInAll').removeClass('active'); _toogleTab(that); } else { console.log('entra 1.2'); _toogleContent(that); } } else { console.log('entra 222222'); console.log('el that', that.attr('data-id')); if (that.attr('data-id') == 'all') { _toogleContent(that); } else { _constructorContent(that); } } } }); jQuery(document).on('click', '.pagerBlock-pagination .blockPager button', function(e){ e.preventDefault(); var that = jQuery(this), idContent = that.closest('.itemContains'), contentsPages = idContent.find('.containerPager-item'), txtPageCurrent = pager.find('.blockPager-text .page'), parentContains = that.closest('.bodyAccordion'); $([document.documentElement, document.body]).animate({ scrollTop: parentContains.offset().top - jQuery('header'). height() }, 1000); var activePage = idContent.find('.containerPager-item.active').attr('data-page'); if (that.hasClass('prev')) { contentsPages.removeClass('active'); idContent.find('[data-page="'+(Number(activePage)-1)+'"]').addClass('active'); txtPageCurrent.text(activePage); _showHideButtons(idContent.find('.containerPager-item.active').attr('data-page')); } else if (that.hasClass('next')) { if (!idContent.find('[data-page="'+(Number(activePage)+1)+'"]').length) { _constructorContent(jQuery('.itemContent.active')); } else { contentsPages.removeClass('active'); var value = Number(activePage)+1; idContent.find('[data-page="'+value+'"]').addClass('active'); txtPageCurrent.text(value+1); _showHideButtons(idContent.find('.containerPager-item.active').attr('data-page')); } } }); jQuery(document).on('change', '.filterState select', function(e){ e.preventDefault(); var id = jQuery(this).val(), input = chunk.find('.templates.hidden').find('[data-id="all"]'); // input.attr('data-url', input.attr('data-data_api').replace('%', id)); input.attr('data-node', id); chunk.attr('data-page', 0); page = chunk.attr('data-page'); chunkContainer.find('.bodyAccordion .itemContains[data-node="all"]').remove(); _constructorContent(jQuery('.itemContent.active')); // chunk.find('.templates.hidden').find('[data-id="all"]').attr('data-node', id); }); }; var controllerTabsProducto = function(){ var chunk = jQuery('[data-dom="tabsProducto"]'), templates = _getTemplates(chunk); var url; var html = ''; var index = 0; var _getNode = function(){ var regExp = /page-node-\w*/g; var node = jQuery('body').attr('class').match(regExp)[0].split('-'), nodeID = node[node.length-1] return nodeID }; var _requestContent = function(){ // RENDER PARA CONTENIDOS DE RESPUESTA // var _render = function(keys, item, template){ // var html = ''; // var data = {}; // keys.forEach(function(key){ // data[key] = item[key]; // if (key == '_link') { data[key] = item['link'].length ? _clues(item['link']) : ''; }; // if (key == 'imagen') { data[key] = item[key][0] }; // }); // html += fillView({ // data: data, // view: template // }); // return html; // }; var api = chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-api'); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent).append(templates.bodyAccordionContents.template); chunk.find('.HTMLOut .'+templates.itemContent.parent).last().addClass('active'); chunk.find('.HTMLOut .'+templates.itemContent.parent).last().attr('data-api', api); if (chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-node').length) { jQuery.ajax({ type: 'GET', url: _urlConstructor(chunk), dataType: 'json', success: function(resp){ var html = ''; if (resp.length == 1) { for(var item in resp){ var props = resp[item]; for(var key in props){ if (key == 'caracteristicas_perfil') { var _items = function(arr){ var html = ''; var index = 1; arr.forEach(function(ele){ var data = {} data['index'] = index; data['color'] = ele.color; data['descripcion'] = ele.descripcion; html += fillView({ data: data, view: templates.caracteristica.template }); index++; }); return html; }; html += fillView({ data: { _caracteristica: _items(props[key])}, view: templates.caracteristicas_perfil.template }); } if (key == 'grados') { var _items = function(arr){ var html = ''; var index = 1; arr.forEach(function(ele){ var data = {}; if (ele.hasOwnProperty('archivo')) { if (ele.archivo.url.length) { data['file'] = ele.archivo.url; } } data['index'] = index; data['color'] = ele.color; data['subtitulo'] = ele.subtitulo; data['titulo'] = ele.titulo; html += fillView({ data: data, view: templates.itemCurriculum.template }); index++; }); return html; }; html += fillView({ data: { _itemCurriculum: _items(props[key])}, view: templates.grados.template }); } if (key == 'titulo_posicion') { html += fillView({ data: { titulo_descritivo: props[key][0].titulo_descritivo}, view: templates.resumePerfil.template }); } if (key == 'imagen' && jQuery(props[key]).length) { html += fillView({ data: { imgDesktop: props[key][0].imagen, imgMobile: props[key][0].imagen_mobile}, view: templates.imagen.template }); } if (key == 'titulo') { html += fillView({ data: { titulo: props[key]}, view: templates.titulo.template }); } if (key == 'video' && typeof props[key][0] == 'string') { html += fillView({ data: { videoid: _getYoutubeID(props[key][0])}, view: templates.videocta.template }); onYouTubeIframeAPIReady(); } if (key == 'video' && typeof props[key][0] == 'object') { var videoprincipal; var _items = function(arr){ var html = ''; arr.forEach(function(ele){ html += fillView({ data: { titulo: ele.titulo, imagen_mobile: ele.imagen_mobile, imagen: ele.imagen, id: _getYoutubeID(ele.url)}, view: templates.videoitem.template }); if (ele.principal == "1") { videoprincipal = _getYoutubeID(ele.url); } }); return html; }; html += fillView({ data: { _videoitem: _items(props[key]), videoid: videoprincipal}, view: templates.changevideo.template }); onYouTubeIframeAPIReady(); } if (key == 'egresados') { var nodes = props[key].join('+'); var apis = chunk.find('.templates [data-block="_testimonios"]').attr('data-url'); var dbs = chunk.find('.templates [data-block="_testimonios"]').attr('data-db'); var element = jQuery('
    '); var htmls = '', intHTML = ''; htmls += fillView({ data: {content: templates.testimonios.template}, view: templates.itemContent.template }); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"]').html(htmls); chunk.find('.HTMLOut [class="'+templates.itemTestimonio.parent+'"]').addClass('owl-carousel'); testimonySlider(chunk.find('.HTMLOut .owl-carousel')); jQuery.ajax({ type: 'GET', url: _urlConstructor(element), dataType: 'json', success: function(resp){ resp.forEach(function(ele){ intHTML += fillView({ data: { titulo: ele.titulo, descripcion: ele.descripcion, carrera: ele.carrera, imagen: ele.imagen[0].imagen }, view: templates.itemTestimonio.template }); chunk.find('.HTMLOut .owl-carousel').owlCarousel('add', intHTML).owlCarousel('update'); intHTML = ''; }); chunk.find('.HTMLOut .owl-carousel').trigger('destroy.owl.carousel'); testimonySlider(chunk.find('.HTMLOut .owl-carousel')); } }); } } } } else { if (resp[0].clase == 'itemCertificado') { var _items = function(arr){ var html = ''; arr.forEach(function(ele){ html += fillView({ data: { titulo: ele.titulo, descripcion: ele.descripcion}, view: templates.itemCertificado.template }); }); return html; }; html += fillView({ data: { _itemCertificado: _items(resp)}, view: templates.certificados.template }); } if (resp[0].clase == 'campus') { var _items = function(arr){ var html = ''; arr.forEach(function(ele){ html += fillView({ data: { titulo: ele.titulo, telefonos: ele.telefono, ubicacion: ele.ubicacion}, view: templates.itemCampus.template }); }); return html; }; html += fillView({ data: { _itemCampus: _items(resp)}, view: templates.campus.template }); } } var finalHTML = ''; var appendHTML = html; if (!chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"] .contentsFilter').length) { finalHTML += fillView({ data: {content: appendHTML}, view: templates.itemContent.template }); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"]').prepend(chunk.find('.HTMLOut .overlapTabs [data-descripcion="'+api+'"]').html()); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"]').append(finalHTML); html = ''; appendHTML = ''; finalHTML = ''; } else { chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"] .contentsFilter').append(appendHTML); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"] .contentsFilter').prepend(chunk.find('.HTMLOut .overlapTabs [data-descripcion="'+api+'"]').html()); html = ''; appendHTML = ''; finalHTML = ''; } onYouTubeIframeAPIReady(); var dataStyles = chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"] .contentsFilter').find('[data-style]'); dataStyles.each(function(eles){ jQuery(dataStyles).eq(eles).attr('style', jQuery(dataStyles).eq(eles).attr('data-style')); }); jQuery('.loader').removeClass('active'); } }); } else { var finalHTML = ''; finalHTML += fillView({ data: {content: ''}, view: templates.itemContent.template }); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"]').prepend(chunk.find('.HTMLOut .overlapTabs [data-descripcion="'+api+'"]').html()); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"]').append(finalHTML); html = ''; appendHTML = ''; finalHTML = ''; onYouTubeIframeAPIReady(); jQuery('.loader').removeClass('active'); } onYouTubeIframeAPIReady(); }; chunk.attr('data-node', _getNode()); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent).html(''); url = _urlConstructor(chunk); jQuery.ajax({ type: 'GET', url: url, dataType: 'JSON', success: function(resp){ var tabsArray = resp[0]; for(var tab in tabsArray){ var data = {}; // data['index'] = index; data['api'] = jQuery('[data-nametabs="'+tab+'"]').length ? jQuery('[data-nametabs="'+tab+'"]').attr('value') : ''; data['titulo'] = tabsArray[tab].titulo_tabs; var prop = tabsArray[tab]; for(var key in prop){ if ( Array.isArray(prop[key]) && prop[key].length >= 1) { if (prop[key].length > 1) { data['node'] = prop[key].join('+'); } else { data['node'] = prop[key][0]; } } } if(tabsArray[tab].hasOwnProperty('json')) { data['json'] = tabsArray[tab].json; } html += fillView({ data: data, view: templates.item.template }); if(prop['visible'] == "1"){ chunk.find('.HTMLOut .'+templates.item.parent).append(html); chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent').last().find('.number').text(''); chunk.find('.HTMLOut .overlapTabs').append(''); index++; }; if (index == 1) { chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent').last().find('.card-container').addClass('active'); chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent').last().addClass('active'); chunk.attr('data-url', data.api); chunk.attr('data-db', data.json); chunk.attr('data-node', data.node); url = _urlConstructor(chunk); _requestContent(); } html = ''; data = {}; } } }); jQuery('body').on('click', '[data-dom="tabsProducto"] .itemContent' ,function(e){ e.preventDefault(); var api = jQuery(this).attr('data-api'); var db = jQuery(this).attr('data-db'); chunk.attr('data-url', api); chunk.attr('data-db', db); url = _urlConstructor(chunk); if(chunk.find('.HTMLOut .bodyAccordion [data-api="'+api+'"]').length){ chunk.find('.HTMLOut .'+templates.itemContent.parent).removeClass('active'); chunk.find('.HTMLOut [data-api="'+api+'"]').addClass('active'); jQuery('.'+templates.item.parent).find('.itemContent.active .card-container').removeClass('active'); jQuery('.'+templates.item.parent).find('.itemContent').removeClass('active'); jQuery(this).find('.card-container').addClass('active'); jQuery(this).addClass('active'); } else { jQuery('.loader').addClass('active'); chunk.find('.HTMLOut .'+templates.itemContent.parent).removeClass('active'); chunk.attr('data-api', jQuery(this).attr('data-api')); chunk.attr('data-node', jQuery(this).attr('data-node')); jQuery('.'+templates.item.parent).find('.itemContent.active .card-container').removeClass('active'); jQuery('.'+templates.item.parent).find('.itemContent').removeClass('active'); jQuery(this).find('.card-container').addClass('active'); jQuery(this).addClass('active'); _requestContent(api); } }); }; var filtroProductoCarrera = function(){ var chunk = jQuery('#filterEscolaridad').closest('[data-namecontent]'), templates = _getTemplates(chunk); var urlCategoria = _urlConstructor(chunk.find('[name="escolaridad"]')), urlCarrera = _urlConstructor(chunk.find('[name="carrera"]')), escolaridad = ''; var carreras = '', texto = ''; // PRIMER RENDER DE CARRERAS var carrera = function () { jQuery.ajax({ type: 'GET', url: urlCarrera, dataType: 'JSON', success: function (arr) { for (var item in arr) { carreras += fillView({ data: { titulo: arr[item].titulo }, view: templates.dropdown2.template }); } chunk.find('#carrera').html(''); chunk.find('#carrera').html(carreras); jQuery('#carrera li:first').addClass('active'); texto = jQuery('#carrera .active').text(); jQuery('.seleccionado').text(texto); } }); }; // METODO PARA OBTENER LAS ESCOLARIDADES jQuery.ajax({ type: 'GET', url: urlCategoria, dataType: 'JSON', success: function (arr) { // jQuery('#escolaridad').html(''); for (var item in arr) { escolaridad += fillView({ data: { id: arr[item].id, titulo: arr[item].titulo }, view: templates.dropdown.template }); } jQuery('#escolaridad').html(escolaridad); jQuery('#escolaridad').updateSelect(); carrera(); } }); // CAMBIO DE CARRERA AL HACER CLICK EN ESCOLARIDAD jQuery('body').on('change', '#escolaridad', function (e) { e.preventDefault(); var nodeCarrera, dataDb, url, carreras = '', texto = ''; nodeCarrera = jQuery('#escolaridad option:selected').attr('value'); jQuery('#carrera').attr('data-node', nodeCarrera); dataDb = '../_json/' + nodeCarrera + '.json'; jQuery('#carrera').attr('data-db', dataDb); url = _urlConstructor(jQuery('#carrera')); jQuery.ajax({ type: 'GET', url: url, dataType: 'JSON', success: function (arr) { for (var item in arr) { carreras += fillView({ data: { titulo: arr[item].titulo }, view: templates.dropdown2.template }); } chunk.find('#carrera').empty(); chunk.find('#carrera').append(carreras); jQuery('#carrera li:first').addClass('active'); texto = jQuery('#carrera .active').text(); jQuery('.seleccionado').text(texto); } }); }); // METODO PARA MOSTRAR Y OCULTAR UNA LA LISTA jQuery('body').on('click', '#select-carrera', function (e) { e.preventDefault(); var lista = $(this).find('#carrera'); lista.toggleClass('active'); }); // METODO PARA MOSTRAR EL TEXTO DEL LI (OPCION SELECCIONADA) EN EL SPAN jQuery('#select-carrera').on('click', 'li', function (e) { e.preventDefault(); e.stopPropagation(); var element = jQuery(this), texto = element.text(), seleccionado = element.parent().prev(), link = element.find('a').attr('href'); lista = element.closest('#carrera'); seleccionado.text(texto); lista.hide(); window.location.href = link; }); }; var constructorInternal = function(block){ var url = _urlConstructor(jQuery('body')); var tempResp; jQuery.ajax({ type: 'GET', url: url, dataType: 'JSON', success: function(resp){ if( resp[0].hasOwnProperty('carreras_relacionadas') && jQuery(resp[0].carreras_relacionadas).length){ var carrerasRelated = resp[0].carreras_relacionadas; jQuery('[data-dom="carreras"]').attr('data-node', carrerasRelated.join('+')); if (jQuery('[data-dom="carreras"]').length && !jQuery('[data-dom="carreras"]').hasClass('carreras')) { fillViewCarreras();} } else { if (jQuery('[data-dom="carreras"]').length && !jQuery('[data-dom="carreras"]').hasClass('carreras')) { jQuery('[data-dom="carreras"]').addClass('hidden'); } } var _remove = function(arr){ jQuery(arr).each(function(item){ delete tempResp[arr[item]]; }); }; if (jQuery('[data-namecontent="bannerProducto"]').length) { constructorTitulo(resp[0]); } if (jQuery('[data-namecontent="descripcion"]').length) { constructorDescripcion(resp[0]); } if (jQuery('[data-namecontent="descripcion_proceso"]').length) { constructorProceso(resp[0]); } if (jQuery('[data-dom="tabsProducto"]').length) { controllerTabsProducto(); } tempResp = resp[0]; _remove(['titulo', 'breadcrumb', 'imagen', 'banner', 'video','titulo_posicion','link_adicional']); //DETECTA TABS if (tempResp.hasOwnProperty('tabs') && jQuery('[data-dom="tabs"]').length) { jQuery('[data-dom="tabs"]').attr('data-node', ''); var chunk = jQuery('[data-dom="tabs"]'); chunk.find('.categoriesCarousel').trigger('destroy.owl.carousel'); var templates = _getTemplates(chunk); var url, filters = ''; var html = ''; var index = 1; var tabsArray = tempResp.tabs; chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent).html(''); var _requestContent = function(api){ var elements = {element : {}}; // LINKS INTERNOS var _clues = function(arr){ var html = ''; var data = {}; if (arr[0].hasOwnProperty('link')) { var elem = arr[0].link; if(elem.hasOwnProperty('text')){ data['text'] = elem.text; }; if(elem.hasOwnProperty('url')){ data['link'] = elem.url; }; html += fillView({ data: data, view: templates.link.template }); } return html; }; // RENDER PARA CONTENIDOS DE RESPUESTA var _render = function(keys, item, template){ var html = ''; var data = {}; keys.forEach(function(key){ data[key] = item[key]; // if (key == '_link') { data[key] = item['link'].length ? _clues(item['link']) : ''; }; if (key == '_link') { data[key] = jQuery(item['descripcion']).length ? item['descripcion'] : ''; }; if (key == 'imagen') { data[key] = item[key][0] }; }); html += fillView({ data: data, view: template }); elements['element'][item.orden] = html; }; jQuery.ajax({ type: 'GET', url: url, dataType: 'json', success: function(resp){ for(var item in resp){ if (resp[item].clase == 'cardProcess') { _render(["orden", "imagen", "titulo", "_link"], resp[item], templates.cardProcess.template); } if (resp[item].clase == 'scholarshipsType') { _render(["orden", "imagen", "titulo", "_link", "descripcion_larga"], resp[item], templates.scholarshipsType.template); } if (resp[item].clase == 'noticeProcess') { _render(["orden", "titulo", "descripcion_larga"], resp[item], templates.noticeProcess.template); } }; var appendHTML = ''; var finalHTML = ''; for(var key in elements['element']){ appendHTML += elements['element'][key]; }; if (chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"] .contentsFilter').length) { chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"] .contentsFilter').html(''); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"] .contentsFilter').append(appendHTML); } else { finalHTML += fillView({ data: {content: appendHTML}, view: templates.itemContent.template }); if (chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"]').length) { chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"]').append(finalHTML); } else { chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent).append(templates.bodyAccordionContents.template); chunk.find('.HTMLOut .'+templates.itemContent.parent).last().addClass('active'); chunk.find('.HTMLOut .'+templates.itemContent.parent).last().attr('data-api', api); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent+' [data-api="'+api+'"]').append(finalHTML); } } elements = {element : {}}; html = ''; appendHTML = ''; finalHTML = ''; jQuery('.loader').removeClass('active'); } }); }; var _requestFilters = function(api){ // CONSTRUYO FILTROS console.log('el api', api); if (chunk.find('.HTMLOut .'+templates.item.parent).find('[data-api="'+api+'"]').attr('data-taxonomia') != '') { var taxonomiaAPI = jQuery('[data-dom="tabs"]').find('.HTMLOut .'+templates.item.parent).find('[data-api="'+api+'"]').attr('data-taxonomia'); var taxonomiaJSON = jQuery('[data-dom="tabs"]').find('.HTMLOut .'+templates.item.parent).find('[data-api="'+api+'"]').attr('data-taxo'); console.log('el taxonomiaAPI', jQuery('[data-dom="tabs"]').find('.HTMLOut .'+templates.item.parent).find('[data-api="'+api+'"]')); console.log('el taxonomiaJSON', taxonomiaJSON); var urlFilter = taxonomiaAPI ? _urlConstructor(jQuery('
    ')) : _urlConstructor(jQuery('
    ')); console.log('esta entrando al _requestFilters', urlFilter); jQuery.ajax({ type: 'GET', url: urlFilter, dataType: 'json', success: function(resp){ var data = ''; var files = ''; for(var ele in resp){ var info = {}; info['id'] = resp[ele].id; info['titulo'] = resp[ele].titulo; data += fillView({ data: info , view: templates.filterItem.template }); if(+resp[ele].hasOwnProperty('documento_requisito')){ files += ''; }; } var info = {}; info['api_taxonomia'] = taxonomiaAPI; info['_filterItem'] = data; if(resp[0].hasOwnProperty('documento_requisito')){ info['_downloadButton'] = templates.downloadButton.template }; html += fillView({ data: info, view: templates.filters.template }); var parent = chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent); parent.append(templates.bodyAccordionContents.template); parent.find('.'+templates.itemContent.parent).last().html(''); parent.find('.'+templates.itemContent.parent).last().html(html); chunk.find('.HTMLOut .'+templates.itemContent.parent).last().addClass('active'); chunk.find('.HTMLOut .'+templates.itemContent.parent).last().attr('data-api', api); parent.find('.'+templates.itemContent.parent).last().find('.categoriesModule .bodyModule').prepend(files); html = ''; //LOCALIZA EL PRIMER FILTRO var filtros = chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active .categoriesCarousel'); categoriesCarousel(filtros); chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active .arrowModule').on('click', function (e) { e.preventDefault(); chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active .categoriesCarousel').trigger('next.owl.carousel'); }) filtros.find('.eachFilter').eq(0).addClass('active'); var idUpdate = filtros.find('.eachFilter.active a' ).attr('data-link'); var urlUpdate = chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active a').attr('data-link'); if(chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active .squareButtonLarge').length){ var file = chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active [data-fileid="'+idUpdate+'"]').attr('value'); var txtName = filtros.find('.eachFilter.active').text(); chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active .downloadButton').find('.name').text(txtName); chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active .downloadButton .contentButton').attr('href', file); } chunk.attr('data-node', idUpdate); url = _urlConstructor(chunk); _requestContent(api); } }); }; }; jQuery('body').on('click', '.categoriesCarousel .eachFilter', function(e){ e.preventDefault(); jQuery('.loader').addClass('active'); var items = chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active .eachFilter'); items.removeClass('active'); jQuery(this).addClass('active'); jQuery(this).closest('.eachFilter').addClass('active'); chunk.attr('data-node', jQuery(this).find('a').attr('data-link')); if(chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active .squareButtonLarge').length){ var file = chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active [data-fileid="'+jQuery(this).find('a').attr('data-link')+'"]').attr('value'); var txtName = jQuery(this).text(); chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active .downloadButton').find('.name').text(txtName); chunk.find('.HTMLOut .'+templates.itemContent.parent+'.active .downloadButton .contentButton').attr('href', file); } url = _urlConstructor(chunk); api = chunk.attr('data-url'); _requestContent(api); }); // SE PINTAN LOS TABS for(var tab in tabsArray){ var data = {}; data['api'] = tabsArray[tab].api_url; data['taxonomia'] = tabsArray[tab].hasOwnProperty('api_taxonomia') ? tabsArray[tab].api_taxonomia: ''; data['titulo'] = tabsArray[tab].titulo; data['hash'] = tabsArray[tab].hash; if(tabsArray[tab].hasOwnProperty('json')) { data['json'] = tabsArray[tab].json; } if(tabsArray[tab].hasOwnProperty('jsontaxo')) { data['jsontaxo'] = tabsArray[tab].jsontaxo; } html += fillView({ data: data, view: templates.item.template }); chunk.find('.HTMLOut .'+templates.item.parent).append(html); chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent').last().attr('data-hash', data.hash); html = ''; data = {}; index++; } // url = _urlConstructor(chunk); // if (chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-taxonomia') != '') { // _requestFilters(api); // } else { // var api = chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-api'); // chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent).append(templates.bodyAccordionContents.template); // chunk.find('.HTMLOut .'+templates.itemContent.parent).last().addClass('active'); // chunk.find('.HTMLOut .'+templates.itemContent.parent).last().attr('data-api', api); // _requestContent(api); // } if (window.location.hash == '' || !jQuery('[data-hash="'+window.location.hash+'"]').length) { chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent').eq(0).find('.card-container').addClass('active'); chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent').eq(0).addClass('active'); chunk.attr('data-url', chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-api')); chunk.attr('data-db', chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-db')); url = _urlConstructor(chunk); if (chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-taxonomia') != '') { var api = chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-taxonomia'); console.log('%c esta entrando aqui', 'background:red;color:white;'); _requestFilters(api); } else { var api = chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-api'); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent).append(templates.bodyAccordionContents.template); chunk.find('.HTMLOut .'+templates.itemContent.parent).last().addClass('active'); chunk.find('.HTMLOut .'+templates.itemContent.parent).last().attr('data-api', api); _requestContent(api); } } else { chunk.attr('data-node', ''); var tabHash = jQuery('[data-hash="'+window.location.hash+'"]'); var api = tabHash.attr('data-api'); var db = tabHash.attr('data-db'); chunk.attr('data-url', api); chunk.attr('data-db', db); url = _urlConstructor(chunk); if(chunk.find('.HTMLOut .bodyAccordion [data-api="'+api+'"]').length){ chunk.find('.HTMLOut .'+templates.itemContent.parent).removeClass('active'); chunk.find('.HTMLOut [data-api="'+api+'"]').addClass('active'); jQuery('.'+templates.item.parent).find('.itemContent.active .card-container').removeClass('active'); jQuery('.'+templates.item.parent).find('.itemContent').removeClass('active'); tabHash.find('.card-container').addClass('active'); tabHash.addClass('active'); } else { jQuery('.loader').addClass('active'); chunk.find('.HTMLOut .'+templates.itemContent.parent).removeClass('active'); chunk.attr('data-api', tabHash.attr('data-api')); jQuery('.'+templates.item.parent).find('.itemContent.active .card-container').removeClass('active'); jQuery('.'+templates.item.parent).find('.itemContent').removeClass('active'); tabHash.find('.card-container').addClass('active'); tabHash.addClass('active'); url = _urlConstructor(chunk); if (chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-taxonomia') != '') { _requestFilters(api); } else { var api = chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-api'); chunk.find('.HTMLOut .'+templates.bodyAccordionContents.parent).append(templates.bodyAccordionContents.template); chunk.find('.HTMLOut .'+templates.itemContent.parent).last().addClass('active'); chunk.find('.HTMLOut .'+templates.itemContent.parent).last().attr('data-api', api); _requestContent(api); } } } jQuery('body').on('click', '[data-dom="tabs"] .itemContent' ,function(e){ e.preventDefault(); chunk.attr('data-node', ''); var api = jQuery(this).attr('data-api'); var db = jQuery(this).attr('data-db'); chunk.attr('data-url', api); chunk.attr('data-db', db); url = _urlConstructor(chunk); if(chunk.find('.HTMLOut .bodyAccordion [data-api="'+api+'"]').length){ chunk.find('.HTMLOut .'+templates.itemContent.parent).removeClass('active'); chunk.find('.HTMLOut [data-api="'+api+'"]').addClass('active'); jQuery('.'+templates.item.parent).find('.itemContent.active .card-container').removeClass('active'); jQuery('.'+templates.item.parent).find('.itemContent').removeClass('active'); jQuery(this).find('.card-container').addClass('active'); jQuery(this).addClass('active'); } else { jQuery('.loader').addClass('active'); chunk.find('.HTMLOut .'+templates.itemContent.parent).removeClass('active'); chunk.attr('data-api', jQuery(this).attr('data-api')); jQuery('.'+templates.item.parent).find('.itemContent.active .card-container').removeClass('active'); jQuery('.'+templates.item.parent).find('.itemContent').removeClass('active'); jQuery(this).find('.card-container').addClass('active'); jQuery(this).addClass('active'); if (chunk.find('.HTMLOut .'+templates.item.parent).find('.itemContent.active').attr('data-taxonomia') != '') { _requestFilters(api); } else { _requestContent(api); } } }); }; if (tempResp.hasOwnProperty('escolaridad') && jQuery('#filterEscolaridad').length) { jQuery('#filterEscolaridad').find('[name="escolaridad"]').attr('data-node', tempResp.escolaridad); } if (tempResp.hasOwnProperty('categorias') && jQuery('#filterEscolaridad').length) { jQuery('#filterEscolaridad').find('[name="carrera"]').attr('data-node', tempResp.categorias[0]); } if (jQuery('#filterEscolaridad').length) { filtroProductoCarrera(); } for(arr in tempResp){ var block = tempResp[arr]; if (block && block.length) { if (block[0].hasOwnProperty('clase')) { constructorBlock(block[0].clase, block, arr, tempResp); } } } } }); }; // funcion que ejecuta los case´s dependiendo si existe una clase en json var constructorBlock = function(template, arr, name, global){ var html = '', num = '', contador = ''; // Metodo para llenar el data-node del elemento del select escolaridad con el objeto escolaridad del arreglo global switch(template) { case 'infoGral': var chunk = jQuery('[data-namecontent="'+name+'"]'), templates = _getTemplates(chunk); for (var item in arr) { // CONVIERTO EL NUMERO DE ITERACIONES A ENTERO num = parseInt(item); // VALIDACION PARA MOSTRAR INDICADOR if (num >= 10) { contador = num; } else { contador = '0' + num + '.'; } // VALIDACION PARA GENERAR LA VISTA DEL CAROUSEL if (arr[item].cabecera == '1') { html += fillView({ data: { descripcion: arr[item].titulo }, view: templates.htmlout.template }); chunk.find('.HTMLOut').html(html); chunk.find('.HTMLOut [class="'+templates.carouselInfoSquare.parent+'"]').addClass('owl-carousel'); carouselInfoSquare(chunk.find('.HTMLOut .owl-carousel')); html = ''; } else { html += fillView({ data: { number: contador, icon: arr[item].imagen, titulo: arr[item].titulo, descripcion: arr[item].descripcion }, view: templates.carouselInfoSquare.template }); chunk.find('.HTMLOut .owl-carousel').owlCarousel('add', html).owlCarousel('update'); html = ''; } } html = ''; break; // CASE FUNCIONAL PARA CALCULADORA DE COSTOS case 'productDescription': var chunk = jQuery('[data-namecontent="'+name+'"]'), templates = _getTemplates(chunk); for (var item in arr) { if (arr[item].cabecera == '1') { html += fillView({ data: { contenido: arr[item].titulo }, view: templates.htmlout.template }); chunk.find('.HTMLOut').html(html); html = ''; } else { var data = {}; data['contenido'] = arr[item].descripcion; html += fillView({ data: data, view: templates.descripcion.template }); chunk.find('.HTMLOut').html(html); } } html = ''; break; } }; // CONSTRURTOR PARA EL BANNER DE PRODUCTO var constructorTitulo = function (resp) { // console.log('sigue entrando'); var html = ''; var chunk = jQuery('[data-namecontent="bannerProducto"]'), templates = _getTemplates(chunk); // FUNCION PARA CONSTRUIR LOS BREADCRUMBS PRODUCTO var _breadcrumbs = function(resp){ var html = ''; for(var item in resp){ html += fillView({ data: { link: resp[item].url, title: resp[item].text }, view: templates.breadcrumb.template }); } return html; }; // FUNCION PARA EL VIDEO DEL BANNER PRODUCTO var _videocta = function(resp){ var html = ''; html += fillView({ data: { videoid: _getYoutubeID(resp.url), video_imagen: resp.imagen[0] }, view: templates.videocta.template }); return html; }; // FUNCION PARA GENERAR Y LLENAR EL TEMPLATE DE LOS BOTONES var _btnbanner = function(resp){ var html = ''; for(var item in resp){ html += fillView({ data: { link: resp[item].link.url, text: resp[item].link.text }, view: templates.btnbanner.template }); } return html; }; // DATAS DEL ARREGLE DE PRODUCTO Y VARIABLES A MOSTRAR EN EL TEMPLATE var data = {}; if('banner' in resp && resp.banner.length){ data["banner_imagen"] = resp.banner[0].imagen; data["banner_imagen_mobile"] = resp.banner[0].imagen_mobile; data["banner_descripcion"] = resp.banner[0].descripcion; } if(('video' in resp && resp.video.length) && Array.isArray(resp.video)){ // console.log('testing'); data["_videocta"] = _videocta(resp.video[0]); } data['titulo_descritivo'] = resp.titulo_posicion[0].titulo_descritivo; data['_breadcrumb'] = _breadcrumbs(resp.breadcrumb); data['_btnbanner'] = _btnbanner(resp.link_adicional); html += fillView({ data: data, view: templates.htmlout.template }); chunk.find('.HTMLOut').html(html); }; // CONSTRUCTOR PARA LA DESCRIPCION DE PRODUCTO var constructorDescripcion = function (resp) { var html = ''; var chunk = jQuery('[data-namecontent="descripcion"]'), templates = _getTemplates(chunk); // console.log('RESPUESTA PRODUCTO: ', resp); var _documento = function (resp) { var html = '' dataDocument = resp; // console.log(resp); html += fillView({ data: { link: dataDocument }, view: templates.documento.template }); return html; }; var data = {}; data['descripcion'] = resp.descripcion_larga; if (resp.documento) { data['_documento'] = _documento(resp.documento.url); } html += fillView({ data: data, view: templates.htmlout.template }); chunk.find('.HTMLOut').html(html); }; // INICIALIZACION DE CAROUSELES // CAROUSEL DE TANS INFO GENERAL var infoGralCarousel = function(slider){ var slider = jQuery('.carouselInfoSquare'), items, itemsNumber; if(slider.length > 0){ items = slider.find('.eachInfoSquare'); itemsNumber = items.length; // console.log('items cantidad:', itemsNumber); slider.owlCarousel({ items: itemsNumber, loop:false, margin:60, autoWidth: true, dots: false, navs:false, center: false, responsive:{ 0:{ items: 1, margin:70 }, 481:{ center: true }, 601:{ items: 2, margin: 33 }, 680:{ margin: 20 }, 768:{ margin: 25 }, 900:{ items: 3, margin: 50 }, 1024:{ margin: 65 } } }); slider.addClass('owl-carousel'); } }; // ---------- VISTAS INDEPENDIENTES (REQUIEREN DE UN SERVICIO Y NODO DISTINTO AL GENERAL) ---------- // VISTA DE PERIODO DE INGRESOS (NUEVA ESTRUCTURA PARA LOS TEMPLATES) var fillViewIngresos = function () { var chunk = jQuery('[data-dom="periodos_ingresos"]'), templates = _getTemplates(chunk), url = _urlConstructor(chunk), img = '', html_ingresos = ''; jQuery.ajax({ type: 'GET', url: url, dataType: 'JSON', success: function (arr) { for (var item in arr) { if (arr[item].cabecera == '1') { html_ingresos += fillView({ data: { descripcion: arr[item].descripcion }, view: templates.htmlout.template }); chunk.find('.HTMLOut').html(html_ingresos); html_ingresos = ''; } else { // VALIDACION DE OBJETOS VACIOS EN CASO DE NO CONTENER IMAGENES if (jQuery.isEmptyObject(arr[item].imagen[0])) { img = '#'; } else { img = arr[item].imagen[0].imagen; } html_ingresos += fillView({ data: { imagen: img, title_periodo: arr[item].titulo, descripcion_periodo: arr[item].descripcion }, view: templates.listPeriodos.template }); chunk.find('.HTMLOut .container').html(html_ingresos); } } } }); }; // VISTA DE PREGUNTAS FRECUENTES (NUEVA ESTRUCTURA PARA LOS TEMPLATES) var fillViewPreguntas = function () { var chunk = jQuery('[data-dom="preguntas"]'), templates = _getTemplates(chunk), url = _urlConstructor(chunk), html_preguntas = ''; jQuery.ajax({ type:'GET', url: url, dataType: 'JSON', success: function (arr) { for (var item in arr) { if (arr[item].cabecera == '1') { html_preguntas += fillView({ data: { descripcion: arr[item].descripcion }, view: templates.htmlout.template }); chunk.find('.HTMLOut').html(html_preguntas); html_preguntas = ''; } else { html_preguntas += fillView({ data: { titulo_pregunta: arr[item].titulo, descripcion_pregunta: arr[item].descripcion }, view: templates.listPreguntas.template }); chunk.find('.HTMLOut .container').html(html_preguntas); } } } }); }; // VISTA DE CARRERAS RELACIONADAS (NUEVA ESTRUCTURA) var fillViewCarreras = function () { var chunk = jQuery('[data-dom="carreras"]'), templates = _getTemplates(chunk), url = _urlConstructor(chunk); var html = ''; jQuery.ajax({ type: 'GET', url: url, dataType: 'JSON', success: function(arr){ chunk.find('.HTMLOut [class="'+templates.item.parent+'"]').html(''); chunk.find('.HTMLOut [class="'+templates.item.parent+'"]').addClass('owl-carousel'); carouselRelCareers(chunk.find('.HTMLOut .owl-carousel')); for(var item in arr){ var enlace = arr[item].url_info.split('"'); var elcolor = arr[item].relacionado.color; html += fillView({ data: { color: elcolor, link: enlace[1], clase: arr[item].relacionado.clase, imagen: arr[item].relacionado.hasOwnProperty('imagen') ? arr[item].relacionado.imagen : '#', descripcion: arr[item].relacionado.titulo_relacionado }, view: templates.item.template }); chunk.find('.HTMLOut .owl-carousel').owlCarousel('add', html).owlCarousel('update'); var dataStyles = chunk.find('.HTMLOut .'+templates.item.parent).find('[data-link]').last(); dataStyles.eq(0).attr('style', 'background:'+elcolor); html = ''; } html = ''; } }); }; init(); })(); (function () { var constructorBlock = function(template, arr, name){ var html = ''; switch(template) { case 'chooseUs': var chunk = jQuery('[data-namecontent="'+name+'"]'), templates = _getTemplates(chunk); for(var item in arr){ html += fillView({ data: { titulo_descritivo: arr[item].titulo_descritivo, descripcion: arr[item].descripcion, imagen: arr[item].imagen }, view: templates.htmlout.template }); } chunk.find('.HTMLOut').html(html); html = ''; break; } }; /* * Pinta todos los bloques de categoria * */ var categorias = function () { var chunk = jQuery('[data-dom="categorias"]'); if (chunk.hasClass('campusCategorias')) { chunk.attr('data-node', _getNode(jQuery('body')).replace('/', '')); } var templates = _getTemplates(chunk), url = _urlConstructor(chunk); var html = ''; var nodeInicial = jQuery('.carreras').attr('data-node'); jQuery.ajax({ type: 'GET', url: url, dataType: 'JSON', success: function(arr){ chunk.find('.HTMLOut [class="'+ templates.item.parent +'"]').html(''); chunk.find('.HTMLOut [class="'+ templates.item.parent +'"]').addClass('owl-carousel'); console.log("va el array: ", arr); html += fillView({ data: { clase: 'todas active', color: '#0649BB', titulo: 'Todas', id: 'all' }, view: templates.item.template }) for(var item in arr){ var elcolor = arr[item].color; html += fillView({ data: { clase: arr[item].clase+' data-style-'+elcolor, color: elcolor, titulo: arr[item].hasOwnProperty('titulo') ? arr[item].titulo : arr[item].name, id: arr[item].id }, view: templates.item.template }); chunk.find('.HTMLOut .owl-carousel').owlCarousel('add', html).owlCarousel('update'); html = ''; } chunk.find('.HTMLOut .owl-carousel').trigger('destroy.owl.carousel'); carouselRelCareers(chunk.find('.HTMLOut .owl-carousel')); chunk.find('.HTMLOut .arrowModule a').click(function(e) { e.preventDefault(); chunk.find('.HTMLOut .owl-carousel').trigger('next.owl.carousel'); }); html = ''; var dataStyles = chunk.find('.HTMLOut .owl-carousel').find('[class*="data-style"]'); dataStyles.each(function(eles){ var element = jQuery(dataStyles).eq(eles); var color = element.attr('class'), lastColor = color.split('-'), endColor = lastColor[lastColor.length-1]; element.attr('style', 'background-color:'+endColor); element.find('[data-link]').attr('style', 'border-color:'+endColor); element.find('[data-link] > span').attr('style', 'color:'+endColor); }); } }); var contador = 0; var arrayCategories = []; /* * Funcionalidad para cuando se le da clic a cada categoria * */ jQuery('body').on('click', '.eachFilter a', function (e) { e.preventDefault(); jQuery('.loader').addClass('active'); if(!$(this).parents('.eachFilter').hasClass('todas')){ var id = jQuery(this).attr('href'); var cadena = jQuery('.carreras').attr('data-node'); // LOGICA CUANDO SE LOCALIZA UN ILTRO DE PRODUCTOS EXCLUSIVOS SOLO PARA UN CAMPO EN ESPECÍICO if (jQuery('[data-dom="campusProductos"]').length) { jQuery('.eachFilter.todas').removeClass('active'); if(!jQuery(this).parents('.eachFilter').hasClass('active')){ jQuery(this).parents('.eachFilter').addClass('active'); arrayCategories.push(id); } else { jQuery(this).parents('.eachFilter').removeClass('active'); if (arrayCategories.indexOf(id) > -1) { arrayCategories.splice(arrayCategories.indexOf(id), 1); } } if (arrayCategories.length) { jQuery('.carreras').attr('data-node', arrayCategories.join('+')); } else { jQuery(this).closest('.bodyModule').find('.eachFilter.todas').addClass('active'); jQuery('.carreras').attr('data-node', nodeInicial); } carreras(jQuery('[data-dom="campusProductos"] [name="campusProductos"]').val()); } else { var cadenaSeparada = cadena.split('/'); var cadenaFiltro = cadenaSeparada[1]; if(jQuery(this).parents('.eachFilter').hasClass('active')){ cadenaSeparada[1] = cadenaFiltro.replace(id, '').replace('++', '+').replace(/^[+]/g, '').replace(/[+]$/g, ''); if(cadenaSeparada[1] === 'all+'){ cadenaSeparada[1] = 'all' } jQuery('.carreras').attr('data-node', cadenaSeparada.join('/')); contador--; }else{ cadenaSeparada[1] = (cadenaFiltro + '+' + id).replace(/^[+]/g, ''); jQuery('.carreras').attr('data-node', (cadenaSeparada.join('/'))); contador++; } carreras(jQuery('[data-dom="campusProductos"] [name="campusProductos"]').val()); if(contador === 0){ jQuery('.eachFilter.todas').addClass('active'); }else{ jQuery('.eachFilter.todas').removeClass('active'); } jQuery(this).parents('.eachFilter').toggleClass('active'); } }else{ arrayCategories = []; jQuery('.eachFilter').removeClass('active'); jQuery(this).parent('.eachFilter').addClass('active'); jQuery('.carreras').attr('data-node', nodeInicial); carreras(jQuery('[data-dom="campusProductos"] [name="campusProductos"]').val()); } }); }; /* * Pinta todos los filtros * */ var filtro = function () { var chunk = jQuery('[data-dom="filtro"]'), templates = _getTemplates(chunk), url = _urlConstructor(chunk); var html = ''; jQuery.ajax({ type: 'GET', url: url, dataType: 'JSON', success: function(arr){ chunk.find('.HTMLOut [class="'+ templates.item.parent +'"]').html(''); chunk.find('.HTMLOut [class="'+ templates.item.parent +'"]').addClass('owl-carousel'); for(var item in arr){ html += fillView({ data: { clase: arr[item].clase, titulo: arr[item].titulo, id: arr[item].id }, view: templates.item.template }); chunk.find('.HTMLOut .owl-carousel').owlCarousel('add', html).owlCarousel('update'); chunk.find('.HTMLOut .arrowModule a').click(function(e) { e.preventDefault(); chunk.find('.HTMLOut .owl-carousel').trigger('next.owl.carousel'); }); html = ''; } chunk.find('.HTMLOut .owl-carousel').trigger('destroy.owl.carousel'); carouselRelCareers(chunk.find('.HTMLOut .owl-carousel')); html = ''; } }); /* * Funcionalidad cuando se da clic a los elementos del filtro * */ jQuery('body').on('click', '.eachFilter input[type="checkbox"]', function (e) { var id = jQuery(this).val(); var cadena = jQuery('.carreras').attr('data-node'); var cadenaSeparada = cadena.split('/'); var cadenaFiltro = cadenaSeparada[0]; if(jQuery(this).prop('checked')){ cadenaSeparada[0] = (cadenaFiltro + '+' + id).replace(/^[+]/g, ''); jQuery('.carreras').attr('data-node', cadenaSeparada.join('/')); }else{ cadenaSeparada[0] = (cadenaFiltro).replace(id, '').replace('++', '+').replace(/^[+]/g, '').replace(/[+]$/g, ''); if(cadenaSeparada.join('/') === '4/all+'){ jQuery('.carreras').attr('data-node', '4/all'); }else{ jQuery('.carreras').attr('data-node', cadenaSeparada.join('/')); } } carreras(jQuery('[data-dom="campusProductos"] [name="campusProductos"]').val()); }); }; /* * Obtiene el template cuando se carga toda la pagina * Exclusivo para carreras * */ if (jQuery('[data-dom="carreras"]').length && jQuery('[data-dom="carreras"]').hasClass('carreras')) { var chunkCarreras = jQuery('[data-dom="carreras"]'); templateCarreras = _getTemplates(chunkCarreras); } /* * Controla como se pintan todas las carreras * */ carreras = function (productosCampus) { jQuery('.loader').addClass('active'); if(productosCampus){ console.log('entra 11111'); var chunk = chunkCarreras, templates = templateCarreras, url = _urlConstructor(chunk)+'/'+productosCampus; console.log('la url nueva de carreras 111111', url); } else { console.log('entra 22222'); var chunk = chunkCarreras, templates = templateCarreras, url = _urlConstructor(chunk); console.log('la url nueva de carreras 222222', url); } var html = ''; jQuery.ajax({ type: 'GET', url: url, dataType: 'JSON', success: function(arr){ for(var item in arr){ cadena = arr[item].url urlCortada = cadena.split('"'); var tituloDuracion = '', descripcionDuracion = '', tituloModalidad = '', descripcionModalidad = ''; for(var itemDos in arr[item].caracteristicas){ if(arr[item].caracteristicas[itemDos].titulo === 'Modalidad'){ tituloModalidad = arr[item].caracteristicas[itemDos].titulo; if(chunk.attr('data-modalidad') !== ''){ descripcionModalidad = chunk.attr('data-modalidad'); }else{ descripcionModalidad = arr[item].caracteristicas[itemDos].descripcion; } } if(arr[item].caracteristicas[itemDos].titulo === 'Duración'){ tituloDuracion = arr[item].caracteristicas[itemDos].titulo; descripcionDuracion = arr[item].caracteristicas[itemDos].descripcion; } } var elcolor = arr[item].color; html += fillView({ data: { link: urlCortada[1], descripcion_corta: arr[item].descripcion_corta, clase: arr[item].clase+' data-style-'+elcolor, icono: arr[item].icono.length ? arr[item].icono[0].imagen : '', titulo: typeof arr[item].titulo === 'object' ? arr[item].titulo[0].titulo_descritivo : arr[item].titulo, tituloDuracion: tituloDuracion, descripcionDuracion: descripcionDuracion, tituloModalidad: tituloModalidad, descripcionModalidad: descripcionModalidad, color: arr[item].color }, view: templates.item.template }); } chunk.find('.HTMLOut .block').html(html); //DEFINICIÓN DE COLORRES IE11 var dataStyles = chunk.find('.HTMLOut .block').find('[class*="data-style"]'); dataStyles.each(function(eles){ var element = jQuery(dataStyles).eq(eles); var color = element.attr('class'), lastColor = color.split('-'), endColor = lastColor[lastColor.length-1]; var icon = element.find('.iconCareer .icon'), fondo = element.find('.titleCareer .fondo'), title = element.find('.titleCareer strong'), content = element.find('.contentBodyCareer'), dataCareer = element.find('.footerCareer .dataCareer span'), footerIcon = element.find('.footerCareer .icon'); //BG [icon, fondo, footerIcon].map(function(m){ m.attr('style', 'background:'+endColor); }); //COLOR [title, content, dataCareer].map(function(m){ m.attr('style', 'color:'+endColor); }); }); html = ''; ellipsisText(); jQuery('.loader').removeClass('active'); } }); }; var ellipsisText = function(){ var card = jQuery('.eachCareer'); card.map(function(m){ if (jQuery(card[m]).find('.contentBodyCareer').text().length >= 232) { // console.log('testing', card[m]+' '+jQuery(card[m]).find('.contentBodyCareer').text().length); jQuery(card[m]).find('.contentBodyCareer').addClass('ellipsis'); } }); }; /* * Controla el mapa de sitio * */ var mapaSitio = function () { var chunk = jQuery('[data-dom="mapaSitio"]'), templates = _getTemplates(chunk), url = _urlConstructor(chunk); jQuery.ajax({ type: 'GET', url: url, dataType: 'JSON', success: function(arr){ var html = '', html2= '', html3 = ''; var hijos = function(levelBelow, template, content){ if (levelBelow) { for(var level in levelBelow){ content += fillView({ data: { titulo: levelBelow[level].title, url: levelBelow[level].absolute, _elementosHijos: hijos(levelBelow[level].below, templates.elementosHijos.template, html3) }, view: template }); } } return content; }; for(var item in arr){ html += fillView({ data: { titulo: arr[item].title, _elementos: hijos(arr[item].below, templates.elementos.template, html2) }, view: templates.titulo.template }); } chunk.find('.HTMLOut .container').html(html); } }); }; var constructorInternal = function(block){ var url = _urlConstructor(jQuery('body')); var tempResp; jQuery.ajax({ type: 'GET', url: url, dataType: 'json', success: function(resp){ //construye titulo var _remove = function(arr){ jQuery(arr).each(function(item){ delete tempResp[arr[item]]; }); }; if (jQuery('[data-namecontent="titulo"]').length) { constructorTitulo(resp[0], 'titulo'); } tempResp = resp[0]; _remove(['titulo', 'breadcrumb', 'imagen', 'banner', 'video', 'descripcion']); for(var arr in tempResp){ var block = tempResp[arr]; if (block && block.length) { if (block[0].hasOwnProperty('clase')) { constructorBlock(block[0].clase, block, arr); } } } } }); }; /* * Manda a llamar a las funciones donde se necesitan... * */ var init = function(){ if (jQuery('body').attr('data-url') || jQuery('body').attr('data-api')) { constructorInternal();} if (jQuery('[data-dom="categorias"]').length) { categorias();} if (jQuery('[data-dom="filtro"]').length) { filtro();} if (jQuery('[data-dom="carreras"]').length && jQuery('[data-dom="carreras"]').hasClass('carreras')) { carreras();} if (jQuery('[data-dom="mapaSitio"]').length) { mapaSitio();} if (jQuery('#block-avisodeprivacidad').length) { function comprobarBreak() { var i = 0; while (i < jQuery('.categoriesCarousel .eachFilter').length) { if (jQuery(jQuery('.categoriesCarousel .eachFilter')[i]).hasClass('active')) break; i++; } return i; } jQuery(".categoriesCarousel").owlCarousel({ startPosition: comprobarBreak(), autoWidth: false, margin: 15, // merge:true, responsive:{ 0:{ items:1 // mergeFit:true }, 771:{ items:3 // mergeFit:true } } }); jQuery('.categoriesModule .arrowModule').click(function(e) { e.preventDefault(); jQuery(".categoriesCarousel").trigger('next.owl.carousel'); }); } if(jQuery(".owl-carousel").length){ jQuery('.owl-carousel').owlCarousel(); } }; var constructorTitulo = function(resp, name){ var html = ''; var chunk = jQuery('[data-namecontent="'+name+'"]'), templates = _getTemplates(chunk); var _breadcrumbs = function(res){ var html = ''; for(var item in res){ html += fillView({ data: { link: res[item].url, title: res[item].text }, view: templates.breadcrumb.template }); } return html; }; var data = {}; //data["titulo"] = resp.titulo; //data["descripcion"] = resp.descripcion; if (templates.hasOwnProperty('breadcrumb')) { //data["_breadcrumb"] = _breadcrumbs(resp.breadcrumb); } }; init(); })(); ;(function(){ var GA = function(){ jQuery(window).on('load', function() { var header = jQuery('.generalHeader'), footer = jQuery('footer'); var menuDesktop = header.find('.principalHeader'), menuMobile = jQuery('.menuMobileMenu'), topHeader = header.find('.topHeader'); var hamburguesa = { ele: menuDesktop.find('.leftMenu .nav-tgl'), tipo: 'action', etiqueta: 'Action Hamburguesa', accion: 'clic', categoria: 'Menú principal', boton: 'Hamburguesa', modo: 'hover'}; var masInfo = { ele: jQuery('.btnAppear'), tipo: 'task', etiqueta: 'Task Home Más Información', accion: 'clic', categoria: 'Más Información', boton: 'Solciitar información', modo: 'click'}; //NAVEGACIÓN DESKTOP TOP var _topNav = { ele: menuDesktop.find('.centerMenu .principalList .wraps '), tipo: 'action', etiqueta: '_topNav', accion: 'clic', categoria: 'Menú principal', boton: '', modo: 'hover'}; var _topNavLinks = { ele: menuDesktop.find('.centerMenu .principalList .wraps .rightSide .info a'), tipo: 'task', etiqueta: '_topNavLinks', accion: 'clic', categoria: 'Menú principal', boton: '', modo: 'click'}; //NAVEGACIÓN MOBILE TOP var _topNavMobile = { ele: menuMobile.find('.globalUl .showMenuTab'), tipo: 'action', etiqueta: '_topNavMobile', accion: 'clic', categoria: 'Menú principal Mobile', boton: '', modo: 'click'}; var _topNavLinksMobile = { ele: menuMobile.find('.globalUl >li .info .info a'), tipo: 'task', etiqueta: '_topNavLinksMobile', accion: 'clic', categoria: 'Menú principal Mobile', boton: '', modo: 'click'}; var _contacto_mobile = { ele: menuMobile.find('.contactLinks > li .contactAnchor'), tipo: 'task', etiqueta: '_contacto_mobile', accion: 'clic', categoria: 'Contacto Mobile', boton: '', modo: 'click'}; var _enlaces_mobile = { ele: menuMobile.find('.anotherLinks > li a'), tipo: 'task', etiqueta: '_enlaces_mobile', accion: 'clic', categoria: 'Enlaces Mobile', boton: '', modo: 'click'}; var unete = { ele: topHeader.find('.linksHeaderCtaContainer .btn').eq(0), tipo: 'task', etiqueta: 'Task Únete a nuestro equipo', accion: 'clic', categoria: 'Menú principal', boton: 'Únete a nuestro equipo', modo: 'click'}; var buscador = { ele: menuDesktop.find('.rightMenu .languageMenu > li').eq(0).find('a').eq(0), tipo: 'action', etiqueta: 'Action Buscador', accion: 'clic', categoria: 'Menú principal', boton: 'BUSCADOR', modo: 'click'}; var whatsapp = { ele: menuDesktop.find('.rightMenu .languageMenu > li').eq(1).find('a').eq(0), tipo: 'task', etiqueta: 'Task WhatsApp', accion: 'clic', categoria: 'Menú principal', boton: 'WhatsApp', modo: 'click'}; var aplicar_ahora = { ele: menuDesktop.find('.rightMenu .languageMenu > li').eq(2).find('a').eq(0), tipo: 'task', etiqueta: 'Task Aplicar Ahora', accion: 'clic', categoria: 'Menú principal', boton: 'Aplicar Ahora', modo: 'click'}; var _descargaFolleto = { ele: jQuery('.squareButtonLarge >a'), tipo: 'task', etiqueta: '_descargaFolleto', accion: 'clic', categoria: 'Producto', boton: '', modo: 'click'}; var contacto_header = { ele: menuDesktop.find('.centerMenu .principalList .contactLinks > li .contactAnchor'), tipo: 'task', etiqueta: '_contactoHeader', accion: 'clic', categoria: 'Menú principal', boton: '', modo: 'click'}; var contacto_footer = { ele: footer.find('.contactLinks > li .contactAnchor'), tipo: 'task', etiqueta: '_contactoFooter', accion: 'clic', categoria: 'Footer', boton: '', modo: 'click'}; var _enlaces = { ele: footer.find('.subFooter > li a'), tipo: 'task', etiqueta: '_enlaces', accion: 'clic', categoria: 'Footer', boton: '', modo: 'click'}; var descargas = { ele: footer.find('.appsSquare .downloads > li a'), tipo: 'task', etiqueta: '_apps', accion: 'clic', categoria: 'Footer', boton: '', modo: 'click'}; var _preparatoria = { ele: jQuery('.eligePrepa .eachChoose a'), tipo: 'task', etiqueta: '_preparatoria', accion: 'clic', categoria: 'Preparatoria', boton: '', modo: 'click'}; var _aplicaProducto = { ele: jQuery('.bannerSection.productDetail .btns .btn'), tipo: 'task', etiqueta: '_aplicaProducto', accion: 'clic', categoria: 'Producto', boton: '', modo: 'click'}; var _tabs = { ele: jQuery('.overlapTabs .overlapTabsItems .itemContent'), tipo: 'task', etiqueta: '_tabs', accion: 'clic', categoria: 'Producto', boton: '', modo: 'click'}; var _carreras_relacionadas = { ele: jQuery('.relCareers .eachRelCareer'), tipo: 'task', etiqueta: '_carreras_relacionadas', accion: 'clic', categoria: 'Producto - Carreras Relacionadas', boton: '', modo: 'click'}; //HOME var _ctaSlider = { ele: jQuery('.principalSlider .eachSilerElement .btn'), tipo: 'task', etiqueta: '_ctaSlider', accion: 'clic', categoria: 'Home Slider', boton: '', modo: 'click'}; var _ctaCuadros = { ele: jQuery('[data-dom="toSections"] .eachButtonSquare'), tipo: 'task', etiqueta: '_ctaCuadros', accion: 'clic', categoria: 'Home Cuadros', boton: '', modo: 'click'}; var _ctaCuadros2 = { ele: jQuery('[data-dom="ourInformation"] a'), tipo: 'task', etiqueta: '_ctaCuadros2', accion: 'clic', categoria: 'Home Cuadros 2', boton: '', modo: 'click'}; var elements = [unete, hamburguesa, _topNav, _topNavLinks, buscador, whatsapp, aplicar_ahora, contacto_header, contacto_footer, descargas, _preparatoria, _descargaFolleto, _aplicaProducto, _tabs, _carreras_relacionadas, _ctaSlider, masInfo, _ctaCuadros, _ctaCuadros2, _topNavMobile, _topNavLinksMobile, _contacto_mobile, _enlaces_mobile, _enlaces]; elements.map(function(block){ var modo = block.modo == 'hover' ? 'mouseenter' : 'click'; if(block.ele.length > 1 || block.etiqueta.indexOf('_') >= 0){ block.ele.each(function(){ jQuery(this).on(modo, function(e){ // e.preventDefault(); var etiqueta; switch(block.etiqueta) { case '_topNav': etiqueta = 'Action '+ jQuery(this).find('a').eq(0).text(); break; case '_topNavMobile': etiqueta = 'Action '+ jQuery(this).find('span').eq(0).text(); break; case '_ctaCuadros': etiqueta = 'Task Home CTA Cuadros - '+jQuery.trim(jQuery(this).find('.textSpace').eq(0).text()); break; case '_ctaCuadros2': etiqueta = 'Task Home CTA Cuadros 2 - '+jQuery.trim(jQuery(this).find('.infoBlock').eq(0).text()); break; case '_ctaSlider': etiqueta = 'Task Home CTA Slider - '+jQuery(this).find('span').eq(0).text(); break; case '_topNavLinks': case '_enlaces_mobile': case '_enlaces': etiqueta = 'Task '+ jQuery(this).text(); break; case '_topNavLinksMobile': etiqueta = 'Task '+ jQuery(this).find('span').eq(0).text(); break; case '_carreras_relacionadas': etiqueta = 'Task '+ jQuery(this).find('.title p').text(); break; case '_apps': etiqueta = 'Task '+ jQuery(this).parent().attr('data-type'); break; case '_tabs': etiqueta = 'Task '+ jQuery(this).find('.titleBlock').eq(0).text(); break; case '_descargaFolleto': etiqueta = 'Task '+ jQuery(this).closest('.squareButtonLarge').find('strong').eq(0).text(); break; case '_aplicaProducto': etiqueta = 'Task '+ jQuery(this).find('span').eq(0).text(); break; case '_preparatoria': etiqueta = 'Action '+ jQuery(this).closest('.eachChoose').find('strong').eq(0).text(); break; case '_contactoHeader': case '_contactoFooter': case '_contacto_mobile': etiqueta = 'Task '+ jQuery(this).parent().find('.titleSquare').text(); break; default: etiqueta = block.etiqueta; } console.info('GA - ', etiqueta, "[ ga('send', '"+block.tipo+"', '"+block.categoria+"', '"+block.accion+"', '"+etiqueta+"'); ]"); ga('send', block.tipo, block.categoria, block.accion, etiqueta); }); }); } else { block.ele.on(modo, function(e) { // e.preventDefault(); console.info('GA - ', block.etiqueta, "[ ga('send', '"+block.tipo+"', '"+block.categoria+"', '"+block.accion+"', '"+block.etiqueta+"'); ]"); ga('send', block.tipo, block.categoria, block.accion, block.etiqueta); }); } }); //CARRERAS jQuery('body').on('click', '.eachCareer', function(e){ // e.preventDefault(); var categoria = jQuery('.breadcrumbs li:last-child a').text(); nombre = jQuery(this).find('h3').eq(0).text(); var producto = 'Task Ver producto - '+nombre; console.info('GA - ', categoria, "[ ga('send', 'task', '"+categoria+"', 'clic', '"+producto+"'); ]"); ga('send', 'task', categoria, 'clic', producto); }); }); }; var init = function(){ GA(); }; init(); })();