$(document).foundation(); $(document).ready(function() { var is_visible = false; function init() { initMegaMenu(); matchHeights(); pageSlider(); innerSlider(); topSlider(); initPartnerMap(); scrollInit(); // To be implemented for infinite scroll on news/events searchInit(); challengeInit(); // countdownTimer(); //backToTop(); triangulateMe('ghosty', 'ghosty', '130'); triangulateMe('angular-grey', 'ghosty', '130'); triangulateMe('angular-pm', 'blue', '130'); triangulateMe('angular-ac', 'orange', '130'); triangulateMe('angular-sb', 'green', '130'); hubNavigation(); newsarchive(); new WOW().init(); FastClick.attach(document.body); $('body').bind('touchstart', function() {}); // $('#mm-menu-1').bind('touchstart touchend', function(e) { // e.preventDefault(); // $(this).toggleClass('mega-button-active'); // }); function challengeInit() { $("#challengesSelector").change(function() { window.location = $(':selected', this).attr('data-link'); }); } function newsarchive() { var pathname = window.location.pathname; if(pathname.indexOf('news-archive-2008') > -1){ $('#eight').addClass('raisin'); } } function scrollInit() { $('.select-container select').click(function() { item = $(this).parent(); if ($(item).hasClass('on')) { $(item).removeClass('on'); } else { $(item).addClass('on'); } }); } $('.scrollTo').on('click', function(e) { e.preventDefault(); $('html, body').animate({ scrollTop: $('[name="' + $(this).attr('href').substr(1) + '"]').offset().top }, 300); }); //function backToTop(){ $(".top-page").click(function() { $('html, body').animate({ scrollTop: 0 }, 'slow'); }); //} function newsandeventscontroller() { // Additional controller for news and events to trigger date selection from dropdown } function searchInit() { $('#globalsearchbutton').click(function() { var code = encodeURI($('#globalsearch').val()); if (location.host == "learn.avecto.com") { parent.location = 'http://www.avecto.com/search?q=' + code; } else { parent.location = '/search?q=' + code; } }); $("#globalsearch").keypress(function(event) { if (event.which == 13) { event.preventDefault(); var code = encodeURI($('#globalsearch').val()); if (location.host == "learn.avecto.com") { parent.location = 'http://www.avecto.com/search?q=' + code; } else { parent.location = '/search?q=' + code; } } }); } function topSlider() { if ($('.top-slider').length !== 0) { try { $('.top-slider').slick({ slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 6000, speed: 2000, dots: true, touchMove: false, swipe: false, swipeToSlide: false, arrows: false, draggable: false, variableWidth: true }); } catch (err) {} } } function pageSlider() { if ($('.page-slider').length !== 0) { try { $('.page-slider').slick({ slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 8000, speed: 1000, dots: true, touchMove: false, swipe: false, swipeToSlide: false, arrows: false, draggable: false, variableWidth: false }); } catch (err) {} } } function innerSlider() { if ($('.inner-slider').length !== 0) { try { $('.inner-slider').slick({ slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 6000, speed: 1000, dots: true, touchMove: false, swipe: false, swipeToSlide: false, arrows: false, draggable: false, variableWidth: false }); } catch (err) {} } } function matchHeights() { if ($('.equal').length !== 0) { try { $('.equal').matchHeight(); } catch (err) {} } } function hubNavigation() { $.stellar({ horizontalScrolling: false, verticalOffset: 40 }); var links = $('.navigation').find('li'); slide = $('.slide'); mywindow = $(window); htmlbody = $('html,body'); //Setup waypoints plugin slide.waypoint(function(event, direction) { dataslide = $(this).attr('data-slide'); if (direction === 'down') { $('.navigation li[data-slide="' + dataslide + '"]').addClass('active').prev().removeClass('active'); } else { $('.navigation li[data-slide="' + dataslide + '"]').addClass('active').next().removeClass('active'); } }, { offset: '20px' }); mywindow.scroll(function() { if (mywindow.scrollTop() == 0) { $('.navigation li[data-slide="1"]').addClass('active'); $('.navigation li[data-slide="2"]').removeClass('active'); } else { $('.navigation li[data-slide="1"]').removeClass('active'); } }); function goToByScroll(dataslide) { htmlbody.animate({ scrollTop: $('.slide[data-slide="' + dataslide + '"]').offset().top }, 2000, 'easeInOutQuint'); } links.click(function(e) { e.preventDefault(); dataslide = $(this).attr('data-slide'); // $(this).addClass('active').prev().removeClass('active'); // $(this).addClass('active') goToByScroll(dataslide); }); } function triangulateMe(element, color, cellSizer) { var elementToTriangulate = '.' + element; var cellBlockSize = cellSizer; var t; switch (color) { case 'blue': t = new Trianglify({ cellsize: cellBlockSize, bleed: 100, noiseIntensity: 0, x_gradient: ["#36A8BF", "#5CB5C3", "#78BFC8", "#8AC3CB", "#A3D0D0", "#A9D3D2", "#B4D7DC"], y_gradient: ["#36A8BF", "#5CB5C3", "#78BFC8", "#8AC3CB", "#A3D0D0", "#A9D3D2", "#B4D7DC"] }); break; case 'green': t = new Trianglify({ cellsize: cellBlockSize, bleed: 100, noiseIntensity: 0, x_gradient: ["#959E1B", "#959E1B"], y_gradient: ["#959E1B", "#CDDB28"] }); break; case 'orange': t = new Trianglify({ cellsize: cellBlockSize, bleed: 100, noiseIntensity: 0, x_gradient: ["#F48B00", "#F48B00"], y_gradient: ["#F48B00", "#FFD17E"] }); break; case 'ghosty-old-broke': t = new Trianglify({ cellsize: cellBlockSize, bleed: 100, noiseIntensity: 0, x_gradient: ["#DDDDDD", "#AAAAAA", "#F5F5F5"], y_gradient: ["#DDDDDD", "#AAAAAA", "#F5F5F5"] }); break; case 'ghosty': t = new Trianglify({ cellsize: cellBlockSize, bleed: 100, noiseIntensity: 0, x_gradient: ["#A7A7A7", "#D6D6D6", "#E4E4E4", "#EBEBEB", "#F2F2F2"], y_gradient: ["#A7A7A7", "#CDCDCD", "#D6D6D6", "#E4E4E4", "#EBEBEB", "#F2F2F2", "#D6D6D6", "#DDDDDD", "#E4E4E4", "#EBEBEB", "#F2F2F2"] }); break; default: t = new Trianglify({ cellsize: cellBlockSize, bleed: 100, noiseIntensity: 0, x_gradient: ["#ccc", "#aaa"], y_gradient: ["#ccc", "#aaa"] }); break; } var pattern = t.generate(document.body.clientWidth, document.body.clientHeight); $(elementToTriangulate).css({ "background-image": pattern.dataUrl }); } function initPartnerMap() { $('#continue-button-partners').click(function() { var country = $('#countrySelector option:selected').val(); var sector = $('#sectorSelector option:selected').val(); var redirString = 'http://learn.avecto.com/partner-registration?country=' + country + '§or=' + sector; alert(redirString); }); var flag = true; $('.map-button').each(function() { //Switch CSS for SVG Buttons $(this).mouseenter(function() { if (flag) { $(this).find("circle").attr("fill", "#004EA8"); } }).mouseleave(function() { if (!flag) return; $(this).find("circle").attr("fill", "#484848"); }); //Set Dropdown Information in RHS Panel $(this).click(function() { flag = false; $('#countrySelector').val($(this).attr('data-ref')); $('.map-button').each(function() { $(this).removeClass('partnerScale'); $(this).find("circle").attr("fill", "#484848"); }); $(this).addClass('partnerScale'); $(this).find("circle").attr("fill", "#004EA8"); }); }); $("#countrySelector").change(function() { flag = false; var selectedItem = $('#countrySelector option:selected').val(); $('.map-button').each(function() { if ($(this).attr('data-ref') == selectedItem) { $(this).addClass('partnerScale'); $(this).find("circle").attr("fill", "#004EA8"); } else { $(this).removeClass('partnerScale'); $(this).find("circle").attr("fill", "#484848"); } }); }); } function initMegaMenu() { mm_selected_menu = {}; $(".mega-button a").hover(function() { $(".mega-button a").each(function(i) { $(this).removeClass("mega-button-active"); }); $(this).addClass("mega-button-active"); mm_selected_menu.selectedMegaMenuDropDown = $(this).attr("data-dropdown"); }, function() { $(this).removeClass("mega-button-active"); }); $("#menu-1, #menu-2, #menu-3, #menu-4, #menu-5, #menu-6").hover(function() { $("#mm-" + mm_selected_menu.selectedMegaMenuDropDown).addClass("mega-button-active"); }, function() { $("#mm-" + mm_selected_menu.selectedMegaMenuDropDown).removeClass("mega-button-active"); }); } } var hashfilter; if (location.hash !== "") { hashfilter = "." + location.hash.substr(1); $("input:checkbox").prop('checked', false); $("input:checkbox[value='" + hashfilter + "']").prop('checked', true); } else { hashfilter = ".init"; } var sortDirection = false; if (location.hash.substr(1) == "Events") { sortDirection = true; } else { sortDirection = false; } // alert(sortDirection); var $container = $('#news-panel-1'); //, $checkboxes = $('div.checkbox input'); $container.isotope({ itemSelector: '.serendipity', filter: hashfilter }); $checkboxes.change(function() { var filters = []; $checkboxes.filter(':checked').each(function() { filters.push(this.value); }); filters = filters.join(', '); $container.isotope({ filter: filters }); }); var $container2 = $('#news-panel-2'), colWidth = function() { var w = $container2.width(), columnNum = 1, columnWidth = 0; if (w > 1200) { columnNum = 3; } else if (w > 900) { columnNum = 3; } else if (w > 600) { columnNum = 3; } else if (w > 300) { columnNum = 1; } columnWidth = Math.floor(w / columnNum); $container2.find('.item').each(function() { var $item = $(this), multiplier_w = $item.attr('class').match(/item-w(\d)/), multiplier_h = $item.attr('class').match(/item-h(\d)/), width = multiplier_w ? columnWidth * multiplier_w[1] - 4 : columnWidth - 4, height = multiplier_h ? columnWidth * multiplier_h[1] * 0.5 - 4 : columnWidth * 0.5 - 4; $item.css({ width: width, height: height }); }); return columnWidth; }, isotope = function() { $container2.isotope({ animationEngine: "best-available", filter: hashfilter, resizable: false, itemSelector: '.item', masonry: { columnWidth: colWidth(), gutterWidth: 4 }, getSortData: { date: '[data-time]' }, sortBy: 'date', sortAscending: sortDirection }); }; isotope(); var $containerScroller = $('#news-panel-2'); //Controller for News and Events Filtering $('#filters .button').click(function() { $('#filters .button').each(function() { $(this).removeClass('active'); }); $(this).addClass('active'); var selector = $(this).attr('data-filter'); var prettyselector = selector.substr(1); var cleverSelector = '.item'; location.hash = prettyselector; if (prettyselector == "Events") { sortDirection = true; cleverSelector = '.item'; } else { sortDirection = false; cleverSelector = '.init'; } //alert(cleverSelector); $container2.isotope({ filter: selector, resizable: false, itemSelector: cleverSelector, masonry: { columnWidth: colWidth(), gutterWidth: 4 }, sortAscending: sortDirection }); return false; }); $(window).hashchange(function() { if (location.hash !== "") { hashfilter = "." + location.hash.substr(1); //Checkbox Pandemonium var hashfilterString = "." + location.hash.substr(1); var hashfilterStringMini = location.hash.substr(1); $("input:checkbox").prop('checked', false); $("input:checkbox[value='" + hashfilterString + "']").prop('checked', true); $('#filters .button').each(function() { $(this).removeClass('active'); }); $('#filters .button').each(function() { if ($(this).attr('data-filter') == hashfilterString) { $(this).addClass('active'); } }); } else { $("input:checkbox").prop('checked', true); hashfilter = "*"; console.warn('Hitting Catch All'); } $container2.isotope({ filter: hashfilter, itemSelector: '.init', animationOptions: { duration: 750, easing: 'linear', queue: false, masonry: { columnWidth: colWidth(), gutterWidth: 4 } } }); $container.isotope({ filter: hashfilter, animationOptions: { duration: 750, easing: 'linear', queue: false, } }); }); $('#news-panel-2').show(); $('input#search').keyup(function() { var filters = []; $checkboxes.filter(':checked').each(function() { filters.push(this.value); }); var filterValue = $(this).val(); if (filterValue.length >= 3) { filters.push(filterValue); filters = filters.join(', '); var tempo = filterValue; $container2.isotope({ itemSelector: '.item', filter: ':containsi(' + tempo + ')' }); } else { $container2.isotope({ filter: '.item' }); } }); $('#searchresources').keyup(function() { var filters = []; $checkboxes.filter(':checked').each(function() { filters.push(this.value); }); var filterValue = $(this).val(); if (filterValue.length >= 3) { filters.push(filterValue); filters = filters.join(', '); var tempo = filterValue; $container.isotope({ itemSelector: '.serendipity', filter: ':containsi(' + tempo + ')' }); } else { $container.isotope({ filter: '.serendipity' }); } }); $.extend($.expr[':'], { 'containsi': function(elem, i, match, array) { return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; } }); var $select = $('#newsSelector'); $("#newsSelector").change(function() { if( $(':selected', this).attr('data-link') !=="") { window.location = '/news-and-events/news-archive-'+$(':selected', this).attr('data-link'); } var $this = $(this); var $container2 = $('#news-panel-2'); var filterValue = $(this).val(); // alert(filterValue); $container2.isotope({ itemSelector: '.item', filter: filterValue }); // return false; }); init(); $(".accordion dd").on("click", "a:eq(0)", function(event) { var dd_parent = $(this).parent(); var firstSpan; var secondSpan; $('.accordion-navigation').each(function() { firstSpan = $(this).find('span.toggle').get(0); secondSpan = $(this).find('span.toggle').get(1); $(firstSpan).removeClass('hide'); //Read More $(secondSpan).addClass('hide'); //Close }); if (dd_parent.hasClass('active')) { $(".accordion dd div.content:visible").slideToggle("normal"); firstSpan = $(this).find('span.toggle').get(0); secondSpan = $(this).find('span.toggle').get(1); $(firstSpan).removeClass('hide'); //Read More $(secondSpan).addClass('hide'); //Close } else { $(".accordion dd div.content:visible").slideToggle("normal"); $(this).parent().find(".content").slideToggle("normal"); firstSpan = $(this).find('span.toggle').get(0); secondSpan = $(this).find('span.toggle').get(1); $(firstSpan).addClass('hide'); //Read More $(secondSpan).removeClass('hide'); //Close } }); });