!function ($) { "use strict"; // jshint ;_; $.fn.nooTransitionEnd = function (duration) { var called = false, $el = this $(this).one($.support.transition.end, function () { called = true }) var callback = function () { if (!called) $($el).trigger($.support.transition.end) } setTimeout(callback, duration) return this } $.fn.NooMobileMenu = function(options){ return this.each(function(){ var $this = $(this), parent = $this.closest('.noonav'), mediaWidth = parent.data('media-width'), button = parent.find('.noo-menu-collapse'), toggle = $this.find('li.noo-nav-item.mega'); var font = parseFloat($this.find('.noo-nav-item > a').css('font-size')); if(!mediaWidth || mediaWidth < 100){ mediaWidth = 767; } if(getViewportW() <= mediaWidth && button.length){ parent.removeClass('not-mobile'); if(!parent.hasClass('to-mobile')){ parent.addClass('to-mobile'); } }else{ parent.removeClass('to-mobile'); parent.addClass('not-mobile'); } $this.find( 'ul, ul li.menu-item, ul li.menu-item > a' ).removeAttr('style').unbind().off(); var transition = (function() { var transitionEnd = (function() { var el = document.createElement('bootstrap'), transEndEventNames = { 'WebkitTransition' : 'webkitTransitionEnd', 'MozTransition' : 'transitionend', 'OTransition' : 'oTransitionEnd otransitionend', 'transition' : 'transitionend' }, name for (name in transEndEventNames) { if (el.style[name] !== undefined) { return transEndEventNames[name] } } }()); return transitionEnd && { end : transitionEnd } })(); if(button.length){ button.click(function(e){ var scroll = $.camelCase(['scroll', 'height'].join('-')); if($this.hasClass('noo-collapse-open')){ //$this['height']($this['height']())[0].offsetHeight; $this.addClass('noocollapsing').removeClass('noocollapse').removeClass('noo-collapse-open'); $this['height'](0); // $this['height'](0).one(transition.end,function(){ $this.removeClass('noocollapsing').addClass('noocollapse'); // }).nooTransitionEnd(350); }else{ $this.removeClass('noocollapse').addClass('noocollapsing'); $this['height'](0); $this.addClass('noo-collapse-open'); //$this.one(transition.end,function(){ $this.removeClass('noocollapsing').addClass('noocollapse').addClass('noo-collapse-open')['height']('auto'); //}).nooTransitionEnd(350)['height']($this[0][scroll]); } e.stopPropagation(); e.preventDefault(); }); } function clearMenus(e) { $(toggle).each(function () { var $parent = $(this); if (!$parent.hasClass('open')) return; $parent.removeClass('open'); }) } function getViewportW() { var client = window.document.documentElement['clientWidth'], inner = window['innerWidth']; return (client < inner) ? inner : client; } function widthBalancing(){ //return false; //FOR MASTER if(parent.data('auto_resize_fonts') == 'no'){ return false; }; if(window.top != window){ return false; } var itemsWidth = $this.parent().width(); var containerWidth = parent.width(); var itemsHeight = $this.children('ul:first-child').outerHeight(); var containerHeight = $this.outerHeight(); if (getViewportW() > 767 && $this.hasClass('horizontal')){ if(itemsHeight >= 2 * containerHeight -10 ){ var loopCount = 0; while(itemsHeight >= 2 * containerHeight- 10){ if(loopCount > 99){ break; } $this.find('li.noo-nav-item[data-level=1]').each(function(){ var aTag = $(this).children('a:first-child')//.find('a:first-child'); var fontSize = parseFloat(aTag.css('font-size')); aTag.css({'font-size': (fontSize-1)+'px'}); if(parent.data('auto_resize_sub_fonts') == 'yes'){ aTag.siblings('.noo-nav-child').find('a').css({'font-size': (fontSize-1)+'px'}); } itemsWidth = $this.parent().width(); containerWidth = parent.width(); itemsHeight = $this.children('ul:first-child').outerHeight(); containerHeight = $this.outerHeight(); }); loopCount++; } }else{ var loop2count = 0; while(itemsHeight < 2 * containerHeight -10){ var breack = false; if(loop2count > 99){ break; } $this.find('li.noo-nav-item[data-level=1]').each(function(){ var aTag = $(this).children('a:first-child')//.find('a:first-child'); var fontSize = parseFloat(aTag.css('font-size')); if(font > fontSize && itemsHeight <= containerHeight){ aTag.css({'font-size': (fontSize+1)+'px'}); if(parent.data('auto_resize_sub_fonts') == 'yes'){ aTag.siblings('.noo-nav-child').find('a').css({'font-size': (fontSize+1)+'px'}); } breack = false; }else if(font == fontSize && itemsHeight < 2 * containerHeight -10){ $this.find('.noo-nav-item > a').removeAttr('style'); breack = true; } }); itemsWidth = $this.parent().width(); containerWidth = parent.width(); itemsHeight = $this.children('ul:first-child').outerHeight(); containerHeight = $this.outerHeight(); if(itemsHeight > 2 * containerHeight -10){ $this.find('li.noo-nav-item[data-level=1]').each(function(){ var aTag = $(this).children('a:first-child')//.find('a:first-child'); var fontSize = parseFloat(aTag.css('font-size')); aTag.css({'font-size': (fontSize-1)+'px'}); if(parent.data('auto_resize_sub_fonts') == 'yes'){ aTag.siblings('.noo-nav-child').find('a').css({'font-size': (fontSize-1)+'px'}); } itemsWidth = $this.parent().width(); containerWidth = parent.width(); itemsHeight = $this.children('ul:first-child').outerHeight(); containerHeight = $this.outerHeight(); }); break; } loop2count++; if(breack) break; } } }else if(getViewportW() < 767){ $this.find('.noo-nav-item > a').removeAttr('style'); } } if (getViewportW() > mediaWidth && $this.hasClass('horizontal')) { var wpadminbar = $('#wpadminbar'); var t; if(wpadminbar.length){ t = parseFloat($('html').css('margin-top')); } var wrapper = '
'; $this.closest('.noonav').each(function(){ if($(this).data('sticky')){ $(this).waypoint( 'sticky' , { wrapper: wrapper, context: window, offset: 0, handler: function(direction){ var p = $this.closest('.noonav'); p.css('top',p.data('offset')); //p.css('top',0); if(p.hasClass('noosticky')){ p.css('top',t + $this.closest('.noonav').data('offset')); }else{ p.css('top',0); } //$this.width($this.closest('#noo-sticky-wrapper').css('float','none').outerWidth()); }, stuckClass: 'noosticky' }); } }) } widthBalancing(); $(window).on('resize',function(){ if(getViewportW() <= mediaWidth && button.length){ parent.removeClass('not-mobile'); if(!parent.hasClass('to-mobile')){ parent.addClass('to-mobile'); } }else{ parent.removeClass('to-mobile'); parent.addClass('not-mobile'); } if(getViewportW() > mediaWidth){ $('div.noo-megamenu.noocollapse').removeAttr('style'); } widthBalancing(); }); $(window).one('resize',function(){ if (getViewportW() > mediaWidth && $this.hasClass('horizontal')) { $this.closest('.noonav').waypoint('unsticky'); var wpadminbar = $('#wpadminbar'); var t; if(wpadminbar.length){ t = parseFloat($('html').css('margin-top')); } var wrapper = '
'; $this.closest('.noonav').each(function(){ if($(this).data('sticky')){ $(this).waypoint( 'sticky' , { wrapper: wrapper, context: window, offset: 0, handler: function(direction){ var p = $this.closest('.noonav'); p.css('top',p.data('offset')); //p.css('top',0); if(p.hasClass('noosticky')){ p.css('top',t + $this.closest('.noonav').data('offset')); }else{ p.css('top',0); } //$this.width($this.closest('#noo-sticky-wrapper').css('float','none').outerWidth()); }, stuckClass: 'noosticky' }); } }) }else{ $this.closest('.noonav').waypoint('unsticky'); } }); // $this.find('li.noo-nav-item.mega').hover(function(){return false},function(){return false}); if ('ontouchstart' in document.documentElement && getViewportW() < mediaWidth) { $this.find('li.noo-nav-item.mega').find(' > a').click(function(e){ var _this = $(this); e.preventDefault(); e.stopPropagation(); var $parent = _this.parent(); var isActive = $parent.hasClass('open'); if (!isActive) { clearMenus(); $parent.addClass('open').parentsUntil('.noo-nav').filter('li.noo-nav-item.mega').addClass('open'); window.scrollTo(0,_this.offset().top-50); }else{ if(_this.attr('href')){ window.location.href = _this.attr('href'); } } return false; }); $(document.body).children().on('click', function(){ clearMenus(); $this.addClass('noocollapsing').removeClass('noocollapse').removeClass('noo-collapse-open'); //$this['height'](0); }); $this.closest('.noonav').click(function(e){ e.stopPropagation(); }); } return false; }); }; $(document).ready(function() { $('.button-bar.noo-menu-collapse').click(function(){ $('.navbar-brand').click(); }); $(document).on("click",function(event){ if($('div.to-mobile').length){ $('.to-mobile .noo-megamenu').removeClass('noo-collapse-open'); $('.to-mobile .noo-megamenu').css({"height":"0px"}); } }); $('.noo-collapse-open').on('click', function(e) { e.stopPropagation(); }); if(is_touch_device() != true){ $('.noo-megamenu').each(function(){$(this).NooMobileMenu()}); $( '.noo-menu-select' ).change(function() { var loc = $(this).find( 'option:selected' ).val(); if( loc != '' && loc != '#' ) window.location = loc; }); $('.noo-menu-back-button').click(function(e){ e.preventDefault(); e.stopPropagation(); $(this).closest('li').addClass("noo-menu-li-open"); }); } var locationT = window.location.href.replace(new RegExp('http://', 'i'), ''); var locSearch = parseQueryString(); var host = window.location.host; $('.noonav').each(function(){ var menu_container = $(this).attr('id'); var containerId = menu_container.split('_'); var menuId = containerId[containerId.length - 1]; $('#'+menu_container+' .noo-nav-item').each(function(){ if($(this).children('a') == undefined || $(this).children('a').attr('href') == undefined) { return; } var link = $(this).children('a').attr('href').replace(new RegExp('http://', 'i'), ''); if(!link || link == ''){ return; } // AG: 2016-01-11 Try to match location / // Break the link into tokens and the match against window.location_id var link_tokens = link.split('/'); if (link_tokens[1] === window.location_id){ if($(this).data('level') == 1){ $(this).addClass('selected_top'); }else{ $(this).addClass('selected_sub'); $(this).parents('.noo-nav-item.dropdown-submenu').addClass('selected_sub'); $(this).parents('.noo-nav-item.dropdown').addClass('selected_top'); } if ($('[id='+menu_container+']').length == 1) { return false; } } if(host+'/' == $.trim(link) && $.trim(link) != $.trim(location)){ link = false; } if(locationT.indexOf(link) > -1){ if($(this).data('level') == 1){ $(this).addClass('selected_top'); }else{ $(this).addClass('selected_sub'); $(this).parents('.noo-nav-item.dropdown-submenu').addClass('selected_sub'); $(this).parents('.noo-nav-item.dropdown').addClass('selected_top'); } }else if(locSearch.location_id){ if(link && (link.indexOf(locSearch.location_id) == 0 || link.indexOf(locSearch.location_id) == 1)){ if($(this).data('level') == 1){ $(this).addClass('selected_top'); }else{ $(this).addClass('selected_sub'); } } } }); }); }); var parseQueryString = function() { var str = window.location.search; var objURL = {}; str.replace( new RegExp( "([^?=&]+)(=([^&]*))?", "g" ), function( $0, $1, $2, $3 ){ objURL[ $1 ] = $3; } ); return objURL; }; function is_touch_device() { return !!('ontouchstart' in window); } var timer; var touchduration = 700; //length of time we want the user to touch before we do something function touchstart(elem) { timer = setTimeout(function(){onlongtouch(elem);}, touchduration); } function touchend() { if (timer) clearTimeout(timer); } function onlongtouch(elem) { var url = $(elem).attr('href'); if(!url || url == '') return; window.location.replace(url); } }(window.jQuery);