/** * @file * A JavaScript file for the theme. * * In order for this JavaScript to be loaded on pages, see the instructions in * the README.txt next to this file. */ // JavaScript should be made compatible with libraries other than jQuery by // wrapping it with an "anonymous closure". See: // - https://drupal.org/node/1446420 // - http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth (function ($, Drupal, window, document, undefined) { // To understand behaviors, see https://drupal.org/node/756722#behaviors Drupal.behaviors.my_custom_behavior = { attach: function(context, settings) { //Show - Hide Share Mobile $(".header__mobile-wrapper .mobile-item-share").click(function (event) { var item = $(this).find(".share-web-mobile"); if(item.is(':visible')){ item.hide(); }else{ item.show(); } }); $("#user-profile-menu, #main-menu").removeClass("retarded_hover"); $("#user-profile-menu, #main-menu").hoverIntent({ over: menu_hover, out: menu_hover_out, interval: 50 }); //Show - Hide menu Mobile $("#page-wrapper .mobile-item-main-menu").click(function () { var body = $("body"); if(body.hasClass("page-wrapper-left")){ body.removeClass("page-wrapper-left"); }else{ body.addClass("page-wrapper-left"); } }); $("#page-wrapper .mobile-item-profile-menu").click(function () { var body = $("body"); if(body.hasClass("page-wrapper-right")){ body.removeClass("page-wrapper-right"); }else{ body.addClass("page-wrapper-right"); } }); //Function menu Mobile $(".page-wrapper-item .menu .menu__item.expanded a, .page-wrapper-item .menu .menu__item.expanded span").click(function () { var item_parent = $(this).parent(); var item = item_parent.find(".menu:first"); if(!item.is(':visible') && !item_parent.hasClass("leaf")){ item.show(); return false; } }); } }; function menu_hover(){ $(this).addClass("retarded_hover"); } function menu_hover_out(){ $(this).removeClass("retarded_hover"); } })(jQuery, Drupal, this, this.document); ; var Carousel = function(thumbnail_elements, background_elements, links_elements, items) { this.thumbnail_elem = jQuery(thumbnail_elements); this.background_elem = jQuery(background_elements); this.links_elem = jQuery(links_elements); this.items = items }; ;(function($) { Carousel.prototype = { active_play: 0, timeout: 5000, current_index: 0, interval: null, background_divs: new Array(), current_background_div: null, setTimeout: function(timeout) { this.timeout = timeout; return this; }, init: function() { var carousel = this; $(carousel.items).each(function(index) { with ({idx: index}) { if (idx == 0) { carousel.background_divs[idx] = carousel.background_elem.find('.background-carousel'); } else { carousel.background_divs[idx] = null; } var thumbnail_link = $('', { 'href': '#', 'title': this.title, 'alt': this.title, 'rel': idx, }).click(function (e) { carousel.change(idx) }); var thumbnail = $('
',{ 'class': 'item-thumbnail' + (idx == 0 ? ' active' : ''), 'html': thumbnail_link, }); $(carousel.links_elem).append(thumbnail); } }); return carousel; }, play: function() { var carousel = this; carousel.interval = setInterval(function () { carousel.change(carousel.current_index+1); },carousel.timeout); return carousel; }, stop: function() { var carousel = this; clearInterval(carousel.interval); return carousel; }, change: function (idx) { var carousel = this; carousel = carousel.stop(); var old_index = carousel.current_index; carousel.current_index = idx % carousel.items.length; if (carousel.background_divs[carousel.current_index] == null) { if($(window).width() > 1020){ var type_url = "url_web"; }else{ var type_url = "url_mobile"; } $('').attr('src', carousel.items[carousel.current_index][type_url]).load(function(){ carousel.background_divs[carousel.current_index] = $('
', { 'class': 'background-carousel', 'style': 'background-image: url(' + carousel.items[carousel.current_index][type_url] + ');z-index:-2;', }); carousel._change_html(old_index, carousel.current_index); }); } else { carousel._change_html(old_index, carousel.current_index); } return carousel; }, _change_html : function(old_index, new_index) { var carousel = this; carousel.background_divs[new_index].css('z-index','-2'); carousel.background_elem.append(carousel.background_divs[new_index]); carousel.background_divs[old_index].fadeOut(1000,function(){ carousel.background_divs[old_index].css('z-index', '-3').show(); carousel.background_divs[new_index].css('z-index','-1'); }); carousel.links_elem.find('.item-thumbnail').removeClass('active'); carousel.thumbnail_elem.find(".thumbnail-carousel-data").fadeOut( 500, function() { carousel.thumbnail_elem.find(".thumbnail-carousel-title").html(carousel.items[new_index]['title']); carousel.thumbnail_elem.find(".thumbnail-carousel-body").html(carousel.items[new_index]['body_value']); if(carousel.items[new_index]['video']){ carousel.thumbnail_elem.find(".thumbnail-carousel-video a.colorbox-load").attr('href', 'https://www.youtube-nocookie.com/embed/'+carousel.items[new_index]['video']+'?version=3&fs=1&width=600&height=360&hl=en_US1&iframe=true&rel=0'); carousel.thumbnail_elem.find(".thumbnail-carousel-video img").show(); }else{ carousel.thumbnail_elem.find(".thumbnail-carousel-video img").hide(); } carousel.thumbnail_elem.find(".thumbnail-carousel-data").fadeIn( 500, function() { carousel.links_elem.find('.item-thumbnail a[rel="' + new_index + '"]').parent('.item-thumbnail').addClass('active'); }); }); carousel.play(); } }; })(jQuery); ; /*! * hoverIntent r7 // 2013.03.11 // jQuery 1.9.1+ * http://cherne.net/brian/resources/jquery.hoverIntent.html * * You may use hoverIntent under the terms of the MIT license. * Copyright 2007, 2013 Brian Cherne */ (function(e){e.fn.hoverIntent=function(t,n,r){var i={interval:100,sensitivity:7,timeout:0};if(typeof t==="object"){i=e.extend(i,t)}else if(e.isFunction(n)){i=e.extend(i,{over:t,out:n,selector:r})}else{i=e.extend(i,{over:t,out:t,selector:n})}var s,o,u,a;var f=function(e){s=e.pageX;o=e.pageY};var l=function(t,n){n.hoverIntent_t=clearTimeout(n.hoverIntent_t);if(Math.abs(u-s)+Math.abs(a-o)